LCOV - code coverage report
Current view: top level - src/frontend/SageIII - Cxx_GrammarNewAndDeleteOperators.C (source / functions) Hit Total Coverage
Test: ROSE Lines: 8541 21080 40.5 %
Date: 2022-12-08 13:48:47 Functions: 574 1360 42.2 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : // MACHINE GENERATED SOURCE FILE WITH ROSE (Grammar.h)--- DO NOT MODIFY!
       2             : 
       3             : #include "sage3basic.h"
       4             : 
       5             : #ifndef ROSE_USE_INTERNAL_FRONTEND_DEVELOPMENT
       6             :    #include "AST_FILE_IO.h"
       7             : #endif 
       8             : // The header file ("rose_config.h") should only be included by source files that require it.
       9             : #include "rose_config.h"
      10             : 
      11             : #if _MSC_VER
      12             : #define USE_CPP_NEW_DELETE_OPERATORS 0
      13             : #endif
      14             : 
      15             : #define ROSE_ALLOC_TRACE 0
      16             : #undef mprintf
      17             : #define mprintf Rose::Diagnostics::mfprintf(Rose::ir_node_mlog[Rose::Diagnostics::DEBUG])
      18             : 
      19             : 
      20             : using namespace std;
      21             : 
      22             : #include "Cxx_GrammarMemoryPoolSupport.h"
      23             : 
      24             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
      25             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
      26             : // obviously imply C++.
      27             : 
      28             : // This implements the support within ROSE for memory pools.  Memory pools
      29             : // support the most condensed usage of memory within the construction of
      30             : // and AST. Large blocks of contiguous storage for each RI node is allocated
      31             : // by a new operator written for each class.
      32             : 
      33             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
      34             :     // User wants multi-thread support and POSIX threads are available.
      35             : #   include <pthread.h>
      36             :     static pthread_mutex_t SgNode_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
      37             : #else
      38             :      // Cause synchronization to be skipped.
      39             : #    ifndef ALLOC_MUTEX
      40             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
      41             : #    endif
      42             : #    ifdef _REENTRANT
      43             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
      44             : #       ifdef _MSC_VER
      45             : #           pragma message("POSIX threads are not available; synchronization being skipped")
      46             : #       else
      47             : #           warning "POSIX threads are not available; synchronization being skipped"
      48             : #       endif
      49             : #    endif
      50             : #endif
      51             : 
      52             : #ifndef ROSE_ALLOC_TRACE
      53             : #  define ROSE_ALLOC_TRACE 0
      54             : #endif
      55             : 
      56             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
      57             : #define ROSE_ALLOC_TRACE_CNT
      58             : #include "memory-pool-snapshot.h"
      59             : unsigned long alloc_trace_cnt = 0;
      60             : #endif
      61             : 
      62             : #if ROSE_ALLOC_TRACE
      63             : const unsigned SgNode::pool_size = 5;
      64             : #else
      65             : const unsigned SgNode::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
      66             : #endif
      67             : 
      68             : #ifndef ROSE_ALLOC_MEMSET
      69             : #  define ROSE_ALLOC_MEMSET 0
      70             : #endif
      71             : 
      72             : #ifndef ROSE_PEDANTIC_ALLOC
      73             : #  define ROSE_PEDANTIC_ALLOC 0
      74             : #endif
      75             : 
      76             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
      77             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
      78             : #endif
      79             : 
      80             : #if !defined(SGNODE__ALL_POOLS)
      81             : #define SGNODE__ALL_POOLS
      82             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
      83             : #endif
      84             : 
      85             : SgNode* SgNode::next_node = nullptr;
      86             : std::vector<unsigned char*> SgNode::pools;
      87             : 
      88             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
      89             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
      90             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
      91             : // around this macro definition rather than each use).
      92             : #ifndef ALLOC_MUTEX
      93             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
      94             :         do {                                                                     \
      95             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
      96             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
      97             :                 abort();                                                         \
      98             :             }                                                                    \
      99             :         } while (0);
     100             : #endif
     101             : 
     102             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
     103             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
     104             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
     105             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
     106             : 
     107             : /*! \brief New operator for SgNode.
     108             : 
     109             :    This new operator implements memory pools to provide most efficent 
     110             :    use of the heap within construction of large ASTs.
     111             : 
     112             : \internal The new and delete operators use the lower level C malloc/free
     113             :    function calls for performance and to make sure that mixing of malloc/free
     114             :    and new/delete by the used can be caught more readily.  This may change
     115             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
     116             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
     117             :    deallocate memory allocated using ROSE_MALLOC.
     118             : */
     119           0 : void *SgNode::operator new ( size_t Size )
     120             : {
     121             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
     122             :      * returning or throwing an exception. */
     123           0 :     ALLOC_MUTEX(SgNode, lock);
     124             : 
     125             : #if ROSE_ALLOC_TRACE == 2
     126             : //    printf("SgNode::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgNode::next_node);
     127             : #endif
     128             : 
     129             : #if USE_CPP_NEW_DELETE_OPERATORS
     130             :     void *mem = ROSE_MALLOC(Size);
     131             :     ALLOC_MUTEX(SgNode, unlock);
     132             :     return mem;
     133             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
     134             : #if ROSE_PEDANTIC_ALLOC
     135             :     ROSE_ASSERT(Size == sizeof(SgNode));
     136             : #else
     137           0 :     if (Size != sizeof(SgNode)) {
     138           0 :       void * object = ROSE_MALLOC(Size);
     139           0 :       ALLOC_MUTEX(SgNode, unlock);
     140             :       return object;
     141             :     }
     142             : #endif
     143             : 
     144           0 :     if (SgNode::next_node == nullptr) {
     145           0 :         SgNode * alloc = (SgNode*) ROSE_MALLOC ( SgNode::pool_size * sizeof(SgNode) );
     146           0 :         ROSE_ASSERT(alloc != nullptr);
     147             : 
     148             : #if ROSE_ALLOC_TRACE == 2
     149             : //        printf("SgNode::alloc\n  block[%zi] = [ %p , %p [\n", SgNode::pools.size(), alloc, alloc + SgNode::pool_size);
     150             : #endif
     151             : 
     152             : #if ROSE_ALLOC_MEMSET == 1
     153             : #elif ROSE_ALLOC_MEMSET == 2
     154             :         memset(alloc, 0x00, SgNode::pool_size * sizeof(SgNode));
     155             : #elif ROSE_ALLOC_MEMSET == 3
     156             :         memset(alloc, 0xAA, SgNode::pool_size * sizeof(SgNode));
     157             : #endif
     158           0 :         for (unsigned i=0; i < SgNode::pool_size-1; i++) {
     159           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
     160             :         }
     161           0 :         alloc[SgNode::pool_size-1].p_freepointer = nullptr;
     162             : 
     163           0 :         SgNode::pools.push_back ( (unsigned char *) alloc );
     164           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgNode::pool_size * sizeof(SgNode), V_SgNode ) );
     165           0 :         SgNode::next_node = alloc;
     166             :     }
     167           0 :     ROSE_ASSERT(SgNode::next_node != nullptr);
     168             : 
     169           0 :     SgNode * object = SgNode::next_node;
     170           0 :     SgNode::next_node = (SgNode*)(object->p_freepointer);
     171             : 
     172             : #if ROSE_ALLOC_TRACE == 2
     173             :     printf("SgNode::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgNode::next_node);
     174             : #endif
     175             : 
     176           0 :     SgNode * fp = object->p_freepointer;
     177             : #if ROSE_ALLOC_MEMSET == 1
     178             : #elif ROSE_ALLOC_MEMSET == 2
     179             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgNode) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
     180             : #elif ROSE_ALLOC_MEMSET == 3
     181             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgNode) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
     182             : #endif
     183           0 :     object->p_freepointer = fp;
     184             : 
     185             : #if ROSE_ALLOC_TRACE == 2
     186             : //    printf("SgNode::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgNode::next_node);
     187             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
     188             :     Rose::MemPool::snapshot(oss.str());
     189             :     alloc_trace_cnt++;
     190             : #endif
     191             : 
     192           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
     193             : 
     194           0 :     ALLOC_MUTEX(SgNode, unlock);
     195             : 
     196             :     return object;
     197             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
     198             : }
     199             : 
     200             : 
     201             : 
     202             : /*! \brief Delete operator for SgNode.
     203             : 
     204             :    This delete operator implements deallocation using memory pools to 
     205             :    provide most efficent use of the heap within construction of large ASTs.
     206             : 
     207             : \internal The new and delete operators use the lower level C malloc/free
     208             :    function calls for performance and to make sure that mixing of malloc/free
     209             :    and new/delete by the used can be caught more readily.  This may change
     210             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
     211             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
     212             :    deallocate memory allocated using ROSE_MALLOC.
     213             : */
     214           0 : void SgNode::operator delete(void *Pointer, size_t Size)
     215             : {
     216             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
     217             :      * or throwing an exception. */
     218           0 :     ALLOC_MUTEX(SgNode, lock);
     219             : 
     220             : #if USE_CPP_NEW_DELETE_OPERATORS
     221             :     ROSE_FREE(Pointer);
     222             : #else
     223             : #if ROSE_PEDANTIC_ALLOC
     224             :     ROSE_ASSERT(Size == sizeof(SgNode));
     225             : #else
     226           0 :     if (Size != sizeof(SgNode)) {
     227           0 :       ROSE_FREE(Pointer);
     228           0 :       ALLOC_MUTEX(SgNode, unlock);
     229             :       return;
     230             :     }
     231             : #endif
     232             : 
     233           0 :     SgNode * object = (SgNode*) Pointer;
     234           0 :     ROSE_ASSERT(object != nullptr);
     235             : 
     236             : #if ROSE_ALLOC_TRACE == 2
     237             : //  printf("SgNode::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgNode::next_node);
     238             :     printf("SgNode::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgNode::next_node);
     239             : #endif
     240             : 
     241             : #if ROSE_PEDANTIC_ALLOC
     242             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
     243             : #endif
     244             : 
     245             : #if ROSE_ALLOC_MEMSET == 1
     246             : #elif ROSE_ALLOC_MEMSET == 2
     247             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgNode) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
     248             : #elif ROSE_ALLOC_MEMSET == 3
     249             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgNode) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
     250             : #endif
     251             : 
     252             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
     253             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
     254             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
     255             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
     256             : #else
     257           0 :     object->p_freepointer = SgNode::next_node;
     258           0 :     SgNode::next_node = object;
     259             : #endif
     260             : 
     261             : #if ROSE_ALLOC_TRACE == 2
     262             : //  printf("SgNode::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgNode::next_node);
     263             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
     264             :     Rose::MemPool::snapshot(oss.str());
     265             :     alloc_trace_cnt++;
     266             : #endif
     267             : 
     268             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
     269             : 
     270           0 :     ALLOC_MUTEX(SgNode, unlock);
     271             : }
     272             : 
     273             : // DQ (11/27/2009): I have moved this member function definition to outside of the
     274             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
     275             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
     276             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
     277             : // Also, note comment below from Robb (copied from the Common.code file).
     278             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
     279             : //
     280             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
     281             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
     282             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
     283             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
     284             : #if 0
     285             : void SgNode::operator delete(void* pointer) { SgNode::operator delete (pointer, sizeof(SgNode)); };
     286             : #endif
     287             : /* #line 288 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
     288             : 
     289             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
     290             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
     291             : // obviously imply C++.
     292             : 
     293             : // This implements the support within ROSE for memory pools.  Memory pools
     294             : // support the most condensed usage of memory within the construction of
     295             : // and AST. Large blocks of contiguous storage for each RI node is allocated
     296             : // by a new operator written for each class.
     297             : 
     298             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
     299             :     // User wants multi-thread support and POSIX threads are available.
     300             : #   include <pthread.h>
     301             :     static pthread_mutex_t SgSupport_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
     302             : #else
     303             :      // Cause synchronization to be skipped.
     304             : #    ifndef ALLOC_MUTEX
     305             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
     306             : #    endif
     307             : #    ifdef _REENTRANT
     308             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
     309             : #       ifdef _MSC_VER
     310             : #           pragma message("POSIX threads are not available; synchronization being skipped")
     311             : #       else
     312             : #           warning "POSIX threads are not available; synchronization being skipped"
     313             : #       endif
     314             : #    endif
     315             : #endif
     316             : 
     317             : #ifndef ROSE_ALLOC_TRACE
     318             : #  define ROSE_ALLOC_TRACE 0
     319             : #endif
     320             : 
     321             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
     322             : #define ROSE_ALLOC_TRACE_CNT
     323             : #include "memory-pool-snapshot.h"
     324             : unsigned long alloc_trace_cnt = 0;
     325             : #endif
     326             : 
     327             : #if ROSE_ALLOC_TRACE
     328             : const unsigned SgSupport::pool_size = 5;
     329             : #else
     330             : const unsigned SgSupport::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
     331             : #endif
     332             : 
     333             : #ifndef ROSE_ALLOC_MEMSET
     334             : #  define ROSE_ALLOC_MEMSET 0
     335             : #endif
     336             : 
     337             : #ifndef ROSE_PEDANTIC_ALLOC
     338             : #  define ROSE_PEDANTIC_ALLOC 0
     339             : #endif
     340             : 
     341             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
     342             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
     343             : #endif
     344             : 
     345             : #if !defined(SGNODE__ALL_POOLS)
     346             : #define SGNODE__ALL_POOLS
     347             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
     348             : #endif
     349             : 
     350             : SgSupport* SgSupport::next_node = nullptr;
     351             : std::vector<unsigned char*> SgSupport::pools;
     352             : 
     353             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
     354             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
     355             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
     356             : // around this macro definition rather than each use).
     357             : #ifndef ALLOC_MUTEX
     358             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
     359             :         do {                                                                     \
     360             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
     361             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
     362             :                 abort();                                                         \
     363             :             }                                                                    \
     364             :         } while (0);
     365             : #endif
     366             : 
     367             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
     368             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
     369             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
     370             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
     371             : 
     372             : /*! \brief New operator for SgSupport.
     373             : 
     374             :    This new operator implements memory pools to provide most efficent 
     375             :    use of the heap within construction of large ASTs.
     376             : 
     377             : \internal The new and delete operators use the lower level C malloc/free
     378             :    function calls for performance and to make sure that mixing of malloc/free
     379             :    and new/delete by the used can be caught more readily.  This may change
     380             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
     381             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
     382             :    deallocate memory allocated using ROSE_MALLOC.
     383             : */
     384           0 : void *SgSupport::operator new ( size_t Size )
     385             : {
     386             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
     387             :      * returning or throwing an exception. */
     388           0 :     ALLOC_MUTEX(SgSupport, lock);
     389             : 
     390             : #if ROSE_ALLOC_TRACE == 2
     391             : //    printf("SgSupport::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgSupport::next_node);
     392             : #endif
     393             : 
     394             : #if USE_CPP_NEW_DELETE_OPERATORS
     395             :     void *mem = ROSE_MALLOC(Size);
     396             :     ALLOC_MUTEX(SgSupport, unlock);
     397             :     return mem;
     398             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
     399             : #if ROSE_PEDANTIC_ALLOC
     400             :     ROSE_ASSERT(Size == sizeof(SgSupport));
     401             : #else
     402           0 :     if (Size != sizeof(SgSupport)) {
     403           0 :       void * object = ROSE_MALLOC(Size);
     404           0 :       ALLOC_MUTEX(SgSupport, unlock);
     405             :       return object;
     406             :     }
     407             : #endif
     408             : 
     409           0 :     if (SgSupport::next_node == nullptr) {
     410           0 :         SgSupport * alloc = (SgSupport*) ROSE_MALLOC ( SgSupport::pool_size * sizeof(SgSupport) );
     411           0 :         ROSE_ASSERT(alloc != nullptr);
     412             : 
     413             : #if ROSE_ALLOC_TRACE == 2
     414             : //        printf("SgSupport::alloc\n  block[%zi] = [ %p , %p [\n", SgSupport::pools.size(), alloc, alloc + SgSupport::pool_size);
     415             : #endif
     416             : 
     417             : #if ROSE_ALLOC_MEMSET == 1
     418             : #elif ROSE_ALLOC_MEMSET == 2
     419             :         memset(alloc, 0x00, SgSupport::pool_size * sizeof(SgSupport));
     420             : #elif ROSE_ALLOC_MEMSET == 3
     421             :         memset(alloc, 0xAA, SgSupport::pool_size * sizeof(SgSupport));
     422             : #endif
     423           0 :         for (unsigned i=0; i < SgSupport::pool_size-1; i++) {
     424           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
     425             :         }
     426           0 :         alloc[SgSupport::pool_size-1].p_freepointer = nullptr;
     427             : 
     428           0 :         SgSupport::pools.push_back ( (unsigned char *) alloc );
     429           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgSupport::pool_size * sizeof(SgSupport), V_SgSupport ) );
     430           0 :         SgSupport::next_node = alloc;
     431             :     }
     432           0 :     ROSE_ASSERT(SgSupport::next_node != nullptr);
     433             : 
     434           0 :     SgSupport * object = SgSupport::next_node;
     435           0 :     SgSupport::next_node = (SgSupport*)(object->p_freepointer);
     436             : 
     437             : #if ROSE_ALLOC_TRACE == 2
     438             :     printf("SgSupport::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgSupport::next_node);
     439             : #endif
     440             : 
     441           0 :     SgNode * fp = object->p_freepointer;
     442             : #if ROSE_ALLOC_MEMSET == 1
     443             : #elif ROSE_ALLOC_MEMSET == 2
     444             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgSupport) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
     445             : #elif ROSE_ALLOC_MEMSET == 3
     446             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgSupport) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
     447             : #endif
     448           0 :     object->p_freepointer = fp;
     449             : 
     450             : #if ROSE_ALLOC_TRACE == 2
     451             : //    printf("SgSupport::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgSupport::next_node);
     452             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
     453             :     Rose::MemPool::snapshot(oss.str());
     454             :     alloc_trace_cnt++;
     455             : #endif
     456             : 
     457           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
     458             : 
     459           0 :     ALLOC_MUTEX(SgSupport, unlock);
     460             : 
     461             :     return object;
     462             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
     463             : }
     464             : 
     465             : 
     466             : 
     467             : /*! \brief Delete operator for SgSupport.
     468             : 
     469             :    This delete operator implements deallocation using memory pools to 
     470             :    provide most efficent use of the heap within construction of large ASTs.
     471             : 
     472             : \internal The new and delete operators use the lower level C malloc/free
     473             :    function calls for performance and to make sure that mixing of malloc/free
     474             :    and new/delete by the used can be caught more readily.  This may change
     475             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
     476             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
     477             :    deallocate memory allocated using ROSE_MALLOC.
     478             : */
     479           0 : void SgSupport::operator delete(void *Pointer, size_t Size)
     480             : {
     481             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
     482             :      * or throwing an exception. */
     483           0 :     ALLOC_MUTEX(SgSupport, lock);
     484             : 
     485             : #if USE_CPP_NEW_DELETE_OPERATORS
     486             :     ROSE_FREE(Pointer);
     487             : #else
     488             : #if ROSE_PEDANTIC_ALLOC
     489             :     ROSE_ASSERT(Size == sizeof(SgSupport));
     490             : #else
     491           0 :     if (Size != sizeof(SgSupport)) {
     492           0 :       ROSE_FREE(Pointer);
     493           0 :       ALLOC_MUTEX(SgSupport, unlock);
     494             :       return;
     495             :     }
     496             : #endif
     497             : 
     498           0 :     SgSupport * object = (SgSupport*) Pointer;
     499           0 :     ROSE_ASSERT(object != nullptr);
     500             : 
     501             : #if ROSE_ALLOC_TRACE == 2
     502             : //  printf("SgSupport::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgSupport::next_node);
     503             :     printf("SgSupport::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgSupport::next_node);
     504             : #endif
     505             : 
     506             : #if ROSE_PEDANTIC_ALLOC
     507             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
     508             : #endif
     509             : 
     510             : #if ROSE_ALLOC_MEMSET == 1
     511             : #elif ROSE_ALLOC_MEMSET == 2
     512             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgSupport) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
     513             : #elif ROSE_ALLOC_MEMSET == 3
     514             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgSupport) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
     515             : #endif
     516             : 
     517             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
     518             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
     519             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
     520             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
     521             : #else
     522           0 :     object->p_freepointer = SgSupport::next_node;
     523           0 :     SgSupport::next_node = object;
     524             : #endif
     525             : 
     526             : #if ROSE_ALLOC_TRACE == 2
     527             : //  printf("SgSupport::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgSupport::next_node);
     528             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
     529             :     Rose::MemPool::snapshot(oss.str());
     530             :     alloc_trace_cnt++;
     531             : #endif
     532             : 
     533             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
     534             : 
     535           0 :     ALLOC_MUTEX(SgSupport, unlock);
     536             : }
     537             : 
     538             : // DQ (11/27/2009): I have moved this member function definition to outside of the
     539             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
     540             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
     541             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
     542             : // Also, note comment below from Robb (copied from the Common.code file).
     543             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
     544             : //
     545             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
     546             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
     547             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
     548             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
     549             : #if 0
     550             : void SgSupport::operator delete(void* pointer) { SgSupport::operator delete (pointer, sizeof(SgSupport)); };
     551             : #endif
     552             : /* #line 553 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
     553             : 
     554             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
     555             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
     556             : // obviously imply C++.
     557             : 
     558             : // This implements the support within ROSE for memory pools.  Memory pools
     559             : // support the most condensed usage of memory within the construction of
     560             : // and AST. Large blocks of contiguous storage for each RI node is allocated
     561             : // by a new operator written for each class.
     562             : 
     563             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
     564             :     // User wants multi-thread support and POSIX threads are available.
     565             : #   include <pthread.h>
     566             :     static pthread_mutex_t SgModifier_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
     567             : #else
     568             :      // Cause synchronization to be skipped.
     569             : #    ifndef ALLOC_MUTEX
     570             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
     571             : #    endif
     572             : #    ifdef _REENTRANT
     573             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
     574             : #       ifdef _MSC_VER
     575             : #           pragma message("POSIX threads are not available; synchronization being skipped")
     576             : #       else
     577             : #           warning "POSIX threads are not available; synchronization being skipped"
     578             : #       endif
     579             : #    endif
     580             : #endif
     581             : 
     582             : #ifndef ROSE_ALLOC_TRACE
     583             : #  define ROSE_ALLOC_TRACE 0
     584             : #endif
     585             : 
     586             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
     587             : #define ROSE_ALLOC_TRACE_CNT
     588             : #include "memory-pool-snapshot.h"
     589             : unsigned long alloc_trace_cnt = 0;
     590             : #endif
     591             : 
     592             : #if ROSE_ALLOC_TRACE
     593             : const unsigned SgModifier::pool_size = 5;
     594             : #else
     595             : const unsigned SgModifier::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
     596             : #endif
     597             : 
     598             : #ifndef ROSE_ALLOC_MEMSET
     599             : #  define ROSE_ALLOC_MEMSET 0
     600             : #endif
     601             : 
     602             : #ifndef ROSE_PEDANTIC_ALLOC
     603             : #  define ROSE_PEDANTIC_ALLOC 0
     604             : #endif
     605             : 
     606             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
     607             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
     608             : #endif
     609             : 
     610             : #if !defined(SGNODE__ALL_POOLS)
     611             : #define SGNODE__ALL_POOLS
     612             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
     613             : #endif
     614             : 
     615             : SgModifier* SgModifier::next_node = nullptr;
     616             : std::vector<unsigned char*> SgModifier::pools;
     617             : 
     618             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
     619             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
     620             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
     621             : // around this macro definition rather than each use).
     622             : #ifndef ALLOC_MUTEX
     623             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
     624             :         do {                                                                     \
     625             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
     626             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
     627             :                 abort();                                                         \
     628             :             }                                                                    \
     629             :         } while (0);
     630             : #endif
     631             : 
     632             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
     633             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
     634             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
     635             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
     636             : 
     637             : /*! \brief New operator for SgModifier.
     638             : 
     639             :    This new operator implements memory pools to provide most efficent 
     640             :    use of the heap within construction of large ASTs.
     641             : 
     642             : \internal The new and delete operators use the lower level C malloc/free
     643             :    function calls for performance and to make sure that mixing of malloc/free
     644             :    and new/delete by the used can be caught more readily.  This may change
     645             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
     646             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
     647             :    deallocate memory allocated using ROSE_MALLOC.
     648             : */
     649           0 : void *SgModifier::operator new ( size_t Size )
     650             : {
     651             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
     652             :      * returning or throwing an exception. */
     653           0 :     ALLOC_MUTEX(SgModifier, lock);
     654             : 
     655             : #if ROSE_ALLOC_TRACE == 2
     656             : //    printf("SgModifier::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgModifier::next_node);
     657             : #endif
     658             : 
     659             : #if USE_CPP_NEW_DELETE_OPERATORS
     660             :     void *mem = ROSE_MALLOC(Size);
     661             :     ALLOC_MUTEX(SgModifier, unlock);
     662             :     return mem;
     663             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
     664             : #if ROSE_PEDANTIC_ALLOC
     665             :     ROSE_ASSERT(Size == sizeof(SgModifier));
     666             : #else
     667           0 :     if (Size != sizeof(SgModifier)) {
     668           0 :       void * object = ROSE_MALLOC(Size);
     669           0 :       ALLOC_MUTEX(SgModifier, unlock);
     670             :       return object;
     671             :     }
     672             : #endif
     673             : 
     674           0 :     if (SgModifier::next_node == nullptr) {
     675           0 :         SgModifier * alloc = (SgModifier*) ROSE_MALLOC ( SgModifier::pool_size * sizeof(SgModifier) );
     676           0 :         ROSE_ASSERT(alloc != nullptr);
     677             : 
     678             : #if ROSE_ALLOC_TRACE == 2
     679             : //        printf("SgModifier::alloc\n  block[%zi] = [ %p , %p [\n", SgModifier::pools.size(), alloc, alloc + SgModifier::pool_size);
     680             : #endif
     681             : 
     682             : #if ROSE_ALLOC_MEMSET == 1
     683             : #elif ROSE_ALLOC_MEMSET == 2
     684             :         memset(alloc, 0x00, SgModifier::pool_size * sizeof(SgModifier));
     685             : #elif ROSE_ALLOC_MEMSET == 3
     686             :         memset(alloc, 0xAA, SgModifier::pool_size * sizeof(SgModifier));
     687             : #endif
     688           0 :         for (unsigned i=0; i < SgModifier::pool_size-1; i++) {
     689           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
     690             :         }
     691           0 :         alloc[SgModifier::pool_size-1].p_freepointer = nullptr;
     692             : 
     693           0 :         SgModifier::pools.push_back ( (unsigned char *) alloc );
     694           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgModifier::pool_size * sizeof(SgModifier), V_SgModifier ) );
     695           0 :         SgModifier::next_node = alloc;
     696             :     }
     697           0 :     ROSE_ASSERT(SgModifier::next_node != nullptr);
     698             : 
     699           0 :     SgModifier * object = SgModifier::next_node;
     700           0 :     SgModifier::next_node = (SgModifier*)(object->p_freepointer);
     701             : 
     702             : #if ROSE_ALLOC_TRACE == 2
     703             :     printf("SgModifier::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgModifier::next_node);
     704             : #endif
     705             : 
     706           0 :     SgNode * fp = object->p_freepointer;
     707             : #if ROSE_ALLOC_MEMSET == 1
     708             : #elif ROSE_ALLOC_MEMSET == 2
     709             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgModifier) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
     710             : #elif ROSE_ALLOC_MEMSET == 3
     711             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgModifier) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
     712             : #endif
     713           0 :     object->p_freepointer = fp;
     714             : 
     715             : #if ROSE_ALLOC_TRACE == 2
     716             : //    printf("SgModifier::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgModifier::next_node);
     717             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
     718             :     Rose::MemPool::snapshot(oss.str());
     719             :     alloc_trace_cnt++;
     720             : #endif
     721             : 
     722           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
     723             : 
     724           0 :     ALLOC_MUTEX(SgModifier, unlock);
     725             : 
     726             :     return object;
     727             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
     728             : }
     729             : 
     730             : 
     731             : 
     732             : /*! \brief Delete operator for SgModifier.
     733             : 
     734             :    This delete operator implements deallocation using memory pools to 
     735             :    provide most efficent use of the heap within construction of large ASTs.
     736             : 
     737             : \internal The new and delete operators use the lower level C malloc/free
     738             :    function calls for performance and to make sure that mixing of malloc/free
     739             :    and new/delete by the used can be caught more readily.  This may change
     740             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
     741             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
     742             :    deallocate memory allocated using ROSE_MALLOC.
     743             : */
     744           0 : void SgModifier::operator delete(void *Pointer, size_t Size)
     745             : {
     746             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
     747             :      * or throwing an exception. */
     748           0 :     ALLOC_MUTEX(SgModifier, lock);
     749             : 
     750             : #if USE_CPP_NEW_DELETE_OPERATORS
     751             :     ROSE_FREE(Pointer);
     752             : #else
     753             : #if ROSE_PEDANTIC_ALLOC
     754             :     ROSE_ASSERT(Size == sizeof(SgModifier));
     755             : #else
     756           0 :     if (Size != sizeof(SgModifier)) {
     757           0 :       ROSE_FREE(Pointer);
     758           0 :       ALLOC_MUTEX(SgModifier, unlock);
     759             :       return;
     760             :     }
     761             : #endif
     762             : 
     763           0 :     SgModifier * object = (SgModifier*) Pointer;
     764           0 :     ROSE_ASSERT(object != nullptr);
     765             : 
     766             : #if ROSE_ALLOC_TRACE == 2
     767             : //  printf("SgModifier::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgModifier::next_node);
     768             :     printf("SgModifier::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgModifier::next_node);
     769             : #endif
     770             : 
     771             : #if ROSE_PEDANTIC_ALLOC
     772             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
     773             : #endif
     774             : 
     775             : #if ROSE_ALLOC_MEMSET == 1
     776             : #elif ROSE_ALLOC_MEMSET == 2
     777             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgModifier) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
     778             : #elif ROSE_ALLOC_MEMSET == 3
     779             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgModifier) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
     780             : #endif
     781             : 
     782             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
     783             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
     784             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
     785             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
     786             : #else
     787           0 :     object->p_freepointer = SgModifier::next_node;
     788           0 :     SgModifier::next_node = object;
     789             : #endif
     790             : 
     791             : #if ROSE_ALLOC_TRACE == 2
     792             : //  printf("SgModifier::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgModifier::next_node);
     793             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
     794             :     Rose::MemPool::snapshot(oss.str());
     795             :     alloc_trace_cnt++;
     796             : #endif
     797             : 
     798             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
     799             : 
     800           0 :     ALLOC_MUTEX(SgModifier, unlock);
     801             : }
     802             : 
     803             : // DQ (11/27/2009): I have moved this member function definition to outside of the
     804             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
     805             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
     806             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
     807             : // Also, note comment below from Robb (copied from the Common.code file).
     808             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
     809             : //
     810             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
     811             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
     812             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
     813             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
     814             : #if 0
     815             : void SgModifier::operator delete(void* pointer) { SgModifier::operator delete (pointer, sizeof(SgModifier)); };
     816             : #endif
     817             : /* #line 818 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
     818             : 
     819             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
     820             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
     821             : // obviously imply C++.
     822             : 
     823             : // This implements the support within ROSE for memory pools.  Memory pools
     824             : // support the most condensed usage of memory within the construction of
     825             : // and AST. Large blocks of contiguous storage for each RI node is allocated
     826             : // by a new operator written for each class.
     827             : 
     828             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
     829             :     // User wants multi-thread support and POSIX threads are available.
     830             : #   include <pthread.h>
     831             :     static pthread_mutex_t SgModifierNodes_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
     832             : #else
     833             :      // Cause synchronization to be skipped.
     834             : #    ifndef ALLOC_MUTEX
     835             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
     836             : #    endif
     837             : #    ifdef _REENTRANT
     838             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
     839             : #       ifdef _MSC_VER
     840             : #           pragma message("POSIX threads are not available; synchronization being skipped")
     841             : #       else
     842             : #           warning "POSIX threads are not available; synchronization being skipped"
     843             : #       endif
     844             : #    endif
     845             : #endif
     846             : 
     847             : #ifndef ROSE_ALLOC_TRACE
     848             : #  define ROSE_ALLOC_TRACE 0
     849             : #endif
     850             : 
     851             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
     852             : #define ROSE_ALLOC_TRACE_CNT
     853             : #include "memory-pool-snapshot.h"
     854             : unsigned long alloc_trace_cnt = 0;
     855             : #endif
     856             : 
     857             : #if ROSE_ALLOC_TRACE
     858             : const unsigned SgModifierNodes::pool_size = 5;
     859             : #else
     860             : const unsigned SgModifierNodes::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
     861             : #endif
     862             : 
     863             : #ifndef ROSE_ALLOC_MEMSET
     864             : #  define ROSE_ALLOC_MEMSET 0
     865             : #endif
     866             : 
     867             : #ifndef ROSE_PEDANTIC_ALLOC
     868             : #  define ROSE_PEDANTIC_ALLOC 0
     869             : #endif
     870             : 
     871             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
     872             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
     873             : #endif
     874             : 
     875             : #if !defined(SGNODE__ALL_POOLS)
     876             : #define SGNODE__ALL_POOLS
     877             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
     878             : #endif
     879             : 
     880             : SgModifierNodes* SgModifierNodes::next_node = nullptr;
     881             : std::vector<unsigned char*> SgModifierNodes::pools;
     882             : 
     883             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
     884             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
     885             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
     886             : // around this macro definition rather than each use).
     887             : #ifndef ALLOC_MUTEX
     888             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
     889             :         do {                                                                     \
     890             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
     891             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
     892             :                 abort();                                                         \
     893             :             }                                                                    \
     894             :         } while (0);
     895             : #endif
     896             : 
     897             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
     898             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
     899             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
     900             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
     901             : 
     902             : /*! \brief New operator for SgModifierNodes.
     903             : 
     904             :    This new operator implements memory pools to provide most efficent 
     905             :    use of the heap within construction of large ASTs.
     906             : 
     907             : \internal The new and delete operators use the lower level C malloc/free
     908             :    function calls for performance and to make sure that mixing of malloc/free
     909             :    and new/delete by the used can be caught more readily.  This may change
     910             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
     911             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
     912             :    deallocate memory allocated using ROSE_MALLOC.
     913             : */
     914           0 : void *SgModifierNodes::operator new ( size_t Size )
     915             : {
     916             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
     917             :      * returning or throwing an exception. */
     918           0 :     ALLOC_MUTEX(SgModifierNodes, lock);
     919             : 
     920             : #if ROSE_ALLOC_TRACE == 2
     921             : //    printf("SgModifierNodes::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgModifierNodes::next_node);
     922             : #endif
     923             : 
     924             : #if USE_CPP_NEW_DELETE_OPERATORS
     925             :     void *mem = ROSE_MALLOC(Size);
     926             :     ALLOC_MUTEX(SgModifierNodes, unlock);
     927             :     return mem;
     928             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
     929             : #if ROSE_PEDANTIC_ALLOC
     930             :     ROSE_ASSERT(Size == sizeof(SgModifierNodes));
     931             : #else
     932           0 :     if (Size != sizeof(SgModifierNodes)) {
     933           0 :       void * object = ROSE_MALLOC(Size);
     934           0 :       ALLOC_MUTEX(SgModifierNodes, unlock);
     935             :       return object;
     936             :     }
     937             : #endif
     938             : 
     939           0 :     if (SgModifierNodes::next_node == nullptr) {
     940           0 :         SgModifierNodes * alloc = (SgModifierNodes*) ROSE_MALLOC ( SgModifierNodes::pool_size * sizeof(SgModifierNodes) );
     941           0 :         ROSE_ASSERT(alloc != nullptr);
     942             : 
     943             : #if ROSE_ALLOC_TRACE == 2
     944             : //        printf("SgModifierNodes::alloc\n  block[%zi] = [ %p , %p [\n", SgModifierNodes::pools.size(), alloc, alloc + SgModifierNodes::pool_size);
     945             : #endif
     946             : 
     947             : #if ROSE_ALLOC_MEMSET == 1
     948             : #elif ROSE_ALLOC_MEMSET == 2
     949             :         memset(alloc, 0x00, SgModifierNodes::pool_size * sizeof(SgModifierNodes));
     950             : #elif ROSE_ALLOC_MEMSET == 3
     951             :         memset(alloc, 0xAA, SgModifierNodes::pool_size * sizeof(SgModifierNodes));
     952             : #endif
     953           0 :         for (unsigned i=0; i < SgModifierNodes::pool_size-1; i++) {
     954           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
     955             :         }
     956           0 :         alloc[SgModifierNodes::pool_size-1].p_freepointer = nullptr;
     957             : 
     958           0 :         SgModifierNodes::pools.push_back ( (unsigned char *) alloc );
     959           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgModifierNodes::pool_size * sizeof(SgModifierNodes), V_SgModifierNodes ) );
     960           0 :         SgModifierNodes::next_node = alloc;
     961             :     }
     962           0 :     ROSE_ASSERT(SgModifierNodes::next_node != nullptr);
     963             : 
     964           0 :     SgModifierNodes * object = SgModifierNodes::next_node;
     965           0 :     SgModifierNodes::next_node = (SgModifierNodes*)(object->p_freepointer);
     966             : 
     967             : #if ROSE_ALLOC_TRACE == 2
     968             :     printf("SgModifierNodes::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgModifierNodes::next_node);
     969             : #endif
     970             : 
     971           0 :     SgNode * fp = object->p_freepointer;
     972             : #if ROSE_ALLOC_MEMSET == 1
     973             : #elif ROSE_ALLOC_MEMSET == 2
     974             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgModifierNodes) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
     975             : #elif ROSE_ALLOC_MEMSET == 3
     976             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgModifierNodes) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
     977             : #endif
     978           0 :     object->p_freepointer = fp;
     979             : 
     980             : #if ROSE_ALLOC_TRACE == 2
     981             : //    printf("SgModifierNodes::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgModifierNodes::next_node);
     982             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
     983             :     Rose::MemPool::snapshot(oss.str());
     984             :     alloc_trace_cnt++;
     985             : #endif
     986             : 
     987           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
     988             : 
     989           0 :     ALLOC_MUTEX(SgModifierNodes, unlock);
     990             : 
     991             :     return object;
     992             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
     993             : }
     994             : 
     995             : 
     996             : 
     997             : /*! \brief Delete operator for SgModifierNodes.
     998             : 
     999             :    This delete operator implements deallocation using memory pools to 
    1000             :    provide most efficent use of the heap within construction of large ASTs.
    1001             : 
    1002             : \internal The new and delete operators use the lower level C malloc/free
    1003             :    function calls for performance and to make sure that mixing of malloc/free
    1004             :    and new/delete by the used can be caught more readily.  This may change
    1005             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
    1006             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
    1007             :    deallocate memory allocated using ROSE_MALLOC.
    1008             : */
    1009           0 : void SgModifierNodes::operator delete(void *Pointer, size_t Size)
    1010             : {
    1011             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
    1012             :      * or throwing an exception. */
    1013           0 :     ALLOC_MUTEX(SgModifierNodes, lock);
    1014             : 
    1015             : #if USE_CPP_NEW_DELETE_OPERATORS
    1016             :     ROSE_FREE(Pointer);
    1017             : #else
    1018             : #if ROSE_PEDANTIC_ALLOC
    1019             :     ROSE_ASSERT(Size == sizeof(SgModifierNodes));
    1020             : #else
    1021           0 :     if (Size != sizeof(SgModifierNodes)) {
    1022           0 :       ROSE_FREE(Pointer);
    1023           0 :       ALLOC_MUTEX(SgModifierNodes, unlock);
    1024             :       return;
    1025             :     }
    1026             : #endif
    1027             : 
    1028           0 :     SgModifierNodes * object = (SgModifierNodes*) Pointer;
    1029           0 :     ROSE_ASSERT(object != nullptr);
    1030             : 
    1031             : #if ROSE_ALLOC_TRACE == 2
    1032             : //  printf("SgModifierNodes::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgModifierNodes::next_node);
    1033             :     printf("SgModifierNodes::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgModifierNodes::next_node);
    1034             : #endif
    1035             : 
    1036             : #if ROSE_PEDANTIC_ALLOC
    1037             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
    1038             : #endif
    1039             : 
    1040             : #if ROSE_ALLOC_MEMSET == 1
    1041             : #elif ROSE_ALLOC_MEMSET == 2
    1042             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgModifierNodes) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
    1043             : #elif ROSE_ALLOC_MEMSET == 3
    1044             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgModifierNodes) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
    1045             : #endif
    1046             : 
    1047             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
    1048             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
    1049             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
    1050             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
    1051             : #else
    1052           0 :     object->p_freepointer = SgModifierNodes::next_node;
    1053           0 :     SgModifierNodes::next_node = object;
    1054             : #endif
    1055             : 
    1056             : #if ROSE_ALLOC_TRACE == 2
    1057             : //  printf("SgModifierNodes::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgModifierNodes::next_node);
    1058             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
    1059             :     Rose::MemPool::snapshot(oss.str());
    1060             :     alloc_trace_cnt++;
    1061             : #endif
    1062             : 
    1063             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
    1064             : 
    1065           0 :     ALLOC_MUTEX(SgModifierNodes, unlock);
    1066             : }
    1067             : 
    1068             : // DQ (11/27/2009): I have moved this member function definition to outside of the
    1069             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
    1070             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
    1071             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
    1072             : // Also, note comment below from Robb (copied from the Common.code file).
    1073             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
    1074             : //
    1075             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
    1076             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
    1077             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
    1078             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
    1079             : #if 0
    1080             : void SgModifierNodes::operator delete(void* pointer) { SgModifierNodes::operator delete (pointer, sizeof(SgModifierNodes)); };
    1081             : #endif
    1082             : /* #line 1083 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
    1083             : 
    1084             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
    1085             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
    1086             : // obviously imply C++.
    1087             : 
    1088             : // This implements the support within ROSE for memory pools.  Memory pools
    1089             : // support the most condensed usage of memory within the construction of
    1090             : // and AST. Large blocks of contiguous storage for each RI node is allocated
    1091             : // by a new operator written for each class.
    1092             : 
    1093             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
    1094             :     // User wants multi-thread support and POSIX threads are available.
    1095             : #   include <pthread.h>
    1096             :     static pthread_mutex_t SgConstVolatileModifier_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
    1097             : #else
    1098             :      // Cause synchronization to be skipped.
    1099             : #    ifndef ALLOC_MUTEX
    1100             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
    1101             : #    endif
    1102             : #    ifdef _REENTRANT
    1103             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
    1104             : #       ifdef _MSC_VER
    1105             : #           pragma message("POSIX threads are not available; synchronization being skipped")
    1106             : #       else
    1107             : #           warning "POSIX threads are not available; synchronization being skipped"
    1108             : #       endif
    1109             : #    endif
    1110             : #endif
    1111             : 
    1112             : #ifndef ROSE_ALLOC_TRACE
    1113             : #  define ROSE_ALLOC_TRACE 0
    1114             : #endif
    1115             : 
    1116             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
    1117             : #define ROSE_ALLOC_TRACE_CNT
    1118             : #include "memory-pool-snapshot.h"
    1119             : unsigned long alloc_trace_cnt = 0;
    1120             : #endif
    1121             : 
    1122             : #if ROSE_ALLOC_TRACE
    1123             : const unsigned SgConstVolatileModifier::pool_size = 5;
    1124             : #else
    1125             : const unsigned SgConstVolatileModifier::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
    1126             : #endif
    1127             : 
    1128             : #ifndef ROSE_ALLOC_MEMSET
    1129             : #  define ROSE_ALLOC_MEMSET 0
    1130             : #endif
    1131             : 
    1132             : #ifndef ROSE_PEDANTIC_ALLOC
    1133             : #  define ROSE_PEDANTIC_ALLOC 0
    1134             : #endif
    1135             : 
    1136             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
    1137             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
    1138             : #endif
    1139             : 
    1140             : #if !defined(SGNODE__ALL_POOLS)
    1141             : #define SGNODE__ALL_POOLS
    1142             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
    1143             : #endif
    1144             : 
    1145             : SgConstVolatileModifier* SgConstVolatileModifier::next_node = nullptr;
    1146             : std::vector<unsigned char*> SgConstVolatileModifier::pools;
    1147             : 
    1148             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
    1149             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
    1150             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
    1151             : // around this macro definition rather than each use).
    1152             : #ifndef ALLOC_MUTEX
    1153             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
    1154             :         do {                                                                     \
    1155             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
    1156             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
    1157             :                 abort();                                                         \
    1158             :             }                                                                    \
    1159             :         } while (0);
    1160             : #endif
    1161             : 
    1162             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
    1163             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
    1164             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
    1165             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
    1166             : 
    1167             : /*! \brief New operator for SgConstVolatileModifier.
    1168             : 
    1169             :    This new operator implements memory pools to provide most efficent 
    1170             :    use of the heap within construction of large ASTs.
    1171             : 
    1172             : \internal The new and delete operators use the lower level C malloc/free
    1173             :    function calls for performance and to make sure that mixing of malloc/free
    1174             :    and new/delete by the used can be caught more readily.  This may change
    1175             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
    1176             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
    1177             :    deallocate memory allocated using ROSE_MALLOC.
    1178             : */
    1179           0 : void *SgConstVolatileModifier::operator new ( size_t Size )
    1180             : {
    1181             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
    1182             :      * returning or throwing an exception. */
    1183           0 :     ALLOC_MUTEX(SgConstVolatileModifier, lock);
    1184             : 
    1185             : #if ROSE_ALLOC_TRACE == 2
    1186             : //    printf("SgConstVolatileModifier::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgConstVolatileModifier::next_node);
    1187             : #endif
    1188             : 
    1189             : #if USE_CPP_NEW_DELETE_OPERATORS
    1190             :     void *mem = ROSE_MALLOC(Size);
    1191             :     ALLOC_MUTEX(SgConstVolatileModifier, unlock);
    1192             :     return mem;
    1193             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
    1194             : #if ROSE_PEDANTIC_ALLOC
    1195             :     ROSE_ASSERT(Size == sizeof(SgConstVolatileModifier));
    1196             : #else
    1197           0 :     if (Size != sizeof(SgConstVolatileModifier)) {
    1198           0 :       void * object = ROSE_MALLOC(Size);
    1199           0 :       ALLOC_MUTEX(SgConstVolatileModifier, unlock);
    1200             :       return object;
    1201             :     }
    1202             : #endif
    1203             : 
    1204           0 :     if (SgConstVolatileModifier::next_node == nullptr) {
    1205           0 :         SgConstVolatileModifier * alloc = (SgConstVolatileModifier*) ROSE_MALLOC ( SgConstVolatileModifier::pool_size * sizeof(SgConstVolatileModifier) );
    1206           0 :         ROSE_ASSERT(alloc != nullptr);
    1207             : 
    1208             : #if ROSE_ALLOC_TRACE == 2
    1209             : //        printf("SgConstVolatileModifier::alloc\n  block[%zi] = [ %p , %p [\n", SgConstVolatileModifier::pools.size(), alloc, alloc + SgConstVolatileModifier::pool_size);
    1210             : #endif
    1211             : 
    1212             : #if ROSE_ALLOC_MEMSET == 1
    1213             : #elif ROSE_ALLOC_MEMSET == 2
    1214             :         memset(alloc, 0x00, SgConstVolatileModifier::pool_size * sizeof(SgConstVolatileModifier));
    1215             : #elif ROSE_ALLOC_MEMSET == 3
    1216             :         memset(alloc, 0xAA, SgConstVolatileModifier::pool_size * sizeof(SgConstVolatileModifier));
    1217             : #endif
    1218           0 :         for (unsigned i=0; i < SgConstVolatileModifier::pool_size-1; i++) {
    1219           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
    1220             :         }
    1221           0 :         alloc[SgConstVolatileModifier::pool_size-1].p_freepointer = nullptr;
    1222             : 
    1223           0 :         SgConstVolatileModifier::pools.push_back ( (unsigned char *) alloc );
    1224           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgConstVolatileModifier::pool_size * sizeof(SgConstVolatileModifier), V_SgConstVolatileModifier ) );
    1225           0 :         SgConstVolatileModifier::next_node = alloc;
    1226             :     }
    1227           0 :     ROSE_ASSERT(SgConstVolatileModifier::next_node != nullptr);
    1228             : 
    1229           0 :     SgConstVolatileModifier * object = SgConstVolatileModifier::next_node;
    1230           0 :     SgConstVolatileModifier::next_node = (SgConstVolatileModifier*)(object->p_freepointer);
    1231             : 
    1232             : #if ROSE_ALLOC_TRACE == 2
    1233             :     printf("SgConstVolatileModifier::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgConstVolatileModifier::next_node);
    1234             : #endif
    1235             : 
    1236           0 :     SgNode * fp = object->p_freepointer;
    1237             : #if ROSE_ALLOC_MEMSET == 1
    1238             : #elif ROSE_ALLOC_MEMSET == 2
    1239             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgConstVolatileModifier) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
    1240             : #elif ROSE_ALLOC_MEMSET == 3
    1241             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgConstVolatileModifier) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
    1242             : #endif
    1243           0 :     object->p_freepointer = fp;
    1244             : 
    1245             : #if ROSE_ALLOC_TRACE == 2
    1246             : //    printf("SgConstVolatileModifier::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgConstVolatileModifier::next_node);
    1247             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
    1248             :     Rose::MemPool::snapshot(oss.str());
    1249             :     alloc_trace_cnt++;
    1250             : #endif
    1251             : 
    1252           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
    1253             : 
    1254           0 :     ALLOC_MUTEX(SgConstVolatileModifier, unlock);
    1255             : 
    1256             :     return object;
    1257             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
    1258             : }
    1259             : 
    1260             : 
    1261             : 
    1262             : /*! \brief Delete operator for SgConstVolatileModifier.
    1263             : 
    1264             :    This delete operator implements deallocation using memory pools to 
    1265             :    provide most efficent use of the heap within construction of large ASTs.
    1266             : 
    1267             : \internal The new and delete operators use the lower level C malloc/free
    1268             :    function calls for performance and to make sure that mixing of malloc/free
    1269             :    and new/delete by the used can be caught more readily.  This may change
    1270             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
    1271             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
    1272             :    deallocate memory allocated using ROSE_MALLOC.
    1273             : */
    1274           0 : void SgConstVolatileModifier::operator delete(void *Pointer, size_t Size)
    1275             : {
    1276             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
    1277             :      * or throwing an exception. */
    1278           0 :     ALLOC_MUTEX(SgConstVolatileModifier, lock);
    1279             : 
    1280             : #if USE_CPP_NEW_DELETE_OPERATORS
    1281             :     ROSE_FREE(Pointer);
    1282             : #else
    1283             : #if ROSE_PEDANTIC_ALLOC
    1284             :     ROSE_ASSERT(Size == sizeof(SgConstVolatileModifier));
    1285             : #else
    1286           0 :     if (Size != sizeof(SgConstVolatileModifier)) {
    1287           0 :       ROSE_FREE(Pointer);
    1288           0 :       ALLOC_MUTEX(SgConstVolatileModifier, unlock);
    1289             :       return;
    1290             :     }
    1291             : #endif
    1292             : 
    1293           0 :     SgConstVolatileModifier * object = (SgConstVolatileModifier*) Pointer;
    1294           0 :     ROSE_ASSERT(object != nullptr);
    1295             : 
    1296             : #if ROSE_ALLOC_TRACE == 2
    1297             : //  printf("SgConstVolatileModifier::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgConstVolatileModifier::next_node);
    1298             :     printf("SgConstVolatileModifier::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgConstVolatileModifier::next_node);
    1299             : #endif
    1300             : 
    1301             : #if ROSE_PEDANTIC_ALLOC
    1302             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
    1303             : #endif
    1304             : 
    1305             : #if ROSE_ALLOC_MEMSET == 1
    1306             : #elif ROSE_ALLOC_MEMSET == 2
    1307             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgConstVolatileModifier) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
    1308             : #elif ROSE_ALLOC_MEMSET == 3
    1309             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgConstVolatileModifier) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
    1310             : #endif
    1311             : 
    1312             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
    1313             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
    1314             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
    1315             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
    1316             : #else
    1317           0 :     object->p_freepointer = SgConstVolatileModifier::next_node;
    1318           0 :     SgConstVolatileModifier::next_node = object;
    1319             : #endif
    1320             : 
    1321             : #if ROSE_ALLOC_TRACE == 2
    1322             : //  printf("SgConstVolatileModifier::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgConstVolatileModifier::next_node);
    1323             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
    1324             :     Rose::MemPool::snapshot(oss.str());
    1325             :     alloc_trace_cnt++;
    1326             : #endif
    1327             : 
    1328             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
    1329             : 
    1330           0 :     ALLOC_MUTEX(SgConstVolatileModifier, unlock);
    1331             : }
    1332             : 
    1333             : // DQ (11/27/2009): I have moved this member function definition to outside of the
    1334             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
    1335             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
    1336             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
    1337             : // Also, note comment below from Robb (copied from the Common.code file).
    1338             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
    1339             : //
    1340             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
    1341             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
    1342             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
    1343             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
    1344             : #if 0
    1345             : void SgConstVolatileModifier::operator delete(void* pointer) { SgConstVolatileModifier::operator delete (pointer, sizeof(SgConstVolatileModifier)); };
    1346             : #endif
    1347             : /* #line 1348 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
    1348             : 
    1349             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
    1350             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
    1351             : // obviously imply C++.
    1352             : 
    1353             : // This implements the support within ROSE for memory pools.  Memory pools
    1354             : // support the most condensed usage of memory within the construction of
    1355             : // and AST. Large blocks of contiguous storage for each RI node is allocated
    1356             : // by a new operator written for each class.
    1357             : 
    1358             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
    1359             :     // User wants multi-thread support and POSIX threads are available.
    1360             : #   include <pthread.h>
    1361             :     static pthread_mutex_t SgStorageModifier_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
    1362             : #else
    1363             :      // Cause synchronization to be skipped.
    1364             : #    ifndef ALLOC_MUTEX
    1365             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
    1366             : #    endif
    1367             : #    ifdef _REENTRANT
    1368             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
    1369             : #       ifdef _MSC_VER
    1370             : #           pragma message("POSIX threads are not available; synchronization being skipped")
    1371             : #       else
    1372             : #           warning "POSIX threads are not available; synchronization being skipped"
    1373             : #       endif
    1374             : #    endif
    1375             : #endif
    1376             : 
    1377             : #ifndef ROSE_ALLOC_TRACE
    1378             : #  define ROSE_ALLOC_TRACE 0
    1379             : #endif
    1380             : 
    1381             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
    1382             : #define ROSE_ALLOC_TRACE_CNT
    1383             : #include "memory-pool-snapshot.h"
    1384             : unsigned long alloc_trace_cnt = 0;
    1385             : #endif
    1386             : 
    1387             : #if ROSE_ALLOC_TRACE
    1388             : const unsigned SgStorageModifier::pool_size = 5;
    1389             : #else
    1390             : const unsigned SgStorageModifier::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
    1391             : #endif
    1392             : 
    1393             : #ifndef ROSE_ALLOC_MEMSET
    1394             : #  define ROSE_ALLOC_MEMSET 0
    1395             : #endif
    1396             : 
    1397             : #ifndef ROSE_PEDANTIC_ALLOC
    1398             : #  define ROSE_PEDANTIC_ALLOC 0
    1399             : #endif
    1400             : 
    1401             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
    1402             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
    1403             : #endif
    1404             : 
    1405             : #if !defined(SGNODE__ALL_POOLS)
    1406             : #define SGNODE__ALL_POOLS
    1407             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
    1408             : #endif
    1409             : 
    1410             : SgStorageModifier* SgStorageModifier::next_node = nullptr;
    1411             : std::vector<unsigned char*> SgStorageModifier::pools;
    1412             : 
    1413             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
    1414             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
    1415             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
    1416             : // around this macro definition rather than each use).
    1417             : #ifndef ALLOC_MUTEX
    1418             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
    1419             :         do {                                                                     \
    1420             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
    1421             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
    1422             :                 abort();                                                         \
    1423             :             }                                                                    \
    1424             :         } while (0);
    1425             : #endif
    1426             : 
    1427             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
    1428             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
    1429             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
    1430             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
    1431             : 
    1432             : /*! \brief New operator for SgStorageModifier.
    1433             : 
    1434             :    This new operator implements memory pools to provide most efficent 
    1435             :    use of the heap within construction of large ASTs.
    1436             : 
    1437             : \internal The new and delete operators use the lower level C malloc/free
    1438             :    function calls for performance and to make sure that mixing of malloc/free
    1439             :    and new/delete by the used can be caught more readily.  This may change
    1440             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
    1441             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
    1442             :    deallocate memory allocated using ROSE_MALLOC.
    1443             : */
    1444     6428380 : void *SgStorageModifier::operator new ( size_t Size )
    1445             : {
    1446             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
    1447             :      * returning or throwing an exception. */
    1448     6428380 :     ALLOC_MUTEX(SgStorageModifier, lock);
    1449             : 
    1450             : #if ROSE_ALLOC_TRACE == 2
    1451             : //    printf("SgStorageModifier::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgStorageModifier::next_node);
    1452             : #endif
    1453             : 
    1454             : #if USE_CPP_NEW_DELETE_OPERATORS
    1455             :     void *mem = ROSE_MALLOC(Size);
    1456             :     ALLOC_MUTEX(SgStorageModifier, unlock);
    1457             :     return mem;
    1458             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
    1459             : #if ROSE_PEDANTIC_ALLOC
    1460             :     ROSE_ASSERT(Size == sizeof(SgStorageModifier));
    1461             : #else
    1462     6428380 :     if (Size != sizeof(SgStorageModifier)) {
    1463           0 :       void * object = ROSE_MALLOC(Size);
    1464           0 :       ALLOC_MUTEX(SgStorageModifier, unlock);
    1465             :       return object;
    1466             :     }
    1467             : #endif
    1468             : 
    1469     6428380 :     if (SgStorageModifier::next_node == nullptr) {
    1470        3337 :         SgStorageModifier * alloc = (SgStorageModifier*) ROSE_MALLOC ( SgStorageModifier::pool_size * sizeof(SgStorageModifier) );
    1471        3337 :         ROSE_ASSERT(alloc != nullptr);
    1472             : 
    1473             : #if ROSE_ALLOC_TRACE == 2
    1474             : //        printf("SgStorageModifier::alloc\n  block[%zi] = [ %p , %p [\n", SgStorageModifier::pools.size(), alloc, alloc + SgStorageModifier::pool_size);
    1475             : #endif
    1476             : 
    1477             : #if ROSE_ALLOC_MEMSET == 1
    1478             : #elif ROSE_ALLOC_MEMSET == 2
    1479             :         memset(alloc, 0x00, SgStorageModifier::pool_size * sizeof(SgStorageModifier));
    1480             : #elif ROSE_ALLOC_MEMSET == 3
    1481             :         memset(alloc, 0xAA, SgStorageModifier::pool_size * sizeof(SgStorageModifier));
    1482             : #endif
    1483     6674000 :         for (unsigned i=0; i < SgStorageModifier::pool_size-1; i++) {
    1484     6670660 :           alloc[i].p_freepointer = &(alloc[i+1]);
    1485             :         }
    1486        3337 :         alloc[SgStorageModifier::pool_size-1].p_freepointer = nullptr;
    1487             : 
    1488        3337 :         SgStorageModifier::pools.push_back ( (unsigned char *) alloc );
    1489        3337 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgStorageModifier::pool_size * sizeof(SgStorageModifier), V_SgStorageModifier ) );
    1490        3337 :         SgStorageModifier::next_node = alloc;
    1491             :     }
    1492     6428380 :     ROSE_ASSERT(SgStorageModifier::next_node != nullptr);
    1493             : 
    1494     6428380 :     SgStorageModifier * object = SgStorageModifier::next_node;
    1495     6428380 :     SgStorageModifier::next_node = (SgStorageModifier*)(object->p_freepointer);
    1496             : 
    1497             : #if ROSE_ALLOC_TRACE == 2
    1498             :     printf("SgStorageModifier::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgStorageModifier::next_node);
    1499             : #endif
    1500             : 
    1501     6428380 :     SgNode * fp = object->p_freepointer;
    1502             : #if ROSE_ALLOC_MEMSET == 1
    1503             : #elif ROSE_ALLOC_MEMSET == 2
    1504             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgStorageModifier) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
    1505             : #elif ROSE_ALLOC_MEMSET == 3
    1506             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgStorageModifier) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
    1507             : #endif
    1508     6428380 :     object->p_freepointer = fp;
    1509             : 
    1510             : #if ROSE_ALLOC_TRACE == 2
    1511             : //    printf("SgStorageModifier::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgStorageModifier::next_node);
    1512             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
    1513             :     Rose::MemPool::snapshot(oss.str());
    1514             :     alloc_trace_cnt++;
    1515             : #endif
    1516             : 
    1517     6428380 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
    1518             : 
    1519     6428380 :     ALLOC_MUTEX(SgStorageModifier, unlock);
    1520             : 
    1521             :     return object;
    1522             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
    1523             : }
    1524             : 
    1525             : 
    1526             : 
    1527             : /*! \brief Delete operator for SgStorageModifier.
    1528             : 
    1529             :    This delete operator implements deallocation using memory pools to 
    1530             :    provide most efficent use of the heap within construction of large ASTs.
    1531             : 
    1532             : \internal The new and delete operators use the lower level C malloc/free
    1533             :    function calls for performance and to make sure that mixing of malloc/free
    1534             :    and new/delete by the used can be caught more readily.  This may change
    1535             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
    1536             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
    1537             :    deallocate memory allocated using ROSE_MALLOC.
    1538             : */
    1539      110459 : void SgStorageModifier::operator delete(void *Pointer, size_t Size)
    1540             : {
    1541             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
    1542             :      * or throwing an exception. */
    1543      110459 :     ALLOC_MUTEX(SgStorageModifier, lock);
    1544             : 
    1545             : #if USE_CPP_NEW_DELETE_OPERATORS
    1546             :     ROSE_FREE(Pointer);
    1547             : #else
    1548             : #if ROSE_PEDANTIC_ALLOC
    1549             :     ROSE_ASSERT(Size == sizeof(SgStorageModifier));
    1550             : #else
    1551      110459 :     if (Size != sizeof(SgStorageModifier)) {
    1552           0 :       ROSE_FREE(Pointer);
    1553           0 :       ALLOC_MUTEX(SgStorageModifier, unlock);
    1554             :       return;
    1555             :     }
    1556             : #endif
    1557             : 
    1558      110459 :     SgStorageModifier * object = (SgStorageModifier*) Pointer;
    1559      110459 :     ROSE_ASSERT(object != nullptr);
    1560             : 
    1561             : #if ROSE_ALLOC_TRACE == 2
    1562             : //  printf("SgStorageModifier::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgStorageModifier::next_node);
    1563             :     printf("SgStorageModifier::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgStorageModifier::next_node);
    1564             : #endif
    1565             : 
    1566             : #if ROSE_PEDANTIC_ALLOC
    1567             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
    1568             : #endif
    1569             : 
    1570             : #if ROSE_ALLOC_MEMSET == 1
    1571             : #elif ROSE_ALLOC_MEMSET == 2
    1572             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgStorageModifier) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
    1573             : #elif ROSE_ALLOC_MEMSET == 3
    1574             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgStorageModifier) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
    1575             : #endif
    1576             : 
    1577             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
    1578             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
    1579             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
    1580             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
    1581             : #else
    1582      110459 :     object->p_freepointer = SgStorageModifier::next_node;
    1583      110459 :     SgStorageModifier::next_node = object;
    1584             : #endif
    1585             : 
    1586             : #if ROSE_ALLOC_TRACE == 2
    1587             : //  printf("SgStorageModifier::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgStorageModifier::next_node);
    1588             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
    1589             :     Rose::MemPool::snapshot(oss.str());
    1590             :     alloc_trace_cnt++;
    1591             : #endif
    1592             : 
    1593             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
    1594             : 
    1595      110459 :     ALLOC_MUTEX(SgStorageModifier, unlock);
    1596             : }
    1597             : 
    1598             : // DQ (11/27/2009): I have moved this member function definition to outside of the
    1599             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
    1600             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
    1601             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
    1602             : // Also, note comment below from Robb (copied from the Common.code file).
    1603             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
    1604             : //
    1605             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
    1606             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
    1607             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
    1608             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
    1609             : #if 0
    1610             : void SgStorageModifier::operator delete(void* pointer) { SgStorageModifier::operator delete (pointer, sizeof(SgStorageModifier)); };
    1611             : #endif
    1612             : /* #line 1613 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
    1613             : 
    1614             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
    1615             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
    1616             : // obviously imply C++.
    1617             : 
    1618             : // This implements the support within ROSE for memory pools.  Memory pools
    1619             : // support the most condensed usage of memory within the construction of
    1620             : // and AST. Large blocks of contiguous storage for each RI node is allocated
    1621             : // by a new operator written for each class.
    1622             : 
    1623             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
    1624             :     // User wants multi-thread support and POSIX threads are available.
    1625             : #   include <pthread.h>
    1626             :     static pthread_mutex_t SgAccessModifier_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
    1627             : #else
    1628             :      // Cause synchronization to be skipped.
    1629             : #    ifndef ALLOC_MUTEX
    1630             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
    1631             : #    endif
    1632             : #    ifdef _REENTRANT
    1633             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
    1634             : #       ifdef _MSC_VER
    1635             : #           pragma message("POSIX threads are not available; synchronization being skipped")
    1636             : #       else
    1637             : #           warning "POSIX threads are not available; synchronization being skipped"
    1638             : #       endif
    1639             : #    endif
    1640             : #endif
    1641             : 
    1642             : #ifndef ROSE_ALLOC_TRACE
    1643             : #  define ROSE_ALLOC_TRACE 0
    1644             : #endif
    1645             : 
    1646             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
    1647             : #define ROSE_ALLOC_TRACE_CNT
    1648             : #include "memory-pool-snapshot.h"
    1649             : unsigned long alloc_trace_cnt = 0;
    1650             : #endif
    1651             : 
    1652             : #if ROSE_ALLOC_TRACE
    1653             : const unsigned SgAccessModifier::pool_size = 5;
    1654             : #else
    1655             : const unsigned SgAccessModifier::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
    1656             : #endif
    1657             : 
    1658             : #ifndef ROSE_ALLOC_MEMSET
    1659             : #  define ROSE_ALLOC_MEMSET 0
    1660             : #endif
    1661             : 
    1662             : #ifndef ROSE_PEDANTIC_ALLOC
    1663             : #  define ROSE_PEDANTIC_ALLOC 0
    1664             : #endif
    1665             : 
    1666             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
    1667             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
    1668             : #endif
    1669             : 
    1670             : #if !defined(SGNODE__ALL_POOLS)
    1671             : #define SGNODE__ALL_POOLS
    1672             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
    1673             : #endif
    1674             : 
    1675             : SgAccessModifier* SgAccessModifier::next_node = nullptr;
    1676             : std::vector<unsigned char*> SgAccessModifier::pools;
    1677             : 
    1678             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
    1679             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
    1680             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
    1681             : // around this macro definition rather than each use).
    1682             : #ifndef ALLOC_MUTEX
    1683             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
    1684             :         do {                                                                     \
    1685             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
    1686             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
    1687             :                 abort();                                                         \
    1688             :             }                                                                    \
    1689             :         } while (0);
    1690             : #endif
    1691             : 
    1692             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
    1693             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
    1694             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
    1695             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
    1696             : 
    1697             : /*! \brief New operator for SgAccessModifier.
    1698             : 
    1699             :    This new operator implements memory pools to provide most efficent 
    1700             :    use of the heap within construction of large ASTs.
    1701             : 
    1702             : \internal The new and delete operators use the lower level C malloc/free
    1703             :    function calls for performance and to make sure that mixing of malloc/free
    1704             :    and new/delete by the used can be caught more readily.  This may change
    1705             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
    1706             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
    1707             :    deallocate memory allocated using ROSE_MALLOC.
    1708             : */
    1709           0 : void *SgAccessModifier::operator new ( size_t Size )
    1710             : {
    1711             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
    1712             :      * returning or throwing an exception. */
    1713           0 :     ALLOC_MUTEX(SgAccessModifier, lock);
    1714             : 
    1715             : #if ROSE_ALLOC_TRACE == 2
    1716             : //    printf("SgAccessModifier::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgAccessModifier::next_node);
    1717             : #endif
    1718             : 
    1719             : #if USE_CPP_NEW_DELETE_OPERATORS
    1720             :     void *mem = ROSE_MALLOC(Size);
    1721             :     ALLOC_MUTEX(SgAccessModifier, unlock);
    1722             :     return mem;
    1723             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
    1724             : #if ROSE_PEDANTIC_ALLOC
    1725             :     ROSE_ASSERT(Size == sizeof(SgAccessModifier));
    1726             : #else
    1727           0 :     if (Size != sizeof(SgAccessModifier)) {
    1728           0 :       void * object = ROSE_MALLOC(Size);
    1729           0 :       ALLOC_MUTEX(SgAccessModifier, unlock);
    1730             :       return object;
    1731             :     }
    1732             : #endif
    1733             : 
    1734           0 :     if (SgAccessModifier::next_node == nullptr) {
    1735           0 :         SgAccessModifier * alloc = (SgAccessModifier*) ROSE_MALLOC ( SgAccessModifier::pool_size * sizeof(SgAccessModifier) );
    1736           0 :         ROSE_ASSERT(alloc != nullptr);
    1737             : 
    1738             : #if ROSE_ALLOC_TRACE == 2
    1739             : //        printf("SgAccessModifier::alloc\n  block[%zi] = [ %p , %p [\n", SgAccessModifier::pools.size(), alloc, alloc + SgAccessModifier::pool_size);
    1740             : #endif
    1741             : 
    1742             : #if ROSE_ALLOC_MEMSET == 1
    1743             : #elif ROSE_ALLOC_MEMSET == 2
    1744             :         memset(alloc, 0x00, SgAccessModifier::pool_size * sizeof(SgAccessModifier));
    1745             : #elif ROSE_ALLOC_MEMSET == 3
    1746             :         memset(alloc, 0xAA, SgAccessModifier::pool_size * sizeof(SgAccessModifier));
    1747             : #endif
    1748           0 :         for (unsigned i=0; i < SgAccessModifier::pool_size-1; i++) {
    1749           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
    1750             :         }
    1751           0 :         alloc[SgAccessModifier::pool_size-1].p_freepointer = nullptr;
    1752             : 
    1753           0 :         SgAccessModifier::pools.push_back ( (unsigned char *) alloc );
    1754           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgAccessModifier::pool_size * sizeof(SgAccessModifier), V_SgAccessModifier ) );
    1755           0 :         SgAccessModifier::next_node = alloc;
    1756             :     }
    1757           0 :     ROSE_ASSERT(SgAccessModifier::next_node != nullptr);
    1758             : 
    1759           0 :     SgAccessModifier * object = SgAccessModifier::next_node;
    1760           0 :     SgAccessModifier::next_node = (SgAccessModifier*)(object->p_freepointer);
    1761             : 
    1762             : #if ROSE_ALLOC_TRACE == 2
    1763             :     printf("SgAccessModifier::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgAccessModifier::next_node);
    1764             : #endif
    1765             : 
    1766           0 :     SgNode * fp = object->p_freepointer;
    1767             : #if ROSE_ALLOC_MEMSET == 1
    1768             : #elif ROSE_ALLOC_MEMSET == 2
    1769             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgAccessModifier) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
    1770             : #elif ROSE_ALLOC_MEMSET == 3
    1771             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgAccessModifier) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
    1772             : #endif
    1773           0 :     object->p_freepointer = fp;
    1774             : 
    1775             : #if ROSE_ALLOC_TRACE == 2
    1776             : //    printf("SgAccessModifier::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgAccessModifier::next_node);
    1777             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
    1778             :     Rose::MemPool::snapshot(oss.str());
    1779             :     alloc_trace_cnt++;
    1780             : #endif
    1781             : 
    1782           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
    1783             : 
    1784           0 :     ALLOC_MUTEX(SgAccessModifier, unlock);
    1785             : 
    1786             :     return object;
    1787             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
    1788             : }
    1789             : 
    1790             : 
    1791             : 
    1792             : /*! \brief Delete operator for SgAccessModifier.
    1793             : 
    1794             :    This delete operator implements deallocation using memory pools to 
    1795             :    provide most efficent use of the heap within construction of large ASTs.
    1796             : 
    1797             : \internal The new and delete operators use the lower level C malloc/free
    1798             :    function calls for performance and to make sure that mixing of malloc/free
    1799             :    and new/delete by the used can be caught more readily.  This may change
    1800             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
    1801             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
    1802             :    deallocate memory allocated using ROSE_MALLOC.
    1803             : */
    1804           0 : void SgAccessModifier::operator delete(void *Pointer, size_t Size)
    1805             : {
    1806             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
    1807             :      * or throwing an exception. */
    1808           0 :     ALLOC_MUTEX(SgAccessModifier, lock);
    1809             : 
    1810             : #if USE_CPP_NEW_DELETE_OPERATORS
    1811             :     ROSE_FREE(Pointer);
    1812             : #else
    1813             : #if ROSE_PEDANTIC_ALLOC
    1814             :     ROSE_ASSERT(Size == sizeof(SgAccessModifier));
    1815             : #else
    1816           0 :     if (Size != sizeof(SgAccessModifier)) {
    1817           0 :       ROSE_FREE(Pointer);
    1818           0 :       ALLOC_MUTEX(SgAccessModifier, unlock);
    1819             :       return;
    1820             :     }
    1821             : #endif
    1822             : 
    1823           0 :     SgAccessModifier * object = (SgAccessModifier*) Pointer;
    1824           0 :     ROSE_ASSERT(object != nullptr);
    1825             : 
    1826             : #if ROSE_ALLOC_TRACE == 2
    1827             : //  printf("SgAccessModifier::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgAccessModifier::next_node);
    1828             :     printf("SgAccessModifier::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgAccessModifier::next_node);
    1829             : #endif
    1830             : 
    1831             : #if ROSE_PEDANTIC_ALLOC
    1832             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
    1833             : #endif
    1834             : 
    1835             : #if ROSE_ALLOC_MEMSET == 1
    1836             : #elif ROSE_ALLOC_MEMSET == 2
    1837             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgAccessModifier) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
    1838             : #elif ROSE_ALLOC_MEMSET == 3
    1839             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgAccessModifier) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
    1840             : #endif
    1841             : 
    1842             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
    1843             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
    1844             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
    1845             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
    1846             : #else
    1847           0 :     object->p_freepointer = SgAccessModifier::next_node;
    1848           0 :     SgAccessModifier::next_node = object;
    1849             : #endif
    1850             : 
    1851             : #if ROSE_ALLOC_TRACE == 2
    1852             : //  printf("SgAccessModifier::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgAccessModifier::next_node);
    1853             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
    1854             :     Rose::MemPool::snapshot(oss.str());
    1855             :     alloc_trace_cnt++;
    1856             : #endif
    1857             : 
    1858             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
    1859             : 
    1860           0 :     ALLOC_MUTEX(SgAccessModifier, unlock);
    1861             : }
    1862             : 
    1863             : // DQ (11/27/2009): I have moved this member function definition to outside of the
    1864             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
    1865             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
    1866             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
    1867             : // Also, note comment below from Robb (copied from the Common.code file).
    1868             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
    1869             : //
    1870             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
    1871             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
    1872             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
    1873             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
    1874             : #if 0
    1875             : void SgAccessModifier::operator delete(void* pointer) { SgAccessModifier::operator delete (pointer, sizeof(SgAccessModifier)); };
    1876             : #endif
    1877             : /* #line 1878 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
    1878             : 
    1879             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
    1880             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
    1881             : // obviously imply C++.
    1882             : 
    1883             : // This implements the support within ROSE for memory pools.  Memory pools
    1884             : // support the most condensed usage of memory within the construction of
    1885             : // and AST. Large blocks of contiguous storage for each RI node is allocated
    1886             : // by a new operator written for each class.
    1887             : 
    1888             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
    1889             :     // User wants multi-thread support and POSIX threads are available.
    1890             : #   include <pthread.h>
    1891             :     static pthread_mutex_t SgFunctionModifier_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
    1892             : #else
    1893             :      // Cause synchronization to be skipped.
    1894             : #    ifndef ALLOC_MUTEX
    1895             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
    1896             : #    endif
    1897             : #    ifdef _REENTRANT
    1898             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
    1899             : #       ifdef _MSC_VER
    1900             : #           pragma message("POSIX threads are not available; synchronization being skipped")
    1901             : #       else
    1902             : #           warning "POSIX threads are not available; synchronization being skipped"
    1903             : #       endif
    1904             : #    endif
    1905             : #endif
    1906             : 
    1907             : #ifndef ROSE_ALLOC_TRACE
    1908             : #  define ROSE_ALLOC_TRACE 0
    1909             : #endif
    1910             : 
    1911             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
    1912             : #define ROSE_ALLOC_TRACE_CNT
    1913             : #include "memory-pool-snapshot.h"
    1914             : unsigned long alloc_trace_cnt = 0;
    1915             : #endif
    1916             : 
    1917             : #if ROSE_ALLOC_TRACE
    1918             : const unsigned SgFunctionModifier::pool_size = 5;
    1919             : #else
    1920             : const unsigned SgFunctionModifier::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
    1921             : #endif
    1922             : 
    1923             : #ifndef ROSE_ALLOC_MEMSET
    1924             : #  define ROSE_ALLOC_MEMSET 0
    1925             : #endif
    1926             : 
    1927             : #ifndef ROSE_PEDANTIC_ALLOC
    1928             : #  define ROSE_PEDANTIC_ALLOC 0
    1929             : #endif
    1930             : 
    1931             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
    1932             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
    1933             : #endif
    1934             : 
    1935             : #if !defined(SGNODE__ALL_POOLS)
    1936             : #define SGNODE__ALL_POOLS
    1937             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
    1938             : #endif
    1939             : 
    1940             : SgFunctionModifier* SgFunctionModifier::next_node = nullptr;
    1941             : std::vector<unsigned char*> SgFunctionModifier::pools;
    1942             : 
    1943             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
    1944             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
    1945             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
    1946             : // around this macro definition rather than each use).
    1947             : #ifndef ALLOC_MUTEX
    1948             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
    1949             :         do {                                                                     \
    1950             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
    1951             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
    1952             :                 abort();                                                         \
    1953             :             }                                                                    \
    1954             :         } while (0);
    1955             : #endif
    1956             : 
    1957             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
    1958             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
    1959             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
    1960             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
    1961             : 
    1962             : /*! \brief New operator for SgFunctionModifier.
    1963             : 
    1964             :    This new operator implements memory pools to provide most efficent 
    1965             :    use of the heap within construction of large ASTs.
    1966             : 
    1967             : \internal The new and delete operators use the lower level C malloc/free
    1968             :    function calls for performance and to make sure that mixing of malloc/free
    1969             :    and new/delete by the used can be caught more readily.  This may change
    1970             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
    1971             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
    1972             :    deallocate memory allocated using ROSE_MALLOC.
    1973             : */
    1974           0 : void *SgFunctionModifier::operator new ( size_t Size )
    1975             : {
    1976             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
    1977             :      * returning or throwing an exception. */
    1978           0 :     ALLOC_MUTEX(SgFunctionModifier, lock);
    1979             : 
    1980             : #if ROSE_ALLOC_TRACE == 2
    1981             : //    printf("SgFunctionModifier::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgFunctionModifier::next_node);
    1982             : #endif
    1983             : 
    1984             : #if USE_CPP_NEW_DELETE_OPERATORS
    1985             :     void *mem = ROSE_MALLOC(Size);
    1986             :     ALLOC_MUTEX(SgFunctionModifier, unlock);
    1987             :     return mem;
    1988             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
    1989             : #if ROSE_PEDANTIC_ALLOC
    1990             :     ROSE_ASSERT(Size == sizeof(SgFunctionModifier));
    1991             : #else
    1992           0 :     if (Size != sizeof(SgFunctionModifier)) {
    1993           0 :       void * object = ROSE_MALLOC(Size);
    1994           0 :       ALLOC_MUTEX(SgFunctionModifier, unlock);
    1995             :       return object;
    1996             :     }
    1997             : #endif
    1998             : 
    1999           0 :     if (SgFunctionModifier::next_node == nullptr) {
    2000           0 :         SgFunctionModifier * alloc = (SgFunctionModifier*) ROSE_MALLOC ( SgFunctionModifier::pool_size * sizeof(SgFunctionModifier) );
    2001           0 :         ROSE_ASSERT(alloc != nullptr);
    2002             : 
    2003             : #if ROSE_ALLOC_TRACE == 2
    2004             : //        printf("SgFunctionModifier::alloc\n  block[%zi] = [ %p , %p [\n", SgFunctionModifier::pools.size(), alloc, alloc + SgFunctionModifier::pool_size);
    2005             : #endif
    2006             : 
    2007             : #if ROSE_ALLOC_MEMSET == 1
    2008             : #elif ROSE_ALLOC_MEMSET == 2
    2009             :         memset(alloc, 0x00, SgFunctionModifier::pool_size * sizeof(SgFunctionModifier));
    2010             : #elif ROSE_ALLOC_MEMSET == 3
    2011             :         memset(alloc, 0xAA, SgFunctionModifier::pool_size * sizeof(SgFunctionModifier));
    2012             : #endif
    2013           0 :         for (unsigned i=0; i < SgFunctionModifier::pool_size-1; i++) {
    2014           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
    2015             :         }
    2016           0 :         alloc[SgFunctionModifier::pool_size-1].p_freepointer = nullptr;
    2017             : 
    2018           0 :         SgFunctionModifier::pools.push_back ( (unsigned char *) alloc );
    2019           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgFunctionModifier::pool_size * sizeof(SgFunctionModifier), V_SgFunctionModifier ) );
    2020           0 :         SgFunctionModifier::next_node = alloc;
    2021             :     }
    2022           0 :     ROSE_ASSERT(SgFunctionModifier::next_node != nullptr);
    2023             : 
    2024           0 :     SgFunctionModifier * object = SgFunctionModifier::next_node;
    2025           0 :     SgFunctionModifier::next_node = (SgFunctionModifier*)(object->p_freepointer);
    2026             : 
    2027             : #if ROSE_ALLOC_TRACE == 2
    2028             :     printf("SgFunctionModifier::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgFunctionModifier::next_node);
    2029             : #endif
    2030             : 
    2031           0 :     SgNode * fp = object->p_freepointer;
    2032             : #if ROSE_ALLOC_MEMSET == 1
    2033             : #elif ROSE_ALLOC_MEMSET == 2
    2034             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgFunctionModifier) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
    2035             : #elif ROSE_ALLOC_MEMSET == 3
    2036             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgFunctionModifier) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
    2037             : #endif
    2038           0 :     object->p_freepointer = fp;
    2039             : 
    2040             : #if ROSE_ALLOC_TRACE == 2
    2041             : //    printf("SgFunctionModifier::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgFunctionModifier::next_node);
    2042             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
    2043             :     Rose::MemPool::snapshot(oss.str());
    2044             :     alloc_trace_cnt++;
    2045             : #endif
    2046             : 
    2047           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
    2048             : 
    2049           0 :     ALLOC_MUTEX(SgFunctionModifier, unlock);
    2050             : 
    2051             :     return object;
    2052             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
    2053             : }
    2054             : 
    2055             : 
    2056             : 
    2057             : /*! \brief Delete operator for SgFunctionModifier.
    2058             : 
    2059             :    This delete operator implements deallocation using memory pools to 
    2060             :    provide most efficent use of the heap within construction of large ASTs.
    2061             : 
    2062             : \internal The new and delete operators use the lower level C malloc/free
    2063             :    function calls for performance and to make sure that mixing of malloc/free
    2064             :    and new/delete by the used can be caught more readily.  This may change
    2065             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
    2066             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
    2067             :    deallocate memory allocated using ROSE_MALLOC.
    2068             : */
    2069           0 : void SgFunctionModifier::operator delete(void *Pointer, size_t Size)
    2070             : {
    2071             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
    2072             :      * or throwing an exception. */
    2073           0 :     ALLOC_MUTEX(SgFunctionModifier, lock);
    2074             : 
    2075             : #if USE_CPP_NEW_DELETE_OPERATORS
    2076             :     ROSE_FREE(Pointer);
    2077             : #else
    2078             : #if ROSE_PEDANTIC_ALLOC
    2079             :     ROSE_ASSERT(Size == sizeof(SgFunctionModifier));
    2080             : #else
    2081           0 :     if (Size != sizeof(SgFunctionModifier)) {
    2082           0 :       ROSE_FREE(Pointer);
    2083           0 :       ALLOC_MUTEX(SgFunctionModifier, unlock);
    2084             :       return;
    2085             :     }
    2086             : #endif
    2087             : 
    2088           0 :     SgFunctionModifier * object = (SgFunctionModifier*) Pointer;
    2089           0 :     ROSE_ASSERT(object != nullptr);
    2090             : 
    2091             : #if ROSE_ALLOC_TRACE == 2
    2092             : //  printf("SgFunctionModifier::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgFunctionModifier::next_node);
    2093             :     printf("SgFunctionModifier::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgFunctionModifier::next_node);
    2094             : #endif
    2095             : 
    2096             : #if ROSE_PEDANTIC_ALLOC
    2097             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
    2098             : #endif
    2099             : 
    2100             : #if ROSE_ALLOC_MEMSET == 1
    2101             : #elif ROSE_ALLOC_MEMSET == 2
    2102             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgFunctionModifier) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
    2103             : #elif ROSE_ALLOC_MEMSET == 3
    2104             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgFunctionModifier) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
    2105             : #endif
    2106             : 
    2107             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
    2108             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
    2109             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
    2110             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
    2111             : #else
    2112           0 :     object->p_freepointer = SgFunctionModifier::next_node;
    2113           0 :     SgFunctionModifier::next_node = object;
    2114             : #endif
    2115             : 
    2116             : #if ROSE_ALLOC_TRACE == 2
    2117             : //  printf("SgFunctionModifier::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgFunctionModifier::next_node);
    2118             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
    2119             :     Rose::MemPool::snapshot(oss.str());
    2120             :     alloc_trace_cnt++;
    2121             : #endif
    2122             : 
    2123             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
    2124             : 
    2125           0 :     ALLOC_MUTEX(SgFunctionModifier, unlock);
    2126             : }
    2127             : 
    2128             : // DQ (11/27/2009): I have moved this member function definition to outside of the
    2129             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
    2130             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
    2131             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
    2132             : // Also, note comment below from Robb (copied from the Common.code file).
    2133             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
    2134             : //
    2135             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
    2136             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
    2137             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
    2138             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
    2139             : #if 0
    2140             : void SgFunctionModifier::operator delete(void* pointer) { SgFunctionModifier::operator delete (pointer, sizeof(SgFunctionModifier)); };
    2141             : #endif
    2142             : /* #line 2143 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
    2143             : 
    2144             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
    2145             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
    2146             : // obviously imply C++.
    2147             : 
    2148             : // This implements the support within ROSE for memory pools.  Memory pools
    2149             : // support the most condensed usage of memory within the construction of
    2150             : // and AST. Large blocks of contiguous storage for each RI node is allocated
    2151             : // by a new operator written for each class.
    2152             : 
    2153             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
    2154             :     // User wants multi-thread support and POSIX threads are available.
    2155             : #   include <pthread.h>
    2156             :     static pthread_mutex_t SgUPC_AccessModifier_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
    2157             : #else
    2158             :      // Cause synchronization to be skipped.
    2159             : #    ifndef ALLOC_MUTEX
    2160             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
    2161             : #    endif
    2162             : #    ifdef _REENTRANT
    2163             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
    2164             : #       ifdef _MSC_VER
    2165             : #           pragma message("POSIX threads are not available; synchronization being skipped")
    2166             : #       else
    2167             : #           warning "POSIX threads are not available; synchronization being skipped"
    2168             : #       endif
    2169             : #    endif
    2170             : #endif
    2171             : 
    2172             : #ifndef ROSE_ALLOC_TRACE
    2173             : #  define ROSE_ALLOC_TRACE 0
    2174             : #endif
    2175             : 
    2176             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
    2177             : #define ROSE_ALLOC_TRACE_CNT
    2178             : #include "memory-pool-snapshot.h"
    2179             : unsigned long alloc_trace_cnt = 0;
    2180             : #endif
    2181             : 
    2182             : #if ROSE_ALLOC_TRACE
    2183             : const unsigned SgUPC_AccessModifier::pool_size = 5;
    2184             : #else
    2185             : const unsigned SgUPC_AccessModifier::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
    2186             : #endif
    2187             : 
    2188             : #ifndef ROSE_ALLOC_MEMSET
    2189             : #  define ROSE_ALLOC_MEMSET 0
    2190             : #endif
    2191             : 
    2192             : #ifndef ROSE_PEDANTIC_ALLOC
    2193             : #  define ROSE_PEDANTIC_ALLOC 0
    2194             : #endif
    2195             : 
    2196             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
    2197             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
    2198             : #endif
    2199             : 
    2200             : #if !defined(SGNODE__ALL_POOLS)
    2201             : #define SGNODE__ALL_POOLS
    2202             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
    2203             : #endif
    2204             : 
    2205             : SgUPC_AccessModifier* SgUPC_AccessModifier::next_node = nullptr;
    2206             : std::vector<unsigned char*> SgUPC_AccessModifier::pools;
    2207             : 
    2208             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
    2209             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
    2210             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
    2211             : // around this macro definition rather than each use).
    2212             : #ifndef ALLOC_MUTEX
    2213             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
    2214             :         do {                                                                     \
    2215             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
    2216             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
    2217             :                 abort();                                                         \
    2218             :             }                                                                    \
    2219             :         } while (0);
    2220             : #endif
    2221             : 
    2222             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
    2223             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
    2224             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
    2225             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
    2226             : 
    2227             : /*! \brief New operator for SgUPC_AccessModifier.
    2228             : 
    2229             :    This new operator implements memory pools to provide most efficent 
    2230             :    use of the heap within construction of large ASTs.
    2231             : 
    2232             : \internal The new and delete operators use the lower level C malloc/free
    2233             :    function calls for performance and to make sure that mixing of malloc/free
    2234             :    and new/delete by the used can be caught more readily.  This may change
    2235             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
    2236             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
    2237             :    deallocate memory allocated using ROSE_MALLOC.
    2238             : */
    2239           0 : void *SgUPC_AccessModifier::operator new ( size_t Size )
    2240             : {
    2241             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
    2242             :      * returning or throwing an exception. */
    2243           0 :     ALLOC_MUTEX(SgUPC_AccessModifier, lock);
    2244             : 
    2245             : #if ROSE_ALLOC_TRACE == 2
    2246             : //    printf("SgUPC_AccessModifier::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgUPC_AccessModifier::next_node);
    2247             : #endif
    2248             : 
    2249             : #if USE_CPP_NEW_DELETE_OPERATORS
    2250             :     void *mem = ROSE_MALLOC(Size);
    2251             :     ALLOC_MUTEX(SgUPC_AccessModifier, unlock);
    2252             :     return mem;
    2253             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
    2254             : #if ROSE_PEDANTIC_ALLOC
    2255             :     ROSE_ASSERT(Size == sizeof(SgUPC_AccessModifier));
    2256             : #else
    2257           0 :     if (Size != sizeof(SgUPC_AccessModifier)) {
    2258           0 :       void * object = ROSE_MALLOC(Size);
    2259           0 :       ALLOC_MUTEX(SgUPC_AccessModifier, unlock);
    2260             :       return object;
    2261             :     }
    2262             : #endif
    2263             : 
    2264           0 :     if (SgUPC_AccessModifier::next_node == nullptr) {
    2265           0 :         SgUPC_AccessModifier * alloc = (SgUPC_AccessModifier*) ROSE_MALLOC ( SgUPC_AccessModifier::pool_size * sizeof(SgUPC_AccessModifier) );
    2266           0 :         ROSE_ASSERT(alloc != nullptr);
    2267             : 
    2268             : #if ROSE_ALLOC_TRACE == 2
    2269             : //        printf("SgUPC_AccessModifier::alloc\n  block[%zi] = [ %p , %p [\n", SgUPC_AccessModifier::pools.size(), alloc, alloc + SgUPC_AccessModifier::pool_size);
    2270             : #endif
    2271             : 
    2272             : #if ROSE_ALLOC_MEMSET == 1
    2273             : #elif ROSE_ALLOC_MEMSET == 2
    2274             :         memset(alloc, 0x00, SgUPC_AccessModifier::pool_size * sizeof(SgUPC_AccessModifier));
    2275             : #elif ROSE_ALLOC_MEMSET == 3
    2276             :         memset(alloc, 0xAA, SgUPC_AccessModifier::pool_size * sizeof(SgUPC_AccessModifier));
    2277             : #endif
    2278           0 :         for (unsigned i=0; i < SgUPC_AccessModifier::pool_size-1; i++) {
    2279           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
    2280             :         }
    2281           0 :         alloc[SgUPC_AccessModifier::pool_size-1].p_freepointer = nullptr;
    2282             : 
    2283           0 :         SgUPC_AccessModifier::pools.push_back ( (unsigned char *) alloc );
    2284           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgUPC_AccessModifier::pool_size * sizeof(SgUPC_AccessModifier), V_SgUPC_AccessModifier ) );
    2285           0 :         SgUPC_AccessModifier::next_node = alloc;
    2286             :     }
    2287           0 :     ROSE_ASSERT(SgUPC_AccessModifier::next_node != nullptr);
    2288             : 
    2289           0 :     SgUPC_AccessModifier * object = SgUPC_AccessModifier::next_node;
    2290           0 :     SgUPC_AccessModifier::next_node = (SgUPC_AccessModifier*)(object->p_freepointer);
    2291             : 
    2292             : #if ROSE_ALLOC_TRACE == 2
    2293             :     printf("SgUPC_AccessModifier::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUPC_AccessModifier::next_node);
    2294             : #endif
    2295             : 
    2296           0 :     SgNode * fp = object->p_freepointer;
    2297             : #if ROSE_ALLOC_MEMSET == 1
    2298             : #elif ROSE_ALLOC_MEMSET == 2
    2299             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgUPC_AccessModifier) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
    2300             : #elif ROSE_ALLOC_MEMSET == 3
    2301             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgUPC_AccessModifier) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
    2302             : #endif
    2303           0 :     object->p_freepointer = fp;
    2304             : 
    2305             : #if ROSE_ALLOC_TRACE == 2
    2306             : //    printf("SgUPC_AccessModifier::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUPC_AccessModifier::next_node);
    2307             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
    2308             :     Rose::MemPool::snapshot(oss.str());
    2309             :     alloc_trace_cnt++;
    2310             : #endif
    2311             : 
    2312           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
    2313             : 
    2314           0 :     ALLOC_MUTEX(SgUPC_AccessModifier, unlock);
    2315             : 
    2316             :     return object;
    2317             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
    2318             : }
    2319             : 
    2320             : 
    2321             : 
    2322             : /*! \brief Delete operator for SgUPC_AccessModifier.
    2323             : 
    2324             :    This delete operator implements deallocation using memory pools to 
    2325             :    provide most efficent use of the heap within construction of large ASTs.
    2326             : 
    2327             : \internal The new and delete operators use the lower level C malloc/free
    2328             :    function calls for performance and to make sure that mixing of malloc/free
    2329             :    and new/delete by the used can be caught more readily.  This may change
    2330             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
    2331             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
    2332             :    deallocate memory allocated using ROSE_MALLOC.
    2333             : */
    2334           0 : void SgUPC_AccessModifier::operator delete(void *Pointer, size_t Size)
    2335             : {
    2336             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
    2337             :      * or throwing an exception. */
    2338           0 :     ALLOC_MUTEX(SgUPC_AccessModifier, lock);
    2339             : 
    2340             : #if USE_CPP_NEW_DELETE_OPERATORS
    2341             :     ROSE_FREE(Pointer);
    2342             : #else
    2343             : #if ROSE_PEDANTIC_ALLOC
    2344             :     ROSE_ASSERT(Size == sizeof(SgUPC_AccessModifier));
    2345             : #else
    2346           0 :     if (Size != sizeof(SgUPC_AccessModifier)) {
    2347           0 :       ROSE_FREE(Pointer);
    2348           0 :       ALLOC_MUTEX(SgUPC_AccessModifier, unlock);
    2349             :       return;
    2350             :     }
    2351             : #endif
    2352             : 
    2353           0 :     SgUPC_AccessModifier * object = (SgUPC_AccessModifier*) Pointer;
    2354           0 :     ROSE_ASSERT(object != nullptr);
    2355             : 
    2356             : #if ROSE_ALLOC_TRACE == 2
    2357             : //  printf("SgUPC_AccessModifier::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUPC_AccessModifier::next_node);
    2358             :     printf("SgUPC_AccessModifier::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUPC_AccessModifier::next_node);
    2359             : #endif
    2360             : 
    2361             : #if ROSE_PEDANTIC_ALLOC
    2362             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
    2363             : #endif
    2364             : 
    2365             : #if ROSE_ALLOC_MEMSET == 1
    2366             : #elif ROSE_ALLOC_MEMSET == 2
    2367             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgUPC_AccessModifier) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
    2368             : #elif ROSE_ALLOC_MEMSET == 3
    2369             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgUPC_AccessModifier) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
    2370             : #endif
    2371             : 
    2372             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
    2373             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
    2374             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
    2375             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
    2376             : #else
    2377           0 :     object->p_freepointer = SgUPC_AccessModifier::next_node;
    2378           0 :     SgUPC_AccessModifier::next_node = object;
    2379             : #endif
    2380             : 
    2381             : #if ROSE_ALLOC_TRACE == 2
    2382             : //  printf("SgUPC_AccessModifier::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUPC_AccessModifier::next_node);
    2383             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
    2384             :     Rose::MemPool::snapshot(oss.str());
    2385             :     alloc_trace_cnt++;
    2386             : #endif
    2387             : 
    2388             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
    2389             : 
    2390           0 :     ALLOC_MUTEX(SgUPC_AccessModifier, unlock);
    2391             : }
    2392             : 
    2393             : // DQ (11/27/2009): I have moved this member function definition to outside of the
    2394             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
    2395             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
    2396             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
    2397             : // Also, note comment below from Robb (copied from the Common.code file).
    2398             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
    2399             : //
    2400             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
    2401             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
    2402             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
    2403             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
    2404             : #if 0
    2405             : void SgUPC_AccessModifier::operator delete(void* pointer) { SgUPC_AccessModifier::operator delete (pointer, sizeof(SgUPC_AccessModifier)); };
    2406             : #endif
    2407             : /* #line 2408 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
    2408             : 
    2409             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
    2410             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
    2411             : // obviously imply C++.
    2412             : 
    2413             : // This implements the support within ROSE for memory pools.  Memory pools
    2414             : // support the most condensed usage of memory within the construction of
    2415             : // and AST. Large blocks of contiguous storage for each RI node is allocated
    2416             : // by a new operator written for each class.
    2417             : 
    2418             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
    2419             :     // User wants multi-thread support and POSIX threads are available.
    2420             : #   include <pthread.h>
    2421             :     static pthread_mutex_t SgSpecialFunctionModifier_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
    2422             : #else
    2423             :      // Cause synchronization to be skipped.
    2424             : #    ifndef ALLOC_MUTEX
    2425             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
    2426             : #    endif
    2427             : #    ifdef _REENTRANT
    2428             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
    2429             : #       ifdef _MSC_VER
    2430             : #           pragma message("POSIX threads are not available; synchronization being skipped")
    2431             : #       else
    2432             : #           warning "POSIX threads are not available; synchronization being skipped"
    2433             : #       endif
    2434             : #    endif
    2435             : #endif
    2436             : 
    2437             : #ifndef ROSE_ALLOC_TRACE
    2438             : #  define ROSE_ALLOC_TRACE 0
    2439             : #endif
    2440             : 
    2441             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
    2442             : #define ROSE_ALLOC_TRACE_CNT
    2443             : #include "memory-pool-snapshot.h"
    2444             : unsigned long alloc_trace_cnt = 0;
    2445             : #endif
    2446             : 
    2447             : #if ROSE_ALLOC_TRACE
    2448             : const unsigned SgSpecialFunctionModifier::pool_size = 5;
    2449             : #else
    2450             : const unsigned SgSpecialFunctionModifier::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
    2451             : #endif
    2452             : 
    2453             : #ifndef ROSE_ALLOC_MEMSET
    2454             : #  define ROSE_ALLOC_MEMSET 0
    2455             : #endif
    2456             : 
    2457             : #ifndef ROSE_PEDANTIC_ALLOC
    2458             : #  define ROSE_PEDANTIC_ALLOC 0
    2459             : #endif
    2460             : 
    2461             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
    2462             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
    2463             : #endif
    2464             : 
    2465             : #if !defined(SGNODE__ALL_POOLS)
    2466             : #define SGNODE__ALL_POOLS
    2467             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
    2468             : #endif
    2469             : 
    2470             : SgSpecialFunctionModifier* SgSpecialFunctionModifier::next_node = nullptr;
    2471             : std::vector<unsigned char*> SgSpecialFunctionModifier::pools;
    2472             : 
    2473             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
    2474             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
    2475             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
    2476             : // around this macro definition rather than each use).
    2477             : #ifndef ALLOC_MUTEX
    2478             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
    2479             :         do {                                                                     \
    2480             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
    2481             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
    2482             :                 abort();                                                         \
    2483             :             }                                                                    \
    2484             :         } while (0);
    2485             : #endif
    2486             : 
    2487             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
    2488             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
    2489             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
    2490             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
    2491             : 
    2492             : /*! \brief New operator for SgSpecialFunctionModifier.
    2493             : 
    2494             :    This new operator implements memory pools to provide most efficent 
    2495             :    use of the heap within construction of large ASTs.
    2496             : 
    2497             : \internal The new and delete operators use the lower level C malloc/free
    2498             :    function calls for performance and to make sure that mixing of malloc/free
    2499             :    and new/delete by the used can be caught more readily.  This may change
    2500             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
    2501             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
    2502             :    deallocate memory allocated using ROSE_MALLOC.
    2503             : */
    2504           0 : void *SgSpecialFunctionModifier::operator new ( size_t Size )
    2505             : {
    2506             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
    2507             :      * returning or throwing an exception. */
    2508           0 :     ALLOC_MUTEX(SgSpecialFunctionModifier, lock);
    2509             : 
    2510             : #if ROSE_ALLOC_TRACE == 2
    2511             : //    printf("SgSpecialFunctionModifier::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgSpecialFunctionModifier::next_node);
    2512             : #endif
    2513             : 
    2514             : #if USE_CPP_NEW_DELETE_OPERATORS
    2515             :     void *mem = ROSE_MALLOC(Size);
    2516             :     ALLOC_MUTEX(SgSpecialFunctionModifier, unlock);
    2517             :     return mem;
    2518             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
    2519             : #if ROSE_PEDANTIC_ALLOC
    2520             :     ROSE_ASSERT(Size == sizeof(SgSpecialFunctionModifier));
    2521             : #else
    2522           0 :     if (Size != sizeof(SgSpecialFunctionModifier)) {
    2523           0 :       void * object = ROSE_MALLOC(Size);
    2524           0 :       ALLOC_MUTEX(SgSpecialFunctionModifier, unlock);
    2525             :       return object;
    2526             :     }
    2527             : #endif
    2528             : 
    2529           0 :     if (SgSpecialFunctionModifier::next_node == nullptr) {
    2530           0 :         SgSpecialFunctionModifier * alloc = (SgSpecialFunctionModifier*) ROSE_MALLOC ( SgSpecialFunctionModifier::pool_size * sizeof(SgSpecialFunctionModifier) );
    2531           0 :         ROSE_ASSERT(alloc != nullptr);
    2532             : 
    2533             : #if ROSE_ALLOC_TRACE == 2
    2534             : //        printf("SgSpecialFunctionModifier::alloc\n  block[%zi] = [ %p , %p [\n", SgSpecialFunctionModifier::pools.size(), alloc, alloc + SgSpecialFunctionModifier::pool_size);
    2535             : #endif
    2536             : 
    2537             : #if ROSE_ALLOC_MEMSET == 1
    2538             : #elif ROSE_ALLOC_MEMSET == 2
    2539             :         memset(alloc, 0x00, SgSpecialFunctionModifier::pool_size * sizeof(SgSpecialFunctionModifier));
    2540             : #elif ROSE_ALLOC_MEMSET == 3
    2541             :         memset(alloc, 0xAA, SgSpecialFunctionModifier::pool_size * sizeof(SgSpecialFunctionModifier));
    2542             : #endif
    2543           0 :         for (unsigned i=0; i < SgSpecialFunctionModifier::pool_size-1; i++) {
    2544           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
    2545             :         }
    2546           0 :         alloc[SgSpecialFunctionModifier::pool_size-1].p_freepointer = nullptr;
    2547             : 
    2548           0 :         SgSpecialFunctionModifier::pools.push_back ( (unsigned char *) alloc );
    2549           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgSpecialFunctionModifier::pool_size * sizeof(SgSpecialFunctionModifier), V_SgSpecialFunctionModifier ) );
    2550           0 :         SgSpecialFunctionModifier::next_node = alloc;
    2551             :     }
    2552           0 :     ROSE_ASSERT(SgSpecialFunctionModifier::next_node != nullptr);
    2553             : 
    2554           0 :     SgSpecialFunctionModifier * object = SgSpecialFunctionModifier::next_node;
    2555           0 :     SgSpecialFunctionModifier::next_node = (SgSpecialFunctionModifier*)(object->p_freepointer);
    2556             : 
    2557             : #if ROSE_ALLOC_TRACE == 2
    2558             :     printf("SgSpecialFunctionModifier::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgSpecialFunctionModifier::next_node);
    2559             : #endif
    2560             : 
    2561           0 :     SgNode * fp = object->p_freepointer;
    2562             : #if ROSE_ALLOC_MEMSET == 1
    2563             : #elif ROSE_ALLOC_MEMSET == 2
    2564             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgSpecialFunctionModifier) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
    2565             : #elif ROSE_ALLOC_MEMSET == 3
    2566             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgSpecialFunctionModifier) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
    2567             : #endif
    2568           0 :     object->p_freepointer = fp;
    2569             : 
    2570             : #if ROSE_ALLOC_TRACE == 2
    2571             : //    printf("SgSpecialFunctionModifier::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgSpecialFunctionModifier::next_node);
    2572             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
    2573             :     Rose::MemPool::snapshot(oss.str());
    2574             :     alloc_trace_cnt++;
    2575             : #endif
    2576             : 
    2577           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
    2578             : 
    2579           0 :     ALLOC_MUTEX(SgSpecialFunctionModifier, unlock);
    2580             : 
    2581             :     return object;
    2582             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
    2583             : }
    2584             : 
    2585             : 
    2586             : 
    2587             : /*! \brief Delete operator for SgSpecialFunctionModifier.
    2588             : 
    2589             :    This delete operator implements deallocation using memory pools to 
    2590             :    provide most efficent use of the heap within construction of large ASTs.
    2591             : 
    2592             : \internal The new and delete operators use the lower level C malloc/free
    2593             :    function calls for performance and to make sure that mixing of malloc/free
    2594             :    and new/delete by the used can be caught more readily.  This may change
    2595             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
    2596             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
    2597             :    deallocate memory allocated using ROSE_MALLOC.
    2598             : */
    2599           0 : void SgSpecialFunctionModifier::operator delete(void *Pointer, size_t Size)
    2600             : {
    2601             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
    2602             :      * or throwing an exception. */
    2603           0 :     ALLOC_MUTEX(SgSpecialFunctionModifier, lock);
    2604             : 
    2605             : #if USE_CPP_NEW_DELETE_OPERATORS
    2606             :     ROSE_FREE(Pointer);
    2607             : #else
    2608             : #if ROSE_PEDANTIC_ALLOC
    2609             :     ROSE_ASSERT(Size == sizeof(SgSpecialFunctionModifier));
    2610             : #else
    2611           0 :     if (Size != sizeof(SgSpecialFunctionModifier)) {
    2612           0 :       ROSE_FREE(Pointer);
    2613           0 :       ALLOC_MUTEX(SgSpecialFunctionModifier, unlock);
    2614             :       return;
    2615             :     }
    2616             : #endif
    2617             : 
    2618           0 :     SgSpecialFunctionModifier * object = (SgSpecialFunctionModifier*) Pointer;
    2619           0 :     ROSE_ASSERT(object != nullptr);
    2620             : 
    2621             : #if ROSE_ALLOC_TRACE == 2
    2622             : //  printf("SgSpecialFunctionModifier::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgSpecialFunctionModifier::next_node);
    2623             :     printf("SgSpecialFunctionModifier::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgSpecialFunctionModifier::next_node);
    2624             : #endif
    2625             : 
    2626             : #if ROSE_PEDANTIC_ALLOC
    2627             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
    2628             : #endif
    2629             : 
    2630             : #if ROSE_ALLOC_MEMSET == 1
    2631             : #elif ROSE_ALLOC_MEMSET == 2
    2632             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgSpecialFunctionModifier) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
    2633             : #elif ROSE_ALLOC_MEMSET == 3
    2634             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgSpecialFunctionModifier) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
    2635             : #endif
    2636             : 
    2637             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
    2638             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
    2639             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
    2640             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
    2641             : #else
    2642           0 :     object->p_freepointer = SgSpecialFunctionModifier::next_node;
    2643           0 :     SgSpecialFunctionModifier::next_node = object;
    2644             : #endif
    2645             : 
    2646             : #if ROSE_ALLOC_TRACE == 2
    2647             : //  printf("SgSpecialFunctionModifier::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgSpecialFunctionModifier::next_node);
    2648             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
    2649             :     Rose::MemPool::snapshot(oss.str());
    2650             :     alloc_trace_cnt++;
    2651             : #endif
    2652             : 
    2653             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
    2654             : 
    2655           0 :     ALLOC_MUTEX(SgSpecialFunctionModifier, unlock);
    2656             : }
    2657             : 
    2658             : // DQ (11/27/2009): I have moved this member function definition to outside of the
    2659             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
    2660             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
    2661             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
    2662             : // Also, note comment below from Robb (copied from the Common.code file).
    2663             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
    2664             : //
    2665             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
    2666             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
    2667             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
    2668             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
    2669             : #if 0
    2670             : void SgSpecialFunctionModifier::operator delete(void* pointer) { SgSpecialFunctionModifier::operator delete (pointer, sizeof(SgSpecialFunctionModifier)); };
    2671             : #endif
    2672             : /* #line 2673 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
    2673             : 
    2674             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
    2675             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
    2676             : // obviously imply C++.
    2677             : 
    2678             : // This implements the support within ROSE for memory pools.  Memory pools
    2679             : // support the most condensed usage of memory within the construction of
    2680             : // and AST. Large blocks of contiguous storage for each RI node is allocated
    2681             : // by a new operator written for each class.
    2682             : 
    2683             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
    2684             :     // User wants multi-thread support and POSIX threads are available.
    2685             : #   include <pthread.h>
    2686             :     static pthread_mutex_t SgElaboratedTypeModifier_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
    2687             : #else
    2688             :      // Cause synchronization to be skipped.
    2689             : #    ifndef ALLOC_MUTEX
    2690             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
    2691             : #    endif
    2692             : #    ifdef _REENTRANT
    2693             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
    2694             : #       ifdef _MSC_VER
    2695             : #           pragma message("POSIX threads are not available; synchronization being skipped")
    2696             : #       else
    2697             : #           warning "POSIX threads are not available; synchronization being skipped"
    2698             : #       endif
    2699             : #    endif
    2700             : #endif
    2701             : 
    2702             : #ifndef ROSE_ALLOC_TRACE
    2703             : #  define ROSE_ALLOC_TRACE 0
    2704             : #endif
    2705             : 
    2706             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
    2707             : #define ROSE_ALLOC_TRACE_CNT
    2708             : #include "memory-pool-snapshot.h"
    2709             : unsigned long alloc_trace_cnt = 0;
    2710             : #endif
    2711             : 
    2712             : #if ROSE_ALLOC_TRACE
    2713             : const unsigned SgElaboratedTypeModifier::pool_size = 5;
    2714             : #else
    2715             : const unsigned SgElaboratedTypeModifier::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
    2716             : #endif
    2717             : 
    2718             : #ifndef ROSE_ALLOC_MEMSET
    2719             : #  define ROSE_ALLOC_MEMSET 0
    2720             : #endif
    2721             : 
    2722             : #ifndef ROSE_PEDANTIC_ALLOC
    2723             : #  define ROSE_PEDANTIC_ALLOC 0
    2724             : #endif
    2725             : 
    2726             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
    2727             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
    2728             : #endif
    2729             : 
    2730             : #if !defined(SGNODE__ALL_POOLS)
    2731             : #define SGNODE__ALL_POOLS
    2732             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
    2733             : #endif
    2734             : 
    2735             : SgElaboratedTypeModifier* SgElaboratedTypeModifier::next_node = nullptr;
    2736             : std::vector<unsigned char*> SgElaboratedTypeModifier::pools;
    2737             : 
    2738             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
    2739             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
    2740             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
    2741             : // around this macro definition rather than each use).
    2742             : #ifndef ALLOC_MUTEX
    2743             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
    2744             :         do {                                                                     \
    2745             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
    2746             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
    2747             :                 abort();                                                         \
    2748             :             }                                                                    \
    2749             :         } while (0);
    2750             : #endif
    2751             : 
    2752             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
    2753             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
    2754             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
    2755             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
    2756             : 
    2757             : /*! \brief New operator for SgElaboratedTypeModifier.
    2758             : 
    2759             :    This new operator implements memory pools to provide most efficent 
    2760             :    use of the heap within construction of large ASTs.
    2761             : 
    2762             : \internal The new and delete operators use the lower level C malloc/free
    2763             :    function calls for performance and to make sure that mixing of malloc/free
    2764             :    and new/delete by the used can be caught more readily.  This may change
    2765             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
    2766             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
    2767             :    deallocate memory allocated using ROSE_MALLOC.
    2768             : */
    2769           0 : void *SgElaboratedTypeModifier::operator new ( size_t Size )
    2770             : {
    2771             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
    2772             :      * returning or throwing an exception. */
    2773           0 :     ALLOC_MUTEX(SgElaboratedTypeModifier, lock);
    2774             : 
    2775             : #if ROSE_ALLOC_TRACE == 2
    2776             : //    printf("SgElaboratedTypeModifier::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgElaboratedTypeModifier::next_node);
    2777             : #endif
    2778             : 
    2779             : #if USE_CPP_NEW_DELETE_OPERATORS
    2780             :     void *mem = ROSE_MALLOC(Size);
    2781             :     ALLOC_MUTEX(SgElaboratedTypeModifier, unlock);
    2782             :     return mem;
    2783             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
    2784             : #if ROSE_PEDANTIC_ALLOC
    2785             :     ROSE_ASSERT(Size == sizeof(SgElaboratedTypeModifier));
    2786             : #else
    2787           0 :     if (Size != sizeof(SgElaboratedTypeModifier)) {
    2788           0 :       void * object = ROSE_MALLOC(Size);
    2789           0 :       ALLOC_MUTEX(SgElaboratedTypeModifier, unlock);
    2790             :       return object;
    2791             :     }
    2792             : #endif
    2793             : 
    2794           0 :     if (SgElaboratedTypeModifier::next_node == nullptr) {
    2795           0 :         SgElaboratedTypeModifier * alloc = (SgElaboratedTypeModifier*) ROSE_MALLOC ( SgElaboratedTypeModifier::pool_size * sizeof(SgElaboratedTypeModifier) );
    2796           0 :         ROSE_ASSERT(alloc != nullptr);
    2797             : 
    2798             : #if ROSE_ALLOC_TRACE == 2
    2799             : //        printf("SgElaboratedTypeModifier::alloc\n  block[%zi] = [ %p , %p [\n", SgElaboratedTypeModifier::pools.size(), alloc, alloc + SgElaboratedTypeModifier::pool_size);
    2800             : #endif
    2801             : 
    2802             : #if ROSE_ALLOC_MEMSET == 1
    2803             : #elif ROSE_ALLOC_MEMSET == 2
    2804             :         memset(alloc, 0x00, SgElaboratedTypeModifier::pool_size * sizeof(SgElaboratedTypeModifier));
    2805             : #elif ROSE_ALLOC_MEMSET == 3
    2806             :         memset(alloc, 0xAA, SgElaboratedTypeModifier::pool_size * sizeof(SgElaboratedTypeModifier));
    2807             : #endif
    2808           0 :         for (unsigned i=0; i < SgElaboratedTypeModifier::pool_size-1; i++) {
    2809           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
    2810             :         }
    2811           0 :         alloc[SgElaboratedTypeModifier::pool_size-1].p_freepointer = nullptr;
    2812             : 
    2813           0 :         SgElaboratedTypeModifier::pools.push_back ( (unsigned char *) alloc );
    2814           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgElaboratedTypeModifier::pool_size * sizeof(SgElaboratedTypeModifier), V_SgElaboratedTypeModifier ) );
    2815           0 :         SgElaboratedTypeModifier::next_node = alloc;
    2816             :     }
    2817           0 :     ROSE_ASSERT(SgElaboratedTypeModifier::next_node != nullptr);
    2818             : 
    2819           0 :     SgElaboratedTypeModifier * object = SgElaboratedTypeModifier::next_node;
    2820           0 :     SgElaboratedTypeModifier::next_node = (SgElaboratedTypeModifier*)(object->p_freepointer);
    2821             : 
    2822             : #if ROSE_ALLOC_TRACE == 2
    2823             :     printf("SgElaboratedTypeModifier::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgElaboratedTypeModifier::next_node);
    2824             : #endif
    2825             : 
    2826           0 :     SgNode * fp = object->p_freepointer;
    2827             : #if ROSE_ALLOC_MEMSET == 1
    2828             : #elif ROSE_ALLOC_MEMSET == 2
    2829             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgElaboratedTypeModifier) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
    2830             : #elif ROSE_ALLOC_MEMSET == 3
    2831             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgElaboratedTypeModifier) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
    2832             : #endif
    2833           0 :     object->p_freepointer = fp;
    2834             : 
    2835             : #if ROSE_ALLOC_TRACE == 2
    2836             : //    printf("SgElaboratedTypeModifier::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgElaboratedTypeModifier::next_node);
    2837             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
    2838             :     Rose::MemPool::snapshot(oss.str());
    2839             :     alloc_trace_cnt++;
    2840             : #endif
    2841             : 
    2842           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
    2843             : 
    2844           0 :     ALLOC_MUTEX(SgElaboratedTypeModifier, unlock);
    2845             : 
    2846             :     return object;
    2847             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
    2848             : }
    2849             : 
    2850             : 
    2851             : 
    2852             : /*! \brief Delete operator for SgElaboratedTypeModifier.
    2853             : 
    2854             :    This delete operator implements deallocation using memory pools to 
    2855             :    provide most efficent use of the heap within construction of large ASTs.
    2856             : 
    2857             : \internal The new and delete operators use the lower level C malloc/free
    2858             :    function calls for performance and to make sure that mixing of malloc/free
    2859             :    and new/delete by the used can be caught more readily.  This may change
    2860             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
    2861             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
    2862             :    deallocate memory allocated using ROSE_MALLOC.
    2863             : */
    2864           0 : void SgElaboratedTypeModifier::operator delete(void *Pointer, size_t Size)
    2865             : {
    2866             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
    2867             :      * or throwing an exception. */
    2868           0 :     ALLOC_MUTEX(SgElaboratedTypeModifier, lock);
    2869             : 
    2870             : #if USE_CPP_NEW_DELETE_OPERATORS
    2871             :     ROSE_FREE(Pointer);
    2872             : #else
    2873             : #if ROSE_PEDANTIC_ALLOC
    2874             :     ROSE_ASSERT(Size == sizeof(SgElaboratedTypeModifier));
    2875             : #else
    2876           0 :     if (Size != sizeof(SgElaboratedTypeModifier)) {
    2877           0 :       ROSE_FREE(Pointer);
    2878           0 :       ALLOC_MUTEX(SgElaboratedTypeModifier, unlock);
    2879             :       return;
    2880             :     }
    2881             : #endif
    2882             : 
    2883           0 :     SgElaboratedTypeModifier * object = (SgElaboratedTypeModifier*) Pointer;
    2884           0 :     ROSE_ASSERT(object != nullptr);
    2885             : 
    2886             : #if ROSE_ALLOC_TRACE == 2
    2887             : //  printf("SgElaboratedTypeModifier::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgElaboratedTypeModifier::next_node);
    2888             :     printf("SgElaboratedTypeModifier::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgElaboratedTypeModifier::next_node);
    2889             : #endif
    2890             : 
    2891             : #if ROSE_PEDANTIC_ALLOC
    2892             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
    2893             : #endif
    2894             : 
    2895             : #if ROSE_ALLOC_MEMSET == 1
    2896             : #elif ROSE_ALLOC_MEMSET == 2
    2897             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgElaboratedTypeModifier) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
    2898             : #elif ROSE_ALLOC_MEMSET == 3
    2899             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgElaboratedTypeModifier) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
    2900             : #endif
    2901             : 
    2902             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
    2903             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
    2904             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
    2905             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
    2906             : #else
    2907           0 :     object->p_freepointer = SgElaboratedTypeModifier::next_node;
    2908           0 :     SgElaboratedTypeModifier::next_node = object;
    2909             : #endif
    2910             : 
    2911             : #if ROSE_ALLOC_TRACE == 2
    2912             : //  printf("SgElaboratedTypeModifier::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgElaboratedTypeModifier::next_node);
    2913             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
    2914             :     Rose::MemPool::snapshot(oss.str());
    2915             :     alloc_trace_cnt++;
    2916             : #endif
    2917             : 
    2918             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
    2919             : 
    2920           0 :     ALLOC_MUTEX(SgElaboratedTypeModifier, unlock);
    2921             : }
    2922             : 
    2923             : // DQ (11/27/2009): I have moved this member function definition to outside of the
    2924             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
    2925             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
    2926             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
    2927             : // Also, note comment below from Robb (copied from the Common.code file).
    2928             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
    2929             : //
    2930             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
    2931             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
    2932             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
    2933             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
    2934             : #if 0
    2935             : void SgElaboratedTypeModifier::operator delete(void* pointer) { SgElaboratedTypeModifier::operator delete (pointer, sizeof(SgElaboratedTypeModifier)); };
    2936             : #endif
    2937             : /* #line 2938 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
    2938             : 
    2939             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
    2940             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
    2941             : // obviously imply C++.
    2942             : 
    2943             : // This implements the support within ROSE for memory pools.  Memory pools
    2944             : // support the most condensed usage of memory within the construction of
    2945             : // and AST. Large blocks of contiguous storage for each RI node is allocated
    2946             : // by a new operator written for each class.
    2947             : 
    2948             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
    2949             :     // User wants multi-thread support and POSIX threads are available.
    2950             : #   include <pthread.h>
    2951             :     static pthread_mutex_t SgLinkageModifier_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
    2952             : #else
    2953             :      // Cause synchronization to be skipped.
    2954             : #    ifndef ALLOC_MUTEX
    2955             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
    2956             : #    endif
    2957             : #    ifdef _REENTRANT
    2958             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
    2959             : #       ifdef _MSC_VER
    2960             : #           pragma message("POSIX threads are not available; synchronization being skipped")
    2961             : #       else
    2962             : #           warning "POSIX threads are not available; synchronization being skipped"
    2963             : #       endif
    2964             : #    endif
    2965             : #endif
    2966             : 
    2967             : #ifndef ROSE_ALLOC_TRACE
    2968             : #  define ROSE_ALLOC_TRACE 0
    2969             : #endif
    2970             : 
    2971             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
    2972             : #define ROSE_ALLOC_TRACE_CNT
    2973             : #include "memory-pool-snapshot.h"
    2974             : unsigned long alloc_trace_cnt = 0;
    2975             : #endif
    2976             : 
    2977             : #if ROSE_ALLOC_TRACE
    2978             : const unsigned SgLinkageModifier::pool_size = 5;
    2979             : #else
    2980             : const unsigned SgLinkageModifier::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
    2981             : #endif
    2982             : 
    2983             : #ifndef ROSE_ALLOC_MEMSET
    2984             : #  define ROSE_ALLOC_MEMSET 0
    2985             : #endif
    2986             : 
    2987             : #ifndef ROSE_PEDANTIC_ALLOC
    2988             : #  define ROSE_PEDANTIC_ALLOC 0
    2989             : #endif
    2990             : 
    2991             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
    2992             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
    2993             : #endif
    2994             : 
    2995             : #if !defined(SGNODE__ALL_POOLS)
    2996             : #define SGNODE__ALL_POOLS
    2997             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
    2998             : #endif
    2999             : 
    3000             : SgLinkageModifier* SgLinkageModifier::next_node = nullptr;
    3001             : std::vector<unsigned char*> SgLinkageModifier::pools;
    3002             : 
    3003             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
    3004             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
    3005             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
    3006             : // around this macro definition rather than each use).
    3007             : #ifndef ALLOC_MUTEX
    3008             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
    3009             :         do {                                                                     \
    3010             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
    3011             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
    3012             :                 abort();                                                         \
    3013             :             }                                                                    \
    3014             :         } while (0);
    3015             : #endif
    3016             : 
    3017             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
    3018             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
    3019             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
    3020             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
    3021             : 
    3022             : /*! \brief New operator for SgLinkageModifier.
    3023             : 
    3024             :    This new operator implements memory pools to provide most efficent 
    3025             :    use of the heap within construction of large ASTs.
    3026             : 
    3027             : \internal The new and delete operators use the lower level C malloc/free
    3028             :    function calls for performance and to make sure that mixing of malloc/free
    3029             :    and new/delete by the used can be caught more readily.  This may change
    3030             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
    3031             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
    3032             :    deallocate memory allocated using ROSE_MALLOC.
    3033             : */
    3034           0 : void *SgLinkageModifier::operator new ( size_t Size )
    3035             : {
    3036             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
    3037             :      * returning or throwing an exception. */
    3038           0 :     ALLOC_MUTEX(SgLinkageModifier, lock);
    3039             : 
    3040             : #if ROSE_ALLOC_TRACE == 2
    3041             : //    printf("SgLinkageModifier::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgLinkageModifier::next_node);
    3042             : #endif
    3043             : 
    3044             : #if USE_CPP_NEW_DELETE_OPERATORS
    3045             :     void *mem = ROSE_MALLOC(Size);
    3046             :     ALLOC_MUTEX(SgLinkageModifier, unlock);
    3047             :     return mem;
    3048             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
    3049             : #if ROSE_PEDANTIC_ALLOC
    3050             :     ROSE_ASSERT(Size == sizeof(SgLinkageModifier));
    3051             : #else
    3052           0 :     if (Size != sizeof(SgLinkageModifier)) {
    3053           0 :       void * object = ROSE_MALLOC(Size);
    3054           0 :       ALLOC_MUTEX(SgLinkageModifier, unlock);
    3055             :       return object;
    3056             :     }
    3057             : #endif
    3058             : 
    3059           0 :     if (SgLinkageModifier::next_node == nullptr) {
    3060           0 :         SgLinkageModifier * alloc = (SgLinkageModifier*) ROSE_MALLOC ( SgLinkageModifier::pool_size * sizeof(SgLinkageModifier) );
    3061           0 :         ROSE_ASSERT(alloc != nullptr);
    3062             : 
    3063             : #if ROSE_ALLOC_TRACE == 2
    3064             : //        printf("SgLinkageModifier::alloc\n  block[%zi] = [ %p , %p [\n", SgLinkageModifier::pools.size(), alloc, alloc + SgLinkageModifier::pool_size);
    3065             : #endif
    3066             : 
    3067             : #if ROSE_ALLOC_MEMSET == 1
    3068             : #elif ROSE_ALLOC_MEMSET == 2
    3069             :         memset(alloc, 0x00, SgLinkageModifier::pool_size * sizeof(SgLinkageModifier));
    3070             : #elif ROSE_ALLOC_MEMSET == 3
    3071             :         memset(alloc, 0xAA, SgLinkageModifier::pool_size * sizeof(SgLinkageModifier));
    3072             : #endif
    3073           0 :         for (unsigned i=0; i < SgLinkageModifier::pool_size-1; i++) {
    3074           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
    3075             :         }
    3076           0 :         alloc[SgLinkageModifier::pool_size-1].p_freepointer = nullptr;
    3077             : 
    3078           0 :         SgLinkageModifier::pools.push_back ( (unsigned char *) alloc );
    3079           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgLinkageModifier::pool_size * sizeof(SgLinkageModifier), V_SgLinkageModifier ) );
    3080           0 :         SgLinkageModifier::next_node = alloc;
    3081             :     }
    3082           0 :     ROSE_ASSERT(SgLinkageModifier::next_node != nullptr);
    3083             : 
    3084           0 :     SgLinkageModifier * object = SgLinkageModifier::next_node;
    3085           0 :     SgLinkageModifier::next_node = (SgLinkageModifier*)(object->p_freepointer);
    3086             : 
    3087             : #if ROSE_ALLOC_TRACE == 2
    3088             :     printf("SgLinkageModifier::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgLinkageModifier::next_node);
    3089             : #endif
    3090             : 
    3091           0 :     SgNode * fp = object->p_freepointer;
    3092             : #if ROSE_ALLOC_MEMSET == 1
    3093             : #elif ROSE_ALLOC_MEMSET == 2
    3094             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgLinkageModifier) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
    3095             : #elif ROSE_ALLOC_MEMSET == 3
    3096             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgLinkageModifier) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
    3097             : #endif
    3098           0 :     object->p_freepointer = fp;
    3099             : 
    3100             : #if ROSE_ALLOC_TRACE == 2
    3101             : //    printf("SgLinkageModifier::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgLinkageModifier::next_node);
    3102             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
    3103             :     Rose::MemPool::snapshot(oss.str());
    3104             :     alloc_trace_cnt++;
    3105             : #endif
    3106             : 
    3107           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
    3108             : 
    3109           0 :     ALLOC_MUTEX(SgLinkageModifier, unlock);
    3110             : 
    3111             :     return object;
    3112             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
    3113             : }
    3114             : 
    3115             : 
    3116             : 
    3117             : /*! \brief Delete operator for SgLinkageModifier.
    3118             : 
    3119             :    This delete operator implements deallocation using memory pools to 
    3120             :    provide most efficent use of the heap within construction of large ASTs.
    3121             : 
    3122             : \internal The new and delete operators use the lower level C malloc/free
    3123             :    function calls for performance and to make sure that mixing of malloc/free
    3124             :    and new/delete by the used can be caught more readily.  This may change
    3125             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
    3126             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
    3127             :    deallocate memory allocated using ROSE_MALLOC.
    3128             : */
    3129           0 : void SgLinkageModifier::operator delete(void *Pointer, size_t Size)
    3130             : {
    3131             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
    3132             :      * or throwing an exception. */
    3133           0 :     ALLOC_MUTEX(SgLinkageModifier, lock);
    3134             : 
    3135             : #if USE_CPP_NEW_DELETE_OPERATORS
    3136             :     ROSE_FREE(Pointer);
    3137             : #else
    3138             : #if ROSE_PEDANTIC_ALLOC
    3139             :     ROSE_ASSERT(Size == sizeof(SgLinkageModifier));
    3140             : #else
    3141           0 :     if (Size != sizeof(SgLinkageModifier)) {
    3142           0 :       ROSE_FREE(Pointer);
    3143           0 :       ALLOC_MUTEX(SgLinkageModifier, unlock);
    3144             :       return;
    3145             :     }
    3146             : #endif
    3147             : 
    3148           0 :     SgLinkageModifier * object = (SgLinkageModifier*) Pointer;
    3149           0 :     ROSE_ASSERT(object != nullptr);
    3150             : 
    3151             : #if ROSE_ALLOC_TRACE == 2
    3152             : //  printf("SgLinkageModifier::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgLinkageModifier::next_node);
    3153             :     printf("SgLinkageModifier::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgLinkageModifier::next_node);
    3154             : #endif
    3155             : 
    3156             : #if ROSE_PEDANTIC_ALLOC
    3157             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
    3158             : #endif
    3159             : 
    3160             : #if ROSE_ALLOC_MEMSET == 1
    3161             : #elif ROSE_ALLOC_MEMSET == 2
    3162             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgLinkageModifier) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
    3163             : #elif ROSE_ALLOC_MEMSET == 3
    3164             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgLinkageModifier) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
    3165             : #endif
    3166             : 
    3167             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
    3168             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
    3169             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
    3170             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
    3171             : #else
    3172           0 :     object->p_freepointer = SgLinkageModifier::next_node;
    3173           0 :     SgLinkageModifier::next_node = object;
    3174             : #endif
    3175             : 
    3176             : #if ROSE_ALLOC_TRACE == 2
    3177             : //  printf("SgLinkageModifier::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgLinkageModifier::next_node);
    3178             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
    3179             :     Rose::MemPool::snapshot(oss.str());
    3180             :     alloc_trace_cnt++;
    3181             : #endif
    3182             : 
    3183             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
    3184             : 
    3185           0 :     ALLOC_MUTEX(SgLinkageModifier, unlock);
    3186             : }
    3187             : 
    3188             : // DQ (11/27/2009): I have moved this member function definition to outside of the
    3189             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
    3190             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
    3191             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
    3192             : // Also, note comment below from Robb (copied from the Common.code file).
    3193             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
    3194             : //
    3195             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
    3196             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
    3197             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
    3198             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
    3199             : #if 0
    3200             : void SgLinkageModifier::operator delete(void* pointer) { SgLinkageModifier::operator delete (pointer, sizeof(SgLinkageModifier)); };
    3201             : #endif
    3202             : /* #line 3203 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
    3203             : 
    3204             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
    3205             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
    3206             : // obviously imply C++.
    3207             : 
    3208             : // This implements the support within ROSE for memory pools.  Memory pools
    3209             : // support the most condensed usage of memory within the construction of
    3210             : // and AST. Large blocks of contiguous storage for each RI node is allocated
    3211             : // by a new operator written for each class.
    3212             : 
    3213             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
    3214             :     // User wants multi-thread support and POSIX threads are available.
    3215             : #   include <pthread.h>
    3216             :     static pthread_mutex_t SgBaseClassModifier_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
    3217             : #else
    3218             :      // Cause synchronization to be skipped.
    3219             : #    ifndef ALLOC_MUTEX
    3220             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
    3221             : #    endif
    3222             : #    ifdef _REENTRANT
    3223             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
    3224             : #       ifdef _MSC_VER
    3225             : #           pragma message("POSIX threads are not available; synchronization being skipped")
    3226             : #       else
    3227             : #           warning "POSIX threads are not available; synchronization being skipped"
    3228             : #       endif
    3229             : #    endif
    3230             : #endif
    3231             : 
    3232             : #ifndef ROSE_ALLOC_TRACE
    3233             : #  define ROSE_ALLOC_TRACE 0
    3234             : #endif
    3235             : 
    3236             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
    3237             : #define ROSE_ALLOC_TRACE_CNT
    3238             : #include "memory-pool-snapshot.h"
    3239             : unsigned long alloc_trace_cnt = 0;
    3240             : #endif
    3241             : 
    3242             : #if ROSE_ALLOC_TRACE
    3243             : const unsigned SgBaseClassModifier::pool_size = 5;
    3244             : #else
    3245             : const unsigned SgBaseClassModifier::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
    3246             : #endif
    3247             : 
    3248             : #ifndef ROSE_ALLOC_MEMSET
    3249             : #  define ROSE_ALLOC_MEMSET 0
    3250             : #endif
    3251             : 
    3252             : #ifndef ROSE_PEDANTIC_ALLOC
    3253             : #  define ROSE_PEDANTIC_ALLOC 0
    3254             : #endif
    3255             : 
    3256             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
    3257             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
    3258             : #endif
    3259             : 
    3260             : #if !defined(SGNODE__ALL_POOLS)
    3261             : #define SGNODE__ALL_POOLS
    3262             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
    3263             : #endif
    3264             : 
    3265             : SgBaseClassModifier* SgBaseClassModifier::next_node = nullptr;
    3266             : std::vector<unsigned char*> SgBaseClassModifier::pools;
    3267             : 
    3268             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
    3269             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
    3270             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
    3271             : // around this macro definition rather than each use).
    3272             : #ifndef ALLOC_MUTEX
    3273             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
    3274             :         do {                                                                     \
    3275             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
    3276             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
    3277             :                 abort();                                                         \
    3278             :             }                                                                    \
    3279             :         } while (0);
    3280             : #endif
    3281             : 
    3282             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
    3283             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
    3284             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
    3285             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
    3286             : 
    3287             : /*! \brief New operator for SgBaseClassModifier.
    3288             : 
    3289             :    This new operator implements memory pools to provide most efficent 
    3290             :    use of the heap within construction of large ASTs.
    3291             : 
    3292             : \internal The new and delete operators use the lower level C malloc/free
    3293             :    function calls for performance and to make sure that mixing of malloc/free
    3294             :    and new/delete by the used can be caught more readily.  This may change
    3295             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
    3296             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
    3297             :    deallocate memory allocated using ROSE_MALLOC.
    3298             : */
    3299        6345 : void *SgBaseClassModifier::operator new ( size_t Size )
    3300             : {
    3301             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
    3302             :      * returning or throwing an exception. */
    3303        6345 :     ALLOC_MUTEX(SgBaseClassModifier, lock);
    3304             : 
    3305             : #if ROSE_ALLOC_TRACE == 2
    3306             : //    printf("SgBaseClassModifier::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgBaseClassModifier::next_node);
    3307             : #endif
    3308             : 
    3309             : #if USE_CPP_NEW_DELETE_OPERATORS
    3310             :     void *mem = ROSE_MALLOC(Size);
    3311             :     ALLOC_MUTEX(SgBaseClassModifier, unlock);
    3312             :     return mem;
    3313             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
    3314             : #if ROSE_PEDANTIC_ALLOC
    3315             :     ROSE_ASSERT(Size == sizeof(SgBaseClassModifier));
    3316             : #else
    3317        6345 :     if (Size != sizeof(SgBaseClassModifier)) {
    3318           0 :       void * object = ROSE_MALLOC(Size);
    3319           0 :       ALLOC_MUTEX(SgBaseClassModifier, unlock);
    3320             :       return object;
    3321             :     }
    3322             : #endif
    3323             : 
    3324        6345 :     if (SgBaseClassModifier::next_node == nullptr) {
    3325          10 :         SgBaseClassModifier * alloc = (SgBaseClassModifier*) ROSE_MALLOC ( SgBaseClassModifier::pool_size * sizeof(SgBaseClassModifier) );
    3326          10 :         ROSE_ASSERT(alloc != nullptr);
    3327             : 
    3328             : #if ROSE_ALLOC_TRACE == 2
    3329             : //        printf("SgBaseClassModifier::alloc\n  block[%zi] = [ %p , %p [\n", SgBaseClassModifier::pools.size(), alloc, alloc + SgBaseClassModifier::pool_size);
    3330             : #endif
    3331             : 
    3332             : #if ROSE_ALLOC_MEMSET == 1
    3333             : #elif ROSE_ALLOC_MEMSET == 2
    3334             :         memset(alloc, 0x00, SgBaseClassModifier::pool_size * sizeof(SgBaseClassModifier));
    3335             : #elif ROSE_ALLOC_MEMSET == 3
    3336             :         memset(alloc, 0xAA, SgBaseClassModifier::pool_size * sizeof(SgBaseClassModifier));
    3337             : #endif
    3338       20000 :         for (unsigned i=0; i < SgBaseClassModifier::pool_size-1; i++) {
    3339       19990 :           alloc[i].p_freepointer = &(alloc[i+1]);
    3340             :         }
    3341          10 :         alloc[SgBaseClassModifier::pool_size-1].p_freepointer = nullptr;
    3342             : 
    3343          10 :         SgBaseClassModifier::pools.push_back ( (unsigned char *) alloc );
    3344          10 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgBaseClassModifier::pool_size * sizeof(SgBaseClassModifier), V_SgBaseClassModifier ) );
    3345          10 :         SgBaseClassModifier::next_node = alloc;
    3346             :     }
    3347        6345 :     ROSE_ASSERT(SgBaseClassModifier::next_node != nullptr);
    3348             : 
    3349        6345 :     SgBaseClassModifier * object = SgBaseClassModifier::next_node;
    3350        6345 :     SgBaseClassModifier::next_node = (SgBaseClassModifier*)(object->p_freepointer);
    3351             : 
    3352             : #if ROSE_ALLOC_TRACE == 2
    3353             :     printf("SgBaseClassModifier::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgBaseClassModifier::next_node);
    3354             : #endif
    3355             : 
    3356        6345 :     SgNode * fp = object->p_freepointer;
    3357             : #if ROSE_ALLOC_MEMSET == 1
    3358             : #elif ROSE_ALLOC_MEMSET == 2
    3359             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgBaseClassModifier) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
    3360             : #elif ROSE_ALLOC_MEMSET == 3
    3361             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgBaseClassModifier) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
    3362             : #endif
    3363        6345 :     object->p_freepointer = fp;
    3364             : 
    3365             : #if ROSE_ALLOC_TRACE == 2
    3366             : //    printf("SgBaseClassModifier::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgBaseClassModifier::next_node);
    3367             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
    3368             :     Rose::MemPool::snapshot(oss.str());
    3369             :     alloc_trace_cnt++;
    3370             : #endif
    3371             : 
    3372        6345 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
    3373             : 
    3374        6345 :     ALLOC_MUTEX(SgBaseClassModifier, unlock);
    3375             : 
    3376             :     return object;
    3377             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
    3378             : }
    3379             : 
    3380             : 
    3381             : 
    3382             : /*! \brief Delete operator for SgBaseClassModifier.
    3383             : 
    3384             :    This delete operator implements deallocation using memory pools to 
    3385             :    provide most efficent use of the heap within construction of large ASTs.
    3386             : 
    3387             : \internal The new and delete operators use the lower level C malloc/free
    3388             :    function calls for performance and to make sure that mixing of malloc/free
    3389             :    and new/delete by the used can be caught more readily.  This may change
    3390             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
    3391             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
    3392             :    deallocate memory allocated using ROSE_MALLOC.
    3393             : */
    3394        1240 : void SgBaseClassModifier::operator delete(void *Pointer, size_t Size)
    3395             : {
    3396             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
    3397             :      * or throwing an exception. */
    3398        1240 :     ALLOC_MUTEX(SgBaseClassModifier, lock);
    3399             : 
    3400             : #if USE_CPP_NEW_DELETE_OPERATORS
    3401             :     ROSE_FREE(Pointer);
    3402             : #else
    3403             : #if ROSE_PEDANTIC_ALLOC
    3404             :     ROSE_ASSERT(Size == sizeof(SgBaseClassModifier));
    3405             : #else
    3406        1240 :     if (Size != sizeof(SgBaseClassModifier)) {
    3407           0 :       ROSE_FREE(Pointer);
    3408           0 :       ALLOC_MUTEX(SgBaseClassModifier, unlock);
    3409             :       return;
    3410             :     }
    3411             : #endif
    3412             : 
    3413        1240 :     SgBaseClassModifier * object = (SgBaseClassModifier*) Pointer;
    3414        1240 :     ROSE_ASSERT(object != nullptr);
    3415             : 
    3416             : #if ROSE_ALLOC_TRACE == 2
    3417             : //  printf("SgBaseClassModifier::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgBaseClassModifier::next_node);
    3418             :     printf("SgBaseClassModifier::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgBaseClassModifier::next_node);
    3419             : #endif
    3420             : 
    3421             : #if ROSE_PEDANTIC_ALLOC
    3422             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
    3423             : #endif
    3424             : 
    3425             : #if ROSE_ALLOC_MEMSET == 1
    3426             : #elif ROSE_ALLOC_MEMSET == 2
    3427             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgBaseClassModifier) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
    3428             : #elif ROSE_ALLOC_MEMSET == 3
    3429             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgBaseClassModifier) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
    3430             : #endif
    3431             : 
    3432             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
    3433             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
    3434             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
    3435             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
    3436             : #else
    3437        1240 :     object->p_freepointer = SgBaseClassModifier::next_node;
    3438        1240 :     SgBaseClassModifier::next_node = object;
    3439             : #endif
    3440             : 
    3441             : #if ROSE_ALLOC_TRACE == 2
    3442             : //  printf("SgBaseClassModifier::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgBaseClassModifier::next_node);
    3443             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
    3444             :     Rose::MemPool::snapshot(oss.str());
    3445             :     alloc_trace_cnt++;
    3446             : #endif
    3447             : 
    3448             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
    3449             : 
    3450        1240 :     ALLOC_MUTEX(SgBaseClassModifier, unlock);
    3451             : }
    3452             : 
    3453             : // DQ (11/27/2009): I have moved this member function definition to outside of the
    3454             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
    3455             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
    3456             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
    3457             : // Also, note comment below from Robb (copied from the Common.code file).
    3458             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
    3459             : //
    3460             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
    3461             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
    3462             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
    3463             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
    3464             : #if 0
    3465             : void SgBaseClassModifier::operator delete(void* pointer) { SgBaseClassModifier::operator delete (pointer, sizeof(SgBaseClassModifier)); };
    3466             : #endif
    3467             : /* #line 3468 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
    3468             : 
    3469             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
    3470             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
    3471             : // obviously imply C++.
    3472             : 
    3473             : // This implements the support within ROSE for memory pools.  Memory pools
    3474             : // support the most condensed usage of memory within the construction of
    3475             : // and AST. Large blocks of contiguous storage for each RI node is allocated
    3476             : // by a new operator written for each class.
    3477             : 
    3478             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
    3479             :     // User wants multi-thread support and POSIX threads are available.
    3480             : #   include <pthread.h>
    3481             :     static pthread_mutex_t SgStructureModifier_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
    3482             : #else
    3483             :      // Cause synchronization to be skipped.
    3484             : #    ifndef ALLOC_MUTEX
    3485             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
    3486             : #    endif
    3487             : #    ifdef _REENTRANT
    3488             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
    3489             : #       ifdef _MSC_VER
    3490             : #           pragma message("POSIX threads are not available; synchronization being skipped")
    3491             : #       else
    3492             : #           warning "POSIX threads are not available; synchronization being skipped"
    3493             : #       endif
    3494             : #    endif
    3495             : #endif
    3496             : 
    3497             : #ifndef ROSE_ALLOC_TRACE
    3498             : #  define ROSE_ALLOC_TRACE 0
    3499             : #endif
    3500             : 
    3501             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
    3502             : #define ROSE_ALLOC_TRACE_CNT
    3503             : #include "memory-pool-snapshot.h"
    3504             : unsigned long alloc_trace_cnt = 0;
    3505             : #endif
    3506             : 
    3507             : #if ROSE_ALLOC_TRACE
    3508             : const unsigned SgStructureModifier::pool_size = 5;
    3509             : #else
    3510             : const unsigned SgStructureModifier::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
    3511             : #endif
    3512             : 
    3513             : #ifndef ROSE_ALLOC_MEMSET
    3514             : #  define ROSE_ALLOC_MEMSET 0
    3515             : #endif
    3516             : 
    3517             : #ifndef ROSE_PEDANTIC_ALLOC
    3518             : #  define ROSE_PEDANTIC_ALLOC 0
    3519             : #endif
    3520             : 
    3521             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
    3522             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
    3523             : #endif
    3524             : 
    3525             : #if !defined(SGNODE__ALL_POOLS)
    3526             : #define SGNODE__ALL_POOLS
    3527             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
    3528             : #endif
    3529             : 
    3530             : SgStructureModifier* SgStructureModifier::next_node = nullptr;
    3531             : std::vector<unsigned char*> SgStructureModifier::pools;
    3532             : 
    3533             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
    3534             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
    3535             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
    3536             : // around this macro definition rather than each use).
    3537             : #ifndef ALLOC_MUTEX
    3538             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
    3539             :         do {                                                                     \
    3540             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
    3541             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
    3542             :                 abort();                                                         \
    3543             :             }                                                                    \
    3544             :         } while (0);
    3545             : #endif
    3546             : 
    3547             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
    3548             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
    3549             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
    3550             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
    3551             : 
    3552             : /*! \brief New operator for SgStructureModifier.
    3553             : 
    3554             :    This new operator implements memory pools to provide most efficent 
    3555             :    use of the heap within construction of large ASTs.
    3556             : 
    3557             : \internal The new and delete operators use the lower level C malloc/free
    3558             :    function calls for performance and to make sure that mixing of malloc/free
    3559             :    and new/delete by the used can be caught more readily.  This may change
    3560             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
    3561             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
    3562             :    deallocate memory allocated using ROSE_MALLOC.
    3563             : */
    3564           0 : void *SgStructureModifier::operator new ( size_t Size )
    3565             : {
    3566             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
    3567             :      * returning or throwing an exception. */
    3568           0 :     ALLOC_MUTEX(SgStructureModifier, lock);
    3569             : 
    3570             : #if ROSE_ALLOC_TRACE == 2
    3571             : //    printf("SgStructureModifier::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgStructureModifier::next_node);
    3572             : #endif
    3573             : 
    3574             : #if USE_CPP_NEW_DELETE_OPERATORS
    3575             :     void *mem = ROSE_MALLOC(Size);
    3576             :     ALLOC_MUTEX(SgStructureModifier, unlock);
    3577             :     return mem;
    3578             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
    3579             : #if ROSE_PEDANTIC_ALLOC
    3580             :     ROSE_ASSERT(Size == sizeof(SgStructureModifier));
    3581             : #else
    3582           0 :     if (Size != sizeof(SgStructureModifier)) {
    3583           0 :       void * object = ROSE_MALLOC(Size);
    3584           0 :       ALLOC_MUTEX(SgStructureModifier, unlock);
    3585             :       return object;
    3586             :     }
    3587             : #endif
    3588             : 
    3589           0 :     if (SgStructureModifier::next_node == nullptr) {
    3590           0 :         SgStructureModifier * alloc = (SgStructureModifier*) ROSE_MALLOC ( SgStructureModifier::pool_size * sizeof(SgStructureModifier) );
    3591           0 :         ROSE_ASSERT(alloc != nullptr);
    3592             : 
    3593             : #if ROSE_ALLOC_TRACE == 2
    3594             : //        printf("SgStructureModifier::alloc\n  block[%zi] = [ %p , %p [\n", SgStructureModifier::pools.size(), alloc, alloc + SgStructureModifier::pool_size);
    3595             : #endif
    3596             : 
    3597             : #if ROSE_ALLOC_MEMSET == 1
    3598             : #elif ROSE_ALLOC_MEMSET == 2
    3599             :         memset(alloc, 0x00, SgStructureModifier::pool_size * sizeof(SgStructureModifier));
    3600             : #elif ROSE_ALLOC_MEMSET == 3
    3601             :         memset(alloc, 0xAA, SgStructureModifier::pool_size * sizeof(SgStructureModifier));
    3602             : #endif
    3603           0 :         for (unsigned i=0; i < SgStructureModifier::pool_size-1; i++) {
    3604           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
    3605             :         }
    3606           0 :         alloc[SgStructureModifier::pool_size-1].p_freepointer = nullptr;
    3607             : 
    3608           0 :         SgStructureModifier::pools.push_back ( (unsigned char *) alloc );
    3609           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgStructureModifier::pool_size * sizeof(SgStructureModifier), V_SgStructureModifier ) );
    3610           0 :         SgStructureModifier::next_node = alloc;
    3611             :     }
    3612           0 :     ROSE_ASSERT(SgStructureModifier::next_node != nullptr);
    3613             : 
    3614           0 :     SgStructureModifier * object = SgStructureModifier::next_node;
    3615           0 :     SgStructureModifier::next_node = (SgStructureModifier*)(object->p_freepointer);
    3616             : 
    3617             : #if ROSE_ALLOC_TRACE == 2
    3618             :     printf("SgStructureModifier::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgStructureModifier::next_node);
    3619             : #endif
    3620             : 
    3621           0 :     SgNode * fp = object->p_freepointer;
    3622             : #if ROSE_ALLOC_MEMSET == 1
    3623             : #elif ROSE_ALLOC_MEMSET == 2
    3624             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgStructureModifier) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
    3625             : #elif ROSE_ALLOC_MEMSET == 3
    3626             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgStructureModifier) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
    3627             : #endif
    3628           0 :     object->p_freepointer = fp;
    3629             : 
    3630             : #if ROSE_ALLOC_TRACE == 2
    3631             : //    printf("SgStructureModifier::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgStructureModifier::next_node);
    3632             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
    3633             :     Rose::MemPool::snapshot(oss.str());
    3634             :     alloc_trace_cnt++;
    3635             : #endif
    3636             : 
    3637           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
    3638             : 
    3639           0 :     ALLOC_MUTEX(SgStructureModifier, unlock);
    3640             : 
    3641             :     return object;
    3642             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
    3643             : }
    3644             : 
    3645             : 
    3646             : 
    3647             : /*! \brief Delete operator for SgStructureModifier.
    3648             : 
    3649             :    This delete operator implements deallocation using memory pools to 
    3650             :    provide most efficent use of the heap within construction of large ASTs.
    3651             : 
    3652             : \internal The new and delete operators use the lower level C malloc/free
    3653             :    function calls for performance and to make sure that mixing of malloc/free
    3654             :    and new/delete by the used can be caught more readily.  This may change
    3655             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
    3656             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
    3657             :    deallocate memory allocated using ROSE_MALLOC.
    3658             : */
    3659           0 : void SgStructureModifier::operator delete(void *Pointer, size_t Size)
    3660             : {
    3661             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
    3662             :      * or throwing an exception. */
    3663           0 :     ALLOC_MUTEX(SgStructureModifier, lock);
    3664             : 
    3665             : #if USE_CPP_NEW_DELETE_OPERATORS
    3666             :     ROSE_FREE(Pointer);
    3667             : #else
    3668             : #if ROSE_PEDANTIC_ALLOC
    3669             :     ROSE_ASSERT(Size == sizeof(SgStructureModifier));
    3670             : #else
    3671           0 :     if (Size != sizeof(SgStructureModifier)) {
    3672           0 :       ROSE_FREE(Pointer);
    3673           0 :       ALLOC_MUTEX(SgStructureModifier, unlock);
    3674             :       return;
    3675             :     }
    3676             : #endif
    3677             : 
    3678           0 :     SgStructureModifier * object = (SgStructureModifier*) Pointer;
    3679           0 :     ROSE_ASSERT(object != nullptr);
    3680             : 
    3681             : #if ROSE_ALLOC_TRACE == 2
    3682             : //  printf("SgStructureModifier::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgStructureModifier::next_node);
    3683             :     printf("SgStructureModifier::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgStructureModifier::next_node);
    3684             : #endif
    3685             : 
    3686             : #if ROSE_PEDANTIC_ALLOC
    3687             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
    3688             : #endif
    3689             : 
    3690             : #if ROSE_ALLOC_MEMSET == 1
    3691             : #elif ROSE_ALLOC_MEMSET == 2
    3692             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgStructureModifier) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
    3693             : #elif ROSE_ALLOC_MEMSET == 3
    3694             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgStructureModifier) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
    3695             : #endif
    3696             : 
    3697             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
    3698             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
    3699             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
    3700             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
    3701             : #else
    3702           0 :     object->p_freepointer = SgStructureModifier::next_node;
    3703           0 :     SgStructureModifier::next_node = object;
    3704             : #endif
    3705             : 
    3706             : #if ROSE_ALLOC_TRACE == 2
    3707             : //  printf("SgStructureModifier::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgStructureModifier::next_node);
    3708             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
    3709             :     Rose::MemPool::snapshot(oss.str());
    3710             :     alloc_trace_cnt++;
    3711             : #endif
    3712             : 
    3713             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
    3714             : 
    3715           0 :     ALLOC_MUTEX(SgStructureModifier, unlock);
    3716             : }
    3717             : 
    3718             : // DQ (11/27/2009): I have moved this member function definition to outside of the
    3719             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
    3720             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
    3721             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
    3722             : // Also, note comment below from Robb (copied from the Common.code file).
    3723             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
    3724             : //
    3725             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
    3726             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
    3727             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
    3728             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
    3729             : #if 0
    3730             : void SgStructureModifier::operator delete(void* pointer) { SgStructureModifier::operator delete (pointer, sizeof(SgStructureModifier)); };
    3731             : #endif
    3732             : /* #line 3733 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
    3733             : 
    3734             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
    3735             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
    3736             : // obviously imply C++.
    3737             : 
    3738             : // This implements the support within ROSE for memory pools.  Memory pools
    3739             : // support the most condensed usage of memory within the construction of
    3740             : // and AST. Large blocks of contiguous storage for each RI node is allocated
    3741             : // by a new operator written for each class.
    3742             : 
    3743             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
    3744             :     // User wants multi-thread support and POSIX threads are available.
    3745             : #   include <pthread.h>
    3746             :     static pthread_mutex_t SgTypeModifier_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
    3747             : #else
    3748             :      // Cause synchronization to be skipped.
    3749             : #    ifndef ALLOC_MUTEX
    3750             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
    3751             : #    endif
    3752             : #    ifdef _REENTRANT
    3753             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
    3754             : #       ifdef _MSC_VER
    3755             : #           pragma message("POSIX threads are not available; synchronization being skipped")
    3756             : #       else
    3757             : #           warning "POSIX threads are not available; synchronization being skipped"
    3758             : #       endif
    3759             : #    endif
    3760             : #endif
    3761             : 
    3762             : #ifndef ROSE_ALLOC_TRACE
    3763             : #  define ROSE_ALLOC_TRACE 0
    3764             : #endif
    3765             : 
    3766             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
    3767             : #define ROSE_ALLOC_TRACE_CNT
    3768             : #include "memory-pool-snapshot.h"
    3769             : unsigned long alloc_trace_cnt = 0;
    3770             : #endif
    3771             : 
    3772             : #if ROSE_ALLOC_TRACE
    3773             : const unsigned SgTypeModifier::pool_size = 5;
    3774             : #else
    3775             : const unsigned SgTypeModifier::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
    3776             : #endif
    3777             : 
    3778             : #ifndef ROSE_ALLOC_MEMSET
    3779             : #  define ROSE_ALLOC_MEMSET 0
    3780             : #endif
    3781             : 
    3782             : #ifndef ROSE_PEDANTIC_ALLOC
    3783             : #  define ROSE_PEDANTIC_ALLOC 0
    3784             : #endif
    3785             : 
    3786             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
    3787             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
    3788             : #endif
    3789             : 
    3790             : #if !defined(SGNODE__ALL_POOLS)
    3791             : #define SGNODE__ALL_POOLS
    3792             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
    3793             : #endif
    3794             : 
    3795             : SgTypeModifier* SgTypeModifier::next_node = nullptr;
    3796             : std::vector<unsigned char*> SgTypeModifier::pools;
    3797             : 
    3798             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
    3799             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
    3800             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
    3801             : // around this macro definition rather than each use).
    3802             : #ifndef ALLOC_MUTEX
    3803             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
    3804             :         do {                                                                     \
    3805             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
    3806             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
    3807             :                 abort();                                                         \
    3808             :             }                                                                    \
    3809             :         } while (0);
    3810             : #endif
    3811             : 
    3812             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
    3813             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
    3814             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
    3815             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
    3816             : 
    3817             : /*! \brief New operator for SgTypeModifier.
    3818             : 
    3819             :    This new operator implements memory pools to provide most efficent 
    3820             :    use of the heap within construction of large ASTs.
    3821             : 
    3822             : \internal The new and delete operators use the lower level C malloc/free
    3823             :    function calls for performance and to make sure that mixing of malloc/free
    3824             :    and new/delete by the used can be caught more readily.  This may change
    3825             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
    3826             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
    3827             :    deallocate memory allocated using ROSE_MALLOC.
    3828             : */
    3829           0 : void *SgTypeModifier::operator new ( size_t Size )
    3830             : {
    3831             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
    3832             :      * returning or throwing an exception. */
    3833           0 :     ALLOC_MUTEX(SgTypeModifier, lock);
    3834             : 
    3835             : #if ROSE_ALLOC_TRACE == 2
    3836             : //    printf("SgTypeModifier::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgTypeModifier::next_node);
    3837             : #endif
    3838             : 
    3839             : #if USE_CPP_NEW_DELETE_OPERATORS
    3840             :     void *mem = ROSE_MALLOC(Size);
    3841             :     ALLOC_MUTEX(SgTypeModifier, unlock);
    3842             :     return mem;
    3843             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
    3844             : #if ROSE_PEDANTIC_ALLOC
    3845             :     ROSE_ASSERT(Size == sizeof(SgTypeModifier));
    3846             : #else
    3847           0 :     if (Size != sizeof(SgTypeModifier)) {
    3848           0 :       void * object = ROSE_MALLOC(Size);
    3849           0 :       ALLOC_MUTEX(SgTypeModifier, unlock);
    3850             :       return object;
    3851             :     }
    3852             : #endif
    3853             : 
    3854           0 :     if (SgTypeModifier::next_node == nullptr) {
    3855           0 :         SgTypeModifier * alloc = (SgTypeModifier*) ROSE_MALLOC ( SgTypeModifier::pool_size * sizeof(SgTypeModifier) );
    3856           0 :         ROSE_ASSERT(alloc != nullptr);
    3857             : 
    3858             : #if ROSE_ALLOC_TRACE == 2
    3859             : //        printf("SgTypeModifier::alloc\n  block[%zi] = [ %p , %p [\n", SgTypeModifier::pools.size(), alloc, alloc + SgTypeModifier::pool_size);
    3860             : #endif
    3861             : 
    3862             : #if ROSE_ALLOC_MEMSET == 1
    3863             : #elif ROSE_ALLOC_MEMSET == 2
    3864             :         memset(alloc, 0x00, SgTypeModifier::pool_size * sizeof(SgTypeModifier));
    3865             : #elif ROSE_ALLOC_MEMSET == 3
    3866             :         memset(alloc, 0xAA, SgTypeModifier::pool_size * sizeof(SgTypeModifier));
    3867             : #endif
    3868           0 :         for (unsigned i=0; i < SgTypeModifier::pool_size-1; i++) {
    3869           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
    3870             :         }
    3871           0 :         alloc[SgTypeModifier::pool_size-1].p_freepointer = nullptr;
    3872             : 
    3873           0 :         SgTypeModifier::pools.push_back ( (unsigned char *) alloc );
    3874           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgTypeModifier::pool_size * sizeof(SgTypeModifier), V_SgTypeModifier ) );
    3875           0 :         SgTypeModifier::next_node = alloc;
    3876             :     }
    3877           0 :     ROSE_ASSERT(SgTypeModifier::next_node != nullptr);
    3878             : 
    3879           0 :     SgTypeModifier * object = SgTypeModifier::next_node;
    3880           0 :     SgTypeModifier::next_node = (SgTypeModifier*)(object->p_freepointer);
    3881             : 
    3882             : #if ROSE_ALLOC_TRACE == 2
    3883             :     printf("SgTypeModifier::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeModifier::next_node);
    3884             : #endif
    3885             : 
    3886           0 :     SgNode * fp = object->p_freepointer;
    3887             : #if ROSE_ALLOC_MEMSET == 1
    3888             : #elif ROSE_ALLOC_MEMSET == 2
    3889             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgTypeModifier) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
    3890             : #elif ROSE_ALLOC_MEMSET == 3
    3891             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgTypeModifier) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
    3892             : #endif
    3893           0 :     object->p_freepointer = fp;
    3894             : 
    3895             : #if ROSE_ALLOC_TRACE == 2
    3896             : //    printf("SgTypeModifier::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeModifier::next_node);
    3897             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
    3898             :     Rose::MemPool::snapshot(oss.str());
    3899             :     alloc_trace_cnt++;
    3900             : #endif
    3901             : 
    3902           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
    3903             : 
    3904           0 :     ALLOC_MUTEX(SgTypeModifier, unlock);
    3905             : 
    3906             :     return object;
    3907             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
    3908             : }
    3909             : 
    3910             : 
    3911             : 
    3912             : /*! \brief Delete operator for SgTypeModifier.
    3913             : 
    3914             :    This delete operator implements deallocation using memory pools to 
    3915             :    provide most efficent use of the heap within construction of large ASTs.
    3916             : 
    3917             : \internal The new and delete operators use the lower level C malloc/free
    3918             :    function calls for performance and to make sure that mixing of malloc/free
    3919             :    and new/delete by the used can be caught more readily.  This may change
    3920             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
    3921             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
    3922             :    deallocate memory allocated using ROSE_MALLOC.
    3923             : */
    3924           0 : void SgTypeModifier::operator delete(void *Pointer, size_t Size)
    3925             : {
    3926             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
    3927             :      * or throwing an exception. */
    3928           0 :     ALLOC_MUTEX(SgTypeModifier, lock);
    3929             : 
    3930             : #if USE_CPP_NEW_DELETE_OPERATORS
    3931             :     ROSE_FREE(Pointer);
    3932             : #else
    3933             : #if ROSE_PEDANTIC_ALLOC
    3934             :     ROSE_ASSERT(Size == sizeof(SgTypeModifier));
    3935             : #else
    3936           0 :     if (Size != sizeof(SgTypeModifier)) {
    3937           0 :       ROSE_FREE(Pointer);
    3938           0 :       ALLOC_MUTEX(SgTypeModifier, unlock);
    3939             :       return;
    3940             :     }
    3941             : #endif
    3942             : 
    3943           0 :     SgTypeModifier * object = (SgTypeModifier*) Pointer;
    3944           0 :     ROSE_ASSERT(object != nullptr);
    3945             : 
    3946             : #if ROSE_ALLOC_TRACE == 2
    3947             : //  printf("SgTypeModifier::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeModifier::next_node);
    3948             :     printf("SgTypeModifier::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeModifier::next_node);
    3949             : #endif
    3950             : 
    3951             : #if ROSE_PEDANTIC_ALLOC
    3952             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
    3953             : #endif
    3954             : 
    3955             : #if ROSE_ALLOC_MEMSET == 1
    3956             : #elif ROSE_ALLOC_MEMSET == 2
    3957             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgTypeModifier) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
    3958             : #elif ROSE_ALLOC_MEMSET == 3
    3959             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgTypeModifier) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
    3960             : #endif
    3961             : 
    3962             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
    3963             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
    3964             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
    3965             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
    3966             : #else
    3967           0 :     object->p_freepointer = SgTypeModifier::next_node;
    3968           0 :     SgTypeModifier::next_node = object;
    3969             : #endif
    3970             : 
    3971             : #if ROSE_ALLOC_TRACE == 2
    3972             : //  printf("SgTypeModifier::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeModifier::next_node);
    3973             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
    3974             :     Rose::MemPool::snapshot(oss.str());
    3975             :     alloc_trace_cnt++;
    3976             : #endif
    3977             : 
    3978             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
    3979             : 
    3980           0 :     ALLOC_MUTEX(SgTypeModifier, unlock);
    3981             : }
    3982             : 
    3983             : // DQ (11/27/2009): I have moved this member function definition to outside of the
    3984             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
    3985             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
    3986             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
    3987             : // Also, note comment below from Robb (copied from the Common.code file).
    3988             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
    3989             : //
    3990             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
    3991             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
    3992             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
    3993             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
    3994             : #if 0
    3995             : void SgTypeModifier::operator delete(void* pointer) { SgTypeModifier::operator delete (pointer, sizeof(SgTypeModifier)); };
    3996             : #endif
    3997             : /* #line 3998 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
    3998             : 
    3999             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
    4000             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
    4001             : // obviously imply C++.
    4002             : 
    4003             : // This implements the support within ROSE for memory pools.  Memory pools
    4004             : // support the most condensed usage of memory within the construction of
    4005             : // and AST. Large blocks of contiguous storage for each RI node is allocated
    4006             : // by a new operator written for each class.
    4007             : 
    4008             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
    4009             :     // User wants multi-thread support and POSIX threads are available.
    4010             : #   include <pthread.h>
    4011             :     static pthread_mutex_t SgDeclarationModifier_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
    4012             : #else
    4013             :      // Cause synchronization to be skipped.
    4014             : #    ifndef ALLOC_MUTEX
    4015             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
    4016             : #    endif
    4017             : #    ifdef _REENTRANT
    4018             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
    4019             : #       ifdef _MSC_VER
    4020             : #           pragma message("POSIX threads are not available; synchronization being skipped")
    4021             : #       else
    4022             : #           warning "POSIX threads are not available; synchronization being skipped"
    4023             : #       endif
    4024             : #    endif
    4025             : #endif
    4026             : 
    4027             : #ifndef ROSE_ALLOC_TRACE
    4028             : #  define ROSE_ALLOC_TRACE 0
    4029             : #endif
    4030             : 
    4031             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
    4032             : #define ROSE_ALLOC_TRACE_CNT
    4033             : #include "memory-pool-snapshot.h"
    4034             : unsigned long alloc_trace_cnt = 0;
    4035             : #endif
    4036             : 
    4037             : #if ROSE_ALLOC_TRACE
    4038             : const unsigned SgDeclarationModifier::pool_size = 5;
    4039             : #else
    4040             : const unsigned SgDeclarationModifier::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
    4041             : #endif
    4042             : 
    4043             : #ifndef ROSE_ALLOC_MEMSET
    4044             : #  define ROSE_ALLOC_MEMSET 0
    4045             : #endif
    4046             : 
    4047             : #ifndef ROSE_PEDANTIC_ALLOC
    4048             : #  define ROSE_PEDANTIC_ALLOC 0
    4049             : #endif
    4050             : 
    4051             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
    4052             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
    4053             : #endif
    4054             : 
    4055             : #if !defined(SGNODE__ALL_POOLS)
    4056             : #define SGNODE__ALL_POOLS
    4057             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
    4058             : #endif
    4059             : 
    4060             : SgDeclarationModifier* SgDeclarationModifier::next_node = nullptr;
    4061             : std::vector<unsigned char*> SgDeclarationModifier::pools;
    4062             : 
    4063             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
    4064             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
    4065             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
    4066             : // around this macro definition rather than each use).
    4067             : #ifndef ALLOC_MUTEX
    4068             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
    4069             :         do {                                                                     \
    4070             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
    4071             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
    4072             :                 abort();                                                         \
    4073             :             }                                                                    \
    4074             :         } while (0);
    4075             : #endif
    4076             : 
    4077             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
    4078             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
    4079             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
    4080             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
    4081             : 
    4082             : /*! \brief New operator for SgDeclarationModifier.
    4083             : 
    4084             :    This new operator implements memory pools to provide most efficent 
    4085             :    use of the heap within construction of large ASTs.
    4086             : 
    4087             : \internal The new and delete operators use the lower level C malloc/free
    4088             :    function calls for performance and to make sure that mixing of malloc/free
    4089             :    and new/delete by the used can be caught more readily.  This may change
    4090             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
    4091             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
    4092             :    deallocate memory allocated using ROSE_MALLOC.
    4093             : */
    4094           0 : void *SgDeclarationModifier::operator new ( size_t Size )
    4095             : {
    4096             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
    4097             :      * returning or throwing an exception. */
    4098           0 :     ALLOC_MUTEX(SgDeclarationModifier, lock);
    4099             : 
    4100             : #if ROSE_ALLOC_TRACE == 2
    4101             : //    printf("SgDeclarationModifier::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgDeclarationModifier::next_node);
    4102             : #endif
    4103             : 
    4104             : #if USE_CPP_NEW_DELETE_OPERATORS
    4105             :     void *mem = ROSE_MALLOC(Size);
    4106             :     ALLOC_MUTEX(SgDeclarationModifier, unlock);
    4107             :     return mem;
    4108             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
    4109             : #if ROSE_PEDANTIC_ALLOC
    4110             :     ROSE_ASSERT(Size == sizeof(SgDeclarationModifier));
    4111             : #else
    4112           0 :     if (Size != sizeof(SgDeclarationModifier)) {
    4113           0 :       void * object = ROSE_MALLOC(Size);
    4114           0 :       ALLOC_MUTEX(SgDeclarationModifier, unlock);
    4115             :       return object;
    4116             :     }
    4117             : #endif
    4118             : 
    4119           0 :     if (SgDeclarationModifier::next_node == nullptr) {
    4120           0 :         SgDeclarationModifier * alloc = (SgDeclarationModifier*) ROSE_MALLOC ( SgDeclarationModifier::pool_size * sizeof(SgDeclarationModifier) );
    4121           0 :         ROSE_ASSERT(alloc != nullptr);
    4122             : 
    4123             : #if ROSE_ALLOC_TRACE == 2
    4124             : //        printf("SgDeclarationModifier::alloc\n  block[%zi] = [ %p , %p [\n", SgDeclarationModifier::pools.size(), alloc, alloc + SgDeclarationModifier::pool_size);
    4125             : #endif
    4126             : 
    4127             : #if ROSE_ALLOC_MEMSET == 1
    4128             : #elif ROSE_ALLOC_MEMSET == 2
    4129             :         memset(alloc, 0x00, SgDeclarationModifier::pool_size * sizeof(SgDeclarationModifier));
    4130             : #elif ROSE_ALLOC_MEMSET == 3
    4131             :         memset(alloc, 0xAA, SgDeclarationModifier::pool_size * sizeof(SgDeclarationModifier));
    4132             : #endif
    4133           0 :         for (unsigned i=0; i < SgDeclarationModifier::pool_size-1; i++) {
    4134           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
    4135             :         }
    4136           0 :         alloc[SgDeclarationModifier::pool_size-1].p_freepointer = nullptr;
    4137             : 
    4138           0 :         SgDeclarationModifier::pools.push_back ( (unsigned char *) alloc );
    4139           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgDeclarationModifier::pool_size * sizeof(SgDeclarationModifier), V_SgDeclarationModifier ) );
    4140           0 :         SgDeclarationModifier::next_node = alloc;
    4141             :     }
    4142           0 :     ROSE_ASSERT(SgDeclarationModifier::next_node != nullptr);
    4143             : 
    4144           0 :     SgDeclarationModifier * object = SgDeclarationModifier::next_node;
    4145           0 :     SgDeclarationModifier::next_node = (SgDeclarationModifier*)(object->p_freepointer);
    4146             : 
    4147             : #if ROSE_ALLOC_TRACE == 2
    4148             :     printf("SgDeclarationModifier::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgDeclarationModifier::next_node);
    4149             : #endif
    4150             : 
    4151           0 :     SgNode * fp = object->p_freepointer;
    4152             : #if ROSE_ALLOC_MEMSET == 1
    4153             : #elif ROSE_ALLOC_MEMSET == 2
    4154             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgDeclarationModifier) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
    4155             : #elif ROSE_ALLOC_MEMSET == 3
    4156             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgDeclarationModifier) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
    4157             : #endif
    4158           0 :     object->p_freepointer = fp;
    4159             : 
    4160             : #if ROSE_ALLOC_TRACE == 2
    4161             : //    printf("SgDeclarationModifier::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgDeclarationModifier::next_node);
    4162             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
    4163             :     Rose::MemPool::snapshot(oss.str());
    4164             :     alloc_trace_cnt++;
    4165             : #endif
    4166             : 
    4167           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
    4168             : 
    4169           0 :     ALLOC_MUTEX(SgDeclarationModifier, unlock);
    4170             : 
    4171             :     return object;
    4172             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
    4173             : }
    4174             : 
    4175             : 
    4176             : 
    4177             : /*! \brief Delete operator for SgDeclarationModifier.
    4178             : 
    4179             :    This delete operator implements deallocation using memory pools to 
    4180             :    provide most efficent use of the heap within construction of large ASTs.
    4181             : 
    4182             : \internal The new and delete operators use the lower level C malloc/free
    4183             :    function calls for performance and to make sure that mixing of malloc/free
    4184             :    and new/delete by the used can be caught more readily.  This may change
    4185             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
    4186             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
    4187             :    deallocate memory allocated using ROSE_MALLOC.
    4188             : */
    4189           0 : void SgDeclarationModifier::operator delete(void *Pointer, size_t Size)
    4190             : {
    4191             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
    4192             :      * or throwing an exception. */
    4193           0 :     ALLOC_MUTEX(SgDeclarationModifier, lock);
    4194             : 
    4195             : #if USE_CPP_NEW_DELETE_OPERATORS
    4196             :     ROSE_FREE(Pointer);
    4197             : #else
    4198             : #if ROSE_PEDANTIC_ALLOC
    4199             :     ROSE_ASSERT(Size == sizeof(SgDeclarationModifier));
    4200             : #else
    4201           0 :     if (Size != sizeof(SgDeclarationModifier)) {
    4202           0 :       ROSE_FREE(Pointer);
    4203           0 :       ALLOC_MUTEX(SgDeclarationModifier, unlock);
    4204             :       return;
    4205             :     }
    4206             : #endif
    4207             : 
    4208           0 :     SgDeclarationModifier * object = (SgDeclarationModifier*) Pointer;
    4209           0 :     ROSE_ASSERT(object != nullptr);
    4210             : 
    4211             : #if ROSE_ALLOC_TRACE == 2
    4212             : //  printf("SgDeclarationModifier::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgDeclarationModifier::next_node);
    4213             :     printf("SgDeclarationModifier::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgDeclarationModifier::next_node);
    4214             : #endif
    4215             : 
    4216             : #if ROSE_PEDANTIC_ALLOC
    4217             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
    4218             : #endif
    4219             : 
    4220             : #if ROSE_ALLOC_MEMSET == 1
    4221             : #elif ROSE_ALLOC_MEMSET == 2
    4222             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgDeclarationModifier) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
    4223             : #elif ROSE_ALLOC_MEMSET == 3
    4224             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgDeclarationModifier) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
    4225             : #endif
    4226             : 
    4227             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
    4228             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
    4229             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
    4230             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
    4231             : #else
    4232           0 :     object->p_freepointer = SgDeclarationModifier::next_node;
    4233           0 :     SgDeclarationModifier::next_node = object;
    4234             : #endif
    4235             : 
    4236             : #if ROSE_ALLOC_TRACE == 2
    4237             : //  printf("SgDeclarationModifier::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgDeclarationModifier::next_node);
    4238             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
    4239             :     Rose::MemPool::snapshot(oss.str());
    4240             :     alloc_trace_cnt++;
    4241             : #endif
    4242             : 
    4243             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
    4244             : 
    4245           0 :     ALLOC_MUTEX(SgDeclarationModifier, unlock);
    4246             : }
    4247             : 
    4248             : // DQ (11/27/2009): I have moved this member function definition to outside of the
    4249             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
    4250             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
    4251             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
    4252             : // Also, note comment below from Robb (copied from the Common.code file).
    4253             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
    4254             : //
    4255             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
    4256             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
    4257             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
    4258             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
    4259             : #if 0
    4260             : void SgDeclarationModifier::operator delete(void* pointer) { SgDeclarationModifier::operator delete (pointer, sizeof(SgDeclarationModifier)); };
    4261             : #endif
    4262             : /* #line 4263 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
    4263             : 
    4264             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
    4265             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
    4266             : // obviously imply C++.
    4267             : 
    4268             : // This implements the support within ROSE for memory pools.  Memory pools
    4269             : // support the most condensed usage of memory within the construction of
    4270             : // and AST. Large blocks of contiguous storage for each RI node is allocated
    4271             : // by a new operator written for each class.
    4272             : 
    4273             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
    4274             :     // User wants multi-thread support and POSIX threads are available.
    4275             : #   include <pthread.h>
    4276             :     static pthread_mutex_t SgOpenclAccessModeModifier_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
    4277             : #else
    4278             :      // Cause synchronization to be skipped.
    4279             : #    ifndef ALLOC_MUTEX
    4280             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
    4281             : #    endif
    4282             : #    ifdef _REENTRANT
    4283             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
    4284             : #       ifdef _MSC_VER
    4285             : #           pragma message("POSIX threads are not available; synchronization being skipped")
    4286             : #       else
    4287             : #           warning "POSIX threads are not available; synchronization being skipped"
    4288             : #       endif
    4289             : #    endif
    4290             : #endif
    4291             : 
    4292             : #ifndef ROSE_ALLOC_TRACE
    4293             : #  define ROSE_ALLOC_TRACE 0
    4294             : #endif
    4295             : 
    4296             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
    4297             : #define ROSE_ALLOC_TRACE_CNT
    4298             : #include "memory-pool-snapshot.h"
    4299             : unsigned long alloc_trace_cnt = 0;
    4300             : #endif
    4301             : 
    4302             : #if ROSE_ALLOC_TRACE
    4303             : const unsigned SgOpenclAccessModeModifier::pool_size = 5;
    4304             : #else
    4305             : const unsigned SgOpenclAccessModeModifier::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
    4306             : #endif
    4307             : 
    4308             : #ifndef ROSE_ALLOC_MEMSET
    4309             : #  define ROSE_ALLOC_MEMSET 0
    4310             : #endif
    4311             : 
    4312             : #ifndef ROSE_PEDANTIC_ALLOC
    4313             : #  define ROSE_PEDANTIC_ALLOC 0
    4314             : #endif
    4315             : 
    4316             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
    4317             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
    4318             : #endif
    4319             : 
    4320             : #if !defined(SGNODE__ALL_POOLS)
    4321             : #define SGNODE__ALL_POOLS
    4322             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
    4323             : #endif
    4324             : 
    4325             : SgOpenclAccessModeModifier* SgOpenclAccessModeModifier::next_node = nullptr;
    4326             : std::vector<unsigned char*> SgOpenclAccessModeModifier::pools;
    4327             : 
    4328             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
    4329             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
    4330             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
    4331             : // around this macro definition rather than each use).
    4332             : #ifndef ALLOC_MUTEX
    4333             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
    4334             :         do {                                                                     \
    4335             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
    4336             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
    4337             :                 abort();                                                         \
    4338             :             }                                                                    \
    4339             :         } while (0);
    4340             : #endif
    4341             : 
    4342             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
    4343             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
    4344             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
    4345             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
    4346             : 
    4347             : /*! \brief New operator for SgOpenclAccessModeModifier.
    4348             : 
    4349             :    This new operator implements memory pools to provide most efficent 
    4350             :    use of the heap within construction of large ASTs.
    4351             : 
    4352             : \internal The new and delete operators use the lower level C malloc/free
    4353             :    function calls for performance and to make sure that mixing of malloc/free
    4354             :    and new/delete by the used can be caught more readily.  This may change
    4355             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
    4356             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
    4357             :    deallocate memory allocated using ROSE_MALLOC.
    4358             : */
    4359           0 : void *SgOpenclAccessModeModifier::operator new ( size_t Size )
    4360             : {
    4361             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
    4362             :      * returning or throwing an exception. */
    4363           0 :     ALLOC_MUTEX(SgOpenclAccessModeModifier, lock);
    4364             : 
    4365             : #if ROSE_ALLOC_TRACE == 2
    4366             : //    printf("SgOpenclAccessModeModifier::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgOpenclAccessModeModifier::next_node);
    4367             : #endif
    4368             : 
    4369             : #if USE_CPP_NEW_DELETE_OPERATORS
    4370             :     void *mem = ROSE_MALLOC(Size);
    4371             :     ALLOC_MUTEX(SgOpenclAccessModeModifier, unlock);
    4372             :     return mem;
    4373             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
    4374             : #if ROSE_PEDANTIC_ALLOC
    4375             :     ROSE_ASSERT(Size == sizeof(SgOpenclAccessModeModifier));
    4376             : #else
    4377           0 :     if (Size != sizeof(SgOpenclAccessModeModifier)) {
    4378           0 :       void * object = ROSE_MALLOC(Size);
    4379           0 :       ALLOC_MUTEX(SgOpenclAccessModeModifier, unlock);
    4380             :       return object;
    4381             :     }
    4382             : #endif
    4383             : 
    4384           0 :     if (SgOpenclAccessModeModifier::next_node == nullptr) {
    4385           0 :         SgOpenclAccessModeModifier * alloc = (SgOpenclAccessModeModifier*) ROSE_MALLOC ( SgOpenclAccessModeModifier::pool_size * sizeof(SgOpenclAccessModeModifier) );
    4386           0 :         ROSE_ASSERT(alloc != nullptr);
    4387             : 
    4388             : #if ROSE_ALLOC_TRACE == 2
    4389             : //        printf("SgOpenclAccessModeModifier::alloc\n  block[%zi] = [ %p , %p [\n", SgOpenclAccessModeModifier::pools.size(), alloc, alloc + SgOpenclAccessModeModifier::pool_size);
    4390             : #endif
    4391             : 
    4392             : #if ROSE_ALLOC_MEMSET == 1
    4393             : #elif ROSE_ALLOC_MEMSET == 2
    4394             :         memset(alloc, 0x00, SgOpenclAccessModeModifier::pool_size * sizeof(SgOpenclAccessModeModifier));
    4395             : #elif ROSE_ALLOC_MEMSET == 3
    4396             :         memset(alloc, 0xAA, SgOpenclAccessModeModifier::pool_size * sizeof(SgOpenclAccessModeModifier));
    4397             : #endif
    4398           0 :         for (unsigned i=0; i < SgOpenclAccessModeModifier::pool_size-1; i++) {
    4399           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
    4400             :         }
    4401           0 :         alloc[SgOpenclAccessModeModifier::pool_size-1].p_freepointer = nullptr;
    4402             : 
    4403           0 :         SgOpenclAccessModeModifier::pools.push_back ( (unsigned char *) alloc );
    4404           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgOpenclAccessModeModifier::pool_size * sizeof(SgOpenclAccessModeModifier), V_SgOpenclAccessModeModifier ) );
    4405           0 :         SgOpenclAccessModeModifier::next_node = alloc;
    4406             :     }
    4407           0 :     ROSE_ASSERT(SgOpenclAccessModeModifier::next_node != nullptr);
    4408             : 
    4409           0 :     SgOpenclAccessModeModifier * object = SgOpenclAccessModeModifier::next_node;
    4410           0 :     SgOpenclAccessModeModifier::next_node = (SgOpenclAccessModeModifier*)(object->p_freepointer);
    4411             : 
    4412             : #if ROSE_ALLOC_TRACE == 2
    4413             :     printf("SgOpenclAccessModeModifier::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOpenclAccessModeModifier::next_node);
    4414             : #endif
    4415             : 
    4416           0 :     SgNode * fp = object->p_freepointer;
    4417             : #if ROSE_ALLOC_MEMSET == 1
    4418             : #elif ROSE_ALLOC_MEMSET == 2
    4419             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOpenclAccessModeModifier) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
    4420             : #elif ROSE_ALLOC_MEMSET == 3
    4421             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgOpenclAccessModeModifier) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
    4422             : #endif
    4423           0 :     object->p_freepointer = fp;
    4424             : 
    4425             : #if ROSE_ALLOC_TRACE == 2
    4426             : //    printf("SgOpenclAccessModeModifier::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOpenclAccessModeModifier::next_node);
    4427             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
    4428             :     Rose::MemPool::snapshot(oss.str());
    4429             :     alloc_trace_cnt++;
    4430             : #endif
    4431             : 
    4432           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
    4433             : 
    4434           0 :     ALLOC_MUTEX(SgOpenclAccessModeModifier, unlock);
    4435             : 
    4436             :     return object;
    4437             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
    4438             : }
    4439             : 
    4440             : 
    4441             : 
    4442             : /*! \brief Delete operator for SgOpenclAccessModeModifier.
    4443             : 
    4444             :    This delete operator implements deallocation using memory pools to 
    4445             :    provide most efficent use of the heap within construction of large ASTs.
    4446             : 
    4447             : \internal The new and delete operators use the lower level C malloc/free
    4448             :    function calls for performance and to make sure that mixing of malloc/free
    4449             :    and new/delete by the used can be caught more readily.  This may change
    4450             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
    4451             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
    4452             :    deallocate memory allocated using ROSE_MALLOC.
    4453             : */
    4454           0 : void SgOpenclAccessModeModifier::operator delete(void *Pointer, size_t Size)
    4455             : {
    4456             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
    4457             :      * or throwing an exception. */
    4458           0 :     ALLOC_MUTEX(SgOpenclAccessModeModifier, lock);
    4459             : 
    4460             : #if USE_CPP_NEW_DELETE_OPERATORS
    4461             :     ROSE_FREE(Pointer);
    4462             : #else
    4463             : #if ROSE_PEDANTIC_ALLOC
    4464             :     ROSE_ASSERT(Size == sizeof(SgOpenclAccessModeModifier));
    4465             : #else
    4466           0 :     if (Size != sizeof(SgOpenclAccessModeModifier)) {
    4467           0 :       ROSE_FREE(Pointer);
    4468           0 :       ALLOC_MUTEX(SgOpenclAccessModeModifier, unlock);
    4469             :       return;
    4470             :     }
    4471             : #endif
    4472             : 
    4473           0 :     SgOpenclAccessModeModifier * object = (SgOpenclAccessModeModifier*) Pointer;
    4474           0 :     ROSE_ASSERT(object != nullptr);
    4475             : 
    4476             : #if ROSE_ALLOC_TRACE == 2
    4477             : //  printf("SgOpenclAccessModeModifier::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOpenclAccessModeModifier::next_node);
    4478             :     printf("SgOpenclAccessModeModifier::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOpenclAccessModeModifier::next_node);
    4479             : #endif
    4480             : 
    4481             : #if ROSE_PEDANTIC_ALLOC
    4482             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
    4483             : #endif
    4484             : 
    4485             : #if ROSE_ALLOC_MEMSET == 1
    4486             : #elif ROSE_ALLOC_MEMSET == 2
    4487             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOpenclAccessModeModifier) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
    4488             : #elif ROSE_ALLOC_MEMSET == 3
    4489             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgOpenclAccessModeModifier) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
    4490             : #endif
    4491             : 
    4492             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
    4493             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
    4494             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
    4495             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
    4496             : #else
    4497           0 :     object->p_freepointer = SgOpenclAccessModeModifier::next_node;
    4498           0 :     SgOpenclAccessModeModifier::next_node = object;
    4499             : #endif
    4500             : 
    4501             : #if ROSE_ALLOC_TRACE == 2
    4502             : //  printf("SgOpenclAccessModeModifier::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOpenclAccessModeModifier::next_node);
    4503             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
    4504             :     Rose::MemPool::snapshot(oss.str());
    4505             :     alloc_trace_cnt++;
    4506             : #endif
    4507             : 
    4508             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
    4509             : 
    4510           0 :     ALLOC_MUTEX(SgOpenclAccessModeModifier, unlock);
    4511             : }
    4512             : 
    4513             : // DQ (11/27/2009): I have moved this member function definition to outside of the
    4514             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
    4515             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
    4516             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
    4517             : // Also, note comment below from Robb (copied from the Common.code file).
    4518             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
    4519             : //
    4520             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
    4521             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
    4522             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
    4523             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
    4524             : #if 0
    4525             : void SgOpenclAccessModeModifier::operator delete(void* pointer) { SgOpenclAccessModeModifier::operator delete (pointer, sizeof(SgOpenclAccessModeModifier)); };
    4526             : #endif
    4527             : /* #line 4528 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
    4528             : 
    4529             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
    4530             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
    4531             : // obviously imply C++.
    4532             : 
    4533             : // This implements the support within ROSE for memory pools.  Memory pools
    4534             : // support the most condensed usage of memory within the construction of
    4535             : // and AST. Large blocks of contiguous storage for each RI node is allocated
    4536             : // by a new operator written for each class.
    4537             : 
    4538             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
    4539             :     // User wants multi-thread support and POSIX threads are available.
    4540             : #   include <pthread.h>
    4541             :     static pthread_mutex_t SgName_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
    4542             : #else
    4543             :      // Cause synchronization to be skipped.
    4544             : #    ifndef ALLOC_MUTEX
    4545             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
    4546             : #    endif
    4547             : #    ifdef _REENTRANT
    4548             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
    4549             : #       ifdef _MSC_VER
    4550             : #           pragma message("POSIX threads are not available; synchronization being skipped")
    4551             : #       else
    4552             : #           warning "POSIX threads are not available; synchronization being skipped"
    4553             : #       endif
    4554             : #    endif
    4555             : #endif
    4556             : 
    4557             : #ifndef ROSE_ALLOC_TRACE
    4558             : #  define ROSE_ALLOC_TRACE 0
    4559             : #endif
    4560             : 
    4561             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
    4562             : #define ROSE_ALLOC_TRACE_CNT
    4563             : #include "memory-pool-snapshot.h"
    4564             : unsigned long alloc_trace_cnt = 0;
    4565             : #endif
    4566             : 
    4567             : #if ROSE_ALLOC_TRACE
    4568             : const unsigned SgName::pool_size = 5;
    4569             : #else
    4570             : const unsigned SgName::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
    4571             : #endif
    4572             : 
    4573             : #ifndef ROSE_ALLOC_MEMSET
    4574             : #  define ROSE_ALLOC_MEMSET 0
    4575             : #endif
    4576             : 
    4577             : #ifndef ROSE_PEDANTIC_ALLOC
    4578             : #  define ROSE_PEDANTIC_ALLOC 0
    4579             : #endif
    4580             : 
    4581             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
    4582             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
    4583             : #endif
    4584             : 
    4585             : #if !defined(SGNODE__ALL_POOLS)
    4586             : #define SGNODE__ALL_POOLS
    4587             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
    4588             : #endif
    4589             : 
    4590             : SgName* SgName::next_node = nullptr;
    4591             : std::vector<unsigned char*> SgName::pools;
    4592             : 
    4593             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
    4594             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
    4595             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
    4596             : // around this macro definition rather than each use).
    4597             : #ifndef ALLOC_MUTEX
    4598             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
    4599             :         do {                                                                     \
    4600             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
    4601             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
    4602             :                 abort();                                                         \
    4603             :             }                                                                    \
    4604             :         } while (0);
    4605             : #endif
    4606             : 
    4607             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
    4608             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
    4609             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
    4610             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
    4611             : 
    4612             : /*! \brief New operator for SgName.
    4613             : 
    4614             :    This new operator implements memory pools to provide most efficent 
    4615             :    use of the heap within construction of large ASTs.
    4616             : 
    4617             : \internal The new and delete operators use the lower level C malloc/free
    4618             :    function calls for performance and to make sure that mixing of malloc/free
    4619             :    and new/delete by the used can be caught more readily.  This may change
    4620             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
    4621             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
    4622             :    deallocate memory allocated using ROSE_MALLOC.
    4623             : */
    4624          28 : void *SgName::operator new ( size_t Size )
    4625             : {
    4626             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
    4627             :      * returning or throwing an exception. */
    4628          28 :     ALLOC_MUTEX(SgName, lock);
    4629             : 
    4630             : #if ROSE_ALLOC_TRACE == 2
    4631             : //    printf("SgName::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgName::next_node);
    4632             : #endif
    4633             : 
    4634             : #if USE_CPP_NEW_DELETE_OPERATORS
    4635             :     void *mem = ROSE_MALLOC(Size);
    4636             :     ALLOC_MUTEX(SgName, unlock);
    4637             :     return mem;
    4638             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
    4639             : #if ROSE_PEDANTIC_ALLOC
    4640             :     ROSE_ASSERT(Size == sizeof(SgName));
    4641             : #else
    4642          28 :     if (Size != sizeof(SgName)) {
    4643           0 :       void * object = ROSE_MALLOC(Size);
    4644           0 :       ALLOC_MUTEX(SgName, unlock);
    4645             :       return object;
    4646             :     }
    4647             : #endif
    4648             : 
    4649          28 :     if (SgName::next_node == nullptr) {
    4650           1 :         SgName * alloc = (SgName*) ROSE_MALLOC ( SgName::pool_size * sizeof(SgName) );
    4651           1 :         ROSE_ASSERT(alloc != nullptr);
    4652             : 
    4653             : #if ROSE_ALLOC_TRACE == 2
    4654             : //        printf("SgName::alloc\n  block[%zi] = [ %p , %p [\n", SgName::pools.size(), alloc, alloc + SgName::pool_size);
    4655             : #endif
    4656             : 
    4657             : #if ROSE_ALLOC_MEMSET == 1
    4658             : #elif ROSE_ALLOC_MEMSET == 2
    4659             :         memset(alloc, 0x00, SgName::pool_size * sizeof(SgName));
    4660             : #elif ROSE_ALLOC_MEMSET == 3
    4661             :         memset(alloc, 0xAA, SgName::pool_size * sizeof(SgName));
    4662             : #endif
    4663        2000 :         for (unsigned i=0; i < SgName::pool_size-1; i++) {
    4664        1999 :           alloc[i].p_freepointer = &(alloc[i+1]);
    4665             :         }
    4666           1 :         alloc[SgName::pool_size-1].p_freepointer = nullptr;
    4667             : 
    4668           1 :         SgName::pools.push_back ( (unsigned char *) alloc );
    4669           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgName::pool_size * sizeof(SgName), V_SgName ) );
    4670           1 :         SgName::next_node = alloc;
    4671             :     }
    4672          28 :     ROSE_ASSERT(SgName::next_node != nullptr);
    4673             : 
    4674          28 :     SgName * object = SgName::next_node;
    4675          28 :     SgName::next_node = (SgName*)(object->p_freepointer);
    4676             : 
    4677             : #if ROSE_ALLOC_TRACE == 2
    4678             :     printf("SgName::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgName::next_node);
    4679             : #endif
    4680             : 
    4681          28 :     SgNode * fp = object->p_freepointer;
    4682             : #if ROSE_ALLOC_MEMSET == 1
    4683             : #elif ROSE_ALLOC_MEMSET == 2
    4684             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgName) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
    4685             : #elif ROSE_ALLOC_MEMSET == 3
    4686             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgName) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
    4687             : #endif
    4688          28 :     object->p_freepointer = fp;
    4689             : 
    4690             : #if ROSE_ALLOC_TRACE == 2
    4691             : //    printf("SgName::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgName::next_node);
    4692             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
    4693             :     Rose::MemPool::snapshot(oss.str());
    4694             :     alloc_trace_cnt++;
    4695             : #endif
    4696             : 
    4697          28 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
    4698             : 
    4699          28 :     ALLOC_MUTEX(SgName, unlock);
    4700             : 
    4701             :     return object;
    4702             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
    4703             : }
    4704             : 
    4705             : 
    4706             : 
    4707             : /*! \brief Delete operator for SgName.
    4708             : 
    4709             :    This delete operator implements deallocation using memory pools to 
    4710             :    provide most efficent use of the heap within construction of large ASTs.
    4711             : 
    4712             : \internal The new and delete operators use the lower level C malloc/free
    4713             :    function calls for performance and to make sure that mixing of malloc/free
    4714             :    and new/delete by the used can be caught more readily.  This may change
    4715             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
    4716             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
    4717             :    deallocate memory allocated using ROSE_MALLOC.
    4718             : */
    4719           0 : void SgName::operator delete(void *Pointer, size_t Size)
    4720             : {
    4721             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
    4722             :      * or throwing an exception. */
    4723           0 :     ALLOC_MUTEX(SgName, lock);
    4724             : 
    4725             : #if USE_CPP_NEW_DELETE_OPERATORS
    4726             :     ROSE_FREE(Pointer);
    4727             : #else
    4728             : #if ROSE_PEDANTIC_ALLOC
    4729             :     ROSE_ASSERT(Size == sizeof(SgName));
    4730             : #else
    4731           0 :     if (Size != sizeof(SgName)) {
    4732           0 :       ROSE_FREE(Pointer);
    4733           0 :       ALLOC_MUTEX(SgName, unlock);
    4734             :       return;
    4735             :     }
    4736             : #endif
    4737             : 
    4738           0 :     SgName * object = (SgName*) Pointer;
    4739           0 :     ROSE_ASSERT(object != nullptr);
    4740             : 
    4741             : #if ROSE_ALLOC_TRACE == 2
    4742             : //  printf("SgName::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgName::next_node);
    4743             :     printf("SgName::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgName::next_node);
    4744             : #endif
    4745             : 
    4746             : #if ROSE_PEDANTIC_ALLOC
    4747             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
    4748             : #endif
    4749             : 
    4750             : #if ROSE_ALLOC_MEMSET == 1
    4751             : #elif ROSE_ALLOC_MEMSET == 2
    4752             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgName) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
    4753             : #elif ROSE_ALLOC_MEMSET == 3
    4754             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgName) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
    4755             : #endif
    4756             : 
    4757             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
    4758             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
    4759             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
    4760             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
    4761             : #else
    4762           0 :     object->p_freepointer = SgName::next_node;
    4763           0 :     SgName::next_node = object;
    4764             : #endif
    4765             : 
    4766             : #if ROSE_ALLOC_TRACE == 2
    4767             : //  printf("SgName::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgName::next_node);
    4768             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
    4769             :     Rose::MemPool::snapshot(oss.str());
    4770             :     alloc_trace_cnt++;
    4771             : #endif
    4772             : 
    4773             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
    4774             : 
    4775           0 :     ALLOC_MUTEX(SgName, unlock);
    4776             : }
    4777             : 
    4778             : // DQ (11/27/2009): I have moved this member function definition to outside of the
    4779             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
    4780             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
    4781             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
    4782             : // Also, note comment below from Robb (copied from the Common.code file).
    4783             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
    4784             : //
    4785             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
    4786             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
    4787             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
    4788             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
    4789             : #if 0
    4790             : void SgName::operator delete(void* pointer) { SgName::operator delete (pointer, sizeof(SgName)); };
    4791             : #endif
    4792             : /* #line 4793 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
    4793             : 
    4794             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
    4795             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
    4796             : // obviously imply C++.
    4797             : 
    4798             : // This implements the support within ROSE for memory pools.  Memory pools
    4799             : // support the most condensed usage of memory within the construction of
    4800             : // and AST. Large blocks of contiguous storage for each RI node is allocated
    4801             : // by a new operator written for each class.
    4802             : 
    4803             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
    4804             :     // User wants multi-thread support and POSIX threads are available.
    4805             : #   include <pthread.h>
    4806             :     static pthread_mutex_t SgSymbolTable_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
    4807             : #else
    4808             :      // Cause synchronization to be skipped.
    4809             : #    ifndef ALLOC_MUTEX
    4810             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
    4811             : #    endif
    4812             : #    ifdef _REENTRANT
    4813             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
    4814             : #       ifdef _MSC_VER
    4815             : #           pragma message("POSIX threads are not available; synchronization being skipped")
    4816             : #       else
    4817             : #           warning "POSIX threads are not available; synchronization being skipped"
    4818             : #       endif
    4819             : #    endif
    4820             : #endif
    4821             : 
    4822             : #ifndef ROSE_ALLOC_TRACE
    4823             : #  define ROSE_ALLOC_TRACE 0
    4824             : #endif
    4825             : 
    4826             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
    4827             : #define ROSE_ALLOC_TRACE_CNT
    4828             : #include "memory-pool-snapshot.h"
    4829             : unsigned long alloc_trace_cnt = 0;
    4830             : #endif
    4831             : 
    4832             : #if ROSE_ALLOC_TRACE
    4833             : const unsigned SgSymbolTable::pool_size = 5;
    4834             : #else
    4835             : const unsigned SgSymbolTable::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
    4836             : #endif
    4837             : 
    4838             : #ifndef ROSE_ALLOC_MEMSET
    4839             : #  define ROSE_ALLOC_MEMSET 0
    4840             : #endif
    4841             : 
    4842             : #ifndef ROSE_PEDANTIC_ALLOC
    4843             : #  define ROSE_PEDANTIC_ALLOC 0
    4844             : #endif
    4845             : 
    4846             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
    4847             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
    4848             : #endif
    4849             : 
    4850             : #if !defined(SGNODE__ALL_POOLS)
    4851             : #define SGNODE__ALL_POOLS
    4852             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
    4853             : #endif
    4854             : 
    4855             : SgSymbolTable* SgSymbolTable::next_node = nullptr;
    4856             : std::vector<unsigned char*> SgSymbolTable::pools;
    4857             : 
    4858             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
    4859             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
    4860             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
    4861             : // around this macro definition rather than each use).
    4862             : #ifndef ALLOC_MUTEX
    4863             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
    4864             :         do {                                                                     \
    4865             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
    4866             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
    4867             :                 abort();                                                         \
    4868             :             }                                                                    \
    4869             :         } while (0);
    4870             : #endif
    4871             : 
    4872             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
    4873             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
    4874             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
    4875             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
    4876             : 
    4877             : /*! \brief New operator for SgSymbolTable.
    4878             : 
    4879             :    This new operator implements memory pools to provide most efficent 
    4880             :    use of the heap within construction of large ASTs.
    4881             : 
    4882             : \internal The new and delete operators use the lower level C malloc/free
    4883             :    function calls for performance and to make sure that mixing of malloc/free
    4884             :    and new/delete by the used can be caught more readily.  This may change
    4885             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
    4886             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
    4887             :    deallocate memory allocated using ROSE_MALLOC.
    4888             : */
    4889      304102 : void *SgSymbolTable::operator new ( size_t Size )
    4890             : {
    4891             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
    4892             :      * returning or throwing an exception. */
    4893      304102 :     ALLOC_MUTEX(SgSymbolTable, lock);
    4894             : 
    4895             : #if ROSE_ALLOC_TRACE == 2
    4896             : //    printf("SgSymbolTable::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgSymbolTable::next_node);
    4897             : #endif
    4898             : 
    4899             : #if USE_CPP_NEW_DELETE_OPERATORS
    4900             :     void *mem = ROSE_MALLOC(Size);
    4901             :     ALLOC_MUTEX(SgSymbolTable, unlock);
    4902             :     return mem;
    4903             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
    4904             : #if ROSE_PEDANTIC_ALLOC
    4905             :     ROSE_ASSERT(Size == sizeof(SgSymbolTable));
    4906             : #else
    4907      304102 :     if (Size != sizeof(SgSymbolTable)) {
    4908           0 :       void * object = ROSE_MALLOC(Size);
    4909           0 :       ALLOC_MUTEX(SgSymbolTable, unlock);
    4910             :       return object;
    4911             :     }
    4912             : #endif
    4913             : 
    4914      304102 :     if (SgSymbolTable::next_node == nullptr) {
    4915         477 :         SgSymbolTable * alloc = (SgSymbolTable*) ROSE_MALLOC ( SgSymbolTable::pool_size * sizeof(SgSymbolTable) );
    4916         477 :         ROSE_ASSERT(alloc != nullptr);
    4917             : 
    4918             : #if ROSE_ALLOC_TRACE == 2
    4919             : //        printf("SgSymbolTable::alloc\n  block[%zi] = [ %p , %p [\n", SgSymbolTable::pools.size(), alloc, alloc + SgSymbolTable::pool_size);
    4920             : #endif
    4921             : 
    4922             : #if ROSE_ALLOC_MEMSET == 1
    4923             : #elif ROSE_ALLOC_MEMSET == 2
    4924             :         memset(alloc, 0x00, SgSymbolTable::pool_size * sizeof(SgSymbolTable));
    4925             : #elif ROSE_ALLOC_MEMSET == 3
    4926             :         memset(alloc, 0xAA, SgSymbolTable::pool_size * sizeof(SgSymbolTable));
    4927             : #endif
    4928      954000 :         for (unsigned i=0; i < SgSymbolTable::pool_size-1; i++) {
    4929      953523 :           alloc[i].p_freepointer = &(alloc[i+1]);
    4930             :         }
    4931         477 :         alloc[SgSymbolTable::pool_size-1].p_freepointer = nullptr;
    4932             : 
    4933         477 :         SgSymbolTable::pools.push_back ( (unsigned char *) alloc );
    4934         477 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgSymbolTable::pool_size * sizeof(SgSymbolTable), V_SgSymbolTable ) );
    4935         477 :         SgSymbolTable::next_node = alloc;
    4936             :     }
    4937      304102 :     ROSE_ASSERT(SgSymbolTable::next_node != nullptr);
    4938             : 
    4939      304102 :     SgSymbolTable * object = SgSymbolTable::next_node;
    4940      304102 :     SgSymbolTable::next_node = (SgSymbolTable*)(object->p_freepointer);
    4941             : 
    4942             : #if ROSE_ALLOC_TRACE == 2
    4943             :     printf("SgSymbolTable::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgSymbolTable::next_node);
    4944             : #endif
    4945             : 
    4946      304102 :     SgNode * fp = object->p_freepointer;
    4947             : #if ROSE_ALLOC_MEMSET == 1
    4948             : #elif ROSE_ALLOC_MEMSET == 2
    4949             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgSymbolTable) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
    4950             : #elif ROSE_ALLOC_MEMSET == 3
    4951             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgSymbolTable) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
    4952             : #endif
    4953      304102 :     object->p_freepointer = fp;
    4954             : 
    4955             : #if ROSE_ALLOC_TRACE == 2
    4956             : //    printf("SgSymbolTable::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgSymbolTable::next_node);
    4957             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
    4958             :     Rose::MemPool::snapshot(oss.str());
    4959             :     alloc_trace_cnt++;
    4960             : #endif
    4961             : 
    4962      304102 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
    4963             : 
    4964      304102 :     ALLOC_MUTEX(SgSymbolTable, unlock);
    4965             : 
    4966             :     return object;
    4967             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
    4968             : }
    4969             : 
    4970             : 
    4971             : 
    4972             : /*! \brief Delete operator for SgSymbolTable.
    4973             : 
    4974             :    This delete operator implements deallocation using memory pools to 
    4975             :    provide most efficent use of the heap within construction of large ASTs.
    4976             : 
    4977             : \internal The new and delete operators use the lower level C malloc/free
    4978             :    function calls for performance and to make sure that mixing of malloc/free
    4979             :    and new/delete by the used can be caught more readily.  This may change
    4980             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
    4981             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
    4982             :    deallocate memory allocated using ROSE_MALLOC.
    4983             : */
    4984       54458 : void SgSymbolTable::operator delete(void *Pointer, size_t Size)
    4985             : {
    4986             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
    4987             :      * or throwing an exception. */
    4988       54458 :     ALLOC_MUTEX(SgSymbolTable, lock);
    4989             : 
    4990             : #if USE_CPP_NEW_DELETE_OPERATORS
    4991             :     ROSE_FREE(Pointer);
    4992             : #else
    4993             : #if ROSE_PEDANTIC_ALLOC
    4994             :     ROSE_ASSERT(Size == sizeof(SgSymbolTable));
    4995             : #else
    4996       54458 :     if (Size != sizeof(SgSymbolTable)) {
    4997           0 :       ROSE_FREE(Pointer);
    4998           0 :       ALLOC_MUTEX(SgSymbolTable, unlock);
    4999             :       return;
    5000             :     }
    5001             : #endif
    5002             : 
    5003       54458 :     SgSymbolTable * object = (SgSymbolTable*) Pointer;
    5004       54458 :     ROSE_ASSERT(object != nullptr);
    5005             : 
    5006             : #if ROSE_ALLOC_TRACE == 2
    5007             : //  printf("SgSymbolTable::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgSymbolTable::next_node);
    5008             :     printf("SgSymbolTable::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgSymbolTable::next_node);
    5009             : #endif
    5010             : 
    5011             : #if ROSE_PEDANTIC_ALLOC
    5012             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
    5013             : #endif
    5014             : 
    5015             : #if ROSE_ALLOC_MEMSET == 1
    5016             : #elif ROSE_ALLOC_MEMSET == 2
    5017             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgSymbolTable) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
    5018             : #elif ROSE_ALLOC_MEMSET == 3
    5019             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgSymbolTable) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
    5020             : #endif
    5021             : 
    5022             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
    5023             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
    5024             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
    5025             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
    5026             : #else
    5027       54458 :     object->p_freepointer = SgSymbolTable::next_node;
    5028       54458 :     SgSymbolTable::next_node = object;
    5029             : #endif
    5030             : 
    5031             : #if ROSE_ALLOC_TRACE == 2
    5032             : //  printf("SgSymbolTable::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgSymbolTable::next_node);
    5033             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
    5034             :     Rose::MemPool::snapshot(oss.str());
    5035             :     alloc_trace_cnt++;
    5036             : #endif
    5037             : 
    5038             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
    5039             : 
    5040       54458 :     ALLOC_MUTEX(SgSymbolTable, unlock);
    5041             : }
    5042             : 
    5043             : // DQ (11/27/2009): I have moved this member function definition to outside of the
    5044             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
    5045             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
    5046             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
    5047             : // Also, note comment below from Robb (copied from the Common.code file).
    5048             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
    5049             : //
    5050             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
    5051             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
    5052             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
    5053             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
    5054             : #if 0
    5055             : void SgSymbolTable::operator delete(void* pointer) { SgSymbolTable::operator delete (pointer, sizeof(SgSymbolTable)); };
    5056             : #endif
    5057             : /* #line 5058 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
    5058             : 
    5059             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
    5060             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
    5061             : // obviously imply C++.
    5062             : 
    5063             : // This implements the support within ROSE for memory pools.  Memory pools
    5064             : // support the most condensed usage of memory within the construction of
    5065             : // and AST. Large blocks of contiguous storage for each RI node is allocated
    5066             : // by a new operator written for each class.
    5067             : 
    5068             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
    5069             :     // User wants multi-thread support and POSIX threads are available.
    5070             : #   include <pthread.h>
    5071             :     static pthread_mutex_t SgAttribute_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
    5072             : #else
    5073             :      // Cause synchronization to be skipped.
    5074             : #    ifndef ALLOC_MUTEX
    5075             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
    5076             : #    endif
    5077             : #    ifdef _REENTRANT
    5078             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
    5079             : #       ifdef _MSC_VER
    5080             : #           pragma message("POSIX threads are not available; synchronization being skipped")
    5081             : #       else
    5082             : #           warning "POSIX threads are not available; synchronization being skipped"
    5083             : #       endif
    5084             : #    endif
    5085             : #endif
    5086             : 
    5087             : #ifndef ROSE_ALLOC_TRACE
    5088             : #  define ROSE_ALLOC_TRACE 0
    5089             : #endif
    5090             : 
    5091             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
    5092             : #define ROSE_ALLOC_TRACE_CNT
    5093             : #include "memory-pool-snapshot.h"
    5094             : unsigned long alloc_trace_cnt = 0;
    5095             : #endif
    5096             : 
    5097             : #if ROSE_ALLOC_TRACE
    5098             : const unsigned SgAttribute::pool_size = 5;
    5099             : #else
    5100             : const unsigned SgAttribute::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
    5101             : #endif
    5102             : 
    5103             : #ifndef ROSE_ALLOC_MEMSET
    5104             : #  define ROSE_ALLOC_MEMSET 0
    5105             : #endif
    5106             : 
    5107             : #ifndef ROSE_PEDANTIC_ALLOC
    5108             : #  define ROSE_PEDANTIC_ALLOC 0
    5109             : #endif
    5110             : 
    5111             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
    5112             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
    5113             : #endif
    5114             : 
    5115             : #if !defined(SGNODE__ALL_POOLS)
    5116             : #define SGNODE__ALL_POOLS
    5117             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
    5118             : #endif
    5119             : 
    5120             : SgAttribute* SgAttribute::next_node = nullptr;
    5121             : std::vector<unsigned char*> SgAttribute::pools;
    5122             : 
    5123             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
    5124             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
    5125             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
    5126             : // around this macro definition rather than each use).
    5127             : #ifndef ALLOC_MUTEX
    5128             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
    5129             :         do {                                                                     \
    5130             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
    5131             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
    5132             :                 abort();                                                         \
    5133             :             }                                                                    \
    5134             :         } while (0);
    5135             : #endif
    5136             : 
    5137             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
    5138             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
    5139             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
    5140             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
    5141             : 
    5142             : /*! \brief New operator for SgAttribute.
    5143             : 
    5144             :    This new operator implements memory pools to provide most efficent 
    5145             :    use of the heap within construction of large ASTs.
    5146             : 
    5147             : \internal The new and delete operators use the lower level C malloc/free
    5148             :    function calls for performance and to make sure that mixing of malloc/free
    5149             :    and new/delete by the used can be caught more readily.  This may change
    5150             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
    5151             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
    5152             :    deallocate memory allocated using ROSE_MALLOC.
    5153             : */
    5154           0 : void *SgAttribute::operator new ( size_t Size )
    5155             : {
    5156             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
    5157             :      * returning or throwing an exception. */
    5158           0 :     ALLOC_MUTEX(SgAttribute, lock);
    5159             : 
    5160             : #if ROSE_ALLOC_TRACE == 2
    5161             : //    printf("SgAttribute::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgAttribute::next_node);
    5162             : #endif
    5163             : 
    5164             : #if USE_CPP_NEW_DELETE_OPERATORS
    5165             :     void *mem = ROSE_MALLOC(Size);
    5166             :     ALLOC_MUTEX(SgAttribute, unlock);
    5167             :     return mem;
    5168             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
    5169             : #if ROSE_PEDANTIC_ALLOC
    5170             :     ROSE_ASSERT(Size == sizeof(SgAttribute));
    5171             : #else
    5172           0 :     if (Size != sizeof(SgAttribute)) {
    5173           0 :       void * object = ROSE_MALLOC(Size);
    5174           0 :       ALLOC_MUTEX(SgAttribute, unlock);
    5175             :       return object;
    5176             :     }
    5177             : #endif
    5178             : 
    5179           0 :     if (SgAttribute::next_node == nullptr) {
    5180           0 :         SgAttribute * alloc = (SgAttribute*) ROSE_MALLOC ( SgAttribute::pool_size * sizeof(SgAttribute) );
    5181           0 :         ROSE_ASSERT(alloc != nullptr);
    5182             : 
    5183             : #if ROSE_ALLOC_TRACE == 2
    5184             : //        printf("SgAttribute::alloc\n  block[%zi] = [ %p , %p [\n", SgAttribute::pools.size(), alloc, alloc + SgAttribute::pool_size);
    5185             : #endif
    5186             : 
    5187             : #if ROSE_ALLOC_MEMSET == 1
    5188             : #elif ROSE_ALLOC_MEMSET == 2
    5189             :         memset(alloc, 0x00, SgAttribute::pool_size * sizeof(SgAttribute));
    5190             : #elif ROSE_ALLOC_MEMSET == 3
    5191             :         memset(alloc, 0xAA, SgAttribute::pool_size * sizeof(SgAttribute));
    5192             : #endif
    5193           0 :         for (unsigned i=0; i < SgAttribute::pool_size-1; i++) {
    5194           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
    5195             :         }
    5196           0 :         alloc[SgAttribute::pool_size-1].p_freepointer = nullptr;
    5197             : 
    5198           0 :         SgAttribute::pools.push_back ( (unsigned char *) alloc );
    5199           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgAttribute::pool_size * sizeof(SgAttribute), V_SgAttribute ) );
    5200           0 :         SgAttribute::next_node = alloc;
    5201             :     }
    5202           0 :     ROSE_ASSERT(SgAttribute::next_node != nullptr);
    5203             : 
    5204           0 :     SgAttribute * object = SgAttribute::next_node;
    5205           0 :     SgAttribute::next_node = (SgAttribute*)(object->p_freepointer);
    5206             : 
    5207             : #if ROSE_ALLOC_TRACE == 2
    5208             :     printf("SgAttribute::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgAttribute::next_node);
    5209             : #endif
    5210             : 
    5211           0 :     SgNode * fp = object->p_freepointer;
    5212             : #if ROSE_ALLOC_MEMSET == 1
    5213             : #elif ROSE_ALLOC_MEMSET == 2
    5214             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgAttribute) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
    5215             : #elif ROSE_ALLOC_MEMSET == 3
    5216             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgAttribute) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
    5217             : #endif
    5218           0 :     object->p_freepointer = fp;
    5219             : 
    5220             : #if ROSE_ALLOC_TRACE == 2
    5221             : //    printf("SgAttribute::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgAttribute::next_node);
    5222             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
    5223             :     Rose::MemPool::snapshot(oss.str());
    5224             :     alloc_trace_cnt++;
    5225             : #endif
    5226             : 
    5227           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
    5228             : 
    5229           0 :     ALLOC_MUTEX(SgAttribute, unlock);
    5230             : 
    5231             :     return object;
    5232             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
    5233             : }
    5234             : 
    5235             : 
    5236             : 
    5237             : /*! \brief Delete operator for SgAttribute.
    5238             : 
    5239             :    This delete operator implements deallocation using memory pools to 
    5240             :    provide most efficent use of the heap within construction of large ASTs.
    5241             : 
    5242             : \internal The new and delete operators use the lower level C malloc/free
    5243             :    function calls for performance and to make sure that mixing of malloc/free
    5244             :    and new/delete by the used can be caught more readily.  This may change
    5245             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
    5246             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
    5247             :    deallocate memory allocated using ROSE_MALLOC.
    5248             : */
    5249           0 : void SgAttribute::operator delete(void *Pointer, size_t Size)
    5250             : {
    5251             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
    5252             :      * or throwing an exception. */
    5253           0 :     ALLOC_MUTEX(SgAttribute, lock);
    5254             : 
    5255             : #if USE_CPP_NEW_DELETE_OPERATORS
    5256             :     ROSE_FREE(Pointer);
    5257             : #else
    5258             : #if ROSE_PEDANTIC_ALLOC
    5259             :     ROSE_ASSERT(Size == sizeof(SgAttribute));
    5260             : #else
    5261           0 :     if (Size != sizeof(SgAttribute)) {
    5262           0 :       ROSE_FREE(Pointer);
    5263           0 :       ALLOC_MUTEX(SgAttribute, unlock);
    5264             :       return;
    5265             :     }
    5266             : #endif
    5267             : 
    5268           0 :     SgAttribute * object = (SgAttribute*) Pointer;
    5269           0 :     ROSE_ASSERT(object != nullptr);
    5270             : 
    5271             : #if ROSE_ALLOC_TRACE == 2
    5272             : //  printf("SgAttribute::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgAttribute::next_node);
    5273             :     printf("SgAttribute::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgAttribute::next_node);
    5274             : #endif
    5275             : 
    5276             : #if ROSE_PEDANTIC_ALLOC
    5277             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
    5278             : #endif
    5279             : 
    5280             : #if ROSE_ALLOC_MEMSET == 1
    5281             : #elif ROSE_ALLOC_MEMSET == 2
    5282             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgAttribute) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
    5283             : #elif ROSE_ALLOC_MEMSET == 3
    5284             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgAttribute) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
    5285             : #endif
    5286             : 
    5287             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
    5288             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
    5289             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
    5290             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
    5291             : #else
    5292           0 :     object->p_freepointer = SgAttribute::next_node;
    5293           0 :     SgAttribute::next_node = object;
    5294             : #endif
    5295             : 
    5296             : #if ROSE_ALLOC_TRACE == 2
    5297             : //  printf("SgAttribute::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgAttribute::next_node);
    5298             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
    5299             :     Rose::MemPool::snapshot(oss.str());
    5300             :     alloc_trace_cnt++;
    5301             : #endif
    5302             : 
    5303             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
    5304             : 
    5305           0 :     ALLOC_MUTEX(SgAttribute, unlock);
    5306             : }
    5307             : 
    5308             : // DQ (11/27/2009): I have moved this member function definition to outside of the
    5309             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
    5310             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
    5311             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
    5312             : // Also, note comment below from Robb (copied from the Common.code file).
    5313             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
    5314             : //
    5315             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
    5316             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
    5317             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
    5318             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
    5319             : #if 0
    5320             : void SgAttribute::operator delete(void* pointer) { SgAttribute::operator delete (pointer, sizeof(SgAttribute)); };
    5321             : #endif
    5322             : /* #line 5323 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
    5323             : 
    5324             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
    5325             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
    5326             : // obviously imply C++.
    5327             : 
    5328             : // This implements the support within ROSE for memory pools.  Memory pools
    5329             : // support the most condensed usage of memory within the construction of
    5330             : // and AST. Large blocks of contiguous storage for each RI node is allocated
    5331             : // by a new operator written for each class.
    5332             : 
    5333             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
    5334             :     // User wants multi-thread support and POSIX threads are available.
    5335             : #   include <pthread.h>
    5336             :     static pthread_mutex_t SgPragma_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
    5337             : #else
    5338             :      // Cause synchronization to be skipped.
    5339             : #    ifndef ALLOC_MUTEX
    5340             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
    5341             : #    endif
    5342             : #    ifdef _REENTRANT
    5343             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
    5344             : #       ifdef _MSC_VER
    5345             : #           pragma message("POSIX threads are not available; synchronization being skipped")
    5346             : #       else
    5347             : #           warning "POSIX threads are not available; synchronization being skipped"
    5348             : #       endif
    5349             : #    endif
    5350             : #endif
    5351             : 
    5352             : #ifndef ROSE_ALLOC_TRACE
    5353             : #  define ROSE_ALLOC_TRACE 0
    5354             : #endif
    5355             : 
    5356             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
    5357             : #define ROSE_ALLOC_TRACE_CNT
    5358             : #include "memory-pool-snapshot.h"
    5359             : unsigned long alloc_trace_cnt = 0;
    5360             : #endif
    5361             : 
    5362             : #if ROSE_ALLOC_TRACE
    5363             : const unsigned SgPragma::pool_size = 5;
    5364             : #else
    5365             : const unsigned SgPragma::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
    5366             : #endif
    5367             : 
    5368             : #ifndef ROSE_ALLOC_MEMSET
    5369             : #  define ROSE_ALLOC_MEMSET 0
    5370             : #endif
    5371             : 
    5372             : #ifndef ROSE_PEDANTIC_ALLOC
    5373             : #  define ROSE_PEDANTIC_ALLOC 0
    5374             : #endif
    5375             : 
    5376             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
    5377             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
    5378             : #endif
    5379             : 
    5380             : #if !defined(SGNODE__ALL_POOLS)
    5381             : #define SGNODE__ALL_POOLS
    5382             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
    5383             : #endif
    5384             : 
    5385             : SgPragma* SgPragma::next_node = nullptr;
    5386             : std::vector<unsigned char*> SgPragma::pools;
    5387             : 
    5388             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
    5389             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
    5390             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
    5391             : // around this macro definition rather than each use).
    5392             : #ifndef ALLOC_MUTEX
    5393             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
    5394             :         do {                                                                     \
    5395             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
    5396             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
    5397             :                 abort();                                                         \
    5398             :             }                                                                    \
    5399             :         } while (0);
    5400             : #endif
    5401             : 
    5402             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
    5403             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
    5404             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
    5405             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
    5406             : 
    5407             : /*! \brief New operator for SgPragma.
    5408             : 
    5409             :    This new operator implements memory pools to provide most efficent 
    5410             :    use of the heap within construction of large ASTs.
    5411             : 
    5412             : \internal The new and delete operators use the lower level C malloc/free
    5413             :    function calls for performance and to make sure that mixing of malloc/free
    5414             :    and new/delete by the used can be caught more readily.  This may change
    5415             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
    5416             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
    5417             :    deallocate memory allocated using ROSE_MALLOC.
    5418             : */
    5419        1926 : void *SgPragma::operator new ( size_t Size )
    5420             : {
    5421             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
    5422             :      * returning or throwing an exception. */
    5423        1926 :     ALLOC_MUTEX(SgPragma, lock);
    5424             : 
    5425             : #if ROSE_ALLOC_TRACE == 2
    5426             : //    printf("SgPragma::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgPragma::next_node);
    5427             : #endif
    5428             : 
    5429             : #if USE_CPP_NEW_DELETE_OPERATORS
    5430             :     void *mem = ROSE_MALLOC(Size);
    5431             :     ALLOC_MUTEX(SgPragma, unlock);
    5432             :     return mem;
    5433             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
    5434             : #if ROSE_PEDANTIC_ALLOC
    5435             :     ROSE_ASSERT(Size == sizeof(SgPragma));
    5436             : #else
    5437        1926 :     if (Size != sizeof(SgPragma)) {
    5438           0 :       void * object = ROSE_MALLOC(Size);
    5439           0 :       ALLOC_MUTEX(SgPragma, unlock);
    5440             :       return object;
    5441             :     }
    5442             : #endif
    5443             : 
    5444        1926 :     if (SgPragma::next_node == nullptr) {
    5445         276 :         SgPragma * alloc = (SgPragma*) ROSE_MALLOC ( SgPragma::pool_size * sizeof(SgPragma) );
    5446         276 :         ROSE_ASSERT(alloc != nullptr);
    5447             : 
    5448             : #if ROSE_ALLOC_TRACE == 2
    5449             : //        printf("SgPragma::alloc\n  block[%zi] = [ %p , %p [\n", SgPragma::pools.size(), alloc, alloc + SgPragma::pool_size);
    5450             : #endif
    5451             : 
    5452             : #if ROSE_ALLOC_MEMSET == 1
    5453             : #elif ROSE_ALLOC_MEMSET == 2
    5454             :         memset(alloc, 0x00, SgPragma::pool_size * sizeof(SgPragma));
    5455             : #elif ROSE_ALLOC_MEMSET == 3
    5456             :         memset(alloc, 0xAA, SgPragma::pool_size * sizeof(SgPragma));
    5457             : #endif
    5458      552000 :         for (unsigned i=0; i < SgPragma::pool_size-1; i++) {
    5459      551724 :           alloc[i].p_freepointer = &(alloc[i+1]);
    5460             :         }
    5461         276 :         alloc[SgPragma::pool_size-1].p_freepointer = nullptr;
    5462             : 
    5463         276 :         SgPragma::pools.push_back ( (unsigned char *) alloc );
    5464         276 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgPragma::pool_size * sizeof(SgPragma), V_SgPragma ) );
    5465         276 :         SgPragma::next_node = alloc;
    5466             :     }
    5467        1926 :     ROSE_ASSERT(SgPragma::next_node != nullptr);
    5468             : 
    5469        1926 :     SgPragma * object = SgPragma::next_node;
    5470        1926 :     SgPragma::next_node = (SgPragma*)(object->p_freepointer);
    5471             : 
    5472             : #if ROSE_ALLOC_TRACE == 2
    5473             :     printf("SgPragma::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgPragma::next_node);
    5474             : #endif
    5475             : 
    5476        1926 :     SgNode * fp = object->p_freepointer;
    5477             : #if ROSE_ALLOC_MEMSET == 1
    5478             : #elif ROSE_ALLOC_MEMSET == 2
    5479             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgPragma) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
    5480             : #elif ROSE_ALLOC_MEMSET == 3
    5481             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgPragma) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
    5482             : #endif
    5483        1926 :     object->p_freepointer = fp;
    5484             : 
    5485             : #if ROSE_ALLOC_TRACE == 2
    5486             : //    printf("SgPragma::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgPragma::next_node);
    5487             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
    5488             :     Rose::MemPool::snapshot(oss.str());
    5489             :     alloc_trace_cnt++;
    5490             : #endif
    5491             : 
    5492        1926 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
    5493             : 
    5494        1926 :     ALLOC_MUTEX(SgPragma, unlock);
    5495             : 
    5496             :     return object;
    5497             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
    5498             : }
    5499             : 
    5500             : 
    5501             : 
    5502             : /*! \brief Delete operator for SgPragma.
    5503             : 
    5504             :    This delete operator implements deallocation using memory pools to 
    5505             :    provide most efficent use of the heap within construction of large ASTs.
    5506             : 
    5507             : \internal The new and delete operators use the lower level C malloc/free
    5508             :    function calls for performance and to make sure that mixing of malloc/free
    5509             :    and new/delete by the used can be caught more readily.  This may change
    5510             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
    5511             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
    5512             :    deallocate memory allocated using ROSE_MALLOC.
    5513             : */
    5514         194 : void SgPragma::operator delete(void *Pointer, size_t Size)
    5515             : {
    5516             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
    5517             :      * or throwing an exception. */
    5518         194 :     ALLOC_MUTEX(SgPragma, lock);
    5519             : 
    5520             : #if USE_CPP_NEW_DELETE_OPERATORS
    5521             :     ROSE_FREE(Pointer);
    5522             : #else
    5523             : #if ROSE_PEDANTIC_ALLOC
    5524             :     ROSE_ASSERT(Size == sizeof(SgPragma));
    5525             : #else
    5526         194 :     if (Size != sizeof(SgPragma)) {
    5527           0 :       ROSE_FREE(Pointer);
    5528           0 :       ALLOC_MUTEX(SgPragma, unlock);
    5529             :       return;
    5530             :     }
    5531             : #endif
    5532             : 
    5533         194 :     SgPragma * object = (SgPragma*) Pointer;
    5534         194 :     ROSE_ASSERT(object != nullptr);
    5535             : 
    5536             : #if ROSE_ALLOC_TRACE == 2
    5537             : //  printf("SgPragma::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgPragma::next_node);
    5538             :     printf("SgPragma::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgPragma::next_node);
    5539             : #endif
    5540             : 
    5541             : #if ROSE_PEDANTIC_ALLOC
    5542             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
    5543             : #endif
    5544             : 
    5545             : #if ROSE_ALLOC_MEMSET == 1
    5546             : #elif ROSE_ALLOC_MEMSET == 2
    5547             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgPragma) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
    5548             : #elif ROSE_ALLOC_MEMSET == 3
    5549             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgPragma) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
    5550             : #endif
    5551             : 
    5552             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
    5553             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
    5554             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
    5555             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
    5556             : #else
    5557         194 :     object->p_freepointer = SgPragma::next_node;
    5558         194 :     SgPragma::next_node = object;
    5559             : #endif
    5560             : 
    5561             : #if ROSE_ALLOC_TRACE == 2
    5562             : //  printf("SgPragma::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgPragma::next_node);
    5563             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
    5564             :     Rose::MemPool::snapshot(oss.str());
    5565             :     alloc_trace_cnt++;
    5566             : #endif
    5567             : 
    5568             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
    5569             : 
    5570         194 :     ALLOC_MUTEX(SgPragma, unlock);
    5571             : }
    5572             : 
    5573             : // DQ (11/27/2009): I have moved this member function definition to outside of the
    5574             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
    5575             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
    5576             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
    5577             : // Also, note comment below from Robb (copied from the Common.code file).
    5578             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
    5579             : //
    5580             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
    5581             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
    5582             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
    5583             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
    5584             : #if 0
    5585             : void SgPragma::operator delete(void* pointer) { SgPragma::operator delete (pointer, sizeof(SgPragma)); };
    5586             : #endif
    5587             : /* #line 5588 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
    5588             : 
    5589             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
    5590             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
    5591             : // obviously imply C++.
    5592             : 
    5593             : // This implements the support within ROSE for memory pools.  Memory pools
    5594             : // support the most condensed usage of memory within the construction of
    5595             : // and AST. Large blocks of contiguous storage for each RI node is allocated
    5596             : // by a new operator written for each class.
    5597             : 
    5598             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
    5599             :     // User wants multi-thread support and POSIX threads are available.
    5600             : #   include <pthread.h>
    5601             :     static pthread_mutex_t SgBitAttribute_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
    5602             : #else
    5603             :      // Cause synchronization to be skipped.
    5604             : #    ifndef ALLOC_MUTEX
    5605             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
    5606             : #    endif
    5607             : #    ifdef _REENTRANT
    5608             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
    5609             : #       ifdef _MSC_VER
    5610             : #           pragma message("POSIX threads are not available; synchronization being skipped")
    5611             : #       else
    5612             : #           warning "POSIX threads are not available; synchronization being skipped"
    5613             : #       endif
    5614             : #    endif
    5615             : #endif
    5616             : 
    5617             : #ifndef ROSE_ALLOC_TRACE
    5618             : #  define ROSE_ALLOC_TRACE 0
    5619             : #endif
    5620             : 
    5621             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
    5622             : #define ROSE_ALLOC_TRACE_CNT
    5623             : #include "memory-pool-snapshot.h"
    5624             : unsigned long alloc_trace_cnt = 0;
    5625             : #endif
    5626             : 
    5627             : #if ROSE_ALLOC_TRACE
    5628             : const unsigned SgBitAttribute::pool_size = 5;
    5629             : #else
    5630             : const unsigned SgBitAttribute::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
    5631             : #endif
    5632             : 
    5633             : #ifndef ROSE_ALLOC_MEMSET
    5634             : #  define ROSE_ALLOC_MEMSET 0
    5635             : #endif
    5636             : 
    5637             : #ifndef ROSE_PEDANTIC_ALLOC
    5638             : #  define ROSE_PEDANTIC_ALLOC 0
    5639             : #endif
    5640             : 
    5641             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
    5642             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
    5643             : #endif
    5644             : 
    5645             : #if !defined(SGNODE__ALL_POOLS)
    5646             : #define SGNODE__ALL_POOLS
    5647             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
    5648             : #endif
    5649             : 
    5650             : SgBitAttribute* SgBitAttribute::next_node = nullptr;
    5651             : std::vector<unsigned char*> SgBitAttribute::pools;
    5652             : 
    5653             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
    5654             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
    5655             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
    5656             : // around this macro definition rather than each use).
    5657             : #ifndef ALLOC_MUTEX
    5658             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
    5659             :         do {                                                                     \
    5660             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
    5661             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
    5662             :                 abort();                                                         \
    5663             :             }                                                                    \
    5664             :         } while (0);
    5665             : #endif
    5666             : 
    5667             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
    5668             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
    5669             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
    5670             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
    5671             : 
    5672             : /*! \brief New operator for SgBitAttribute.
    5673             : 
    5674             :    This new operator implements memory pools to provide most efficent 
    5675             :    use of the heap within construction of large ASTs.
    5676             : 
    5677             : \internal The new and delete operators use the lower level C malloc/free
    5678             :    function calls for performance and to make sure that mixing of malloc/free
    5679             :    and new/delete by the used can be caught more readily.  This may change
    5680             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
    5681             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
    5682             :    deallocate memory allocated using ROSE_MALLOC.
    5683             : */
    5684           0 : void *SgBitAttribute::operator new ( size_t Size )
    5685             : {
    5686             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
    5687             :      * returning or throwing an exception. */
    5688           0 :     ALLOC_MUTEX(SgBitAttribute, lock);
    5689             : 
    5690             : #if ROSE_ALLOC_TRACE == 2
    5691             : //    printf("SgBitAttribute::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgBitAttribute::next_node);
    5692             : #endif
    5693             : 
    5694             : #if USE_CPP_NEW_DELETE_OPERATORS
    5695             :     void *mem = ROSE_MALLOC(Size);
    5696             :     ALLOC_MUTEX(SgBitAttribute, unlock);
    5697             :     return mem;
    5698             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
    5699             : #if ROSE_PEDANTIC_ALLOC
    5700             :     ROSE_ASSERT(Size == sizeof(SgBitAttribute));
    5701             : #else
    5702           0 :     if (Size != sizeof(SgBitAttribute)) {
    5703           0 :       void * object = ROSE_MALLOC(Size);
    5704           0 :       ALLOC_MUTEX(SgBitAttribute, unlock);
    5705             :       return object;
    5706             :     }
    5707             : #endif
    5708             : 
    5709           0 :     if (SgBitAttribute::next_node == nullptr) {
    5710           0 :         SgBitAttribute * alloc = (SgBitAttribute*) ROSE_MALLOC ( SgBitAttribute::pool_size * sizeof(SgBitAttribute) );
    5711           0 :         ROSE_ASSERT(alloc != nullptr);
    5712             : 
    5713             : #if ROSE_ALLOC_TRACE == 2
    5714             : //        printf("SgBitAttribute::alloc\n  block[%zi] = [ %p , %p [\n", SgBitAttribute::pools.size(), alloc, alloc + SgBitAttribute::pool_size);
    5715             : #endif
    5716             : 
    5717             : #if ROSE_ALLOC_MEMSET == 1
    5718             : #elif ROSE_ALLOC_MEMSET == 2
    5719             :         memset(alloc, 0x00, SgBitAttribute::pool_size * sizeof(SgBitAttribute));
    5720             : #elif ROSE_ALLOC_MEMSET == 3
    5721             :         memset(alloc, 0xAA, SgBitAttribute::pool_size * sizeof(SgBitAttribute));
    5722             : #endif
    5723           0 :         for (unsigned i=0; i < SgBitAttribute::pool_size-1; i++) {
    5724           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
    5725             :         }
    5726           0 :         alloc[SgBitAttribute::pool_size-1].p_freepointer = nullptr;
    5727             : 
    5728           0 :         SgBitAttribute::pools.push_back ( (unsigned char *) alloc );
    5729           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgBitAttribute::pool_size * sizeof(SgBitAttribute), V_SgBitAttribute ) );
    5730           0 :         SgBitAttribute::next_node = alloc;
    5731             :     }
    5732           0 :     ROSE_ASSERT(SgBitAttribute::next_node != nullptr);
    5733             : 
    5734           0 :     SgBitAttribute * object = SgBitAttribute::next_node;
    5735           0 :     SgBitAttribute::next_node = (SgBitAttribute*)(object->p_freepointer);
    5736             : 
    5737             : #if ROSE_ALLOC_TRACE == 2
    5738             :     printf("SgBitAttribute::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgBitAttribute::next_node);
    5739             : #endif
    5740             : 
    5741           0 :     SgNode * fp = object->p_freepointer;
    5742             : #if ROSE_ALLOC_MEMSET == 1
    5743             : #elif ROSE_ALLOC_MEMSET == 2
    5744             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgBitAttribute) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
    5745             : #elif ROSE_ALLOC_MEMSET == 3
    5746             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgBitAttribute) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
    5747             : #endif
    5748           0 :     object->p_freepointer = fp;
    5749             : 
    5750             : #if ROSE_ALLOC_TRACE == 2
    5751             : //    printf("SgBitAttribute::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgBitAttribute::next_node);
    5752             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
    5753             :     Rose::MemPool::snapshot(oss.str());
    5754             :     alloc_trace_cnt++;
    5755             : #endif
    5756             : 
    5757           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
    5758             : 
    5759           0 :     ALLOC_MUTEX(SgBitAttribute, unlock);
    5760             : 
    5761             :     return object;
    5762             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
    5763             : }
    5764             : 
    5765             : 
    5766             : 
    5767             : /*! \brief Delete operator for SgBitAttribute.
    5768             : 
    5769             :    This delete operator implements deallocation using memory pools to 
    5770             :    provide most efficent use of the heap within construction of large ASTs.
    5771             : 
    5772             : \internal The new and delete operators use the lower level C malloc/free
    5773             :    function calls for performance and to make sure that mixing of malloc/free
    5774             :    and new/delete by the used can be caught more readily.  This may change
    5775             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
    5776             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
    5777             :    deallocate memory allocated using ROSE_MALLOC.
    5778             : */
    5779           0 : void SgBitAttribute::operator delete(void *Pointer, size_t Size)
    5780             : {
    5781             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
    5782             :      * or throwing an exception. */
    5783           0 :     ALLOC_MUTEX(SgBitAttribute, lock);
    5784             : 
    5785             : #if USE_CPP_NEW_DELETE_OPERATORS
    5786             :     ROSE_FREE(Pointer);
    5787             : #else
    5788             : #if ROSE_PEDANTIC_ALLOC
    5789             :     ROSE_ASSERT(Size == sizeof(SgBitAttribute));
    5790             : #else
    5791           0 :     if (Size != sizeof(SgBitAttribute)) {
    5792           0 :       ROSE_FREE(Pointer);
    5793           0 :       ALLOC_MUTEX(SgBitAttribute, unlock);
    5794             :       return;
    5795             :     }
    5796             : #endif
    5797             : 
    5798           0 :     SgBitAttribute * object = (SgBitAttribute*) Pointer;
    5799           0 :     ROSE_ASSERT(object != nullptr);
    5800             : 
    5801             : #if ROSE_ALLOC_TRACE == 2
    5802             : //  printf("SgBitAttribute::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgBitAttribute::next_node);
    5803             :     printf("SgBitAttribute::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgBitAttribute::next_node);
    5804             : #endif
    5805             : 
    5806             : #if ROSE_PEDANTIC_ALLOC
    5807             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
    5808             : #endif
    5809             : 
    5810             : #if ROSE_ALLOC_MEMSET == 1
    5811             : #elif ROSE_ALLOC_MEMSET == 2
    5812             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgBitAttribute) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
    5813             : #elif ROSE_ALLOC_MEMSET == 3
    5814             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgBitAttribute) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
    5815             : #endif
    5816             : 
    5817             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
    5818             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
    5819             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
    5820             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
    5821             : #else
    5822           0 :     object->p_freepointer = SgBitAttribute::next_node;
    5823           0 :     SgBitAttribute::next_node = object;
    5824             : #endif
    5825             : 
    5826             : #if ROSE_ALLOC_TRACE == 2
    5827             : //  printf("SgBitAttribute::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgBitAttribute::next_node);
    5828             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
    5829             :     Rose::MemPool::snapshot(oss.str());
    5830             :     alloc_trace_cnt++;
    5831             : #endif
    5832             : 
    5833             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
    5834             : 
    5835           0 :     ALLOC_MUTEX(SgBitAttribute, unlock);
    5836             : }
    5837             : 
    5838             : // DQ (11/27/2009): I have moved this member function definition to outside of the
    5839             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
    5840             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
    5841             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
    5842             : // Also, note comment below from Robb (copied from the Common.code file).
    5843             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
    5844             : //
    5845             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
    5846             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
    5847             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
    5848             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
    5849             : #if 0
    5850             : void SgBitAttribute::operator delete(void* pointer) { SgBitAttribute::operator delete (pointer, sizeof(SgBitAttribute)); };
    5851             : #endif
    5852             : /* #line 5853 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
    5853             : 
    5854             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
    5855             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
    5856             : // obviously imply C++.
    5857             : 
    5858             : // This implements the support within ROSE for memory pools.  Memory pools
    5859             : // support the most condensed usage of memory within the construction of
    5860             : // and AST. Large blocks of contiguous storage for each RI node is allocated
    5861             : // by a new operator written for each class.
    5862             : 
    5863             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
    5864             :     // User wants multi-thread support and POSIX threads are available.
    5865             : #   include <pthread.h>
    5866             :     static pthread_mutex_t SgFuncDecl_attr_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
    5867             : #else
    5868             :      // Cause synchronization to be skipped.
    5869             : #    ifndef ALLOC_MUTEX
    5870             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
    5871             : #    endif
    5872             : #    ifdef _REENTRANT
    5873             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
    5874             : #       ifdef _MSC_VER
    5875             : #           pragma message("POSIX threads are not available; synchronization being skipped")
    5876             : #       else
    5877             : #           warning "POSIX threads are not available; synchronization being skipped"
    5878             : #       endif
    5879             : #    endif
    5880             : #endif
    5881             : 
    5882             : #ifndef ROSE_ALLOC_TRACE
    5883             : #  define ROSE_ALLOC_TRACE 0
    5884             : #endif
    5885             : 
    5886             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
    5887             : #define ROSE_ALLOC_TRACE_CNT
    5888             : #include "memory-pool-snapshot.h"
    5889             : unsigned long alloc_trace_cnt = 0;
    5890             : #endif
    5891             : 
    5892             : #if ROSE_ALLOC_TRACE
    5893             : const unsigned SgFuncDecl_attr::pool_size = 5;
    5894             : #else
    5895             : const unsigned SgFuncDecl_attr::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
    5896             : #endif
    5897             : 
    5898             : #ifndef ROSE_ALLOC_MEMSET
    5899             : #  define ROSE_ALLOC_MEMSET 0
    5900             : #endif
    5901             : 
    5902             : #ifndef ROSE_PEDANTIC_ALLOC
    5903             : #  define ROSE_PEDANTIC_ALLOC 0
    5904             : #endif
    5905             : 
    5906             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
    5907             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
    5908             : #endif
    5909             : 
    5910             : #if !defined(SGNODE__ALL_POOLS)
    5911             : #define SGNODE__ALL_POOLS
    5912             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
    5913             : #endif
    5914             : 
    5915             : SgFuncDecl_attr* SgFuncDecl_attr::next_node = nullptr;
    5916             : std::vector<unsigned char*> SgFuncDecl_attr::pools;
    5917             : 
    5918             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
    5919             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
    5920             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
    5921             : // around this macro definition rather than each use).
    5922             : #ifndef ALLOC_MUTEX
    5923             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
    5924             :         do {                                                                     \
    5925             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
    5926             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
    5927             :                 abort();                                                         \
    5928             :             }                                                                    \
    5929             :         } while (0);
    5930             : #endif
    5931             : 
    5932             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
    5933             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
    5934             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
    5935             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
    5936             : 
    5937             : /*! \brief New operator for SgFuncDecl_attr.
    5938             : 
    5939             :    This new operator implements memory pools to provide most efficent 
    5940             :    use of the heap within construction of large ASTs.
    5941             : 
    5942             : \internal The new and delete operators use the lower level C malloc/free
    5943             :    function calls for performance and to make sure that mixing of malloc/free
    5944             :    and new/delete by the used can be caught more readily.  This may change
    5945             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
    5946             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
    5947             :    deallocate memory allocated using ROSE_MALLOC.
    5948             : */
    5949           0 : void *SgFuncDecl_attr::operator new ( size_t Size )
    5950             : {
    5951             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
    5952             :      * returning or throwing an exception. */
    5953           0 :     ALLOC_MUTEX(SgFuncDecl_attr, lock);
    5954             : 
    5955             : #if ROSE_ALLOC_TRACE == 2
    5956             : //    printf("SgFuncDecl_attr::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgFuncDecl_attr::next_node);
    5957             : #endif
    5958             : 
    5959             : #if USE_CPP_NEW_DELETE_OPERATORS
    5960             :     void *mem = ROSE_MALLOC(Size);
    5961             :     ALLOC_MUTEX(SgFuncDecl_attr, unlock);
    5962             :     return mem;
    5963             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
    5964             : #if ROSE_PEDANTIC_ALLOC
    5965             :     ROSE_ASSERT(Size == sizeof(SgFuncDecl_attr));
    5966             : #else
    5967           0 :     if (Size != sizeof(SgFuncDecl_attr)) {
    5968           0 :       void * object = ROSE_MALLOC(Size);
    5969           0 :       ALLOC_MUTEX(SgFuncDecl_attr, unlock);
    5970             :       return object;
    5971             :     }
    5972             : #endif
    5973             : 
    5974           0 :     if (SgFuncDecl_attr::next_node == nullptr) {
    5975           0 :         SgFuncDecl_attr * alloc = (SgFuncDecl_attr*) ROSE_MALLOC ( SgFuncDecl_attr::pool_size * sizeof(SgFuncDecl_attr) );
    5976           0 :         ROSE_ASSERT(alloc != nullptr);
    5977             : 
    5978             : #if ROSE_ALLOC_TRACE == 2
    5979             : //        printf("SgFuncDecl_attr::alloc\n  block[%zi] = [ %p , %p [\n", SgFuncDecl_attr::pools.size(), alloc, alloc + SgFuncDecl_attr::pool_size);
    5980             : #endif
    5981             : 
    5982             : #if ROSE_ALLOC_MEMSET == 1
    5983             : #elif ROSE_ALLOC_MEMSET == 2
    5984             :         memset(alloc, 0x00, SgFuncDecl_attr::pool_size * sizeof(SgFuncDecl_attr));
    5985             : #elif ROSE_ALLOC_MEMSET == 3
    5986             :         memset(alloc, 0xAA, SgFuncDecl_attr::pool_size * sizeof(SgFuncDecl_attr));
    5987             : #endif
    5988           0 :         for (unsigned i=0; i < SgFuncDecl_attr::pool_size-1; i++) {
    5989           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
    5990             :         }
    5991           0 :         alloc[SgFuncDecl_attr::pool_size-1].p_freepointer = nullptr;
    5992             : 
    5993           0 :         SgFuncDecl_attr::pools.push_back ( (unsigned char *) alloc );
    5994           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgFuncDecl_attr::pool_size * sizeof(SgFuncDecl_attr), V_SgFuncDecl_attr ) );
    5995           0 :         SgFuncDecl_attr::next_node = alloc;
    5996             :     }
    5997           0 :     ROSE_ASSERT(SgFuncDecl_attr::next_node != nullptr);
    5998             : 
    5999           0 :     SgFuncDecl_attr * object = SgFuncDecl_attr::next_node;
    6000           0 :     SgFuncDecl_attr::next_node = (SgFuncDecl_attr*)(object->p_freepointer);
    6001             : 
    6002             : #if ROSE_ALLOC_TRACE == 2
    6003             :     printf("SgFuncDecl_attr::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgFuncDecl_attr::next_node);
    6004             : #endif
    6005             : 
    6006           0 :     SgNode * fp = object->p_freepointer;
    6007             : #if ROSE_ALLOC_MEMSET == 1
    6008             : #elif ROSE_ALLOC_MEMSET == 2
    6009             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgFuncDecl_attr) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
    6010             : #elif ROSE_ALLOC_MEMSET == 3
    6011             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgFuncDecl_attr) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
    6012             : #endif
    6013           0 :     object->p_freepointer = fp;
    6014             : 
    6015             : #if ROSE_ALLOC_TRACE == 2
    6016             : //    printf("SgFuncDecl_attr::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgFuncDecl_attr::next_node);
    6017             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
    6018             :     Rose::MemPool::snapshot(oss.str());
    6019             :     alloc_trace_cnt++;
    6020             : #endif
    6021             : 
    6022           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
    6023             : 
    6024           0 :     ALLOC_MUTEX(SgFuncDecl_attr, unlock);
    6025             : 
    6026             :     return object;
    6027             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
    6028             : }
    6029             : 
    6030             : 
    6031             : 
    6032             : /*! \brief Delete operator for SgFuncDecl_attr.
    6033             : 
    6034             :    This delete operator implements deallocation using memory pools to 
    6035             :    provide most efficent use of the heap within construction of large ASTs.
    6036             : 
    6037             : \internal The new and delete operators use the lower level C malloc/free
    6038             :    function calls for performance and to make sure that mixing of malloc/free
    6039             :    and new/delete by the used can be caught more readily.  This may change
    6040             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
    6041             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
    6042             :    deallocate memory allocated using ROSE_MALLOC.
    6043             : */
    6044           0 : void SgFuncDecl_attr::operator delete(void *Pointer, size_t Size)
    6045             : {
    6046             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
    6047             :      * or throwing an exception. */
    6048           0 :     ALLOC_MUTEX(SgFuncDecl_attr, lock);
    6049             : 
    6050             : #if USE_CPP_NEW_DELETE_OPERATORS
    6051             :     ROSE_FREE(Pointer);
    6052             : #else
    6053             : #if ROSE_PEDANTIC_ALLOC
    6054             :     ROSE_ASSERT(Size == sizeof(SgFuncDecl_attr));
    6055             : #else
    6056           0 :     if (Size != sizeof(SgFuncDecl_attr)) {
    6057           0 :       ROSE_FREE(Pointer);
    6058           0 :       ALLOC_MUTEX(SgFuncDecl_attr, unlock);
    6059             :       return;
    6060             :     }
    6061             : #endif
    6062             : 
    6063           0 :     SgFuncDecl_attr * object = (SgFuncDecl_attr*) Pointer;
    6064           0 :     ROSE_ASSERT(object != nullptr);
    6065             : 
    6066             : #if ROSE_ALLOC_TRACE == 2
    6067             : //  printf("SgFuncDecl_attr::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgFuncDecl_attr::next_node);
    6068             :     printf("SgFuncDecl_attr::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgFuncDecl_attr::next_node);
    6069             : #endif
    6070             : 
    6071             : #if ROSE_PEDANTIC_ALLOC
    6072             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
    6073             : #endif
    6074             : 
    6075             : #if ROSE_ALLOC_MEMSET == 1
    6076             : #elif ROSE_ALLOC_MEMSET == 2
    6077             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgFuncDecl_attr) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
    6078             : #elif ROSE_ALLOC_MEMSET == 3
    6079             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgFuncDecl_attr) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
    6080             : #endif
    6081             : 
    6082             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
    6083             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
    6084             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
    6085             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
    6086             : #else
    6087           0 :     object->p_freepointer = SgFuncDecl_attr::next_node;
    6088           0 :     SgFuncDecl_attr::next_node = object;
    6089             : #endif
    6090             : 
    6091             : #if ROSE_ALLOC_TRACE == 2
    6092             : //  printf("SgFuncDecl_attr::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgFuncDecl_attr::next_node);
    6093             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
    6094             :     Rose::MemPool::snapshot(oss.str());
    6095             :     alloc_trace_cnt++;
    6096             : #endif
    6097             : 
    6098             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
    6099             : 
    6100           0 :     ALLOC_MUTEX(SgFuncDecl_attr, unlock);
    6101             : }
    6102             : 
    6103             : // DQ (11/27/2009): I have moved this member function definition to outside of the
    6104             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
    6105             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
    6106             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
    6107             : // Also, note comment below from Robb (copied from the Common.code file).
    6108             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
    6109             : //
    6110             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
    6111             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
    6112             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
    6113             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
    6114             : #if 0
    6115             : void SgFuncDecl_attr::operator delete(void* pointer) { SgFuncDecl_attr::operator delete (pointer, sizeof(SgFuncDecl_attr)); };
    6116             : #endif
    6117             : /* #line 6118 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
    6118             : 
    6119             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
    6120             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
    6121             : // obviously imply C++.
    6122             : 
    6123             : // This implements the support within ROSE for memory pools.  Memory pools
    6124             : // support the most condensed usage of memory within the construction of
    6125             : // and AST. Large blocks of contiguous storage for each RI node is allocated
    6126             : // by a new operator written for each class.
    6127             : 
    6128             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
    6129             :     // User wants multi-thread support and POSIX threads are available.
    6130             : #   include <pthread.h>
    6131             :     static pthread_mutex_t SgClassDecl_attr_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
    6132             : #else
    6133             :      // Cause synchronization to be skipped.
    6134             : #    ifndef ALLOC_MUTEX
    6135             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
    6136             : #    endif
    6137             : #    ifdef _REENTRANT
    6138             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
    6139             : #       ifdef _MSC_VER
    6140             : #           pragma message("POSIX threads are not available; synchronization being skipped")
    6141             : #       else
    6142             : #           warning "POSIX threads are not available; synchronization being skipped"
    6143             : #       endif
    6144             : #    endif
    6145             : #endif
    6146             : 
    6147             : #ifndef ROSE_ALLOC_TRACE
    6148             : #  define ROSE_ALLOC_TRACE 0
    6149             : #endif
    6150             : 
    6151             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
    6152             : #define ROSE_ALLOC_TRACE_CNT
    6153             : #include "memory-pool-snapshot.h"
    6154             : unsigned long alloc_trace_cnt = 0;
    6155             : #endif
    6156             : 
    6157             : #if ROSE_ALLOC_TRACE
    6158             : const unsigned SgClassDecl_attr::pool_size = 5;
    6159             : #else
    6160             : const unsigned SgClassDecl_attr::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
    6161             : #endif
    6162             : 
    6163             : #ifndef ROSE_ALLOC_MEMSET
    6164             : #  define ROSE_ALLOC_MEMSET 0
    6165             : #endif
    6166             : 
    6167             : #ifndef ROSE_PEDANTIC_ALLOC
    6168             : #  define ROSE_PEDANTIC_ALLOC 0
    6169             : #endif
    6170             : 
    6171             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
    6172             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
    6173             : #endif
    6174             : 
    6175             : #if !defined(SGNODE__ALL_POOLS)
    6176             : #define SGNODE__ALL_POOLS
    6177             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
    6178             : #endif
    6179             : 
    6180             : SgClassDecl_attr* SgClassDecl_attr::next_node = nullptr;
    6181             : std::vector<unsigned char*> SgClassDecl_attr::pools;
    6182             : 
    6183             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
    6184             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
    6185             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
    6186             : // around this macro definition rather than each use).
    6187             : #ifndef ALLOC_MUTEX
    6188             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
    6189             :         do {                                                                     \
    6190             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
    6191             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
    6192             :                 abort();                                                         \
    6193             :             }                                                                    \
    6194             :         } while (0);
    6195             : #endif
    6196             : 
    6197             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
    6198             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
    6199             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
    6200             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
    6201             : 
    6202             : /*! \brief New operator for SgClassDecl_attr.
    6203             : 
    6204             :    This new operator implements memory pools to provide most efficent 
    6205             :    use of the heap within construction of large ASTs.
    6206             : 
    6207             : \internal The new and delete operators use the lower level C malloc/free
    6208             :    function calls for performance and to make sure that mixing of malloc/free
    6209             :    and new/delete by the used can be caught more readily.  This may change
    6210             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
    6211             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
    6212             :    deallocate memory allocated using ROSE_MALLOC.
    6213             : */
    6214           0 : void *SgClassDecl_attr::operator new ( size_t Size )
    6215             : {
    6216             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
    6217             :      * returning or throwing an exception. */
    6218           0 :     ALLOC_MUTEX(SgClassDecl_attr, lock);
    6219             : 
    6220             : #if ROSE_ALLOC_TRACE == 2
    6221             : //    printf("SgClassDecl_attr::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgClassDecl_attr::next_node);
    6222             : #endif
    6223             : 
    6224             : #if USE_CPP_NEW_DELETE_OPERATORS
    6225             :     void *mem = ROSE_MALLOC(Size);
    6226             :     ALLOC_MUTEX(SgClassDecl_attr, unlock);
    6227             :     return mem;
    6228             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
    6229             : #if ROSE_PEDANTIC_ALLOC
    6230             :     ROSE_ASSERT(Size == sizeof(SgClassDecl_attr));
    6231             : #else
    6232           0 :     if (Size != sizeof(SgClassDecl_attr)) {
    6233           0 :       void * object = ROSE_MALLOC(Size);
    6234           0 :       ALLOC_MUTEX(SgClassDecl_attr, unlock);
    6235             :       return object;
    6236             :     }
    6237             : #endif
    6238             : 
    6239           0 :     if (SgClassDecl_attr::next_node == nullptr) {
    6240           0 :         SgClassDecl_attr * alloc = (SgClassDecl_attr*) ROSE_MALLOC ( SgClassDecl_attr::pool_size * sizeof(SgClassDecl_attr) );
    6241           0 :         ROSE_ASSERT(alloc != nullptr);
    6242             : 
    6243             : #if ROSE_ALLOC_TRACE == 2
    6244             : //        printf("SgClassDecl_attr::alloc\n  block[%zi] = [ %p , %p [\n", SgClassDecl_attr::pools.size(), alloc, alloc + SgClassDecl_attr::pool_size);
    6245             : #endif
    6246             : 
    6247             : #if ROSE_ALLOC_MEMSET == 1
    6248             : #elif ROSE_ALLOC_MEMSET == 2
    6249             :         memset(alloc, 0x00, SgClassDecl_attr::pool_size * sizeof(SgClassDecl_attr));
    6250             : #elif ROSE_ALLOC_MEMSET == 3
    6251             :         memset(alloc, 0xAA, SgClassDecl_attr::pool_size * sizeof(SgClassDecl_attr));
    6252             : #endif
    6253           0 :         for (unsigned i=0; i < SgClassDecl_attr::pool_size-1; i++) {
    6254           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
    6255             :         }
    6256           0 :         alloc[SgClassDecl_attr::pool_size-1].p_freepointer = nullptr;
    6257             : 
    6258           0 :         SgClassDecl_attr::pools.push_back ( (unsigned char *) alloc );
    6259           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgClassDecl_attr::pool_size * sizeof(SgClassDecl_attr), V_SgClassDecl_attr ) );
    6260           0 :         SgClassDecl_attr::next_node = alloc;
    6261             :     }
    6262           0 :     ROSE_ASSERT(SgClassDecl_attr::next_node != nullptr);
    6263             : 
    6264           0 :     SgClassDecl_attr * object = SgClassDecl_attr::next_node;
    6265           0 :     SgClassDecl_attr::next_node = (SgClassDecl_attr*)(object->p_freepointer);
    6266             : 
    6267             : #if ROSE_ALLOC_TRACE == 2
    6268             :     printf("SgClassDecl_attr::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgClassDecl_attr::next_node);
    6269             : #endif
    6270             : 
    6271           0 :     SgNode * fp = object->p_freepointer;
    6272             : #if ROSE_ALLOC_MEMSET == 1
    6273             : #elif ROSE_ALLOC_MEMSET == 2
    6274             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgClassDecl_attr) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
    6275             : #elif ROSE_ALLOC_MEMSET == 3
    6276             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgClassDecl_attr) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
    6277             : #endif
    6278           0 :     object->p_freepointer = fp;
    6279             : 
    6280             : #if ROSE_ALLOC_TRACE == 2
    6281             : //    printf("SgClassDecl_attr::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgClassDecl_attr::next_node);
    6282             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
    6283             :     Rose::MemPool::snapshot(oss.str());
    6284             :     alloc_trace_cnt++;
    6285             : #endif
    6286             : 
    6287           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
    6288             : 
    6289           0 :     ALLOC_MUTEX(SgClassDecl_attr, unlock);
    6290             : 
    6291             :     return object;
    6292             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
    6293             : }
    6294             : 
    6295             : 
    6296             : 
    6297             : /*! \brief Delete operator for SgClassDecl_attr.
    6298             : 
    6299             :    This delete operator implements deallocation using memory pools to 
    6300             :    provide most efficent use of the heap within construction of large ASTs.
    6301             : 
    6302             : \internal The new and delete operators use the lower level C malloc/free
    6303             :    function calls for performance and to make sure that mixing of malloc/free
    6304             :    and new/delete by the used can be caught more readily.  This may change
    6305             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
    6306             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
    6307             :    deallocate memory allocated using ROSE_MALLOC.
    6308             : */
    6309           0 : void SgClassDecl_attr::operator delete(void *Pointer, size_t Size)
    6310             : {
    6311             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
    6312             :      * or throwing an exception. */
    6313           0 :     ALLOC_MUTEX(SgClassDecl_attr, lock);
    6314             : 
    6315             : #if USE_CPP_NEW_DELETE_OPERATORS
    6316             :     ROSE_FREE(Pointer);
    6317             : #else
    6318             : #if ROSE_PEDANTIC_ALLOC
    6319             :     ROSE_ASSERT(Size == sizeof(SgClassDecl_attr));
    6320             : #else
    6321           0 :     if (Size != sizeof(SgClassDecl_attr)) {
    6322           0 :       ROSE_FREE(Pointer);
    6323           0 :       ALLOC_MUTEX(SgClassDecl_attr, unlock);
    6324             :       return;
    6325             :     }
    6326             : #endif
    6327             : 
    6328           0 :     SgClassDecl_attr * object = (SgClassDecl_attr*) Pointer;
    6329           0 :     ROSE_ASSERT(object != nullptr);
    6330             : 
    6331             : #if ROSE_ALLOC_TRACE == 2
    6332             : //  printf("SgClassDecl_attr::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgClassDecl_attr::next_node);
    6333             :     printf("SgClassDecl_attr::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgClassDecl_attr::next_node);
    6334             : #endif
    6335             : 
    6336             : #if ROSE_PEDANTIC_ALLOC
    6337             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
    6338             : #endif
    6339             : 
    6340             : #if ROSE_ALLOC_MEMSET == 1
    6341             : #elif ROSE_ALLOC_MEMSET == 2
    6342             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgClassDecl_attr) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
    6343             : #elif ROSE_ALLOC_MEMSET == 3
    6344             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgClassDecl_attr) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
    6345             : #endif
    6346             : 
    6347             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
    6348             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
    6349             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
    6350             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
    6351             : #else
    6352           0 :     object->p_freepointer = SgClassDecl_attr::next_node;
    6353           0 :     SgClassDecl_attr::next_node = object;
    6354             : #endif
    6355             : 
    6356             : #if ROSE_ALLOC_TRACE == 2
    6357             : //  printf("SgClassDecl_attr::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgClassDecl_attr::next_node);
    6358             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
    6359             :     Rose::MemPool::snapshot(oss.str());
    6360             :     alloc_trace_cnt++;
    6361             : #endif
    6362             : 
    6363             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
    6364             : 
    6365           0 :     ALLOC_MUTEX(SgClassDecl_attr, unlock);
    6366             : }
    6367             : 
    6368             : // DQ (11/27/2009): I have moved this member function definition to outside of the
    6369             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
    6370             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
    6371             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
    6372             : // Also, note comment below from Robb (copied from the Common.code file).
    6373             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
    6374             : //
    6375             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
    6376             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
    6377             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
    6378             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
    6379             : #if 0
    6380             : void SgClassDecl_attr::operator delete(void* pointer) { SgClassDecl_attr::operator delete (pointer, sizeof(SgClassDecl_attr)); };
    6381             : #endif
    6382             : /* #line 6383 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
    6383             : 
    6384             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
    6385             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
    6386             : // obviously imply C++.
    6387             : 
    6388             : // This implements the support within ROSE for memory pools.  Memory pools
    6389             : // support the most condensed usage of memory within the construction of
    6390             : // and AST. Large blocks of contiguous storage for each RI node is allocated
    6391             : // by a new operator written for each class.
    6392             : 
    6393             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
    6394             :     // User wants multi-thread support and POSIX threads are available.
    6395             : #   include <pthread.h>
    6396             :     static pthread_mutex_t Sg_File_Info_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
    6397             : #else
    6398             :      // Cause synchronization to be skipped.
    6399             : #    ifndef ALLOC_MUTEX
    6400             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
    6401             : #    endif
    6402             : #    ifdef _REENTRANT
    6403             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
    6404             : #       ifdef _MSC_VER
    6405             : #           pragma message("POSIX threads are not available; synchronization being skipped")
    6406             : #       else
    6407             : #           warning "POSIX threads are not available; synchronization being skipped"
    6408             : #       endif
    6409             : #    endif
    6410             : #endif
    6411             : 
    6412             : #ifndef ROSE_ALLOC_TRACE
    6413             : #  define ROSE_ALLOC_TRACE 0
    6414             : #endif
    6415             : 
    6416             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
    6417             : #define ROSE_ALLOC_TRACE_CNT
    6418             : #include "memory-pool-snapshot.h"
    6419             : unsigned long alloc_trace_cnt = 0;
    6420             : #endif
    6421             : 
    6422             : #if ROSE_ALLOC_TRACE
    6423             : const unsigned Sg_File_Info::pool_size = 5;
    6424             : #else
    6425             : const unsigned Sg_File_Info::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
    6426             : #endif
    6427             : 
    6428             : #ifndef ROSE_ALLOC_MEMSET
    6429             : #  define ROSE_ALLOC_MEMSET 0
    6430             : #endif
    6431             : 
    6432             : #ifndef ROSE_PEDANTIC_ALLOC
    6433             : #  define ROSE_PEDANTIC_ALLOC 0
    6434             : #endif
    6435             : 
    6436             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
    6437             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
    6438             : #endif
    6439             : 
    6440             : #if !defined(SGNODE__ALL_POOLS)
    6441             : #define SGNODE__ALL_POOLS
    6442             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
    6443             : #endif
    6444             : 
    6445             : Sg_File_Info* Sg_File_Info::next_node = nullptr;
    6446             : std::vector<unsigned char*> Sg_File_Info::pools;
    6447             : 
    6448             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
    6449             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
    6450             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
    6451             : // around this macro definition rather than each use).
    6452             : #ifndef ALLOC_MUTEX
    6453             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
    6454             :         do {                                                                     \
    6455             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
    6456             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
    6457             :                 abort();                                                         \
    6458             :             }                                                                    \
    6459             :         } while (0);
    6460             : #endif
    6461             : 
    6462             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
    6463             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
    6464             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
    6465             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
    6466             : 
    6467             : /*! \brief New operator for Sg_File_Info.
    6468             : 
    6469             :    This new operator implements memory pools to provide most efficent 
    6470             :    use of the heap within construction of large ASTs.
    6471             : 
    6472             : \internal The new and delete operators use the lower level C malloc/free
    6473             :    function calls for performance and to make sure that mixing of malloc/free
    6474             :    and new/delete by the used can be caught more readily.  This may change
    6475             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
    6476             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
    6477             :    deallocate memory allocated using ROSE_MALLOC.
    6478             : */
    6479    65077200 : void *Sg_File_Info::operator new ( size_t Size )
    6480             : {
    6481             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
    6482             :      * returning or throwing an exception. */
    6483    65077200 :     ALLOC_MUTEX(Sg_File_Info, lock);
    6484             : 
    6485             : #if ROSE_ALLOC_TRACE == 2
    6486             : //    printf("Sg_File_Info::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, Sg_File_Info::next_node);
    6487             : #endif
    6488             : 
    6489             : #if USE_CPP_NEW_DELETE_OPERATORS
    6490             :     void *mem = ROSE_MALLOC(Size);
    6491             :     ALLOC_MUTEX(Sg_File_Info, unlock);
    6492             :     return mem;
    6493             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
    6494             : #if ROSE_PEDANTIC_ALLOC
    6495             :     ROSE_ASSERT(Size == sizeof(Sg_File_Info));
    6496             : #else
    6497    65077200 :     if (Size != sizeof(Sg_File_Info)) {
    6498           0 :       void * object = ROSE_MALLOC(Size);
    6499           0 :       ALLOC_MUTEX(Sg_File_Info, unlock);
    6500             :       return object;
    6501             :     }
    6502             : #endif
    6503             : 
    6504    65077200 :     if (Sg_File_Info::next_node == nullptr) {
    6505       20277 :         Sg_File_Info * alloc = (Sg_File_Info*) ROSE_MALLOC ( Sg_File_Info::pool_size * sizeof(Sg_File_Info) );
    6506       20277 :         ROSE_ASSERT(alloc != nullptr);
    6507             : 
    6508             : #if ROSE_ALLOC_TRACE == 2
    6509             : //        printf("Sg_File_Info::alloc\n  block[%zi] = [ %p , %p [\n", Sg_File_Info::pools.size(), alloc, alloc + Sg_File_Info::pool_size);
    6510             : #endif
    6511             : 
    6512             : #if ROSE_ALLOC_MEMSET == 1
    6513             : #elif ROSE_ALLOC_MEMSET == 2
    6514             :         memset(alloc, 0x00, Sg_File_Info::pool_size * sizeof(Sg_File_Info));
    6515             : #elif ROSE_ALLOC_MEMSET == 3
    6516             :         memset(alloc, 0xAA, Sg_File_Info::pool_size * sizeof(Sg_File_Info));
    6517             : #endif
    6518    40554000 :         for (unsigned i=0; i < Sg_File_Info::pool_size-1; i++) {
    6519    40533700 :           alloc[i].p_freepointer = &(alloc[i+1]);
    6520             :         }
    6521       20277 :         alloc[Sg_File_Info::pool_size-1].p_freepointer = nullptr;
    6522             : 
    6523       20277 :         Sg_File_Info::pools.push_back ( (unsigned char *) alloc );
    6524       20277 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, Sg_File_Info::pool_size * sizeof(Sg_File_Info), V_Sg_File_Info ) );
    6525       20277 :         Sg_File_Info::next_node = alloc;
    6526             :     }
    6527    65077200 :     ROSE_ASSERT(Sg_File_Info::next_node != nullptr);
    6528             : 
    6529    65077200 :     Sg_File_Info * object = Sg_File_Info::next_node;
    6530    65077200 :     Sg_File_Info::next_node = (Sg_File_Info*)(object->p_freepointer);
    6531             : 
    6532             : #if ROSE_ALLOC_TRACE == 2
    6533             :     printf("Sg_File_Info::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, Sg_File_Info::next_node);
    6534             : #endif
    6535             : 
    6536    65077200 :     SgNode * fp = object->p_freepointer;
    6537             : #if ROSE_ALLOC_MEMSET == 1
    6538             : #elif ROSE_ALLOC_MEMSET == 2
    6539             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(Sg_File_Info) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
    6540             : #elif ROSE_ALLOC_MEMSET == 3
    6541             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(Sg_File_Info) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
    6542             : #endif
    6543    65077200 :     object->p_freepointer = fp;
    6544             : 
    6545             : #if ROSE_ALLOC_TRACE == 2
    6546             : //    printf("Sg_File_Info::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, Sg_File_Info::next_node);
    6547             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
    6548             :     Rose::MemPool::snapshot(oss.str());
    6549             :     alloc_trace_cnt++;
    6550             : #endif
    6551             : 
    6552    65077200 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
    6553             : 
    6554    65077200 :     ALLOC_MUTEX(Sg_File_Info, unlock);
    6555             : 
    6556             :     return object;
    6557             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
    6558             : }
    6559             : 
    6560             : 
    6561             : 
    6562             : /*! \brief Delete operator for Sg_File_Info.
    6563             : 
    6564             :    This delete operator implements deallocation using memory pools to 
    6565             :    provide most efficent use of the heap within construction of large ASTs.
    6566             : 
    6567             : \internal The new and delete operators use the lower level C malloc/free
    6568             :    function calls for performance and to make sure that mixing of malloc/free
    6569             :    and new/delete by the used can be caught more readily.  This may change
    6570             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
    6571             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
    6572             :    deallocate memory allocated using ROSE_MALLOC.
    6573             : */
    6574    25591200 : void Sg_File_Info::operator delete(void *Pointer, size_t Size)
    6575             : {
    6576             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
    6577             :      * or throwing an exception. */
    6578    25591200 :     ALLOC_MUTEX(Sg_File_Info, lock);
    6579             : 
    6580             : #if USE_CPP_NEW_DELETE_OPERATORS
    6581             :     ROSE_FREE(Pointer);
    6582             : #else
    6583             : #if ROSE_PEDANTIC_ALLOC
    6584             :     ROSE_ASSERT(Size == sizeof(Sg_File_Info));
    6585             : #else
    6586    25591200 :     if (Size != sizeof(Sg_File_Info)) {
    6587           0 :       ROSE_FREE(Pointer);
    6588           0 :       ALLOC_MUTEX(Sg_File_Info, unlock);
    6589             :       return;
    6590             :     }
    6591             : #endif
    6592             : 
    6593    25591200 :     Sg_File_Info * object = (Sg_File_Info*) Pointer;
    6594    25591200 :     ROSE_ASSERT(object != nullptr);
    6595             : 
    6596             : #if ROSE_ALLOC_TRACE == 2
    6597             : //  printf("Sg_File_Info::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, Sg_File_Info::next_node);
    6598             :     printf("Sg_File_Info::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, Sg_File_Info::next_node);
    6599             : #endif
    6600             : 
    6601             : #if ROSE_PEDANTIC_ALLOC
    6602             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
    6603             : #endif
    6604             : 
    6605             : #if ROSE_ALLOC_MEMSET == 1
    6606             : #elif ROSE_ALLOC_MEMSET == 2
    6607             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(Sg_File_Info) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
    6608             : #elif ROSE_ALLOC_MEMSET == 3
    6609             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(Sg_File_Info) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
    6610             : #endif
    6611             : 
    6612             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
    6613             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
    6614             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
    6615             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
    6616             : #else
    6617    25591200 :     object->p_freepointer = Sg_File_Info::next_node;
    6618    25591200 :     Sg_File_Info::next_node = object;
    6619             : #endif
    6620             : 
    6621             : #if ROSE_ALLOC_TRACE == 2
    6622             : //  printf("Sg_File_Info::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, Sg_File_Info::next_node);
    6623             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
    6624             :     Rose::MemPool::snapshot(oss.str());
    6625             :     alloc_trace_cnt++;
    6626             : #endif
    6627             : 
    6628             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
    6629             : 
    6630    25591200 :     ALLOC_MUTEX(Sg_File_Info, unlock);
    6631             : }
    6632             : 
    6633             : // DQ (11/27/2009): I have moved this member function definition to outside of the
    6634             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
    6635             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
    6636             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
    6637             : // Also, note comment below from Robb (copied from the Common.code file).
    6638             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
    6639             : //
    6640             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
    6641             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
    6642             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
    6643             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
    6644             : #if 0
    6645             : void Sg_File_Info::operator delete(void* pointer) { Sg_File_Info::operator delete (pointer, sizeof(Sg_File_Info)); };
    6646             : #endif
    6647             : /* #line 6648 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
    6648             : 
    6649             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
    6650             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
    6651             : // obviously imply C++.
    6652             : 
    6653             : // This implements the support within ROSE for memory pools.  Memory pools
    6654             : // support the most condensed usage of memory within the construction of
    6655             : // and AST. Large blocks of contiguous storage for each RI node is allocated
    6656             : // by a new operator written for each class.
    6657             : 
    6658             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
    6659             :     // User wants multi-thread support and POSIX threads are available.
    6660             : #   include <pthread.h>
    6661             :     static pthread_mutex_t SgFile_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
    6662             : #else
    6663             :      // Cause synchronization to be skipped.
    6664             : #    ifndef ALLOC_MUTEX
    6665             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
    6666             : #    endif
    6667             : #    ifdef _REENTRANT
    6668             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
    6669             : #       ifdef _MSC_VER
    6670             : #           pragma message("POSIX threads are not available; synchronization being skipped")
    6671             : #       else
    6672             : #           warning "POSIX threads are not available; synchronization being skipped"
    6673             : #       endif
    6674             : #    endif
    6675             : #endif
    6676             : 
    6677             : #ifndef ROSE_ALLOC_TRACE
    6678             : #  define ROSE_ALLOC_TRACE 0
    6679             : #endif
    6680             : 
    6681             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
    6682             : #define ROSE_ALLOC_TRACE_CNT
    6683             : #include "memory-pool-snapshot.h"
    6684             : unsigned long alloc_trace_cnt = 0;
    6685             : #endif
    6686             : 
    6687             : #if ROSE_ALLOC_TRACE
    6688             : const unsigned SgFile::pool_size = 5;
    6689             : #else
    6690             : const unsigned SgFile::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
    6691             : #endif
    6692             : 
    6693             : #ifndef ROSE_ALLOC_MEMSET
    6694             : #  define ROSE_ALLOC_MEMSET 0
    6695             : #endif
    6696             : 
    6697             : #ifndef ROSE_PEDANTIC_ALLOC
    6698             : #  define ROSE_PEDANTIC_ALLOC 0
    6699             : #endif
    6700             : 
    6701             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
    6702             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
    6703             : #endif
    6704             : 
    6705             : #if !defined(SGNODE__ALL_POOLS)
    6706             : #define SGNODE__ALL_POOLS
    6707             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
    6708             : #endif
    6709             : 
    6710             : SgFile* SgFile::next_node = nullptr;
    6711             : std::vector<unsigned char*> SgFile::pools;
    6712             : 
    6713             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
    6714             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
    6715             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
    6716             : // around this macro definition rather than each use).
    6717             : #ifndef ALLOC_MUTEX
    6718             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
    6719             :         do {                                                                     \
    6720             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
    6721             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
    6722             :                 abort();                                                         \
    6723             :             }                                                                    \
    6724             :         } while (0);
    6725             : #endif
    6726             : 
    6727             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
    6728             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
    6729             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
    6730             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
    6731             : 
    6732             : /*! \brief New operator for SgFile.
    6733             : 
    6734             :    This new operator implements memory pools to provide most efficent 
    6735             :    use of the heap within construction of large ASTs.
    6736             : 
    6737             : \internal The new and delete operators use the lower level C malloc/free
    6738             :    function calls for performance and to make sure that mixing of malloc/free
    6739             :    and new/delete by the used can be caught more readily.  This may change
    6740             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
    6741             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
    6742             :    deallocate memory allocated using ROSE_MALLOC.
    6743             : */
    6744           0 : void *SgFile::operator new ( size_t Size )
    6745             : {
    6746             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
    6747             :      * returning or throwing an exception. */
    6748           0 :     ALLOC_MUTEX(SgFile, lock);
    6749             : 
    6750             : #if ROSE_ALLOC_TRACE == 2
    6751             : //    printf("SgFile::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgFile::next_node);
    6752             : #endif
    6753             : 
    6754             : #if USE_CPP_NEW_DELETE_OPERATORS
    6755             :     void *mem = ROSE_MALLOC(Size);
    6756             :     ALLOC_MUTEX(SgFile, unlock);
    6757             :     return mem;
    6758             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
    6759             : #if ROSE_PEDANTIC_ALLOC
    6760             :     ROSE_ASSERT(Size == sizeof(SgFile));
    6761             : #else
    6762           0 :     if (Size != sizeof(SgFile)) {
    6763           0 :       void * object = ROSE_MALLOC(Size);
    6764           0 :       ALLOC_MUTEX(SgFile, unlock);
    6765             :       return object;
    6766             :     }
    6767             : #endif
    6768             : 
    6769           0 :     if (SgFile::next_node == nullptr) {
    6770           0 :         SgFile * alloc = (SgFile*) ROSE_MALLOC ( SgFile::pool_size * sizeof(SgFile) );
    6771           0 :         ROSE_ASSERT(alloc != nullptr);
    6772             : 
    6773             : #if ROSE_ALLOC_TRACE == 2
    6774             : //        printf("SgFile::alloc\n  block[%zi] = [ %p , %p [\n", SgFile::pools.size(), alloc, alloc + SgFile::pool_size);
    6775             : #endif
    6776             : 
    6777             : #if ROSE_ALLOC_MEMSET == 1
    6778             : #elif ROSE_ALLOC_MEMSET == 2
    6779             :         memset(alloc, 0x00, SgFile::pool_size * sizeof(SgFile));
    6780             : #elif ROSE_ALLOC_MEMSET == 3
    6781             :         memset(alloc, 0xAA, SgFile::pool_size * sizeof(SgFile));
    6782             : #endif
    6783           0 :         for (unsigned i=0; i < SgFile::pool_size-1; i++) {
    6784           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
    6785             :         }
    6786           0 :         alloc[SgFile::pool_size-1].p_freepointer = nullptr;
    6787             : 
    6788           0 :         SgFile::pools.push_back ( (unsigned char *) alloc );
    6789           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgFile::pool_size * sizeof(SgFile), V_SgFile ) );
    6790           0 :         SgFile::next_node = alloc;
    6791             :     }
    6792           0 :     ROSE_ASSERT(SgFile::next_node != nullptr);
    6793             : 
    6794           0 :     SgFile * object = SgFile::next_node;
    6795           0 :     SgFile::next_node = (SgFile*)(object->p_freepointer);
    6796             : 
    6797             : #if ROSE_ALLOC_TRACE == 2
    6798             :     printf("SgFile::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgFile::next_node);
    6799             : #endif
    6800             : 
    6801           0 :     SgNode * fp = object->p_freepointer;
    6802             : #if ROSE_ALLOC_MEMSET == 1
    6803             : #elif ROSE_ALLOC_MEMSET == 2
    6804             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgFile) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
    6805             : #elif ROSE_ALLOC_MEMSET == 3
    6806             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgFile) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
    6807             : #endif
    6808           0 :     object->p_freepointer = fp;
    6809             : 
    6810             : #if ROSE_ALLOC_TRACE == 2
    6811             : //    printf("SgFile::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgFile::next_node);
    6812             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
    6813             :     Rose::MemPool::snapshot(oss.str());
    6814             :     alloc_trace_cnt++;
    6815             : #endif
    6816             : 
    6817           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
    6818             : 
    6819           0 :     ALLOC_MUTEX(SgFile, unlock);
    6820             : 
    6821             :     return object;
    6822             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
    6823             : }
    6824             : 
    6825             : 
    6826             : 
    6827             : /*! \brief Delete operator for SgFile.
    6828             : 
    6829             :    This delete operator implements deallocation using memory pools to 
    6830             :    provide most efficent use of the heap within construction of large ASTs.
    6831             : 
    6832             : \internal The new and delete operators use the lower level C malloc/free
    6833             :    function calls for performance and to make sure that mixing of malloc/free
    6834             :    and new/delete by the used can be caught more readily.  This may change
    6835             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
    6836             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
    6837             :    deallocate memory allocated using ROSE_MALLOC.
    6838             : */
    6839           0 : void SgFile::operator delete(void *Pointer, size_t Size)
    6840             : {
    6841             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
    6842             :      * or throwing an exception. */
    6843           0 :     ALLOC_MUTEX(SgFile, lock);
    6844             : 
    6845             : #if USE_CPP_NEW_DELETE_OPERATORS
    6846             :     ROSE_FREE(Pointer);
    6847             : #else
    6848             : #if ROSE_PEDANTIC_ALLOC
    6849             :     ROSE_ASSERT(Size == sizeof(SgFile));
    6850             : #else
    6851           0 :     if (Size != sizeof(SgFile)) {
    6852           0 :       ROSE_FREE(Pointer);
    6853           0 :       ALLOC_MUTEX(SgFile, unlock);
    6854             :       return;
    6855             :     }
    6856             : #endif
    6857             : 
    6858           0 :     SgFile * object = (SgFile*) Pointer;
    6859           0 :     ROSE_ASSERT(object != nullptr);
    6860             : 
    6861             : #if ROSE_ALLOC_TRACE == 2
    6862             : //  printf("SgFile::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgFile::next_node);
    6863             :     printf("SgFile::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgFile::next_node);
    6864             : #endif
    6865             : 
    6866             : #if ROSE_PEDANTIC_ALLOC
    6867             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
    6868             : #endif
    6869             : 
    6870             : #if ROSE_ALLOC_MEMSET == 1
    6871             : #elif ROSE_ALLOC_MEMSET == 2
    6872             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgFile) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
    6873             : #elif ROSE_ALLOC_MEMSET == 3
    6874             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgFile) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
    6875             : #endif
    6876             : 
    6877             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
    6878             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
    6879             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
    6880             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
    6881             : #else
    6882           0 :     object->p_freepointer = SgFile::next_node;
    6883           0 :     SgFile::next_node = object;
    6884             : #endif
    6885             : 
    6886             : #if ROSE_ALLOC_TRACE == 2
    6887             : //  printf("SgFile::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgFile::next_node);
    6888             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
    6889             :     Rose::MemPool::snapshot(oss.str());
    6890             :     alloc_trace_cnt++;
    6891             : #endif
    6892             : 
    6893             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
    6894             : 
    6895           0 :     ALLOC_MUTEX(SgFile, unlock);
    6896             : }
    6897             : 
    6898             : // DQ (11/27/2009): I have moved this member function definition to outside of the
    6899             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
    6900             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
    6901             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
    6902             : // Also, note comment below from Robb (copied from the Common.code file).
    6903             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
    6904             : //
    6905             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
    6906             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
    6907             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
    6908             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
    6909             : #if 0
    6910             : void SgFile::operator delete(void* pointer) { SgFile::operator delete (pointer, sizeof(SgFile)); };
    6911             : #endif
    6912             : /* #line 6913 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
    6913             : 
    6914             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
    6915             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
    6916             : // obviously imply C++.
    6917             : 
    6918             : // This implements the support within ROSE for memory pools.  Memory pools
    6919             : // support the most condensed usage of memory within the construction of
    6920             : // and AST. Large blocks of contiguous storage for each RI node is allocated
    6921             : // by a new operator written for each class.
    6922             : 
    6923             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
    6924             :     // User wants multi-thread support and POSIX threads are available.
    6925             : #   include <pthread.h>
    6926             :     static pthread_mutex_t SgSourceFile_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
    6927             : #else
    6928             :      // Cause synchronization to be skipped.
    6929             : #    ifndef ALLOC_MUTEX
    6930             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
    6931             : #    endif
    6932             : #    ifdef _REENTRANT
    6933             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
    6934             : #       ifdef _MSC_VER
    6935             : #           pragma message("POSIX threads are not available; synchronization being skipped")
    6936             : #       else
    6937             : #           warning "POSIX threads are not available; synchronization being skipped"
    6938             : #       endif
    6939             : #    endif
    6940             : #endif
    6941             : 
    6942             : #ifndef ROSE_ALLOC_TRACE
    6943             : #  define ROSE_ALLOC_TRACE 0
    6944             : #endif
    6945             : 
    6946             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
    6947             : #define ROSE_ALLOC_TRACE_CNT
    6948             : #include "memory-pool-snapshot.h"
    6949             : unsigned long alloc_trace_cnt = 0;
    6950             : #endif
    6951             : 
    6952             : #if ROSE_ALLOC_TRACE
    6953             : const unsigned SgSourceFile::pool_size = 5;
    6954             : #else
    6955             : const unsigned SgSourceFile::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
    6956             : #endif
    6957             : 
    6958             : #ifndef ROSE_ALLOC_MEMSET
    6959             : #  define ROSE_ALLOC_MEMSET 0
    6960             : #endif
    6961             : 
    6962             : #ifndef ROSE_PEDANTIC_ALLOC
    6963             : #  define ROSE_PEDANTIC_ALLOC 0
    6964             : #endif
    6965             : 
    6966             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
    6967             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
    6968             : #endif
    6969             : 
    6970             : #if !defined(SGNODE__ALL_POOLS)
    6971             : #define SGNODE__ALL_POOLS
    6972             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
    6973             : #endif
    6974             : 
    6975             : SgSourceFile* SgSourceFile::next_node = nullptr;
    6976             : std::vector<unsigned char*> SgSourceFile::pools;
    6977             : 
    6978             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
    6979             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
    6980             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
    6981             : // around this macro definition rather than each use).
    6982             : #ifndef ALLOC_MUTEX
    6983             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
    6984             :         do {                                                                     \
    6985             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
    6986             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
    6987             :                 abort();                                                         \
    6988             :             }                                                                    \
    6989             :         } while (0);
    6990             : #endif
    6991             : 
    6992             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
    6993             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
    6994             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
    6995             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
    6996             : 
    6997             : /*! \brief New operator for SgSourceFile.
    6998             : 
    6999             :    This new operator implements memory pools to provide most efficent 
    7000             :    use of the heap within construction of large ASTs.
    7001             : 
    7002             : \internal The new and delete operators use the lower level C malloc/free
    7003             :    function calls for performance and to make sure that mixing of malloc/free
    7004             :    and new/delete by the used can be caught more readily.  This may change
    7005             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
    7006             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
    7007             :    deallocate memory allocated using ROSE_MALLOC.
    7008             : */
    7009       11451 : void *SgSourceFile::operator new ( size_t Size )
    7010             : {
    7011             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
    7012             :      * returning or throwing an exception. */
    7013       11451 :     ALLOC_MUTEX(SgSourceFile, lock);
    7014             : 
    7015             : #if ROSE_ALLOC_TRACE == 2
    7016             : //    printf("SgSourceFile::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgSourceFile::next_node);
    7017             : #endif
    7018             : 
    7019             : #if USE_CPP_NEW_DELETE_OPERATORS
    7020             :     void *mem = ROSE_MALLOC(Size);
    7021             :     ALLOC_MUTEX(SgSourceFile, unlock);
    7022             :     return mem;
    7023             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
    7024             : #if ROSE_PEDANTIC_ALLOC
    7025             :     ROSE_ASSERT(Size == sizeof(SgSourceFile));
    7026             : #else
    7027       11451 :     if (Size != sizeof(SgSourceFile)) {
    7028           0 :       void * object = ROSE_MALLOC(Size);
    7029           0 :       ALLOC_MUTEX(SgSourceFile, unlock);
    7030             :       return object;
    7031             :     }
    7032             : #endif
    7033             : 
    7034       11451 :     if (SgSourceFile::next_node == nullptr) {
    7035         352 :         SgSourceFile * alloc = (SgSourceFile*) ROSE_MALLOC ( SgSourceFile::pool_size * sizeof(SgSourceFile) );
    7036         352 :         ROSE_ASSERT(alloc != nullptr);
    7037             : 
    7038             : #if ROSE_ALLOC_TRACE == 2
    7039             : //        printf("SgSourceFile::alloc\n  block[%zi] = [ %p , %p [\n", SgSourceFile::pools.size(), alloc, alloc + SgSourceFile::pool_size);
    7040             : #endif
    7041             : 
    7042             : #if ROSE_ALLOC_MEMSET == 1
    7043             : #elif ROSE_ALLOC_MEMSET == 2
    7044             :         memset(alloc, 0x00, SgSourceFile::pool_size * sizeof(SgSourceFile));
    7045             : #elif ROSE_ALLOC_MEMSET == 3
    7046             :         memset(alloc, 0xAA, SgSourceFile::pool_size * sizeof(SgSourceFile));
    7047             : #endif
    7048      704000 :         for (unsigned i=0; i < SgSourceFile::pool_size-1; i++) {
    7049      703648 :           alloc[i].p_freepointer = &(alloc[i+1]);
    7050             :         }
    7051         352 :         alloc[SgSourceFile::pool_size-1].p_freepointer = nullptr;
    7052             : 
    7053         352 :         SgSourceFile::pools.push_back ( (unsigned char *) alloc );
    7054         352 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgSourceFile::pool_size * sizeof(SgSourceFile), V_SgSourceFile ) );
    7055         352 :         SgSourceFile::next_node = alloc;
    7056             :     }
    7057       11451 :     ROSE_ASSERT(SgSourceFile::next_node != nullptr);
    7058             : 
    7059       11451 :     SgSourceFile * object = SgSourceFile::next_node;
    7060       11451 :     SgSourceFile::next_node = (SgSourceFile*)(object->p_freepointer);
    7061             : 
    7062             : #if ROSE_ALLOC_TRACE == 2
    7063             :     printf("SgSourceFile::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgSourceFile::next_node);
    7064             : #endif
    7065             : 
    7066       11451 :     SgNode * fp = object->p_freepointer;
    7067             : #if ROSE_ALLOC_MEMSET == 1
    7068             : #elif ROSE_ALLOC_MEMSET == 2
    7069             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgSourceFile) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
    7070             : #elif ROSE_ALLOC_MEMSET == 3
    7071             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgSourceFile) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
    7072             : #endif
    7073       11451 :     object->p_freepointer = fp;
    7074             : 
    7075             : #if ROSE_ALLOC_TRACE == 2
    7076             : //    printf("SgSourceFile::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgSourceFile::next_node);
    7077             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
    7078             :     Rose::MemPool::snapshot(oss.str());
    7079             :     alloc_trace_cnt++;
    7080             : #endif
    7081             : 
    7082       11451 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
    7083             : 
    7084       11451 :     ALLOC_MUTEX(SgSourceFile, unlock);
    7085             : 
    7086             :     return object;
    7087             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
    7088             : }
    7089             : 
    7090             : 
    7091             : 
    7092             : /*! \brief Delete operator for SgSourceFile.
    7093             : 
    7094             :    This delete operator implements deallocation using memory pools to 
    7095             :    provide most efficent use of the heap within construction of large ASTs.
    7096             : 
    7097             : \internal The new and delete operators use the lower level C malloc/free
    7098             :    function calls for performance and to make sure that mixing of malloc/free
    7099             :    and new/delete by the used can be caught more readily.  This may change
    7100             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
    7101             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
    7102             :    deallocate memory allocated using ROSE_MALLOC.
    7103             : */
    7104         395 : void SgSourceFile::operator delete(void *Pointer, size_t Size)
    7105             : {
    7106             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
    7107             :      * or throwing an exception. */
    7108         395 :     ALLOC_MUTEX(SgSourceFile, lock);
    7109             : 
    7110             : #if USE_CPP_NEW_DELETE_OPERATORS
    7111             :     ROSE_FREE(Pointer);
    7112             : #else
    7113             : #if ROSE_PEDANTIC_ALLOC
    7114             :     ROSE_ASSERT(Size == sizeof(SgSourceFile));
    7115             : #else
    7116         395 :     if (Size != sizeof(SgSourceFile)) {
    7117           0 :       ROSE_FREE(Pointer);
    7118           0 :       ALLOC_MUTEX(SgSourceFile, unlock);
    7119             :       return;
    7120             :     }
    7121             : #endif
    7122             : 
    7123         395 :     SgSourceFile * object = (SgSourceFile*) Pointer;
    7124         395 :     ROSE_ASSERT(object != nullptr);
    7125             : 
    7126             : #if ROSE_ALLOC_TRACE == 2
    7127             : //  printf("SgSourceFile::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgSourceFile::next_node);
    7128             :     printf("SgSourceFile::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgSourceFile::next_node);
    7129             : #endif
    7130             : 
    7131             : #if ROSE_PEDANTIC_ALLOC
    7132             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
    7133             : #endif
    7134             : 
    7135             : #if ROSE_ALLOC_MEMSET == 1
    7136             : #elif ROSE_ALLOC_MEMSET == 2
    7137             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgSourceFile) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
    7138             : #elif ROSE_ALLOC_MEMSET == 3
    7139             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgSourceFile) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
    7140             : #endif
    7141             : 
    7142             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
    7143             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
    7144             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
    7145             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
    7146             : #else
    7147         395 :     object->p_freepointer = SgSourceFile::next_node;
    7148         395 :     SgSourceFile::next_node = object;
    7149             : #endif
    7150             : 
    7151             : #if ROSE_ALLOC_TRACE == 2
    7152             : //  printf("SgSourceFile::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgSourceFile::next_node);
    7153             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
    7154             :     Rose::MemPool::snapshot(oss.str());
    7155             :     alloc_trace_cnt++;
    7156             : #endif
    7157             : 
    7158             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
    7159             : 
    7160         395 :     ALLOC_MUTEX(SgSourceFile, unlock);
    7161             : }
    7162             : 
    7163             : // DQ (11/27/2009): I have moved this member function definition to outside of the
    7164             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
    7165             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
    7166             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
    7167             : // Also, note comment below from Robb (copied from the Common.code file).
    7168             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
    7169             : //
    7170             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
    7171             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
    7172             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
    7173             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
    7174             : #if 0
    7175             : void SgSourceFile::operator delete(void* pointer) { SgSourceFile::operator delete (pointer, sizeof(SgSourceFile)); };
    7176             : #endif
    7177             : /* #line 7178 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
    7178             : 
    7179             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
    7180             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
    7181             : // obviously imply C++.
    7182             : 
    7183             : // This implements the support within ROSE for memory pools.  Memory pools
    7184             : // support the most condensed usage of memory within the construction of
    7185             : // and AST. Large blocks of contiguous storage for each RI node is allocated
    7186             : // by a new operator written for each class.
    7187             : 
    7188             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
    7189             :     // User wants multi-thread support and POSIX threads are available.
    7190             : #   include <pthread.h>
    7191             :     static pthread_mutex_t SgUnknownFile_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
    7192             : #else
    7193             :      // Cause synchronization to be skipped.
    7194             : #    ifndef ALLOC_MUTEX
    7195             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
    7196             : #    endif
    7197             : #    ifdef _REENTRANT
    7198             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
    7199             : #       ifdef _MSC_VER
    7200             : #           pragma message("POSIX threads are not available; synchronization being skipped")
    7201             : #       else
    7202             : #           warning "POSIX threads are not available; synchronization being skipped"
    7203             : #       endif
    7204             : #    endif
    7205             : #endif
    7206             : 
    7207             : #ifndef ROSE_ALLOC_TRACE
    7208             : #  define ROSE_ALLOC_TRACE 0
    7209             : #endif
    7210             : 
    7211             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
    7212             : #define ROSE_ALLOC_TRACE_CNT
    7213             : #include "memory-pool-snapshot.h"
    7214             : unsigned long alloc_trace_cnt = 0;
    7215             : #endif
    7216             : 
    7217             : #if ROSE_ALLOC_TRACE
    7218             : const unsigned SgUnknownFile::pool_size = 5;
    7219             : #else
    7220             : const unsigned SgUnknownFile::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
    7221             : #endif
    7222             : 
    7223             : #ifndef ROSE_ALLOC_MEMSET
    7224             : #  define ROSE_ALLOC_MEMSET 0
    7225             : #endif
    7226             : 
    7227             : #ifndef ROSE_PEDANTIC_ALLOC
    7228             : #  define ROSE_PEDANTIC_ALLOC 0
    7229             : #endif
    7230             : 
    7231             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
    7232             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
    7233             : #endif
    7234             : 
    7235             : #if !defined(SGNODE__ALL_POOLS)
    7236             : #define SGNODE__ALL_POOLS
    7237             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
    7238             : #endif
    7239             : 
    7240             : SgUnknownFile* SgUnknownFile::next_node = nullptr;
    7241             : std::vector<unsigned char*> SgUnknownFile::pools;
    7242             : 
    7243             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
    7244             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
    7245             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
    7246             : // around this macro definition rather than each use).
    7247             : #ifndef ALLOC_MUTEX
    7248             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
    7249             :         do {                                                                     \
    7250             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
    7251             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
    7252             :                 abort();                                                         \
    7253             :             }                                                                    \
    7254             :         } while (0);
    7255             : #endif
    7256             : 
    7257             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
    7258             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
    7259             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
    7260             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
    7261             : 
    7262             : /*! \brief New operator for SgUnknownFile.
    7263             : 
    7264             :    This new operator implements memory pools to provide most efficent 
    7265             :    use of the heap within construction of large ASTs.
    7266             : 
    7267             : \internal The new and delete operators use the lower level C malloc/free
    7268             :    function calls for performance and to make sure that mixing of malloc/free
    7269             :    and new/delete by the used can be caught more readily.  This may change
    7270             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
    7271             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
    7272             :    deallocate memory allocated using ROSE_MALLOC.
    7273             : */
    7274           0 : void *SgUnknownFile::operator new ( size_t Size )
    7275             : {
    7276             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
    7277             :      * returning or throwing an exception. */
    7278           0 :     ALLOC_MUTEX(SgUnknownFile, lock);
    7279             : 
    7280             : #if ROSE_ALLOC_TRACE == 2
    7281             : //    printf("SgUnknownFile::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgUnknownFile::next_node);
    7282             : #endif
    7283             : 
    7284             : #if USE_CPP_NEW_DELETE_OPERATORS
    7285             :     void *mem = ROSE_MALLOC(Size);
    7286             :     ALLOC_MUTEX(SgUnknownFile, unlock);
    7287             :     return mem;
    7288             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
    7289             : #if ROSE_PEDANTIC_ALLOC
    7290             :     ROSE_ASSERT(Size == sizeof(SgUnknownFile));
    7291             : #else
    7292           0 :     if (Size != sizeof(SgUnknownFile)) {
    7293           0 :       void * object = ROSE_MALLOC(Size);
    7294           0 :       ALLOC_MUTEX(SgUnknownFile, unlock);
    7295             :       return object;
    7296             :     }
    7297             : #endif
    7298             : 
    7299           0 :     if (SgUnknownFile::next_node == nullptr) {
    7300           0 :         SgUnknownFile * alloc = (SgUnknownFile*) ROSE_MALLOC ( SgUnknownFile::pool_size * sizeof(SgUnknownFile) );
    7301           0 :         ROSE_ASSERT(alloc != nullptr);
    7302             : 
    7303             : #if ROSE_ALLOC_TRACE == 2
    7304             : //        printf("SgUnknownFile::alloc\n  block[%zi] = [ %p , %p [\n", SgUnknownFile::pools.size(), alloc, alloc + SgUnknownFile::pool_size);
    7305             : #endif
    7306             : 
    7307             : #if ROSE_ALLOC_MEMSET == 1
    7308             : #elif ROSE_ALLOC_MEMSET == 2
    7309             :         memset(alloc, 0x00, SgUnknownFile::pool_size * sizeof(SgUnknownFile));
    7310             : #elif ROSE_ALLOC_MEMSET == 3
    7311             :         memset(alloc, 0xAA, SgUnknownFile::pool_size * sizeof(SgUnknownFile));
    7312             : #endif
    7313           0 :         for (unsigned i=0; i < SgUnknownFile::pool_size-1; i++) {
    7314           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
    7315             :         }
    7316           0 :         alloc[SgUnknownFile::pool_size-1].p_freepointer = nullptr;
    7317             : 
    7318           0 :         SgUnknownFile::pools.push_back ( (unsigned char *) alloc );
    7319           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgUnknownFile::pool_size * sizeof(SgUnknownFile), V_SgUnknownFile ) );
    7320           0 :         SgUnknownFile::next_node = alloc;
    7321             :     }
    7322           0 :     ROSE_ASSERT(SgUnknownFile::next_node != nullptr);
    7323             : 
    7324           0 :     SgUnknownFile * object = SgUnknownFile::next_node;
    7325           0 :     SgUnknownFile::next_node = (SgUnknownFile*)(object->p_freepointer);
    7326             : 
    7327             : #if ROSE_ALLOC_TRACE == 2
    7328             :     printf("SgUnknownFile::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUnknownFile::next_node);
    7329             : #endif
    7330             : 
    7331           0 :     SgNode * fp = object->p_freepointer;
    7332             : #if ROSE_ALLOC_MEMSET == 1
    7333             : #elif ROSE_ALLOC_MEMSET == 2
    7334             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgUnknownFile) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
    7335             : #elif ROSE_ALLOC_MEMSET == 3
    7336             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgUnknownFile) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
    7337             : #endif
    7338           0 :     object->p_freepointer = fp;
    7339             : 
    7340             : #if ROSE_ALLOC_TRACE == 2
    7341             : //    printf("SgUnknownFile::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUnknownFile::next_node);
    7342             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
    7343             :     Rose::MemPool::snapshot(oss.str());
    7344             :     alloc_trace_cnt++;
    7345             : #endif
    7346             : 
    7347           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
    7348             : 
    7349           0 :     ALLOC_MUTEX(SgUnknownFile, unlock);
    7350             : 
    7351             :     return object;
    7352             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
    7353             : }
    7354             : 
    7355             : 
    7356             : 
    7357             : /*! \brief Delete operator for SgUnknownFile.
    7358             : 
    7359             :    This delete operator implements deallocation using memory pools to 
    7360             :    provide most efficent use of the heap within construction of large ASTs.
    7361             : 
    7362             : \internal The new and delete operators use the lower level C malloc/free
    7363             :    function calls for performance and to make sure that mixing of malloc/free
    7364             :    and new/delete by the used can be caught more readily.  This may change
    7365             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
    7366             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
    7367             :    deallocate memory allocated using ROSE_MALLOC.
    7368             : */
    7369           0 : void SgUnknownFile::operator delete(void *Pointer, size_t Size)
    7370             : {
    7371             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
    7372             :      * or throwing an exception. */
    7373           0 :     ALLOC_MUTEX(SgUnknownFile, lock);
    7374             : 
    7375             : #if USE_CPP_NEW_DELETE_OPERATORS
    7376             :     ROSE_FREE(Pointer);
    7377             : #else
    7378             : #if ROSE_PEDANTIC_ALLOC
    7379             :     ROSE_ASSERT(Size == sizeof(SgUnknownFile));
    7380             : #else
    7381           0 :     if (Size != sizeof(SgUnknownFile)) {
    7382           0 :       ROSE_FREE(Pointer);
    7383           0 :       ALLOC_MUTEX(SgUnknownFile, unlock);
    7384             :       return;
    7385             :     }
    7386             : #endif
    7387             : 
    7388           0 :     SgUnknownFile * object = (SgUnknownFile*) Pointer;
    7389           0 :     ROSE_ASSERT(object != nullptr);
    7390             : 
    7391             : #if ROSE_ALLOC_TRACE == 2
    7392             : //  printf("SgUnknownFile::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUnknownFile::next_node);
    7393             :     printf("SgUnknownFile::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUnknownFile::next_node);
    7394             : #endif
    7395             : 
    7396             : #if ROSE_PEDANTIC_ALLOC
    7397             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
    7398             : #endif
    7399             : 
    7400             : #if ROSE_ALLOC_MEMSET == 1
    7401             : #elif ROSE_ALLOC_MEMSET == 2
    7402             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgUnknownFile) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
    7403             : #elif ROSE_ALLOC_MEMSET == 3
    7404             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgUnknownFile) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
    7405             : #endif
    7406             : 
    7407             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
    7408             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
    7409             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
    7410             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
    7411             : #else
    7412           0 :     object->p_freepointer = SgUnknownFile::next_node;
    7413           0 :     SgUnknownFile::next_node = object;
    7414             : #endif
    7415             : 
    7416             : #if ROSE_ALLOC_TRACE == 2
    7417             : //  printf("SgUnknownFile::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUnknownFile::next_node);
    7418             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
    7419             :     Rose::MemPool::snapshot(oss.str());
    7420             :     alloc_trace_cnt++;
    7421             : #endif
    7422             : 
    7423             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
    7424             : 
    7425           0 :     ALLOC_MUTEX(SgUnknownFile, unlock);
    7426             : }
    7427             : 
    7428             : // DQ (11/27/2009): I have moved this member function definition to outside of the
    7429             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
    7430             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
    7431             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
    7432             : // Also, note comment below from Robb (copied from the Common.code file).
    7433             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
    7434             : //
    7435             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
    7436             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
    7437             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
    7438             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
    7439             : #if 0
    7440             : void SgUnknownFile::operator delete(void* pointer) { SgUnknownFile::operator delete (pointer, sizeof(SgUnknownFile)); };
    7441             : #endif
    7442             : /* #line 7443 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
    7443             : 
    7444             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
    7445             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
    7446             : // obviously imply C++.
    7447             : 
    7448             : // This implements the support within ROSE for memory pools.  Memory pools
    7449             : // support the most condensed usage of memory within the construction of
    7450             : // and AST. Large blocks of contiguous storage for each RI node is allocated
    7451             : // by a new operator written for each class.
    7452             : 
    7453             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
    7454             :     // User wants multi-thread support and POSIX threads are available.
    7455             : #   include <pthread.h>
    7456             :     static pthread_mutex_t SgProject_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
    7457             : #else
    7458             :      // Cause synchronization to be skipped.
    7459             : #    ifndef ALLOC_MUTEX
    7460             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
    7461             : #    endif
    7462             : #    ifdef _REENTRANT
    7463             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
    7464             : #       ifdef _MSC_VER
    7465             : #           pragma message("POSIX threads are not available; synchronization being skipped")
    7466             : #       else
    7467             : #           warning "POSIX threads are not available; synchronization being skipped"
    7468             : #       endif
    7469             : #    endif
    7470             : #endif
    7471             : 
    7472             : #ifndef ROSE_ALLOC_TRACE
    7473             : #  define ROSE_ALLOC_TRACE 0
    7474             : #endif
    7475             : 
    7476             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
    7477             : #define ROSE_ALLOC_TRACE_CNT
    7478             : #include "memory-pool-snapshot.h"
    7479             : unsigned long alloc_trace_cnt = 0;
    7480             : #endif
    7481             : 
    7482             : #if ROSE_ALLOC_TRACE
    7483             : const unsigned SgProject::pool_size = 5;
    7484             : #else
    7485             : const unsigned SgProject::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
    7486             : #endif
    7487             : 
    7488             : #ifndef ROSE_ALLOC_MEMSET
    7489             : #  define ROSE_ALLOC_MEMSET 0
    7490             : #endif
    7491             : 
    7492             : #ifndef ROSE_PEDANTIC_ALLOC
    7493             : #  define ROSE_PEDANTIC_ALLOC 0
    7494             : #endif
    7495             : 
    7496             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
    7497             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
    7498             : #endif
    7499             : 
    7500             : #if !defined(SGNODE__ALL_POOLS)
    7501             : #define SGNODE__ALL_POOLS
    7502             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
    7503             : #endif
    7504             : 
    7505             : SgProject* SgProject::next_node = nullptr;
    7506             : std::vector<unsigned char*> SgProject::pools;
    7507             : 
    7508             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
    7509             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
    7510             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
    7511             : // around this macro definition rather than each use).
    7512             : #ifndef ALLOC_MUTEX
    7513             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
    7514             :         do {                                                                     \
    7515             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
    7516             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
    7517             :                 abort();                                                         \
    7518             :             }                                                                    \
    7519             :         } while (0);
    7520             : #endif
    7521             : 
    7522             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
    7523             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
    7524             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
    7525             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
    7526             : 
    7527             : /*! \brief New operator for SgProject.
    7528             : 
    7529             :    This new operator implements memory pools to provide most efficent 
    7530             :    use of the heap within construction of large ASTs.
    7531             : 
    7532             : \internal The new and delete operators use the lower level C malloc/free
    7533             :    function calls for performance and to make sure that mixing of malloc/free
    7534             :    and new/delete by the used can be caught more readily.  This may change
    7535             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
    7536             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
    7537             :    deallocate memory allocated using ROSE_MALLOC.
    7538             : */
    7539         359 : void *SgProject::operator new ( size_t Size )
    7540             : {
    7541             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
    7542             :      * returning or throwing an exception. */
    7543         359 :     ALLOC_MUTEX(SgProject, lock);
    7544             : 
    7545             : #if ROSE_ALLOC_TRACE == 2
    7546             : //    printf("SgProject::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgProject::next_node);
    7547             : #endif
    7548             : 
    7549             : #if USE_CPP_NEW_DELETE_OPERATORS
    7550             :     void *mem = ROSE_MALLOC(Size);
    7551             :     ALLOC_MUTEX(SgProject, unlock);
    7552             :     return mem;
    7553             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
    7554             : #if ROSE_PEDANTIC_ALLOC
    7555             :     ROSE_ASSERT(Size == sizeof(SgProject));
    7556             : #else
    7557         359 :     if (Size != sizeof(SgProject)) {
    7558           0 :       void * object = ROSE_MALLOC(Size);
    7559           0 :       ALLOC_MUTEX(SgProject, unlock);
    7560             :       return object;
    7561             :     }
    7562             : #endif
    7563             : 
    7564         359 :     if (SgProject::next_node == nullptr) {
    7565         355 :         SgProject * alloc = (SgProject*) ROSE_MALLOC ( SgProject::pool_size * sizeof(SgProject) );
    7566         355 :         ROSE_ASSERT(alloc != nullptr);
    7567             : 
    7568             : #if ROSE_ALLOC_TRACE == 2
    7569             : //        printf("SgProject::alloc\n  block[%zi] = [ %p , %p [\n", SgProject::pools.size(), alloc, alloc + SgProject::pool_size);
    7570             : #endif
    7571             : 
    7572             : #if ROSE_ALLOC_MEMSET == 1
    7573             : #elif ROSE_ALLOC_MEMSET == 2
    7574             :         memset(alloc, 0x00, SgProject::pool_size * sizeof(SgProject));
    7575             : #elif ROSE_ALLOC_MEMSET == 3
    7576             :         memset(alloc, 0xAA, SgProject::pool_size * sizeof(SgProject));
    7577             : #endif
    7578      710000 :         for (unsigned i=0; i < SgProject::pool_size-1; i++) {
    7579      709645 :           alloc[i].p_freepointer = &(alloc[i+1]);
    7580             :         }
    7581         355 :         alloc[SgProject::pool_size-1].p_freepointer = nullptr;
    7582             : 
    7583         355 :         SgProject::pools.push_back ( (unsigned char *) alloc );
    7584         355 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgProject::pool_size * sizeof(SgProject), V_SgProject ) );
    7585         355 :         SgProject::next_node = alloc;
    7586             :     }
    7587         359 :     ROSE_ASSERT(SgProject::next_node != nullptr);
    7588             : 
    7589         359 :     SgProject * object = SgProject::next_node;
    7590         359 :     SgProject::next_node = (SgProject*)(object->p_freepointer);
    7591             : 
    7592             : #if ROSE_ALLOC_TRACE == 2
    7593             :     printf("SgProject::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgProject::next_node);
    7594             : #endif
    7595             : 
    7596         359 :     SgNode * fp = object->p_freepointer;
    7597             : #if ROSE_ALLOC_MEMSET == 1
    7598             : #elif ROSE_ALLOC_MEMSET == 2
    7599             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgProject) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
    7600             : #elif ROSE_ALLOC_MEMSET == 3
    7601             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgProject) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
    7602             : #endif
    7603         359 :     object->p_freepointer = fp;
    7604             : 
    7605             : #if ROSE_ALLOC_TRACE == 2
    7606             : //    printf("SgProject::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgProject::next_node);
    7607             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
    7608             :     Rose::MemPool::snapshot(oss.str());
    7609             :     alloc_trace_cnt++;
    7610             : #endif
    7611             : 
    7612         359 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
    7613             : 
    7614         359 :     ALLOC_MUTEX(SgProject, unlock);
    7615             : 
    7616             :     return object;
    7617             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
    7618             : }
    7619             : 
    7620             : 
    7621             : 
    7622             : /*! \brief Delete operator for SgProject.
    7623             : 
    7624             :    This delete operator implements deallocation using memory pools to 
    7625             :    provide most efficent use of the heap within construction of large ASTs.
    7626             : 
    7627             : \internal The new and delete operators use the lower level C malloc/free
    7628             :    function calls for performance and to make sure that mixing of malloc/free
    7629             :    and new/delete by the used can be caught more readily.  This may change
    7630             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
    7631             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
    7632             :    deallocate memory allocated using ROSE_MALLOC.
    7633             : */
    7634           7 : void SgProject::operator delete(void *Pointer, size_t Size)
    7635             : {
    7636             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
    7637             :      * or throwing an exception. */
    7638           7 :     ALLOC_MUTEX(SgProject, lock);
    7639             : 
    7640             : #if USE_CPP_NEW_DELETE_OPERATORS
    7641             :     ROSE_FREE(Pointer);
    7642             : #else
    7643             : #if ROSE_PEDANTIC_ALLOC
    7644             :     ROSE_ASSERT(Size == sizeof(SgProject));
    7645             : #else
    7646           7 :     if (Size != sizeof(SgProject)) {
    7647           0 :       ROSE_FREE(Pointer);
    7648           0 :       ALLOC_MUTEX(SgProject, unlock);
    7649             :       return;
    7650             :     }
    7651             : #endif
    7652             : 
    7653           7 :     SgProject * object = (SgProject*) Pointer;
    7654           7 :     ROSE_ASSERT(object != nullptr);
    7655             : 
    7656             : #if ROSE_ALLOC_TRACE == 2
    7657             : //  printf("SgProject::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgProject::next_node);
    7658             :     printf("SgProject::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgProject::next_node);
    7659             : #endif
    7660             : 
    7661             : #if ROSE_PEDANTIC_ALLOC
    7662             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
    7663             : #endif
    7664             : 
    7665             : #if ROSE_ALLOC_MEMSET == 1
    7666             : #elif ROSE_ALLOC_MEMSET == 2
    7667             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgProject) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
    7668             : #elif ROSE_ALLOC_MEMSET == 3
    7669             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgProject) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
    7670             : #endif
    7671             : 
    7672             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
    7673             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
    7674             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
    7675             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
    7676             : #else
    7677           7 :     object->p_freepointer = SgProject::next_node;
    7678           7 :     SgProject::next_node = object;
    7679             : #endif
    7680             : 
    7681             : #if ROSE_ALLOC_TRACE == 2
    7682             : //  printf("SgProject::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgProject::next_node);
    7683             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
    7684             :     Rose::MemPool::snapshot(oss.str());
    7685             :     alloc_trace_cnt++;
    7686             : #endif
    7687             : 
    7688             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
    7689             : 
    7690           7 :     ALLOC_MUTEX(SgProject, unlock);
    7691             : }
    7692             : 
    7693             : // DQ (11/27/2009): I have moved this member function definition to outside of the
    7694             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
    7695             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
    7696             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
    7697             : // Also, note comment below from Robb (copied from the Common.code file).
    7698             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
    7699             : //
    7700             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
    7701             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
    7702             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
    7703             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
    7704             : #if 0
    7705             : void SgProject::operator delete(void* pointer) { SgProject::operator delete (pointer, sizeof(SgProject)); };
    7706             : #endif
    7707             : /* #line 7708 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
    7708             : 
    7709             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
    7710             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
    7711             : // obviously imply C++.
    7712             : 
    7713             : // This implements the support within ROSE for memory pools.  Memory pools
    7714             : // support the most condensed usage of memory within the construction of
    7715             : // and AST. Large blocks of contiguous storage for each RI node is allocated
    7716             : // by a new operator written for each class.
    7717             : 
    7718             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
    7719             :     // User wants multi-thread support and POSIX threads are available.
    7720             : #   include <pthread.h>
    7721             :     static pthread_mutex_t SgOptions_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
    7722             : #else
    7723             :      // Cause synchronization to be skipped.
    7724             : #    ifndef ALLOC_MUTEX
    7725             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
    7726             : #    endif
    7727             : #    ifdef _REENTRANT
    7728             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
    7729             : #       ifdef _MSC_VER
    7730             : #           pragma message("POSIX threads are not available; synchronization being skipped")
    7731             : #       else
    7732             : #           warning "POSIX threads are not available; synchronization being skipped"
    7733             : #       endif
    7734             : #    endif
    7735             : #endif
    7736             : 
    7737             : #ifndef ROSE_ALLOC_TRACE
    7738             : #  define ROSE_ALLOC_TRACE 0
    7739             : #endif
    7740             : 
    7741             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
    7742             : #define ROSE_ALLOC_TRACE_CNT
    7743             : #include "memory-pool-snapshot.h"
    7744             : unsigned long alloc_trace_cnt = 0;
    7745             : #endif
    7746             : 
    7747             : #if ROSE_ALLOC_TRACE
    7748             : const unsigned SgOptions::pool_size = 5;
    7749             : #else
    7750             : const unsigned SgOptions::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
    7751             : #endif
    7752             : 
    7753             : #ifndef ROSE_ALLOC_MEMSET
    7754             : #  define ROSE_ALLOC_MEMSET 0
    7755             : #endif
    7756             : 
    7757             : #ifndef ROSE_PEDANTIC_ALLOC
    7758             : #  define ROSE_PEDANTIC_ALLOC 0
    7759             : #endif
    7760             : 
    7761             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
    7762             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
    7763             : #endif
    7764             : 
    7765             : #if !defined(SGNODE__ALL_POOLS)
    7766             : #define SGNODE__ALL_POOLS
    7767             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
    7768             : #endif
    7769             : 
    7770             : SgOptions* SgOptions::next_node = nullptr;
    7771             : std::vector<unsigned char*> SgOptions::pools;
    7772             : 
    7773             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
    7774             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
    7775             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
    7776             : // around this macro definition rather than each use).
    7777             : #ifndef ALLOC_MUTEX
    7778             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
    7779             :         do {                                                                     \
    7780             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
    7781             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
    7782             :                 abort();                                                         \
    7783             :             }                                                                    \
    7784             :         } while (0);
    7785             : #endif
    7786             : 
    7787             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
    7788             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
    7789             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
    7790             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
    7791             : 
    7792             : /*! \brief New operator for SgOptions.
    7793             : 
    7794             :    This new operator implements memory pools to provide most efficent 
    7795             :    use of the heap within construction of large ASTs.
    7796             : 
    7797             : \internal The new and delete operators use the lower level C malloc/free
    7798             :    function calls for performance and to make sure that mixing of malloc/free
    7799             :    and new/delete by the used can be caught more readily.  This may change
    7800             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
    7801             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
    7802             :    deallocate memory allocated using ROSE_MALLOC.
    7803             : */
    7804           0 : void *SgOptions::operator new ( size_t Size )
    7805             : {
    7806             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
    7807             :      * returning or throwing an exception. */
    7808           0 :     ALLOC_MUTEX(SgOptions, lock);
    7809             : 
    7810             : #if ROSE_ALLOC_TRACE == 2
    7811             : //    printf("SgOptions::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgOptions::next_node);
    7812             : #endif
    7813             : 
    7814             : #if USE_CPP_NEW_DELETE_OPERATORS
    7815             :     void *mem = ROSE_MALLOC(Size);
    7816             :     ALLOC_MUTEX(SgOptions, unlock);
    7817             :     return mem;
    7818             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
    7819             : #if ROSE_PEDANTIC_ALLOC
    7820             :     ROSE_ASSERT(Size == sizeof(SgOptions));
    7821             : #else
    7822           0 :     if (Size != sizeof(SgOptions)) {
    7823           0 :       void * object = ROSE_MALLOC(Size);
    7824           0 :       ALLOC_MUTEX(SgOptions, unlock);
    7825             :       return object;
    7826             :     }
    7827             : #endif
    7828             : 
    7829           0 :     if (SgOptions::next_node == nullptr) {
    7830           0 :         SgOptions * alloc = (SgOptions*) ROSE_MALLOC ( SgOptions::pool_size * sizeof(SgOptions) );
    7831           0 :         ROSE_ASSERT(alloc != nullptr);
    7832             : 
    7833             : #if ROSE_ALLOC_TRACE == 2
    7834             : //        printf("SgOptions::alloc\n  block[%zi] = [ %p , %p [\n", SgOptions::pools.size(), alloc, alloc + SgOptions::pool_size);
    7835             : #endif
    7836             : 
    7837             : #if ROSE_ALLOC_MEMSET == 1
    7838             : #elif ROSE_ALLOC_MEMSET == 2
    7839             :         memset(alloc, 0x00, SgOptions::pool_size * sizeof(SgOptions));
    7840             : #elif ROSE_ALLOC_MEMSET == 3
    7841             :         memset(alloc, 0xAA, SgOptions::pool_size * sizeof(SgOptions));
    7842             : #endif
    7843           0 :         for (unsigned i=0; i < SgOptions::pool_size-1; i++) {
    7844           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
    7845             :         }
    7846           0 :         alloc[SgOptions::pool_size-1].p_freepointer = nullptr;
    7847             : 
    7848           0 :         SgOptions::pools.push_back ( (unsigned char *) alloc );
    7849           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgOptions::pool_size * sizeof(SgOptions), V_SgOptions ) );
    7850           0 :         SgOptions::next_node = alloc;
    7851             :     }
    7852           0 :     ROSE_ASSERT(SgOptions::next_node != nullptr);
    7853             : 
    7854           0 :     SgOptions * object = SgOptions::next_node;
    7855           0 :     SgOptions::next_node = (SgOptions*)(object->p_freepointer);
    7856             : 
    7857             : #if ROSE_ALLOC_TRACE == 2
    7858             :     printf("SgOptions::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOptions::next_node);
    7859             : #endif
    7860             : 
    7861           0 :     SgNode * fp = object->p_freepointer;
    7862             : #if ROSE_ALLOC_MEMSET == 1
    7863             : #elif ROSE_ALLOC_MEMSET == 2
    7864             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOptions) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
    7865             : #elif ROSE_ALLOC_MEMSET == 3
    7866             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgOptions) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
    7867             : #endif
    7868           0 :     object->p_freepointer = fp;
    7869             : 
    7870             : #if ROSE_ALLOC_TRACE == 2
    7871             : //    printf("SgOptions::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOptions::next_node);
    7872             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
    7873             :     Rose::MemPool::snapshot(oss.str());
    7874             :     alloc_trace_cnt++;
    7875             : #endif
    7876             : 
    7877           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
    7878             : 
    7879           0 :     ALLOC_MUTEX(SgOptions, unlock);
    7880             : 
    7881             :     return object;
    7882             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
    7883             : }
    7884             : 
    7885             : 
    7886             : 
    7887             : /*! \brief Delete operator for SgOptions.
    7888             : 
    7889             :    This delete operator implements deallocation using memory pools to 
    7890             :    provide most efficent use of the heap within construction of large ASTs.
    7891             : 
    7892             : \internal The new and delete operators use the lower level C malloc/free
    7893             :    function calls for performance and to make sure that mixing of malloc/free
    7894             :    and new/delete by the used can be caught more readily.  This may change
    7895             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
    7896             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
    7897             :    deallocate memory allocated using ROSE_MALLOC.
    7898             : */
    7899           0 : void SgOptions::operator delete(void *Pointer, size_t Size)
    7900             : {
    7901             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
    7902             :      * or throwing an exception. */
    7903           0 :     ALLOC_MUTEX(SgOptions, lock);
    7904             : 
    7905             : #if USE_CPP_NEW_DELETE_OPERATORS
    7906             :     ROSE_FREE(Pointer);
    7907             : #else
    7908             : #if ROSE_PEDANTIC_ALLOC
    7909             :     ROSE_ASSERT(Size == sizeof(SgOptions));
    7910             : #else
    7911           0 :     if (Size != sizeof(SgOptions)) {
    7912           0 :       ROSE_FREE(Pointer);
    7913           0 :       ALLOC_MUTEX(SgOptions, unlock);
    7914             :       return;
    7915             :     }
    7916             : #endif
    7917             : 
    7918           0 :     SgOptions * object = (SgOptions*) Pointer;
    7919           0 :     ROSE_ASSERT(object != nullptr);
    7920             : 
    7921             : #if ROSE_ALLOC_TRACE == 2
    7922             : //  printf("SgOptions::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOptions::next_node);
    7923             :     printf("SgOptions::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOptions::next_node);
    7924             : #endif
    7925             : 
    7926             : #if ROSE_PEDANTIC_ALLOC
    7927             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
    7928             : #endif
    7929             : 
    7930             : #if ROSE_ALLOC_MEMSET == 1
    7931             : #elif ROSE_ALLOC_MEMSET == 2
    7932             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOptions) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
    7933             : #elif ROSE_ALLOC_MEMSET == 3
    7934             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgOptions) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
    7935             : #endif
    7936             : 
    7937             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
    7938             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
    7939             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
    7940             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
    7941             : #else
    7942           0 :     object->p_freepointer = SgOptions::next_node;
    7943           0 :     SgOptions::next_node = object;
    7944             : #endif
    7945             : 
    7946             : #if ROSE_ALLOC_TRACE == 2
    7947             : //  printf("SgOptions::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOptions::next_node);
    7948             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
    7949             :     Rose::MemPool::snapshot(oss.str());
    7950             :     alloc_trace_cnt++;
    7951             : #endif
    7952             : 
    7953             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
    7954             : 
    7955           0 :     ALLOC_MUTEX(SgOptions, unlock);
    7956             : }
    7957             : 
    7958             : // DQ (11/27/2009): I have moved this member function definition to outside of the
    7959             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
    7960             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
    7961             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
    7962             : // Also, note comment below from Robb (copied from the Common.code file).
    7963             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
    7964             : //
    7965             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
    7966             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
    7967             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
    7968             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
    7969             : #if 0
    7970             : void SgOptions::operator delete(void* pointer) { SgOptions::operator delete (pointer, sizeof(SgOptions)); };
    7971             : #endif
    7972             : /* #line 7973 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
    7973             : 
    7974             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
    7975             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
    7976             : // obviously imply C++.
    7977             : 
    7978             : // This implements the support within ROSE for memory pools.  Memory pools
    7979             : // support the most condensed usage of memory within the construction of
    7980             : // and AST. Large blocks of contiguous storage for each RI node is allocated
    7981             : // by a new operator written for each class.
    7982             : 
    7983             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
    7984             :     // User wants multi-thread support and POSIX threads are available.
    7985             : #   include <pthread.h>
    7986             :     static pthread_mutex_t SgUnparse_Info_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
    7987             : #else
    7988             :      // Cause synchronization to be skipped.
    7989             : #    ifndef ALLOC_MUTEX
    7990             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
    7991             : #    endif
    7992             : #    ifdef _REENTRANT
    7993             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
    7994             : #       ifdef _MSC_VER
    7995             : #           pragma message("POSIX threads are not available; synchronization being skipped")
    7996             : #       else
    7997             : #           warning "POSIX threads are not available; synchronization being skipped"
    7998             : #       endif
    7999             : #    endif
    8000             : #endif
    8001             : 
    8002             : #ifndef ROSE_ALLOC_TRACE
    8003             : #  define ROSE_ALLOC_TRACE 0
    8004             : #endif
    8005             : 
    8006             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
    8007             : #define ROSE_ALLOC_TRACE_CNT
    8008             : #include "memory-pool-snapshot.h"
    8009             : unsigned long alloc_trace_cnt = 0;
    8010             : #endif
    8011             : 
    8012             : #if ROSE_ALLOC_TRACE
    8013             : const unsigned SgUnparse_Info::pool_size = 5;
    8014             : #else
    8015             : const unsigned SgUnparse_Info::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
    8016             : #endif
    8017             : 
    8018             : #ifndef ROSE_ALLOC_MEMSET
    8019             : #  define ROSE_ALLOC_MEMSET 0
    8020             : #endif
    8021             : 
    8022             : #ifndef ROSE_PEDANTIC_ALLOC
    8023             : #  define ROSE_PEDANTIC_ALLOC 0
    8024             : #endif
    8025             : 
    8026             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
    8027             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
    8028             : #endif
    8029             : 
    8030             : #if !defined(SGNODE__ALL_POOLS)
    8031             : #define SGNODE__ALL_POOLS
    8032             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
    8033             : #endif
    8034             : 
    8035             : SgUnparse_Info* SgUnparse_Info::next_node = nullptr;
    8036             : std::vector<unsigned char*> SgUnparse_Info::pools;
    8037             : 
    8038             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
    8039             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
    8040             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
    8041             : // around this macro definition rather than each use).
    8042             : #ifndef ALLOC_MUTEX
    8043             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
    8044             :         do {                                                                     \
    8045             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
    8046             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
    8047             :                 abort();                                                         \
    8048             :             }                                                                    \
    8049             :         } while (0);
    8050             : #endif
    8051             : 
    8052             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
    8053             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
    8054             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
    8055             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
    8056             : 
    8057             : /*! \brief New operator for SgUnparse_Info.
    8058             : 
    8059             :    This new operator implements memory pools to provide most efficent 
    8060             :    use of the heap within construction of large ASTs.
    8061             : 
    8062             : \internal The new and delete operators use the lower level C malloc/free
    8063             :    function calls for performance and to make sure that mixing of malloc/free
    8064             :    and new/delete by the used can be caught more readily.  This may change
    8065             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
    8066             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
    8067             :    deallocate memory allocated using ROSE_MALLOC.
    8068             : */
    8069     1640230 : void *SgUnparse_Info::operator new ( size_t Size )
    8070             : {
    8071             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
    8072             :      * returning or throwing an exception. */
    8073     1640230 :     ALLOC_MUTEX(SgUnparse_Info, lock);
    8074             : 
    8075             : #if ROSE_ALLOC_TRACE == 2
    8076             : //    printf("SgUnparse_Info::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgUnparse_Info::next_node);
    8077             : #endif
    8078             : 
    8079             : #if USE_CPP_NEW_DELETE_OPERATORS
    8080             :     void *mem = ROSE_MALLOC(Size);
    8081             :     ALLOC_MUTEX(SgUnparse_Info, unlock);
    8082             :     return mem;
    8083             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
    8084             : #if ROSE_PEDANTIC_ALLOC
    8085             :     ROSE_ASSERT(Size == sizeof(SgUnparse_Info));
    8086             : #else
    8087     1640230 :     if (Size != sizeof(SgUnparse_Info)) {
    8088           0 :       void * object = ROSE_MALLOC(Size);
    8089           0 :       ALLOC_MUTEX(SgUnparse_Info, unlock);
    8090             :       return object;
    8091             :     }
    8092             : #endif
    8093             : 
    8094     1640230 :     if (SgUnparse_Info::next_node == nullptr) {
    8095         282 :         SgUnparse_Info * alloc = (SgUnparse_Info*) ROSE_MALLOC ( SgUnparse_Info::pool_size * sizeof(SgUnparse_Info) );
    8096         282 :         ROSE_ASSERT(alloc != nullptr);
    8097             : 
    8098             : #if ROSE_ALLOC_TRACE == 2
    8099             : //        printf("SgUnparse_Info::alloc\n  block[%zi] = [ %p , %p [\n", SgUnparse_Info::pools.size(), alloc, alloc + SgUnparse_Info::pool_size);
    8100             : #endif
    8101             : 
    8102             : #if ROSE_ALLOC_MEMSET == 1
    8103             : #elif ROSE_ALLOC_MEMSET == 2
    8104             :         memset(alloc, 0x00, SgUnparse_Info::pool_size * sizeof(SgUnparse_Info));
    8105             : #elif ROSE_ALLOC_MEMSET == 3
    8106             :         memset(alloc, 0xAA, SgUnparse_Info::pool_size * sizeof(SgUnparse_Info));
    8107             : #endif
    8108      564000 :         for (unsigned i=0; i < SgUnparse_Info::pool_size-1; i++) {
    8109      563718 :           alloc[i].p_freepointer = &(alloc[i+1]);
    8110             :         }
    8111         282 :         alloc[SgUnparse_Info::pool_size-1].p_freepointer = nullptr;
    8112             : 
    8113         282 :         SgUnparse_Info::pools.push_back ( (unsigned char *) alloc );
    8114         282 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgUnparse_Info::pool_size * sizeof(SgUnparse_Info), V_SgUnparse_Info ) );
    8115         282 :         SgUnparse_Info::next_node = alloc;
    8116             :     }
    8117     1640230 :     ROSE_ASSERT(SgUnparse_Info::next_node != nullptr);
    8118             : 
    8119     1640230 :     SgUnparse_Info * object = SgUnparse_Info::next_node;
    8120     1640230 :     SgUnparse_Info::next_node = (SgUnparse_Info*)(object->p_freepointer);
    8121             : 
    8122             : #if ROSE_ALLOC_TRACE == 2
    8123             :     printf("SgUnparse_Info::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUnparse_Info::next_node);
    8124             : #endif
    8125             : 
    8126     1640230 :     SgNode * fp = object->p_freepointer;
    8127             : #if ROSE_ALLOC_MEMSET == 1
    8128             : #elif ROSE_ALLOC_MEMSET == 2
    8129             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgUnparse_Info) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
    8130             : #elif ROSE_ALLOC_MEMSET == 3
    8131             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgUnparse_Info) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
    8132             : #endif
    8133     1640230 :     object->p_freepointer = fp;
    8134             : 
    8135             : #if ROSE_ALLOC_TRACE == 2
    8136             : //    printf("SgUnparse_Info::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUnparse_Info::next_node);
    8137             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
    8138             :     Rose::MemPool::snapshot(oss.str());
    8139             :     alloc_trace_cnt++;
    8140             : #endif
    8141             : 
    8142     1640230 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
    8143             : 
    8144     1640230 :     ALLOC_MUTEX(SgUnparse_Info, unlock);
    8145             : 
    8146             :     return object;
    8147             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
    8148             : }
    8149             : 
    8150             : 
    8151             : 
    8152             : /*! \brief Delete operator for SgUnparse_Info.
    8153             : 
    8154             :    This delete operator implements deallocation using memory pools to 
    8155             :    provide most efficent use of the heap within construction of large ASTs.
    8156             : 
    8157             : \internal The new and delete operators use the lower level C malloc/free
    8158             :    function calls for performance and to make sure that mixing of malloc/free
    8159             :    and new/delete by the used can be caught more readily.  This may change
    8160             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
    8161             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
    8162             :    deallocate memory allocated using ROSE_MALLOC.
    8163             : */
    8164     1625440 : void SgUnparse_Info::operator delete(void *Pointer, size_t Size)
    8165             : {
    8166             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
    8167             :      * or throwing an exception. */
    8168     1625440 :     ALLOC_MUTEX(SgUnparse_Info, lock);
    8169             : 
    8170             : #if USE_CPP_NEW_DELETE_OPERATORS
    8171             :     ROSE_FREE(Pointer);
    8172             : #else
    8173             : #if ROSE_PEDANTIC_ALLOC
    8174             :     ROSE_ASSERT(Size == sizeof(SgUnparse_Info));
    8175             : #else
    8176     1625440 :     if (Size != sizeof(SgUnparse_Info)) {
    8177           0 :       ROSE_FREE(Pointer);
    8178           0 :       ALLOC_MUTEX(SgUnparse_Info, unlock);
    8179             :       return;
    8180             :     }
    8181             : #endif
    8182             : 
    8183     1625440 :     SgUnparse_Info * object = (SgUnparse_Info*) Pointer;
    8184     1625440 :     ROSE_ASSERT(object != nullptr);
    8185             : 
    8186             : #if ROSE_ALLOC_TRACE == 2
    8187             : //  printf("SgUnparse_Info::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUnparse_Info::next_node);
    8188             :     printf("SgUnparse_Info::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUnparse_Info::next_node);
    8189             : #endif
    8190             : 
    8191             : #if ROSE_PEDANTIC_ALLOC
    8192             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
    8193             : #endif
    8194             : 
    8195             : #if ROSE_ALLOC_MEMSET == 1
    8196             : #elif ROSE_ALLOC_MEMSET == 2
    8197             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgUnparse_Info) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
    8198             : #elif ROSE_ALLOC_MEMSET == 3
    8199             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgUnparse_Info) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
    8200             : #endif
    8201             : 
    8202             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
    8203             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
    8204             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
    8205             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
    8206             : #else
    8207     1625440 :     object->p_freepointer = SgUnparse_Info::next_node;
    8208     1625440 :     SgUnparse_Info::next_node = object;
    8209             : #endif
    8210             : 
    8211             : #if ROSE_ALLOC_TRACE == 2
    8212             : //  printf("SgUnparse_Info::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUnparse_Info::next_node);
    8213             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
    8214             :     Rose::MemPool::snapshot(oss.str());
    8215             :     alloc_trace_cnt++;
    8216             : #endif
    8217             : 
    8218             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
    8219             : 
    8220     1625440 :     ALLOC_MUTEX(SgUnparse_Info, unlock);
    8221             : }
    8222             : 
    8223             : // DQ (11/27/2009): I have moved this member function definition to outside of the
    8224             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
    8225             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
    8226             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
    8227             : // Also, note comment below from Robb (copied from the Common.code file).
    8228             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
    8229             : //
    8230             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
    8231             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
    8232             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
    8233             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
    8234             : #if 0
    8235             : void SgUnparse_Info::operator delete(void* pointer) { SgUnparse_Info::operator delete (pointer, sizeof(SgUnparse_Info)); };
    8236             : #endif
    8237             : /* #line 8238 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
    8238             : 
    8239             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
    8240             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
    8241             : // obviously imply C++.
    8242             : 
    8243             : // This implements the support within ROSE for memory pools.  Memory pools
    8244             : // support the most condensed usage of memory within the construction of
    8245             : // and AST. Large blocks of contiguous storage for each RI node is allocated
    8246             : // by a new operator written for each class.
    8247             : 
    8248             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
    8249             :     // User wants multi-thread support and POSIX threads are available.
    8250             : #   include <pthread.h>
    8251             :     static pthread_mutex_t SgBaseClass_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
    8252             : #else
    8253             :      // Cause synchronization to be skipped.
    8254             : #    ifndef ALLOC_MUTEX
    8255             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
    8256             : #    endif
    8257             : #    ifdef _REENTRANT
    8258             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
    8259             : #       ifdef _MSC_VER
    8260             : #           pragma message("POSIX threads are not available; synchronization being skipped")
    8261             : #       else
    8262             : #           warning "POSIX threads are not available; synchronization being skipped"
    8263             : #       endif
    8264             : #    endif
    8265             : #endif
    8266             : 
    8267             : #ifndef ROSE_ALLOC_TRACE
    8268             : #  define ROSE_ALLOC_TRACE 0
    8269             : #endif
    8270             : 
    8271             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
    8272             : #define ROSE_ALLOC_TRACE_CNT
    8273             : #include "memory-pool-snapshot.h"
    8274             : unsigned long alloc_trace_cnt = 0;
    8275             : #endif
    8276             : 
    8277             : #if ROSE_ALLOC_TRACE
    8278             : const unsigned SgBaseClass::pool_size = 5;
    8279             : #else
    8280             : const unsigned SgBaseClass::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
    8281             : #endif
    8282             : 
    8283             : #ifndef ROSE_ALLOC_MEMSET
    8284             : #  define ROSE_ALLOC_MEMSET 0
    8285             : #endif
    8286             : 
    8287             : #ifndef ROSE_PEDANTIC_ALLOC
    8288             : #  define ROSE_PEDANTIC_ALLOC 0
    8289             : #endif
    8290             : 
    8291             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
    8292             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
    8293             : #endif
    8294             : 
    8295             : #if !defined(SGNODE__ALL_POOLS)
    8296             : #define SGNODE__ALL_POOLS
    8297             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
    8298             : #endif
    8299             : 
    8300             : SgBaseClass* SgBaseClass::next_node = nullptr;
    8301             : std::vector<unsigned char*> SgBaseClass::pools;
    8302             : 
    8303             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
    8304             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
    8305             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
    8306             : // around this macro definition rather than each use).
    8307             : #ifndef ALLOC_MUTEX
    8308             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
    8309             :         do {                                                                     \
    8310             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
    8311             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
    8312             :                 abort();                                                         \
    8313             :             }                                                                    \
    8314             :         } while (0);
    8315             : #endif
    8316             : 
    8317             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
    8318             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
    8319             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
    8320             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
    8321             : 
    8322             : /*! \brief New operator for SgBaseClass.
    8323             : 
    8324             :    This new operator implements memory pools to provide most efficent 
    8325             :    use of the heap within construction of large ASTs.
    8326             : 
    8327             : \internal The new and delete operators use the lower level C malloc/free
    8328             :    function calls for performance and to make sure that mixing of malloc/free
    8329             :    and new/delete by the used can be caught more readily.  This may change
    8330             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
    8331             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
    8332             :    deallocate memory allocated using ROSE_MALLOC.
    8333             : */
    8334        4237 : void *SgBaseClass::operator new ( size_t Size )
    8335             : {
    8336             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
    8337             :      * returning or throwing an exception. */
    8338        4237 :     ALLOC_MUTEX(SgBaseClass, lock);
    8339             : 
    8340             : #if ROSE_ALLOC_TRACE == 2
    8341             : //    printf("SgBaseClass::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgBaseClass::next_node);
    8342             : #endif
    8343             : 
    8344             : #if USE_CPP_NEW_DELETE_OPERATORS
    8345             :     void *mem = ROSE_MALLOC(Size);
    8346             :     ALLOC_MUTEX(SgBaseClass, unlock);
    8347             :     return mem;
    8348             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
    8349             : #if ROSE_PEDANTIC_ALLOC
    8350             :     ROSE_ASSERT(Size == sizeof(SgBaseClass));
    8351             : #else
    8352        4237 :     if (Size != sizeof(SgBaseClass)) {
    8353           0 :       void * object = ROSE_MALLOC(Size);
    8354           0 :       ALLOC_MUTEX(SgBaseClass, unlock);
    8355             :       return object;
    8356             :     }
    8357             : #endif
    8358             : 
    8359        4237 :     if (SgBaseClass::next_node == nullptr) {
    8360          10 :         SgBaseClass * alloc = (SgBaseClass*) ROSE_MALLOC ( SgBaseClass::pool_size * sizeof(SgBaseClass) );
    8361          10 :         ROSE_ASSERT(alloc != nullptr);
    8362             : 
    8363             : #if ROSE_ALLOC_TRACE == 2
    8364             : //        printf("SgBaseClass::alloc\n  block[%zi] = [ %p , %p [\n", SgBaseClass::pools.size(), alloc, alloc + SgBaseClass::pool_size);
    8365             : #endif
    8366             : 
    8367             : #if ROSE_ALLOC_MEMSET == 1
    8368             : #elif ROSE_ALLOC_MEMSET == 2
    8369             :         memset(alloc, 0x00, SgBaseClass::pool_size * sizeof(SgBaseClass));
    8370             : #elif ROSE_ALLOC_MEMSET == 3
    8371             :         memset(alloc, 0xAA, SgBaseClass::pool_size * sizeof(SgBaseClass));
    8372             : #endif
    8373       20000 :         for (unsigned i=0; i < SgBaseClass::pool_size-1; i++) {
    8374       19990 :           alloc[i].p_freepointer = &(alloc[i+1]);
    8375             :         }
    8376          10 :         alloc[SgBaseClass::pool_size-1].p_freepointer = nullptr;
    8377             : 
    8378          10 :         SgBaseClass::pools.push_back ( (unsigned char *) alloc );
    8379          10 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgBaseClass::pool_size * sizeof(SgBaseClass), V_SgBaseClass ) );
    8380          10 :         SgBaseClass::next_node = alloc;
    8381             :     }
    8382        4237 :     ROSE_ASSERT(SgBaseClass::next_node != nullptr);
    8383             : 
    8384        4237 :     SgBaseClass * object = SgBaseClass::next_node;
    8385        4237 :     SgBaseClass::next_node = (SgBaseClass*)(object->p_freepointer);
    8386             : 
    8387             : #if ROSE_ALLOC_TRACE == 2
    8388             :     printf("SgBaseClass::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgBaseClass::next_node);
    8389             : #endif
    8390             : 
    8391        4237 :     SgNode * fp = object->p_freepointer;
    8392             : #if ROSE_ALLOC_MEMSET == 1
    8393             : #elif ROSE_ALLOC_MEMSET == 2
    8394             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgBaseClass) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
    8395             : #elif ROSE_ALLOC_MEMSET == 3
    8396             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgBaseClass) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
    8397             : #endif
    8398        4237 :     object->p_freepointer = fp;
    8399             : 
    8400             : #if ROSE_ALLOC_TRACE == 2
    8401             : //    printf("SgBaseClass::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgBaseClass::next_node);
    8402             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
    8403             :     Rose::MemPool::snapshot(oss.str());
    8404             :     alloc_trace_cnt++;
    8405             : #endif
    8406             : 
    8407        4237 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
    8408             : 
    8409        4237 :     ALLOC_MUTEX(SgBaseClass, unlock);
    8410             : 
    8411             :     return object;
    8412             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
    8413             : }
    8414             : 
    8415             : 
    8416             : 
    8417             : /*! \brief Delete operator for SgBaseClass.
    8418             : 
    8419             :    This delete operator implements deallocation using memory pools to 
    8420             :    provide most efficent use of the heap within construction of large ASTs.
    8421             : 
    8422             : \internal The new and delete operators use the lower level C malloc/free
    8423             :    function calls for performance and to make sure that mixing of malloc/free
    8424             :    and new/delete by the used can be caught more readily.  This may change
    8425             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
    8426             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
    8427             :    deallocate memory allocated using ROSE_MALLOC.
    8428             : */
    8429         840 : void SgBaseClass::operator delete(void *Pointer, size_t Size)
    8430             : {
    8431             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
    8432             :      * or throwing an exception. */
    8433         840 :     ALLOC_MUTEX(SgBaseClass, lock);
    8434             : 
    8435             : #if USE_CPP_NEW_DELETE_OPERATORS
    8436             :     ROSE_FREE(Pointer);
    8437             : #else
    8438             : #if ROSE_PEDANTIC_ALLOC
    8439             :     ROSE_ASSERT(Size == sizeof(SgBaseClass));
    8440             : #else
    8441         840 :     if (Size != sizeof(SgBaseClass)) {
    8442           0 :       ROSE_FREE(Pointer);
    8443           0 :       ALLOC_MUTEX(SgBaseClass, unlock);
    8444             :       return;
    8445             :     }
    8446             : #endif
    8447             : 
    8448         840 :     SgBaseClass * object = (SgBaseClass*) Pointer;
    8449         840 :     ROSE_ASSERT(object != nullptr);
    8450             : 
    8451             : #if ROSE_ALLOC_TRACE == 2
    8452             : //  printf("SgBaseClass::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgBaseClass::next_node);
    8453             :     printf("SgBaseClass::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgBaseClass::next_node);
    8454             : #endif
    8455             : 
    8456             : #if ROSE_PEDANTIC_ALLOC
    8457             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
    8458             : #endif
    8459             : 
    8460             : #if ROSE_ALLOC_MEMSET == 1
    8461             : #elif ROSE_ALLOC_MEMSET == 2
    8462             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgBaseClass) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
    8463             : #elif ROSE_ALLOC_MEMSET == 3
    8464             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgBaseClass) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
    8465             : #endif
    8466             : 
    8467             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
    8468             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
    8469             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
    8470             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
    8471             : #else
    8472         840 :     object->p_freepointer = SgBaseClass::next_node;
    8473         840 :     SgBaseClass::next_node = object;
    8474             : #endif
    8475             : 
    8476             : #if ROSE_ALLOC_TRACE == 2
    8477             : //  printf("SgBaseClass::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgBaseClass::next_node);
    8478             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
    8479             :     Rose::MemPool::snapshot(oss.str());
    8480             :     alloc_trace_cnt++;
    8481             : #endif
    8482             : 
    8483             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
    8484             : 
    8485         840 :     ALLOC_MUTEX(SgBaseClass, unlock);
    8486             : }
    8487             : 
    8488             : // DQ (11/27/2009): I have moved this member function definition to outside of the
    8489             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
    8490             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
    8491             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
    8492             : // Also, note comment below from Robb (copied from the Common.code file).
    8493             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
    8494             : //
    8495             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
    8496             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
    8497             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
    8498             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
    8499             : #if 0
    8500             : void SgBaseClass::operator delete(void* pointer) { SgBaseClass::operator delete (pointer, sizeof(SgBaseClass)); };
    8501             : #endif
    8502             : /* #line 8503 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
    8503             : 
    8504             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
    8505             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
    8506             : // obviously imply C++.
    8507             : 
    8508             : // This implements the support within ROSE for memory pools.  Memory pools
    8509             : // support the most condensed usage of memory within the construction of
    8510             : // and AST. Large blocks of contiguous storage for each RI node is allocated
    8511             : // by a new operator written for each class.
    8512             : 
    8513             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
    8514             :     // User wants multi-thread support and POSIX threads are available.
    8515             : #   include <pthread.h>
    8516             :     static pthread_mutex_t SgExpBaseClass_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
    8517             : #else
    8518             :      // Cause synchronization to be skipped.
    8519             : #    ifndef ALLOC_MUTEX
    8520             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
    8521             : #    endif
    8522             : #    ifdef _REENTRANT
    8523             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
    8524             : #       ifdef _MSC_VER
    8525             : #           pragma message("POSIX threads are not available; synchronization being skipped")
    8526             : #       else
    8527             : #           warning "POSIX threads are not available; synchronization being skipped"
    8528             : #       endif
    8529             : #    endif
    8530             : #endif
    8531             : 
    8532             : #ifndef ROSE_ALLOC_TRACE
    8533             : #  define ROSE_ALLOC_TRACE 0
    8534             : #endif
    8535             : 
    8536             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
    8537             : #define ROSE_ALLOC_TRACE_CNT
    8538             : #include "memory-pool-snapshot.h"
    8539             : unsigned long alloc_trace_cnt = 0;
    8540             : #endif
    8541             : 
    8542             : #if ROSE_ALLOC_TRACE
    8543             : const unsigned SgExpBaseClass::pool_size = 5;
    8544             : #else
    8545             : const unsigned SgExpBaseClass::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
    8546             : #endif
    8547             : 
    8548             : #ifndef ROSE_ALLOC_MEMSET
    8549             : #  define ROSE_ALLOC_MEMSET 0
    8550             : #endif
    8551             : 
    8552             : #ifndef ROSE_PEDANTIC_ALLOC
    8553             : #  define ROSE_PEDANTIC_ALLOC 0
    8554             : #endif
    8555             : 
    8556             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
    8557             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
    8558             : #endif
    8559             : 
    8560             : #if !defined(SGNODE__ALL_POOLS)
    8561             : #define SGNODE__ALL_POOLS
    8562             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
    8563             : #endif
    8564             : 
    8565             : SgExpBaseClass* SgExpBaseClass::next_node = nullptr;
    8566             : std::vector<unsigned char*> SgExpBaseClass::pools;
    8567             : 
    8568             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
    8569             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
    8570             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
    8571             : // around this macro definition rather than each use).
    8572             : #ifndef ALLOC_MUTEX
    8573             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
    8574             :         do {                                                                     \
    8575             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
    8576             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
    8577             :                 abort();                                                         \
    8578             :             }                                                                    \
    8579             :         } while (0);
    8580             : #endif
    8581             : 
    8582             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
    8583             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
    8584             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
    8585             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
    8586             : 
    8587             : /*! \brief New operator for SgExpBaseClass.
    8588             : 
    8589             :    This new operator implements memory pools to provide most efficent 
    8590             :    use of the heap within construction of large ASTs.
    8591             : 
    8592             : \internal The new and delete operators use the lower level C malloc/free
    8593             :    function calls for performance and to make sure that mixing of malloc/free
    8594             :    and new/delete by the used can be caught more readily.  This may change
    8595             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
    8596             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
    8597             :    deallocate memory allocated using ROSE_MALLOC.
    8598             : */
    8599           0 : void *SgExpBaseClass::operator new ( size_t Size )
    8600             : {
    8601             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
    8602             :      * returning or throwing an exception. */
    8603           0 :     ALLOC_MUTEX(SgExpBaseClass, lock);
    8604             : 
    8605             : #if ROSE_ALLOC_TRACE == 2
    8606             : //    printf("SgExpBaseClass::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgExpBaseClass::next_node);
    8607             : #endif
    8608             : 
    8609             : #if USE_CPP_NEW_DELETE_OPERATORS
    8610             :     void *mem = ROSE_MALLOC(Size);
    8611             :     ALLOC_MUTEX(SgExpBaseClass, unlock);
    8612             :     return mem;
    8613             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
    8614             : #if ROSE_PEDANTIC_ALLOC
    8615             :     ROSE_ASSERT(Size == sizeof(SgExpBaseClass));
    8616             : #else
    8617           0 :     if (Size != sizeof(SgExpBaseClass)) {
    8618           0 :       void * object = ROSE_MALLOC(Size);
    8619           0 :       ALLOC_MUTEX(SgExpBaseClass, unlock);
    8620             :       return object;
    8621             :     }
    8622             : #endif
    8623             : 
    8624           0 :     if (SgExpBaseClass::next_node == nullptr) {
    8625           0 :         SgExpBaseClass * alloc = (SgExpBaseClass*) ROSE_MALLOC ( SgExpBaseClass::pool_size * sizeof(SgExpBaseClass) );
    8626           0 :         ROSE_ASSERT(alloc != nullptr);
    8627             : 
    8628             : #if ROSE_ALLOC_TRACE == 2
    8629             : //        printf("SgExpBaseClass::alloc\n  block[%zi] = [ %p , %p [\n", SgExpBaseClass::pools.size(), alloc, alloc + SgExpBaseClass::pool_size);
    8630             : #endif
    8631             : 
    8632             : #if ROSE_ALLOC_MEMSET == 1
    8633             : #elif ROSE_ALLOC_MEMSET == 2
    8634             :         memset(alloc, 0x00, SgExpBaseClass::pool_size * sizeof(SgExpBaseClass));
    8635             : #elif ROSE_ALLOC_MEMSET == 3
    8636             :         memset(alloc, 0xAA, SgExpBaseClass::pool_size * sizeof(SgExpBaseClass));
    8637             : #endif
    8638           0 :         for (unsigned i=0; i < SgExpBaseClass::pool_size-1; i++) {
    8639           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
    8640             :         }
    8641           0 :         alloc[SgExpBaseClass::pool_size-1].p_freepointer = nullptr;
    8642             : 
    8643           0 :         SgExpBaseClass::pools.push_back ( (unsigned char *) alloc );
    8644           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgExpBaseClass::pool_size * sizeof(SgExpBaseClass), V_SgExpBaseClass ) );
    8645           0 :         SgExpBaseClass::next_node = alloc;
    8646             :     }
    8647           0 :     ROSE_ASSERT(SgExpBaseClass::next_node != nullptr);
    8648             : 
    8649           0 :     SgExpBaseClass * object = SgExpBaseClass::next_node;
    8650           0 :     SgExpBaseClass::next_node = (SgExpBaseClass*)(object->p_freepointer);
    8651             : 
    8652             : #if ROSE_ALLOC_TRACE == 2
    8653             :     printf("SgExpBaseClass::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgExpBaseClass::next_node);
    8654             : #endif
    8655             : 
    8656           0 :     SgNode * fp = object->p_freepointer;
    8657             : #if ROSE_ALLOC_MEMSET == 1
    8658             : #elif ROSE_ALLOC_MEMSET == 2
    8659             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgExpBaseClass) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
    8660             : #elif ROSE_ALLOC_MEMSET == 3
    8661             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgExpBaseClass) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
    8662             : #endif
    8663           0 :     object->p_freepointer = fp;
    8664             : 
    8665             : #if ROSE_ALLOC_TRACE == 2
    8666             : //    printf("SgExpBaseClass::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgExpBaseClass::next_node);
    8667             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
    8668             :     Rose::MemPool::snapshot(oss.str());
    8669             :     alloc_trace_cnt++;
    8670             : #endif
    8671             : 
    8672           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
    8673             : 
    8674           0 :     ALLOC_MUTEX(SgExpBaseClass, unlock);
    8675             : 
    8676             :     return object;
    8677             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
    8678             : }
    8679             : 
    8680             : 
    8681             : 
    8682             : /*! \brief Delete operator for SgExpBaseClass.
    8683             : 
    8684             :    This delete operator implements deallocation using memory pools to 
    8685             :    provide most efficent use of the heap within construction of large ASTs.
    8686             : 
    8687             : \internal The new and delete operators use the lower level C malloc/free
    8688             :    function calls for performance and to make sure that mixing of malloc/free
    8689             :    and new/delete by the used can be caught more readily.  This may change
    8690             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
    8691             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
    8692             :    deallocate memory allocated using ROSE_MALLOC.
    8693             : */
    8694           0 : void SgExpBaseClass::operator delete(void *Pointer, size_t Size)
    8695             : {
    8696             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
    8697             :      * or throwing an exception. */
    8698           0 :     ALLOC_MUTEX(SgExpBaseClass, lock);
    8699             : 
    8700             : #if USE_CPP_NEW_DELETE_OPERATORS
    8701             :     ROSE_FREE(Pointer);
    8702             : #else
    8703             : #if ROSE_PEDANTIC_ALLOC
    8704             :     ROSE_ASSERT(Size == sizeof(SgExpBaseClass));
    8705             : #else
    8706           0 :     if (Size != sizeof(SgExpBaseClass)) {
    8707           0 :       ROSE_FREE(Pointer);
    8708           0 :       ALLOC_MUTEX(SgExpBaseClass, unlock);
    8709             :       return;
    8710             :     }
    8711             : #endif
    8712             : 
    8713           0 :     SgExpBaseClass * object = (SgExpBaseClass*) Pointer;
    8714           0 :     ROSE_ASSERT(object != nullptr);
    8715             : 
    8716             : #if ROSE_ALLOC_TRACE == 2
    8717             : //  printf("SgExpBaseClass::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgExpBaseClass::next_node);
    8718             :     printf("SgExpBaseClass::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgExpBaseClass::next_node);
    8719             : #endif
    8720             : 
    8721             : #if ROSE_PEDANTIC_ALLOC
    8722             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
    8723             : #endif
    8724             : 
    8725             : #if ROSE_ALLOC_MEMSET == 1
    8726             : #elif ROSE_ALLOC_MEMSET == 2
    8727             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgExpBaseClass) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
    8728             : #elif ROSE_ALLOC_MEMSET == 3
    8729             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgExpBaseClass) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
    8730             : #endif
    8731             : 
    8732             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
    8733             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
    8734             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
    8735             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
    8736             : #else
    8737           0 :     object->p_freepointer = SgExpBaseClass::next_node;
    8738           0 :     SgExpBaseClass::next_node = object;
    8739             : #endif
    8740             : 
    8741             : #if ROSE_ALLOC_TRACE == 2
    8742             : //  printf("SgExpBaseClass::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgExpBaseClass::next_node);
    8743             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
    8744             :     Rose::MemPool::snapshot(oss.str());
    8745             :     alloc_trace_cnt++;
    8746             : #endif
    8747             : 
    8748             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
    8749             : 
    8750           0 :     ALLOC_MUTEX(SgExpBaseClass, unlock);
    8751             : }
    8752             : 
    8753             : // DQ (11/27/2009): I have moved this member function definition to outside of the
    8754             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
    8755             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
    8756             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
    8757             : // Also, note comment below from Robb (copied from the Common.code file).
    8758             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
    8759             : //
    8760             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
    8761             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
    8762             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
    8763             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
    8764             : #if 0
    8765             : void SgExpBaseClass::operator delete(void* pointer) { SgExpBaseClass::operator delete (pointer, sizeof(SgExpBaseClass)); };
    8766             : #endif
    8767             : /* #line 8768 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
    8768             : 
    8769             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
    8770             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
    8771             : // obviously imply C++.
    8772             : 
    8773             : // This implements the support within ROSE for memory pools.  Memory pools
    8774             : // support the most condensed usage of memory within the construction of
    8775             : // and AST. Large blocks of contiguous storage for each RI node is allocated
    8776             : // by a new operator written for each class.
    8777             : 
    8778             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
    8779             :     // User wants multi-thread support and POSIX threads are available.
    8780             : #   include <pthread.h>
    8781             :     static pthread_mutex_t SgNonrealBaseClass_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
    8782             : #else
    8783             :      // Cause synchronization to be skipped.
    8784             : #    ifndef ALLOC_MUTEX
    8785             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
    8786             : #    endif
    8787             : #    ifdef _REENTRANT
    8788             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
    8789             : #       ifdef _MSC_VER
    8790             : #           pragma message("POSIX threads are not available; synchronization being skipped")
    8791             : #       else
    8792             : #           warning "POSIX threads are not available; synchronization being skipped"
    8793             : #       endif
    8794             : #    endif
    8795             : #endif
    8796             : 
    8797             : #ifndef ROSE_ALLOC_TRACE
    8798             : #  define ROSE_ALLOC_TRACE 0
    8799             : #endif
    8800             : 
    8801             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
    8802             : #define ROSE_ALLOC_TRACE_CNT
    8803             : #include "memory-pool-snapshot.h"
    8804             : unsigned long alloc_trace_cnt = 0;
    8805             : #endif
    8806             : 
    8807             : #if ROSE_ALLOC_TRACE
    8808             : const unsigned SgNonrealBaseClass::pool_size = 5;
    8809             : #else
    8810             : const unsigned SgNonrealBaseClass::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
    8811             : #endif
    8812             : 
    8813             : #ifndef ROSE_ALLOC_MEMSET
    8814             : #  define ROSE_ALLOC_MEMSET 0
    8815             : #endif
    8816             : 
    8817             : #ifndef ROSE_PEDANTIC_ALLOC
    8818             : #  define ROSE_PEDANTIC_ALLOC 0
    8819             : #endif
    8820             : 
    8821             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
    8822             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
    8823             : #endif
    8824             : 
    8825             : #if !defined(SGNODE__ALL_POOLS)
    8826             : #define SGNODE__ALL_POOLS
    8827             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
    8828             : #endif
    8829             : 
    8830             : SgNonrealBaseClass* SgNonrealBaseClass::next_node = nullptr;
    8831             : std::vector<unsigned char*> SgNonrealBaseClass::pools;
    8832             : 
    8833             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
    8834             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
    8835             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
    8836             : // around this macro definition rather than each use).
    8837             : #ifndef ALLOC_MUTEX
    8838             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
    8839             :         do {                                                                     \
    8840             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
    8841             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
    8842             :                 abort();                                                         \
    8843             :             }                                                                    \
    8844             :         } while (0);
    8845             : #endif
    8846             : 
    8847             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
    8848             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
    8849             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
    8850             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
    8851             : 
    8852             : /*! \brief New operator for SgNonrealBaseClass.
    8853             : 
    8854             :    This new operator implements memory pools to provide most efficent 
    8855             :    use of the heap within construction of large ASTs.
    8856             : 
    8857             : \internal The new and delete operators use the lower level C malloc/free
    8858             :    function calls for performance and to make sure that mixing of malloc/free
    8859             :    and new/delete by the used can be caught more readily.  This may change
    8860             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
    8861             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
    8862             :    deallocate memory allocated using ROSE_MALLOC.
    8863             : */
    8864        2108 : void *SgNonrealBaseClass::operator new ( size_t Size )
    8865             : {
    8866             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
    8867             :      * returning or throwing an exception. */
    8868        2108 :     ALLOC_MUTEX(SgNonrealBaseClass, lock);
    8869             : 
    8870             : #if ROSE_ALLOC_TRACE == 2
    8871             : //    printf("SgNonrealBaseClass::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgNonrealBaseClass::next_node);
    8872             : #endif
    8873             : 
    8874             : #if USE_CPP_NEW_DELETE_OPERATORS
    8875             :     void *mem = ROSE_MALLOC(Size);
    8876             :     ALLOC_MUTEX(SgNonrealBaseClass, unlock);
    8877             :     return mem;
    8878             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
    8879             : #if ROSE_PEDANTIC_ALLOC
    8880             :     ROSE_ASSERT(Size == sizeof(SgNonrealBaseClass));
    8881             : #else
    8882        2108 :     if (Size != sizeof(SgNonrealBaseClass)) {
    8883           0 :       void * object = ROSE_MALLOC(Size);
    8884           0 :       ALLOC_MUTEX(SgNonrealBaseClass, unlock);
    8885             :       return object;
    8886             :     }
    8887             : #endif
    8888             : 
    8889        2108 :     if (SgNonrealBaseClass::next_node == nullptr) {
    8890          10 :         SgNonrealBaseClass * alloc = (SgNonrealBaseClass*) ROSE_MALLOC ( SgNonrealBaseClass::pool_size * sizeof(SgNonrealBaseClass) );
    8891          10 :         ROSE_ASSERT(alloc != nullptr);
    8892             : 
    8893             : #if ROSE_ALLOC_TRACE == 2
    8894             : //        printf("SgNonrealBaseClass::alloc\n  block[%zi] = [ %p , %p [\n", SgNonrealBaseClass::pools.size(), alloc, alloc + SgNonrealBaseClass::pool_size);
    8895             : #endif
    8896             : 
    8897             : #if ROSE_ALLOC_MEMSET == 1
    8898             : #elif ROSE_ALLOC_MEMSET == 2
    8899             :         memset(alloc, 0x00, SgNonrealBaseClass::pool_size * sizeof(SgNonrealBaseClass));
    8900             : #elif ROSE_ALLOC_MEMSET == 3
    8901             :         memset(alloc, 0xAA, SgNonrealBaseClass::pool_size * sizeof(SgNonrealBaseClass));
    8902             : #endif
    8903       20000 :         for (unsigned i=0; i < SgNonrealBaseClass::pool_size-1; i++) {
    8904       19990 :           alloc[i].p_freepointer = &(alloc[i+1]);
    8905             :         }
    8906          10 :         alloc[SgNonrealBaseClass::pool_size-1].p_freepointer = nullptr;
    8907             : 
    8908          10 :         SgNonrealBaseClass::pools.push_back ( (unsigned char *) alloc );
    8909          10 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgNonrealBaseClass::pool_size * sizeof(SgNonrealBaseClass), V_SgNonrealBaseClass ) );
    8910          10 :         SgNonrealBaseClass::next_node = alloc;
    8911             :     }
    8912        2108 :     ROSE_ASSERT(SgNonrealBaseClass::next_node != nullptr);
    8913             : 
    8914        2108 :     SgNonrealBaseClass * object = SgNonrealBaseClass::next_node;
    8915        2108 :     SgNonrealBaseClass::next_node = (SgNonrealBaseClass*)(object->p_freepointer);
    8916             : 
    8917             : #if ROSE_ALLOC_TRACE == 2
    8918             :     printf("SgNonrealBaseClass::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgNonrealBaseClass::next_node);
    8919             : #endif
    8920             : 
    8921        2108 :     SgNode * fp = object->p_freepointer;
    8922             : #if ROSE_ALLOC_MEMSET == 1
    8923             : #elif ROSE_ALLOC_MEMSET == 2
    8924             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgNonrealBaseClass) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
    8925             : #elif ROSE_ALLOC_MEMSET == 3
    8926             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgNonrealBaseClass) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
    8927             : #endif
    8928        2108 :     object->p_freepointer = fp;
    8929             : 
    8930             : #if ROSE_ALLOC_TRACE == 2
    8931             : //    printf("SgNonrealBaseClass::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgNonrealBaseClass::next_node);
    8932             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
    8933             :     Rose::MemPool::snapshot(oss.str());
    8934             :     alloc_trace_cnt++;
    8935             : #endif
    8936             : 
    8937        2108 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
    8938             : 
    8939        2108 :     ALLOC_MUTEX(SgNonrealBaseClass, unlock);
    8940             : 
    8941             :     return object;
    8942             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
    8943             : }
    8944             : 
    8945             : 
    8946             : 
    8947             : /*! \brief Delete operator for SgNonrealBaseClass.
    8948             : 
    8949             :    This delete operator implements deallocation using memory pools to 
    8950             :    provide most efficent use of the heap within construction of large ASTs.
    8951             : 
    8952             : \internal The new and delete operators use the lower level C malloc/free
    8953             :    function calls for performance and to make sure that mixing of malloc/free
    8954             :    and new/delete by the used can be caught more readily.  This may change
    8955             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
    8956             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
    8957             :    deallocate memory allocated using ROSE_MALLOC.
    8958             : */
    8959         400 : void SgNonrealBaseClass::operator delete(void *Pointer, size_t Size)
    8960             : {
    8961             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
    8962             :      * or throwing an exception. */
    8963         400 :     ALLOC_MUTEX(SgNonrealBaseClass, lock);
    8964             : 
    8965             : #if USE_CPP_NEW_DELETE_OPERATORS
    8966             :     ROSE_FREE(Pointer);
    8967             : #else
    8968             : #if ROSE_PEDANTIC_ALLOC
    8969             :     ROSE_ASSERT(Size == sizeof(SgNonrealBaseClass));
    8970             : #else
    8971         400 :     if (Size != sizeof(SgNonrealBaseClass)) {
    8972           0 :       ROSE_FREE(Pointer);
    8973           0 :       ALLOC_MUTEX(SgNonrealBaseClass, unlock);
    8974             :       return;
    8975             :     }
    8976             : #endif
    8977             : 
    8978         400 :     SgNonrealBaseClass * object = (SgNonrealBaseClass*) Pointer;
    8979         400 :     ROSE_ASSERT(object != nullptr);
    8980             : 
    8981             : #if ROSE_ALLOC_TRACE == 2
    8982             : //  printf("SgNonrealBaseClass::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgNonrealBaseClass::next_node);
    8983             :     printf("SgNonrealBaseClass::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgNonrealBaseClass::next_node);
    8984             : #endif
    8985             : 
    8986             : #if ROSE_PEDANTIC_ALLOC
    8987             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
    8988             : #endif
    8989             : 
    8990             : #if ROSE_ALLOC_MEMSET == 1
    8991             : #elif ROSE_ALLOC_MEMSET == 2
    8992             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgNonrealBaseClass) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
    8993             : #elif ROSE_ALLOC_MEMSET == 3
    8994             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgNonrealBaseClass) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
    8995             : #endif
    8996             : 
    8997             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
    8998             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
    8999             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
    9000             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
    9001             : #else
    9002         400 :     object->p_freepointer = SgNonrealBaseClass::next_node;
    9003         400 :     SgNonrealBaseClass::next_node = object;
    9004             : #endif
    9005             : 
    9006             : #if ROSE_ALLOC_TRACE == 2
    9007             : //  printf("SgNonrealBaseClass::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgNonrealBaseClass::next_node);
    9008             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
    9009             :     Rose::MemPool::snapshot(oss.str());
    9010             :     alloc_trace_cnt++;
    9011             : #endif
    9012             : 
    9013             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
    9014             : 
    9015         400 :     ALLOC_MUTEX(SgNonrealBaseClass, unlock);
    9016             : }
    9017             : 
    9018             : // DQ (11/27/2009): I have moved this member function definition to outside of the
    9019             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
    9020             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
    9021             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
    9022             : // Also, note comment below from Robb (copied from the Common.code file).
    9023             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
    9024             : //
    9025             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
    9026             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
    9027             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
    9028             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
    9029             : #if 0
    9030             : void SgNonrealBaseClass::operator delete(void* pointer) { SgNonrealBaseClass::operator delete (pointer, sizeof(SgNonrealBaseClass)); };
    9031             : #endif
    9032             : /* #line 9033 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
    9033             : 
    9034             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
    9035             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
    9036             : // obviously imply C++.
    9037             : 
    9038             : // This implements the support within ROSE for memory pools.  Memory pools
    9039             : // support the most condensed usage of memory within the construction of
    9040             : // and AST. Large blocks of contiguous storage for each RI node is allocated
    9041             : // by a new operator written for each class.
    9042             : 
    9043             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
    9044             :     // User wants multi-thread support and POSIX threads are available.
    9045             : #   include <pthread.h>
    9046             :     static pthread_mutex_t SgTypedefSeq_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
    9047             : #else
    9048             :      // Cause synchronization to be skipped.
    9049             : #    ifndef ALLOC_MUTEX
    9050             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
    9051             : #    endif
    9052             : #    ifdef _REENTRANT
    9053             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
    9054             : #       ifdef _MSC_VER
    9055             : #           pragma message("POSIX threads are not available; synchronization being skipped")
    9056             : #       else
    9057             : #           warning "POSIX threads are not available; synchronization being skipped"
    9058             : #       endif
    9059             : #    endif
    9060             : #endif
    9061             : 
    9062             : #ifndef ROSE_ALLOC_TRACE
    9063             : #  define ROSE_ALLOC_TRACE 0
    9064             : #endif
    9065             : 
    9066             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
    9067             : #define ROSE_ALLOC_TRACE_CNT
    9068             : #include "memory-pool-snapshot.h"
    9069             : unsigned long alloc_trace_cnt = 0;
    9070             : #endif
    9071             : 
    9072             : #if ROSE_ALLOC_TRACE
    9073             : const unsigned SgTypedefSeq::pool_size = 5;
    9074             : #else
    9075             : const unsigned SgTypedefSeq::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
    9076             : #endif
    9077             : 
    9078             : #ifndef ROSE_ALLOC_MEMSET
    9079             : #  define ROSE_ALLOC_MEMSET 0
    9080             : #endif
    9081             : 
    9082             : #ifndef ROSE_PEDANTIC_ALLOC
    9083             : #  define ROSE_PEDANTIC_ALLOC 0
    9084             : #endif
    9085             : 
    9086             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
    9087             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
    9088             : #endif
    9089             : 
    9090             : #if !defined(SGNODE__ALL_POOLS)
    9091             : #define SGNODE__ALL_POOLS
    9092             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
    9093             : #endif
    9094             : 
    9095             : SgTypedefSeq* SgTypedefSeq::next_node = nullptr;
    9096             : std::vector<unsigned char*> SgTypedefSeq::pools;
    9097             : 
    9098             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
    9099             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
    9100             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
    9101             : // around this macro definition rather than each use).
    9102             : #ifndef ALLOC_MUTEX
    9103             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
    9104             :         do {                                                                     \
    9105             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
    9106             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
    9107             :                 abort();                                                         \
    9108             :             }                                                                    \
    9109             :         } while (0);
    9110             : #endif
    9111             : 
    9112             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
    9113             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
    9114             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
    9115             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
    9116             : 
    9117             : /*! \brief New operator for SgTypedefSeq.
    9118             : 
    9119             :    This new operator implements memory pools to provide most efficent 
    9120             :    use of the heap within construction of large ASTs.
    9121             : 
    9122             : \internal The new and delete operators use the lower level C malloc/free
    9123             :    function calls for performance and to make sure that mixing of malloc/free
    9124             :    and new/delete by the used can be caught more readily.  This may change
    9125             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
    9126             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
    9127             :    deallocate memory allocated using ROSE_MALLOC.
    9128             : */
    9129      626126 : void *SgTypedefSeq::operator new ( size_t Size )
    9130             : {
    9131             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
    9132             :      * returning or throwing an exception. */
    9133      626126 :     ALLOC_MUTEX(SgTypedefSeq, lock);
    9134             : 
    9135             : #if ROSE_ALLOC_TRACE == 2
    9136             : //    printf("SgTypedefSeq::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgTypedefSeq::next_node);
    9137             : #endif
    9138             : 
    9139             : #if USE_CPP_NEW_DELETE_OPERATORS
    9140             :     void *mem = ROSE_MALLOC(Size);
    9141             :     ALLOC_MUTEX(SgTypedefSeq, unlock);
    9142             :     return mem;
    9143             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
    9144             : #if ROSE_PEDANTIC_ALLOC
    9145             :     ROSE_ASSERT(Size == sizeof(SgTypedefSeq));
    9146             : #else
    9147      626126 :     if (Size != sizeof(SgTypedefSeq)) {
    9148           0 :       void * object = ROSE_MALLOC(Size);
    9149           0 :       ALLOC_MUTEX(SgTypedefSeq, unlock);
    9150             :       return object;
    9151             :     }
    9152             : #endif
    9153             : 
    9154      626126 :     if (SgTypedefSeq::next_node == nullptr) {
    9155         417 :         SgTypedefSeq * alloc = (SgTypedefSeq*) ROSE_MALLOC ( SgTypedefSeq::pool_size * sizeof(SgTypedefSeq) );
    9156         417 :         ROSE_ASSERT(alloc != nullptr);
    9157             : 
    9158             : #if ROSE_ALLOC_TRACE == 2
    9159             : //        printf("SgTypedefSeq::alloc\n  block[%zi] = [ %p , %p [\n", SgTypedefSeq::pools.size(), alloc, alloc + SgTypedefSeq::pool_size);
    9160             : #endif
    9161             : 
    9162             : #if ROSE_ALLOC_MEMSET == 1
    9163             : #elif ROSE_ALLOC_MEMSET == 2
    9164             :         memset(alloc, 0x00, SgTypedefSeq::pool_size * sizeof(SgTypedefSeq));
    9165             : #elif ROSE_ALLOC_MEMSET == 3
    9166             :         memset(alloc, 0xAA, SgTypedefSeq::pool_size * sizeof(SgTypedefSeq));
    9167             : #endif
    9168      834000 :         for (unsigned i=0; i < SgTypedefSeq::pool_size-1; i++) {
    9169      833583 :           alloc[i].p_freepointer = &(alloc[i+1]);
    9170             :         }
    9171         417 :         alloc[SgTypedefSeq::pool_size-1].p_freepointer = nullptr;
    9172             : 
    9173         417 :         SgTypedefSeq::pools.push_back ( (unsigned char *) alloc );
    9174         417 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgTypedefSeq::pool_size * sizeof(SgTypedefSeq), V_SgTypedefSeq ) );
    9175         417 :         SgTypedefSeq::next_node = alloc;
    9176             :     }
    9177      626126 :     ROSE_ASSERT(SgTypedefSeq::next_node != nullptr);
    9178             : 
    9179      626126 :     SgTypedefSeq * object = SgTypedefSeq::next_node;
    9180      626126 :     SgTypedefSeq::next_node = (SgTypedefSeq*)(object->p_freepointer);
    9181             : 
    9182             : #if ROSE_ALLOC_TRACE == 2
    9183             :     printf("SgTypedefSeq::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypedefSeq::next_node);
    9184             : #endif
    9185             : 
    9186      626126 :     SgNode * fp = object->p_freepointer;
    9187             : #if ROSE_ALLOC_MEMSET == 1
    9188             : #elif ROSE_ALLOC_MEMSET == 2
    9189             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgTypedefSeq) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
    9190             : #elif ROSE_ALLOC_MEMSET == 3
    9191             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgTypedefSeq) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
    9192             : #endif
    9193      626126 :     object->p_freepointer = fp;
    9194             : 
    9195             : #if ROSE_ALLOC_TRACE == 2
    9196             : //    printf("SgTypedefSeq::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypedefSeq::next_node);
    9197             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
    9198             :     Rose::MemPool::snapshot(oss.str());
    9199             :     alloc_trace_cnt++;
    9200             : #endif
    9201             : 
    9202      626126 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
    9203             : 
    9204      626126 :     ALLOC_MUTEX(SgTypedefSeq, unlock);
    9205             : 
    9206             :     return object;
    9207             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
    9208             : }
    9209             : 
    9210             : 
    9211             : 
    9212             : /*! \brief Delete operator for SgTypedefSeq.
    9213             : 
    9214             :    This delete operator implements deallocation using memory pools to 
    9215             :    provide most efficent use of the heap within construction of large ASTs.
    9216             : 
    9217             : \internal The new and delete operators use the lower level C malloc/free
    9218             :    function calls for performance and to make sure that mixing of malloc/free
    9219             :    and new/delete by the used can be caught more readily.  This may change
    9220             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
    9221             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
    9222             :    deallocate memory allocated using ROSE_MALLOC.
    9223             : */
    9224      197209 : void SgTypedefSeq::operator delete(void *Pointer, size_t Size)
    9225             : {
    9226             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
    9227             :      * or throwing an exception. */
    9228      197209 :     ALLOC_MUTEX(SgTypedefSeq, lock);
    9229             : 
    9230             : #if USE_CPP_NEW_DELETE_OPERATORS
    9231             :     ROSE_FREE(Pointer);
    9232             : #else
    9233             : #if ROSE_PEDANTIC_ALLOC
    9234             :     ROSE_ASSERT(Size == sizeof(SgTypedefSeq));
    9235             : #else
    9236      197209 :     if (Size != sizeof(SgTypedefSeq)) {
    9237           0 :       ROSE_FREE(Pointer);
    9238           0 :       ALLOC_MUTEX(SgTypedefSeq, unlock);
    9239             :       return;
    9240             :     }
    9241             : #endif
    9242             : 
    9243      197209 :     SgTypedefSeq * object = (SgTypedefSeq*) Pointer;
    9244      197209 :     ROSE_ASSERT(object != nullptr);
    9245             : 
    9246             : #if ROSE_ALLOC_TRACE == 2
    9247             : //  printf("SgTypedefSeq::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypedefSeq::next_node);
    9248             :     printf("SgTypedefSeq::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypedefSeq::next_node);
    9249             : #endif
    9250             : 
    9251             : #if ROSE_PEDANTIC_ALLOC
    9252             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
    9253             : #endif
    9254             : 
    9255             : #if ROSE_ALLOC_MEMSET == 1
    9256             : #elif ROSE_ALLOC_MEMSET == 2
    9257             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgTypedefSeq) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
    9258             : #elif ROSE_ALLOC_MEMSET == 3
    9259             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgTypedefSeq) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
    9260             : #endif
    9261             : 
    9262             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
    9263             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
    9264             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
    9265             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
    9266             : #else
    9267      197209 :     object->p_freepointer = SgTypedefSeq::next_node;
    9268      197209 :     SgTypedefSeq::next_node = object;
    9269             : #endif
    9270             : 
    9271             : #if ROSE_ALLOC_TRACE == 2
    9272             : //  printf("SgTypedefSeq::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypedefSeq::next_node);
    9273             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
    9274             :     Rose::MemPool::snapshot(oss.str());
    9275             :     alloc_trace_cnt++;
    9276             : #endif
    9277             : 
    9278             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
    9279             : 
    9280      197209 :     ALLOC_MUTEX(SgTypedefSeq, unlock);
    9281             : }
    9282             : 
    9283             : // DQ (11/27/2009): I have moved this member function definition to outside of the
    9284             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
    9285             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
    9286             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
    9287             : // Also, note comment below from Robb (copied from the Common.code file).
    9288             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
    9289             : //
    9290             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
    9291             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
    9292             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
    9293             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
    9294             : #if 0
    9295             : void SgTypedefSeq::operator delete(void* pointer) { SgTypedefSeq::operator delete (pointer, sizeof(SgTypedefSeq)); };
    9296             : #endif
    9297             : /* #line 9298 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
    9298             : 
    9299             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
    9300             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
    9301             : // obviously imply C++.
    9302             : 
    9303             : // This implements the support within ROSE for memory pools.  Memory pools
    9304             : // support the most condensed usage of memory within the construction of
    9305             : // and AST. Large blocks of contiguous storage for each RI node is allocated
    9306             : // by a new operator written for each class.
    9307             : 
    9308             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
    9309             :     // User wants multi-thread support and POSIX threads are available.
    9310             : #   include <pthread.h>
    9311             :     static pthread_mutex_t SgTemplateParameter_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
    9312             : #else
    9313             :      // Cause synchronization to be skipped.
    9314             : #    ifndef ALLOC_MUTEX
    9315             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
    9316             : #    endif
    9317             : #    ifdef _REENTRANT
    9318             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
    9319             : #       ifdef _MSC_VER
    9320             : #           pragma message("POSIX threads are not available; synchronization being skipped")
    9321             : #       else
    9322             : #           warning "POSIX threads are not available; synchronization being skipped"
    9323             : #       endif
    9324             : #    endif
    9325             : #endif
    9326             : 
    9327             : #ifndef ROSE_ALLOC_TRACE
    9328             : #  define ROSE_ALLOC_TRACE 0
    9329             : #endif
    9330             : 
    9331             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
    9332             : #define ROSE_ALLOC_TRACE_CNT
    9333             : #include "memory-pool-snapshot.h"
    9334             : unsigned long alloc_trace_cnt = 0;
    9335             : #endif
    9336             : 
    9337             : #if ROSE_ALLOC_TRACE
    9338             : const unsigned SgTemplateParameter::pool_size = 5;
    9339             : #else
    9340             : const unsigned SgTemplateParameter::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
    9341             : #endif
    9342             : 
    9343             : #ifndef ROSE_ALLOC_MEMSET
    9344             : #  define ROSE_ALLOC_MEMSET 0
    9345             : #endif
    9346             : 
    9347             : #ifndef ROSE_PEDANTIC_ALLOC
    9348             : #  define ROSE_PEDANTIC_ALLOC 0
    9349             : #endif
    9350             : 
    9351             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
    9352             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
    9353             : #endif
    9354             : 
    9355             : #if !defined(SGNODE__ALL_POOLS)
    9356             : #define SGNODE__ALL_POOLS
    9357             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
    9358             : #endif
    9359             : 
    9360             : SgTemplateParameter* SgTemplateParameter::next_node = nullptr;
    9361             : std::vector<unsigned char*> SgTemplateParameter::pools;
    9362             : 
    9363             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
    9364             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
    9365             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
    9366             : // around this macro definition rather than each use).
    9367             : #ifndef ALLOC_MUTEX
    9368             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
    9369             :         do {                                                                     \
    9370             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
    9371             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
    9372             :                 abort();                                                         \
    9373             :             }                                                                    \
    9374             :         } while (0);
    9375             : #endif
    9376             : 
    9377             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
    9378             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
    9379             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
    9380             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
    9381             : 
    9382             : /*! \brief New operator for SgTemplateParameter.
    9383             : 
    9384             :    This new operator implements memory pools to provide most efficent 
    9385             :    use of the heap within construction of large ASTs.
    9386             : 
    9387             : \internal The new and delete operators use the lower level C malloc/free
    9388             :    function calls for performance and to make sure that mixing of malloc/free
    9389             :    and new/delete by the used can be caught more readily.  This may change
    9390             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
    9391             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
    9392             :    deallocate memory allocated using ROSE_MALLOC.
    9393             : */
    9394       23176 : void *SgTemplateParameter::operator new ( size_t Size )
    9395             : {
    9396             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
    9397             :      * returning or throwing an exception. */
    9398       23176 :     ALLOC_MUTEX(SgTemplateParameter, lock);
    9399             : 
    9400             : #if ROSE_ALLOC_TRACE == 2
    9401             : //    printf("SgTemplateParameter::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgTemplateParameter::next_node);
    9402             : #endif
    9403             : 
    9404             : #if USE_CPP_NEW_DELETE_OPERATORS
    9405             :     void *mem = ROSE_MALLOC(Size);
    9406             :     ALLOC_MUTEX(SgTemplateParameter, unlock);
    9407             :     return mem;
    9408             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
    9409             : #if ROSE_PEDANTIC_ALLOC
    9410             :     ROSE_ASSERT(Size == sizeof(SgTemplateParameter));
    9411             : #else
    9412       23176 :     if (Size != sizeof(SgTemplateParameter)) {
    9413           0 :       void * object = ROSE_MALLOC(Size);
    9414           0 :       ALLOC_MUTEX(SgTemplateParameter, unlock);
    9415             :       return object;
    9416             :     }
    9417             : #endif
    9418             : 
    9419       23176 :     if (SgTemplateParameter::next_node == nullptr) {
    9420          19 :         SgTemplateParameter * alloc = (SgTemplateParameter*) ROSE_MALLOC ( SgTemplateParameter::pool_size * sizeof(SgTemplateParameter) );
    9421          19 :         ROSE_ASSERT(alloc != nullptr);
    9422             : 
    9423             : #if ROSE_ALLOC_TRACE == 2
    9424             : //        printf("SgTemplateParameter::alloc\n  block[%zi] = [ %p , %p [\n", SgTemplateParameter::pools.size(), alloc, alloc + SgTemplateParameter::pool_size);
    9425             : #endif
    9426             : 
    9427             : #if ROSE_ALLOC_MEMSET == 1
    9428             : #elif ROSE_ALLOC_MEMSET == 2
    9429             :         memset(alloc, 0x00, SgTemplateParameter::pool_size * sizeof(SgTemplateParameter));
    9430             : #elif ROSE_ALLOC_MEMSET == 3
    9431             :         memset(alloc, 0xAA, SgTemplateParameter::pool_size * sizeof(SgTemplateParameter));
    9432             : #endif
    9433       38000 :         for (unsigned i=0; i < SgTemplateParameter::pool_size-1; i++) {
    9434       37981 :           alloc[i].p_freepointer = &(alloc[i+1]);
    9435             :         }
    9436          19 :         alloc[SgTemplateParameter::pool_size-1].p_freepointer = nullptr;
    9437             : 
    9438          19 :         SgTemplateParameter::pools.push_back ( (unsigned char *) alloc );
    9439          19 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgTemplateParameter::pool_size * sizeof(SgTemplateParameter), V_SgTemplateParameter ) );
    9440          19 :         SgTemplateParameter::next_node = alloc;
    9441             :     }
    9442       23176 :     ROSE_ASSERT(SgTemplateParameter::next_node != nullptr);
    9443             : 
    9444       23176 :     SgTemplateParameter * object = SgTemplateParameter::next_node;
    9445       23176 :     SgTemplateParameter::next_node = (SgTemplateParameter*)(object->p_freepointer);
    9446             : 
    9447             : #if ROSE_ALLOC_TRACE == 2
    9448             :     printf("SgTemplateParameter::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTemplateParameter::next_node);
    9449             : #endif
    9450             : 
    9451       23176 :     SgNode * fp = object->p_freepointer;
    9452             : #if ROSE_ALLOC_MEMSET == 1
    9453             : #elif ROSE_ALLOC_MEMSET == 2
    9454             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgTemplateParameter) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
    9455             : #elif ROSE_ALLOC_MEMSET == 3
    9456             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgTemplateParameter) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
    9457             : #endif
    9458       23176 :     object->p_freepointer = fp;
    9459             : 
    9460             : #if ROSE_ALLOC_TRACE == 2
    9461             : //    printf("SgTemplateParameter::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTemplateParameter::next_node);
    9462             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
    9463             :     Rose::MemPool::snapshot(oss.str());
    9464             :     alloc_trace_cnt++;
    9465             : #endif
    9466             : 
    9467       23176 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
    9468             : 
    9469       23176 :     ALLOC_MUTEX(SgTemplateParameter, unlock);
    9470             : 
    9471             :     return object;
    9472             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
    9473             : }
    9474             : 
    9475             : 
    9476             : 
    9477             : /*! \brief Delete operator for SgTemplateParameter.
    9478             : 
    9479             :    This delete operator implements deallocation using memory pools to 
    9480             :    provide most efficent use of the heap within construction of large ASTs.
    9481             : 
    9482             : \internal The new and delete operators use the lower level C malloc/free
    9483             :    function calls for performance and to make sure that mixing of malloc/free
    9484             :    and new/delete by the used can be caught more readily.  This may change
    9485             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
    9486             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
    9487             :    deallocate memory allocated using ROSE_MALLOC.
    9488             : */
    9489        4334 : void SgTemplateParameter::operator delete(void *Pointer, size_t Size)
    9490             : {
    9491             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
    9492             :      * or throwing an exception. */
    9493        4334 :     ALLOC_MUTEX(SgTemplateParameter, lock);
    9494             : 
    9495             : #if USE_CPP_NEW_DELETE_OPERATORS
    9496             :     ROSE_FREE(Pointer);
    9497             : #else
    9498             : #if ROSE_PEDANTIC_ALLOC
    9499             :     ROSE_ASSERT(Size == sizeof(SgTemplateParameter));
    9500             : #else
    9501        4334 :     if (Size != sizeof(SgTemplateParameter)) {
    9502           0 :       ROSE_FREE(Pointer);
    9503           0 :       ALLOC_MUTEX(SgTemplateParameter, unlock);
    9504             :       return;
    9505             :     }
    9506             : #endif
    9507             : 
    9508        4334 :     SgTemplateParameter * object = (SgTemplateParameter*) Pointer;
    9509        4334 :     ROSE_ASSERT(object != nullptr);
    9510             : 
    9511             : #if ROSE_ALLOC_TRACE == 2
    9512             : //  printf("SgTemplateParameter::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTemplateParameter::next_node);
    9513             :     printf("SgTemplateParameter::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTemplateParameter::next_node);
    9514             : #endif
    9515             : 
    9516             : #if ROSE_PEDANTIC_ALLOC
    9517             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
    9518             : #endif
    9519             : 
    9520             : #if ROSE_ALLOC_MEMSET == 1
    9521             : #elif ROSE_ALLOC_MEMSET == 2
    9522             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgTemplateParameter) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
    9523             : #elif ROSE_ALLOC_MEMSET == 3
    9524             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgTemplateParameter) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
    9525             : #endif
    9526             : 
    9527             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
    9528             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
    9529             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
    9530             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
    9531             : #else
    9532        4334 :     object->p_freepointer = SgTemplateParameter::next_node;
    9533        4334 :     SgTemplateParameter::next_node = object;
    9534             : #endif
    9535             : 
    9536             : #if ROSE_ALLOC_TRACE == 2
    9537             : //  printf("SgTemplateParameter::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTemplateParameter::next_node);
    9538             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
    9539             :     Rose::MemPool::snapshot(oss.str());
    9540             :     alloc_trace_cnt++;
    9541             : #endif
    9542             : 
    9543             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
    9544             : 
    9545        4334 :     ALLOC_MUTEX(SgTemplateParameter, unlock);
    9546             : }
    9547             : 
    9548             : // DQ (11/27/2009): I have moved this member function definition to outside of the
    9549             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
    9550             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
    9551             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
    9552             : // Also, note comment below from Robb (copied from the Common.code file).
    9553             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
    9554             : //
    9555             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
    9556             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
    9557             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
    9558             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
    9559             : #if 0
    9560             : void SgTemplateParameter::operator delete(void* pointer) { SgTemplateParameter::operator delete (pointer, sizeof(SgTemplateParameter)); };
    9561             : #endif
    9562             : /* #line 9563 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
    9563             : 
    9564             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
    9565             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
    9566             : // obviously imply C++.
    9567             : 
    9568             : // This implements the support within ROSE for memory pools.  Memory pools
    9569             : // support the most condensed usage of memory within the construction of
    9570             : // and AST. Large blocks of contiguous storage for each RI node is allocated
    9571             : // by a new operator written for each class.
    9572             : 
    9573             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
    9574             :     // User wants multi-thread support and POSIX threads are available.
    9575             : #   include <pthread.h>
    9576             :     static pthread_mutex_t SgTemplateArgument_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
    9577             : #else
    9578             :      // Cause synchronization to be skipped.
    9579             : #    ifndef ALLOC_MUTEX
    9580             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
    9581             : #    endif
    9582             : #    ifdef _REENTRANT
    9583             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
    9584             : #       ifdef _MSC_VER
    9585             : #           pragma message("POSIX threads are not available; synchronization being skipped")
    9586             : #       else
    9587             : #           warning "POSIX threads are not available; synchronization being skipped"
    9588             : #       endif
    9589             : #    endif
    9590             : #endif
    9591             : 
    9592             : #ifndef ROSE_ALLOC_TRACE
    9593             : #  define ROSE_ALLOC_TRACE 0
    9594             : #endif
    9595             : 
    9596             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
    9597             : #define ROSE_ALLOC_TRACE_CNT
    9598             : #include "memory-pool-snapshot.h"
    9599             : unsigned long alloc_trace_cnt = 0;
    9600             : #endif
    9601             : 
    9602             : #if ROSE_ALLOC_TRACE
    9603             : const unsigned SgTemplateArgument::pool_size = 5;
    9604             : #else
    9605             : const unsigned SgTemplateArgument::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
    9606             : #endif
    9607             : 
    9608             : #ifndef ROSE_ALLOC_MEMSET
    9609             : #  define ROSE_ALLOC_MEMSET 0
    9610             : #endif
    9611             : 
    9612             : #ifndef ROSE_PEDANTIC_ALLOC
    9613             : #  define ROSE_PEDANTIC_ALLOC 0
    9614             : #endif
    9615             : 
    9616             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
    9617             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
    9618             : #endif
    9619             : 
    9620             : #if !defined(SGNODE__ALL_POOLS)
    9621             : #define SGNODE__ALL_POOLS
    9622             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
    9623             : #endif
    9624             : 
    9625             : SgTemplateArgument* SgTemplateArgument::next_node = nullptr;
    9626             : std::vector<unsigned char*> SgTemplateArgument::pools;
    9627             : 
    9628             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
    9629             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
    9630             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
    9631             : // around this macro definition rather than each use).
    9632             : #ifndef ALLOC_MUTEX
    9633             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
    9634             :         do {                                                                     \
    9635             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
    9636             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
    9637             :                 abort();                                                         \
    9638             :             }                                                                    \
    9639             :         } while (0);
    9640             : #endif
    9641             : 
    9642             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
    9643             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
    9644             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
    9645             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
    9646             : 
    9647             : /*! \brief New operator for SgTemplateArgument.
    9648             : 
    9649             :    This new operator implements memory pools to provide most efficent 
    9650             :    use of the heap within construction of large ASTs.
    9651             : 
    9652             : \internal The new and delete operators use the lower level C malloc/free
    9653             :    function calls for performance and to make sure that mixing of malloc/free
    9654             :    and new/delete by the used can be caught more readily.  This may change
    9655             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
    9656             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
    9657             :    deallocate memory allocated using ROSE_MALLOC.
    9658             : */
    9659       69898 : void *SgTemplateArgument::operator new ( size_t Size )
    9660             : {
    9661             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
    9662             :      * returning or throwing an exception. */
    9663       69898 :     ALLOC_MUTEX(SgTemplateArgument, lock);
    9664             : 
    9665             : #if ROSE_ALLOC_TRACE == 2
    9666             : //    printf("SgTemplateArgument::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgTemplateArgument::next_node);
    9667             : #endif
    9668             : 
    9669             : #if USE_CPP_NEW_DELETE_OPERATORS
    9670             :     void *mem = ROSE_MALLOC(Size);
    9671             :     ALLOC_MUTEX(SgTemplateArgument, unlock);
    9672             :     return mem;
    9673             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
    9674             : #if ROSE_PEDANTIC_ALLOC
    9675             :     ROSE_ASSERT(Size == sizeof(SgTemplateArgument));
    9676             : #else
    9677       69898 :     if (Size != sizeof(SgTemplateArgument)) {
    9678           0 :       void * object = ROSE_MALLOC(Size);
    9679           0 :       ALLOC_MUTEX(SgTemplateArgument, unlock);
    9680             :       return object;
    9681             :     }
    9682             : #endif
    9683             : 
    9684       69898 :     if (SgTemplateArgument::next_node == nullptr) {
    9685          38 :         SgTemplateArgument * alloc = (SgTemplateArgument*) ROSE_MALLOC ( SgTemplateArgument::pool_size * sizeof(SgTemplateArgument) );
    9686          38 :         ROSE_ASSERT(alloc != nullptr);
    9687             : 
    9688             : #if ROSE_ALLOC_TRACE == 2
    9689             : //        printf("SgTemplateArgument::alloc\n  block[%zi] = [ %p , %p [\n", SgTemplateArgument::pools.size(), alloc, alloc + SgTemplateArgument::pool_size);
    9690             : #endif
    9691             : 
    9692             : #if ROSE_ALLOC_MEMSET == 1
    9693             : #elif ROSE_ALLOC_MEMSET == 2
    9694             :         memset(alloc, 0x00, SgTemplateArgument::pool_size * sizeof(SgTemplateArgument));
    9695             : #elif ROSE_ALLOC_MEMSET == 3
    9696             :         memset(alloc, 0xAA, SgTemplateArgument::pool_size * sizeof(SgTemplateArgument));
    9697             : #endif
    9698       76000 :         for (unsigned i=0; i < SgTemplateArgument::pool_size-1; i++) {
    9699       75962 :           alloc[i].p_freepointer = &(alloc[i+1]);
    9700             :         }
    9701          38 :         alloc[SgTemplateArgument::pool_size-1].p_freepointer = nullptr;
    9702             : 
    9703          38 :         SgTemplateArgument::pools.push_back ( (unsigned char *) alloc );
    9704          38 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgTemplateArgument::pool_size * sizeof(SgTemplateArgument), V_SgTemplateArgument ) );
    9705          38 :         SgTemplateArgument::next_node = alloc;
    9706             :     }
    9707       69898 :     ROSE_ASSERT(SgTemplateArgument::next_node != nullptr);
    9708             : 
    9709       69898 :     SgTemplateArgument * object = SgTemplateArgument::next_node;
    9710       69898 :     SgTemplateArgument::next_node = (SgTemplateArgument*)(object->p_freepointer);
    9711             : 
    9712             : #if ROSE_ALLOC_TRACE == 2
    9713             :     printf("SgTemplateArgument::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTemplateArgument::next_node);
    9714             : #endif
    9715             : 
    9716       69898 :     SgNode * fp = object->p_freepointer;
    9717             : #if ROSE_ALLOC_MEMSET == 1
    9718             : #elif ROSE_ALLOC_MEMSET == 2
    9719             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgTemplateArgument) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
    9720             : #elif ROSE_ALLOC_MEMSET == 3
    9721             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgTemplateArgument) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
    9722             : #endif
    9723       69898 :     object->p_freepointer = fp;
    9724             : 
    9725             : #if ROSE_ALLOC_TRACE == 2
    9726             : //    printf("SgTemplateArgument::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTemplateArgument::next_node);
    9727             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
    9728             :     Rose::MemPool::snapshot(oss.str());
    9729             :     alloc_trace_cnt++;
    9730             : #endif
    9731             : 
    9732       69898 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
    9733             : 
    9734       69898 :     ALLOC_MUTEX(SgTemplateArgument, unlock);
    9735             : 
    9736             :     return object;
    9737             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
    9738             : }
    9739             : 
    9740             : 
    9741             : 
    9742             : /*! \brief Delete operator for SgTemplateArgument.
    9743             : 
    9744             :    This delete operator implements deallocation using memory pools to 
    9745             :    provide most efficent use of the heap within construction of large ASTs.
    9746             : 
    9747             : \internal The new and delete operators use the lower level C malloc/free
    9748             :    function calls for performance and to make sure that mixing of malloc/free
    9749             :    and new/delete by the used can be caught more readily.  This may change
    9750             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
    9751             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
    9752             :    deallocate memory allocated using ROSE_MALLOC.
    9753             : */
    9754       13450 : void SgTemplateArgument::operator delete(void *Pointer, size_t Size)
    9755             : {
    9756             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
    9757             :      * or throwing an exception. */
    9758       13450 :     ALLOC_MUTEX(SgTemplateArgument, lock);
    9759             : 
    9760             : #if USE_CPP_NEW_DELETE_OPERATORS
    9761             :     ROSE_FREE(Pointer);
    9762             : #else
    9763             : #if ROSE_PEDANTIC_ALLOC
    9764             :     ROSE_ASSERT(Size == sizeof(SgTemplateArgument));
    9765             : #else
    9766       13450 :     if (Size != sizeof(SgTemplateArgument)) {
    9767           0 :       ROSE_FREE(Pointer);
    9768           0 :       ALLOC_MUTEX(SgTemplateArgument, unlock);
    9769             :       return;
    9770             :     }
    9771             : #endif
    9772             : 
    9773       13450 :     SgTemplateArgument * object = (SgTemplateArgument*) Pointer;
    9774       13450 :     ROSE_ASSERT(object != nullptr);
    9775             : 
    9776             : #if ROSE_ALLOC_TRACE == 2
    9777             : //  printf("SgTemplateArgument::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTemplateArgument::next_node);
    9778             :     printf("SgTemplateArgument::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTemplateArgument::next_node);
    9779             : #endif
    9780             : 
    9781             : #if ROSE_PEDANTIC_ALLOC
    9782             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
    9783             : #endif
    9784             : 
    9785             : #if ROSE_ALLOC_MEMSET == 1
    9786             : #elif ROSE_ALLOC_MEMSET == 2
    9787             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgTemplateArgument) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
    9788             : #elif ROSE_ALLOC_MEMSET == 3
    9789             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgTemplateArgument) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
    9790             : #endif
    9791             : 
    9792             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
    9793             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
    9794             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
    9795             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
    9796             : #else
    9797       13450 :     object->p_freepointer = SgTemplateArgument::next_node;
    9798       13450 :     SgTemplateArgument::next_node = object;
    9799             : #endif
    9800             : 
    9801             : #if ROSE_ALLOC_TRACE == 2
    9802             : //  printf("SgTemplateArgument::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTemplateArgument::next_node);
    9803             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
    9804             :     Rose::MemPool::snapshot(oss.str());
    9805             :     alloc_trace_cnt++;
    9806             : #endif
    9807             : 
    9808             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
    9809             : 
    9810       13450 :     ALLOC_MUTEX(SgTemplateArgument, unlock);
    9811             : }
    9812             : 
    9813             : // DQ (11/27/2009): I have moved this member function definition to outside of the
    9814             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
    9815             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
    9816             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
    9817             : // Also, note comment below from Robb (copied from the Common.code file).
    9818             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
    9819             : //
    9820             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
    9821             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
    9822             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
    9823             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
    9824             : #if 0
    9825             : void SgTemplateArgument::operator delete(void* pointer) { SgTemplateArgument::operator delete (pointer, sizeof(SgTemplateArgument)); };
    9826             : #endif
    9827             : /* #line 9828 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
    9828             : 
    9829             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
    9830             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
    9831             : // obviously imply C++.
    9832             : 
    9833             : // This implements the support within ROSE for memory pools.  Memory pools
    9834             : // support the most condensed usage of memory within the construction of
    9835             : // and AST. Large blocks of contiguous storage for each RI node is allocated
    9836             : // by a new operator written for each class.
    9837             : 
    9838             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
    9839             :     // User wants multi-thread support and POSIX threads are available.
    9840             : #   include <pthread.h>
    9841             :     static pthread_mutex_t SgDirectory_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
    9842             : #else
    9843             :      // Cause synchronization to be skipped.
    9844             : #    ifndef ALLOC_MUTEX
    9845             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
    9846             : #    endif
    9847             : #    ifdef _REENTRANT
    9848             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
    9849             : #       ifdef _MSC_VER
    9850             : #           pragma message("POSIX threads are not available; synchronization being skipped")
    9851             : #       else
    9852             : #           warning "POSIX threads are not available; synchronization being skipped"
    9853             : #       endif
    9854             : #    endif
    9855             : #endif
    9856             : 
    9857             : #ifndef ROSE_ALLOC_TRACE
    9858             : #  define ROSE_ALLOC_TRACE 0
    9859             : #endif
    9860             : 
    9861             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
    9862             : #define ROSE_ALLOC_TRACE_CNT
    9863             : #include "memory-pool-snapshot.h"
    9864             : unsigned long alloc_trace_cnt = 0;
    9865             : #endif
    9866             : 
    9867             : #if ROSE_ALLOC_TRACE
    9868             : const unsigned SgDirectory::pool_size = 5;
    9869             : #else
    9870             : const unsigned SgDirectory::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
    9871             : #endif
    9872             : 
    9873             : #ifndef ROSE_ALLOC_MEMSET
    9874             : #  define ROSE_ALLOC_MEMSET 0
    9875             : #endif
    9876             : 
    9877             : #ifndef ROSE_PEDANTIC_ALLOC
    9878             : #  define ROSE_PEDANTIC_ALLOC 0
    9879             : #endif
    9880             : 
    9881             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
    9882             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
    9883             : #endif
    9884             : 
    9885             : #if !defined(SGNODE__ALL_POOLS)
    9886             : #define SGNODE__ALL_POOLS
    9887             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
    9888             : #endif
    9889             : 
    9890             : SgDirectory* SgDirectory::next_node = nullptr;
    9891             : std::vector<unsigned char*> SgDirectory::pools;
    9892             : 
    9893             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
    9894             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
    9895             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
    9896             : // around this macro definition rather than each use).
    9897             : #ifndef ALLOC_MUTEX
    9898             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
    9899             :         do {                                                                     \
    9900             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
    9901             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
    9902             :                 abort();                                                         \
    9903             :             }                                                                    \
    9904             :         } while (0);
    9905             : #endif
    9906             : 
    9907             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
    9908             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
    9909             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
    9910             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
    9911             : 
    9912             : /*! \brief New operator for SgDirectory.
    9913             : 
    9914             :    This new operator implements memory pools to provide most efficent 
    9915             :    use of the heap within construction of large ASTs.
    9916             : 
    9917             : \internal The new and delete operators use the lower level C malloc/free
    9918             :    function calls for performance and to make sure that mixing of malloc/free
    9919             :    and new/delete by the used can be caught more readily.  This may change
    9920             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
    9921             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
    9922             :    deallocate memory allocated using ROSE_MALLOC.
    9923             : */
    9924           0 : void *SgDirectory::operator new ( size_t Size )
    9925             : {
    9926             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
    9927             :      * returning or throwing an exception. */
    9928           0 :     ALLOC_MUTEX(SgDirectory, lock);
    9929             : 
    9930             : #if ROSE_ALLOC_TRACE == 2
    9931             : //    printf("SgDirectory::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgDirectory::next_node);
    9932             : #endif
    9933             : 
    9934             : #if USE_CPP_NEW_DELETE_OPERATORS
    9935             :     void *mem = ROSE_MALLOC(Size);
    9936             :     ALLOC_MUTEX(SgDirectory, unlock);
    9937             :     return mem;
    9938             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
    9939             : #if ROSE_PEDANTIC_ALLOC
    9940             :     ROSE_ASSERT(Size == sizeof(SgDirectory));
    9941             : #else
    9942           0 :     if (Size != sizeof(SgDirectory)) {
    9943           0 :       void * object = ROSE_MALLOC(Size);
    9944           0 :       ALLOC_MUTEX(SgDirectory, unlock);
    9945             :       return object;
    9946             :     }
    9947             : #endif
    9948             : 
    9949           0 :     if (SgDirectory::next_node == nullptr) {
    9950           0 :         SgDirectory * alloc = (SgDirectory*) ROSE_MALLOC ( SgDirectory::pool_size * sizeof(SgDirectory) );
    9951           0 :         ROSE_ASSERT(alloc != nullptr);
    9952             : 
    9953             : #if ROSE_ALLOC_TRACE == 2
    9954             : //        printf("SgDirectory::alloc\n  block[%zi] = [ %p , %p [\n", SgDirectory::pools.size(), alloc, alloc + SgDirectory::pool_size);
    9955             : #endif
    9956             : 
    9957             : #if ROSE_ALLOC_MEMSET == 1
    9958             : #elif ROSE_ALLOC_MEMSET == 2
    9959             :         memset(alloc, 0x00, SgDirectory::pool_size * sizeof(SgDirectory));
    9960             : #elif ROSE_ALLOC_MEMSET == 3
    9961             :         memset(alloc, 0xAA, SgDirectory::pool_size * sizeof(SgDirectory));
    9962             : #endif
    9963           0 :         for (unsigned i=0; i < SgDirectory::pool_size-1; i++) {
    9964           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
    9965             :         }
    9966           0 :         alloc[SgDirectory::pool_size-1].p_freepointer = nullptr;
    9967             : 
    9968           0 :         SgDirectory::pools.push_back ( (unsigned char *) alloc );
    9969           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgDirectory::pool_size * sizeof(SgDirectory), V_SgDirectory ) );
    9970           0 :         SgDirectory::next_node = alloc;
    9971             :     }
    9972           0 :     ROSE_ASSERT(SgDirectory::next_node != nullptr);
    9973             : 
    9974           0 :     SgDirectory * object = SgDirectory::next_node;
    9975           0 :     SgDirectory::next_node = (SgDirectory*)(object->p_freepointer);
    9976             : 
    9977             : #if ROSE_ALLOC_TRACE == 2
    9978             :     printf("SgDirectory::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgDirectory::next_node);
    9979             : #endif
    9980             : 
    9981           0 :     SgNode * fp = object->p_freepointer;
    9982             : #if ROSE_ALLOC_MEMSET == 1
    9983             : #elif ROSE_ALLOC_MEMSET == 2
    9984             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgDirectory) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
    9985             : #elif ROSE_ALLOC_MEMSET == 3
    9986             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgDirectory) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
    9987             : #endif
    9988           0 :     object->p_freepointer = fp;
    9989             : 
    9990             : #if ROSE_ALLOC_TRACE == 2
    9991             : //    printf("SgDirectory::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgDirectory::next_node);
    9992             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
    9993             :     Rose::MemPool::snapshot(oss.str());
    9994             :     alloc_trace_cnt++;
    9995             : #endif
    9996             : 
    9997           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
    9998             : 
    9999           0 :     ALLOC_MUTEX(SgDirectory, unlock);
   10000             : 
   10001             :     return object;
   10002             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   10003             : }
   10004             : 
   10005             : 
   10006             : 
   10007             : /*! \brief Delete operator for SgDirectory.
   10008             : 
   10009             :    This delete operator implements deallocation using memory pools to 
   10010             :    provide most efficent use of the heap within construction of large ASTs.
   10011             : 
   10012             : \internal The new and delete operators use the lower level C malloc/free
   10013             :    function calls for performance and to make sure that mixing of malloc/free
   10014             :    and new/delete by the used can be caught more readily.  This may change
   10015             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   10016             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   10017             :    deallocate memory allocated using ROSE_MALLOC.
   10018             : */
   10019           0 : void SgDirectory::operator delete(void *Pointer, size_t Size)
   10020             : {
   10021             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   10022             :      * or throwing an exception. */
   10023           0 :     ALLOC_MUTEX(SgDirectory, lock);
   10024             : 
   10025             : #if USE_CPP_NEW_DELETE_OPERATORS
   10026             :     ROSE_FREE(Pointer);
   10027             : #else
   10028             : #if ROSE_PEDANTIC_ALLOC
   10029             :     ROSE_ASSERT(Size == sizeof(SgDirectory));
   10030             : #else
   10031           0 :     if (Size != sizeof(SgDirectory)) {
   10032           0 :       ROSE_FREE(Pointer);
   10033           0 :       ALLOC_MUTEX(SgDirectory, unlock);
   10034             :       return;
   10035             :     }
   10036             : #endif
   10037             : 
   10038           0 :     SgDirectory * object = (SgDirectory*) Pointer;
   10039           0 :     ROSE_ASSERT(object != nullptr);
   10040             : 
   10041             : #if ROSE_ALLOC_TRACE == 2
   10042             : //  printf("SgDirectory::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgDirectory::next_node);
   10043             :     printf("SgDirectory::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgDirectory::next_node);
   10044             : #endif
   10045             : 
   10046             : #if ROSE_PEDANTIC_ALLOC
   10047             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   10048             : #endif
   10049             : 
   10050             : #if ROSE_ALLOC_MEMSET == 1
   10051             : #elif ROSE_ALLOC_MEMSET == 2
   10052             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgDirectory) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   10053             : #elif ROSE_ALLOC_MEMSET == 3
   10054             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgDirectory) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   10055             : #endif
   10056             : 
   10057             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   10058             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   10059             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   10060             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   10061             : #else
   10062           0 :     object->p_freepointer = SgDirectory::next_node;
   10063           0 :     SgDirectory::next_node = object;
   10064             : #endif
   10065             : 
   10066             : #if ROSE_ALLOC_TRACE == 2
   10067             : //  printf("SgDirectory::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgDirectory::next_node);
   10068             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   10069             :     Rose::MemPool::snapshot(oss.str());
   10070             :     alloc_trace_cnt++;
   10071             : #endif
   10072             : 
   10073             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   10074             : 
   10075           0 :     ALLOC_MUTEX(SgDirectory, unlock);
   10076             : }
   10077             : 
   10078             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   10079             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   10080             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   10081             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   10082             : // Also, note comment below from Robb (copied from the Common.code file).
   10083             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   10084             : //
   10085             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   10086             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   10087             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   10088             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   10089             : #if 0
   10090             : void SgDirectory::operator delete(void* pointer) { SgDirectory::operator delete (pointer, sizeof(SgDirectory)); };
   10091             : #endif
   10092             : /* #line 10093 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   10093             : 
   10094             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   10095             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   10096             : // obviously imply C++.
   10097             : 
   10098             : // This implements the support within ROSE for memory pools.  Memory pools
   10099             : // support the most condensed usage of memory within the construction of
   10100             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   10101             : // by a new operator written for each class.
   10102             : 
   10103             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   10104             :     // User wants multi-thread support and POSIX threads are available.
   10105             : #   include <pthread.h>
   10106             :     static pthread_mutex_t SgFileList_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   10107             : #else
   10108             :      // Cause synchronization to be skipped.
   10109             : #    ifndef ALLOC_MUTEX
   10110             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   10111             : #    endif
   10112             : #    ifdef _REENTRANT
   10113             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   10114             : #       ifdef _MSC_VER
   10115             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   10116             : #       else
   10117             : #           warning "POSIX threads are not available; synchronization being skipped"
   10118             : #       endif
   10119             : #    endif
   10120             : #endif
   10121             : 
   10122             : #ifndef ROSE_ALLOC_TRACE
   10123             : #  define ROSE_ALLOC_TRACE 0
   10124             : #endif
   10125             : 
   10126             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   10127             : #define ROSE_ALLOC_TRACE_CNT
   10128             : #include "memory-pool-snapshot.h"
   10129             : unsigned long alloc_trace_cnt = 0;
   10130             : #endif
   10131             : 
   10132             : #if ROSE_ALLOC_TRACE
   10133             : const unsigned SgFileList::pool_size = 5;
   10134             : #else
   10135             : const unsigned SgFileList::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   10136             : #endif
   10137             : 
   10138             : #ifndef ROSE_ALLOC_MEMSET
   10139             : #  define ROSE_ALLOC_MEMSET 0
   10140             : #endif
   10141             : 
   10142             : #ifndef ROSE_PEDANTIC_ALLOC
   10143             : #  define ROSE_PEDANTIC_ALLOC 0
   10144             : #endif
   10145             : 
   10146             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   10147             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   10148             : #endif
   10149             : 
   10150             : #if !defined(SGNODE__ALL_POOLS)
   10151             : #define SGNODE__ALL_POOLS
   10152             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   10153             : #endif
   10154             : 
   10155             : SgFileList* SgFileList::next_node = nullptr;
   10156             : std::vector<unsigned char*> SgFileList::pools;
   10157             : 
   10158             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   10159             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   10160             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   10161             : // around this macro definition rather than each use).
   10162             : #ifndef ALLOC_MUTEX
   10163             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   10164             :         do {                                                                     \
   10165             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   10166             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   10167             :                 abort();                                                         \
   10168             :             }                                                                    \
   10169             :         } while (0);
   10170             : #endif
   10171             : 
   10172             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   10173             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   10174             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   10175             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   10176             : 
   10177             : /*! \brief New operator for SgFileList.
   10178             : 
   10179             :    This new operator implements memory pools to provide most efficent 
   10180             :    use of the heap within construction of large ASTs.
   10181             : 
   10182             : \internal The new and delete operators use the lower level C malloc/free
   10183             :    function calls for performance and to make sure that mixing of malloc/free
   10184             :    and new/delete by the used can be caught more readily.  This may change
   10185             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   10186             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   10187             :    deallocate memory allocated using ROSE_MALLOC.
   10188             : */
   10189         359 : void *SgFileList::operator new ( size_t Size )
   10190             : {
   10191             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   10192             :      * returning or throwing an exception. */
   10193         359 :     ALLOC_MUTEX(SgFileList, lock);
   10194             : 
   10195             : #if ROSE_ALLOC_TRACE == 2
   10196             : //    printf("SgFileList::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgFileList::next_node);
   10197             : #endif
   10198             : 
   10199             : #if USE_CPP_NEW_DELETE_OPERATORS
   10200             :     void *mem = ROSE_MALLOC(Size);
   10201             :     ALLOC_MUTEX(SgFileList, unlock);
   10202             :     return mem;
   10203             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   10204             : #if ROSE_PEDANTIC_ALLOC
   10205             :     ROSE_ASSERT(Size == sizeof(SgFileList));
   10206             : #else
   10207         359 :     if (Size != sizeof(SgFileList)) {
   10208           0 :       void * object = ROSE_MALLOC(Size);
   10209           0 :       ALLOC_MUTEX(SgFileList, unlock);
   10210             :       return object;
   10211             :     }
   10212             : #endif
   10213             : 
   10214         359 :     if (SgFileList::next_node == nullptr) {
   10215         355 :         SgFileList * alloc = (SgFileList*) ROSE_MALLOC ( SgFileList::pool_size * sizeof(SgFileList) );
   10216         355 :         ROSE_ASSERT(alloc != nullptr);
   10217             : 
   10218             : #if ROSE_ALLOC_TRACE == 2
   10219             : //        printf("SgFileList::alloc\n  block[%zi] = [ %p , %p [\n", SgFileList::pools.size(), alloc, alloc + SgFileList::pool_size);
   10220             : #endif
   10221             : 
   10222             : #if ROSE_ALLOC_MEMSET == 1
   10223             : #elif ROSE_ALLOC_MEMSET == 2
   10224             :         memset(alloc, 0x00, SgFileList::pool_size * sizeof(SgFileList));
   10225             : #elif ROSE_ALLOC_MEMSET == 3
   10226             :         memset(alloc, 0xAA, SgFileList::pool_size * sizeof(SgFileList));
   10227             : #endif
   10228      710000 :         for (unsigned i=0; i < SgFileList::pool_size-1; i++) {
   10229      709645 :           alloc[i].p_freepointer = &(alloc[i+1]);
   10230             :         }
   10231         355 :         alloc[SgFileList::pool_size-1].p_freepointer = nullptr;
   10232             : 
   10233         355 :         SgFileList::pools.push_back ( (unsigned char *) alloc );
   10234         355 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgFileList::pool_size * sizeof(SgFileList), V_SgFileList ) );
   10235         355 :         SgFileList::next_node = alloc;
   10236             :     }
   10237         359 :     ROSE_ASSERT(SgFileList::next_node != nullptr);
   10238             : 
   10239         359 :     SgFileList * object = SgFileList::next_node;
   10240         359 :     SgFileList::next_node = (SgFileList*)(object->p_freepointer);
   10241             : 
   10242             : #if ROSE_ALLOC_TRACE == 2
   10243             :     printf("SgFileList::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgFileList::next_node);
   10244             : #endif
   10245             : 
   10246         359 :     SgNode * fp = object->p_freepointer;
   10247             : #if ROSE_ALLOC_MEMSET == 1
   10248             : #elif ROSE_ALLOC_MEMSET == 2
   10249             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgFileList) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   10250             : #elif ROSE_ALLOC_MEMSET == 3
   10251             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgFileList) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   10252             : #endif
   10253         359 :     object->p_freepointer = fp;
   10254             : 
   10255             : #if ROSE_ALLOC_TRACE == 2
   10256             : //    printf("SgFileList::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgFileList::next_node);
   10257             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   10258             :     Rose::MemPool::snapshot(oss.str());
   10259             :     alloc_trace_cnt++;
   10260             : #endif
   10261             : 
   10262         359 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   10263             : 
   10264         359 :     ALLOC_MUTEX(SgFileList, unlock);
   10265             : 
   10266             :     return object;
   10267             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   10268             : }
   10269             : 
   10270             : 
   10271             : 
   10272             : /*! \brief Delete operator for SgFileList.
   10273             : 
   10274             :    This delete operator implements deallocation using memory pools to 
   10275             :    provide most efficent use of the heap within construction of large ASTs.
   10276             : 
   10277             : \internal The new and delete operators use the lower level C malloc/free
   10278             :    function calls for performance and to make sure that mixing of malloc/free
   10279             :    and new/delete by the used can be caught more readily.  This may change
   10280             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   10281             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   10282             :    deallocate memory allocated using ROSE_MALLOC.
   10283             : */
   10284           7 : void SgFileList::operator delete(void *Pointer, size_t Size)
   10285             : {
   10286             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   10287             :      * or throwing an exception. */
   10288           7 :     ALLOC_MUTEX(SgFileList, lock);
   10289             : 
   10290             : #if USE_CPP_NEW_DELETE_OPERATORS
   10291             :     ROSE_FREE(Pointer);
   10292             : #else
   10293             : #if ROSE_PEDANTIC_ALLOC
   10294             :     ROSE_ASSERT(Size == sizeof(SgFileList));
   10295             : #else
   10296           7 :     if (Size != sizeof(SgFileList)) {
   10297           0 :       ROSE_FREE(Pointer);
   10298           0 :       ALLOC_MUTEX(SgFileList, unlock);
   10299             :       return;
   10300             :     }
   10301             : #endif
   10302             : 
   10303           7 :     SgFileList * object = (SgFileList*) Pointer;
   10304           7 :     ROSE_ASSERT(object != nullptr);
   10305             : 
   10306             : #if ROSE_ALLOC_TRACE == 2
   10307             : //  printf("SgFileList::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgFileList::next_node);
   10308             :     printf("SgFileList::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgFileList::next_node);
   10309             : #endif
   10310             : 
   10311             : #if ROSE_PEDANTIC_ALLOC
   10312             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   10313             : #endif
   10314             : 
   10315             : #if ROSE_ALLOC_MEMSET == 1
   10316             : #elif ROSE_ALLOC_MEMSET == 2
   10317             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgFileList) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   10318             : #elif ROSE_ALLOC_MEMSET == 3
   10319             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgFileList) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   10320             : #endif
   10321             : 
   10322             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   10323             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   10324             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   10325             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   10326             : #else
   10327           7 :     object->p_freepointer = SgFileList::next_node;
   10328           7 :     SgFileList::next_node = object;
   10329             : #endif
   10330             : 
   10331             : #if ROSE_ALLOC_TRACE == 2
   10332             : //  printf("SgFileList::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgFileList::next_node);
   10333             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   10334             :     Rose::MemPool::snapshot(oss.str());
   10335             :     alloc_trace_cnt++;
   10336             : #endif
   10337             : 
   10338             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   10339             : 
   10340           7 :     ALLOC_MUTEX(SgFileList, unlock);
   10341             : }
   10342             : 
   10343             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   10344             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   10345             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   10346             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   10347             : // Also, note comment below from Robb (copied from the Common.code file).
   10348             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   10349             : //
   10350             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   10351             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   10352             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   10353             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   10354             : #if 0
   10355             : void SgFileList::operator delete(void* pointer) { SgFileList::operator delete (pointer, sizeof(SgFileList)); };
   10356             : #endif
   10357             : /* #line 10358 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   10358             : 
   10359             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   10360             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   10361             : // obviously imply C++.
   10362             : 
   10363             : // This implements the support within ROSE for memory pools.  Memory pools
   10364             : // support the most condensed usage of memory within the construction of
   10365             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   10366             : // by a new operator written for each class.
   10367             : 
   10368             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   10369             :     // User wants multi-thread support and POSIX threads are available.
   10370             : #   include <pthread.h>
   10371             :     static pthread_mutex_t SgDirectoryList_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   10372             : #else
   10373             :      // Cause synchronization to be skipped.
   10374             : #    ifndef ALLOC_MUTEX
   10375             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   10376             : #    endif
   10377             : #    ifdef _REENTRANT
   10378             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   10379             : #       ifdef _MSC_VER
   10380             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   10381             : #       else
   10382             : #           warning "POSIX threads are not available; synchronization being skipped"
   10383             : #       endif
   10384             : #    endif
   10385             : #endif
   10386             : 
   10387             : #ifndef ROSE_ALLOC_TRACE
   10388             : #  define ROSE_ALLOC_TRACE 0
   10389             : #endif
   10390             : 
   10391             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   10392             : #define ROSE_ALLOC_TRACE_CNT
   10393             : #include "memory-pool-snapshot.h"
   10394             : unsigned long alloc_trace_cnt = 0;
   10395             : #endif
   10396             : 
   10397             : #if ROSE_ALLOC_TRACE
   10398             : const unsigned SgDirectoryList::pool_size = 5;
   10399             : #else
   10400             : const unsigned SgDirectoryList::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   10401             : #endif
   10402             : 
   10403             : #ifndef ROSE_ALLOC_MEMSET
   10404             : #  define ROSE_ALLOC_MEMSET 0
   10405             : #endif
   10406             : 
   10407             : #ifndef ROSE_PEDANTIC_ALLOC
   10408             : #  define ROSE_PEDANTIC_ALLOC 0
   10409             : #endif
   10410             : 
   10411             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   10412             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   10413             : #endif
   10414             : 
   10415             : #if !defined(SGNODE__ALL_POOLS)
   10416             : #define SGNODE__ALL_POOLS
   10417             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   10418             : #endif
   10419             : 
   10420             : SgDirectoryList* SgDirectoryList::next_node = nullptr;
   10421             : std::vector<unsigned char*> SgDirectoryList::pools;
   10422             : 
   10423             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   10424             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   10425             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   10426             : // around this macro definition rather than each use).
   10427             : #ifndef ALLOC_MUTEX
   10428             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   10429             :         do {                                                                     \
   10430             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   10431             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   10432             :                 abort();                                                         \
   10433             :             }                                                                    \
   10434             :         } while (0);
   10435             : #endif
   10436             : 
   10437             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   10438             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   10439             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   10440             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   10441             : 
   10442             : /*! \brief New operator for SgDirectoryList.
   10443             : 
   10444             :    This new operator implements memory pools to provide most efficent 
   10445             :    use of the heap within construction of large ASTs.
   10446             : 
   10447             : \internal The new and delete operators use the lower level C malloc/free
   10448             :    function calls for performance and to make sure that mixing of malloc/free
   10449             :    and new/delete by the used can be caught more readily.  This may change
   10450             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   10451             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   10452             :    deallocate memory allocated using ROSE_MALLOC.
   10453             : */
   10454         359 : void *SgDirectoryList::operator new ( size_t Size )
   10455             : {
   10456             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   10457             :      * returning or throwing an exception. */
   10458         359 :     ALLOC_MUTEX(SgDirectoryList, lock);
   10459             : 
   10460             : #if ROSE_ALLOC_TRACE == 2
   10461             : //    printf("SgDirectoryList::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgDirectoryList::next_node);
   10462             : #endif
   10463             : 
   10464             : #if USE_CPP_NEW_DELETE_OPERATORS
   10465             :     void *mem = ROSE_MALLOC(Size);
   10466             :     ALLOC_MUTEX(SgDirectoryList, unlock);
   10467             :     return mem;
   10468             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   10469             : #if ROSE_PEDANTIC_ALLOC
   10470             :     ROSE_ASSERT(Size == sizeof(SgDirectoryList));
   10471             : #else
   10472         359 :     if (Size != sizeof(SgDirectoryList)) {
   10473           0 :       void * object = ROSE_MALLOC(Size);
   10474           0 :       ALLOC_MUTEX(SgDirectoryList, unlock);
   10475             :       return object;
   10476             :     }
   10477             : #endif
   10478             : 
   10479         359 :     if (SgDirectoryList::next_node == nullptr) {
   10480         355 :         SgDirectoryList * alloc = (SgDirectoryList*) ROSE_MALLOC ( SgDirectoryList::pool_size * sizeof(SgDirectoryList) );
   10481         355 :         ROSE_ASSERT(alloc != nullptr);
   10482             : 
   10483             : #if ROSE_ALLOC_TRACE == 2
   10484             : //        printf("SgDirectoryList::alloc\n  block[%zi] = [ %p , %p [\n", SgDirectoryList::pools.size(), alloc, alloc + SgDirectoryList::pool_size);
   10485             : #endif
   10486             : 
   10487             : #if ROSE_ALLOC_MEMSET == 1
   10488             : #elif ROSE_ALLOC_MEMSET == 2
   10489             :         memset(alloc, 0x00, SgDirectoryList::pool_size * sizeof(SgDirectoryList));
   10490             : #elif ROSE_ALLOC_MEMSET == 3
   10491             :         memset(alloc, 0xAA, SgDirectoryList::pool_size * sizeof(SgDirectoryList));
   10492             : #endif
   10493      710000 :         for (unsigned i=0; i < SgDirectoryList::pool_size-1; i++) {
   10494      709645 :           alloc[i].p_freepointer = &(alloc[i+1]);
   10495             :         }
   10496         355 :         alloc[SgDirectoryList::pool_size-1].p_freepointer = nullptr;
   10497             : 
   10498         355 :         SgDirectoryList::pools.push_back ( (unsigned char *) alloc );
   10499         355 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgDirectoryList::pool_size * sizeof(SgDirectoryList), V_SgDirectoryList ) );
   10500         355 :         SgDirectoryList::next_node = alloc;
   10501             :     }
   10502         359 :     ROSE_ASSERT(SgDirectoryList::next_node != nullptr);
   10503             : 
   10504         359 :     SgDirectoryList * object = SgDirectoryList::next_node;
   10505         359 :     SgDirectoryList::next_node = (SgDirectoryList*)(object->p_freepointer);
   10506             : 
   10507             : #if ROSE_ALLOC_TRACE == 2
   10508             :     printf("SgDirectoryList::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgDirectoryList::next_node);
   10509             : #endif
   10510             : 
   10511         359 :     SgNode * fp = object->p_freepointer;
   10512             : #if ROSE_ALLOC_MEMSET == 1
   10513             : #elif ROSE_ALLOC_MEMSET == 2
   10514             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgDirectoryList) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   10515             : #elif ROSE_ALLOC_MEMSET == 3
   10516             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgDirectoryList) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   10517             : #endif
   10518         359 :     object->p_freepointer = fp;
   10519             : 
   10520             : #if ROSE_ALLOC_TRACE == 2
   10521             : //    printf("SgDirectoryList::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgDirectoryList::next_node);
   10522             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   10523             :     Rose::MemPool::snapshot(oss.str());
   10524             :     alloc_trace_cnt++;
   10525             : #endif
   10526             : 
   10527         359 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   10528             : 
   10529         359 :     ALLOC_MUTEX(SgDirectoryList, unlock);
   10530             : 
   10531             :     return object;
   10532             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   10533             : }
   10534             : 
   10535             : 
   10536             : 
   10537             : /*! \brief Delete operator for SgDirectoryList.
   10538             : 
   10539             :    This delete operator implements deallocation using memory pools to 
   10540             :    provide most efficent use of the heap within construction of large ASTs.
   10541             : 
   10542             : \internal The new and delete operators use the lower level C malloc/free
   10543             :    function calls for performance and to make sure that mixing of malloc/free
   10544             :    and new/delete by the used can be caught more readily.  This may change
   10545             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   10546             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   10547             :    deallocate memory allocated using ROSE_MALLOC.
   10548             : */
   10549           7 : void SgDirectoryList::operator delete(void *Pointer, size_t Size)
   10550             : {
   10551             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   10552             :      * or throwing an exception. */
   10553           7 :     ALLOC_MUTEX(SgDirectoryList, lock);
   10554             : 
   10555             : #if USE_CPP_NEW_DELETE_OPERATORS
   10556             :     ROSE_FREE(Pointer);
   10557             : #else
   10558             : #if ROSE_PEDANTIC_ALLOC
   10559             :     ROSE_ASSERT(Size == sizeof(SgDirectoryList));
   10560             : #else
   10561           7 :     if (Size != sizeof(SgDirectoryList)) {
   10562           0 :       ROSE_FREE(Pointer);
   10563           0 :       ALLOC_MUTEX(SgDirectoryList, unlock);
   10564             :       return;
   10565             :     }
   10566             : #endif
   10567             : 
   10568           7 :     SgDirectoryList * object = (SgDirectoryList*) Pointer;
   10569           7 :     ROSE_ASSERT(object != nullptr);
   10570             : 
   10571             : #if ROSE_ALLOC_TRACE == 2
   10572             : //  printf("SgDirectoryList::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgDirectoryList::next_node);
   10573             :     printf("SgDirectoryList::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgDirectoryList::next_node);
   10574             : #endif
   10575             : 
   10576             : #if ROSE_PEDANTIC_ALLOC
   10577             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   10578             : #endif
   10579             : 
   10580             : #if ROSE_ALLOC_MEMSET == 1
   10581             : #elif ROSE_ALLOC_MEMSET == 2
   10582             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgDirectoryList) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   10583             : #elif ROSE_ALLOC_MEMSET == 3
   10584             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgDirectoryList) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   10585             : #endif
   10586             : 
   10587             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   10588             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   10589             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   10590             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   10591             : #else
   10592           7 :     object->p_freepointer = SgDirectoryList::next_node;
   10593           7 :     SgDirectoryList::next_node = object;
   10594             : #endif
   10595             : 
   10596             : #if ROSE_ALLOC_TRACE == 2
   10597             : //  printf("SgDirectoryList::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgDirectoryList::next_node);
   10598             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   10599             :     Rose::MemPool::snapshot(oss.str());
   10600             :     alloc_trace_cnt++;
   10601             : #endif
   10602             : 
   10603             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   10604             : 
   10605           7 :     ALLOC_MUTEX(SgDirectoryList, unlock);
   10606             : }
   10607             : 
   10608             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   10609             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   10610             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   10611             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   10612             : // Also, note comment below from Robb (copied from the Common.code file).
   10613             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   10614             : //
   10615             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   10616             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   10617             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   10618             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   10619             : #if 0
   10620             : void SgDirectoryList::operator delete(void* pointer) { SgDirectoryList::operator delete (pointer, sizeof(SgDirectoryList)); };
   10621             : #endif
   10622             : /* #line 10623 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   10623             : 
   10624             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   10625             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   10626             : // obviously imply C++.
   10627             : 
   10628             : // This implements the support within ROSE for memory pools.  Memory pools
   10629             : // support the most condensed usage of memory within the construction of
   10630             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   10631             : // by a new operator written for each class.
   10632             : 
   10633             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   10634             :     // User wants multi-thread support and POSIX threads are available.
   10635             : #   include <pthread.h>
   10636             :     static pthread_mutex_t SgFunctionParameterTypeList_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   10637             : #else
   10638             :      // Cause synchronization to be skipped.
   10639             : #    ifndef ALLOC_MUTEX
   10640             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   10641             : #    endif
   10642             : #    ifdef _REENTRANT
   10643             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   10644             : #       ifdef _MSC_VER
   10645             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   10646             : #       else
   10647             : #           warning "POSIX threads are not available; synchronization being skipped"
   10648             : #       endif
   10649             : #    endif
   10650             : #endif
   10651             : 
   10652             : #ifndef ROSE_ALLOC_TRACE
   10653             : #  define ROSE_ALLOC_TRACE 0
   10654             : #endif
   10655             : 
   10656             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   10657             : #define ROSE_ALLOC_TRACE_CNT
   10658             : #include "memory-pool-snapshot.h"
   10659             : unsigned long alloc_trace_cnt = 0;
   10660             : #endif
   10661             : 
   10662             : #if ROSE_ALLOC_TRACE
   10663             : const unsigned SgFunctionParameterTypeList::pool_size = 5;
   10664             : #else
   10665             : const unsigned SgFunctionParameterTypeList::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   10666             : #endif
   10667             : 
   10668             : #ifndef ROSE_ALLOC_MEMSET
   10669             : #  define ROSE_ALLOC_MEMSET 0
   10670             : #endif
   10671             : 
   10672             : #ifndef ROSE_PEDANTIC_ALLOC
   10673             : #  define ROSE_PEDANTIC_ALLOC 0
   10674             : #endif
   10675             : 
   10676             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   10677             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   10678             : #endif
   10679             : 
   10680             : #if !defined(SGNODE__ALL_POOLS)
   10681             : #define SGNODE__ALL_POOLS
   10682             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   10683             : #endif
   10684             : 
   10685             : SgFunctionParameterTypeList* SgFunctionParameterTypeList::next_node = nullptr;
   10686             : std::vector<unsigned char*> SgFunctionParameterTypeList::pools;
   10687             : 
   10688             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   10689             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   10690             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   10691             : // around this macro definition rather than each use).
   10692             : #ifndef ALLOC_MUTEX
   10693             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   10694             :         do {                                                                     \
   10695             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   10696             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   10697             :                 abort();                                                         \
   10698             :             }                                                                    \
   10699             :         } while (0);
   10700             : #endif
   10701             : 
   10702             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   10703             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   10704             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   10705             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   10706             : 
   10707             : /*! \brief New operator for SgFunctionParameterTypeList.
   10708             : 
   10709             :    This new operator implements memory pools to provide most efficent 
   10710             :    use of the heap within construction of large ASTs.
   10711             : 
   10712             : \internal The new and delete operators use the lower level C malloc/free
   10713             :    function calls for performance and to make sure that mixing of malloc/free
   10714             :    and new/delete by the used can be caught more readily.  This may change
   10715             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   10716             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   10717             :    deallocate memory allocated using ROSE_MALLOC.
   10718             : */
   10719     2601900 : void *SgFunctionParameterTypeList::operator new ( size_t Size )
   10720             : {
   10721             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   10722             :      * returning or throwing an exception. */
   10723     2601900 :     ALLOC_MUTEX(SgFunctionParameterTypeList, lock);
   10724             : 
   10725             : #if ROSE_ALLOC_TRACE == 2
   10726             : //    printf("SgFunctionParameterTypeList::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgFunctionParameterTypeList::next_node);
   10727             : #endif
   10728             : 
   10729             : #if USE_CPP_NEW_DELETE_OPERATORS
   10730             :     void *mem = ROSE_MALLOC(Size);
   10731             :     ALLOC_MUTEX(SgFunctionParameterTypeList, unlock);
   10732             :     return mem;
   10733             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   10734             : #if ROSE_PEDANTIC_ALLOC
   10735             :     ROSE_ASSERT(Size == sizeof(SgFunctionParameterTypeList));
   10736             : #else
   10737     2601900 :     if (Size != sizeof(SgFunctionParameterTypeList)) {
   10738           0 :       void * object = ROSE_MALLOC(Size);
   10739           0 :       ALLOC_MUTEX(SgFunctionParameterTypeList, unlock);
   10740             :       return object;
   10741             :     }
   10742             : #endif
   10743             : 
   10744     2601900 :     if (SgFunctionParameterTypeList::next_node == nullptr) {
   10745         379 :         SgFunctionParameterTypeList * alloc = (SgFunctionParameterTypeList*) ROSE_MALLOC ( SgFunctionParameterTypeList::pool_size * sizeof(SgFunctionParameterTypeList) );
   10746         379 :         ROSE_ASSERT(alloc != nullptr);
   10747             : 
   10748             : #if ROSE_ALLOC_TRACE == 2
   10749             : //        printf("SgFunctionParameterTypeList::alloc\n  block[%zi] = [ %p , %p [\n", SgFunctionParameterTypeList::pools.size(), alloc, alloc + SgFunctionParameterTypeList::pool_size);
   10750             : #endif
   10751             : 
   10752             : #if ROSE_ALLOC_MEMSET == 1
   10753             : #elif ROSE_ALLOC_MEMSET == 2
   10754             :         memset(alloc, 0x00, SgFunctionParameterTypeList::pool_size * sizeof(SgFunctionParameterTypeList));
   10755             : #elif ROSE_ALLOC_MEMSET == 3
   10756             :         memset(alloc, 0xAA, SgFunctionParameterTypeList::pool_size * sizeof(SgFunctionParameterTypeList));
   10757             : #endif
   10758      758000 :         for (unsigned i=0; i < SgFunctionParameterTypeList::pool_size-1; i++) {
   10759      757621 :           alloc[i].p_freepointer = &(alloc[i+1]);
   10760             :         }
   10761         379 :         alloc[SgFunctionParameterTypeList::pool_size-1].p_freepointer = nullptr;
   10762             : 
   10763         379 :         SgFunctionParameterTypeList::pools.push_back ( (unsigned char *) alloc );
   10764         379 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgFunctionParameterTypeList::pool_size * sizeof(SgFunctionParameterTypeList), V_SgFunctionParameterTypeList ) );
   10765         379 :         SgFunctionParameterTypeList::next_node = alloc;
   10766             :     }
   10767     2601900 :     ROSE_ASSERT(SgFunctionParameterTypeList::next_node != nullptr);
   10768             : 
   10769     2601900 :     SgFunctionParameterTypeList * object = SgFunctionParameterTypeList::next_node;
   10770     2601900 :     SgFunctionParameterTypeList::next_node = (SgFunctionParameterTypeList*)(object->p_freepointer);
   10771             : 
   10772             : #if ROSE_ALLOC_TRACE == 2
   10773             :     printf("SgFunctionParameterTypeList::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgFunctionParameterTypeList::next_node);
   10774             : #endif
   10775             : 
   10776     2601900 :     SgNode * fp = object->p_freepointer;
   10777             : #if ROSE_ALLOC_MEMSET == 1
   10778             : #elif ROSE_ALLOC_MEMSET == 2
   10779             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgFunctionParameterTypeList) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   10780             : #elif ROSE_ALLOC_MEMSET == 3
   10781             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgFunctionParameterTypeList) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   10782             : #endif
   10783     2601900 :     object->p_freepointer = fp;
   10784             : 
   10785             : #if ROSE_ALLOC_TRACE == 2
   10786             : //    printf("SgFunctionParameterTypeList::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgFunctionParameterTypeList::next_node);
   10787             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   10788             :     Rose::MemPool::snapshot(oss.str());
   10789             :     alloc_trace_cnt++;
   10790             : #endif
   10791             : 
   10792     2601900 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   10793             : 
   10794     2601900 :     ALLOC_MUTEX(SgFunctionParameterTypeList, unlock);
   10795             : 
   10796             :     return object;
   10797             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   10798             : }
   10799             : 
   10800             : 
   10801             : 
   10802             : /*! \brief Delete operator for SgFunctionParameterTypeList.
   10803             : 
   10804             :    This delete operator implements deallocation using memory pools to 
   10805             :    provide most efficent use of the heap within construction of large ASTs.
   10806             : 
   10807             : \internal The new and delete operators use the lower level C malloc/free
   10808             :    function calls for performance and to make sure that mixing of malloc/free
   10809             :    and new/delete by the used can be caught more readily.  This may change
   10810             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   10811             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   10812             :    deallocate memory allocated using ROSE_MALLOC.
   10813             : */
   10814     2332860 : void SgFunctionParameterTypeList::operator delete(void *Pointer, size_t Size)
   10815             : {
   10816             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   10817             :      * or throwing an exception. */
   10818     2332860 :     ALLOC_MUTEX(SgFunctionParameterTypeList, lock);
   10819             : 
   10820             : #if USE_CPP_NEW_DELETE_OPERATORS
   10821             :     ROSE_FREE(Pointer);
   10822             : #else
   10823             : #if ROSE_PEDANTIC_ALLOC
   10824             :     ROSE_ASSERT(Size == sizeof(SgFunctionParameterTypeList));
   10825             : #else
   10826     2332860 :     if (Size != sizeof(SgFunctionParameterTypeList)) {
   10827           0 :       ROSE_FREE(Pointer);
   10828           0 :       ALLOC_MUTEX(SgFunctionParameterTypeList, unlock);
   10829             :       return;
   10830             :     }
   10831             : #endif
   10832             : 
   10833     2332860 :     SgFunctionParameterTypeList * object = (SgFunctionParameterTypeList*) Pointer;
   10834     2332860 :     ROSE_ASSERT(object != nullptr);
   10835             : 
   10836             : #if ROSE_ALLOC_TRACE == 2
   10837             : //  printf("SgFunctionParameterTypeList::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgFunctionParameterTypeList::next_node);
   10838             :     printf("SgFunctionParameterTypeList::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgFunctionParameterTypeList::next_node);
   10839             : #endif
   10840             : 
   10841             : #if ROSE_PEDANTIC_ALLOC
   10842             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   10843             : #endif
   10844             : 
   10845             : #if ROSE_ALLOC_MEMSET == 1
   10846             : #elif ROSE_ALLOC_MEMSET == 2
   10847             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgFunctionParameterTypeList) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   10848             : #elif ROSE_ALLOC_MEMSET == 3
   10849             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgFunctionParameterTypeList) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   10850             : #endif
   10851             : 
   10852             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   10853             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   10854             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   10855             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   10856             : #else
   10857     2332860 :     object->p_freepointer = SgFunctionParameterTypeList::next_node;
   10858     2332860 :     SgFunctionParameterTypeList::next_node = object;
   10859             : #endif
   10860             : 
   10861             : #if ROSE_ALLOC_TRACE == 2
   10862             : //  printf("SgFunctionParameterTypeList::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgFunctionParameterTypeList::next_node);
   10863             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   10864             :     Rose::MemPool::snapshot(oss.str());
   10865             :     alloc_trace_cnt++;
   10866             : #endif
   10867             : 
   10868             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   10869             : 
   10870     2332860 :     ALLOC_MUTEX(SgFunctionParameterTypeList, unlock);
   10871             : }
   10872             : 
   10873             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   10874             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   10875             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   10876             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   10877             : // Also, note comment below from Robb (copied from the Common.code file).
   10878             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   10879             : //
   10880             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   10881             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   10882             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   10883             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   10884             : #if 0
   10885             : void SgFunctionParameterTypeList::operator delete(void* pointer) { SgFunctionParameterTypeList::operator delete (pointer, sizeof(SgFunctionParameterTypeList)); };
   10886             : #endif
   10887             : /* #line 10888 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   10888             : 
   10889             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   10890             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   10891             : // obviously imply C++.
   10892             : 
   10893             : // This implements the support within ROSE for memory pools.  Memory pools
   10894             : // support the most condensed usage of memory within the construction of
   10895             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   10896             : // by a new operator written for each class.
   10897             : 
   10898             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   10899             :     // User wants multi-thread support and POSIX threads are available.
   10900             : #   include <pthread.h>
   10901             :     static pthread_mutex_t SgQualifiedName_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   10902             : #else
   10903             :      // Cause synchronization to be skipped.
   10904             : #    ifndef ALLOC_MUTEX
   10905             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   10906             : #    endif
   10907             : #    ifdef _REENTRANT
   10908             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   10909             : #       ifdef _MSC_VER
   10910             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   10911             : #       else
   10912             : #           warning "POSIX threads are not available; synchronization being skipped"
   10913             : #       endif
   10914             : #    endif
   10915             : #endif
   10916             : 
   10917             : #ifndef ROSE_ALLOC_TRACE
   10918             : #  define ROSE_ALLOC_TRACE 0
   10919             : #endif
   10920             : 
   10921             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   10922             : #define ROSE_ALLOC_TRACE_CNT
   10923             : #include "memory-pool-snapshot.h"
   10924             : unsigned long alloc_trace_cnt = 0;
   10925             : #endif
   10926             : 
   10927             : #if ROSE_ALLOC_TRACE
   10928             : const unsigned SgQualifiedName::pool_size = 5;
   10929             : #else
   10930             : const unsigned SgQualifiedName::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   10931             : #endif
   10932             : 
   10933             : #ifndef ROSE_ALLOC_MEMSET
   10934             : #  define ROSE_ALLOC_MEMSET 0
   10935             : #endif
   10936             : 
   10937             : #ifndef ROSE_PEDANTIC_ALLOC
   10938             : #  define ROSE_PEDANTIC_ALLOC 0
   10939             : #endif
   10940             : 
   10941             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   10942             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   10943             : #endif
   10944             : 
   10945             : #if !defined(SGNODE__ALL_POOLS)
   10946             : #define SGNODE__ALL_POOLS
   10947             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   10948             : #endif
   10949             : 
   10950             : SgQualifiedName* SgQualifiedName::next_node = nullptr;
   10951             : std::vector<unsigned char*> SgQualifiedName::pools;
   10952             : 
   10953             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   10954             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   10955             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   10956             : // around this macro definition rather than each use).
   10957             : #ifndef ALLOC_MUTEX
   10958             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   10959             :         do {                                                                     \
   10960             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   10961             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   10962             :                 abort();                                                         \
   10963             :             }                                                                    \
   10964             :         } while (0);
   10965             : #endif
   10966             : 
   10967             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   10968             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   10969             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   10970             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   10971             : 
   10972             : /*! \brief New operator for SgQualifiedName.
   10973             : 
   10974             :    This new operator implements memory pools to provide most efficent 
   10975             :    use of the heap within construction of large ASTs.
   10976             : 
   10977             : \internal The new and delete operators use the lower level C malloc/free
   10978             :    function calls for performance and to make sure that mixing of malloc/free
   10979             :    and new/delete by the used can be caught more readily.  This may change
   10980             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   10981             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   10982             :    deallocate memory allocated using ROSE_MALLOC.
   10983             : */
   10984           0 : void *SgQualifiedName::operator new ( size_t Size )
   10985             : {
   10986             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   10987             :      * returning or throwing an exception. */
   10988           0 :     ALLOC_MUTEX(SgQualifiedName, lock);
   10989             : 
   10990             : #if ROSE_ALLOC_TRACE == 2
   10991             : //    printf("SgQualifiedName::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgQualifiedName::next_node);
   10992             : #endif
   10993             : 
   10994             : #if USE_CPP_NEW_DELETE_OPERATORS
   10995             :     void *mem = ROSE_MALLOC(Size);
   10996             :     ALLOC_MUTEX(SgQualifiedName, unlock);
   10997             :     return mem;
   10998             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   10999             : #if ROSE_PEDANTIC_ALLOC
   11000             :     ROSE_ASSERT(Size == sizeof(SgQualifiedName));
   11001             : #else
   11002           0 :     if (Size != sizeof(SgQualifiedName)) {
   11003           0 :       void * object = ROSE_MALLOC(Size);
   11004           0 :       ALLOC_MUTEX(SgQualifiedName, unlock);
   11005             :       return object;
   11006             :     }
   11007             : #endif
   11008             : 
   11009           0 :     if (SgQualifiedName::next_node == nullptr) {
   11010           0 :         SgQualifiedName * alloc = (SgQualifiedName*) ROSE_MALLOC ( SgQualifiedName::pool_size * sizeof(SgQualifiedName) );
   11011           0 :         ROSE_ASSERT(alloc != nullptr);
   11012             : 
   11013             : #if ROSE_ALLOC_TRACE == 2
   11014             : //        printf("SgQualifiedName::alloc\n  block[%zi] = [ %p , %p [\n", SgQualifiedName::pools.size(), alloc, alloc + SgQualifiedName::pool_size);
   11015             : #endif
   11016             : 
   11017             : #if ROSE_ALLOC_MEMSET == 1
   11018             : #elif ROSE_ALLOC_MEMSET == 2
   11019             :         memset(alloc, 0x00, SgQualifiedName::pool_size * sizeof(SgQualifiedName));
   11020             : #elif ROSE_ALLOC_MEMSET == 3
   11021             :         memset(alloc, 0xAA, SgQualifiedName::pool_size * sizeof(SgQualifiedName));
   11022             : #endif
   11023           0 :         for (unsigned i=0; i < SgQualifiedName::pool_size-1; i++) {
   11024           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
   11025             :         }
   11026           0 :         alloc[SgQualifiedName::pool_size-1].p_freepointer = nullptr;
   11027             : 
   11028           0 :         SgQualifiedName::pools.push_back ( (unsigned char *) alloc );
   11029           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgQualifiedName::pool_size * sizeof(SgQualifiedName), V_SgQualifiedName ) );
   11030           0 :         SgQualifiedName::next_node = alloc;
   11031             :     }
   11032           0 :     ROSE_ASSERT(SgQualifiedName::next_node != nullptr);
   11033             : 
   11034           0 :     SgQualifiedName * object = SgQualifiedName::next_node;
   11035           0 :     SgQualifiedName::next_node = (SgQualifiedName*)(object->p_freepointer);
   11036             : 
   11037             : #if ROSE_ALLOC_TRACE == 2
   11038             :     printf("SgQualifiedName::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgQualifiedName::next_node);
   11039             : #endif
   11040             : 
   11041           0 :     SgNode * fp = object->p_freepointer;
   11042             : #if ROSE_ALLOC_MEMSET == 1
   11043             : #elif ROSE_ALLOC_MEMSET == 2
   11044             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgQualifiedName) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   11045             : #elif ROSE_ALLOC_MEMSET == 3
   11046             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgQualifiedName) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   11047             : #endif
   11048           0 :     object->p_freepointer = fp;
   11049             : 
   11050             : #if ROSE_ALLOC_TRACE == 2
   11051             : //    printf("SgQualifiedName::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgQualifiedName::next_node);
   11052             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   11053             :     Rose::MemPool::snapshot(oss.str());
   11054             :     alloc_trace_cnt++;
   11055             : #endif
   11056             : 
   11057           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   11058             : 
   11059           0 :     ALLOC_MUTEX(SgQualifiedName, unlock);
   11060             : 
   11061             :     return object;
   11062             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   11063             : }
   11064             : 
   11065             : 
   11066             : 
   11067             : /*! \brief Delete operator for SgQualifiedName.
   11068             : 
   11069             :    This delete operator implements deallocation using memory pools to 
   11070             :    provide most efficent use of the heap within construction of large ASTs.
   11071             : 
   11072             : \internal The new and delete operators use the lower level C malloc/free
   11073             :    function calls for performance and to make sure that mixing of malloc/free
   11074             :    and new/delete by the used can be caught more readily.  This may change
   11075             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   11076             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   11077             :    deallocate memory allocated using ROSE_MALLOC.
   11078             : */
   11079           0 : void SgQualifiedName::operator delete(void *Pointer, size_t Size)
   11080             : {
   11081             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   11082             :      * or throwing an exception. */
   11083           0 :     ALLOC_MUTEX(SgQualifiedName, lock);
   11084             : 
   11085             : #if USE_CPP_NEW_DELETE_OPERATORS
   11086             :     ROSE_FREE(Pointer);
   11087             : #else
   11088             : #if ROSE_PEDANTIC_ALLOC
   11089             :     ROSE_ASSERT(Size == sizeof(SgQualifiedName));
   11090             : #else
   11091           0 :     if (Size != sizeof(SgQualifiedName)) {
   11092           0 :       ROSE_FREE(Pointer);
   11093           0 :       ALLOC_MUTEX(SgQualifiedName, unlock);
   11094             :       return;
   11095             :     }
   11096             : #endif
   11097             : 
   11098           0 :     SgQualifiedName * object = (SgQualifiedName*) Pointer;
   11099           0 :     ROSE_ASSERT(object != nullptr);
   11100             : 
   11101             : #if ROSE_ALLOC_TRACE == 2
   11102             : //  printf("SgQualifiedName::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgQualifiedName::next_node);
   11103             :     printf("SgQualifiedName::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgQualifiedName::next_node);
   11104             : #endif
   11105             : 
   11106             : #if ROSE_PEDANTIC_ALLOC
   11107             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   11108             : #endif
   11109             : 
   11110             : #if ROSE_ALLOC_MEMSET == 1
   11111             : #elif ROSE_ALLOC_MEMSET == 2
   11112             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgQualifiedName) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   11113             : #elif ROSE_ALLOC_MEMSET == 3
   11114             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgQualifiedName) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   11115             : #endif
   11116             : 
   11117             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   11118             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   11119             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   11120             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   11121             : #else
   11122           0 :     object->p_freepointer = SgQualifiedName::next_node;
   11123           0 :     SgQualifiedName::next_node = object;
   11124             : #endif
   11125             : 
   11126             : #if ROSE_ALLOC_TRACE == 2
   11127             : //  printf("SgQualifiedName::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgQualifiedName::next_node);
   11128             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   11129             :     Rose::MemPool::snapshot(oss.str());
   11130             :     alloc_trace_cnt++;
   11131             : #endif
   11132             : 
   11133             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   11134             : 
   11135           0 :     ALLOC_MUTEX(SgQualifiedName, unlock);
   11136             : }
   11137             : 
   11138             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   11139             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   11140             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   11141             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   11142             : // Also, note comment below from Robb (copied from the Common.code file).
   11143             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   11144             : //
   11145             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   11146             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   11147             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   11148             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   11149             : #if 0
   11150             : void SgQualifiedName::operator delete(void* pointer) { SgQualifiedName::operator delete (pointer, sizeof(SgQualifiedName)); };
   11151             : #endif
   11152             : /* #line 11153 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   11153             : 
   11154             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   11155             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   11156             : // obviously imply C++.
   11157             : 
   11158             : // This implements the support within ROSE for memory pools.  Memory pools
   11159             : // support the most condensed usage of memory within the construction of
   11160             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   11161             : // by a new operator written for each class.
   11162             : 
   11163             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   11164             :     // User wants multi-thread support and POSIX threads are available.
   11165             : #   include <pthread.h>
   11166             :     static pthread_mutex_t SgTemplateArgumentList_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   11167             : #else
   11168             :      // Cause synchronization to be skipped.
   11169             : #    ifndef ALLOC_MUTEX
   11170             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   11171             : #    endif
   11172             : #    ifdef _REENTRANT
   11173             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   11174             : #       ifdef _MSC_VER
   11175             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   11176             : #       else
   11177             : #           warning "POSIX threads are not available; synchronization being skipped"
   11178             : #       endif
   11179             : #    endif
   11180             : #endif
   11181             : 
   11182             : #ifndef ROSE_ALLOC_TRACE
   11183             : #  define ROSE_ALLOC_TRACE 0
   11184             : #endif
   11185             : 
   11186             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   11187             : #define ROSE_ALLOC_TRACE_CNT
   11188             : #include "memory-pool-snapshot.h"
   11189             : unsigned long alloc_trace_cnt = 0;
   11190             : #endif
   11191             : 
   11192             : #if ROSE_ALLOC_TRACE
   11193             : const unsigned SgTemplateArgumentList::pool_size = 5;
   11194             : #else
   11195             : const unsigned SgTemplateArgumentList::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   11196             : #endif
   11197             : 
   11198             : #ifndef ROSE_ALLOC_MEMSET
   11199             : #  define ROSE_ALLOC_MEMSET 0
   11200             : #endif
   11201             : 
   11202             : #ifndef ROSE_PEDANTIC_ALLOC
   11203             : #  define ROSE_PEDANTIC_ALLOC 0
   11204             : #endif
   11205             : 
   11206             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   11207             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   11208             : #endif
   11209             : 
   11210             : #if !defined(SGNODE__ALL_POOLS)
   11211             : #define SGNODE__ALL_POOLS
   11212             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   11213             : #endif
   11214             : 
   11215             : SgTemplateArgumentList* SgTemplateArgumentList::next_node = nullptr;
   11216             : std::vector<unsigned char*> SgTemplateArgumentList::pools;
   11217             : 
   11218             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   11219             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   11220             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   11221             : // around this macro definition rather than each use).
   11222             : #ifndef ALLOC_MUTEX
   11223             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   11224             :         do {                                                                     \
   11225             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   11226             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   11227             :                 abort();                                                         \
   11228             :             }                                                                    \
   11229             :         } while (0);
   11230             : #endif
   11231             : 
   11232             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   11233             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   11234             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   11235             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   11236             : 
   11237             : /*! \brief New operator for SgTemplateArgumentList.
   11238             : 
   11239             :    This new operator implements memory pools to provide most efficent 
   11240             :    use of the heap within construction of large ASTs.
   11241             : 
   11242             : \internal The new and delete operators use the lower level C malloc/free
   11243             :    function calls for performance and to make sure that mixing of malloc/free
   11244             :    and new/delete by the used can be caught more readily.  This may change
   11245             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   11246             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   11247             :    deallocate memory allocated using ROSE_MALLOC.
   11248             : */
   11249           0 : void *SgTemplateArgumentList::operator new ( size_t Size )
   11250             : {
   11251             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   11252             :      * returning or throwing an exception. */
   11253           0 :     ALLOC_MUTEX(SgTemplateArgumentList, lock);
   11254             : 
   11255             : #if ROSE_ALLOC_TRACE == 2
   11256             : //    printf("SgTemplateArgumentList::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgTemplateArgumentList::next_node);
   11257             : #endif
   11258             : 
   11259             : #if USE_CPP_NEW_DELETE_OPERATORS
   11260             :     void *mem = ROSE_MALLOC(Size);
   11261             :     ALLOC_MUTEX(SgTemplateArgumentList, unlock);
   11262             :     return mem;
   11263             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   11264             : #if ROSE_PEDANTIC_ALLOC
   11265             :     ROSE_ASSERT(Size == sizeof(SgTemplateArgumentList));
   11266             : #else
   11267           0 :     if (Size != sizeof(SgTemplateArgumentList)) {
   11268           0 :       void * object = ROSE_MALLOC(Size);
   11269           0 :       ALLOC_MUTEX(SgTemplateArgumentList, unlock);
   11270             :       return object;
   11271             :     }
   11272             : #endif
   11273             : 
   11274           0 :     if (SgTemplateArgumentList::next_node == nullptr) {
   11275           0 :         SgTemplateArgumentList * alloc = (SgTemplateArgumentList*) ROSE_MALLOC ( SgTemplateArgumentList::pool_size * sizeof(SgTemplateArgumentList) );
   11276           0 :         ROSE_ASSERT(alloc != nullptr);
   11277             : 
   11278             : #if ROSE_ALLOC_TRACE == 2
   11279             : //        printf("SgTemplateArgumentList::alloc\n  block[%zi] = [ %p , %p [\n", SgTemplateArgumentList::pools.size(), alloc, alloc + SgTemplateArgumentList::pool_size);
   11280             : #endif
   11281             : 
   11282             : #if ROSE_ALLOC_MEMSET == 1
   11283             : #elif ROSE_ALLOC_MEMSET == 2
   11284             :         memset(alloc, 0x00, SgTemplateArgumentList::pool_size * sizeof(SgTemplateArgumentList));
   11285             : #elif ROSE_ALLOC_MEMSET == 3
   11286             :         memset(alloc, 0xAA, SgTemplateArgumentList::pool_size * sizeof(SgTemplateArgumentList));
   11287             : #endif
   11288           0 :         for (unsigned i=0; i < SgTemplateArgumentList::pool_size-1; i++) {
   11289           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
   11290             :         }
   11291           0 :         alloc[SgTemplateArgumentList::pool_size-1].p_freepointer = nullptr;
   11292             : 
   11293           0 :         SgTemplateArgumentList::pools.push_back ( (unsigned char *) alloc );
   11294           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgTemplateArgumentList::pool_size * sizeof(SgTemplateArgumentList), V_SgTemplateArgumentList ) );
   11295           0 :         SgTemplateArgumentList::next_node = alloc;
   11296             :     }
   11297           0 :     ROSE_ASSERT(SgTemplateArgumentList::next_node != nullptr);
   11298             : 
   11299           0 :     SgTemplateArgumentList * object = SgTemplateArgumentList::next_node;
   11300           0 :     SgTemplateArgumentList::next_node = (SgTemplateArgumentList*)(object->p_freepointer);
   11301             : 
   11302             : #if ROSE_ALLOC_TRACE == 2
   11303             :     printf("SgTemplateArgumentList::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTemplateArgumentList::next_node);
   11304             : #endif
   11305             : 
   11306           0 :     SgNode * fp = object->p_freepointer;
   11307             : #if ROSE_ALLOC_MEMSET == 1
   11308             : #elif ROSE_ALLOC_MEMSET == 2
   11309             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgTemplateArgumentList) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   11310             : #elif ROSE_ALLOC_MEMSET == 3
   11311             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgTemplateArgumentList) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   11312             : #endif
   11313           0 :     object->p_freepointer = fp;
   11314             : 
   11315             : #if ROSE_ALLOC_TRACE == 2
   11316             : //    printf("SgTemplateArgumentList::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTemplateArgumentList::next_node);
   11317             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   11318             :     Rose::MemPool::snapshot(oss.str());
   11319             :     alloc_trace_cnt++;
   11320             : #endif
   11321             : 
   11322           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   11323             : 
   11324           0 :     ALLOC_MUTEX(SgTemplateArgumentList, unlock);
   11325             : 
   11326             :     return object;
   11327             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   11328             : }
   11329             : 
   11330             : 
   11331             : 
   11332             : /*! \brief Delete operator for SgTemplateArgumentList.
   11333             : 
   11334             :    This delete operator implements deallocation using memory pools to 
   11335             :    provide most efficent use of the heap within construction of large ASTs.
   11336             : 
   11337             : \internal The new and delete operators use the lower level C malloc/free
   11338             :    function calls for performance and to make sure that mixing of malloc/free
   11339             :    and new/delete by the used can be caught more readily.  This may change
   11340             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   11341             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   11342             :    deallocate memory allocated using ROSE_MALLOC.
   11343             : */
   11344           0 : void SgTemplateArgumentList::operator delete(void *Pointer, size_t Size)
   11345             : {
   11346             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   11347             :      * or throwing an exception. */
   11348           0 :     ALLOC_MUTEX(SgTemplateArgumentList, lock);
   11349             : 
   11350             : #if USE_CPP_NEW_DELETE_OPERATORS
   11351             :     ROSE_FREE(Pointer);
   11352             : #else
   11353             : #if ROSE_PEDANTIC_ALLOC
   11354             :     ROSE_ASSERT(Size == sizeof(SgTemplateArgumentList));
   11355             : #else
   11356           0 :     if (Size != sizeof(SgTemplateArgumentList)) {
   11357           0 :       ROSE_FREE(Pointer);
   11358           0 :       ALLOC_MUTEX(SgTemplateArgumentList, unlock);
   11359             :       return;
   11360             :     }
   11361             : #endif
   11362             : 
   11363           0 :     SgTemplateArgumentList * object = (SgTemplateArgumentList*) Pointer;
   11364           0 :     ROSE_ASSERT(object != nullptr);
   11365             : 
   11366             : #if ROSE_ALLOC_TRACE == 2
   11367             : //  printf("SgTemplateArgumentList::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTemplateArgumentList::next_node);
   11368             :     printf("SgTemplateArgumentList::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTemplateArgumentList::next_node);
   11369             : #endif
   11370             : 
   11371             : #if ROSE_PEDANTIC_ALLOC
   11372             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   11373             : #endif
   11374             : 
   11375             : #if ROSE_ALLOC_MEMSET == 1
   11376             : #elif ROSE_ALLOC_MEMSET == 2
   11377             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgTemplateArgumentList) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   11378             : #elif ROSE_ALLOC_MEMSET == 3
   11379             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgTemplateArgumentList) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   11380             : #endif
   11381             : 
   11382             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   11383             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   11384             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   11385             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   11386             : #else
   11387           0 :     object->p_freepointer = SgTemplateArgumentList::next_node;
   11388           0 :     SgTemplateArgumentList::next_node = object;
   11389             : #endif
   11390             : 
   11391             : #if ROSE_ALLOC_TRACE == 2
   11392             : //  printf("SgTemplateArgumentList::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTemplateArgumentList::next_node);
   11393             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   11394             :     Rose::MemPool::snapshot(oss.str());
   11395             :     alloc_trace_cnt++;
   11396             : #endif
   11397             : 
   11398             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   11399             : 
   11400           0 :     ALLOC_MUTEX(SgTemplateArgumentList, unlock);
   11401             : }
   11402             : 
   11403             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   11404             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   11405             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   11406             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   11407             : // Also, note comment below from Robb (copied from the Common.code file).
   11408             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   11409             : //
   11410             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   11411             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   11412             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   11413             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   11414             : #if 0
   11415             : void SgTemplateArgumentList::operator delete(void* pointer) { SgTemplateArgumentList::operator delete (pointer, sizeof(SgTemplateArgumentList)); };
   11416             : #endif
   11417             : /* #line 11418 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   11418             : 
   11419             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   11420             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   11421             : // obviously imply C++.
   11422             : 
   11423             : // This implements the support within ROSE for memory pools.  Memory pools
   11424             : // support the most condensed usage of memory within the construction of
   11425             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   11426             : // by a new operator written for each class.
   11427             : 
   11428             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   11429             :     // User wants multi-thread support and POSIX threads are available.
   11430             : #   include <pthread.h>
   11431             :     static pthread_mutex_t SgTemplateParameterList_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   11432             : #else
   11433             :      // Cause synchronization to be skipped.
   11434             : #    ifndef ALLOC_MUTEX
   11435             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   11436             : #    endif
   11437             : #    ifdef _REENTRANT
   11438             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   11439             : #       ifdef _MSC_VER
   11440             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   11441             : #       else
   11442             : #           warning "POSIX threads are not available; synchronization being skipped"
   11443             : #       endif
   11444             : #    endif
   11445             : #endif
   11446             : 
   11447             : #ifndef ROSE_ALLOC_TRACE
   11448             : #  define ROSE_ALLOC_TRACE 0
   11449             : #endif
   11450             : 
   11451             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   11452             : #define ROSE_ALLOC_TRACE_CNT
   11453             : #include "memory-pool-snapshot.h"
   11454             : unsigned long alloc_trace_cnt = 0;
   11455             : #endif
   11456             : 
   11457             : #if ROSE_ALLOC_TRACE
   11458             : const unsigned SgTemplateParameterList::pool_size = 5;
   11459             : #else
   11460             : const unsigned SgTemplateParameterList::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   11461             : #endif
   11462             : 
   11463             : #ifndef ROSE_ALLOC_MEMSET
   11464             : #  define ROSE_ALLOC_MEMSET 0
   11465             : #endif
   11466             : 
   11467             : #ifndef ROSE_PEDANTIC_ALLOC
   11468             : #  define ROSE_PEDANTIC_ALLOC 0
   11469             : #endif
   11470             : 
   11471             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   11472             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   11473             : #endif
   11474             : 
   11475             : #if !defined(SGNODE__ALL_POOLS)
   11476             : #define SGNODE__ALL_POOLS
   11477             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   11478             : #endif
   11479             : 
   11480             : SgTemplateParameterList* SgTemplateParameterList::next_node = nullptr;
   11481             : std::vector<unsigned char*> SgTemplateParameterList::pools;
   11482             : 
   11483             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   11484             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   11485             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   11486             : // around this macro definition rather than each use).
   11487             : #ifndef ALLOC_MUTEX
   11488             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   11489             :         do {                                                                     \
   11490             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   11491             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   11492             :                 abort();                                                         \
   11493             :             }                                                                    \
   11494             :         } while (0);
   11495             : #endif
   11496             : 
   11497             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   11498             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   11499             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   11500             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   11501             : 
   11502             : /*! \brief New operator for SgTemplateParameterList.
   11503             : 
   11504             :    This new operator implements memory pools to provide most efficent 
   11505             :    use of the heap within construction of large ASTs.
   11506             : 
   11507             : \internal The new and delete operators use the lower level C malloc/free
   11508             :    function calls for performance and to make sure that mixing of malloc/free
   11509             :    and new/delete by the used can be caught more readily.  This may change
   11510             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   11511             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   11512             :    deallocate memory allocated using ROSE_MALLOC.
   11513             : */
   11514           0 : void *SgTemplateParameterList::operator new ( size_t Size )
   11515             : {
   11516             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   11517             :      * returning or throwing an exception. */
   11518           0 :     ALLOC_MUTEX(SgTemplateParameterList, lock);
   11519             : 
   11520             : #if ROSE_ALLOC_TRACE == 2
   11521             : //    printf("SgTemplateParameterList::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgTemplateParameterList::next_node);
   11522             : #endif
   11523             : 
   11524             : #if USE_CPP_NEW_DELETE_OPERATORS
   11525             :     void *mem = ROSE_MALLOC(Size);
   11526             :     ALLOC_MUTEX(SgTemplateParameterList, unlock);
   11527             :     return mem;
   11528             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   11529             : #if ROSE_PEDANTIC_ALLOC
   11530             :     ROSE_ASSERT(Size == sizeof(SgTemplateParameterList));
   11531             : #else
   11532           0 :     if (Size != sizeof(SgTemplateParameterList)) {
   11533           0 :       void * object = ROSE_MALLOC(Size);
   11534           0 :       ALLOC_MUTEX(SgTemplateParameterList, unlock);
   11535             :       return object;
   11536             :     }
   11537             : #endif
   11538             : 
   11539           0 :     if (SgTemplateParameterList::next_node == nullptr) {
   11540           0 :         SgTemplateParameterList * alloc = (SgTemplateParameterList*) ROSE_MALLOC ( SgTemplateParameterList::pool_size * sizeof(SgTemplateParameterList) );
   11541           0 :         ROSE_ASSERT(alloc != nullptr);
   11542             : 
   11543             : #if ROSE_ALLOC_TRACE == 2
   11544             : //        printf("SgTemplateParameterList::alloc\n  block[%zi] = [ %p , %p [\n", SgTemplateParameterList::pools.size(), alloc, alloc + SgTemplateParameterList::pool_size);
   11545             : #endif
   11546             : 
   11547             : #if ROSE_ALLOC_MEMSET == 1
   11548             : #elif ROSE_ALLOC_MEMSET == 2
   11549             :         memset(alloc, 0x00, SgTemplateParameterList::pool_size * sizeof(SgTemplateParameterList));
   11550             : #elif ROSE_ALLOC_MEMSET == 3
   11551             :         memset(alloc, 0xAA, SgTemplateParameterList::pool_size * sizeof(SgTemplateParameterList));
   11552             : #endif
   11553           0 :         for (unsigned i=0; i < SgTemplateParameterList::pool_size-1; i++) {
   11554           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
   11555             :         }
   11556           0 :         alloc[SgTemplateParameterList::pool_size-1].p_freepointer = nullptr;
   11557             : 
   11558           0 :         SgTemplateParameterList::pools.push_back ( (unsigned char *) alloc );
   11559           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgTemplateParameterList::pool_size * sizeof(SgTemplateParameterList), V_SgTemplateParameterList ) );
   11560           0 :         SgTemplateParameterList::next_node = alloc;
   11561             :     }
   11562           0 :     ROSE_ASSERT(SgTemplateParameterList::next_node != nullptr);
   11563             : 
   11564           0 :     SgTemplateParameterList * object = SgTemplateParameterList::next_node;
   11565           0 :     SgTemplateParameterList::next_node = (SgTemplateParameterList*)(object->p_freepointer);
   11566             : 
   11567             : #if ROSE_ALLOC_TRACE == 2
   11568             :     printf("SgTemplateParameterList::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTemplateParameterList::next_node);
   11569             : #endif
   11570             : 
   11571           0 :     SgNode * fp = object->p_freepointer;
   11572             : #if ROSE_ALLOC_MEMSET == 1
   11573             : #elif ROSE_ALLOC_MEMSET == 2
   11574             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgTemplateParameterList) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   11575             : #elif ROSE_ALLOC_MEMSET == 3
   11576             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgTemplateParameterList) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   11577             : #endif
   11578           0 :     object->p_freepointer = fp;
   11579             : 
   11580             : #if ROSE_ALLOC_TRACE == 2
   11581             : //    printf("SgTemplateParameterList::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTemplateParameterList::next_node);
   11582             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   11583             :     Rose::MemPool::snapshot(oss.str());
   11584             :     alloc_trace_cnt++;
   11585             : #endif
   11586             : 
   11587           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   11588             : 
   11589           0 :     ALLOC_MUTEX(SgTemplateParameterList, unlock);
   11590             : 
   11591             :     return object;
   11592             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   11593             : }
   11594             : 
   11595             : 
   11596             : 
   11597             : /*! \brief Delete operator for SgTemplateParameterList.
   11598             : 
   11599             :    This delete operator implements deallocation using memory pools to 
   11600             :    provide most efficent use of the heap within construction of large ASTs.
   11601             : 
   11602             : \internal The new and delete operators use the lower level C malloc/free
   11603             :    function calls for performance and to make sure that mixing of malloc/free
   11604             :    and new/delete by the used can be caught more readily.  This may change
   11605             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   11606             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   11607             :    deallocate memory allocated using ROSE_MALLOC.
   11608             : */
   11609           0 : void SgTemplateParameterList::operator delete(void *Pointer, size_t Size)
   11610             : {
   11611             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   11612             :      * or throwing an exception. */
   11613           0 :     ALLOC_MUTEX(SgTemplateParameterList, lock);
   11614             : 
   11615             : #if USE_CPP_NEW_DELETE_OPERATORS
   11616             :     ROSE_FREE(Pointer);
   11617             : #else
   11618             : #if ROSE_PEDANTIC_ALLOC
   11619             :     ROSE_ASSERT(Size == sizeof(SgTemplateParameterList));
   11620             : #else
   11621           0 :     if (Size != sizeof(SgTemplateParameterList)) {
   11622           0 :       ROSE_FREE(Pointer);
   11623           0 :       ALLOC_MUTEX(SgTemplateParameterList, unlock);
   11624             :       return;
   11625             :     }
   11626             : #endif
   11627             : 
   11628           0 :     SgTemplateParameterList * object = (SgTemplateParameterList*) Pointer;
   11629           0 :     ROSE_ASSERT(object != nullptr);
   11630             : 
   11631             : #if ROSE_ALLOC_TRACE == 2
   11632             : //  printf("SgTemplateParameterList::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTemplateParameterList::next_node);
   11633             :     printf("SgTemplateParameterList::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTemplateParameterList::next_node);
   11634             : #endif
   11635             : 
   11636             : #if ROSE_PEDANTIC_ALLOC
   11637             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   11638             : #endif
   11639             : 
   11640             : #if ROSE_ALLOC_MEMSET == 1
   11641             : #elif ROSE_ALLOC_MEMSET == 2
   11642             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgTemplateParameterList) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   11643             : #elif ROSE_ALLOC_MEMSET == 3
   11644             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgTemplateParameterList) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   11645             : #endif
   11646             : 
   11647             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   11648             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   11649             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   11650             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   11651             : #else
   11652           0 :     object->p_freepointer = SgTemplateParameterList::next_node;
   11653           0 :     SgTemplateParameterList::next_node = object;
   11654             : #endif
   11655             : 
   11656             : #if ROSE_ALLOC_TRACE == 2
   11657             : //  printf("SgTemplateParameterList::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTemplateParameterList::next_node);
   11658             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   11659             :     Rose::MemPool::snapshot(oss.str());
   11660             :     alloc_trace_cnt++;
   11661             : #endif
   11662             : 
   11663             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   11664             : 
   11665           0 :     ALLOC_MUTEX(SgTemplateParameterList, unlock);
   11666             : }
   11667             : 
   11668             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   11669             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   11670             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   11671             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   11672             : // Also, note comment below from Robb (copied from the Common.code file).
   11673             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   11674             : //
   11675             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   11676             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   11677             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   11678             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   11679             : #if 0
   11680             : void SgTemplateParameterList::operator delete(void* pointer) { SgTemplateParameterList::operator delete (pointer, sizeof(SgTemplateParameterList)); };
   11681             : #endif
   11682             : /* #line 11683 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   11683             : 
   11684             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   11685             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   11686             : // obviously imply C++.
   11687             : 
   11688             : // This implements the support within ROSE for memory pools.  Memory pools
   11689             : // support the most condensed usage of memory within the construction of
   11690             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   11691             : // by a new operator written for each class.
   11692             : 
   11693             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   11694             :     // User wants multi-thread support and POSIX threads are available.
   11695             : #   include <pthread.h>
   11696             :     static pthread_mutex_t SgGraph_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   11697             : #else
   11698             :      // Cause synchronization to be skipped.
   11699             : #    ifndef ALLOC_MUTEX
   11700             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   11701             : #    endif
   11702             : #    ifdef _REENTRANT
   11703             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   11704             : #       ifdef _MSC_VER
   11705             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   11706             : #       else
   11707             : #           warning "POSIX threads are not available; synchronization being skipped"
   11708             : #       endif
   11709             : #    endif
   11710             : #endif
   11711             : 
   11712             : #ifndef ROSE_ALLOC_TRACE
   11713             : #  define ROSE_ALLOC_TRACE 0
   11714             : #endif
   11715             : 
   11716             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   11717             : #define ROSE_ALLOC_TRACE_CNT
   11718             : #include "memory-pool-snapshot.h"
   11719             : unsigned long alloc_trace_cnt = 0;
   11720             : #endif
   11721             : 
   11722             : #if ROSE_ALLOC_TRACE
   11723             : const unsigned SgGraph::pool_size = 5;
   11724             : #else
   11725             : const unsigned SgGraph::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   11726             : #endif
   11727             : 
   11728             : #ifndef ROSE_ALLOC_MEMSET
   11729             : #  define ROSE_ALLOC_MEMSET 0
   11730             : #endif
   11731             : 
   11732             : #ifndef ROSE_PEDANTIC_ALLOC
   11733             : #  define ROSE_PEDANTIC_ALLOC 0
   11734             : #endif
   11735             : 
   11736             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   11737             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   11738             : #endif
   11739             : 
   11740             : #if !defined(SGNODE__ALL_POOLS)
   11741             : #define SGNODE__ALL_POOLS
   11742             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   11743             : #endif
   11744             : 
   11745             : SgGraph* SgGraph::next_node = nullptr;
   11746             : std::vector<unsigned char*> SgGraph::pools;
   11747             : 
   11748             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   11749             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   11750             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   11751             : // around this macro definition rather than each use).
   11752             : #ifndef ALLOC_MUTEX
   11753             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   11754             :         do {                                                                     \
   11755             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   11756             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   11757             :                 abort();                                                         \
   11758             :             }                                                                    \
   11759             :         } while (0);
   11760             : #endif
   11761             : 
   11762             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   11763             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   11764             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   11765             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   11766             : 
   11767             : /*! \brief New operator for SgGraph.
   11768             : 
   11769             :    This new operator implements memory pools to provide most efficent 
   11770             :    use of the heap within construction of large ASTs.
   11771             : 
   11772             : \internal The new and delete operators use the lower level C malloc/free
   11773             :    function calls for performance and to make sure that mixing of malloc/free
   11774             :    and new/delete by the used can be caught more readily.  This may change
   11775             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   11776             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   11777             :    deallocate memory allocated using ROSE_MALLOC.
   11778             : */
   11779           0 : void *SgGraph::operator new ( size_t Size )
   11780             : {
   11781             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   11782             :      * returning or throwing an exception. */
   11783           0 :     ALLOC_MUTEX(SgGraph, lock);
   11784             : 
   11785             : #if ROSE_ALLOC_TRACE == 2
   11786             : //    printf("SgGraph::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgGraph::next_node);
   11787             : #endif
   11788             : 
   11789             : #if USE_CPP_NEW_DELETE_OPERATORS
   11790             :     void *mem = ROSE_MALLOC(Size);
   11791             :     ALLOC_MUTEX(SgGraph, unlock);
   11792             :     return mem;
   11793             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   11794             : #if ROSE_PEDANTIC_ALLOC
   11795             :     ROSE_ASSERT(Size == sizeof(SgGraph));
   11796             : #else
   11797           0 :     if (Size != sizeof(SgGraph)) {
   11798           0 :       void * object = ROSE_MALLOC(Size);
   11799           0 :       ALLOC_MUTEX(SgGraph, unlock);
   11800             :       return object;
   11801             :     }
   11802             : #endif
   11803             : 
   11804           0 :     if (SgGraph::next_node == nullptr) {
   11805           0 :         SgGraph * alloc = (SgGraph*) ROSE_MALLOC ( SgGraph::pool_size * sizeof(SgGraph) );
   11806           0 :         ROSE_ASSERT(alloc != nullptr);
   11807             : 
   11808             : #if ROSE_ALLOC_TRACE == 2
   11809             : //        printf("SgGraph::alloc\n  block[%zi] = [ %p , %p [\n", SgGraph::pools.size(), alloc, alloc + SgGraph::pool_size);
   11810             : #endif
   11811             : 
   11812             : #if ROSE_ALLOC_MEMSET == 1
   11813             : #elif ROSE_ALLOC_MEMSET == 2
   11814             :         memset(alloc, 0x00, SgGraph::pool_size * sizeof(SgGraph));
   11815             : #elif ROSE_ALLOC_MEMSET == 3
   11816             :         memset(alloc, 0xAA, SgGraph::pool_size * sizeof(SgGraph));
   11817             : #endif
   11818           0 :         for (unsigned i=0; i < SgGraph::pool_size-1; i++) {
   11819           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
   11820             :         }
   11821           0 :         alloc[SgGraph::pool_size-1].p_freepointer = nullptr;
   11822             : 
   11823           0 :         SgGraph::pools.push_back ( (unsigned char *) alloc );
   11824           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgGraph::pool_size * sizeof(SgGraph), V_SgGraph ) );
   11825           0 :         SgGraph::next_node = alloc;
   11826             :     }
   11827           0 :     ROSE_ASSERT(SgGraph::next_node != nullptr);
   11828             : 
   11829           0 :     SgGraph * object = SgGraph::next_node;
   11830           0 :     SgGraph::next_node = (SgGraph*)(object->p_freepointer);
   11831             : 
   11832             : #if ROSE_ALLOC_TRACE == 2
   11833             :     printf("SgGraph::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgGraph::next_node);
   11834             : #endif
   11835             : 
   11836           0 :     SgNode * fp = object->p_freepointer;
   11837             : #if ROSE_ALLOC_MEMSET == 1
   11838             : #elif ROSE_ALLOC_MEMSET == 2
   11839             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgGraph) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   11840             : #elif ROSE_ALLOC_MEMSET == 3
   11841             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgGraph) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   11842             : #endif
   11843           0 :     object->p_freepointer = fp;
   11844             : 
   11845             : #if ROSE_ALLOC_TRACE == 2
   11846             : //    printf("SgGraph::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgGraph::next_node);
   11847             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   11848             :     Rose::MemPool::snapshot(oss.str());
   11849             :     alloc_trace_cnt++;
   11850             : #endif
   11851             : 
   11852           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   11853             : 
   11854           0 :     ALLOC_MUTEX(SgGraph, unlock);
   11855             : 
   11856             :     return object;
   11857             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   11858             : }
   11859             : 
   11860             : 
   11861             : 
   11862             : /*! \brief Delete operator for SgGraph.
   11863             : 
   11864             :    This delete operator implements deallocation using memory pools to 
   11865             :    provide most efficent use of the heap within construction of large ASTs.
   11866             : 
   11867             : \internal The new and delete operators use the lower level C malloc/free
   11868             :    function calls for performance and to make sure that mixing of malloc/free
   11869             :    and new/delete by the used can be caught more readily.  This may change
   11870             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   11871             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   11872             :    deallocate memory allocated using ROSE_MALLOC.
   11873             : */
   11874           0 : void SgGraph::operator delete(void *Pointer, size_t Size)
   11875             : {
   11876             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   11877             :      * or throwing an exception. */
   11878           0 :     ALLOC_MUTEX(SgGraph, lock);
   11879             : 
   11880             : #if USE_CPP_NEW_DELETE_OPERATORS
   11881             :     ROSE_FREE(Pointer);
   11882             : #else
   11883             : #if ROSE_PEDANTIC_ALLOC
   11884             :     ROSE_ASSERT(Size == sizeof(SgGraph));
   11885             : #else
   11886           0 :     if (Size != sizeof(SgGraph)) {
   11887           0 :       ROSE_FREE(Pointer);
   11888           0 :       ALLOC_MUTEX(SgGraph, unlock);
   11889             :       return;
   11890             :     }
   11891             : #endif
   11892             : 
   11893           0 :     SgGraph * object = (SgGraph*) Pointer;
   11894           0 :     ROSE_ASSERT(object != nullptr);
   11895             : 
   11896             : #if ROSE_ALLOC_TRACE == 2
   11897             : //  printf("SgGraph::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgGraph::next_node);
   11898             :     printf("SgGraph::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgGraph::next_node);
   11899             : #endif
   11900             : 
   11901             : #if ROSE_PEDANTIC_ALLOC
   11902             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   11903             : #endif
   11904             : 
   11905             : #if ROSE_ALLOC_MEMSET == 1
   11906             : #elif ROSE_ALLOC_MEMSET == 2
   11907             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgGraph) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   11908             : #elif ROSE_ALLOC_MEMSET == 3
   11909             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgGraph) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   11910             : #endif
   11911             : 
   11912             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   11913             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   11914             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   11915             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   11916             : #else
   11917           0 :     object->p_freepointer = SgGraph::next_node;
   11918           0 :     SgGraph::next_node = object;
   11919             : #endif
   11920             : 
   11921             : #if ROSE_ALLOC_TRACE == 2
   11922             : //  printf("SgGraph::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgGraph::next_node);
   11923             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   11924             :     Rose::MemPool::snapshot(oss.str());
   11925             :     alloc_trace_cnt++;
   11926             : #endif
   11927             : 
   11928             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   11929             : 
   11930           0 :     ALLOC_MUTEX(SgGraph, unlock);
   11931             : }
   11932             : 
   11933             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   11934             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   11935             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   11936             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   11937             : // Also, note comment below from Robb (copied from the Common.code file).
   11938             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   11939             : //
   11940             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   11941             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   11942             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   11943             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   11944             : #if 0
   11945             : void SgGraph::operator delete(void* pointer) { SgGraph::operator delete (pointer, sizeof(SgGraph)); };
   11946             : #endif
   11947             : /* #line 11948 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   11948             : 
   11949             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   11950             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   11951             : // obviously imply C++.
   11952             : 
   11953             : // This implements the support within ROSE for memory pools.  Memory pools
   11954             : // support the most condensed usage of memory within the construction of
   11955             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   11956             : // by a new operator written for each class.
   11957             : 
   11958             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   11959             :     // User wants multi-thread support and POSIX threads are available.
   11960             : #   include <pthread.h>
   11961             :     static pthread_mutex_t SgIncidenceDirectedGraph_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   11962             : #else
   11963             :      // Cause synchronization to be skipped.
   11964             : #    ifndef ALLOC_MUTEX
   11965             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   11966             : #    endif
   11967             : #    ifdef _REENTRANT
   11968             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   11969             : #       ifdef _MSC_VER
   11970             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   11971             : #       else
   11972             : #           warning "POSIX threads are not available; synchronization being skipped"
   11973             : #       endif
   11974             : #    endif
   11975             : #endif
   11976             : 
   11977             : #ifndef ROSE_ALLOC_TRACE
   11978             : #  define ROSE_ALLOC_TRACE 0
   11979             : #endif
   11980             : 
   11981             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   11982             : #define ROSE_ALLOC_TRACE_CNT
   11983             : #include "memory-pool-snapshot.h"
   11984             : unsigned long alloc_trace_cnt = 0;
   11985             : #endif
   11986             : 
   11987             : #if ROSE_ALLOC_TRACE
   11988             : const unsigned SgIncidenceDirectedGraph::pool_size = 5;
   11989             : #else
   11990             : const unsigned SgIncidenceDirectedGraph::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   11991             : #endif
   11992             : 
   11993             : #ifndef ROSE_ALLOC_MEMSET
   11994             : #  define ROSE_ALLOC_MEMSET 0
   11995             : #endif
   11996             : 
   11997             : #ifndef ROSE_PEDANTIC_ALLOC
   11998             : #  define ROSE_PEDANTIC_ALLOC 0
   11999             : #endif
   12000             : 
   12001             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   12002             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   12003             : #endif
   12004             : 
   12005             : #if !defined(SGNODE__ALL_POOLS)
   12006             : #define SGNODE__ALL_POOLS
   12007             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   12008             : #endif
   12009             : 
   12010             : SgIncidenceDirectedGraph* SgIncidenceDirectedGraph::next_node = nullptr;
   12011             : std::vector<unsigned char*> SgIncidenceDirectedGraph::pools;
   12012             : 
   12013             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   12014             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   12015             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   12016             : // around this macro definition rather than each use).
   12017             : #ifndef ALLOC_MUTEX
   12018             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   12019             :         do {                                                                     \
   12020             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   12021             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   12022             :                 abort();                                                         \
   12023             :             }                                                                    \
   12024             :         } while (0);
   12025             : #endif
   12026             : 
   12027             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   12028             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   12029             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   12030             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   12031             : 
   12032             : /*! \brief New operator for SgIncidenceDirectedGraph.
   12033             : 
   12034             :    This new operator implements memory pools to provide most efficent 
   12035             :    use of the heap within construction of large ASTs.
   12036             : 
   12037             : \internal The new and delete operators use the lower level C malloc/free
   12038             :    function calls for performance and to make sure that mixing of malloc/free
   12039             :    and new/delete by the used can be caught more readily.  This may change
   12040             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   12041             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   12042             :    deallocate memory allocated using ROSE_MALLOC.
   12043             : */
   12044           0 : void *SgIncidenceDirectedGraph::operator new ( size_t Size )
   12045             : {
   12046             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   12047             :      * returning or throwing an exception. */
   12048           0 :     ALLOC_MUTEX(SgIncidenceDirectedGraph, lock);
   12049             : 
   12050             : #if ROSE_ALLOC_TRACE == 2
   12051             : //    printf("SgIncidenceDirectedGraph::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgIncidenceDirectedGraph::next_node);
   12052             : #endif
   12053             : 
   12054             : #if USE_CPP_NEW_DELETE_OPERATORS
   12055             :     void *mem = ROSE_MALLOC(Size);
   12056             :     ALLOC_MUTEX(SgIncidenceDirectedGraph, unlock);
   12057             :     return mem;
   12058             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   12059             : #if ROSE_PEDANTIC_ALLOC
   12060             :     ROSE_ASSERT(Size == sizeof(SgIncidenceDirectedGraph));
   12061             : #else
   12062           0 :     if (Size != sizeof(SgIncidenceDirectedGraph)) {
   12063           0 :       void * object = ROSE_MALLOC(Size);
   12064           0 :       ALLOC_MUTEX(SgIncidenceDirectedGraph, unlock);
   12065             :       return object;
   12066             :     }
   12067             : #endif
   12068             : 
   12069           0 :     if (SgIncidenceDirectedGraph::next_node == nullptr) {
   12070           0 :         SgIncidenceDirectedGraph * alloc = (SgIncidenceDirectedGraph*) ROSE_MALLOC ( SgIncidenceDirectedGraph::pool_size * sizeof(SgIncidenceDirectedGraph) );
   12071           0 :         ROSE_ASSERT(alloc != nullptr);
   12072             : 
   12073             : #if ROSE_ALLOC_TRACE == 2
   12074             : //        printf("SgIncidenceDirectedGraph::alloc\n  block[%zi] = [ %p , %p [\n", SgIncidenceDirectedGraph::pools.size(), alloc, alloc + SgIncidenceDirectedGraph::pool_size);
   12075             : #endif
   12076             : 
   12077             : #if ROSE_ALLOC_MEMSET == 1
   12078             : #elif ROSE_ALLOC_MEMSET == 2
   12079             :         memset(alloc, 0x00, SgIncidenceDirectedGraph::pool_size * sizeof(SgIncidenceDirectedGraph));
   12080             : #elif ROSE_ALLOC_MEMSET == 3
   12081             :         memset(alloc, 0xAA, SgIncidenceDirectedGraph::pool_size * sizeof(SgIncidenceDirectedGraph));
   12082             : #endif
   12083           0 :         for (unsigned i=0; i < SgIncidenceDirectedGraph::pool_size-1; i++) {
   12084           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
   12085             :         }
   12086           0 :         alloc[SgIncidenceDirectedGraph::pool_size-1].p_freepointer = nullptr;
   12087             : 
   12088           0 :         SgIncidenceDirectedGraph::pools.push_back ( (unsigned char *) alloc );
   12089           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgIncidenceDirectedGraph::pool_size * sizeof(SgIncidenceDirectedGraph), V_SgIncidenceDirectedGraph ) );
   12090           0 :         SgIncidenceDirectedGraph::next_node = alloc;
   12091             :     }
   12092           0 :     ROSE_ASSERT(SgIncidenceDirectedGraph::next_node != nullptr);
   12093             : 
   12094           0 :     SgIncidenceDirectedGraph * object = SgIncidenceDirectedGraph::next_node;
   12095           0 :     SgIncidenceDirectedGraph::next_node = (SgIncidenceDirectedGraph*)(object->p_freepointer);
   12096             : 
   12097             : #if ROSE_ALLOC_TRACE == 2
   12098             :     printf("SgIncidenceDirectedGraph::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgIncidenceDirectedGraph::next_node);
   12099             : #endif
   12100             : 
   12101           0 :     SgNode * fp = object->p_freepointer;
   12102             : #if ROSE_ALLOC_MEMSET == 1
   12103             : #elif ROSE_ALLOC_MEMSET == 2
   12104             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgIncidenceDirectedGraph) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   12105             : #elif ROSE_ALLOC_MEMSET == 3
   12106             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgIncidenceDirectedGraph) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   12107             : #endif
   12108           0 :     object->p_freepointer = fp;
   12109             : 
   12110             : #if ROSE_ALLOC_TRACE == 2
   12111             : //    printf("SgIncidenceDirectedGraph::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgIncidenceDirectedGraph::next_node);
   12112             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   12113             :     Rose::MemPool::snapshot(oss.str());
   12114             :     alloc_trace_cnt++;
   12115             : #endif
   12116             : 
   12117           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   12118             : 
   12119           0 :     ALLOC_MUTEX(SgIncidenceDirectedGraph, unlock);
   12120             : 
   12121             :     return object;
   12122             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   12123             : }
   12124             : 
   12125             : 
   12126             : 
   12127             : /*! \brief Delete operator for SgIncidenceDirectedGraph.
   12128             : 
   12129             :    This delete operator implements deallocation using memory pools to 
   12130             :    provide most efficent use of the heap within construction of large ASTs.
   12131             : 
   12132             : \internal The new and delete operators use the lower level C malloc/free
   12133             :    function calls for performance and to make sure that mixing of malloc/free
   12134             :    and new/delete by the used can be caught more readily.  This may change
   12135             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   12136             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   12137             :    deallocate memory allocated using ROSE_MALLOC.
   12138             : */
   12139           0 : void SgIncidenceDirectedGraph::operator delete(void *Pointer, size_t Size)
   12140             : {
   12141             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   12142             :      * or throwing an exception. */
   12143           0 :     ALLOC_MUTEX(SgIncidenceDirectedGraph, lock);
   12144             : 
   12145             : #if USE_CPP_NEW_DELETE_OPERATORS
   12146             :     ROSE_FREE(Pointer);
   12147             : #else
   12148             : #if ROSE_PEDANTIC_ALLOC
   12149             :     ROSE_ASSERT(Size == sizeof(SgIncidenceDirectedGraph));
   12150             : #else
   12151           0 :     if (Size != sizeof(SgIncidenceDirectedGraph)) {
   12152           0 :       ROSE_FREE(Pointer);
   12153           0 :       ALLOC_MUTEX(SgIncidenceDirectedGraph, unlock);
   12154             :       return;
   12155             :     }
   12156             : #endif
   12157             : 
   12158           0 :     SgIncidenceDirectedGraph * object = (SgIncidenceDirectedGraph*) Pointer;
   12159           0 :     ROSE_ASSERT(object != nullptr);
   12160             : 
   12161             : #if ROSE_ALLOC_TRACE == 2
   12162             : //  printf("SgIncidenceDirectedGraph::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgIncidenceDirectedGraph::next_node);
   12163             :     printf("SgIncidenceDirectedGraph::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgIncidenceDirectedGraph::next_node);
   12164             : #endif
   12165             : 
   12166             : #if ROSE_PEDANTIC_ALLOC
   12167             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   12168             : #endif
   12169             : 
   12170             : #if ROSE_ALLOC_MEMSET == 1
   12171             : #elif ROSE_ALLOC_MEMSET == 2
   12172             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgIncidenceDirectedGraph) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   12173             : #elif ROSE_ALLOC_MEMSET == 3
   12174             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgIncidenceDirectedGraph) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   12175             : #endif
   12176             : 
   12177             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   12178             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   12179             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   12180             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   12181             : #else
   12182           0 :     object->p_freepointer = SgIncidenceDirectedGraph::next_node;
   12183           0 :     SgIncidenceDirectedGraph::next_node = object;
   12184             : #endif
   12185             : 
   12186             : #if ROSE_ALLOC_TRACE == 2
   12187             : //  printf("SgIncidenceDirectedGraph::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgIncidenceDirectedGraph::next_node);
   12188             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   12189             :     Rose::MemPool::snapshot(oss.str());
   12190             :     alloc_trace_cnt++;
   12191             : #endif
   12192             : 
   12193             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   12194             : 
   12195           0 :     ALLOC_MUTEX(SgIncidenceDirectedGraph, unlock);
   12196             : }
   12197             : 
   12198             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   12199             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   12200             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   12201             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   12202             : // Also, note comment below from Robb (copied from the Common.code file).
   12203             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   12204             : //
   12205             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   12206             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   12207             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   12208             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   12209             : #if 0
   12210             : void SgIncidenceDirectedGraph::operator delete(void* pointer) { SgIncidenceDirectedGraph::operator delete (pointer, sizeof(SgIncidenceDirectedGraph)); };
   12211             : #endif
   12212             : /* #line 12213 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   12213             : 
   12214             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   12215             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   12216             : // obviously imply C++.
   12217             : 
   12218             : // This implements the support within ROSE for memory pools.  Memory pools
   12219             : // support the most condensed usage of memory within the construction of
   12220             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   12221             : // by a new operator written for each class.
   12222             : 
   12223             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   12224             :     // User wants multi-thread support and POSIX threads are available.
   12225             : #   include <pthread.h>
   12226             :     static pthread_mutex_t SgBidirectionalGraph_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   12227             : #else
   12228             :      // Cause synchronization to be skipped.
   12229             : #    ifndef ALLOC_MUTEX
   12230             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   12231             : #    endif
   12232             : #    ifdef _REENTRANT
   12233             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   12234             : #       ifdef _MSC_VER
   12235             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   12236             : #       else
   12237             : #           warning "POSIX threads are not available; synchronization being skipped"
   12238             : #       endif
   12239             : #    endif
   12240             : #endif
   12241             : 
   12242             : #ifndef ROSE_ALLOC_TRACE
   12243             : #  define ROSE_ALLOC_TRACE 0
   12244             : #endif
   12245             : 
   12246             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   12247             : #define ROSE_ALLOC_TRACE_CNT
   12248             : #include "memory-pool-snapshot.h"
   12249             : unsigned long alloc_trace_cnt = 0;
   12250             : #endif
   12251             : 
   12252             : #if ROSE_ALLOC_TRACE
   12253             : const unsigned SgBidirectionalGraph::pool_size = 5;
   12254             : #else
   12255             : const unsigned SgBidirectionalGraph::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   12256             : #endif
   12257             : 
   12258             : #ifndef ROSE_ALLOC_MEMSET
   12259             : #  define ROSE_ALLOC_MEMSET 0
   12260             : #endif
   12261             : 
   12262             : #ifndef ROSE_PEDANTIC_ALLOC
   12263             : #  define ROSE_PEDANTIC_ALLOC 0
   12264             : #endif
   12265             : 
   12266             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   12267             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   12268             : #endif
   12269             : 
   12270             : #if !defined(SGNODE__ALL_POOLS)
   12271             : #define SGNODE__ALL_POOLS
   12272             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   12273             : #endif
   12274             : 
   12275             : SgBidirectionalGraph* SgBidirectionalGraph::next_node = nullptr;
   12276             : std::vector<unsigned char*> SgBidirectionalGraph::pools;
   12277             : 
   12278             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   12279             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   12280             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   12281             : // around this macro definition rather than each use).
   12282             : #ifndef ALLOC_MUTEX
   12283             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   12284             :         do {                                                                     \
   12285             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   12286             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   12287             :                 abort();                                                         \
   12288             :             }                                                                    \
   12289             :         } while (0);
   12290             : #endif
   12291             : 
   12292             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   12293             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   12294             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   12295             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   12296             : 
   12297             : /*! \brief New operator for SgBidirectionalGraph.
   12298             : 
   12299             :    This new operator implements memory pools to provide most efficent 
   12300             :    use of the heap within construction of large ASTs.
   12301             : 
   12302             : \internal The new and delete operators use the lower level C malloc/free
   12303             :    function calls for performance and to make sure that mixing of malloc/free
   12304             :    and new/delete by the used can be caught more readily.  This may change
   12305             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   12306             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   12307             :    deallocate memory allocated using ROSE_MALLOC.
   12308             : */
   12309           0 : void *SgBidirectionalGraph::operator new ( size_t Size )
   12310             : {
   12311             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   12312             :      * returning or throwing an exception. */
   12313           0 :     ALLOC_MUTEX(SgBidirectionalGraph, lock);
   12314             : 
   12315             : #if ROSE_ALLOC_TRACE == 2
   12316             : //    printf("SgBidirectionalGraph::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgBidirectionalGraph::next_node);
   12317             : #endif
   12318             : 
   12319             : #if USE_CPP_NEW_DELETE_OPERATORS
   12320             :     void *mem = ROSE_MALLOC(Size);
   12321             :     ALLOC_MUTEX(SgBidirectionalGraph, unlock);
   12322             :     return mem;
   12323             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   12324             : #if ROSE_PEDANTIC_ALLOC
   12325             :     ROSE_ASSERT(Size == sizeof(SgBidirectionalGraph));
   12326             : #else
   12327           0 :     if (Size != sizeof(SgBidirectionalGraph)) {
   12328           0 :       void * object = ROSE_MALLOC(Size);
   12329           0 :       ALLOC_MUTEX(SgBidirectionalGraph, unlock);
   12330             :       return object;
   12331             :     }
   12332             : #endif
   12333             : 
   12334           0 :     if (SgBidirectionalGraph::next_node == nullptr) {
   12335           0 :         SgBidirectionalGraph * alloc = (SgBidirectionalGraph*) ROSE_MALLOC ( SgBidirectionalGraph::pool_size * sizeof(SgBidirectionalGraph) );
   12336           0 :         ROSE_ASSERT(alloc != nullptr);
   12337             : 
   12338             : #if ROSE_ALLOC_TRACE == 2
   12339             : //        printf("SgBidirectionalGraph::alloc\n  block[%zi] = [ %p , %p [\n", SgBidirectionalGraph::pools.size(), alloc, alloc + SgBidirectionalGraph::pool_size);
   12340             : #endif
   12341             : 
   12342             : #if ROSE_ALLOC_MEMSET == 1
   12343             : #elif ROSE_ALLOC_MEMSET == 2
   12344             :         memset(alloc, 0x00, SgBidirectionalGraph::pool_size * sizeof(SgBidirectionalGraph));
   12345             : #elif ROSE_ALLOC_MEMSET == 3
   12346             :         memset(alloc, 0xAA, SgBidirectionalGraph::pool_size * sizeof(SgBidirectionalGraph));
   12347             : #endif
   12348           0 :         for (unsigned i=0; i < SgBidirectionalGraph::pool_size-1; i++) {
   12349           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
   12350             :         }
   12351           0 :         alloc[SgBidirectionalGraph::pool_size-1].p_freepointer = nullptr;
   12352             : 
   12353           0 :         SgBidirectionalGraph::pools.push_back ( (unsigned char *) alloc );
   12354           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgBidirectionalGraph::pool_size * sizeof(SgBidirectionalGraph), V_SgBidirectionalGraph ) );
   12355           0 :         SgBidirectionalGraph::next_node = alloc;
   12356             :     }
   12357           0 :     ROSE_ASSERT(SgBidirectionalGraph::next_node != nullptr);
   12358             : 
   12359           0 :     SgBidirectionalGraph * object = SgBidirectionalGraph::next_node;
   12360           0 :     SgBidirectionalGraph::next_node = (SgBidirectionalGraph*)(object->p_freepointer);
   12361             : 
   12362             : #if ROSE_ALLOC_TRACE == 2
   12363             :     printf("SgBidirectionalGraph::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgBidirectionalGraph::next_node);
   12364             : #endif
   12365             : 
   12366           0 :     SgNode * fp = object->p_freepointer;
   12367             : #if ROSE_ALLOC_MEMSET == 1
   12368             : #elif ROSE_ALLOC_MEMSET == 2
   12369             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgBidirectionalGraph) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   12370             : #elif ROSE_ALLOC_MEMSET == 3
   12371             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgBidirectionalGraph) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   12372             : #endif
   12373           0 :     object->p_freepointer = fp;
   12374             : 
   12375             : #if ROSE_ALLOC_TRACE == 2
   12376             : //    printf("SgBidirectionalGraph::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgBidirectionalGraph::next_node);
   12377             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   12378             :     Rose::MemPool::snapshot(oss.str());
   12379             :     alloc_trace_cnt++;
   12380             : #endif
   12381             : 
   12382           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   12383             : 
   12384           0 :     ALLOC_MUTEX(SgBidirectionalGraph, unlock);
   12385             : 
   12386             :     return object;
   12387             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   12388             : }
   12389             : 
   12390             : 
   12391             : 
   12392             : /*! \brief Delete operator for SgBidirectionalGraph.
   12393             : 
   12394             :    This delete operator implements deallocation using memory pools to 
   12395             :    provide most efficent use of the heap within construction of large ASTs.
   12396             : 
   12397             : \internal The new and delete operators use the lower level C malloc/free
   12398             :    function calls for performance and to make sure that mixing of malloc/free
   12399             :    and new/delete by the used can be caught more readily.  This may change
   12400             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   12401             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   12402             :    deallocate memory allocated using ROSE_MALLOC.
   12403             : */
   12404           0 : void SgBidirectionalGraph::operator delete(void *Pointer, size_t Size)
   12405             : {
   12406             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   12407             :      * or throwing an exception. */
   12408           0 :     ALLOC_MUTEX(SgBidirectionalGraph, lock);
   12409             : 
   12410             : #if USE_CPP_NEW_DELETE_OPERATORS
   12411             :     ROSE_FREE(Pointer);
   12412             : #else
   12413             : #if ROSE_PEDANTIC_ALLOC
   12414             :     ROSE_ASSERT(Size == sizeof(SgBidirectionalGraph));
   12415             : #else
   12416           0 :     if (Size != sizeof(SgBidirectionalGraph)) {
   12417           0 :       ROSE_FREE(Pointer);
   12418           0 :       ALLOC_MUTEX(SgBidirectionalGraph, unlock);
   12419             :       return;
   12420             :     }
   12421             : #endif
   12422             : 
   12423           0 :     SgBidirectionalGraph * object = (SgBidirectionalGraph*) Pointer;
   12424           0 :     ROSE_ASSERT(object != nullptr);
   12425             : 
   12426             : #if ROSE_ALLOC_TRACE == 2
   12427             : //  printf("SgBidirectionalGraph::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgBidirectionalGraph::next_node);
   12428             :     printf("SgBidirectionalGraph::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgBidirectionalGraph::next_node);
   12429             : #endif
   12430             : 
   12431             : #if ROSE_PEDANTIC_ALLOC
   12432             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   12433             : #endif
   12434             : 
   12435             : #if ROSE_ALLOC_MEMSET == 1
   12436             : #elif ROSE_ALLOC_MEMSET == 2
   12437             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgBidirectionalGraph) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   12438             : #elif ROSE_ALLOC_MEMSET == 3
   12439             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgBidirectionalGraph) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   12440             : #endif
   12441             : 
   12442             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   12443             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   12444             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   12445             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   12446             : #else
   12447           0 :     object->p_freepointer = SgBidirectionalGraph::next_node;
   12448           0 :     SgBidirectionalGraph::next_node = object;
   12449             : #endif
   12450             : 
   12451             : #if ROSE_ALLOC_TRACE == 2
   12452             : //  printf("SgBidirectionalGraph::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgBidirectionalGraph::next_node);
   12453             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   12454             :     Rose::MemPool::snapshot(oss.str());
   12455             :     alloc_trace_cnt++;
   12456             : #endif
   12457             : 
   12458             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   12459             : 
   12460           0 :     ALLOC_MUTEX(SgBidirectionalGraph, unlock);
   12461             : }
   12462             : 
   12463             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   12464             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   12465             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   12466             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   12467             : // Also, note comment below from Robb (copied from the Common.code file).
   12468             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   12469             : //
   12470             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   12471             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   12472             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   12473             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   12474             : #if 0
   12475             : void SgBidirectionalGraph::operator delete(void* pointer) { SgBidirectionalGraph::operator delete (pointer, sizeof(SgBidirectionalGraph)); };
   12476             : #endif
   12477             : /* #line 12478 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   12478             : 
   12479             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   12480             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   12481             : // obviously imply C++.
   12482             : 
   12483             : // This implements the support within ROSE for memory pools.  Memory pools
   12484             : // support the most condensed usage of memory within the construction of
   12485             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   12486             : // by a new operator written for each class.
   12487             : 
   12488             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   12489             :     // User wants multi-thread support and POSIX threads are available.
   12490             : #   include <pthread.h>
   12491             :     static pthread_mutex_t SgStringKeyedBidirectionalGraph_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   12492             : #else
   12493             :      // Cause synchronization to be skipped.
   12494             : #    ifndef ALLOC_MUTEX
   12495             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   12496             : #    endif
   12497             : #    ifdef _REENTRANT
   12498             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   12499             : #       ifdef _MSC_VER
   12500             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   12501             : #       else
   12502             : #           warning "POSIX threads are not available; synchronization being skipped"
   12503             : #       endif
   12504             : #    endif
   12505             : #endif
   12506             : 
   12507             : #ifndef ROSE_ALLOC_TRACE
   12508             : #  define ROSE_ALLOC_TRACE 0
   12509             : #endif
   12510             : 
   12511             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   12512             : #define ROSE_ALLOC_TRACE_CNT
   12513             : #include "memory-pool-snapshot.h"
   12514             : unsigned long alloc_trace_cnt = 0;
   12515             : #endif
   12516             : 
   12517             : #if ROSE_ALLOC_TRACE
   12518             : const unsigned SgStringKeyedBidirectionalGraph::pool_size = 5;
   12519             : #else
   12520             : const unsigned SgStringKeyedBidirectionalGraph::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   12521             : #endif
   12522             : 
   12523             : #ifndef ROSE_ALLOC_MEMSET
   12524             : #  define ROSE_ALLOC_MEMSET 0
   12525             : #endif
   12526             : 
   12527             : #ifndef ROSE_PEDANTIC_ALLOC
   12528             : #  define ROSE_PEDANTIC_ALLOC 0
   12529             : #endif
   12530             : 
   12531             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   12532             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   12533             : #endif
   12534             : 
   12535             : #if !defined(SGNODE__ALL_POOLS)
   12536             : #define SGNODE__ALL_POOLS
   12537             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   12538             : #endif
   12539             : 
   12540             : SgStringKeyedBidirectionalGraph* SgStringKeyedBidirectionalGraph::next_node = nullptr;
   12541             : std::vector<unsigned char*> SgStringKeyedBidirectionalGraph::pools;
   12542             : 
   12543             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   12544             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   12545             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   12546             : // around this macro definition rather than each use).
   12547             : #ifndef ALLOC_MUTEX
   12548             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   12549             :         do {                                                                     \
   12550             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   12551             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   12552             :                 abort();                                                         \
   12553             :             }                                                                    \
   12554             :         } while (0);
   12555             : #endif
   12556             : 
   12557             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   12558             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   12559             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   12560             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   12561             : 
   12562             : /*! \brief New operator for SgStringKeyedBidirectionalGraph.
   12563             : 
   12564             :    This new operator implements memory pools to provide most efficent 
   12565             :    use of the heap within construction of large ASTs.
   12566             : 
   12567             : \internal The new and delete operators use the lower level C malloc/free
   12568             :    function calls for performance and to make sure that mixing of malloc/free
   12569             :    and new/delete by the used can be caught more readily.  This may change
   12570             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   12571             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   12572             :    deallocate memory allocated using ROSE_MALLOC.
   12573             : */
   12574           0 : void *SgStringKeyedBidirectionalGraph::operator new ( size_t Size )
   12575             : {
   12576             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   12577             :      * returning or throwing an exception. */
   12578           0 :     ALLOC_MUTEX(SgStringKeyedBidirectionalGraph, lock);
   12579             : 
   12580             : #if ROSE_ALLOC_TRACE == 2
   12581             : //    printf("SgStringKeyedBidirectionalGraph::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgStringKeyedBidirectionalGraph::next_node);
   12582             : #endif
   12583             : 
   12584             : #if USE_CPP_NEW_DELETE_OPERATORS
   12585             :     void *mem = ROSE_MALLOC(Size);
   12586             :     ALLOC_MUTEX(SgStringKeyedBidirectionalGraph, unlock);
   12587             :     return mem;
   12588             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   12589             : #if ROSE_PEDANTIC_ALLOC
   12590             :     ROSE_ASSERT(Size == sizeof(SgStringKeyedBidirectionalGraph));
   12591             : #else
   12592           0 :     if (Size != sizeof(SgStringKeyedBidirectionalGraph)) {
   12593           0 :       void * object = ROSE_MALLOC(Size);
   12594           0 :       ALLOC_MUTEX(SgStringKeyedBidirectionalGraph, unlock);
   12595             :       return object;
   12596             :     }
   12597             : #endif
   12598             : 
   12599           0 :     if (SgStringKeyedBidirectionalGraph::next_node == nullptr) {
   12600           0 :         SgStringKeyedBidirectionalGraph * alloc = (SgStringKeyedBidirectionalGraph*) ROSE_MALLOC ( SgStringKeyedBidirectionalGraph::pool_size * sizeof(SgStringKeyedBidirectionalGraph) );
   12601           0 :         ROSE_ASSERT(alloc != nullptr);
   12602             : 
   12603             : #if ROSE_ALLOC_TRACE == 2
   12604             : //        printf("SgStringKeyedBidirectionalGraph::alloc\n  block[%zi] = [ %p , %p [\n", SgStringKeyedBidirectionalGraph::pools.size(), alloc, alloc + SgStringKeyedBidirectionalGraph::pool_size);
   12605             : #endif
   12606             : 
   12607             : #if ROSE_ALLOC_MEMSET == 1
   12608             : #elif ROSE_ALLOC_MEMSET == 2
   12609             :         memset(alloc, 0x00, SgStringKeyedBidirectionalGraph::pool_size * sizeof(SgStringKeyedBidirectionalGraph));
   12610             : #elif ROSE_ALLOC_MEMSET == 3
   12611             :         memset(alloc, 0xAA, SgStringKeyedBidirectionalGraph::pool_size * sizeof(SgStringKeyedBidirectionalGraph));
   12612             : #endif
   12613           0 :         for (unsigned i=0; i < SgStringKeyedBidirectionalGraph::pool_size-1; i++) {
   12614           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
   12615             :         }
   12616           0 :         alloc[SgStringKeyedBidirectionalGraph::pool_size-1].p_freepointer = nullptr;
   12617             : 
   12618           0 :         SgStringKeyedBidirectionalGraph::pools.push_back ( (unsigned char *) alloc );
   12619           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgStringKeyedBidirectionalGraph::pool_size * sizeof(SgStringKeyedBidirectionalGraph), V_SgStringKeyedBidirectionalGraph ) );
   12620           0 :         SgStringKeyedBidirectionalGraph::next_node = alloc;
   12621             :     }
   12622           0 :     ROSE_ASSERT(SgStringKeyedBidirectionalGraph::next_node != nullptr);
   12623             : 
   12624           0 :     SgStringKeyedBidirectionalGraph * object = SgStringKeyedBidirectionalGraph::next_node;
   12625           0 :     SgStringKeyedBidirectionalGraph::next_node = (SgStringKeyedBidirectionalGraph*)(object->p_freepointer);
   12626             : 
   12627             : #if ROSE_ALLOC_TRACE == 2
   12628             :     printf("SgStringKeyedBidirectionalGraph::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgStringKeyedBidirectionalGraph::next_node);
   12629             : #endif
   12630             : 
   12631           0 :     SgNode * fp = object->p_freepointer;
   12632             : #if ROSE_ALLOC_MEMSET == 1
   12633             : #elif ROSE_ALLOC_MEMSET == 2
   12634             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgStringKeyedBidirectionalGraph) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   12635             : #elif ROSE_ALLOC_MEMSET == 3
   12636             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgStringKeyedBidirectionalGraph) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   12637             : #endif
   12638           0 :     object->p_freepointer = fp;
   12639             : 
   12640             : #if ROSE_ALLOC_TRACE == 2
   12641             : //    printf("SgStringKeyedBidirectionalGraph::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgStringKeyedBidirectionalGraph::next_node);
   12642             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   12643             :     Rose::MemPool::snapshot(oss.str());
   12644             :     alloc_trace_cnt++;
   12645             : #endif
   12646             : 
   12647           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   12648             : 
   12649           0 :     ALLOC_MUTEX(SgStringKeyedBidirectionalGraph, unlock);
   12650             : 
   12651             :     return object;
   12652             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   12653             : }
   12654             : 
   12655             : 
   12656             : 
   12657             : /*! \brief Delete operator for SgStringKeyedBidirectionalGraph.
   12658             : 
   12659             :    This delete operator implements deallocation using memory pools to 
   12660             :    provide most efficent use of the heap within construction of large ASTs.
   12661             : 
   12662             : \internal The new and delete operators use the lower level C malloc/free
   12663             :    function calls for performance and to make sure that mixing of malloc/free
   12664             :    and new/delete by the used can be caught more readily.  This may change
   12665             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   12666             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   12667             :    deallocate memory allocated using ROSE_MALLOC.
   12668             : */
   12669           0 : void SgStringKeyedBidirectionalGraph::operator delete(void *Pointer, size_t Size)
   12670             : {
   12671             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   12672             :      * or throwing an exception. */
   12673           0 :     ALLOC_MUTEX(SgStringKeyedBidirectionalGraph, lock);
   12674             : 
   12675             : #if USE_CPP_NEW_DELETE_OPERATORS
   12676             :     ROSE_FREE(Pointer);
   12677             : #else
   12678             : #if ROSE_PEDANTIC_ALLOC
   12679             :     ROSE_ASSERT(Size == sizeof(SgStringKeyedBidirectionalGraph));
   12680             : #else
   12681           0 :     if (Size != sizeof(SgStringKeyedBidirectionalGraph)) {
   12682           0 :       ROSE_FREE(Pointer);
   12683           0 :       ALLOC_MUTEX(SgStringKeyedBidirectionalGraph, unlock);
   12684             :       return;
   12685             :     }
   12686             : #endif
   12687             : 
   12688           0 :     SgStringKeyedBidirectionalGraph * object = (SgStringKeyedBidirectionalGraph*) Pointer;
   12689           0 :     ROSE_ASSERT(object != nullptr);
   12690             : 
   12691             : #if ROSE_ALLOC_TRACE == 2
   12692             : //  printf("SgStringKeyedBidirectionalGraph::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgStringKeyedBidirectionalGraph::next_node);
   12693             :     printf("SgStringKeyedBidirectionalGraph::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgStringKeyedBidirectionalGraph::next_node);
   12694             : #endif
   12695             : 
   12696             : #if ROSE_PEDANTIC_ALLOC
   12697             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   12698             : #endif
   12699             : 
   12700             : #if ROSE_ALLOC_MEMSET == 1
   12701             : #elif ROSE_ALLOC_MEMSET == 2
   12702             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgStringKeyedBidirectionalGraph) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   12703             : #elif ROSE_ALLOC_MEMSET == 3
   12704             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgStringKeyedBidirectionalGraph) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   12705             : #endif
   12706             : 
   12707             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   12708             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   12709             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   12710             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   12711             : #else
   12712           0 :     object->p_freepointer = SgStringKeyedBidirectionalGraph::next_node;
   12713           0 :     SgStringKeyedBidirectionalGraph::next_node = object;
   12714             : #endif
   12715             : 
   12716             : #if ROSE_ALLOC_TRACE == 2
   12717             : //  printf("SgStringKeyedBidirectionalGraph::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgStringKeyedBidirectionalGraph::next_node);
   12718             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   12719             :     Rose::MemPool::snapshot(oss.str());
   12720             :     alloc_trace_cnt++;
   12721             : #endif
   12722             : 
   12723             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   12724             : 
   12725           0 :     ALLOC_MUTEX(SgStringKeyedBidirectionalGraph, unlock);
   12726             : }
   12727             : 
   12728             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   12729             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   12730             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   12731             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   12732             : // Also, note comment below from Robb (copied from the Common.code file).
   12733             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   12734             : //
   12735             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   12736             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   12737             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   12738             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   12739             : #if 0
   12740             : void SgStringKeyedBidirectionalGraph::operator delete(void* pointer) { SgStringKeyedBidirectionalGraph::operator delete (pointer, sizeof(SgStringKeyedBidirectionalGraph)); };
   12741             : #endif
   12742             : /* #line 12743 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   12743             : 
   12744             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   12745             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   12746             : // obviously imply C++.
   12747             : 
   12748             : // This implements the support within ROSE for memory pools.  Memory pools
   12749             : // support the most condensed usage of memory within the construction of
   12750             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   12751             : // by a new operator written for each class.
   12752             : 
   12753             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   12754             :     // User wants multi-thread support and POSIX threads are available.
   12755             : #   include <pthread.h>
   12756             :     static pthread_mutex_t SgIntKeyedBidirectionalGraph_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   12757             : #else
   12758             :      // Cause synchronization to be skipped.
   12759             : #    ifndef ALLOC_MUTEX
   12760             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   12761             : #    endif
   12762             : #    ifdef _REENTRANT
   12763             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   12764             : #       ifdef _MSC_VER
   12765             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   12766             : #       else
   12767             : #           warning "POSIX threads are not available; synchronization being skipped"
   12768             : #       endif
   12769             : #    endif
   12770             : #endif
   12771             : 
   12772             : #ifndef ROSE_ALLOC_TRACE
   12773             : #  define ROSE_ALLOC_TRACE 0
   12774             : #endif
   12775             : 
   12776             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   12777             : #define ROSE_ALLOC_TRACE_CNT
   12778             : #include "memory-pool-snapshot.h"
   12779             : unsigned long alloc_trace_cnt = 0;
   12780             : #endif
   12781             : 
   12782             : #if ROSE_ALLOC_TRACE
   12783             : const unsigned SgIntKeyedBidirectionalGraph::pool_size = 5;
   12784             : #else
   12785             : const unsigned SgIntKeyedBidirectionalGraph::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   12786             : #endif
   12787             : 
   12788             : #ifndef ROSE_ALLOC_MEMSET
   12789             : #  define ROSE_ALLOC_MEMSET 0
   12790             : #endif
   12791             : 
   12792             : #ifndef ROSE_PEDANTIC_ALLOC
   12793             : #  define ROSE_PEDANTIC_ALLOC 0
   12794             : #endif
   12795             : 
   12796             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   12797             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   12798             : #endif
   12799             : 
   12800             : #if !defined(SGNODE__ALL_POOLS)
   12801             : #define SGNODE__ALL_POOLS
   12802             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   12803             : #endif
   12804             : 
   12805             : SgIntKeyedBidirectionalGraph* SgIntKeyedBidirectionalGraph::next_node = nullptr;
   12806             : std::vector<unsigned char*> SgIntKeyedBidirectionalGraph::pools;
   12807             : 
   12808             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   12809             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   12810             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   12811             : // around this macro definition rather than each use).
   12812             : #ifndef ALLOC_MUTEX
   12813             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   12814             :         do {                                                                     \
   12815             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   12816             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   12817             :                 abort();                                                         \
   12818             :             }                                                                    \
   12819             :         } while (0);
   12820             : #endif
   12821             : 
   12822             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   12823             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   12824             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   12825             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   12826             : 
   12827             : /*! \brief New operator for SgIntKeyedBidirectionalGraph.
   12828             : 
   12829             :    This new operator implements memory pools to provide most efficent 
   12830             :    use of the heap within construction of large ASTs.
   12831             : 
   12832             : \internal The new and delete operators use the lower level C malloc/free
   12833             :    function calls for performance and to make sure that mixing of malloc/free
   12834             :    and new/delete by the used can be caught more readily.  This may change
   12835             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   12836             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   12837             :    deallocate memory allocated using ROSE_MALLOC.
   12838             : */
   12839           0 : void *SgIntKeyedBidirectionalGraph::operator new ( size_t Size )
   12840             : {
   12841             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   12842             :      * returning or throwing an exception. */
   12843           0 :     ALLOC_MUTEX(SgIntKeyedBidirectionalGraph, lock);
   12844             : 
   12845             : #if ROSE_ALLOC_TRACE == 2
   12846             : //    printf("SgIntKeyedBidirectionalGraph::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgIntKeyedBidirectionalGraph::next_node);
   12847             : #endif
   12848             : 
   12849             : #if USE_CPP_NEW_DELETE_OPERATORS
   12850             :     void *mem = ROSE_MALLOC(Size);
   12851             :     ALLOC_MUTEX(SgIntKeyedBidirectionalGraph, unlock);
   12852             :     return mem;
   12853             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   12854             : #if ROSE_PEDANTIC_ALLOC
   12855             :     ROSE_ASSERT(Size == sizeof(SgIntKeyedBidirectionalGraph));
   12856             : #else
   12857           0 :     if (Size != sizeof(SgIntKeyedBidirectionalGraph)) {
   12858           0 :       void * object = ROSE_MALLOC(Size);
   12859           0 :       ALLOC_MUTEX(SgIntKeyedBidirectionalGraph, unlock);
   12860             :       return object;
   12861             :     }
   12862             : #endif
   12863             : 
   12864           0 :     if (SgIntKeyedBidirectionalGraph::next_node == nullptr) {
   12865           0 :         SgIntKeyedBidirectionalGraph * alloc = (SgIntKeyedBidirectionalGraph*) ROSE_MALLOC ( SgIntKeyedBidirectionalGraph::pool_size * sizeof(SgIntKeyedBidirectionalGraph) );
   12866           0 :         ROSE_ASSERT(alloc != nullptr);
   12867             : 
   12868             : #if ROSE_ALLOC_TRACE == 2
   12869             : //        printf("SgIntKeyedBidirectionalGraph::alloc\n  block[%zi] = [ %p , %p [\n", SgIntKeyedBidirectionalGraph::pools.size(), alloc, alloc + SgIntKeyedBidirectionalGraph::pool_size);
   12870             : #endif
   12871             : 
   12872             : #if ROSE_ALLOC_MEMSET == 1
   12873             : #elif ROSE_ALLOC_MEMSET == 2
   12874             :         memset(alloc, 0x00, SgIntKeyedBidirectionalGraph::pool_size * sizeof(SgIntKeyedBidirectionalGraph));
   12875             : #elif ROSE_ALLOC_MEMSET == 3
   12876             :         memset(alloc, 0xAA, SgIntKeyedBidirectionalGraph::pool_size * sizeof(SgIntKeyedBidirectionalGraph));
   12877             : #endif
   12878           0 :         for (unsigned i=0; i < SgIntKeyedBidirectionalGraph::pool_size-1; i++) {
   12879           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
   12880             :         }
   12881           0 :         alloc[SgIntKeyedBidirectionalGraph::pool_size-1].p_freepointer = nullptr;
   12882             : 
   12883           0 :         SgIntKeyedBidirectionalGraph::pools.push_back ( (unsigned char *) alloc );
   12884           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgIntKeyedBidirectionalGraph::pool_size * sizeof(SgIntKeyedBidirectionalGraph), V_SgIntKeyedBidirectionalGraph ) );
   12885           0 :         SgIntKeyedBidirectionalGraph::next_node = alloc;
   12886             :     }
   12887           0 :     ROSE_ASSERT(SgIntKeyedBidirectionalGraph::next_node != nullptr);
   12888             : 
   12889           0 :     SgIntKeyedBidirectionalGraph * object = SgIntKeyedBidirectionalGraph::next_node;
   12890           0 :     SgIntKeyedBidirectionalGraph::next_node = (SgIntKeyedBidirectionalGraph*)(object->p_freepointer);
   12891             : 
   12892             : #if ROSE_ALLOC_TRACE == 2
   12893             :     printf("SgIntKeyedBidirectionalGraph::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgIntKeyedBidirectionalGraph::next_node);
   12894             : #endif
   12895             : 
   12896           0 :     SgNode * fp = object->p_freepointer;
   12897             : #if ROSE_ALLOC_MEMSET == 1
   12898             : #elif ROSE_ALLOC_MEMSET == 2
   12899             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgIntKeyedBidirectionalGraph) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   12900             : #elif ROSE_ALLOC_MEMSET == 3
   12901             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgIntKeyedBidirectionalGraph) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   12902             : #endif
   12903           0 :     object->p_freepointer = fp;
   12904             : 
   12905             : #if ROSE_ALLOC_TRACE == 2
   12906             : //    printf("SgIntKeyedBidirectionalGraph::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgIntKeyedBidirectionalGraph::next_node);
   12907             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   12908             :     Rose::MemPool::snapshot(oss.str());
   12909             :     alloc_trace_cnt++;
   12910             : #endif
   12911             : 
   12912           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   12913             : 
   12914           0 :     ALLOC_MUTEX(SgIntKeyedBidirectionalGraph, unlock);
   12915             : 
   12916             :     return object;
   12917             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   12918             : }
   12919             : 
   12920             : 
   12921             : 
   12922             : /*! \brief Delete operator for SgIntKeyedBidirectionalGraph.
   12923             : 
   12924             :    This delete operator implements deallocation using memory pools to 
   12925             :    provide most efficent use of the heap within construction of large ASTs.
   12926             : 
   12927             : \internal The new and delete operators use the lower level C malloc/free
   12928             :    function calls for performance and to make sure that mixing of malloc/free
   12929             :    and new/delete by the used can be caught more readily.  This may change
   12930             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   12931             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   12932             :    deallocate memory allocated using ROSE_MALLOC.
   12933             : */
   12934           0 : void SgIntKeyedBidirectionalGraph::operator delete(void *Pointer, size_t Size)
   12935             : {
   12936             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   12937             :      * or throwing an exception. */
   12938           0 :     ALLOC_MUTEX(SgIntKeyedBidirectionalGraph, lock);
   12939             : 
   12940             : #if USE_CPP_NEW_DELETE_OPERATORS
   12941             :     ROSE_FREE(Pointer);
   12942             : #else
   12943             : #if ROSE_PEDANTIC_ALLOC
   12944             :     ROSE_ASSERT(Size == sizeof(SgIntKeyedBidirectionalGraph));
   12945             : #else
   12946           0 :     if (Size != sizeof(SgIntKeyedBidirectionalGraph)) {
   12947           0 :       ROSE_FREE(Pointer);
   12948           0 :       ALLOC_MUTEX(SgIntKeyedBidirectionalGraph, unlock);
   12949             :       return;
   12950             :     }
   12951             : #endif
   12952             : 
   12953           0 :     SgIntKeyedBidirectionalGraph * object = (SgIntKeyedBidirectionalGraph*) Pointer;
   12954           0 :     ROSE_ASSERT(object != nullptr);
   12955             : 
   12956             : #if ROSE_ALLOC_TRACE == 2
   12957             : //  printf("SgIntKeyedBidirectionalGraph::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgIntKeyedBidirectionalGraph::next_node);
   12958             :     printf("SgIntKeyedBidirectionalGraph::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgIntKeyedBidirectionalGraph::next_node);
   12959             : #endif
   12960             : 
   12961             : #if ROSE_PEDANTIC_ALLOC
   12962             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   12963             : #endif
   12964             : 
   12965             : #if ROSE_ALLOC_MEMSET == 1
   12966             : #elif ROSE_ALLOC_MEMSET == 2
   12967             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgIntKeyedBidirectionalGraph) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   12968             : #elif ROSE_ALLOC_MEMSET == 3
   12969             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgIntKeyedBidirectionalGraph) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   12970             : #endif
   12971             : 
   12972             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   12973             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   12974             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   12975             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   12976             : #else
   12977           0 :     object->p_freepointer = SgIntKeyedBidirectionalGraph::next_node;
   12978           0 :     SgIntKeyedBidirectionalGraph::next_node = object;
   12979             : #endif
   12980             : 
   12981             : #if ROSE_ALLOC_TRACE == 2
   12982             : //  printf("SgIntKeyedBidirectionalGraph::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgIntKeyedBidirectionalGraph::next_node);
   12983             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   12984             :     Rose::MemPool::snapshot(oss.str());
   12985             :     alloc_trace_cnt++;
   12986             : #endif
   12987             : 
   12988             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   12989             : 
   12990           0 :     ALLOC_MUTEX(SgIntKeyedBidirectionalGraph, unlock);
   12991             : }
   12992             : 
   12993             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   12994             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   12995             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   12996             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   12997             : // Also, note comment below from Robb (copied from the Common.code file).
   12998             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   12999             : //
   13000             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   13001             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   13002             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   13003             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   13004             : #if 0
   13005             : void SgIntKeyedBidirectionalGraph::operator delete(void* pointer) { SgIntKeyedBidirectionalGraph::operator delete (pointer, sizeof(SgIntKeyedBidirectionalGraph)); };
   13006             : #endif
   13007             : /* #line 13008 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   13008             : 
   13009             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   13010             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   13011             : // obviously imply C++.
   13012             : 
   13013             : // This implements the support within ROSE for memory pools.  Memory pools
   13014             : // support the most condensed usage of memory within the construction of
   13015             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   13016             : // by a new operator written for each class.
   13017             : 
   13018             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   13019             :     // User wants multi-thread support and POSIX threads are available.
   13020             : #   include <pthread.h>
   13021             :     static pthread_mutex_t SgIncidenceUndirectedGraph_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   13022             : #else
   13023             :      // Cause synchronization to be skipped.
   13024             : #    ifndef ALLOC_MUTEX
   13025             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   13026             : #    endif
   13027             : #    ifdef _REENTRANT
   13028             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   13029             : #       ifdef _MSC_VER
   13030             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   13031             : #       else
   13032             : #           warning "POSIX threads are not available; synchronization being skipped"
   13033             : #       endif
   13034             : #    endif
   13035             : #endif
   13036             : 
   13037             : #ifndef ROSE_ALLOC_TRACE
   13038             : #  define ROSE_ALLOC_TRACE 0
   13039             : #endif
   13040             : 
   13041             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   13042             : #define ROSE_ALLOC_TRACE_CNT
   13043             : #include "memory-pool-snapshot.h"
   13044             : unsigned long alloc_trace_cnt = 0;
   13045             : #endif
   13046             : 
   13047             : #if ROSE_ALLOC_TRACE
   13048             : const unsigned SgIncidenceUndirectedGraph::pool_size = 5;
   13049             : #else
   13050             : const unsigned SgIncidenceUndirectedGraph::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   13051             : #endif
   13052             : 
   13053             : #ifndef ROSE_ALLOC_MEMSET
   13054             : #  define ROSE_ALLOC_MEMSET 0
   13055             : #endif
   13056             : 
   13057             : #ifndef ROSE_PEDANTIC_ALLOC
   13058             : #  define ROSE_PEDANTIC_ALLOC 0
   13059             : #endif
   13060             : 
   13061             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   13062             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   13063             : #endif
   13064             : 
   13065             : #if !defined(SGNODE__ALL_POOLS)
   13066             : #define SGNODE__ALL_POOLS
   13067             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   13068             : #endif
   13069             : 
   13070             : SgIncidenceUndirectedGraph* SgIncidenceUndirectedGraph::next_node = nullptr;
   13071             : std::vector<unsigned char*> SgIncidenceUndirectedGraph::pools;
   13072             : 
   13073             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   13074             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   13075             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   13076             : // around this macro definition rather than each use).
   13077             : #ifndef ALLOC_MUTEX
   13078             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   13079             :         do {                                                                     \
   13080             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   13081             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   13082             :                 abort();                                                         \
   13083             :             }                                                                    \
   13084             :         } while (0);
   13085             : #endif
   13086             : 
   13087             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   13088             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   13089             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   13090             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   13091             : 
   13092             : /*! \brief New operator for SgIncidenceUndirectedGraph.
   13093             : 
   13094             :    This new operator implements memory pools to provide most efficent 
   13095             :    use of the heap within construction of large ASTs.
   13096             : 
   13097             : \internal The new and delete operators use the lower level C malloc/free
   13098             :    function calls for performance and to make sure that mixing of malloc/free
   13099             :    and new/delete by the used can be caught more readily.  This may change
   13100             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   13101             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   13102             :    deallocate memory allocated using ROSE_MALLOC.
   13103             : */
   13104           0 : void *SgIncidenceUndirectedGraph::operator new ( size_t Size )
   13105             : {
   13106             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   13107             :      * returning or throwing an exception. */
   13108           0 :     ALLOC_MUTEX(SgIncidenceUndirectedGraph, lock);
   13109             : 
   13110             : #if ROSE_ALLOC_TRACE == 2
   13111             : //    printf("SgIncidenceUndirectedGraph::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgIncidenceUndirectedGraph::next_node);
   13112             : #endif
   13113             : 
   13114             : #if USE_CPP_NEW_DELETE_OPERATORS
   13115             :     void *mem = ROSE_MALLOC(Size);
   13116             :     ALLOC_MUTEX(SgIncidenceUndirectedGraph, unlock);
   13117             :     return mem;
   13118             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   13119             : #if ROSE_PEDANTIC_ALLOC
   13120             :     ROSE_ASSERT(Size == sizeof(SgIncidenceUndirectedGraph));
   13121             : #else
   13122           0 :     if (Size != sizeof(SgIncidenceUndirectedGraph)) {
   13123           0 :       void * object = ROSE_MALLOC(Size);
   13124           0 :       ALLOC_MUTEX(SgIncidenceUndirectedGraph, unlock);
   13125             :       return object;
   13126             :     }
   13127             : #endif
   13128             : 
   13129           0 :     if (SgIncidenceUndirectedGraph::next_node == nullptr) {
   13130           0 :         SgIncidenceUndirectedGraph * alloc = (SgIncidenceUndirectedGraph*) ROSE_MALLOC ( SgIncidenceUndirectedGraph::pool_size * sizeof(SgIncidenceUndirectedGraph) );
   13131           0 :         ROSE_ASSERT(alloc != nullptr);
   13132             : 
   13133             : #if ROSE_ALLOC_TRACE == 2
   13134             : //        printf("SgIncidenceUndirectedGraph::alloc\n  block[%zi] = [ %p , %p [\n", SgIncidenceUndirectedGraph::pools.size(), alloc, alloc + SgIncidenceUndirectedGraph::pool_size);
   13135             : #endif
   13136             : 
   13137             : #if ROSE_ALLOC_MEMSET == 1
   13138             : #elif ROSE_ALLOC_MEMSET == 2
   13139             :         memset(alloc, 0x00, SgIncidenceUndirectedGraph::pool_size * sizeof(SgIncidenceUndirectedGraph));
   13140             : #elif ROSE_ALLOC_MEMSET == 3
   13141             :         memset(alloc, 0xAA, SgIncidenceUndirectedGraph::pool_size * sizeof(SgIncidenceUndirectedGraph));
   13142             : #endif
   13143           0 :         for (unsigned i=0; i < SgIncidenceUndirectedGraph::pool_size-1; i++) {
   13144           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
   13145             :         }
   13146           0 :         alloc[SgIncidenceUndirectedGraph::pool_size-1].p_freepointer = nullptr;
   13147             : 
   13148           0 :         SgIncidenceUndirectedGraph::pools.push_back ( (unsigned char *) alloc );
   13149           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgIncidenceUndirectedGraph::pool_size * sizeof(SgIncidenceUndirectedGraph), V_SgIncidenceUndirectedGraph ) );
   13150           0 :         SgIncidenceUndirectedGraph::next_node = alloc;
   13151             :     }
   13152           0 :     ROSE_ASSERT(SgIncidenceUndirectedGraph::next_node != nullptr);
   13153             : 
   13154           0 :     SgIncidenceUndirectedGraph * object = SgIncidenceUndirectedGraph::next_node;
   13155           0 :     SgIncidenceUndirectedGraph::next_node = (SgIncidenceUndirectedGraph*)(object->p_freepointer);
   13156             : 
   13157             : #if ROSE_ALLOC_TRACE == 2
   13158             :     printf("SgIncidenceUndirectedGraph::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgIncidenceUndirectedGraph::next_node);
   13159             : #endif
   13160             : 
   13161           0 :     SgNode * fp = object->p_freepointer;
   13162             : #if ROSE_ALLOC_MEMSET == 1
   13163             : #elif ROSE_ALLOC_MEMSET == 2
   13164             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgIncidenceUndirectedGraph) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   13165             : #elif ROSE_ALLOC_MEMSET == 3
   13166             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgIncidenceUndirectedGraph) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   13167             : #endif
   13168           0 :     object->p_freepointer = fp;
   13169             : 
   13170             : #if ROSE_ALLOC_TRACE == 2
   13171             : //    printf("SgIncidenceUndirectedGraph::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgIncidenceUndirectedGraph::next_node);
   13172             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   13173             :     Rose::MemPool::snapshot(oss.str());
   13174             :     alloc_trace_cnt++;
   13175             : #endif
   13176             : 
   13177           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   13178             : 
   13179           0 :     ALLOC_MUTEX(SgIncidenceUndirectedGraph, unlock);
   13180             : 
   13181             :     return object;
   13182             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   13183             : }
   13184             : 
   13185             : 
   13186             : 
   13187             : /*! \brief Delete operator for SgIncidenceUndirectedGraph.
   13188             : 
   13189             :    This delete operator implements deallocation using memory pools to 
   13190             :    provide most efficent use of the heap within construction of large ASTs.
   13191             : 
   13192             : \internal The new and delete operators use the lower level C malloc/free
   13193             :    function calls for performance and to make sure that mixing of malloc/free
   13194             :    and new/delete by the used can be caught more readily.  This may change
   13195             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   13196             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   13197             :    deallocate memory allocated using ROSE_MALLOC.
   13198             : */
   13199           0 : void SgIncidenceUndirectedGraph::operator delete(void *Pointer, size_t Size)
   13200             : {
   13201             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   13202             :      * or throwing an exception. */
   13203           0 :     ALLOC_MUTEX(SgIncidenceUndirectedGraph, lock);
   13204             : 
   13205             : #if USE_CPP_NEW_DELETE_OPERATORS
   13206             :     ROSE_FREE(Pointer);
   13207             : #else
   13208             : #if ROSE_PEDANTIC_ALLOC
   13209             :     ROSE_ASSERT(Size == sizeof(SgIncidenceUndirectedGraph));
   13210             : #else
   13211           0 :     if (Size != sizeof(SgIncidenceUndirectedGraph)) {
   13212           0 :       ROSE_FREE(Pointer);
   13213           0 :       ALLOC_MUTEX(SgIncidenceUndirectedGraph, unlock);
   13214             :       return;
   13215             :     }
   13216             : #endif
   13217             : 
   13218           0 :     SgIncidenceUndirectedGraph * object = (SgIncidenceUndirectedGraph*) Pointer;
   13219           0 :     ROSE_ASSERT(object != nullptr);
   13220             : 
   13221             : #if ROSE_ALLOC_TRACE == 2
   13222             : //  printf("SgIncidenceUndirectedGraph::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgIncidenceUndirectedGraph::next_node);
   13223             :     printf("SgIncidenceUndirectedGraph::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgIncidenceUndirectedGraph::next_node);
   13224             : #endif
   13225             : 
   13226             : #if ROSE_PEDANTIC_ALLOC
   13227             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   13228             : #endif
   13229             : 
   13230             : #if ROSE_ALLOC_MEMSET == 1
   13231             : #elif ROSE_ALLOC_MEMSET == 2
   13232             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgIncidenceUndirectedGraph) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   13233             : #elif ROSE_ALLOC_MEMSET == 3
   13234             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgIncidenceUndirectedGraph) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   13235             : #endif
   13236             : 
   13237             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   13238             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   13239             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   13240             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   13241             : #else
   13242           0 :     object->p_freepointer = SgIncidenceUndirectedGraph::next_node;
   13243           0 :     SgIncidenceUndirectedGraph::next_node = object;
   13244             : #endif
   13245             : 
   13246             : #if ROSE_ALLOC_TRACE == 2
   13247             : //  printf("SgIncidenceUndirectedGraph::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgIncidenceUndirectedGraph::next_node);
   13248             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   13249             :     Rose::MemPool::snapshot(oss.str());
   13250             :     alloc_trace_cnt++;
   13251             : #endif
   13252             : 
   13253             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   13254             : 
   13255           0 :     ALLOC_MUTEX(SgIncidenceUndirectedGraph, unlock);
   13256             : }
   13257             : 
   13258             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   13259             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   13260             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   13261             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   13262             : // Also, note comment below from Robb (copied from the Common.code file).
   13263             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   13264             : //
   13265             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   13266             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   13267             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   13268             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   13269             : #if 0
   13270             : void SgIncidenceUndirectedGraph::operator delete(void* pointer) { SgIncidenceUndirectedGraph::operator delete (pointer, sizeof(SgIncidenceUndirectedGraph)); };
   13271             : #endif
   13272             : /* #line 13273 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   13273             : 
   13274             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   13275             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   13276             : // obviously imply C++.
   13277             : 
   13278             : // This implements the support within ROSE for memory pools.  Memory pools
   13279             : // support the most condensed usage of memory within the construction of
   13280             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   13281             : // by a new operator written for each class.
   13282             : 
   13283             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   13284             :     // User wants multi-thread support and POSIX threads are available.
   13285             : #   include <pthread.h>
   13286             :     static pthread_mutex_t SgGraphNode_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   13287             : #else
   13288             :      // Cause synchronization to be skipped.
   13289             : #    ifndef ALLOC_MUTEX
   13290             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   13291             : #    endif
   13292             : #    ifdef _REENTRANT
   13293             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   13294             : #       ifdef _MSC_VER
   13295             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   13296             : #       else
   13297             : #           warning "POSIX threads are not available; synchronization being skipped"
   13298             : #       endif
   13299             : #    endif
   13300             : #endif
   13301             : 
   13302             : #ifndef ROSE_ALLOC_TRACE
   13303             : #  define ROSE_ALLOC_TRACE 0
   13304             : #endif
   13305             : 
   13306             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   13307             : #define ROSE_ALLOC_TRACE_CNT
   13308             : #include "memory-pool-snapshot.h"
   13309             : unsigned long alloc_trace_cnt = 0;
   13310             : #endif
   13311             : 
   13312             : #if ROSE_ALLOC_TRACE
   13313             : const unsigned SgGraphNode::pool_size = 5;
   13314             : #else
   13315             : const unsigned SgGraphNode::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   13316             : #endif
   13317             : 
   13318             : #ifndef ROSE_ALLOC_MEMSET
   13319             : #  define ROSE_ALLOC_MEMSET 0
   13320             : #endif
   13321             : 
   13322             : #ifndef ROSE_PEDANTIC_ALLOC
   13323             : #  define ROSE_PEDANTIC_ALLOC 0
   13324             : #endif
   13325             : 
   13326             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   13327             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   13328             : #endif
   13329             : 
   13330             : #if !defined(SGNODE__ALL_POOLS)
   13331             : #define SGNODE__ALL_POOLS
   13332             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   13333             : #endif
   13334             : 
   13335             : SgGraphNode* SgGraphNode::next_node = nullptr;
   13336             : std::vector<unsigned char*> SgGraphNode::pools;
   13337             : 
   13338             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   13339             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   13340             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   13341             : // around this macro definition rather than each use).
   13342             : #ifndef ALLOC_MUTEX
   13343             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   13344             :         do {                                                                     \
   13345             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   13346             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   13347             :                 abort();                                                         \
   13348             :             }                                                                    \
   13349             :         } while (0);
   13350             : #endif
   13351             : 
   13352             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   13353             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   13354             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   13355             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   13356             : 
   13357             : /*! \brief New operator for SgGraphNode.
   13358             : 
   13359             :    This new operator implements memory pools to provide most efficent 
   13360             :    use of the heap within construction of large ASTs.
   13361             : 
   13362             : \internal The new and delete operators use the lower level C malloc/free
   13363             :    function calls for performance and to make sure that mixing of malloc/free
   13364             :    and new/delete by the used can be caught more readily.  This may change
   13365             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   13366             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   13367             :    deallocate memory allocated using ROSE_MALLOC.
   13368             : */
   13369           0 : void *SgGraphNode::operator new ( size_t Size )
   13370             : {
   13371             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   13372             :      * returning or throwing an exception. */
   13373           0 :     ALLOC_MUTEX(SgGraphNode, lock);
   13374             : 
   13375             : #if ROSE_ALLOC_TRACE == 2
   13376             : //    printf("SgGraphNode::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgGraphNode::next_node);
   13377             : #endif
   13378             : 
   13379             : #if USE_CPP_NEW_DELETE_OPERATORS
   13380             :     void *mem = ROSE_MALLOC(Size);
   13381             :     ALLOC_MUTEX(SgGraphNode, unlock);
   13382             :     return mem;
   13383             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   13384             : #if ROSE_PEDANTIC_ALLOC
   13385             :     ROSE_ASSERT(Size == sizeof(SgGraphNode));
   13386             : #else
   13387           0 :     if (Size != sizeof(SgGraphNode)) {
   13388           0 :       void * object = ROSE_MALLOC(Size);
   13389           0 :       ALLOC_MUTEX(SgGraphNode, unlock);
   13390             :       return object;
   13391             :     }
   13392             : #endif
   13393             : 
   13394           0 :     if (SgGraphNode::next_node == nullptr) {
   13395           0 :         SgGraphNode * alloc = (SgGraphNode*) ROSE_MALLOC ( SgGraphNode::pool_size * sizeof(SgGraphNode) );
   13396           0 :         ROSE_ASSERT(alloc != nullptr);
   13397             : 
   13398             : #if ROSE_ALLOC_TRACE == 2
   13399             : //        printf("SgGraphNode::alloc\n  block[%zi] = [ %p , %p [\n", SgGraphNode::pools.size(), alloc, alloc + SgGraphNode::pool_size);
   13400             : #endif
   13401             : 
   13402             : #if ROSE_ALLOC_MEMSET == 1
   13403             : #elif ROSE_ALLOC_MEMSET == 2
   13404             :         memset(alloc, 0x00, SgGraphNode::pool_size * sizeof(SgGraphNode));
   13405             : #elif ROSE_ALLOC_MEMSET == 3
   13406             :         memset(alloc, 0xAA, SgGraphNode::pool_size * sizeof(SgGraphNode));
   13407             : #endif
   13408           0 :         for (unsigned i=0; i < SgGraphNode::pool_size-1; i++) {
   13409           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
   13410             :         }
   13411           0 :         alloc[SgGraphNode::pool_size-1].p_freepointer = nullptr;
   13412             : 
   13413           0 :         SgGraphNode::pools.push_back ( (unsigned char *) alloc );
   13414           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgGraphNode::pool_size * sizeof(SgGraphNode), V_SgGraphNode ) );
   13415           0 :         SgGraphNode::next_node = alloc;
   13416             :     }
   13417           0 :     ROSE_ASSERT(SgGraphNode::next_node != nullptr);
   13418             : 
   13419           0 :     SgGraphNode * object = SgGraphNode::next_node;
   13420           0 :     SgGraphNode::next_node = (SgGraphNode*)(object->p_freepointer);
   13421             : 
   13422             : #if ROSE_ALLOC_TRACE == 2
   13423             :     printf("SgGraphNode::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgGraphNode::next_node);
   13424             : #endif
   13425             : 
   13426           0 :     SgNode * fp = object->p_freepointer;
   13427             : #if ROSE_ALLOC_MEMSET == 1
   13428             : #elif ROSE_ALLOC_MEMSET == 2
   13429             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgGraphNode) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   13430             : #elif ROSE_ALLOC_MEMSET == 3
   13431             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgGraphNode) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   13432             : #endif
   13433           0 :     object->p_freepointer = fp;
   13434             : 
   13435             : #if ROSE_ALLOC_TRACE == 2
   13436             : //    printf("SgGraphNode::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgGraphNode::next_node);
   13437             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   13438             :     Rose::MemPool::snapshot(oss.str());
   13439             :     alloc_trace_cnt++;
   13440             : #endif
   13441             : 
   13442           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   13443             : 
   13444           0 :     ALLOC_MUTEX(SgGraphNode, unlock);
   13445             : 
   13446             :     return object;
   13447             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   13448             : }
   13449             : 
   13450             : 
   13451             : 
   13452             : /*! \brief Delete operator for SgGraphNode.
   13453             : 
   13454             :    This delete operator implements deallocation using memory pools to 
   13455             :    provide most efficent use of the heap within construction of large ASTs.
   13456             : 
   13457             : \internal The new and delete operators use the lower level C malloc/free
   13458             :    function calls for performance and to make sure that mixing of malloc/free
   13459             :    and new/delete by the used can be caught more readily.  This may change
   13460             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   13461             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   13462             :    deallocate memory allocated using ROSE_MALLOC.
   13463             : */
   13464           0 : void SgGraphNode::operator delete(void *Pointer, size_t Size)
   13465             : {
   13466             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   13467             :      * or throwing an exception. */
   13468           0 :     ALLOC_MUTEX(SgGraphNode, lock);
   13469             : 
   13470             : #if USE_CPP_NEW_DELETE_OPERATORS
   13471             :     ROSE_FREE(Pointer);
   13472             : #else
   13473             : #if ROSE_PEDANTIC_ALLOC
   13474             :     ROSE_ASSERT(Size == sizeof(SgGraphNode));
   13475             : #else
   13476           0 :     if (Size != sizeof(SgGraphNode)) {
   13477           0 :       ROSE_FREE(Pointer);
   13478           0 :       ALLOC_MUTEX(SgGraphNode, unlock);
   13479             :       return;
   13480             :     }
   13481             : #endif
   13482             : 
   13483           0 :     SgGraphNode * object = (SgGraphNode*) Pointer;
   13484           0 :     ROSE_ASSERT(object != nullptr);
   13485             : 
   13486             : #if ROSE_ALLOC_TRACE == 2
   13487             : //  printf("SgGraphNode::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgGraphNode::next_node);
   13488             :     printf("SgGraphNode::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgGraphNode::next_node);
   13489             : #endif
   13490             : 
   13491             : #if ROSE_PEDANTIC_ALLOC
   13492             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   13493             : #endif
   13494             : 
   13495             : #if ROSE_ALLOC_MEMSET == 1
   13496             : #elif ROSE_ALLOC_MEMSET == 2
   13497             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgGraphNode) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   13498             : #elif ROSE_ALLOC_MEMSET == 3
   13499             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgGraphNode) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   13500             : #endif
   13501             : 
   13502             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   13503             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   13504             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   13505             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   13506             : #else
   13507           0 :     object->p_freepointer = SgGraphNode::next_node;
   13508           0 :     SgGraphNode::next_node = object;
   13509             : #endif
   13510             : 
   13511             : #if ROSE_ALLOC_TRACE == 2
   13512             : //  printf("SgGraphNode::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgGraphNode::next_node);
   13513             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   13514             :     Rose::MemPool::snapshot(oss.str());
   13515             :     alloc_trace_cnt++;
   13516             : #endif
   13517             : 
   13518             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   13519             : 
   13520           0 :     ALLOC_MUTEX(SgGraphNode, unlock);
   13521             : }
   13522             : 
   13523             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   13524             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   13525             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   13526             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   13527             : // Also, note comment below from Robb (copied from the Common.code file).
   13528             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   13529             : //
   13530             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   13531             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   13532             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   13533             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   13534             : #if 0
   13535             : void SgGraphNode::operator delete(void* pointer) { SgGraphNode::operator delete (pointer, sizeof(SgGraphNode)); };
   13536             : #endif
   13537             : /* #line 13538 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   13538             : 
   13539             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   13540             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   13541             : // obviously imply C++.
   13542             : 
   13543             : // This implements the support within ROSE for memory pools.  Memory pools
   13544             : // support the most condensed usage of memory within the construction of
   13545             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   13546             : // by a new operator written for each class.
   13547             : 
   13548             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   13549             :     // User wants multi-thread support and POSIX threads are available.
   13550             : #   include <pthread.h>
   13551             :     static pthread_mutex_t SgGraphEdge_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   13552             : #else
   13553             :      // Cause synchronization to be skipped.
   13554             : #    ifndef ALLOC_MUTEX
   13555             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   13556             : #    endif
   13557             : #    ifdef _REENTRANT
   13558             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   13559             : #       ifdef _MSC_VER
   13560             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   13561             : #       else
   13562             : #           warning "POSIX threads are not available; synchronization being skipped"
   13563             : #       endif
   13564             : #    endif
   13565             : #endif
   13566             : 
   13567             : #ifndef ROSE_ALLOC_TRACE
   13568             : #  define ROSE_ALLOC_TRACE 0
   13569             : #endif
   13570             : 
   13571             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   13572             : #define ROSE_ALLOC_TRACE_CNT
   13573             : #include "memory-pool-snapshot.h"
   13574             : unsigned long alloc_trace_cnt = 0;
   13575             : #endif
   13576             : 
   13577             : #if ROSE_ALLOC_TRACE
   13578             : const unsigned SgGraphEdge::pool_size = 5;
   13579             : #else
   13580             : const unsigned SgGraphEdge::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   13581             : #endif
   13582             : 
   13583             : #ifndef ROSE_ALLOC_MEMSET
   13584             : #  define ROSE_ALLOC_MEMSET 0
   13585             : #endif
   13586             : 
   13587             : #ifndef ROSE_PEDANTIC_ALLOC
   13588             : #  define ROSE_PEDANTIC_ALLOC 0
   13589             : #endif
   13590             : 
   13591             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   13592             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   13593             : #endif
   13594             : 
   13595             : #if !defined(SGNODE__ALL_POOLS)
   13596             : #define SGNODE__ALL_POOLS
   13597             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   13598             : #endif
   13599             : 
   13600             : SgGraphEdge* SgGraphEdge::next_node = nullptr;
   13601             : std::vector<unsigned char*> SgGraphEdge::pools;
   13602             : 
   13603             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   13604             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   13605             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   13606             : // around this macro definition rather than each use).
   13607             : #ifndef ALLOC_MUTEX
   13608             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   13609             :         do {                                                                     \
   13610             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   13611             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   13612             :                 abort();                                                         \
   13613             :             }                                                                    \
   13614             :         } while (0);
   13615             : #endif
   13616             : 
   13617             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   13618             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   13619             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   13620             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   13621             : 
   13622             : /*! \brief New operator for SgGraphEdge.
   13623             : 
   13624             :    This new operator implements memory pools to provide most efficent 
   13625             :    use of the heap within construction of large ASTs.
   13626             : 
   13627             : \internal The new and delete operators use the lower level C malloc/free
   13628             :    function calls for performance and to make sure that mixing of malloc/free
   13629             :    and new/delete by the used can be caught more readily.  This may change
   13630             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   13631             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   13632             :    deallocate memory allocated using ROSE_MALLOC.
   13633             : */
   13634           0 : void *SgGraphEdge::operator new ( size_t Size )
   13635             : {
   13636             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   13637             :      * returning or throwing an exception. */
   13638           0 :     ALLOC_MUTEX(SgGraphEdge, lock);
   13639             : 
   13640             : #if ROSE_ALLOC_TRACE == 2
   13641             : //    printf("SgGraphEdge::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgGraphEdge::next_node);
   13642             : #endif
   13643             : 
   13644             : #if USE_CPP_NEW_DELETE_OPERATORS
   13645             :     void *mem = ROSE_MALLOC(Size);
   13646             :     ALLOC_MUTEX(SgGraphEdge, unlock);
   13647             :     return mem;
   13648             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   13649             : #if ROSE_PEDANTIC_ALLOC
   13650             :     ROSE_ASSERT(Size == sizeof(SgGraphEdge));
   13651             : #else
   13652           0 :     if (Size != sizeof(SgGraphEdge)) {
   13653           0 :       void * object = ROSE_MALLOC(Size);
   13654           0 :       ALLOC_MUTEX(SgGraphEdge, unlock);
   13655             :       return object;
   13656             :     }
   13657             : #endif
   13658             : 
   13659           0 :     if (SgGraphEdge::next_node == nullptr) {
   13660           0 :         SgGraphEdge * alloc = (SgGraphEdge*) ROSE_MALLOC ( SgGraphEdge::pool_size * sizeof(SgGraphEdge) );
   13661           0 :         ROSE_ASSERT(alloc != nullptr);
   13662             : 
   13663             : #if ROSE_ALLOC_TRACE == 2
   13664             : //        printf("SgGraphEdge::alloc\n  block[%zi] = [ %p , %p [\n", SgGraphEdge::pools.size(), alloc, alloc + SgGraphEdge::pool_size);
   13665             : #endif
   13666             : 
   13667             : #if ROSE_ALLOC_MEMSET == 1
   13668             : #elif ROSE_ALLOC_MEMSET == 2
   13669             :         memset(alloc, 0x00, SgGraphEdge::pool_size * sizeof(SgGraphEdge));
   13670             : #elif ROSE_ALLOC_MEMSET == 3
   13671             :         memset(alloc, 0xAA, SgGraphEdge::pool_size * sizeof(SgGraphEdge));
   13672             : #endif
   13673           0 :         for (unsigned i=0; i < SgGraphEdge::pool_size-1; i++) {
   13674           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
   13675             :         }
   13676           0 :         alloc[SgGraphEdge::pool_size-1].p_freepointer = nullptr;
   13677             : 
   13678           0 :         SgGraphEdge::pools.push_back ( (unsigned char *) alloc );
   13679           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgGraphEdge::pool_size * sizeof(SgGraphEdge), V_SgGraphEdge ) );
   13680           0 :         SgGraphEdge::next_node = alloc;
   13681             :     }
   13682           0 :     ROSE_ASSERT(SgGraphEdge::next_node != nullptr);
   13683             : 
   13684           0 :     SgGraphEdge * object = SgGraphEdge::next_node;
   13685           0 :     SgGraphEdge::next_node = (SgGraphEdge*)(object->p_freepointer);
   13686             : 
   13687             : #if ROSE_ALLOC_TRACE == 2
   13688             :     printf("SgGraphEdge::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgGraphEdge::next_node);
   13689             : #endif
   13690             : 
   13691           0 :     SgNode * fp = object->p_freepointer;
   13692             : #if ROSE_ALLOC_MEMSET == 1
   13693             : #elif ROSE_ALLOC_MEMSET == 2
   13694             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgGraphEdge) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   13695             : #elif ROSE_ALLOC_MEMSET == 3
   13696             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgGraphEdge) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   13697             : #endif
   13698           0 :     object->p_freepointer = fp;
   13699             : 
   13700             : #if ROSE_ALLOC_TRACE == 2
   13701             : //    printf("SgGraphEdge::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgGraphEdge::next_node);
   13702             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   13703             :     Rose::MemPool::snapshot(oss.str());
   13704             :     alloc_trace_cnt++;
   13705             : #endif
   13706             : 
   13707           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   13708             : 
   13709           0 :     ALLOC_MUTEX(SgGraphEdge, unlock);
   13710             : 
   13711             :     return object;
   13712             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   13713             : }
   13714             : 
   13715             : 
   13716             : 
   13717             : /*! \brief Delete operator for SgGraphEdge.
   13718             : 
   13719             :    This delete operator implements deallocation using memory pools to 
   13720             :    provide most efficent use of the heap within construction of large ASTs.
   13721             : 
   13722             : \internal The new and delete operators use the lower level C malloc/free
   13723             :    function calls for performance and to make sure that mixing of malloc/free
   13724             :    and new/delete by the used can be caught more readily.  This may change
   13725             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   13726             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   13727             :    deallocate memory allocated using ROSE_MALLOC.
   13728             : */
   13729           0 : void SgGraphEdge::operator delete(void *Pointer, size_t Size)
   13730             : {
   13731             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   13732             :      * or throwing an exception. */
   13733           0 :     ALLOC_MUTEX(SgGraphEdge, lock);
   13734             : 
   13735             : #if USE_CPP_NEW_DELETE_OPERATORS
   13736             :     ROSE_FREE(Pointer);
   13737             : #else
   13738             : #if ROSE_PEDANTIC_ALLOC
   13739             :     ROSE_ASSERT(Size == sizeof(SgGraphEdge));
   13740             : #else
   13741           0 :     if (Size != sizeof(SgGraphEdge)) {
   13742           0 :       ROSE_FREE(Pointer);
   13743           0 :       ALLOC_MUTEX(SgGraphEdge, unlock);
   13744             :       return;
   13745             :     }
   13746             : #endif
   13747             : 
   13748           0 :     SgGraphEdge * object = (SgGraphEdge*) Pointer;
   13749           0 :     ROSE_ASSERT(object != nullptr);
   13750             : 
   13751             : #if ROSE_ALLOC_TRACE == 2
   13752             : //  printf("SgGraphEdge::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgGraphEdge::next_node);
   13753             :     printf("SgGraphEdge::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgGraphEdge::next_node);
   13754             : #endif
   13755             : 
   13756             : #if ROSE_PEDANTIC_ALLOC
   13757             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   13758             : #endif
   13759             : 
   13760             : #if ROSE_ALLOC_MEMSET == 1
   13761             : #elif ROSE_ALLOC_MEMSET == 2
   13762             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgGraphEdge) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   13763             : #elif ROSE_ALLOC_MEMSET == 3
   13764             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgGraphEdge) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   13765             : #endif
   13766             : 
   13767             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   13768             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   13769             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   13770             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   13771             : #else
   13772           0 :     object->p_freepointer = SgGraphEdge::next_node;
   13773           0 :     SgGraphEdge::next_node = object;
   13774             : #endif
   13775             : 
   13776             : #if ROSE_ALLOC_TRACE == 2
   13777             : //  printf("SgGraphEdge::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgGraphEdge::next_node);
   13778             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   13779             :     Rose::MemPool::snapshot(oss.str());
   13780             :     alloc_trace_cnt++;
   13781             : #endif
   13782             : 
   13783             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   13784             : 
   13785           0 :     ALLOC_MUTEX(SgGraphEdge, unlock);
   13786             : }
   13787             : 
   13788             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   13789             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   13790             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   13791             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   13792             : // Also, note comment below from Robb (copied from the Common.code file).
   13793             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   13794             : //
   13795             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   13796             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   13797             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   13798             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   13799             : #if 0
   13800             : void SgGraphEdge::operator delete(void* pointer) { SgGraphEdge::operator delete (pointer, sizeof(SgGraphEdge)); };
   13801             : #endif
   13802             : /* #line 13803 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   13803             : 
   13804             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   13805             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   13806             : // obviously imply C++.
   13807             : 
   13808             : // This implements the support within ROSE for memory pools.  Memory pools
   13809             : // support the most condensed usage of memory within the construction of
   13810             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   13811             : // by a new operator written for each class.
   13812             : 
   13813             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   13814             :     // User wants multi-thread support and POSIX threads are available.
   13815             : #   include <pthread.h>
   13816             :     static pthread_mutex_t SgDirectedGraphEdge_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   13817             : #else
   13818             :      // Cause synchronization to be skipped.
   13819             : #    ifndef ALLOC_MUTEX
   13820             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   13821             : #    endif
   13822             : #    ifdef _REENTRANT
   13823             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   13824             : #       ifdef _MSC_VER
   13825             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   13826             : #       else
   13827             : #           warning "POSIX threads are not available; synchronization being skipped"
   13828             : #       endif
   13829             : #    endif
   13830             : #endif
   13831             : 
   13832             : #ifndef ROSE_ALLOC_TRACE
   13833             : #  define ROSE_ALLOC_TRACE 0
   13834             : #endif
   13835             : 
   13836             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   13837             : #define ROSE_ALLOC_TRACE_CNT
   13838             : #include "memory-pool-snapshot.h"
   13839             : unsigned long alloc_trace_cnt = 0;
   13840             : #endif
   13841             : 
   13842             : #if ROSE_ALLOC_TRACE
   13843             : const unsigned SgDirectedGraphEdge::pool_size = 5;
   13844             : #else
   13845             : const unsigned SgDirectedGraphEdge::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   13846             : #endif
   13847             : 
   13848             : #ifndef ROSE_ALLOC_MEMSET
   13849             : #  define ROSE_ALLOC_MEMSET 0
   13850             : #endif
   13851             : 
   13852             : #ifndef ROSE_PEDANTIC_ALLOC
   13853             : #  define ROSE_PEDANTIC_ALLOC 0
   13854             : #endif
   13855             : 
   13856             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   13857             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   13858             : #endif
   13859             : 
   13860             : #if !defined(SGNODE__ALL_POOLS)
   13861             : #define SGNODE__ALL_POOLS
   13862             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   13863             : #endif
   13864             : 
   13865             : SgDirectedGraphEdge* SgDirectedGraphEdge::next_node = nullptr;
   13866             : std::vector<unsigned char*> SgDirectedGraphEdge::pools;
   13867             : 
   13868             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   13869             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   13870             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   13871             : // around this macro definition rather than each use).
   13872             : #ifndef ALLOC_MUTEX
   13873             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   13874             :         do {                                                                     \
   13875             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   13876             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   13877             :                 abort();                                                         \
   13878             :             }                                                                    \
   13879             :         } while (0);
   13880             : #endif
   13881             : 
   13882             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   13883             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   13884             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   13885             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   13886             : 
   13887             : /*! \brief New operator for SgDirectedGraphEdge.
   13888             : 
   13889             :    This new operator implements memory pools to provide most efficent 
   13890             :    use of the heap within construction of large ASTs.
   13891             : 
   13892             : \internal The new and delete operators use the lower level C malloc/free
   13893             :    function calls for performance and to make sure that mixing of malloc/free
   13894             :    and new/delete by the used can be caught more readily.  This may change
   13895             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   13896             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   13897             :    deallocate memory allocated using ROSE_MALLOC.
   13898             : */
   13899           0 : void *SgDirectedGraphEdge::operator new ( size_t Size )
   13900             : {
   13901             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   13902             :      * returning or throwing an exception. */
   13903           0 :     ALLOC_MUTEX(SgDirectedGraphEdge, lock);
   13904             : 
   13905             : #if ROSE_ALLOC_TRACE == 2
   13906             : //    printf("SgDirectedGraphEdge::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgDirectedGraphEdge::next_node);
   13907             : #endif
   13908             : 
   13909             : #if USE_CPP_NEW_DELETE_OPERATORS
   13910             :     void *mem = ROSE_MALLOC(Size);
   13911             :     ALLOC_MUTEX(SgDirectedGraphEdge, unlock);
   13912             :     return mem;
   13913             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   13914             : #if ROSE_PEDANTIC_ALLOC
   13915             :     ROSE_ASSERT(Size == sizeof(SgDirectedGraphEdge));
   13916             : #else
   13917           0 :     if (Size != sizeof(SgDirectedGraphEdge)) {
   13918           0 :       void * object = ROSE_MALLOC(Size);
   13919           0 :       ALLOC_MUTEX(SgDirectedGraphEdge, unlock);
   13920             :       return object;
   13921             :     }
   13922             : #endif
   13923             : 
   13924           0 :     if (SgDirectedGraphEdge::next_node == nullptr) {
   13925           0 :         SgDirectedGraphEdge * alloc = (SgDirectedGraphEdge*) ROSE_MALLOC ( SgDirectedGraphEdge::pool_size * sizeof(SgDirectedGraphEdge) );
   13926           0 :         ROSE_ASSERT(alloc != nullptr);
   13927             : 
   13928             : #if ROSE_ALLOC_TRACE == 2
   13929             : //        printf("SgDirectedGraphEdge::alloc\n  block[%zi] = [ %p , %p [\n", SgDirectedGraphEdge::pools.size(), alloc, alloc + SgDirectedGraphEdge::pool_size);
   13930             : #endif
   13931             : 
   13932             : #if ROSE_ALLOC_MEMSET == 1
   13933             : #elif ROSE_ALLOC_MEMSET == 2
   13934             :         memset(alloc, 0x00, SgDirectedGraphEdge::pool_size * sizeof(SgDirectedGraphEdge));
   13935             : #elif ROSE_ALLOC_MEMSET == 3
   13936             :         memset(alloc, 0xAA, SgDirectedGraphEdge::pool_size * sizeof(SgDirectedGraphEdge));
   13937             : #endif
   13938           0 :         for (unsigned i=0; i < SgDirectedGraphEdge::pool_size-1; i++) {
   13939           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
   13940             :         }
   13941           0 :         alloc[SgDirectedGraphEdge::pool_size-1].p_freepointer = nullptr;
   13942             : 
   13943           0 :         SgDirectedGraphEdge::pools.push_back ( (unsigned char *) alloc );
   13944           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgDirectedGraphEdge::pool_size * sizeof(SgDirectedGraphEdge), V_SgDirectedGraphEdge ) );
   13945           0 :         SgDirectedGraphEdge::next_node = alloc;
   13946             :     }
   13947           0 :     ROSE_ASSERT(SgDirectedGraphEdge::next_node != nullptr);
   13948             : 
   13949           0 :     SgDirectedGraphEdge * object = SgDirectedGraphEdge::next_node;
   13950           0 :     SgDirectedGraphEdge::next_node = (SgDirectedGraphEdge*)(object->p_freepointer);
   13951             : 
   13952             : #if ROSE_ALLOC_TRACE == 2
   13953             :     printf("SgDirectedGraphEdge::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgDirectedGraphEdge::next_node);
   13954             : #endif
   13955             : 
   13956           0 :     SgNode * fp = object->p_freepointer;
   13957             : #if ROSE_ALLOC_MEMSET == 1
   13958             : #elif ROSE_ALLOC_MEMSET == 2
   13959             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgDirectedGraphEdge) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   13960             : #elif ROSE_ALLOC_MEMSET == 3
   13961             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgDirectedGraphEdge) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   13962             : #endif
   13963           0 :     object->p_freepointer = fp;
   13964             : 
   13965             : #if ROSE_ALLOC_TRACE == 2
   13966             : //    printf("SgDirectedGraphEdge::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgDirectedGraphEdge::next_node);
   13967             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   13968             :     Rose::MemPool::snapshot(oss.str());
   13969             :     alloc_trace_cnt++;
   13970             : #endif
   13971             : 
   13972           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   13973             : 
   13974           0 :     ALLOC_MUTEX(SgDirectedGraphEdge, unlock);
   13975             : 
   13976             :     return object;
   13977             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   13978             : }
   13979             : 
   13980             : 
   13981             : 
   13982             : /*! \brief Delete operator for SgDirectedGraphEdge.
   13983             : 
   13984             :    This delete operator implements deallocation using memory pools to 
   13985             :    provide most efficent use of the heap within construction of large ASTs.
   13986             : 
   13987             : \internal The new and delete operators use the lower level C malloc/free
   13988             :    function calls for performance and to make sure that mixing of malloc/free
   13989             :    and new/delete by the used can be caught more readily.  This may change
   13990             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   13991             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   13992             :    deallocate memory allocated using ROSE_MALLOC.
   13993             : */
   13994           0 : void SgDirectedGraphEdge::operator delete(void *Pointer, size_t Size)
   13995             : {
   13996             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   13997             :      * or throwing an exception. */
   13998           0 :     ALLOC_MUTEX(SgDirectedGraphEdge, lock);
   13999             : 
   14000             : #if USE_CPP_NEW_DELETE_OPERATORS
   14001             :     ROSE_FREE(Pointer);
   14002             : #else
   14003             : #if ROSE_PEDANTIC_ALLOC
   14004             :     ROSE_ASSERT(Size == sizeof(SgDirectedGraphEdge));
   14005             : #else
   14006           0 :     if (Size != sizeof(SgDirectedGraphEdge)) {
   14007           0 :       ROSE_FREE(Pointer);
   14008           0 :       ALLOC_MUTEX(SgDirectedGraphEdge, unlock);
   14009             :       return;
   14010             :     }
   14011             : #endif
   14012             : 
   14013           0 :     SgDirectedGraphEdge * object = (SgDirectedGraphEdge*) Pointer;
   14014           0 :     ROSE_ASSERT(object != nullptr);
   14015             : 
   14016             : #if ROSE_ALLOC_TRACE == 2
   14017             : //  printf("SgDirectedGraphEdge::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgDirectedGraphEdge::next_node);
   14018             :     printf("SgDirectedGraphEdge::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgDirectedGraphEdge::next_node);
   14019             : #endif
   14020             : 
   14021             : #if ROSE_PEDANTIC_ALLOC
   14022             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   14023             : #endif
   14024             : 
   14025             : #if ROSE_ALLOC_MEMSET == 1
   14026             : #elif ROSE_ALLOC_MEMSET == 2
   14027             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgDirectedGraphEdge) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   14028             : #elif ROSE_ALLOC_MEMSET == 3
   14029             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgDirectedGraphEdge) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   14030             : #endif
   14031             : 
   14032             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   14033             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   14034             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   14035             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   14036             : #else
   14037           0 :     object->p_freepointer = SgDirectedGraphEdge::next_node;
   14038           0 :     SgDirectedGraphEdge::next_node = object;
   14039             : #endif
   14040             : 
   14041             : #if ROSE_ALLOC_TRACE == 2
   14042             : //  printf("SgDirectedGraphEdge::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgDirectedGraphEdge::next_node);
   14043             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   14044             :     Rose::MemPool::snapshot(oss.str());
   14045             :     alloc_trace_cnt++;
   14046             : #endif
   14047             : 
   14048             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   14049             : 
   14050           0 :     ALLOC_MUTEX(SgDirectedGraphEdge, unlock);
   14051             : }
   14052             : 
   14053             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   14054             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   14055             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   14056             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   14057             : // Also, note comment below from Robb (copied from the Common.code file).
   14058             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   14059             : //
   14060             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   14061             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   14062             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   14063             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   14064             : #if 0
   14065             : void SgDirectedGraphEdge::operator delete(void* pointer) { SgDirectedGraphEdge::operator delete (pointer, sizeof(SgDirectedGraphEdge)); };
   14066             : #endif
   14067             : /* #line 14068 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   14068             : 
   14069             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   14070             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   14071             : // obviously imply C++.
   14072             : 
   14073             : // This implements the support within ROSE for memory pools.  Memory pools
   14074             : // support the most condensed usage of memory within the construction of
   14075             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   14076             : // by a new operator written for each class.
   14077             : 
   14078             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   14079             :     // User wants multi-thread support and POSIX threads are available.
   14080             : #   include <pthread.h>
   14081             :     static pthread_mutex_t SgUndirectedGraphEdge_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   14082             : #else
   14083             :      // Cause synchronization to be skipped.
   14084             : #    ifndef ALLOC_MUTEX
   14085             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   14086             : #    endif
   14087             : #    ifdef _REENTRANT
   14088             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   14089             : #       ifdef _MSC_VER
   14090             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   14091             : #       else
   14092             : #           warning "POSIX threads are not available; synchronization being skipped"
   14093             : #       endif
   14094             : #    endif
   14095             : #endif
   14096             : 
   14097             : #ifndef ROSE_ALLOC_TRACE
   14098             : #  define ROSE_ALLOC_TRACE 0
   14099             : #endif
   14100             : 
   14101             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   14102             : #define ROSE_ALLOC_TRACE_CNT
   14103             : #include "memory-pool-snapshot.h"
   14104             : unsigned long alloc_trace_cnt = 0;
   14105             : #endif
   14106             : 
   14107             : #if ROSE_ALLOC_TRACE
   14108             : const unsigned SgUndirectedGraphEdge::pool_size = 5;
   14109             : #else
   14110             : const unsigned SgUndirectedGraphEdge::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   14111             : #endif
   14112             : 
   14113             : #ifndef ROSE_ALLOC_MEMSET
   14114             : #  define ROSE_ALLOC_MEMSET 0
   14115             : #endif
   14116             : 
   14117             : #ifndef ROSE_PEDANTIC_ALLOC
   14118             : #  define ROSE_PEDANTIC_ALLOC 0
   14119             : #endif
   14120             : 
   14121             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   14122             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   14123             : #endif
   14124             : 
   14125             : #if !defined(SGNODE__ALL_POOLS)
   14126             : #define SGNODE__ALL_POOLS
   14127             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   14128             : #endif
   14129             : 
   14130             : SgUndirectedGraphEdge* SgUndirectedGraphEdge::next_node = nullptr;
   14131             : std::vector<unsigned char*> SgUndirectedGraphEdge::pools;
   14132             : 
   14133             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   14134             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   14135             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   14136             : // around this macro definition rather than each use).
   14137             : #ifndef ALLOC_MUTEX
   14138             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   14139             :         do {                                                                     \
   14140             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   14141             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   14142             :                 abort();                                                         \
   14143             :             }                                                                    \
   14144             :         } while (0);
   14145             : #endif
   14146             : 
   14147             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   14148             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   14149             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   14150             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   14151             : 
   14152             : /*! \brief New operator for SgUndirectedGraphEdge.
   14153             : 
   14154             :    This new operator implements memory pools to provide most efficent 
   14155             :    use of the heap within construction of large ASTs.
   14156             : 
   14157             : \internal The new and delete operators use the lower level C malloc/free
   14158             :    function calls for performance and to make sure that mixing of malloc/free
   14159             :    and new/delete by the used can be caught more readily.  This may change
   14160             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   14161             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   14162             :    deallocate memory allocated using ROSE_MALLOC.
   14163             : */
   14164           0 : void *SgUndirectedGraphEdge::operator new ( size_t Size )
   14165             : {
   14166             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   14167             :      * returning or throwing an exception. */
   14168           0 :     ALLOC_MUTEX(SgUndirectedGraphEdge, lock);
   14169             : 
   14170             : #if ROSE_ALLOC_TRACE == 2
   14171             : //    printf("SgUndirectedGraphEdge::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgUndirectedGraphEdge::next_node);
   14172             : #endif
   14173             : 
   14174             : #if USE_CPP_NEW_DELETE_OPERATORS
   14175             :     void *mem = ROSE_MALLOC(Size);
   14176             :     ALLOC_MUTEX(SgUndirectedGraphEdge, unlock);
   14177             :     return mem;
   14178             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   14179             : #if ROSE_PEDANTIC_ALLOC
   14180             :     ROSE_ASSERT(Size == sizeof(SgUndirectedGraphEdge));
   14181             : #else
   14182           0 :     if (Size != sizeof(SgUndirectedGraphEdge)) {
   14183           0 :       void * object = ROSE_MALLOC(Size);
   14184           0 :       ALLOC_MUTEX(SgUndirectedGraphEdge, unlock);
   14185             :       return object;
   14186             :     }
   14187             : #endif
   14188             : 
   14189           0 :     if (SgUndirectedGraphEdge::next_node == nullptr) {
   14190           0 :         SgUndirectedGraphEdge * alloc = (SgUndirectedGraphEdge*) ROSE_MALLOC ( SgUndirectedGraphEdge::pool_size * sizeof(SgUndirectedGraphEdge) );
   14191           0 :         ROSE_ASSERT(alloc != nullptr);
   14192             : 
   14193             : #if ROSE_ALLOC_TRACE == 2
   14194             : //        printf("SgUndirectedGraphEdge::alloc\n  block[%zi] = [ %p , %p [\n", SgUndirectedGraphEdge::pools.size(), alloc, alloc + SgUndirectedGraphEdge::pool_size);
   14195             : #endif
   14196             : 
   14197             : #if ROSE_ALLOC_MEMSET == 1
   14198             : #elif ROSE_ALLOC_MEMSET == 2
   14199             :         memset(alloc, 0x00, SgUndirectedGraphEdge::pool_size * sizeof(SgUndirectedGraphEdge));
   14200             : #elif ROSE_ALLOC_MEMSET == 3
   14201             :         memset(alloc, 0xAA, SgUndirectedGraphEdge::pool_size * sizeof(SgUndirectedGraphEdge));
   14202             : #endif
   14203           0 :         for (unsigned i=0; i < SgUndirectedGraphEdge::pool_size-1; i++) {
   14204           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
   14205             :         }
   14206           0 :         alloc[SgUndirectedGraphEdge::pool_size-1].p_freepointer = nullptr;
   14207             : 
   14208           0 :         SgUndirectedGraphEdge::pools.push_back ( (unsigned char *) alloc );
   14209           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgUndirectedGraphEdge::pool_size * sizeof(SgUndirectedGraphEdge), V_SgUndirectedGraphEdge ) );
   14210           0 :         SgUndirectedGraphEdge::next_node = alloc;
   14211             :     }
   14212           0 :     ROSE_ASSERT(SgUndirectedGraphEdge::next_node != nullptr);
   14213             : 
   14214           0 :     SgUndirectedGraphEdge * object = SgUndirectedGraphEdge::next_node;
   14215           0 :     SgUndirectedGraphEdge::next_node = (SgUndirectedGraphEdge*)(object->p_freepointer);
   14216             : 
   14217             : #if ROSE_ALLOC_TRACE == 2
   14218             :     printf("SgUndirectedGraphEdge::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUndirectedGraphEdge::next_node);
   14219             : #endif
   14220             : 
   14221           0 :     SgNode * fp = object->p_freepointer;
   14222             : #if ROSE_ALLOC_MEMSET == 1
   14223             : #elif ROSE_ALLOC_MEMSET == 2
   14224             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgUndirectedGraphEdge) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   14225             : #elif ROSE_ALLOC_MEMSET == 3
   14226             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgUndirectedGraphEdge) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   14227             : #endif
   14228           0 :     object->p_freepointer = fp;
   14229             : 
   14230             : #if ROSE_ALLOC_TRACE == 2
   14231             : //    printf("SgUndirectedGraphEdge::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUndirectedGraphEdge::next_node);
   14232             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   14233             :     Rose::MemPool::snapshot(oss.str());
   14234             :     alloc_trace_cnt++;
   14235             : #endif
   14236             : 
   14237           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   14238             : 
   14239           0 :     ALLOC_MUTEX(SgUndirectedGraphEdge, unlock);
   14240             : 
   14241             :     return object;
   14242             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   14243             : }
   14244             : 
   14245             : 
   14246             : 
   14247             : /*! \brief Delete operator for SgUndirectedGraphEdge.
   14248             : 
   14249             :    This delete operator implements deallocation using memory pools to 
   14250             :    provide most efficent use of the heap within construction of large ASTs.
   14251             : 
   14252             : \internal The new and delete operators use the lower level C malloc/free
   14253             :    function calls for performance and to make sure that mixing of malloc/free
   14254             :    and new/delete by the used can be caught more readily.  This may change
   14255             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   14256             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   14257             :    deallocate memory allocated using ROSE_MALLOC.
   14258             : */
   14259           0 : void SgUndirectedGraphEdge::operator delete(void *Pointer, size_t Size)
   14260             : {
   14261             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   14262             :      * or throwing an exception. */
   14263           0 :     ALLOC_MUTEX(SgUndirectedGraphEdge, lock);
   14264             : 
   14265             : #if USE_CPP_NEW_DELETE_OPERATORS
   14266             :     ROSE_FREE(Pointer);
   14267             : #else
   14268             : #if ROSE_PEDANTIC_ALLOC
   14269             :     ROSE_ASSERT(Size == sizeof(SgUndirectedGraphEdge));
   14270             : #else
   14271           0 :     if (Size != sizeof(SgUndirectedGraphEdge)) {
   14272           0 :       ROSE_FREE(Pointer);
   14273           0 :       ALLOC_MUTEX(SgUndirectedGraphEdge, unlock);
   14274             :       return;
   14275             :     }
   14276             : #endif
   14277             : 
   14278           0 :     SgUndirectedGraphEdge * object = (SgUndirectedGraphEdge*) Pointer;
   14279           0 :     ROSE_ASSERT(object != nullptr);
   14280             : 
   14281             : #if ROSE_ALLOC_TRACE == 2
   14282             : //  printf("SgUndirectedGraphEdge::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUndirectedGraphEdge::next_node);
   14283             :     printf("SgUndirectedGraphEdge::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUndirectedGraphEdge::next_node);
   14284             : #endif
   14285             : 
   14286             : #if ROSE_PEDANTIC_ALLOC
   14287             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   14288             : #endif
   14289             : 
   14290             : #if ROSE_ALLOC_MEMSET == 1
   14291             : #elif ROSE_ALLOC_MEMSET == 2
   14292             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgUndirectedGraphEdge) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   14293             : #elif ROSE_ALLOC_MEMSET == 3
   14294             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgUndirectedGraphEdge) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   14295             : #endif
   14296             : 
   14297             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   14298             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   14299             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   14300             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   14301             : #else
   14302           0 :     object->p_freepointer = SgUndirectedGraphEdge::next_node;
   14303           0 :     SgUndirectedGraphEdge::next_node = object;
   14304             : #endif
   14305             : 
   14306             : #if ROSE_ALLOC_TRACE == 2
   14307             : //  printf("SgUndirectedGraphEdge::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUndirectedGraphEdge::next_node);
   14308             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   14309             :     Rose::MemPool::snapshot(oss.str());
   14310             :     alloc_trace_cnt++;
   14311             : #endif
   14312             : 
   14313             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   14314             : 
   14315           0 :     ALLOC_MUTEX(SgUndirectedGraphEdge, unlock);
   14316             : }
   14317             : 
   14318             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   14319             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   14320             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   14321             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   14322             : // Also, note comment below from Robb (copied from the Common.code file).
   14323             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   14324             : //
   14325             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   14326             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   14327             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   14328             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   14329             : #if 0
   14330             : void SgUndirectedGraphEdge::operator delete(void* pointer) { SgUndirectedGraphEdge::operator delete (pointer, sizeof(SgUndirectedGraphEdge)); };
   14331             : #endif
   14332             : /* #line 14333 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   14333             : 
   14334             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   14335             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   14336             : // obviously imply C++.
   14337             : 
   14338             : // This implements the support within ROSE for memory pools.  Memory pools
   14339             : // support the most condensed usage of memory within the construction of
   14340             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   14341             : // by a new operator written for each class.
   14342             : 
   14343             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   14344             :     // User wants multi-thread support and POSIX threads are available.
   14345             : #   include <pthread.h>
   14346             :     static pthread_mutex_t SgGraphNodeList_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   14347             : #else
   14348             :      // Cause synchronization to be skipped.
   14349             : #    ifndef ALLOC_MUTEX
   14350             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   14351             : #    endif
   14352             : #    ifdef _REENTRANT
   14353             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   14354             : #       ifdef _MSC_VER
   14355             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   14356             : #       else
   14357             : #           warning "POSIX threads are not available; synchronization being skipped"
   14358             : #       endif
   14359             : #    endif
   14360             : #endif
   14361             : 
   14362             : #ifndef ROSE_ALLOC_TRACE
   14363             : #  define ROSE_ALLOC_TRACE 0
   14364             : #endif
   14365             : 
   14366             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   14367             : #define ROSE_ALLOC_TRACE_CNT
   14368             : #include "memory-pool-snapshot.h"
   14369             : unsigned long alloc_trace_cnt = 0;
   14370             : #endif
   14371             : 
   14372             : #if ROSE_ALLOC_TRACE
   14373             : const unsigned SgGraphNodeList::pool_size = 5;
   14374             : #else
   14375             : const unsigned SgGraphNodeList::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   14376             : #endif
   14377             : 
   14378             : #ifndef ROSE_ALLOC_MEMSET
   14379             : #  define ROSE_ALLOC_MEMSET 0
   14380             : #endif
   14381             : 
   14382             : #ifndef ROSE_PEDANTIC_ALLOC
   14383             : #  define ROSE_PEDANTIC_ALLOC 0
   14384             : #endif
   14385             : 
   14386             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   14387             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   14388             : #endif
   14389             : 
   14390             : #if !defined(SGNODE__ALL_POOLS)
   14391             : #define SGNODE__ALL_POOLS
   14392             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   14393             : #endif
   14394             : 
   14395             : SgGraphNodeList* SgGraphNodeList::next_node = nullptr;
   14396             : std::vector<unsigned char*> SgGraphNodeList::pools;
   14397             : 
   14398             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   14399             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   14400             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   14401             : // around this macro definition rather than each use).
   14402             : #ifndef ALLOC_MUTEX
   14403             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   14404             :         do {                                                                     \
   14405             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   14406             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   14407             :                 abort();                                                         \
   14408             :             }                                                                    \
   14409             :         } while (0);
   14410             : #endif
   14411             : 
   14412             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   14413             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   14414             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   14415             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   14416             : 
   14417             : /*! \brief New operator for SgGraphNodeList.
   14418             : 
   14419             :    This new operator implements memory pools to provide most efficent 
   14420             :    use of the heap within construction of large ASTs.
   14421             : 
   14422             : \internal The new and delete operators use the lower level C malloc/free
   14423             :    function calls for performance and to make sure that mixing of malloc/free
   14424             :    and new/delete by the used can be caught more readily.  This may change
   14425             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   14426             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   14427             :    deallocate memory allocated using ROSE_MALLOC.
   14428             : */
   14429           0 : void *SgGraphNodeList::operator new ( size_t Size )
   14430             : {
   14431             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   14432             :      * returning or throwing an exception. */
   14433           0 :     ALLOC_MUTEX(SgGraphNodeList, lock);
   14434             : 
   14435             : #if ROSE_ALLOC_TRACE == 2
   14436             : //    printf("SgGraphNodeList::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgGraphNodeList::next_node);
   14437             : #endif
   14438             : 
   14439             : #if USE_CPP_NEW_DELETE_OPERATORS
   14440             :     void *mem = ROSE_MALLOC(Size);
   14441             :     ALLOC_MUTEX(SgGraphNodeList, unlock);
   14442             :     return mem;
   14443             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   14444             : #if ROSE_PEDANTIC_ALLOC
   14445             :     ROSE_ASSERT(Size == sizeof(SgGraphNodeList));
   14446             : #else
   14447           0 :     if (Size != sizeof(SgGraphNodeList)) {
   14448           0 :       void * object = ROSE_MALLOC(Size);
   14449           0 :       ALLOC_MUTEX(SgGraphNodeList, unlock);
   14450             :       return object;
   14451             :     }
   14452             : #endif
   14453             : 
   14454           0 :     if (SgGraphNodeList::next_node == nullptr) {
   14455           0 :         SgGraphNodeList * alloc = (SgGraphNodeList*) ROSE_MALLOC ( SgGraphNodeList::pool_size * sizeof(SgGraphNodeList) );
   14456           0 :         ROSE_ASSERT(alloc != nullptr);
   14457             : 
   14458             : #if ROSE_ALLOC_TRACE == 2
   14459             : //        printf("SgGraphNodeList::alloc\n  block[%zi] = [ %p , %p [\n", SgGraphNodeList::pools.size(), alloc, alloc + SgGraphNodeList::pool_size);
   14460             : #endif
   14461             : 
   14462             : #if ROSE_ALLOC_MEMSET == 1
   14463             : #elif ROSE_ALLOC_MEMSET == 2
   14464             :         memset(alloc, 0x00, SgGraphNodeList::pool_size * sizeof(SgGraphNodeList));
   14465             : #elif ROSE_ALLOC_MEMSET == 3
   14466             :         memset(alloc, 0xAA, SgGraphNodeList::pool_size * sizeof(SgGraphNodeList));
   14467             : #endif
   14468           0 :         for (unsigned i=0; i < SgGraphNodeList::pool_size-1; i++) {
   14469           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
   14470             :         }
   14471           0 :         alloc[SgGraphNodeList::pool_size-1].p_freepointer = nullptr;
   14472             : 
   14473           0 :         SgGraphNodeList::pools.push_back ( (unsigned char *) alloc );
   14474           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgGraphNodeList::pool_size * sizeof(SgGraphNodeList), V_SgGraphNodeList ) );
   14475           0 :         SgGraphNodeList::next_node = alloc;
   14476             :     }
   14477           0 :     ROSE_ASSERT(SgGraphNodeList::next_node != nullptr);
   14478             : 
   14479           0 :     SgGraphNodeList * object = SgGraphNodeList::next_node;
   14480           0 :     SgGraphNodeList::next_node = (SgGraphNodeList*)(object->p_freepointer);
   14481             : 
   14482             : #if ROSE_ALLOC_TRACE == 2
   14483             :     printf("SgGraphNodeList::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgGraphNodeList::next_node);
   14484             : #endif
   14485             : 
   14486           0 :     SgNode * fp = object->p_freepointer;
   14487             : #if ROSE_ALLOC_MEMSET == 1
   14488             : #elif ROSE_ALLOC_MEMSET == 2
   14489             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgGraphNodeList) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   14490             : #elif ROSE_ALLOC_MEMSET == 3
   14491             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgGraphNodeList) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   14492             : #endif
   14493           0 :     object->p_freepointer = fp;
   14494             : 
   14495             : #if ROSE_ALLOC_TRACE == 2
   14496             : //    printf("SgGraphNodeList::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgGraphNodeList::next_node);
   14497             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   14498             :     Rose::MemPool::snapshot(oss.str());
   14499             :     alloc_trace_cnt++;
   14500             : #endif
   14501             : 
   14502           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   14503             : 
   14504           0 :     ALLOC_MUTEX(SgGraphNodeList, unlock);
   14505             : 
   14506             :     return object;
   14507             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   14508             : }
   14509             : 
   14510             : 
   14511             : 
   14512             : /*! \brief Delete operator for SgGraphNodeList.
   14513             : 
   14514             :    This delete operator implements deallocation using memory pools to 
   14515             :    provide most efficent use of the heap within construction of large ASTs.
   14516             : 
   14517             : \internal The new and delete operators use the lower level C malloc/free
   14518             :    function calls for performance and to make sure that mixing of malloc/free
   14519             :    and new/delete by the used can be caught more readily.  This may change
   14520             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   14521             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   14522             :    deallocate memory allocated using ROSE_MALLOC.
   14523             : */
   14524           0 : void SgGraphNodeList::operator delete(void *Pointer, size_t Size)
   14525             : {
   14526             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   14527             :      * or throwing an exception. */
   14528           0 :     ALLOC_MUTEX(SgGraphNodeList, lock);
   14529             : 
   14530             : #if USE_CPP_NEW_DELETE_OPERATORS
   14531             :     ROSE_FREE(Pointer);
   14532             : #else
   14533             : #if ROSE_PEDANTIC_ALLOC
   14534             :     ROSE_ASSERT(Size == sizeof(SgGraphNodeList));
   14535             : #else
   14536           0 :     if (Size != sizeof(SgGraphNodeList)) {
   14537           0 :       ROSE_FREE(Pointer);
   14538           0 :       ALLOC_MUTEX(SgGraphNodeList, unlock);
   14539             :       return;
   14540             :     }
   14541             : #endif
   14542             : 
   14543           0 :     SgGraphNodeList * object = (SgGraphNodeList*) Pointer;
   14544           0 :     ROSE_ASSERT(object != nullptr);
   14545             : 
   14546             : #if ROSE_ALLOC_TRACE == 2
   14547             : //  printf("SgGraphNodeList::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgGraphNodeList::next_node);
   14548             :     printf("SgGraphNodeList::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgGraphNodeList::next_node);
   14549             : #endif
   14550             : 
   14551             : #if ROSE_PEDANTIC_ALLOC
   14552             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   14553             : #endif
   14554             : 
   14555             : #if ROSE_ALLOC_MEMSET == 1
   14556             : #elif ROSE_ALLOC_MEMSET == 2
   14557             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgGraphNodeList) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   14558             : #elif ROSE_ALLOC_MEMSET == 3
   14559             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgGraphNodeList) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   14560             : #endif
   14561             : 
   14562             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   14563             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   14564             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   14565             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   14566             : #else
   14567           0 :     object->p_freepointer = SgGraphNodeList::next_node;
   14568           0 :     SgGraphNodeList::next_node = object;
   14569             : #endif
   14570             : 
   14571             : #if ROSE_ALLOC_TRACE == 2
   14572             : //  printf("SgGraphNodeList::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgGraphNodeList::next_node);
   14573             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   14574             :     Rose::MemPool::snapshot(oss.str());
   14575             :     alloc_trace_cnt++;
   14576             : #endif
   14577             : 
   14578             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   14579             : 
   14580           0 :     ALLOC_MUTEX(SgGraphNodeList, unlock);
   14581             : }
   14582             : 
   14583             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   14584             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   14585             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   14586             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   14587             : // Also, note comment below from Robb (copied from the Common.code file).
   14588             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   14589             : //
   14590             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   14591             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   14592             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   14593             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   14594             : #if 0
   14595             : void SgGraphNodeList::operator delete(void* pointer) { SgGraphNodeList::operator delete (pointer, sizeof(SgGraphNodeList)); };
   14596             : #endif
   14597             : /* #line 14598 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   14598             : 
   14599             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   14600             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   14601             : // obviously imply C++.
   14602             : 
   14603             : // This implements the support within ROSE for memory pools.  Memory pools
   14604             : // support the most condensed usage of memory within the construction of
   14605             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   14606             : // by a new operator written for each class.
   14607             : 
   14608             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   14609             :     // User wants multi-thread support and POSIX threads are available.
   14610             : #   include <pthread.h>
   14611             :     static pthread_mutex_t SgGraphEdgeList_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   14612             : #else
   14613             :      // Cause synchronization to be skipped.
   14614             : #    ifndef ALLOC_MUTEX
   14615             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   14616             : #    endif
   14617             : #    ifdef _REENTRANT
   14618             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   14619             : #       ifdef _MSC_VER
   14620             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   14621             : #       else
   14622             : #           warning "POSIX threads are not available; synchronization being skipped"
   14623             : #       endif
   14624             : #    endif
   14625             : #endif
   14626             : 
   14627             : #ifndef ROSE_ALLOC_TRACE
   14628             : #  define ROSE_ALLOC_TRACE 0
   14629             : #endif
   14630             : 
   14631             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   14632             : #define ROSE_ALLOC_TRACE_CNT
   14633             : #include "memory-pool-snapshot.h"
   14634             : unsigned long alloc_trace_cnt = 0;
   14635             : #endif
   14636             : 
   14637             : #if ROSE_ALLOC_TRACE
   14638             : const unsigned SgGraphEdgeList::pool_size = 5;
   14639             : #else
   14640             : const unsigned SgGraphEdgeList::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   14641             : #endif
   14642             : 
   14643             : #ifndef ROSE_ALLOC_MEMSET
   14644             : #  define ROSE_ALLOC_MEMSET 0
   14645             : #endif
   14646             : 
   14647             : #ifndef ROSE_PEDANTIC_ALLOC
   14648             : #  define ROSE_PEDANTIC_ALLOC 0
   14649             : #endif
   14650             : 
   14651             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   14652             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   14653             : #endif
   14654             : 
   14655             : #if !defined(SGNODE__ALL_POOLS)
   14656             : #define SGNODE__ALL_POOLS
   14657             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   14658             : #endif
   14659             : 
   14660             : SgGraphEdgeList* SgGraphEdgeList::next_node = nullptr;
   14661             : std::vector<unsigned char*> SgGraphEdgeList::pools;
   14662             : 
   14663             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   14664             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   14665             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   14666             : // around this macro definition rather than each use).
   14667             : #ifndef ALLOC_MUTEX
   14668             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   14669             :         do {                                                                     \
   14670             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   14671             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   14672             :                 abort();                                                         \
   14673             :             }                                                                    \
   14674             :         } while (0);
   14675             : #endif
   14676             : 
   14677             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   14678             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   14679             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   14680             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   14681             : 
   14682             : /*! \brief New operator for SgGraphEdgeList.
   14683             : 
   14684             :    This new operator implements memory pools to provide most efficent 
   14685             :    use of the heap within construction of large ASTs.
   14686             : 
   14687             : \internal The new and delete operators use the lower level C malloc/free
   14688             :    function calls for performance and to make sure that mixing of malloc/free
   14689             :    and new/delete by the used can be caught more readily.  This may change
   14690             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   14691             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   14692             :    deallocate memory allocated using ROSE_MALLOC.
   14693             : */
   14694           0 : void *SgGraphEdgeList::operator new ( size_t Size )
   14695             : {
   14696             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   14697             :      * returning or throwing an exception. */
   14698           0 :     ALLOC_MUTEX(SgGraphEdgeList, lock);
   14699             : 
   14700             : #if ROSE_ALLOC_TRACE == 2
   14701             : //    printf("SgGraphEdgeList::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgGraphEdgeList::next_node);
   14702             : #endif
   14703             : 
   14704             : #if USE_CPP_NEW_DELETE_OPERATORS
   14705             :     void *mem = ROSE_MALLOC(Size);
   14706             :     ALLOC_MUTEX(SgGraphEdgeList, unlock);
   14707             :     return mem;
   14708             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   14709             : #if ROSE_PEDANTIC_ALLOC
   14710             :     ROSE_ASSERT(Size == sizeof(SgGraphEdgeList));
   14711             : #else
   14712           0 :     if (Size != sizeof(SgGraphEdgeList)) {
   14713           0 :       void * object = ROSE_MALLOC(Size);
   14714           0 :       ALLOC_MUTEX(SgGraphEdgeList, unlock);
   14715             :       return object;
   14716             :     }
   14717             : #endif
   14718             : 
   14719           0 :     if (SgGraphEdgeList::next_node == nullptr) {
   14720           0 :         SgGraphEdgeList * alloc = (SgGraphEdgeList*) ROSE_MALLOC ( SgGraphEdgeList::pool_size * sizeof(SgGraphEdgeList) );
   14721           0 :         ROSE_ASSERT(alloc != nullptr);
   14722             : 
   14723             : #if ROSE_ALLOC_TRACE == 2
   14724             : //        printf("SgGraphEdgeList::alloc\n  block[%zi] = [ %p , %p [\n", SgGraphEdgeList::pools.size(), alloc, alloc + SgGraphEdgeList::pool_size);
   14725             : #endif
   14726             : 
   14727             : #if ROSE_ALLOC_MEMSET == 1
   14728             : #elif ROSE_ALLOC_MEMSET == 2
   14729             :         memset(alloc, 0x00, SgGraphEdgeList::pool_size * sizeof(SgGraphEdgeList));
   14730             : #elif ROSE_ALLOC_MEMSET == 3
   14731             :         memset(alloc, 0xAA, SgGraphEdgeList::pool_size * sizeof(SgGraphEdgeList));
   14732             : #endif
   14733           0 :         for (unsigned i=0; i < SgGraphEdgeList::pool_size-1; i++) {
   14734           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
   14735             :         }
   14736           0 :         alloc[SgGraphEdgeList::pool_size-1].p_freepointer = nullptr;
   14737             : 
   14738           0 :         SgGraphEdgeList::pools.push_back ( (unsigned char *) alloc );
   14739           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgGraphEdgeList::pool_size * sizeof(SgGraphEdgeList), V_SgGraphEdgeList ) );
   14740           0 :         SgGraphEdgeList::next_node = alloc;
   14741             :     }
   14742           0 :     ROSE_ASSERT(SgGraphEdgeList::next_node != nullptr);
   14743             : 
   14744           0 :     SgGraphEdgeList * object = SgGraphEdgeList::next_node;
   14745           0 :     SgGraphEdgeList::next_node = (SgGraphEdgeList*)(object->p_freepointer);
   14746             : 
   14747             : #if ROSE_ALLOC_TRACE == 2
   14748             :     printf("SgGraphEdgeList::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgGraphEdgeList::next_node);
   14749             : #endif
   14750             : 
   14751           0 :     SgNode * fp = object->p_freepointer;
   14752             : #if ROSE_ALLOC_MEMSET == 1
   14753             : #elif ROSE_ALLOC_MEMSET == 2
   14754             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgGraphEdgeList) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   14755             : #elif ROSE_ALLOC_MEMSET == 3
   14756             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgGraphEdgeList) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   14757             : #endif
   14758           0 :     object->p_freepointer = fp;
   14759             : 
   14760             : #if ROSE_ALLOC_TRACE == 2
   14761             : //    printf("SgGraphEdgeList::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgGraphEdgeList::next_node);
   14762             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   14763             :     Rose::MemPool::snapshot(oss.str());
   14764             :     alloc_trace_cnt++;
   14765             : #endif
   14766             : 
   14767           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   14768             : 
   14769           0 :     ALLOC_MUTEX(SgGraphEdgeList, unlock);
   14770             : 
   14771             :     return object;
   14772             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   14773             : }
   14774             : 
   14775             : 
   14776             : 
   14777             : /*! \brief Delete operator for SgGraphEdgeList.
   14778             : 
   14779             :    This delete operator implements deallocation using memory pools to 
   14780             :    provide most efficent use of the heap within construction of large ASTs.
   14781             : 
   14782             : \internal The new and delete operators use the lower level C malloc/free
   14783             :    function calls for performance and to make sure that mixing of malloc/free
   14784             :    and new/delete by the used can be caught more readily.  This may change
   14785             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   14786             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   14787             :    deallocate memory allocated using ROSE_MALLOC.
   14788             : */
   14789           0 : void SgGraphEdgeList::operator delete(void *Pointer, size_t Size)
   14790             : {
   14791             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   14792             :      * or throwing an exception. */
   14793           0 :     ALLOC_MUTEX(SgGraphEdgeList, lock);
   14794             : 
   14795             : #if USE_CPP_NEW_DELETE_OPERATORS
   14796             :     ROSE_FREE(Pointer);
   14797             : #else
   14798             : #if ROSE_PEDANTIC_ALLOC
   14799             :     ROSE_ASSERT(Size == sizeof(SgGraphEdgeList));
   14800             : #else
   14801           0 :     if (Size != sizeof(SgGraphEdgeList)) {
   14802           0 :       ROSE_FREE(Pointer);
   14803           0 :       ALLOC_MUTEX(SgGraphEdgeList, unlock);
   14804             :       return;
   14805             :     }
   14806             : #endif
   14807             : 
   14808           0 :     SgGraphEdgeList * object = (SgGraphEdgeList*) Pointer;
   14809           0 :     ROSE_ASSERT(object != nullptr);
   14810             : 
   14811             : #if ROSE_ALLOC_TRACE == 2
   14812             : //  printf("SgGraphEdgeList::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgGraphEdgeList::next_node);
   14813             :     printf("SgGraphEdgeList::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgGraphEdgeList::next_node);
   14814             : #endif
   14815             : 
   14816             : #if ROSE_PEDANTIC_ALLOC
   14817             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   14818             : #endif
   14819             : 
   14820             : #if ROSE_ALLOC_MEMSET == 1
   14821             : #elif ROSE_ALLOC_MEMSET == 2
   14822             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgGraphEdgeList) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   14823             : #elif ROSE_ALLOC_MEMSET == 3
   14824             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgGraphEdgeList) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   14825             : #endif
   14826             : 
   14827             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   14828             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   14829             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   14830             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   14831             : #else
   14832           0 :     object->p_freepointer = SgGraphEdgeList::next_node;
   14833           0 :     SgGraphEdgeList::next_node = object;
   14834             : #endif
   14835             : 
   14836             : #if ROSE_ALLOC_TRACE == 2
   14837             : //  printf("SgGraphEdgeList::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgGraphEdgeList::next_node);
   14838             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   14839             :     Rose::MemPool::snapshot(oss.str());
   14840             :     alloc_trace_cnt++;
   14841             : #endif
   14842             : 
   14843             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   14844             : 
   14845           0 :     ALLOC_MUTEX(SgGraphEdgeList, unlock);
   14846             : }
   14847             : 
   14848             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   14849             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   14850             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   14851             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   14852             : // Also, note comment below from Robb (copied from the Common.code file).
   14853             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   14854             : //
   14855             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   14856             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   14857             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   14858             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   14859             : #if 0
   14860             : void SgGraphEdgeList::operator delete(void* pointer) { SgGraphEdgeList::operator delete (pointer, sizeof(SgGraphEdgeList)); };
   14861             : #endif
   14862             : /* #line 14863 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   14863             : 
   14864             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   14865             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   14866             : // obviously imply C++.
   14867             : 
   14868             : // This implements the support within ROSE for memory pools.  Memory pools
   14869             : // support the most condensed usage of memory within the construction of
   14870             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   14871             : // by a new operator written for each class.
   14872             : 
   14873             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   14874             :     // User wants multi-thread support and POSIX threads are available.
   14875             : #   include <pthread.h>
   14876             :     static pthread_mutex_t SgTypeTable_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   14877             : #else
   14878             :      // Cause synchronization to be skipped.
   14879             : #    ifndef ALLOC_MUTEX
   14880             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   14881             : #    endif
   14882             : #    ifdef _REENTRANT
   14883             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   14884             : #       ifdef _MSC_VER
   14885             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   14886             : #       else
   14887             : #           warning "POSIX threads are not available; synchronization being skipped"
   14888             : #       endif
   14889             : #    endif
   14890             : #endif
   14891             : 
   14892             : #ifndef ROSE_ALLOC_TRACE
   14893             : #  define ROSE_ALLOC_TRACE 0
   14894             : #endif
   14895             : 
   14896             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   14897             : #define ROSE_ALLOC_TRACE_CNT
   14898             : #include "memory-pool-snapshot.h"
   14899             : unsigned long alloc_trace_cnt = 0;
   14900             : #endif
   14901             : 
   14902             : #if ROSE_ALLOC_TRACE
   14903             : const unsigned SgTypeTable::pool_size = 5;
   14904             : #else
   14905             : const unsigned SgTypeTable::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   14906             : #endif
   14907             : 
   14908             : #ifndef ROSE_ALLOC_MEMSET
   14909             : #  define ROSE_ALLOC_MEMSET 0
   14910             : #endif
   14911             : 
   14912             : #ifndef ROSE_PEDANTIC_ALLOC
   14913             : #  define ROSE_PEDANTIC_ALLOC 0
   14914             : #endif
   14915             : 
   14916             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   14917             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   14918             : #endif
   14919             : 
   14920             : #if !defined(SGNODE__ALL_POOLS)
   14921             : #define SGNODE__ALL_POOLS
   14922             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   14923             : #endif
   14924             : 
   14925             : SgTypeTable* SgTypeTable::next_node = nullptr;
   14926             : std::vector<unsigned char*> SgTypeTable::pools;
   14927             : 
   14928             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   14929             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   14930             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   14931             : // around this macro definition rather than each use).
   14932             : #ifndef ALLOC_MUTEX
   14933             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   14934             :         do {                                                                     \
   14935             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   14936             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   14937             :                 abort();                                                         \
   14938             :             }                                                                    \
   14939             :         } while (0);
   14940             : #endif
   14941             : 
   14942             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   14943             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   14944             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   14945             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   14946             : 
   14947             : /*! \brief New operator for SgTypeTable.
   14948             : 
   14949             :    This new operator implements memory pools to provide most efficent 
   14950             :    use of the heap within construction of large ASTs.
   14951             : 
   14952             : \internal The new and delete operators use the lower level C malloc/free
   14953             :    function calls for performance and to make sure that mixing of malloc/free
   14954             :    and new/delete by the used can be caught more readily.  This may change
   14955             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   14956             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   14957             :    deallocate memory allocated using ROSE_MALLOC.
   14958             : */
   14959      152051 : void *SgTypeTable::operator new ( size_t Size )
   14960             : {
   14961             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   14962             :      * returning or throwing an exception. */
   14963      152051 :     ALLOC_MUTEX(SgTypeTable, lock);
   14964             : 
   14965             : #if ROSE_ALLOC_TRACE == 2
   14966             : //    printf("SgTypeTable::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgTypeTable::next_node);
   14967             : #endif
   14968             : 
   14969             : #if USE_CPP_NEW_DELETE_OPERATORS
   14970             :     void *mem = ROSE_MALLOC(Size);
   14971             :     ALLOC_MUTEX(SgTypeTable, unlock);
   14972             :     return mem;
   14973             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   14974             : #if ROSE_PEDANTIC_ALLOC
   14975             :     ROSE_ASSERT(Size == sizeof(SgTypeTable));
   14976             : #else
   14977      152051 :     if (Size != sizeof(SgTypeTable)) {
   14978           0 :       void * object = ROSE_MALLOC(Size);
   14979           0 :       ALLOC_MUTEX(SgTypeTable, unlock);
   14980             :       return object;
   14981             :     }
   14982             : #endif
   14983             : 
   14984      152051 :     if (SgTypeTable::next_node == nullptr) {
   14985         412 :         SgTypeTable * alloc = (SgTypeTable*) ROSE_MALLOC ( SgTypeTable::pool_size * sizeof(SgTypeTable) );
   14986         412 :         ROSE_ASSERT(alloc != nullptr);
   14987             : 
   14988             : #if ROSE_ALLOC_TRACE == 2
   14989             : //        printf("SgTypeTable::alloc\n  block[%zi] = [ %p , %p [\n", SgTypeTable::pools.size(), alloc, alloc + SgTypeTable::pool_size);
   14990             : #endif
   14991             : 
   14992             : #if ROSE_ALLOC_MEMSET == 1
   14993             : #elif ROSE_ALLOC_MEMSET == 2
   14994             :         memset(alloc, 0x00, SgTypeTable::pool_size * sizeof(SgTypeTable));
   14995             : #elif ROSE_ALLOC_MEMSET == 3
   14996             :         memset(alloc, 0xAA, SgTypeTable::pool_size * sizeof(SgTypeTable));
   14997             : #endif
   14998      824000 :         for (unsigned i=0; i < SgTypeTable::pool_size-1; i++) {
   14999      823588 :           alloc[i].p_freepointer = &(alloc[i+1]);
   15000             :         }
   15001         412 :         alloc[SgTypeTable::pool_size-1].p_freepointer = nullptr;
   15002             : 
   15003         412 :         SgTypeTable::pools.push_back ( (unsigned char *) alloc );
   15004         412 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgTypeTable::pool_size * sizeof(SgTypeTable), V_SgTypeTable ) );
   15005         412 :         SgTypeTable::next_node = alloc;
   15006             :     }
   15007      152051 :     ROSE_ASSERT(SgTypeTable::next_node != nullptr);
   15008             : 
   15009      152051 :     SgTypeTable * object = SgTypeTable::next_node;
   15010      152051 :     SgTypeTable::next_node = (SgTypeTable*)(object->p_freepointer);
   15011             : 
   15012             : #if ROSE_ALLOC_TRACE == 2
   15013             :     printf("SgTypeTable::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeTable::next_node);
   15014             : #endif
   15015             : 
   15016      152051 :     SgNode * fp = object->p_freepointer;
   15017             : #if ROSE_ALLOC_MEMSET == 1
   15018             : #elif ROSE_ALLOC_MEMSET == 2
   15019             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgTypeTable) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   15020             : #elif ROSE_ALLOC_MEMSET == 3
   15021             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgTypeTable) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   15022             : #endif
   15023      152051 :     object->p_freepointer = fp;
   15024             : 
   15025             : #if ROSE_ALLOC_TRACE == 2
   15026             : //    printf("SgTypeTable::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeTable::next_node);
   15027             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   15028             :     Rose::MemPool::snapshot(oss.str());
   15029             :     alloc_trace_cnt++;
   15030             : #endif
   15031             : 
   15032      152051 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   15033             : 
   15034      152051 :     ALLOC_MUTEX(SgTypeTable, unlock);
   15035             : 
   15036             :     return object;
   15037             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   15038             : }
   15039             : 
   15040             : 
   15041             : 
   15042             : /*! \brief Delete operator for SgTypeTable.
   15043             : 
   15044             :    This delete operator implements deallocation using memory pools to 
   15045             :    provide most efficent use of the heap within construction of large ASTs.
   15046             : 
   15047             : \internal The new and delete operators use the lower level C malloc/free
   15048             :    function calls for performance and to make sure that mixing of malloc/free
   15049             :    and new/delete by the used can be caught more readily.  This may change
   15050             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   15051             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   15052             :    deallocate memory allocated using ROSE_MALLOC.
   15053             : */
   15054       27229 : void SgTypeTable::operator delete(void *Pointer, size_t Size)
   15055             : {
   15056             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   15057             :      * or throwing an exception. */
   15058       27229 :     ALLOC_MUTEX(SgTypeTable, lock);
   15059             : 
   15060             : #if USE_CPP_NEW_DELETE_OPERATORS
   15061             :     ROSE_FREE(Pointer);
   15062             : #else
   15063             : #if ROSE_PEDANTIC_ALLOC
   15064             :     ROSE_ASSERT(Size == sizeof(SgTypeTable));
   15065             : #else
   15066       27229 :     if (Size != sizeof(SgTypeTable)) {
   15067           0 :       ROSE_FREE(Pointer);
   15068           0 :       ALLOC_MUTEX(SgTypeTable, unlock);
   15069             :       return;
   15070             :     }
   15071             : #endif
   15072             : 
   15073       27229 :     SgTypeTable * object = (SgTypeTable*) Pointer;
   15074       27229 :     ROSE_ASSERT(object != nullptr);
   15075             : 
   15076             : #if ROSE_ALLOC_TRACE == 2
   15077             : //  printf("SgTypeTable::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeTable::next_node);
   15078             :     printf("SgTypeTable::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeTable::next_node);
   15079             : #endif
   15080             : 
   15081             : #if ROSE_PEDANTIC_ALLOC
   15082             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   15083             : #endif
   15084             : 
   15085             : #if ROSE_ALLOC_MEMSET == 1
   15086             : #elif ROSE_ALLOC_MEMSET == 2
   15087             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgTypeTable) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   15088             : #elif ROSE_ALLOC_MEMSET == 3
   15089             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgTypeTable) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   15090             : #endif
   15091             : 
   15092             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   15093             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   15094             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   15095             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   15096             : #else
   15097       27229 :     object->p_freepointer = SgTypeTable::next_node;
   15098       27229 :     SgTypeTable::next_node = object;
   15099             : #endif
   15100             : 
   15101             : #if ROSE_ALLOC_TRACE == 2
   15102             : //  printf("SgTypeTable::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeTable::next_node);
   15103             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   15104             :     Rose::MemPool::snapshot(oss.str());
   15105             :     alloc_trace_cnt++;
   15106             : #endif
   15107             : 
   15108             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   15109             : 
   15110       27229 :     ALLOC_MUTEX(SgTypeTable, unlock);
   15111             : }
   15112             : 
   15113             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   15114             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   15115             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   15116             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   15117             : // Also, note comment below from Robb (copied from the Common.code file).
   15118             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   15119             : //
   15120             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   15121             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   15122             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   15123             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   15124             : #if 0
   15125             : void SgTypeTable::operator delete(void* pointer) { SgTypeTable::operator delete (pointer, sizeof(SgTypeTable)); };
   15126             : #endif
   15127             : /* #line 15128 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   15128             : 
   15129             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   15130             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   15131             : // obviously imply C++.
   15132             : 
   15133             : // This implements the support within ROSE for memory pools.  Memory pools
   15134             : // support the most condensed usage of memory within the construction of
   15135             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   15136             : // by a new operator written for each class.
   15137             : 
   15138             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   15139             :     // User wants multi-thread support and POSIX threads are available.
   15140             : #   include <pthread.h>
   15141             :     static pthread_mutex_t SgNameGroup_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   15142             : #else
   15143             :      // Cause synchronization to be skipped.
   15144             : #    ifndef ALLOC_MUTEX
   15145             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   15146             : #    endif
   15147             : #    ifdef _REENTRANT
   15148             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   15149             : #       ifdef _MSC_VER
   15150             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   15151             : #       else
   15152             : #           warning "POSIX threads are not available; synchronization being skipped"
   15153             : #       endif
   15154             : #    endif
   15155             : #endif
   15156             : 
   15157             : #ifndef ROSE_ALLOC_TRACE
   15158             : #  define ROSE_ALLOC_TRACE 0
   15159             : #endif
   15160             : 
   15161             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   15162             : #define ROSE_ALLOC_TRACE_CNT
   15163             : #include "memory-pool-snapshot.h"
   15164             : unsigned long alloc_trace_cnt = 0;
   15165             : #endif
   15166             : 
   15167             : #if ROSE_ALLOC_TRACE
   15168             : const unsigned SgNameGroup::pool_size = 5;
   15169             : #else
   15170             : const unsigned SgNameGroup::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   15171             : #endif
   15172             : 
   15173             : #ifndef ROSE_ALLOC_MEMSET
   15174             : #  define ROSE_ALLOC_MEMSET 0
   15175             : #endif
   15176             : 
   15177             : #ifndef ROSE_PEDANTIC_ALLOC
   15178             : #  define ROSE_PEDANTIC_ALLOC 0
   15179             : #endif
   15180             : 
   15181             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   15182             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   15183             : #endif
   15184             : 
   15185             : #if !defined(SGNODE__ALL_POOLS)
   15186             : #define SGNODE__ALL_POOLS
   15187             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   15188             : #endif
   15189             : 
   15190             : SgNameGroup* SgNameGroup::next_node = nullptr;
   15191             : std::vector<unsigned char*> SgNameGroup::pools;
   15192             : 
   15193             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   15194             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   15195             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   15196             : // around this macro definition rather than each use).
   15197             : #ifndef ALLOC_MUTEX
   15198             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   15199             :         do {                                                                     \
   15200             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   15201             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   15202             :                 abort();                                                         \
   15203             :             }                                                                    \
   15204             :         } while (0);
   15205             : #endif
   15206             : 
   15207             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   15208             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   15209             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   15210             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   15211             : 
   15212             : /*! \brief New operator for SgNameGroup.
   15213             : 
   15214             :    This new operator implements memory pools to provide most efficent 
   15215             :    use of the heap within construction of large ASTs.
   15216             : 
   15217             : \internal The new and delete operators use the lower level C malloc/free
   15218             :    function calls for performance and to make sure that mixing of malloc/free
   15219             :    and new/delete by the used can be caught more readily.  This may change
   15220             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   15221             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   15222             :    deallocate memory allocated using ROSE_MALLOC.
   15223             : */
   15224           0 : void *SgNameGroup::operator new ( size_t Size )
   15225             : {
   15226             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   15227             :      * returning or throwing an exception. */
   15228           0 :     ALLOC_MUTEX(SgNameGroup, lock);
   15229             : 
   15230             : #if ROSE_ALLOC_TRACE == 2
   15231             : //    printf("SgNameGroup::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgNameGroup::next_node);
   15232             : #endif
   15233             : 
   15234             : #if USE_CPP_NEW_DELETE_OPERATORS
   15235             :     void *mem = ROSE_MALLOC(Size);
   15236             :     ALLOC_MUTEX(SgNameGroup, unlock);
   15237             :     return mem;
   15238             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   15239             : #if ROSE_PEDANTIC_ALLOC
   15240             :     ROSE_ASSERT(Size == sizeof(SgNameGroup));
   15241             : #else
   15242           0 :     if (Size != sizeof(SgNameGroup)) {
   15243           0 :       void * object = ROSE_MALLOC(Size);
   15244           0 :       ALLOC_MUTEX(SgNameGroup, unlock);
   15245             :       return object;
   15246             :     }
   15247             : #endif
   15248             : 
   15249           0 :     if (SgNameGroup::next_node == nullptr) {
   15250           0 :         SgNameGroup * alloc = (SgNameGroup*) ROSE_MALLOC ( SgNameGroup::pool_size * sizeof(SgNameGroup) );
   15251           0 :         ROSE_ASSERT(alloc != nullptr);
   15252             : 
   15253             : #if ROSE_ALLOC_TRACE == 2
   15254             : //        printf("SgNameGroup::alloc\n  block[%zi] = [ %p , %p [\n", SgNameGroup::pools.size(), alloc, alloc + SgNameGroup::pool_size);
   15255             : #endif
   15256             : 
   15257             : #if ROSE_ALLOC_MEMSET == 1
   15258             : #elif ROSE_ALLOC_MEMSET == 2
   15259             :         memset(alloc, 0x00, SgNameGroup::pool_size * sizeof(SgNameGroup));
   15260             : #elif ROSE_ALLOC_MEMSET == 3
   15261             :         memset(alloc, 0xAA, SgNameGroup::pool_size * sizeof(SgNameGroup));
   15262             : #endif
   15263           0 :         for (unsigned i=0; i < SgNameGroup::pool_size-1; i++) {
   15264           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
   15265             :         }
   15266           0 :         alloc[SgNameGroup::pool_size-1].p_freepointer = nullptr;
   15267             : 
   15268           0 :         SgNameGroup::pools.push_back ( (unsigned char *) alloc );
   15269           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgNameGroup::pool_size * sizeof(SgNameGroup), V_SgNameGroup ) );
   15270           0 :         SgNameGroup::next_node = alloc;
   15271             :     }
   15272           0 :     ROSE_ASSERT(SgNameGroup::next_node != nullptr);
   15273             : 
   15274           0 :     SgNameGroup * object = SgNameGroup::next_node;
   15275           0 :     SgNameGroup::next_node = (SgNameGroup*)(object->p_freepointer);
   15276             : 
   15277             : #if ROSE_ALLOC_TRACE == 2
   15278             :     printf("SgNameGroup::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgNameGroup::next_node);
   15279             : #endif
   15280             : 
   15281           0 :     SgNode * fp = object->p_freepointer;
   15282             : #if ROSE_ALLOC_MEMSET == 1
   15283             : #elif ROSE_ALLOC_MEMSET == 2
   15284             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgNameGroup) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   15285             : #elif ROSE_ALLOC_MEMSET == 3
   15286             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgNameGroup) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   15287             : #endif
   15288           0 :     object->p_freepointer = fp;
   15289             : 
   15290             : #if ROSE_ALLOC_TRACE == 2
   15291             : //    printf("SgNameGroup::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgNameGroup::next_node);
   15292             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   15293             :     Rose::MemPool::snapshot(oss.str());
   15294             :     alloc_trace_cnt++;
   15295             : #endif
   15296             : 
   15297           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   15298             : 
   15299           0 :     ALLOC_MUTEX(SgNameGroup, unlock);
   15300             : 
   15301             :     return object;
   15302             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   15303             : }
   15304             : 
   15305             : 
   15306             : 
   15307             : /*! \brief Delete operator for SgNameGroup.
   15308             : 
   15309             :    This delete operator implements deallocation using memory pools to 
   15310             :    provide most efficent use of the heap within construction of large ASTs.
   15311             : 
   15312             : \internal The new and delete operators use the lower level C malloc/free
   15313             :    function calls for performance and to make sure that mixing of malloc/free
   15314             :    and new/delete by the used can be caught more readily.  This may change
   15315             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   15316             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   15317             :    deallocate memory allocated using ROSE_MALLOC.
   15318             : */
   15319           0 : void SgNameGroup::operator delete(void *Pointer, size_t Size)
   15320             : {
   15321             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   15322             :      * or throwing an exception. */
   15323           0 :     ALLOC_MUTEX(SgNameGroup, lock);
   15324             : 
   15325             : #if USE_CPP_NEW_DELETE_OPERATORS
   15326             :     ROSE_FREE(Pointer);
   15327             : #else
   15328             : #if ROSE_PEDANTIC_ALLOC
   15329             :     ROSE_ASSERT(Size == sizeof(SgNameGroup));
   15330             : #else
   15331           0 :     if (Size != sizeof(SgNameGroup)) {
   15332           0 :       ROSE_FREE(Pointer);
   15333           0 :       ALLOC_MUTEX(SgNameGroup, unlock);
   15334             :       return;
   15335             :     }
   15336             : #endif
   15337             : 
   15338           0 :     SgNameGroup * object = (SgNameGroup*) Pointer;
   15339           0 :     ROSE_ASSERT(object != nullptr);
   15340             : 
   15341             : #if ROSE_ALLOC_TRACE == 2
   15342             : //  printf("SgNameGroup::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgNameGroup::next_node);
   15343             :     printf("SgNameGroup::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgNameGroup::next_node);
   15344             : #endif
   15345             : 
   15346             : #if ROSE_PEDANTIC_ALLOC
   15347             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   15348             : #endif
   15349             : 
   15350             : #if ROSE_ALLOC_MEMSET == 1
   15351             : #elif ROSE_ALLOC_MEMSET == 2
   15352             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgNameGroup) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   15353             : #elif ROSE_ALLOC_MEMSET == 3
   15354             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgNameGroup) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   15355             : #endif
   15356             : 
   15357             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   15358             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   15359             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   15360             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   15361             : #else
   15362           0 :     object->p_freepointer = SgNameGroup::next_node;
   15363           0 :     SgNameGroup::next_node = object;
   15364             : #endif
   15365             : 
   15366             : #if ROSE_ALLOC_TRACE == 2
   15367             : //  printf("SgNameGroup::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgNameGroup::next_node);
   15368             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   15369             :     Rose::MemPool::snapshot(oss.str());
   15370             :     alloc_trace_cnt++;
   15371             : #endif
   15372             : 
   15373             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   15374             : 
   15375           0 :     ALLOC_MUTEX(SgNameGroup, unlock);
   15376             : }
   15377             : 
   15378             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   15379             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   15380             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   15381             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   15382             : // Also, note comment below from Robb (copied from the Common.code file).
   15383             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   15384             : //
   15385             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   15386             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   15387             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   15388             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   15389             : #if 0
   15390             : void SgNameGroup::operator delete(void* pointer) { SgNameGroup::operator delete (pointer, sizeof(SgNameGroup)); };
   15391             : #endif
   15392             : /* #line 15393 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   15393             : 
   15394             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   15395             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   15396             : // obviously imply C++.
   15397             : 
   15398             : // This implements the support within ROSE for memory pools.  Memory pools
   15399             : // support the most condensed usage of memory within the construction of
   15400             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   15401             : // by a new operator written for each class.
   15402             : 
   15403             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   15404             :     // User wants multi-thread support and POSIX threads are available.
   15405             : #   include <pthread.h>
   15406             :     static pthread_mutex_t SgDimensionObject_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   15407             : #else
   15408             :      // Cause synchronization to be skipped.
   15409             : #    ifndef ALLOC_MUTEX
   15410             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   15411             : #    endif
   15412             : #    ifdef _REENTRANT
   15413             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   15414             : #       ifdef _MSC_VER
   15415             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   15416             : #       else
   15417             : #           warning "POSIX threads are not available; synchronization being skipped"
   15418             : #       endif
   15419             : #    endif
   15420             : #endif
   15421             : 
   15422             : #ifndef ROSE_ALLOC_TRACE
   15423             : #  define ROSE_ALLOC_TRACE 0
   15424             : #endif
   15425             : 
   15426             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   15427             : #define ROSE_ALLOC_TRACE_CNT
   15428             : #include "memory-pool-snapshot.h"
   15429             : unsigned long alloc_trace_cnt = 0;
   15430             : #endif
   15431             : 
   15432             : #if ROSE_ALLOC_TRACE
   15433             : const unsigned SgDimensionObject::pool_size = 5;
   15434             : #else
   15435             : const unsigned SgDimensionObject::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   15436             : #endif
   15437             : 
   15438             : #ifndef ROSE_ALLOC_MEMSET
   15439             : #  define ROSE_ALLOC_MEMSET 0
   15440             : #endif
   15441             : 
   15442             : #ifndef ROSE_PEDANTIC_ALLOC
   15443             : #  define ROSE_PEDANTIC_ALLOC 0
   15444             : #endif
   15445             : 
   15446             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   15447             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   15448             : #endif
   15449             : 
   15450             : #if !defined(SGNODE__ALL_POOLS)
   15451             : #define SGNODE__ALL_POOLS
   15452             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   15453             : #endif
   15454             : 
   15455             : SgDimensionObject* SgDimensionObject::next_node = nullptr;
   15456             : std::vector<unsigned char*> SgDimensionObject::pools;
   15457             : 
   15458             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   15459             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   15460             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   15461             : // around this macro definition rather than each use).
   15462             : #ifndef ALLOC_MUTEX
   15463             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   15464             :         do {                                                                     \
   15465             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   15466             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   15467             :                 abort();                                                         \
   15468             :             }                                                                    \
   15469             :         } while (0);
   15470             : #endif
   15471             : 
   15472             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   15473             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   15474             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   15475             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   15476             : 
   15477             : /*! \brief New operator for SgDimensionObject.
   15478             : 
   15479             :    This new operator implements memory pools to provide most efficent 
   15480             :    use of the heap within construction of large ASTs.
   15481             : 
   15482             : \internal The new and delete operators use the lower level C malloc/free
   15483             :    function calls for performance and to make sure that mixing of malloc/free
   15484             :    and new/delete by the used can be caught more readily.  This may change
   15485             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   15486             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   15487             :    deallocate memory allocated using ROSE_MALLOC.
   15488             : */
   15489           0 : void *SgDimensionObject::operator new ( size_t Size )
   15490             : {
   15491             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   15492             :      * returning or throwing an exception. */
   15493           0 :     ALLOC_MUTEX(SgDimensionObject, lock);
   15494             : 
   15495             : #if ROSE_ALLOC_TRACE == 2
   15496             : //    printf("SgDimensionObject::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgDimensionObject::next_node);
   15497             : #endif
   15498             : 
   15499             : #if USE_CPP_NEW_DELETE_OPERATORS
   15500             :     void *mem = ROSE_MALLOC(Size);
   15501             :     ALLOC_MUTEX(SgDimensionObject, unlock);
   15502             :     return mem;
   15503             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   15504             : #if ROSE_PEDANTIC_ALLOC
   15505             :     ROSE_ASSERT(Size == sizeof(SgDimensionObject));
   15506             : #else
   15507           0 :     if (Size != sizeof(SgDimensionObject)) {
   15508           0 :       void * object = ROSE_MALLOC(Size);
   15509           0 :       ALLOC_MUTEX(SgDimensionObject, unlock);
   15510             :       return object;
   15511             :     }
   15512             : #endif
   15513             : 
   15514           0 :     if (SgDimensionObject::next_node == nullptr) {
   15515           0 :         SgDimensionObject * alloc = (SgDimensionObject*) ROSE_MALLOC ( SgDimensionObject::pool_size * sizeof(SgDimensionObject) );
   15516           0 :         ROSE_ASSERT(alloc != nullptr);
   15517             : 
   15518             : #if ROSE_ALLOC_TRACE == 2
   15519             : //        printf("SgDimensionObject::alloc\n  block[%zi] = [ %p , %p [\n", SgDimensionObject::pools.size(), alloc, alloc + SgDimensionObject::pool_size);
   15520             : #endif
   15521             : 
   15522             : #if ROSE_ALLOC_MEMSET == 1
   15523             : #elif ROSE_ALLOC_MEMSET == 2
   15524             :         memset(alloc, 0x00, SgDimensionObject::pool_size * sizeof(SgDimensionObject));
   15525             : #elif ROSE_ALLOC_MEMSET == 3
   15526             :         memset(alloc, 0xAA, SgDimensionObject::pool_size * sizeof(SgDimensionObject));
   15527             : #endif
   15528           0 :         for (unsigned i=0; i < SgDimensionObject::pool_size-1; i++) {
   15529           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
   15530             :         }
   15531           0 :         alloc[SgDimensionObject::pool_size-1].p_freepointer = nullptr;
   15532             : 
   15533           0 :         SgDimensionObject::pools.push_back ( (unsigned char *) alloc );
   15534           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgDimensionObject::pool_size * sizeof(SgDimensionObject), V_SgDimensionObject ) );
   15535           0 :         SgDimensionObject::next_node = alloc;
   15536             :     }
   15537           0 :     ROSE_ASSERT(SgDimensionObject::next_node != nullptr);
   15538             : 
   15539           0 :     SgDimensionObject * object = SgDimensionObject::next_node;
   15540           0 :     SgDimensionObject::next_node = (SgDimensionObject*)(object->p_freepointer);
   15541             : 
   15542             : #if ROSE_ALLOC_TRACE == 2
   15543             :     printf("SgDimensionObject::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgDimensionObject::next_node);
   15544             : #endif
   15545             : 
   15546           0 :     SgNode * fp = object->p_freepointer;
   15547             : #if ROSE_ALLOC_MEMSET == 1
   15548             : #elif ROSE_ALLOC_MEMSET == 2
   15549             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgDimensionObject) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   15550             : #elif ROSE_ALLOC_MEMSET == 3
   15551             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgDimensionObject) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   15552             : #endif
   15553           0 :     object->p_freepointer = fp;
   15554             : 
   15555             : #if ROSE_ALLOC_TRACE == 2
   15556             : //    printf("SgDimensionObject::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgDimensionObject::next_node);
   15557             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   15558             :     Rose::MemPool::snapshot(oss.str());
   15559             :     alloc_trace_cnt++;
   15560             : #endif
   15561             : 
   15562           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   15563             : 
   15564           0 :     ALLOC_MUTEX(SgDimensionObject, unlock);
   15565             : 
   15566             :     return object;
   15567             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   15568             : }
   15569             : 
   15570             : 
   15571             : 
   15572             : /*! \brief Delete operator for SgDimensionObject.
   15573             : 
   15574             :    This delete operator implements deallocation using memory pools to 
   15575             :    provide most efficent use of the heap within construction of large ASTs.
   15576             : 
   15577             : \internal The new and delete operators use the lower level C malloc/free
   15578             :    function calls for performance and to make sure that mixing of malloc/free
   15579             :    and new/delete by the used can be caught more readily.  This may change
   15580             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   15581             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   15582             :    deallocate memory allocated using ROSE_MALLOC.
   15583             : */
   15584           0 : void SgDimensionObject::operator delete(void *Pointer, size_t Size)
   15585             : {
   15586             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   15587             :      * or throwing an exception. */
   15588           0 :     ALLOC_MUTEX(SgDimensionObject, lock);
   15589             : 
   15590             : #if USE_CPP_NEW_DELETE_OPERATORS
   15591             :     ROSE_FREE(Pointer);
   15592             : #else
   15593             : #if ROSE_PEDANTIC_ALLOC
   15594             :     ROSE_ASSERT(Size == sizeof(SgDimensionObject));
   15595             : #else
   15596           0 :     if (Size != sizeof(SgDimensionObject)) {
   15597           0 :       ROSE_FREE(Pointer);
   15598           0 :       ALLOC_MUTEX(SgDimensionObject, unlock);
   15599             :       return;
   15600             :     }
   15601             : #endif
   15602             : 
   15603           0 :     SgDimensionObject * object = (SgDimensionObject*) Pointer;
   15604           0 :     ROSE_ASSERT(object != nullptr);
   15605             : 
   15606             : #if ROSE_ALLOC_TRACE == 2
   15607             : //  printf("SgDimensionObject::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgDimensionObject::next_node);
   15608             :     printf("SgDimensionObject::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgDimensionObject::next_node);
   15609             : #endif
   15610             : 
   15611             : #if ROSE_PEDANTIC_ALLOC
   15612             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   15613             : #endif
   15614             : 
   15615             : #if ROSE_ALLOC_MEMSET == 1
   15616             : #elif ROSE_ALLOC_MEMSET == 2
   15617             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgDimensionObject) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   15618             : #elif ROSE_ALLOC_MEMSET == 3
   15619             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgDimensionObject) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   15620             : #endif
   15621             : 
   15622             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   15623             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   15624             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   15625             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   15626             : #else
   15627           0 :     object->p_freepointer = SgDimensionObject::next_node;
   15628           0 :     SgDimensionObject::next_node = object;
   15629             : #endif
   15630             : 
   15631             : #if ROSE_ALLOC_TRACE == 2
   15632             : //  printf("SgDimensionObject::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgDimensionObject::next_node);
   15633             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   15634             :     Rose::MemPool::snapshot(oss.str());
   15635             :     alloc_trace_cnt++;
   15636             : #endif
   15637             : 
   15638             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   15639             : 
   15640           0 :     ALLOC_MUTEX(SgDimensionObject, unlock);
   15641             : }
   15642             : 
   15643             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   15644             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   15645             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   15646             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   15647             : // Also, note comment below from Robb (copied from the Common.code file).
   15648             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   15649             : //
   15650             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   15651             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   15652             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   15653             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   15654             : #if 0
   15655             : void SgDimensionObject::operator delete(void* pointer) { SgDimensionObject::operator delete (pointer, sizeof(SgDimensionObject)); };
   15656             : #endif
   15657             : /* #line 15658 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   15658             : 
   15659             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   15660             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   15661             : // obviously imply C++.
   15662             : 
   15663             : // This implements the support within ROSE for memory pools.  Memory pools
   15664             : // support the most condensed usage of memory within the construction of
   15665             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   15666             : // by a new operator written for each class.
   15667             : 
   15668             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   15669             :     // User wants multi-thread support and POSIX threads are available.
   15670             : #   include <pthread.h>
   15671             :     static pthread_mutex_t SgFormatItem_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   15672             : #else
   15673             :      // Cause synchronization to be skipped.
   15674             : #    ifndef ALLOC_MUTEX
   15675             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   15676             : #    endif
   15677             : #    ifdef _REENTRANT
   15678             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   15679             : #       ifdef _MSC_VER
   15680             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   15681             : #       else
   15682             : #           warning "POSIX threads are not available; synchronization being skipped"
   15683             : #       endif
   15684             : #    endif
   15685             : #endif
   15686             : 
   15687             : #ifndef ROSE_ALLOC_TRACE
   15688             : #  define ROSE_ALLOC_TRACE 0
   15689             : #endif
   15690             : 
   15691             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   15692             : #define ROSE_ALLOC_TRACE_CNT
   15693             : #include "memory-pool-snapshot.h"
   15694             : unsigned long alloc_trace_cnt = 0;
   15695             : #endif
   15696             : 
   15697             : #if ROSE_ALLOC_TRACE
   15698             : const unsigned SgFormatItem::pool_size = 5;
   15699             : #else
   15700             : const unsigned SgFormatItem::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   15701             : #endif
   15702             : 
   15703             : #ifndef ROSE_ALLOC_MEMSET
   15704             : #  define ROSE_ALLOC_MEMSET 0
   15705             : #endif
   15706             : 
   15707             : #ifndef ROSE_PEDANTIC_ALLOC
   15708             : #  define ROSE_PEDANTIC_ALLOC 0
   15709             : #endif
   15710             : 
   15711             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   15712             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   15713             : #endif
   15714             : 
   15715             : #if !defined(SGNODE__ALL_POOLS)
   15716             : #define SGNODE__ALL_POOLS
   15717             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   15718             : #endif
   15719             : 
   15720             : SgFormatItem* SgFormatItem::next_node = nullptr;
   15721             : std::vector<unsigned char*> SgFormatItem::pools;
   15722             : 
   15723             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   15724             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   15725             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   15726             : // around this macro definition rather than each use).
   15727             : #ifndef ALLOC_MUTEX
   15728             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   15729             :         do {                                                                     \
   15730             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   15731             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   15732             :                 abort();                                                         \
   15733             :             }                                                                    \
   15734             :         } while (0);
   15735             : #endif
   15736             : 
   15737             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   15738             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   15739             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   15740             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   15741             : 
   15742             : /*! \brief New operator for SgFormatItem.
   15743             : 
   15744             :    This new operator implements memory pools to provide most efficent 
   15745             :    use of the heap within construction of large ASTs.
   15746             : 
   15747             : \internal The new and delete operators use the lower level C malloc/free
   15748             :    function calls for performance and to make sure that mixing of malloc/free
   15749             :    and new/delete by the used can be caught more readily.  This may change
   15750             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   15751             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   15752             :    deallocate memory allocated using ROSE_MALLOC.
   15753             : */
   15754           0 : void *SgFormatItem::operator new ( size_t Size )
   15755             : {
   15756             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   15757             :      * returning or throwing an exception. */
   15758           0 :     ALLOC_MUTEX(SgFormatItem, lock);
   15759             : 
   15760             : #if ROSE_ALLOC_TRACE == 2
   15761             : //    printf("SgFormatItem::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgFormatItem::next_node);
   15762             : #endif
   15763             : 
   15764             : #if USE_CPP_NEW_DELETE_OPERATORS
   15765             :     void *mem = ROSE_MALLOC(Size);
   15766             :     ALLOC_MUTEX(SgFormatItem, unlock);
   15767             :     return mem;
   15768             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   15769             : #if ROSE_PEDANTIC_ALLOC
   15770             :     ROSE_ASSERT(Size == sizeof(SgFormatItem));
   15771             : #else
   15772           0 :     if (Size != sizeof(SgFormatItem)) {
   15773           0 :       void * object = ROSE_MALLOC(Size);
   15774           0 :       ALLOC_MUTEX(SgFormatItem, unlock);
   15775             :       return object;
   15776             :     }
   15777             : #endif
   15778             : 
   15779           0 :     if (SgFormatItem::next_node == nullptr) {
   15780           0 :         SgFormatItem * alloc = (SgFormatItem*) ROSE_MALLOC ( SgFormatItem::pool_size * sizeof(SgFormatItem) );
   15781           0 :         ROSE_ASSERT(alloc != nullptr);
   15782             : 
   15783             : #if ROSE_ALLOC_TRACE == 2
   15784             : //        printf("SgFormatItem::alloc\n  block[%zi] = [ %p , %p [\n", SgFormatItem::pools.size(), alloc, alloc + SgFormatItem::pool_size);
   15785             : #endif
   15786             : 
   15787             : #if ROSE_ALLOC_MEMSET == 1
   15788             : #elif ROSE_ALLOC_MEMSET == 2
   15789             :         memset(alloc, 0x00, SgFormatItem::pool_size * sizeof(SgFormatItem));
   15790             : #elif ROSE_ALLOC_MEMSET == 3
   15791             :         memset(alloc, 0xAA, SgFormatItem::pool_size * sizeof(SgFormatItem));
   15792             : #endif
   15793           0 :         for (unsigned i=0; i < SgFormatItem::pool_size-1; i++) {
   15794           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
   15795             :         }
   15796           0 :         alloc[SgFormatItem::pool_size-1].p_freepointer = nullptr;
   15797             : 
   15798           0 :         SgFormatItem::pools.push_back ( (unsigned char *) alloc );
   15799           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgFormatItem::pool_size * sizeof(SgFormatItem), V_SgFormatItem ) );
   15800           0 :         SgFormatItem::next_node = alloc;
   15801             :     }
   15802           0 :     ROSE_ASSERT(SgFormatItem::next_node != nullptr);
   15803             : 
   15804           0 :     SgFormatItem * object = SgFormatItem::next_node;
   15805           0 :     SgFormatItem::next_node = (SgFormatItem*)(object->p_freepointer);
   15806             : 
   15807             : #if ROSE_ALLOC_TRACE == 2
   15808             :     printf("SgFormatItem::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgFormatItem::next_node);
   15809             : #endif
   15810             : 
   15811           0 :     SgNode * fp = object->p_freepointer;
   15812             : #if ROSE_ALLOC_MEMSET == 1
   15813             : #elif ROSE_ALLOC_MEMSET == 2
   15814             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgFormatItem) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   15815             : #elif ROSE_ALLOC_MEMSET == 3
   15816             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgFormatItem) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   15817             : #endif
   15818           0 :     object->p_freepointer = fp;
   15819             : 
   15820             : #if ROSE_ALLOC_TRACE == 2
   15821             : //    printf("SgFormatItem::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgFormatItem::next_node);
   15822             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   15823             :     Rose::MemPool::snapshot(oss.str());
   15824             :     alloc_trace_cnt++;
   15825             : #endif
   15826             : 
   15827           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   15828             : 
   15829           0 :     ALLOC_MUTEX(SgFormatItem, unlock);
   15830             : 
   15831             :     return object;
   15832             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   15833             : }
   15834             : 
   15835             : 
   15836             : 
   15837             : /*! \brief Delete operator for SgFormatItem.
   15838             : 
   15839             :    This delete operator implements deallocation using memory pools to 
   15840             :    provide most efficent use of the heap within construction of large ASTs.
   15841             : 
   15842             : \internal The new and delete operators use the lower level C malloc/free
   15843             :    function calls for performance and to make sure that mixing of malloc/free
   15844             :    and new/delete by the used can be caught more readily.  This may change
   15845             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   15846             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   15847             :    deallocate memory allocated using ROSE_MALLOC.
   15848             : */
   15849           0 : void SgFormatItem::operator delete(void *Pointer, size_t Size)
   15850             : {
   15851             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   15852             :      * or throwing an exception. */
   15853           0 :     ALLOC_MUTEX(SgFormatItem, lock);
   15854             : 
   15855             : #if USE_CPP_NEW_DELETE_OPERATORS
   15856             :     ROSE_FREE(Pointer);
   15857             : #else
   15858             : #if ROSE_PEDANTIC_ALLOC
   15859             :     ROSE_ASSERT(Size == sizeof(SgFormatItem));
   15860             : #else
   15861           0 :     if (Size != sizeof(SgFormatItem)) {
   15862           0 :       ROSE_FREE(Pointer);
   15863           0 :       ALLOC_MUTEX(SgFormatItem, unlock);
   15864             :       return;
   15865             :     }
   15866             : #endif
   15867             : 
   15868           0 :     SgFormatItem * object = (SgFormatItem*) Pointer;
   15869           0 :     ROSE_ASSERT(object != nullptr);
   15870             : 
   15871             : #if ROSE_ALLOC_TRACE == 2
   15872             : //  printf("SgFormatItem::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgFormatItem::next_node);
   15873             :     printf("SgFormatItem::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgFormatItem::next_node);
   15874             : #endif
   15875             : 
   15876             : #if ROSE_PEDANTIC_ALLOC
   15877             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   15878             : #endif
   15879             : 
   15880             : #if ROSE_ALLOC_MEMSET == 1
   15881             : #elif ROSE_ALLOC_MEMSET == 2
   15882             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgFormatItem) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   15883             : #elif ROSE_ALLOC_MEMSET == 3
   15884             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgFormatItem) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   15885             : #endif
   15886             : 
   15887             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   15888             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   15889             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   15890             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   15891             : #else
   15892           0 :     object->p_freepointer = SgFormatItem::next_node;
   15893           0 :     SgFormatItem::next_node = object;
   15894             : #endif
   15895             : 
   15896             : #if ROSE_ALLOC_TRACE == 2
   15897             : //  printf("SgFormatItem::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgFormatItem::next_node);
   15898             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   15899             :     Rose::MemPool::snapshot(oss.str());
   15900             :     alloc_trace_cnt++;
   15901             : #endif
   15902             : 
   15903             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   15904             : 
   15905           0 :     ALLOC_MUTEX(SgFormatItem, unlock);
   15906             : }
   15907             : 
   15908             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   15909             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   15910             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   15911             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   15912             : // Also, note comment below from Robb (copied from the Common.code file).
   15913             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   15914             : //
   15915             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   15916             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   15917             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   15918             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   15919             : #if 0
   15920             : void SgFormatItem::operator delete(void* pointer) { SgFormatItem::operator delete (pointer, sizeof(SgFormatItem)); };
   15921             : #endif
   15922             : /* #line 15923 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   15923             : 
   15924             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   15925             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   15926             : // obviously imply C++.
   15927             : 
   15928             : // This implements the support within ROSE for memory pools.  Memory pools
   15929             : // support the most condensed usage of memory within the construction of
   15930             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   15931             : // by a new operator written for each class.
   15932             : 
   15933             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   15934             :     // User wants multi-thread support and POSIX threads are available.
   15935             : #   include <pthread.h>
   15936             :     static pthread_mutex_t SgFormatItemList_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   15937             : #else
   15938             :      // Cause synchronization to be skipped.
   15939             : #    ifndef ALLOC_MUTEX
   15940             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   15941             : #    endif
   15942             : #    ifdef _REENTRANT
   15943             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   15944             : #       ifdef _MSC_VER
   15945             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   15946             : #       else
   15947             : #           warning "POSIX threads are not available; synchronization being skipped"
   15948             : #       endif
   15949             : #    endif
   15950             : #endif
   15951             : 
   15952             : #ifndef ROSE_ALLOC_TRACE
   15953             : #  define ROSE_ALLOC_TRACE 0
   15954             : #endif
   15955             : 
   15956             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   15957             : #define ROSE_ALLOC_TRACE_CNT
   15958             : #include "memory-pool-snapshot.h"
   15959             : unsigned long alloc_trace_cnt = 0;
   15960             : #endif
   15961             : 
   15962             : #if ROSE_ALLOC_TRACE
   15963             : const unsigned SgFormatItemList::pool_size = 5;
   15964             : #else
   15965             : const unsigned SgFormatItemList::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   15966             : #endif
   15967             : 
   15968             : #ifndef ROSE_ALLOC_MEMSET
   15969             : #  define ROSE_ALLOC_MEMSET 0
   15970             : #endif
   15971             : 
   15972             : #ifndef ROSE_PEDANTIC_ALLOC
   15973             : #  define ROSE_PEDANTIC_ALLOC 0
   15974             : #endif
   15975             : 
   15976             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   15977             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   15978             : #endif
   15979             : 
   15980             : #if !defined(SGNODE__ALL_POOLS)
   15981             : #define SGNODE__ALL_POOLS
   15982             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   15983             : #endif
   15984             : 
   15985             : SgFormatItemList* SgFormatItemList::next_node = nullptr;
   15986             : std::vector<unsigned char*> SgFormatItemList::pools;
   15987             : 
   15988             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   15989             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   15990             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   15991             : // around this macro definition rather than each use).
   15992             : #ifndef ALLOC_MUTEX
   15993             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   15994             :         do {                                                                     \
   15995             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   15996             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   15997             :                 abort();                                                         \
   15998             :             }                                                                    \
   15999             :         } while (0);
   16000             : #endif
   16001             : 
   16002             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   16003             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   16004             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   16005             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   16006             : 
   16007             : /*! \brief New operator for SgFormatItemList.
   16008             : 
   16009             :    This new operator implements memory pools to provide most efficent 
   16010             :    use of the heap within construction of large ASTs.
   16011             : 
   16012             : \internal The new and delete operators use the lower level C malloc/free
   16013             :    function calls for performance and to make sure that mixing of malloc/free
   16014             :    and new/delete by the used can be caught more readily.  This may change
   16015             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   16016             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   16017             :    deallocate memory allocated using ROSE_MALLOC.
   16018             : */
   16019           0 : void *SgFormatItemList::operator new ( size_t Size )
   16020             : {
   16021             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   16022             :      * returning or throwing an exception. */
   16023           0 :     ALLOC_MUTEX(SgFormatItemList, lock);
   16024             : 
   16025             : #if ROSE_ALLOC_TRACE == 2
   16026             : //    printf("SgFormatItemList::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgFormatItemList::next_node);
   16027             : #endif
   16028             : 
   16029             : #if USE_CPP_NEW_DELETE_OPERATORS
   16030             :     void *mem = ROSE_MALLOC(Size);
   16031             :     ALLOC_MUTEX(SgFormatItemList, unlock);
   16032             :     return mem;
   16033             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   16034             : #if ROSE_PEDANTIC_ALLOC
   16035             :     ROSE_ASSERT(Size == sizeof(SgFormatItemList));
   16036             : #else
   16037           0 :     if (Size != sizeof(SgFormatItemList)) {
   16038           0 :       void * object = ROSE_MALLOC(Size);
   16039           0 :       ALLOC_MUTEX(SgFormatItemList, unlock);
   16040             :       return object;
   16041             :     }
   16042             : #endif
   16043             : 
   16044           0 :     if (SgFormatItemList::next_node == nullptr) {
   16045           0 :         SgFormatItemList * alloc = (SgFormatItemList*) ROSE_MALLOC ( SgFormatItemList::pool_size * sizeof(SgFormatItemList) );
   16046           0 :         ROSE_ASSERT(alloc != nullptr);
   16047             : 
   16048             : #if ROSE_ALLOC_TRACE == 2
   16049             : //        printf("SgFormatItemList::alloc\n  block[%zi] = [ %p , %p [\n", SgFormatItemList::pools.size(), alloc, alloc + SgFormatItemList::pool_size);
   16050             : #endif
   16051             : 
   16052             : #if ROSE_ALLOC_MEMSET == 1
   16053             : #elif ROSE_ALLOC_MEMSET == 2
   16054             :         memset(alloc, 0x00, SgFormatItemList::pool_size * sizeof(SgFormatItemList));
   16055             : #elif ROSE_ALLOC_MEMSET == 3
   16056             :         memset(alloc, 0xAA, SgFormatItemList::pool_size * sizeof(SgFormatItemList));
   16057             : #endif
   16058           0 :         for (unsigned i=0; i < SgFormatItemList::pool_size-1; i++) {
   16059           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
   16060             :         }
   16061           0 :         alloc[SgFormatItemList::pool_size-1].p_freepointer = nullptr;
   16062             : 
   16063           0 :         SgFormatItemList::pools.push_back ( (unsigned char *) alloc );
   16064           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgFormatItemList::pool_size * sizeof(SgFormatItemList), V_SgFormatItemList ) );
   16065           0 :         SgFormatItemList::next_node = alloc;
   16066             :     }
   16067           0 :     ROSE_ASSERT(SgFormatItemList::next_node != nullptr);
   16068             : 
   16069           0 :     SgFormatItemList * object = SgFormatItemList::next_node;
   16070           0 :     SgFormatItemList::next_node = (SgFormatItemList*)(object->p_freepointer);
   16071             : 
   16072             : #if ROSE_ALLOC_TRACE == 2
   16073             :     printf("SgFormatItemList::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgFormatItemList::next_node);
   16074             : #endif
   16075             : 
   16076           0 :     SgNode * fp = object->p_freepointer;
   16077             : #if ROSE_ALLOC_MEMSET == 1
   16078             : #elif ROSE_ALLOC_MEMSET == 2
   16079             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgFormatItemList) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   16080             : #elif ROSE_ALLOC_MEMSET == 3
   16081             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgFormatItemList) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   16082             : #endif
   16083           0 :     object->p_freepointer = fp;
   16084             : 
   16085             : #if ROSE_ALLOC_TRACE == 2
   16086             : //    printf("SgFormatItemList::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgFormatItemList::next_node);
   16087             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   16088             :     Rose::MemPool::snapshot(oss.str());
   16089             :     alloc_trace_cnt++;
   16090             : #endif
   16091             : 
   16092           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   16093             : 
   16094           0 :     ALLOC_MUTEX(SgFormatItemList, unlock);
   16095             : 
   16096             :     return object;
   16097             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   16098             : }
   16099             : 
   16100             : 
   16101             : 
   16102             : /*! \brief Delete operator for SgFormatItemList.
   16103             : 
   16104             :    This delete operator implements deallocation using memory pools to 
   16105             :    provide most efficent use of the heap within construction of large ASTs.
   16106             : 
   16107             : \internal The new and delete operators use the lower level C malloc/free
   16108             :    function calls for performance and to make sure that mixing of malloc/free
   16109             :    and new/delete by the used can be caught more readily.  This may change
   16110             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   16111             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   16112             :    deallocate memory allocated using ROSE_MALLOC.
   16113             : */
   16114           0 : void SgFormatItemList::operator delete(void *Pointer, size_t Size)
   16115             : {
   16116             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   16117             :      * or throwing an exception. */
   16118           0 :     ALLOC_MUTEX(SgFormatItemList, lock);
   16119             : 
   16120             : #if USE_CPP_NEW_DELETE_OPERATORS
   16121             :     ROSE_FREE(Pointer);
   16122             : #else
   16123             : #if ROSE_PEDANTIC_ALLOC
   16124             :     ROSE_ASSERT(Size == sizeof(SgFormatItemList));
   16125             : #else
   16126           0 :     if (Size != sizeof(SgFormatItemList)) {
   16127           0 :       ROSE_FREE(Pointer);
   16128           0 :       ALLOC_MUTEX(SgFormatItemList, unlock);
   16129             :       return;
   16130             :     }
   16131             : #endif
   16132             : 
   16133           0 :     SgFormatItemList * object = (SgFormatItemList*) Pointer;
   16134           0 :     ROSE_ASSERT(object != nullptr);
   16135             : 
   16136             : #if ROSE_ALLOC_TRACE == 2
   16137             : //  printf("SgFormatItemList::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgFormatItemList::next_node);
   16138             :     printf("SgFormatItemList::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgFormatItemList::next_node);
   16139             : #endif
   16140             : 
   16141             : #if ROSE_PEDANTIC_ALLOC
   16142             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   16143             : #endif
   16144             : 
   16145             : #if ROSE_ALLOC_MEMSET == 1
   16146             : #elif ROSE_ALLOC_MEMSET == 2
   16147             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgFormatItemList) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   16148             : #elif ROSE_ALLOC_MEMSET == 3
   16149             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgFormatItemList) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   16150             : #endif
   16151             : 
   16152             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   16153             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   16154             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   16155             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   16156             : #else
   16157           0 :     object->p_freepointer = SgFormatItemList::next_node;
   16158           0 :     SgFormatItemList::next_node = object;
   16159             : #endif
   16160             : 
   16161             : #if ROSE_ALLOC_TRACE == 2
   16162             : //  printf("SgFormatItemList::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgFormatItemList::next_node);
   16163             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   16164             :     Rose::MemPool::snapshot(oss.str());
   16165             :     alloc_trace_cnt++;
   16166             : #endif
   16167             : 
   16168             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   16169             : 
   16170           0 :     ALLOC_MUTEX(SgFormatItemList, unlock);
   16171             : }
   16172             : 
   16173             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   16174             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   16175             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   16176             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   16177             : // Also, note comment below from Robb (copied from the Common.code file).
   16178             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   16179             : //
   16180             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   16181             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   16182             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   16183             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   16184             : #if 0
   16185             : void SgFormatItemList::operator delete(void* pointer) { SgFormatItemList::operator delete (pointer, sizeof(SgFormatItemList)); };
   16186             : #endif
   16187             : /* #line 16188 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   16188             : 
   16189             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   16190             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   16191             : // obviously imply C++.
   16192             : 
   16193             : // This implements the support within ROSE for memory pools.  Memory pools
   16194             : // support the most condensed usage of memory within the construction of
   16195             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   16196             : // by a new operator written for each class.
   16197             : 
   16198             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   16199             :     // User wants multi-thread support and POSIX threads are available.
   16200             : #   include <pthread.h>
   16201             :     static pthread_mutex_t SgDataStatementGroup_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   16202             : #else
   16203             :      // Cause synchronization to be skipped.
   16204             : #    ifndef ALLOC_MUTEX
   16205             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   16206             : #    endif
   16207             : #    ifdef _REENTRANT
   16208             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   16209             : #       ifdef _MSC_VER
   16210             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   16211             : #       else
   16212             : #           warning "POSIX threads are not available; synchronization being skipped"
   16213             : #       endif
   16214             : #    endif
   16215             : #endif
   16216             : 
   16217             : #ifndef ROSE_ALLOC_TRACE
   16218             : #  define ROSE_ALLOC_TRACE 0
   16219             : #endif
   16220             : 
   16221             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   16222             : #define ROSE_ALLOC_TRACE_CNT
   16223             : #include "memory-pool-snapshot.h"
   16224             : unsigned long alloc_trace_cnt = 0;
   16225             : #endif
   16226             : 
   16227             : #if ROSE_ALLOC_TRACE
   16228             : const unsigned SgDataStatementGroup::pool_size = 5;
   16229             : #else
   16230             : const unsigned SgDataStatementGroup::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   16231             : #endif
   16232             : 
   16233             : #ifndef ROSE_ALLOC_MEMSET
   16234             : #  define ROSE_ALLOC_MEMSET 0
   16235             : #endif
   16236             : 
   16237             : #ifndef ROSE_PEDANTIC_ALLOC
   16238             : #  define ROSE_PEDANTIC_ALLOC 0
   16239             : #endif
   16240             : 
   16241             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   16242             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   16243             : #endif
   16244             : 
   16245             : #if !defined(SGNODE__ALL_POOLS)
   16246             : #define SGNODE__ALL_POOLS
   16247             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   16248             : #endif
   16249             : 
   16250             : SgDataStatementGroup* SgDataStatementGroup::next_node = nullptr;
   16251             : std::vector<unsigned char*> SgDataStatementGroup::pools;
   16252             : 
   16253             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   16254             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   16255             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   16256             : // around this macro definition rather than each use).
   16257             : #ifndef ALLOC_MUTEX
   16258             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   16259             :         do {                                                                     \
   16260             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   16261             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   16262             :                 abort();                                                         \
   16263             :             }                                                                    \
   16264             :         } while (0);
   16265             : #endif
   16266             : 
   16267             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   16268             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   16269             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   16270             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   16271             : 
   16272             : /*! \brief New operator for SgDataStatementGroup.
   16273             : 
   16274             :    This new operator implements memory pools to provide most efficent 
   16275             :    use of the heap within construction of large ASTs.
   16276             : 
   16277             : \internal The new and delete operators use the lower level C malloc/free
   16278             :    function calls for performance and to make sure that mixing of malloc/free
   16279             :    and new/delete by the used can be caught more readily.  This may change
   16280             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   16281             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   16282             :    deallocate memory allocated using ROSE_MALLOC.
   16283             : */
   16284           0 : void *SgDataStatementGroup::operator new ( size_t Size )
   16285             : {
   16286             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   16287             :      * returning or throwing an exception. */
   16288           0 :     ALLOC_MUTEX(SgDataStatementGroup, lock);
   16289             : 
   16290             : #if ROSE_ALLOC_TRACE == 2
   16291             : //    printf("SgDataStatementGroup::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgDataStatementGroup::next_node);
   16292             : #endif
   16293             : 
   16294             : #if USE_CPP_NEW_DELETE_OPERATORS
   16295             :     void *mem = ROSE_MALLOC(Size);
   16296             :     ALLOC_MUTEX(SgDataStatementGroup, unlock);
   16297             :     return mem;
   16298             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   16299             : #if ROSE_PEDANTIC_ALLOC
   16300             :     ROSE_ASSERT(Size == sizeof(SgDataStatementGroup));
   16301             : #else
   16302           0 :     if (Size != sizeof(SgDataStatementGroup)) {
   16303           0 :       void * object = ROSE_MALLOC(Size);
   16304           0 :       ALLOC_MUTEX(SgDataStatementGroup, unlock);
   16305             :       return object;
   16306             :     }
   16307             : #endif
   16308             : 
   16309           0 :     if (SgDataStatementGroup::next_node == nullptr) {
   16310           0 :         SgDataStatementGroup * alloc = (SgDataStatementGroup*) ROSE_MALLOC ( SgDataStatementGroup::pool_size * sizeof(SgDataStatementGroup) );
   16311           0 :         ROSE_ASSERT(alloc != nullptr);
   16312             : 
   16313             : #if ROSE_ALLOC_TRACE == 2
   16314             : //        printf("SgDataStatementGroup::alloc\n  block[%zi] = [ %p , %p [\n", SgDataStatementGroup::pools.size(), alloc, alloc + SgDataStatementGroup::pool_size);
   16315             : #endif
   16316             : 
   16317             : #if ROSE_ALLOC_MEMSET == 1
   16318             : #elif ROSE_ALLOC_MEMSET == 2
   16319             :         memset(alloc, 0x00, SgDataStatementGroup::pool_size * sizeof(SgDataStatementGroup));
   16320             : #elif ROSE_ALLOC_MEMSET == 3
   16321             :         memset(alloc, 0xAA, SgDataStatementGroup::pool_size * sizeof(SgDataStatementGroup));
   16322             : #endif
   16323           0 :         for (unsigned i=0; i < SgDataStatementGroup::pool_size-1; i++) {
   16324           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
   16325             :         }
   16326           0 :         alloc[SgDataStatementGroup::pool_size-1].p_freepointer = nullptr;
   16327             : 
   16328           0 :         SgDataStatementGroup::pools.push_back ( (unsigned char *) alloc );
   16329           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgDataStatementGroup::pool_size * sizeof(SgDataStatementGroup), V_SgDataStatementGroup ) );
   16330           0 :         SgDataStatementGroup::next_node = alloc;
   16331             :     }
   16332           0 :     ROSE_ASSERT(SgDataStatementGroup::next_node != nullptr);
   16333             : 
   16334           0 :     SgDataStatementGroup * object = SgDataStatementGroup::next_node;
   16335           0 :     SgDataStatementGroup::next_node = (SgDataStatementGroup*)(object->p_freepointer);
   16336             : 
   16337             : #if ROSE_ALLOC_TRACE == 2
   16338             :     printf("SgDataStatementGroup::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgDataStatementGroup::next_node);
   16339             : #endif
   16340             : 
   16341           0 :     SgNode * fp = object->p_freepointer;
   16342             : #if ROSE_ALLOC_MEMSET == 1
   16343             : #elif ROSE_ALLOC_MEMSET == 2
   16344             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgDataStatementGroup) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   16345             : #elif ROSE_ALLOC_MEMSET == 3
   16346             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgDataStatementGroup) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   16347             : #endif
   16348           0 :     object->p_freepointer = fp;
   16349             : 
   16350             : #if ROSE_ALLOC_TRACE == 2
   16351             : //    printf("SgDataStatementGroup::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgDataStatementGroup::next_node);
   16352             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   16353             :     Rose::MemPool::snapshot(oss.str());
   16354             :     alloc_trace_cnt++;
   16355             : #endif
   16356             : 
   16357           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   16358             : 
   16359           0 :     ALLOC_MUTEX(SgDataStatementGroup, unlock);
   16360             : 
   16361             :     return object;
   16362             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   16363             : }
   16364             : 
   16365             : 
   16366             : 
   16367             : /*! \brief Delete operator for SgDataStatementGroup.
   16368             : 
   16369             :    This delete operator implements deallocation using memory pools to 
   16370             :    provide most efficent use of the heap within construction of large ASTs.
   16371             : 
   16372             : \internal The new and delete operators use the lower level C malloc/free
   16373             :    function calls for performance and to make sure that mixing of malloc/free
   16374             :    and new/delete by the used can be caught more readily.  This may change
   16375             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   16376             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   16377             :    deallocate memory allocated using ROSE_MALLOC.
   16378             : */
   16379           0 : void SgDataStatementGroup::operator delete(void *Pointer, size_t Size)
   16380             : {
   16381             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   16382             :      * or throwing an exception. */
   16383           0 :     ALLOC_MUTEX(SgDataStatementGroup, lock);
   16384             : 
   16385             : #if USE_CPP_NEW_DELETE_OPERATORS
   16386             :     ROSE_FREE(Pointer);
   16387             : #else
   16388             : #if ROSE_PEDANTIC_ALLOC
   16389             :     ROSE_ASSERT(Size == sizeof(SgDataStatementGroup));
   16390             : #else
   16391           0 :     if (Size != sizeof(SgDataStatementGroup)) {
   16392           0 :       ROSE_FREE(Pointer);
   16393           0 :       ALLOC_MUTEX(SgDataStatementGroup, unlock);
   16394             :       return;
   16395             :     }
   16396             : #endif
   16397             : 
   16398           0 :     SgDataStatementGroup * object = (SgDataStatementGroup*) Pointer;
   16399           0 :     ROSE_ASSERT(object != nullptr);
   16400             : 
   16401             : #if ROSE_ALLOC_TRACE == 2
   16402             : //  printf("SgDataStatementGroup::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgDataStatementGroup::next_node);
   16403             :     printf("SgDataStatementGroup::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgDataStatementGroup::next_node);
   16404             : #endif
   16405             : 
   16406             : #if ROSE_PEDANTIC_ALLOC
   16407             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   16408             : #endif
   16409             : 
   16410             : #if ROSE_ALLOC_MEMSET == 1
   16411             : #elif ROSE_ALLOC_MEMSET == 2
   16412             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgDataStatementGroup) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   16413             : #elif ROSE_ALLOC_MEMSET == 3
   16414             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgDataStatementGroup) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   16415             : #endif
   16416             : 
   16417             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   16418             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   16419             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   16420             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   16421             : #else
   16422           0 :     object->p_freepointer = SgDataStatementGroup::next_node;
   16423           0 :     SgDataStatementGroup::next_node = object;
   16424             : #endif
   16425             : 
   16426             : #if ROSE_ALLOC_TRACE == 2
   16427             : //  printf("SgDataStatementGroup::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgDataStatementGroup::next_node);
   16428             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   16429             :     Rose::MemPool::snapshot(oss.str());
   16430             :     alloc_trace_cnt++;
   16431             : #endif
   16432             : 
   16433             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   16434             : 
   16435           0 :     ALLOC_MUTEX(SgDataStatementGroup, unlock);
   16436             : }
   16437             : 
   16438             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   16439             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   16440             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   16441             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   16442             : // Also, note comment below from Robb (copied from the Common.code file).
   16443             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   16444             : //
   16445             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   16446             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   16447             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   16448             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   16449             : #if 0
   16450             : void SgDataStatementGroup::operator delete(void* pointer) { SgDataStatementGroup::operator delete (pointer, sizeof(SgDataStatementGroup)); };
   16451             : #endif
   16452             : /* #line 16453 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   16453             : 
   16454             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   16455             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   16456             : // obviously imply C++.
   16457             : 
   16458             : // This implements the support within ROSE for memory pools.  Memory pools
   16459             : // support the most condensed usage of memory within the construction of
   16460             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   16461             : // by a new operator written for each class.
   16462             : 
   16463             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   16464             :     // User wants multi-thread support and POSIX threads are available.
   16465             : #   include <pthread.h>
   16466             :     static pthread_mutex_t SgDataStatementObject_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   16467             : #else
   16468             :      // Cause synchronization to be skipped.
   16469             : #    ifndef ALLOC_MUTEX
   16470             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   16471             : #    endif
   16472             : #    ifdef _REENTRANT
   16473             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   16474             : #       ifdef _MSC_VER
   16475             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   16476             : #       else
   16477             : #           warning "POSIX threads are not available; synchronization being skipped"
   16478             : #       endif
   16479             : #    endif
   16480             : #endif
   16481             : 
   16482             : #ifndef ROSE_ALLOC_TRACE
   16483             : #  define ROSE_ALLOC_TRACE 0
   16484             : #endif
   16485             : 
   16486             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   16487             : #define ROSE_ALLOC_TRACE_CNT
   16488             : #include "memory-pool-snapshot.h"
   16489             : unsigned long alloc_trace_cnt = 0;
   16490             : #endif
   16491             : 
   16492             : #if ROSE_ALLOC_TRACE
   16493             : const unsigned SgDataStatementObject::pool_size = 5;
   16494             : #else
   16495             : const unsigned SgDataStatementObject::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   16496             : #endif
   16497             : 
   16498             : #ifndef ROSE_ALLOC_MEMSET
   16499             : #  define ROSE_ALLOC_MEMSET 0
   16500             : #endif
   16501             : 
   16502             : #ifndef ROSE_PEDANTIC_ALLOC
   16503             : #  define ROSE_PEDANTIC_ALLOC 0
   16504             : #endif
   16505             : 
   16506             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   16507             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   16508             : #endif
   16509             : 
   16510             : #if !defined(SGNODE__ALL_POOLS)
   16511             : #define SGNODE__ALL_POOLS
   16512             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   16513             : #endif
   16514             : 
   16515             : SgDataStatementObject* SgDataStatementObject::next_node = nullptr;
   16516             : std::vector<unsigned char*> SgDataStatementObject::pools;
   16517             : 
   16518             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   16519             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   16520             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   16521             : // around this macro definition rather than each use).
   16522             : #ifndef ALLOC_MUTEX
   16523             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   16524             :         do {                                                                     \
   16525             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   16526             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   16527             :                 abort();                                                         \
   16528             :             }                                                                    \
   16529             :         } while (0);
   16530             : #endif
   16531             : 
   16532             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   16533             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   16534             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   16535             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   16536             : 
   16537             : /*! \brief New operator for SgDataStatementObject.
   16538             : 
   16539             :    This new operator implements memory pools to provide most efficent 
   16540             :    use of the heap within construction of large ASTs.
   16541             : 
   16542             : \internal The new and delete operators use the lower level C malloc/free
   16543             :    function calls for performance and to make sure that mixing of malloc/free
   16544             :    and new/delete by the used can be caught more readily.  This may change
   16545             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   16546             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   16547             :    deallocate memory allocated using ROSE_MALLOC.
   16548             : */
   16549           0 : void *SgDataStatementObject::operator new ( size_t Size )
   16550             : {
   16551             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   16552             :      * returning or throwing an exception. */
   16553           0 :     ALLOC_MUTEX(SgDataStatementObject, lock);
   16554             : 
   16555             : #if ROSE_ALLOC_TRACE == 2
   16556             : //    printf("SgDataStatementObject::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgDataStatementObject::next_node);
   16557             : #endif
   16558             : 
   16559             : #if USE_CPP_NEW_DELETE_OPERATORS
   16560             :     void *mem = ROSE_MALLOC(Size);
   16561             :     ALLOC_MUTEX(SgDataStatementObject, unlock);
   16562             :     return mem;
   16563             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   16564             : #if ROSE_PEDANTIC_ALLOC
   16565             :     ROSE_ASSERT(Size == sizeof(SgDataStatementObject));
   16566             : #else
   16567           0 :     if (Size != sizeof(SgDataStatementObject)) {
   16568           0 :       void * object = ROSE_MALLOC(Size);
   16569           0 :       ALLOC_MUTEX(SgDataStatementObject, unlock);
   16570             :       return object;
   16571             :     }
   16572             : #endif
   16573             : 
   16574           0 :     if (SgDataStatementObject::next_node == nullptr) {
   16575           0 :         SgDataStatementObject * alloc = (SgDataStatementObject*) ROSE_MALLOC ( SgDataStatementObject::pool_size * sizeof(SgDataStatementObject) );
   16576           0 :         ROSE_ASSERT(alloc != nullptr);
   16577             : 
   16578             : #if ROSE_ALLOC_TRACE == 2
   16579             : //        printf("SgDataStatementObject::alloc\n  block[%zi] = [ %p , %p [\n", SgDataStatementObject::pools.size(), alloc, alloc + SgDataStatementObject::pool_size);
   16580             : #endif
   16581             : 
   16582             : #if ROSE_ALLOC_MEMSET == 1
   16583             : #elif ROSE_ALLOC_MEMSET == 2
   16584             :         memset(alloc, 0x00, SgDataStatementObject::pool_size * sizeof(SgDataStatementObject));
   16585             : #elif ROSE_ALLOC_MEMSET == 3
   16586             :         memset(alloc, 0xAA, SgDataStatementObject::pool_size * sizeof(SgDataStatementObject));
   16587             : #endif
   16588           0 :         for (unsigned i=0; i < SgDataStatementObject::pool_size-1; i++) {
   16589           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
   16590             :         }
   16591           0 :         alloc[SgDataStatementObject::pool_size-1].p_freepointer = nullptr;
   16592             : 
   16593           0 :         SgDataStatementObject::pools.push_back ( (unsigned char *) alloc );
   16594           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgDataStatementObject::pool_size * sizeof(SgDataStatementObject), V_SgDataStatementObject ) );
   16595           0 :         SgDataStatementObject::next_node = alloc;
   16596             :     }
   16597           0 :     ROSE_ASSERT(SgDataStatementObject::next_node != nullptr);
   16598             : 
   16599           0 :     SgDataStatementObject * object = SgDataStatementObject::next_node;
   16600           0 :     SgDataStatementObject::next_node = (SgDataStatementObject*)(object->p_freepointer);
   16601             : 
   16602             : #if ROSE_ALLOC_TRACE == 2
   16603             :     printf("SgDataStatementObject::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgDataStatementObject::next_node);
   16604             : #endif
   16605             : 
   16606           0 :     SgNode * fp = object->p_freepointer;
   16607             : #if ROSE_ALLOC_MEMSET == 1
   16608             : #elif ROSE_ALLOC_MEMSET == 2
   16609             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgDataStatementObject) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   16610             : #elif ROSE_ALLOC_MEMSET == 3
   16611             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgDataStatementObject) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   16612             : #endif
   16613           0 :     object->p_freepointer = fp;
   16614             : 
   16615             : #if ROSE_ALLOC_TRACE == 2
   16616             : //    printf("SgDataStatementObject::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgDataStatementObject::next_node);
   16617             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   16618             :     Rose::MemPool::snapshot(oss.str());
   16619             :     alloc_trace_cnt++;
   16620             : #endif
   16621             : 
   16622           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   16623             : 
   16624           0 :     ALLOC_MUTEX(SgDataStatementObject, unlock);
   16625             : 
   16626             :     return object;
   16627             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   16628             : }
   16629             : 
   16630             : 
   16631             : 
   16632             : /*! \brief Delete operator for SgDataStatementObject.
   16633             : 
   16634             :    This delete operator implements deallocation using memory pools to 
   16635             :    provide most efficent use of the heap within construction of large ASTs.
   16636             : 
   16637             : \internal The new and delete operators use the lower level C malloc/free
   16638             :    function calls for performance and to make sure that mixing of malloc/free
   16639             :    and new/delete by the used can be caught more readily.  This may change
   16640             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   16641             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   16642             :    deallocate memory allocated using ROSE_MALLOC.
   16643             : */
   16644           0 : void SgDataStatementObject::operator delete(void *Pointer, size_t Size)
   16645             : {
   16646             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   16647             :      * or throwing an exception. */
   16648           0 :     ALLOC_MUTEX(SgDataStatementObject, lock);
   16649             : 
   16650             : #if USE_CPP_NEW_DELETE_OPERATORS
   16651             :     ROSE_FREE(Pointer);
   16652             : #else
   16653             : #if ROSE_PEDANTIC_ALLOC
   16654             :     ROSE_ASSERT(Size == sizeof(SgDataStatementObject));
   16655             : #else
   16656           0 :     if (Size != sizeof(SgDataStatementObject)) {
   16657           0 :       ROSE_FREE(Pointer);
   16658           0 :       ALLOC_MUTEX(SgDataStatementObject, unlock);
   16659             :       return;
   16660             :     }
   16661             : #endif
   16662             : 
   16663           0 :     SgDataStatementObject * object = (SgDataStatementObject*) Pointer;
   16664           0 :     ROSE_ASSERT(object != nullptr);
   16665             : 
   16666             : #if ROSE_ALLOC_TRACE == 2
   16667             : //  printf("SgDataStatementObject::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgDataStatementObject::next_node);
   16668             :     printf("SgDataStatementObject::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgDataStatementObject::next_node);
   16669             : #endif
   16670             : 
   16671             : #if ROSE_PEDANTIC_ALLOC
   16672             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   16673             : #endif
   16674             : 
   16675             : #if ROSE_ALLOC_MEMSET == 1
   16676             : #elif ROSE_ALLOC_MEMSET == 2
   16677             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgDataStatementObject) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   16678             : #elif ROSE_ALLOC_MEMSET == 3
   16679             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgDataStatementObject) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   16680             : #endif
   16681             : 
   16682             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   16683             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   16684             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   16685             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   16686             : #else
   16687           0 :     object->p_freepointer = SgDataStatementObject::next_node;
   16688           0 :     SgDataStatementObject::next_node = object;
   16689             : #endif
   16690             : 
   16691             : #if ROSE_ALLOC_TRACE == 2
   16692             : //  printf("SgDataStatementObject::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgDataStatementObject::next_node);
   16693             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   16694             :     Rose::MemPool::snapshot(oss.str());
   16695             :     alloc_trace_cnt++;
   16696             : #endif
   16697             : 
   16698             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   16699             : 
   16700           0 :     ALLOC_MUTEX(SgDataStatementObject, unlock);
   16701             : }
   16702             : 
   16703             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   16704             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   16705             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   16706             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   16707             : // Also, note comment below from Robb (copied from the Common.code file).
   16708             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   16709             : //
   16710             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   16711             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   16712             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   16713             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   16714             : #if 0
   16715             : void SgDataStatementObject::operator delete(void* pointer) { SgDataStatementObject::operator delete (pointer, sizeof(SgDataStatementObject)); };
   16716             : #endif
   16717             : /* #line 16718 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   16718             : 
   16719             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   16720             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   16721             : // obviously imply C++.
   16722             : 
   16723             : // This implements the support within ROSE for memory pools.  Memory pools
   16724             : // support the most condensed usage of memory within the construction of
   16725             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   16726             : // by a new operator written for each class.
   16727             : 
   16728             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   16729             :     // User wants multi-thread support and POSIX threads are available.
   16730             : #   include <pthread.h>
   16731             :     static pthread_mutex_t SgIncludeFile_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   16732             : #else
   16733             :      // Cause synchronization to be skipped.
   16734             : #    ifndef ALLOC_MUTEX
   16735             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   16736             : #    endif
   16737             : #    ifdef _REENTRANT
   16738             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   16739             : #       ifdef _MSC_VER
   16740             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   16741             : #       else
   16742             : #           warning "POSIX threads are not available; synchronization being skipped"
   16743             : #       endif
   16744             : #    endif
   16745             : #endif
   16746             : 
   16747             : #ifndef ROSE_ALLOC_TRACE
   16748             : #  define ROSE_ALLOC_TRACE 0
   16749             : #endif
   16750             : 
   16751             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   16752             : #define ROSE_ALLOC_TRACE_CNT
   16753             : #include "memory-pool-snapshot.h"
   16754             : unsigned long alloc_trace_cnt = 0;
   16755             : #endif
   16756             : 
   16757             : #if ROSE_ALLOC_TRACE
   16758             : const unsigned SgIncludeFile::pool_size = 5;
   16759             : #else
   16760             : const unsigned SgIncludeFile::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   16761             : #endif
   16762             : 
   16763             : #ifndef ROSE_ALLOC_MEMSET
   16764             : #  define ROSE_ALLOC_MEMSET 0
   16765             : #endif
   16766             : 
   16767             : #ifndef ROSE_PEDANTIC_ALLOC
   16768             : #  define ROSE_PEDANTIC_ALLOC 0
   16769             : #endif
   16770             : 
   16771             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   16772             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   16773             : #endif
   16774             : 
   16775             : #if !defined(SGNODE__ALL_POOLS)
   16776             : #define SGNODE__ALL_POOLS
   16777             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   16778             : #endif
   16779             : 
   16780             : SgIncludeFile* SgIncludeFile::next_node = nullptr;
   16781             : std::vector<unsigned char*> SgIncludeFile::pools;
   16782             : 
   16783             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   16784             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   16785             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   16786             : // around this macro definition rather than each use).
   16787             : #ifndef ALLOC_MUTEX
   16788             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   16789             :         do {                                                                     \
   16790             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   16791             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   16792             :                 abort();                                                         \
   16793             :             }                                                                    \
   16794             :         } while (0);
   16795             : #endif
   16796             : 
   16797             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   16798             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   16799             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   16800             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   16801             : 
   16802             : /*! \brief New operator for SgIncludeFile.
   16803             : 
   16804             :    This new operator implements memory pools to provide most efficent 
   16805             :    use of the heap within construction of large ASTs.
   16806             : 
   16807             : \internal The new and delete operators use the lower level C malloc/free
   16808             :    function calls for performance and to make sure that mixing of malloc/free
   16809             :    and new/delete by the used can be caught more readily.  This may change
   16810             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   16811             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   16812             :    deallocate memory allocated using ROSE_MALLOC.
   16813             : */
   16814       13424 : void *SgIncludeFile::operator new ( size_t Size )
   16815             : {
   16816             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   16817             :      * returning or throwing an exception. */
   16818       13424 :     ALLOC_MUTEX(SgIncludeFile, lock);
   16819             : 
   16820             : #if ROSE_ALLOC_TRACE == 2
   16821             : //    printf("SgIncludeFile::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgIncludeFile::next_node);
   16822             : #endif
   16823             : 
   16824             : #if USE_CPP_NEW_DELETE_OPERATORS
   16825             :     void *mem = ROSE_MALLOC(Size);
   16826             :     ALLOC_MUTEX(SgIncludeFile, unlock);
   16827             :     return mem;
   16828             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   16829             : #if ROSE_PEDANTIC_ALLOC
   16830             :     ROSE_ASSERT(Size == sizeof(SgIncludeFile));
   16831             : #else
   16832       13424 :     if (Size != sizeof(SgIncludeFile)) {
   16833           0 :       void * object = ROSE_MALLOC(Size);
   16834           0 :       ALLOC_MUTEX(SgIncludeFile, unlock);
   16835             :       return object;
   16836             :     }
   16837             : #endif
   16838             : 
   16839       13424 :     if (SgIncludeFile::next_node == nullptr) {
   16840         315 :         SgIncludeFile * alloc = (SgIncludeFile*) ROSE_MALLOC ( SgIncludeFile::pool_size * sizeof(SgIncludeFile) );
   16841         315 :         ROSE_ASSERT(alloc != nullptr);
   16842             : 
   16843             : #if ROSE_ALLOC_TRACE == 2
   16844             : //        printf("SgIncludeFile::alloc\n  block[%zi] = [ %p , %p [\n", SgIncludeFile::pools.size(), alloc, alloc + SgIncludeFile::pool_size);
   16845             : #endif
   16846             : 
   16847             : #if ROSE_ALLOC_MEMSET == 1
   16848             : #elif ROSE_ALLOC_MEMSET == 2
   16849             :         memset(alloc, 0x00, SgIncludeFile::pool_size * sizeof(SgIncludeFile));
   16850             : #elif ROSE_ALLOC_MEMSET == 3
   16851             :         memset(alloc, 0xAA, SgIncludeFile::pool_size * sizeof(SgIncludeFile));
   16852             : #endif
   16853      630000 :         for (unsigned i=0; i < SgIncludeFile::pool_size-1; i++) {
   16854      629685 :           alloc[i].p_freepointer = &(alloc[i+1]);
   16855             :         }
   16856         315 :         alloc[SgIncludeFile::pool_size-1].p_freepointer = nullptr;
   16857             : 
   16858         315 :         SgIncludeFile::pools.push_back ( (unsigned char *) alloc );
   16859         315 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgIncludeFile::pool_size * sizeof(SgIncludeFile), V_SgIncludeFile ) );
   16860         315 :         SgIncludeFile::next_node = alloc;
   16861             :     }
   16862       13424 :     ROSE_ASSERT(SgIncludeFile::next_node != nullptr);
   16863             : 
   16864       13424 :     SgIncludeFile * object = SgIncludeFile::next_node;
   16865       13424 :     SgIncludeFile::next_node = (SgIncludeFile*)(object->p_freepointer);
   16866             : 
   16867             : #if ROSE_ALLOC_TRACE == 2
   16868             :     printf("SgIncludeFile::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgIncludeFile::next_node);
   16869             : #endif
   16870             : 
   16871       13424 :     SgNode * fp = object->p_freepointer;
   16872             : #if ROSE_ALLOC_MEMSET == 1
   16873             : #elif ROSE_ALLOC_MEMSET == 2
   16874             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgIncludeFile) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   16875             : #elif ROSE_ALLOC_MEMSET == 3
   16876             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgIncludeFile) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   16877             : #endif
   16878       13424 :     object->p_freepointer = fp;
   16879             : 
   16880             : #if ROSE_ALLOC_TRACE == 2
   16881             : //    printf("SgIncludeFile::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgIncludeFile::next_node);
   16882             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   16883             :     Rose::MemPool::snapshot(oss.str());
   16884             :     alloc_trace_cnt++;
   16885             : #endif
   16886             : 
   16887       13424 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   16888             : 
   16889       13424 :     ALLOC_MUTEX(SgIncludeFile, unlock);
   16890             : 
   16891             :     return object;
   16892             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   16893             : }
   16894             : 
   16895             : 
   16896             : 
   16897             : /*! \brief Delete operator for SgIncludeFile.
   16898             : 
   16899             :    This delete operator implements deallocation using memory pools to 
   16900             :    provide most efficent use of the heap within construction of large ASTs.
   16901             : 
   16902             : \internal The new and delete operators use the lower level C malloc/free
   16903             :    function calls for performance and to make sure that mixing of malloc/free
   16904             :    and new/delete by the used can be caught more readily.  This may change
   16905             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   16906             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   16907             :    deallocate memory allocated using ROSE_MALLOC.
   16908             : */
   16909         448 : void SgIncludeFile::operator delete(void *Pointer, size_t Size)
   16910             : {
   16911             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   16912             :      * or throwing an exception. */
   16913         448 :     ALLOC_MUTEX(SgIncludeFile, lock);
   16914             : 
   16915             : #if USE_CPP_NEW_DELETE_OPERATORS
   16916             :     ROSE_FREE(Pointer);
   16917             : #else
   16918             : #if ROSE_PEDANTIC_ALLOC
   16919             :     ROSE_ASSERT(Size == sizeof(SgIncludeFile));
   16920             : #else
   16921         448 :     if (Size != sizeof(SgIncludeFile)) {
   16922           0 :       ROSE_FREE(Pointer);
   16923           0 :       ALLOC_MUTEX(SgIncludeFile, unlock);
   16924             :       return;
   16925             :     }
   16926             : #endif
   16927             : 
   16928         448 :     SgIncludeFile * object = (SgIncludeFile*) Pointer;
   16929         448 :     ROSE_ASSERT(object != nullptr);
   16930             : 
   16931             : #if ROSE_ALLOC_TRACE == 2
   16932             : //  printf("SgIncludeFile::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgIncludeFile::next_node);
   16933             :     printf("SgIncludeFile::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgIncludeFile::next_node);
   16934             : #endif
   16935             : 
   16936             : #if ROSE_PEDANTIC_ALLOC
   16937             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   16938             : #endif
   16939             : 
   16940             : #if ROSE_ALLOC_MEMSET == 1
   16941             : #elif ROSE_ALLOC_MEMSET == 2
   16942             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgIncludeFile) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   16943             : #elif ROSE_ALLOC_MEMSET == 3
   16944             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgIncludeFile) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   16945             : #endif
   16946             : 
   16947             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   16948             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   16949             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   16950             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   16951             : #else
   16952         448 :     object->p_freepointer = SgIncludeFile::next_node;
   16953         448 :     SgIncludeFile::next_node = object;
   16954             : #endif
   16955             : 
   16956             : #if ROSE_ALLOC_TRACE == 2
   16957             : //  printf("SgIncludeFile::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgIncludeFile::next_node);
   16958             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   16959             :     Rose::MemPool::snapshot(oss.str());
   16960             :     alloc_trace_cnt++;
   16961             : #endif
   16962             : 
   16963             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   16964             : 
   16965         448 :     ALLOC_MUTEX(SgIncludeFile, unlock);
   16966             : }
   16967             : 
   16968             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   16969             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   16970             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   16971             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   16972             : // Also, note comment below from Robb (copied from the Common.code file).
   16973             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   16974             : //
   16975             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   16976             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   16977             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   16978             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   16979             : #if 0
   16980             : void SgIncludeFile::operator delete(void* pointer) { SgIncludeFile::operator delete (pointer, sizeof(SgIncludeFile)); };
   16981             : #endif
   16982             : /* #line 16983 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   16983             : 
   16984             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   16985             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   16986             : // obviously imply C++.
   16987             : 
   16988             : // This implements the support within ROSE for memory pools.  Memory pools
   16989             : // support the most condensed usage of memory within the construction of
   16990             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   16991             : // by a new operator written for each class.
   16992             : 
   16993             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   16994             :     // User wants multi-thread support and POSIX threads are available.
   16995             : #   include <pthread.h>
   16996             :     static pthread_mutex_t SgDataStatementValue_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   16997             : #else
   16998             :      // Cause synchronization to be skipped.
   16999             : #    ifndef ALLOC_MUTEX
   17000             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   17001             : #    endif
   17002             : #    ifdef _REENTRANT
   17003             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   17004             : #       ifdef _MSC_VER
   17005             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   17006             : #       else
   17007             : #           warning "POSIX threads are not available; synchronization being skipped"
   17008             : #       endif
   17009             : #    endif
   17010             : #endif
   17011             : 
   17012             : #ifndef ROSE_ALLOC_TRACE
   17013             : #  define ROSE_ALLOC_TRACE 0
   17014             : #endif
   17015             : 
   17016             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   17017             : #define ROSE_ALLOC_TRACE_CNT
   17018             : #include "memory-pool-snapshot.h"
   17019             : unsigned long alloc_trace_cnt = 0;
   17020             : #endif
   17021             : 
   17022             : #if ROSE_ALLOC_TRACE
   17023             : const unsigned SgDataStatementValue::pool_size = 5;
   17024             : #else
   17025             : const unsigned SgDataStatementValue::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   17026             : #endif
   17027             : 
   17028             : #ifndef ROSE_ALLOC_MEMSET
   17029             : #  define ROSE_ALLOC_MEMSET 0
   17030             : #endif
   17031             : 
   17032             : #ifndef ROSE_PEDANTIC_ALLOC
   17033             : #  define ROSE_PEDANTIC_ALLOC 0
   17034             : #endif
   17035             : 
   17036             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   17037             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   17038             : #endif
   17039             : 
   17040             : #if !defined(SGNODE__ALL_POOLS)
   17041             : #define SGNODE__ALL_POOLS
   17042             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   17043             : #endif
   17044             : 
   17045             : SgDataStatementValue* SgDataStatementValue::next_node = nullptr;
   17046             : std::vector<unsigned char*> SgDataStatementValue::pools;
   17047             : 
   17048             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   17049             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   17050             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   17051             : // around this macro definition rather than each use).
   17052             : #ifndef ALLOC_MUTEX
   17053             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   17054             :         do {                                                                     \
   17055             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   17056             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   17057             :                 abort();                                                         \
   17058             :             }                                                                    \
   17059             :         } while (0);
   17060             : #endif
   17061             : 
   17062             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   17063             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   17064             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   17065             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   17066             : 
   17067             : /*! \brief New operator for SgDataStatementValue.
   17068             : 
   17069             :    This new operator implements memory pools to provide most efficent 
   17070             :    use of the heap within construction of large ASTs.
   17071             : 
   17072             : \internal The new and delete operators use the lower level C malloc/free
   17073             :    function calls for performance and to make sure that mixing of malloc/free
   17074             :    and new/delete by the used can be caught more readily.  This may change
   17075             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   17076             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   17077             :    deallocate memory allocated using ROSE_MALLOC.
   17078             : */
   17079           0 : void *SgDataStatementValue::operator new ( size_t Size )
   17080             : {
   17081             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   17082             :      * returning or throwing an exception. */
   17083           0 :     ALLOC_MUTEX(SgDataStatementValue, lock);
   17084             : 
   17085             : #if ROSE_ALLOC_TRACE == 2
   17086             : //    printf("SgDataStatementValue::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgDataStatementValue::next_node);
   17087             : #endif
   17088             : 
   17089             : #if USE_CPP_NEW_DELETE_OPERATORS
   17090             :     void *mem = ROSE_MALLOC(Size);
   17091             :     ALLOC_MUTEX(SgDataStatementValue, unlock);
   17092             :     return mem;
   17093             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   17094             : #if ROSE_PEDANTIC_ALLOC
   17095             :     ROSE_ASSERT(Size == sizeof(SgDataStatementValue));
   17096             : #else
   17097           0 :     if (Size != sizeof(SgDataStatementValue)) {
   17098           0 :       void * object = ROSE_MALLOC(Size);
   17099           0 :       ALLOC_MUTEX(SgDataStatementValue, unlock);
   17100             :       return object;
   17101             :     }
   17102             : #endif
   17103             : 
   17104           0 :     if (SgDataStatementValue::next_node == nullptr) {
   17105           0 :         SgDataStatementValue * alloc = (SgDataStatementValue*) ROSE_MALLOC ( SgDataStatementValue::pool_size * sizeof(SgDataStatementValue) );
   17106           0 :         ROSE_ASSERT(alloc != nullptr);
   17107             : 
   17108             : #if ROSE_ALLOC_TRACE == 2
   17109             : //        printf("SgDataStatementValue::alloc\n  block[%zi] = [ %p , %p [\n", SgDataStatementValue::pools.size(), alloc, alloc + SgDataStatementValue::pool_size);
   17110             : #endif
   17111             : 
   17112             : #if ROSE_ALLOC_MEMSET == 1
   17113             : #elif ROSE_ALLOC_MEMSET == 2
   17114             :         memset(alloc, 0x00, SgDataStatementValue::pool_size * sizeof(SgDataStatementValue));
   17115             : #elif ROSE_ALLOC_MEMSET == 3
   17116             :         memset(alloc, 0xAA, SgDataStatementValue::pool_size * sizeof(SgDataStatementValue));
   17117             : #endif
   17118           0 :         for (unsigned i=0; i < SgDataStatementValue::pool_size-1; i++) {
   17119           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
   17120             :         }
   17121           0 :         alloc[SgDataStatementValue::pool_size-1].p_freepointer = nullptr;
   17122             : 
   17123           0 :         SgDataStatementValue::pools.push_back ( (unsigned char *) alloc );
   17124           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgDataStatementValue::pool_size * sizeof(SgDataStatementValue), V_SgDataStatementValue ) );
   17125           0 :         SgDataStatementValue::next_node = alloc;
   17126             :     }
   17127           0 :     ROSE_ASSERT(SgDataStatementValue::next_node != nullptr);
   17128             : 
   17129           0 :     SgDataStatementValue * object = SgDataStatementValue::next_node;
   17130           0 :     SgDataStatementValue::next_node = (SgDataStatementValue*)(object->p_freepointer);
   17131             : 
   17132             : #if ROSE_ALLOC_TRACE == 2
   17133             :     printf("SgDataStatementValue::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgDataStatementValue::next_node);
   17134             : #endif
   17135             : 
   17136           0 :     SgNode * fp = object->p_freepointer;
   17137             : #if ROSE_ALLOC_MEMSET == 1
   17138             : #elif ROSE_ALLOC_MEMSET == 2
   17139             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgDataStatementValue) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   17140             : #elif ROSE_ALLOC_MEMSET == 3
   17141             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgDataStatementValue) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   17142             : #endif
   17143           0 :     object->p_freepointer = fp;
   17144             : 
   17145             : #if ROSE_ALLOC_TRACE == 2
   17146             : //    printf("SgDataStatementValue::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgDataStatementValue::next_node);
   17147             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   17148             :     Rose::MemPool::snapshot(oss.str());
   17149             :     alloc_trace_cnt++;
   17150             : #endif
   17151             : 
   17152           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   17153             : 
   17154           0 :     ALLOC_MUTEX(SgDataStatementValue, unlock);
   17155             : 
   17156             :     return object;
   17157             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   17158             : }
   17159             : 
   17160             : 
   17161             : 
   17162             : /*! \brief Delete operator for SgDataStatementValue.
   17163             : 
   17164             :    This delete operator implements deallocation using memory pools to 
   17165             :    provide most efficent use of the heap within construction of large ASTs.
   17166             : 
   17167             : \internal The new and delete operators use the lower level C malloc/free
   17168             :    function calls for performance and to make sure that mixing of malloc/free
   17169             :    and new/delete by the used can be caught more readily.  This may change
   17170             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   17171             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   17172             :    deallocate memory allocated using ROSE_MALLOC.
   17173             : */
   17174           0 : void SgDataStatementValue::operator delete(void *Pointer, size_t Size)
   17175             : {
   17176             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   17177             :      * or throwing an exception. */
   17178           0 :     ALLOC_MUTEX(SgDataStatementValue, lock);
   17179             : 
   17180             : #if USE_CPP_NEW_DELETE_OPERATORS
   17181             :     ROSE_FREE(Pointer);
   17182             : #else
   17183             : #if ROSE_PEDANTIC_ALLOC
   17184             :     ROSE_ASSERT(Size == sizeof(SgDataStatementValue));
   17185             : #else
   17186           0 :     if (Size != sizeof(SgDataStatementValue)) {
   17187           0 :       ROSE_FREE(Pointer);
   17188           0 :       ALLOC_MUTEX(SgDataStatementValue, unlock);
   17189             :       return;
   17190             :     }
   17191             : #endif
   17192             : 
   17193           0 :     SgDataStatementValue * object = (SgDataStatementValue*) Pointer;
   17194           0 :     ROSE_ASSERT(object != nullptr);
   17195             : 
   17196             : #if ROSE_ALLOC_TRACE == 2
   17197             : //  printf("SgDataStatementValue::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgDataStatementValue::next_node);
   17198             :     printf("SgDataStatementValue::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgDataStatementValue::next_node);
   17199             : #endif
   17200             : 
   17201             : #if ROSE_PEDANTIC_ALLOC
   17202             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   17203             : #endif
   17204             : 
   17205             : #if ROSE_ALLOC_MEMSET == 1
   17206             : #elif ROSE_ALLOC_MEMSET == 2
   17207             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgDataStatementValue) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   17208             : #elif ROSE_ALLOC_MEMSET == 3
   17209             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgDataStatementValue) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   17210             : #endif
   17211             : 
   17212             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   17213             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   17214             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   17215             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   17216             : #else
   17217           0 :     object->p_freepointer = SgDataStatementValue::next_node;
   17218           0 :     SgDataStatementValue::next_node = object;
   17219             : #endif
   17220             : 
   17221             : #if ROSE_ALLOC_TRACE == 2
   17222             : //  printf("SgDataStatementValue::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgDataStatementValue::next_node);
   17223             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   17224             :     Rose::MemPool::snapshot(oss.str());
   17225             :     alloc_trace_cnt++;
   17226             : #endif
   17227             : 
   17228             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   17229             : 
   17230           0 :     ALLOC_MUTEX(SgDataStatementValue, unlock);
   17231             : }
   17232             : 
   17233             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   17234             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   17235             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   17236             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   17237             : // Also, note comment below from Robb (copied from the Common.code file).
   17238             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   17239             : //
   17240             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   17241             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   17242             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   17243             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   17244             : #if 0
   17245             : void SgDataStatementValue::operator delete(void* pointer) { SgDataStatementValue::operator delete (pointer, sizeof(SgDataStatementValue)); };
   17246             : #endif
   17247             : /* #line 17248 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   17248             : 
   17249             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   17250             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   17251             : // obviously imply C++.
   17252             : 
   17253             : // This implements the support within ROSE for memory pools.  Memory pools
   17254             : // support the most condensed usage of memory within the construction of
   17255             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   17256             : // by a new operator written for each class.
   17257             : 
   17258             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   17259             :     // User wants multi-thread support and POSIX threads are available.
   17260             : #   include <pthread.h>
   17261             :     static pthread_mutex_t SgHeaderFileReport_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   17262             : #else
   17263             :      // Cause synchronization to be skipped.
   17264             : #    ifndef ALLOC_MUTEX
   17265             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   17266             : #    endif
   17267             : #    ifdef _REENTRANT
   17268             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   17269             : #       ifdef _MSC_VER
   17270             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   17271             : #       else
   17272             : #           warning "POSIX threads are not available; synchronization being skipped"
   17273             : #       endif
   17274             : #    endif
   17275             : #endif
   17276             : 
   17277             : #ifndef ROSE_ALLOC_TRACE
   17278             : #  define ROSE_ALLOC_TRACE 0
   17279             : #endif
   17280             : 
   17281             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   17282             : #define ROSE_ALLOC_TRACE_CNT
   17283             : #include "memory-pool-snapshot.h"
   17284             : unsigned long alloc_trace_cnt = 0;
   17285             : #endif
   17286             : 
   17287             : #if ROSE_ALLOC_TRACE
   17288             : const unsigned SgHeaderFileReport::pool_size = 5;
   17289             : #else
   17290             : const unsigned SgHeaderFileReport::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   17291             : #endif
   17292             : 
   17293             : #ifndef ROSE_ALLOC_MEMSET
   17294             : #  define ROSE_ALLOC_MEMSET 0
   17295             : #endif
   17296             : 
   17297             : #ifndef ROSE_PEDANTIC_ALLOC
   17298             : #  define ROSE_PEDANTIC_ALLOC 0
   17299             : #endif
   17300             : 
   17301             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   17302             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   17303             : #endif
   17304             : 
   17305             : #if !defined(SGNODE__ALL_POOLS)
   17306             : #define SGNODE__ALL_POOLS
   17307             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   17308             : #endif
   17309             : 
   17310             : SgHeaderFileReport* SgHeaderFileReport::next_node = nullptr;
   17311             : std::vector<unsigned char*> SgHeaderFileReport::pools;
   17312             : 
   17313             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   17314             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   17315             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   17316             : // around this macro definition rather than each use).
   17317             : #ifndef ALLOC_MUTEX
   17318             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   17319             :         do {                                                                     \
   17320             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   17321             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   17322             :                 abort();                                                         \
   17323             :             }                                                                    \
   17324             :         } while (0);
   17325             : #endif
   17326             : 
   17327             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   17328             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   17329             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   17330             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   17331             : 
   17332             : /*! \brief New operator for SgHeaderFileReport.
   17333             : 
   17334             :    This new operator implements memory pools to provide most efficent 
   17335             :    use of the heap within construction of large ASTs.
   17336             : 
   17337             : \internal The new and delete operators use the lower level C malloc/free
   17338             :    function calls for performance and to make sure that mixing of malloc/free
   17339             :    and new/delete by the used can be caught more readily.  This may change
   17340             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   17341             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   17342             :    deallocate memory allocated using ROSE_MALLOC.
   17343             : */
   17344           0 : void *SgHeaderFileReport::operator new ( size_t Size )
   17345             : {
   17346             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   17347             :      * returning or throwing an exception. */
   17348           0 :     ALLOC_MUTEX(SgHeaderFileReport, lock);
   17349             : 
   17350             : #if ROSE_ALLOC_TRACE == 2
   17351             : //    printf("SgHeaderFileReport::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgHeaderFileReport::next_node);
   17352             : #endif
   17353             : 
   17354             : #if USE_CPP_NEW_DELETE_OPERATORS
   17355             :     void *mem = ROSE_MALLOC(Size);
   17356             :     ALLOC_MUTEX(SgHeaderFileReport, unlock);
   17357             :     return mem;
   17358             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   17359             : #if ROSE_PEDANTIC_ALLOC
   17360             :     ROSE_ASSERT(Size == sizeof(SgHeaderFileReport));
   17361             : #else
   17362           0 :     if (Size != sizeof(SgHeaderFileReport)) {
   17363           0 :       void * object = ROSE_MALLOC(Size);
   17364           0 :       ALLOC_MUTEX(SgHeaderFileReport, unlock);
   17365             :       return object;
   17366             :     }
   17367             : #endif
   17368             : 
   17369           0 :     if (SgHeaderFileReport::next_node == nullptr) {
   17370           0 :         SgHeaderFileReport * alloc = (SgHeaderFileReport*) ROSE_MALLOC ( SgHeaderFileReport::pool_size * sizeof(SgHeaderFileReport) );
   17371           0 :         ROSE_ASSERT(alloc != nullptr);
   17372             : 
   17373             : #if ROSE_ALLOC_TRACE == 2
   17374             : //        printf("SgHeaderFileReport::alloc\n  block[%zi] = [ %p , %p [\n", SgHeaderFileReport::pools.size(), alloc, alloc + SgHeaderFileReport::pool_size);
   17375             : #endif
   17376             : 
   17377             : #if ROSE_ALLOC_MEMSET == 1
   17378             : #elif ROSE_ALLOC_MEMSET == 2
   17379             :         memset(alloc, 0x00, SgHeaderFileReport::pool_size * sizeof(SgHeaderFileReport));
   17380             : #elif ROSE_ALLOC_MEMSET == 3
   17381             :         memset(alloc, 0xAA, SgHeaderFileReport::pool_size * sizeof(SgHeaderFileReport));
   17382             : #endif
   17383           0 :         for (unsigned i=0; i < SgHeaderFileReport::pool_size-1; i++) {
   17384           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
   17385             :         }
   17386           0 :         alloc[SgHeaderFileReport::pool_size-1].p_freepointer = nullptr;
   17387             : 
   17388           0 :         SgHeaderFileReport::pools.push_back ( (unsigned char *) alloc );
   17389           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgHeaderFileReport::pool_size * sizeof(SgHeaderFileReport), V_SgHeaderFileReport ) );
   17390           0 :         SgHeaderFileReport::next_node = alloc;
   17391             :     }
   17392           0 :     ROSE_ASSERT(SgHeaderFileReport::next_node != nullptr);
   17393             : 
   17394           0 :     SgHeaderFileReport * object = SgHeaderFileReport::next_node;
   17395           0 :     SgHeaderFileReport::next_node = (SgHeaderFileReport*)(object->p_freepointer);
   17396             : 
   17397             : #if ROSE_ALLOC_TRACE == 2
   17398             :     printf("SgHeaderFileReport::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgHeaderFileReport::next_node);
   17399             : #endif
   17400             : 
   17401           0 :     SgNode * fp = object->p_freepointer;
   17402             : #if ROSE_ALLOC_MEMSET == 1
   17403             : #elif ROSE_ALLOC_MEMSET == 2
   17404             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgHeaderFileReport) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   17405             : #elif ROSE_ALLOC_MEMSET == 3
   17406             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgHeaderFileReport) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   17407             : #endif
   17408           0 :     object->p_freepointer = fp;
   17409             : 
   17410             : #if ROSE_ALLOC_TRACE == 2
   17411             : //    printf("SgHeaderFileReport::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgHeaderFileReport::next_node);
   17412             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   17413             :     Rose::MemPool::snapshot(oss.str());
   17414             :     alloc_trace_cnt++;
   17415             : #endif
   17416             : 
   17417           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   17418             : 
   17419           0 :     ALLOC_MUTEX(SgHeaderFileReport, unlock);
   17420             : 
   17421             :     return object;
   17422             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   17423             : }
   17424             : 
   17425             : 
   17426             : 
   17427             : /*! \brief Delete operator for SgHeaderFileReport.
   17428             : 
   17429             :    This delete operator implements deallocation using memory pools to 
   17430             :    provide most efficent use of the heap within construction of large ASTs.
   17431             : 
   17432             : \internal The new and delete operators use the lower level C malloc/free
   17433             :    function calls for performance and to make sure that mixing of malloc/free
   17434             :    and new/delete by the used can be caught more readily.  This may change
   17435             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   17436             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   17437             :    deallocate memory allocated using ROSE_MALLOC.
   17438             : */
   17439           0 : void SgHeaderFileReport::operator delete(void *Pointer, size_t Size)
   17440             : {
   17441             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   17442             :      * or throwing an exception. */
   17443           0 :     ALLOC_MUTEX(SgHeaderFileReport, lock);
   17444             : 
   17445             : #if USE_CPP_NEW_DELETE_OPERATORS
   17446             :     ROSE_FREE(Pointer);
   17447             : #else
   17448             : #if ROSE_PEDANTIC_ALLOC
   17449             :     ROSE_ASSERT(Size == sizeof(SgHeaderFileReport));
   17450             : #else
   17451           0 :     if (Size != sizeof(SgHeaderFileReport)) {
   17452           0 :       ROSE_FREE(Pointer);
   17453           0 :       ALLOC_MUTEX(SgHeaderFileReport, unlock);
   17454             :       return;
   17455             :     }
   17456             : #endif
   17457             : 
   17458           0 :     SgHeaderFileReport * object = (SgHeaderFileReport*) Pointer;
   17459           0 :     ROSE_ASSERT(object != nullptr);
   17460             : 
   17461             : #if ROSE_ALLOC_TRACE == 2
   17462             : //  printf("SgHeaderFileReport::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgHeaderFileReport::next_node);
   17463             :     printf("SgHeaderFileReport::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgHeaderFileReport::next_node);
   17464             : #endif
   17465             : 
   17466             : #if ROSE_PEDANTIC_ALLOC
   17467             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   17468             : #endif
   17469             : 
   17470             : #if ROSE_ALLOC_MEMSET == 1
   17471             : #elif ROSE_ALLOC_MEMSET == 2
   17472             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgHeaderFileReport) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   17473             : #elif ROSE_ALLOC_MEMSET == 3
   17474             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgHeaderFileReport) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   17475             : #endif
   17476             : 
   17477             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   17478             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   17479             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   17480             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   17481             : #else
   17482           0 :     object->p_freepointer = SgHeaderFileReport::next_node;
   17483           0 :     SgHeaderFileReport::next_node = object;
   17484             : #endif
   17485             : 
   17486             : #if ROSE_ALLOC_TRACE == 2
   17487             : //  printf("SgHeaderFileReport::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgHeaderFileReport::next_node);
   17488             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   17489             :     Rose::MemPool::snapshot(oss.str());
   17490             :     alloc_trace_cnt++;
   17491             : #endif
   17492             : 
   17493             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   17494             : 
   17495           0 :     ALLOC_MUTEX(SgHeaderFileReport, unlock);
   17496             : }
   17497             : 
   17498             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   17499             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   17500             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   17501             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   17502             : // Also, note comment below from Robb (copied from the Common.code file).
   17503             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   17504             : //
   17505             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   17506             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   17507             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   17508             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   17509             : #if 0
   17510             : void SgHeaderFileReport::operator delete(void* pointer) { SgHeaderFileReport::operator delete (pointer, sizeof(SgHeaderFileReport)); };
   17511             : #endif
   17512             : /* #line 17513 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   17513             : 
   17514             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   17515             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   17516             : // obviously imply C++.
   17517             : 
   17518             : // This implements the support within ROSE for memory pools.  Memory pools
   17519             : // support the most condensed usage of memory within the construction of
   17520             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   17521             : // by a new operator written for each class.
   17522             : 
   17523             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   17524             :     // User wants multi-thread support and POSIX threads are available.
   17525             : #   include <pthread.h>
   17526             :     static pthread_mutex_t SgType_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   17527             : #else
   17528             :      // Cause synchronization to be skipped.
   17529             : #    ifndef ALLOC_MUTEX
   17530             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   17531             : #    endif
   17532             : #    ifdef _REENTRANT
   17533             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   17534             : #       ifdef _MSC_VER
   17535             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   17536             : #       else
   17537             : #           warning "POSIX threads are not available; synchronization being skipped"
   17538             : #       endif
   17539             : #    endif
   17540             : #endif
   17541             : 
   17542             : #ifndef ROSE_ALLOC_TRACE
   17543             : #  define ROSE_ALLOC_TRACE 0
   17544             : #endif
   17545             : 
   17546             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   17547             : #define ROSE_ALLOC_TRACE_CNT
   17548             : #include "memory-pool-snapshot.h"
   17549             : unsigned long alloc_trace_cnt = 0;
   17550             : #endif
   17551             : 
   17552             : #if ROSE_ALLOC_TRACE
   17553             : const unsigned SgType::pool_size = 5;
   17554             : #else
   17555             : const unsigned SgType::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   17556             : #endif
   17557             : 
   17558             : #ifndef ROSE_ALLOC_MEMSET
   17559             : #  define ROSE_ALLOC_MEMSET 0
   17560             : #endif
   17561             : 
   17562             : #ifndef ROSE_PEDANTIC_ALLOC
   17563             : #  define ROSE_PEDANTIC_ALLOC 0
   17564             : #endif
   17565             : 
   17566             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   17567             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   17568             : #endif
   17569             : 
   17570             : #if !defined(SGNODE__ALL_POOLS)
   17571             : #define SGNODE__ALL_POOLS
   17572             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   17573             : #endif
   17574             : 
   17575             : SgType* SgType::next_node = nullptr;
   17576             : std::vector<unsigned char*> SgType::pools;
   17577             : 
   17578             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   17579             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   17580             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   17581             : // around this macro definition rather than each use).
   17582             : #ifndef ALLOC_MUTEX
   17583             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   17584             :         do {                                                                     \
   17585             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   17586             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   17587             :                 abort();                                                         \
   17588             :             }                                                                    \
   17589             :         } while (0);
   17590             : #endif
   17591             : 
   17592             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   17593             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   17594             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   17595             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   17596             : 
   17597             : /*! \brief New operator for SgType.
   17598             : 
   17599             :    This new operator implements memory pools to provide most efficent 
   17600             :    use of the heap within construction of large ASTs.
   17601             : 
   17602             : \internal The new and delete operators use the lower level C malloc/free
   17603             :    function calls for performance and to make sure that mixing of malloc/free
   17604             :    and new/delete by the used can be caught more readily.  This may change
   17605             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   17606             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   17607             :    deallocate memory allocated using ROSE_MALLOC.
   17608             : */
   17609           0 : void *SgType::operator new ( size_t Size )
   17610             : {
   17611             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   17612             :      * returning or throwing an exception. */
   17613           0 :     ALLOC_MUTEX(SgType, lock);
   17614             : 
   17615             : #if ROSE_ALLOC_TRACE == 2
   17616             : //    printf("SgType::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgType::next_node);
   17617             : #endif
   17618             : 
   17619             : #if USE_CPP_NEW_DELETE_OPERATORS
   17620             :     void *mem = ROSE_MALLOC(Size);
   17621             :     ALLOC_MUTEX(SgType, unlock);
   17622             :     return mem;
   17623             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   17624             : #if ROSE_PEDANTIC_ALLOC
   17625             :     ROSE_ASSERT(Size == sizeof(SgType));
   17626             : #else
   17627           0 :     if (Size != sizeof(SgType)) {
   17628           0 :       void * object = ROSE_MALLOC(Size);
   17629           0 :       ALLOC_MUTEX(SgType, unlock);
   17630             :       return object;
   17631             :     }
   17632             : #endif
   17633             : 
   17634           0 :     if (SgType::next_node == nullptr) {
   17635           0 :         SgType * alloc = (SgType*) ROSE_MALLOC ( SgType::pool_size * sizeof(SgType) );
   17636           0 :         ROSE_ASSERT(alloc != nullptr);
   17637             : 
   17638             : #if ROSE_ALLOC_TRACE == 2
   17639             : //        printf("SgType::alloc\n  block[%zi] = [ %p , %p [\n", SgType::pools.size(), alloc, alloc + SgType::pool_size);
   17640             : #endif
   17641             : 
   17642             : #if ROSE_ALLOC_MEMSET == 1
   17643             : #elif ROSE_ALLOC_MEMSET == 2
   17644             :         memset(alloc, 0x00, SgType::pool_size * sizeof(SgType));
   17645             : #elif ROSE_ALLOC_MEMSET == 3
   17646             :         memset(alloc, 0xAA, SgType::pool_size * sizeof(SgType));
   17647             : #endif
   17648           0 :         for (unsigned i=0; i < SgType::pool_size-1; i++) {
   17649           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
   17650             :         }
   17651           0 :         alloc[SgType::pool_size-1].p_freepointer = nullptr;
   17652             : 
   17653           0 :         SgType::pools.push_back ( (unsigned char *) alloc );
   17654           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgType::pool_size * sizeof(SgType), V_SgType ) );
   17655           0 :         SgType::next_node = alloc;
   17656             :     }
   17657           0 :     ROSE_ASSERT(SgType::next_node != nullptr);
   17658             : 
   17659           0 :     SgType * object = SgType::next_node;
   17660           0 :     SgType::next_node = (SgType*)(object->p_freepointer);
   17661             : 
   17662             : #if ROSE_ALLOC_TRACE == 2
   17663             :     printf("SgType::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgType::next_node);
   17664             : #endif
   17665             : 
   17666           0 :     SgNode * fp = object->p_freepointer;
   17667             : #if ROSE_ALLOC_MEMSET == 1
   17668             : #elif ROSE_ALLOC_MEMSET == 2
   17669             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgType) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   17670             : #elif ROSE_ALLOC_MEMSET == 3
   17671             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgType) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   17672             : #endif
   17673           0 :     object->p_freepointer = fp;
   17674             : 
   17675             : #if ROSE_ALLOC_TRACE == 2
   17676             : //    printf("SgType::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgType::next_node);
   17677             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   17678             :     Rose::MemPool::snapshot(oss.str());
   17679             :     alloc_trace_cnt++;
   17680             : #endif
   17681             : 
   17682           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   17683             : 
   17684           0 :     ALLOC_MUTEX(SgType, unlock);
   17685             : 
   17686             :     return object;
   17687             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   17688             : }
   17689             : 
   17690             : 
   17691             : 
   17692             : /*! \brief Delete operator for SgType.
   17693             : 
   17694             :    This delete operator implements deallocation using memory pools to 
   17695             :    provide most efficent use of the heap within construction of large ASTs.
   17696             : 
   17697             : \internal The new and delete operators use the lower level C malloc/free
   17698             :    function calls for performance and to make sure that mixing of malloc/free
   17699             :    and new/delete by the used can be caught more readily.  This may change
   17700             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   17701             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   17702             :    deallocate memory allocated using ROSE_MALLOC.
   17703             : */
   17704           0 : void SgType::operator delete(void *Pointer, size_t Size)
   17705             : {
   17706             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   17707             :      * or throwing an exception. */
   17708           0 :     ALLOC_MUTEX(SgType, lock);
   17709             : 
   17710             : #if USE_CPP_NEW_DELETE_OPERATORS
   17711             :     ROSE_FREE(Pointer);
   17712             : #else
   17713             : #if ROSE_PEDANTIC_ALLOC
   17714             :     ROSE_ASSERT(Size == sizeof(SgType));
   17715             : #else
   17716           0 :     if (Size != sizeof(SgType)) {
   17717           0 :       ROSE_FREE(Pointer);
   17718           0 :       ALLOC_MUTEX(SgType, unlock);
   17719             :       return;
   17720             :     }
   17721             : #endif
   17722             : 
   17723           0 :     SgType * object = (SgType*) Pointer;
   17724           0 :     ROSE_ASSERT(object != nullptr);
   17725             : 
   17726             : #if ROSE_ALLOC_TRACE == 2
   17727             : //  printf("SgType::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgType::next_node);
   17728             :     printf("SgType::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgType::next_node);
   17729             : #endif
   17730             : 
   17731             : #if ROSE_PEDANTIC_ALLOC
   17732             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   17733             : #endif
   17734             : 
   17735             : #if ROSE_ALLOC_MEMSET == 1
   17736             : #elif ROSE_ALLOC_MEMSET == 2
   17737             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgType) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   17738             : #elif ROSE_ALLOC_MEMSET == 3
   17739             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgType) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   17740             : #endif
   17741             : 
   17742             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   17743             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   17744             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   17745             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   17746             : #else
   17747           0 :     object->p_freepointer = SgType::next_node;
   17748           0 :     SgType::next_node = object;
   17749             : #endif
   17750             : 
   17751             : #if ROSE_ALLOC_TRACE == 2
   17752             : //  printf("SgType::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgType::next_node);
   17753             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   17754             :     Rose::MemPool::snapshot(oss.str());
   17755             :     alloc_trace_cnt++;
   17756             : #endif
   17757             : 
   17758             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   17759             : 
   17760           0 :     ALLOC_MUTEX(SgType, unlock);
   17761             : }
   17762             : 
   17763             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   17764             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   17765             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   17766             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   17767             : // Also, note comment below from Robb (copied from the Common.code file).
   17768             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   17769             : //
   17770             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   17771             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   17772             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   17773             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   17774             : #if 0
   17775             : void SgType::operator delete(void* pointer) { SgType::operator delete (pointer, sizeof(SgType)); };
   17776             : #endif
   17777             : /* #line 17778 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   17778             : 
   17779             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   17780             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   17781             : // obviously imply C++.
   17782             : 
   17783             : // This implements the support within ROSE for memory pools.  Memory pools
   17784             : // support the most condensed usage of memory within the construction of
   17785             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   17786             : // by a new operator written for each class.
   17787             : 
   17788             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   17789             :     // User wants multi-thread support and POSIX threads are available.
   17790             : #   include <pthread.h>
   17791             :     static pthread_mutex_t SgTypeUnknown_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   17792             : #else
   17793             :      // Cause synchronization to be skipped.
   17794             : #    ifndef ALLOC_MUTEX
   17795             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   17796             : #    endif
   17797             : #    ifdef _REENTRANT
   17798             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   17799             : #       ifdef _MSC_VER
   17800             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   17801             : #       else
   17802             : #           warning "POSIX threads are not available; synchronization being skipped"
   17803             : #       endif
   17804             : #    endif
   17805             : #endif
   17806             : 
   17807             : #ifndef ROSE_ALLOC_TRACE
   17808             : #  define ROSE_ALLOC_TRACE 0
   17809             : #endif
   17810             : 
   17811             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   17812             : #define ROSE_ALLOC_TRACE_CNT
   17813             : #include "memory-pool-snapshot.h"
   17814             : unsigned long alloc_trace_cnt = 0;
   17815             : #endif
   17816             : 
   17817             : #if ROSE_ALLOC_TRACE
   17818             : const unsigned SgTypeUnknown::pool_size = 5;
   17819             : #else
   17820             : const unsigned SgTypeUnknown::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   17821             : #endif
   17822             : 
   17823             : #ifndef ROSE_ALLOC_MEMSET
   17824             : #  define ROSE_ALLOC_MEMSET 0
   17825             : #endif
   17826             : 
   17827             : #ifndef ROSE_PEDANTIC_ALLOC
   17828             : #  define ROSE_PEDANTIC_ALLOC 0
   17829             : #endif
   17830             : 
   17831             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   17832             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   17833             : #endif
   17834             : 
   17835             : #if !defined(SGNODE__ALL_POOLS)
   17836             : #define SGNODE__ALL_POOLS
   17837             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   17838             : #endif
   17839             : 
   17840             : SgTypeUnknown* SgTypeUnknown::next_node = nullptr;
   17841             : std::vector<unsigned char*> SgTypeUnknown::pools;
   17842             : 
   17843             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   17844             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   17845             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   17846             : // around this macro definition rather than each use).
   17847             : #ifndef ALLOC_MUTEX
   17848             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   17849             :         do {                                                                     \
   17850             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   17851             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   17852             :                 abort();                                                         \
   17853             :             }                                                                    \
   17854             :         } while (0);
   17855             : #endif
   17856             : 
   17857             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   17858             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   17859             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   17860             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   17861             : 
   17862             : /*! \brief New operator for SgTypeUnknown.
   17863             : 
   17864             :    This new operator implements memory pools to provide most efficent 
   17865             :    use of the heap within construction of large ASTs.
   17866             : 
   17867             : \internal The new and delete operators use the lower level C malloc/free
   17868             :    function calls for performance and to make sure that mixing of malloc/free
   17869             :    and new/delete by the used can be caught more readily.  This may change
   17870             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   17871             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   17872             :    deallocate memory allocated using ROSE_MALLOC.
   17873             : */
   17874       19646 : void *SgTypeUnknown::operator new ( size_t Size )
   17875             : {
   17876             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   17877             :      * returning or throwing an exception. */
   17878       19646 :     ALLOC_MUTEX(SgTypeUnknown, lock);
   17879             : 
   17880             : #if ROSE_ALLOC_TRACE == 2
   17881             : //    printf("SgTypeUnknown::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgTypeUnknown::next_node);
   17882             : #endif
   17883             : 
   17884             : #if USE_CPP_NEW_DELETE_OPERATORS
   17885             :     void *mem = ROSE_MALLOC(Size);
   17886             :     ALLOC_MUTEX(SgTypeUnknown, unlock);
   17887             :     return mem;
   17888             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   17889             : #if ROSE_PEDANTIC_ALLOC
   17890             :     ROSE_ASSERT(Size == sizeof(SgTypeUnknown));
   17891             : #else
   17892       19646 :     if (Size != sizeof(SgTypeUnknown)) {
   17893           0 :       void * object = ROSE_MALLOC(Size);
   17894           0 :       ALLOC_MUTEX(SgTypeUnknown, unlock);
   17895             :       return object;
   17896             :     }
   17897             : #endif
   17898             : 
   17899       19646 :     if (SgTypeUnknown::next_node == nullptr) {
   17900          28 :         SgTypeUnknown * alloc = (SgTypeUnknown*) ROSE_MALLOC ( SgTypeUnknown::pool_size * sizeof(SgTypeUnknown) );
   17901          28 :         ROSE_ASSERT(alloc != nullptr);
   17902             : 
   17903             : #if ROSE_ALLOC_TRACE == 2
   17904             : //        printf("SgTypeUnknown::alloc\n  block[%zi] = [ %p , %p [\n", SgTypeUnknown::pools.size(), alloc, alloc + SgTypeUnknown::pool_size);
   17905             : #endif
   17906             : 
   17907             : #if ROSE_ALLOC_MEMSET == 1
   17908             : #elif ROSE_ALLOC_MEMSET == 2
   17909             :         memset(alloc, 0x00, SgTypeUnknown::pool_size * sizeof(SgTypeUnknown));
   17910             : #elif ROSE_ALLOC_MEMSET == 3
   17911             :         memset(alloc, 0xAA, SgTypeUnknown::pool_size * sizeof(SgTypeUnknown));
   17912             : #endif
   17913       56000 :         for (unsigned i=0; i < SgTypeUnknown::pool_size-1; i++) {
   17914       55972 :           alloc[i].p_freepointer = &(alloc[i+1]);
   17915             :         }
   17916          28 :         alloc[SgTypeUnknown::pool_size-1].p_freepointer = nullptr;
   17917             : 
   17918          28 :         SgTypeUnknown::pools.push_back ( (unsigned char *) alloc );
   17919          28 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgTypeUnknown::pool_size * sizeof(SgTypeUnknown), V_SgTypeUnknown ) );
   17920          28 :         SgTypeUnknown::next_node = alloc;
   17921             :     }
   17922       19646 :     ROSE_ASSERT(SgTypeUnknown::next_node != nullptr);
   17923             : 
   17924       19646 :     SgTypeUnknown * object = SgTypeUnknown::next_node;
   17925       19646 :     SgTypeUnknown::next_node = (SgTypeUnknown*)(object->p_freepointer);
   17926             : 
   17927             : #if ROSE_ALLOC_TRACE == 2
   17928             :     printf("SgTypeUnknown::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeUnknown::next_node);
   17929             : #endif
   17930             : 
   17931       19646 :     SgNode * fp = object->p_freepointer;
   17932             : #if ROSE_ALLOC_MEMSET == 1
   17933             : #elif ROSE_ALLOC_MEMSET == 2
   17934             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgTypeUnknown) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   17935             : #elif ROSE_ALLOC_MEMSET == 3
   17936             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgTypeUnknown) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   17937             : #endif
   17938       19646 :     object->p_freepointer = fp;
   17939             : 
   17940             : #if ROSE_ALLOC_TRACE == 2
   17941             : //    printf("SgTypeUnknown::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeUnknown::next_node);
   17942             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   17943             :     Rose::MemPool::snapshot(oss.str());
   17944             :     alloc_trace_cnt++;
   17945             : #endif
   17946             : 
   17947       19646 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   17948             : 
   17949       19646 :     ALLOC_MUTEX(SgTypeUnknown, unlock);
   17950             : 
   17951             :     return object;
   17952             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   17953             : }
   17954             : 
   17955             : 
   17956             : 
   17957             : /*! \brief Delete operator for SgTypeUnknown.
   17958             : 
   17959             :    This delete operator implements deallocation using memory pools to 
   17960             :    provide most efficent use of the heap within construction of large ASTs.
   17961             : 
   17962             : \internal The new and delete operators use the lower level C malloc/free
   17963             :    function calls for performance and to make sure that mixing of malloc/free
   17964             :    and new/delete by the used can be caught more readily.  This may change
   17965             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   17966             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   17967             :    deallocate memory allocated using ROSE_MALLOC.
   17968             : */
   17969       19619 : void SgTypeUnknown::operator delete(void *Pointer, size_t Size)
   17970             : {
   17971             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   17972             :      * or throwing an exception. */
   17973       19619 :     ALLOC_MUTEX(SgTypeUnknown, lock);
   17974             : 
   17975             : #if USE_CPP_NEW_DELETE_OPERATORS
   17976             :     ROSE_FREE(Pointer);
   17977             : #else
   17978             : #if ROSE_PEDANTIC_ALLOC
   17979             :     ROSE_ASSERT(Size == sizeof(SgTypeUnknown));
   17980             : #else
   17981       19619 :     if (Size != sizeof(SgTypeUnknown)) {
   17982           0 :       ROSE_FREE(Pointer);
   17983           0 :       ALLOC_MUTEX(SgTypeUnknown, unlock);
   17984             :       return;
   17985             :     }
   17986             : #endif
   17987             : 
   17988       19619 :     SgTypeUnknown * object = (SgTypeUnknown*) Pointer;
   17989       19619 :     ROSE_ASSERT(object != nullptr);
   17990             : 
   17991             : #if ROSE_ALLOC_TRACE == 2
   17992             : //  printf("SgTypeUnknown::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeUnknown::next_node);
   17993             :     printf("SgTypeUnknown::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeUnknown::next_node);
   17994             : #endif
   17995             : 
   17996             : #if ROSE_PEDANTIC_ALLOC
   17997             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   17998             : #endif
   17999             : 
   18000             : #if ROSE_ALLOC_MEMSET == 1
   18001             : #elif ROSE_ALLOC_MEMSET == 2
   18002             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgTypeUnknown) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   18003             : #elif ROSE_ALLOC_MEMSET == 3
   18004             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgTypeUnknown) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   18005             : #endif
   18006             : 
   18007             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   18008             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   18009             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   18010             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   18011             : #else
   18012       19619 :     object->p_freepointer = SgTypeUnknown::next_node;
   18013       19619 :     SgTypeUnknown::next_node = object;
   18014             : #endif
   18015             : 
   18016             : #if ROSE_ALLOC_TRACE == 2
   18017             : //  printf("SgTypeUnknown::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeUnknown::next_node);
   18018             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   18019             :     Rose::MemPool::snapshot(oss.str());
   18020             :     alloc_trace_cnt++;
   18021             : #endif
   18022             : 
   18023             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   18024             : 
   18025       19619 :     ALLOC_MUTEX(SgTypeUnknown, unlock);
   18026             : }
   18027             : 
   18028             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   18029             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   18030             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   18031             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   18032             : // Also, note comment below from Robb (copied from the Common.code file).
   18033             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   18034             : //
   18035             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   18036             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   18037             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   18038             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   18039             : #if 0
   18040             : void SgTypeUnknown::operator delete(void* pointer) { SgTypeUnknown::operator delete (pointer, sizeof(SgTypeUnknown)); };
   18041             : #endif
   18042             : /* #line 18043 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   18043             : 
   18044             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   18045             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   18046             : // obviously imply C++.
   18047             : 
   18048             : // This implements the support within ROSE for memory pools.  Memory pools
   18049             : // support the most condensed usage of memory within the construction of
   18050             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   18051             : // by a new operator written for each class.
   18052             : 
   18053             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   18054             :     // User wants multi-thread support and POSIX threads are available.
   18055             : #   include <pthread.h>
   18056             :     static pthread_mutex_t SgTypeChar_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   18057             : #else
   18058             :      // Cause synchronization to be skipped.
   18059             : #    ifndef ALLOC_MUTEX
   18060             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   18061             : #    endif
   18062             : #    ifdef _REENTRANT
   18063             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   18064             : #       ifdef _MSC_VER
   18065             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   18066             : #       else
   18067             : #           warning "POSIX threads are not available; synchronization being skipped"
   18068             : #       endif
   18069             : #    endif
   18070             : #endif
   18071             : 
   18072             : #ifndef ROSE_ALLOC_TRACE
   18073             : #  define ROSE_ALLOC_TRACE 0
   18074             : #endif
   18075             : 
   18076             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   18077             : #define ROSE_ALLOC_TRACE_CNT
   18078             : #include "memory-pool-snapshot.h"
   18079             : unsigned long alloc_trace_cnt = 0;
   18080             : #endif
   18081             : 
   18082             : #if ROSE_ALLOC_TRACE
   18083             : const unsigned SgTypeChar::pool_size = 5;
   18084             : #else
   18085             : const unsigned SgTypeChar::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   18086             : #endif
   18087             : 
   18088             : #ifndef ROSE_ALLOC_MEMSET
   18089             : #  define ROSE_ALLOC_MEMSET 0
   18090             : #endif
   18091             : 
   18092             : #ifndef ROSE_PEDANTIC_ALLOC
   18093             : #  define ROSE_PEDANTIC_ALLOC 0
   18094             : #endif
   18095             : 
   18096             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   18097             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   18098             : #endif
   18099             : 
   18100             : #if !defined(SGNODE__ALL_POOLS)
   18101             : #define SGNODE__ALL_POOLS
   18102             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   18103             : #endif
   18104             : 
   18105             : SgTypeChar* SgTypeChar::next_node = nullptr;
   18106             : std::vector<unsigned char*> SgTypeChar::pools;
   18107             : 
   18108             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   18109             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   18110             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   18111             : // around this macro definition rather than each use).
   18112             : #ifndef ALLOC_MUTEX
   18113             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   18114             :         do {                                                                     \
   18115             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   18116             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   18117             :                 abort();                                                         \
   18118             :             }                                                                    \
   18119             :         } while (0);
   18120             : #endif
   18121             : 
   18122             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   18123             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   18124             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   18125             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   18126             : 
   18127             : /*! \brief New operator for SgTypeChar.
   18128             : 
   18129             :    This new operator implements memory pools to provide most efficent 
   18130             :    use of the heap within construction of large ASTs.
   18131             : 
   18132             : \internal The new and delete operators use the lower level C malloc/free
   18133             :    function calls for performance and to make sure that mixing of malloc/free
   18134             :    and new/delete by the used can be caught more readily.  This may change
   18135             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   18136             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   18137             :    deallocate memory allocated using ROSE_MALLOC.
   18138             : */
   18139         810 : void *SgTypeChar::operator new ( size_t Size )
   18140             : {
   18141             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   18142             :      * returning or throwing an exception. */
   18143         810 :     ALLOC_MUTEX(SgTypeChar, lock);
   18144             : 
   18145             : #if ROSE_ALLOC_TRACE == 2
   18146             : //    printf("SgTypeChar::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgTypeChar::next_node);
   18147             : #endif
   18148             : 
   18149             : #if USE_CPP_NEW_DELETE_OPERATORS
   18150             :     void *mem = ROSE_MALLOC(Size);
   18151             :     ALLOC_MUTEX(SgTypeChar, unlock);
   18152             :     return mem;
   18153             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   18154             : #if ROSE_PEDANTIC_ALLOC
   18155             :     ROSE_ASSERT(Size == sizeof(SgTypeChar));
   18156             : #else
   18157         810 :     if (Size != sizeof(SgTypeChar)) {
   18158           0 :       void * object = ROSE_MALLOC(Size);
   18159           0 :       ALLOC_MUTEX(SgTypeChar, unlock);
   18160             :       return object;
   18161             :     }
   18162             : #endif
   18163             : 
   18164         810 :     if (SgTypeChar::next_node == nullptr) {
   18165         315 :         SgTypeChar * alloc = (SgTypeChar*) ROSE_MALLOC ( SgTypeChar::pool_size * sizeof(SgTypeChar) );
   18166         315 :         ROSE_ASSERT(alloc != nullptr);
   18167             : 
   18168             : #if ROSE_ALLOC_TRACE == 2
   18169             : //        printf("SgTypeChar::alloc\n  block[%zi] = [ %p , %p [\n", SgTypeChar::pools.size(), alloc, alloc + SgTypeChar::pool_size);
   18170             : #endif
   18171             : 
   18172             : #if ROSE_ALLOC_MEMSET == 1
   18173             : #elif ROSE_ALLOC_MEMSET == 2
   18174             :         memset(alloc, 0x00, SgTypeChar::pool_size * sizeof(SgTypeChar));
   18175             : #elif ROSE_ALLOC_MEMSET == 3
   18176             :         memset(alloc, 0xAA, SgTypeChar::pool_size * sizeof(SgTypeChar));
   18177             : #endif
   18178      630000 :         for (unsigned i=0; i < SgTypeChar::pool_size-1; i++) {
   18179      629685 :           alloc[i].p_freepointer = &(alloc[i+1]);
   18180             :         }
   18181         315 :         alloc[SgTypeChar::pool_size-1].p_freepointer = nullptr;
   18182             : 
   18183         315 :         SgTypeChar::pools.push_back ( (unsigned char *) alloc );
   18184         315 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgTypeChar::pool_size * sizeof(SgTypeChar), V_SgTypeChar ) );
   18185         315 :         SgTypeChar::next_node = alloc;
   18186             :     }
   18187         810 :     ROSE_ASSERT(SgTypeChar::next_node != nullptr);
   18188             : 
   18189         810 :     SgTypeChar * object = SgTypeChar::next_node;
   18190         810 :     SgTypeChar::next_node = (SgTypeChar*)(object->p_freepointer);
   18191             : 
   18192             : #if ROSE_ALLOC_TRACE == 2
   18193             :     printf("SgTypeChar::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeChar::next_node);
   18194             : #endif
   18195             : 
   18196         810 :     SgNode * fp = object->p_freepointer;
   18197             : #if ROSE_ALLOC_MEMSET == 1
   18198             : #elif ROSE_ALLOC_MEMSET == 2
   18199             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgTypeChar) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   18200             : #elif ROSE_ALLOC_MEMSET == 3
   18201             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgTypeChar) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   18202             : #endif
   18203         810 :     object->p_freepointer = fp;
   18204             : 
   18205             : #if ROSE_ALLOC_TRACE == 2
   18206             : //    printf("SgTypeChar::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeChar::next_node);
   18207             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   18208             :     Rose::MemPool::snapshot(oss.str());
   18209             :     alloc_trace_cnt++;
   18210             : #endif
   18211             : 
   18212         810 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   18213             : 
   18214         810 :     ALLOC_MUTEX(SgTypeChar, unlock);
   18215             : 
   18216             :     return object;
   18217             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   18218             : }
   18219             : 
   18220             : 
   18221             : 
   18222             : /*! \brief Delete operator for SgTypeChar.
   18223             : 
   18224             :    This delete operator implements deallocation using memory pools to 
   18225             :    provide most efficent use of the heap within construction of large ASTs.
   18226             : 
   18227             : \internal The new and delete operators use the lower level C malloc/free
   18228             :    function calls for performance and to make sure that mixing of malloc/free
   18229             :    and new/delete by the used can be caught more readily.  This may change
   18230             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   18231             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   18232             :    deallocate memory allocated using ROSE_MALLOC.
   18233             : */
   18234         497 : void SgTypeChar::operator delete(void *Pointer, size_t Size)
   18235             : {
   18236             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   18237             :      * or throwing an exception. */
   18238         497 :     ALLOC_MUTEX(SgTypeChar, lock);
   18239             : 
   18240             : #if USE_CPP_NEW_DELETE_OPERATORS
   18241             :     ROSE_FREE(Pointer);
   18242             : #else
   18243             : #if ROSE_PEDANTIC_ALLOC
   18244             :     ROSE_ASSERT(Size == sizeof(SgTypeChar));
   18245             : #else
   18246         497 :     if (Size != sizeof(SgTypeChar)) {
   18247           0 :       ROSE_FREE(Pointer);
   18248           0 :       ALLOC_MUTEX(SgTypeChar, unlock);
   18249             :       return;
   18250             :     }
   18251             : #endif
   18252             : 
   18253         497 :     SgTypeChar * object = (SgTypeChar*) Pointer;
   18254         497 :     ROSE_ASSERT(object != nullptr);
   18255             : 
   18256             : #if ROSE_ALLOC_TRACE == 2
   18257             : //  printf("SgTypeChar::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeChar::next_node);
   18258             :     printf("SgTypeChar::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeChar::next_node);
   18259             : #endif
   18260             : 
   18261             : #if ROSE_PEDANTIC_ALLOC
   18262             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   18263             : #endif
   18264             : 
   18265             : #if ROSE_ALLOC_MEMSET == 1
   18266             : #elif ROSE_ALLOC_MEMSET == 2
   18267             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgTypeChar) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   18268             : #elif ROSE_ALLOC_MEMSET == 3
   18269             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgTypeChar) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   18270             : #endif
   18271             : 
   18272             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   18273             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   18274             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   18275             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   18276             : #else
   18277         497 :     object->p_freepointer = SgTypeChar::next_node;
   18278         497 :     SgTypeChar::next_node = object;
   18279             : #endif
   18280             : 
   18281             : #if ROSE_ALLOC_TRACE == 2
   18282             : //  printf("SgTypeChar::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeChar::next_node);
   18283             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   18284             :     Rose::MemPool::snapshot(oss.str());
   18285             :     alloc_trace_cnt++;
   18286             : #endif
   18287             : 
   18288             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   18289             : 
   18290         497 :     ALLOC_MUTEX(SgTypeChar, unlock);
   18291             : }
   18292             : 
   18293             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   18294             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   18295             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   18296             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   18297             : // Also, note comment below from Robb (copied from the Common.code file).
   18298             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   18299             : //
   18300             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   18301             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   18302             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   18303             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   18304             : #if 0
   18305             : void SgTypeChar::operator delete(void* pointer) { SgTypeChar::operator delete (pointer, sizeof(SgTypeChar)); };
   18306             : #endif
   18307             : /* #line 18308 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   18308             : 
   18309             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   18310             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   18311             : // obviously imply C++.
   18312             : 
   18313             : // This implements the support within ROSE for memory pools.  Memory pools
   18314             : // support the most condensed usage of memory within the construction of
   18315             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   18316             : // by a new operator written for each class.
   18317             : 
   18318             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   18319             :     // User wants multi-thread support and POSIX threads are available.
   18320             : #   include <pthread.h>
   18321             :     static pthread_mutex_t SgTypeSignedChar_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   18322             : #else
   18323             :      // Cause synchronization to be skipped.
   18324             : #    ifndef ALLOC_MUTEX
   18325             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   18326             : #    endif
   18327             : #    ifdef _REENTRANT
   18328             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   18329             : #       ifdef _MSC_VER
   18330             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   18331             : #       else
   18332             : #           warning "POSIX threads are not available; synchronization being skipped"
   18333             : #       endif
   18334             : #    endif
   18335             : #endif
   18336             : 
   18337             : #ifndef ROSE_ALLOC_TRACE
   18338             : #  define ROSE_ALLOC_TRACE 0
   18339             : #endif
   18340             : 
   18341             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   18342             : #define ROSE_ALLOC_TRACE_CNT
   18343             : #include "memory-pool-snapshot.h"
   18344             : unsigned long alloc_trace_cnt = 0;
   18345             : #endif
   18346             : 
   18347             : #if ROSE_ALLOC_TRACE
   18348             : const unsigned SgTypeSignedChar::pool_size = 5;
   18349             : #else
   18350             : const unsigned SgTypeSignedChar::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   18351             : #endif
   18352             : 
   18353             : #ifndef ROSE_ALLOC_MEMSET
   18354             : #  define ROSE_ALLOC_MEMSET 0
   18355             : #endif
   18356             : 
   18357             : #ifndef ROSE_PEDANTIC_ALLOC
   18358             : #  define ROSE_PEDANTIC_ALLOC 0
   18359             : #endif
   18360             : 
   18361             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   18362             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   18363             : #endif
   18364             : 
   18365             : #if !defined(SGNODE__ALL_POOLS)
   18366             : #define SGNODE__ALL_POOLS
   18367             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   18368             : #endif
   18369             : 
   18370             : SgTypeSignedChar* SgTypeSignedChar::next_node = nullptr;
   18371             : std::vector<unsigned char*> SgTypeSignedChar::pools;
   18372             : 
   18373             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   18374             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   18375             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   18376             : // around this macro definition rather than each use).
   18377             : #ifndef ALLOC_MUTEX
   18378             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   18379             :         do {                                                                     \
   18380             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   18381             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   18382             :                 abort();                                                         \
   18383             :             }                                                                    \
   18384             :         } while (0);
   18385             : #endif
   18386             : 
   18387             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   18388             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   18389             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   18390             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   18391             : 
   18392             : /*! \brief New operator for SgTypeSignedChar.
   18393             : 
   18394             :    This new operator implements memory pools to provide most efficent 
   18395             :    use of the heap within construction of large ASTs.
   18396             : 
   18397             : \internal The new and delete operators use the lower level C malloc/free
   18398             :    function calls for performance and to make sure that mixing of malloc/free
   18399             :    and new/delete by the used can be caught more readily.  This may change
   18400             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   18401             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   18402             :    deallocate memory allocated using ROSE_MALLOC.
   18403             : */
   18404         200 : void *SgTypeSignedChar::operator new ( size_t Size )
   18405             : {
   18406             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   18407             :      * returning or throwing an exception. */
   18408         200 :     ALLOC_MUTEX(SgTypeSignedChar, lock);
   18409             : 
   18410             : #if ROSE_ALLOC_TRACE == 2
   18411             : //    printf("SgTypeSignedChar::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgTypeSignedChar::next_node);
   18412             : #endif
   18413             : 
   18414             : #if USE_CPP_NEW_DELETE_OPERATORS
   18415             :     void *mem = ROSE_MALLOC(Size);
   18416             :     ALLOC_MUTEX(SgTypeSignedChar, unlock);
   18417             :     return mem;
   18418             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   18419             : #if ROSE_PEDANTIC_ALLOC
   18420             :     ROSE_ASSERT(Size == sizeof(SgTypeSignedChar));
   18421             : #else
   18422         200 :     if (Size != sizeof(SgTypeSignedChar)) {
   18423           0 :       void * object = ROSE_MALLOC(Size);
   18424           0 :       ALLOC_MUTEX(SgTypeSignedChar, unlock);
   18425             :       return object;
   18426             :     }
   18427             : #endif
   18428             : 
   18429         200 :     if (SgTypeSignedChar::next_node == nullptr) {
   18430         198 :         SgTypeSignedChar * alloc = (SgTypeSignedChar*) ROSE_MALLOC ( SgTypeSignedChar::pool_size * sizeof(SgTypeSignedChar) );
   18431         198 :         ROSE_ASSERT(alloc != nullptr);
   18432             : 
   18433             : #if ROSE_ALLOC_TRACE == 2
   18434             : //        printf("SgTypeSignedChar::alloc\n  block[%zi] = [ %p , %p [\n", SgTypeSignedChar::pools.size(), alloc, alloc + SgTypeSignedChar::pool_size);
   18435             : #endif
   18436             : 
   18437             : #if ROSE_ALLOC_MEMSET == 1
   18438             : #elif ROSE_ALLOC_MEMSET == 2
   18439             :         memset(alloc, 0x00, SgTypeSignedChar::pool_size * sizeof(SgTypeSignedChar));
   18440             : #elif ROSE_ALLOC_MEMSET == 3
   18441             :         memset(alloc, 0xAA, SgTypeSignedChar::pool_size * sizeof(SgTypeSignedChar));
   18442             : #endif
   18443      396000 :         for (unsigned i=0; i < SgTypeSignedChar::pool_size-1; i++) {
   18444      395802 :           alloc[i].p_freepointer = &(alloc[i+1]);
   18445             :         }
   18446         198 :         alloc[SgTypeSignedChar::pool_size-1].p_freepointer = nullptr;
   18447             : 
   18448         198 :         SgTypeSignedChar::pools.push_back ( (unsigned char *) alloc );
   18449         198 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgTypeSignedChar::pool_size * sizeof(SgTypeSignedChar), V_SgTypeSignedChar ) );
   18450         198 :         SgTypeSignedChar::next_node = alloc;
   18451             :     }
   18452         200 :     ROSE_ASSERT(SgTypeSignedChar::next_node != nullptr);
   18453             : 
   18454         200 :     SgTypeSignedChar * object = SgTypeSignedChar::next_node;
   18455         200 :     SgTypeSignedChar::next_node = (SgTypeSignedChar*)(object->p_freepointer);
   18456             : 
   18457             : #if ROSE_ALLOC_TRACE == 2
   18458             :     printf("SgTypeSignedChar::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeSignedChar::next_node);
   18459             : #endif
   18460             : 
   18461         200 :     SgNode * fp = object->p_freepointer;
   18462             : #if ROSE_ALLOC_MEMSET == 1
   18463             : #elif ROSE_ALLOC_MEMSET == 2
   18464             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgTypeSignedChar) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   18465             : #elif ROSE_ALLOC_MEMSET == 3
   18466             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgTypeSignedChar) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   18467             : #endif
   18468         200 :     object->p_freepointer = fp;
   18469             : 
   18470             : #if ROSE_ALLOC_TRACE == 2
   18471             : //    printf("SgTypeSignedChar::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeSignedChar::next_node);
   18472             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   18473             :     Rose::MemPool::snapshot(oss.str());
   18474             :     alloc_trace_cnt++;
   18475             : #endif
   18476             : 
   18477         200 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   18478             : 
   18479         200 :     ALLOC_MUTEX(SgTypeSignedChar, unlock);
   18480             : 
   18481             :     return object;
   18482             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   18483             : }
   18484             : 
   18485             : 
   18486             : 
   18487             : /*! \brief Delete operator for SgTypeSignedChar.
   18488             : 
   18489             :    This delete operator implements deallocation using memory pools to 
   18490             :    provide most efficent use of the heap within construction of large ASTs.
   18491             : 
   18492             : \internal The new and delete operators use the lower level C malloc/free
   18493             :    function calls for performance and to make sure that mixing of malloc/free
   18494             :    and new/delete by the used can be caught more readily.  This may change
   18495             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   18496             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   18497             :    deallocate memory allocated using ROSE_MALLOC.
   18498             : */
   18499           4 : void SgTypeSignedChar::operator delete(void *Pointer, size_t Size)
   18500             : {
   18501             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   18502             :      * or throwing an exception. */
   18503           4 :     ALLOC_MUTEX(SgTypeSignedChar, lock);
   18504             : 
   18505             : #if USE_CPP_NEW_DELETE_OPERATORS
   18506             :     ROSE_FREE(Pointer);
   18507             : #else
   18508             : #if ROSE_PEDANTIC_ALLOC
   18509             :     ROSE_ASSERT(Size == sizeof(SgTypeSignedChar));
   18510             : #else
   18511           4 :     if (Size != sizeof(SgTypeSignedChar)) {
   18512           0 :       ROSE_FREE(Pointer);
   18513           0 :       ALLOC_MUTEX(SgTypeSignedChar, unlock);
   18514             :       return;
   18515             :     }
   18516             : #endif
   18517             : 
   18518           4 :     SgTypeSignedChar * object = (SgTypeSignedChar*) Pointer;
   18519           4 :     ROSE_ASSERT(object != nullptr);
   18520             : 
   18521             : #if ROSE_ALLOC_TRACE == 2
   18522             : //  printf("SgTypeSignedChar::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeSignedChar::next_node);
   18523             :     printf("SgTypeSignedChar::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeSignedChar::next_node);
   18524             : #endif
   18525             : 
   18526             : #if ROSE_PEDANTIC_ALLOC
   18527             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   18528             : #endif
   18529             : 
   18530             : #if ROSE_ALLOC_MEMSET == 1
   18531             : #elif ROSE_ALLOC_MEMSET == 2
   18532             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgTypeSignedChar) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   18533             : #elif ROSE_ALLOC_MEMSET == 3
   18534             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgTypeSignedChar) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   18535             : #endif
   18536             : 
   18537             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   18538             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   18539             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   18540             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   18541             : #else
   18542           4 :     object->p_freepointer = SgTypeSignedChar::next_node;
   18543           4 :     SgTypeSignedChar::next_node = object;
   18544             : #endif
   18545             : 
   18546             : #if ROSE_ALLOC_TRACE == 2
   18547             : //  printf("SgTypeSignedChar::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeSignedChar::next_node);
   18548             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   18549             :     Rose::MemPool::snapshot(oss.str());
   18550             :     alloc_trace_cnt++;
   18551             : #endif
   18552             : 
   18553             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   18554             : 
   18555           4 :     ALLOC_MUTEX(SgTypeSignedChar, unlock);
   18556             : }
   18557             : 
   18558             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   18559             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   18560             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   18561             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   18562             : // Also, note comment below from Robb (copied from the Common.code file).
   18563             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   18564             : //
   18565             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   18566             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   18567             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   18568             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   18569             : #if 0
   18570             : void SgTypeSignedChar::operator delete(void* pointer) { SgTypeSignedChar::operator delete (pointer, sizeof(SgTypeSignedChar)); };
   18571             : #endif
   18572             : /* #line 18573 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   18573             : 
   18574             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   18575             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   18576             : // obviously imply C++.
   18577             : 
   18578             : // This implements the support within ROSE for memory pools.  Memory pools
   18579             : // support the most condensed usage of memory within the construction of
   18580             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   18581             : // by a new operator written for each class.
   18582             : 
   18583             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   18584             :     // User wants multi-thread support and POSIX threads are available.
   18585             : #   include <pthread.h>
   18586             :     static pthread_mutex_t SgTypeUnsignedChar_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   18587             : #else
   18588             :      // Cause synchronization to be skipped.
   18589             : #    ifndef ALLOC_MUTEX
   18590             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   18591             : #    endif
   18592             : #    ifdef _REENTRANT
   18593             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   18594             : #       ifdef _MSC_VER
   18595             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   18596             : #       else
   18597             : #           warning "POSIX threads are not available; synchronization being skipped"
   18598             : #       endif
   18599             : #    endif
   18600             : #endif
   18601             : 
   18602             : #ifndef ROSE_ALLOC_TRACE
   18603             : #  define ROSE_ALLOC_TRACE 0
   18604             : #endif
   18605             : 
   18606             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   18607             : #define ROSE_ALLOC_TRACE_CNT
   18608             : #include "memory-pool-snapshot.h"
   18609             : unsigned long alloc_trace_cnt = 0;
   18610             : #endif
   18611             : 
   18612             : #if ROSE_ALLOC_TRACE
   18613             : const unsigned SgTypeUnsignedChar::pool_size = 5;
   18614             : #else
   18615             : const unsigned SgTypeUnsignedChar::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   18616             : #endif
   18617             : 
   18618             : #ifndef ROSE_ALLOC_MEMSET
   18619             : #  define ROSE_ALLOC_MEMSET 0
   18620             : #endif
   18621             : 
   18622             : #ifndef ROSE_PEDANTIC_ALLOC
   18623             : #  define ROSE_PEDANTIC_ALLOC 0
   18624             : #endif
   18625             : 
   18626             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   18627             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   18628             : #endif
   18629             : 
   18630             : #if !defined(SGNODE__ALL_POOLS)
   18631             : #define SGNODE__ALL_POOLS
   18632             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   18633             : #endif
   18634             : 
   18635             : SgTypeUnsignedChar* SgTypeUnsignedChar::next_node = nullptr;
   18636             : std::vector<unsigned char*> SgTypeUnsignedChar::pools;
   18637             : 
   18638             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   18639             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   18640             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   18641             : // around this macro definition rather than each use).
   18642             : #ifndef ALLOC_MUTEX
   18643             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   18644             :         do {                                                                     \
   18645             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   18646             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   18647             :                 abort();                                                         \
   18648             :             }                                                                    \
   18649             :         } while (0);
   18650             : #endif
   18651             : 
   18652             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   18653             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   18654             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   18655             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   18656             : 
   18657             : /*! \brief New operator for SgTypeUnsignedChar.
   18658             : 
   18659             :    This new operator implements memory pools to provide most efficent 
   18660             :    use of the heap within construction of large ASTs.
   18661             : 
   18662             : \internal The new and delete operators use the lower level C malloc/free
   18663             :    function calls for performance and to make sure that mixing of malloc/free
   18664             :    and new/delete by the used can be caught more readily.  This may change
   18665             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   18666             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   18667             :    deallocate memory allocated using ROSE_MALLOC.
   18668             : */
   18669         324 : void *SgTypeUnsignedChar::operator new ( size_t Size )
   18670             : {
   18671             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   18672             :      * returning or throwing an exception. */
   18673         324 :     ALLOC_MUTEX(SgTypeUnsignedChar, lock);
   18674             : 
   18675             : #if ROSE_ALLOC_TRACE == 2
   18676             : //    printf("SgTypeUnsignedChar::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgTypeUnsignedChar::next_node);
   18677             : #endif
   18678             : 
   18679             : #if USE_CPP_NEW_DELETE_OPERATORS
   18680             :     void *mem = ROSE_MALLOC(Size);
   18681             :     ALLOC_MUTEX(SgTypeUnsignedChar, unlock);
   18682             :     return mem;
   18683             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   18684             : #if ROSE_PEDANTIC_ALLOC
   18685             :     ROSE_ASSERT(Size == sizeof(SgTypeUnsignedChar));
   18686             : #else
   18687         324 :     if (Size != sizeof(SgTypeUnsignedChar)) {
   18688           0 :       void * object = ROSE_MALLOC(Size);
   18689           0 :       ALLOC_MUTEX(SgTypeUnsignedChar, unlock);
   18690             :       return object;
   18691             :     }
   18692             : #endif
   18693             : 
   18694         324 :     if (SgTypeUnsignedChar::next_node == nullptr) {
   18695         315 :         SgTypeUnsignedChar * alloc = (SgTypeUnsignedChar*) ROSE_MALLOC ( SgTypeUnsignedChar::pool_size * sizeof(SgTypeUnsignedChar) );
   18696         315 :         ROSE_ASSERT(alloc != nullptr);
   18697             : 
   18698             : #if ROSE_ALLOC_TRACE == 2
   18699             : //        printf("SgTypeUnsignedChar::alloc\n  block[%zi] = [ %p , %p [\n", SgTypeUnsignedChar::pools.size(), alloc, alloc + SgTypeUnsignedChar::pool_size);
   18700             : #endif
   18701             : 
   18702             : #if ROSE_ALLOC_MEMSET == 1
   18703             : #elif ROSE_ALLOC_MEMSET == 2
   18704             :         memset(alloc, 0x00, SgTypeUnsignedChar::pool_size * sizeof(SgTypeUnsignedChar));
   18705             : #elif ROSE_ALLOC_MEMSET == 3
   18706             :         memset(alloc, 0xAA, SgTypeUnsignedChar::pool_size * sizeof(SgTypeUnsignedChar));
   18707             : #endif
   18708      630000 :         for (unsigned i=0; i < SgTypeUnsignedChar::pool_size-1; i++) {
   18709      629685 :           alloc[i].p_freepointer = &(alloc[i+1]);
   18710             :         }
   18711         315 :         alloc[SgTypeUnsignedChar::pool_size-1].p_freepointer = nullptr;
   18712             : 
   18713         315 :         SgTypeUnsignedChar::pools.push_back ( (unsigned char *) alloc );
   18714         315 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgTypeUnsignedChar::pool_size * sizeof(SgTypeUnsignedChar), V_SgTypeUnsignedChar ) );
   18715         315 :         SgTypeUnsignedChar::next_node = alloc;
   18716             :     }
   18717         324 :     ROSE_ASSERT(SgTypeUnsignedChar::next_node != nullptr);
   18718             : 
   18719         324 :     SgTypeUnsignedChar * object = SgTypeUnsignedChar::next_node;
   18720         324 :     SgTypeUnsignedChar::next_node = (SgTypeUnsignedChar*)(object->p_freepointer);
   18721             : 
   18722             : #if ROSE_ALLOC_TRACE == 2
   18723             :     printf("SgTypeUnsignedChar::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeUnsignedChar::next_node);
   18724             : #endif
   18725             : 
   18726         324 :     SgNode * fp = object->p_freepointer;
   18727             : #if ROSE_ALLOC_MEMSET == 1
   18728             : #elif ROSE_ALLOC_MEMSET == 2
   18729             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgTypeUnsignedChar) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   18730             : #elif ROSE_ALLOC_MEMSET == 3
   18731             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgTypeUnsignedChar) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   18732             : #endif
   18733         324 :     object->p_freepointer = fp;
   18734             : 
   18735             : #if ROSE_ALLOC_TRACE == 2
   18736             : //    printf("SgTypeUnsignedChar::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeUnsignedChar::next_node);
   18737             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   18738             :     Rose::MemPool::snapshot(oss.str());
   18739             :     alloc_trace_cnt++;
   18740             : #endif
   18741             : 
   18742         324 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   18743             : 
   18744         324 :     ALLOC_MUTEX(SgTypeUnsignedChar, unlock);
   18745             : 
   18746             :     return object;
   18747             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   18748             : }
   18749             : 
   18750             : 
   18751             : 
   18752             : /*! \brief Delete operator for SgTypeUnsignedChar.
   18753             : 
   18754             :    This delete operator implements deallocation using memory pools to 
   18755             :    provide most efficent use of the heap within construction of large ASTs.
   18756             : 
   18757             : \internal The new and delete operators use the lower level C malloc/free
   18758             :    function calls for performance and to make sure that mixing of malloc/free
   18759             :    and new/delete by the used can be caught more readily.  This may change
   18760             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   18761             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   18762             :    deallocate memory allocated using ROSE_MALLOC.
   18763             : */
   18764          11 : void SgTypeUnsignedChar::operator delete(void *Pointer, size_t Size)
   18765             : {
   18766             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   18767             :      * or throwing an exception. */
   18768          11 :     ALLOC_MUTEX(SgTypeUnsignedChar, lock);
   18769             : 
   18770             : #if USE_CPP_NEW_DELETE_OPERATORS
   18771             :     ROSE_FREE(Pointer);
   18772             : #else
   18773             : #if ROSE_PEDANTIC_ALLOC
   18774             :     ROSE_ASSERT(Size == sizeof(SgTypeUnsignedChar));
   18775             : #else
   18776          11 :     if (Size != sizeof(SgTypeUnsignedChar)) {
   18777           0 :       ROSE_FREE(Pointer);
   18778           0 :       ALLOC_MUTEX(SgTypeUnsignedChar, unlock);
   18779             :       return;
   18780             :     }
   18781             : #endif
   18782             : 
   18783          11 :     SgTypeUnsignedChar * object = (SgTypeUnsignedChar*) Pointer;
   18784          11 :     ROSE_ASSERT(object != nullptr);
   18785             : 
   18786             : #if ROSE_ALLOC_TRACE == 2
   18787             : //  printf("SgTypeUnsignedChar::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeUnsignedChar::next_node);
   18788             :     printf("SgTypeUnsignedChar::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeUnsignedChar::next_node);
   18789             : #endif
   18790             : 
   18791             : #if ROSE_PEDANTIC_ALLOC
   18792             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   18793             : #endif
   18794             : 
   18795             : #if ROSE_ALLOC_MEMSET == 1
   18796             : #elif ROSE_ALLOC_MEMSET == 2
   18797             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgTypeUnsignedChar) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   18798             : #elif ROSE_ALLOC_MEMSET == 3
   18799             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgTypeUnsignedChar) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   18800             : #endif
   18801             : 
   18802             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   18803             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   18804             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   18805             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   18806             : #else
   18807          11 :     object->p_freepointer = SgTypeUnsignedChar::next_node;
   18808          11 :     SgTypeUnsignedChar::next_node = object;
   18809             : #endif
   18810             : 
   18811             : #if ROSE_ALLOC_TRACE == 2
   18812             : //  printf("SgTypeUnsignedChar::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeUnsignedChar::next_node);
   18813             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   18814             :     Rose::MemPool::snapshot(oss.str());
   18815             :     alloc_trace_cnt++;
   18816             : #endif
   18817             : 
   18818             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   18819             : 
   18820          11 :     ALLOC_MUTEX(SgTypeUnsignedChar, unlock);
   18821             : }
   18822             : 
   18823             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   18824             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   18825             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   18826             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   18827             : // Also, note comment below from Robb (copied from the Common.code file).
   18828             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   18829             : //
   18830             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   18831             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   18832             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   18833             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   18834             : #if 0
   18835             : void SgTypeUnsignedChar::operator delete(void* pointer) { SgTypeUnsignedChar::operator delete (pointer, sizeof(SgTypeUnsignedChar)); };
   18836             : #endif
   18837             : /* #line 18838 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   18838             : 
   18839             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   18840             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   18841             : // obviously imply C++.
   18842             : 
   18843             : // This implements the support within ROSE for memory pools.  Memory pools
   18844             : // support the most condensed usage of memory within the construction of
   18845             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   18846             : // by a new operator written for each class.
   18847             : 
   18848             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   18849             :     // User wants multi-thread support and POSIX threads are available.
   18850             : #   include <pthread.h>
   18851             :     static pthread_mutex_t SgTypeShort_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   18852             : #else
   18853             :      // Cause synchronization to be skipped.
   18854             : #    ifndef ALLOC_MUTEX
   18855             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   18856             : #    endif
   18857             : #    ifdef _REENTRANT
   18858             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   18859             : #       ifdef _MSC_VER
   18860             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   18861             : #       else
   18862             : #           warning "POSIX threads are not available; synchronization being skipped"
   18863             : #       endif
   18864             : #    endif
   18865             : #endif
   18866             : 
   18867             : #ifndef ROSE_ALLOC_TRACE
   18868             : #  define ROSE_ALLOC_TRACE 0
   18869             : #endif
   18870             : 
   18871             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   18872             : #define ROSE_ALLOC_TRACE_CNT
   18873             : #include "memory-pool-snapshot.h"
   18874             : unsigned long alloc_trace_cnt = 0;
   18875             : #endif
   18876             : 
   18877             : #if ROSE_ALLOC_TRACE
   18878             : const unsigned SgTypeShort::pool_size = 5;
   18879             : #else
   18880             : const unsigned SgTypeShort::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   18881             : #endif
   18882             : 
   18883             : #ifndef ROSE_ALLOC_MEMSET
   18884             : #  define ROSE_ALLOC_MEMSET 0
   18885             : #endif
   18886             : 
   18887             : #ifndef ROSE_PEDANTIC_ALLOC
   18888             : #  define ROSE_PEDANTIC_ALLOC 0
   18889             : #endif
   18890             : 
   18891             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   18892             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   18893             : #endif
   18894             : 
   18895             : #if !defined(SGNODE__ALL_POOLS)
   18896             : #define SGNODE__ALL_POOLS
   18897             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   18898             : #endif
   18899             : 
   18900             : SgTypeShort* SgTypeShort::next_node = nullptr;
   18901             : std::vector<unsigned char*> SgTypeShort::pools;
   18902             : 
   18903             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   18904             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   18905             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   18906             : // around this macro definition rather than each use).
   18907             : #ifndef ALLOC_MUTEX
   18908             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   18909             :         do {                                                                     \
   18910             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   18911             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   18912             :                 abort();                                                         \
   18913             :             }                                                                    \
   18914             :         } while (0);
   18915             : #endif
   18916             : 
   18917             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   18918             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   18919             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   18920             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   18921             : 
   18922             : /*! \brief New operator for SgTypeShort.
   18923             : 
   18924             :    This new operator implements memory pools to provide most efficent 
   18925             :    use of the heap within construction of large ASTs.
   18926             : 
   18927             : \internal The new and delete operators use the lower level C malloc/free
   18928             :    function calls for performance and to make sure that mixing of malloc/free
   18929             :    and new/delete by the used can be caught more readily.  This may change
   18930             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   18931             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   18932             :    deallocate memory allocated using ROSE_MALLOC.
   18933             : */
   18934         324 : void *SgTypeShort::operator new ( size_t Size )
   18935             : {
   18936             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   18937             :      * returning or throwing an exception. */
   18938         324 :     ALLOC_MUTEX(SgTypeShort, lock);
   18939             : 
   18940             : #if ROSE_ALLOC_TRACE == 2
   18941             : //    printf("SgTypeShort::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgTypeShort::next_node);
   18942             : #endif
   18943             : 
   18944             : #if USE_CPP_NEW_DELETE_OPERATORS
   18945             :     void *mem = ROSE_MALLOC(Size);
   18946             :     ALLOC_MUTEX(SgTypeShort, unlock);
   18947             :     return mem;
   18948             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   18949             : #if ROSE_PEDANTIC_ALLOC
   18950             :     ROSE_ASSERT(Size == sizeof(SgTypeShort));
   18951             : #else
   18952         324 :     if (Size != sizeof(SgTypeShort)) {
   18953           0 :       void * object = ROSE_MALLOC(Size);
   18954           0 :       ALLOC_MUTEX(SgTypeShort, unlock);
   18955             :       return object;
   18956             :     }
   18957             : #endif
   18958             : 
   18959         324 :     if (SgTypeShort::next_node == nullptr) {
   18960         315 :         SgTypeShort * alloc = (SgTypeShort*) ROSE_MALLOC ( SgTypeShort::pool_size * sizeof(SgTypeShort) );
   18961         315 :         ROSE_ASSERT(alloc != nullptr);
   18962             : 
   18963             : #if ROSE_ALLOC_TRACE == 2
   18964             : //        printf("SgTypeShort::alloc\n  block[%zi] = [ %p , %p [\n", SgTypeShort::pools.size(), alloc, alloc + SgTypeShort::pool_size);
   18965             : #endif
   18966             : 
   18967             : #if ROSE_ALLOC_MEMSET == 1
   18968             : #elif ROSE_ALLOC_MEMSET == 2
   18969             :         memset(alloc, 0x00, SgTypeShort::pool_size * sizeof(SgTypeShort));
   18970             : #elif ROSE_ALLOC_MEMSET == 3
   18971             :         memset(alloc, 0xAA, SgTypeShort::pool_size * sizeof(SgTypeShort));
   18972             : #endif
   18973      630000 :         for (unsigned i=0; i < SgTypeShort::pool_size-1; i++) {
   18974      629685 :           alloc[i].p_freepointer = &(alloc[i+1]);
   18975             :         }
   18976         315 :         alloc[SgTypeShort::pool_size-1].p_freepointer = nullptr;
   18977             : 
   18978         315 :         SgTypeShort::pools.push_back ( (unsigned char *) alloc );
   18979         315 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgTypeShort::pool_size * sizeof(SgTypeShort), V_SgTypeShort ) );
   18980         315 :         SgTypeShort::next_node = alloc;
   18981             :     }
   18982         324 :     ROSE_ASSERT(SgTypeShort::next_node != nullptr);
   18983             : 
   18984         324 :     SgTypeShort * object = SgTypeShort::next_node;
   18985         324 :     SgTypeShort::next_node = (SgTypeShort*)(object->p_freepointer);
   18986             : 
   18987             : #if ROSE_ALLOC_TRACE == 2
   18988             :     printf("SgTypeShort::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeShort::next_node);
   18989             : #endif
   18990             : 
   18991         324 :     SgNode * fp = object->p_freepointer;
   18992             : #if ROSE_ALLOC_MEMSET == 1
   18993             : #elif ROSE_ALLOC_MEMSET == 2
   18994             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgTypeShort) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   18995             : #elif ROSE_ALLOC_MEMSET == 3
   18996             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgTypeShort) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   18997             : #endif
   18998         324 :     object->p_freepointer = fp;
   18999             : 
   19000             : #if ROSE_ALLOC_TRACE == 2
   19001             : //    printf("SgTypeShort::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeShort::next_node);
   19002             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   19003             :     Rose::MemPool::snapshot(oss.str());
   19004             :     alloc_trace_cnt++;
   19005             : #endif
   19006             : 
   19007         324 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   19008             : 
   19009         324 :     ALLOC_MUTEX(SgTypeShort, unlock);
   19010             : 
   19011             :     return object;
   19012             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   19013             : }
   19014             : 
   19015             : 
   19016             : 
   19017             : /*! \brief Delete operator for SgTypeShort.
   19018             : 
   19019             :    This delete operator implements deallocation using memory pools to 
   19020             :    provide most efficent use of the heap within construction of large ASTs.
   19021             : 
   19022             : \internal The new and delete operators use the lower level C malloc/free
   19023             :    function calls for performance and to make sure that mixing of malloc/free
   19024             :    and new/delete by the used can be caught more readily.  This may change
   19025             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   19026             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   19027             :    deallocate memory allocated using ROSE_MALLOC.
   19028             : */
   19029          11 : void SgTypeShort::operator delete(void *Pointer, size_t Size)
   19030             : {
   19031             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   19032             :      * or throwing an exception. */
   19033          11 :     ALLOC_MUTEX(SgTypeShort, lock);
   19034             : 
   19035             : #if USE_CPP_NEW_DELETE_OPERATORS
   19036             :     ROSE_FREE(Pointer);
   19037             : #else
   19038             : #if ROSE_PEDANTIC_ALLOC
   19039             :     ROSE_ASSERT(Size == sizeof(SgTypeShort));
   19040             : #else
   19041          11 :     if (Size != sizeof(SgTypeShort)) {
   19042           0 :       ROSE_FREE(Pointer);
   19043           0 :       ALLOC_MUTEX(SgTypeShort, unlock);
   19044             :       return;
   19045             :     }
   19046             : #endif
   19047             : 
   19048          11 :     SgTypeShort * object = (SgTypeShort*) Pointer;
   19049          11 :     ROSE_ASSERT(object != nullptr);
   19050             : 
   19051             : #if ROSE_ALLOC_TRACE == 2
   19052             : //  printf("SgTypeShort::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeShort::next_node);
   19053             :     printf("SgTypeShort::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeShort::next_node);
   19054             : #endif
   19055             : 
   19056             : #if ROSE_PEDANTIC_ALLOC
   19057             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   19058             : #endif
   19059             : 
   19060             : #if ROSE_ALLOC_MEMSET == 1
   19061             : #elif ROSE_ALLOC_MEMSET == 2
   19062             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgTypeShort) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   19063             : #elif ROSE_ALLOC_MEMSET == 3
   19064             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgTypeShort) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   19065             : #endif
   19066             : 
   19067             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   19068             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   19069             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   19070             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   19071             : #else
   19072          11 :     object->p_freepointer = SgTypeShort::next_node;
   19073          11 :     SgTypeShort::next_node = object;
   19074             : #endif
   19075             : 
   19076             : #if ROSE_ALLOC_TRACE == 2
   19077             : //  printf("SgTypeShort::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeShort::next_node);
   19078             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   19079             :     Rose::MemPool::snapshot(oss.str());
   19080             :     alloc_trace_cnt++;
   19081             : #endif
   19082             : 
   19083             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   19084             : 
   19085          11 :     ALLOC_MUTEX(SgTypeShort, unlock);
   19086             : }
   19087             : 
   19088             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   19089             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   19090             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   19091             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   19092             : // Also, note comment below from Robb (copied from the Common.code file).
   19093             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   19094             : //
   19095             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   19096             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   19097             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   19098             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   19099             : #if 0
   19100             : void SgTypeShort::operator delete(void* pointer) { SgTypeShort::operator delete (pointer, sizeof(SgTypeShort)); };
   19101             : #endif
   19102             : /* #line 19103 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   19103             : 
   19104             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   19105             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   19106             : // obviously imply C++.
   19107             : 
   19108             : // This implements the support within ROSE for memory pools.  Memory pools
   19109             : // support the most condensed usage of memory within the construction of
   19110             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   19111             : // by a new operator written for each class.
   19112             : 
   19113             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   19114             :     // User wants multi-thread support and POSIX threads are available.
   19115             : #   include <pthread.h>
   19116             :     static pthread_mutex_t SgTypeSignedShort_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   19117             : #else
   19118             :      // Cause synchronization to be skipped.
   19119             : #    ifndef ALLOC_MUTEX
   19120             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   19121             : #    endif
   19122             : #    ifdef _REENTRANT
   19123             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   19124             : #       ifdef _MSC_VER
   19125             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   19126             : #       else
   19127             : #           warning "POSIX threads are not available; synchronization being skipped"
   19128             : #       endif
   19129             : #    endif
   19130             : #endif
   19131             : 
   19132             : #ifndef ROSE_ALLOC_TRACE
   19133             : #  define ROSE_ALLOC_TRACE 0
   19134             : #endif
   19135             : 
   19136             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   19137             : #define ROSE_ALLOC_TRACE_CNT
   19138             : #include "memory-pool-snapshot.h"
   19139             : unsigned long alloc_trace_cnt = 0;
   19140             : #endif
   19141             : 
   19142             : #if ROSE_ALLOC_TRACE
   19143             : const unsigned SgTypeSignedShort::pool_size = 5;
   19144             : #else
   19145             : const unsigned SgTypeSignedShort::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   19146             : #endif
   19147             : 
   19148             : #ifndef ROSE_ALLOC_MEMSET
   19149             : #  define ROSE_ALLOC_MEMSET 0
   19150             : #endif
   19151             : 
   19152             : #ifndef ROSE_PEDANTIC_ALLOC
   19153             : #  define ROSE_PEDANTIC_ALLOC 0
   19154             : #endif
   19155             : 
   19156             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   19157             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   19158             : #endif
   19159             : 
   19160             : #if !defined(SGNODE__ALL_POOLS)
   19161             : #define SGNODE__ALL_POOLS
   19162             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   19163             : #endif
   19164             : 
   19165             : SgTypeSignedShort* SgTypeSignedShort::next_node = nullptr;
   19166             : std::vector<unsigned char*> SgTypeSignedShort::pools;
   19167             : 
   19168             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   19169             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   19170             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   19171             : // around this macro definition rather than each use).
   19172             : #ifndef ALLOC_MUTEX
   19173             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   19174             :         do {                                                                     \
   19175             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   19176             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   19177             :                 abort();                                                         \
   19178             :             }                                                                    \
   19179             :         } while (0);
   19180             : #endif
   19181             : 
   19182             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   19183             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   19184             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   19185             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   19186             : 
   19187             : /*! \brief New operator for SgTypeSignedShort.
   19188             : 
   19189             :    This new operator implements memory pools to provide most efficent 
   19190             :    use of the heap within construction of large ASTs.
   19191             : 
   19192             : \internal The new and delete operators use the lower level C malloc/free
   19193             :    function calls for performance and to make sure that mixing of malloc/free
   19194             :    and new/delete by the used can be caught more readily.  This may change
   19195             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   19196             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   19197             :    deallocate memory allocated using ROSE_MALLOC.
   19198             : */
   19199         200 : void *SgTypeSignedShort::operator new ( size_t Size )
   19200             : {
   19201             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   19202             :      * returning or throwing an exception. */
   19203         200 :     ALLOC_MUTEX(SgTypeSignedShort, lock);
   19204             : 
   19205             : #if ROSE_ALLOC_TRACE == 2
   19206             : //    printf("SgTypeSignedShort::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgTypeSignedShort::next_node);
   19207             : #endif
   19208             : 
   19209             : #if USE_CPP_NEW_DELETE_OPERATORS
   19210             :     void *mem = ROSE_MALLOC(Size);
   19211             :     ALLOC_MUTEX(SgTypeSignedShort, unlock);
   19212             :     return mem;
   19213             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   19214             : #if ROSE_PEDANTIC_ALLOC
   19215             :     ROSE_ASSERT(Size == sizeof(SgTypeSignedShort));
   19216             : #else
   19217         200 :     if (Size != sizeof(SgTypeSignedShort)) {
   19218           0 :       void * object = ROSE_MALLOC(Size);
   19219           0 :       ALLOC_MUTEX(SgTypeSignedShort, unlock);
   19220             :       return object;
   19221             :     }
   19222             : #endif
   19223             : 
   19224         200 :     if (SgTypeSignedShort::next_node == nullptr) {
   19225         198 :         SgTypeSignedShort * alloc = (SgTypeSignedShort*) ROSE_MALLOC ( SgTypeSignedShort::pool_size * sizeof(SgTypeSignedShort) );
   19226         198 :         ROSE_ASSERT(alloc != nullptr);
   19227             : 
   19228             : #if ROSE_ALLOC_TRACE == 2
   19229             : //        printf("SgTypeSignedShort::alloc\n  block[%zi] = [ %p , %p [\n", SgTypeSignedShort::pools.size(), alloc, alloc + SgTypeSignedShort::pool_size);
   19230             : #endif
   19231             : 
   19232             : #if ROSE_ALLOC_MEMSET == 1
   19233             : #elif ROSE_ALLOC_MEMSET == 2
   19234             :         memset(alloc, 0x00, SgTypeSignedShort::pool_size * sizeof(SgTypeSignedShort));
   19235             : #elif ROSE_ALLOC_MEMSET == 3
   19236             :         memset(alloc, 0xAA, SgTypeSignedShort::pool_size * sizeof(SgTypeSignedShort));
   19237             : #endif
   19238      396000 :         for (unsigned i=0; i < SgTypeSignedShort::pool_size-1; i++) {
   19239      395802 :           alloc[i].p_freepointer = &(alloc[i+1]);
   19240             :         }
   19241         198 :         alloc[SgTypeSignedShort::pool_size-1].p_freepointer = nullptr;
   19242             : 
   19243         198 :         SgTypeSignedShort::pools.push_back ( (unsigned char *) alloc );
   19244         198 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgTypeSignedShort::pool_size * sizeof(SgTypeSignedShort), V_SgTypeSignedShort ) );
   19245         198 :         SgTypeSignedShort::next_node = alloc;
   19246             :     }
   19247         200 :     ROSE_ASSERT(SgTypeSignedShort::next_node != nullptr);
   19248             : 
   19249         200 :     SgTypeSignedShort * object = SgTypeSignedShort::next_node;
   19250         200 :     SgTypeSignedShort::next_node = (SgTypeSignedShort*)(object->p_freepointer);
   19251             : 
   19252             : #if ROSE_ALLOC_TRACE == 2
   19253             :     printf("SgTypeSignedShort::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeSignedShort::next_node);
   19254             : #endif
   19255             : 
   19256         200 :     SgNode * fp = object->p_freepointer;
   19257             : #if ROSE_ALLOC_MEMSET == 1
   19258             : #elif ROSE_ALLOC_MEMSET == 2
   19259             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgTypeSignedShort) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   19260             : #elif ROSE_ALLOC_MEMSET == 3
   19261             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgTypeSignedShort) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   19262             : #endif
   19263         200 :     object->p_freepointer = fp;
   19264             : 
   19265             : #if ROSE_ALLOC_TRACE == 2
   19266             : //    printf("SgTypeSignedShort::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeSignedShort::next_node);
   19267             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   19268             :     Rose::MemPool::snapshot(oss.str());
   19269             :     alloc_trace_cnt++;
   19270             : #endif
   19271             : 
   19272         200 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   19273             : 
   19274         200 :     ALLOC_MUTEX(SgTypeSignedShort, unlock);
   19275             : 
   19276             :     return object;
   19277             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   19278             : }
   19279             : 
   19280             : 
   19281             : 
   19282             : /*! \brief Delete operator for SgTypeSignedShort.
   19283             : 
   19284             :    This delete operator implements deallocation using memory pools to 
   19285             :    provide most efficent use of the heap within construction of large ASTs.
   19286             : 
   19287             : \internal The new and delete operators use the lower level C malloc/free
   19288             :    function calls for performance and to make sure that mixing of malloc/free
   19289             :    and new/delete by the used can be caught more readily.  This may change
   19290             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   19291             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   19292             :    deallocate memory allocated using ROSE_MALLOC.
   19293             : */
   19294           4 : void SgTypeSignedShort::operator delete(void *Pointer, size_t Size)
   19295             : {
   19296             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   19297             :      * or throwing an exception. */
   19298           4 :     ALLOC_MUTEX(SgTypeSignedShort, lock);
   19299             : 
   19300             : #if USE_CPP_NEW_DELETE_OPERATORS
   19301             :     ROSE_FREE(Pointer);
   19302             : #else
   19303             : #if ROSE_PEDANTIC_ALLOC
   19304             :     ROSE_ASSERT(Size == sizeof(SgTypeSignedShort));
   19305             : #else
   19306           4 :     if (Size != sizeof(SgTypeSignedShort)) {
   19307           0 :       ROSE_FREE(Pointer);
   19308           0 :       ALLOC_MUTEX(SgTypeSignedShort, unlock);
   19309             :       return;
   19310             :     }
   19311             : #endif
   19312             : 
   19313           4 :     SgTypeSignedShort * object = (SgTypeSignedShort*) Pointer;
   19314           4 :     ROSE_ASSERT(object != nullptr);
   19315             : 
   19316             : #if ROSE_ALLOC_TRACE == 2
   19317             : //  printf("SgTypeSignedShort::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeSignedShort::next_node);
   19318             :     printf("SgTypeSignedShort::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeSignedShort::next_node);
   19319             : #endif
   19320             : 
   19321             : #if ROSE_PEDANTIC_ALLOC
   19322             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   19323             : #endif
   19324             : 
   19325             : #if ROSE_ALLOC_MEMSET == 1
   19326             : #elif ROSE_ALLOC_MEMSET == 2
   19327             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgTypeSignedShort) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   19328             : #elif ROSE_ALLOC_MEMSET == 3
   19329             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgTypeSignedShort) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   19330             : #endif
   19331             : 
   19332             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   19333             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   19334             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   19335             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   19336             : #else
   19337           4 :     object->p_freepointer = SgTypeSignedShort::next_node;
   19338           4 :     SgTypeSignedShort::next_node = object;
   19339             : #endif
   19340             : 
   19341             : #if ROSE_ALLOC_TRACE == 2
   19342             : //  printf("SgTypeSignedShort::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeSignedShort::next_node);
   19343             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   19344             :     Rose::MemPool::snapshot(oss.str());
   19345             :     alloc_trace_cnt++;
   19346             : #endif
   19347             : 
   19348             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   19349             : 
   19350           4 :     ALLOC_MUTEX(SgTypeSignedShort, unlock);
   19351             : }
   19352             : 
   19353             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   19354             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   19355             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   19356             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   19357             : // Also, note comment below from Robb (copied from the Common.code file).
   19358             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   19359             : //
   19360             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   19361             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   19362             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   19363             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   19364             : #if 0
   19365             : void SgTypeSignedShort::operator delete(void* pointer) { SgTypeSignedShort::operator delete (pointer, sizeof(SgTypeSignedShort)); };
   19366             : #endif
   19367             : /* #line 19368 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   19368             : 
   19369             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   19370             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   19371             : // obviously imply C++.
   19372             : 
   19373             : // This implements the support within ROSE for memory pools.  Memory pools
   19374             : // support the most condensed usage of memory within the construction of
   19375             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   19376             : // by a new operator written for each class.
   19377             : 
   19378             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   19379             :     // User wants multi-thread support and POSIX threads are available.
   19380             : #   include <pthread.h>
   19381             :     static pthread_mutex_t SgTypeUnsignedShort_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   19382             : #else
   19383             :      // Cause synchronization to be skipped.
   19384             : #    ifndef ALLOC_MUTEX
   19385             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   19386             : #    endif
   19387             : #    ifdef _REENTRANT
   19388             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   19389             : #       ifdef _MSC_VER
   19390             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   19391             : #       else
   19392             : #           warning "POSIX threads are not available; synchronization being skipped"
   19393             : #       endif
   19394             : #    endif
   19395             : #endif
   19396             : 
   19397             : #ifndef ROSE_ALLOC_TRACE
   19398             : #  define ROSE_ALLOC_TRACE 0
   19399             : #endif
   19400             : 
   19401             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   19402             : #define ROSE_ALLOC_TRACE_CNT
   19403             : #include "memory-pool-snapshot.h"
   19404             : unsigned long alloc_trace_cnt = 0;
   19405             : #endif
   19406             : 
   19407             : #if ROSE_ALLOC_TRACE
   19408             : const unsigned SgTypeUnsignedShort::pool_size = 5;
   19409             : #else
   19410             : const unsigned SgTypeUnsignedShort::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   19411             : #endif
   19412             : 
   19413             : #ifndef ROSE_ALLOC_MEMSET
   19414             : #  define ROSE_ALLOC_MEMSET 0
   19415             : #endif
   19416             : 
   19417             : #ifndef ROSE_PEDANTIC_ALLOC
   19418             : #  define ROSE_PEDANTIC_ALLOC 0
   19419             : #endif
   19420             : 
   19421             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   19422             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   19423             : #endif
   19424             : 
   19425             : #if !defined(SGNODE__ALL_POOLS)
   19426             : #define SGNODE__ALL_POOLS
   19427             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   19428             : #endif
   19429             : 
   19430             : SgTypeUnsignedShort* SgTypeUnsignedShort::next_node = nullptr;
   19431             : std::vector<unsigned char*> SgTypeUnsignedShort::pools;
   19432             : 
   19433             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   19434             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   19435             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   19436             : // around this macro definition rather than each use).
   19437             : #ifndef ALLOC_MUTEX
   19438             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   19439             :         do {                                                                     \
   19440             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   19441             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   19442             :                 abort();                                                         \
   19443             :             }                                                                    \
   19444             :         } while (0);
   19445             : #endif
   19446             : 
   19447             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   19448             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   19449             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   19450             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   19451             : 
   19452             : /*! \brief New operator for SgTypeUnsignedShort.
   19453             : 
   19454             :    This new operator implements memory pools to provide most efficent 
   19455             :    use of the heap within construction of large ASTs.
   19456             : 
   19457             : \internal The new and delete operators use the lower level C malloc/free
   19458             :    function calls for performance and to make sure that mixing of malloc/free
   19459             :    and new/delete by the used can be caught more readily.  This may change
   19460             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   19461             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   19462             :    deallocate memory allocated using ROSE_MALLOC.
   19463             : */
   19464         324 : void *SgTypeUnsignedShort::operator new ( size_t Size )
   19465             : {
   19466             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   19467             :      * returning or throwing an exception. */
   19468         324 :     ALLOC_MUTEX(SgTypeUnsignedShort, lock);
   19469             : 
   19470             : #if ROSE_ALLOC_TRACE == 2
   19471             : //    printf("SgTypeUnsignedShort::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgTypeUnsignedShort::next_node);
   19472             : #endif
   19473             : 
   19474             : #if USE_CPP_NEW_DELETE_OPERATORS
   19475             :     void *mem = ROSE_MALLOC(Size);
   19476             :     ALLOC_MUTEX(SgTypeUnsignedShort, unlock);
   19477             :     return mem;
   19478             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   19479             : #if ROSE_PEDANTIC_ALLOC
   19480             :     ROSE_ASSERT(Size == sizeof(SgTypeUnsignedShort));
   19481             : #else
   19482         324 :     if (Size != sizeof(SgTypeUnsignedShort)) {
   19483           0 :       void * object = ROSE_MALLOC(Size);
   19484           0 :       ALLOC_MUTEX(SgTypeUnsignedShort, unlock);
   19485             :       return object;
   19486             :     }
   19487             : #endif
   19488             : 
   19489         324 :     if (SgTypeUnsignedShort::next_node == nullptr) {
   19490         315 :         SgTypeUnsignedShort * alloc = (SgTypeUnsignedShort*) ROSE_MALLOC ( SgTypeUnsignedShort::pool_size * sizeof(SgTypeUnsignedShort) );
   19491         315 :         ROSE_ASSERT(alloc != nullptr);
   19492             : 
   19493             : #if ROSE_ALLOC_TRACE == 2
   19494             : //        printf("SgTypeUnsignedShort::alloc\n  block[%zi] = [ %p , %p [\n", SgTypeUnsignedShort::pools.size(), alloc, alloc + SgTypeUnsignedShort::pool_size);
   19495             : #endif
   19496             : 
   19497             : #if ROSE_ALLOC_MEMSET == 1
   19498             : #elif ROSE_ALLOC_MEMSET == 2
   19499             :         memset(alloc, 0x00, SgTypeUnsignedShort::pool_size * sizeof(SgTypeUnsignedShort));
   19500             : #elif ROSE_ALLOC_MEMSET == 3
   19501             :         memset(alloc, 0xAA, SgTypeUnsignedShort::pool_size * sizeof(SgTypeUnsignedShort));
   19502             : #endif
   19503      630000 :         for (unsigned i=0; i < SgTypeUnsignedShort::pool_size-1; i++) {
   19504      629685 :           alloc[i].p_freepointer = &(alloc[i+1]);
   19505             :         }
   19506         315 :         alloc[SgTypeUnsignedShort::pool_size-1].p_freepointer = nullptr;
   19507             : 
   19508         315 :         SgTypeUnsignedShort::pools.push_back ( (unsigned char *) alloc );
   19509         315 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgTypeUnsignedShort::pool_size * sizeof(SgTypeUnsignedShort), V_SgTypeUnsignedShort ) );
   19510         315 :         SgTypeUnsignedShort::next_node = alloc;
   19511             :     }
   19512         324 :     ROSE_ASSERT(SgTypeUnsignedShort::next_node != nullptr);
   19513             : 
   19514         324 :     SgTypeUnsignedShort * object = SgTypeUnsignedShort::next_node;
   19515         324 :     SgTypeUnsignedShort::next_node = (SgTypeUnsignedShort*)(object->p_freepointer);
   19516             : 
   19517             : #if ROSE_ALLOC_TRACE == 2
   19518             :     printf("SgTypeUnsignedShort::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeUnsignedShort::next_node);
   19519             : #endif
   19520             : 
   19521         324 :     SgNode * fp = object->p_freepointer;
   19522             : #if ROSE_ALLOC_MEMSET == 1
   19523             : #elif ROSE_ALLOC_MEMSET == 2
   19524             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgTypeUnsignedShort) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   19525             : #elif ROSE_ALLOC_MEMSET == 3
   19526             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgTypeUnsignedShort) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   19527             : #endif
   19528         324 :     object->p_freepointer = fp;
   19529             : 
   19530             : #if ROSE_ALLOC_TRACE == 2
   19531             : //    printf("SgTypeUnsignedShort::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeUnsignedShort::next_node);
   19532             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   19533             :     Rose::MemPool::snapshot(oss.str());
   19534             :     alloc_trace_cnt++;
   19535             : #endif
   19536             : 
   19537         324 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   19538             : 
   19539         324 :     ALLOC_MUTEX(SgTypeUnsignedShort, unlock);
   19540             : 
   19541             :     return object;
   19542             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   19543             : }
   19544             : 
   19545             : 
   19546             : 
   19547             : /*! \brief Delete operator for SgTypeUnsignedShort.
   19548             : 
   19549             :    This delete operator implements deallocation using memory pools to 
   19550             :    provide most efficent use of the heap within construction of large ASTs.
   19551             : 
   19552             : \internal The new and delete operators use the lower level C malloc/free
   19553             :    function calls for performance and to make sure that mixing of malloc/free
   19554             :    and new/delete by the used can be caught more readily.  This may change
   19555             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   19556             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   19557             :    deallocate memory allocated using ROSE_MALLOC.
   19558             : */
   19559          11 : void SgTypeUnsignedShort::operator delete(void *Pointer, size_t Size)
   19560             : {
   19561             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   19562             :      * or throwing an exception. */
   19563          11 :     ALLOC_MUTEX(SgTypeUnsignedShort, lock);
   19564             : 
   19565             : #if USE_CPP_NEW_DELETE_OPERATORS
   19566             :     ROSE_FREE(Pointer);
   19567             : #else
   19568             : #if ROSE_PEDANTIC_ALLOC
   19569             :     ROSE_ASSERT(Size == sizeof(SgTypeUnsignedShort));
   19570             : #else
   19571          11 :     if (Size != sizeof(SgTypeUnsignedShort)) {
   19572           0 :       ROSE_FREE(Pointer);
   19573           0 :       ALLOC_MUTEX(SgTypeUnsignedShort, unlock);
   19574             :       return;
   19575             :     }
   19576             : #endif
   19577             : 
   19578          11 :     SgTypeUnsignedShort * object = (SgTypeUnsignedShort*) Pointer;
   19579          11 :     ROSE_ASSERT(object != nullptr);
   19580             : 
   19581             : #if ROSE_ALLOC_TRACE == 2
   19582             : //  printf("SgTypeUnsignedShort::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeUnsignedShort::next_node);
   19583             :     printf("SgTypeUnsignedShort::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeUnsignedShort::next_node);
   19584             : #endif
   19585             : 
   19586             : #if ROSE_PEDANTIC_ALLOC
   19587             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   19588             : #endif
   19589             : 
   19590             : #if ROSE_ALLOC_MEMSET == 1
   19591             : #elif ROSE_ALLOC_MEMSET == 2
   19592             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgTypeUnsignedShort) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   19593             : #elif ROSE_ALLOC_MEMSET == 3
   19594             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgTypeUnsignedShort) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   19595             : #endif
   19596             : 
   19597             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   19598             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   19599             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   19600             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   19601             : #else
   19602          11 :     object->p_freepointer = SgTypeUnsignedShort::next_node;
   19603          11 :     SgTypeUnsignedShort::next_node = object;
   19604             : #endif
   19605             : 
   19606             : #if ROSE_ALLOC_TRACE == 2
   19607             : //  printf("SgTypeUnsignedShort::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeUnsignedShort::next_node);
   19608             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   19609             :     Rose::MemPool::snapshot(oss.str());
   19610             :     alloc_trace_cnt++;
   19611             : #endif
   19612             : 
   19613             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   19614             : 
   19615          11 :     ALLOC_MUTEX(SgTypeUnsignedShort, unlock);
   19616             : }
   19617             : 
   19618             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   19619             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   19620             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   19621             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   19622             : // Also, note comment below from Robb (copied from the Common.code file).
   19623             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   19624             : //
   19625             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   19626             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   19627             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   19628             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   19629             : #if 0
   19630             : void SgTypeUnsignedShort::operator delete(void* pointer) { SgTypeUnsignedShort::operator delete (pointer, sizeof(SgTypeUnsignedShort)); };
   19631             : #endif
   19632             : /* #line 19633 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   19633             : 
   19634             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   19635             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   19636             : // obviously imply C++.
   19637             : 
   19638             : // This implements the support within ROSE for memory pools.  Memory pools
   19639             : // support the most condensed usage of memory within the construction of
   19640             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   19641             : // by a new operator written for each class.
   19642             : 
   19643             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   19644             :     // User wants multi-thread support and POSIX threads are available.
   19645             : #   include <pthread.h>
   19646             :     static pthread_mutex_t SgTypeInt_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   19647             : #else
   19648             :      // Cause synchronization to be skipped.
   19649             : #    ifndef ALLOC_MUTEX
   19650             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   19651             : #    endif
   19652             : #    ifdef _REENTRANT
   19653             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   19654             : #       ifdef _MSC_VER
   19655             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   19656             : #       else
   19657             : #           warning "POSIX threads are not available; synchronization being skipped"
   19658             : #       endif
   19659             : #    endif
   19660             : #endif
   19661             : 
   19662             : #ifndef ROSE_ALLOC_TRACE
   19663             : #  define ROSE_ALLOC_TRACE 0
   19664             : #endif
   19665             : 
   19666             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   19667             : #define ROSE_ALLOC_TRACE_CNT
   19668             : #include "memory-pool-snapshot.h"
   19669             : unsigned long alloc_trace_cnt = 0;
   19670             : #endif
   19671             : 
   19672             : #if ROSE_ALLOC_TRACE
   19673             : const unsigned SgTypeInt::pool_size = 5;
   19674             : #else
   19675             : const unsigned SgTypeInt::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   19676             : #endif
   19677             : 
   19678             : #ifndef ROSE_ALLOC_MEMSET
   19679             : #  define ROSE_ALLOC_MEMSET 0
   19680             : #endif
   19681             : 
   19682             : #ifndef ROSE_PEDANTIC_ALLOC
   19683             : #  define ROSE_PEDANTIC_ALLOC 0
   19684             : #endif
   19685             : 
   19686             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   19687             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   19688             : #endif
   19689             : 
   19690             : #if !defined(SGNODE__ALL_POOLS)
   19691             : #define SGNODE__ALL_POOLS
   19692             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   19693             : #endif
   19694             : 
   19695             : SgTypeInt* SgTypeInt::next_node = nullptr;
   19696             : std::vector<unsigned char*> SgTypeInt::pools;
   19697             : 
   19698             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   19699             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   19700             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   19701             : // around this macro definition rather than each use).
   19702             : #ifndef ALLOC_MUTEX
   19703             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   19704             :         do {                                                                     \
   19705             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   19706             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   19707             :                 abort();                                                         \
   19708             :             }                                                                    \
   19709             :         } while (0);
   19710             : #endif
   19711             : 
   19712             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   19713             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   19714             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   19715             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   19716             : 
   19717             : /*! \brief New operator for SgTypeInt.
   19718             : 
   19719             :    This new operator implements memory pools to provide most efficent 
   19720             :    use of the heap within construction of large ASTs.
   19721             : 
   19722             : \internal The new and delete operators use the lower level C malloc/free
   19723             :    function calls for performance and to make sure that mixing of malloc/free
   19724             :    and new/delete by the used can be caught more readily.  This may change
   19725             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   19726             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   19727             :    deallocate memory allocated using ROSE_MALLOC.
   19728             : */
   19729       17949 : void *SgTypeInt::operator new ( size_t Size )
   19730             : {
   19731             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   19732             :      * returning or throwing an exception. */
   19733       17949 :     ALLOC_MUTEX(SgTypeInt, lock);
   19734             : 
   19735             : #if ROSE_ALLOC_TRACE == 2
   19736             : //    printf("SgTypeInt::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgTypeInt::next_node);
   19737             : #endif
   19738             : 
   19739             : #if USE_CPP_NEW_DELETE_OPERATORS
   19740             :     void *mem = ROSE_MALLOC(Size);
   19741             :     ALLOC_MUTEX(SgTypeInt, unlock);
   19742             :     return mem;
   19743             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   19744             : #if ROSE_PEDANTIC_ALLOC
   19745             :     ROSE_ASSERT(Size == sizeof(SgTypeInt));
   19746             : #else
   19747       17949 :     if (Size != sizeof(SgTypeInt)) {
   19748           0 :       void * object = ROSE_MALLOC(Size);
   19749           0 :       ALLOC_MUTEX(SgTypeInt, unlock);
   19750             :       return object;
   19751             :     }
   19752             : #endif
   19753             : 
   19754       17949 :     if (SgTypeInt::next_node == nullptr) {
   19755         341 :         SgTypeInt * alloc = (SgTypeInt*) ROSE_MALLOC ( SgTypeInt::pool_size * sizeof(SgTypeInt) );
   19756         341 :         ROSE_ASSERT(alloc != nullptr);
   19757             : 
   19758             : #if ROSE_ALLOC_TRACE == 2
   19759             : //        printf("SgTypeInt::alloc\n  block[%zi] = [ %p , %p [\n", SgTypeInt::pools.size(), alloc, alloc + SgTypeInt::pool_size);
   19760             : #endif
   19761             : 
   19762             : #if ROSE_ALLOC_MEMSET == 1
   19763             : #elif ROSE_ALLOC_MEMSET == 2
   19764             :         memset(alloc, 0x00, SgTypeInt::pool_size * sizeof(SgTypeInt));
   19765             : #elif ROSE_ALLOC_MEMSET == 3
   19766             :         memset(alloc, 0xAA, SgTypeInt::pool_size * sizeof(SgTypeInt));
   19767             : #endif
   19768      682000 :         for (unsigned i=0; i < SgTypeInt::pool_size-1; i++) {
   19769      681659 :           alloc[i].p_freepointer = &(alloc[i+1]);
   19770             :         }
   19771         341 :         alloc[SgTypeInt::pool_size-1].p_freepointer = nullptr;
   19772             : 
   19773         341 :         SgTypeInt::pools.push_back ( (unsigned char *) alloc );
   19774         341 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgTypeInt::pool_size * sizeof(SgTypeInt), V_SgTypeInt ) );
   19775         341 :         SgTypeInt::next_node = alloc;
   19776             :     }
   19777       17949 :     ROSE_ASSERT(SgTypeInt::next_node != nullptr);
   19778             : 
   19779       17949 :     SgTypeInt * object = SgTypeInt::next_node;
   19780       17949 :     SgTypeInt::next_node = (SgTypeInt*)(object->p_freepointer);
   19781             : 
   19782             : #if ROSE_ALLOC_TRACE == 2
   19783             :     printf("SgTypeInt::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeInt::next_node);
   19784             : #endif
   19785             : 
   19786       17949 :     SgNode * fp = object->p_freepointer;
   19787             : #if ROSE_ALLOC_MEMSET == 1
   19788             : #elif ROSE_ALLOC_MEMSET == 2
   19789             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgTypeInt) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   19790             : #elif ROSE_ALLOC_MEMSET == 3
   19791             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgTypeInt) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   19792             : #endif
   19793       17949 :     object->p_freepointer = fp;
   19794             : 
   19795             : #if ROSE_ALLOC_TRACE == 2
   19796             : //    printf("SgTypeInt::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeInt::next_node);
   19797             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   19798             :     Rose::MemPool::snapshot(oss.str());
   19799             :     alloc_trace_cnt++;
   19800             : #endif
   19801             : 
   19802       17949 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   19803             : 
   19804       17949 :     ALLOC_MUTEX(SgTypeInt, unlock);
   19805             : 
   19806             :     return object;
   19807             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   19808             : }
   19809             : 
   19810             : 
   19811             : 
   19812             : /*! \brief Delete operator for SgTypeInt.
   19813             : 
   19814             :    This delete operator implements deallocation using memory pools to 
   19815             :    provide most efficent use of the heap within construction of large ASTs.
   19816             : 
   19817             : \internal The new and delete operators use the lower level C malloc/free
   19818             :    function calls for performance and to make sure that mixing of malloc/free
   19819             :    and new/delete by the used can be caught more readily.  This may change
   19820             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   19821             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   19822             :    deallocate memory allocated using ROSE_MALLOC.
   19823             : */
   19824       17554 : void SgTypeInt::operator delete(void *Pointer, size_t Size)
   19825             : {
   19826             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   19827             :      * or throwing an exception. */
   19828       17554 :     ALLOC_MUTEX(SgTypeInt, lock);
   19829             : 
   19830             : #if USE_CPP_NEW_DELETE_OPERATORS
   19831             :     ROSE_FREE(Pointer);
   19832             : #else
   19833             : #if ROSE_PEDANTIC_ALLOC
   19834             :     ROSE_ASSERT(Size == sizeof(SgTypeInt));
   19835             : #else
   19836       17554 :     if (Size != sizeof(SgTypeInt)) {
   19837           0 :       ROSE_FREE(Pointer);
   19838           0 :       ALLOC_MUTEX(SgTypeInt, unlock);
   19839             :       return;
   19840             :     }
   19841             : #endif
   19842             : 
   19843       17554 :     SgTypeInt * object = (SgTypeInt*) Pointer;
   19844       17554 :     ROSE_ASSERT(object != nullptr);
   19845             : 
   19846             : #if ROSE_ALLOC_TRACE == 2
   19847             : //  printf("SgTypeInt::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeInt::next_node);
   19848             :     printf("SgTypeInt::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeInt::next_node);
   19849             : #endif
   19850             : 
   19851             : #if ROSE_PEDANTIC_ALLOC
   19852             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   19853             : #endif
   19854             : 
   19855             : #if ROSE_ALLOC_MEMSET == 1
   19856             : #elif ROSE_ALLOC_MEMSET == 2
   19857             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgTypeInt) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   19858             : #elif ROSE_ALLOC_MEMSET == 3
   19859             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgTypeInt) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   19860             : #endif
   19861             : 
   19862             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   19863             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   19864             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   19865             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   19866             : #else
   19867       17554 :     object->p_freepointer = SgTypeInt::next_node;
   19868       17554 :     SgTypeInt::next_node = object;
   19869             : #endif
   19870             : 
   19871             : #if ROSE_ALLOC_TRACE == 2
   19872             : //  printf("SgTypeInt::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeInt::next_node);
   19873             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   19874             :     Rose::MemPool::snapshot(oss.str());
   19875             :     alloc_trace_cnt++;
   19876             : #endif
   19877             : 
   19878             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   19879             : 
   19880       17554 :     ALLOC_MUTEX(SgTypeInt, unlock);
   19881             : }
   19882             : 
   19883             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   19884             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   19885             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   19886             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   19887             : // Also, note comment below from Robb (copied from the Common.code file).
   19888             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   19889             : //
   19890             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   19891             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   19892             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   19893             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   19894             : #if 0
   19895             : void SgTypeInt::operator delete(void* pointer) { SgTypeInt::operator delete (pointer, sizeof(SgTypeInt)); };
   19896             : #endif
   19897             : /* #line 19898 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   19898             : 
   19899             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   19900             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   19901             : // obviously imply C++.
   19902             : 
   19903             : // This implements the support within ROSE for memory pools.  Memory pools
   19904             : // support the most condensed usage of memory within the construction of
   19905             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   19906             : // by a new operator written for each class.
   19907             : 
   19908             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   19909             :     // User wants multi-thread support and POSIX threads are available.
   19910             : #   include <pthread.h>
   19911             :     static pthread_mutex_t SgTypeSignedInt_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   19912             : #else
   19913             :      // Cause synchronization to be skipped.
   19914             : #    ifndef ALLOC_MUTEX
   19915             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   19916             : #    endif
   19917             : #    ifdef _REENTRANT
   19918             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   19919             : #       ifdef _MSC_VER
   19920             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   19921             : #       else
   19922             : #           warning "POSIX threads are not available; synchronization being skipped"
   19923             : #       endif
   19924             : #    endif
   19925             : #endif
   19926             : 
   19927             : #ifndef ROSE_ALLOC_TRACE
   19928             : #  define ROSE_ALLOC_TRACE 0
   19929             : #endif
   19930             : 
   19931             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   19932             : #define ROSE_ALLOC_TRACE_CNT
   19933             : #include "memory-pool-snapshot.h"
   19934             : unsigned long alloc_trace_cnt = 0;
   19935             : #endif
   19936             : 
   19937             : #if ROSE_ALLOC_TRACE
   19938             : const unsigned SgTypeSignedInt::pool_size = 5;
   19939             : #else
   19940             : const unsigned SgTypeSignedInt::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   19941             : #endif
   19942             : 
   19943             : #ifndef ROSE_ALLOC_MEMSET
   19944             : #  define ROSE_ALLOC_MEMSET 0
   19945             : #endif
   19946             : 
   19947             : #ifndef ROSE_PEDANTIC_ALLOC
   19948             : #  define ROSE_PEDANTIC_ALLOC 0
   19949             : #endif
   19950             : 
   19951             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   19952             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   19953             : #endif
   19954             : 
   19955             : #if !defined(SGNODE__ALL_POOLS)
   19956             : #define SGNODE__ALL_POOLS
   19957             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   19958             : #endif
   19959             : 
   19960             : SgTypeSignedInt* SgTypeSignedInt::next_node = nullptr;
   19961             : std::vector<unsigned char*> SgTypeSignedInt::pools;
   19962             : 
   19963             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   19964             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   19965             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   19966             : // around this macro definition rather than each use).
   19967             : #ifndef ALLOC_MUTEX
   19968             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   19969             :         do {                                                                     \
   19970             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   19971             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   19972             :                 abort();                                                         \
   19973             :             }                                                                    \
   19974             :         } while (0);
   19975             : #endif
   19976             : 
   19977             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   19978             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   19979             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   19980             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   19981             : 
   19982             : /*! \brief New operator for SgTypeSignedInt.
   19983             : 
   19984             :    This new operator implements memory pools to provide most efficent 
   19985             :    use of the heap within construction of large ASTs.
   19986             : 
   19987             : \internal The new and delete operators use the lower level C malloc/free
   19988             :    function calls for performance and to make sure that mixing of malloc/free
   19989             :    and new/delete by the used can be caught more readily.  This may change
   19990             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   19991             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   19992             :    deallocate memory allocated using ROSE_MALLOC.
   19993             : */
   19994         200 : void *SgTypeSignedInt::operator new ( size_t Size )
   19995             : {
   19996             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   19997             :      * returning or throwing an exception. */
   19998         200 :     ALLOC_MUTEX(SgTypeSignedInt, lock);
   19999             : 
   20000             : #if ROSE_ALLOC_TRACE == 2
   20001             : //    printf("SgTypeSignedInt::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgTypeSignedInt::next_node);
   20002             : #endif
   20003             : 
   20004             : #if USE_CPP_NEW_DELETE_OPERATORS
   20005             :     void *mem = ROSE_MALLOC(Size);
   20006             :     ALLOC_MUTEX(SgTypeSignedInt, unlock);
   20007             :     return mem;
   20008             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   20009             : #if ROSE_PEDANTIC_ALLOC
   20010             :     ROSE_ASSERT(Size == sizeof(SgTypeSignedInt));
   20011             : #else
   20012         200 :     if (Size != sizeof(SgTypeSignedInt)) {
   20013           0 :       void * object = ROSE_MALLOC(Size);
   20014           0 :       ALLOC_MUTEX(SgTypeSignedInt, unlock);
   20015             :       return object;
   20016             :     }
   20017             : #endif
   20018             : 
   20019         200 :     if (SgTypeSignedInt::next_node == nullptr) {
   20020         198 :         SgTypeSignedInt * alloc = (SgTypeSignedInt*) ROSE_MALLOC ( SgTypeSignedInt::pool_size * sizeof(SgTypeSignedInt) );
   20021         198 :         ROSE_ASSERT(alloc != nullptr);
   20022             : 
   20023             : #if ROSE_ALLOC_TRACE == 2
   20024             : //        printf("SgTypeSignedInt::alloc\n  block[%zi] = [ %p , %p [\n", SgTypeSignedInt::pools.size(), alloc, alloc + SgTypeSignedInt::pool_size);
   20025             : #endif
   20026             : 
   20027             : #if ROSE_ALLOC_MEMSET == 1
   20028             : #elif ROSE_ALLOC_MEMSET == 2
   20029             :         memset(alloc, 0x00, SgTypeSignedInt::pool_size * sizeof(SgTypeSignedInt));
   20030             : #elif ROSE_ALLOC_MEMSET == 3
   20031             :         memset(alloc, 0xAA, SgTypeSignedInt::pool_size * sizeof(SgTypeSignedInt));
   20032             : #endif
   20033      396000 :         for (unsigned i=0; i < SgTypeSignedInt::pool_size-1; i++) {
   20034      395802 :           alloc[i].p_freepointer = &(alloc[i+1]);
   20035             :         }
   20036         198 :         alloc[SgTypeSignedInt::pool_size-1].p_freepointer = nullptr;
   20037             : 
   20038         198 :         SgTypeSignedInt::pools.push_back ( (unsigned char *) alloc );
   20039         198 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgTypeSignedInt::pool_size * sizeof(SgTypeSignedInt), V_SgTypeSignedInt ) );
   20040         198 :         SgTypeSignedInt::next_node = alloc;
   20041             :     }
   20042         200 :     ROSE_ASSERT(SgTypeSignedInt::next_node != nullptr);
   20043             : 
   20044         200 :     SgTypeSignedInt * object = SgTypeSignedInt::next_node;
   20045         200 :     SgTypeSignedInt::next_node = (SgTypeSignedInt*)(object->p_freepointer);
   20046             : 
   20047             : #if ROSE_ALLOC_TRACE == 2
   20048             :     printf("SgTypeSignedInt::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeSignedInt::next_node);
   20049             : #endif
   20050             : 
   20051         200 :     SgNode * fp = object->p_freepointer;
   20052             : #if ROSE_ALLOC_MEMSET == 1
   20053             : #elif ROSE_ALLOC_MEMSET == 2
   20054             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgTypeSignedInt) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   20055             : #elif ROSE_ALLOC_MEMSET == 3
   20056             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgTypeSignedInt) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   20057             : #endif
   20058         200 :     object->p_freepointer = fp;
   20059             : 
   20060             : #if ROSE_ALLOC_TRACE == 2
   20061             : //    printf("SgTypeSignedInt::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeSignedInt::next_node);
   20062             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   20063             :     Rose::MemPool::snapshot(oss.str());
   20064             :     alloc_trace_cnt++;
   20065             : #endif
   20066             : 
   20067         200 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   20068             : 
   20069         200 :     ALLOC_MUTEX(SgTypeSignedInt, unlock);
   20070             : 
   20071             :     return object;
   20072             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   20073             : }
   20074             : 
   20075             : 
   20076             : 
   20077             : /*! \brief Delete operator for SgTypeSignedInt.
   20078             : 
   20079             :    This delete operator implements deallocation using memory pools to 
   20080             :    provide most efficent use of the heap within construction of large ASTs.
   20081             : 
   20082             : \internal The new and delete operators use the lower level C malloc/free
   20083             :    function calls for performance and to make sure that mixing of malloc/free
   20084             :    and new/delete by the used can be caught more readily.  This may change
   20085             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   20086             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   20087             :    deallocate memory allocated using ROSE_MALLOC.
   20088             : */
   20089           4 : void SgTypeSignedInt::operator delete(void *Pointer, size_t Size)
   20090             : {
   20091             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   20092             :      * or throwing an exception. */
   20093           4 :     ALLOC_MUTEX(SgTypeSignedInt, lock);
   20094             : 
   20095             : #if USE_CPP_NEW_DELETE_OPERATORS
   20096             :     ROSE_FREE(Pointer);
   20097             : #else
   20098             : #if ROSE_PEDANTIC_ALLOC
   20099             :     ROSE_ASSERT(Size == sizeof(SgTypeSignedInt));
   20100             : #else
   20101           4 :     if (Size != sizeof(SgTypeSignedInt)) {
   20102           0 :       ROSE_FREE(Pointer);
   20103           0 :       ALLOC_MUTEX(SgTypeSignedInt, unlock);
   20104             :       return;
   20105             :     }
   20106             : #endif
   20107             : 
   20108           4 :     SgTypeSignedInt * object = (SgTypeSignedInt*) Pointer;
   20109           4 :     ROSE_ASSERT(object != nullptr);
   20110             : 
   20111             : #if ROSE_ALLOC_TRACE == 2
   20112             : //  printf("SgTypeSignedInt::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeSignedInt::next_node);
   20113             :     printf("SgTypeSignedInt::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeSignedInt::next_node);
   20114             : #endif
   20115             : 
   20116             : #if ROSE_PEDANTIC_ALLOC
   20117             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   20118             : #endif
   20119             : 
   20120             : #if ROSE_ALLOC_MEMSET == 1
   20121             : #elif ROSE_ALLOC_MEMSET == 2
   20122             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgTypeSignedInt) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   20123             : #elif ROSE_ALLOC_MEMSET == 3
   20124             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgTypeSignedInt) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   20125             : #endif
   20126             : 
   20127             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   20128             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   20129             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   20130             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   20131             : #else
   20132           4 :     object->p_freepointer = SgTypeSignedInt::next_node;
   20133           4 :     SgTypeSignedInt::next_node = object;
   20134             : #endif
   20135             : 
   20136             : #if ROSE_ALLOC_TRACE == 2
   20137             : //  printf("SgTypeSignedInt::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeSignedInt::next_node);
   20138             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   20139             :     Rose::MemPool::snapshot(oss.str());
   20140             :     alloc_trace_cnt++;
   20141             : #endif
   20142             : 
   20143             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   20144             : 
   20145           4 :     ALLOC_MUTEX(SgTypeSignedInt, unlock);
   20146             : }
   20147             : 
   20148             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   20149             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   20150             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   20151             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   20152             : // Also, note comment below from Robb (copied from the Common.code file).
   20153             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   20154             : //
   20155             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   20156             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   20157             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   20158             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   20159             : #if 0
   20160             : void SgTypeSignedInt::operator delete(void* pointer) { SgTypeSignedInt::operator delete (pointer, sizeof(SgTypeSignedInt)); };
   20161             : #endif
   20162             : /* #line 20163 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   20163             : 
   20164             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   20165             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   20166             : // obviously imply C++.
   20167             : 
   20168             : // This implements the support within ROSE for memory pools.  Memory pools
   20169             : // support the most condensed usage of memory within the construction of
   20170             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   20171             : // by a new operator written for each class.
   20172             : 
   20173             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   20174             :     // User wants multi-thread support and POSIX threads are available.
   20175             : #   include <pthread.h>
   20176             :     static pthread_mutex_t SgTypeUnsignedInt_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   20177             : #else
   20178             :      // Cause synchronization to be skipped.
   20179             : #    ifndef ALLOC_MUTEX
   20180             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   20181             : #    endif
   20182             : #    ifdef _REENTRANT
   20183             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   20184             : #       ifdef _MSC_VER
   20185             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   20186             : #       else
   20187             : #           warning "POSIX threads are not available; synchronization being skipped"
   20188             : #       endif
   20189             : #    endif
   20190             : #endif
   20191             : 
   20192             : #ifndef ROSE_ALLOC_TRACE
   20193             : #  define ROSE_ALLOC_TRACE 0
   20194             : #endif
   20195             : 
   20196             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   20197             : #define ROSE_ALLOC_TRACE_CNT
   20198             : #include "memory-pool-snapshot.h"
   20199             : unsigned long alloc_trace_cnt = 0;
   20200             : #endif
   20201             : 
   20202             : #if ROSE_ALLOC_TRACE
   20203             : const unsigned SgTypeUnsignedInt::pool_size = 5;
   20204             : #else
   20205             : const unsigned SgTypeUnsignedInt::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   20206             : #endif
   20207             : 
   20208             : #ifndef ROSE_ALLOC_MEMSET
   20209             : #  define ROSE_ALLOC_MEMSET 0
   20210             : #endif
   20211             : 
   20212             : #ifndef ROSE_PEDANTIC_ALLOC
   20213             : #  define ROSE_PEDANTIC_ALLOC 0
   20214             : #endif
   20215             : 
   20216             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   20217             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   20218             : #endif
   20219             : 
   20220             : #if !defined(SGNODE__ALL_POOLS)
   20221             : #define SGNODE__ALL_POOLS
   20222             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   20223             : #endif
   20224             : 
   20225             : SgTypeUnsignedInt* SgTypeUnsignedInt::next_node = nullptr;
   20226             : std::vector<unsigned char*> SgTypeUnsignedInt::pools;
   20227             : 
   20228             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   20229             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   20230             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   20231             : // around this macro definition rather than each use).
   20232             : #ifndef ALLOC_MUTEX
   20233             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   20234             :         do {                                                                     \
   20235             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   20236             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   20237             :                 abort();                                                         \
   20238             :             }                                                                    \
   20239             :         } while (0);
   20240             : #endif
   20241             : 
   20242             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   20243             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   20244             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   20245             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   20246             : 
   20247             : /*! \brief New operator for SgTypeUnsignedInt.
   20248             : 
   20249             :    This new operator implements memory pools to provide most efficent 
   20250             :    use of the heap within construction of large ASTs.
   20251             : 
   20252             : \internal The new and delete operators use the lower level C malloc/free
   20253             :    function calls for performance and to make sure that mixing of malloc/free
   20254             :    and new/delete by the used can be caught more readily.  This may change
   20255             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   20256             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   20257             :    deallocate memory allocated using ROSE_MALLOC.
   20258             : */
   20259        1786 : void *SgTypeUnsignedInt::operator new ( size_t Size )
   20260             : {
   20261             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   20262             :      * returning or throwing an exception. */
   20263        1786 :     ALLOC_MUTEX(SgTypeUnsignedInt, lock);
   20264             : 
   20265             : #if ROSE_ALLOC_TRACE == 2
   20266             : //    printf("SgTypeUnsignedInt::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgTypeUnsignedInt::next_node);
   20267             : #endif
   20268             : 
   20269             : #if USE_CPP_NEW_DELETE_OPERATORS
   20270             :     void *mem = ROSE_MALLOC(Size);
   20271             :     ALLOC_MUTEX(SgTypeUnsignedInt, unlock);
   20272             :     return mem;
   20273             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   20274             : #if ROSE_PEDANTIC_ALLOC
   20275             :     ROSE_ASSERT(Size == sizeof(SgTypeUnsignedInt));
   20276             : #else
   20277        1786 :     if (Size != sizeof(SgTypeUnsignedInt)) {
   20278           0 :       void * object = ROSE_MALLOC(Size);
   20279           0 :       ALLOC_MUTEX(SgTypeUnsignedInt, unlock);
   20280             :       return object;
   20281             :     }
   20282             : #endif
   20283             : 
   20284        1786 :     if (SgTypeUnsignedInt::next_node == nullptr) {
   20285         315 :         SgTypeUnsignedInt * alloc = (SgTypeUnsignedInt*) ROSE_MALLOC ( SgTypeUnsignedInt::pool_size * sizeof(SgTypeUnsignedInt) );
   20286         315 :         ROSE_ASSERT(alloc != nullptr);
   20287             : 
   20288             : #if ROSE_ALLOC_TRACE == 2
   20289             : //        printf("SgTypeUnsignedInt::alloc\n  block[%zi] = [ %p , %p [\n", SgTypeUnsignedInt::pools.size(), alloc, alloc + SgTypeUnsignedInt::pool_size);
   20290             : #endif
   20291             : 
   20292             : #if ROSE_ALLOC_MEMSET == 1
   20293             : #elif ROSE_ALLOC_MEMSET == 2
   20294             :         memset(alloc, 0x00, SgTypeUnsignedInt::pool_size * sizeof(SgTypeUnsignedInt));
   20295             : #elif ROSE_ALLOC_MEMSET == 3
   20296             :         memset(alloc, 0xAA, SgTypeUnsignedInt::pool_size * sizeof(SgTypeUnsignedInt));
   20297             : #endif
   20298      630000 :         for (unsigned i=0; i < SgTypeUnsignedInt::pool_size-1; i++) {
   20299      629685 :           alloc[i].p_freepointer = &(alloc[i+1]);
   20300             :         }
   20301         315 :         alloc[SgTypeUnsignedInt::pool_size-1].p_freepointer = nullptr;
   20302             : 
   20303         315 :         SgTypeUnsignedInt::pools.push_back ( (unsigned char *) alloc );
   20304         315 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgTypeUnsignedInt::pool_size * sizeof(SgTypeUnsignedInt), V_SgTypeUnsignedInt ) );
   20305         315 :         SgTypeUnsignedInt::next_node = alloc;
   20306             :     }
   20307        1786 :     ROSE_ASSERT(SgTypeUnsignedInt::next_node != nullptr);
   20308             : 
   20309        1786 :     SgTypeUnsignedInt * object = SgTypeUnsignedInt::next_node;
   20310        1786 :     SgTypeUnsignedInt::next_node = (SgTypeUnsignedInt*)(object->p_freepointer);
   20311             : 
   20312             : #if ROSE_ALLOC_TRACE == 2
   20313             :     printf("SgTypeUnsignedInt::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeUnsignedInt::next_node);
   20314             : #endif
   20315             : 
   20316        1786 :     SgNode * fp = object->p_freepointer;
   20317             : #if ROSE_ALLOC_MEMSET == 1
   20318             : #elif ROSE_ALLOC_MEMSET == 2
   20319             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgTypeUnsignedInt) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   20320             : #elif ROSE_ALLOC_MEMSET == 3
   20321             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgTypeUnsignedInt) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   20322             : #endif
   20323        1786 :     object->p_freepointer = fp;
   20324             : 
   20325             : #if ROSE_ALLOC_TRACE == 2
   20326             : //    printf("SgTypeUnsignedInt::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeUnsignedInt::next_node);
   20327             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   20328             :     Rose::MemPool::snapshot(oss.str());
   20329             :     alloc_trace_cnt++;
   20330             : #endif
   20331             : 
   20332        1786 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   20333             : 
   20334        1786 :     ALLOC_MUTEX(SgTypeUnsignedInt, unlock);
   20335             : 
   20336             :     return object;
   20337             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   20338             : }
   20339             : 
   20340             : 
   20341             : 
   20342             : /*! \brief Delete operator for SgTypeUnsignedInt.
   20343             : 
   20344             :    This delete operator implements deallocation using memory pools to 
   20345             :    provide most efficent use of the heap within construction of large ASTs.
   20346             : 
   20347             : \internal The new and delete operators use the lower level C malloc/free
   20348             :    function calls for performance and to make sure that mixing of malloc/free
   20349             :    and new/delete by the used can be caught more readily.  This may change
   20350             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   20351             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   20352             :    deallocate memory allocated using ROSE_MALLOC.
   20353             : */
   20354        1473 : void SgTypeUnsignedInt::operator delete(void *Pointer, size_t Size)
   20355             : {
   20356             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   20357             :      * or throwing an exception. */
   20358        1473 :     ALLOC_MUTEX(SgTypeUnsignedInt, lock);
   20359             : 
   20360             : #if USE_CPP_NEW_DELETE_OPERATORS
   20361             :     ROSE_FREE(Pointer);
   20362             : #else
   20363             : #if ROSE_PEDANTIC_ALLOC
   20364             :     ROSE_ASSERT(Size == sizeof(SgTypeUnsignedInt));
   20365             : #else
   20366        1473 :     if (Size != sizeof(SgTypeUnsignedInt)) {
   20367           0 :       ROSE_FREE(Pointer);
   20368           0 :       ALLOC_MUTEX(SgTypeUnsignedInt, unlock);
   20369             :       return;
   20370             :     }
   20371             : #endif
   20372             : 
   20373        1473 :     SgTypeUnsignedInt * object = (SgTypeUnsignedInt*) Pointer;
   20374        1473 :     ROSE_ASSERT(object != nullptr);
   20375             : 
   20376             : #if ROSE_ALLOC_TRACE == 2
   20377             : //  printf("SgTypeUnsignedInt::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeUnsignedInt::next_node);
   20378             :     printf("SgTypeUnsignedInt::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeUnsignedInt::next_node);
   20379             : #endif
   20380             : 
   20381             : #if ROSE_PEDANTIC_ALLOC
   20382             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   20383             : #endif
   20384             : 
   20385             : #if ROSE_ALLOC_MEMSET == 1
   20386             : #elif ROSE_ALLOC_MEMSET == 2
   20387             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgTypeUnsignedInt) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   20388             : #elif ROSE_ALLOC_MEMSET == 3
   20389             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgTypeUnsignedInt) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   20390             : #endif
   20391             : 
   20392             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   20393             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   20394             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   20395             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   20396             : #else
   20397        1473 :     object->p_freepointer = SgTypeUnsignedInt::next_node;
   20398        1473 :     SgTypeUnsignedInt::next_node = object;
   20399             : #endif
   20400             : 
   20401             : #if ROSE_ALLOC_TRACE == 2
   20402             : //  printf("SgTypeUnsignedInt::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeUnsignedInt::next_node);
   20403             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   20404             :     Rose::MemPool::snapshot(oss.str());
   20405             :     alloc_trace_cnt++;
   20406             : #endif
   20407             : 
   20408             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   20409             : 
   20410        1473 :     ALLOC_MUTEX(SgTypeUnsignedInt, unlock);
   20411             : }
   20412             : 
   20413             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   20414             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   20415             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   20416             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   20417             : // Also, note comment below from Robb (copied from the Common.code file).
   20418             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   20419             : //
   20420             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   20421             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   20422             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   20423             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   20424             : #if 0
   20425             : void SgTypeUnsignedInt::operator delete(void* pointer) { SgTypeUnsignedInt::operator delete (pointer, sizeof(SgTypeUnsignedInt)); };
   20426             : #endif
   20427             : /* #line 20428 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   20428             : 
   20429             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   20430             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   20431             : // obviously imply C++.
   20432             : 
   20433             : // This implements the support within ROSE for memory pools.  Memory pools
   20434             : // support the most condensed usage of memory within the construction of
   20435             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   20436             : // by a new operator written for each class.
   20437             : 
   20438             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   20439             :     // User wants multi-thread support and POSIX threads are available.
   20440             : #   include <pthread.h>
   20441             :     static pthread_mutex_t SgTypeLong_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   20442             : #else
   20443             :      // Cause synchronization to be skipped.
   20444             : #    ifndef ALLOC_MUTEX
   20445             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   20446             : #    endif
   20447             : #    ifdef _REENTRANT
   20448             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   20449             : #       ifdef _MSC_VER
   20450             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   20451             : #       else
   20452             : #           warning "POSIX threads are not available; synchronization being skipped"
   20453             : #       endif
   20454             : #    endif
   20455             : #endif
   20456             : 
   20457             : #ifndef ROSE_ALLOC_TRACE
   20458             : #  define ROSE_ALLOC_TRACE 0
   20459             : #endif
   20460             : 
   20461             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   20462             : #define ROSE_ALLOC_TRACE_CNT
   20463             : #include "memory-pool-snapshot.h"
   20464             : unsigned long alloc_trace_cnt = 0;
   20465             : #endif
   20466             : 
   20467             : #if ROSE_ALLOC_TRACE
   20468             : const unsigned SgTypeLong::pool_size = 5;
   20469             : #else
   20470             : const unsigned SgTypeLong::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   20471             : #endif
   20472             : 
   20473             : #ifndef ROSE_ALLOC_MEMSET
   20474             : #  define ROSE_ALLOC_MEMSET 0
   20475             : #endif
   20476             : 
   20477             : #ifndef ROSE_PEDANTIC_ALLOC
   20478             : #  define ROSE_PEDANTIC_ALLOC 0
   20479             : #endif
   20480             : 
   20481             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   20482             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   20483             : #endif
   20484             : 
   20485             : #if !defined(SGNODE__ALL_POOLS)
   20486             : #define SGNODE__ALL_POOLS
   20487             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   20488             : #endif
   20489             : 
   20490             : SgTypeLong* SgTypeLong::next_node = nullptr;
   20491             : std::vector<unsigned char*> SgTypeLong::pools;
   20492             : 
   20493             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   20494             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   20495             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   20496             : // around this macro definition rather than each use).
   20497             : #ifndef ALLOC_MUTEX
   20498             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   20499             :         do {                                                                     \
   20500             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   20501             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   20502             :                 abort();                                                         \
   20503             :             }                                                                    \
   20504             :         } while (0);
   20505             : #endif
   20506             : 
   20507             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   20508             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   20509             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   20510             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   20511             : 
   20512             : /*! \brief New operator for SgTypeLong.
   20513             : 
   20514             :    This new operator implements memory pools to provide most efficent 
   20515             :    use of the heap within construction of large ASTs.
   20516             : 
   20517             : \internal The new and delete operators use the lower level C malloc/free
   20518             :    function calls for performance and to make sure that mixing of malloc/free
   20519             :    and new/delete by the used can be caught more readily.  This may change
   20520             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   20521             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   20522             :    deallocate memory allocated using ROSE_MALLOC.
   20523             : */
   20524         486 : void *SgTypeLong::operator new ( size_t Size )
   20525             : {
   20526             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   20527             :      * returning or throwing an exception. */
   20528         486 :     ALLOC_MUTEX(SgTypeLong, lock);
   20529             : 
   20530             : #if ROSE_ALLOC_TRACE == 2
   20531             : //    printf("SgTypeLong::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgTypeLong::next_node);
   20532             : #endif
   20533             : 
   20534             : #if USE_CPP_NEW_DELETE_OPERATORS
   20535             :     void *mem = ROSE_MALLOC(Size);
   20536             :     ALLOC_MUTEX(SgTypeLong, unlock);
   20537             :     return mem;
   20538             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   20539             : #if ROSE_PEDANTIC_ALLOC
   20540             :     ROSE_ASSERT(Size == sizeof(SgTypeLong));
   20541             : #else
   20542         486 :     if (Size != sizeof(SgTypeLong)) {
   20543           0 :       void * object = ROSE_MALLOC(Size);
   20544           0 :       ALLOC_MUTEX(SgTypeLong, unlock);
   20545             :       return object;
   20546             :     }
   20547             : #endif
   20548             : 
   20549         486 :     if (SgTypeLong::next_node == nullptr) {
   20550         315 :         SgTypeLong * alloc = (SgTypeLong*) ROSE_MALLOC ( SgTypeLong::pool_size * sizeof(SgTypeLong) );
   20551         315 :         ROSE_ASSERT(alloc != nullptr);
   20552             : 
   20553             : #if ROSE_ALLOC_TRACE == 2
   20554             : //        printf("SgTypeLong::alloc\n  block[%zi] = [ %p , %p [\n", SgTypeLong::pools.size(), alloc, alloc + SgTypeLong::pool_size);
   20555             : #endif
   20556             : 
   20557             : #if ROSE_ALLOC_MEMSET == 1
   20558             : #elif ROSE_ALLOC_MEMSET == 2
   20559             :         memset(alloc, 0x00, SgTypeLong::pool_size * sizeof(SgTypeLong));
   20560             : #elif ROSE_ALLOC_MEMSET == 3
   20561             :         memset(alloc, 0xAA, SgTypeLong::pool_size * sizeof(SgTypeLong));
   20562             : #endif
   20563      630000 :         for (unsigned i=0; i < SgTypeLong::pool_size-1; i++) {
   20564      629685 :           alloc[i].p_freepointer = &(alloc[i+1]);
   20565             :         }
   20566         315 :         alloc[SgTypeLong::pool_size-1].p_freepointer = nullptr;
   20567             : 
   20568         315 :         SgTypeLong::pools.push_back ( (unsigned char *) alloc );
   20569         315 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgTypeLong::pool_size * sizeof(SgTypeLong), V_SgTypeLong ) );
   20570         315 :         SgTypeLong::next_node = alloc;
   20571             :     }
   20572         486 :     ROSE_ASSERT(SgTypeLong::next_node != nullptr);
   20573             : 
   20574         486 :     SgTypeLong * object = SgTypeLong::next_node;
   20575         486 :     SgTypeLong::next_node = (SgTypeLong*)(object->p_freepointer);
   20576             : 
   20577             : #if ROSE_ALLOC_TRACE == 2
   20578             :     printf("SgTypeLong::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeLong::next_node);
   20579             : #endif
   20580             : 
   20581         486 :     SgNode * fp = object->p_freepointer;
   20582             : #if ROSE_ALLOC_MEMSET == 1
   20583             : #elif ROSE_ALLOC_MEMSET == 2
   20584             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgTypeLong) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   20585             : #elif ROSE_ALLOC_MEMSET == 3
   20586             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgTypeLong) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   20587             : #endif
   20588         486 :     object->p_freepointer = fp;
   20589             : 
   20590             : #if ROSE_ALLOC_TRACE == 2
   20591             : //    printf("SgTypeLong::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeLong::next_node);
   20592             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   20593             :     Rose::MemPool::snapshot(oss.str());
   20594             :     alloc_trace_cnt++;
   20595             : #endif
   20596             : 
   20597         486 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   20598             : 
   20599         486 :     ALLOC_MUTEX(SgTypeLong, unlock);
   20600             : 
   20601             :     return object;
   20602             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   20603             : }
   20604             : 
   20605             : 
   20606             : 
   20607             : /*! \brief Delete operator for SgTypeLong.
   20608             : 
   20609             :    This delete operator implements deallocation using memory pools to 
   20610             :    provide most efficent use of the heap within construction of large ASTs.
   20611             : 
   20612             : \internal The new and delete operators use the lower level C malloc/free
   20613             :    function calls for performance and to make sure that mixing of malloc/free
   20614             :    and new/delete by the used can be caught more readily.  This may change
   20615             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   20616             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   20617             :    deallocate memory allocated using ROSE_MALLOC.
   20618             : */
   20619         173 : void SgTypeLong::operator delete(void *Pointer, size_t Size)
   20620             : {
   20621             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   20622             :      * or throwing an exception. */
   20623         173 :     ALLOC_MUTEX(SgTypeLong, lock);
   20624             : 
   20625             : #if USE_CPP_NEW_DELETE_OPERATORS
   20626             :     ROSE_FREE(Pointer);
   20627             : #else
   20628             : #if ROSE_PEDANTIC_ALLOC
   20629             :     ROSE_ASSERT(Size == sizeof(SgTypeLong));
   20630             : #else
   20631         173 :     if (Size != sizeof(SgTypeLong)) {
   20632           0 :       ROSE_FREE(Pointer);
   20633           0 :       ALLOC_MUTEX(SgTypeLong, unlock);
   20634             :       return;
   20635             :     }
   20636             : #endif
   20637             : 
   20638         173 :     SgTypeLong * object = (SgTypeLong*) Pointer;
   20639         173 :     ROSE_ASSERT(object != nullptr);
   20640             : 
   20641             : #if ROSE_ALLOC_TRACE == 2
   20642             : //  printf("SgTypeLong::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeLong::next_node);
   20643             :     printf("SgTypeLong::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeLong::next_node);
   20644             : #endif
   20645             : 
   20646             : #if ROSE_PEDANTIC_ALLOC
   20647             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   20648             : #endif
   20649             : 
   20650             : #if ROSE_ALLOC_MEMSET == 1
   20651             : #elif ROSE_ALLOC_MEMSET == 2
   20652             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgTypeLong) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   20653             : #elif ROSE_ALLOC_MEMSET == 3
   20654             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgTypeLong) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   20655             : #endif
   20656             : 
   20657             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   20658             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   20659             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   20660             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   20661             : #else
   20662         173 :     object->p_freepointer = SgTypeLong::next_node;
   20663         173 :     SgTypeLong::next_node = object;
   20664             : #endif
   20665             : 
   20666             : #if ROSE_ALLOC_TRACE == 2
   20667             : //  printf("SgTypeLong::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeLong::next_node);
   20668             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   20669             :     Rose::MemPool::snapshot(oss.str());
   20670             :     alloc_trace_cnt++;
   20671             : #endif
   20672             : 
   20673             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   20674             : 
   20675         173 :     ALLOC_MUTEX(SgTypeLong, unlock);
   20676             : }
   20677             : 
   20678             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   20679             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   20680             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   20681             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   20682             : // Also, note comment below from Robb (copied from the Common.code file).
   20683             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   20684             : //
   20685             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   20686             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   20687             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   20688             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   20689             : #if 0
   20690             : void SgTypeLong::operator delete(void* pointer) { SgTypeLong::operator delete (pointer, sizeof(SgTypeLong)); };
   20691             : #endif
   20692             : /* #line 20693 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   20693             : 
   20694             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   20695             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   20696             : // obviously imply C++.
   20697             : 
   20698             : // This implements the support within ROSE for memory pools.  Memory pools
   20699             : // support the most condensed usage of memory within the construction of
   20700             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   20701             : // by a new operator written for each class.
   20702             : 
   20703             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   20704             :     // User wants multi-thread support and POSIX threads are available.
   20705             : #   include <pthread.h>
   20706             :     static pthread_mutex_t SgTypeSignedLong_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   20707             : #else
   20708             :      // Cause synchronization to be skipped.
   20709             : #    ifndef ALLOC_MUTEX
   20710             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   20711             : #    endif
   20712             : #    ifdef _REENTRANT
   20713             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   20714             : #       ifdef _MSC_VER
   20715             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   20716             : #       else
   20717             : #           warning "POSIX threads are not available; synchronization being skipped"
   20718             : #       endif
   20719             : #    endif
   20720             : #endif
   20721             : 
   20722             : #ifndef ROSE_ALLOC_TRACE
   20723             : #  define ROSE_ALLOC_TRACE 0
   20724             : #endif
   20725             : 
   20726             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   20727             : #define ROSE_ALLOC_TRACE_CNT
   20728             : #include "memory-pool-snapshot.h"
   20729             : unsigned long alloc_trace_cnt = 0;
   20730             : #endif
   20731             : 
   20732             : #if ROSE_ALLOC_TRACE
   20733             : const unsigned SgTypeSignedLong::pool_size = 5;
   20734             : #else
   20735             : const unsigned SgTypeSignedLong::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   20736             : #endif
   20737             : 
   20738             : #ifndef ROSE_ALLOC_MEMSET
   20739             : #  define ROSE_ALLOC_MEMSET 0
   20740             : #endif
   20741             : 
   20742             : #ifndef ROSE_PEDANTIC_ALLOC
   20743             : #  define ROSE_PEDANTIC_ALLOC 0
   20744             : #endif
   20745             : 
   20746             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   20747             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   20748             : #endif
   20749             : 
   20750             : #if !defined(SGNODE__ALL_POOLS)
   20751             : #define SGNODE__ALL_POOLS
   20752             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   20753             : #endif
   20754             : 
   20755             : SgTypeSignedLong* SgTypeSignedLong::next_node = nullptr;
   20756             : std::vector<unsigned char*> SgTypeSignedLong::pools;
   20757             : 
   20758             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   20759             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   20760             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   20761             : // around this macro definition rather than each use).
   20762             : #ifndef ALLOC_MUTEX
   20763             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   20764             :         do {                                                                     \
   20765             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   20766             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   20767             :                 abort();                                                         \
   20768             :             }                                                                    \
   20769             :         } while (0);
   20770             : #endif
   20771             : 
   20772             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   20773             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   20774             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   20775             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   20776             : 
   20777             : /*! \brief New operator for SgTypeSignedLong.
   20778             : 
   20779             :    This new operator implements memory pools to provide most efficent 
   20780             :    use of the heap within construction of large ASTs.
   20781             : 
   20782             : \internal The new and delete operators use the lower level C malloc/free
   20783             :    function calls for performance and to make sure that mixing of malloc/free
   20784             :    and new/delete by the used can be caught more readily.  This may change
   20785             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   20786             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   20787             :    deallocate memory allocated using ROSE_MALLOC.
   20788             : */
   20789         200 : void *SgTypeSignedLong::operator new ( size_t Size )
   20790             : {
   20791             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   20792             :      * returning or throwing an exception. */
   20793         200 :     ALLOC_MUTEX(SgTypeSignedLong, lock);
   20794             : 
   20795             : #if ROSE_ALLOC_TRACE == 2
   20796             : //    printf("SgTypeSignedLong::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgTypeSignedLong::next_node);
   20797             : #endif
   20798             : 
   20799             : #if USE_CPP_NEW_DELETE_OPERATORS
   20800             :     void *mem = ROSE_MALLOC(Size);
   20801             :     ALLOC_MUTEX(SgTypeSignedLong, unlock);
   20802             :     return mem;
   20803             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   20804             : #if ROSE_PEDANTIC_ALLOC
   20805             :     ROSE_ASSERT(Size == sizeof(SgTypeSignedLong));
   20806             : #else
   20807         200 :     if (Size != sizeof(SgTypeSignedLong)) {
   20808           0 :       void * object = ROSE_MALLOC(Size);
   20809           0 :       ALLOC_MUTEX(SgTypeSignedLong, unlock);
   20810             :       return object;
   20811             :     }
   20812             : #endif
   20813             : 
   20814         200 :     if (SgTypeSignedLong::next_node == nullptr) {
   20815         198 :         SgTypeSignedLong * alloc = (SgTypeSignedLong*) ROSE_MALLOC ( SgTypeSignedLong::pool_size * sizeof(SgTypeSignedLong) );
   20816         198 :         ROSE_ASSERT(alloc != nullptr);
   20817             : 
   20818             : #if ROSE_ALLOC_TRACE == 2
   20819             : //        printf("SgTypeSignedLong::alloc\n  block[%zi] = [ %p , %p [\n", SgTypeSignedLong::pools.size(), alloc, alloc + SgTypeSignedLong::pool_size);
   20820             : #endif
   20821             : 
   20822             : #if ROSE_ALLOC_MEMSET == 1
   20823             : #elif ROSE_ALLOC_MEMSET == 2
   20824             :         memset(alloc, 0x00, SgTypeSignedLong::pool_size * sizeof(SgTypeSignedLong));
   20825             : #elif ROSE_ALLOC_MEMSET == 3
   20826             :         memset(alloc, 0xAA, SgTypeSignedLong::pool_size * sizeof(SgTypeSignedLong));
   20827             : #endif
   20828      396000 :         for (unsigned i=0; i < SgTypeSignedLong::pool_size-1; i++) {
   20829      395802 :           alloc[i].p_freepointer = &(alloc[i+1]);
   20830             :         }
   20831         198 :         alloc[SgTypeSignedLong::pool_size-1].p_freepointer = nullptr;
   20832             : 
   20833         198 :         SgTypeSignedLong::pools.push_back ( (unsigned char *) alloc );
   20834         198 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgTypeSignedLong::pool_size * sizeof(SgTypeSignedLong), V_SgTypeSignedLong ) );
   20835         198 :         SgTypeSignedLong::next_node = alloc;
   20836             :     }
   20837         200 :     ROSE_ASSERT(SgTypeSignedLong::next_node != nullptr);
   20838             : 
   20839         200 :     SgTypeSignedLong * object = SgTypeSignedLong::next_node;
   20840         200 :     SgTypeSignedLong::next_node = (SgTypeSignedLong*)(object->p_freepointer);
   20841             : 
   20842             : #if ROSE_ALLOC_TRACE == 2
   20843             :     printf("SgTypeSignedLong::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeSignedLong::next_node);
   20844             : #endif
   20845             : 
   20846         200 :     SgNode * fp = object->p_freepointer;
   20847             : #if ROSE_ALLOC_MEMSET == 1
   20848             : #elif ROSE_ALLOC_MEMSET == 2
   20849             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgTypeSignedLong) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   20850             : #elif ROSE_ALLOC_MEMSET == 3
   20851             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgTypeSignedLong) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   20852             : #endif
   20853         200 :     object->p_freepointer = fp;
   20854             : 
   20855             : #if ROSE_ALLOC_TRACE == 2
   20856             : //    printf("SgTypeSignedLong::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeSignedLong::next_node);
   20857             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   20858             :     Rose::MemPool::snapshot(oss.str());
   20859             :     alloc_trace_cnt++;
   20860             : #endif
   20861             : 
   20862         200 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   20863             : 
   20864         200 :     ALLOC_MUTEX(SgTypeSignedLong, unlock);
   20865             : 
   20866             :     return object;
   20867             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   20868             : }
   20869             : 
   20870             : 
   20871             : 
   20872             : /*! \brief Delete operator for SgTypeSignedLong.
   20873             : 
   20874             :    This delete operator implements deallocation using memory pools to 
   20875             :    provide most efficent use of the heap within construction of large ASTs.
   20876             : 
   20877             : \internal The new and delete operators use the lower level C malloc/free
   20878             :    function calls for performance and to make sure that mixing of malloc/free
   20879             :    and new/delete by the used can be caught more readily.  This may change
   20880             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   20881             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   20882             :    deallocate memory allocated using ROSE_MALLOC.
   20883             : */
   20884           4 : void SgTypeSignedLong::operator delete(void *Pointer, size_t Size)
   20885             : {
   20886             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   20887             :      * or throwing an exception. */
   20888           4 :     ALLOC_MUTEX(SgTypeSignedLong, lock);
   20889             : 
   20890             : #if USE_CPP_NEW_DELETE_OPERATORS
   20891             :     ROSE_FREE(Pointer);
   20892             : #else
   20893             : #if ROSE_PEDANTIC_ALLOC
   20894             :     ROSE_ASSERT(Size == sizeof(SgTypeSignedLong));
   20895             : #else
   20896           4 :     if (Size != sizeof(SgTypeSignedLong)) {
   20897           0 :       ROSE_FREE(Pointer);
   20898           0 :       ALLOC_MUTEX(SgTypeSignedLong, unlock);
   20899             :       return;
   20900             :     }
   20901             : #endif
   20902             : 
   20903           4 :     SgTypeSignedLong * object = (SgTypeSignedLong*) Pointer;
   20904           4 :     ROSE_ASSERT(object != nullptr);
   20905             : 
   20906             : #if ROSE_ALLOC_TRACE == 2
   20907             : //  printf("SgTypeSignedLong::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeSignedLong::next_node);
   20908             :     printf("SgTypeSignedLong::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeSignedLong::next_node);
   20909             : #endif
   20910             : 
   20911             : #if ROSE_PEDANTIC_ALLOC
   20912             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   20913             : #endif
   20914             : 
   20915             : #if ROSE_ALLOC_MEMSET == 1
   20916             : #elif ROSE_ALLOC_MEMSET == 2
   20917             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgTypeSignedLong) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   20918             : #elif ROSE_ALLOC_MEMSET == 3
   20919             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgTypeSignedLong) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   20920             : #endif
   20921             : 
   20922             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   20923             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   20924             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   20925             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   20926             : #else
   20927           4 :     object->p_freepointer = SgTypeSignedLong::next_node;
   20928           4 :     SgTypeSignedLong::next_node = object;
   20929             : #endif
   20930             : 
   20931             : #if ROSE_ALLOC_TRACE == 2
   20932             : //  printf("SgTypeSignedLong::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeSignedLong::next_node);
   20933             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   20934             :     Rose::MemPool::snapshot(oss.str());
   20935             :     alloc_trace_cnt++;
   20936             : #endif
   20937             : 
   20938             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   20939             : 
   20940           4 :     ALLOC_MUTEX(SgTypeSignedLong, unlock);
   20941             : }
   20942             : 
   20943             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   20944             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   20945             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   20946             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   20947             : // Also, note comment below from Robb (copied from the Common.code file).
   20948             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   20949             : //
   20950             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   20951             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   20952             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   20953             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   20954             : #if 0
   20955             : void SgTypeSignedLong::operator delete(void* pointer) { SgTypeSignedLong::operator delete (pointer, sizeof(SgTypeSignedLong)); };
   20956             : #endif
   20957             : /* #line 20958 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   20958             : 
   20959             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   20960             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   20961             : // obviously imply C++.
   20962             : 
   20963             : // This implements the support within ROSE for memory pools.  Memory pools
   20964             : // support the most condensed usage of memory within the construction of
   20965             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   20966             : // by a new operator written for each class.
   20967             : 
   20968             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   20969             :     // User wants multi-thread support and POSIX threads are available.
   20970             : #   include <pthread.h>
   20971             :     static pthread_mutex_t SgTypeUnsignedLong_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   20972             : #else
   20973             :      // Cause synchronization to be skipped.
   20974             : #    ifndef ALLOC_MUTEX
   20975             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   20976             : #    endif
   20977             : #    ifdef _REENTRANT
   20978             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   20979             : #       ifdef _MSC_VER
   20980             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   20981             : #       else
   20982             : #           warning "POSIX threads are not available; synchronization being skipped"
   20983             : #       endif
   20984             : #    endif
   20985             : #endif
   20986             : 
   20987             : #ifndef ROSE_ALLOC_TRACE
   20988             : #  define ROSE_ALLOC_TRACE 0
   20989             : #endif
   20990             : 
   20991             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   20992             : #define ROSE_ALLOC_TRACE_CNT
   20993             : #include "memory-pool-snapshot.h"
   20994             : unsigned long alloc_trace_cnt = 0;
   20995             : #endif
   20996             : 
   20997             : #if ROSE_ALLOC_TRACE
   20998             : const unsigned SgTypeUnsignedLong::pool_size = 5;
   20999             : #else
   21000             : const unsigned SgTypeUnsignedLong::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   21001             : #endif
   21002             : 
   21003             : #ifndef ROSE_ALLOC_MEMSET
   21004             : #  define ROSE_ALLOC_MEMSET 0
   21005             : #endif
   21006             : 
   21007             : #ifndef ROSE_PEDANTIC_ALLOC
   21008             : #  define ROSE_PEDANTIC_ALLOC 0
   21009             : #endif
   21010             : 
   21011             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   21012             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   21013             : #endif
   21014             : 
   21015             : #if !defined(SGNODE__ALL_POOLS)
   21016             : #define SGNODE__ALL_POOLS
   21017             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   21018             : #endif
   21019             : 
   21020             : SgTypeUnsignedLong* SgTypeUnsignedLong::next_node = nullptr;
   21021             : std::vector<unsigned char*> SgTypeUnsignedLong::pools;
   21022             : 
   21023             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   21024             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   21025             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   21026             : // around this macro definition rather than each use).
   21027             : #ifndef ALLOC_MUTEX
   21028             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   21029             :         do {                                                                     \
   21030             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   21031             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   21032             :                 abort();                                                         \
   21033             :             }                                                                    \
   21034             :         } while (0);
   21035             : #endif
   21036             : 
   21037             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   21038             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   21039             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   21040             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   21041             : 
   21042             : /*! \brief New operator for SgTypeUnsignedLong.
   21043             : 
   21044             :    This new operator implements memory pools to provide most efficent 
   21045             :    use of the heap within construction of large ASTs.
   21046             : 
   21047             : \internal The new and delete operators use the lower level C malloc/free
   21048             :    function calls for performance and to make sure that mixing of malloc/free
   21049             :    and new/delete by the used can be caught more readily.  This may change
   21050             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   21051             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   21052             :    deallocate memory allocated using ROSE_MALLOC.
   21053             : */
   21054        1097 : void *SgTypeUnsignedLong::operator new ( size_t Size )
   21055             : {
   21056             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   21057             :      * returning or throwing an exception. */
   21058        1097 :     ALLOC_MUTEX(SgTypeUnsignedLong, lock);
   21059             : 
   21060             : #if ROSE_ALLOC_TRACE == 2
   21061             : //    printf("SgTypeUnsignedLong::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgTypeUnsignedLong::next_node);
   21062             : #endif
   21063             : 
   21064             : #if USE_CPP_NEW_DELETE_OPERATORS
   21065             :     void *mem = ROSE_MALLOC(Size);
   21066             :     ALLOC_MUTEX(SgTypeUnsignedLong, unlock);
   21067             :     return mem;
   21068             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   21069             : #if ROSE_PEDANTIC_ALLOC
   21070             :     ROSE_ASSERT(Size == sizeof(SgTypeUnsignedLong));
   21071             : #else
   21072        1097 :     if (Size != sizeof(SgTypeUnsignedLong)) {
   21073           0 :       void * object = ROSE_MALLOC(Size);
   21074           0 :       ALLOC_MUTEX(SgTypeUnsignedLong, unlock);
   21075             :       return object;
   21076             :     }
   21077             : #endif
   21078             : 
   21079        1097 :     if (SgTypeUnsignedLong::next_node == nullptr) {
   21080         315 :         SgTypeUnsignedLong * alloc = (SgTypeUnsignedLong*) ROSE_MALLOC ( SgTypeUnsignedLong::pool_size * sizeof(SgTypeUnsignedLong) );
   21081         315 :         ROSE_ASSERT(alloc != nullptr);
   21082             : 
   21083             : #if ROSE_ALLOC_TRACE == 2
   21084             : //        printf("SgTypeUnsignedLong::alloc\n  block[%zi] = [ %p , %p [\n", SgTypeUnsignedLong::pools.size(), alloc, alloc + SgTypeUnsignedLong::pool_size);
   21085             : #endif
   21086             : 
   21087             : #if ROSE_ALLOC_MEMSET == 1
   21088             : #elif ROSE_ALLOC_MEMSET == 2
   21089             :         memset(alloc, 0x00, SgTypeUnsignedLong::pool_size * sizeof(SgTypeUnsignedLong));
   21090             : #elif ROSE_ALLOC_MEMSET == 3
   21091             :         memset(alloc, 0xAA, SgTypeUnsignedLong::pool_size * sizeof(SgTypeUnsignedLong));
   21092             : #endif
   21093      630000 :         for (unsigned i=0; i < SgTypeUnsignedLong::pool_size-1; i++) {
   21094      629685 :           alloc[i].p_freepointer = &(alloc[i+1]);
   21095             :         }
   21096         315 :         alloc[SgTypeUnsignedLong::pool_size-1].p_freepointer = nullptr;
   21097             : 
   21098         315 :         SgTypeUnsignedLong::pools.push_back ( (unsigned char *) alloc );
   21099         315 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgTypeUnsignedLong::pool_size * sizeof(SgTypeUnsignedLong), V_SgTypeUnsignedLong ) );
   21100         315 :         SgTypeUnsignedLong::next_node = alloc;
   21101             :     }
   21102        1097 :     ROSE_ASSERT(SgTypeUnsignedLong::next_node != nullptr);
   21103             : 
   21104        1097 :     SgTypeUnsignedLong * object = SgTypeUnsignedLong::next_node;
   21105        1097 :     SgTypeUnsignedLong::next_node = (SgTypeUnsignedLong*)(object->p_freepointer);
   21106             : 
   21107             : #if ROSE_ALLOC_TRACE == 2
   21108             :     printf("SgTypeUnsignedLong::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeUnsignedLong::next_node);
   21109             : #endif
   21110             : 
   21111        1097 :     SgNode * fp = object->p_freepointer;
   21112             : #if ROSE_ALLOC_MEMSET == 1
   21113             : #elif ROSE_ALLOC_MEMSET == 2
   21114             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgTypeUnsignedLong) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   21115             : #elif ROSE_ALLOC_MEMSET == 3
   21116             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgTypeUnsignedLong) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   21117             : #endif
   21118        1097 :     object->p_freepointer = fp;
   21119             : 
   21120             : #if ROSE_ALLOC_TRACE == 2
   21121             : //    printf("SgTypeUnsignedLong::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeUnsignedLong::next_node);
   21122             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   21123             :     Rose::MemPool::snapshot(oss.str());
   21124             :     alloc_trace_cnt++;
   21125             : #endif
   21126             : 
   21127        1097 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   21128             : 
   21129        1097 :     ALLOC_MUTEX(SgTypeUnsignedLong, unlock);
   21130             : 
   21131             :     return object;
   21132             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   21133             : }
   21134             : 
   21135             : 
   21136             : 
   21137             : /*! \brief Delete operator for SgTypeUnsignedLong.
   21138             : 
   21139             :    This delete operator implements deallocation using memory pools to 
   21140             :    provide most efficent use of the heap within construction of large ASTs.
   21141             : 
   21142             : \internal The new and delete operators use the lower level C malloc/free
   21143             :    function calls for performance and to make sure that mixing of malloc/free
   21144             :    and new/delete by the used can be caught more readily.  This may change
   21145             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   21146             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   21147             :    deallocate memory allocated using ROSE_MALLOC.
   21148             : */
   21149         784 : void SgTypeUnsignedLong::operator delete(void *Pointer, size_t Size)
   21150             : {
   21151             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   21152             :      * or throwing an exception. */
   21153         784 :     ALLOC_MUTEX(SgTypeUnsignedLong, lock);
   21154             : 
   21155             : #if USE_CPP_NEW_DELETE_OPERATORS
   21156             :     ROSE_FREE(Pointer);
   21157             : #else
   21158             : #if ROSE_PEDANTIC_ALLOC
   21159             :     ROSE_ASSERT(Size == sizeof(SgTypeUnsignedLong));
   21160             : #else
   21161         784 :     if (Size != sizeof(SgTypeUnsignedLong)) {
   21162           0 :       ROSE_FREE(Pointer);
   21163           0 :       ALLOC_MUTEX(SgTypeUnsignedLong, unlock);
   21164             :       return;
   21165             :     }
   21166             : #endif
   21167             : 
   21168         784 :     SgTypeUnsignedLong * object = (SgTypeUnsignedLong*) Pointer;
   21169         784 :     ROSE_ASSERT(object != nullptr);
   21170             : 
   21171             : #if ROSE_ALLOC_TRACE == 2
   21172             : //  printf("SgTypeUnsignedLong::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeUnsignedLong::next_node);
   21173             :     printf("SgTypeUnsignedLong::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeUnsignedLong::next_node);
   21174             : #endif
   21175             : 
   21176             : #if ROSE_PEDANTIC_ALLOC
   21177             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   21178             : #endif
   21179             : 
   21180             : #if ROSE_ALLOC_MEMSET == 1
   21181             : #elif ROSE_ALLOC_MEMSET == 2
   21182             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgTypeUnsignedLong) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   21183             : #elif ROSE_ALLOC_MEMSET == 3
   21184             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgTypeUnsignedLong) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   21185             : #endif
   21186             : 
   21187             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   21188             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   21189             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   21190             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   21191             : #else
   21192         784 :     object->p_freepointer = SgTypeUnsignedLong::next_node;
   21193         784 :     SgTypeUnsignedLong::next_node = object;
   21194             : #endif
   21195             : 
   21196             : #if ROSE_ALLOC_TRACE == 2
   21197             : //  printf("SgTypeUnsignedLong::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeUnsignedLong::next_node);
   21198             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   21199             :     Rose::MemPool::snapshot(oss.str());
   21200             :     alloc_trace_cnt++;
   21201             : #endif
   21202             : 
   21203             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   21204             : 
   21205         784 :     ALLOC_MUTEX(SgTypeUnsignedLong, unlock);
   21206             : }
   21207             : 
   21208             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   21209             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   21210             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   21211             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   21212             : // Also, note comment below from Robb (copied from the Common.code file).
   21213             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   21214             : //
   21215             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   21216             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   21217             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   21218             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   21219             : #if 0
   21220             : void SgTypeUnsignedLong::operator delete(void* pointer) { SgTypeUnsignedLong::operator delete (pointer, sizeof(SgTypeUnsignedLong)); };
   21221             : #endif
   21222             : /* #line 21223 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   21223             : 
   21224             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   21225             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   21226             : // obviously imply C++.
   21227             : 
   21228             : // This implements the support within ROSE for memory pools.  Memory pools
   21229             : // support the most condensed usage of memory within the construction of
   21230             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   21231             : // by a new operator written for each class.
   21232             : 
   21233             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   21234             :     // User wants multi-thread support and POSIX threads are available.
   21235             : #   include <pthread.h>
   21236             :     static pthread_mutex_t SgTypeVoid_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   21237             : #else
   21238             :      // Cause synchronization to be skipped.
   21239             : #    ifndef ALLOC_MUTEX
   21240             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   21241             : #    endif
   21242             : #    ifdef _REENTRANT
   21243             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   21244             : #       ifdef _MSC_VER
   21245             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   21246             : #       else
   21247             : #           warning "POSIX threads are not available; synchronization being skipped"
   21248             : #       endif
   21249             : #    endif
   21250             : #endif
   21251             : 
   21252             : #ifndef ROSE_ALLOC_TRACE
   21253             : #  define ROSE_ALLOC_TRACE 0
   21254             : #endif
   21255             : 
   21256             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   21257             : #define ROSE_ALLOC_TRACE_CNT
   21258             : #include "memory-pool-snapshot.h"
   21259             : unsigned long alloc_trace_cnt = 0;
   21260             : #endif
   21261             : 
   21262             : #if ROSE_ALLOC_TRACE
   21263             : const unsigned SgTypeVoid::pool_size = 5;
   21264             : #else
   21265             : const unsigned SgTypeVoid::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   21266             : #endif
   21267             : 
   21268             : #ifndef ROSE_ALLOC_MEMSET
   21269             : #  define ROSE_ALLOC_MEMSET 0
   21270             : #endif
   21271             : 
   21272             : #ifndef ROSE_PEDANTIC_ALLOC
   21273             : #  define ROSE_PEDANTIC_ALLOC 0
   21274             : #endif
   21275             : 
   21276             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   21277             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   21278             : #endif
   21279             : 
   21280             : #if !defined(SGNODE__ALL_POOLS)
   21281             : #define SGNODE__ALL_POOLS
   21282             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   21283             : #endif
   21284             : 
   21285             : SgTypeVoid* SgTypeVoid::next_node = nullptr;
   21286             : std::vector<unsigned char*> SgTypeVoid::pools;
   21287             : 
   21288             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   21289             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   21290             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   21291             : // around this macro definition rather than each use).
   21292             : #ifndef ALLOC_MUTEX
   21293             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   21294             :         do {                                                                     \
   21295             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   21296             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   21297             :                 abort();                                                         \
   21298             :             }                                                                    \
   21299             :         } while (0);
   21300             : #endif
   21301             : 
   21302             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   21303             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   21304             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   21305             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   21306             : 
   21307             : /*! \brief New operator for SgTypeVoid.
   21308             : 
   21309             :    This new operator implements memory pools to provide most efficent 
   21310             :    use of the heap within construction of large ASTs.
   21311             : 
   21312             : \internal The new and delete operators use the lower level C malloc/free
   21313             :    function calls for performance and to make sure that mixing of malloc/free
   21314             :    and new/delete by the used can be caught more readily.  This may change
   21315             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   21316             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   21317             :    deallocate memory allocated using ROSE_MALLOC.
   21318             : */
   21319         940 : void *SgTypeVoid::operator new ( size_t Size )
   21320             : {
   21321             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   21322             :      * returning or throwing an exception. */
   21323         940 :     ALLOC_MUTEX(SgTypeVoid, lock);
   21324             : 
   21325             : #if ROSE_ALLOC_TRACE == 2
   21326             : //    printf("SgTypeVoid::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgTypeVoid::next_node);
   21327             : #endif
   21328             : 
   21329             : #if USE_CPP_NEW_DELETE_OPERATORS
   21330             :     void *mem = ROSE_MALLOC(Size);
   21331             :     ALLOC_MUTEX(SgTypeVoid, unlock);
   21332             :     return mem;
   21333             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   21334             : #if ROSE_PEDANTIC_ALLOC
   21335             :     ROSE_ASSERT(Size == sizeof(SgTypeVoid));
   21336             : #else
   21337         940 :     if (Size != sizeof(SgTypeVoid)) {
   21338           0 :       void * object = ROSE_MALLOC(Size);
   21339           0 :       ALLOC_MUTEX(SgTypeVoid, unlock);
   21340             :       return object;
   21341             :     }
   21342             : #endif
   21343             : 
   21344         940 :     if (SgTypeVoid::next_node == nullptr) {
   21345         351 :         SgTypeVoid * alloc = (SgTypeVoid*) ROSE_MALLOC ( SgTypeVoid::pool_size * sizeof(SgTypeVoid) );
   21346         351 :         ROSE_ASSERT(alloc != nullptr);
   21347             : 
   21348             : #if ROSE_ALLOC_TRACE == 2
   21349             : //        printf("SgTypeVoid::alloc\n  block[%zi] = [ %p , %p [\n", SgTypeVoid::pools.size(), alloc, alloc + SgTypeVoid::pool_size);
   21350             : #endif
   21351             : 
   21352             : #if ROSE_ALLOC_MEMSET == 1
   21353             : #elif ROSE_ALLOC_MEMSET == 2
   21354             :         memset(alloc, 0x00, SgTypeVoid::pool_size * sizeof(SgTypeVoid));
   21355             : #elif ROSE_ALLOC_MEMSET == 3
   21356             :         memset(alloc, 0xAA, SgTypeVoid::pool_size * sizeof(SgTypeVoid));
   21357             : #endif
   21358      702000 :         for (unsigned i=0; i < SgTypeVoid::pool_size-1; i++) {
   21359      701649 :           alloc[i].p_freepointer = &(alloc[i+1]);
   21360             :         }
   21361         351 :         alloc[SgTypeVoid::pool_size-1].p_freepointer = nullptr;
   21362             : 
   21363         351 :         SgTypeVoid::pools.push_back ( (unsigned char *) alloc );
   21364         351 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgTypeVoid::pool_size * sizeof(SgTypeVoid), V_SgTypeVoid ) );
   21365         351 :         SgTypeVoid::next_node = alloc;
   21366             :     }
   21367         940 :     ROSE_ASSERT(SgTypeVoid::next_node != nullptr);
   21368             : 
   21369         940 :     SgTypeVoid * object = SgTypeVoid::next_node;
   21370         940 :     SgTypeVoid::next_node = (SgTypeVoid*)(object->p_freepointer);
   21371             : 
   21372             : #if ROSE_ALLOC_TRACE == 2
   21373             :     printf("SgTypeVoid::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeVoid::next_node);
   21374             : #endif
   21375             : 
   21376         940 :     SgNode * fp = object->p_freepointer;
   21377             : #if ROSE_ALLOC_MEMSET == 1
   21378             : #elif ROSE_ALLOC_MEMSET == 2
   21379             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgTypeVoid) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   21380             : #elif ROSE_ALLOC_MEMSET == 3
   21381             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgTypeVoid) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   21382             : #endif
   21383         940 :     object->p_freepointer = fp;
   21384             : 
   21385             : #if ROSE_ALLOC_TRACE == 2
   21386             : //    printf("SgTypeVoid::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeVoid::next_node);
   21387             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   21388             :     Rose::MemPool::snapshot(oss.str());
   21389             :     alloc_trace_cnt++;
   21390             : #endif
   21391             : 
   21392         940 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   21393             : 
   21394         940 :     ALLOC_MUTEX(SgTypeVoid, unlock);
   21395             : 
   21396             :     return object;
   21397             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   21398             : }
   21399             : 
   21400             : 
   21401             : 
   21402             : /*! \brief Delete operator for SgTypeVoid.
   21403             : 
   21404             :    This delete operator implements deallocation using memory pools to 
   21405             :    provide most efficent use of the heap within construction of large ASTs.
   21406             : 
   21407             : \internal The new and delete operators use the lower level C malloc/free
   21408             :    function calls for performance and to make sure that mixing of malloc/free
   21409             :    and new/delete by the used can be caught more readily.  This may change
   21410             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   21411             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   21412             :    deallocate memory allocated using ROSE_MALLOC.
   21413             : */
   21414         592 : void SgTypeVoid::operator delete(void *Pointer, size_t Size)
   21415             : {
   21416             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   21417             :      * or throwing an exception. */
   21418         592 :     ALLOC_MUTEX(SgTypeVoid, lock);
   21419             : 
   21420             : #if USE_CPP_NEW_DELETE_OPERATORS
   21421             :     ROSE_FREE(Pointer);
   21422             : #else
   21423             : #if ROSE_PEDANTIC_ALLOC
   21424             :     ROSE_ASSERT(Size == sizeof(SgTypeVoid));
   21425             : #else
   21426         592 :     if (Size != sizeof(SgTypeVoid)) {
   21427           0 :       ROSE_FREE(Pointer);
   21428           0 :       ALLOC_MUTEX(SgTypeVoid, unlock);
   21429             :       return;
   21430             :     }
   21431             : #endif
   21432             : 
   21433         592 :     SgTypeVoid * object = (SgTypeVoid*) Pointer;
   21434         592 :     ROSE_ASSERT(object != nullptr);
   21435             : 
   21436             : #if ROSE_ALLOC_TRACE == 2
   21437             : //  printf("SgTypeVoid::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeVoid::next_node);
   21438             :     printf("SgTypeVoid::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeVoid::next_node);
   21439             : #endif
   21440             : 
   21441             : #if ROSE_PEDANTIC_ALLOC
   21442             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   21443             : #endif
   21444             : 
   21445             : #if ROSE_ALLOC_MEMSET == 1
   21446             : #elif ROSE_ALLOC_MEMSET == 2
   21447             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgTypeVoid) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   21448             : #elif ROSE_ALLOC_MEMSET == 3
   21449             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgTypeVoid) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   21450             : #endif
   21451             : 
   21452             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   21453             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   21454             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   21455             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   21456             : #else
   21457         592 :     object->p_freepointer = SgTypeVoid::next_node;
   21458         592 :     SgTypeVoid::next_node = object;
   21459             : #endif
   21460             : 
   21461             : #if ROSE_ALLOC_TRACE == 2
   21462             : //  printf("SgTypeVoid::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeVoid::next_node);
   21463             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   21464             :     Rose::MemPool::snapshot(oss.str());
   21465             :     alloc_trace_cnt++;
   21466             : #endif
   21467             : 
   21468             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   21469             : 
   21470         592 :     ALLOC_MUTEX(SgTypeVoid, unlock);
   21471             : }
   21472             : 
   21473             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   21474             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   21475             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   21476             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   21477             : // Also, note comment below from Robb (copied from the Common.code file).
   21478             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   21479             : //
   21480             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   21481             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   21482             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   21483             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   21484             : #if 0
   21485             : void SgTypeVoid::operator delete(void* pointer) { SgTypeVoid::operator delete (pointer, sizeof(SgTypeVoid)); };
   21486             : #endif
   21487             : /* #line 21488 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   21488             : 
   21489             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   21490             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   21491             : // obviously imply C++.
   21492             : 
   21493             : // This implements the support within ROSE for memory pools.  Memory pools
   21494             : // support the most condensed usage of memory within the construction of
   21495             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   21496             : // by a new operator written for each class.
   21497             : 
   21498             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   21499             :     // User wants multi-thread support and POSIX threads are available.
   21500             : #   include <pthread.h>
   21501             :     static pthread_mutex_t SgTypeGlobalVoid_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   21502             : #else
   21503             :      // Cause synchronization to be skipped.
   21504             : #    ifndef ALLOC_MUTEX
   21505             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   21506             : #    endif
   21507             : #    ifdef _REENTRANT
   21508             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   21509             : #       ifdef _MSC_VER
   21510             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   21511             : #       else
   21512             : #           warning "POSIX threads are not available; synchronization being skipped"
   21513             : #       endif
   21514             : #    endif
   21515             : #endif
   21516             : 
   21517             : #ifndef ROSE_ALLOC_TRACE
   21518             : #  define ROSE_ALLOC_TRACE 0
   21519             : #endif
   21520             : 
   21521             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   21522             : #define ROSE_ALLOC_TRACE_CNT
   21523             : #include "memory-pool-snapshot.h"
   21524             : unsigned long alloc_trace_cnt = 0;
   21525             : #endif
   21526             : 
   21527             : #if ROSE_ALLOC_TRACE
   21528             : const unsigned SgTypeGlobalVoid::pool_size = 5;
   21529             : #else
   21530             : const unsigned SgTypeGlobalVoid::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   21531             : #endif
   21532             : 
   21533             : #ifndef ROSE_ALLOC_MEMSET
   21534             : #  define ROSE_ALLOC_MEMSET 0
   21535             : #endif
   21536             : 
   21537             : #ifndef ROSE_PEDANTIC_ALLOC
   21538             : #  define ROSE_PEDANTIC_ALLOC 0
   21539             : #endif
   21540             : 
   21541             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   21542             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   21543             : #endif
   21544             : 
   21545             : #if !defined(SGNODE__ALL_POOLS)
   21546             : #define SGNODE__ALL_POOLS
   21547             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   21548             : #endif
   21549             : 
   21550             : SgTypeGlobalVoid* SgTypeGlobalVoid::next_node = nullptr;
   21551             : std::vector<unsigned char*> SgTypeGlobalVoid::pools;
   21552             : 
   21553             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   21554             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   21555             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   21556             : // around this macro definition rather than each use).
   21557             : #ifndef ALLOC_MUTEX
   21558             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   21559             :         do {                                                                     \
   21560             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   21561             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   21562             :                 abort();                                                         \
   21563             :             }                                                                    \
   21564             :         } while (0);
   21565             : #endif
   21566             : 
   21567             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   21568             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   21569             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   21570             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   21571             : 
   21572             : /*! \brief New operator for SgTypeGlobalVoid.
   21573             : 
   21574             :    This new operator implements memory pools to provide most efficent 
   21575             :    use of the heap within construction of large ASTs.
   21576             : 
   21577             : \internal The new and delete operators use the lower level C malloc/free
   21578             :    function calls for performance and to make sure that mixing of malloc/free
   21579             :    and new/delete by the used can be caught more readily.  This may change
   21580             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   21581             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   21582             :    deallocate memory allocated using ROSE_MALLOC.
   21583             : */
   21584           0 : void *SgTypeGlobalVoid::operator new ( size_t Size )
   21585             : {
   21586             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   21587             :      * returning or throwing an exception. */
   21588           0 :     ALLOC_MUTEX(SgTypeGlobalVoid, lock);
   21589             : 
   21590             : #if ROSE_ALLOC_TRACE == 2
   21591             : //    printf("SgTypeGlobalVoid::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgTypeGlobalVoid::next_node);
   21592             : #endif
   21593             : 
   21594             : #if USE_CPP_NEW_DELETE_OPERATORS
   21595             :     void *mem = ROSE_MALLOC(Size);
   21596             :     ALLOC_MUTEX(SgTypeGlobalVoid, unlock);
   21597             :     return mem;
   21598             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   21599             : #if ROSE_PEDANTIC_ALLOC
   21600             :     ROSE_ASSERT(Size == sizeof(SgTypeGlobalVoid));
   21601             : #else
   21602           0 :     if (Size != sizeof(SgTypeGlobalVoid)) {
   21603           0 :       void * object = ROSE_MALLOC(Size);
   21604           0 :       ALLOC_MUTEX(SgTypeGlobalVoid, unlock);
   21605             :       return object;
   21606             :     }
   21607             : #endif
   21608             : 
   21609           0 :     if (SgTypeGlobalVoid::next_node == nullptr) {
   21610           0 :         SgTypeGlobalVoid * alloc = (SgTypeGlobalVoid*) ROSE_MALLOC ( SgTypeGlobalVoid::pool_size * sizeof(SgTypeGlobalVoid) );
   21611           0 :         ROSE_ASSERT(alloc != nullptr);
   21612             : 
   21613             : #if ROSE_ALLOC_TRACE == 2
   21614             : //        printf("SgTypeGlobalVoid::alloc\n  block[%zi] = [ %p , %p [\n", SgTypeGlobalVoid::pools.size(), alloc, alloc + SgTypeGlobalVoid::pool_size);
   21615             : #endif
   21616             : 
   21617             : #if ROSE_ALLOC_MEMSET == 1
   21618             : #elif ROSE_ALLOC_MEMSET == 2
   21619             :         memset(alloc, 0x00, SgTypeGlobalVoid::pool_size * sizeof(SgTypeGlobalVoid));
   21620             : #elif ROSE_ALLOC_MEMSET == 3
   21621             :         memset(alloc, 0xAA, SgTypeGlobalVoid::pool_size * sizeof(SgTypeGlobalVoid));
   21622             : #endif
   21623           0 :         for (unsigned i=0; i < SgTypeGlobalVoid::pool_size-1; i++) {
   21624           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
   21625             :         }
   21626           0 :         alloc[SgTypeGlobalVoid::pool_size-1].p_freepointer = nullptr;
   21627             : 
   21628           0 :         SgTypeGlobalVoid::pools.push_back ( (unsigned char *) alloc );
   21629           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgTypeGlobalVoid::pool_size * sizeof(SgTypeGlobalVoid), V_SgTypeGlobalVoid ) );
   21630           0 :         SgTypeGlobalVoid::next_node = alloc;
   21631             :     }
   21632           0 :     ROSE_ASSERT(SgTypeGlobalVoid::next_node != nullptr);
   21633             : 
   21634           0 :     SgTypeGlobalVoid * object = SgTypeGlobalVoid::next_node;
   21635           0 :     SgTypeGlobalVoid::next_node = (SgTypeGlobalVoid*)(object->p_freepointer);
   21636             : 
   21637             : #if ROSE_ALLOC_TRACE == 2
   21638             :     printf("SgTypeGlobalVoid::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeGlobalVoid::next_node);
   21639             : #endif
   21640             : 
   21641           0 :     SgNode * fp = object->p_freepointer;
   21642             : #if ROSE_ALLOC_MEMSET == 1
   21643             : #elif ROSE_ALLOC_MEMSET == 2
   21644             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgTypeGlobalVoid) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   21645             : #elif ROSE_ALLOC_MEMSET == 3
   21646             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgTypeGlobalVoid) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   21647             : #endif
   21648           0 :     object->p_freepointer = fp;
   21649             : 
   21650             : #if ROSE_ALLOC_TRACE == 2
   21651             : //    printf("SgTypeGlobalVoid::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeGlobalVoid::next_node);
   21652             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   21653             :     Rose::MemPool::snapshot(oss.str());
   21654             :     alloc_trace_cnt++;
   21655             : #endif
   21656             : 
   21657           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   21658             : 
   21659           0 :     ALLOC_MUTEX(SgTypeGlobalVoid, unlock);
   21660             : 
   21661             :     return object;
   21662             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   21663             : }
   21664             : 
   21665             : 
   21666             : 
   21667             : /*! \brief Delete operator for SgTypeGlobalVoid.
   21668             : 
   21669             :    This delete operator implements deallocation using memory pools to 
   21670             :    provide most efficent use of the heap within construction of large ASTs.
   21671             : 
   21672             : \internal The new and delete operators use the lower level C malloc/free
   21673             :    function calls for performance and to make sure that mixing of malloc/free
   21674             :    and new/delete by the used can be caught more readily.  This may change
   21675             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   21676             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   21677             :    deallocate memory allocated using ROSE_MALLOC.
   21678             : */
   21679           0 : void SgTypeGlobalVoid::operator delete(void *Pointer, size_t Size)
   21680             : {
   21681             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   21682             :      * or throwing an exception. */
   21683           0 :     ALLOC_MUTEX(SgTypeGlobalVoid, lock);
   21684             : 
   21685             : #if USE_CPP_NEW_DELETE_OPERATORS
   21686             :     ROSE_FREE(Pointer);
   21687             : #else
   21688             : #if ROSE_PEDANTIC_ALLOC
   21689             :     ROSE_ASSERT(Size == sizeof(SgTypeGlobalVoid));
   21690             : #else
   21691           0 :     if (Size != sizeof(SgTypeGlobalVoid)) {
   21692           0 :       ROSE_FREE(Pointer);
   21693           0 :       ALLOC_MUTEX(SgTypeGlobalVoid, unlock);
   21694             :       return;
   21695             :     }
   21696             : #endif
   21697             : 
   21698           0 :     SgTypeGlobalVoid * object = (SgTypeGlobalVoid*) Pointer;
   21699           0 :     ROSE_ASSERT(object != nullptr);
   21700             : 
   21701             : #if ROSE_ALLOC_TRACE == 2
   21702             : //  printf("SgTypeGlobalVoid::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeGlobalVoid::next_node);
   21703             :     printf("SgTypeGlobalVoid::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeGlobalVoid::next_node);
   21704             : #endif
   21705             : 
   21706             : #if ROSE_PEDANTIC_ALLOC
   21707             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   21708             : #endif
   21709             : 
   21710             : #if ROSE_ALLOC_MEMSET == 1
   21711             : #elif ROSE_ALLOC_MEMSET == 2
   21712             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgTypeGlobalVoid) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   21713             : #elif ROSE_ALLOC_MEMSET == 3
   21714             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgTypeGlobalVoid) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   21715             : #endif
   21716             : 
   21717             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   21718             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   21719             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   21720             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   21721             : #else
   21722           0 :     object->p_freepointer = SgTypeGlobalVoid::next_node;
   21723           0 :     SgTypeGlobalVoid::next_node = object;
   21724             : #endif
   21725             : 
   21726             : #if ROSE_ALLOC_TRACE == 2
   21727             : //  printf("SgTypeGlobalVoid::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeGlobalVoid::next_node);
   21728             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   21729             :     Rose::MemPool::snapshot(oss.str());
   21730             :     alloc_trace_cnt++;
   21731             : #endif
   21732             : 
   21733             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   21734             : 
   21735           0 :     ALLOC_MUTEX(SgTypeGlobalVoid, unlock);
   21736             : }
   21737             : 
   21738             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   21739             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   21740             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   21741             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   21742             : // Also, note comment below from Robb (copied from the Common.code file).
   21743             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   21744             : //
   21745             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   21746             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   21747             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   21748             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   21749             : #if 0
   21750             : void SgTypeGlobalVoid::operator delete(void* pointer) { SgTypeGlobalVoid::operator delete (pointer, sizeof(SgTypeGlobalVoid)); };
   21751             : #endif
   21752             : /* #line 21753 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   21753             : 
   21754             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   21755             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   21756             : // obviously imply C++.
   21757             : 
   21758             : // This implements the support within ROSE for memory pools.  Memory pools
   21759             : // support the most condensed usage of memory within the construction of
   21760             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   21761             : // by a new operator written for each class.
   21762             : 
   21763             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   21764             :     // User wants multi-thread support and POSIX threads are available.
   21765             : #   include <pthread.h>
   21766             :     static pthread_mutex_t SgTypeWchar_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   21767             : #else
   21768             :      // Cause synchronization to be skipped.
   21769             : #    ifndef ALLOC_MUTEX
   21770             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   21771             : #    endif
   21772             : #    ifdef _REENTRANT
   21773             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   21774             : #       ifdef _MSC_VER
   21775             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   21776             : #       else
   21777             : #           warning "POSIX threads are not available; synchronization being skipped"
   21778             : #       endif
   21779             : #    endif
   21780             : #endif
   21781             : 
   21782             : #ifndef ROSE_ALLOC_TRACE
   21783             : #  define ROSE_ALLOC_TRACE 0
   21784             : #endif
   21785             : 
   21786             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   21787             : #define ROSE_ALLOC_TRACE_CNT
   21788             : #include "memory-pool-snapshot.h"
   21789             : unsigned long alloc_trace_cnt = 0;
   21790             : #endif
   21791             : 
   21792             : #if ROSE_ALLOC_TRACE
   21793             : const unsigned SgTypeWchar::pool_size = 5;
   21794             : #else
   21795             : const unsigned SgTypeWchar::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   21796             : #endif
   21797             : 
   21798             : #ifndef ROSE_ALLOC_MEMSET
   21799             : #  define ROSE_ALLOC_MEMSET 0
   21800             : #endif
   21801             : 
   21802             : #ifndef ROSE_PEDANTIC_ALLOC
   21803             : #  define ROSE_PEDANTIC_ALLOC 0
   21804             : #endif
   21805             : 
   21806             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   21807             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   21808             : #endif
   21809             : 
   21810             : #if !defined(SGNODE__ALL_POOLS)
   21811             : #define SGNODE__ALL_POOLS
   21812             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   21813             : #endif
   21814             : 
   21815             : SgTypeWchar* SgTypeWchar::next_node = nullptr;
   21816             : std::vector<unsigned char*> SgTypeWchar::pools;
   21817             : 
   21818             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   21819             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   21820             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   21821             : // around this macro definition rather than each use).
   21822             : #ifndef ALLOC_MUTEX
   21823             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   21824             :         do {                                                                     \
   21825             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   21826             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   21827             :                 abort();                                                         \
   21828             :             }                                                                    \
   21829             :         } while (0);
   21830             : #endif
   21831             : 
   21832             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   21833             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   21834             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   21835             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   21836             : 
   21837             : /*! \brief New operator for SgTypeWchar.
   21838             : 
   21839             :    This new operator implements memory pools to provide most efficent 
   21840             :    use of the heap within construction of large ASTs.
   21841             : 
   21842             : \internal The new and delete operators use the lower level C malloc/free
   21843             :    function calls for performance and to make sure that mixing of malloc/free
   21844             :    and new/delete by the used can be caught more readily.  This may change
   21845             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   21846             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   21847             :    deallocate memory allocated using ROSE_MALLOC.
   21848             : */
   21849          15 : void *SgTypeWchar::operator new ( size_t Size )
   21850             : {
   21851             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   21852             :      * returning or throwing an exception. */
   21853          15 :     ALLOC_MUTEX(SgTypeWchar, lock);
   21854             : 
   21855             : #if ROSE_ALLOC_TRACE == 2
   21856             : //    printf("SgTypeWchar::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgTypeWchar::next_node);
   21857             : #endif
   21858             : 
   21859             : #if USE_CPP_NEW_DELETE_OPERATORS
   21860             :     void *mem = ROSE_MALLOC(Size);
   21861             :     ALLOC_MUTEX(SgTypeWchar, unlock);
   21862             :     return mem;
   21863             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   21864             : #if ROSE_PEDANTIC_ALLOC
   21865             :     ROSE_ASSERT(Size == sizeof(SgTypeWchar));
   21866             : #else
   21867          15 :     if (Size != sizeof(SgTypeWchar)) {
   21868           0 :       void * object = ROSE_MALLOC(Size);
   21869           0 :       ALLOC_MUTEX(SgTypeWchar, unlock);
   21870             :       return object;
   21871             :     }
   21872             : #endif
   21873             : 
   21874          15 :     if (SgTypeWchar::next_node == nullptr) {
   21875          14 :         SgTypeWchar * alloc = (SgTypeWchar*) ROSE_MALLOC ( SgTypeWchar::pool_size * sizeof(SgTypeWchar) );
   21876          14 :         ROSE_ASSERT(alloc != nullptr);
   21877             : 
   21878             : #if ROSE_ALLOC_TRACE == 2
   21879             : //        printf("SgTypeWchar::alloc\n  block[%zi] = [ %p , %p [\n", SgTypeWchar::pools.size(), alloc, alloc + SgTypeWchar::pool_size);
   21880             : #endif
   21881             : 
   21882             : #if ROSE_ALLOC_MEMSET == 1
   21883             : #elif ROSE_ALLOC_MEMSET == 2
   21884             :         memset(alloc, 0x00, SgTypeWchar::pool_size * sizeof(SgTypeWchar));
   21885             : #elif ROSE_ALLOC_MEMSET == 3
   21886             :         memset(alloc, 0xAA, SgTypeWchar::pool_size * sizeof(SgTypeWchar));
   21887             : #endif
   21888       28000 :         for (unsigned i=0; i < SgTypeWchar::pool_size-1; i++) {
   21889       27986 :           alloc[i].p_freepointer = &(alloc[i+1]);
   21890             :         }
   21891          14 :         alloc[SgTypeWchar::pool_size-1].p_freepointer = nullptr;
   21892             : 
   21893          14 :         SgTypeWchar::pools.push_back ( (unsigned char *) alloc );
   21894          14 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgTypeWchar::pool_size * sizeof(SgTypeWchar), V_SgTypeWchar ) );
   21895          14 :         SgTypeWchar::next_node = alloc;
   21896             :     }
   21897          15 :     ROSE_ASSERT(SgTypeWchar::next_node != nullptr);
   21898             : 
   21899          15 :     SgTypeWchar * object = SgTypeWchar::next_node;
   21900          15 :     SgTypeWchar::next_node = (SgTypeWchar*)(object->p_freepointer);
   21901             : 
   21902             : #if ROSE_ALLOC_TRACE == 2
   21903             :     printf("SgTypeWchar::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeWchar::next_node);
   21904             : #endif
   21905             : 
   21906          15 :     SgNode * fp = object->p_freepointer;
   21907             : #if ROSE_ALLOC_MEMSET == 1
   21908             : #elif ROSE_ALLOC_MEMSET == 2
   21909             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgTypeWchar) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   21910             : #elif ROSE_ALLOC_MEMSET == 3
   21911             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgTypeWchar) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   21912             : #endif
   21913          15 :     object->p_freepointer = fp;
   21914             : 
   21915             : #if ROSE_ALLOC_TRACE == 2
   21916             : //    printf("SgTypeWchar::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeWchar::next_node);
   21917             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   21918             :     Rose::MemPool::snapshot(oss.str());
   21919             :     alloc_trace_cnt++;
   21920             : #endif
   21921             : 
   21922          15 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   21923             : 
   21924          15 :     ALLOC_MUTEX(SgTypeWchar, unlock);
   21925             : 
   21926             :     return object;
   21927             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   21928             : }
   21929             : 
   21930             : 
   21931             : 
   21932             : /*! \brief Delete operator for SgTypeWchar.
   21933             : 
   21934             :    This delete operator implements deallocation using memory pools to 
   21935             :    provide most efficent use of the heap within construction of large ASTs.
   21936             : 
   21937             : \internal The new and delete operators use the lower level C malloc/free
   21938             :    function calls for performance and to make sure that mixing of malloc/free
   21939             :    and new/delete by the used can be caught more readily.  This may change
   21940             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   21941             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   21942             :    deallocate memory allocated using ROSE_MALLOC.
   21943             : */
   21944           2 : void SgTypeWchar::operator delete(void *Pointer, size_t Size)
   21945             : {
   21946             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   21947             :      * or throwing an exception. */
   21948           2 :     ALLOC_MUTEX(SgTypeWchar, lock);
   21949             : 
   21950             : #if USE_CPP_NEW_DELETE_OPERATORS
   21951             :     ROSE_FREE(Pointer);
   21952             : #else
   21953             : #if ROSE_PEDANTIC_ALLOC
   21954             :     ROSE_ASSERT(Size == sizeof(SgTypeWchar));
   21955             : #else
   21956           2 :     if (Size != sizeof(SgTypeWchar)) {
   21957           0 :       ROSE_FREE(Pointer);
   21958           0 :       ALLOC_MUTEX(SgTypeWchar, unlock);
   21959             :       return;
   21960             :     }
   21961             : #endif
   21962             : 
   21963           2 :     SgTypeWchar * object = (SgTypeWchar*) Pointer;
   21964           2 :     ROSE_ASSERT(object != nullptr);
   21965             : 
   21966             : #if ROSE_ALLOC_TRACE == 2
   21967             : //  printf("SgTypeWchar::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeWchar::next_node);
   21968             :     printf("SgTypeWchar::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeWchar::next_node);
   21969             : #endif
   21970             : 
   21971             : #if ROSE_PEDANTIC_ALLOC
   21972             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   21973             : #endif
   21974             : 
   21975             : #if ROSE_ALLOC_MEMSET == 1
   21976             : #elif ROSE_ALLOC_MEMSET == 2
   21977             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgTypeWchar) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   21978             : #elif ROSE_ALLOC_MEMSET == 3
   21979             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgTypeWchar) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   21980             : #endif
   21981             : 
   21982             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   21983             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   21984             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   21985             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   21986             : #else
   21987           2 :     object->p_freepointer = SgTypeWchar::next_node;
   21988           2 :     SgTypeWchar::next_node = object;
   21989             : #endif
   21990             : 
   21991             : #if ROSE_ALLOC_TRACE == 2
   21992             : //  printf("SgTypeWchar::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeWchar::next_node);
   21993             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   21994             :     Rose::MemPool::snapshot(oss.str());
   21995             :     alloc_trace_cnt++;
   21996             : #endif
   21997             : 
   21998             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   21999             : 
   22000           2 :     ALLOC_MUTEX(SgTypeWchar, unlock);
   22001             : }
   22002             : 
   22003             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   22004             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   22005             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   22006             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   22007             : // Also, note comment below from Robb (copied from the Common.code file).
   22008             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   22009             : //
   22010             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   22011             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   22012             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   22013             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   22014             : #if 0
   22015             : void SgTypeWchar::operator delete(void* pointer) { SgTypeWchar::operator delete (pointer, sizeof(SgTypeWchar)); };
   22016             : #endif
   22017             : /* #line 22018 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   22018             : 
   22019             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   22020             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   22021             : // obviously imply C++.
   22022             : 
   22023             : // This implements the support within ROSE for memory pools.  Memory pools
   22024             : // support the most condensed usage of memory within the construction of
   22025             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   22026             : // by a new operator written for each class.
   22027             : 
   22028             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   22029             :     // User wants multi-thread support and POSIX threads are available.
   22030             : #   include <pthread.h>
   22031             :     static pthread_mutex_t SgTypeFloat_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   22032             : #else
   22033             :      // Cause synchronization to be skipped.
   22034             : #    ifndef ALLOC_MUTEX
   22035             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   22036             : #    endif
   22037             : #    ifdef _REENTRANT
   22038             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   22039             : #       ifdef _MSC_VER
   22040             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   22041             : #       else
   22042             : #           warning "POSIX threads are not available; synchronization being skipped"
   22043             : #       endif
   22044             : #    endif
   22045             : #endif
   22046             : 
   22047             : #ifndef ROSE_ALLOC_TRACE
   22048             : #  define ROSE_ALLOC_TRACE 0
   22049             : #endif
   22050             : 
   22051             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   22052             : #define ROSE_ALLOC_TRACE_CNT
   22053             : #include "memory-pool-snapshot.h"
   22054             : unsigned long alloc_trace_cnt = 0;
   22055             : #endif
   22056             : 
   22057             : #if ROSE_ALLOC_TRACE
   22058             : const unsigned SgTypeFloat::pool_size = 5;
   22059             : #else
   22060             : const unsigned SgTypeFloat::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   22061             : #endif
   22062             : 
   22063             : #ifndef ROSE_ALLOC_MEMSET
   22064             : #  define ROSE_ALLOC_MEMSET 0
   22065             : #endif
   22066             : 
   22067             : #ifndef ROSE_PEDANTIC_ALLOC
   22068             : #  define ROSE_PEDANTIC_ALLOC 0
   22069             : #endif
   22070             : 
   22071             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   22072             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   22073             : #endif
   22074             : 
   22075             : #if !defined(SGNODE__ALL_POOLS)
   22076             : #define SGNODE__ALL_POOLS
   22077             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   22078             : #endif
   22079             : 
   22080             : SgTypeFloat* SgTypeFloat::next_node = nullptr;
   22081             : std::vector<unsigned char*> SgTypeFloat::pools;
   22082             : 
   22083             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   22084             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   22085             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   22086             : // around this macro definition rather than each use).
   22087             : #ifndef ALLOC_MUTEX
   22088             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   22089             :         do {                                                                     \
   22090             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   22091             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   22092             :                 abort();                                                         \
   22093             :             }                                                                    \
   22094             :         } while (0);
   22095             : #endif
   22096             : 
   22097             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   22098             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   22099             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   22100             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   22101             : 
   22102             : /*! \brief New operator for SgTypeFloat.
   22103             : 
   22104             :    This new operator implements memory pools to provide most efficent 
   22105             :    use of the heap within construction of large ASTs.
   22106             : 
   22107             : \internal The new and delete operators use the lower level C malloc/free
   22108             :    function calls for performance and to make sure that mixing of malloc/free
   22109             :    and new/delete by the used can be caught more readily.  This may change
   22110             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   22111             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   22112             :    deallocate memory allocated using ROSE_MALLOC.
   22113             : */
   22114        1162 : void *SgTypeFloat::operator new ( size_t Size )
   22115             : {
   22116             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   22117             :      * returning or throwing an exception. */
   22118        1162 :     ALLOC_MUTEX(SgTypeFloat, lock);
   22119             : 
   22120             : #if ROSE_ALLOC_TRACE == 2
   22121             : //    printf("SgTypeFloat::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgTypeFloat::next_node);
   22122             : #endif
   22123             : 
   22124             : #if USE_CPP_NEW_DELETE_OPERATORS
   22125             :     void *mem = ROSE_MALLOC(Size);
   22126             :     ALLOC_MUTEX(SgTypeFloat, unlock);
   22127             :     return mem;
   22128             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   22129             : #if ROSE_PEDANTIC_ALLOC
   22130             :     ROSE_ASSERT(Size == sizeof(SgTypeFloat));
   22131             : #else
   22132        1162 :     if (Size != sizeof(SgTypeFloat)) {
   22133           0 :       void * object = ROSE_MALLOC(Size);
   22134           0 :       ALLOC_MUTEX(SgTypeFloat, unlock);
   22135             :       return object;
   22136             :     }
   22137             : #endif
   22138             : 
   22139        1162 :     if (SgTypeFloat::next_node == nullptr) {
   22140         336 :         SgTypeFloat * alloc = (SgTypeFloat*) ROSE_MALLOC ( SgTypeFloat::pool_size * sizeof(SgTypeFloat) );
   22141         336 :         ROSE_ASSERT(alloc != nullptr);
   22142             : 
   22143             : #if ROSE_ALLOC_TRACE == 2
   22144             : //        printf("SgTypeFloat::alloc\n  block[%zi] = [ %p , %p [\n", SgTypeFloat::pools.size(), alloc, alloc + SgTypeFloat::pool_size);
   22145             : #endif
   22146             : 
   22147             : #if ROSE_ALLOC_MEMSET == 1
   22148             : #elif ROSE_ALLOC_MEMSET == 2
   22149             :         memset(alloc, 0x00, SgTypeFloat::pool_size * sizeof(SgTypeFloat));
   22150             : #elif ROSE_ALLOC_MEMSET == 3
   22151             :         memset(alloc, 0xAA, SgTypeFloat::pool_size * sizeof(SgTypeFloat));
   22152             : #endif
   22153      672000 :         for (unsigned i=0; i < SgTypeFloat::pool_size-1; i++) {
   22154      671664 :           alloc[i].p_freepointer = &(alloc[i+1]);
   22155             :         }
   22156         336 :         alloc[SgTypeFloat::pool_size-1].p_freepointer = nullptr;
   22157             : 
   22158         336 :         SgTypeFloat::pools.push_back ( (unsigned char *) alloc );
   22159         336 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgTypeFloat::pool_size * sizeof(SgTypeFloat), V_SgTypeFloat ) );
   22160         336 :         SgTypeFloat::next_node = alloc;
   22161             :     }
   22162        1162 :     ROSE_ASSERT(SgTypeFloat::next_node != nullptr);
   22163             : 
   22164        1162 :     SgTypeFloat * object = SgTypeFloat::next_node;
   22165        1162 :     SgTypeFloat::next_node = (SgTypeFloat*)(object->p_freepointer);
   22166             : 
   22167             : #if ROSE_ALLOC_TRACE == 2
   22168             :     printf("SgTypeFloat::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeFloat::next_node);
   22169             : #endif
   22170             : 
   22171        1162 :     SgNode * fp = object->p_freepointer;
   22172             : #if ROSE_ALLOC_MEMSET == 1
   22173             : #elif ROSE_ALLOC_MEMSET == 2
   22174             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgTypeFloat) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   22175             : #elif ROSE_ALLOC_MEMSET == 3
   22176             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgTypeFloat) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   22177             : #endif
   22178        1162 :     object->p_freepointer = fp;
   22179             : 
   22180             : #if ROSE_ALLOC_TRACE == 2
   22181             : //    printf("SgTypeFloat::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeFloat::next_node);
   22182             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   22183             :     Rose::MemPool::snapshot(oss.str());
   22184             :     alloc_trace_cnt++;
   22185             : #endif
   22186             : 
   22187        1162 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   22188             : 
   22189        1162 :     ALLOC_MUTEX(SgTypeFloat, unlock);
   22190             : 
   22191             :     return object;
   22192             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   22193             : }
   22194             : 
   22195             : 
   22196             : 
   22197             : /*! \brief Delete operator for SgTypeFloat.
   22198             : 
   22199             :    This delete operator implements deallocation using memory pools to 
   22200             :    provide most efficent use of the heap within construction of large ASTs.
   22201             : 
   22202             : \internal The new and delete operators use the lower level C malloc/free
   22203             :    function calls for performance and to make sure that mixing of malloc/free
   22204             :    and new/delete by the used can be caught more readily.  This may change
   22205             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   22206             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   22207             :    deallocate memory allocated using ROSE_MALLOC.
   22208             : */
   22209         828 : void SgTypeFloat::operator delete(void *Pointer, size_t Size)
   22210             : {
   22211             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   22212             :      * or throwing an exception. */
   22213         828 :     ALLOC_MUTEX(SgTypeFloat, lock);
   22214             : 
   22215             : #if USE_CPP_NEW_DELETE_OPERATORS
   22216             :     ROSE_FREE(Pointer);
   22217             : #else
   22218             : #if ROSE_PEDANTIC_ALLOC
   22219             :     ROSE_ASSERT(Size == sizeof(SgTypeFloat));
   22220             : #else
   22221         828 :     if (Size != sizeof(SgTypeFloat)) {
   22222           0 :       ROSE_FREE(Pointer);
   22223           0 :       ALLOC_MUTEX(SgTypeFloat, unlock);
   22224             :       return;
   22225             :     }
   22226             : #endif
   22227             : 
   22228         828 :     SgTypeFloat * object = (SgTypeFloat*) Pointer;
   22229         828 :     ROSE_ASSERT(object != nullptr);
   22230             : 
   22231             : #if ROSE_ALLOC_TRACE == 2
   22232             : //  printf("SgTypeFloat::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeFloat::next_node);
   22233             :     printf("SgTypeFloat::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeFloat::next_node);
   22234             : #endif
   22235             : 
   22236             : #if ROSE_PEDANTIC_ALLOC
   22237             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   22238             : #endif
   22239             : 
   22240             : #if ROSE_ALLOC_MEMSET == 1
   22241             : #elif ROSE_ALLOC_MEMSET == 2
   22242             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgTypeFloat) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   22243             : #elif ROSE_ALLOC_MEMSET == 3
   22244             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgTypeFloat) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   22245             : #endif
   22246             : 
   22247             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   22248             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   22249             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   22250             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   22251             : #else
   22252         828 :     object->p_freepointer = SgTypeFloat::next_node;
   22253         828 :     SgTypeFloat::next_node = object;
   22254             : #endif
   22255             : 
   22256             : #if ROSE_ALLOC_TRACE == 2
   22257             : //  printf("SgTypeFloat::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeFloat::next_node);
   22258             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   22259             :     Rose::MemPool::snapshot(oss.str());
   22260             :     alloc_trace_cnt++;
   22261             : #endif
   22262             : 
   22263             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   22264             : 
   22265         828 :     ALLOC_MUTEX(SgTypeFloat, unlock);
   22266             : }
   22267             : 
   22268             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   22269             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   22270             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   22271             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   22272             : // Also, note comment below from Robb (copied from the Common.code file).
   22273             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   22274             : //
   22275             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   22276             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   22277             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   22278             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   22279             : #if 0
   22280             : void SgTypeFloat::operator delete(void* pointer) { SgTypeFloat::operator delete (pointer, sizeof(SgTypeFloat)); };
   22281             : #endif
   22282             : /* #line 22283 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   22283             : 
   22284             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   22285             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   22286             : // obviously imply C++.
   22287             : 
   22288             : // This implements the support within ROSE for memory pools.  Memory pools
   22289             : // support the most condensed usage of memory within the construction of
   22290             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   22291             : // by a new operator written for each class.
   22292             : 
   22293             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   22294             :     // User wants multi-thread support and POSIX threads are available.
   22295             : #   include <pthread.h>
   22296             :     static pthread_mutex_t SgTypeDouble_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   22297             : #else
   22298             :      // Cause synchronization to be skipped.
   22299             : #    ifndef ALLOC_MUTEX
   22300             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   22301             : #    endif
   22302             : #    ifdef _REENTRANT
   22303             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   22304             : #       ifdef _MSC_VER
   22305             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   22306             : #       else
   22307             : #           warning "POSIX threads are not available; synchronization being skipped"
   22308             : #       endif
   22309             : #    endif
   22310             : #endif
   22311             : 
   22312             : #ifndef ROSE_ALLOC_TRACE
   22313             : #  define ROSE_ALLOC_TRACE 0
   22314             : #endif
   22315             : 
   22316             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   22317             : #define ROSE_ALLOC_TRACE_CNT
   22318             : #include "memory-pool-snapshot.h"
   22319             : unsigned long alloc_trace_cnt = 0;
   22320             : #endif
   22321             : 
   22322             : #if ROSE_ALLOC_TRACE
   22323             : const unsigned SgTypeDouble::pool_size = 5;
   22324             : #else
   22325             : const unsigned SgTypeDouble::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   22326             : #endif
   22327             : 
   22328             : #ifndef ROSE_ALLOC_MEMSET
   22329             : #  define ROSE_ALLOC_MEMSET 0
   22330             : #endif
   22331             : 
   22332             : #ifndef ROSE_PEDANTIC_ALLOC
   22333             : #  define ROSE_PEDANTIC_ALLOC 0
   22334             : #endif
   22335             : 
   22336             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   22337             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   22338             : #endif
   22339             : 
   22340             : #if !defined(SGNODE__ALL_POOLS)
   22341             : #define SGNODE__ALL_POOLS
   22342             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   22343             : #endif
   22344             : 
   22345             : SgTypeDouble* SgTypeDouble::next_node = nullptr;
   22346             : std::vector<unsigned char*> SgTypeDouble::pools;
   22347             : 
   22348             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   22349             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   22350             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   22351             : // around this macro definition rather than each use).
   22352             : #ifndef ALLOC_MUTEX
   22353             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   22354             :         do {                                                                     \
   22355             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   22356             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   22357             :                 abort();                                                         \
   22358             :             }                                                                    \
   22359             :         } while (0);
   22360             : #endif
   22361             : 
   22362             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   22363             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   22364             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   22365             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   22366             : 
   22367             : /*! \brief New operator for SgTypeDouble.
   22368             : 
   22369             :    This new operator implements memory pools to provide most efficent 
   22370             :    use of the heap within construction of large ASTs.
   22371             : 
   22372             : \internal The new and delete operators use the lower level C malloc/free
   22373             :    function calls for performance and to make sure that mixing of malloc/free
   22374             :    and new/delete by the used can be caught more readily.  This may change
   22375             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   22376             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   22377             :    deallocate memory allocated using ROSE_MALLOC.
   22378             : */
   22379       12176 : void *SgTypeDouble::operator new ( size_t Size )
   22380             : {
   22381             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   22382             :      * returning or throwing an exception. */
   22383       12176 :     ALLOC_MUTEX(SgTypeDouble, lock);
   22384             : 
   22385             : #if ROSE_ALLOC_TRACE == 2
   22386             : //    printf("SgTypeDouble::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgTypeDouble::next_node);
   22387             : #endif
   22388             : 
   22389             : #if USE_CPP_NEW_DELETE_OPERATORS
   22390             :     void *mem = ROSE_MALLOC(Size);
   22391             :     ALLOC_MUTEX(SgTypeDouble, unlock);
   22392             :     return mem;
   22393             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   22394             : #if ROSE_PEDANTIC_ALLOC
   22395             :     ROSE_ASSERT(Size == sizeof(SgTypeDouble));
   22396             : #else
   22397       12176 :     if (Size != sizeof(SgTypeDouble)) {
   22398           0 :       void * object = ROSE_MALLOC(Size);
   22399           0 :       ALLOC_MUTEX(SgTypeDouble, unlock);
   22400             :       return object;
   22401             :     }
   22402             : #endif
   22403             : 
   22404       12176 :     if (SgTypeDouble::next_node == nullptr) {
   22405         327 :         SgTypeDouble * alloc = (SgTypeDouble*) ROSE_MALLOC ( SgTypeDouble::pool_size * sizeof(SgTypeDouble) );
   22406         327 :         ROSE_ASSERT(alloc != nullptr);
   22407             : 
   22408             : #if ROSE_ALLOC_TRACE == 2
   22409             : //        printf("SgTypeDouble::alloc\n  block[%zi] = [ %p , %p [\n", SgTypeDouble::pools.size(), alloc, alloc + SgTypeDouble::pool_size);
   22410             : #endif
   22411             : 
   22412             : #if ROSE_ALLOC_MEMSET == 1
   22413             : #elif ROSE_ALLOC_MEMSET == 2
   22414             :         memset(alloc, 0x00, SgTypeDouble::pool_size * sizeof(SgTypeDouble));
   22415             : #elif ROSE_ALLOC_MEMSET == 3
   22416             :         memset(alloc, 0xAA, SgTypeDouble::pool_size * sizeof(SgTypeDouble));
   22417             : #endif
   22418      654000 :         for (unsigned i=0; i < SgTypeDouble::pool_size-1; i++) {
   22419      653673 :           alloc[i].p_freepointer = &(alloc[i+1]);
   22420             :         }
   22421         327 :         alloc[SgTypeDouble::pool_size-1].p_freepointer = nullptr;
   22422             : 
   22423         327 :         SgTypeDouble::pools.push_back ( (unsigned char *) alloc );
   22424         327 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgTypeDouble::pool_size * sizeof(SgTypeDouble), V_SgTypeDouble ) );
   22425         327 :         SgTypeDouble::next_node = alloc;
   22426             :     }
   22427       12176 :     ROSE_ASSERT(SgTypeDouble::next_node != nullptr);
   22428             : 
   22429       12176 :     SgTypeDouble * object = SgTypeDouble::next_node;
   22430       12176 :     SgTypeDouble::next_node = (SgTypeDouble*)(object->p_freepointer);
   22431             : 
   22432             : #if ROSE_ALLOC_TRACE == 2
   22433             :     printf("SgTypeDouble::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeDouble::next_node);
   22434             : #endif
   22435             : 
   22436       12176 :     SgNode * fp = object->p_freepointer;
   22437             : #if ROSE_ALLOC_MEMSET == 1
   22438             : #elif ROSE_ALLOC_MEMSET == 2
   22439             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgTypeDouble) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   22440             : #elif ROSE_ALLOC_MEMSET == 3
   22441             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgTypeDouble) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   22442             : #endif
   22443       12176 :     object->p_freepointer = fp;
   22444             : 
   22445             : #if ROSE_ALLOC_TRACE == 2
   22446             : //    printf("SgTypeDouble::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeDouble::next_node);
   22447             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   22448             :     Rose::MemPool::snapshot(oss.str());
   22449             :     alloc_trace_cnt++;
   22450             : #endif
   22451             : 
   22452       12176 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   22453             : 
   22454       12176 :     ALLOC_MUTEX(SgTypeDouble, unlock);
   22455             : 
   22456             :     return object;
   22457             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   22458             : }
   22459             : 
   22460             : 
   22461             : 
   22462             : /*! \brief Delete operator for SgTypeDouble.
   22463             : 
   22464             :    This delete operator implements deallocation using memory pools to 
   22465             :    provide most efficent use of the heap within construction of large ASTs.
   22466             : 
   22467             : \internal The new and delete operators use the lower level C malloc/free
   22468             :    function calls for performance and to make sure that mixing of malloc/free
   22469             :    and new/delete by the used can be caught more readily.  This may change
   22470             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   22471             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   22472             :    deallocate memory allocated using ROSE_MALLOC.
   22473             : */
   22474       11851 : void SgTypeDouble::operator delete(void *Pointer, size_t Size)
   22475             : {
   22476             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   22477             :      * or throwing an exception. */
   22478       11851 :     ALLOC_MUTEX(SgTypeDouble, lock);
   22479             : 
   22480             : #if USE_CPP_NEW_DELETE_OPERATORS
   22481             :     ROSE_FREE(Pointer);
   22482             : #else
   22483             : #if ROSE_PEDANTIC_ALLOC
   22484             :     ROSE_ASSERT(Size == sizeof(SgTypeDouble));
   22485             : #else
   22486       11851 :     if (Size != sizeof(SgTypeDouble)) {
   22487           0 :       ROSE_FREE(Pointer);
   22488           0 :       ALLOC_MUTEX(SgTypeDouble, unlock);
   22489             :       return;
   22490             :     }
   22491             : #endif
   22492             : 
   22493       11851 :     SgTypeDouble * object = (SgTypeDouble*) Pointer;
   22494       11851 :     ROSE_ASSERT(object != nullptr);
   22495             : 
   22496             : #if ROSE_ALLOC_TRACE == 2
   22497             : //  printf("SgTypeDouble::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeDouble::next_node);
   22498             :     printf("SgTypeDouble::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeDouble::next_node);
   22499             : #endif
   22500             : 
   22501             : #if ROSE_PEDANTIC_ALLOC
   22502             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   22503             : #endif
   22504             : 
   22505             : #if ROSE_ALLOC_MEMSET == 1
   22506             : #elif ROSE_ALLOC_MEMSET == 2
   22507             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgTypeDouble) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   22508             : #elif ROSE_ALLOC_MEMSET == 3
   22509             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgTypeDouble) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   22510             : #endif
   22511             : 
   22512             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   22513             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   22514             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   22515             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   22516             : #else
   22517       11851 :     object->p_freepointer = SgTypeDouble::next_node;
   22518       11851 :     SgTypeDouble::next_node = object;
   22519             : #endif
   22520             : 
   22521             : #if ROSE_ALLOC_TRACE == 2
   22522             : //  printf("SgTypeDouble::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeDouble::next_node);
   22523             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   22524             :     Rose::MemPool::snapshot(oss.str());
   22525             :     alloc_trace_cnt++;
   22526             : #endif
   22527             : 
   22528             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   22529             : 
   22530       11851 :     ALLOC_MUTEX(SgTypeDouble, unlock);
   22531             : }
   22532             : 
   22533             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   22534             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   22535             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   22536             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   22537             : // Also, note comment below from Robb (copied from the Common.code file).
   22538             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   22539             : //
   22540             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   22541             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   22542             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   22543             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   22544             : #if 0
   22545             : void SgTypeDouble::operator delete(void* pointer) { SgTypeDouble::operator delete (pointer, sizeof(SgTypeDouble)); };
   22546             : #endif
   22547             : /* #line 22548 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   22548             : 
   22549             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   22550             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   22551             : // obviously imply C++.
   22552             : 
   22553             : // This implements the support within ROSE for memory pools.  Memory pools
   22554             : // support the most condensed usage of memory within the construction of
   22555             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   22556             : // by a new operator written for each class.
   22557             : 
   22558             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   22559             :     // User wants multi-thread support and POSIX threads are available.
   22560             : #   include <pthread.h>
   22561             :     static pthread_mutex_t SgTypeLongLong_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   22562             : #else
   22563             :      // Cause synchronization to be skipped.
   22564             : #    ifndef ALLOC_MUTEX
   22565             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   22566             : #    endif
   22567             : #    ifdef _REENTRANT
   22568             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   22569             : #       ifdef _MSC_VER
   22570             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   22571             : #       else
   22572             : #           warning "POSIX threads are not available; synchronization being skipped"
   22573             : #       endif
   22574             : #    endif
   22575             : #endif
   22576             : 
   22577             : #ifndef ROSE_ALLOC_TRACE
   22578             : #  define ROSE_ALLOC_TRACE 0
   22579             : #endif
   22580             : 
   22581             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   22582             : #define ROSE_ALLOC_TRACE_CNT
   22583             : #include "memory-pool-snapshot.h"
   22584             : unsigned long alloc_trace_cnt = 0;
   22585             : #endif
   22586             : 
   22587             : #if ROSE_ALLOC_TRACE
   22588             : const unsigned SgTypeLongLong::pool_size = 5;
   22589             : #else
   22590             : const unsigned SgTypeLongLong::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   22591             : #endif
   22592             : 
   22593             : #ifndef ROSE_ALLOC_MEMSET
   22594             : #  define ROSE_ALLOC_MEMSET 0
   22595             : #endif
   22596             : 
   22597             : #ifndef ROSE_PEDANTIC_ALLOC
   22598             : #  define ROSE_PEDANTIC_ALLOC 0
   22599             : #endif
   22600             : 
   22601             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   22602             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   22603             : #endif
   22604             : 
   22605             : #if !defined(SGNODE__ALL_POOLS)
   22606             : #define SGNODE__ALL_POOLS
   22607             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   22608             : #endif
   22609             : 
   22610             : SgTypeLongLong* SgTypeLongLong::next_node = nullptr;
   22611             : std::vector<unsigned char*> SgTypeLongLong::pools;
   22612             : 
   22613             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   22614             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   22615             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   22616             : // around this macro definition rather than each use).
   22617             : #ifndef ALLOC_MUTEX
   22618             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   22619             :         do {                                                                     \
   22620             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   22621             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   22622             :                 abort();                                                         \
   22623             :             }                                                                    \
   22624             :         } while (0);
   22625             : #endif
   22626             : 
   22627             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   22628             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   22629             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   22630             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   22631             : 
   22632             : /*! \brief New operator for SgTypeLongLong.
   22633             : 
   22634             :    This new operator implements memory pools to provide most efficent 
   22635             :    use of the heap within construction of large ASTs.
   22636             : 
   22637             : \internal The new and delete operators use the lower level C malloc/free
   22638             :    function calls for performance and to make sure that mixing of malloc/free
   22639             :    and new/delete by the used can be caught more readily.  This may change
   22640             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   22641             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   22642             :    deallocate memory allocated using ROSE_MALLOC.
   22643             : */
   22644         322 : void *SgTypeLongLong::operator new ( size_t Size )
   22645             : {
   22646             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   22647             :      * returning or throwing an exception. */
   22648         322 :     ALLOC_MUTEX(SgTypeLongLong, lock);
   22649             : 
   22650             : #if ROSE_ALLOC_TRACE == 2
   22651             : //    printf("SgTypeLongLong::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgTypeLongLong::next_node);
   22652             : #endif
   22653             : 
   22654             : #if USE_CPP_NEW_DELETE_OPERATORS
   22655             :     void *mem = ROSE_MALLOC(Size);
   22656             :     ALLOC_MUTEX(SgTypeLongLong, unlock);
   22657             :     return mem;
   22658             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   22659             : #if ROSE_PEDANTIC_ALLOC
   22660             :     ROSE_ASSERT(Size == sizeof(SgTypeLongLong));
   22661             : #else
   22662         322 :     if (Size != sizeof(SgTypeLongLong)) {
   22663           0 :       void * object = ROSE_MALLOC(Size);
   22664           0 :       ALLOC_MUTEX(SgTypeLongLong, unlock);
   22665             :       return object;
   22666             :     }
   22667             : #endif
   22668             : 
   22669         322 :     if (SgTypeLongLong::next_node == nullptr) {
   22670         315 :         SgTypeLongLong * alloc = (SgTypeLongLong*) ROSE_MALLOC ( SgTypeLongLong::pool_size * sizeof(SgTypeLongLong) );
   22671         315 :         ROSE_ASSERT(alloc != nullptr);
   22672             : 
   22673             : #if ROSE_ALLOC_TRACE == 2
   22674             : //        printf("SgTypeLongLong::alloc\n  block[%zi] = [ %p , %p [\n", SgTypeLongLong::pools.size(), alloc, alloc + SgTypeLongLong::pool_size);
   22675             : #endif
   22676             : 
   22677             : #if ROSE_ALLOC_MEMSET == 1
   22678             : #elif ROSE_ALLOC_MEMSET == 2
   22679             :         memset(alloc, 0x00, SgTypeLongLong::pool_size * sizeof(SgTypeLongLong));
   22680             : #elif ROSE_ALLOC_MEMSET == 3
   22681             :         memset(alloc, 0xAA, SgTypeLongLong::pool_size * sizeof(SgTypeLongLong));
   22682             : #endif
   22683      630000 :         for (unsigned i=0; i < SgTypeLongLong::pool_size-1; i++) {
   22684      629685 :           alloc[i].p_freepointer = &(alloc[i+1]);
   22685             :         }
   22686         315 :         alloc[SgTypeLongLong::pool_size-1].p_freepointer = nullptr;
   22687             : 
   22688         315 :         SgTypeLongLong::pools.push_back ( (unsigned char *) alloc );
   22689         315 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgTypeLongLong::pool_size * sizeof(SgTypeLongLong), V_SgTypeLongLong ) );
   22690         315 :         SgTypeLongLong::next_node = alloc;
   22691             :     }
   22692         322 :     ROSE_ASSERT(SgTypeLongLong::next_node != nullptr);
   22693             : 
   22694         322 :     SgTypeLongLong * object = SgTypeLongLong::next_node;
   22695         322 :     SgTypeLongLong::next_node = (SgTypeLongLong*)(object->p_freepointer);
   22696             : 
   22697             : #if ROSE_ALLOC_TRACE == 2
   22698             :     printf("SgTypeLongLong::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeLongLong::next_node);
   22699             : #endif
   22700             : 
   22701         322 :     SgNode * fp = object->p_freepointer;
   22702             : #if ROSE_ALLOC_MEMSET == 1
   22703             : #elif ROSE_ALLOC_MEMSET == 2
   22704             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgTypeLongLong) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   22705             : #elif ROSE_ALLOC_MEMSET == 3
   22706             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgTypeLongLong) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   22707             : #endif
   22708         322 :     object->p_freepointer = fp;
   22709             : 
   22710             : #if ROSE_ALLOC_TRACE == 2
   22711             : //    printf("SgTypeLongLong::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeLongLong::next_node);
   22712             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   22713             :     Rose::MemPool::snapshot(oss.str());
   22714             :     alloc_trace_cnt++;
   22715             : #endif
   22716             : 
   22717         322 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   22718             : 
   22719         322 :     ALLOC_MUTEX(SgTypeLongLong, unlock);
   22720             : 
   22721             :     return object;
   22722             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   22723             : }
   22724             : 
   22725             : 
   22726             : 
   22727             : /*! \brief Delete operator for SgTypeLongLong.
   22728             : 
   22729             :    This delete operator implements deallocation using memory pools to 
   22730             :    provide most efficent use of the heap within construction of large ASTs.
   22731             : 
   22732             : \internal The new and delete operators use the lower level C malloc/free
   22733             :    function calls for performance and to make sure that mixing of malloc/free
   22734             :    and new/delete by the used can be caught more readily.  This may change
   22735             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   22736             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   22737             :    deallocate memory allocated using ROSE_MALLOC.
   22738             : */
   22739           9 : void SgTypeLongLong::operator delete(void *Pointer, size_t Size)
   22740             : {
   22741             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   22742             :      * or throwing an exception. */
   22743           9 :     ALLOC_MUTEX(SgTypeLongLong, lock);
   22744             : 
   22745             : #if USE_CPP_NEW_DELETE_OPERATORS
   22746             :     ROSE_FREE(Pointer);
   22747             : #else
   22748             : #if ROSE_PEDANTIC_ALLOC
   22749             :     ROSE_ASSERT(Size == sizeof(SgTypeLongLong));
   22750             : #else
   22751           9 :     if (Size != sizeof(SgTypeLongLong)) {
   22752           0 :       ROSE_FREE(Pointer);
   22753           0 :       ALLOC_MUTEX(SgTypeLongLong, unlock);
   22754             :       return;
   22755             :     }
   22756             : #endif
   22757             : 
   22758           9 :     SgTypeLongLong * object = (SgTypeLongLong*) Pointer;
   22759           9 :     ROSE_ASSERT(object != nullptr);
   22760             : 
   22761             : #if ROSE_ALLOC_TRACE == 2
   22762             : //  printf("SgTypeLongLong::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeLongLong::next_node);
   22763             :     printf("SgTypeLongLong::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeLongLong::next_node);
   22764             : #endif
   22765             : 
   22766             : #if ROSE_PEDANTIC_ALLOC
   22767             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   22768             : #endif
   22769             : 
   22770             : #if ROSE_ALLOC_MEMSET == 1
   22771             : #elif ROSE_ALLOC_MEMSET == 2
   22772             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgTypeLongLong) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   22773             : #elif ROSE_ALLOC_MEMSET == 3
   22774             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgTypeLongLong) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   22775             : #endif
   22776             : 
   22777             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   22778             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   22779             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   22780             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   22781             : #else
   22782           9 :     object->p_freepointer = SgTypeLongLong::next_node;
   22783           9 :     SgTypeLongLong::next_node = object;
   22784             : #endif
   22785             : 
   22786             : #if ROSE_ALLOC_TRACE == 2
   22787             : //  printf("SgTypeLongLong::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeLongLong::next_node);
   22788             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   22789             :     Rose::MemPool::snapshot(oss.str());
   22790             :     alloc_trace_cnt++;
   22791             : #endif
   22792             : 
   22793             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   22794             : 
   22795           9 :     ALLOC_MUTEX(SgTypeLongLong, unlock);
   22796             : }
   22797             : 
   22798             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   22799             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   22800             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   22801             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   22802             : // Also, note comment below from Robb (copied from the Common.code file).
   22803             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   22804             : //
   22805             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   22806             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   22807             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   22808             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   22809             : #if 0
   22810             : void SgTypeLongLong::operator delete(void* pointer) { SgTypeLongLong::operator delete (pointer, sizeof(SgTypeLongLong)); };
   22811             : #endif
   22812             : /* #line 22813 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   22813             : 
   22814             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   22815             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   22816             : // obviously imply C++.
   22817             : 
   22818             : // This implements the support within ROSE for memory pools.  Memory pools
   22819             : // support the most condensed usage of memory within the construction of
   22820             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   22821             : // by a new operator written for each class.
   22822             : 
   22823             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   22824             :     // User wants multi-thread support and POSIX threads are available.
   22825             : #   include <pthread.h>
   22826             :     static pthread_mutex_t SgTypeSignedLongLong_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   22827             : #else
   22828             :      // Cause synchronization to be skipped.
   22829             : #    ifndef ALLOC_MUTEX
   22830             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   22831             : #    endif
   22832             : #    ifdef _REENTRANT
   22833             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   22834             : #       ifdef _MSC_VER
   22835             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   22836             : #       else
   22837             : #           warning "POSIX threads are not available; synchronization being skipped"
   22838             : #       endif
   22839             : #    endif
   22840             : #endif
   22841             : 
   22842             : #ifndef ROSE_ALLOC_TRACE
   22843             : #  define ROSE_ALLOC_TRACE 0
   22844             : #endif
   22845             : 
   22846             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   22847             : #define ROSE_ALLOC_TRACE_CNT
   22848             : #include "memory-pool-snapshot.h"
   22849             : unsigned long alloc_trace_cnt = 0;
   22850             : #endif
   22851             : 
   22852             : #if ROSE_ALLOC_TRACE
   22853             : const unsigned SgTypeSignedLongLong::pool_size = 5;
   22854             : #else
   22855             : const unsigned SgTypeSignedLongLong::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   22856             : #endif
   22857             : 
   22858             : #ifndef ROSE_ALLOC_MEMSET
   22859             : #  define ROSE_ALLOC_MEMSET 0
   22860             : #endif
   22861             : 
   22862             : #ifndef ROSE_PEDANTIC_ALLOC
   22863             : #  define ROSE_PEDANTIC_ALLOC 0
   22864             : #endif
   22865             : 
   22866             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   22867             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   22868             : #endif
   22869             : 
   22870             : #if !defined(SGNODE__ALL_POOLS)
   22871             : #define SGNODE__ALL_POOLS
   22872             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   22873             : #endif
   22874             : 
   22875             : SgTypeSignedLongLong* SgTypeSignedLongLong::next_node = nullptr;
   22876             : std::vector<unsigned char*> SgTypeSignedLongLong::pools;
   22877             : 
   22878             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   22879             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   22880             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   22881             : // around this macro definition rather than each use).
   22882             : #ifndef ALLOC_MUTEX
   22883             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   22884             :         do {                                                                     \
   22885             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   22886             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   22887             :                 abort();                                                         \
   22888             :             }                                                                    \
   22889             :         } while (0);
   22890             : #endif
   22891             : 
   22892             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   22893             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   22894             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   22895             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   22896             : 
   22897             : /*! \brief New operator for SgTypeSignedLongLong.
   22898             : 
   22899             :    This new operator implements memory pools to provide most efficent 
   22900             :    use of the heap within construction of large ASTs.
   22901             : 
   22902             : \internal The new and delete operators use the lower level C malloc/free
   22903             :    function calls for performance and to make sure that mixing of malloc/free
   22904             :    and new/delete by the used can be caught more readily.  This may change
   22905             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   22906             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   22907             :    deallocate memory allocated using ROSE_MALLOC.
   22908             : */
   22909          11 : void *SgTypeSignedLongLong::operator new ( size_t Size )
   22910             : {
   22911             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   22912             :      * returning or throwing an exception. */
   22913          11 :     ALLOC_MUTEX(SgTypeSignedLongLong, lock);
   22914             : 
   22915             : #if ROSE_ALLOC_TRACE == 2
   22916             : //    printf("SgTypeSignedLongLong::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgTypeSignedLongLong::next_node);
   22917             : #endif
   22918             : 
   22919             : #if USE_CPP_NEW_DELETE_OPERATORS
   22920             :     void *mem = ROSE_MALLOC(Size);
   22921             :     ALLOC_MUTEX(SgTypeSignedLongLong, unlock);
   22922             :     return mem;
   22923             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   22924             : #if ROSE_PEDANTIC_ALLOC
   22925             :     ROSE_ASSERT(Size == sizeof(SgTypeSignedLongLong));
   22926             : #else
   22927          11 :     if (Size != sizeof(SgTypeSignedLongLong)) {
   22928           0 :       void * object = ROSE_MALLOC(Size);
   22929           0 :       ALLOC_MUTEX(SgTypeSignedLongLong, unlock);
   22930             :       return object;
   22931             :     }
   22932             : #endif
   22933             : 
   22934          11 :     if (SgTypeSignedLongLong::next_node == nullptr) {
   22935          10 :         SgTypeSignedLongLong * alloc = (SgTypeSignedLongLong*) ROSE_MALLOC ( SgTypeSignedLongLong::pool_size * sizeof(SgTypeSignedLongLong) );
   22936          10 :         ROSE_ASSERT(alloc != nullptr);
   22937             : 
   22938             : #if ROSE_ALLOC_TRACE == 2
   22939             : //        printf("SgTypeSignedLongLong::alloc\n  block[%zi] = [ %p , %p [\n", SgTypeSignedLongLong::pools.size(), alloc, alloc + SgTypeSignedLongLong::pool_size);
   22940             : #endif
   22941             : 
   22942             : #if ROSE_ALLOC_MEMSET == 1
   22943             : #elif ROSE_ALLOC_MEMSET == 2
   22944             :         memset(alloc, 0x00, SgTypeSignedLongLong::pool_size * sizeof(SgTypeSignedLongLong));
   22945             : #elif ROSE_ALLOC_MEMSET == 3
   22946             :         memset(alloc, 0xAA, SgTypeSignedLongLong::pool_size * sizeof(SgTypeSignedLongLong));
   22947             : #endif
   22948       20000 :         for (unsigned i=0; i < SgTypeSignedLongLong::pool_size-1; i++) {
   22949       19990 :           alloc[i].p_freepointer = &(alloc[i+1]);
   22950             :         }
   22951          10 :         alloc[SgTypeSignedLongLong::pool_size-1].p_freepointer = nullptr;
   22952             : 
   22953          10 :         SgTypeSignedLongLong::pools.push_back ( (unsigned char *) alloc );
   22954          10 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgTypeSignedLongLong::pool_size * sizeof(SgTypeSignedLongLong), V_SgTypeSignedLongLong ) );
   22955          10 :         SgTypeSignedLongLong::next_node = alloc;
   22956             :     }
   22957          11 :     ROSE_ASSERT(SgTypeSignedLongLong::next_node != nullptr);
   22958             : 
   22959          11 :     SgTypeSignedLongLong * object = SgTypeSignedLongLong::next_node;
   22960          11 :     SgTypeSignedLongLong::next_node = (SgTypeSignedLongLong*)(object->p_freepointer);
   22961             : 
   22962             : #if ROSE_ALLOC_TRACE == 2
   22963             :     printf("SgTypeSignedLongLong::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeSignedLongLong::next_node);
   22964             : #endif
   22965             : 
   22966          11 :     SgNode * fp = object->p_freepointer;
   22967             : #if ROSE_ALLOC_MEMSET == 1
   22968             : #elif ROSE_ALLOC_MEMSET == 2
   22969             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgTypeSignedLongLong) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   22970             : #elif ROSE_ALLOC_MEMSET == 3
   22971             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgTypeSignedLongLong) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   22972             : #endif
   22973          11 :     object->p_freepointer = fp;
   22974             : 
   22975             : #if ROSE_ALLOC_TRACE == 2
   22976             : //    printf("SgTypeSignedLongLong::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeSignedLongLong::next_node);
   22977             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   22978             :     Rose::MemPool::snapshot(oss.str());
   22979             :     alloc_trace_cnt++;
   22980             : #endif
   22981             : 
   22982          11 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   22983             : 
   22984          11 :     ALLOC_MUTEX(SgTypeSignedLongLong, unlock);
   22985             : 
   22986             :     return object;
   22987             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   22988             : }
   22989             : 
   22990             : 
   22991             : 
   22992             : /*! \brief Delete operator for SgTypeSignedLongLong.
   22993             : 
   22994             :    This delete operator implements deallocation using memory pools to 
   22995             :    provide most efficent use of the heap within construction of large ASTs.
   22996             : 
   22997             : \internal The new and delete operators use the lower level C malloc/free
   22998             :    function calls for performance and to make sure that mixing of malloc/free
   22999             :    and new/delete by the used can be caught more readily.  This may change
   23000             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   23001             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   23002             :    deallocate memory allocated using ROSE_MALLOC.
   23003             : */
   23004           2 : void SgTypeSignedLongLong::operator delete(void *Pointer, size_t Size)
   23005             : {
   23006             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   23007             :      * or throwing an exception. */
   23008           2 :     ALLOC_MUTEX(SgTypeSignedLongLong, lock);
   23009             : 
   23010             : #if USE_CPP_NEW_DELETE_OPERATORS
   23011             :     ROSE_FREE(Pointer);
   23012             : #else
   23013             : #if ROSE_PEDANTIC_ALLOC
   23014             :     ROSE_ASSERT(Size == sizeof(SgTypeSignedLongLong));
   23015             : #else
   23016           2 :     if (Size != sizeof(SgTypeSignedLongLong)) {
   23017           0 :       ROSE_FREE(Pointer);
   23018           0 :       ALLOC_MUTEX(SgTypeSignedLongLong, unlock);
   23019             :       return;
   23020             :     }
   23021             : #endif
   23022             : 
   23023           2 :     SgTypeSignedLongLong * object = (SgTypeSignedLongLong*) Pointer;
   23024           2 :     ROSE_ASSERT(object != nullptr);
   23025             : 
   23026             : #if ROSE_ALLOC_TRACE == 2
   23027             : //  printf("SgTypeSignedLongLong::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeSignedLongLong::next_node);
   23028             :     printf("SgTypeSignedLongLong::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeSignedLongLong::next_node);
   23029             : #endif
   23030             : 
   23031             : #if ROSE_PEDANTIC_ALLOC
   23032             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   23033             : #endif
   23034             : 
   23035             : #if ROSE_ALLOC_MEMSET == 1
   23036             : #elif ROSE_ALLOC_MEMSET == 2
   23037             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgTypeSignedLongLong) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   23038             : #elif ROSE_ALLOC_MEMSET == 3
   23039             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgTypeSignedLongLong) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   23040             : #endif
   23041             : 
   23042             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   23043             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   23044             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   23045             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   23046             : #else
   23047           2 :     object->p_freepointer = SgTypeSignedLongLong::next_node;
   23048           2 :     SgTypeSignedLongLong::next_node = object;
   23049             : #endif
   23050             : 
   23051             : #if ROSE_ALLOC_TRACE == 2
   23052             : //  printf("SgTypeSignedLongLong::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeSignedLongLong::next_node);
   23053             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   23054             :     Rose::MemPool::snapshot(oss.str());
   23055             :     alloc_trace_cnt++;
   23056             : #endif
   23057             : 
   23058             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   23059             : 
   23060           2 :     ALLOC_MUTEX(SgTypeSignedLongLong, unlock);
   23061             : }
   23062             : 
   23063             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   23064             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   23065             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   23066             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   23067             : // Also, note comment below from Robb (copied from the Common.code file).
   23068             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   23069             : //
   23070             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   23071             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   23072             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   23073             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   23074             : #if 0
   23075             : void SgTypeSignedLongLong::operator delete(void* pointer) { SgTypeSignedLongLong::operator delete (pointer, sizeof(SgTypeSignedLongLong)); };
   23076             : #endif
   23077             : /* #line 23078 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   23078             : 
   23079             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   23080             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   23081             : // obviously imply C++.
   23082             : 
   23083             : // This implements the support within ROSE for memory pools.  Memory pools
   23084             : // support the most condensed usage of memory within the construction of
   23085             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   23086             : // by a new operator written for each class.
   23087             : 
   23088             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   23089             :     // User wants multi-thread support and POSIX threads are available.
   23090             : #   include <pthread.h>
   23091             :     static pthread_mutex_t SgTypeUnsignedLongLong_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   23092             : #else
   23093             :      // Cause synchronization to be skipped.
   23094             : #    ifndef ALLOC_MUTEX
   23095             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   23096             : #    endif
   23097             : #    ifdef _REENTRANT
   23098             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   23099             : #       ifdef _MSC_VER
   23100             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   23101             : #       else
   23102             : #           warning "POSIX threads are not available; synchronization being skipped"
   23103             : #       endif
   23104             : #    endif
   23105             : #endif
   23106             : 
   23107             : #ifndef ROSE_ALLOC_TRACE
   23108             : #  define ROSE_ALLOC_TRACE 0
   23109             : #endif
   23110             : 
   23111             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   23112             : #define ROSE_ALLOC_TRACE_CNT
   23113             : #include "memory-pool-snapshot.h"
   23114             : unsigned long alloc_trace_cnt = 0;
   23115             : #endif
   23116             : 
   23117             : #if ROSE_ALLOC_TRACE
   23118             : const unsigned SgTypeUnsignedLongLong::pool_size = 5;
   23119             : #else
   23120             : const unsigned SgTypeUnsignedLongLong::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   23121             : #endif
   23122             : 
   23123             : #ifndef ROSE_ALLOC_MEMSET
   23124             : #  define ROSE_ALLOC_MEMSET 0
   23125             : #endif
   23126             : 
   23127             : #ifndef ROSE_PEDANTIC_ALLOC
   23128             : #  define ROSE_PEDANTIC_ALLOC 0
   23129             : #endif
   23130             : 
   23131             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   23132             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   23133             : #endif
   23134             : 
   23135             : #if !defined(SGNODE__ALL_POOLS)
   23136             : #define SGNODE__ALL_POOLS
   23137             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   23138             : #endif
   23139             : 
   23140             : SgTypeUnsignedLongLong* SgTypeUnsignedLongLong::next_node = nullptr;
   23141             : std::vector<unsigned char*> SgTypeUnsignedLongLong::pools;
   23142             : 
   23143             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   23144             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   23145             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   23146             : // around this macro definition rather than each use).
   23147             : #ifndef ALLOC_MUTEX
   23148             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   23149             :         do {                                                                     \
   23150             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   23151             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   23152             :                 abort();                                                         \
   23153             :             }                                                                    \
   23154             :         } while (0);
   23155             : #endif
   23156             : 
   23157             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   23158             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   23159             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   23160             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   23161             : 
   23162             : /*! \brief New operator for SgTypeUnsignedLongLong.
   23163             : 
   23164             :    This new operator implements memory pools to provide most efficent 
   23165             :    use of the heap within construction of large ASTs.
   23166             : 
   23167             : \internal The new and delete operators use the lower level C malloc/free
   23168             :    function calls for performance and to make sure that mixing of malloc/free
   23169             :    and new/delete by the used can be caught more readily.  This may change
   23170             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   23171             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   23172             :    deallocate memory allocated using ROSE_MALLOC.
   23173             : */
   23174         324 : void *SgTypeUnsignedLongLong::operator new ( size_t Size )
   23175             : {
   23176             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   23177             :      * returning or throwing an exception. */
   23178         324 :     ALLOC_MUTEX(SgTypeUnsignedLongLong, lock);
   23179             : 
   23180             : #if ROSE_ALLOC_TRACE == 2
   23181             : //    printf("SgTypeUnsignedLongLong::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgTypeUnsignedLongLong::next_node);
   23182             : #endif
   23183             : 
   23184             : #if USE_CPP_NEW_DELETE_OPERATORS
   23185             :     void *mem = ROSE_MALLOC(Size);
   23186             :     ALLOC_MUTEX(SgTypeUnsignedLongLong, unlock);
   23187             :     return mem;
   23188             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   23189             : #if ROSE_PEDANTIC_ALLOC
   23190             :     ROSE_ASSERT(Size == sizeof(SgTypeUnsignedLongLong));
   23191             : #else
   23192         324 :     if (Size != sizeof(SgTypeUnsignedLongLong)) {
   23193           0 :       void * object = ROSE_MALLOC(Size);
   23194           0 :       ALLOC_MUTEX(SgTypeUnsignedLongLong, unlock);
   23195             :       return object;
   23196             :     }
   23197             : #endif
   23198             : 
   23199         324 :     if (SgTypeUnsignedLongLong::next_node == nullptr) {
   23200         315 :         SgTypeUnsignedLongLong * alloc = (SgTypeUnsignedLongLong*) ROSE_MALLOC ( SgTypeUnsignedLongLong::pool_size * sizeof(SgTypeUnsignedLongLong) );
   23201         315 :         ROSE_ASSERT(alloc != nullptr);
   23202             : 
   23203             : #if ROSE_ALLOC_TRACE == 2
   23204             : //        printf("SgTypeUnsignedLongLong::alloc\n  block[%zi] = [ %p , %p [\n", SgTypeUnsignedLongLong::pools.size(), alloc, alloc + SgTypeUnsignedLongLong::pool_size);
   23205             : #endif
   23206             : 
   23207             : #if ROSE_ALLOC_MEMSET == 1
   23208             : #elif ROSE_ALLOC_MEMSET == 2
   23209             :         memset(alloc, 0x00, SgTypeUnsignedLongLong::pool_size * sizeof(SgTypeUnsignedLongLong));
   23210             : #elif ROSE_ALLOC_MEMSET == 3
   23211             :         memset(alloc, 0xAA, SgTypeUnsignedLongLong::pool_size * sizeof(SgTypeUnsignedLongLong));
   23212             : #endif
   23213      630000 :         for (unsigned i=0; i < SgTypeUnsignedLongLong::pool_size-1; i++) {
   23214      629685 :           alloc[i].p_freepointer = &(alloc[i+1]);
   23215             :         }
   23216         315 :         alloc[SgTypeUnsignedLongLong::pool_size-1].p_freepointer = nullptr;
   23217             : 
   23218         315 :         SgTypeUnsignedLongLong::pools.push_back ( (unsigned char *) alloc );
   23219         315 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgTypeUnsignedLongLong::pool_size * sizeof(SgTypeUnsignedLongLong), V_SgTypeUnsignedLongLong ) );
   23220         315 :         SgTypeUnsignedLongLong::next_node = alloc;
   23221             :     }
   23222         324 :     ROSE_ASSERT(SgTypeUnsignedLongLong::next_node != nullptr);
   23223             : 
   23224         324 :     SgTypeUnsignedLongLong * object = SgTypeUnsignedLongLong::next_node;
   23225         324 :     SgTypeUnsignedLongLong::next_node = (SgTypeUnsignedLongLong*)(object->p_freepointer);
   23226             : 
   23227             : #if ROSE_ALLOC_TRACE == 2
   23228             :     printf("SgTypeUnsignedLongLong::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeUnsignedLongLong::next_node);
   23229             : #endif
   23230             : 
   23231         324 :     SgNode * fp = object->p_freepointer;
   23232             : #if ROSE_ALLOC_MEMSET == 1
   23233             : #elif ROSE_ALLOC_MEMSET == 2
   23234             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgTypeUnsignedLongLong) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   23235             : #elif ROSE_ALLOC_MEMSET == 3
   23236             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgTypeUnsignedLongLong) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   23237             : #endif
   23238         324 :     object->p_freepointer = fp;
   23239             : 
   23240             : #if ROSE_ALLOC_TRACE == 2
   23241             : //    printf("SgTypeUnsignedLongLong::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeUnsignedLongLong::next_node);
   23242             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   23243             :     Rose::MemPool::snapshot(oss.str());
   23244             :     alloc_trace_cnt++;
   23245             : #endif
   23246             : 
   23247         324 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   23248             : 
   23249         324 :     ALLOC_MUTEX(SgTypeUnsignedLongLong, unlock);
   23250             : 
   23251             :     return object;
   23252             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   23253             : }
   23254             : 
   23255             : 
   23256             : 
   23257             : /*! \brief Delete operator for SgTypeUnsignedLongLong.
   23258             : 
   23259             :    This delete operator implements deallocation using memory pools to 
   23260             :    provide most efficent use of the heap within construction of large ASTs.
   23261             : 
   23262             : \internal The new and delete operators use the lower level C malloc/free
   23263             :    function calls for performance and to make sure that mixing of malloc/free
   23264             :    and new/delete by the used can be caught more readily.  This may change
   23265             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   23266             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   23267             :    deallocate memory allocated using ROSE_MALLOC.
   23268             : */
   23269          11 : void SgTypeUnsignedLongLong::operator delete(void *Pointer, size_t Size)
   23270             : {
   23271             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   23272             :      * or throwing an exception. */
   23273          11 :     ALLOC_MUTEX(SgTypeUnsignedLongLong, lock);
   23274             : 
   23275             : #if USE_CPP_NEW_DELETE_OPERATORS
   23276             :     ROSE_FREE(Pointer);
   23277             : #else
   23278             : #if ROSE_PEDANTIC_ALLOC
   23279             :     ROSE_ASSERT(Size == sizeof(SgTypeUnsignedLongLong));
   23280             : #else
   23281          11 :     if (Size != sizeof(SgTypeUnsignedLongLong)) {
   23282           0 :       ROSE_FREE(Pointer);
   23283           0 :       ALLOC_MUTEX(SgTypeUnsignedLongLong, unlock);
   23284             :       return;
   23285             :     }
   23286             : #endif
   23287             : 
   23288          11 :     SgTypeUnsignedLongLong * object = (SgTypeUnsignedLongLong*) Pointer;
   23289          11 :     ROSE_ASSERT(object != nullptr);
   23290             : 
   23291             : #if ROSE_ALLOC_TRACE == 2
   23292             : //  printf("SgTypeUnsignedLongLong::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeUnsignedLongLong::next_node);
   23293             :     printf("SgTypeUnsignedLongLong::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeUnsignedLongLong::next_node);
   23294             : #endif
   23295             : 
   23296             : #if ROSE_PEDANTIC_ALLOC
   23297             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   23298             : #endif
   23299             : 
   23300             : #if ROSE_ALLOC_MEMSET == 1
   23301             : #elif ROSE_ALLOC_MEMSET == 2
   23302             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgTypeUnsignedLongLong) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   23303             : #elif ROSE_ALLOC_MEMSET == 3
   23304             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgTypeUnsignedLongLong) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   23305             : #endif
   23306             : 
   23307             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   23308             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   23309             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   23310             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   23311             : #else
   23312          11 :     object->p_freepointer = SgTypeUnsignedLongLong::next_node;
   23313          11 :     SgTypeUnsignedLongLong::next_node = object;
   23314             : #endif
   23315             : 
   23316             : #if ROSE_ALLOC_TRACE == 2
   23317             : //  printf("SgTypeUnsignedLongLong::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeUnsignedLongLong::next_node);
   23318             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   23319             :     Rose::MemPool::snapshot(oss.str());
   23320             :     alloc_trace_cnt++;
   23321             : #endif
   23322             : 
   23323             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   23324             : 
   23325          11 :     ALLOC_MUTEX(SgTypeUnsignedLongLong, unlock);
   23326             : }
   23327             : 
   23328             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   23329             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   23330             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   23331             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   23332             : // Also, note comment below from Robb (copied from the Common.code file).
   23333             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   23334             : //
   23335             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   23336             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   23337             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   23338             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   23339             : #if 0
   23340             : void SgTypeUnsignedLongLong::operator delete(void* pointer) { SgTypeUnsignedLongLong::operator delete (pointer, sizeof(SgTypeUnsignedLongLong)); };
   23341             : #endif
   23342             : /* #line 23343 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   23343             : 
   23344             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   23345             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   23346             : // obviously imply C++.
   23347             : 
   23348             : // This implements the support within ROSE for memory pools.  Memory pools
   23349             : // support the most condensed usage of memory within the construction of
   23350             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   23351             : // by a new operator written for each class.
   23352             : 
   23353             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   23354             :     // User wants multi-thread support and POSIX threads are available.
   23355             : #   include <pthread.h>
   23356             :     static pthread_mutex_t SgTypeSigned128bitInteger_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   23357             : #else
   23358             :      // Cause synchronization to be skipped.
   23359             : #    ifndef ALLOC_MUTEX
   23360             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   23361             : #    endif
   23362             : #    ifdef _REENTRANT
   23363             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   23364             : #       ifdef _MSC_VER
   23365             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   23366             : #       else
   23367             : #           warning "POSIX threads are not available; synchronization being skipped"
   23368             : #       endif
   23369             : #    endif
   23370             : #endif
   23371             : 
   23372             : #ifndef ROSE_ALLOC_TRACE
   23373             : #  define ROSE_ALLOC_TRACE 0
   23374             : #endif
   23375             : 
   23376             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   23377             : #define ROSE_ALLOC_TRACE_CNT
   23378             : #include "memory-pool-snapshot.h"
   23379             : unsigned long alloc_trace_cnt = 0;
   23380             : #endif
   23381             : 
   23382             : #if ROSE_ALLOC_TRACE
   23383             : const unsigned SgTypeSigned128bitInteger::pool_size = 5;
   23384             : #else
   23385             : const unsigned SgTypeSigned128bitInteger::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   23386             : #endif
   23387             : 
   23388             : #ifndef ROSE_ALLOC_MEMSET
   23389             : #  define ROSE_ALLOC_MEMSET 0
   23390             : #endif
   23391             : 
   23392             : #ifndef ROSE_PEDANTIC_ALLOC
   23393             : #  define ROSE_PEDANTIC_ALLOC 0
   23394             : #endif
   23395             : 
   23396             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   23397             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   23398             : #endif
   23399             : 
   23400             : #if !defined(SGNODE__ALL_POOLS)
   23401             : #define SGNODE__ALL_POOLS
   23402             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   23403             : #endif
   23404             : 
   23405             : SgTypeSigned128bitInteger* SgTypeSigned128bitInteger::next_node = nullptr;
   23406             : std::vector<unsigned char*> SgTypeSigned128bitInteger::pools;
   23407             : 
   23408             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   23409             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   23410             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   23411             : // around this macro definition rather than each use).
   23412             : #ifndef ALLOC_MUTEX
   23413             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   23414             :         do {                                                                     \
   23415             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   23416             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   23417             :                 abort();                                                         \
   23418             :             }                                                                    \
   23419             :         } while (0);
   23420             : #endif
   23421             : 
   23422             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   23423             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   23424             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   23425             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   23426             : 
   23427             : /*! \brief New operator for SgTypeSigned128bitInteger.
   23428             : 
   23429             :    This new operator implements memory pools to provide most efficent 
   23430             :    use of the heap within construction of large ASTs.
   23431             : 
   23432             : \internal The new and delete operators use the lower level C malloc/free
   23433             :    function calls for performance and to make sure that mixing of malloc/free
   23434             :    and new/delete by the used can be caught more readily.  This may change
   23435             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   23436             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   23437             :    deallocate memory allocated using ROSE_MALLOC.
   23438             : */
   23439          67 : void *SgTypeSigned128bitInteger::operator new ( size_t Size )
   23440             : {
   23441             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   23442             :      * returning or throwing an exception. */
   23443          67 :     ALLOC_MUTEX(SgTypeSigned128bitInteger, lock);
   23444             : 
   23445             : #if ROSE_ALLOC_TRACE == 2
   23446             : //    printf("SgTypeSigned128bitInteger::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgTypeSigned128bitInteger::next_node);
   23447             : #endif
   23448             : 
   23449             : #if USE_CPP_NEW_DELETE_OPERATORS
   23450             :     void *mem = ROSE_MALLOC(Size);
   23451             :     ALLOC_MUTEX(SgTypeSigned128bitInteger, unlock);
   23452             :     return mem;
   23453             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   23454             : #if ROSE_PEDANTIC_ALLOC
   23455             :     ROSE_ASSERT(Size == sizeof(SgTypeSigned128bitInteger));
   23456             : #else
   23457          67 :     if (Size != sizeof(SgTypeSigned128bitInteger)) {
   23458           0 :       void * object = ROSE_MALLOC(Size);
   23459           0 :       ALLOC_MUTEX(SgTypeSigned128bitInteger, unlock);
   23460             :       return object;
   23461             :     }
   23462             : #endif
   23463             : 
   23464          67 :     if (SgTypeSigned128bitInteger::next_node == nullptr) {
   23465          62 :         SgTypeSigned128bitInteger * alloc = (SgTypeSigned128bitInteger*) ROSE_MALLOC ( SgTypeSigned128bitInteger::pool_size * sizeof(SgTypeSigned128bitInteger) );
   23466          62 :         ROSE_ASSERT(alloc != nullptr);
   23467             : 
   23468             : #if ROSE_ALLOC_TRACE == 2
   23469             : //        printf("SgTypeSigned128bitInteger::alloc\n  block[%zi] = [ %p , %p [\n", SgTypeSigned128bitInteger::pools.size(), alloc, alloc + SgTypeSigned128bitInteger::pool_size);
   23470             : #endif
   23471             : 
   23472             : #if ROSE_ALLOC_MEMSET == 1
   23473             : #elif ROSE_ALLOC_MEMSET == 2
   23474             :         memset(alloc, 0x00, SgTypeSigned128bitInteger::pool_size * sizeof(SgTypeSigned128bitInteger));
   23475             : #elif ROSE_ALLOC_MEMSET == 3
   23476             :         memset(alloc, 0xAA, SgTypeSigned128bitInteger::pool_size * sizeof(SgTypeSigned128bitInteger));
   23477             : #endif
   23478      124000 :         for (unsigned i=0; i < SgTypeSigned128bitInteger::pool_size-1; i++) {
   23479      123938 :           alloc[i].p_freepointer = &(alloc[i+1]);
   23480             :         }
   23481          62 :         alloc[SgTypeSigned128bitInteger::pool_size-1].p_freepointer = nullptr;
   23482             : 
   23483          62 :         SgTypeSigned128bitInteger::pools.push_back ( (unsigned char *) alloc );
   23484          62 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgTypeSigned128bitInteger::pool_size * sizeof(SgTypeSigned128bitInteger), V_SgTypeSigned128bitInteger ) );
   23485          62 :         SgTypeSigned128bitInteger::next_node = alloc;
   23486             :     }
   23487          67 :     ROSE_ASSERT(SgTypeSigned128bitInteger::next_node != nullptr);
   23488             : 
   23489          67 :     SgTypeSigned128bitInteger * object = SgTypeSigned128bitInteger::next_node;
   23490          67 :     SgTypeSigned128bitInteger::next_node = (SgTypeSigned128bitInteger*)(object->p_freepointer);
   23491             : 
   23492             : #if ROSE_ALLOC_TRACE == 2
   23493             :     printf("SgTypeSigned128bitInteger::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeSigned128bitInteger::next_node);
   23494             : #endif
   23495             : 
   23496          67 :     SgNode * fp = object->p_freepointer;
   23497             : #if ROSE_ALLOC_MEMSET == 1
   23498             : #elif ROSE_ALLOC_MEMSET == 2
   23499             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgTypeSigned128bitInteger) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   23500             : #elif ROSE_ALLOC_MEMSET == 3
   23501             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgTypeSigned128bitInteger) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   23502             : #endif
   23503          67 :     object->p_freepointer = fp;
   23504             : 
   23505             : #if ROSE_ALLOC_TRACE == 2
   23506             : //    printf("SgTypeSigned128bitInteger::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeSigned128bitInteger::next_node);
   23507             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   23508             :     Rose::MemPool::snapshot(oss.str());
   23509             :     alloc_trace_cnt++;
   23510             : #endif
   23511             : 
   23512          67 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   23513             : 
   23514          67 :     ALLOC_MUTEX(SgTypeSigned128bitInteger, unlock);
   23515             : 
   23516             :     return object;
   23517             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   23518             : }
   23519             : 
   23520             : 
   23521             : 
   23522             : /*! \brief Delete operator for SgTypeSigned128bitInteger.
   23523             : 
   23524             :    This delete operator implements deallocation using memory pools to 
   23525             :    provide most efficent use of the heap within construction of large ASTs.
   23526             : 
   23527             : \internal The new and delete operators use the lower level C malloc/free
   23528             :    function calls for performance and to make sure that mixing of malloc/free
   23529             :    and new/delete by the used can be caught more readily.  This may change
   23530             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   23531             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   23532             :    deallocate memory allocated using ROSE_MALLOC.
   23533             : */
   23534           6 : void SgTypeSigned128bitInteger::operator delete(void *Pointer, size_t Size)
   23535             : {
   23536             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   23537             :      * or throwing an exception. */
   23538           6 :     ALLOC_MUTEX(SgTypeSigned128bitInteger, lock);
   23539             : 
   23540             : #if USE_CPP_NEW_DELETE_OPERATORS
   23541             :     ROSE_FREE(Pointer);
   23542             : #else
   23543             : #if ROSE_PEDANTIC_ALLOC
   23544             :     ROSE_ASSERT(Size == sizeof(SgTypeSigned128bitInteger));
   23545             : #else
   23546           6 :     if (Size != sizeof(SgTypeSigned128bitInteger)) {
   23547           0 :       ROSE_FREE(Pointer);
   23548           0 :       ALLOC_MUTEX(SgTypeSigned128bitInteger, unlock);
   23549             :       return;
   23550             :     }
   23551             : #endif
   23552             : 
   23553           6 :     SgTypeSigned128bitInteger * object = (SgTypeSigned128bitInteger*) Pointer;
   23554           6 :     ROSE_ASSERT(object != nullptr);
   23555             : 
   23556             : #if ROSE_ALLOC_TRACE == 2
   23557             : //  printf("SgTypeSigned128bitInteger::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeSigned128bitInteger::next_node);
   23558             :     printf("SgTypeSigned128bitInteger::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeSigned128bitInteger::next_node);
   23559             : #endif
   23560             : 
   23561             : #if ROSE_PEDANTIC_ALLOC
   23562             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   23563             : #endif
   23564             : 
   23565             : #if ROSE_ALLOC_MEMSET == 1
   23566             : #elif ROSE_ALLOC_MEMSET == 2
   23567             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgTypeSigned128bitInteger) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   23568             : #elif ROSE_ALLOC_MEMSET == 3
   23569             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgTypeSigned128bitInteger) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   23570             : #endif
   23571             : 
   23572             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   23573             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   23574             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   23575             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   23576             : #else
   23577           6 :     object->p_freepointer = SgTypeSigned128bitInteger::next_node;
   23578           6 :     SgTypeSigned128bitInteger::next_node = object;
   23579             : #endif
   23580             : 
   23581             : #if ROSE_ALLOC_TRACE == 2
   23582             : //  printf("SgTypeSigned128bitInteger::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeSigned128bitInteger::next_node);
   23583             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   23584             :     Rose::MemPool::snapshot(oss.str());
   23585             :     alloc_trace_cnt++;
   23586             : #endif
   23587             : 
   23588             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   23589             : 
   23590           6 :     ALLOC_MUTEX(SgTypeSigned128bitInteger, unlock);
   23591             : }
   23592             : 
   23593             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   23594             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   23595             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   23596             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   23597             : // Also, note comment below from Robb (copied from the Common.code file).
   23598             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   23599             : //
   23600             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   23601             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   23602             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   23603             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   23604             : #if 0
   23605             : void SgTypeSigned128bitInteger::operator delete(void* pointer) { SgTypeSigned128bitInteger::operator delete (pointer, sizeof(SgTypeSigned128bitInteger)); };
   23606             : #endif
   23607             : /* #line 23608 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   23608             : 
   23609             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   23610             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   23611             : // obviously imply C++.
   23612             : 
   23613             : // This implements the support within ROSE for memory pools.  Memory pools
   23614             : // support the most condensed usage of memory within the construction of
   23615             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   23616             : // by a new operator written for each class.
   23617             : 
   23618             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   23619             :     // User wants multi-thread support and POSIX threads are available.
   23620             : #   include <pthread.h>
   23621             :     static pthread_mutex_t SgTypeUnsigned128bitInteger_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   23622             : #else
   23623             :      // Cause synchronization to be skipped.
   23624             : #    ifndef ALLOC_MUTEX
   23625             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   23626             : #    endif
   23627             : #    ifdef _REENTRANT
   23628             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   23629             : #       ifdef _MSC_VER
   23630             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   23631             : #       else
   23632             : #           warning "POSIX threads are not available; synchronization being skipped"
   23633             : #       endif
   23634             : #    endif
   23635             : #endif
   23636             : 
   23637             : #ifndef ROSE_ALLOC_TRACE
   23638             : #  define ROSE_ALLOC_TRACE 0
   23639             : #endif
   23640             : 
   23641             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   23642             : #define ROSE_ALLOC_TRACE_CNT
   23643             : #include "memory-pool-snapshot.h"
   23644             : unsigned long alloc_trace_cnt = 0;
   23645             : #endif
   23646             : 
   23647             : #if ROSE_ALLOC_TRACE
   23648             : const unsigned SgTypeUnsigned128bitInteger::pool_size = 5;
   23649             : #else
   23650             : const unsigned SgTypeUnsigned128bitInteger::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   23651             : #endif
   23652             : 
   23653             : #ifndef ROSE_ALLOC_MEMSET
   23654             : #  define ROSE_ALLOC_MEMSET 0
   23655             : #endif
   23656             : 
   23657             : #ifndef ROSE_PEDANTIC_ALLOC
   23658             : #  define ROSE_PEDANTIC_ALLOC 0
   23659             : #endif
   23660             : 
   23661             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   23662             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   23663             : #endif
   23664             : 
   23665             : #if !defined(SGNODE__ALL_POOLS)
   23666             : #define SGNODE__ALL_POOLS
   23667             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   23668             : #endif
   23669             : 
   23670             : SgTypeUnsigned128bitInteger* SgTypeUnsigned128bitInteger::next_node = nullptr;
   23671             : std::vector<unsigned char*> SgTypeUnsigned128bitInteger::pools;
   23672             : 
   23673             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   23674             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   23675             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   23676             : // around this macro definition rather than each use).
   23677             : #ifndef ALLOC_MUTEX
   23678             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   23679             :         do {                                                                     \
   23680             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   23681             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   23682             :                 abort();                                                         \
   23683             :             }                                                                    \
   23684             :         } while (0);
   23685             : #endif
   23686             : 
   23687             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   23688             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   23689             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   23690             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   23691             : 
   23692             : /*! \brief New operator for SgTypeUnsigned128bitInteger.
   23693             : 
   23694             :    This new operator implements memory pools to provide most efficent 
   23695             :    use of the heap within construction of large ASTs.
   23696             : 
   23697             : \internal The new and delete operators use the lower level C malloc/free
   23698             :    function calls for performance and to make sure that mixing of malloc/free
   23699             :    and new/delete by the used can be caught more readily.  This may change
   23700             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   23701             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   23702             :    deallocate memory allocated using ROSE_MALLOC.
   23703             : */
   23704          11 : void *SgTypeUnsigned128bitInteger::operator new ( size_t Size )
   23705             : {
   23706             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   23707             :      * returning or throwing an exception. */
   23708          11 :     ALLOC_MUTEX(SgTypeUnsigned128bitInteger, lock);
   23709             : 
   23710             : #if ROSE_ALLOC_TRACE == 2
   23711             : //    printf("SgTypeUnsigned128bitInteger::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgTypeUnsigned128bitInteger::next_node);
   23712             : #endif
   23713             : 
   23714             : #if USE_CPP_NEW_DELETE_OPERATORS
   23715             :     void *mem = ROSE_MALLOC(Size);
   23716             :     ALLOC_MUTEX(SgTypeUnsigned128bitInteger, unlock);
   23717             :     return mem;
   23718             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   23719             : #if ROSE_PEDANTIC_ALLOC
   23720             :     ROSE_ASSERT(Size == sizeof(SgTypeUnsigned128bitInteger));
   23721             : #else
   23722          11 :     if (Size != sizeof(SgTypeUnsigned128bitInteger)) {
   23723           0 :       void * object = ROSE_MALLOC(Size);
   23724           0 :       ALLOC_MUTEX(SgTypeUnsigned128bitInteger, unlock);
   23725             :       return object;
   23726             :     }
   23727             : #endif
   23728             : 
   23729          11 :     if (SgTypeUnsigned128bitInteger::next_node == nullptr) {
   23730          10 :         SgTypeUnsigned128bitInteger * alloc = (SgTypeUnsigned128bitInteger*) ROSE_MALLOC ( SgTypeUnsigned128bitInteger::pool_size * sizeof(SgTypeUnsigned128bitInteger) );
   23731          10 :         ROSE_ASSERT(alloc != nullptr);
   23732             : 
   23733             : #if ROSE_ALLOC_TRACE == 2
   23734             : //        printf("SgTypeUnsigned128bitInteger::alloc\n  block[%zi] = [ %p , %p [\n", SgTypeUnsigned128bitInteger::pools.size(), alloc, alloc + SgTypeUnsigned128bitInteger::pool_size);
   23735             : #endif
   23736             : 
   23737             : #if ROSE_ALLOC_MEMSET == 1
   23738             : #elif ROSE_ALLOC_MEMSET == 2
   23739             :         memset(alloc, 0x00, SgTypeUnsigned128bitInteger::pool_size * sizeof(SgTypeUnsigned128bitInteger));
   23740             : #elif ROSE_ALLOC_MEMSET == 3
   23741             :         memset(alloc, 0xAA, SgTypeUnsigned128bitInteger::pool_size * sizeof(SgTypeUnsigned128bitInteger));
   23742             : #endif
   23743       20000 :         for (unsigned i=0; i < SgTypeUnsigned128bitInteger::pool_size-1; i++) {
   23744       19990 :           alloc[i].p_freepointer = &(alloc[i+1]);
   23745             :         }
   23746          10 :         alloc[SgTypeUnsigned128bitInteger::pool_size-1].p_freepointer = nullptr;
   23747             : 
   23748          10 :         SgTypeUnsigned128bitInteger::pools.push_back ( (unsigned char *) alloc );
   23749          10 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgTypeUnsigned128bitInteger::pool_size * sizeof(SgTypeUnsigned128bitInteger), V_SgTypeUnsigned128bitInteger ) );
   23750          10 :         SgTypeUnsigned128bitInteger::next_node = alloc;
   23751             :     }
   23752          11 :     ROSE_ASSERT(SgTypeUnsigned128bitInteger::next_node != nullptr);
   23753             : 
   23754          11 :     SgTypeUnsigned128bitInteger * object = SgTypeUnsigned128bitInteger::next_node;
   23755          11 :     SgTypeUnsigned128bitInteger::next_node = (SgTypeUnsigned128bitInteger*)(object->p_freepointer);
   23756             : 
   23757             : #if ROSE_ALLOC_TRACE == 2
   23758             :     printf("SgTypeUnsigned128bitInteger::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeUnsigned128bitInteger::next_node);
   23759             : #endif
   23760             : 
   23761          11 :     SgNode * fp = object->p_freepointer;
   23762             : #if ROSE_ALLOC_MEMSET == 1
   23763             : #elif ROSE_ALLOC_MEMSET == 2
   23764             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgTypeUnsigned128bitInteger) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   23765             : #elif ROSE_ALLOC_MEMSET == 3
   23766             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgTypeUnsigned128bitInteger) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   23767             : #endif
   23768          11 :     object->p_freepointer = fp;
   23769             : 
   23770             : #if ROSE_ALLOC_TRACE == 2
   23771             : //    printf("SgTypeUnsigned128bitInteger::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeUnsigned128bitInteger::next_node);
   23772             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   23773             :     Rose::MemPool::snapshot(oss.str());
   23774             :     alloc_trace_cnt++;
   23775             : #endif
   23776             : 
   23777          11 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   23778             : 
   23779          11 :     ALLOC_MUTEX(SgTypeUnsigned128bitInteger, unlock);
   23780             : 
   23781             :     return object;
   23782             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   23783             : }
   23784             : 
   23785             : 
   23786             : 
   23787             : /*! \brief Delete operator for SgTypeUnsigned128bitInteger.
   23788             : 
   23789             :    This delete operator implements deallocation using memory pools to 
   23790             :    provide most efficent use of the heap within construction of large ASTs.
   23791             : 
   23792             : \internal The new and delete operators use the lower level C malloc/free
   23793             :    function calls for performance and to make sure that mixing of malloc/free
   23794             :    and new/delete by the used can be caught more readily.  This may change
   23795             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   23796             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   23797             :    deallocate memory allocated using ROSE_MALLOC.
   23798             : */
   23799           2 : void SgTypeUnsigned128bitInteger::operator delete(void *Pointer, size_t Size)
   23800             : {
   23801             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   23802             :      * or throwing an exception. */
   23803           2 :     ALLOC_MUTEX(SgTypeUnsigned128bitInteger, lock);
   23804             : 
   23805             : #if USE_CPP_NEW_DELETE_OPERATORS
   23806             :     ROSE_FREE(Pointer);
   23807             : #else
   23808             : #if ROSE_PEDANTIC_ALLOC
   23809             :     ROSE_ASSERT(Size == sizeof(SgTypeUnsigned128bitInteger));
   23810             : #else
   23811           2 :     if (Size != sizeof(SgTypeUnsigned128bitInteger)) {
   23812           0 :       ROSE_FREE(Pointer);
   23813           0 :       ALLOC_MUTEX(SgTypeUnsigned128bitInteger, unlock);
   23814             :       return;
   23815             :     }
   23816             : #endif
   23817             : 
   23818           2 :     SgTypeUnsigned128bitInteger * object = (SgTypeUnsigned128bitInteger*) Pointer;
   23819           2 :     ROSE_ASSERT(object != nullptr);
   23820             : 
   23821             : #if ROSE_ALLOC_TRACE == 2
   23822             : //  printf("SgTypeUnsigned128bitInteger::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeUnsigned128bitInteger::next_node);
   23823             :     printf("SgTypeUnsigned128bitInteger::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeUnsigned128bitInteger::next_node);
   23824             : #endif
   23825             : 
   23826             : #if ROSE_PEDANTIC_ALLOC
   23827             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   23828             : #endif
   23829             : 
   23830             : #if ROSE_ALLOC_MEMSET == 1
   23831             : #elif ROSE_ALLOC_MEMSET == 2
   23832             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgTypeUnsigned128bitInteger) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   23833             : #elif ROSE_ALLOC_MEMSET == 3
   23834             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgTypeUnsigned128bitInteger) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   23835             : #endif
   23836             : 
   23837             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   23838             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   23839             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   23840             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   23841             : #else
   23842           2 :     object->p_freepointer = SgTypeUnsigned128bitInteger::next_node;
   23843           2 :     SgTypeUnsigned128bitInteger::next_node = object;
   23844             : #endif
   23845             : 
   23846             : #if ROSE_ALLOC_TRACE == 2
   23847             : //  printf("SgTypeUnsigned128bitInteger::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeUnsigned128bitInteger::next_node);
   23848             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   23849             :     Rose::MemPool::snapshot(oss.str());
   23850             :     alloc_trace_cnt++;
   23851             : #endif
   23852             : 
   23853             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   23854             : 
   23855           2 :     ALLOC_MUTEX(SgTypeUnsigned128bitInteger, unlock);
   23856             : }
   23857             : 
   23858             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   23859             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   23860             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   23861             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   23862             : // Also, note comment below from Robb (copied from the Common.code file).
   23863             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   23864             : //
   23865             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   23866             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   23867             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   23868             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   23869             : #if 0
   23870             : void SgTypeUnsigned128bitInteger::operator delete(void* pointer) { SgTypeUnsigned128bitInteger::operator delete (pointer, sizeof(SgTypeUnsigned128bitInteger)); };
   23871             : #endif
   23872             : /* #line 23873 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   23873             : 
   23874             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   23875             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   23876             : // obviously imply C++.
   23877             : 
   23878             : // This implements the support within ROSE for memory pools.  Memory pools
   23879             : // support the most condensed usage of memory within the construction of
   23880             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   23881             : // by a new operator written for each class.
   23882             : 
   23883             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   23884             :     // User wants multi-thread support and POSIX threads are available.
   23885             : #   include <pthread.h>
   23886             :     static pthread_mutex_t SgTypeFloat80_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   23887             : #else
   23888             :      // Cause synchronization to be skipped.
   23889             : #    ifndef ALLOC_MUTEX
   23890             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   23891             : #    endif
   23892             : #    ifdef _REENTRANT
   23893             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   23894             : #       ifdef _MSC_VER
   23895             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   23896             : #       else
   23897             : #           warning "POSIX threads are not available; synchronization being skipped"
   23898             : #       endif
   23899             : #    endif
   23900             : #endif
   23901             : 
   23902             : #ifndef ROSE_ALLOC_TRACE
   23903             : #  define ROSE_ALLOC_TRACE 0
   23904             : #endif
   23905             : 
   23906             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   23907             : #define ROSE_ALLOC_TRACE_CNT
   23908             : #include "memory-pool-snapshot.h"
   23909             : unsigned long alloc_trace_cnt = 0;
   23910             : #endif
   23911             : 
   23912             : #if ROSE_ALLOC_TRACE
   23913             : const unsigned SgTypeFloat80::pool_size = 5;
   23914             : #else
   23915             : const unsigned SgTypeFloat80::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   23916             : #endif
   23917             : 
   23918             : #ifndef ROSE_ALLOC_MEMSET
   23919             : #  define ROSE_ALLOC_MEMSET 0
   23920             : #endif
   23921             : 
   23922             : #ifndef ROSE_PEDANTIC_ALLOC
   23923             : #  define ROSE_PEDANTIC_ALLOC 0
   23924             : #endif
   23925             : 
   23926             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   23927             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   23928             : #endif
   23929             : 
   23930             : #if !defined(SGNODE__ALL_POOLS)
   23931             : #define SGNODE__ALL_POOLS
   23932             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   23933             : #endif
   23934             : 
   23935             : SgTypeFloat80* SgTypeFloat80::next_node = nullptr;
   23936             : std::vector<unsigned char*> SgTypeFloat80::pools;
   23937             : 
   23938             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   23939             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   23940             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   23941             : // around this macro definition rather than each use).
   23942             : #ifndef ALLOC_MUTEX
   23943             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   23944             :         do {                                                                     \
   23945             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   23946             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   23947             :                 abort();                                                         \
   23948             :             }                                                                    \
   23949             :         } while (0);
   23950             : #endif
   23951             : 
   23952             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   23953             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   23954             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   23955             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   23956             : 
   23957             : /*! \brief New operator for SgTypeFloat80.
   23958             : 
   23959             :    This new operator implements memory pools to provide most efficent 
   23960             :    use of the heap within construction of large ASTs.
   23961             : 
   23962             : \internal The new and delete operators use the lower level C malloc/free
   23963             :    function calls for performance and to make sure that mixing of malloc/free
   23964             :    and new/delete by the used can be caught more readily.  This may change
   23965             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   23966             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   23967             :    deallocate memory allocated using ROSE_MALLOC.
   23968             : */
   23969           0 : void *SgTypeFloat80::operator new ( size_t Size )
   23970             : {
   23971             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   23972             :      * returning or throwing an exception. */
   23973           0 :     ALLOC_MUTEX(SgTypeFloat80, lock);
   23974             : 
   23975             : #if ROSE_ALLOC_TRACE == 2
   23976             : //    printf("SgTypeFloat80::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgTypeFloat80::next_node);
   23977             : #endif
   23978             : 
   23979             : #if USE_CPP_NEW_DELETE_OPERATORS
   23980             :     void *mem = ROSE_MALLOC(Size);
   23981             :     ALLOC_MUTEX(SgTypeFloat80, unlock);
   23982             :     return mem;
   23983             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   23984             : #if ROSE_PEDANTIC_ALLOC
   23985             :     ROSE_ASSERT(Size == sizeof(SgTypeFloat80));
   23986             : #else
   23987           0 :     if (Size != sizeof(SgTypeFloat80)) {
   23988           0 :       void * object = ROSE_MALLOC(Size);
   23989           0 :       ALLOC_MUTEX(SgTypeFloat80, unlock);
   23990             :       return object;
   23991             :     }
   23992             : #endif
   23993             : 
   23994           0 :     if (SgTypeFloat80::next_node == nullptr) {
   23995           0 :         SgTypeFloat80 * alloc = (SgTypeFloat80*) ROSE_MALLOC ( SgTypeFloat80::pool_size * sizeof(SgTypeFloat80) );
   23996           0 :         ROSE_ASSERT(alloc != nullptr);
   23997             : 
   23998             : #if ROSE_ALLOC_TRACE == 2
   23999             : //        printf("SgTypeFloat80::alloc\n  block[%zi] = [ %p , %p [\n", SgTypeFloat80::pools.size(), alloc, alloc + SgTypeFloat80::pool_size);
   24000             : #endif
   24001             : 
   24002             : #if ROSE_ALLOC_MEMSET == 1
   24003             : #elif ROSE_ALLOC_MEMSET == 2
   24004             :         memset(alloc, 0x00, SgTypeFloat80::pool_size * sizeof(SgTypeFloat80));
   24005             : #elif ROSE_ALLOC_MEMSET == 3
   24006             :         memset(alloc, 0xAA, SgTypeFloat80::pool_size * sizeof(SgTypeFloat80));
   24007             : #endif
   24008           0 :         for (unsigned i=0; i < SgTypeFloat80::pool_size-1; i++) {
   24009           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
   24010             :         }
   24011           0 :         alloc[SgTypeFloat80::pool_size-1].p_freepointer = nullptr;
   24012             : 
   24013           0 :         SgTypeFloat80::pools.push_back ( (unsigned char *) alloc );
   24014           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgTypeFloat80::pool_size * sizeof(SgTypeFloat80), V_SgTypeFloat80 ) );
   24015           0 :         SgTypeFloat80::next_node = alloc;
   24016             :     }
   24017           0 :     ROSE_ASSERT(SgTypeFloat80::next_node != nullptr);
   24018             : 
   24019           0 :     SgTypeFloat80 * object = SgTypeFloat80::next_node;
   24020           0 :     SgTypeFloat80::next_node = (SgTypeFloat80*)(object->p_freepointer);
   24021             : 
   24022             : #if ROSE_ALLOC_TRACE == 2
   24023             :     printf("SgTypeFloat80::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeFloat80::next_node);
   24024             : #endif
   24025             : 
   24026           0 :     SgNode * fp = object->p_freepointer;
   24027             : #if ROSE_ALLOC_MEMSET == 1
   24028             : #elif ROSE_ALLOC_MEMSET == 2
   24029             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgTypeFloat80) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   24030             : #elif ROSE_ALLOC_MEMSET == 3
   24031             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgTypeFloat80) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   24032             : #endif
   24033           0 :     object->p_freepointer = fp;
   24034             : 
   24035             : #if ROSE_ALLOC_TRACE == 2
   24036             : //    printf("SgTypeFloat80::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeFloat80::next_node);
   24037             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   24038             :     Rose::MemPool::snapshot(oss.str());
   24039             :     alloc_trace_cnt++;
   24040             : #endif
   24041             : 
   24042           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   24043             : 
   24044           0 :     ALLOC_MUTEX(SgTypeFloat80, unlock);
   24045             : 
   24046             :     return object;
   24047             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   24048             : }
   24049             : 
   24050             : 
   24051             : 
   24052             : /*! \brief Delete operator for SgTypeFloat80.
   24053             : 
   24054             :    This delete operator implements deallocation using memory pools to 
   24055             :    provide most efficent use of the heap within construction of large ASTs.
   24056             : 
   24057             : \internal The new and delete operators use the lower level C malloc/free
   24058             :    function calls for performance and to make sure that mixing of malloc/free
   24059             :    and new/delete by the used can be caught more readily.  This may change
   24060             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   24061             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   24062             :    deallocate memory allocated using ROSE_MALLOC.
   24063             : */
   24064           0 : void SgTypeFloat80::operator delete(void *Pointer, size_t Size)
   24065             : {
   24066             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   24067             :      * or throwing an exception. */
   24068           0 :     ALLOC_MUTEX(SgTypeFloat80, lock);
   24069             : 
   24070             : #if USE_CPP_NEW_DELETE_OPERATORS
   24071             :     ROSE_FREE(Pointer);
   24072             : #else
   24073             : #if ROSE_PEDANTIC_ALLOC
   24074             :     ROSE_ASSERT(Size == sizeof(SgTypeFloat80));
   24075             : #else
   24076           0 :     if (Size != sizeof(SgTypeFloat80)) {
   24077           0 :       ROSE_FREE(Pointer);
   24078           0 :       ALLOC_MUTEX(SgTypeFloat80, unlock);
   24079             :       return;
   24080             :     }
   24081             : #endif
   24082             : 
   24083           0 :     SgTypeFloat80 * object = (SgTypeFloat80*) Pointer;
   24084           0 :     ROSE_ASSERT(object != nullptr);
   24085             : 
   24086             : #if ROSE_ALLOC_TRACE == 2
   24087             : //  printf("SgTypeFloat80::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeFloat80::next_node);
   24088             :     printf("SgTypeFloat80::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeFloat80::next_node);
   24089             : #endif
   24090             : 
   24091             : #if ROSE_PEDANTIC_ALLOC
   24092             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   24093             : #endif
   24094             : 
   24095             : #if ROSE_ALLOC_MEMSET == 1
   24096             : #elif ROSE_ALLOC_MEMSET == 2
   24097             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgTypeFloat80) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   24098             : #elif ROSE_ALLOC_MEMSET == 3
   24099             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgTypeFloat80) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   24100             : #endif
   24101             : 
   24102             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   24103             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   24104             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   24105             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   24106             : #else
   24107           0 :     object->p_freepointer = SgTypeFloat80::next_node;
   24108           0 :     SgTypeFloat80::next_node = object;
   24109             : #endif
   24110             : 
   24111             : #if ROSE_ALLOC_TRACE == 2
   24112             : //  printf("SgTypeFloat80::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeFloat80::next_node);
   24113             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   24114             :     Rose::MemPool::snapshot(oss.str());
   24115             :     alloc_trace_cnt++;
   24116             : #endif
   24117             : 
   24118             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   24119             : 
   24120           0 :     ALLOC_MUTEX(SgTypeFloat80, unlock);
   24121             : }
   24122             : 
   24123             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   24124             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   24125             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   24126             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   24127             : // Also, note comment below from Robb (copied from the Common.code file).
   24128             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   24129             : //
   24130             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   24131             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   24132             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   24133             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   24134             : #if 0
   24135             : void SgTypeFloat80::operator delete(void* pointer) { SgTypeFloat80::operator delete (pointer, sizeof(SgTypeFloat80)); };
   24136             : #endif
   24137             : /* #line 24138 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   24138             : 
   24139             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   24140             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   24141             : // obviously imply C++.
   24142             : 
   24143             : // This implements the support within ROSE for memory pools.  Memory pools
   24144             : // support the most condensed usage of memory within the construction of
   24145             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   24146             : // by a new operator written for each class.
   24147             : 
   24148             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   24149             :     // User wants multi-thread support and POSIX threads are available.
   24150             : #   include <pthread.h>
   24151             :     static pthread_mutex_t SgTypeLongDouble_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   24152             : #else
   24153             :      // Cause synchronization to be skipped.
   24154             : #    ifndef ALLOC_MUTEX
   24155             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   24156             : #    endif
   24157             : #    ifdef _REENTRANT
   24158             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   24159             : #       ifdef _MSC_VER
   24160             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   24161             : #       else
   24162             : #           warning "POSIX threads are not available; synchronization being skipped"
   24163             : #       endif
   24164             : #    endif
   24165             : #endif
   24166             : 
   24167             : #ifndef ROSE_ALLOC_TRACE
   24168             : #  define ROSE_ALLOC_TRACE 0
   24169             : #endif
   24170             : 
   24171             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   24172             : #define ROSE_ALLOC_TRACE_CNT
   24173             : #include "memory-pool-snapshot.h"
   24174             : unsigned long alloc_trace_cnt = 0;
   24175             : #endif
   24176             : 
   24177             : #if ROSE_ALLOC_TRACE
   24178             : const unsigned SgTypeLongDouble::pool_size = 5;
   24179             : #else
   24180             : const unsigned SgTypeLongDouble::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   24181             : #endif
   24182             : 
   24183             : #ifndef ROSE_ALLOC_MEMSET
   24184             : #  define ROSE_ALLOC_MEMSET 0
   24185             : #endif
   24186             : 
   24187             : #ifndef ROSE_PEDANTIC_ALLOC
   24188             : #  define ROSE_PEDANTIC_ALLOC 0
   24189             : #endif
   24190             : 
   24191             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   24192             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   24193             : #endif
   24194             : 
   24195             : #if !defined(SGNODE__ALL_POOLS)
   24196             : #define SGNODE__ALL_POOLS
   24197             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   24198             : #endif
   24199             : 
   24200             : SgTypeLongDouble* SgTypeLongDouble::next_node = nullptr;
   24201             : std::vector<unsigned char*> SgTypeLongDouble::pools;
   24202             : 
   24203             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   24204             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   24205             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   24206             : // around this macro definition rather than each use).
   24207             : #ifndef ALLOC_MUTEX
   24208             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   24209             :         do {                                                                     \
   24210             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   24211             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   24212             :                 abort();                                                         \
   24213             :             }                                                                    \
   24214             :         } while (0);
   24215             : #endif
   24216             : 
   24217             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   24218             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   24219             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   24220             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   24221             : 
   24222             : /*! \brief New operator for SgTypeLongDouble.
   24223             : 
   24224             :    This new operator implements memory pools to provide most efficent 
   24225             :    use of the heap within construction of large ASTs.
   24226             : 
   24227             : \internal The new and delete operators use the lower level C malloc/free
   24228             :    function calls for performance and to make sure that mixing of malloc/free
   24229             :    and new/delete by the used can be caught more readily.  This may change
   24230             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   24231             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   24232             :    deallocate memory allocated using ROSE_MALLOC.
   24233             : */
   24234         644 : void *SgTypeLongDouble::operator new ( size_t Size )
   24235             : {
   24236             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   24237             :      * returning or throwing an exception. */
   24238         644 :     ALLOC_MUTEX(SgTypeLongDouble, lock);
   24239             : 
   24240             : #if ROSE_ALLOC_TRACE == 2
   24241             : //    printf("SgTypeLongDouble::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgTypeLongDouble::next_node);
   24242             : #endif
   24243             : 
   24244             : #if USE_CPP_NEW_DELETE_OPERATORS
   24245             :     void *mem = ROSE_MALLOC(Size);
   24246             :     ALLOC_MUTEX(SgTypeLongDouble, unlock);
   24247             :     return mem;
   24248             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   24249             : #if ROSE_PEDANTIC_ALLOC
   24250             :     ROSE_ASSERT(Size == sizeof(SgTypeLongDouble));
   24251             : #else
   24252         644 :     if (Size != sizeof(SgTypeLongDouble)) {
   24253           0 :       void * object = ROSE_MALLOC(Size);
   24254           0 :       ALLOC_MUTEX(SgTypeLongDouble, unlock);
   24255             :       return object;
   24256             :     }
   24257             : #endif
   24258             : 
   24259         644 :     if (SgTypeLongDouble::next_node == nullptr) {
   24260         315 :         SgTypeLongDouble * alloc = (SgTypeLongDouble*) ROSE_MALLOC ( SgTypeLongDouble::pool_size * sizeof(SgTypeLongDouble) );
   24261         315 :         ROSE_ASSERT(alloc != nullptr);
   24262             : 
   24263             : #if ROSE_ALLOC_TRACE == 2
   24264             : //        printf("SgTypeLongDouble::alloc\n  block[%zi] = [ %p , %p [\n", SgTypeLongDouble::pools.size(), alloc, alloc + SgTypeLongDouble::pool_size);
   24265             : #endif
   24266             : 
   24267             : #if ROSE_ALLOC_MEMSET == 1
   24268             : #elif ROSE_ALLOC_MEMSET == 2
   24269             :         memset(alloc, 0x00, SgTypeLongDouble::pool_size * sizeof(SgTypeLongDouble));
   24270             : #elif ROSE_ALLOC_MEMSET == 3
   24271             :         memset(alloc, 0xAA, SgTypeLongDouble::pool_size * sizeof(SgTypeLongDouble));
   24272             : #endif
   24273      630000 :         for (unsigned i=0; i < SgTypeLongDouble::pool_size-1; i++) {
   24274      629685 :           alloc[i].p_freepointer = &(alloc[i+1]);
   24275             :         }
   24276         315 :         alloc[SgTypeLongDouble::pool_size-1].p_freepointer = nullptr;
   24277             : 
   24278         315 :         SgTypeLongDouble::pools.push_back ( (unsigned char *) alloc );
   24279         315 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgTypeLongDouble::pool_size * sizeof(SgTypeLongDouble), V_SgTypeLongDouble ) );
   24280         315 :         SgTypeLongDouble::next_node = alloc;
   24281             :     }
   24282         644 :     ROSE_ASSERT(SgTypeLongDouble::next_node != nullptr);
   24283             : 
   24284         644 :     SgTypeLongDouble * object = SgTypeLongDouble::next_node;
   24285         644 :     SgTypeLongDouble::next_node = (SgTypeLongDouble*)(object->p_freepointer);
   24286             : 
   24287             : #if ROSE_ALLOC_TRACE == 2
   24288             :     printf("SgTypeLongDouble::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeLongDouble::next_node);
   24289             : #endif
   24290             : 
   24291         644 :     SgNode * fp = object->p_freepointer;
   24292             : #if ROSE_ALLOC_MEMSET == 1
   24293             : #elif ROSE_ALLOC_MEMSET == 2
   24294             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgTypeLongDouble) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   24295             : #elif ROSE_ALLOC_MEMSET == 3
   24296             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgTypeLongDouble) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   24297             : #endif
   24298         644 :     object->p_freepointer = fp;
   24299             : 
   24300             : #if ROSE_ALLOC_TRACE == 2
   24301             : //    printf("SgTypeLongDouble::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeLongDouble::next_node);
   24302             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   24303             :     Rose::MemPool::snapshot(oss.str());
   24304             :     alloc_trace_cnt++;
   24305             : #endif
   24306             : 
   24307         644 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   24308             : 
   24309         644 :     ALLOC_MUTEX(SgTypeLongDouble, unlock);
   24310             : 
   24311             :     return object;
   24312             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   24313             : }
   24314             : 
   24315             : 
   24316             : 
   24317             : /*! \brief Delete operator for SgTypeLongDouble.
   24318             : 
   24319             :    This delete operator implements deallocation using memory pools to 
   24320             :    provide most efficent use of the heap within construction of large ASTs.
   24321             : 
   24322             : \internal The new and delete operators use the lower level C malloc/free
   24323             :    function calls for performance and to make sure that mixing of malloc/free
   24324             :    and new/delete by the used can be caught more readily.  This may change
   24325             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   24326             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   24327             :    deallocate memory allocated using ROSE_MALLOC.
   24328             : */
   24329         331 : void SgTypeLongDouble::operator delete(void *Pointer, size_t Size)
   24330             : {
   24331             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   24332             :      * or throwing an exception. */
   24333         331 :     ALLOC_MUTEX(SgTypeLongDouble, lock);
   24334             : 
   24335             : #if USE_CPP_NEW_DELETE_OPERATORS
   24336             :     ROSE_FREE(Pointer);
   24337             : #else
   24338             : #if ROSE_PEDANTIC_ALLOC
   24339             :     ROSE_ASSERT(Size == sizeof(SgTypeLongDouble));
   24340             : #else
   24341         331 :     if (Size != sizeof(SgTypeLongDouble)) {
   24342           0 :       ROSE_FREE(Pointer);
   24343           0 :       ALLOC_MUTEX(SgTypeLongDouble, unlock);
   24344             :       return;
   24345             :     }
   24346             : #endif
   24347             : 
   24348         331 :     SgTypeLongDouble * object = (SgTypeLongDouble*) Pointer;
   24349         331 :     ROSE_ASSERT(object != nullptr);
   24350             : 
   24351             : #if ROSE_ALLOC_TRACE == 2
   24352             : //  printf("SgTypeLongDouble::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeLongDouble::next_node);
   24353             :     printf("SgTypeLongDouble::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeLongDouble::next_node);
   24354             : #endif
   24355             : 
   24356             : #if ROSE_PEDANTIC_ALLOC
   24357             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   24358             : #endif
   24359             : 
   24360             : #if ROSE_ALLOC_MEMSET == 1
   24361             : #elif ROSE_ALLOC_MEMSET == 2
   24362             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgTypeLongDouble) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   24363             : #elif ROSE_ALLOC_MEMSET == 3
   24364             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgTypeLongDouble) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   24365             : #endif
   24366             : 
   24367             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   24368             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   24369             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   24370             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   24371             : #else
   24372         331 :     object->p_freepointer = SgTypeLongDouble::next_node;
   24373         331 :     SgTypeLongDouble::next_node = object;
   24374             : #endif
   24375             : 
   24376             : #if ROSE_ALLOC_TRACE == 2
   24377             : //  printf("SgTypeLongDouble::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeLongDouble::next_node);
   24378             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   24379             :     Rose::MemPool::snapshot(oss.str());
   24380             :     alloc_trace_cnt++;
   24381             : #endif
   24382             : 
   24383             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   24384             : 
   24385         331 :     ALLOC_MUTEX(SgTypeLongDouble, unlock);
   24386             : }
   24387             : 
   24388             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   24389             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   24390             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   24391             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   24392             : // Also, note comment below from Robb (copied from the Common.code file).
   24393             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   24394             : //
   24395             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   24396             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   24397             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   24398             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   24399             : #if 0
   24400             : void SgTypeLongDouble::operator delete(void* pointer) { SgTypeLongDouble::operator delete (pointer, sizeof(SgTypeLongDouble)); };
   24401             : #endif
   24402             : /* #line 24403 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   24403             : 
   24404             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   24405             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   24406             : // obviously imply C++.
   24407             : 
   24408             : // This implements the support within ROSE for memory pools.  Memory pools
   24409             : // support the most condensed usage of memory within the construction of
   24410             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   24411             : // by a new operator written for each class.
   24412             : 
   24413             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   24414             :     // User wants multi-thread support and POSIX threads are available.
   24415             : #   include <pthread.h>
   24416             :     static pthread_mutex_t SgTypeString_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   24417             : #else
   24418             :      // Cause synchronization to be skipped.
   24419             : #    ifndef ALLOC_MUTEX
   24420             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   24421             : #    endif
   24422             : #    ifdef _REENTRANT
   24423             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   24424             : #       ifdef _MSC_VER
   24425             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   24426             : #       else
   24427             : #           warning "POSIX threads are not available; synchronization being skipped"
   24428             : #       endif
   24429             : #    endif
   24430             : #endif
   24431             : 
   24432             : #ifndef ROSE_ALLOC_TRACE
   24433             : #  define ROSE_ALLOC_TRACE 0
   24434             : #endif
   24435             : 
   24436             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   24437             : #define ROSE_ALLOC_TRACE_CNT
   24438             : #include "memory-pool-snapshot.h"
   24439             : unsigned long alloc_trace_cnt = 0;
   24440             : #endif
   24441             : 
   24442             : #if ROSE_ALLOC_TRACE
   24443             : const unsigned SgTypeString::pool_size = 5;
   24444             : #else
   24445             : const unsigned SgTypeString::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   24446             : #endif
   24447             : 
   24448             : #ifndef ROSE_ALLOC_MEMSET
   24449             : #  define ROSE_ALLOC_MEMSET 0
   24450             : #endif
   24451             : 
   24452             : #ifndef ROSE_PEDANTIC_ALLOC
   24453             : #  define ROSE_PEDANTIC_ALLOC 0
   24454             : #endif
   24455             : 
   24456             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   24457             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   24458             : #endif
   24459             : 
   24460             : #if !defined(SGNODE__ALL_POOLS)
   24461             : #define SGNODE__ALL_POOLS
   24462             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   24463             : #endif
   24464             : 
   24465             : SgTypeString* SgTypeString::next_node = nullptr;
   24466             : std::vector<unsigned char*> SgTypeString::pools;
   24467             : 
   24468             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   24469             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   24470             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   24471             : // around this macro definition rather than each use).
   24472             : #ifndef ALLOC_MUTEX
   24473             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   24474             :         do {                                                                     \
   24475             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   24476             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   24477             :                 abort();                                                         \
   24478             :             }                                                                    \
   24479             :         } while (0);
   24480             : #endif
   24481             : 
   24482             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   24483             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   24484             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   24485             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   24486             : 
   24487             : /*! \brief New operator for SgTypeString.
   24488             : 
   24489             :    This new operator implements memory pools to provide most efficent 
   24490             :    use of the heap within construction of large ASTs.
   24491             : 
   24492             : \internal The new and delete operators use the lower level C malloc/free
   24493             :    function calls for performance and to make sure that mixing of malloc/free
   24494             :    and new/delete by the used can be caught more readily.  This may change
   24495             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   24496             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   24497             :    deallocate memory allocated using ROSE_MALLOC.
   24498             : */
   24499         170 : void *SgTypeString::operator new ( size_t Size )
   24500             : {
   24501             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   24502             :      * returning or throwing an exception. */
   24503         170 :     ALLOC_MUTEX(SgTypeString, lock);
   24504             : 
   24505             : #if ROSE_ALLOC_TRACE == 2
   24506             : //    printf("SgTypeString::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgTypeString::next_node);
   24507             : #endif
   24508             : 
   24509             : #if USE_CPP_NEW_DELETE_OPERATORS
   24510             :     void *mem = ROSE_MALLOC(Size);
   24511             :     ALLOC_MUTEX(SgTypeString, unlock);
   24512             :     return mem;
   24513             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   24514             : #if ROSE_PEDANTIC_ALLOC
   24515             :     ROSE_ASSERT(Size == sizeof(SgTypeString));
   24516             : #else
   24517         170 :     if (Size != sizeof(SgTypeString)) {
   24518           0 :       void * object = ROSE_MALLOC(Size);
   24519           0 :       ALLOC_MUTEX(SgTypeString, unlock);
   24520             :       return object;
   24521             :     }
   24522             : #endif
   24523             : 
   24524         170 :     if (SgTypeString::next_node == nullptr) {
   24525           6 :         SgTypeString * alloc = (SgTypeString*) ROSE_MALLOC ( SgTypeString::pool_size * sizeof(SgTypeString) );
   24526           6 :         ROSE_ASSERT(alloc != nullptr);
   24527             : 
   24528             : #if ROSE_ALLOC_TRACE == 2
   24529             : //        printf("SgTypeString::alloc\n  block[%zi] = [ %p , %p [\n", SgTypeString::pools.size(), alloc, alloc + SgTypeString::pool_size);
   24530             : #endif
   24531             : 
   24532             : #if ROSE_ALLOC_MEMSET == 1
   24533             : #elif ROSE_ALLOC_MEMSET == 2
   24534             :         memset(alloc, 0x00, SgTypeString::pool_size * sizeof(SgTypeString));
   24535             : #elif ROSE_ALLOC_MEMSET == 3
   24536             :         memset(alloc, 0xAA, SgTypeString::pool_size * sizeof(SgTypeString));
   24537             : #endif
   24538       12000 :         for (unsigned i=0; i < SgTypeString::pool_size-1; i++) {
   24539       11994 :           alloc[i].p_freepointer = &(alloc[i+1]);
   24540             :         }
   24541           6 :         alloc[SgTypeString::pool_size-1].p_freepointer = nullptr;
   24542             : 
   24543           6 :         SgTypeString::pools.push_back ( (unsigned char *) alloc );
   24544           6 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgTypeString::pool_size * sizeof(SgTypeString), V_SgTypeString ) );
   24545           6 :         SgTypeString::next_node = alloc;
   24546             :     }
   24547         170 :     ROSE_ASSERT(SgTypeString::next_node != nullptr);
   24548             : 
   24549         170 :     SgTypeString * object = SgTypeString::next_node;
   24550         170 :     SgTypeString::next_node = (SgTypeString*)(object->p_freepointer);
   24551             : 
   24552             : #if ROSE_ALLOC_TRACE == 2
   24553             :     printf("SgTypeString::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeString::next_node);
   24554             : #endif
   24555             : 
   24556         170 :     SgNode * fp = object->p_freepointer;
   24557             : #if ROSE_ALLOC_MEMSET == 1
   24558             : #elif ROSE_ALLOC_MEMSET == 2
   24559             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgTypeString) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   24560             : #elif ROSE_ALLOC_MEMSET == 3
   24561             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgTypeString) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   24562             : #endif
   24563         170 :     object->p_freepointer = fp;
   24564             : 
   24565             : #if ROSE_ALLOC_TRACE == 2
   24566             : //    printf("SgTypeString::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeString::next_node);
   24567             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   24568             :     Rose::MemPool::snapshot(oss.str());
   24569             :     alloc_trace_cnt++;
   24570             : #endif
   24571             : 
   24572         170 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   24573             : 
   24574         170 :     ALLOC_MUTEX(SgTypeString, unlock);
   24575             : 
   24576             :     return object;
   24577             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   24578             : }
   24579             : 
   24580             : 
   24581             : 
   24582             : /*! \brief Delete operator for SgTypeString.
   24583             : 
   24584             :    This delete operator implements deallocation using memory pools to 
   24585             :    provide most efficent use of the heap within construction of large ASTs.
   24586             : 
   24587             : \internal The new and delete operators use the lower level C malloc/free
   24588             :    function calls for performance and to make sure that mixing of malloc/free
   24589             :    and new/delete by the used can be caught more readily.  This may change
   24590             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   24591             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   24592             :    deallocate memory allocated using ROSE_MALLOC.
   24593             : */
   24594         109 : void SgTypeString::operator delete(void *Pointer, size_t Size)
   24595             : {
   24596             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   24597             :      * or throwing an exception. */
   24598         109 :     ALLOC_MUTEX(SgTypeString, lock);
   24599             : 
   24600             : #if USE_CPP_NEW_DELETE_OPERATORS
   24601             :     ROSE_FREE(Pointer);
   24602             : #else
   24603             : #if ROSE_PEDANTIC_ALLOC
   24604             :     ROSE_ASSERT(Size == sizeof(SgTypeString));
   24605             : #else
   24606         109 :     if (Size != sizeof(SgTypeString)) {
   24607           0 :       ROSE_FREE(Pointer);
   24608           0 :       ALLOC_MUTEX(SgTypeString, unlock);
   24609             :       return;
   24610             :     }
   24611             : #endif
   24612             : 
   24613         109 :     SgTypeString * object = (SgTypeString*) Pointer;
   24614         109 :     ROSE_ASSERT(object != nullptr);
   24615             : 
   24616             : #if ROSE_ALLOC_TRACE == 2
   24617             : //  printf("SgTypeString::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeString::next_node);
   24618             :     printf("SgTypeString::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeString::next_node);
   24619             : #endif
   24620             : 
   24621             : #if ROSE_PEDANTIC_ALLOC
   24622             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   24623             : #endif
   24624             : 
   24625             : #if ROSE_ALLOC_MEMSET == 1
   24626             : #elif ROSE_ALLOC_MEMSET == 2
   24627             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgTypeString) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   24628             : #elif ROSE_ALLOC_MEMSET == 3
   24629             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgTypeString) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   24630             : #endif
   24631             : 
   24632             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   24633             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   24634             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   24635             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   24636             : #else
   24637         109 :     object->p_freepointer = SgTypeString::next_node;
   24638         109 :     SgTypeString::next_node = object;
   24639             : #endif
   24640             : 
   24641             : #if ROSE_ALLOC_TRACE == 2
   24642             : //  printf("SgTypeString::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeString::next_node);
   24643             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   24644             :     Rose::MemPool::snapshot(oss.str());
   24645             :     alloc_trace_cnt++;
   24646             : #endif
   24647             : 
   24648             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   24649             : 
   24650         109 :     ALLOC_MUTEX(SgTypeString, unlock);
   24651             : }
   24652             : 
   24653             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   24654             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   24655             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   24656             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   24657             : // Also, note comment below from Robb (copied from the Common.code file).
   24658             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   24659             : //
   24660             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   24661             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   24662             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   24663             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   24664             : #if 0
   24665             : void SgTypeString::operator delete(void* pointer) { SgTypeString::operator delete (pointer, sizeof(SgTypeString)); };
   24666             : #endif
   24667             : /* #line 24668 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   24668             : 
   24669             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   24670             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   24671             : // obviously imply C++.
   24672             : 
   24673             : // This implements the support within ROSE for memory pools.  Memory pools
   24674             : // support the most condensed usage of memory within the construction of
   24675             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   24676             : // by a new operator written for each class.
   24677             : 
   24678             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   24679             :     // User wants multi-thread support and POSIX threads are available.
   24680             : #   include <pthread.h>
   24681             :     static pthread_mutex_t SgTypeBool_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   24682             : #else
   24683             :      // Cause synchronization to be skipped.
   24684             : #    ifndef ALLOC_MUTEX
   24685             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   24686             : #    endif
   24687             : #    ifdef _REENTRANT
   24688             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   24689             : #       ifdef _MSC_VER
   24690             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   24691             : #       else
   24692             : #           warning "POSIX threads are not available; synchronization being skipped"
   24693             : #       endif
   24694             : #    endif
   24695             : #endif
   24696             : 
   24697             : #ifndef ROSE_ALLOC_TRACE
   24698             : #  define ROSE_ALLOC_TRACE 0
   24699             : #endif
   24700             : 
   24701             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   24702             : #define ROSE_ALLOC_TRACE_CNT
   24703             : #include "memory-pool-snapshot.h"
   24704             : unsigned long alloc_trace_cnt = 0;
   24705             : #endif
   24706             : 
   24707             : #if ROSE_ALLOC_TRACE
   24708             : const unsigned SgTypeBool::pool_size = 5;
   24709             : #else
   24710             : const unsigned SgTypeBool::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   24711             : #endif
   24712             : 
   24713             : #ifndef ROSE_ALLOC_MEMSET
   24714             : #  define ROSE_ALLOC_MEMSET 0
   24715             : #endif
   24716             : 
   24717             : #ifndef ROSE_PEDANTIC_ALLOC
   24718             : #  define ROSE_PEDANTIC_ALLOC 0
   24719             : #endif
   24720             : 
   24721             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   24722             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   24723             : #endif
   24724             : 
   24725             : #if !defined(SGNODE__ALL_POOLS)
   24726             : #define SGNODE__ALL_POOLS
   24727             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   24728             : #endif
   24729             : 
   24730             : SgTypeBool* SgTypeBool::next_node = nullptr;
   24731             : std::vector<unsigned char*> SgTypeBool::pools;
   24732             : 
   24733             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   24734             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   24735             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   24736             : // around this macro definition rather than each use).
   24737             : #ifndef ALLOC_MUTEX
   24738             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   24739             :         do {                                                                     \
   24740             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   24741             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   24742             :                 abort();                                                         \
   24743             :             }                                                                    \
   24744             :         } while (0);
   24745             : #endif
   24746             : 
   24747             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   24748             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   24749             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   24750             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   24751             : 
   24752             : /*! \brief New operator for SgTypeBool.
   24753             : 
   24754             :    This new operator implements memory pools to provide most efficent 
   24755             :    use of the heap within construction of large ASTs.
   24756             : 
   24757             : \internal The new and delete operators use the lower level C malloc/free
   24758             :    function calls for performance and to make sure that mixing of malloc/free
   24759             :    and new/delete by the used can be caught more readily.  This may change
   24760             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   24761             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   24762             :    deallocate memory allocated using ROSE_MALLOC.
   24763             : */
   24764       26843 : void *SgTypeBool::operator new ( size_t Size )
   24765             : {
   24766             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   24767             :      * returning or throwing an exception. */
   24768       26843 :     ALLOC_MUTEX(SgTypeBool, lock);
   24769             : 
   24770             : #if ROSE_ALLOC_TRACE == 2
   24771             : //    printf("SgTypeBool::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgTypeBool::next_node);
   24772             : #endif
   24773             : 
   24774             : #if USE_CPP_NEW_DELETE_OPERATORS
   24775             :     void *mem = ROSE_MALLOC(Size);
   24776             :     ALLOC_MUTEX(SgTypeBool, unlock);
   24777             :     return mem;
   24778             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   24779             : #if ROSE_PEDANTIC_ALLOC
   24780             :     ROSE_ASSERT(Size == sizeof(SgTypeBool));
   24781             : #else
   24782       26843 :     if (Size != sizeof(SgTypeBool)) {
   24783           0 :       void * object = ROSE_MALLOC(Size);
   24784           0 :       ALLOC_MUTEX(SgTypeBool, unlock);
   24785             :       return object;
   24786             :     }
   24787             : #endif
   24788             : 
   24789       26843 :     if (SgTypeBool::next_node == nullptr) {
   24790          76 :         SgTypeBool * alloc = (SgTypeBool*) ROSE_MALLOC ( SgTypeBool::pool_size * sizeof(SgTypeBool) );
   24791          76 :         ROSE_ASSERT(alloc != nullptr);
   24792             : 
   24793             : #if ROSE_ALLOC_TRACE == 2
   24794             : //        printf("SgTypeBool::alloc\n  block[%zi] = [ %p , %p [\n", SgTypeBool::pools.size(), alloc, alloc + SgTypeBool::pool_size);
   24795             : #endif
   24796             : 
   24797             : #if ROSE_ALLOC_MEMSET == 1
   24798             : #elif ROSE_ALLOC_MEMSET == 2
   24799             :         memset(alloc, 0x00, SgTypeBool::pool_size * sizeof(SgTypeBool));
   24800             : #elif ROSE_ALLOC_MEMSET == 3
   24801             :         memset(alloc, 0xAA, SgTypeBool::pool_size * sizeof(SgTypeBool));
   24802             : #endif
   24803      152000 :         for (unsigned i=0; i < SgTypeBool::pool_size-1; i++) {
   24804      151924 :           alloc[i].p_freepointer = &(alloc[i+1]);
   24805             :         }
   24806          76 :         alloc[SgTypeBool::pool_size-1].p_freepointer = nullptr;
   24807             : 
   24808          76 :         SgTypeBool::pools.push_back ( (unsigned char *) alloc );
   24809          76 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgTypeBool::pool_size * sizeof(SgTypeBool), V_SgTypeBool ) );
   24810          76 :         SgTypeBool::next_node = alloc;
   24811             :     }
   24812       26843 :     ROSE_ASSERT(SgTypeBool::next_node != nullptr);
   24813             : 
   24814       26843 :     SgTypeBool * object = SgTypeBool::next_node;
   24815       26843 :     SgTypeBool::next_node = (SgTypeBool*)(object->p_freepointer);
   24816             : 
   24817             : #if ROSE_ALLOC_TRACE == 2
   24818             :     printf("SgTypeBool::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeBool::next_node);
   24819             : #endif
   24820             : 
   24821       26843 :     SgNode * fp = object->p_freepointer;
   24822             : #if ROSE_ALLOC_MEMSET == 1
   24823             : #elif ROSE_ALLOC_MEMSET == 2
   24824             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgTypeBool) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   24825             : #elif ROSE_ALLOC_MEMSET == 3
   24826             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgTypeBool) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   24827             : #endif
   24828       26843 :     object->p_freepointer = fp;
   24829             : 
   24830             : #if ROSE_ALLOC_TRACE == 2
   24831             : //    printf("SgTypeBool::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeBool::next_node);
   24832             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   24833             :     Rose::MemPool::snapshot(oss.str());
   24834             :     alloc_trace_cnt++;
   24835             : #endif
   24836             : 
   24837       26843 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   24838             : 
   24839       26843 :     ALLOC_MUTEX(SgTypeBool, unlock);
   24840             : 
   24841             :     return object;
   24842             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   24843             : }
   24844             : 
   24845             : 
   24846             : 
   24847             : /*! \brief Delete operator for SgTypeBool.
   24848             : 
   24849             :    This delete operator implements deallocation using memory pools to 
   24850             :    provide most efficent use of the heap within construction of large ASTs.
   24851             : 
   24852             : \internal The new and delete operators use the lower level C malloc/free
   24853             :    function calls for performance and to make sure that mixing of malloc/free
   24854             :    and new/delete by the used can be caught more readily.  This may change
   24855             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   24856             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   24857             :    deallocate memory allocated using ROSE_MALLOC.
   24858             : */
   24859       26768 : void SgTypeBool::operator delete(void *Pointer, size_t Size)
   24860             : {
   24861             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   24862             :      * or throwing an exception. */
   24863       26768 :     ALLOC_MUTEX(SgTypeBool, lock);
   24864             : 
   24865             : #if USE_CPP_NEW_DELETE_OPERATORS
   24866             :     ROSE_FREE(Pointer);
   24867             : #else
   24868             : #if ROSE_PEDANTIC_ALLOC
   24869             :     ROSE_ASSERT(Size == sizeof(SgTypeBool));
   24870             : #else
   24871       26768 :     if (Size != sizeof(SgTypeBool)) {
   24872           0 :       ROSE_FREE(Pointer);
   24873           0 :       ALLOC_MUTEX(SgTypeBool, unlock);
   24874             :       return;
   24875             :     }
   24876             : #endif
   24877             : 
   24878       26768 :     SgTypeBool * object = (SgTypeBool*) Pointer;
   24879       26768 :     ROSE_ASSERT(object != nullptr);
   24880             : 
   24881             : #if ROSE_ALLOC_TRACE == 2
   24882             : //  printf("SgTypeBool::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeBool::next_node);
   24883             :     printf("SgTypeBool::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeBool::next_node);
   24884             : #endif
   24885             : 
   24886             : #if ROSE_PEDANTIC_ALLOC
   24887             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   24888             : #endif
   24889             : 
   24890             : #if ROSE_ALLOC_MEMSET == 1
   24891             : #elif ROSE_ALLOC_MEMSET == 2
   24892             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgTypeBool) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   24893             : #elif ROSE_ALLOC_MEMSET == 3
   24894             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgTypeBool) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   24895             : #endif
   24896             : 
   24897             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   24898             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   24899             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   24900             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   24901             : #else
   24902       26768 :     object->p_freepointer = SgTypeBool::next_node;
   24903       26768 :     SgTypeBool::next_node = object;
   24904             : #endif
   24905             : 
   24906             : #if ROSE_ALLOC_TRACE == 2
   24907             : //  printf("SgTypeBool::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeBool::next_node);
   24908             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   24909             :     Rose::MemPool::snapshot(oss.str());
   24910             :     alloc_trace_cnt++;
   24911             : #endif
   24912             : 
   24913             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   24914             : 
   24915       26768 :     ALLOC_MUTEX(SgTypeBool, unlock);
   24916             : }
   24917             : 
   24918             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   24919             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   24920             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   24921             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   24922             : // Also, note comment below from Robb (copied from the Common.code file).
   24923             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   24924             : //
   24925             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   24926             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   24927             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   24928             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   24929             : #if 0
   24930             : void SgTypeBool::operator delete(void* pointer) { SgTypeBool::operator delete (pointer, sizeof(SgTypeBool)); };
   24931             : #endif
   24932             : /* #line 24933 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   24933             : 
   24934             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   24935             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   24936             : // obviously imply C++.
   24937             : 
   24938             : // This implements the support within ROSE for memory pools.  Memory pools
   24939             : // support the most condensed usage of memory within the construction of
   24940             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   24941             : // by a new operator written for each class.
   24942             : 
   24943             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   24944             :     // User wants multi-thread support and POSIX threads are available.
   24945             : #   include <pthread.h>
   24946             :     static pthread_mutex_t SgPointerType_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   24947             : #else
   24948             :      // Cause synchronization to be skipped.
   24949             : #    ifndef ALLOC_MUTEX
   24950             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   24951             : #    endif
   24952             : #    ifdef _REENTRANT
   24953             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   24954             : #       ifdef _MSC_VER
   24955             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   24956             : #       else
   24957             : #           warning "POSIX threads are not available; synchronization being skipped"
   24958             : #       endif
   24959             : #    endif
   24960             : #endif
   24961             : 
   24962             : #ifndef ROSE_ALLOC_TRACE
   24963             : #  define ROSE_ALLOC_TRACE 0
   24964             : #endif
   24965             : 
   24966             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   24967             : #define ROSE_ALLOC_TRACE_CNT
   24968             : #include "memory-pool-snapshot.h"
   24969             : unsigned long alloc_trace_cnt = 0;
   24970             : #endif
   24971             : 
   24972             : #if ROSE_ALLOC_TRACE
   24973             : const unsigned SgPointerType::pool_size = 5;
   24974             : #else
   24975             : const unsigned SgPointerType::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   24976             : #endif
   24977             : 
   24978             : #ifndef ROSE_ALLOC_MEMSET
   24979             : #  define ROSE_ALLOC_MEMSET 0
   24980             : #endif
   24981             : 
   24982             : #ifndef ROSE_PEDANTIC_ALLOC
   24983             : #  define ROSE_PEDANTIC_ALLOC 0
   24984             : #endif
   24985             : 
   24986             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   24987             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   24988             : #endif
   24989             : 
   24990             : #if !defined(SGNODE__ALL_POOLS)
   24991             : #define SGNODE__ALL_POOLS
   24992             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   24993             : #endif
   24994             : 
   24995             : SgPointerType* SgPointerType::next_node = nullptr;
   24996             : std::vector<unsigned char*> SgPointerType::pools;
   24997             : 
   24998             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   24999             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   25000             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   25001             : // around this macro definition rather than each use).
   25002             : #ifndef ALLOC_MUTEX
   25003             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   25004             :         do {                                                                     \
   25005             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   25006             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   25007             :                 abort();                                                         \
   25008             :             }                                                                    \
   25009             :         } while (0);
   25010             : #endif
   25011             : 
   25012             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   25013             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   25014             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   25015             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   25016             : 
   25017             : /*! \brief New operator for SgPointerType.
   25018             : 
   25019             :    This new operator implements memory pools to provide most efficent 
   25020             :    use of the heap within construction of large ASTs.
   25021             : 
   25022             : \internal The new and delete operators use the lower level C malloc/free
   25023             :    function calls for performance and to make sure that mixing of malloc/free
   25024             :    and new/delete by the used can be caught more readily.  This may change
   25025             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   25026             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   25027             :    deallocate memory allocated using ROSE_MALLOC.
   25028             : */
   25029       27752 : void *SgPointerType::operator new ( size_t Size )
   25030             : {
   25031             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   25032             :      * returning or throwing an exception. */
   25033       27752 :     ALLOC_MUTEX(SgPointerType, lock);
   25034             : 
   25035             : #if ROSE_ALLOC_TRACE == 2
   25036             : //    printf("SgPointerType::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgPointerType::next_node);
   25037             : #endif
   25038             : 
   25039             : #if USE_CPP_NEW_DELETE_OPERATORS
   25040             :     void *mem = ROSE_MALLOC(Size);
   25041             :     ALLOC_MUTEX(SgPointerType, unlock);
   25042             :     return mem;
   25043             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   25044             : #if ROSE_PEDANTIC_ALLOC
   25045             :     ROSE_ASSERT(Size == sizeof(SgPointerType));
   25046             : #else
   25047       27752 :     if (Size != sizeof(SgPointerType)) {
   25048           0 :       void * object = ROSE_MALLOC(Size);
   25049           0 :       ALLOC_MUTEX(SgPointerType, unlock);
   25050             :       return object;
   25051             :     }
   25052             : #endif
   25053             : 
   25054       27752 :     if (SgPointerType::next_node == nullptr) {
   25055         316 :         SgPointerType * alloc = (SgPointerType*) ROSE_MALLOC ( SgPointerType::pool_size * sizeof(SgPointerType) );
   25056         316 :         ROSE_ASSERT(alloc != nullptr);
   25057             : 
   25058             : #if ROSE_ALLOC_TRACE == 2
   25059             : //        printf("SgPointerType::alloc\n  block[%zi] = [ %p , %p [\n", SgPointerType::pools.size(), alloc, alloc + SgPointerType::pool_size);
   25060             : #endif
   25061             : 
   25062             : #if ROSE_ALLOC_MEMSET == 1
   25063             : #elif ROSE_ALLOC_MEMSET == 2
   25064             :         memset(alloc, 0x00, SgPointerType::pool_size * sizeof(SgPointerType));
   25065             : #elif ROSE_ALLOC_MEMSET == 3
   25066             :         memset(alloc, 0xAA, SgPointerType::pool_size * sizeof(SgPointerType));
   25067             : #endif
   25068      632000 :         for (unsigned i=0; i < SgPointerType::pool_size-1; i++) {
   25069      631684 :           alloc[i].p_freepointer = &(alloc[i+1]);
   25070             :         }
   25071         316 :         alloc[SgPointerType::pool_size-1].p_freepointer = nullptr;
   25072             : 
   25073         316 :         SgPointerType::pools.push_back ( (unsigned char *) alloc );
   25074         316 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgPointerType::pool_size * sizeof(SgPointerType), V_SgPointerType ) );
   25075         316 :         SgPointerType::next_node = alloc;
   25076             :     }
   25077       27752 :     ROSE_ASSERT(SgPointerType::next_node != nullptr);
   25078             : 
   25079       27752 :     SgPointerType * object = SgPointerType::next_node;
   25080       27752 :     SgPointerType::next_node = (SgPointerType*)(object->p_freepointer);
   25081             : 
   25082             : #if ROSE_ALLOC_TRACE == 2
   25083             :     printf("SgPointerType::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgPointerType::next_node);
   25084             : #endif
   25085             : 
   25086       27752 :     SgNode * fp = object->p_freepointer;
   25087             : #if ROSE_ALLOC_MEMSET == 1
   25088             : #elif ROSE_ALLOC_MEMSET == 2
   25089             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgPointerType) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   25090             : #elif ROSE_ALLOC_MEMSET == 3
   25091             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgPointerType) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   25092             : #endif
   25093       27752 :     object->p_freepointer = fp;
   25094             : 
   25095             : #if ROSE_ALLOC_TRACE == 2
   25096             : //    printf("SgPointerType::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgPointerType::next_node);
   25097             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   25098             :     Rose::MemPool::snapshot(oss.str());
   25099             :     alloc_trace_cnt++;
   25100             : #endif
   25101             : 
   25102       27752 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   25103             : 
   25104       27752 :     ALLOC_MUTEX(SgPointerType, unlock);
   25105             : 
   25106             :     return object;
   25107             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   25108             : }
   25109             : 
   25110             : 
   25111             : 
   25112             : /*! \brief Delete operator for SgPointerType.
   25113             : 
   25114             :    This delete operator implements deallocation using memory pools to 
   25115             :    provide most efficent use of the heap within construction of large ASTs.
   25116             : 
   25117             : \internal The new and delete operators use the lower level C malloc/free
   25118             :    function calls for performance and to make sure that mixing of malloc/free
   25119             :    and new/delete by the used can be caught more readily.  This may change
   25120             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   25121             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   25122             :    deallocate memory allocated using ROSE_MALLOC.
   25123             : */
   25124        1382 : void SgPointerType::operator delete(void *Pointer, size_t Size)
   25125             : {
   25126             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   25127             :      * or throwing an exception. */
   25128        1382 :     ALLOC_MUTEX(SgPointerType, lock);
   25129             : 
   25130             : #if USE_CPP_NEW_DELETE_OPERATORS
   25131             :     ROSE_FREE(Pointer);
   25132             : #else
   25133             : #if ROSE_PEDANTIC_ALLOC
   25134             :     ROSE_ASSERT(Size == sizeof(SgPointerType));
   25135             : #else
   25136        1382 :     if (Size != sizeof(SgPointerType)) {
   25137           0 :       ROSE_FREE(Pointer);
   25138           0 :       ALLOC_MUTEX(SgPointerType, unlock);
   25139             :       return;
   25140             :     }
   25141             : #endif
   25142             : 
   25143        1382 :     SgPointerType * object = (SgPointerType*) Pointer;
   25144        1382 :     ROSE_ASSERT(object != nullptr);
   25145             : 
   25146             : #if ROSE_ALLOC_TRACE == 2
   25147             : //  printf("SgPointerType::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgPointerType::next_node);
   25148             :     printf("SgPointerType::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgPointerType::next_node);
   25149             : #endif
   25150             : 
   25151             : #if ROSE_PEDANTIC_ALLOC
   25152             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   25153             : #endif
   25154             : 
   25155             : #if ROSE_ALLOC_MEMSET == 1
   25156             : #elif ROSE_ALLOC_MEMSET == 2
   25157             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgPointerType) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   25158             : #elif ROSE_ALLOC_MEMSET == 3
   25159             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgPointerType) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   25160             : #endif
   25161             : 
   25162             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   25163             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   25164             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   25165             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   25166             : #else
   25167        1382 :     object->p_freepointer = SgPointerType::next_node;
   25168        1382 :     SgPointerType::next_node = object;
   25169             : #endif
   25170             : 
   25171             : #if ROSE_ALLOC_TRACE == 2
   25172             : //  printf("SgPointerType::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgPointerType::next_node);
   25173             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   25174             :     Rose::MemPool::snapshot(oss.str());
   25175             :     alloc_trace_cnt++;
   25176             : #endif
   25177             : 
   25178             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   25179             : 
   25180        1382 :     ALLOC_MUTEX(SgPointerType, unlock);
   25181             : }
   25182             : 
   25183             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   25184             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   25185             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   25186             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   25187             : // Also, note comment below from Robb (copied from the Common.code file).
   25188             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   25189             : //
   25190             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   25191             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   25192             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   25193             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   25194             : #if 0
   25195             : void SgPointerType::operator delete(void* pointer) { SgPointerType::operator delete (pointer, sizeof(SgPointerType)); };
   25196             : #endif
   25197             : /* #line 25198 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   25198             : 
   25199             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   25200             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   25201             : // obviously imply C++.
   25202             : 
   25203             : // This implements the support within ROSE for memory pools.  Memory pools
   25204             : // support the most condensed usage of memory within the construction of
   25205             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   25206             : // by a new operator written for each class.
   25207             : 
   25208             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   25209             :     // User wants multi-thread support and POSIX threads are available.
   25210             : #   include <pthread.h>
   25211             :     static pthread_mutex_t SgPointerMemberType_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   25212             : #else
   25213             :      // Cause synchronization to be skipped.
   25214             : #    ifndef ALLOC_MUTEX
   25215             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   25216             : #    endif
   25217             : #    ifdef _REENTRANT
   25218             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   25219             : #       ifdef _MSC_VER
   25220             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   25221             : #       else
   25222             : #           warning "POSIX threads are not available; synchronization being skipped"
   25223             : #       endif
   25224             : #    endif
   25225             : #endif
   25226             : 
   25227             : #ifndef ROSE_ALLOC_TRACE
   25228             : #  define ROSE_ALLOC_TRACE 0
   25229             : #endif
   25230             : 
   25231             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   25232             : #define ROSE_ALLOC_TRACE_CNT
   25233             : #include "memory-pool-snapshot.h"
   25234             : unsigned long alloc_trace_cnt = 0;
   25235             : #endif
   25236             : 
   25237             : #if ROSE_ALLOC_TRACE
   25238             : const unsigned SgPointerMemberType::pool_size = 5;
   25239             : #else
   25240             : const unsigned SgPointerMemberType::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   25241             : #endif
   25242             : 
   25243             : #ifndef ROSE_ALLOC_MEMSET
   25244             : #  define ROSE_ALLOC_MEMSET 0
   25245             : #endif
   25246             : 
   25247             : #ifndef ROSE_PEDANTIC_ALLOC
   25248             : #  define ROSE_PEDANTIC_ALLOC 0
   25249             : #endif
   25250             : 
   25251             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   25252             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   25253             : #endif
   25254             : 
   25255             : #if !defined(SGNODE__ALL_POOLS)
   25256             : #define SGNODE__ALL_POOLS
   25257             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   25258             : #endif
   25259             : 
   25260             : SgPointerMemberType* SgPointerMemberType::next_node = nullptr;
   25261             : std::vector<unsigned char*> SgPointerMemberType::pools;
   25262             : 
   25263             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   25264             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   25265             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   25266             : // around this macro definition rather than each use).
   25267             : #ifndef ALLOC_MUTEX
   25268             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   25269             :         do {                                                                     \
   25270             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   25271             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   25272             :                 abort();                                                         \
   25273             :             }                                                                    \
   25274             :         } while (0);
   25275             : #endif
   25276             : 
   25277             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   25278             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   25279             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   25280             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   25281             : 
   25282             : /*! \brief New operator for SgPointerMemberType.
   25283             : 
   25284             :    This new operator implements memory pools to provide most efficent 
   25285             :    use of the heap within construction of large ASTs.
   25286             : 
   25287             : \internal The new and delete operators use the lower level C malloc/free
   25288             :    function calls for performance and to make sure that mixing of malloc/free
   25289             :    and new/delete by the used can be caught more readily.  This may change
   25290             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   25291             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   25292             :    deallocate memory allocated using ROSE_MALLOC.
   25293             : */
   25294         271 : void *SgPointerMemberType::operator new ( size_t Size )
   25295             : {
   25296             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   25297             :      * returning or throwing an exception. */
   25298         271 :     ALLOC_MUTEX(SgPointerMemberType, lock);
   25299             : 
   25300             : #if ROSE_ALLOC_TRACE == 2
   25301             : //    printf("SgPointerMemberType::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgPointerMemberType::next_node);
   25302             : #endif
   25303             : 
   25304             : #if USE_CPP_NEW_DELETE_OPERATORS
   25305             :     void *mem = ROSE_MALLOC(Size);
   25306             :     ALLOC_MUTEX(SgPointerMemberType, unlock);
   25307             :     return mem;
   25308             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   25309             : #if ROSE_PEDANTIC_ALLOC
   25310             :     ROSE_ASSERT(Size == sizeof(SgPointerMemberType));
   25311             : #else
   25312         271 :     if (Size != sizeof(SgPointerMemberType)) {
   25313           0 :       void * object = ROSE_MALLOC(Size);
   25314           0 :       ALLOC_MUTEX(SgPointerMemberType, unlock);
   25315             :       return object;
   25316             :     }
   25317             : #endif
   25318             : 
   25319         271 :     if (SgPointerMemberType::next_node == nullptr) {
   25320          10 :         SgPointerMemberType * alloc = (SgPointerMemberType*) ROSE_MALLOC ( SgPointerMemberType::pool_size * sizeof(SgPointerMemberType) );
   25321          10 :         ROSE_ASSERT(alloc != nullptr);
   25322             : 
   25323             : #if ROSE_ALLOC_TRACE == 2
   25324             : //        printf("SgPointerMemberType::alloc\n  block[%zi] = [ %p , %p [\n", SgPointerMemberType::pools.size(), alloc, alloc + SgPointerMemberType::pool_size);
   25325             : #endif
   25326             : 
   25327             : #if ROSE_ALLOC_MEMSET == 1
   25328             : #elif ROSE_ALLOC_MEMSET == 2
   25329             :         memset(alloc, 0x00, SgPointerMemberType::pool_size * sizeof(SgPointerMemberType));
   25330             : #elif ROSE_ALLOC_MEMSET == 3
   25331             :         memset(alloc, 0xAA, SgPointerMemberType::pool_size * sizeof(SgPointerMemberType));
   25332             : #endif
   25333       20000 :         for (unsigned i=0; i < SgPointerMemberType::pool_size-1; i++) {
   25334       19990 :           alloc[i].p_freepointer = &(alloc[i+1]);
   25335             :         }
   25336          10 :         alloc[SgPointerMemberType::pool_size-1].p_freepointer = nullptr;
   25337             : 
   25338          10 :         SgPointerMemberType::pools.push_back ( (unsigned char *) alloc );
   25339          10 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgPointerMemberType::pool_size * sizeof(SgPointerMemberType), V_SgPointerMemberType ) );
   25340          10 :         SgPointerMemberType::next_node = alloc;
   25341             :     }
   25342         271 :     ROSE_ASSERT(SgPointerMemberType::next_node != nullptr);
   25343             : 
   25344         271 :     SgPointerMemberType * object = SgPointerMemberType::next_node;
   25345         271 :     SgPointerMemberType::next_node = (SgPointerMemberType*)(object->p_freepointer);
   25346             : 
   25347             : #if ROSE_ALLOC_TRACE == 2
   25348             :     printf("SgPointerMemberType::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgPointerMemberType::next_node);
   25349             : #endif
   25350             : 
   25351         271 :     SgNode * fp = object->p_freepointer;
   25352             : #if ROSE_ALLOC_MEMSET == 1
   25353             : #elif ROSE_ALLOC_MEMSET == 2
   25354             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgPointerMemberType) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   25355             : #elif ROSE_ALLOC_MEMSET == 3
   25356             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgPointerMemberType) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   25357             : #endif
   25358         271 :     object->p_freepointer = fp;
   25359             : 
   25360             : #if ROSE_ALLOC_TRACE == 2
   25361             : //    printf("SgPointerMemberType::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgPointerMemberType::next_node);
   25362             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   25363             :     Rose::MemPool::snapshot(oss.str());
   25364             :     alloc_trace_cnt++;
   25365             : #endif
   25366             : 
   25367         271 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   25368             : 
   25369         271 :     ALLOC_MUTEX(SgPointerMemberType, unlock);
   25370             : 
   25371             :     return object;
   25372             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   25373             : }
   25374             : 
   25375             : 
   25376             : 
   25377             : /*! \brief Delete operator for SgPointerMemberType.
   25378             : 
   25379             :    This delete operator implements deallocation using memory pools to 
   25380             :    provide most efficent use of the heap within construction of large ASTs.
   25381             : 
   25382             : \internal The new and delete operators use the lower level C malloc/free
   25383             :    function calls for performance and to make sure that mixing of malloc/free
   25384             :    and new/delete by the used can be caught more readily.  This may change
   25385             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   25386             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   25387             :    deallocate memory allocated using ROSE_MALLOC.
   25388             : */
   25389          58 : void SgPointerMemberType::operator delete(void *Pointer, size_t Size)
   25390             : {
   25391             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   25392             :      * or throwing an exception. */
   25393          58 :     ALLOC_MUTEX(SgPointerMemberType, lock);
   25394             : 
   25395             : #if USE_CPP_NEW_DELETE_OPERATORS
   25396             :     ROSE_FREE(Pointer);
   25397             : #else
   25398             : #if ROSE_PEDANTIC_ALLOC
   25399             :     ROSE_ASSERT(Size == sizeof(SgPointerMemberType));
   25400             : #else
   25401          58 :     if (Size != sizeof(SgPointerMemberType)) {
   25402           0 :       ROSE_FREE(Pointer);
   25403           0 :       ALLOC_MUTEX(SgPointerMemberType, unlock);
   25404             :       return;
   25405             :     }
   25406             : #endif
   25407             : 
   25408          58 :     SgPointerMemberType * object = (SgPointerMemberType*) Pointer;
   25409          58 :     ROSE_ASSERT(object != nullptr);
   25410             : 
   25411             : #if ROSE_ALLOC_TRACE == 2
   25412             : //  printf("SgPointerMemberType::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgPointerMemberType::next_node);
   25413             :     printf("SgPointerMemberType::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgPointerMemberType::next_node);
   25414             : #endif
   25415             : 
   25416             : #if ROSE_PEDANTIC_ALLOC
   25417             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   25418             : #endif
   25419             : 
   25420             : #if ROSE_ALLOC_MEMSET == 1
   25421             : #elif ROSE_ALLOC_MEMSET == 2
   25422             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgPointerMemberType) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   25423             : #elif ROSE_ALLOC_MEMSET == 3
   25424             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgPointerMemberType) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   25425             : #endif
   25426             : 
   25427             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   25428             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   25429             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   25430             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   25431             : #else
   25432          58 :     object->p_freepointer = SgPointerMemberType::next_node;
   25433          58 :     SgPointerMemberType::next_node = object;
   25434             : #endif
   25435             : 
   25436             : #if ROSE_ALLOC_TRACE == 2
   25437             : //  printf("SgPointerMemberType::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgPointerMemberType::next_node);
   25438             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   25439             :     Rose::MemPool::snapshot(oss.str());
   25440             :     alloc_trace_cnt++;
   25441             : #endif
   25442             : 
   25443             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   25444             : 
   25445          58 :     ALLOC_MUTEX(SgPointerMemberType, unlock);
   25446             : }
   25447             : 
   25448             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   25449             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   25450             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   25451             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   25452             : // Also, note comment below from Robb (copied from the Common.code file).
   25453             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   25454             : //
   25455             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   25456             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   25457             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   25458             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   25459             : #if 0
   25460             : void SgPointerMemberType::operator delete(void* pointer) { SgPointerMemberType::operator delete (pointer, sizeof(SgPointerMemberType)); };
   25461             : #endif
   25462             : /* #line 25463 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   25463             : 
   25464             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   25465             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   25466             : // obviously imply C++.
   25467             : 
   25468             : // This implements the support within ROSE for memory pools.  Memory pools
   25469             : // support the most condensed usage of memory within the construction of
   25470             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   25471             : // by a new operator written for each class.
   25472             : 
   25473             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   25474             :     // User wants multi-thread support and POSIX threads are available.
   25475             : #   include <pthread.h>
   25476             :     static pthread_mutex_t SgReferenceType_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   25477             : #else
   25478             :      // Cause synchronization to be skipped.
   25479             : #    ifndef ALLOC_MUTEX
   25480             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   25481             : #    endif
   25482             : #    ifdef _REENTRANT
   25483             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   25484             : #       ifdef _MSC_VER
   25485             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   25486             : #       else
   25487             : #           warning "POSIX threads are not available; synchronization being skipped"
   25488             : #       endif
   25489             : #    endif
   25490             : #endif
   25491             : 
   25492             : #ifndef ROSE_ALLOC_TRACE
   25493             : #  define ROSE_ALLOC_TRACE 0
   25494             : #endif
   25495             : 
   25496             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   25497             : #define ROSE_ALLOC_TRACE_CNT
   25498             : #include "memory-pool-snapshot.h"
   25499             : unsigned long alloc_trace_cnt = 0;
   25500             : #endif
   25501             : 
   25502             : #if ROSE_ALLOC_TRACE
   25503             : const unsigned SgReferenceType::pool_size = 5;
   25504             : #else
   25505             : const unsigned SgReferenceType::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   25506             : #endif
   25507             : 
   25508             : #ifndef ROSE_ALLOC_MEMSET
   25509             : #  define ROSE_ALLOC_MEMSET 0
   25510             : #endif
   25511             : 
   25512             : #ifndef ROSE_PEDANTIC_ALLOC
   25513             : #  define ROSE_PEDANTIC_ALLOC 0
   25514             : #endif
   25515             : 
   25516             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   25517             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   25518             : #endif
   25519             : 
   25520             : #if !defined(SGNODE__ALL_POOLS)
   25521             : #define SGNODE__ALL_POOLS
   25522             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   25523             : #endif
   25524             : 
   25525             : SgReferenceType* SgReferenceType::next_node = nullptr;
   25526             : std::vector<unsigned char*> SgReferenceType::pools;
   25527             : 
   25528             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   25529             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   25530             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   25531             : // around this macro definition rather than each use).
   25532             : #ifndef ALLOC_MUTEX
   25533             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   25534             :         do {                                                                     \
   25535             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   25536             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   25537             :                 abort();                                                         \
   25538             :             }                                                                    \
   25539             :         } while (0);
   25540             : #endif
   25541             : 
   25542             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   25543             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   25544             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   25545             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   25546             : 
   25547             : /*! \brief New operator for SgReferenceType.
   25548             : 
   25549             :    This new operator implements memory pools to provide most efficent 
   25550             :    use of the heap within construction of large ASTs.
   25551             : 
   25552             : \internal The new and delete operators use the lower level C malloc/free
   25553             :    function calls for performance and to make sure that mixing of malloc/free
   25554             :    and new/delete by the used can be caught more readily.  This may change
   25555             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   25556             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   25557             :    deallocate memory allocated using ROSE_MALLOC.
   25558             : */
   25559        7559 : void *SgReferenceType::operator new ( size_t Size )
   25560             : {
   25561             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   25562             :      * returning or throwing an exception. */
   25563        7559 :     ALLOC_MUTEX(SgReferenceType, lock);
   25564             : 
   25565             : #if ROSE_ALLOC_TRACE == 2
   25566             : //    printf("SgReferenceType::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgReferenceType::next_node);
   25567             : #endif
   25568             : 
   25569             : #if USE_CPP_NEW_DELETE_OPERATORS
   25570             :     void *mem = ROSE_MALLOC(Size);
   25571             :     ALLOC_MUTEX(SgReferenceType, unlock);
   25572             :     return mem;
   25573             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   25574             : #if ROSE_PEDANTIC_ALLOC
   25575             :     ROSE_ASSERT(Size == sizeof(SgReferenceType));
   25576             : #else
   25577        7559 :     if (Size != sizeof(SgReferenceType)) {
   25578           0 :       void * object = ROSE_MALLOC(Size);
   25579           0 :       ALLOC_MUTEX(SgReferenceType, unlock);
   25580             :       return object;
   25581             :     }
   25582             : #endif
   25583             : 
   25584        7559 :     if (SgReferenceType::next_node == nullptr) {
   25585          62 :         SgReferenceType * alloc = (SgReferenceType*) ROSE_MALLOC ( SgReferenceType::pool_size * sizeof(SgReferenceType) );
   25586          62 :         ROSE_ASSERT(alloc != nullptr);
   25587             : 
   25588             : #if ROSE_ALLOC_TRACE == 2
   25589             : //        printf("SgReferenceType::alloc\n  block[%zi] = [ %p , %p [\n", SgReferenceType::pools.size(), alloc, alloc + SgReferenceType::pool_size);
   25590             : #endif
   25591             : 
   25592             : #if ROSE_ALLOC_MEMSET == 1
   25593             : #elif ROSE_ALLOC_MEMSET == 2
   25594             :         memset(alloc, 0x00, SgReferenceType::pool_size * sizeof(SgReferenceType));
   25595             : #elif ROSE_ALLOC_MEMSET == 3
   25596             :         memset(alloc, 0xAA, SgReferenceType::pool_size * sizeof(SgReferenceType));
   25597             : #endif
   25598      124000 :         for (unsigned i=0; i < SgReferenceType::pool_size-1; i++) {
   25599      123938 :           alloc[i].p_freepointer = &(alloc[i+1]);
   25600             :         }
   25601          62 :         alloc[SgReferenceType::pool_size-1].p_freepointer = nullptr;
   25602             : 
   25603          62 :         SgReferenceType::pools.push_back ( (unsigned char *) alloc );
   25604          62 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgReferenceType::pool_size * sizeof(SgReferenceType), V_SgReferenceType ) );
   25605          62 :         SgReferenceType::next_node = alloc;
   25606             :     }
   25607        7559 :     ROSE_ASSERT(SgReferenceType::next_node != nullptr);
   25608             : 
   25609        7559 :     SgReferenceType * object = SgReferenceType::next_node;
   25610        7559 :     SgReferenceType::next_node = (SgReferenceType*)(object->p_freepointer);
   25611             : 
   25612             : #if ROSE_ALLOC_TRACE == 2
   25613             :     printf("SgReferenceType::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgReferenceType::next_node);
   25614             : #endif
   25615             : 
   25616        7559 :     SgNode * fp = object->p_freepointer;
   25617             : #if ROSE_ALLOC_MEMSET == 1
   25618             : #elif ROSE_ALLOC_MEMSET == 2
   25619             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgReferenceType) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   25620             : #elif ROSE_ALLOC_MEMSET == 3
   25621             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgReferenceType) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   25622             : #endif
   25623        7559 :     object->p_freepointer = fp;
   25624             : 
   25625             : #if ROSE_ALLOC_TRACE == 2
   25626             : //    printf("SgReferenceType::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgReferenceType::next_node);
   25627             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   25628             :     Rose::MemPool::snapshot(oss.str());
   25629             :     alloc_trace_cnt++;
   25630             : #endif
   25631             : 
   25632        7559 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   25633             : 
   25634        7559 :     ALLOC_MUTEX(SgReferenceType, unlock);
   25635             : 
   25636             :     return object;
   25637             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   25638             : }
   25639             : 
   25640             : 
   25641             : 
   25642             : /*! \brief Delete operator for SgReferenceType.
   25643             : 
   25644             :    This delete operator implements deallocation using memory pools to 
   25645             :    provide most efficent use of the heap within construction of large ASTs.
   25646             : 
   25647             : \internal The new and delete operators use the lower level C malloc/free
   25648             :    function calls for performance and to make sure that mixing of malloc/free
   25649             :    and new/delete by the used can be caught more readily.  This may change
   25650             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   25651             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   25652             :    deallocate memory allocated using ROSE_MALLOC.
   25653             : */
   25654        1452 : void SgReferenceType::operator delete(void *Pointer, size_t Size)
   25655             : {
   25656             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   25657             :      * or throwing an exception. */
   25658        1452 :     ALLOC_MUTEX(SgReferenceType, lock);
   25659             : 
   25660             : #if USE_CPP_NEW_DELETE_OPERATORS
   25661             :     ROSE_FREE(Pointer);
   25662             : #else
   25663             : #if ROSE_PEDANTIC_ALLOC
   25664             :     ROSE_ASSERT(Size == sizeof(SgReferenceType));
   25665             : #else
   25666        1452 :     if (Size != sizeof(SgReferenceType)) {
   25667           0 :       ROSE_FREE(Pointer);
   25668           0 :       ALLOC_MUTEX(SgReferenceType, unlock);
   25669             :       return;
   25670             :     }
   25671             : #endif
   25672             : 
   25673        1452 :     SgReferenceType * object = (SgReferenceType*) Pointer;
   25674        1452 :     ROSE_ASSERT(object != nullptr);
   25675             : 
   25676             : #if ROSE_ALLOC_TRACE == 2
   25677             : //  printf("SgReferenceType::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgReferenceType::next_node);
   25678             :     printf("SgReferenceType::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgReferenceType::next_node);
   25679             : #endif
   25680             : 
   25681             : #if ROSE_PEDANTIC_ALLOC
   25682             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   25683             : #endif
   25684             : 
   25685             : #if ROSE_ALLOC_MEMSET == 1
   25686             : #elif ROSE_ALLOC_MEMSET == 2
   25687             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgReferenceType) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   25688             : #elif ROSE_ALLOC_MEMSET == 3
   25689             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgReferenceType) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   25690             : #endif
   25691             : 
   25692             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   25693             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   25694             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   25695             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   25696             : #else
   25697        1452 :     object->p_freepointer = SgReferenceType::next_node;
   25698        1452 :     SgReferenceType::next_node = object;
   25699             : #endif
   25700             : 
   25701             : #if ROSE_ALLOC_TRACE == 2
   25702             : //  printf("SgReferenceType::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgReferenceType::next_node);
   25703             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   25704             :     Rose::MemPool::snapshot(oss.str());
   25705             :     alloc_trace_cnt++;
   25706             : #endif
   25707             : 
   25708             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   25709             : 
   25710        1452 :     ALLOC_MUTEX(SgReferenceType, unlock);
   25711             : }
   25712             : 
   25713             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   25714             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   25715             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   25716             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   25717             : // Also, note comment below from Robb (copied from the Common.code file).
   25718             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   25719             : //
   25720             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   25721             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   25722             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   25723             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   25724             : #if 0
   25725             : void SgReferenceType::operator delete(void* pointer) { SgReferenceType::operator delete (pointer, sizeof(SgReferenceType)); };
   25726             : #endif
   25727             : /* #line 25728 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   25728             : 
   25729             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   25730             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   25731             : // obviously imply C++.
   25732             : 
   25733             : // This implements the support within ROSE for memory pools.  Memory pools
   25734             : // support the most condensed usage of memory within the construction of
   25735             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   25736             : // by a new operator written for each class.
   25737             : 
   25738             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   25739             :     // User wants multi-thread support and POSIX threads are available.
   25740             : #   include <pthread.h>
   25741             :     static pthread_mutex_t SgNamedType_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   25742             : #else
   25743             :      // Cause synchronization to be skipped.
   25744             : #    ifndef ALLOC_MUTEX
   25745             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   25746             : #    endif
   25747             : #    ifdef _REENTRANT
   25748             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   25749             : #       ifdef _MSC_VER
   25750             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   25751             : #       else
   25752             : #           warning "POSIX threads are not available; synchronization being skipped"
   25753             : #       endif
   25754             : #    endif
   25755             : #endif
   25756             : 
   25757             : #ifndef ROSE_ALLOC_TRACE
   25758             : #  define ROSE_ALLOC_TRACE 0
   25759             : #endif
   25760             : 
   25761             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   25762             : #define ROSE_ALLOC_TRACE_CNT
   25763             : #include "memory-pool-snapshot.h"
   25764             : unsigned long alloc_trace_cnt = 0;
   25765             : #endif
   25766             : 
   25767             : #if ROSE_ALLOC_TRACE
   25768             : const unsigned SgNamedType::pool_size = 5;
   25769             : #else
   25770             : const unsigned SgNamedType::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   25771             : #endif
   25772             : 
   25773             : #ifndef ROSE_ALLOC_MEMSET
   25774             : #  define ROSE_ALLOC_MEMSET 0
   25775             : #endif
   25776             : 
   25777             : #ifndef ROSE_PEDANTIC_ALLOC
   25778             : #  define ROSE_PEDANTIC_ALLOC 0
   25779             : #endif
   25780             : 
   25781             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   25782             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   25783             : #endif
   25784             : 
   25785             : #if !defined(SGNODE__ALL_POOLS)
   25786             : #define SGNODE__ALL_POOLS
   25787             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   25788             : #endif
   25789             : 
   25790             : SgNamedType* SgNamedType::next_node = nullptr;
   25791             : std::vector<unsigned char*> SgNamedType::pools;
   25792             : 
   25793             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   25794             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   25795             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   25796             : // around this macro definition rather than each use).
   25797             : #ifndef ALLOC_MUTEX
   25798             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   25799             :         do {                                                                     \
   25800             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   25801             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   25802             :                 abort();                                                         \
   25803             :             }                                                                    \
   25804             :         } while (0);
   25805             : #endif
   25806             : 
   25807             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   25808             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   25809             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   25810             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   25811             : 
   25812             : /*! \brief New operator for SgNamedType.
   25813             : 
   25814             :    This new operator implements memory pools to provide most efficent 
   25815             :    use of the heap within construction of large ASTs.
   25816             : 
   25817             : \internal The new and delete operators use the lower level C malloc/free
   25818             :    function calls for performance and to make sure that mixing of malloc/free
   25819             :    and new/delete by the used can be caught more readily.  This may change
   25820             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   25821             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   25822             :    deallocate memory allocated using ROSE_MALLOC.
   25823             : */
   25824           0 : void *SgNamedType::operator new ( size_t Size )
   25825             : {
   25826             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   25827             :      * returning or throwing an exception. */
   25828           0 :     ALLOC_MUTEX(SgNamedType, lock);
   25829             : 
   25830             : #if ROSE_ALLOC_TRACE == 2
   25831             : //    printf("SgNamedType::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgNamedType::next_node);
   25832             : #endif
   25833             : 
   25834             : #if USE_CPP_NEW_DELETE_OPERATORS
   25835             :     void *mem = ROSE_MALLOC(Size);
   25836             :     ALLOC_MUTEX(SgNamedType, unlock);
   25837             :     return mem;
   25838             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   25839             : #if ROSE_PEDANTIC_ALLOC
   25840             :     ROSE_ASSERT(Size == sizeof(SgNamedType));
   25841             : #else
   25842           0 :     if (Size != sizeof(SgNamedType)) {
   25843           0 :       void * object = ROSE_MALLOC(Size);
   25844           0 :       ALLOC_MUTEX(SgNamedType, unlock);
   25845             :       return object;
   25846             :     }
   25847             : #endif
   25848             : 
   25849           0 :     if (SgNamedType::next_node == nullptr) {
   25850           0 :         SgNamedType * alloc = (SgNamedType*) ROSE_MALLOC ( SgNamedType::pool_size * sizeof(SgNamedType) );
   25851           0 :         ROSE_ASSERT(alloc != nullptr);
   25852             : 
   25853             : #if ROSE_ALLOC_TRACE == 2
   25854             : //        printf("SgNamedType::alloc\n  block[%zi] = [ %p , %p [\n", SgNamedType::pools.size(), alloc, alloc + SgNamedType::pool_size);
   25855             : #endif
   25856             : 
   25857             : #if ROSE_ALLOC_MEMSET == 1
   25858             : #elif ROSE_ALLOC_MEMSET == 2
   25859             :         memset(alloc, 0x00, SgNamedType::pool_size * sizeof(SgNamedType));
   25860             : #elif ROSE_ALLOC_MEMSET == 3
   25861             :         memset(alloc, 0xAA, SgNamedType::pool_size * sizeof(SgNamedType));
   25862             : #endif
   25863           0 :         for (unsigned i=0; i < SgNamedType::pool_size-1; i++) {
   25864           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
   25865             :         }
   25866           0 :         alloc[SgNamedType::pool_size-1].p_freepointer = nullptr;
   25867             : 
   25868           0 :         SgNamedType::pools.push_back ( (unsigned char *) alloc );
   25869           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgNamedType::pool_size * sizeof(SgNamedType), V_SgNamedType ) );
   25870           0 :         SgNamedType::next_node = alloc;
   25871             :     }
   25872           0 :     ROSE_ASSERT(SgNamedType::next_node != nullptr);
   25873             : 
   25874           0 :     SgNamedType * object = SgNamedType::next_node;
   25875           0 :     SgNamedType::next_node = (SgNamedType*)(object->p_freepointer);
   25876             : 
   25877             : #if ROSE_ALLOC_TRACE == 2
   25878             :     printf("SgNamedType::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgNamedType::next_node);
   25879             : #endif
   25880             : 
   25881           0 :     SgNode * fp = object->p_freepointer;
   25882             : #if ROSE_ALLOC_MEMSET == 1
   25883             : #elif ROSE_ALLOC_MEMSET == 2
   25884             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgNamedType) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   25885             : #elif ROSE_ALLOC_MEMSET == 3
   25886             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgNamedType) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   25887             : #endif
   25888           0 :     object->p_freepointer = fp;
   25889             : 
   25890             : #if ROSE_ALLOC_TRACE == 2
   25891             : //    printf("SgNamedType::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgNamedType::next_node);
   25892             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   25893             :     Rose::MemPool::snapshot(oss.str());
   25894             :     alloc_trace_cnt++;
   25895             : #endif
   25896             : 
   25897           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   25898             : 
   25899           0 :     ALLOC_MUTEX(SgNamedType, unlock);
   25900             : 
   25901             :     return object;
   25902             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   25903             : }
   25904             : 
   25905             : 
   25906             : 
   25907             : /*! \brief Delete operator for SgNamedType.
   25908             : 
   25909             :    This delete operator implements deallocation using memory pools to 
   25910             :    provide most efficent use of the heap within construction of large ASTs.
   25911             : 
   25912             : \internal The new and delete operators use the lower level C malloc/free
   25913             :    function calls for performance and to make sure that mixing of malloc/free
   25914             :    and new/delete by the used can be caught more readily.  This may change
   25915             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   25916             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   25917             :    deallocate memory allocated using ROSE_MALLOC.
   25918             : */
   25919           0 : void SgNamedType::operator delete(void *Pointer, size_t Size)
   25920             : {
   25921             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   25922             :      * or throwing an exception. */
   25923           0 :     ALLOC_MUTEX(SgNamedType, lock);
   25924             : 
   25925             : #if USE_CPP_NEW_DELETE_OPERATORS
   25926             :     ROSE_FREE(Pointer);
   25927             : #else
   25928             : #if ROSE_PEDANTIC_ALLOC
   25929             :     ROSE_ASSERT(Size == sizeof(SgNamedType));
   25930             : #else
   25931           0 :     if (Size != sizeof(SgNamedType)) {
   25932           0 :       ROSE_FREE(Pointer);
   25933           0 :       ALLOC_MUTEX(SgNamedType, unlock);
   25934             :       return;
   25935             :     }
   25936             : #endif
   25937             : 
   25938           0 :     SgNamedType * object = (SgNamedType*) Pointer;
   25939           0 :     ROSE_ASSERT(object != nullptr);
   25940             : 
   25941             : #if ROSE_ALLOC_TRACE == 2
   25942             : //  printf("SgNamedType::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgNamedType::next_node);
   25943             :     printf("SgNamedType::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgNamedType::next_node);
   25944             : #endif
   25945             : 
   25946             : #if ROSE_PEDANTIC_ALLOC
   25947             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   25948             : #endif
   25949             : 
   25950             : #if ROSE_ALLOC_MEMSET == 1
   25951             : #elif ROSE_ALLOC_MEMSET == 2
   25952             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgNamedType) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   25953             : #elif ROSE_ALLOC_MEMSET == 3
   25954             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgNamedType) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   25955             : #endif
   25956             : 
   25957             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   25958             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   25959             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   25960             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   25961             : #else
   25962           0 :     object->p_freepointer = SgNamedType::next_node;
   25963           0 :     SgNamedType::next_node = object;
   25964             : #endif
   25965             : 
   25966             : #if ROSE_ALLOC_TRACE == 2
   25967             : //  printf("SgNamedType::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgNamedType::next_node);
   25968             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   25969             :     Rose::MemPool::snapshot(oss.str());
   25970             :     alloc_trace_cnt++;
   25971             : #endif
   25972             : 
   25973             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   25974             : 
   25975           0 :     ALLOC_MUTEX(SgNamedType, unlock);
   25976             : }
   25977             : 
   25978             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   25979             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   25980             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   25981             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   25982             : // Also, note comment below from Robb (copied from the Common.code file).
   25983             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   25984             : //
   25985             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   25986             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   25987             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   25988             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   25989             : #if 0
   25990             : void SgNamedType::operator delete(void* pointer) { SgNamedType::operator delete (pointer, sizeof(SgNamedType)); };
   25991             : #endif
   25992             : /* #line 25993 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   25993             : 
   25994             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   25995             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   25996             : // obviously imply C++.
   25997             : 
   25998             : // This implements the support within ROSE for memory pools.  Memory pools
   25999             : // support the most condensed usage of memory within the construction of
   26000             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   26001             : // by a new operator written for each class.
   26002             : 
   26003             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   26004             :     // User wants multi-thread support and POSIX threads are available.
   26005             : #   include <pthread.h>
   26006             :     static pthread_mutex_t SgClassType_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   26007             : #else
   26008             :      // Cause synchronization to be skipped.
   26009             : #    ifndef ALLOC_MUTEX
   26010             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   26011             : #    endif
   26012             : #    ifdef _REENTRANT
   26013             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   26014             : #       ifdef _MSC_VER
   26015             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   26016             : #       else
   26017             : #           warning "POSIX threads are not available; synchronization being skipped"
   26018             : #       endif
   26019             : #    endif
   26020             : #endif
   26021             : 
   26022             : #ifndef ROSE_ALLOC_TRACE
   26023             : #  define ROSE_ALLOC_TRACE 0
   26024             : #endif
   26025             : 
   26026             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   26027             : #define ROSE_ALLOC_TRACE_CNT
   26028             : #include "memory-pool-snapshot.h"
   26029             : unsigned long alloc_trace_cnt = 0;
   26030             : #endif
   26031             : 
   26032             : #if ROSE_ALLOC_TRACE
   26033             : const unsigned SgClassType::pool_size = 5;
   26034             : #else
   26035             : const unsigned SgClassType::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   26036             : #endif
   26037             : 
   26038             : #ifndef ROSE_ALLOC_MEMSET
   26039             : #  define ROSE_ALLOC_MEMSET 0
   26040             : #endif
   26041             : 
   26042             : #ifndef ROSE_PEDANTIC_ALLOC
   26043             : #  define ROSE_PEDANTIC_ALLOC 0
   26044             : #endif
   26045             : 
   26046             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   26047             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   26048             : #endif
   26049             : 
   26050             : #if !defined(SGNODE__ALL_POOLS)
   26051             : #define SGNODE__ALL_POOLS
   26052             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   26053             : #endif
   26054             : 
   26055             : SgClassType* SgClassType::next_node = nullptr;
   26056             : std::vector<unsigned char*> SgClassType::pools;
   26057             : 
   26058             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   26059             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   26060             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   26061             : // around this macro definition rather than each use).
   26062             : #ifndef ALLOC_MUTEX
   26063             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   26064             :         do {                                                                     \
   26065             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   26066             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   26067             :                 abort();                                                         \
   26068             :             }                                                                    \
   26069             :         } while (0);
   26070             : #endif
   26071             : 
   26072             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   26073             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   26074             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   26075             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   26076             : 
   26077             : /*! \brief New operator for SgClassType.
   26078             : 
   26079             :    This new operator implements memory pools to provide most efficent 
   26080             :    use of the heap within construction of large ASTs.
   26081             : 
   26082             : \internal The new and delete operators use the lower level C malloc/free
   26083             :    function calls for performance and to make sure that mixing of malloc/free
   26084             :    and new/delete by the used can be caught more readily.  This may change
   26085             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   26086             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   26087             :    deallocate memory allocated using ROSE_MALLOC.
   26088             : */
   26089       20475 : void *SgClassType::operator new ( size_t Size )
   26090             : {
   26091             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   26092             :      * returning or throwing an exception. */
   26093       20475 :     ALLOC_MUTEX(SgClassType, lock);
   26094             : 
   26095             : #if ROSE_ALLOC_TRACE == 2
   26096             : //    printf("SgClassType::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgClassType::next_node);
   26097             : #endif
   26098             : 
   26099             : #if USE_CPP_NEW_DELETE_OPERATORS
   26100             :     void *mem = ROSE_MALLOC(Size);
   26101             :     ALLOC_MUTEX(SgClassType, unlock);
   26102             :     return mem;
   26103             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   26104             : #if ROSE_PEDANTIC_ALLOC
   26105             :     ROSE_ASSERT(Size == sizeof(SgClassType));
   26106             : #else
   26107       20475 :     if (Size != sizeof(SgClassType)) {
   26108           0 :       void * object = ROSE_MALLOC(Size);
   26109           0 :       ALLOC_MUTEX(SgClassType, unlock);
   26110             :       return object;
   26111             :     }
   26112             : #endif
   26113             : 
   26114       20475 :     if (SgClassType::next_node == nullptr) {
   26115         213 :         SgClassType * alloc = (SgClassType*) ROSE_MALLOC ( SgClassType::pool_size * sizeof(SgClassType) );
   26116         213 :         ROSE_ASSERT(alloc != nullptr);
   26117             : 
   26118             : #if ROSE_ALLOC_TRACE == 2
   26119             : //        printf("SgClassType::alloc\n  block[%zi] = [ %p , %p [\n", SgClassType::pools.size(), alloc, alloc + SgClassType::pool_size);
   26120             : #endif
   26121             : 
   26122             : #if ROSE_ALLOC_MEMSET == 1
   26123             : #elif ROSE_ALLOC_MEMSET == 2
   26124             :         memset(alloc, 0x00, SgClassType::pool_size * sizeof(SgClassType));
   26125             : #elif ROSE_ALLOC_MEMSET == 3
   26126             :         memset(alloc, 0xAA, SgClassType::pool_size * sizeof(SgClassType));
   26127             : #endif
   26128      426000 :         for (unsigned i=0; i < SgClassType::pool_size-1; i++) {
   26129      425787 :           alloc[i].p_freepointer = &(alloc[i+1]);
   26130             :         }
   26131         213 :         alloc[SgClassType::pool_size-1].p_freepointer = nullptr;
   26132             : 
   26133         213 :         SgClassType::pools.push_back ( (unsigned char *) alloc );
   26134         213 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgClassType::pool_size * sizeof(SgClassType), V_SgClassType ) );
   26135         213 :         SgClassType::next_node = alloc;
   26136             :     }
   26137       20475 :     ROSE_ASSERT(SgClassType::next_node != nullptr);
   26138             : 
   26139       20475 :     SgClassType * object = SgClassType::next_node;
   26140       20475 :     SgClassType::next_node = (SgClassType*)(object->p_freepointer);
   26141             : 
   26142             : #if ROSE_ALLOC_TRACE == 2
   26143             :     printf("SgClassType::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgClassType::next_node);
   26144             : #endif
   26145             : 
   26146       20475 :     SgNode * fp = object->p_freepointer;
   26147             : #if ROSE_ALLOC_MEMSET == 1
   26148             : #elif ROSE_ALLOC_MEMSET == 2
   26149             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgClassType) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   26150             : #elif ROSE_ALLOC_MEMSET == 3
   26151             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgClassType) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   26152             : #endif
   26153       20475 :     object->p_freepointer = fp;
   26154             : 
   26155             : #if ROSE_ALLOC_TRACE == 2
   26156             : //    printf("SgClassType::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgClassType::next_node);
   26157             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   26158             :     Rose::MemPool::snapshot(oss.str());
   26159             :     alloc_trace_cnt++;
   26160             : #endif
   26161             : 
   26162       20475 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   26163             : 
   26164       20475 :     ALLOC_MUTEX(SgClassType, unlock);
   26165             : 
   26166             :     return object;
   26167             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   26168             : }
   26169             : 
   26170             : 
   26171             : 
   26172             : /*! \brief Delete operator for SgClassType.
   26173             : 
   26174             :    This delete operator implements deallocation using memory pools to 
   26175             :    provide most efficent use of the heap within construction of large ASTs.
   26176             : 
   26177             : \internal The new and delete operators use the lower level C malloc/free
   26178             :    function calls for performance and to make sure that mixing of malloc/free
   26179             :    and new/delete by the used can be caught more readily.  This may change
   26180             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   26181             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   26182             :    deallocate memory allocated using ROSE_MALLOC.
   26183             : */
   26184        3032 : void SgClassType::operator delete(void *Pointer, size_t Size)
   26185             : {
   26186             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   26187             :      * or throwing an exception. */
   26188        3032 :     ALLOC_MUTEX(SgClassType, lock);
   26189             : 
   26190             : #if USE_CPP_NEW_DELETE_OPERATORS
   26191             :     ROSE_FREE(Pointer);
   26192             : #else
   26193             : #if ROSE_PEDANTIC_ALLOC
   26194             :     ROSE_ASSERT(Size == sizeof(SgClassType));
   26195             : #else
   26196        3032 :     if (Size != sizeof(SgClassType)) {
   26197           0 :       ROSE_FREE(Pointer);
   26198           0 :       ALLOC_MUTEX(SgClassType, unlock);
   26199             :       return;
   26200             :     }
   26201             : #endif
   26202             : 
   26203        3032 :     SgClassType * object = (SgClassType*) Pointer;
   26204        3032 :     ROSE_ASSERT(object != nullptr);
   26205             : 
   26206             : #if ROSE_ALLOC_TRACE == 2
   26207             : //  printf("SgClassType::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgClassType::next_node);
   26208             :     printf("SgClassType::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgClassType::next_node);
   26209             : #endif
   26210             : 
   26211             : #if ROSE_PEDANTIC_ALLOC
   26212             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   26213             : #endif
   26214             : 
   26215             : #if ROSE_ALLOC_MEMSET == 1
   26216             : #elif ROSE_ALLOC_MEMSET == 2
   26217             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgClassType) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   26218             : #elif ROSE_ALLOC_MEMSET == 3
   26219             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgClassType) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   26220             : #endif
   26221             : 
   26222             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   26223             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   26224             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   26225             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   26226             : #else
   26227        3032 :     object->p_freepointer = SgClassType::next_node;
   26228        3032 :     SgClassType::next_node = object;
   26229             : #endif
   26230             : 
   26231             : #if ROSE_ALLOC_TRACE == 2
   26232             : //  printf("SgClassType::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgClassType::next_node);
   26233             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   26234             :     Rose::MemPool::snapshot(oss.str());
   26235             :     alloc_trace_cnt++;
   26236             : #endif
   26237             : 
   26238             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   26239             : 
   26240        3032 :     ALLOC_MUTEX(SgClassType, unlock);
   26241             : }
   26242             : 
   26243             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   26244             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   26245             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   26246             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   26247             : // Also, note comment below from Robb (copied from the Common.code file).
   26248             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   26249             : //
   26250             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   26251             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   26252             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   26253             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   26254             : #if 0
   26255             : void SgClassType::operator delete(void* pointer) { SgClassType::operator delete (pointer, sizeof(SgClassType)); };
   26256             : #endif
   26257             : /* #line 26258 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   26258             : 
   26259             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   26260             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   26261             : // obviously imply C++.
   26262             : 
   26263             : // This implements the support within ROSE for memory pools.  Memory pools
   26264             : // support the most condensed usage of memory within the construction of
   26265             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   26266             : // by a new operator written for each class.
   26267             : 
   26268             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   26269             :     // User wants multi-thread support and POSIX threads are available.
   26270             : #   include <pthread.h>
   26271             :     static pthread_mutex_t SgEnumType_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   26272             : #else
   26273             :      // Cause synchronization to be skipped.
   26274             : #    ifndef ALLOC_MUTEX
   26275             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   26276             : #    endif
   26277             : #    ifdef _REENTRANT
   26278             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   26279             : #       ifdef _MSC_VER
   26280             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   26281             : #       else
   26282             : #           warning "POSIX threads are not available; synchronization being skipped"
   26283             : #       endif
   26284             : #    endif
   26285             : #endif
   26286             : 
   26287             : #ifndef ROSE_ALLOC_TRACE
   26288             : #  define ROSE_ALLOC_TRACE 0
   26289             : #endif
   26290             : 
   26291             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   26292             : #define ROSE_ALLOC_TRACE_CNT
   26293             : #include "memory-pool-snapshot.h"
   26294             : unsigned long alloc_trace_cnt = 0;
   26295             : #endif
   26296             : 
   26297             : #if ROSE_ALLOC_TRACE
   26298             : const unsigned SgEnumType::pool_size = 5;
   26299             : #else
   26300             : const unsigned SgEnumType::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   26301             : #endif
   26302             : 
   26303             : #ifndef ROSE_ALLOC_MEMSET
   26304             : #  define ROSE_ALLOC_MEMSET 0
   26305             : #endif
   26306             : 
   26307             : #ifndef ROSE_PEDANTIC_ALLOC
   26308             : #  define ROSE_PEDANTIC_ALLOC 0
   26309             : #endif
   26310             : 
   26311             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   26312             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   26313             : #endif
   26314             : 
   26315             : #if !defined(SGNODE__ALL_POOLS)
   26316             : #define SGNODE__ALL_POOLS
   26317             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   26318             : #endif
   26319             : 
   26320             : SgEnumType* SgEnumType::next_node = nullptr;
   26321             : std::vector<unsigned char*> SgEnumType::pools;
   26322             : 
   26323             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   26324             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   26325             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   26326             : // around this macro definition rather than each use).
   26327             : #ifndef ALLOC_MUTEX
   26328             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   26329             :         do {                                                                     \
   26330             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   26331             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   26332             :                 abort();                                                         \
   26333             :             }                                                                    \
   26334             :         } while (0);
   26335             : #endif
   26336             : 
   26337             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   26338             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   26339             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   26340             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   26341             : 
   26342             : /*! \brief New operator for SgEnumType.
   26343             : 
   26344             :    This new operator implements memory pools to provide most efficent 
   26345             :    use of the heap within construction of large ASTs.
   26346             : 
   26347             : \internal The new and delete operators use the lower level C malloc/free
   26348             :    function calls for performance and to make sure that mixing of malloc/free
   26349             :    and new/delete by the used can be caught more readily.  This may change
   26350             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   26351             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   26352             :    deallocate memory allocated using ROSE_MALLOC.
   26353             : */
   26354        3019 : void *SgEnumType::operator new ( size_t Size )
   26355             : {
   26356             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   26357             :      * returning or throwing an exception. */
   26358        3019 :     ALLOC_MUTEX(SgEnumType, lock);
   26359             : 
   26360             : #if ROSE_ALLOC_TRACE == 2
   26361             : //    printf("SgEnumType::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgEnumType::next_node);
   26362             : #endif
   26363             : 
   26364             : #if USE_CPP_NEW_DELETE_OPERATORS
   26365             :     void *mem = ROSE_MALLOC(Size);
   26366             :     ALLOC_MUTEX(SgEnumType, unlock);
   26367             :     return mem;
   26368             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   26369             : #if ROSE_PEDANTIC_ALLOC
   26370             :     ROSE_ASSERT(Size == sizeof(SgEnumType));
   26371             : #else
   26372        3019 :     if (Size != sizeof(SgEnumType)) {
   26373           0 :       void * object = ROSE_MALLOC(Size);
   26374           0 :       ALLOC_MUTEX(SgEnumType, unlock);
   26375             :       return object;
   26376             :     }
   26377             : #endif
   26378             : 
   26379        3019 :     if (SgEnumType::next_node == nullptr) {
   26380         183 :         SgEnumType * alloc = (SgEnumType*) ROSE_MALLOC ( SgEnumType::pool_size * sizeof(SgEnumType) );
   26381         183 :         ROSE_ASSERT(alloc != nullptr);
   26382             : 
   26383             : #if ROSE_ALLOC_TRACE == 2
   26384             : //        printf("SgEnumType::alloc\n  block[%zi] = [ %p , %p [\n", SgEnumType::pools.size(), alloc, alloc + SgEnumType::pool_size);
   26385             : #endif
   26386             : 
   26387             : #if ROSE_ALLOC_MEMSET == 1
   26388             : #elif ROSE_ALLOC_MEMSET == 2
   26389             :         memset(alloc, 0x00, SgEnumType::pool_size * sizeof(SgEnumType));
   26390             : #elif ROSE_ALLOC_MEMSET == 3
   26391             :         memset(alloc, 0xAA, SgEnumType::pool_size * sizeof(SgEnumType));
   26392             : #endif
   26393      366000 :         for (unsigned i=0; i < SgEnumType::pool_size-1; i++) {
   26394      365817 :           alloc[i].p_freepointer = &(alloc[i+1]);
   26395             :         }
   26396         183 :         alloc[SgEnumType::pool_size-1].p_freepointer = nullptr;
   26397             : 
   26398         183 :         SgEnumType::pools.push_back ( (unsigned char *) alloc );
   26399         183 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgEnumType::pool_size * sizeof(SgEnumType), V_SgEnumType ) );
   26400         183 :         SgEnumType::next_node = alloc;
   26401             :     }
   26402        3019 :     ROSE_ASSERT(SgEnumType::next_node != nullptr);
   26403             : 
   26404        3019 :     SgEnumType * object = SgEnumType::next_node;
   26405        3019 :     SgEnumType::next_node = (SgEnumType*)(object->p_freepointer);
   26406             : 
   26407             : #if ROSE_ALLOC_TRACE == 2
   26408             :     printf("SgEnumType::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgEnumType::next_node);
   26409             : #endif
   26410             : 
   26411        3019 :     SgNode * fp = object->p_freepointer;
   26412             : #if ROSE_ALLOC_MEMSET == 1
   26413             : #elif ROSE_ALLOC_MEMSET == 2
   26414             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgEnumType) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   26415             : #elif ROSE_ALLOC_MEMSET == 3
   26416             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgEnumType) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   26417             : #endif
   26418        3019 :     object->p_freepointer = fp;
   26419             : 
   26420             : #if ROSE_ALLOC_TRACE == 2
   26421             : //    printf("SgEnumType::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgEnumType::next_node);
   26422             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   26423             :     Rose::MemPool::snapshot(oss.str());
   26424             :     alloc_trace_cnt++;
   26425             : #endif
   26426             : 
   26427        3019 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   26428             : 
   26429        3019 :     ALLOC_MUTEX(SgEnumType, unlock);
   26430             : 
   26431             :     return object;
   26432             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   26433             : }
   26434             : 
   26435             : 
   26436             : 
   26437             : /*! \brief Delete operator for SgEnumType.
   26438             : 
   26439             :    This delete operator implements deallocation using memory pools to 
   26440             :    provide most efficent use of the heap within construction of large ASTs.
   26441             : 
   26442             : \internal The new and delete operators use the lower level C malloc/free
   26443             :    function calls for performance and to make sure that mixing of malloc/free
   26444             :    and new/delete by the used can be caught more readily.  This may change
   26445             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   26446             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   26447             :    deallocate memory allocated using ROSE_MALLOC.
   26448             : */
   26449        1624 : void SgEnumType::operator delete(void *Pointer, size_t Size)
   26450             : {
   26451             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   26452             :      * or throwing an exception. */
   26453        1624 :     ALLOC_MUTEX(SgEnumType, lock);
   26454             : 
   26455             : #if USE_CPP_NEW_DELETE_OPERATORS
   26456             :     ROSE_FREE(Pointer);
   26457             : #else
   26458             : #if ROSE_PEDANTIC_ALLOC
   26459             :     ROSE_ASSERT(Size == sizeof(SgEnumType));
   26460             : #else
   26461        1624 :     if (Size != sizeof(SgEnumType)) {
   26462           0 :       ROSE_FREE(Pointer);
   26463           0 :       ALLOC_MUTEX(SgEnumType, unlock);
   26464             :       return;
   26465             :     }
   26466             : #endif
   26467             : 
   26468        1624 :     SgEnumType * object = (SgEnumType*) Pointer;
   26469        1624 :     ROSE_ASSERT(object != nullptr);
   26470             : 
   26471             : #if ROSE_ALLOC_TRACE == 2
   26472             : //  printf("SgEnumType::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgEnumType::next_node);
   26473             :     printf("SgEnumType::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgEnumType::next_node);
   26474             : #endif
   26475             : 
   26476             : #if ROSE_PEDANTIC_ALLOC
   26477             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   26478             : #endif
   26479             : 
   26480             : #if ROSE_ALLOC_MEMSET == 1
   26481             : #elif ROSE_ALLOC_MEMSET == 2
   26482             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgEnumType) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   26483             : #elif ROSE_ALLOC_MEMSET == 3
   26484             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgEnumType) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   26485             : #endif
   26486             : 
   26487             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   26488             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   26489             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   26490             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   26491             : #else
   26492        1624 :     object->p_freepointer = SgEnumType::next_node;
   26493        1624 :     SgEnumType::next_node = object;
   26494             : #endif
   26495             : 
   26496             : #if ROSE_ALLOC_TRACE == 2
   26497             : //  printf("SgEnumType::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgEnumType::next_node);
   26498             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   26499             :     Rose::MemPool::snapshot(oss.str());
   26500             :     alloc_trace_cnt++;
   26501             : #endif
   26502             : 
   26503             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   26504             : 
   26505        1624 :     ALLOC_MUTEX(SgEnumType, unlock);
   26506             : }
   26507             : 
   26508             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   26509             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   26510             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   26511             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   26512             : // Also, note comment below from Robb (copied from the Common.code file).
   26513             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   26514             : //
   26515             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   26516             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   26517             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   26518             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   26519             : #if 0
   26520             : void SgEnumType::operator delete(void* pointer) { SgEnumType::operator delete (pointer, sizeof(SgEnumType)); };
   26521             : #endif
   26522             : /* #line 26523 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   26523             : 
   26524             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   26525             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   26526             : // obviously imply C++.
   26527             : 
   26528             : // This implements the support within ROSE for memory pools.  Memory pools
   26529             : // support the most condensed usage of memory within the construction of
   26530             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   26531             : // by a new operator written for each class.
   26532             : 
   26533             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   26534             :     // User wants multi-thread support and POSIX threads are available.
   26535             : #   include <pthread.h>
   26536             :     static pthread_mutex_t SgTypedefType_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   26537             : #else
   26538             :      // Cause synchronization to be skipped.
   26539             : #    ifndef ALLOC_MUTEX
   26540             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   26541             : #    endif
   26542             : #    ifdef _REENTRANT
   26543             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   26544             : #       ifdef _MSC_VER
   26545             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   26546             : #       else
   26547             : #           warning "POSIX threads are not available; synchronization being skipped"
   26548             : #       endif
   26549             : #    endif
   26550             : #endif
   26551             : 
   26552             : #ifndef ROSE_ALLOC_TRACE
   26553             : #  define ROSE_ALLOC_TRACE 0
   26554             : #endif
   26555             : 
   26556             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   26557             : #define ROSE_ALLOC_TRACE_CNT
   26558             : #include "memory-pool-snapshot.h"
   26559             : unsigned long alloc_trace_cnt = 0;
   26560             : #endif
   26561             : 
   26562             : #if ROSE_ALLOC_TRACE
   26563             : const unsigned SgTypedefType::pool_size = 5;
   26564             : #else
   26565             : const unsigned SgTypedefType::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   26566             : #endif
   26567             : 
   26568             : #ifndef ROSE_ALLOC_MEMSET
   26569             : #  define ROSE_ALLOC_MEMSET 0
   26570             : #endif
   26571             : 
   26572             : #ifndef ROSE_PEDANTIC_ALLOC
   26573             : #  define ROSE_PEDANTIC_ALLOC 0
   26574             : #endif
   26575             : 
   26576             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   26577             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   26578             : #endif
   26579             : 
   26580             : #if !defined(SGNODE__ALL_POOLS)
   26581             : #define SGNODE__ALL_POOLS
   26582             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   26583             : #endif
   26584             : 
   26585             : SgTypedefType* SgTypedefType::next_node = nullptr;
   26586             : std::vector<unsigned char*> SgTypedefType::pools;
   26587             : 
   26588             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   26589             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   26590             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   26591             : // around this macro definition rather than each use).
   26592             : #ifndef ALLOC_MUTEX
   26593             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   26594             :         do {                                                                     \
   26595             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   26596             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   26597             :                 abort();                                                         \
   26598             :             }                                                                    \
   26599             :         } while (0);
   26600             : #endif
   26601             : 
   26602             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   26603             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   26604             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   26605             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   26606             : 
   26607             : /*! \brief New operator for SgTypedefType.
   26608             : 
   26609             :    This new operator implements memory pools to provide most efficent 
   26610             :    use of the heap within construction of large ASTs.
   26611             : 
   26612             : \internal The new and delete operators use the lower level C malloc/free
   26613             :    function calls for performance and to make sure that mixing of malloc/free
   26614             :    and new/delete by the used can be caught more readily.  This may change
   26615             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   26616             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   26617             :    deallocate memory allocated using ROSE_MALLOC.
   26618             : */
   26619       54333 : void *SgTypedefType::operator new ( size_t Size )
   26620             : {
   26621             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   26622             :      * returning or throwing an exception. */
   26623       54333 :     ALLOC_MUTEX(SgTypedefType, lock);
   26624             : 
   26625             : #if ROSE_ALLOC_TRACE == 2
   26626             : //    printf("SgTypedefType::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgTypedefType::next_node);
   26627             : #endif
   26628             : 
   26629             : #if USE_CPP_NEW_DELETE_OPERATORS
   26630             :     void *mem = ROSE_MALLOC(Size);
   26631             :     ALLOC_MUTEX(SgTypedefType, unlock);
   26632             :     return mem;
   26633             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   26634             : #if ROSE_PEDANTIC_ALLOC
   26635             :     ROSE_ASSERT(Size == sizeof(SgTypedefType));
   26636             : #else
   26637       54333 :     if (Size != sizeof(SgTypedefType)) {
   26638           0 :       void * object = ROSE_MALLOC(Size);
   26639           0 :       ALLOC_MUTEX(SgTypedefType, unlock);
   26640             :       return object;
   26641             :     }
   26642             : #endif
   26643             : 
   26644       54333 :     if (SgTypedefType::next_node == nullptr) {
   26645         315 :         SgTypedefType * alloc = (SgTypedefType*) ROSE_MALLOC ( SgTypedefType::pool_size * sizeof(SgTypedefType) );
   26646         315 :         ROSE_ASSERT(alloc != nullptr);
   26647             : 
   26648             : #if ROSE_ALLOC_TRACE == 2
   26649             : //        printf("SgTypedefType::alloc\n  block[%zi] = [ %p , %p [\n", SgTypedefType::pools.size(), alloc, alloc + SgTypedefType::pool_size);
   26650             : #endif
   26651             : 
   26652             : #if ROSE_ALLOC_MEMSET == 1
   26653             : #elif ROSE_ALLOC_MEMSET == 2
   26654             :         memset(alloc, 0x00, SgTypedefType::pool_size * sizeof(SgTypedefType));
   26655             : #elif ROSE_ALLOC_MEMSET == 3
   26656             :         memset(alloc, 0xAA, SgTypedefType::pool_size * sizeof(SgTypedefType));
   26657             : #endif
   26658      630000 :         for (unsigned i=0; i < SgTypedefType::pool_size-1; i++) {
   26659      629685 :           alloc[i].p_freepointer = &(alloc[i+1]);
   26660             :         }
   26661         315 :         alloc[SgTypedefType::pool_size-1].p_freepointer = nullptr;
   26662             : 
   26663         315 :         SgTypedefType::pools.push_back ( (unsigned char *) alloc );
   26664         315 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgTypedefType::pool_size * sizeof(SgTypedefType), V_SgTypedefType ) );
   26665         315 :         SgTypedefType::next_node = alloc;
   26666             :     }
   26667       54333 :     ROSE_ASSERT(SgTypedefType::next_node != nullptr);
   26668             : 
   26669       54333 :     SgTypedefType * object = SgTypedefType::next_node;
   26670       54333 :     SgTypedefType::next_node = (SgTypedefType*)(object->p_freepointer);
   26671             : 
   26672             : #if ROSE_ALLOC_TRACE == 2
   26673             :     printf("SgTypedefType::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypedefType::next_node);
   26674             : #endif
   26675             : 
   26676       54333 :     SgNode * fp = object->p_freepointer;
   26677             : #if ROSE_ALLOC_MEMSET == 1
   26678             : #elif ROSE_ALLOC_MEMSET == 2
   26679             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgTypedefType) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   26680             : #elif ROSE_ALLOC_MEMSET == 3
   26681             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgTypedefType) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   26682             : #endif
   26683       54333 :     object->p_freepointer = fp;
   26684             : 
   26685             : #if ROSE_ALLOC_TRACE == 2
   26686             : //    printf("SgTypedefType::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypedefType::next_node);
   26687             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   26688             :     Rose::MemPool::snapshot(oss.str());
   26689             :     alloc_trace_cnt++;
   26690             : #endif
   26691             : 
   26692       54333 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   26693             : 
   26694       54333 :     ALLOC_MUTEX(SgTypedefType, unlock);
   26695             : 
   26696             :     return object;
   26697             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   26698             : }
   26699             : 
   26700             : 
   26701             : 
   26702             : /*! \brief Delete operator for SgTypedefType.
   26703             : 
   26704             :    This delete operator implements deallocation using memory pools to 
   26705             :    provide most efficent use of the heap within construction of large ASTs.
   26706             : 
   26707             : \internal The new and delete operators use the lower level C malloc/free
   26708             :    function calls for performance and to make sure that mixing of malloc/free
   26709             :    and new/delete by the used can be caught more readily.  This may change
   26710             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   26711             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   26712             :    deallocate memory allocated using ROSE_MALLOC.
   26713             : */
   26714        3696 : void SgTypedefType::operator delete(void *Pointer, size_t Size)
   26715             : {
   26716             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   26717             :      * or throwing an exception. */
   26718        3696 :     ALLOC_MUTEX(SgTypedefType, lock);
   26719             : 
   26720             : #if USE_CPP_NEW_DELETE_OPERATORS
   26721             :     ROSE_FREE(Pointer);
   26722             : #else
   26723             : #if ROSE_PEDANTIC_ALLOC
   26724             :     ROSE_ASSERT(Size == sizeof(SgTypedefType));
   26725             : #else
   26726        3696 :     if (Size != sizeof(SgTypedefType)) {
   26727           0 :       ROSE_FREE(Pointer);
   26728           0 :       ALLOC_MUTEX(SgTypedefType, unlock);
   26729             :       return;
   26730             :     }
   26731             : #endif
   26732             : 
   26733        3696 :     SgTypedefType * object = (SgTypedefType*) Pointer;
   26734        3696 :     ROSE_ASSERT(object != nullptr);
   26735             : 
   26736             : #if ROSE_ALLOC_TRACE == 2
   26737             : //  printf("SgTypedefType::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypedefType::next_node);
   26738             :     printf("SgTypedefType::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypedefType::next_node);
   26739             : #endif
   26740             : 
   26741             : #if ROSE_PEDANTIC_ALLOC
   26742             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   26743             : #endif
   26744             : 
   26745             : #if ROSE_ALLOC_MEMSET == 1
   26746             : #elif ROSE_ALLOC_MEMSET == 2
   26747             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgTypedefType) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   26748             : #elif ROSE_ALLOC_MEMSET == 3
   26749             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgTypedefType) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   26750             : #endif
   26751             : 
   26752             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   26753             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   26754             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   26755             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   26756             : #else
   26757        3696 :     object->p_freepointer = SgTypedefType::next_node;
   26758        3696 :     SgTypedefType::next_node = object;
   26759             : #endif
   26760             : 
   26761             : #if ROSE_ALLOC_TRACE == 2
   26762             : //  printf("SgTypedefType::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypedefType::next_node);
   26763             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   26764             :     Rose::MemPool::snapshot(oss.str());
   26765             :     alloc_trace_cnt++;
   26766             : #endif
   26767             : 
   26768             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   26769             : 
   26770        3696 :     ALLOC_MUTEX(SgTypedefType, unlock);
   26771             : }
   26772             : 
   26773             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   26774             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   26775             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   26776             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   26777             : // Also, note comment below from Robb (copied from the Common.code file).
   26778             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   26779             : //
   26780             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   26781             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   26782             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   26783             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   26784             : #if 0
   26785             : void SgTypedefType::operator delete(void* pointer) { SgTypedefType::operator delete (pointer, sizeof(SgTypedefType)); };
   26786             : #endif
   26787             : /* #line 26788 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   26788             : 
   26789             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   26790             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   26791             : // obviously imply C++.
   26792             : 
   26793             : // This implements the support within ROSE for memory pools.  Memory pools
   26794             : // support the most condensed usage of memory within the construction of
   26795             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   26796             : // by a new operator written for each class.
   26797             : 
   26798             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   26799             :     // User wants multi-thread support and POSIX threads are available.
   26800             : #   include <pthread.h>
   26801             :     static pthread_mutex_t SgNonrealType_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   26802             : #else
   26803             :      // Cause synchronization to be skipped.
   26804             : #    ifndef ALLOC_MUTEX
   26805             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   26806             : #    endif
   26807             : #    ifdef _REENTRANT
   26808             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   26809             : #       ifdef _MSC_VER
   26810             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   26811             : #       else
   26812             : #           warning "POSIX threads are not available; synchronization being skipped"
   26813             : #       endif
   26814             : #    endif
   26815             : #endif
   26816             : 
   26817             : #ifndef ROSE_ALLOC_TRACE
   26818             : #  define ROSE_ALLOC_TRACE 0
   26819             : #endif
   26820             : 
   26821             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   26822             : #define ROSE_ALLOC_TRACE_CNT
   26823             : #include "memory-pool-snapshot.h"
   26824             : unsigned long alloc_trace_cnt = 0;
   26825             : #endif
   26826             : 
   26827             : #if ROSE_ALLOC_TRACE
   26828             : const unsigned SgNonrealType::pool_size = 5;
   26829             : #else
   26830             : const unsigned SgNonrealType::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   26831             : #endif
   26832             : 
   26833             : #ifndef ROSE_ALLOC_MEMSET
   26834             : #  define ROSE_ALLOC_MEMSET 0
   26835             : #endif
   26836             : 
   26837             : #ifndef ROSE_PEDANTIC_ALLOC
   26838             : #  define ROSE_PEDANTIC_ALLOC 0
   26839             : #endif
   26840             : 
   26841             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   26842             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   26843             : #endif
   26844             : 
   26845             : #if !defined(SGNODE__ALL_POOLS)
   26846             : #define SGNODE__ALL_POOLS
   26847             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   26848             : #endif
   26849             : 
   26850             : SgNonrealType* SgNonrealType::next_node = nullptr;
   26851             : std::vector<unsigned char*> SgNonrealType::pools;
   26852             : 
   26853             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   26854             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   26855             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   26856             : // around this macro definition rather than each use).
   26857             : #ifndef ALLOC_MUTEX
   26858             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   26859             :         do {                                                                     \
   26860             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   26861             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   26862             :                 abort();                                                         \
   26863             :             }                                                                    \
   26864             :         } while (0);
   26865             : #endif
   26866             : 
   26867             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   26868             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   26869             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   26870             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   26871             : 
   26872             : /*! \brief New operator for SgNonrealType.
   26873             : 
   26874             :    This new operator implements memory pools to provide most efficent 
   26875             :    use of the heap within construction of large ASTs.
   26876             : 
   26877             : \internal The new and delete operators use the lower level C malloc/free
   26878             :    function calls for performance and to make sure that mixing of malloc/free
   26879             :    and new/delete by the used can be caught more readily.  This may change
   26880             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   26881             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   26882             :    deallocate memory allocated using ROSE_MALLOC.
   26883             : */
   26884       54405 : void *SgNonrealType::operator new ( size_t Size )
   26885             : {
   26886             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   26887             :      * returning or throwing an exception. */
   26888       54405 :     ALLOC_MUTEX(SgNonrealType, lock);
   26889             : 
   26890             : #if ROSE_ALLOC_TRACE == 2
   26891             : //    printf("SgNonrealType::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgNonrealType::next_node);
   26892             : #endif
   26893             : 
   26894             : #if USE_CPP_NEW_DELETE_OPERATORS
   26895             :     void *mem = ROSE_MALLOC(Size);
   26896             :     ALLOC_MUTEX(SgNonrealType, unlock);
   26897             :     return mem;
   26898             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   26899             : #if ROSE_PEDANTIC_ALLOC
   26900             :     ROSE_ASSERT(Size == sizeof(SgNonrealType));
   26901             : #else
   26902       54405 :     if (Size != sizeof(SgNonrealType)) {
   26903           0 :       void * object = ROSE_MALLOC(Size);
   26904           0 :       ALLOC_MUTEX(SgNonrealType, unlock);
   26905             :       return object;
   26906             :     }
   26907             : #endif
   26908             : 
   26909       54405 :     if (SgNonrealType::next_node == nullptr) {
   26910          31 :         SgNonrealType * alloc = (SgNonrealType*) ROSE_MALLOC ( SgNonrealType::pool_size * sizeof(SgNonrealType) );
   26911          31 :         ROSE_ASSERT(alloc != nullptr);
   26912             : 
   26913             : #if ROSE_ALLOC_TRACE == 2
   26914             : //        printf("SgNonrealType::alloc\n  block[%zi] = [ %p , %p [\n", SgNonrealType::pools.size(), alloc, alloc + SgNonrealType::pool_size);
   26915             : #endif
   26916             : 
   26917             : #if ROSE_ALLOC_MEMSET == 1
   26918             : #elif ROSE_ALLOC_MEMSET == 2
   26919             :         memset(alloc, 0x00, SgNonrealType::pool_size * sizeof(SgNonrealType));
   26920             : #elif ROSE_ALLOC_MEMSET == 3
   26921             :         memset(alloc, 0xAA, SgNonrealType::pool_size * sizeof(SgNonrealType));
   26922             : #endif
   26923       62000 :         for (unsigned i=0; i < SgNonrealType::pool_size-1; i++) {
   26924       61969 :           alloc[i].p_freepointer = &(alloc[i+1]);
   26925             :         }
   26926          31 :         alloc[SgNonrealType::pool_size-1].p_freepointer = nullptr;
   26927             : 
   26928          31 :         SgNonrealType::pools.push_back ( (unsigned char *) alloc );
   26929          31 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgNonrealType::pool_size * sizeof(SgNonrealType), V_SgNonrealType ) );
   26930          31 :         SgNonrealType::next_node = alloc;
   26931             :     }
   26932       54405 :     ROSE_ASSERT(SgNonrealType::next_node != nullptr);
   26933             : 
   26934       54405 :     SgNonrealType * object = SgNonrealType::next_node;
   26935       54405 :     SgNonrealType::next_node = (SgNonrealType*)(object->p_freepointer);
   26936             : 
   26937             : #if ROSE_ALLOC_TRACE == 2
   26938             :     printf("SgNonrealType::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgNonrealType::next_node);
   26939             : #endif
   26940             : 
   26941       54405 :     SgNode * fp = object->p_freepointer;
   26942             : #if ROSE_ALLOC_MEMSET == 1
   26943             : #elif ROSE_ALLOC_MEMSET == 2
   26944             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgNonrealType) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   26945             : #elif ROSE_ALLOC_MEMSET == 3
   26946             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgNonrealType) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   26947             : #endif
   26948       54405 :     object->p_freepointer = fp;
   26949             : 
   26950             : #if ROSE_ALLOC_TRACE == 2
   26951             : //    printf("SgNonrealType::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgNonrealType::next_node);
   26952             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   26953             :     Rose::MemPool::snapshot(oss.str());
   26954             :     alloc_trace_cnt++;
   26955             : #endif
   26956             : 
   26957       54405 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   26958             : 
   26959       54405 :     ALLOC_MUTEX(SgNonrealType, unlock);
   26960             : 
   26961             :     return object;
   26962             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   26963             : }
   26964             : 
   26965             : 
   26966             : 
   26967             : /*! \brief Delete operator for SgNonrealType.
   26968             : 
   26969             :    This delete operator implements deallocation using memory pools to 
   26970             :    provide most efficent use of the heap within construction of large ASTs.
   26971             : 
   26972             : \internal The new and delete operators use the lower level C malloc/free
   26973             :    function calls for performance and to make sure that mixing of malloc/free
   26974             :    and new/delete by the used can be caught more readily.  This may change
   26975             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   26976             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   26977             :    deallocate memory allocated using ROSE_MALLOC.
   26978             : */
   26979       10160 : void SgNonrealType::operator delete(void *Pointer, size_t Size)
   26980             : {
   26981             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   26982             :      * or throwing an exception. */
   26983       10160 :     ALLOC_MUTEX(SgNonrealType, lock);
   26984             : 
   26985             : #if USE_CPP_NEW_DELETE_OPERATORS
   26986             :     ROSE_FREE(Pointer);
   26987             : #else
   26988             : #if ROSE_PEDANTIC_ALLOC
   26989             :     ROSE_ASSERT(Size == sizeof(SgNonrealType));
   26990             : #else
   26991       10160 :     if (Size != sizeof(SgNonrealType)) {
   26992           0 :       ROSE_FREE(Pointer);
   26993           0 :       ALLOC_MUTEX(SgNonrealType, unlock);
   26994             :       return;
   26995             :     }
   26996             : #endif
   26997             : 
   26998       10160 :     SgNonrealType * object = (SgNonrealType*) Pointer;
   26999       10160 :     ROSE_ASSERT(object != nullptr);
   27000             : 
   27001             : #if ROSE_ALLOC_TRACE == 2
   27002             : //  printf("SgNonrealType::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgNonrealType::next_node);
   27003             :     printf("SgNonrealType::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgNonrealType::next_node);
   27004             : #endif
   27005             : 
   27006             : #if ROSE_PEDANTIC_ALLOC
   27007             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   27008             : #endif
   27009             : 
   27010             : #if ROSE_ALLOC_MEMSET == 1
   27011             : #elif ROSE_ALLOC_MEMSET == 2
   27012             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgNonrealType) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   27013             : #elif ROSE_ALLOC_MEMSET == 3
   27014             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgNonrealType) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   27015             : #endif
   27016             : 
   27017             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   27018             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   27019             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   27020             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   27021             : #else
   27022       10160 :     object->p_freepointer = SgNonrealType::next_node;
   27023       10160 :     SgNonrealType::next_node = object;
   27024             : #endif
   27025             : 
   27026             : #if ROSE_ALLOC_TRACE == 2
   27027             : //  printf("SgNonrealType::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgNonrealType::next_node);
   27028             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   27029             :     Rose::MemPool::snapshot(oss.str());
   27030             :     alloc_trace_cnt++;
   27031             : #endif
   27032             : 
   27033             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   27034             : 
   27035       10160 :     ALLOC_MUTEX(SgNonrealType, unlock);
   27036             : }
   27037             : 
   27038             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   27039             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   27040             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   27041             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   27042             : // Also, note comment below from Robb (copied from the Common.code file).
   27043             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   27044             : //
   27045             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   27046             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   27047             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   27048             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   27049             : #if 0
   27050             : void SgNonrealType::operator delete(void* pointer) { SgNonrealType::operator delete (pointer, sizeof(SgNonrealType)); };
   27051             : #endif
   27052             : /* #line 27053 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   27053             : 
   27054             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   27055             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   27056             : // obviously imply C++.
   27057             : 
   27058             : // This implements the support within ROSE for memory pools.  Memory pools
   27059             : // support the most condensed usage of memory within the construction of
   27060             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   27061             : // by a new operator written for each class.
   27062             : 
   27063             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   27064             :     // User wants multi-thread support and POSIX threads are available.
   27065             : #   include <pthread.h>
   27066             :     static pthread_mutex_t SgModifierType_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   27067             : #else
   27068             :      // Cause synchronization to be skipped.
   27069             : #    ifndef ALLOC_MUTEX
   27070             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   27071             : #    endif
   27072             : #    ifdef _REENTRANT
   27073             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   27074             : #       ifdef _MSC_VER
   27075             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   27076             : #       else
   27077             : #           warning "POSIX threads are not available; synchronization being skipped"
   27078             : #       endif
   27079             : #    endif
   27080             : #endif
   27081             : 
   27082             : #ifndef ROSE_ALLOC_TRACE
   27083             : #  define ROSE_ALLOC_TRACE 0
   27084             : #endif
   27085             : 
   27086             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   27087             : #define ROSE_ALLOC_TRACE_CNT
   27088             : #include "memory-pool-snapshot.h"
   27089             : unsigned long alloc_trace_cnt = 0;
   27090             : #endif
   27091             : 
   27092             : #if ROSE_ALLOC_TRACE
   27093             : const unsigned SgModifierType::pool_size = 5;
   27094             : #else
   27095             : const unsigned SgModifierType::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   27096             : #endif
   27097             : 
   27098             : #ifndef ROSE_ALLOC_MEMSET
   27099             : #  define ROSE_ALLOC_MEMSET 0
   27100             : #endif
   27101             : 
   27102             : #ifndef ROSE_PEDANTIC_ALLOC
   27103             : #  define ROSE_PEDANTIC_ALLOC 0
   27104             : #endif
   27105             : 
   27106             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   27107             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   27108             : #endif
   27109             : 
   27110             : #if !defined(SGNODE__ALL_POOLS)
   27111             : #define SGNODE__ALL_POOLS
   27112             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   27113             : #endif
   27114             : 
   27115             : SgModifierType* SgModifierType::next_node = nullptr;
   27116             : std::vector<unsigned char*> SgModifierType::pools;
   27117             : 
   27118             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   27119             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   27120             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   27121             : // around this macro definition rather than each use).
   27122             : #ifndef ALLOC_MUTEX
   27123             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   27124             :         do {                                                                     \
   27125             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   27126             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   27127             :                 abort();                                                         \
   27128             :             }                                                                    \
   27129             :         } while (0);
   27130             : #endif
   27131             : 
   27132             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   27133             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   27134             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   27135             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   27136             : 
   27137             : /*! \brief New operator for SgModifierType.
   27138             : 
   27139             :    This new operator implements memory pools to provide most efficent 
   27140             :    use of the heap within construction of large ASTs.
   27141             : 
   27142             : \internal The new and delete operators use the lower level C malloc/free
   27143             :    function calls for performance and to make sure that mixing of malloc/free
   27144             :    and new/delete by the used can be caught more readily.  This may change
   27145             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   27146             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   27147             :    deallocate memory allocated using ROSE_MALLOC.
   27148             : */
   27149       22843 : void *SgModifierType::operator new ( size_t Size )
   27150             : {
   27151             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   27152             :      * returning or throwing an exception. */
   27153       22843 :     ALLOC_MUTEX(SgModifierType, lock);
   27154             : 
   27155             : #if ROSE_ALLOC_TRACE == 2
   27156             : //    printf("SgModifierType::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgModifierType::next_node);
   27157             : #endif
   27158             : 
   27159             : #if USE_CPP_NEW_DELETE_OPERATORS
   27160             :     void *mem = ROSE_MALLOC(Size);
   27161             :     ALLOC_MUTEX(SgModifierType, unlock);
   27162             :     return mem;
   27163             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   27164             : #if ROSE_PEDANTIC_ALLOC
   27165             :     ROSE_ASSERT(Size == sizeof(SgModifierType));
   27166             : #else
   27167       22843 :     if (Size != sizeof(SgModifierType)) {
   27168           0 :       void * object = ROSE_MALLOC(Size);
   27169           0 :       ALLOC_MUTEX(SgModifierType, unlock);
   27170             :       return object;
   27171             :     }
   27172             : #endif
   27173             : 
   27174       22843 :     if (SgModifierType::next_node == nullptr) {
   27175         315 :         SgModifierType * alloc = (SgModifierType*) ROSE_MALLOC ( SgModifierType::pool_size * sizeof(SgModifierType) );
   27176         315 :         ROSE_ASSERT(alloc != nullptr);
   27177             : 
   27178             : #if ROSE_ALLOC_TRACE == 2
   27179             : //        printf("SgModifierType::alloc\n  block[%zi] = [ %p , %p [\n", SgModifierType::pools.size(), alloc, alloc + SgModifierType::pool_size);
   27180             : #endif
   27181             : 
   27182             : #if ROSE_ALLOC_MEMSET == 1
   27183             : #elif ROSE_ALLOC_MEMSET == 2
   27184             :         memset(alloc, 0x00, SgModifierType::pool_size * sizeof(SgModifierType));
   27185             : #elif ROSE_ALLOC_MEMSET == 3
   27186             :         memset(alloc, 0xAA, SgModifierType::pool_size * sizeof(SgModifierType));
   27187             : #endif
   27188      630000 :         for (unsigned i=0; i < SgModifierType::pool_size-1; i++) {
   27189      629685 :           alloc[i].p_freepointer = &(alloc[i+1]);
   27190             :         }
   27191         315 :         alloc[SgModifierType::pool_size-1].p_freepointer = nullptr;
   27192             : 
   27193         315 :         SgModifierType::pools.push_back ( (unsigned char *) alloc );
   27194         315 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgModifierType::pool_size * sizeof(SgModifierType), V_SgModifierType ) );
   27195         315 :         SgModifierType::next_node = alloc;
   27196             :     }
   27197       22843 :     ROSE_ASSERT(SgModifierType::next_node != nullptr);
   27198             : 
   27199       22843 :     SgModifierType * object = SgModifierType::next_node;
   27200       22843 :     SgModifierType::next_node = (SgModifierType*)(object->p_freepointer);
   27201             : 
   27202             : #if ROSE_ALLOC_TRACE == 2
   27203             :     printf("SgModifierType::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgModifierType::next_node);
   27204             : #endif
   27205             : 
   27206       22843 :     SgNode * fp = object->p_freepointer;
   27207             : #if ROSE_ALLOC_MEMSET == 1
   27208             : #elif ROSE_ALLOC_MEMSET == 2
   27209             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgModifierType) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   27210             : #elif ROSE_ALLOC_MEMSET == 3
   27211             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgModifierType) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   27212             : #endif
   27213       22843 :     object->p_freepointer = fp;
   27214             : 
   27215             : #if ROSE_ALLOC_TRACE == 2
   27216             : //    printf("SgModifierType::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgModifierType::next_node);
   27217             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   27218             :     Rose::MemPool::snapshot(oss.str());
   27219             :     alloc_trace_cnt++;
   27220             : #endif
   27221             : 
   27222       22843 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   27223             : 
   27224       22843 :     ALLOC_MUTEX(SgModifierType, unlock);
   27225             : 
   27226             :     return object;
   27227             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   27228             : }
   27229             : 
   27230             : 
   27231             : 
   27232             : /*! \brief Delete operator for SgModifierType.
   27233             : 
   27234             :    This delete operator implements deallocation using memory pools to 
   27235             :    provide most efficent use of the heap within construction of large ASTs.
   27236             : 
   27237             : \internal The new and delete operators use the lower level C malloc/free
   27238             :    function calls for performance and to make sure that mixing of malloc/free
   27239             :    and new/delete by the used can be caught more readily.  This may change
   27240             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   27241             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   27242             :    deallocate memory allocated using ROSE_MALLOC.
   27243             : */
   27244        1906 : void SgModifierType::operator delete(void *Pointer, size_t Size)
   27245             : {
   27246             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   27247             :      * or throwing an exception. */
   27248        1906 :     ALLOC_MUTEX(SgModifierType, lock);
   27249             : 
   27250             : #if USE_CPP_NEW_DELETE_OPERATORS
   27251             :     ROSE_FREE(Pointer);
   27252             : #else
   27253             : #if ROSE_PEDANTIC_ALLOC
   27254             :     ROSE_ASSERT(Size == sizeof(SgModifierType));
   27255             : #else
   27256        1906 :     if (Size != sizeof(SgModifierType)) {
   27257           0 :       ROSE_FREE(Pointer);
   27258           0 :       ALLOC_MUTEX(SgModifierType, unlock);
   27259             :       return;
   27260             :     }
   27261             : #endif
   27262             : 
   27263        1906 :     SgModifierType * object = (SgModifierType*) Pointer;
   27264        1906 :     ROSE_ASSERT(object != nullptr);
   27265             : 
   27266             : #if ROSE_ALLOC_TRACE == 2
   27267             : //  printf("SgModifierType::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgModifierType::next_node);
   27268             :     printf("SgModifierType::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgModifierType::next_node);
   27269             : #endif
   27270             : 
   27271             : #if ROSE_PEDANTIC_ALLOC
   27272             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   27273             : #endif
   27274             : 
   27275             : #if ROSE_ALLOC_MEMSET == 1
   27276             : #elif ROSE_ALLOC_MEMSET == 2
   27277             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgModifierType) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   27278             : #elif ROSE_ALLOC_MEMSET == 3
   27279             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgModifierType) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   27280             : #endif
   27281             : 
   27282             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   27283             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   27284             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   27285             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   27286             : #else
   27287        1906 :     object->p_freepointer = SgModifierType::next_node;
   27288        1906 :     SgModifierType::next_node = object;
   27289             : #endif
   27290             : 
   27291             : #if ROSE_ALLOC_TRACE == 2
   27292             : //  printf("SgModifierType::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgModifierType::next_node);
   27293             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   27294             :     Rose::MemPool::snapshot(oss.str());
   27295             :     alloc_trace_cnt++;
   27296             : #endif
   27297             : 
   27298             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   27299             : 
   27300        1906 :     ALLOC_MUTEX(SgModifierType, unlock);
   27301             : }
   27302             : 
   27303             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   27304             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   27305             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   27306             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   27307             : // Also, note comment below from Robb (copied from the Common.code file).
   27308             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   27309             : //
   27310             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   27311             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   27312             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   27313             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   27314             : #if 0
   27315             : void SgModifierType::operator delete(void* pointer) { SgModifierType::operator delete (pointer, sizeof(SgModifierType)); };
   27316             : #endif
   27317             : /* #line 27318 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   27318             : 
   27319             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   27320             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   27321             : // obviously imply C++.
   27322             : 
   27323             : // This implements the support within ROSE for memory pools.  Memory pools
   27324             : // support the most condensed usage of memory within the construction of
   27325             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   27326             : // by a new operator written for each class.
   27327             : 
   27328             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   27329             :     // User wants multi-thread support and POSIX threads are available.
   27330             : #   include <pthread.h>
   27331             :     static pthread_mutex_t SgFunctionType_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   27332             : #else
   27333             :      // Cause synchronization to be skipped.
   27334             : #    ifndef ALLOC_MUTEX
   27335             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   27336             : #    endif
   27337             : #    ifdef _REENTRANT
   27338             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   27339             : #       ifdef _MSC_VER
   27340             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   27341             : #       else
   27342             : #           warning "POSIX threads are not available; synchronization being skipped"
   27343             : #       endif
   27344             : #    endif
   27345             : #endif
   27346             : 
   27347             : #ifndef ROSE_ALLOC_TRACE
   27348             : #  define ROSE_ALLOC_TRACE 0
   27349             : #endif
   27350             : 
   27351             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   27352             : #define ROSE_ALLOC_TRACE_CNT
   27353             : #include "memory-pool-snapshot.h"
   27354             : unsigned long alloc_trace_cnt = 0;
   27355             : #endif
   27356             : 
   27357             : #if ROSE_ALLOC_TRACE
   27358             : const unsigned SgFunctionType::pool_size = 5;
   27359             : #else
   27360             : const unsigned SgFunctionType::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   27361             : #endif
   27362             : 
   27363             : #ifndef ROSE_ALLOC_MEMSET
   27364             : #  define ROSE_ALLOC_MEMSET 0
   27365             : #endif
   27366             : 
   27367             : #ifndef ROSE_PEDANTIC_ALLOC
   27368             : #  define ROSE_PEDANTIC_ALLOC 0
   27369             : #endif
   27370             : 
   27371             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   27372             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   27373             : #endif
   27374             : 
   27375             : #if !defined(SGNODE__ALL_POOLS)
   27376             : #define SGNODE__ALL_POOLS
   27377             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   27378             : #endif
   27379             : 
   27380             : SgFunctionType* SgFunctionType::next_node = nullptr;
   27381             : std::vector<unsigned char*> SgFunctionType::pools;
   27382             : 
   27383             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   27384             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   27385             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   27386             : // around this macro definition rather than each use).
   27387             : #ifndef ALLOC_MUTEX
   27388             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   27389             :         do {                                                                     \
   27390             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   27391             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   27392             :                 abort();                                                         \
   27393             :             }                                                                    \
   27394             :         } while (0);
   27395             : #endif
   27396             : 
   27397             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   27398             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   27399             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   27400             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   27401             : 
   27402             : /*! \brief New operator for SgFunctionType.
   27403             : 
   27404             :    This new operator implements memory pools to provide most efficent 
   27405             :    use of the heap within construction of large ASTs.
   27406             : 
   27407             : \internal The new and delete operators use the lower level C malloc/free
   27408             :    function calls for performance and to make sure that mixing of malloc/free
   27409             :    and new/delete by the used can be caught more readily.  This may change
   27410             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   27411             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   27412             :    deallocate memory allocated using ROSE_MALLOC.
   27413             : */
   27414      234454 : void *SgFunctionType::operator new ( size_t Size )
   27415             : {
   27416             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   27417             :      * returning or throwing an exception. */
   27418      234454 :     ALLOC_MUTEX(SgFunctionType, lock);
   27419             : 
   27420             : #if ROSE_ALLOC_TRACE == 2
   27421             : //    printf("SgFunctionType::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgFunctionType::next_node);
   27422             : #endif
   27423             : 
   27424             : #if USE_CPP_NEW_DELETE_OPERATORS
   27425             :     void *mem = ROSE_MALLOC(Size);
   27426             :     ALLOC_MUTEX(SgFunctionType, unlock);
   27427             :     return mem;
   27428             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   27429             : #if ROSE_PEDANTIC_ALLOC
   27430             :     ROSE_ASSERT(Size == sizeof(SgFunctionType));
   27431             : #else
   27432      234454 :     if (Size != sizeof(SgFunctionType)) {
   27433           0 :       void * object = ROSE_MALLOC(Size);
   27434           0 :       ALLOC_MUTEX(SgFunctionType, unlock);
   27435             :       return object;
   27436             :     }
   27437             : #endif
   27438             : 
   27439      234454 :     if (SgFunctionType::next_node == nullptr) {
   27440         360 :         SgFunctionType * alloc = (SgFunctionType*) ROSE_MALLOC ( SgFunctionType::pool_size * sizeof(SgFunctionType) );
   27441         360 :         ROSE_ASSERT(alloc != nullptr);
   27442             : 
   27443             : #if ROSE_ALLOC_TRACE == 2
   27444             : //        printf("SgFunctionType::alloc\n  block[%zi] = [ %p , %p [\n", SgFunctionType::pools.size(), alloc, alloc + SgFunctionType::pool_size);
   27445             : #endif
   27446             : 
   27447             : #if ROSE_ALLOC_MEMSET == 1
   27448             : #elif ROSE_ALLOC_MEMSET == 2
   27449             :         memset(alloc, 0x00, SgFunctionType::pool_size * sizeof(SgFunctionType));
   27450             : #elif ROSE_ALLOC_MEMSET == 3
   27451             :         memset(alloc, 0xAA, SgFunctionType::pool_size * sizeof(SgFunctionType));
   27452             : #endif
   27453      720000 :         for (unsigned i=0; i < SgFunctionType::pool_size-1; i++) {
   27454      719640 :           alloc[i].p_freepointer = &(alloc[i+1]);
   27455             :         }
   27456         360 :         alloc[SgFunctionType::pool_size-1].p_freepointer = nullptr;
   27457             : 
   27458         360 :         SgFunctionType::pools.push_back ( (unsigned char *) alloc );
   27459         360 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgFunctionType::pool_size * sizeof(SgFunctionType), V_SgFunctionType ) );
   27460         360 :         SgFunctionType::next_node = alloc;
   27461             :     }
   27462      234454 :     ROSE_ASSERT(SgFunctionType::next_node != nullptr);
   27463             : 
   27464      234454 :     SgFunctionType * object = SgFunctionType::next_node;
   27465      234454 :     SgFunctionType::next_node = (SgFunctionType*)(object->p_freepointer);
   27466             : 
   27467             : #if ROSE_ALLOC_TRACE == 2
   27468             :     printf("SgFunctionType::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgFunctionType::next_node);
   27469             : #endif
   27470             : 
   27471      234454 :     SgNode * fp = object->p_freepointer;
   27472             : #if ROSE_ALLOC_MEMSET == 1
   27473             : #elif ROSE_ALLOC_MEMSET == 2
   27474             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgFunctionType) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   27475             : #elif ROSE_ALLOC_MEMSET == 3
   27476             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgFunctionType) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   27477             : #endif
   27478      234454 :     object->p_freepointer = fp;
   27479             : 
   27480             : #if ROSE_ALLOC_TRACE == 2
   27481             : //    printf("SgFunctionType::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgFunctionType::next_node);
   27482             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   27483             :     Rose::MemPool::snapshot(oss.str());
   27484             :     alloc_trace_cnt++;
   27485             : #endif
   27486             : 
   27487      234454 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   27488             : 
   27489      234454 :     ALLOC_MUTEX(SgFunctionType, unlock);
   27490             : 
   27491             :     return object;
   27492             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   27493             : }
   27494             : 
   27495             : 
   27496             : 
   27497             : /*! \brief Delete operator for SgFunctionType.
   27498             : 
   27499             :    This delete operator implements deallocation using memory pools to 
   27500             :    provide most efficent use of the heap within construction of large ASTs.
   27501             : 
   27502             : \internal The new and delete operators use the lower level C malloc/free
   27503             :    function calls for performance and to make sure that mixing of malloc/free
   27504             :    and new/delete by the used can be caught more readily.  This may change
   27505             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   27506             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   27507             :    deallocate memory allocated using ROSE_MALLOC.
   27508             : */
   27509        6299 : void SgFunctionType::operator delete(void *Pointer, size_t Size)
   27510             : {
   27511             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   27512             :      * or throwing an exception. */
   27513        6299 :     ALLOC_MUTEX(SgFunctionType, lock);
   27514             : 
   27515             : #if USE_CPP_NEW_DELETE_OPERATORS
   27516             :     ROSE_FREE(Pointer);
   27517             : #else
   27518             : #if ROSE_PEDANTIC_ALLOC
   27519             :     ROSE_ASSERT(Size == sizeof(SgFunctionType));
   27520             : #else
   27521        6299 :     if (Size != sizeof(SgFunctionType)) {
   27522           0 :       ROSE_FREE(Pointer);
   27523           0 :       ALLOC_MUTEX(SgFunctionType, unlock);
   27524             :       return;
   27525             :     }
   27526             : #endif
   27527             : 
   27528        6299 :     SgFunctionType * object = (SgFunctionType*) Pointer;
   27529        6299 :     ROSE_ASSERT(object != nullptr);
   27530             : 
   27531             : #if ROSE_ALLOC_TRACE == 2
   27532             : //  printf("SgFunctionType::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgFunctionType::next_node);
   27533             :     printf("SgFunctionType::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgFunctionType::next_node);
   27534             : #endif
   27535             : 
   27536             : #if ROSE_PEDANTIC_ALLOC
   27537             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   27538             : #endif
   27539             : 
   27540             : #if ROSE_ALLOC_MEMSET == 1
   27541             : #elif ROSE_ALLOC_MEMSET == 2
   27542             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgFunctionType) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   27543             : #elif ROSE_ALLOC_MEMSET == 3
   27544             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgFunctionType) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   27545             : #endif
   27546             : 
   27547             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   27548             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   27549             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   27550             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   27551             : #else
   27552        6299 :     object->p_freepointer = SgFunctionType::next_node;
   27553        6299 :     SgFunctionType::next_node = object;
   27554             : #endif
   27555             : 
   27556             : #if ROSE_ALLOC_TRACE == 2
   27557             : //  printf("SgFunctionType::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgFunctionType::next_node);
   27558             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   27559             :     Rose::MemPool::snapshot(oss.str());
   27560             :     alloc_trace_cnt++;
   27561             : #endif
   27562             : 
   27563             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   27564             : 
   27565        6299 :     ALLOC_MUTEX(SgFunctionType, unlock);
   27566             : }
   27567             : 
   27568             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   27569             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   27570             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   27571             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   27572             : // Also, note comment below from Robb (copied from the Common.code file).
   27573             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   27574             : //
   27575             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   27576             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   27577             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   27578             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   27579             : #if 0
   27580             : void SgFunctionType::operator delete(void* pointer) { SgFunctionType::operator delete (pointer, sizeof(SgFunctionType)); };
   27581             : #endif
   27582             : /* #line 27583 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   27583             : 
   27584             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   27585             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   27586             : // obviously imply C++.
   27587             : 
   27588             : // This implements the support within ROSE for memory pools.  Memory pools
   27589             : // support the most condensed usage of memory within the construction of
   27590             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   27591             : // by a new operator written for each class.
   27592             : 
   27593             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   27594             :     // User wants multi-thread support and POSIX threads are available.
   27595             : #   include <pthread.h>
   27596             :     static pthread_mutex_t SgMemberFunctionType_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   27597             : #else
   27598             :      // Cause synchronization to be skipped.
   27599             : #    ifndef ALLOC_MUTEX
   27600             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   27601             : #    endif
   27602             : #    ifdef _REENTRANT
   27603             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   27604             : #       ifdef _MSC_VER
   27605             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   27606             : #       else
   27607             : #           warning "POSIX threads are not available; synchronization being skipped"
   27608             : #       endif
   27609             : #    endif
   27610             : #endif
   27611             : 
   27612             : #ifndef ROSE_ALLOC_TRACE
   27613             : #  define ROSE_ALLOC_TRACE 0
   27614             : #endif
   27615             : 
   27616             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   27617             : #define ROSE_ALLOC_TRACE_CNT
   27618             : #include "memory-pool-snapshot.h"
   27619             : unsigned long alloc_trace_cnt = 0;
   27620             : #endif
   27621             : 
   27622             : #if ROSE_ALLOC_TRACE
   27623             : const unsigned SgMemberFunctionType::pool_size = 5;
   27624             : #else
   27625             : const unsigned SgMemberFunctionType::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   27626             : #endif
   27627             : 
   27628             : #ifndef ROSE_ALLOC_MEMSET
   27629             : #  define ROSE_ALLOC_MEMSET 0
   27630             : #endif
   27631             : 
   27632             : #ifndef ROSE_PEDANTIC_ALLOC
   27633             : #  define ROSE_PEDANTIC_ALLOC 0
   27634             : #endif
   27635             : 
   27636             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   27637             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   27638             : #endif
   27639             : 
   27640             : #if !defined(SGNODE__ALL_POOLS)
   27641             : #define SGNODE__ALL_POOLS
   27642             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   27643             : #endif
   27644             : 
   27645             : SgMemberFunctionType* SgMemberFunctionType::next_node = nullptr;
   27646             : std::vector<unsigned char*> SgMemberFunctionType::pools;
   27647             : 
   27648             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   27649             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   27650             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   27651             : // around this macro definition rather than each use).
   27652             : #ifndef ALLOC_MUTEX
   27653             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   27654             :         do {                                                                     \
   27655             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   27656             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   27657             :                 abort();                                                         \
   27658             :             }                                                                    \
   27659             :         } while (0);
   27660             : #endif
   27661             : 
   27662             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   27663             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   27664             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   27665             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   27666             : 
   27667             : /*! \brief New operator for SgMemberFunctionType.
   27668             : 
   27669             :    This new operator implements memory pools to provide most efficent 
   27670             :    use of the heap within construction of large ASTs.
   27671             : 
   27672             : \internal The new and delete operators use the lower level C malloc/free
   27673             :    function calls for performance and to make sure that mixing of malloc/free
   27674             :    and new/delete by the used can be caught more readily.  This may change
   27675             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   27676             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   27677             :    deallocate memory allocated using ROSE_MALLOC.
   27678             : */
   27679       21259 : void *SgMemberFunctionType::operator new ( size_t Size )
   27680             : {
   27681             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   27682             :      * returning or throwing an exception. */
   27683       21259 :     ALLOC_MUTEX(SgMemberFunctionType, lock);
   27684             : 
   27685             : #if ROSE_ALLOC_TRACE == 2
   27686             : //    printf("SgMemberFunctionType::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgMemberFunctionType::next_node);
   27687             : #endif
   27688             : 
   27689             : #if USE_CPP_NEW_DELETE_OPERATORS
   27690             :     void *mem = ROSE_MALLOC(Size);
   27691             :     ALLOC_MUTEX(SgMemberFunctionType, unlock);
   27692             :     return mem;
   27693             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   27694             : #if ROSE_PEDANTIC_ALLOC
   27695             :     ROSE_ASSERT(Size == sizeof(SgMemberFunctionType));
   27696             : #else
   27697       21259 :     if (Size != sizeof(SgMemberFunctionType)) {
   27698           0 :       void * object = ROSE_MALLOC(Size);
   27699           0 :       ALLOC_MUTEX(SgMemberFunctionType, unlock);
   27700             :       return object;
   27701             :     }
   27702             : #endif
   27703             : 
   27704       21259 :     if (SgMemberFunctionType::next_node == nullptr) {
   27705          25 :         SgMemberFunctionType * alloc = (SgMemberFunctionType*) ROSE_MALLOC ( SgMemberFunctionType::pool_size * sizeof(SgMemberFunctionType) );
   27706          25 :         ROSE_ASSERT(alloc != nullptr);
   27707             : 
   27708             : #if ROSE_ALLOC_TRACE == 2
   27709             : //        printf("SgMemberFunctionType::alloc\n  block[%zi] = [ %p , %p [\n", SgMemberFunctionType::pools.size(), alloc, alloc + SgMemberFunctionType::pool_size);
   27710             : #endif
   27711             : 
   27712             : #if ROSE_ALLOC_MEMSET == 1
   27713             : #elif ROSE_ALLOC_MEMSET == 2
   27714             :         memset(alloc, 0x00, SgMemberFunctionType::pool_size * sizeof(SgMemberFunctionType));
   27715             : #elif ROSE_ALLOC_MEMSET == 3
   27716             :         memset(alloc, 0xAA, SgMemberFunctionType::pool_size * sizeof(SgMemberFunctionType));
   27717             : #endif
   27718       50000 :         for (unsigned i=0; i < SgMemberFunctionType::pool_size-1; i++) {
   27719       49975 :           alloc[i].p_freepointer = &(alloc[i+1]);
   27720             :         }
   27721          25 :         alloc[SgMemberFunctionType::pool_size-1].p_freepointer = nullptr;
   27722             : 
   27723          25 :         SgMemberFunctionType::pools.push_back ( (unsigned char *) alloc );
   27724          25 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgMemberFunctionType::pool_size * sizeof(SgMemberFunctionType), V_SgMemberFunctionType ) );
   27725          25 :         SgMemberFunctionType::next_node = alloc;
   27726             :     }
   27727       21259 :     ROSE_ASSERT(SgMemberFunctionType::next_node != nullptr);
   27728             : 
   27729       21259 :     SgMemberFunctionType * object = SgMemberFunctionType::next_node;
   27730       21259 :     SgMemberFunctionType::next_node = (SgMemberFunctionType*)(object->p_freepointer);
   27731             : 
   27732             : #if ROSE_ALLOC_TRACE == 2
   27733             :     printf("SgMemberFunctionType::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgMemberFunctionType::next_node);
   27734             : #endif
   27735             : 
   27736       21259 :     SgNode * fp = object->p_freepointer;
   27737             : #if ROSE_ALLOC_MEMSET == 1
   27738             : #elif ROSE_ALLOC_MEMSET == 2
   27739             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgMemberFunctionType) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   27740             : #elif ROSE_ALLOC_MEMSET == 3
   27741             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgMemberFunctionType) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   27742             : #endif
   27743       21259 :     object->p_freepointer = fp;
   27744             : 
   27745             : #if ROSE_ALLOC_TRACE == 2
   27746             : //    printf("SgMemberFunctionType::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgMemberFunctionType::next_node);
   27747             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   27748             :     Rose::MemPool::snapshot(oss.str());
   27749             :     alloc_trace_cnt++;
   27750             : #endif
   27751             : 
   27752       21259 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   27753             : 
   27754       21259 :     ALLOC_MUTEX(SgMemberFunctionType, unlock);
   27755             : 
   27756             :     return object;
   27757             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   27758             : }
   27759             : 
   27760             : 
   27761             : 
   27762             : /*! \brief Delete operator for SgMemberFunctionType.
   27763             : 
   27764             :    This delete operator implements deallocation using memory pools to 
   27765             :    provide most efficent use of the heap within construction of large ASTs.
   27766             : 
   27767             : \internal The new and delete operators use the lower level C malloc/free
   27768             :    function calls for performance and to make sure that mixing of malloc/free
   27769             :    and new/delete by the used can be caught more readily.  This may change
   27770             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   27771             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   27772             :    deallocate memory allocated using ROSE_MALLOC.
   27773             : */
   27774        4334 : void SgMemberFunctionType::operator delete(void *Pointer, size_t Size)
   27775             : {
   27776             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   27777             :      * or throwing an exception. */
   27778        4334 :     ALLOC_MUTEX(SgMemberFunctionType, lock);
   27779             : 
   27780             : #if USE_CPP_NEW_DELETE_OPERATORS
   27781             :     ROSE_FREE(Pointer);
   27782             : #else
   27783             : #if ROSE_PEDANTIC_ALLOC
   27784             :     ROSE_ASSERT(Size == sizeof(SgMemberFunctionType));
   27785             : #else
   27786        4334 :     if (Size != sizeof(SgMemberFunctionType)) {
   27787           0 :       ROSE_FREE(Pointer);
   27788           0 :       ALLOC_MUTEX(SgMemberFunctionType, unlock);
   27789             :       return;
   27790             :     }
   27791             : #endif
   27792             : 
   27793        4334 :     SgMemberFunctionType * object = (SgMemberFunctionType*) Pointer;
   27794        4334 :     ROSE_ASSERT(object != nullptr);
   27795             : 
   27796             : #if ROSE_ALLOC_TRACE == 2
   27797             : //  printf("SgMemberFunctionType::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgMemberFunctionType::next_node);
   27798             :     printf("SgMemberFunctionType::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgMemberFunctionType::next_node);
   27799             : #endif
   27800             : 
   27801             : #if ROSE_PEDANTIC_ALLOC
   27802             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   27803             : #endif
   27804             : 
   27805             : #if ROSE_ALLOC_MEMSET == 1
   27806             : #elif ROSE_ALLOC_MEMSET == 2
   27807             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgMemberFunctionType) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   27808             : #elif ROSE_ALLOC_MEMSET == 3
   27809             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgMemberFunctionType) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   27810             : #endif
   27811             : 
   27812             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   27813             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   27814             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   27815             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   27816             : #else
   27817        4334 :     object->p_freepointer = SgMemberFunctionType::next_node;
   27818        4334 :     SgMemberFunctionType::next_node = object;
   27819             : #endif
   27820             : 
   27821             : #if ROSE_ALLOC_TRACE == 2
   27822             : //  printf("SgMemberFunctionType::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgMemberFunctionType::next_node);
   27823             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   27824             :     Rose::MemPool::snapshot(oss.str());
   27825             :     alloc_trace_cnt++;
   27826             : #endif
   27827             : 
   27828             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   27829             : 
   27830        4334 :     ALLOC_MUTEX(SgMemberFunctionType, unlock);
   27831             : }
   27832             : 
   27833             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   27834             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   27835             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   27836             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   27837             : // Also, note comment below from Robb (copied from the Common.code file).
   27838             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   27839             : //
   27840             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   27841             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   27842             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   27843             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   27844             : #if 0
   27845             : void SgMemberFunctionType::operator delete(void* pointer) { SgMemberFunctionType::operator delete (pointer, sizeof(SgMemberFunctionType)); };
   27846             : #endif
   27847             : /* #line 27848 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   27848             : 
   27849             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   27850             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   27851             : // obviously imply C++.
   27852             : 
   27853             : // This implements the support within ROSE for memory pools.  Memory pools
   27854             : // support the most condensed usage of memory within the construction of
   27855             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   27856             : // by a new operator written for each class.
   27857             : 
   27858             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   27859             :     // User wants multi-thread support and POSIX threads are available.
   27860             : #   include <pthread.h>
   27861             :     static pthread_mutex_t SgPartialFunctionType_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   27862             : #else
   27863             :      // Cause synchronization to be skipped.
   27864             : #    ifndef ALLOC_MUTEX
   27865             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   27866             : #    endif
   27867             : #    ifdef _REENTRANT
   27868             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   27869             : #       ifdef _MSC_VER
   27870             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   27871             : #       else
   27872             : #           warning "POSIX threads are not available; synchronization being skipped"
   27873             : #       endif
   27874             : #    endif
   27875             : #endif
   27876             : 
   27877             : #ifndef ROSE_ALLOC_TRACE
   27878             : #  define ROSE_ALLOC_TRACE 0
   27879             : #endif
   27880             : 
   27881             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   27882             : #define ROSE_ALLOC_TRACE_CNT
   27883             : #include "memory-pool-snapshot.h"
   27884             : unsigned long alloc_trace_cnt = 0;
   27885             : #endif
   27886             : 
   27887             : #if ROSE_ALLOC_TRACE
   27888             : const unsigned SgPartialFunctionType::pool_size = 5;
   27889             : #else
   27890             : const unsigned SgPartialFunctionType::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   27891             : #endif
   27892             : 
   27893             : #ifndef ROSE_ALLOC_MEMSET
   27894             : #  define ROSE_ALLOC_MEMSET 0
   27895             : #endif
   27896             : 
   27897             : #ifndef ROSE_PEDANTIC_ALLOC
   27898             : #  define ROSE_PEDANTIC_ALLOC 0
   27899             : #endif
   27900             : 
   27901             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   27902             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   27903             : #endif
   27904             : 
   27905             : #if !defined(SGNODE__ALL_POOLS)
   27906             : #define SGNODE__ALL_POOLS
   27907             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   27908             : #endif
   27909             : 
   27910             : SgPartialFunctionType* SgPartialFunctionType::next_node = nullptr;
   27911             : std::vector<unsigned char*> SgPartialFunctionType::pools;
   27912             : 
   27913             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   27914             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   27915             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   27916             : // around this macro definition rather than each use).
   27917             : #ifndef ALLOC_MUTEX
   27918             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   27919             :         do {                                                                     \
   27920             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   27921             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   27922             :                 abort();                                                         \
   27923             :             }                                                                    \
   27924             :         } while (0);
   27925             : #endif
   27926             : 
   27927             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   27928             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   27929             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   27930             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   27931             : 
   27932             : /*! \brief New operator for SgPartialFunctionType.
   27933             : 
   27934             :    This new operator implements memory pools to provide most efficent 
   27935             :    use of the heap within construction of large ASTs.
   27936             : 
   27937             : \internal The new and delete operators use the lower level C malloc/free
   27938             :    function calls for performance and to make sure that mixing of malloc/free
   27939             :    and new/delete by the used can be caught more readily.  This may change
   27940             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   27941             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   27942             :    deallocate memory allocated using ROSE_MALLOC.
   27943             : */
   27944       19092 : void *SgPartialFunctionType::operator new ( size_t Size )
   27945             : {
   27946             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   27947             :      * returning or throwing an exception. */
   27948       19092 :     ALLOC_MUTEX(SgPartialFunctionType, lock);
   27949             : 
   27950             : #if ROSE_ALLOC_TRACE == 2
   27951             : //    printf("SgPartialFunctionType::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgPartialFunctionType::next_node);
   27952             : #endif
   27953             : 
   27954             : #if USE_CPP_NEW_DELETE_OPERATORS
   27955             :     void *mem = ROSE_MALLOC(Size);
   27956             :     ALLOC_MUTEX(SgPartialFunctionType, unlock);
   27957             :     return mem;
   27958             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   27959             : #if ROSE_PEDANTIC_ALLOC
   27960             :     ROSE_ASSERT(Size == sizeof(SgPartialFunctionType));
   27961             : #else
   27962       19092 :     if (Size != sizeof(SgPartialFunctionType)) {
   27963           0 :       void * object = ROSE_MALLOC(Size);
   27964           0 :       ALLOC_MUTEX(SgPartialFunctionType, unlock);
   27965             :       return object;
   27966             :     }
   27967             : #endif
   27968             : 
   27969       19092 :     if (SgPartialFunctionType::next_node == nullptr) {
   27970          17 :         SgPartialFunctionType * alloc = (SgPartialFunctionType*) ROSE_MALLOC ( SgPartialFunctionType::pool_size * sizeof(SgPartialFunctionType) );
   27971          17 :         ROSE_ASSERT(alloc != nullptr);
   27972             : 
   27973             : #if ROSE_ALLOC_TRACE == 2
   27974             : //        printf("SgPartialFunctionType::alloc\n  block[%zi] = [ %p , %p [\n", SgPartialFunctionType::pools.size(), alloc, alloc + SgPartialFunctionType::pool_size);
   27975             : #endif
   27976             : 
   27977             : #if ROSE_ALLOC_MEMSET == 1
   27978             : #elif ROSE_ALLOC_MEMSET == 2
   27979             :         memset(alloc, 0x00, SgPartialFunctionType::pool_size * sizeof(SgPartialFunctionType));
   27980             : #elif ROSE_ALLOC_MEMSET == 3
   27981             :         memset(alloc, 0xAA, SgPartialFunctionType::pool_size * sizeof(SgPartialFunctionType));
   27982             : #endif
   27983       34000 :         for (unsigned i=0; i < SgPartialFunctionType::pool_size-1; i++) {
   27984       33983 :           alloc[i].p_freepointer = &(alloc[i+1]);
   27985             :         }
   27986          17 :         alloc[SgPartialFunctionType::pool_size-1].p_freepointer = nullptr;
   27987             : 
   27988          17 :         SgPartialFunctionType::pools.push_back ( (unsigned char *) alloc );
   27989          17 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgPartialFunctionType::pool_size * sizeof(SgPartialFunctionType), V_SgPartialFunctionType ) );
   27990          17 :         SgPartialFunctionType::next_node = alloc;
   27991             :     }
   27992       19092 :     ROSE_ASSERT(SgPartialFunctionType::next_node != nullptr);
   27993             : 
   27994       19092 :     SgPartialFunctionType * object = SgPartialFunctionType::next_node;
   27995       19092 :     SgPartialFunctionType::next_node = (SgPartialFunctionType*)(object->p_freepointer);
   27996             : 
   27997             : #if ROSE_ALLOC_TRACE == 2
   27998             :     printf("SgPartialFunctionType::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgPartialFunctionType::next_node);
   27999             : #endif
   28000             : 
   28001       19092 :     SgNode * fp = object->p_freepointer;
   28002             : #if ROSE_ALLOC_MEMSET == 1
   28003             : #elif ROSE_ALLOC_MEMSET == 2
   28004             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgPartialFunctionType) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   28005             : #elif ROSE_ALLOC_MEMSET == 3
   28006             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgPartialFunctionType) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   28007             : #endif
   28008       19092 :     object->p_freepointer = fp;
   28009             : 
   28010             : #if ROSE_ALLOC_TRACE == 2
   28011             : //    printf("SgPartialFunctionType::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgPartialFunctionType::next_node);
   28012             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   28013             :     Rose::MemPool::snapshot(oss.str());
   28014             :     alloc_trace_cnt++;
   28015             : #endif
   28016             : 
   28017       19092 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   28018             : 
   28019       19092 :     ALLOC_MUTEX(SgPartialFunctionType, unlock);
   28020             : 
   28021             :     return object;
   28022             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   28023             : }
   28024             : 
   28025             : 
   28026             : 
   28027             : /*! \brief Delete operator for SgPartialFunctionType.
   28028             : 
   28029             :    This delete operator implements deallocation using memory pools to 
   28030             :    provide most efficent use of the heap within construction of large ASTs.
   28031             : 
   28032             : \internal The new and delete operators use the lower level C malloc/free
   28033             :    function calls for performance and to make sure that mixing of malloc/free
   28034             :    and new/delete by the used can be caught more readily.  This may change
   28035             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   28036             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   28037             :    deallocate memory allocated using ROSE_MALLOC.
   28038             : */
   28039       19092 : void SgPartialFunctionType::operator delete(void *Pointer, size_t Size)
   28040             : {
   28041             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   28042             :      * or throwing an exception. */
   28043       19092 :     ALLOC_MUTEX(SgPartialFunctionType, lock);
   28044             : 
   28045             : #if USE_CPP_NEW_DELETE_OPERATORS
   28046             :     ROSE_FREE(Pointer);
   28047             : #else
   28048             : #if ROSE_PEDANTIC_ALLOC
   28049             :     ROSE_ASSERT(Size == sizeof(SgPartialFunctionType));
   28050             : #else
   28051       19092 :     if (Size != sizeof(SgPartialFunctionType)) {
   28052           0 :       ROSE_FREE(Pointer);
   28053           0 :       ALLOC_MUTEX(SgPartialFunctionType, unlock);
   28054             :       return;
   28055             :     }
   28056             : #endif
   28057             : 
   28058       19092 :     SgPartialFunctionType * object = (SgPartialFunctionType*) Pointer;
   28059       19092 :     ROSE_ASSERT(object != nullptr);
   28060             : 
   28061             : #if ROSE_ALLOC_TRACE == 2
   28062             : //  printf("SgPartialFunctionType::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgPartialFunctionType::next_node);
   28063             :     printf("SgPartialFunctionType::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgPartialFunctionType::next_node);
   28064             : #endif
   28065             : 
   28066             : #if ROSE_PEDANTIC_ALLOC
   28067             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   28068             : #endif
   28069             : 
   28070             : #if ROSE_ALLOC_MEMSET == 1
   28071             : #elif ROSE_ALLOC_MEMSET == 2
   28072             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgPartialFunctionType) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   28073             : #elif ROSE_ALLOC_MEMSET == 3
   28074             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgPartialFunctionType) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   28075             : #endif
   28076             : 
   28077             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   28078             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   28079             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   28080             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   28081             : #else
   28082       19092 :     object->p_freepointer = SgPartialFunctionType::next_node;
   28083       19092 :     SgPartialFunctionType::next_node = object;
   28084             : #endif
   28085             : 
   28086             : #if ROSE_ALLOC_TRACE == 2
   28087             : //  printf("SgPartialFunctionType::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgPartialFunctionType::next_node);
   28088             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   28089             :     Rose::MemPool::snapshot(oss.str());
   28090             :     alloc_trace_cnt++;
   28091             : #endif
   28092             : 
   28093             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   28094             : 
   28095       19092 :     ALLOC_MUTEX(SgPartialFunctionType, unlock);
   28096             : }
   28097             : 
   28098             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   28099             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   28100             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   28101             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   28102             : // Also, note comment below from Robb (copied from the Common.code file).
   28103             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   28104             : //
   28105             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   28106             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   28107             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   28108             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   28109             : #if 0
   28110             : void SgPartialFunctionType::operator delete(void* pointer) { SgPartialFunctionType::operator delete (pointer, sizeof(SgPartialFunctionType)); };
   28111             : #endif
   28112             : /* #line 28113 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   28113             : 
   28114             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   28115             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   28116             : // obviously imply C++.
   28117             : 
   28118             : // This implements the support within ROSE for memory pools.  Memory pools
   28119             : // support the most condensed usage of memory within the construction of
   28120             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   28121             : // by a new operator written for each class.
   28122             : 
   28123             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   28124             :     // User wants multi-thread support and POSIX threads are available.
   28125             : #   include <pthread.h>
   28126             :     static pthread_mutex_t SgPartialFunctionModifierType_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   28127             : #else
   28128             :      // Cause synchronization to be skipped.
   28129             : #    ifndef ALLOC_MUTEX
   28130             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   28131             : #    endif
   28132             : #    ifdef _REENTRANT
   28133             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   28134             : #       ifdef _MSC_VER
   28135             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   28136             : #       else
   28137             : #           warning "POSIX threads are not available; synchronization being skipped"
   28138             : #       endif
   28139             : #    endif
   28140             : #endif
   28141             : 
   28142             : #ifndef ROSE_ALLOC_TRACE
   28143             : #  define ROSE_ALLOC_TRACE 0
   28144             : #endif
   28145             : 
   28146             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   28147             : #define ROSE_ALLOC_TRACE_CNT
   28148             : #include "memory-pool-snapshot.h"
   28149             : unsigned long alloc_trace_cnt = 0;
   28150             : #endif
   28151             : 
   28152             : #if ROSE_ALLOC_TRACE
   28153             : const unsigned SgPartialFunctionModifierType::pool_size = 5;
   28154             : #else
   28155             : const unsigned SgPartialFunctionModifierType::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   28156             : #endif
   28157             : 
   28158             : #ifndef ROSE_ALLOC_MEMSET
   28159             : #  define ROSE_ALLOC_MEMSET 0
   28160             : #endif
   28161             : 
   28162             : #ifndef ROSE_PEDANTIC_ALLOC
   28163             : #  define ROSE_PEDANTIC_ALLOC 0
   28164             : #endif
   28165             : 
   28166             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   28167             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   28168             : #endif
   28169             : 
   28170             : #if !defined(SGNODE__ALL_POOLS)
   28171             : #define SGNODE__ALL_POOLS
   28172             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   28173             : #endif
   28174             : 
   28175             : SgPartialFunctionModifierType* SgPartialFunctionModifierType::next_node = nullptr;
   28176             : std::vector<unsigned char*> SgPartialFunctionModifierType::pools;
   28177             : 
   28178             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   28179             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   28180             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   28181             : // around this macro definition rather than each use).
   28182             : #ifndef ALLOC_MUTEX
   28183             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   28184             :         do {                                                                     \
   28185             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   28186             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   28187             :                 abort();                                                         \
   28188             :             }                                                                    \
   28189             :         } while (0);
   28190             : #endif
   28191             : 
   28192             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   28193             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   28194             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   28195             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   28196             : 
   28197             : /*! \brief New operator for SgPartialFunctionModifierType.
   28198             : 
   28199             :    This new operator implements memory pools to provide most efficent 
   28200             :    use of the heap within construction of large ASTs.
   28201             : 
   28202             : \internal The new and delete operators use the lower level C malloc/free
   28203             :    function calls for performance and to make sure that mixing of malloc/free
   28204             :    and new/delete by the used can be caught more readily.  This may change
   28205             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   28206             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   28207             :    deallocate memory allocated using ROSE_MALLOC.
   28208             : */
   28209           0 : void *SgPartialFunctionModifierType::operator new ( size_t Size )
   28210             : {
   28211             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   28212             :      * returning or throwing an exception. */
   28213           0 :     ALLOC_MUTEX(SgPartialFunctionModifierType, lock);
   28214             : 
   28215             : #if ROSE_ALLOC_TRACE == 2
   28216             : //    printf("SgPartialFunctionModifierType::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgPartialFunctionModifierType::next_node);
   28217             : #endif
   28218             : 
   28219             : #if USE_CPP_NEW_DELETE_OPERATORS
   28220             :     void *mem = ROSE_MALLOC(Size);
   28221             :     ALLOC_MUTEX(SgPartialFunctionModifierType, unlock);
   28222             :     return mem;
   28223             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   28224             : #if ROSE_PEDANTIC_ALLOC
   28225             :     ROSE_ASSERT(Size == sizeof(SgPartialFunctionModifierType));
   28226             : #else
   28227           0 :     if (Size != sizeof(SgPartialFunctionModifierType)) {
   28228           0 :       void * object = ROSE_MALLOC(Size);
   28229           0 :       ALLOC_MUTEX(SgPartialFunctionModifierType, unlock);
   28230             :       return object;
   28231             :     }
   28232             : #endif
   28233             : 
   28234           0 :     if (SgPartialFunctionModifierType::next_node == nullptr) {
   28235           0 :         SgPartialFunctionModifierType * alloc = (SgPartialFunctionModifierType*) ROSE_MALLOC ( SgPartialFunctionModifierType::pool_size * sizeof(SgPartialFunctionModifierType) );
   28236           0 :         ROSE_ASSERT(alloc != nullptr);
   28237             : 
   28238             : #if ROSE_ALLOC_TRACE == 2
   28239             : //        printf("SgPartialFunctionModifierType::alloc\n  block[%zi] = [ %p , %p [\n", SgPartialFunctionModifierType::pools.size(), alloc, alloc + SgPartialFunctionModifierType::pool_size);
   28240             : #endif
   28241             : 
   28242             : #if ROSE_ALLOC_MEMSET == 1
   28243             : #elif ROSE_ALLOC_MEMSET == 2
   28244             :         memset(alloc, 0x00, SgPartialFunctionModifierType::pool_size * sizeof(SgPartialFunctionModifierType));
   28245             : #elif ROSE_ALLOC_MEMSET == 3
   28246             :         memset(alloc, 0xAA, SgPartialFunctionModifierType::pool_size * sizeof(SgPartialFunctionModifierType));
   28247             : #endif
   28248           0 :         for (unsigned i=0; i < SgPartialFunctionModifierType::pool_size-1; i++) {
   28249           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
   28250             :         }
   28251           0 :         alloc[SgPartialFunctionModifierType::pool_size-1].p_freepointer = nullptr;
   28252             : 
   28253           0 :         SgPartialFunctionModifierType::pools.push_back ( (unsigned char *) alloc );
   28254           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgPartialFunctionModifierType::pool_size * sizeof(SgPartialFunctionModifierType), V_SgPartialFunctionModifierType ) );
   28255           0 :         SgPartialFunctionModifierType::next_node = alloc;
   28256             :     }
   28257           0 :     ROSE_ASSERT(SgPartialFunctionModifierType::next_node != nullptr);
   28258             : 
   28259           0 :     SgPartialFunctionModifierType * object = SgPartialFunctionModifierType::next_node;
   28260           0 :     SgPartialFunctionModifierType::next_node = (SgPartialFunctionModifierType*)(object->p_freepointer);
   28261             : 
   28262             : #if ROSE_ALLOC_TRACE == 2
   28263             :     printf("SgPartialFunctionModifierType::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgPartialFunctionModifierType::next_node);
   28264             : #endif
   28265             : 
   28266           0 :     SgNode * fp = object->p_freepointer;
   28267             : #if ROSE_ALLOC_MEMSET == 1
   28268             : #elif ROSE_ALLOC_MEMSET == 2
   28269             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgPartialFunctionModifierType) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   28270             : #elif ROSE_ALLOC_MEMSET == 3
   28271             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgPartialFunctionModifierType) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   28272             : #endif
   28273           0 :     object->p_freepointer = fp;
   28274             : 
   28275             : #if ROSE_ALLOC_TRACE == 2
   28276             : //    printf("SgPartialFunctionModifierType::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgPartialFunctionModifierType::next_node);
   28277             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   28278             :     Rose::MemPool::snapshot(oss.str());
   28279             :     alloc_trace_cnt++;
   28280             : #endif
   28281             : 
   28282           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   28283             : 
   28284           0 :     ALLOC_MUTEX(SgPartialFunctionModifierType, unlock);
   28285             : 
   28286             :     return object;
   28287             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   28288             : }
   28289             : 
   28290             : 
   28291             : 
   28292             : /*! \brief Delete operator for SgPartialFunctionModifierType.
   28293             : 
   28294             :    This delete operator implements deallocation using memory pools to 
   28295             :    provide most efficent use of the heap within construction of large ASTs.
   28296             : 
   28297             : \internal The new and delete operators use the lower level C malloc/free
   28298             :    function calls for performance and to make sure that mixing of malloc/free
   28299             :    and new/delete by the used can be caught more readily.  This may change
   28300             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   28301             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   28302             :    deallocate memory allocated using ROSE_MALLOC.
   28303             : */
   28304           0 : void SgPartialFunctionModifierType::operator delete(void *Pointer, size_t Size)
   28305             : {
   28306             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   28307             :      * or throwing an exception. */
   28308           0 :     ALLOC_MUTEX(SgPartialFunctionModifierType, lock);
   28309             : 
   28310             : #if USE_CPP_NEW_DELETE_OPERATORS
   28311             :     ROSE_FREE(Pointer);
   28312             : #else
   28313             : #if ROSE_PEDANTIC_ALLOC
   28314             :     ROSE_ASSERT(Size == sizeof(SgPartialFunctionModifierType));
   28315             : #else
   28316           0 :     if (Size != sizeof(SgPartialFunctionModifierType)) {
   28317           0 :       ROSE_FREE(Pointer);
   28318           0 :       ALLOC_MUTEX(SgPartialFunctionModifierType, unlock);
   28319             :       return;
   28320             :     }
   28321             : #endif
   28322             : 
   28323           0 :     SgPartialFunctionModifierType * object = (SgPartialFunctionModifierType*) Pointer;
   28324           0 :     ROSE_ASSERT(object != nullptr);
   28325             : 
   28326             : #if ROSE_ALLOC_TRACE == 2
   28327             : //  printf("SgPartialFunctionModifierType::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgPartialFunctionModifierType::next_node);
   28328             :     printf("SgPartialFunctionModifierType::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgPartialFunctionModifierType::next_node);
   28329             : #endif
   28330             : 
   28331             : #if ROSE_PEDANTIC_ALLOC
   28332             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   28333             : #endif
   28334             : 
   28335             : #if ROSE_ALLOC_MEMSET == 1
   28336             : #elif ROSE_ALLOC_MEMSET == 2
   28337             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgPartialFunctionModifierType) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   28338             : #elif ROSE_ALLOC_MEMSET == 3
   28339             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgPartialFunctionModifierType) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   28340             : #endif
   28341             : 
   28342             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   28343             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   28344             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   28345             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   28346             : #else
   28347           0 :     object->p_freepointer = SgPartialFunctionModifierType::next_node;
   28348           0 :     SgPartialFunctionModifierType::next_node = object;
   28349             : #endif
   28350             : 
   28351             : #if ROSE_ALLOC_TRACE == 2
   28352             : //  printf("SgPartialFunctionModifierType::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgPartialFunctionModifierType::next_node);
   28353             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   28354             :     Rose::MemPool::snapshot(oss.str());
   28355             :     alloc_trace_cnt++;
   28356             : #endif
   28357             : 
   28358             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   28359             : 
   28360           0 :     ALLOC_MUTEX(SgPartialFunctionModifierType, unlock);
   28361             : }
   28362             : 
   28363             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   28364             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   28365             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   28366             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   28367             : // Also, note comment below from Robb (copied from the Common.code file).
   28368             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   28369             : //
   28370             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   28371             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   28372             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   28373             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   28374             : #if 0
   28375             : void SgPartialFunctionModifierType::operator delete(void* pointer) { SgPartialFunctionModifierType::operator delete (pointer, sizeof(SgPartialFunctionModifierType)); };
   28376             : #endif
   28377             : /* #line 28378 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   28378             : 
   28379             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   28380             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   28381             : // obviously imply C++.
   28382             : 
   28383             : // This implements the support within ROSE for memory pools.  Memory pools
   28384             : // support the most condensed usage of memory within the construction of
   28385             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   28386             : // by a new operator written for each class.
   28387             : 
   28388             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   28389             :     // User wants multi-thread support and POSIX threads are available.
   28390             : #   include <pthread.h>
   28391             :     static pthread_mutex_t SgArrayType_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   28392             : #else
   28393             :      // Cause synchronization to be skipped.
   28394             : #    ifndef ALLOC_MUTEX
   28395             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   28396             : #    endif
   28397             : #    ifdef _REENTRANT
   28398             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   28399             : #       ifdef _MSC_VER
   28400             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   28401             : #       else
   28402             : #           warning "POSIX threads are not available; synchronization being skipped"
   28403             : #       endif
   28404             : #    endif
   28405             : #endif
   28406             : 
   28407             : #ifndef ROSE_ALLOC_TRACE
   28408             : #  define ROSE_ALLOC_TRACE 0
   28409             : #endif
   28410             : 
   28411             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   28412             : #define ROSE_ALLOC_TRACE_CNT
   28413             : #include "memory-pool-snapshot.h"
   28414             : unsigned long alloc_trace_cnt = 0;
   28415             : #endif
   28416             : 
   28417             : #if ROSE_ALLOC_TRACE
   28418             : const unsigned SgArrayType::pool_size = 5;
   28419             : #else
   28420             : const unsigned SgArrayType::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   28421             : #endif
   28422             : 
   28423             : #ifndef ROSE_ALLOC_MEMSET
   28424             : #  define ROSE_ALLOC_MEMSET 0
   28425             : #endif
   28426             : 
   28427             : #ifndef ROSE_PEDANTIC_ALLOC
   28428             : #  define ROSE_PEDANTIC_ALLOC 0
   28429             : #endif
   28430             : 
   28431             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   28432             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   28433             : #endif
   28434             : 
   28435             : #if !defined(SGNODE__ALL_POOLS)
   28436             : #define SGNODE__ALL_POOLS
   28437             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   28438             : #endif
   28439             : 
   28440             : SgArrayType* SgArrayType::next_node = nullptr;
   28441             : std::vector<unsigned char*> SgArrayType::pools;
   28442             : 
   28443             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   28444             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   28445             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   28446             : // around this macro definition rather than each use).
   28447             : #ifndef ALLOC_MUTEX
   28448             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   28449             :         do {                                                                     \
   28450             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   28451             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   28452             :                 abort();                                                         \
   28453             :             }                                                                    \
   28454             :         } while (0);
   28455             : #endif
   28456             : 
   28457             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   28458             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   28459             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   28460             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   28461             : 
   28462             : /*! \brief New operator for SgArrayType.
   28463             : 
   28464             :    This new operator implements memory pools to provide most efficent 
   28465             :    use of the heap within construction of large ASTs.
   28466             : 
   28467             : \internal The new and delete operators use the lower level C malloc/free
   28468             :    function calls for performance and to make sure that mixing of malloc/free
   28469             :    and new/delete by the used can be caught more readily.  This may change
   28470             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   28471             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   28472             :    deallocate memory allocated using ROSE_MALLOC.
   28473             : */
   28474        6784 : void *SgArrayType::operator new ( size_t Size )
   28475             : {
   28476             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   28477             :      * returning or throwing an exception. */
   28478        6784 :     ALLOC_MUTEX(SgArrayType, lock);
   28479             : 
   28480             : #if ROSE_ALLOC_TRACE == 2
   28481             : //    printf("SgArrayType::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgArrayType::next_node);
   28482             : #endif
   28483             : 
   28484             : #if USE_CPP_NEW_DELETE_OPERATORS
   28485             :     void *mem = ROSE_MALLOC(Size);
   28486             :     ALLOC_MUTEX(SgArrayType, unlock);
   28487             :     return mem;
   28488             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   28489             : #if ROSE_PEDANTIC_ALLOC
   28490             :     ROSE_ASSERT(Size == sizeof(SgArrayType));
   28491             : #else
   28492        6784 :     if (Size != sizeof(SgArrayType)) {
   28493           0 :       void * object = ROSE_MALLOC(Size);
   28494           0 :       ALLOC_MUTEX(SgArrayType, unlock);
   28495             :       return object;
   28496             :     }
   28497             : #endif
   28498             : 
   28499        6784 :     if (SgArrayType::next_node == nullptr) {
   28500         252 :         SgArrayType * alloc = (SgArrayType*) ROSE_MALLOC ( SgArrayType::pool_size * sizeof(SgArrayType) );
   28501         252 :         ROSE_ASSERT(alloc != nullptr);
   28502             : 
   28503             : #if ROSE_ALLOC_TRACE == 2
   28504             : //        printf("SgArrayType::alloc\n  block[%zi] = [ %p , %p [\n", SgArrayType::pools.size(), alloc, alloc + SgArrayType::pool_size);
   28505             : #endif
   28506             : 
   28507             : #if ROSE_ALLOC_MEMSET == 1
   28508             : #elif ROSE_ALLOC_MEMSET == 2
   28509             :         memset(alloc, 0x00, SgArrayType::pool_size * sizeof(SgArrayType));
   28510             : #elif ROSE_ALLOC_MEMSET == 3
   28511             :         memset(alloc, 0xAA, SgArrayType::pool_size * sizeof(SgArrayType));
   28512             : #endif
   28513      504000 :         for (unsigned i=0; i < SgArrayType::pool_size-1; i++) {
   28514      503748 :           alloc[i].p_freepointer = &(alloc[i+1]);
   28515             :         }
   28516         252 :         alloc[SgArrayType::pool_size-1].p_freepointer = nullptr;
   28517             : 
   28518         252 :         SgArrayType::pools.push_back ( (unsigned char *) alloc );
   28519         252 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgArrayType::pool_size * sizeof(SgArrayType), V_SgArrayType ) );
   28520         252 :         SgArrayType::next_node = alloc;
   28521             :     }
   28522        6784 :     ROSE_ASSERT(SgArrayType::next_node != nullptr);
   28523             : 
   28524        6784 :     SgArrayType * object = SgArrayType::next_node;
   28525        6784 :     SgArrayType::next_node = (SgArrayType*)(object->p_freepointer);
   28526             : 
   28527             : #if ROSE_ALLOC_TRACE == 2
   28528             :     printf("SgArrayType::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgArrayType::next_node);
   28529             : #endif
   28530             : 
   28531        6784 :     SgNode * fp = object->p_freepointer;
   28532             : #if ROSE_ALLOC_MEMSET == 1
   28533             : #elif ROSE_ALLOC_MEMSET == 2
   28534             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgArrayType) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   28535             : #elif ROSE_ALLOC_MEMSET == 3
   28536             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgArrayType) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   28537             : #endif
   28538        6784 :     object->p_freepointer = fp;
   28539             : 
   28540             : #if ROSE_ALLOC_TRACE == 2
   28541             : //    printf("SgArrayType::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgArrayType::next_node);
   28542             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   28543             :     Rose::MemPool::snapshot(oss.str());
   28544             :     alloc_trace_cnt++;
   28545             : #endif
   28546             : 
   28547        6784 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   28548             : 
   28549        6784 :     ALLOC_MUTEX(SgArrayType, unlock);
   28550             : 
   28551             :     return object;
   28552             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   28553             : }
   28554             : 
   28555             : 
   28556             : 
   28557             : /*! \brief Delete operator for SgArrayType.
   28558             : 
   28559             :    This delete operator implements deallocation using memory pools to 
   28560             :    provide most efficent use of the heap within construction of large ASTs.
   28561             : 
   28562             : \internal The new and delete operators use the lower level C malloc/free
   28563             :    function calls for performance and to make sure that mixing of malloc/free
   28564             :    and new/delete by the used can be caught more readily.  This may change
   28565             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   28566             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   28567             :    deallocate memory allocated using ROSE_MALLOC.
   28568             : */
   28569         216 : void SgArrayType::operator delete(void *Pointer, size_t Size)
   28570             : {
   28571             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   28572             :      * or throwing an exception. */
   28573         216 :     ALLOC_MUTEX(SgArrayType, lock);
   28574             : 
   28575             : #if USE_CPP_NEW_DELETE_OPERATORS
   28576             :     ROSE_FREE(Pointer);
   28577             : #else
   28578             : #if ROSE_PEDANTIC_ALLOC
   28579             :     ROSE_ASSERT(Size == sizeof(SgArrayType));
   28580             : #else
   28581         216 :     if (Size != sizeof(SgArrayType)) {
   28582           0 :       ROSE_FREE(Pointer);
   28583           0 :       ALLOC_MUTEX(SgArrayType, unlock);
   28584             :       return;
   28585             :     }
   28586             : #endif
   28587             : 
   28588         216 :     SgArrayType * object = (SgArrayType*) Pointer;
   28589         216 :     ROSE_ASSERT(object != nullptr);
   28590             : 
   28591             : #if ROSE_ALLOC_TRACE == 2
   28592             : //  printf("SgArrayType::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgArrayType::next_node);
   28593             :     printf("SgArrayType::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgArrayType::next_node);
   28594             : #endif
   28595             : 
   28596             : #if ROSE_PEDANTIC_ALLOC
   28597             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   28598             : #endif
   28599             : 
   28600             : #if ROSE_ALLOC_MEMSET == 1
   28601             : #elif ROSE_ALLOC_MEMSET == 2
   28602             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgArrayType) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   28603             : #elif ROSE_ALLOC_MEMSET == 3
   28604             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgArrayType) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   28605             : #endif
   28606             : 
   28607             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   28608             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   28609             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   28610             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   28611             : #else
   28612         216 :     object->p_freepointer = SgArrayType::next_node;
   28613         216 :     SgArrayType::next_node = object;
   28614             : #endif
   28615             : 
   28616             : #if ROSE_ALLOC_TRACE == 2
   28617             : //  printf("SgArrayType::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgArrayType::next_node);
   28618             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   28619             :     Rose::MemPool::snapshot(oss.str());
   28620             :     alloc_trace_cnt++;
   28621             : #endif
   28622             : 
   28623             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   28624             : 
   28625         216 :     ALLOC_MUTEX(SgArrayType, unlock);
   28626             : }
   28627             : 
   28628             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   28629             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   28630             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   28631             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   28632             : // Also, note comment below from Robb (copied from the Common.code file).
   28633             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   28634             : //
   28635             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   28636             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   28637             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   28638             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   28639             : #if 0
   28640             : void SgArrayType::operator delete(void* pointer) { SgArrayType::operator delete (pointer, sizeof(SgArrayType)); };
   28641             : #endif
   28642             : /* #line 28643 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   28643             : 
   28644             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   28645             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   28646             : // obviously imply C++.
   28647             : 
   28648             : // This implements the support within ROSE for memory pools.  Memory pools
   28649             : // support the most condensed usage of memory within the construction of
   28650             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   28651             : // by a new operator written for each class.
   28652             : 
   28653             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   28654             :     // User wants multi-thread support and POSIX threads are available.
   28655             : #   include <pthread.h>
   28656             :     static pthread_mutex_t SgTypeEllipse_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   28657             : #else
   28658             :      // Cause synchronization to be skipped.
   28659             : #    ifndef ALLOC_MUTEX
   28660             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   28661             : #    endif
   28662             : #    ifdef _REENTRANT
   28663             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   28664             : #       ifdef _MSC_VER
   28665             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   28666             : #       else
   28667             : #           warning "POSIX threads are not available; synchronization being skipped"
   28668             : #       endif
   28669             : #    endif
   28670             : #endif
   28671             : 
   28672             : #ifndef ROSE_ALLOC_TRACE
   28673             : #  define ROSE_ALLOC_TRACE 0
   28674             : #endif
   28675             : 
   28676             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   28677             : #define ROSE_ALLOC_TRACE_CNT
   28678             : #include "memory-pool-snapshot.h"
   28679             : unsigned long alloc_trace_cnt = 0;
   28680             : #endif
   28681             : 
   28682             : #if ROSE_ALLOC_TRACE
   28683             : const unsigned SgTypeEllipse::pool_size = 5;
   28684             : #else
   28685             : const unsigned SgTypeEllipse::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   28686             : #endif
   28687             : 
   28688             : #ifndef ROSE_ALLOC_MEMSET
   28689             : #  define ROSE_ALLOC_MEMSET 0
   28690             : #endif
   28691             : 
   28692             : #ifndef ROSE_PEDANTIC_ALLOC
   28693             : #  define ROSE_PEDANTIC_ALLOC 0
   28694             : #endif
   28695             : 
   28696             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   28697             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   28698             : #endif
   28699             : 
   28700             : #if !defined(SGNODE__ALL_POOLS)
   28701             : #define SGNODE__ALL_POOLS
   28702             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   28703             : #endif
   28704             : 
   28705             : SgTypeEllipse* SgTypeEllipse::next_node = nullptr;
   28706             : std::vector<unsigned char*> SgTypeEllipse::pools;
   28707             : 
   28708             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   28709             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   28710             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   28711             : // around this macro definition rather than each use).
   28712             : #ifndef ALLOC_MUTEX
   28713             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   28714             :         do {                                                                     \
   28715             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   28716             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   28717             :                 abort();                                                         \
   28718             :             }                                                                    \
   28719             :         } while (0);
   28720             : #endif
   28721             : 
   28722             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   28723             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   28724             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   28725             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   28726             : 
   28727             : /*! \brief New operator for SgTypeEllipse.
   28728             : 
   28729             :    This new operator implements memory pools to provide most efficent 
   28730             :    use of the heap within construction of large ASTs.
   28731             : 
   28732             : \internal The new and delete operators use the lower level C malloc/free
   28733             :    function calls for performance and to make sure that mixing of malloc/free
   28734             :    and new/delete by the used can be caught more readily.  This may change
   28735             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   28736             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   28737             :    deallocate memory allocated using ROSE_MALLOC.
   28738             : */
   28739       28338 : void *SgTypeEllipse::operator new ( size_t Size )
   28740             : {
   28741             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   28742             :      * returning or throwing an exception. */
   28743       28338 :     ALLOC_MUTEX(SgTypeEllipse, lock);
   28744             : 
   28745             : #if ROSE_ALLOC_TRACE == 2
   28746             : //    printf("SgTypeEllipse::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgTypeEllipse::next_node);
   28747             : #endif
   28748             : 
   28749             : #if USE_CPP_NEW_DELETE_OPERATORS
   28750             :     void *mem = ROSE_MALLOC(Size);
   28751             :     ALLOC_MUTEX(SgTypeEllipse, unlock);
   28752             :     return mem;
   28753             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   28754             : #if ROSE_PEDANTIC_ALLOC
   28755             :     ROSE_ASSERT(Size == sizeof(SgTypeEllipse));
   28756             : #else
   28757       28338 :     if (Size != sizeof(SgTypeEllipse)) {
   28758           0 :       void * object = ROSE_MALLOC(Size);
   28759           0 :       ALLOC_MUTEX(SgTypeEllipse, unlock);
   28760             :       return object;
   28761             :     }
   28762             : #endif
   28763             : 
   28764       28338 :     if (SgTypeEllipse::next_node == nullptr) {
   28765         208 :         SgTypeEllipse * alloc = (SgTypeEllipse*) ROSE_MALLOC ( SgTypeEllipse::pool_size * sizeof(SgTypeEllipse) );
   28766         208 :         ROSE_ASSERT(alloc != nullptr);
   28767             : 
   28768             : #if ROSE_ALLOC_TRACE == 2
   28769             : //        printf("SgTypeEllipse::alloc\n  block[%zi] = [ %p , %p [\n", SgTypeEllipse::pools.size(), alloc, alloc + SgTypeEllipse::pool_size);
   28770             : #endif
   28771             : 
   28772             : #if ROSE_ALLOC_MEMSET == 1
   28773             : #elif ROSE_ALLOC_MEMSET == 2
   28774             :         memset(alloc, 0x00, SgTypeEllipse::pool_size * sizeof(SgTypeEllipse));
   28775             : #elif ROSE_ALLOC_MEMSET == 3
   28776             :         memset(alloc, 0xAA, SgTypeEllipse::pool_size * sizeof(SgTypeEllipse));
   28777             : #endif
   28778      416000 :         for (unsigned i=0; i < SgTypeEllipse::pool_size-1; i++) {
   28779      415792 :           alloc[i].p_freepointer = &(alloc[i+1]);
   28780             :         }
   28781         208 :         alloc[SgTypeEllipse::pool_size-1].p_freepointer = nullptr;
   28782             : 
   28783         208 :         SgTypeEllipse::pools.push_back ( (unsigned char *) alloc );
   28784         208 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgTypeEllipse::pool_size * sizeof(SgTypeEllipse), V_SgTypeEllipse ) );
   28785         208 :         SgTypeEllipse::next_node = alloc;
   28786             :     }
   28787       28338 :     ROSE_ASSERT(SgTypeEllipse::next_node != nullptr);
   28788             : 
   28789       28338 :     SgTypeEllipse * object = SgTypeEllipse::next_node;
   28790       28338 :     SgTypeEllipse::next_node = (SgTypeEllipse*)(object->p_freepointer);
   28791             : 
   28792             : #if ROSE_ALLOC_TRACE == 2
   28793             :     printf("SgTypeEllipse::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeEllipse::next_node);
   28794             : #endif
   28795             : 
   28796       28338 :     SgNode * fp = object->p_freepointer;
   28797             : #if ROSE_ALLOC_MEMSET == 1
   28798             : #elif ROSE_ALLOC_MEMSET == 2
   28799             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgTypeEllipse) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   28800             : #elif ROSE_ALLOC_MEMSET == 3
   28801             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgTypeEllipse) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   28802             : #endif
   28803       28338 :     object->p_freepointer = fp;
   28804             : 
   28805             : #if ROSE_ALLOC_TRACE == 2
   28806             : //    printf("SgTypeEllipse::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeEllipse::next_node);
   28807             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   28808             :     Rose::MemPool::snapshot(oss.str());
   28809             :     alloc_trace_cnt++;
   28810             : #endif
   28811             : 
   28812       28338 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   28813             : 
   28814       28338 :     ALLOC_MUTEX(SgTypeEllipse, unlock);
   28815             : 
   28816             :     return object;
   28817             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   28818             : }
   28819             : 
   28820             : 
   28821             : 
   28822             : /*! \brief Delete operator for SgTypeEllipse.
   28823             : 
   28824             :    This delete operator implements deallocation using memory pools to 
   28825             :    provide most efficent use of the heap within construction of large ASTs.
   28826             : 
   28827             : \internal The new and delete operators use the lower level C malloc/free
   28828             :    function calls for performance and to make sure that mixing of malloc/free
   28829             :    and new/delete by the used can be caught more readily.  This may change
   28830             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   28831             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   28832             :    deallocate memory allocated using ROSE_MALLOC.
   28833             : */
   28834       28132 : void SgTypeEllipse::operator delete(void *Pointer, size_t Size)
   28835             : {
   28836             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   28837             :      * or throwing an exception. */
   28838       28132 :     ALLOC_MUTEX(SgTypeEllipse, lock);
   28839             : 
   28840             : #if USE_CPP_NEW_DELETE_OPERATORS
   28841             :     ROSE_FREE(Pointer);
   28842             : #else
   28843             : #if ROSE_PEDANTIC_ALLOC
   28844             :     ROSE_ASSERT(Size == sizeof(SgTypeEllipse));
   28845             : #else
   28846       28132 :     if (Size != sizeof(SgTypeEllipse)) {
   28847           0 :       ROSE_FREE(Pointer);
   28848           0 :       ALLOC_MUTEX(SgTypeEllipse, unlock);
   28849             :       return;
   28850             :     }
   28851             : #endif
   28852             : 
   28853       28132 :     SgTypeEllipse * object = (SgTypeEllipse*) Pointer;
   28854       28132 :     ROSE_ASSERT(object != nullptr);
   28855             : 
   28856             : #if ROSE_ALLOC_TRACE == 2
   28857             : //  printf("SgTypeEllipse::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeEllipse::next_node);
   28858             :     printf("SgTypeEllipse::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeEllipse::next_node);
   28859             : #endif
   28860             : 
   28861             : #if ROSE_PEDANTIC_ALLOC
   28862             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   28863             : #endif
   28864             : 
   28865             : #if ROSE_ALLOC_MEMSET == 1
   28866             : #elif ROSE_ALLOC_MEMSET == 2
   28867             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgTypeEllipse) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   28868             : #elif ROSE_ALLOC_MEMSET == 3
   28869             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgTypeEllipse) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   28870             : #endif
   28871             : 
   28872             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   28873             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   28874             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   28875             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   28876             : #else
   28877       28132 :     object->p_freepointer = SgTypeEllipse::next_node;
   28878       28132 :     SgTypeEllipse::next_node = object;
   28879             : #endif
   28880             : 
   28881             : #if ROSE_ALLOC_TRACE == 2
   28882             : //  printf("SgTypeEllipse::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeEllipse::next_node);
   28883             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   28884             :     Rose::MemPool::snapshot(oss.str());
   28885             :     alloc_trace_cnt++;
   28886             : #endif
   28887             : 
   28888             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   28889             : 
   28890       28132 :     ALLOC_MUTEX(SgTypeEllipse, unlock);
   28891             : }
   28892             : 
   28893             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   28894             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   28895             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   28896             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   28897             : // Also, note comment below from Robb (copied from the Common.code file).
   28898             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   28899             : //
   28900             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   28901             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   28902             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   28903             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   28904             : #if 0
   28905             : void SgTypeEllipse::operator delete(void* pointer) { SgTypeEllipse::operator delete (pointer, sizeof(SgTypeEllipse)); };
   28906             : #endif
   28907             : /* #line 28908 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   28908             : 
   28909             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   28910             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   28911             : // obviously imply C++.
   28912             : 
   28913             : // This implements the support within ROSE for memory pools.  Memory pools
   28914             : // support the most condensed usage of memory within the construction of
   28915             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   28916             : // by a new operator written for each class.
   28917             : 
   28918             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   28919             :     // User wants multi-thread support and POSIX threads are available.
   28920             : #   include <pthread.h>
   28921             :     static pthread_mutex_t SgTemplateType_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   28922             : #else
   28923             :      // Cause synchronization to be skipped.
   28924             : #    ifndef ALLOC_MUTEX
   28925             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   28926             : #    endif
   28927             : #    ifdef _REENTRANT
   28928             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   28929             : #       ifdef _MSC_VER
   28930             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   28931             : #       else
   28932             : #           warning "POSIX threads are not available; synchronization being skipped"
   28933             : #       endif
   28934             : #    endif
   28935             : #endif
   28936             : 
   28937             : #ifndef ROSE_ALLOC_TRACE
   28938             : #  define ROSE_ALLOC_TRACE 0
   28939             : #endif
   28940             : 
   28941             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   28942             : #define ROSE_ALLOC_TRACE_CNT
   28943             : #include "memory-pool-snapshot.h"
   28944             : unsigned long alloc_trace_cnt = 0;
   28945             : #endif
   28946             : 
   28947             : #if ROSE_ALLOC_TRACE
   28948             : const unsigned SgTemplateType::pool_size = 5;
   28949             : #else
   28950             : const unsigned SgTemplateType::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   28951             : #endif
   28952             : 
   28953             : #ifndef ROSE_ALLOC_MEMSET
   28954             : #  define ROSE_ALLOC_MEMSET 0
   28955             : #endif
   28956             : 
   28957             : #ifndef ROSE_PEDANTIC_ALLOC
   28958             : #  define ROSE_PEDANTIC_ALLOC 0
   28959             : #endif
   28960             : 
   28961             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   28962             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   28963             : #endif
   28964             : 
   28965             : #if !defined(SGNODE__ALL_POOLS)
   28966             : #define SGNODE__ALL_POOLS
   28967             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   28968             : #endif
   28969             : 
   28970             : SgTemplateType* SgTemplateType::next_node = nullptr;
   28971             : std::vector<unsigned char*> SgTemplateType::pools;
   28972             : 
   28973             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   28974             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   28975             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   28976             : // around this macro definition rather than each use).
   28977             : #ifndef ALLOC_MUTEX
   28978             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   28979             :         do {                                                                     \
   28980             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   28981             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   28982             :                 abort();                                                         \
   28983             :             }                                                                    \
   28984             :         } while (0);
   28985             : #endif
   28986             : 
   28987             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   28988             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   28989             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   28990             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   28991             : 
   28992             : /*! \brief New operator for SgTemplateType.
   28993             : 
   28994             :    This new operator implements memory pools to provide most efficent 
   28995             :    use of the heap within construction of large ASTs.
   28996             : 
   28997             : \internal The new and delete operators use the lower level C malloc/free
   28998             :    function calls for performance and to make sure that mixing of malloc/free
   28999             :    and new/delete by the used can be caught more readily.  This may change
   29000             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   29001             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   29002             :    deallocate memory allocated using ROSE_MALLOC.
   29003             : */
   29004           0 : void *SgTemplateType::operator new ( size_t Size )
   29005             : {
   29006             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   29007             :      * returning or throwing an exception. */
   29008           0 :     ALLOC_MUTEX(SgTemplateType, lock);
   29009             : 
   29010             : #if ROSE_ALLOC_TRACE == 2
   29011             : //    printf("SgTemplateType::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgTemplateType::next_node);
   29012             : #endif
   29013             : 
   29014             : #if USE_CPP_NEW_DELETE_OPERATORS
   29015             :     void *mem = ROSE_MALLOC(Size);
   29016             :     ALLOC_MUTEX(SgTemplateType, unlock);
   29017             :     return mem;
   29018             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   29019             : #if ROSE_PEDANTIC_ALLOC
   29020             :     ROSE_ASSERT(Size == sizeof(SgTemplateType));
   29021             : #else
   29022           0 :     if (Size != sizeof(SgTemplateType)) {
   29023           0 :       void * object = ROSE_MALLOC(Size);
   29024           0 :       ALLOC_MUTEX(SgTemplateType, unlock);
   29025             :       return object;
   29026             :     }
   29027             : #endif
   29028             : 
   29029           0 :     if (SgTemplateType::next_node == nullptr) {
   29030           0 :         SgTemplateType * alloc = (SgTemplateType*) ROSE_MALLOC ( SgTemplateType::pool_size * sizeof(SgTemplateType) );
   29031           0 :         ROSE_ASSERT(alloc != nullptr);
   29032             : 
   29033             : #if ROSE_ALLOC_TRACE == 2
   29034             : //        printf("SgTemplateType::alloc\n  block[%zi] = [ %p , %p [\n", SgTemplateType::pools.size(), alloc, alloc + SgTemplateType::pool_size);
   29035             : #endif
   29036             : 
   29037             : #if ROSE_ALLOC_MEMSET == 1
   29038             : #elif ROSE_ALLOC_MEMSET == 2
   29039             :         memset(alloc, 0x00, SgTemplateType::pool_size * sizeof(SgTemplateType));
   29040             : #elif ROSE_ALLOC_MEMSET == 3
   29041             :         memset(alloc, 0xAA, SgTemplateType::pool_size * sizeof(SgTemplateType));
   29042             : #endif
   29043           0 :         for (unsigned i=0; i < SgTemplateType::pool_size-1; i++) {
   29044           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
   29045             :         }
   29046           0 :         alloc[SgTemplateType::pool_size-1].p_freepointer = nullptr;
   29047             : 
   29048           0 :         SgTemplateType::pools.push_back ( (unsigned char *) alloc );
   29049           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgTemplateType::pool_size * sizeof(SgTemplateType), V_SgTemplateType ) );
   29050           0 :         SgTemplateType::next_node = alloc;
   29051             :     }
   29052           0 :     ROSE_ASSERT(SgTemplateType::next_node != nullptr);
   29053             : 
   29054           0 :     SgTemplateType * object = SgTemplateType::next_node;
   29055           0 :     SgTemplateType::next_node = (SgTemplateType*)(object->p_freepointer);
   29056             : 
   29057             : #if ROSE_ALLOC_TRACE == 2
   29058             :     printf("SgTemplateType::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTemplateType::next_node);
   29059             : #endif
   29060             : 
   29061           0 :     SgNode * fp = object->p_freepointer;
   29062             : #if ROSE_ALLOC_MEMSET == 1
   29063             : #elif ROSE_ALLOC_MEMSET == 2
   29064             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgTemplateType) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   29065             : #elif ROSE_ALLOC_MEMSET == 3
   29066             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgTemplateType) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   29067             : #endif
   29068           0 :     object->p_freepointer = fp;
   29069             : 
   29070             : #if ROSE_ALLOC_TRACE == 2
   29071             : //    printf("SgTemplateType::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTemplateType::next_node);
   29072             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   29073             :     Rose::MemPool::snapshot(oss.str());
   29074             :     alloc_trace_cnt++;
   29075             : #endif
   29076             : 
   29077           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   29078             : 
   29079           0 :     ALLOC_MUTEX(SgTemplateType, unlock);
   29080             : 
   29081             :     return object;
   29082             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   29083             : }
   29084             : 
   29085             : 
   29086             : 
   29087             : /*! \brief Delete operator for SgTemplateType.
   29088             : 
   29089             :    This delete operator implements deallocation using memory pools to 
   29090             :    provide most efficent use of the heap within construction of large ASTs.
   29091             : 
   29092             : \internal The new and delete operators use the lower level C malloc/free
   29093             :    function calls for performance and to make sure that mixing of malloc/free
   29094             :    and new/delete by the used can be caught more readily.  This may change
   29095             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   29096             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   29097             :    deallocate memory allocated using ROSE_MALLOC.
   29098             : */
   29099           0 : void SgTemplateType::operator delete(void *Pointer, size_t Size)
   29100             : {
   29101             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   29102             :      * or throwing an exception. */
   29103           0 :     ALLOC_MUTEX(SgTemplateType, lock);
   29104             : 
   29105             : #if USE_CPP_NEW_DELETE_OPERATORS
   29106             :     ROSE_FREE(Pointer);
   29107             : #else
   29108             : #if ROSE_PEDANTIC_ALLOC
   29109             :     ROSE_ASSERT(Size == sizeof(SgTemplateType));
   29110             : #else
   29111           0 :     if (Size != sizeof(SgTemplateType)) {
   29112           0 :       ROSE_FREE(Pointer);
   29113           0 :       ALLOC_MUTEX(SgTemplateType, unlock);
   29114             :       return;
   29115             :     }
   29116             : #endif
   29117             : 
   29118           0 :     SgTemplateType * object = (SgTemplateType*) Pointer;
   29119           0 :     ROSE_ASSERT(object != nullptr);
   29120             : 
   29121             : #if ROSE_ALLOC_TRACE == 2
   29122             : //  printf("SgTemplateType::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTemplateType::next_node);
   29123             :     printf("SgTemplateType::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTemplateType::next_node);
   29124             : #endif
   29125             : 
   29126             : #if ROSE_PEDANTIC_ALLOC
   29127             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   29128             : #endif
   29129             : 
   29130             : #if ROSE_ALLOC_MEMSET == 1
   29131             : #elif ROSE_ALLOC_MEMSET == 2
   29132             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgTemplateType) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   29133             : #elif ROSE_ALLOC_MEMSET == 3
   29134             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgTemplateType) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   29135             : #endif
   29136             : 
   29137             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   29138             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   29139             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   29140             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   29141             : #else
   29142           0 :     object->p_freepointer = SgTemplateType::next_node;
   29143           0 :     SgTemplateType::next_node = object;
   29144             : #endif
   29145             : 
   29146             : #if ROSE_ALLOC_TRACE == 2
   29147             : //  printf("SgTemplateType::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTemplateType::next_node);
   29148             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   29149             :     Rose::MemPool::snapshot(oss.str());
   29150             :     alloc_trace_cnt++;
   29151             : #endif
   29152             : 
   29153             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   29154             : 
   29155           0 :     ALLOC_MUTEX(SgTemplateType, unlock);
   29156             : }
   29157             : 
   29158             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   29159             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   29160             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   29161             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   29162             : // Also, note comment below from Robb (copied from the Common.code file).
   29163             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   29164             : //
   29165             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   29166             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   29167             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   29168             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   29169             : #if 0
   29170             : void SgTemplateType::operator delete(void* pointer) { SgTemplateType::operator delete (pointer, sizeof(SgTemplateType)); };
   29171             : #endif
   29172             : /* #line 29173 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   29173             : 
   29174             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   29175             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   29176             : // obviously imply C++.
   29177             : 
   29178             : // This implements the support within ROSE for memory pools.  Memory pools
   29179             : // support the most condensed usage of memory within the construction of
   29180             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   29181             : // by a new operator written for each class.
   29182             : 
   29183             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   29184             :     // User wants multi-thread support and POSIX threads are available.
   29185             : #   include <pthread.h>
   29186             :     static pthread_mutex_t SgQualifiedNameType_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   29187             : #else
   29188             :      // Cause synchronization to be skipped.
   29189             : #    ifndef ALLOC_MUTEX
   29190             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   29191             : #    endif
   29192             : #    ifdef _REENTRANT
   29193             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   29194             : #       ifdef _MSC_VER
   29195             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   29196             : #       else
   29197             : #           warning "POSIX threads are not available; synchronization being skipped"
   29198             : #       endif
   29199             : #    endif
   29200             : #endif
   29201             : 
   29202             : #ifndef ROSE_ALLOC_TRACE
   29203             : #  define ROSE_ALLOC_TRACE 0
   29204             : #endif
   29205             : 
   29206             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   29207             : #define ROSE_ALLOC_TRACE_CNT
   29208             : #include "memory-pool-snapshot.h"
   29209             : unsigned long alloc_trace_cnt = 0;
   29210             : #endif
   29211             : 
   29212             : #if ROSE_ALLOC_TRACE
   29213             : const unsigned SgQualifiedNameType::pool_size = 5;
   29214             : #else
   29215             : const unsigned SgQualifiedNameType::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   29216             : #endif
   29217             : 
   29218             : #ifndef ROSE_ALLOC_MEMSET
   29219             : #  define ROSE_ALLOC_MEMSET 0
   29220             : #endif
   29221             : 
   29222             : #ifndef ROSE_PEDANTIC_ALLOC
   29223             : #  define ROSE_PEDANTIC_ALLOC 0
   29224             : #endif
   29225             : 
   29226             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   29227             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   29228             : #endif
   29229             : 
   29230             : #if !defined(SGNODE__ALL_POOLS)
   29231             : #define SGNODE__ALL_POOLS
   29232             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   29233             : #endif
   29234             : 
   29235             : SgQualifiedNameType* SgQualifiedNameType::next_node = nullptr;
   29236             : std::vector<unsigned char*> SgQualifiedNameType::pools;
   29237             : 
   29238             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   29239             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   29240             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   29241             : // around this macro definition rather than each use).
   29242             : #ifndef ALLOC_MUTEX
   29243             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   29244             :         do {                                                                     \
   29245             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   29246             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   29247             :                 abort();                                                         \
   29248             :             }                                                                    \
   29249             :         } while (0);
   29250             : #endif
   29251             : 
   29252             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   29253             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   29254             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   29255             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   29256             : 
   29257             : /*! \brief New operator for SgQualifiedNameType.
   29258             : 
   29259             :    This new operator implements memory pools to provide most efficent 
   29260             :    use of the heap within construction of large ASTs.
   29261             : 
   29262             : \internal The new and delete operators use the lower level C malloc/free
   29263             :    function calls for performance and to make sure that mixing of malloc/free
   29264             :    and new/delete by the used can be caught more readily.  This may change
   29265             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   29266             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   29267             :    deallocate memory allocated using ROSE_MALLOC.
   29268             : */
   29269           0 : void *SgQualifiedNameType::operator new ( size_t Size )
   29270             : {
   29271             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   29272             :      * returning or throwing an exception. */
   29273           0 :     ALLOC_MUTEX(SgQualifiedNameType, lock);
   29274             : 
   29275             : #if ROSE_ALLOC_TRACE == 2
   29276             : //    printf("SgQualifiedNameType::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgQualifiedNameType::next_node);
   29277             : #endif
   29278             : 
   29279             : #if USE_CPP_NEW_DELETE_OPERATORS
   29280             :     void *mem = ROSE_MALLOC(Size);
   29281             :     ALLOC_MUTEX(SgQualifiedNameType, unlock);
   29282             :     return mem;
   29283             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   29284             : #if ROSE_PEDANTIC_ALLOC
   29285             :     ROSE_ASSERT(Size == sizeof(SgQualifiedNameType));
   29286             : #else
   29287           0 :     if (Size != sizeof(SgQualifiedNameType)) {
   29288           0 :       void * object = ROSE_MALLOC(Size);
   29289           0 :       ALLOC_MUTEX(SgQualifiedNameType, unlock);
   29290             :       return object;
   29291             :     }
   29292             : #endif
   29293             : 
   29294           0 :     if (SgQualifiedNameType::next_node == nullptr) {
   29295           0 :         SgQualifiedNameType * alloc = (SgQualifiedNameType*) ROSE_MALLOC ( SgQualifiedNameType::pool_size * sizeof(SgQualifiedNameType) );
   29296           0 :         ROSE_ASSERT(alloc != nullptr);
   29297             : 
   29298             : #if ROSE_ALLOC_TRACE == 2
   29299             : //        printf("SgQualifiedNameType::alloc\n  block[%zi] = [ %p , %p [\n", SgQualifiedNameType::pools.size(), alloc, alloc + SgQualifiedNameType::pool_size);
   29300             : #endif
   29301             : 
   29302             : #if ROSE_ALLOC_MEMSET == 1
   29303             : #elif ROSE_ALLOC_MEMSET == 2
   29304             :         memset(alloc, 0x00, SgQualifiedNameType::pool_size * sizeof(SgQualifiedNameType));
   29305             : #elif ROSE_ALLOC_MEMSET == 3
   29306             :         memset(alloc, 0xAA, SgQualifiedNameType::pool_size * sizeof(SgQualifiedNameType));
   29307             : #endif
   29308           0 :         for (unsigned i=0; i < SgQualifiedNameType::pool_size-1; i++) {
   29309           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
   29310             :         }
   29311           0 :         alloc[SgQualifiedNameType::pool_size-1].p_freepointer = nullptr;
   29312             : 
   29313           0 :         SgQualifiedNameType::pools.push_back ( (unsigned char *) alloc );
   29314           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgQualifiedNameType::pool_size * sizeof(SgQualifiedNameType), V_SgQualifiedNameType ) );
   29315           0 :         SgQualifiedNameType::next_node = alloc;
   29316             :     }
   29317           0 :     ROSE_ASSERT(SgQualifiedNameType::next_node != nullptr);
   29318             : 
   29319           0 :     SgQualifiedNameType * object = SgQualifiedNameType::next_node;
   29320           0 :     SgQualifiedNameType::next_node = (SgQualifiedNameType*)(object->p_freepointer);
   29321             : 
   29322             : #if ROSE_ALLOC_TRACE == 2
   29323             :     printf("SgQualifiedNameType::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgQualifiedNameType::next_node);
   29324             : #endif
   29325             : 
   29326           0 :     SgNode * fp = object->p_freepointer;
   29327             : #if ROSE_ALLOC_MEMSET == 1
   29328             : #elif ROSE_ALLOC_MEMSET == 2
   29329             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgQualifiedNameType) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   29330             : #elif ROSE_ALLOC_MEMSET == 3
   29331             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgQualifiedNameType) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   29332             : #endif
   29333           0 :     object->p_freepointer = fp;
   29334             : 
   29335             : #if ROSE_ALLOC_TRACE == 2
   29336             : //    printf("SgQualifiedNameType::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgQualifiedNameType::next_node);
   29337             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   29338             :     Rose::MemPool::snapshot(oss.str());
   29339             :     alloc_trace_cnt++;
   29340             : #endif
   29341             : 
   29342           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   29343             : 
   29344           0 :     ALLOC_MUTEX(SgQualifiedNameType, unlock);
   29345             : 
   29346             :     return object;
   29347             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   29348             : }
   29349             : 
   29350             : 
   29351             : 
   29352             : /*! \brief Delete operator for SgQualifiedNameType.
   29353             : 
   29354             :    This delete operator implements deallocation using memory pools to 
   29355             :    provide most efficent use of the heap within construction of large ASTs.
   29356             : 
   29357             : \internal The new and delete operators use the lower level C malloc/free
   29358             :    function calls for performance and to make sure that mixing of malloc/free
   29359             :    and new/delete by the used can be caught more readily.  This may change
   29360             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   29361             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   29362             :    deallocate memory allocated using ROSE_MALLOC.
   29363             : */
   29364           0 : void SgQualifiedNameType::operator delete(void *Pointer, size_t Size)
   29365             : {
   29366             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   29367             :      * or throwing an exception. */
   29368           0 :     ALLOC_MUTEX(SgQualifiedNameType, lock);
   29369             : 
   29370             : #if USE_CPP_NEW_DELETE_OPERATORS
   29371             :     ROSE_FREE(Pointer);
   29372             : #else
   29373             : #if ROSE_PEDANTIC_ALLOC
   29374             :     ROSE_ASSERT(Size == sizeof(SgQualifiedNameType));
   29375             : #else
   29376           0 :     if (Size != sizeof(SgQualifiedNameType)) {
   29377           0 :       ROSE_FREE(Pointer);
   29378           0 :       ALLOC_MUTEX(SgQualifiedNameType, unlock);
   29379             :       return;
   29380             :     }
   29381             : #endif
   29382             : 
   29383           0 :     SgQualifiedNameType * object = (SgQualifiedNameType*) Pointer;
   29384           0 :     ROSE_ASSERT(object != nullptr);
   29385             : 
   29386             : #if ROSE_ALLOC_TRACE == 2
   29387             : //  printf("SgQualifiedNameType::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgQualifiedNameType::next_node);
   29388             :     printf("SgQualifiedNameType::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgQualifiedNameType::next_node);
   29389             : #endif
   29390             : 
   29391             : #if ROSE_PEDANTIC_ALLOC
   29392             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   29393             : #endif
   29394             : 
   29395             : #if ROSE_ALLOC_MEMSET == 1
   29396             : #elif ROSE_ALLOC_MEMSET == 2
   29397             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgQualifiedNameType) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   29398             : #elif ROSE_ALLOC_MEMSET == 3
   29399             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgQualifiedNameType) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   29400             : #endif
   29401             : 
   29402             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   29403             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   29404             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   29405             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   29406             : #else
   29407           0 :     object->p_freepointer = SgQualifiedNameType::next_node;
   29408           0 :     SgQualifiedNameType::next_node = object;
   29409             : #endif
   29410             : 
   29411             : #if ROSE_ALLOC_TRACE == 2
   29412             : //  printf("SgQualifiedNameType::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgQualifiedNameType::next_node);
   29413             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   29414             :     Rose::MemPool::snapshot(oss.str());
   29415             :     alloc_trace_cnt++;
   29416             : #endif
   29417             : 
   29418             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   29419             : 
   29420           0 :     ALLOC_MUTEX(SgQualifiedNameType, unlock);
   29421             : }
   29422             : 
   29423             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   29424             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   29425             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   29426             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   29427             : // Also, note comment below from Robb (copied from the Common.code file).
   29428             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   29429             : //
   29430             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   29431             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   29432             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   29433             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   29434             : #if 0
   29435             : void SgQualifiedNameType::operator delete(void* pointer) { SgQualifiedNameType::operator delete (pointer, sizeof(SgQualifiedNameType)); };
   29436             : #endif
   29437             : /* #line 29438 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   29438             : 
   29439             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   29440             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   29441             : // obviously imply C++.
   29442             : 
   29443             : // This implements the support within ROSE for memory pools.  Memory pools
   29444             : // support the most condensed usage of memory within the construction of
   29445             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   29446             : // by a new operator written for each class.
   29447             : 
   29448             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   29449             :     // User wants multi-thread support and POSIX threads are available.
   29450             : #   include <pthread.h>
   29451             :     static pthread_mutex_t SgTypeComplex_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   29452             : #else
   29453             :      // Cause synchronization to be skipped.
   29454             : #    ifndef ALLOC_MUTEX
   29455             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   29456             : #    endif
   29457             : #    ifdef _REENTRANT
   29458             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   29459             : #       ifdef _MSC_VER
   29460             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   29461             : #       else
   29462             : #           warning "POSIX threads are not available; synchronization being skipped"
   29463             : #       endif
   29464             : #    endif
   29465             : #endif
   29466             : 
   29467             : #ifndef ROSE_ALLOC_TRACE
   29468             : #  define ROSE_ALLOC_TRACE 0
   29469             : #endif
   29470             : 
   29471             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   29472             : #define ROSE_ALLOC_TRACE_CNT
   29473             : #include "memory-pool-snapshot.h"
   29474             : unsigned long alloc_trace_cnt = 0;
   29475             : #endif
   29476             : 
   29477             : #if ROSE_ALLOC_TRACE
   29478             : const unsigned SgTypeComplex::pool_size = 5;
   29479             : #else
   29480             : const unsigned SgTypeComplex::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   29481             : #endif
   29482             : 
   29483             : #ifndef ROSE_ALLOC_MEMSET
   29484             : #  define ROSE_ALLOC_MEMSET 0
   29485             : #endif
   29486             : 
   29487             : #ifndef ROSE_PEDANTIC_ALLOC
   29488             : #  define ROSE_PEDANTIC_ALLOC 0
   29489             : #endif
   29490             : 
   29491             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   29492             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   29493             : #endif
   29494             : 
   29495             : #if !defined(SGNODE__ALL_POOLS)
   29496             : #define SGNODE__ALL_POOLS
   29497             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   29498             : #endif
   29499             : 
   29500             : SgTypeComplex* SgTypeComplex::next_node = nullptr;
   29501             : std::vector<unsigned char*> SgTypeComplex::pools;
   29502             : 
   29503             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   29504             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   29505             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   29506             : // around this macro definition rather than each use).
   29507             : #ifndef ALLOC_MUTEX
   29508             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   29509             :         do {                                                                     \
   29510             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   29511             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   29512             :                 abort();                                                         \
   29513             :             }                                                                    \
   29514             :         } while (0);
   29515             : #endif
   29516             : 
   29517             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   29518             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   29519             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   29520             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   29521             : 
   29522             : /*! \brief New operator for SgTypeComplex.
   29523             : 
   29524             :    This new operator implements memory pools to provide most efficent 
   29525             :    use of the heap within construction of large ASTs.
   29526             : 
   29527             : \internal The new and delete operators use the lower level C malloc/free
   29528             :    function calls for performance and to make sure that mixing of malloc/free
   29529             :    and new/delete by the used can be caught more readily.  This may change
   29530             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   29531             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   29532             :    deallocate memory allocated using ROSE_MALLOC.
   29533             : */
   29534         982 : void *SgTypeComplex::operator new ( size_t Size )
   29535             : {
   29536             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   29537             :      * returning or throwing an exception. */
   29538         982 :     ALLOC_MUTEX(SgTypeComplex, lock);
   29539             : 
   29540             : #if ROSE_ALLOC_TRACE == 2
   29541             : //    printf("SgTypeComplex::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgTypeComplex::next_node);
   29542             : #endif
   29543             : 
   29544             : #if USE_CPP_NEW_DELETE_OPERATORS
   29545             :     void *mem = ROSE_MALLOC(Size);
   29546             :     ALLOC_MUTEX(SgTypeComplex, unlock);
   29547             :     return mem;
   29548             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   29549             : #if ROSE_PEDANTIC_ALLOC
   29550             :     ROSE_ASSERT(Size == sizeof(SgTypeComplex));
   29551             : #else
   29552         982 :     if (Size != sizeof(SgTypeComplex)) {
   29553           0 :       void * object = ROSE_MALLOC(Size);
   29554           0 :       ALLOC_MUTEX(SgTypeComplex, unlock);
   29555             :       return object;
   29556             :     }
   29557             : #endif
   29558             : 
   29559         982 :     if (SgTypeComplex::next_node == nullptr) {
   29560         315 :         SgTypeComplex * alloc = (SgTypeComplex*) ROSE_MALLOC ( SgTypeComplex::pool_size * sizeof(SgTypeComplex) );
   29561         315 :         ROSE_ASSERT(alloc != nullptr);
   29562             : 
   29563             : #if ROSE_ALLOC_TRACE == 2
   29564             : //        printf("SgTypeComplex::alloc\n  block[%zi] = [ %p , %p [\n", SgTypeComplex::pools.size(), alloc, alloc + SgTypeComplex::pool_size);
   29565             : #endif
   29566             : 
   29567             : #if ROSE_ALLOC_MEMSET == 1
   29568             : #elif ROSE_ALLOC_MEMSET == 2
   29569             :         memset(alloc, 0x00, SgTypeComplex::pool_size * sizeof(SgTypeComplex));
   29570             : #elif ROSE_ALLOC_MEMSET == 3
   29571             :         memset(alloc, 0xAA, SgTypeComplex::pool_size * sizeof(SgTypeComplex));
   29572             : #endif
   29573      630000 :         for (unsigned i=0; i < SgTypeComplex::pool_size-1; i++) {
   29574      629685 :           alloc[i].p_freepointer = &(alloc[i+1]);
   29575             :         }
   29576         315 :         alloc[SgTypeComplex::pool_size-1].p_freepointer = nullptr;
   29577             : 
   29578         315 :         SgTypeComplex::pools.push_back ( (unsigned char *) alloc );
   29579         315 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgTypeComplex::pool_size * sizeof(SgTypeComplex), V_SgTypeComplex ) );
   29580         315 :         SgTypeComplex::next_node = alloc;
   29581             :     }
   29582         982 :     ROSE_ASSERT(SgTypeComplex::next_node != nullptr);
   29583             : 
   29584         982 :     SgTypeComplex * object = SgTypeComplex::next_node;
   29585         982 :     SgTypeComplex::next_node = (SgTypeComplex*)(object->p_freepointer);
   29586             : 
   29587             : #if ROSE_ALLOC_TRACE == 2
   29588             :     printf("SgTypeComplex::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeComplex::next_node);
   29589             : #endif
   29590             : 
   29591         982 :     SgNode * fp = object->p_freepointer;
   29592             : #if ROSE_ALLOC_MEMSET == 1
   29593             : #elif ROSE_ALLOC_MEMSET == 2
   29594             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgTypeComplex) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   29595             : #elif ROSE_ALLOC_MEMSET == 3
   29596             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgTypeComplex) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   29597             : #endif
   29598         982 :     object->p_freepointer = fp;
   29599             : 
   29600             : #if ROSE_ALLOC_TRACE == 2
   29601             : //    printf("SgTypeComplex::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeComplex::next_node);
   29602             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   29603             :     Rose::MemPool::snapshot(oss.str());
   29604             :     alloc_trace_cnt++;
   29605             : #endif
   29606             : 
   29607         982 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   29608             : 
   29609         982 :     ALLOC_MUTEX(SgTypeComplex, unlock);
   29610             : 
   29611             :     return object;
   29612             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   29613             : }
   29614             : 
   29615             : 
   29616             : 
   29617             : /*! \brief Delete operator for SgTypeComplex.
   29618             : 
   29619             :    This delete operator implements deallocation using memory pools to 
   29620             :    provide most efficent use of the heap within construction of large ASTs.
   29621             : 
   29622             : \internal The new and delete operators use the lower level C malloc/free
   29623             :    function calls for performance and to make sure that mixing of malloc/free
   29624             :    and new/delete by the used can be caught more readily.  This may change
   29625             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   29626             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   29627             :    deallocate memory allocated using ROSE_MALLOC.
   29628             : */
   29629          14 : void SgTypeComplex::operator delete(void *Pointer, size_t Size)
   29630             : {
   29631             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   29632             :      * or throwing an exception. */
   29633          14 :     ALLOC_MUTEX(SgTypeComplex, lock);
   29634             : 
   29635             : #if USE_CPP_NEW_DELETE_OPERATORS
   29636             :     ROSE_FREE(Pointer);
   29637             : #else
   29638             : #if ROSE_PEDANTIC_ALLOC
   29639             :     ROSE_ASSERT(Size == sizeof(SgTypeComplex));
   29640             : #else
   29641          14 :     if (Size != sizeof(SgTypeComplex)) {
   29642           0 :       ROSE_FREE(Pointer);
   29643           0 :       ALLOC_MUTEX(SgTypeComplex, unlock);
   29644             :       return;
   29645             :     }
   29646             : #endif
   29647             : 
   29648          14 :     SgTypeComplex * object = (SgTypeComplex*) Pointer;
   29649          14 :     ROSE_ASSERT(object != nullptr);
   29650             : 
   29651             : #if ROSE_ALLOC_TRACE == 2
   29652             : //  printf("SgTypeComplex::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeComplex::next_node);
   29653             :     printf("SgTypeComplex::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeComplex::next_node);
   29654             : #endif
   29655             : 
   29656             : #if ROSE_PEDANTIC_ALLOC
   29657             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   29658             : #endif
   29659             : 
   29660             : #if ROSE_ALLOC_MEMSET == 1
   29661             : #elif ROSE_ALLOC_MEMSET == 2
   29662             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgTypeComplex) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   29663             : #elif ROSE_ALLOC_MEMSET == 3
   29664             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgTypeComplex) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   29665             : #endif
   29666             : 
   29667             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   29668             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   29669             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   29670             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   29671             : #else
   29672          14 :     object->p_freepointer = SgTypeComplex::next_node;
   29673          14 :     SgTypeComplex::next_node = object;
   29674             : #endif
   29675             : 
   29676             : #if ROSE_ALLOC_TRACE == 2
   29677             : //  printf("SgTypeComplex::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeComplex::next_node);
   29678             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   29679             :     Rose::MemPool::snapshot(oss.str());
   29680             :     alloc_trace_cnt++;
   29681             : #endif
   29682             : 
   29683             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   29684             : 
   29685          14 :     ALLOC_MUTEX(SgTypeComplex, unlock);
   29686             : }
   29687             : 
   29688             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   29689             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   29690             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   29691             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   29692             : // Also, note comment below from Robb (copied from the Common.code file).
   29693             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   29694             : //
   29695             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   29696             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   29697             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   29698             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   29699             : #if 0
   29700             : void SgTypeComplex::operator delete(void* pointer) { SgTypeComplex::operator delete (pointer, sizeof(SgTypeComplex)); };
   29701             : #endif
   29702             : /* #line 29703 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   29703             : 
   29704             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   29705             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   29706             : // obviously imply C++.
   29707             : 
   29708             : // This implements the support within ROSE for memory pools.  Memory pools
   29709             : // support the most condensed usage of memory within the construction of
   29710             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   29711             : // by a new operator written for each class.
   29712             : 
   29713             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   29714             :     // User wants multi-thread support and POSIX threads are available.
   29715             : #   include <pthread.h>
   29716             :     static pthread_mutex_t SgTypeImaginary_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   29717             : #else
   29718             :      // Cause synchronization to be skipped.
   29719             : #    ifndef ALLOC_MUTEX
   29720             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   29721             : #    endif
   29722             : #    ifdef _REENTRANT
   29723             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   29724             : #       ifdef _MSC_VER
   29725             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   29726             : #       else
   29727             : #           warning "POSIX threads are not available; synchronization being skipped"
   29728             : #       endif
   29729             : #    endif
   29730             : #endif
   29731             : 
   29732             : #ifndef ROSE_ALLOC_TRACE
   29733             : #  define ROSE_ALLOC_TRACE 0
   29734             : #endif
   29735             : 
   29736             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   29737             : #define ROSE_ALLOC_TRACE_CNT
   29738             : #include "memory-pool-snapshot.h"
   29739             : unsigned long alloc_trace_cnt = 0;
   29740             : #endif
   29741             : 
   29742             : #if ROSE_ALLOC_TRACE
   29743             : const unsigned SgTypeImaginary::pool_size = 5;
   29744             : #else
   29745             : const unsigned SgTypeImaginary::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   29746             : #endif
   29747             : 
   29748             : #ifndef ROSE_ALLOC_MEMSET
   29749             : #  define ROSE_ALLOC_MEMSET 0
   29750             : #endif
   29751             : 
   29752             : #ifndef ROSE_PEDANTIC_ALLOC
   29753             : #  define ROSE_PEDANTIC_ALLOC 0
   29754             : #endif
   29755             : 
   29756             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   29757             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   29758             : #endif
   29759             : 
   29760             : #if !defined(SGNODE__ALL_POOLS)
   29761             : #define SGNODE__ALL_POOLS
   29762             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   29763             : #endif
   29764             : 
   29765             : SgTypeImaginary* SgTypeImaginary::next_node = nullptr;
   29766             : std::vector<unsigned char*> SgTypeImaginary::pools;
   29767             : 
   29768             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   29769             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   29770             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   29771             : // around this macro definition rather than each use).
   29772             : #ifndef ALLOC_MUTEX
   29773             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   29774             :         do {                                                                     \
   29775             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   29776             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   29777             :                 abort();                                                         \
   29778             :             }                                                                    \
   29779             :         } while (0);
   29780             : #endif
   29781             : 
   29782             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   29783             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   29784             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   29785             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   29786             : 
   29787             : /*! \brief New operator for SgTypeImaginary.
   29788             : 
   29789             :    This new operator implements memory pools to provide most efficent 
   29790             :    use of the heap within construction of large ASTs.
   29791             : 
   29792             : \internal The new and delete operators use the lower level C malloc/free
   29793             :    function calls for performance and to make sure that mixing of malloc/free
   29794             :    and new/delete by the used can be caught more readily.  This may change
   29795             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   29796             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   29797             :    deallocate memory allocated using ROSE_MALLOC.
   29798             : */
   29799           0 : void *SgTypeImaginary::operator new ( size_t Size )
   29800             : {
   29801             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   29802             :      * returning or throwing an exception. */
   29803           0 :     ALLOC_MUTEX(SgTypeImaginary, lock);
   29804             : 
   29805             : #if ROSE_ALLOC_TRACE == 2
   29806             : //    printf("SgTypeImaginary::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgTypeImaginary::next_node);
   29807             : #endif
   29808             : 
   29809             : #if USE_CPP_NEW_DELETE_OPERATORS
   29810             :     void *mem = ROSE_MALLOC(Size);
   29811             :     ALLOC_MUTEX(SgTypeImaginary, unlock);
   29812             :     return mem;
   29813             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   29814             : #if ROSE_PEDANTIC_ALLOC
   29815             :     ROSE_ASSERT(Size == sizeof(SgTypeImaginary));
   29816             : #else
   29817           0 :     if (Size != sizeof(SgTypeImaginary)) {
   29818           0 :       void * object = ROSE_MALLOC(Size);
   29819           0 :       ALLOC_MUTEX(SgTypeImaginary, unlock);
   29820             :       return object;
   29821             :     }
   29822             : #endif
   29823             : 
   29824           0 :     if (SgTypeImaginary::next_node == nullptr) {
   29825           0 :         SgTypeImaginary * alloc = (SgTypeImaginary*) ROSE_MALLOC ( SgTypeImaginary::pool_size * sizeof(SgTypeImaginary) );
   29826           0 :         ROSE_ASSERT(alloc != nullptr);
   29827             : 
   29828             : #if ROSE_ALLOC_TRACE == 2
   29829             : //        printf("SgTypeImaginary::alloc\n  block[%zi] = [ %p , %p [\n", SgTypeImaginary::pools.size(), alloc, alloc + SgTypeImaginary::pool_size);
   29830             : #endif
   29831             : 
   29832             : #if ROSE_ALLOC_MEMSET == 1
   29833             : #elif ROSE_ALLOC_MEMSET == 2
   29834             :         memset(alloc, 0x00, SgTypeImaginary::pool_size * sizeof(SgTypeImaginary));
   29835             : #elif ROSE_ALLOC_MEMSET == 3
   29836             :         memset(alloc, 0xAA, SgTypeImaginary::pool_size * sizeof(SgTypeImaginary));
   29837             : #endif
   29838           0 :         for (unsigned i=0; i < SgTypeImaginary::pool_size-1; i++) {
   29839           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
   29840             :         }
   29841           0 :         alloc[SgTypeImaginary::pool_size-1].p_freepointer = nullptr;
   29842             : 
   29843           0 :         SgTypeImaginary::pools.push_back ( (unsigned char *) alloc );
   29844           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgTypeImaginary::pool_size * sizeof(SgTypeImaginary), V_SgTypeImaginary ) );
   29845           0 :         SgTypeImaginary::next_node = alloc;
   29846             :     }
   29847           0 :     ROSE_ASSERT(SgTypeImaginary::next_node != nullptr);
   29848             : 
   29849           0 :     SgTypeImaginary * object = SgTypeImaginary::next_node;
   29850           0 :     SgTypeImaginary::next_node = (SgTypeImaginary*)(object->p_freepointer);
   29851             : 
   29852             : #if ROSE_ALLOC_TRACE == 2
   29853             :     printf("SgTypeImaginary::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeImaginary::next_node);
   29854             : #endif
   29855             : 
   29856           0 :     SgNode * fp = object->p_freepointer;
   29857             : #if ROSE_ALLOC_MEMSET == 1
   29858             : #elif ROSE_ALLOC_MEMSET == 2
   29859             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgTypeImaginary) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   29860             : #elif ROSE_ALLOC_MEMSET == 3
   29861             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgTypeImaginary) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   29862             : #endif
   29863           0 :     object->p_freepointer = fp;
   29864             : 
   29865             : #if ROSE_ALLOC_TRACE == 2
   29866             : //    printf("SgTypeImaginary::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeImaginary::next_node);
   29867             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   29868             :     Rose::MemPool::snapshot(oss.str());
   29869             :     alloc_trace_cnt++;
   29870             : #endif
   29871             : 
   29872           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   29873             : 
   29874           0 :     ALLOC_MUTEX(SgTypeImaginary, unlock);
   29875             : 
   29876             :     return object;
   29877             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   29878             : }
   29879             : 
   29880             : 
   29881             : 
   29882             : /*! \brief Delete operator for SgTypeImaginary.
   29883             : 
   29884             :    This delete operator implements deallocation using memory pools to 
   29885             :    provide most efficent use of the heap within construction of large ASTs.
   29886             : 
   29887             : \internal The new and delete operators use the lower level C malloc/free
   29888             :    function calls for performance and to make sure that mixing of malloc/free
   29889             :    and new/delete by the used can be caught more readily.  This may change
   29890             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   29891             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   29892             :    deallocate memory allocated using ROSE_MALLOC.
   29893             : */
   29894           0 : void SgTypeImaginary::operator delete(void *Pointer, size_t Size)
   29895             : {
   29896             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   29897             :      * or throwing an exception. */
   29898           0 :     ALLOC_MUTEX(SgTypeImaginary, lock);
   29899             : 
   29900             : #if USE_CPP_NEW_DELETE_OPERATORS
   29901             :     ROSE_FREE(Pointer);
   29902             : #else
   29903             : #if ROSE_PEDANTIC_ALLOC
   29904             :     ROSE_ASSERT(Size == sizeof(SgTypeImaginary));
   29905             : #else
   29906           0 :     if (Size != sizeof(SgTypeImaginary)) {
   29907           0 :       ROSE_FREE(Pointer);
   29908           0 :       ALLOC_MUTEX(SgTypeImaginary, unlock);
   29909             :       return;
   29910             :     }
   29911             : #endif
   29912             : 
   29913           0 :     SgTypeImaginary * object = (SgTypeImaginary*) Pointer;
   29914           0 :     ROSE_ASSERT(object != nullptr);
   29915             : 
   29916             : #if ROSE_ALLOC_TRACE == 2
   29917             : //  printf("SgTypeImaginary::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeImaginary::next_node);
   29918             :     printf("SgTypeImaginary::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeImaginary::next_node);
   29919             : #endif
   29920             : 
   29921             : #if ROSE_PEDANTIC_ALLOC
   29922             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   29923             : #endif
   29924             : 
   29925             : #if ROSE_ALLOC_MEMSET == 1
   29926             : #elif ROSE_ALLOC_MEMSET == 2
   29927             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgTypeImaginary) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   29928             : #elif ROSE_ALLOC_MEMSET == 3
   29929             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgTypeImaginary) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   29930             : #endif
   29931             : 
   29932             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   29933             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   29934             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   29935             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   29936             : #else
   29937           0 :     object->p_freepointer = SgTypeImaginary::next_node;
   29938           0 :     SgTypeImaginary::next_node = object;
   29939             : #endif
   29940             : 
   29941             : #if ROSE_ALLOC_TRACE == 2
   29942             : //  printf("SgTypeImaginary::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeImaginary::next_node);
   29943             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   29944             :     Rose::MemPool::snapshot(oss.str());
   29945             :     alloc_trace_cnt++;
   29946             : #endif
   29947             : 
   29948             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   29949             : 
   29950           0 :     ALLOC_MUTEX(SgTypeImaginary, unlock);
   29951             : }
   29952             : 
   29953             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   29954             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   29955             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   29956             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   29957             : // Also, note comment below from Robb (copied from the Common.code file).
   29958             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   29959             : //
   29960             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   29961             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   29962             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   29963             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   29964             : #if 0
   29965             : void SgTypeImaginary::operator delete(void* pointer) { SgTypeImaginary::operator delete (pointer, sizeof(SgTypeImaginary)); };
   29966             : #endif
   29967             : /* #line 29968 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   29968             : 
   29969             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   29970             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   29971             : // obviously imply C++.
   29972             : 
   29973             : // This implements the support within ROSE for memory pools.  Memory pools
   29974             : // support the most condensed usage of memory within the construction of
   29975             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   29976             : // by a new operator written for each class.
   29977             : 
   29978             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   29979             :     // User wants multi-thread support and POSIX threads are available.
   29980             : #   include <pthread.h>
   29981             :     static pthread_mutex_t SgTypeDefault_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   29982             : #else
   29983             :      // Cause synchronization to be skipped.
   29984             : #    ifndef ALLOC_MUTEX
   29985             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   29986             : #    endif
   29987             : #    ifdef _REENTRANT
   29988             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   29989             : #       ifdef _MSC_VER
   29990             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   29991             : #       else
   29992             : #           warning "POSIX threads are not available; synchronization being skipped"
   29993             : #       endif
   29994             : #    endif
   29995             : #endif
   29996             : 
   29997             : #ifndef ROSE_ALLOC_TRACE
   29998             : #  define ROSE_ALLOC_TRACE 0
   29999             : #endif
   30000             : 
   30001             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   30002             : #define ROSE_ALLOC_TRACE_CNT
   30003             : #include "memory-pool-snapshot.h"
   30004             : unsigned long alloc_trace_cnt = 0;
   30005             : #endif
   30006             : 
   30007             : #if ROSE_ALLOC_TRACE
   30008             : const unsigned SgTypeDefault::pool_size = 5;
   30009             : #else
   30010             : const unsigned SgTypeDefault::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   30011             : #endif
   30012             : 
   30013             : #ifndef ROSE_ALLOC_MEMSET
   30014             : #  define ROSE_ALLOC_MEMSET 0
   30015             : #endif
   30016             : 
   30017             : #ifndef ROSE_PEDANTIC_ALLOC
   30018             : #  define ROSE_PEDANTIC_ALLOC 0
   30019             : #endif
   30020             : 
   30021             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   30022             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   30023             : #endif
   30024             : 
   30025             : #if !defined(SGNODE__ALL_POOLS)
   30026             : #define SGNODE__ALL_POOLS
   30027             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   30028             : #endif
   30029             : 
   30030             : SgTypeDefault* SgTypeDefault::next_node = nullptr;
   30031             : std::vector<unsigned char*> SgTypeDefault::pools;
   30032             : 
   30033             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   30034             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   30035             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   30036             : // around this macro definition rather than each use).
   30037             : #ifndef ALLOC_MUTEX
   30038             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   30039             :         do {                                                                     \
   30040             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   30041             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   30042             :                 abort();                                                         \
   30043             :             }                                                                    \
   30044             :         } while (0);
   30045             : #endif
   30046             : 
   30047             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   30048             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   30049             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   30050             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   30051             : 
   30052             : /*! \brief New operator for SgTypeDefault.
   30053             : 
   30054             :    This new operator implements memory pools to provide most efficent 
   30055             :    use of the heap within construction of large ASTs.
   30056             : 
   30057             : \internal The new and delete operators use the lower level C malloc/free
   30058             :    function calls for performance and to make sure that mixing of malloc/free
   30059             :    and new/delete by the used can be caught more readily.  This may change
   30060             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   30061             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   30062             :    deallocate memory allocated using ROSE_MALLOC.
   30063             : */
   30064       34840 : void *SgTypeDefault::operator new ( size_t Size )
   30065             : {
   30066             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   30067             :      * returning or throwing an exception. */
   30068       34840 :     ALLOC_MUTEX(SgTypeDefault, lock);
   30069             : 
   30070             : #if ROSE_ALLOC_TRACE == 2
   30071             : //    printf("SgTypeDefault::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgTypeDefault::next_node);
   30072             : #endif
   30073             : 
   30074             : #if USE_CPP_NEW_DELETE_OPERATORS
   30075             :     void *mem = ROSE_MALLOC(Size);
   30076             :     ALLOC_MUTEX(SgTypeDefault, unlock);
   30077             :     return mem;
   30078             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   30079             : #if ROSE_PEDANTIC_ALLOC
   30080             :     ROSE_ASSERT(Size == sizeof(SgTypeDefault));
   30081             : #else
   30082       34840 :     if (Size != sizeof(SgTypeDefault)) {
   30083           0 :       void * object = ROSE_MALLOC(Size);
   30084           0 :       ALLOC_MUTEX(SgTypeDefault, unlock);
   30085             :       return object;
   30086             :     }
   30087             : #endif
   30088             : 
   30089       34840 :     if (SgTypeDefault::next_node == nullptr) {
   30090         348 :         SgTypeDefault * alloc = (SgTypeDefault*) ROSE_MALLOC ( SgTypeDefault::pool_size * sizeof(SgTypeDefault) );
   30091         348 :         ROSE_ASSERT(alloc != nullptr);
   30092             : 
   30093             : #if ROSE_ALLOC_TRACE == 2
   30094             : //        printf("SgTypeDefault::alloc\n  block[%zi] = [ %p , %p [\n", SgTypeDefault::pools.size(), alloc, alloc + SgTypeDefault::pool_size);
   30095             : #endif
   30096             : 
   30097             : #if ROSE_ALLOC_MEMSET == 1
   30098             : #elif ROSE_ALLOC_MEMSET == 2
   30099             :         memset(alloc, 0x00, SgTypeDefault::pool_size * sizeof(SgTypeDefault));
   30100             : #elif ROSE_ALLOC_MEMSET == 3
   30101             :         memset(alloc, 0xAA, SgTypeDefault::pool_size * sizeof(SgTypeDefault));
   30102             : #endif
   30103      696000 :         for (unsigned i=0; i < SgTypeDefault::pool_size-1; i++) {
   30104      695652 :           alloc[i].p_freepointer = &(alloc[i+1]);
   30105             :         }
   30106         348 :         alloc[SgTypeDefault::pool_size-1].p_freepointer = nullptr;
   30107             : 
   30108         348 :         SgTypeDefault::pools.push_back ( (unsigned char *) alloc );
   30109         348 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgTypeDefault::pool_size * sizeof(SgTypeDefault), V_SgTypeDefault ) );
   30110         348 :         SgTypeDefault::next_node = alloc;
   30111             :     }
   30112       34840 :     ROSE_ASSERT(SgTypeDefault::next_node != nullptr);
   30113             : 
   30114       34840 :     SgTypeDefault * object = SgTypeDefault::next_node;
   30115       34840 :     SgTypeDefault::next_node = (SgTypeDefault*)(object->p_freepointer);
   30116             : 
   30117             : #if ROSE_ALLOC_TRACE == 2
   30118             :     printf("SgTypeDefault::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeDefault::next_node);
   30119             : #endif
   30120             : 
   30121       34840 :     SgNode * fp = object->p_freepointer;
   30122             : #if ROSE_ALLOC_MEMSET == 1
   30123             : #elif ROSE_ALLOC_MEMSET == 2
   30124             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgTypeDefault) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   30125             : #elif ROSE_ALLOC_MEMSET == 3
   30126             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgTypeDefault) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   30127             : #endif
   30128       34840 :     object->p_freepointer = fp;
   30129             : 
   30130             : #if ROSE_ALLOC_TRACE == 2
   30131             : //    printf("SgTypeDefault::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeDefault::next_node);
   30132             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   30133             :     Rose::MemPool::snapshot(oss.str());
   30134             :     alloc_trace_cnt++;
   30135             : #endif
   30136             : 
   30137       34840 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   30138             : 
   30139       34840 :     ALLOC_MUTEX(SgTypeDefault, unlock);
   30140             : 
   30141             :     return object;
   30142             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   30143             : }
   30144             : 
   30145             : 
   30146             : 
   30147             : /*! \brief Delete operator for SgTypeDefault.
   30148             : 
   30149             :    This delete operator implements deallocation using memory pools to 
   30150             :    provide most efficent use of the heap within construction of large ASTs.
   30151             : 
   30152             : \internal The new and delete operators use the lower level C malloc/free
   30153             :    function calls for performance and to make sure that mixing of malloc/free
   30154             :    and new/delete by the used can be caught more readily.  This may change
   30155             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   30156             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   30157             :    deallocate memory allocated using ROSE_MALLOC.
   30158             : */
   30159       34213 : void SgTypeDefault::operator delete(void *Pointer, size_t Size)
   30160             : {
   30161             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   30162             :      * or throwing an exception. */
   30163       34213 :     ALLOC_MUTEX(SgTypeDefault, lock);
   30164             : 
   30165             : #if USE_CPP_NEW_DELETE_OPERATORS
   30166             :     ROSE_FREE(Pointer);
   30167             : #else
   30168             : #if ROSE_PEDANTIC_ALLOC
   30169             :     ROSE_ASSERT(Size == sizeof(SgTypeDefault));
   30170             : #else
   30171       34213 :     if (Size != sizeof(SgTypeDefault)) {
   30172           0 :       ROSE_FREE(Pointer);
   30173           0 :       ALLOC_MUTEX(SgTypeDefault, unlock);
   30174             :       return;
   30175             :     }
   30176             : #endif
   30177             : 
   30178       34213 :     SgTypeDefault * object = (SgTypeDefault*) Pointer;
   30179       34213 :     ROSE_ASSERT(object != nullptr);
   30180             : 
   30181             : #if ROSE_ALLOC_TRACE == 2
   30182             : //  printf("SgTypeDefault::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeDefault::next_node);
   30183             :     printf("SgTypeDefault::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeDefault::next_node);
   30184             : #endif
   30185             : 
   30186             : #if ROSE_PEDANTIC_ALLOC
   30187             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   30188             : #endif
   30189             : 
   30190             : #if ROSE_ALLOC_MEMSET == 1
   30191             : #elif ROSE_ALLOC_MEMSET == 2
   30192             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgTypeDefault) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   30193             : #elif ROSE_ALLOC_MEMSET == 3
   30194             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgTypeDefault) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   30195             : #endif
   30196             : 
   30197             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   30198             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   30199             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   30200             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   30201             : #else
   30202       34213 :     object->p_freepointer = SgTypeDefault::next_node;
   30203       34213 :     SgTypeDefault::next_node = object;
   30204             : #endif
   30205             : 
   30206             : #if ROSE_ALLOC_TRACE == 2
   30207             : //  printf("SgTypeDefault::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeDefault::next_node);
   30208             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   30209             :     Rose::MemPool::snapshot(oss.str());
   30210             :     alloc_trace_cnt++;
   30211             : #endif
   30212             : 
   30213             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   30214             : 
   30215       34213 :     ALLOC_MUTEX(SgTypeDefault, unlock);
   30216             : }
   30217             : 
   30218             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   30219             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   30220             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   30221             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   30222             : // Also, note comment below from Robb (copied from the Common.code file).
   30223             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   30224             : //
   30225             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   30226             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   30227             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   30228             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   30229             : #if 0
   30230             : void SgTypeDefault::operator delete(void* pointer) { SgTypeDefault::operator delete (pointer, sizeof(SgTypeDefault)); };
   30231             : #endif
   30232             : /* #line 30233 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   30233             : 
   30234             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   30235             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   30236             : // obviously imply C++.
   30237             : 
   30238             : // This implements the support within ROSE for memory pools.  Memory pools
   30239             : // support the most condensed usage of memory within the construction of
   30240             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   30241             : // by a new operator written for each class.
   30242             : 
   30243             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   30244             :     // User wants multi-thread support and POSIX threads are available.
   30245             : #   include <pthread.h>
   30246             :     static pthread_mutex_t SgTypeCAFTeam_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   30247             : #else
   30248             :      // Cause synchronization to be skipped.
   30249             : #    ifndef ALLOC_MUTEX
   30250             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   30251             : #    endif
   30252             : #    ifdef _REENTRANT
   30253             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   30254             : #       ifdef _MSC_VER
   30255             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   30256             : #       else
   30257             : #           warning "POSIX threads are not available; synchronization being skipped"
   30258             : #       endif
   30259             : #    endif
   30260             : #endif
   30261             : 
   30262             : #ifndef ROSE_ALLOC_TRACE
   30263             : #  define ROSE_ALLOC_TRACE 0
   30264             : #endif
   30265             : 
   30266             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   30267             : #define ROSE_ALLOC_TRACE_CNT
   30268             : #include "memory-pool-snapshot.h"
   30269             : unsigned long alloc_trace_cnt = 0;
   30270             : #endif
   30271             : 
   30272             : #if ROSE_ALLOC_TRACE
   30273             : const unsigned SgTypeCAFTeam::pool_size = 5;
   30274             : #else
   30275             : const unsigned SgTypeCAFTeam::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   30276             : #endif
   30277             : 
   30278             : #ifndef ROSE_ALLOC_MEMSET
   30279             : #  define ROSE_ALLOC_MEMSET 0
   30280             : #endif
   30281             : 
   30282             : #ifndef ROSE_PEDANTIC_ALLOC
   30283             : #  define ROSE_PEDANTIC_ALLOC 0
   30284             : #endif
   30285             : 
   30286             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   30287             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   30288             : #endif
   30289             : 
   30290             : #if !defined(SGNODE__ALL_POOLS)
   30291             : #define SGNODE__ALL_POOLS
   30292             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   30293             : #endif
   30294             : 
   30295             : SgTypeCAFTeam* SgTypeCAFTeam::next_node = nullptr;
   30296             : std::vector<unsigned char*> SgTypeCAFTeam::pools;
   30297             : 
   30298             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   30299             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   30300             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   30301             : // around this macro definition rather than each use).
   30302             : #ifndef ALLOC_MUTEX
   30303             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   30304             :         do {                                                                     \
   30305             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   30306             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   30307             :                 abort();                                                         \
   30308             :             }                                                                    \
   30309             :         } while (0);
   30310             : #endif
   30311             : 
   30312             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   30313             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   30314             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   30315             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   30316             : 
   30317             : /*! \brief New operator for SgTypeCAFTeam.
   30318             : 
   30319             :    This new operator implements memory pools to provide most efficent 
   30320             :    use of the heap within construction of large ASTs.
   30321             : 
   30322             : \internal The new and delete operators use the lower level C malloc/free
   30323             :    function calls for performance and to make sure that mixing of malloc/free
   30324             :    and new/delete by the used can be caught more readily.  This may change
   30325             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   30326             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   30327             :    deallocate memory allocated using ROSE_MALLOC.
   30328             : */
   30329           0 : void *SgTypeCAFTeam::operator new ( size_t Size )
   30330             : {
   30331             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   30332             :      * returning or throwing an exception. */
   30333           0 :     ALLOC_MUTEX(SgTypeCAFTeam, lock);
   30334             : 
   30335             : #if ROSE_ALLOC_TRACE == 2
   30336             : //    printf("SgTypeCAFTeam::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgTypeCAFTeam::next_node);
   30337             : #endif
   30338             : 
   30339             : #if USE_CPP_NEW_DELETE_OPERATORS
   30340             :     void *mem = ROSE_MALLOC(Size);
   30341             :     ALLOC_MUTEX(SgTypeCAFTeam, unlock);
   30342             :     return mem;
   30343             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   30344             : #if ROSE_PEDANTIC_ALLOC
   30345             :     ROSE_ASSERT(Size == sizeof(SgTypeCAFTeam));
   30346             : #else
   30347           0 :     if (Size != sizeof(SgTypeCAFTeam)) {
   30348           0 :       void * object = ROSE_MALLOC(Size);
   30349           0 :       ALLOC_MUTEX(SgTypeCAFTeam, unlock);
   30350             :       return object;
   30351             :     }
   30352             : #endif
   30353             : 
   30354           0 :     if (SgTypeCAFTeam::next_node == nullptr) {
   30355           0 :         SgTypeCAFTeam * alloc = (SgTypeCAFTeam*) ROSE_MALLOC ( SgTypeCAFTeam::pool_size * sizeof(SgTypeCAFTeam) );
   30356           0 :         ROSE_ASSERT(alloc != nullptr);
   30357             : 
   30358             : #if ROSE_ALLOC_TRACE == 2
   30359             : //        printf("SgTypeCAFTeam::alloc\n  block[%zi] = [ %p , %p [\n", SgTypeCAFTeam::pools.size(), alloc, alloc + SgTypeCAFTeam::pool_size);
   30360             : #endif
   30361             : 
   30362             : #if ROSE_ALLOC_MEMSET == 1
   30363             : #elif ROSE_ALLOC_MEMSET == 2
   30364             :         memset(alloc, 0x00, SgTypeCAFTeam::pool_size * sizeof(SgTypeCAFTeam));
   30365             : #elif ROSE_ALLOC_MEMSET == 3
   30366             :         memset(alloc, 0xAA, SgTypeCAFTeam::pool_size * sizeof(SgTypeCAFTeam));
   30367             : #endif
   30368           0 :         for (unsigned i=0; i < SgTypeCAFTeam::pool_size-1; i++) {
   30369           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
   30370             :         }
   30371           0 :         alloc[SgTypeCAFTeam::pool_size-1].p_freepointer = nullptr;
   30372             : 
   30373           0 :         SgTypeCAFTeam::pools.push_back ( (unsigned char *) alloc );
   30374           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgTypeCAFTeam::pool_size * sizeof(SgTypeCAFTeam), V_SgTypeCAFTeam ) );
   30375           0 :         SgTypeCAFTeam::next_node = alloc;
   30376             :     }
   30377           0 :     ROSE_ASSERT(SgTypeCAFTeam::next_node != nullptr);
   30378             : 
   30379           0 :     SgTypeCAFTeam * object = SgTypeCAFTeam::next_node;
   30380           0 :     SgTypeCAFTeam::next_node = (SgTypeCAFTeam*)(object->p_freepointer);
   30381             : 
   30382             : #if ROSE_ALLOC_TRACE == 2
   30383             :     printf("SgTypeCAFTeam::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeCAFTeam::next_node);
   30384             : #endif
   30385             : 
   30386           0 :     SgNode * fp = object->p_freepointer;
   30387             : #if ROSE_ALLOC_MEMSET == 1
   30388             : #elif ROSE_ALLOC_MEMSET == 2
   30389             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgTypeCAFTeam) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   30390             : #elif ROSE_ALLOC_MEMSET == 3
   30391             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgTypeCAFTeam) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   30392             : #endif
   30393           0 :     object->p_freepointer = fp;
   30394             : 
   30395             : #if ROSE_ALLOC_TRACE == 2
   30396             : //    printf("SgTypeCAFTeam::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeCAFTeam::next_node);
   30397             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   30398             :     Rose::MemPool::snapshot(oss.str());
   30399             :     alloc_trace_cnt++;
   30400             : #endif
   30401             : 
   30402           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   30403             : 
   30404           0 :     ALLOC_MUTEX(SgTypeCAFTeam, unlock);
   30405             : 
   30406             :     return object;
   30407             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   30408             : }
   30409             : 
   30410             : 
   30411             : 
   30412             : /*! \brief Delete operator for SgTypeCAFTeam.
   30413             : 
   30414             :    This delete operator implements deallocation using memory pools to 
   30415             :    provide most efficent use of the heap within construction of large ASTs.
   30416             : 
   30417             : \internal The new and delete operators use the lower level C malloc/free
   30418             :    function calls for performance and to make sure that mixing of malloc/free
   30419             :    and new/delete by the used can be caught more readily.  This may change
   30420             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   30421             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   30422             :    deallocate memory allocated using ROSE_MALLOC.
   30423             : */
   30424           0 : void SgTypeCAFTeam::operator delete(void *Pointer, size_t Size)
   30425             : {
   30426             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   30427             :      * or throwing an exception. */
   30428           0 :     ALLOC_MUTEX(SgTypeCAFTeam, lock);
   30429             : 
   30430             : #if USE_CPP_NEW_DELETE_OPERATORS
   30431             :     ROSE_FREE(Pointer);
   30432             : #else
   30433             : #if ROSE_PEDANTIC_ALLOC
   30434             :     ROSE_ASSERT(Size == sizeof(SgTypeCAFTeam));
   30435             : #else
   30436           0 :     if (Size != sizeof(SgTypeCAFTeam)) {
   30437           0 :       ROSE_FREE(Pointer);
   30438           0 :       ALLOC_MUTEX(SgTypeCAFTeam, unlock);
   30439             :       return;
   30440             :     }
   30441             : #endif
   30442             : 
   30443           0 :     SgTypeCAFTeam * object = (SgTypeCAFTeam*) Pointer;
   30444           0 :     ROSE_ASSERT(object != nullptr);
   30445             : 
   30446             : #if ROSE_ALLOC_TRACE == 2
   30447             : //  printf("SgTypeCAFTeam::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeCAFTeam::next_node);
   30448             :     printf("SgTypeCAFTeam::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeCAFTeam::next_node);
   30449             : #endif
   30450             : 
   30451             : #if ROSE_PEDANTIC_ALLOC
   30452             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   30453             : #endif
   30454             : 
   30455             : #if ROSE_ALLOC_MEMSET == 1
   30456             : #elif ROSE_ALLOC_MEMSET == 2
   30457             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgTypeCAFTeam) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   30458             : #elif ROSE_ALLOC_MEMSET == 3
   30459             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgTypeCAFTeam) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   30460             : #endif
   30461             : 
   30462             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   30463             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   30464             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   30465             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   30466             : #else
   30467           0 :     object->p_freepointer = SgTypeCAFTeam::next_node;
   30468           0 :     SgTypeCAFTeam::next_node = object;
   30469             : #endif
   30470             : 
   30471             : #if ROSE_ALLOC_TRACE == 2
   30472             : //  printf("SgTypeCAFTeam::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeCAFTeam::next_node);
   30473             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   30474             :     Rose::MemPool::snapshot(oss.str());
   30475             :     alloc_trace_cnt++;
   30476             : #endif
   30477             : 
   30478             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   30479             : 
   30480           0 :     ALLOC_MUTEX(SgTypeCAFTeam, unlock);
   30481             : }
   30482             : 
   30483             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   30484             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   30485             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   30486             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   30487             : // Also, note comment below from Robb (copied from the Common.code file).
   30488             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   30489             : //
   30490             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   30491             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   30492             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   30493             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   30494             : #if 0
   30495             : void SgTypeCAFTeam::operator delete(void* pointer) { SgTypeCAFTeam::operator delete (pointer, sizeof(SgTypeCAFTeam)); };
   30496             : #endif
   30497             : /* #line 30498 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   30498             : 
   30499             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   30500             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   30501             : // obviously imply C++.
   30502             : 
   30503             : // This implements the support within ROSE for memory pools.  Memory pools
   30504             : // support the most condensed usage of memory within the construction of
   30505             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   30506             : // by a new operator written for each class.
   30507             : 
   30508             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   30509             :     // User wants multi-thread support and POSIX threads are available.
   30510             : #   include <pthread.h>
   30511             :     static pthread_mutex_t SgTypeCrayPointer_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   30512             : #else
   30513             :      // Cause synchronization to be skipped.
   30514             : #    ifndef ALLOC_MUTEX
   30515             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   30516             : #    endif
   30517             : #    ifdef _REENTRANT
   30518             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   30519             : #       ifdef _MSC_VER
   30520             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   30521             : #       else
   30522             : #           warning "POSIX threads are not available; synchronization being skipped"
   30523             : #       endif
   30524             : #    endif
   30525             : #endif
   30526             : 
   30527             : #ifndef ROSE_ALLOC_TRACE
   30528             : #  define ROSE_ALLOC_TRACE 0
   30529             : #endif
   30530             : 
   30531             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   30532             : #define ROSE_ALLOC_TRACE_CNT
   30533             : #include "memory-pool-snapshot.h"
   30534             : unsigned long alloc_trace_cnt = 0;
   30535             : #endif
   30536             : 
   30537             : #if ROSE_ALLOC_TRACE
   30538             : const unsigned SgTypeCrayPointer::pool_size = 5;
   30539             : #else
   30540             : const unsigned SgTypeCrayPointer::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   30541             : #endif
   30542             : 
   30543             : #ifndef ROSE_ALLOC_MEMSET
   30544             : #  define ROSE_ALLOC_MEMSET 0
   30545             : #endif
   30546             : 
   30547             : #ifndef ROSE_PEDANTIC_ALLOC
   30548             : #  define ROSE_PEDANTIC_ALLOC 0
   30549             : #endif
   30550             : 
   30551             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   30552             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   30553             : #endif
   30554             : 
   30555             : #if !defined(SGNODE__ALL_POOLS)
   30556             : #define SGNODE__ALL_POOLS
   30557             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   30558             : #endif
   30559             : 
   30560             : SgTypeCrayPointer* SgTypeCrayPointer::next_node = nullptr;
   30561             : std::vector<unsigned char*> SgTypeCrayPointer::pools;
   30562             : 
   30563             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   30564             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   30565             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   30566             : // around this macro definition rather than each use).
   30567             : #ifndef ALLOC_MUTEX
   30568             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   30569             :         do {                                                                     \
   30570             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   30571             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   30572             :                 abort();                                                         \
   30573             :             }                                                                    \
   30574             :         } while (0);
   30575             : #endif
   30576             : 
   30577             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   30578             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   30579             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   30580             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   30581             : 
   30582             : /*! \brief New operator for SgTypeCrayPointer.
   30583             : 
   30584             :    This new operator implements memory pools to provide most efficent 
   30585             :    use of the heap within construction of large ASTs.
   30586             : 
   30587             : \internal The new and delete operators use the lower level C malloc/free
   30588             :    function calls for performance and to make sure that mixing of malloc/free
   30589             :    and new/delete by the used can be caught more readily.  This may change
   30590             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   30591             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   30592             :    deallocate memory allocated using ROSE_MALLOC.
   30593             : */
   30594           0 : void *SgTypeCrayPointer::operator new ( size_t Size )
   30595             : {
   30596             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   30597             :      * returning or throwing an exception. */
   30598           0 :     ALLOC_MUTEX(SgTypeCrayPointer, lock);
   30599             : 
   30600             : #if ROSE_ALLOC_TRACE == 2
   30601             : //    printf("SgTypeCrayPointer::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgTypeCrayPointer::next_node);
   30602             : #endif
   30603             : 
   30604             : #if USE_CPP_NEW_DELETE_OPERATORS
   30605             :     void *mem = ROSE_MALLOC(Size);
   30606             :     ALLOC_MUTEX(SgTypeCrayPointer, unlock);
   30607             :     return mem;
   30608             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   30609             : #if ROSE_PEDANTIC_ALLOC
   30610             :     ROSE_ASSERT(Size == sizeof(SgTypeCrayPointer));
   30611             : #else
   30612           0 :     if (Size != sizeof(SgTypeCrayPointer)) {
   30613           0 :       void * object = ROSE_MALLOC(Size);
   30614           0 :       ALLOC_MUTEX(SgTypeCrayPointer, unlock);
   30615             :       return object;
   30616             :     }
   30617             : #endif
   30618             : 
   30619           0 :     if (SgTypeCrayPointer::next_node == nullptr) {
   30620           0 :         SgTypeCrayPointer * alloc = (SgTypeCrayPointer*) ROSE_MALLOC ( SgTypeCrayPointer::pool_size * sizeof(SgTypeCrayPointer) );
   30621           0 :         ROSE_ASSERT(alloc != nullptr);
   30622             : 
   30623             : #if ROSE_ALLOC_TRACE == 2
   30624             : //        printf("SgTypeCrayPointer::alloc\n  block[%zi] = [ %p , %p [\n", SgTypeCrayPointer::pools.size(), alloc, alloc + SgTypeCrayPointer::pool_size);
   30625             : #endif
   30626             : 
   30627             : #if ROSE_ALLOC_MEMSET == 1
   30628             : #elif ROSE_ALLOC_MEMSET == 2
   30629             :         memset(alloc, 0x00, SgTypeCrayPointer::pool_size * sizeof(SgTypeCrayPointer));
   30630             : #elif ROSE_ALLOC_MEMSET == 3
   30631             :         memset(alloc, 0xAA, SgTypeCrayPointer::pool_size * sizeof(SgTypeCrayPointer));
   30632             : #endif
   30633           0 :         for (unsigned i=0; i < SgTypeCrayPointer::pool_size-1; i++) {
   30634           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
   30635             :         }
   30636           0 :         alloc[SgTypeCrayPointer::pool_size-1].p_freepointer = nullptr;
   30637             : 
   30638           0 :         SgTypeCrayPointer::pools.push_back ( (unsigned char *) alloc );
   30639           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgTypeCrayPointer::pool_size * sizeof(SgTypeCrayPointer), V_SgTypeCrayPointer ) );
   30640           0 :         SgTypeCrayPointer::next_node = alloc;
   30641             :     }
   30642           0 :     ROSE_ASSERT(SgTypeCrayPointer::next_node != nullptr);
   30643             : 
   30644           0 :     SgTypeCrayPointer * object = SgTypeCrayPointer::next_node;
   30645           0 :     SgTypeCrayPointer::next_node = (SgTypeCrayPointer*)(object->p_freepointer);
   30646             : 
   30647             : #if ROSE_ALLOC_TRACE == 2
   30648             :     printf("SgTypeCrayPointer::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeCrayPointer::next_node);
   30649             : #endif
   30650             : 
   30651           0 :     SgNode * fp = object->p_freepointer;
   30652             : #if ROSE_ALLOC_MEMSET == 1
   30653             : #elif ROSE_ALLOC_MEMSET == 2
   30654             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgTypeCrayPointer) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   30655             : #elif ROSE_ALLOC_MEMSET == 3
   30656             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgTypeCrayPointer) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   30657             : #endif
   30658           0 :     object->p_freepointer = fp;
   30659             : 
   30660             : #if ROSE_ALLOC_TRACE == 2
   30661             : //    printf("SgTypeCrayPointer::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeCrayPointer::next_node);
   30662             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   30663             :     Rose::MemPool::snapshot(oss.str());
   30664             :     alloc_trace_cnt++;
   30665             : #endif
   30666             : 
   30667           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   30668             : 
   30669           0 :     ALLOC_MUTEX(SgTypeCrayPointer, unlock);
   30670             : 
   30671             :     return object;
   30672             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   30673             : }
   30674             : 
   30675             : 
   30676             : 
   30677             : /*! \brief Delete operator for SgTypeCrayPointer.
   30678             : 
   30679             :    This delete operator implements deallocation using memory pools to 
   30680             :    provide most efficent use of the heap within construction of large ASTs.
   30681             : 
   30682             : \internal The new and delete operators use the lower level C malloc/free
   30683             :    function calls for performance and to make sure that mixing of malloc/free
   30684             :    and new/delete by the used can be caught more readily.  This may change
   30685             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   30686             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   30687             :    deallocate memory allocated using ROSE_MALLOC.
   30688             : */
   30689           0 : void SgTypeCrayPointer::operator delete(void *Pointer, size_t Size)
   30690             : {
   30691             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   30692             :      * or throwing an exception. */
   30693           0 :     ALLOC_MUTEX(SgTypeCrayPointer, lock);
   30694             : 
   30695             : #if USE_CPP_NEW_DELETE_OPERATORS
   30696             :     ROSE_FREE(Pointer);
   30697             : #else
   30698             : #if ROSE_PEDANTIC_ALLOC
   30699             :     ROSE_ASSERT(Size == sizeof(SgTypeCrayPointer));
   30700             : #else
   30701           0 :     if (Size != sizeof(SgTypeCrayPointer)) {
   30702           0 :       ROSE_FREE(Pointer);
   30703           0 :       ALLOC_MUTEX(SgTypeCrayPointer, unlock);
   30704             :       return;
   30705             :     }
   30706             : #endif
   30707             : 
   30708           0 :     SgTypeCrayPointer * object = (SgTypeCrayPointer*) Pointer;
   30709           0 :     ROSE_ASSERT(object != nullptr);
   30710             : 
   30711             : #if ROSE_ALLOC_TRACE == 2
   30712             : //  printf("SgTypeCrayPointer::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeCrayPointer::next_node);
   30713             :     printf("SgTypeCrayPointer::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeCrayPointer::next_node);
   30714             : #endif
   30715             : 
   30716             : #if ROSE_PEDANTIC_ALLOC
   30717             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   30718             : #endif
   30719             : 
   30720             : #if ROSE_ALLOC_MEMSET == 1
   30721             : #elif ROSE_ALLOC_MEMSET == 2
   30722             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgTypeCrayPointer) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   30723             : #elif ROSE_ALLOC_MEMSET == 3
   30724             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgTypeCrayPointer) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   30725             : #endif
   30726             : 
   30727             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   30728             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   30729             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   30730             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   30731             : #else
   30732           0 :     object->p_freepointer = SgTypeCrayPointer::next_node;
   30733           0 :     SgTypeCrayPointer::next_node = object;
   30734             : #endif
   30735             : 
   30736             : #if ROSE_ALLOC_TRACE == 2
   30737             : //  printf("SgTypeCrayPointer::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeCrayPointer::next_node);
   30738             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   30739             :     Rose::MemPool::snapshot(oss.str());
   30740             :     alloc_trace_cnt++;
   30741             : #endif
   30742             : 
   30743             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   30744             : 
   30745           0 :     ALLOC_MUTEX(SgTypeCrayPointer, unlock);
   30746             : }
   30747             : 
   30748             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   30749             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   30750             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   30751             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   30752             : // Also, note comment below from Robb (copied from the Common.code file).
   30753             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   30754             : //
   30755             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   30756             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   30757             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   30758             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   30759             : #if 0
   30760             : void SgTypeCrayPointer::operator delete(void* pointer) { SgTypeCrayPointer::operator delete (pointer, sizeof(SgTypeCrayPointer)); };
   30761             : #endif
   30762             : /* #line 30763 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   30763             : 
   30764             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   30765             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   30766             : // obviously imply C++.
   30767             : 
   30768             : // This implements the support within ROSE for memory pools.  Memory pools
   30769             : // support the most condensed usage of memory within the construction of
   30770             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   30771             : // by a new operator written for each class.
   30772             : 
   30773             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   30774             :     // User wants multi-thread support and POSIX threads are available.
   30775             : #   include <pthread.h>
   30776             :     static pthread_mutex_t SgTypeLabel_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   30777             : #else
   30778             :      // Cause synchronization to be skipped.
   30779             : #    ifndef ALLOC_MUTEX
   30780             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   30781             : #    endif
   30782             : #    ifdef _REENTRANT
   30783             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   30784             : #       ifdef _MSC_VER
   30785             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   30786             : #       else
   30787             : #           warning "POSIX threads are not available; synchronization being skipped"
   30788             : #       endif
   30789             : #    endif
   30790             : #endif
   30791             : 
   30792             : #ifndef ROSE_ALLOC_TRACE
   30793             : #  define ROSE_ALLOC_TRACE 0
   30794             : #endif
   30795             : 
   30796             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   30797             : #define ROSE_ALLOC_TRACE_CNT
   30798             : #include "memory-pool-snapshot.h"
   30799             : unsigned long alloc_trace_cnt = 0;
   30800             : #endif
   30801             : 
   30802             : #if ROSE_ALLOC_TRACE
   30803             : const unsigned SgTypeLabel::pool_size = 5;
   30804             : #else
   30805             : const unsigned SgTypeLabel::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   30806             : #endif
   30807             : 
   30808             : #ifndef ROSE_ALLOC_MEMSET
   30809             : #  define ROSE_ALLOC_MEMSET 0
   30810             : #endif
   30811             : 
   30812             : #ifndef ROSE_PEDANTIC_ALLOC
   30813             : #  define ROSE_PEDANTIC_ALLOC 0
   30814             : #endif
   30815             : 
   30816             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   30817             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   30818             : #endif
   30819             : 
   30820             : #if !defined(SGNODE__ALL_POOLS)
   30821             : #define SGNODE__ALL_POOLS
   30822             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   30823             : #endif
   30824             : 
   30825             : SgTypeLabel* SgTypeLabel::next_node = nullptr;
   30826             : std::vector<unsigned char*> SgTypeLabel::pools;
   30827             : 
   30828             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   30829             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   30830             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   30831             : // around this macro definition rather than each use).
   30832             : #ifndef ALLOC_MUTEX
   30833             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   30834             :         do {                                                                     \
   30835             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   30836             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   30837             :                 abort();                                                         \
   30838             :             }                                                                    \
   30839             :         } while (0);
   30840             : #endif
   30841             : 
   30842             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   30843             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   30844             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   30845             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   30846             : 
   30847             : /*! \brief New operator for SgTypeLabel.
   30848             : 
   30849             :    This new operator implements memory pools to provide most efficent 
   30850             :    use of the heap within construction of large ASTs.
   30851             : 
   30852             : \internal The new and delete operators use the lower level C malloc/free
   30853             :    function calls for performance and to make sure that mixing of malloc/free
   30854             :    and new/delete by the used can be caught more readily.  This may change
   30855             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   30856             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   30857             :    deallocate memory allocated using ROSE_MALLOC.
   30858             : */
   30859           0 : void *SgTypeLabel::operator new ( size_t Size )
   30860             : {
   30861             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   30862             :      * returning or throwing an exception. */
   30863           0 :     ALLOC_MUTEX(SgTypeLabel, lock);
   30864             : 
   30865             : #if ROSE_ALLOC_TRACE == 2
   30866             : //    printf("SgTypeLabel::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgTypeLabel::next_node);
   30867             : #endif
   30868             : 
   30869             : #if USE_CPP_NEW_DELETE_OPERATORS
   30870             :     void *mem = ROSE_MALLOC(Size);
   30871             :     ALLOC_MUTEX(SgTypeLabel, unlock);
   30872             :     return mem;
   30873             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   30874             : #if ROSE_PEDANTIC_ALLOC
   30875             :     ROSE_ASSERT(Size == sizeof(SgTypeLabel));
   30876             : #else
   30877           0 :     if (Size != sizeof(SgTypeLabel)) {
   30878           0 :       void * object = ROSE_MALLOC(Size);
   30879           0 :       ALLOC_MUTEX(SgTypeLabel, unlock);
   30880             :       return object;
   30881             :     }
   30882             : #endif
   30883             : 
   30884           0 :     if (SgTypeLabel::next_node == nullptr) {
   30885           0 :         SgTypeLabel * alloc = (SgTypeLabel*) ROSE_MALLOC ( SgTypeLabel::pool_size * sizeof(SgTypeLabel) );
   30886           0 :         ROSE_ASSERT(alloc != nullptr);
   30887             : 
   30888             : #if ROSE_ALLOC_TRACE == 2
   30889             : //        printf("SgTypeLabel::alloc\n  block[%zi] = [ %p , %p [\n", SgTypeLabel::pools.size(), alloc, alloc + SgTypeLabel::pool_size);
   30890             : #endif
   30891             : 
   30892             : #if ROSE_ALLOC_MEMSET == 1
   30893             : #elif ROSE_ALLOC_MEMSET == 2
   30894             :         memset(alloc, 0x00, SgTypeLabel::pool_size * sizeof(SgTypeLabel));
   30895             : #elif ROSE_ALLOC_MEMSET == 3
   30896             :         memset(alloc, 0xAA, SgTypeLabel::pool_size * sizeof(SgTypeLabel));
   30897             : #endif
   30898           0 :         for (unsigned i=0; i < SgTypeLabel::pool_size-1; i++) {
   30899           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
   30900             :         }
   30901           0 :         alloc[SgTypeLabel::pool_size-1].p_freepointer = nullptr;
   30902             : 
   30903           0 :         SgTypeLabel::pools.push_back ( (unsigned char *) alloc );
   30904           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgTypeLabel::pool_size * sizeof(SgTypeLabel), V_SgTypeLabel ) );
   30905           0 :         SgTypeLabel::next_node = alloc;
   30906             :     }
   30907           0 :     ROSE_ASSERT(SgTypeLabel::next_node != nullptr);
   30908             : 
   30909           0 :     SgTypeLabel * object = SgTypeLabel::next_node;
   30910           0 :     SgTypeLabel::next_node = (SgTypeLabel*)(object->p_freepointer);
   30911             : 
   30912             : #if ROSE_ALLOC_TRACE == 2
   30913             :     printf("SgTypeLabel::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeLabel::next_node);
   30914             : #endif
   30915             : 
   30916           0 :     SgNode * fp = object->p_freepointer;
   30917             : #if ROSE_ALLOC_MEMSET == 1
   30918             : #elif ROSE_ALLOC_MEMSET == 2
   30919             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgTypeLabel) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   30920             : #elif ROSE_ALLOC_MEMSET == 3
   30921             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgTypeLabel) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   30922             : #endif
   30923           0 :     object->p_freepointer = fp;
   30924             : 
   30925             : #if ROSE_ALLOC_TRACE == 2
   30926             : //    printf("SgTypeLabel::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeLabel::next_node);
   30927             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   30928             :     Rose::MemPool::snapshot(oss.str());
   30929             :     alloc_trace_cnt++;
   30930             : #endif
   30931             : 
   30932           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   30933             : 
   30934           0 :     ALLOC_MUTEX(SgTypeLabel, unlock);
   30935             : 
   30936             :     return object;
   30937             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   30938             : }
   30939             : 
   30940             : 
   30941             : 
   30942             : /*! \brief Delete operator for SgTypeLabel.
   30943             : 
   30944             :    This delete operator implements deallocation using memory pools to 
   30945             :    provide most efficent use of the heap within construction of large ASTs.
   30946             : 
   30947             : \internal The new and delete operators use the lower level C malloc/free
   30948             :    function calls for performance and to make sure that mixing of malloc/free
   30949             :    and new/delete by the used can be caught more readily.  This may change
   30950             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   30951             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   30952             :    deallocate memory allocated using ROSE_MALLOC.
   30953             : */
   30954           0 : void SgTypeLabel::operator delete(void *Pointer, size_t Size)
   30955             : {
   30956             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   30957             :      * or throwing an exception. */
   30958           0 :     ALLOC_MUTEX(SgTypeLabel, lock);
   30959             : 
   30960             : #if USE_CPP_NEW_DELETE_OPERATORS
   30961             :     ROSE_FREE(Pointer);
   30962             : #else
   30963             : #if ROSE_PEDANTIC_ALLOC
   30964             :     ROSE_ASSERT(Size == sizeof(SgTypeLabel));
   30965             : #else
   30966           0 :     if (Size != sizeof(SgTypeLabel)) {
   30967           0 :       ROSE_FREE(Pointer);
   30968           0 :       ALLOC_MUTEX(SgTypeLabel, unlock);
   30969             :       return;
   30970             :     }
   30971             : #endif
   30972             : 
   30973           0 :     SgTypeLabel * object = (SgTypeLabel*) Pointer;
   30974           0 :     ROSE_ASSERT(object != nullptr);
   30975             : 
   30976             : #if ROSE_ALLOC_TRACE == 2
   30977             : //  printf("SgTypeLabel::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeLabel::next_node);
   30978             :     printf("SgTypeLabel::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeLabel::next_node);
   30979             : #endif
   30980             : 
   30981             : #if ROSE_PEDANTIC_ALLOC
   30982             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   30983             : #endif
   30984             : 
   30985             : #if ROSE_ALLOC_MEMSET == 1
   30986             : #elif ROSE_ALLOC_MEMSET == 2
   30987             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgTypeLabel) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   30988             : #elif ROSE_ALLOC_MEMSET == 3
   30989             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgTypeLabel) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   30990             : #endif
   30991             : 
   30992             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   30993             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   30994             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   30995             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   30996             : #else
   30997           0 :     object->p_freepointer = SgTypeLabel::next_node;
   30998           0 :     SgTypeLabel::next_node = object;
   30999             : #endif
   31000             : 
   31001             : #if ROSE_ALLOC_TRACE == 2
   31002             : //  printf("SgTypeLabel::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeLabel::next_node);
   31003             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   31004             :     Rose::MemPool::snapshot(oss.str());
   31005             :     alloc_trace_cnt++;
   31006             : #endif
   31007             : 
   31008             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   31009             : 
   31010           0 :     ALLOC_MUTEX(SgTypeLabel, unlock);
   31011             : }
   31012             : 
   31013             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   31014             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   31015             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   31016             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   31017             : // Also, note comment below from Robb (copied from the Common.code file).
   31018             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   31019             : //
   31020             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   31021             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   31022             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   31023             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   31024             : #if 0
   31025             : void SgTypeLabel::operator delete(void* pointer) { SgTypeLabel::operator delete (pointer, sizeof(SgTypeLabel)); };
   31026             : #endif
   31027             : /* #line 31028 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   31028             : 
   31029             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   31030             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   31031             : // obviously imply C++.
   31032             : 
   31033             : // This implements the support within ROSE for memory pools.  Memory pools
   31034             : // support the most condensed usage of memory within the construction of
   31035             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   31036             : // by a new operator written for each class.
   31037             : 
   31038             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   31039             :     // User wants multi-thread support and POSIX threads are available.
   31040             : #   include <pthread.h>
   31041             :     static pthread_mutex_t SgRvalueReferenceType_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   31042             : #else
   31043             :      // Cause synchronization to be skipped.
   31044             : #    ifndef ALLOC_MUTEX
   31045             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   31046             : #    endif
   31047             : #    ifdef _REENTRANT
   31048             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   31049             : #       ifdef _MSC_VER
   31050             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   31051             : #       else
   31052             : #           warning "POSIX threads are not available; synchronization being skipped"
   31053             : #       endif
   31054             : #    endif
   31055             : #endif
   31056             : 
   31057             : #ifndef ROSE_ALLOC_TRACE
   31058             : #  define ROSE_ALLOC_TRACE 0
   31059             : #endif
   31060             : 
   31061             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   31062             : #define ROSE_ALLOC_TRACE_CNT
   31063             : #include "memory-pool-snapshot.h"
   31064             : unsigned long alloc_trace_cnt = 0;
   31065             : #endif
   31066             : 
   31067             : #if ROSE_ALLOC_TRACE
   31068             : const unsigned SgRvalueReferenceType::pool_size = 5;
   31069             : #else
   31070             : const unsigned SgRvalueReferenceType::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   31071             : #endif
   31072             : 
   31073             : #ifndef ROSE_ALLOC_MEMSET
   31074             : #  define ROSE_ALLOC_MEMSET 0
   31075             : #endif
   31076             : 
   31077             : #ifndef ROSE_PEDANTIC_ALLOC
   31078             : #  define ROSE_PEDANTIC_ALLOC 0
   31079             : #endif
   31080             : 
   31081             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   31082             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   31083             : #endif
   31084             : 
   31085             : #if !defined(SGNODE__ALL_POOLS)
   31086             : #define SGNODE__ALL_POOLS
   31087             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   31088             : #endif
   31089             : 
   31090             : SgRvalueReferenceType* SgRvalueReferenceType::next_node = nullptr;
   31091             : std::vector<unsigned char*> SgRvalueReferenceType::pools;
   31092             : 
   31093             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   31094             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   31095             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   31096             : // around this macro definition rather than each use).
   31097             : #ifndef ALLOC_MUTEX
   31098             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   31099             :         do {                                                                     \
   31100             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   31101             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   31102             :                 abort();                                                         \
   31103             :             }                                                                    \
   31104             :         } while (0);
   31105             : #endif
   31106             : 
   31107             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   31108             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   31109             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   31110             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   31111             : 
   31112             : /*! \brief New operator for SgRvalueReferenceType.
   31113             : 
   31114             :    This new operator implements memory pools to provide most efficent 
   31115             :    use of the heap within construction of large ASTs.
   31116             : 
   31117             : \internal The new and delete operators use the lower level C malloc/free
   31118             :    function calls for performance and to make sure that mixing of malloc/free
   31119             :    and new/delete by the used can be caught more readily.  This may change
   31120             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   31121             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   31122             :    deallocate memory allocated using ROSE_MALLOC.
   31123             : */
   31124        1859 : void *SgRvalueReferenceType::operator new ( size_t Size )
   31125             : {
   31126             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   31127             :      * returning or throwing an exception. */
   31128        1859 :     ALLOC_MUTEX(SgRvalueReferenceType, lock);
   31129             : 
   31130             : #if ROSE_ALLOC_TRACE == 2
   31131             : //    printf("SgRvalueReferenceType::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgRvalueReferenceType::next_node);
   31132             : #endif
   31133             : 
   31134             : #if USE_CPP_NEW_DELETE_OPERATORS
   31135             :     void *mem = ROSE_MALLOC(Size);
   31136             :     ALLOC_MUTEX(SgRvalueReferenceType, unlock);
   31137             :     return mem;
   31138             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   31139             : #if ROSE_PEDANTIC_ALLOC
   31140             :     ROSE_ASSERT(Size == sizeof(SgRvalueReferenceType));
   31141             : #else
   31142        1859 :     if (Size != sizeof(SgRvalueReferenceType)) {
   31143           0 :       void * object = ROSE_MALLOC(Size);
   31144           0 :       ALLOC_MUTEX(SgRvalueReferenceType, unlock);
   31145             :       return object;
   31146             :     }
   31147             : #endif
   31148             : 
   31149        1859 :     if (SgRvalueReferenceType::next_node == nullptr) {
   31150          10 :         SgRvalueReferenceType * alloc = (SgRvalueReferenceType*) ROSE_MALLOC ( SgRvalueReferenceType::pool_size * sizeof(SgRvalueReferenceType) );
   31151          10 :         ROSE_ASSERT(alloc != nullptr);
   31152             : 
   31153             : #if ROSE_ALLOC_TRACE == 2
   31154             : //        printf("SgRvalueReferenceType::alloc\n  block[%zi] = [ %p , %p [\n", SgRvalueReferenceType::pools.size(), alloc, alloc + SgRvalueReferenceType::pool_size);
   31155             : #endif
   31156             : 
   31157             : #if ROSE_ALLOC_MEMSET == 1
   31158             : #elif ROSE_ALLOC_MEMSET == 2
   31159             :         memset(alloc, 0x00, SgRvalueReferenceType::pool_size * sizeof(SgRvalueReferenceType));
   31160             : #elif ROSE_ALLOC_MEMSET == 3
   31161             :         memset(alloc, 0xAA, SgRvalueReferenceType::pool_size * sizeof(SgRvalueReferenceType));
   31162             : #endif
   31163       20000 :         for (unsigned i=0; i < SgRvalueReferenceType::pool_size-1; i++) {
   31164       19990 :           alloc[i].p_freepointer = &(alloc[i+1]);
   31165             :         }
   31166          10 :         alloc[SgRvalueReferenceType::pool_size-1].p_freepointer = nullptr;
   31167             : 
   31168          10 :         SgRvalueReferenceType::pools.push_back ( (unsigned char *) alloc );
   31169          10 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgRvalueReferenceType::pool_size * sizeof(SgRvalueReferenceType), V_SgRvalueReferenceType ) );
   31170          10 :         SgRvalueReferenceType::next_node = alloc;
   31171             :     }
   31172        1859 :     ROSE_ASSERT(SgRvalueReferenceType::next_node != nullptr);
   31173             : 
   31174        1859 :     SgRvalueReferenceType * object = SgRvalueReferenceType::next_node;
   31175        1859 :     SgRvalueReferenceType::next_node = (SgRvalueReferenceType*)(object->p_freepointer);
   31176             : 
   31177             : #if ROSE_ALLOC_TRACE == 2
   31178             :     printf("SgRvalueReferenceType::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgRvalueReferenceType::next_node);
   31179             : #endif
   31180             : 
   31181        1859 :     SgNode * fp = object->p_freepointer;
   31182             : #if ROSE_ALLOC_MEMSET == 1
   31183             : #elif ROSE_ALLOC_MEMSET == 2
   31184             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgRvalueReferenceType) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   31185             : #elif ROSE_ALLOC_MEMSET == 3
   31186             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgRvalueReferenceType) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   31187             : #endif
   31188        1859 :     object->p_freepointer = fp;
   31189             : 
   31190             : #if ROSE_ALLOC_TRACE == 2
   31191             : //    printf("SgRvalueReferenceType::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgRvalueReferenceType::next_node);
   31192             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   31193             :     Rose::MemPool::snapshot(oss.str());
   31194             :     alloc_trace_cnt++;
   31195             : #endif
   31196             : 
   31197        1859 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   31198             : 
   31199        1859 :     ALLOC_MUTEX(SgRvalueReferenceType, unlock);
   31200             : 
   31201             :     return object;
   31202             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   31203             : }
   31204             : 
   31205             : 
   31206             : 
   31207             : /*! \brief Delete operator for SgRvalueReferenceType.
   31208             : 
   31209             :    This delete operator implements deallocation using memory pools to 
   31210             :    provide most efficent use of the heap within construction of large ASTs.
   31211             : 
   31212             : \internal The new and delete operators use the lower level C malloc/free
   31213             :    function calls for performance and to make sure that mixing of malloc/free
   31214             :    and new/delete by the used can be caught more readily.  This may change
   31215             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   31216             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   31217             :    deallocate memory allocated using ROSE_MALLOC.
   31218             : */
   31219         364 : void SgRvalueReferenceType::operator delete(void *Pointer, size_t Size)
   31220             : {
   31221             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   31222             :      * or throwing an exception. */
   31223         364 :     ALLOC_MUTEX(SgRvalueReferenceType, lock);
   31224             : 
   31225             : #if USE_CPP_NEW_DELETE_OPERATORS
   31226             :     ROSE_FREE(Pointer);
   31227             : #else
   31228             : #if ROSE_PEDANTIC_ALLOC
   31229             :     ROSE_ASSERT(Size == sizeof(SgRvalueReferenceType));
   31230             : #else
   31231         364 :     if (Size != sizeof(SgRvalueReferenceType)) {
   31232           0 :       ROSE_FREE(Pointer);
   31233           0 :       ALLOC_MUTEX(SgRvalueReferenceType, unlock);
   31234             :       return;
   31235             :     }
   31236             : #endif
   31237             : 
   31238         364 :     SgRvalueReferenceType * object = (SgRvalueReferenceType*) Pointer;
   31239         364 :     ROSE_ASSERT(object != nullptr);
   31240             : 
   31241             : #if ROSE_ALLOC_TRACE == 2
   31242             : //  printf("SgRvalueReferenceType::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgRvalueReferenceType::next_node);
   31243             :     printf("SgRvalueReferenceType::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgRvalueReferenceType::next_node);
   31244             : #endif
   31245             : 
   31246             : #if ROSE_PEDANTIC_ALLOC
   31247             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   31248             : #endif
   31249             : 
   31250             : #if ROSE_ALLOC_MEMSET == 1
   31251             : #elif ROSE_ALLOC_MEMSET == 2
   31252             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgRvalueReferenceType) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   31253             : #elif ROSE_ALLOC_MEMSET == 3
   31254             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgRvalueReferenceType) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   31255             : #endif
   31256             : 
   31257             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   31258             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   31259             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   31260             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   31261             : #else
   31262         364 :     object->p_freepointer = SgRvalueReferenceType::next_node;
   31263         364 :     SgRvalueReferenceType::next_node = object;
   31264             : #endif
   31265             : 
   31266             : #if ROSE_ALLOC_TRACE == 2
   31267             : //  printf("SgRvalueReferenceType::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgRvalueReferenceType::next_node);
   31268             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   31269             :     Rose::MemPool::snapshot(oss.str());
   31270             :     alloc_trace_cnt++;
   31271             : #endif
   31272             : 
   31273             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   31274             : 
   31275         364 :     ALLOC_MUTEX(SgRvalueReferenceType, unlock);
   31276             : }
   31277             : 
   31278             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   31279             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   31280             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   31281             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   31282             : // Also, note comment below from Robb (copied from the Common.code file).
   31283             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   31284             : //
   31285             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   31286             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   31287             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   31288             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   31289             : #if 0
   31290             : void SgRvalueReferenceType::operator delete(void* pointer) { SgRvalueReferenceType::operator delete (pointer, sizeof(SgRvalueReferenceType)); };
   31291             : #endif
   31292             : /* #line 31293 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   31293             : 
   31294             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   31295             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   31296             : // obviously imply C++.
   31297             : 
   31298             : // This implements the support within ROSE for memory pools.  Memory pools
   31299             : // support the most condensed usage of memory within the construction of
   31300             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   31301             : // by a new operator written for each class.
   31302             : 
   31303             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   31304             :     // User wants multi-thread support and POSIX threads are available.
   31305             : #   include <pthread.h>
   31306             :     static pthread_mutex_t SgTypeNullptr_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   31307             : #else
   31308             :      // Cause synchronization to be skipped.
   31309             : #    ifndef ALLOC_MUTEX
   31310             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   31311             : #    endif
   31312             : #    ifdef _REENTRANT
   31313             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   31314             : #       ifdef _MSC_VER
   31315             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   31316             : #       else
   31317             : #           warning "POSIX threads are not available; synchronization being skipped"
   31318             : #       endif
   31319             : #    endif
   31320             : #endif
   31321             : 
   31322             : #ifndef ROSE_ALLOC_TRACE
   31323             : #  define ROSE_ALLOC_TRACE 0
   31324             : #endif
   31325             : 
   31326             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   31327             : #define ROSE_ALLOC_TRACE_CNT
   31328             : #include "memory-pool-snapshot.h"
   31329             : unsigned long alloc_trace_cnt = 0;
   31330             : #endif
   31331             : 
   31332             : #if ROSE_ALLOC_TRACE
   31333             : const unsigned SgTypeNullptr::pool_size = 5;
   31334             : #else
   31335             : const unsigned SgTypeNullptr::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   31336             : #endif
   31337             : 
   31338             : #ifndef ROSE_ALLOC_MEMSET
   31339             : #  define ROSE_ALLOC_MEMSET 0
   31340             : #endif
   31341             : 
   31342             : #ifndef ROSE_PEDANTIC_ALLOC
   31343             : #  define ROSE_PEDANTIC_ALLOC 0
   31344             : #endif
   31345             : 
   31346             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   31347             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   31348             : #endif
   31349             : 
   31350             : #if !defined(SGNODE__ALL_POOLS)
   31351             : #define SGNODE__ALL_POOLS
   31352             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   31353             : #endif
   31354             : 
   31355             : SgTypeNullptr* SgTypeNullptr::next_node = nullptr;
   31356             : std::vector<unsigned char*> SgTypeNullptr::pools;
   31357             : 
   31358             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   31359             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   31360             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   31361             : // around this macro definition rather than each use).
   31362             : #ifndef ALLOC_MUTEX
   31363             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   31364             :         do {                                                                     \
   31365             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   31366             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   31367             :                 abort();                                                         \
   31368             :             }                                                                    \
   31369             :         } while (0);
   31370             : #endif
   31371             : 
   31372             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   31373             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   31374             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   31375             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   31376             : 
   31377             : /*! \brief New operator for SgTypeNullptr.
   31378             : 
   31379             :    This new operator implements memory pools to provide most efficent 
   31380             :    use of the heap within construction of large ASTs.
   31381             : 
   31382             : \internal The new and delete operators use the lower level C malloc/free
   31383             :    function calls for performance and to make sure that mixing of malloc/free
   31384             :    and new/delete by the used can be caught more readily.  This may change
   31385             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   31386             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   31387             :    deallocate memory allocated using ROSE_MALLOC.
   31388             : */
   31389         246 : void *SgTypeNullptr::operator new ( size_t Size )
   31390             : {
   31391             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   31392             :      * returning or throwing an exception. */
   31393         246 :     ALLOC_MUTEX(SgTypeNullptr, lock);
   31394             : 
   31395             : #if ROSE_ALLOC_TRACE == 2
   31396             : //    printf("SgTypeNullptr::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgTypeNullptr::next_node);
   31397             : #endif
   31398             : 
   31399             : #if USE_CPP_NEW_DELETE_OPERATORS
   31400             :     void *mem = ROSE_MALLOC(Size);
   31401             :     ALLOC_MUTEX(SgTypeNullptr, unlock);
   31402             :     return mem;
   31403             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   31404             : #if ROSE_PEDANTIC_ALLOC
   31405             :     ROSE_ASSERT(Size == sizeof(SgTypeNullptr));
   31406             : #else
   31407         246 :     if (Size != sizeof(SgTypeNullptr)) {
   31408           0 :       void * object = ROSE_MALLOC(Size);
   31409           0 :       ALLOC_MUTEX(SgTypeNullptr, unlock);
   31410             :       return object;
   31411             :     }
   31412             : #endif
   31413             : 
   31414         246 :     if (SgTypeNullptr::next_node == nullptr) {
   31415          62 :         SgTypeNullptr * alloc = (SgTypeNullptr*) ROSE_MALLOC ( SgTypeNullptr::pool_size * sizeof(SgTypeNullptr) );
   31416          62 :         ROSE_ASSERT(alloc != nullptr);
   31417             : 
   31418             : #if ROSE_ALLOC_TRACE == 2
   31419             : //        printf("SgTypeNullptr::alloc\n  block[%zi] = [ %p , %p [\n", SgTypeNullptr::pools.size(), alloc, alloc + SgTypeNullptr::pool_size);
   31420             : #endif
   31421             : 
   31422             : #if ROSE_ALLOC_MEMSET == 1
   31423             : #elif ROSE_ALLOC_MEMSET == 2
   31424             :         memset(alloc, 0x00, SgTypeNullptr::pool_size * sizeof(SgTypeNullptr));
   31425             : #elif ROSE_ALLOC_MEMSET == 3
   31426             :         memset(alloc, 0xAA, SgTypeNullptr::pool_size * sizeof(SgTypeNullptr));
   31427             : #endif
   31428      124000 :         for (unsigned i=0; i < SgTypeNullptr::pool_size-1; i++) {
   31429      123938 :           alloc[i].p_freepointer = &(alloc[i+1]);
   31430             :         }
   31431          62 :         alloc[SgTypeNullptr::pool_size-1].p_freepointer = nullptr;
   31432             : 
   31433          62 :         SgTypeNullptr::pools.push_back ( (unsigned char *) alloc );
   31434          62 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgTypeNullptr::pool_size * sizeof(SgTypeNullptr), V_SgTypeNullptr ) );
   31435          62 :         SgTypeNullptr::next_node = alloc;
   31436             :     }
   31437         246 :     ROSE_ASSERT(SgTypeNullptr::next_node != nullptr);
   31438             : 
   31439         246 :     SgTypeNullptr * object = SgTypeNullptr::next_node;
   31440         246 :     SgTypeNullptr::next_node = (SgTypeNullptr*)(object->p_freepointer);
   31441             : 
   31442             : #if ROSE_ALLOC_TRACE == 2
   31443             :     printf("SgTypeNullptr::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeNullptr::next_node);
   31444             : #endif
   31445             : 
   31446         246 :     SgNode * fp = object->p_freepointer;
   31447             : #if ROSE_ALLOC_MEMSET == 1
   31448             : #elif ROSE_ALLOC_MEMSET == 2
   31449             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgTypeNullptr) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   31450             : #elif ROSE_ALLOC_MEMSET == 3
   31451             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgTypeNullptr) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   31452             : #endif
   31453         246 :     object->p_freepointer = fp;
   31454             : 
   31455             : #if ROSE_ALLOC_TRACE == 2
   31456             : //    printf("SgTypeNullptr::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeNullptr::next_node);
   31457             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   31458             :     Rose::MemPool::snapshot(oss.str());
   31459             :     alloc_trace_cnt++;
   31460             : #endif
   31461             : 
   31462         246 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   31463             : 
   31464         246 :     ALLOC_MUTEX(SgTypeNullptr, unlock);
   31465             : 
   31466             :     return object;
   31467             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   31468             : }
   31469             : 
   31470             : 
   31471             : 
   31472             : /*! \brief Delete operator for SgTypeNullptr.
   31473             : 
   31474             :    This delete operator implements deallocation using memory pools to 
   31475             :    provide most efficent use of the heap within construction of large ASTs.
   31476             : 
   31477             : \internal The new and delete operators use the lower level C malloc/free
   31478             :    function calls for performance and to make sure that mixing of malloc/free
   31479             :    and new/delete by the used can be caught more readily.  This may change
   31480             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   31481             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   31482             :    deallocate memory allocated using ROSE_MALLOC.
   31483             : */
   31484         185 : void SgTypeNullptr::operator delete(void *Pointer, size_t Size)
   31485             : {
   31486             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   31487             :      * or throwing an exception. */
   31488         185 :     ALLOC_MUTEX(SgTypeNullptr, lock);
   31489             : 
   31490             : #if USE_CPP_NEW_DELETE_OPERATORS
   31491             :     ROSE_FREE(Pointer);
   31492             : #else
   31493             : #if ROSE_PEDANTIC_ALLOC
   31494             :     ROSE_ASSERT(Size == sizeof(SgTypeNullptr));
   31495             : #else
   31496         185 :     if (Size != sizeof(SgTypeNullptr)) {
   31497           0 :       ROSE_FREE(Pointer);
   31498           0 :       ALLOC_MUTEX(SgTypeNullptr, unlock);
   31499             :       return;
   31500             :     }
   31501             : #endif
   31502             : 
   31503         185 :     SgTypeNullptr * object = (SgTypeNullptr*) Pointer;
   31504         185 :     ROSE_ASSERT(object != nullptr);
   31505             : 
   31506             : #if ROSE_ALLOC_TRACE == 2
   31507             : //  printf("SgTypeNullptr::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeNullptr::next_node);
   31508             :     printf("SgTypeNullptr::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeNullptr::next_node);
   31509             : #endif
   31510             : 
   31511             : #if ROSE_PEDANTIC_ALLOC
   31512             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   31513             : #endif
   31514             : 
   31515             : #if ROSE_ALLOC_MEMSET == 1
   31516             : #elif ROSE_ALLOC_MEMSET == 2
   31517             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgTypeNullptr) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   31518             : #elif ROSE_ALLOC_MEMSET == 3
   31519             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgTypeNullptr) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   31520             : #endif
   31521             : 
   31522             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   31523             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   31524             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   31525             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   31526             : #else
   31527         185 :     object->p_freepointer = SgTypeNullptr::next_node;
   31528         185 :     SgTypeNullptr::next_node = object;
   31529             : #endif
   31530             : 
   31531             : #if ROSE_ALLOC_TRACE == 2
   31532             : //  printf("SgTypeNullptr::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeNullptr::next_node);
   31533             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   31534             :     Rose::MemPool::snapshot(oss.str());
   31535             :     alloc_trace_cnt++;
   31536             : #endif
   31537             : 
   31538             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   31539             : 
   31540         185 :     ALLOC_MUTEX(SgTypeNullptr, unlock);
   31541             : }
   31542             : 
   31543             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   31544             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   31545             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   31546             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   31547             : // Also, note comment below from Robb (copied from the Common.code file).
   31548             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   31549             : //
   31550             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   31551             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   31552             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   31553             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   31554             : #if 0
   31555             : void SgTypeNullptr::operator delete(void* pointer) { SgTypeNullptr::operator delete (pointer, sizeof(SgTypeNullptr)); };
   31556             : #endif
   31557             : /* #line 31558 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   31558             : 
   31559             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   31560             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   31561             : // obviously imply C++.
   31562             : 
   31563             : // This implements the support within ROSE for memory pools.  Memory pools
   31564             : // support the most condensed usage of memory within the construction of
   31565             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   31566             : // by a new operator written for each class.
   31567             : 
   31568             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   31569             :     // User wants multi-thread support and POSIX threads are available.
   31570             : #   include <pthread.h>
   31571             :     static pthread_mutex_t SgDeclType_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   31572             : #else
   31573             :      // Cause synchronization to be skipped.
   31574             : #    ifndef ALLOC_MUTEX
   31575             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   31576             : #    endif
   31577             : #    ifdef _REENTRANT
   31578             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   31579             : #       ifdef _MSC_VER
   31580             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   31581             : #       else
   31582             : #           warning "POSIX threads are not available; synchronization being skipped"
   31583             : #       endif
   31584             : #    endif
   31585             : #endif
   31586             : 
   31587             : #ifndef ROSE_ALLOC_TRACE
   31588             : #  define ROSE_ALLOC_TRACE 0
   31589             : #endif
   31590             : 
   31591             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   31592             : #define ROSE_ALLOC_TRACE_CNT
   31593             : #include "memory-pool-snapshot.h"
   31594             : unsigned long alloc_trace_cnt = 0;
   31595             : #endif
   31596             : 
   31597             : #if ROSE_ALLOC_TRACE
   31598             : const unsigned SgDeclType::pool_size = 5;
   31599             : #else
   31600             : const unsigned SgDeclType::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   31601             : #endif
   31602             : 
   31603             : #ifndef ROSE_ALLOC_MEMSET
   31604             : #  define ROSE_ALLOC_MEMSET 0
   31605             : #endif
   31606             : 
   31607             : #ifndef ROSE_PEDANTIC_ALLOC
   31608             : #  define ROSE_PEDANTIC_ALLOC 0
   31609             : #endif
   31610             : 
   31611             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   31612             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   31613             : #endif
   31614             : 
   31615             : #if !defined(SGNODE__ALL_POOLS)
   31616             : #define SGNODE__ALL_POOLS
   31617             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   31618             : #endif
   31619             : 
   31620             : SgDeclType* SgDeclType::next_node = nullptr;
   31621             : std::vector<unsigned char*> SgDeclType::pools;
   31622             : 
   31623             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   31624             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   31625             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   31626             : // around this macro definition rather than each use).
   31627             : #ifndef ALLOC_MUTEX
   31628             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   31629             :         do {                                                                     \
   31630             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   31631             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   31632             :                 abort();                                                         \
   31633             :             }                                                                    \
   31634             :         } while (0);
   31635             : #endif
   31636             : 
   31637             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   31638             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   31639             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   31640             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   31641             : 
   31642             : /*! \brief New operator for SgDeclType.
   31643             : 
   31644             :    This new operator implements memory pools to provide most efficent 
   31645             :    use of the heap within construction of large ASTs.
   31646             : 
   31647             : \internal The new and delete operators use the lower level C malloc/free
   31648             :    function calls for performance and to make sure that mixing of malloc/free
   31649             :    and new/delete by the used can be caught more readily.  This may change
   31650             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   31651             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   31652             :    deallocate memory allocated using ROSE_MALLOC.
   31653             : */
   31654        1136 : void *SgDeclType::operator new ( size_t Size )
   31655             : {
   31656             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   31657             :      * returning or throwing an exception. */
   31658        1136 :     ALLOC_MUTEX(SgDeclType, lock);
   31659             : 
   31660             : #if ROSE_ALLOC_TRACE == 2
   31661             : //    printf("SgDeclType::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgDeclType::next_node);
   31662             : #endif
   31663             : 
   31664             : #if USE_CPP_NEW_DELETE_OPERATORS
   31665             :     void *mem = ROSE_MALLOC(Size);
   31666             :     ALLOC_MUTEX(SgDeclType, unlock);
   31667             :     return mem;
   31668             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   31669             : #if ROSE_PEDANTIC_ALLOC
   31670             :     ROSE_ASSERT(Size == sizeof(SgDeclType));
   31671             : #else
   31672        1136 :     if (Size != sizeof(SgDeclType)) {
   31673           0 :       void * object = ROSE_MALLOC(Size);
   31674           0 :       ALLOC_MUTEX(SgDeclType, unlock);
   31675             :       return object;
   31676             :     }
   31677             : #endif
   31678             : 
   31679        1136 :     if (SgDeclType::next_node == nullptr) {
   31680          62 :         SgDeclType * alloc = (SgDeclType*) ROSE_MALLOC ( SgDeclType::pool_size * sizeof(SgDeclType) );
   31681          62 :         ROSE_ASSERT(alloc != nullptr);
   31682             : 
   31683             : #if ROSE_ALLOC_TRACE == 2
   31684             : //        printf("SgDeclType::alloc\n  block[%zi] = [ %p , %p [\n", SgDeclType::pools.size(), alloc, alloc + SgDeclType::pool_size);
   31685             : #endif
   31686             : 
   31687             : #if ROSE_ALLOC_MEMSET == 1
   31688             : #elif ROSE_ALLOC_MEMSET == 2
   31689             :         memset(alloc, 0x00, SgDeclType::pool_size * sizeof(SgDeclType));
   31690             : #elif ROSE_ALLOC_MEMSET == 3
   31691             :         memset(alloc, 0xAA, SgDeclType::pool_size * sizeof(SgDeclType));
   31692             : #endif
   31693      124000 :         for (unsigned i=0; i < SgDeclType::pool_size-1; i++) {
   31694      123938 :           alloc[i].p_freepointer = &(alloc[i+1]);
   31695             :         }
   31696          62 :         alloc[SgDeclType::pool_size-1].p_freepointer = nullptr;
   31697             : 
   31698          62 :         SgDeclType::pools.push_back ( (unsigned char *) alloc );
   31699          62 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgDeclType::pool_size * sizeof(SgDeclType), V_SgDeclType ) );
   31700          62 :         SgDeclType::next_node = alloc;
   31701             :     }
   31702        1136 :     ROSE_ASSERT(SgDeclType::next_node != nullptr);
   31703             : 
   31704        1136 :     SgDeclType * object = SgDeclType::next_node;
   31705        1136 :     SgDeclType::next_node = (SgDeclType*)(object->p_freepointer);
   31706             : 
   31707             : #if ROSE_ALLOC_TRACE == 2
   31708             :     printf("SgDeclType::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgDeclType::next_node);
   31709             : #endif
   31710             : 
   31711        1136 :     SgNode * fp = object->p_freepointer;
   31712             : #if ROSE_ALLOC_MEMSET == 1
   31713             : #elif ROSE_ALLOC_MEMSET == 2
   31714             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgDeclType) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   31715             : #elif ROSE_ALLOC_MEMSET == 3
   31716             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgDeclType) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   31717             : #endif
   31718        1136 :     object->p_freepointer = fp;
   31719             : 
   31720             : #if ROSE_ALLOC_TRACE == 2
   31721             : //    printf("SgDeclType::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgDeclType::next_node);
   31722             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   31723             :     Rose::MemPool::snapshot(oss.str());
   31724             :     alloc_trace_cnt++;
   31725             : #endif
   31726             : 
   31727        1136 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   31728             : 
   31729        1136 :     ALLOC_MUTEX(SgDeclType, unlock);
   31730             : 
   31731             :     return object;
   31732             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   31733             : }
   31734             : 
   31735             : 
   31736             : 
   31737             : /*! \brief Delete operator for SgDeclType.
   31738             : 
   31739             :    This delete operator implements deallocation using memory pools to 
   31740             :    provide most efficent use of the heap within construction of large ASTs.
   31741             : 
   31742             : \internal The new and delete operators use the lower level C malloc/free
   31743             :    function calls for performance and to make sure that mixing of malloc/free
   31744             :    and new/delete by the used can be caught more readily.  This may change
   31745             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   31746             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   31747             :    deallocate memory allocated using ROSE_MALLOC.
   31748             : */
   31749         337 : void SgDeclType::operator delete(void *Pointer, size_t Size)
   31750             : {
   31751             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   31752             :      * or throwing an exception. */
   31753         337 :     ALLOC_MUTEX(SgDeclType, lock);
   31754             : 
   31755             : #if USE_CPP_NEW_DELETE_OPERATORS
   31756             :     ROSE_FREE(Pointer);
   31757             : #else
   31758             : #if ROSE_PEDANTIC_ALLOC
   31759             :     ROSE_ASSERT(Size == sizeof(SgDeclType));
   31760             : #else
   31761         337 :     if (Size != sizeof(SgDeclType)) {
   31762           0 :       ROSE_FREE(Pointer);
   31763           0 :       ALLOC_MUTEX(SgDeclType, unlock);
   31764             :       return;
   31765             :     }
   31766             : #endif
   31767             : 
   31768         337 :     SgDeclType * object = (SgDeclType*) Pointer;
   31769         337 :     ROSE_ASSERT(object != nullptr);
   31770             : 
   31771             : #if ROSE_ALLOC_TRACE == 2
   31772             : //  printf("SgDeclType::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgDeclType::next_node);
   31773             :     printf("SgDeclType::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgDeclType::next_node);
   31774             : #endif
   31775             : 
   31776             : #if ROSE_PEDANTIC_ALLOC
   31777             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   31778             : #endif
   31779             : 
   31780             : #if ROSE_ALLOC_MEMSET == 1
   31781             : #elif ROSE_ALLOC_MEMSET == 2
   31782             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgDeclType) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   31783             : #elif ROSE_ALLOC_MEMSET == 3
   31784             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgDeclType) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   31785             : #endif
   31786             : 
   31787             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   31788             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   31789             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   31790             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   31791             : #else
   31792         337 :     object->p_freepointer = SgDeclType::next_node;
   31793         337 :     SgDeclType::next_node = object;
   31794             : #endif
   31795             : 
   31796             : #if ROSE_ALLOC_TRACE == 2
   31797             : //  printf("SgDeclType::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgDeclType::next_node);
   31798             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   31799             :     Rose::MemPool::snapshot(oss.str());
   31800             :     alloc_trace_cnt++;
   31801             : #endif
   31802             : 
   31803             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   31804             : 
   31805         337 :     ALLOC_MUTEX(SgDeclType, unlock);
   31806             : }
   31807             : 
   31808             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   31809             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   31810             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   31811             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   31812             : // Also, note comment below from Robb (copied from the Common.code file).
   31813             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   31814             : //
   31815             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   31816             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   31817             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   31818             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   31819             : #if 0
   31820             : void SgDeclType::operator delete(void* pointer) { SgDeclType::operator delete (pointer, sizeof(SgDeclType)); };
   31821             : #endif
   31822             : /* #line 31823 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   31823             : 
   31824             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   31825             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   31826             : // obviously imply C++.
   31827             : 
   31828             : // This implements the support within ROSE for memory pools.  Memory pools
   31829             : // support the most condensed usage of memory within the construction of
   31830             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   31831             : // by a new operator written for each class.
   31832             : 
   31833             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   31834             :     // User wants multi-thread support and POSIX threads are available.
   31835             : #   include <pthread.h>
   31836             :     static pthread_mutex_t SgTypeOfType_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   31837             : #else
   31838             :      // Cause synchronization to be skipped.
   31839             : #    ifndef ALLOC_MUTEX
   31840             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   31841             : #    endif
   31842             : #    ifdef _REENTRANT
   31843             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   31844             : #       ifdef _MSC_VER
   31845             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   31846             : #       else
   31847             : #           warning "POSIX threads are not available; synchronization being skipped"
   31848             : #       endif
   31849             : #    endif
   31850             : #endif
   31851             : 
   31852             : #ifndef ROSE_ALLOC_TRACE
   31853             : #  define ROSE_ALLOC_TRACE 0
   31854             : #endif
   31855             : 
   31856             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   31857             : #define ROSE_ALLOC_TRACE_CNT
   31858             : #include "memory-pool-snapshot.h"
   31859             : unsigned long alloc_trace_cnt = 0;
   31860             : #endif
   31861             : 
   31862             : #if ROSE_ALLOC_TRACE
   31863             : const unsigned SgTypeOfType::pool_size = 5;
   31864             : #else
   31865             : const unsigned SgTypeOfType::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   31866             : #endif
   31867             : 
   31868             : #ifndef ROSE_ALLOC_MEMSET
   31869             : #  define ROSE_ALLOC_MEMSET 0
   31870             : #endif
   31871             : 
   31872             : #ifndef ROSE_PEDANTIC_ALLOC
   31873             : #  define ROSE_PEDANTIC_ALLOC 0
   31874             : #endif
   31875             : 
   31876             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   31877             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   31878             : #endif
   31879             : 
   31880             : #if !defined(SGNODE__ALL_POOLS)
   31881             : #define SGNODE__ALL_POOLS
   31882             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   31883             : #endif
   31884             : 
   31885             : SgTypeOfType* SgTypeOfType::next_node = nullptr;
   31886             : std::vector<unsigned char*> SgTypeOfType::pools;
   31887             : 
   31888             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   31889             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   31890             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   31891             : // around this macro definition rather than each use).
   31892             : #ifndef ALLOC_MUTEX
   31893             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   31894             :         do {                                                                     \
   31895             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   31896             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   31897             :                 abort();                                                         \
   31898             :             }                                                                    \
   31899             :         } while (0);
   31900             : #endif
   31901             : 
   31902             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   31903             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   31904             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   31905             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   31906             : 
   31907             : /*! \brief New operator for SgTypeOfType.
   31908             : 
   31909             :    This new operator implements memory pools to provide most efficent 
   31910             :    use of the heap within construction of large ASTs.
   31911             : 
   31912             : \internal The new and delete operators use the lower level C malloc/free
   31913             :    function calls for performance and to make sure that mixing of malloc/free
   31914             :    and new/delete by the used can be caught more readily.  This may change
   31915             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   31916             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   31917             :    deallocate memory allocated using ROSE_MALLOC.
   31918             : */
   31919          39 : void *SgTypeOfType::operator new ( size_t Size )
   31920             : {
   31921             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   31922             :      * returning or throwing an exception. */
   31923          39 :     ALLOC_MUTEX(SgTypeOfType, lock);
   31924             : 
   31925             : #if ROSE_ALLOC_TRACE == 2
   31926             : //    printf("SgTypeOfType::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgTypeOfType::next_node);
   31927             : #endif
   31928             : 
   31929             : #if USE_CPP_NEW_DELETE_OPERATORS
   31930             :     void *mem = ROSE_MALLOC(Size);
   31931             :     ALLOC_MUTEX(SgTypeOfType, unlock);
   31932             :     return mem;
   31933             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   31934             : #if ROSE_PEDANTIC_ALLOC
   31935             :     ROSE_ASSERT(Size == sizeof(SgTypeOfType));
   31936             : #else
   31937          39 :     if (Size != sizeof(SgTypeOfType)) {
   31938           0 :       void * object = ROSE_MALLOC(Size);
   31939           0 :       ALLOC_MUTEX(SgTypeOfType, unlock);
   31940             :       return object;
   31941             :     }
   31942             : #endif
   31943             : 
   31944          39 :     if (SgTypeOfType::next_node == nullptr) {
   31945          10 :         SgTypeOfType * alloc = (SgTypeOfType*) ROSE_MALLOC ( SgTypeOfType::pool_size * sizeof(SgTypeOfType) );
   31946          10 :         ROSE_ASSERT(alloc != nullptr);
   31947             : 
   31948             : #if ROSE_ALLOC_TRACE == 2
   31949             : //        printf("SgTypeOfType::alloc\n  block[%zi] = [ %p , %p [\n", SgTypeOfType::pools.size(), alloc, alloc + SgTypeOfType::pool_size);
   31950             : #endif
   31951             : 
   31952             : #if ROSE_ALLOC_MEMSET == 1
   31953             : #elif ROSE_ALLOC_MEMSET == 2
   31954             :         memset(alloc, 0x00, SgTypeOfType::pool_size * sizeof(SgTypeOfType));
   31955             : #elif ROSE_ALLOC_MEMSET == 3
   31956             :         memset(alloc, 0xAA, SgTypeOfType::pool_size * sizeof(SgTypeOfType));
   31957             : #endif
   31958       20000 :         for (unsigned i=0; i < SgTypeOfType::pool_size-1; i++) {
   31959       19990 :           alloc[i].p_freepointer = &(alloc[i+1]);
   31960             :         }
   31961          10 :         alloc[SgTypeOfType::pool_size-1].p_freepointer = nullptr;
   31962             : 
   31963          10 :         SgTypeOfType::pools.push_back ( (unsigned char *) alloc );
   31964          10 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgTypeOfType::pool_size * sizeof(SgTypeOfType), V_SgTypeOfType ) );
   31965          10 :         SgTypeOfType::next_node = alloc;
   31966             :     }
   31967          39 :     ROSE_ASSERT(SgTypeOfType::next_node != nullptr);
   31968             : 
   31969          39 :     SgTypeOfType * object = SgTypeOfType::next_node;
   31970          39 :     SgTypeOfType::next_node = (SgTypeOfType*)(object->p_freepointer);
   31971             : 
   31972             : #if ROSE_ALLOC_TRACE == 2
   31973             :     printf("SgTypeOfType::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeOfType::next_node);
   31974             : #endif
   31975             : 
   31976          39 :     SgNode * fp = object->p_freepointer;
   31977             : #if ROSE_ALLOC_MEMSET == 1
   31978             : #elif ROSE_ALLOC_MEMSET == 2
   31979             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgTypeOfType) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   31980             : #elif ROSE_ALLOC_MEMSET == 3
   31981             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgTypeOfType) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   31982             : #endif
   31983          39 :     object->p_freepointer = fp;
   31984             : 
   31985             : #if ROSE_ALLOC_TRACE == 2
   31986             : //    printf("SgTypeOfType::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeOfType::next_node);
   31987             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   31988             :     Rose::MemPool::snapshot(oss.str());
   31989             :     alloc_trace_cnt++;
   31990             : #endif
   31991             : 
   31992          39 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   31993             : 
   31994          39 :     ALLOC_MUTEX(SgTypeOfType, unlock);
   31995             : 
   31996             :     return object;
   31997             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   31998             : }
   31999             : 
   32000             : 
   32001             : 
   32002             : /*! \brief Delete operator for SgTypeOfType.
   32003             : 
   32004             :    This delete operator implements deallocation using memory pools to 
   32005             :    provide most efficent use of the heap within construction of large ASTs.
   32006             : 
   32007             : \internal The new and delete operators use the lower level C malloc/free
   32008             :    function calls for performance and to make sure that mixing of malloc/free
   32009             :    and new/delete by the used can be caught more readily.  This may change
   32010             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   32011             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   32012             :    deallocate memory allocated using ROSE_MALLOC.
   32013             : */
   32014           6 : void SgTypeOfType::operator delete(void *Pointer, size_t Size)
   32015             : {
   32016             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   32017             :      * or throwing an exception. */
   32018           6 :     ALLOC_MUTEX(SgTypeOfType, lock);
   32019             : 
   32020             : #if USE_CPP_NEW_DELETE_OPERATORS
   32021             :     ROSE_FREE(Pointer);
   32022             : #else
   32023             : #if ROSE_PEDANTIC_ALLOC
   32024             :     ROSE_ASSERT(Size == sizeof(SgTypeOfType));
   32025             : #else
   32026           6 :     if (Size != sizeof(SgTypeOfType)) {
   32027           0 :       ROSE_FREE(Pointer);
   32028           0 :       ALLOC_MUTEX(SgTypeOfType, unlock);
   32029             :       return;
   32030             :     }
   32031             : #endif
   32032             : 
   32033           6 :     SgTypeOfType * object = (SgTypeOfType*) Pointer;
   32034           6 :     ROSE_ASSERT(object != nullptr);
   32035             : 
   32036             : #if ROSE_ALLOC_TRACE == 2
   32037             : //  printf("SgTypeOfType::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeOfType::next_node);
   32038             :     printf("SgTypeOfType::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeOfType::next_node);
   32039             : #endif
   32040             : 
   32041             : #if ROSE_PEDANTIC_ALLOC
   32042             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   32043             : #endif
   32044             : 
   32045             : #if ROSE_ALLOC_MEMSET == 1
   32046             : #elif ROSE_ALLOC_MEMSET == 2
   32047             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgTypeOfType) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   32048             : #elif ROSE_ALLOC_MEMSET == 3
   32049             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgTypeOfType) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   32050             : #endif
   32051             : 
   32052             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   32053             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   32054             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   32055             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   32056             : #else
   32057           6 :     object->p_freepointer = SgTypeOfType::next_node;
   32058           6 :     SgTypeOfType::next_node = object;
   32059             : #endif
   32060             : 
   32061             : #if ROSE_ALLOC_TRACE == 2
   32062             : //  printf("SgTypeOfType::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeOfType::next_node);
   32063             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   32064             :     Rose::MemPool::snapshot(oss.str());
   32065             :     alloc_trace_cnt++;
   32066             : #endif
   32067             : 
   32068             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   32069             : 
   32070           6 :     ALLOC_MUTEX(SgTypeOfType, unlock);
   32071             : }
   32072             : 
   32073             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   32074             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   32075             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   32076             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   32077             : // Also, note comment below from Robb (copied from the Common.code file).
   32078             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   32079             : //
   32080             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   32081             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   32082             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   32083             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   32084             : #if 0
   32085             : void SgTypeOfType::operator delete(void* pointer) { SgTypeOfType::operator delete (pointer, sizeof(SgTypeOfType)); };
   32086             : #endif
   32087             : /* #line 32088 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   32088             : 
   32089             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   32090             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   32091             : // obviously imply C++.
   32092             : 
   32093             : // This implements the support within ROSE for memory pools.  Memory pools
   32094             : // support the most condensed usage of memory within the construction of
   32095             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   32096             : // by a new operator written for each class.
   32097             : 
   32098             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   32099             :     // User wants multi-thread support and POSIX threads are available.
   32100             : #   include <pthread.h>
   32101             :     static pthread_mutex_t SgTypeMatrix_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   32102             : #else
   32103             :      // Cause synchronization to be skipped.
   32104             : #    ifndef ALLOC_MUTEX
   32105             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   32106             : #    endif
   32107             : #    ifdef _REENTRANT
   32108             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   32109             : #       ifdef _MSC_VER
   32110             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   32111             : #       else
   32112             : #           warning "POSIX threads are not available; synchronization being skipped"
   32113             : #       endif
   32114             : #    endif
   32115             : #endif
   32116             : 
   32117             : #ifndef ROSE_ALLOC_TRACE
   32118             : #  define ROSE_ALLOC_TRACE 0
   32119             : #endif
   32120             : 
   32121             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   32122             : #define ROSE_ALLOC_TRACE_CNT
   32123             : #include "memory-pool-snapshot.h"
   32124             : unsigned long alloc_trace_cnt = 0;
   32125             : #endif
   32126             : 
   32127             : #if ROSE_ALLOC_TRACE
   32128             : const unsigned SgTypeMatrix::pool_size = 5;
   32129             : #else
   32130             : const unsigned SgTypeMatrix::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   32131             : #endif
   32132             : 
   32133             : #ifndef ROSE_ALLOC_MEMSET
   32134             : #  define ROSE_ALLOC_MEMSET 0
   32135             : #endif
   32136             : 
   32137             : #ifndef ROSE_PEDANTIC_ALLOC
   32138             : #  define ROSE_PEDANTIC_ALLOC 0
   32139             : #endif
   32140             : 
   32141             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   32142             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   32143             : #endif
   32144             : 
   32145             : #if !defined(SGNODE__ALL_POOLS)
   32146             : #define SGNODE__ALL_POOLS
   32147             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   32148             : #endif
   32149             : 
   32150             : SgTypeMatrix* SgTypeMatrix::next_node = nullptr;
   32151             : std::vector<unsigned char*> SgTypeMatrix::pools;
   32152             : 
   32153             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   32154             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   32155             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   32156             : // around this macro definition rather than each use).
   32157             : #ifndef ALLOC_MUTEX
   32158             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   32159             :         do {                                                                     \
   32160             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   32161             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   32162             :                 abort();                                                         \
   32163             :             }                                                                    \
   32164             :         } while (0);
   32165             : #endif
   32166             : 
   32167             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   32168             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   32169             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   32170             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   32171             : 
   32172             : /*! \brief New operator for SgTypeMatrix.
   32173             : 
   32174             :    This new operator implements memory pools to provide most efficent 
   32175             :    use of the heap within construction of large ASTs.
   32176             : 
   32177             : \internal The new and delete operators use the lower level C malloc/free
   32178             :    function calls for performance and to make sure that mixing of malloc/free
   32179             :    and new/delete by the used can be caught more readily.  This may change
   32180             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   32181             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   32182             :    deallocate memory allocated using ROSE_MALLOC.
   32183             : */
   32184           0 : void *SgTypeMatrix::operator new ( size_t Size )
   32185             : {
   32186             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   32187             :      * returning or throwing an exception. */
   32188           0 :     ALLOC_MUTEX(SgTypeMatrix, lock);
   32189             : 
   32190             : #if ROSE_ALLOC_TRACE == 2
   32191             : //    printf("SgTypeMatrix::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgTypeMatrix::next_node);
   32192             : #endif
   32193             : 
   32194             : #if USE_CPP_NEW_DELETE_OPERATORS
   32195             :     void *mem = ROSE_MALLOC(Size);
   32196             :     ALLOC_MUTEX(SgTypeMatrix, unlock);
   32197             :     return mem;
   32198             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   32199             : #if ROSE_PEDANTIC_ALLOC
   32200             :     ROSE_ASSERT(Size == sizeof(SgTypeMatrix));
   32201             : #else
   32202           0 :     if (Size != sizeof(SgTypeMatrix)) {
   32203           0 :       void * object = ROSE_MALLOC(Size);
   32204           0 :       ALLOC_MUTEX(SgTypeMatrix, unlock);
   32205             :       return object;
   32206             :     }
   32207             : #endif
   32208             : 
   32209           0 :     if (SgTypeMatrix::next_node == nullptr) {
   32210           0 :         SgTypeMatrix * alloc = (SgTypeMatrix*) ROSE_MALLOC ( SgTypeMatrix::pool_size * sizeof(SgTypeMatrix) );
   32211           0 :         ROSE_ASSERT(alloc != nullptr);
   32212             : 
   32213             : #if ROSE_ALLOC_TRACE == 2
   32214             : //        printf("SgTypeMatrix::alloc\n  block[%zi] = [ %p , %p [\n", SgTypeMatrix::pools.size(), alloc, alloc + SgTypeMatrix::pool_size);
   32215             : #endif
   32216             : 
   32217             : #if ROSE_ALLOC_MEMSET == 1
   32218             : #elif ROSE_ALLOC_MEMSET == 2
   32219             :         memset(alloc, 0x00, SgTypeMatrix::pool_size * sizeof(SgTypeMatrix));
   32220             : #elif ROSE_ALLOC_MEMSET == 3
   32221             :         memset(alloc, 0xAA, SgTypeMatrix::pool_size * sizeof(SgTypeMatrix));
   32222             : #endif
   32223           0 :         for (unsigned i=0; i < SgTypeMatrix::pool_size-1; i++) {
   32224           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
   32225             :         }
   32226           0 :         alloc[SgTypeMatrix::pool_size-1].p_freepointer = nullptr;
   32227             : 
   32228           0 :         SgTypeMatrix::pools.push_back ( (unsigned char *) alloc );
   32229           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgTypeMatrix::pool_size * sizeof(SgTypeMatrix), V_SgTypeMatrix ) );
   32230           0 :         SgTypeMatrix::next_node = alloc;
   32231             :     }
   32232           0 :     ROSE_ASSERT(SgTypeMatrix::next_node != nullptr);
   32233             : 
   32234           0 :     SgTypeMatrix * object = SgTypeMatrix::next_node;
   32235           0 :     SgTypeMatrix::next_node = (SgTypeMatrix*)(object->p_freepointer);
   32236             : 
   32237             : #if ROSE_ALLOC_TRACE == 2
   32238             :     printf("SgTypeMatrix::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeMatrix::next_node);
   32239             : #endif
   32240             : 
   32241           0 :     SgNode * fp = object->p_freepointer;
   32242             : #if ROSE_ALLOC_MEMSET == 1
   32243             : #elif ROSE_ALLOC_MEMSET == 2
   32244             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgTypeMatrix) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   32245             : #elif ROSE_ALLOC_MEMSET == 3
   32246             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgTypeMatrix) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   32247             : #endif
   32248           0 :     object->p_freepointer = fp;
   32249             : 
   32250             : #if ROSE_ALLOC_TRACE == 2
   32251             : //    printf("SgTypeMatrix::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeMatrix::next_node);
   32252             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   32253             :     Rose::MemPool::snapshot(oss.str());
   32254             :     alloc_trace_cnt++;
   32255             : #endif
   32256             : 
   32257           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   32258             : 
   32259           0 :     ALLOC_MUTEX(SgTypeMatrix, unlock);
   32260             : 
   32261             :     return object;
   32262             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   32263             : }
   32264             : 
   32265             : 
   32266             : 
   32267             : /*! \brief Delete operator for SgTypeMatrix.
   32268             : 
   32269             :    This delete operator implements deallocation using memory pools to 
   32270             :    provide most efficent use of the heap within construction of large ASTs.
   32271             : 
   32272             : \internal The new and delete operators use the lower level C malloc/free
   32273             :    function calls for performance and to make sure that mixing of malloc/free
   32274             :    and new/delete by the used can be caught more readily.  This may change
   32275             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   32276             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   32277             :    deallocate memory allocated using ROSE_MALLOC.
   32278             : */
   32279           0 : void SgTypeMatrix::operator delete(void *Pointer, size_t Size)
   32280             : {
   32281             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   32282             :      * or throwing an exception. */
   32283           0 :     ALLOC_MUTEX(SgTypeMatrix, lock);
   32284             : 
   32285             : #if USE_CPP_NEW_DELETE_OPERATORS
   32286             :     ROSE_FREE(Pointer);
   32287             : #else
   32288             : #if ROSE_PEDANTIC_ALLOC
   32289             :     ROSE_ASSERT(Size == sizeof(SgTypeMatrix));
   32290             : #else
   32291           0 :     if (Size != sizeof(SgTypeMatrix)) {
   32292           0 :       ROSE_FREE(Pointer);
   32293           0 :       ALLOC_MUTEX(SgTypeMatrix, unlock);
   32294             :       return;
   32295             :     }
   32296             : #endif
   32297             : 
   32298           0 :     SgTypeMatrix * object = (SgTypeMatrix*) Pointer;
   32299           0 :     ROSE_ASSERT(object != nullptr);
   32300             : 
   32301             : #if ROSE_ALLOC_TRACE == 2
   32302             : //  printf("SgTypeMatrix::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeMatrix::next_node);
   32303             :     printf("SgTypeMatrix::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeMatrix::next_node);
   32304             : #endif
   32305             : 
   32306             : #if ROSE_PEDANTIC_ALLOC
   32307             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   32308             : #endif
   32309             : 
   32310             : #if ROSE_ALLOC_MEMSET == 1
   32311             : #elif ROSE_ALLOC_MEMSET == 2
   32312             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgTypeMatrix) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   32313             : #elif ROSE_ALLOC_MEMSET == 3
   32314             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgTypeMatrix) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   32315             : #endif
   32316             : 
   32317             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   32318             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   32319             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   32320             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   32321             : #else
   32322           0 :     object->p_freepointer = SgTypeMatrix::next_node;
   32323           0 :     SgTypeMatrix::next_node = object;
   32324             : #endif
   32325             : 
   32326             : #if ROSE_ALLOC_TRACE == 2
   32327             : //  printf("SgTypeMatrix::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeMatrix::next_node);
   32328             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   32329             :     Rose::MemPool::snapshot(oss.str());
   32330             :     alloc_trace_cnt++;
   32331             : #endif
   32332             : 
   32333             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   32334             : 
   32335           0 :     ALLOC_MUTEX(SgTypeMatrix, unlock);
   32336             : }
   32337             : 
   32338             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   32339             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   32340             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   32341             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   32342             : // Also, note comment below from Robb (copied from the Common.code file).
   32343             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   32344             : //
   32345             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   32346             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   32347             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   32348             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   32349             : #if 0
   32350             : void SgTypeMatrix::operator delete(void* pointer) { SgTypeMatrix::operator delete (pointer, sizeof(SgTypeMatrix)); };
   32351             : #endif
   32352             : /* #line 32353 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   32353             : 
   32354             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   32355             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   32356             : // obviously imply C++.
   32357             : 
   32358             : // This implements the support within ROSE for memory pools.  Memory pools
   32359             : // support the most condensed usage of memory within the construction of
   32360             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   32361             : // by a new operator written for each class.
   32362             : 
   32363             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   32364             :     // User wants multi-thread support and POSIX threads are available.
   32365             : #   include <pthread.h>
   32366             :     static pthread_mutex_t SgTypeTuple_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   32367             : #else
   32368             :      // Cause synchronization to be skipped.
   32369             : #    ifndef ALLOC_MUTEX
   32370             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   32371             : #    endif
   32372             : #    ifdef _REENTRANT
   32373             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   32374             : #       ifdef _MSC_VER
   32375             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   32376             : #       else
   32377             : #           warning "POSIX threads are not available; synchronization being skipped"
   32378             : #       endif
   32379             : #    endif
   32380             : #endif
   32381             : 
   32382             : #ifndef ROSE_ALLOC_TRACE
   32383             : #  define ROSE_ALLOC_TRACE 0
   32384             : #endif
   32385             : 
   32386             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   32387             : #define ROSE_ALLOC_TRACE_CNT
   32388             : #include "memory-pool-snapshot.h"
   32389             : unsigned long alloc_trace_cnt = 0;
   32390             : #endif
   32391             : 
   32392             : #if ROSE_ALLOC_TRACE
   32393             : const unsigned SgTypeTuple::pool_size = 5;
   32394             : #else
   32395             : const unsigned SgTypeTuple::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   32396             : #endif
   32397             : 
   32398             : #ifndef ROSE_ALLOC_MEMSET
   32399             : #  define ROSE_ALLOC_MEMSET 0
   32400             : #endif
   32401             : 
   32402             : #ifndef ROSE_PEDANTIC_ALLOC
   32403             : #  define ROSE_PEDANTIC_ALLOC 0
   32404             : #endif
   32405             : 
   32406             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   32407             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   32408             : #endif
   32409             : 
   32410             : #if !defined(SGNODE__ALL_POOLS)
   32411             : #define SGNODE__ALL_POOLS
   32412             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   32413             : #endif
   32414             : 
   32415             : SgTypeTuple* SgTypeTuple::next_node = nullptr;
   32416             : std::vector<unsigned char*> SgTypeTuple::pools;
   32417             : 
   32418             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   32419             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   32420             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   32421             : // around this macro definition rather than each use).
   32422             : #ifndef ALLOC_MUTEX
   32423             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   32424             :         do {                                                                     \
   32425             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   32426             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   32427             :                 abort();                                                         \
   32428             :             }                                                                    \
   32429             :         } while (0);
   32430             : #endif
   32431             : 
   32432             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   32433             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   32434             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   32435             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   32436             : 
   32437             : /*! \brief New operator for SgTypeTuple.
   32438             : 
   32439             :    This new operator implements memory pools to provide most efficent 
   32440             :    use of the heap within construction of large ASTs.
   32441             : 
   32442             : \internal The new and delete operators use the lower level C malloc/free
   32443             :    function calls for performance and to make sure that mixing of malloc/free
   32444             :    and new/delete by the used can be caught more readily.  This may change
   32445             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   32446             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   32447             :    deallocate memory allocated using ROSE_MALLOC.
   32448             : */
   32449           0 : void *SgTypeTuple::operator new ( size_t Size )
   32450             : {
   32451             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   32452             :      * returning or throwing an exception. */
   32453           0 :     ALLOC_MUTEX(SgTypeTuple, lock);
   32454             : 
   32455             : #if ROSE_ALLOC_TRACE == 2
   32456             : //    printf("SgTypeTuple::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgTypeTuple::next_node);
   32457             : #endif
   32458             : 
   32459             : #if USE_CPP_NEW_DELETE_OPERATORS
   32460             :     void *mem = ROSE_MALLOC(Size);
   32461             :     ALLOC_MUTEX(SgTypeTuple, unlock);
   32462             :     return mem;
   32463             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   32464             : #if ROSE_PEDANTIC_ALLOC
   32465             :     ROSE_ASSERT(Size == sizeof(SgTypeTuple));
   32466             : #else
   32467           0 :     if (Size != sizeof(SgTypeTuple)) {
   32468           0 :       void * object = ROSE_MALLOC(Size);
   32469           0 :       ALLOC_MUTEX(SgTypeTuple, unlock);
   32470             :       return object;
   32471             :     }
   32472             : #endif
   32473             : 
   32474           0 :     if (SgTypeTuple::next_node == nullptr) {
   32475           0 :         SgTypeTuple * alloc = (SgTypeTuple*) ROSE_MALLOC ( SgTypeTuple::pool_size * sizeof(SgTypeTuple) );
   32476           0 :         ROSE_ASSERT(alloc != nullptr);
   32477             : 
   32478             : #if ROSE_ALLOC_TRACE == 2
   32479             : //        printf("SgTypeTuple::alloc\n  block[%zi] = [ %p , %p [\n", SgTypeTuple::pools.size(), alloc, alloc + SgTypeTuple::pool_size);
   32480             : #endif
   32481             : 
   32482             : #if ROSE_ALLOC_MEMSET == 1
   32483             : #elif ROSE_ALLOC_MEMSET == 2
   32484             :         memset(alloc, 0x00, SgTypeTuple::pool_size * sizeof(SgTypeTuple));
   32485             : #elif ROSE_ALLOC_MEMSET == 3
   32486             :         memset(alloc, 0xAA, SgTypeTuple::pool_size * sizeof(SgTypeTuple));
   32487             : #endif
   32488           0 :         for (unsigned i=0; i < SgTypeTuple::pool_size-1; i++) {
   32489           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
   32490             :         }
   32491           0 :         alloc[SgTypeTuple::pool_size-1].p_freepointer = nullptr;
   32492             : 
   32493           0 :         SgTypeTuple::pools.push_back ( (unsigned char *) alloc );
   32494           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgTypeTuple::pool_size * sizeof(SgTypeTuple), V_SgTypeTuple ) );
   32495           0 :         SgTypeTuple::next_node = alloc;
   32496             :     }
   32497           0 :     ROSE_ASSERT(SgTypeTuple::next_node != nullptr);
   32498             : 
   32499           0 :     SgTypeTuple * object = SgTypeTuple::next_node;
   32500           0 :     SgTypeTuple::next_node = (SgTypeTuple*)(object->p_freepointer);
   32501             : 
   32502             : #if ROSE_ALLOC_TRACE == 2
   32503             :     printf("SgTypeTuple::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeTuple::next_node);
   32504             : #endif
   32505             : 
   32506           0 :     SgNode * fp = object->p_freepointer;
   32507             : #if ROSE_ALLOC_MEMSET == 1
   32508             : #elif ROSE_ALLOC_MEMSET == 2
   32509             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgTypeTuple) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   32510             : #elif ROSE_ALLOC_MEMSET == 3
   32511             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgTypeTuple) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   32512             : #endif
   32513           0 :     object->p_freepointer = fp;
   32514             : 
   32515             : #if ROSE_ALLOC_TRACE == 2
   32516             : //    printf("SgTypeTuple::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeTuple::next_node);
   32517             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   32518             :     Rose::MemPool::snapshot(oss.str());
   32519             :     alloc_trace_cnt++;
   32520             : #endif
   32521             : 
   32522           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   32523             : 
   32524           0 :     ALLOC_MUTEX(SgTypeTuple, unlock);
   32525             : 
   32526             :     return object;
   32527             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   32528             : }
   32529             : 
   32530             : 
   32531             : 
   32532             : /*! \brief Delete operator for SgTypeTuple.
   32533             : 
   32534             :    This delete operator implements deallocation using memory pools to 
   32535             :    provide most efficent use of the heap within construction of large ASTs.
   32536             : 
   32537             : \internal The new and delete operators use the lower level C malloc/free
   32538             :    function calls for performance and to make sure that mixing of malloc/free
   32539             :    and new/delete by the used can be caught more readily.  This may change
   32540             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   32541             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   32542             :    deallocate memory allocated using ROSE_MALLOC.
   32543             : */
   32544           0 : void SgTypeTuple::operator delete(void *Pointer, size_t Size)
   32545             : {
   32546             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   32547             :      * or throwing an exception. */
   32548           0 :     ALLOC_MUTEX(SgTypeTuple, lock);
   32549             : 
   32550             : #if USE_CPP_NEW_DELETE_OPERATORS
   32551             :     ROSE_FREE(Pointer);
   32552             : #else
   32553             : #if ROSE_PEDANTIC_ALLOC
   32554             :     ROSE_ASSERT(Size == sizeof(SgTypeTuple));
   32555             : #else
   32556           0 :     if (Size != sizeof(SgTypeTuple)) {
   32557           0 :       ROSE_FREE(Pointer);
   32558           0 :       ALLOC_MUTEX(SgTypeTuple, unlock);
   32559             :       return;
   32560             :     }
   32561             : #endif
   32562             : 
   32563           0 :     SgTypeTuple * object = (SgTypeTuple*) Pointer;
   32564           0 :     ROSE_ASSERT(object != nullptr);
   32565             : 
   32566             : #if ROSE_ALLOC_TRACE == 2
   32567             : //  printf("SgTypeTuple::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeTuple::next_node);
   32568             :     printf("SgTypeTuple::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeTuple::next_node);
   32569             : #endif
   32570             : 
   32571             : #if ROSE_PEDANTIC_ALLOC
   32572             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   32573             : #endif
   32574             : 
   32575             : #if ROSE_ALLOC_MEMSET == 1
   32576             : #elif ROSE_ALLOC_MEMSET == 2
   32577             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgTypeTuple) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   32578             : #elif ROSE_ALLOC_MEMSET == 3
   32579             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgTypeTuple) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   32580             : #endif
   32581             : 
   32582             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   32583             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   32584             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   32585             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   32586             : #else
   32587           0 :     object->p_freepointer = SgTypeTuple::next_node;
   32588           0 :     SgTypeTuple::next_node = object;
   32589             : #endif
   32590             : 
   32591             : #if ROSE_ALLOC_TRACE == 2
   32592             : //  printf("SgTypeTuple::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeTuple::next_node);
   32593             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   32594             :     Rose::MemPool::snapshot(oss.str());
   32595             :     alloc_trace_cnt++;
   32596             : #endif
   32597             : 
   32598             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   32599             : 
   32600           0 :     ALLOC_MUTEX(SgTypeTuple, unlock);
   32601             : }
   32602             : 
   32603             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   32604             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   32605             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   32606             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   32607             : // Also, note comment below from Robb (copied from the Common.code file).
   32608             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   32609             : //
   32610             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   32611             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   32612             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   32613             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   32614             : #if 0
   32615             : void SgTypeTuple::operator delete(void* pointer) { SgTypeTuple::operator delete (pointer, sizeof(SgTypeTuple)); };
   32616             : #endif
   32617             : /* #line 32618 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   32618             : 
   32619             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   32620             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   32621             : // obviously imply C++.
   32622             : 
   32623             : // This implements the support within ROSE for memory pools.  Memory pools
   32624             : // support the most condensed usage of memory within the construction of
   32625             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   32626             : // by a new operator written for each class.
   32627             : 
   32628             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   32629             :     // User wants multi-thread support and POSIX threads are available.
   32630             : #   include <pthread.h>
   32631             :     static pthread_mutex_t SgTypeChar16_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   32632             : #else
   32633             :      // Cause synchronization to be skipped.
   32634             : #    ifndef ALLOC_MUTEX
   32635             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   32636             : #    endif
   32637             : #    ifdef _REENTRANT
   32638             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   32639             : #       ifdef _MSC_VER
   32640             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   32641             : #       else
   32642             : #           warning "POSIX threads are not available; synchronization being skipped"
   32643             : #       endif
   32644             : #    endif
   32645             : #endif
   32646             : 
   32647             : #ifndef ROSE_ALLOC_TRACE
   32648             : #  define ROSE_ALLOC_TRACE 0
   32649             : #endif
   32650             : 
   32651             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   32652             : #define ROSE_ALLOC_TRACE_CNT
   32653             : #include "memory-pool-snapshot.h"
   32654             : unsigned long alloc_trace_cnt = 0;
   32655             : #endif
   32656             : 
   32657             : #if ROSE_ALLOC_TRACE
   32658             : const unsigned SgTypeChar16::pool_size = 5;
   32659             : #else
   32660             : const unsigned SgTypeChar16::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   32661             : #endif
   32662             : 
   32663             : #ifndef ROSE_ALLOC_MEMSET
   32664             : #  define ROSE_ALLOC_MEMSET 0
   32665             : #endif
   32666             : 
   32667             : #ifndef ROSE_PEDANTIC_ALLOC
   32668             : #  define ROSE_PEDANTIC_ALLOC 0
   32669             : #endif
   32670             : 
   32671             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   32672             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   32673             : #endif
   32674             : 
   32675             : #if !defined(SGNODE__ALL_POOLS)
   32676             : #define SGNODE__ALL_POOLS
   32677             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   32678             : #endif
   32679             : 
   32680             : SgTypeChar16* SgTypeChar16::next_node = nullptr;
   32681             : std::vector<unsigned char*> SgTypeChar16::pools;
   32682             : 
   32683             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   32684             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   32685             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   32686             : // around this macro definition rather than each use).
   32687             : #ifndef ALLOC_MUTEX
   32688             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   32689             :         do {                                                                     \
   32690             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   32691             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   32692             :                 abort();                                                         \
   32693             :             }                                                                    \
   32694             :         } while (0);
   32695             : #endif
   32696             : 
   32697             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   32698             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   32699             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   32700             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   32701             : 
   32702             : /*! \brief New operator for SgTypeChar16.
   32703             : 
   32704             :    This new operator implements memory pools to provide most efficent 
   32705             :    use of the heap within construction of large ASTs.
   32706             : 
   32707             : \internal The new and delete operators use the lower level C malloc/free
   32708             :    function calls for performance and to make sure that mixing of malloc/free
   32709             :    and new/delete by the used can be caught more readily.  This may change
   32710             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   32711             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   32712             :    deallocate memory allocated using ROSE_MALLOC.
   32713             : */
   32714          11 : void *SgTypeChar16::operator new ( size_t Size )
   32715             : {
   32716             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   32717             :      * returning or throwing an exception. */
   32718          11 :     ALLOC_MUTEX(SgTypeChar16, lock);
   32719             : 
   32720             : #if ROSE_ALLOC_TRACE == 2
   32721             : //    printf("SgTypeChar16::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgTypeChar16::next_node);
   32722             : #endif
   32723             : 
   32724             : #if USE_CPP_NEW_DELETE_OPERATORS
   32725             :     void *mem = ROSE_MALLOC(Size);
   32726             :     ALLOC_MUTEX(SgTypeChar16, unlock);
   32727             :     return mem;
   32728             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   32729             : #if ROSE_PEDANTIC_ALLOC
   32730             :     ROSE_ASSERT(Size == sizeof(SgTypeChar16));
   32731             : #else
   32732          11 :     if (Size != sizeof(SgTypeChar16)) {
   32733           0 :       void * object = ROSE_MALLOC(Size);
   32734           0 :       ALLOC_MUTEX(SgTypeChar16, unlock);
   32735             :       return object;
   32736             :     }
   32737             : #endif
   32738             : 
   32739          11 :     if (SgTypeChar16::next_node == nullptr) {
   32740          10 :         SgTypeChar16 * alloc = (SgTypeChar16*) ROSE_MALLOC ( SgTypeChar16::pool_size * sizeof(SgTypeChar16) );
   32741          10 :         ROSE_ASSERT(alloc != nullptr);
   32742             : 
   32743             : #if ROSE_ALLOC_TRACE == 2
   32744             : //        printf("SgTypeChar16::alloc\n  block[%zi] = [ %p , %p [\n", SgTypeChar16::pools.size(), alloc, alloc + SgTypeChar16::pool_size);
   32745             : #endif
   32746             : 
   32747             : #if ROSE_ALLOC_MEMSET == 1
   32748             : #elif ROSE_ALLOC_MEMSET == 2
   32749             :         memset(alloc, 0x00, SgTypeChar16::pool_size * sizeof(SgTypeChar16));
   32750             : #elif ROSE_ALLOC_MEMSET == 3
   32751             :         memset(alloc, 0xAA, SgTypeChar16::pool_size * sizeof(SgTypeChar16));
   32752             : #endif
   32753       20000 :         for (unsigned i=0; i < SgTypeChar16::pool_size-1; i++) {
   32754       19990 :           alloc[i].p_freepointer = &(alloc[i+1]);
   32755             :         }
   32756          10 :         alloc[SgTypeChar16::pool_size-1].p_freepointer = nullptr;
   32757             : 
   32758          10 :         SgTypeChar16::pools.push_back ( (unsigned char *) alloc );
   32759          10 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgTypeChar16::pool_size * sizeof(SgTypeChar16), V_SgTypeChar16 ) );
   32760          10 :         SgTypeChar16::next_node = alloc;
   32761             :     }
   32762          11 :     ROSE_ASSERT(SgTypeChar16::next_node != nullptr);
   32763             : 
   32764          11 :     SgTypeChar16 * object = SgTypeChar16::next_node;
   32765          11 :     SgTypeChar16::next_node = (SgTypeChar16*)(object->p_freepointer);
   32766             : 
   32767             : #if ROSE_ALLOC_TRACE == 2
   32768             :     printf("SgTypeChar16::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeChar16::next_node);
   32769             : #endif
   32770             : 
   32771          11 :     SgNode * fp = object->p_freepointer;
   32772             : #if ROSE_ALLOC_MEMSET == 1
   32773             : #elif ROSE_ALLOC_MEMSET == 2
   32774             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgTypeChar16) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   32775             : #elif ROSE_ALLOC_MEMSET == 3
   32776             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgTypeChar16) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   32777             : #endif
   32778          11 :     object->p_freepointer = fp;
   32779             : 
   32780             : #if ROSE_ALLOC_TRACE == 2
   32781             : //    printf("SgTypeChar16::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeChar16::next_node);
   32782             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   32783             :     Rose::MemPool::snapshot(oss.str());
   32784             :     alloc_trace_cnt++;
   32785             : #endif
   32786             : 
   32787          11 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   32788             : 
   32789          11 :     ALLOC_MUTEX(SgTypeChar16, unlock);
   32790             : 
   32791             :     return object;
   32792             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   32793             : }
   32794             : 
   32795             : 
   32796             : 
   32797             : /*! \brief Delete operator for SgTypeChar16.
   32798             : 
   32799             :    This delete operator implements deallocation using memory pools to 
   32800             :    provide most efficent use of the heap within construction of large ASTs.
   32801             : 
   32802             : \internal The new and delete operators use the lower level C malloc/free
   32803             :    function calls for performance and to make sure that mixing of malloc/free
   32804             :    and new/delete by the used can be caught more readily.  This may change
   32805             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   32806             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   32807             :    deallocate memory allocated using ROSE_MALLOC.
   32808             : */
   32809           2 : void SgTypeChar16::operator delete(void *Pointer, size_t Size)
   32810             : {
   32811             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   32812             :      * or throwing an exception. */
   32813           2 :     ALLOC_MUTEX(SgTypeChar16, lock);
   32814             : 
   32815             : #if USE_CPP_NEW_DELETE_OPERATORS
   32816             :     ROSE_FREE(Pointer);
   32817             : #else
   32818             : #if ROSE_PEDANTIC_ALLOC
   32819             :     ROSE_ASSERT(Size == sizeof(SgTypeChar16));
   32820             : #else
   32821           2 :     if (Size != sizeof(SgTypeChar16)) {
   32822           0 :       ROSE_FREE(Pointer);
   32823           0 :       ALLOC_MUTEX(SgTypeChar16, unlock);
   32824             :       return;
   32825             :     }
   32826             : #endif
   32827             : 
   32828           2 :     SgTypeChar16 * object = (SgTypeChar16*) Pointer;
   32829           2 :     ROSE_ASSERT(object != nullptr);
   32830             : 
   32831             : #if ROSE_ALLOC_TRACE == 2
   32832             : //  printf("SgTypeChar16::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeChar16::next_node);
   32833             :     printf("SgTypeChar16::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeChar16::next_node);
   32834             : #endif
   32835             : 
   32836             : #if ROSE_PEDANTIC_ALLOC
   32837             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   32838             : #endif
   32839             : 
   32840             : #if ROSE_ALLOC_MEMSET == 1
   32841             : #elif ROSE_ALLOC_MEMSET == 2
   32842             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgTypeChar16) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   32843             : #elif ROSE_ALLOC_MEMSET == 3
   32844             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgTypeChar16) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   32845             : #endif
   32846             : 
   32847             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   32848             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   32849             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   32850             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   32851             : #else
   32852           2 :     object->p_freepointer = SgTypeChar16::next_node;
   32853           2 :     SgTypeChar16::next_node = object;
   32854             : #endif
   32855             : 
   32856             : #if ROSE_ALLOC_TRACE == 2
   32857             : //  printf("SgTypeChar16::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeChar16::next_node);
   32858             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   32859             :     Rose::MemPool::snapshot(oss.str());
   32860             :     alloc_trace_cnt++;
   32861             : #endif
   32862             : 
   32863             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   32864             : 
   32865           2 :     ALLOC_MUTEX(SgTypeChar16, unlock);
   32866             : }
   32867             : 
   32868             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   32869             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   32870             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   32871             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   32872             : // Also, note comment below from Robb (copied from the Common.code file).
   32873             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   32874             : //
   32875             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   32876             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   32877             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   32878             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   32879             : #if 0
   32880             : void SgTypeChar16::operator delete(void* pointer) { SgTypeChar16::operator delete (pointer, sizeof(SgTypeChar16)); };
   32881             : #endif
   32882             : /* #line 32883 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   32883             : 
   32884             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   32885             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   32886             : // obviously imply C++.
   32887             : 
   32888             : // This implements the support within ROSE for memory pools.  Memory pools
   32889             : // support the most condensed usage of memory within the construction of
   32890             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   32891             : // by a new operator written for each class.
   32892             : 
   32893             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   32894             :     // User wants multi-thread support and POSIX threads are available.
   32895             : #   include <pthread.h>
   32896             :     static pthread_mutex_t SgTypeChar32_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   32897             : #else
   32898             :      // Cause synchronization to be skipped.
   32899             : #    ifndef ALLOC_MUTEX
   32900             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   32901             : #    endif
   32902             : #    ifdef _REENTRANT
   32903             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   32904             : #       ifdef _MSC_VER
   32905             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   32906             : #       else
   32907             : #           warning "POSIX threads are not available; synchronization being skipped"
   32908             : #       endif
   32909             : #    endif
   32910             : #endif
   32911             : 
   32912             : #ifndef ROSE_ALLOC_TRACE
   32913             : #  define ROSE_ALLOC_TRACE 0
   32914             : #endif
   32915             : 
   32916             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   32917             : #define ROSE_ALLOC_TRACE_CNT
   32918             : #include "memory-pool-snapshot.h"
   32919             : unsigned long alloc_trace_cnt = 0;
   32920             : #endif
   32921             : 
   32922             : #if ROSE_ALLOC_TRACE
   32923             : const unsigned SgTypeChar32::pool_size = 5;
   32924             : #else
   32925             : const unsigned SgTypeChar32::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   32926             : #endif
   32927             : 
   32928             : #ifndef ROSE_ALLOC_MEMSET
   32929             : #  define ROSE_ALLOC_MEMSET 0
   32930             : #endif
   32931             : 
   32932             : #ifndef ROSE_PEDANTIC_ALLOC
   32933             : #  define ROSE_PEDANTIC_ALLOC 0
   32934             : #endif
   32935             : 
   32936             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   32937             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   32938             : #endif
   32939             : 
   32940             : #if !defined(SGNODE__ALL_POOLS)
   32941             : #define SGNODE__ALL_POOLS
   32942             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   32943             : #endif
   32944             : 
   32945             : SgTypeChar32* SgTypeChar32::next_node = nullptr;
   32946             : std::vector<unsigned char*> SgTypeChar32::pools;
   32947             : 
   32948             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   32949             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   32950             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   32951             : // around this macro definition rather than each use).
   32952             : #ifndef ALLOC_MUTEX
   32953             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   32954             :         do {                                                                     \
   32955             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   32956             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   32957             :                 abort();                                                         \
   32958             :             }                                                                    \
   32959             :         } while (0);
   32960             : #endif
   32961             : 
   32962             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   32963             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   32964             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   32965             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   32966             : 
   32967             : /*! \brief New operator for SgTypeChar32.
   32968             : 
   32969             :    This new operator implements memory pools to provide most efficent 
   32970             :    use of the heap within construction of large ASTs.
   32971             : 
   32972             : \internal The new and delete operators use the lower level C malloc/free
   32973             :    function calls for performance and to make sure that mixing of malloc/free
   32974             :    and new/delete by the used can be caught more readily.  This may change
   32975             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   32976             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   32977             :    deallocate memory allocated using ROSE_MALLOC.
   32978             : */
   32979          11 : void *SgTypeChar32::operator new ( size_t Size )
   32980             : {
   32981             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   32982             :      * returning or throwing an exception. */
   32983          11 :     ALLOC_MUTEX(SgTypeChar32, lock);
   32984             : 
   32985             : #if ROSE_ALLOC_TRACE == 2
   32986             : //    printf("SgTypeChar32::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgTypeChar32::next_node);
   32987             : #endif
   32988             : 
   32989             : #if USE_CPP_NEW_DELETE_OPERATORS
   32990             :     void *mem = ROSE_MALLOC(Size);
   32991             :     ALLOC_MUTEX(SgTypeChar32, unlock);
   32992             :     return mem;
   32993             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   32994             : #if ROSE_PEDANTIC_ALLOC
   32995             :     ROSE_ASSERT(Size == sizeof(SgTypeChar32));
   32996             : #else
   32997          11 :     if (Size != sizeof(SgTypeChar32)) {
   32998           0 :       void * object = ROSE_MALLOC(Size);
   32999           0 :       ALLOC_MUTEX(SgTypeChar32, unlock);
   33000             :       return object;
   33001             :     }
   33002             : #endif
   33003             : 
   33004          11 :     if (SgTypeChar32::next_node == nullptr) {
   33005          10 :         SgTypeChar32 * alloc = (SgTypeChar32*) ROSE_MALLOC ( SgTypeChar32::pool_size * sizeof(SgTypeChar32) );
   33006          10 :         ROSE_ASSERT(alloc != nullptr);
   33007             : 
   33008             : #if ROSE_ALLOC_TRACE == 2
   33009             : //        printf("SgTypeChar32::alloc\n  block[%zi] = [ %p , %p [\n", SgTypeChar32::pools.size(), alloc, alloc + SgTypeChar32::pool_size);
   33010             : #endif
   33011             : 
   33012             : #if ROSE_ALLOC_MEMSET == 1
   33013             : #elif ROSE_ALLOC_MEMSET == 2
   33014             :         memset(alloc, 0x00, SgTypeChar32::pool_size * sizeof(SgTypeChar32));
   33015             : #elif ROSE_ALLOC_MEMSET == 3
   33016             :         memset(alloc, 0xAA, SgTypeChar32::pool_size * sizeof(SgTypeChar32));
   33017             : #endif
   33018       20000 :         for (unsigned i=0; i < SgTypeChar32::pool_size-1; i++) {
   33019       19990 :           alloc[i].p_freepointer = &(alloc[i+1]);
   33020             :         }
   33021          10 :         alloc[SgTypeChar32::pool_size-1].p_freepointer = nullptr;
   33022             : 
   33023          10 :         SgTypeChar32::pools.push_back ( (unsigned char *) alloc );
   33024          10 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgTypeChar32::pool_size * sizeof(SgTypeChar32), V_SgTypeChar32 ) );
   33025          10 :         SgTypeChar32::next_node = alloc;
   33026             :     }
   33027          11 :     ROSE_ASSERT(SgTypeChar32::next_node != nullptr);
   33028             : 
   33029          11 :     SgTypeChar32 * object = SgTypeChar32::next_node;
   33030          11 :     SgTypeChar32::next_node = (SgTypeChar32*)(object->p_freepointer);
   33031             : 
   33032             : #if ROSE_ALLOC_TRACE == 2
   33033             :     printf("SgTypeChar32::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeChar32::next_node);
   33034             : #endif
   33035             : 
   33036          11 :     SgNode * fp = object->p_freepointer;
   33037             : #if ROSE_ALLOC_MEMSET == 1
   33038             : #elif ROSE_ALLOC_MEMSET == 2
   33039             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgTypeChar32) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   33040             : #elif ROSE_ALLOC_MEMSET == 3
   33041             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgTypeChar32) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   33042             : #endif
   33043          11 :     object->p_freepointer = fp;
   33044             : 
   33045             : #if ROSE_ALLOC_TRACE == 2
   33046             : //    printf("SgTypeChar32::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeChar32::next_node);
   33047             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   33048             :     Rose::MemPool::snapshot(oss.str());
   33049             :     alloc_trace_cnt++;
   33050             : #endif
   33051             : 
   33052          11 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   33053             : 
   33054          11 :     ALLOC_MUTEX(SgTypeChar32, unlock);
   33055             : 
   33056             :     return object;
   33057             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   33058             : }
   33059             : 
   33060             : 
   33061             : 
   33062             : /*! \brief Delete operator for SgTypeChar32.
   33063             : 
   33064             :    This delete operator implements deallocation using memory pools to 
   33065             :    provide most efficent use of the heap within construction of large ASTs.
   33066             : 
   33067             : \internal The new and delete operators use the lower level C malloc/free
   33068             :    function calls for performance and to make sure that mixing of malloc/free
   33069             :    and new/delete by the used can be caught more readily.  This may change
   33070             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   33071             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   33072             :    deallocate memory allocated using ROSE_MALLOC.
   33073             : */
   33074           2 : void SgTypeChar32::operator delete(void *Pointer, size_t Size)
   33075             : {
   33076             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   33077             :      * or throwing an exception. */
   33078           2 :     ALLOC_MUTEX(SgTypeChar32, lock);
   33079             : 
   33080             : #if USE_CPP_NEW_DELETE_OPERATORS
   33081             :     ROSE_FREE(Pointer);
   33082             : #else
   33083             : #if ROSE_PEDANTIC_ALLOC
   33084             :     ROSE_ASSERT(Size == sizeof(SgTypeChar32));
   33085             : #else
   33086           2 :     if (Size != sizeof(SgTypeChar32)) {
   33087           0 :       ROSE_FREE(Pointer);
   33088           0 :       ALLOC_MUTEX(SgTypeChar32, unlock);
   33089             :       return;
   33090             :     }
   33091             : #endif
   33092             : 
   33093           2 :     SgTypeChar32 * object = (SgTypeChar32*) Pointer;
   33094           2 :     ROSE_ASSERT(object != nullptr);
   33095             : 
   33096             : #if ROSE_ALLOC_TRACE == 2
   33097             : //  printf("SgTypeChar32::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeChar32::next_node);
   33098             :     printf("SgTypeChar32::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeChar32::next_node);
   33099             : #endif
   33100             : 
   33101             : #if ROSE_PEDANTIC_ALLOC
   33102             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   33103             : #endif
   33104             : 
   33105             : #if ROSE_ALLOC_MEMSET == 1
   33106             : #elif ROSE_ALLOC_MEMSET == 2
   33107             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgTypeChar32) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   33108             : #elif ROSE_ALLOC_MEMSET == 3
   33109             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgTypeChar32) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   33110             : #endif
   33111             : 
   33112             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   33113             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   33114             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   33115             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   33116             : #else
   33117           2 :     object->p_freepointer = SgTypeChar32::next_node;
   33118           2 :     SgTypeChar32::next_node = object;
   33119             : #endif
   33120             : 
   33121             : #if ROSE_ALLOC_TRACE == 2
   33122             : //  printf("SgTypeChar32::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeChar32::next_node);
   33123             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   33124             :     Rose::MemPool::snapshot(oss.str());
   33125             :     alloc_trace_cnt++;
   33126             : #endif
   33127             : 
   33128             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   33129             : 
   33130           2 :     ALLOC_MUTEX(SgTypeChar32, unlock);
   33131             : }
   33132             : 
   33133             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   33134             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   33135             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   33136             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   33137             : // Also, note comment below from Robb (copied from the Common.code file).
   33138             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   33139             : //
   33140             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   33141             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   33142             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   33143             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   33144             : #if 0
   33145             : void SgTypeChar32::operator delete(void* pointer) { SgTypeChar32::operator delete (pointer, sizeof(SgTypeChar32)); };
   33146             : #endif
   33147             : /* #line 33148 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   33148             : 
   33149             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   33150             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   33151             : // obviously imply C++.
   33152             : 
   33153             : // This implements the support within ROSE for memory pools.  Memory pools
   33154             : // support the most condensed usage of memory within the construction of
   33155             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   33156             : // by a new operator written for each class.
   33157             : 
   33158             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   33159             :     // User wants multi-thread support and POSIX threads are available.
   33160             : #   include <pthread.h>
   33161             :     static pthread_mutex_t SgTypeFloat128_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   33162             : #else
   33163             :      // Cause synchronization to be skipped.
   33164             : #    ifndef ALLOC_MUTEX
   33165             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   33166             : #    endif
   33167             : #    ifdef _REENTRANT
   33168             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   33169             : #       ifdef _MSC_VER
   33170             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   33171             : #       else
   33172             : #           warning "POSIX threads are not available; synchronization being skipped"
   33173             : #       endif
   33174             : #    endif
   33175             : #endif
   33176             : 
   33177             : #ifndef ROSE_ALLOC_TRACE
   33178             : #  define ROSE_ALLOC_TRACE 0
   33179             : #endif
   33180             : 
   33181             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   33182             : #define ROSE_ALLOC_TRACE_CNT
   33183             : #include "memory-pool-snapshot.h"
   33184             : unsigned long alloc_trace_cnt = 0;
   33185             : #endif
   33186             : 
   33187             : #if ROSE_ALLOC_TRACE
   33188             : const unsigned SgTypeFloat128::pool_size = 5;
   33189             : #else
   33190             : const unsigned SgTypeFloat128::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   33191             : #endif
   33192             : 
   33193             : #ifndef ROSE_ALLOC_MEMSET
   33194             : #  define ROSE_ALLOC_MEMSET 0
   33195             : #endif
   33196             : 
   33197             : #ifndef ROSE_PEDANTIC_ALLOC
   33198             : #  define ROSE_PEDANTIC_ALLOC 0
   33199             : #endif
   33200             : 
   33201             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   33202             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   33203             : #endif
   33204             : 
   33205             : #if !defined(SGNODE__ALL_POOLS)
   33206             : #define SGNODE__ALL_POOLS
   33207             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   33208             : #endif
   33209             : 
   33210             : SgTypeFloat128* SgTypeFloat128::next_node = nullptr;
   33211             : std::vector<unsigned char*> SgTypeFloat128::pools;
   33212             : 
   33213             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   33214             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   33215             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   33216             : // around this macro definition rather than each use).
   33217             : #ifndef ALLOC_MUTEX
   33218             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   33219             :         do {                                                                     \
   33220             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   33221             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   33222             :                 abort();                                                         \
   33223             :             }                                                                    \
   33224             :         } while (0);
   33225             : #endif
   33226             : 
   33227             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   33228             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   33229             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   33230             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   33231             : 
   33232             : /*! \brief New operator for SgTypeFloat128.
   33233             : 
   33234             :    This new operator implements memory pools to provide most efficent 
   33235             :    use of the heap within construction of large ASTs.
   33236             : 
   33237             : \internal The new and delete operators use the lower level C malloc/free
   33238             :    function calls for performance and to make sure that mixing of malloc/free
   33239             :    and new/delete by the used can be caught more readily.  This may change
   33240             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   33241             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   33242             :    deallocate memory allocated using ROSE_MALLOC.
   33243             : */
   33244          27 : void *SgTypeFloat128::operator new ( size_t Size )
   33245             : {
   33246             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   33247             :      * returning or throwing an exception. */
   33248          27 :     ALLOC_MUTEX(SgTypeFloat128, lock);
   33249             : 
   33250             : #if ROSE_ALLOC_TRACE == 2
   33251             : //    printf("SgTypeFloat128::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgTypeFloat128::next_node);
   33252             : #endif
   33253             : 
   33254             : #if USE_CPP_NEW_DELETE_OPERATORS
   33255             :     void *mem = ROSE_MALLOC(Size);
   33256             :     ALLOC_MUTEX(SgTypeFloat128, unlock);
   33257             :     return mem;
   33258             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   33259             : #if ROSE_PEDANTIC_ALLOC
   33260             :     ROSE_ASSERT(Size == sizeof(SgTypeFloat128));
   33261             : #else
   33262          27 :     if (Size != sizeof(SgTypeFloat128)) {
   33263           0 :       void * object = ROSE_MALLOC(Size);
   33264           0 :       ALLOC_MUTEX(SgTypeFloat128, unlock);
   33265             :       return object;
   33266             :     }
   33267             : #endif
   33268             : 
   33269          27 :     if (SgTypeFloat128::next_node == nullptr) {
   33270          13 :         SgTypeFloat128 * alloc = (SgTypeFloat128*) ROSE_MALLOC ( SgTypeFloat128::pool_size * sizeof(SgTypeFloat128) );
   33271          13 :         ROSE_ASSERT(alloc != nullptr);
   33272             : 
   33273             : #if ROSE_ALLOC_TRACE == 2
   33274             : //        printf("SgTypeFloat128::alloc\n  block[%zi] = [ %p , %p [\n", SgTypeFloat128::pools.size(), alloc, alloc + SgTypeFloat128::pool_size);
   33275             : #endif
   33276             : 
   33277             : #if ROSE_ALLOC_MEMSET == 1
   33278             : #elif ROSE_ALLOC_MEMSET == 2
   33279             :         memset(alloc, 0x00, SgTypeFloat128::pool_size * sizeof(SgTypeFloat128));
   33280             : #elif ROSE_ALLOC_MEMSET == 3
   33281             :         memset(alloc, 0xAA, SgTypeFloat128::pool_size * sizeof(SgTypeFloat128));
   33282             : #endif
   33283       26000 :         for (unsigned i=0; i < SgTypeFloat128::pool_size-1; i++) {
   33284       25987 :           alloc[i].p_freepointer = &(alloc[i+1]);
   33285             :         }
   33286          13 :         alloc[SgTypeFloat128::pool_size-1].p_freepointer = nullptr;
   33287             : 
   33288          13 :         SgTypeFloat128::pools.push_back ( (unsigned char *) alloc );
   33289          13 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgTypeFloat128::pool_size * sizeof(SgTypeFloat128), V_SgTypeFloat128 ) );
   33290          13 :         SgTypeFloat128::next_node = alloc;
   33291             :     }
   33292          27 :     ROSE_ASSERT(SgTypeFloat128::next_node != nullptr);
   33293             : 
   33294          27 :     SgTypeFloat128 * object = SgTypeFloat128::next_node;
   33295          27 :     SgTypeFloat128::next_node = (SgTypeFloat128*)(object->p_freepointer);
   33296             : 
   33297             : #if ROSE_ALLOC_TRACE == 2
   33298             :     printf("SgTypeFloat128::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeFloat128::next_node);
   33299             : #endif
   33300             : 
   33301          27 :     SgNode * fp = object->p_freepointer;
   33302             : #if ROSE_ALLOC_MEMSET == 1
   33303             : #elif ROSE_ALLOC_MEMSET == 2
   33304             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgTypeFloat128) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   33305             : #elif ROSE_ALLOC_MEMSET == 3
   33306             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgTypeFloat128) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   33307             : #endif
   33308          27 :     object->p_freepointer = fp;
   33309             : 
   33310             : #if ROSE_ALLOC_TRACE == 2
   33311             : //    printf("SgTypeFloat128::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeFloat128::next_node);
   33312             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   33313             :     Rose::MemPool::snapshot(oss.str());
   33314             :     alloc_trace_cnt++;
   33315             : #endif
   33316             : 
   33317          27 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   33318             : 
   33319          27 :     ALLOC_MUTEX(SgTypeFloat128, unlock);
   33320             : 
   33321             :     return object;
   33322             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   33323             : }
   33324             : 
   33325             : 
   33326             : 
   33327             : /*! \brief Delete operator for SgTypeFloat128.
   33328             : 
   33329             :    This delete operator implements deallocation using memory pools to 
   33330             :    provide most efficent use of the heap within construction of large ASTs.
   33331             : 
   33332             : \internal The new and delete operators use the lower level C malloc/free
   33333             :    function calls for performance and to make sure that mixing of malloc/free
   33334             :    and new/delete by the used can be caught more readily.  This may change
   33335             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   33336             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   33337             :    deallocate memory allocated using ROSE_MALLOC.
   33338             : */
   33339          15 : void SgTypeFloat128::operator delete(void *Pointer, size_t Size)
   33340             : {
   33341             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   33342             :      * or throwing an exception. */
   33343          15 :     ALLOC_MUTEX(SgTypeFloat128, lock);
   33344             : 
   33345             : #if USE_CPP_NEW_DELETE_OPERATORS
   33346             :     ROSE_FREE(Pointer);
   33347             : #else
   33348             : #if ROSE_PEDANTIC_ALLOC
   33349             :     ROSE_ASSERT(Size == sizeof(SgTypeFloat128));
   33350             : #else
   33351          15 :     if (Size != sizeof(SgTypeFloat128)) {
   33352           0 :       ROSE_FREE(Pointer);
   33353           0 :       ALLOC_MUTEX(SgTypeFloat128, unlock);
   33354             :       return;
   33355             :     }
   33356             : #endif
   33357             : 
   33358          15 :     SgTypeFloat128 * object = (SgTypeFloat128*) Pointer;
   33359          15 :     ROSE_ASSERT(object != nullptr);
   33360             : 
   33361             : #if ROSE_ALLOC_TRACE == 2
   33362             : //  printf("SgTypeFloat128::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeFloat128::next_node);
   33363             :     printf("SgTypeFloat128::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeFloat128::next_node);
   33364             : #endif
   33365             : 
   33366             : #if ROSE_PEDANTIC_ALLOC
   33367             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   33368             : #endif
   33369             : 
   33370             : #if ROSE_ALLOC_MEMSET == 1
   33371             : #elif ROSE_ALLOC_MEMSET == 2
   33372             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgTypeFloat128) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   33373             : #elif ROSE_ALLOC_MEMSET == 3
   33374             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgTypeFloat128) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   33375             : #endif
   33376             : 
   33377             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   33378             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   33379             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   33380             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   33381             : #else
   33382          15 :     object->p_freepointer = SgTypeFloat128::next_node;
   33383          15 :     SgTypeFloat128::next_node = object;
   33384             : #endif
   33385             : 
   33386             : #if ROSE_ALLOC_TRACE == 2
   33387             : //  printf("SgTypeFloat128::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeFloat128::next_node);
   33388             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   33389             :     Rose::MemPool::snapshot(oss.str());
   33390             :     alloc_trace_cnt++;
   33391             : #endif
   33392             : 
   33393             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   33394             : 
   33395          15 :     ALLOC_MUTEX(SgTypeFloat128, unlock);
   33396             : }
   33397             : 
   33398             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   33399             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   33400             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   33401             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   33402             : // Also, note comment below from Robb (copied from the Common.code file).
   33403             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   33404             : //
   33405             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   33406             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   33407             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   33408             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   33409             : #if 0
   33410             : void SgTypeFloat128::operator delete(void* pointer) { SgTypeFloat128::operator delete (pointer, sizeof(SgTypeFloat128)); };
   33411             : #endif
   33412             : /* #line 33413 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   33413             : 
   33414             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   33415             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   33416             : // obviously imply C++.
   33417             : 
   33418             : // This implements the support within ROSE for memory pools.  Memory pools
   33419             : // support the most condensed usage of memory within the construction of
   33420             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   33421             : // by a new operator written for each class.
   33422             : 
   33423             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   33424             :     // User wants multi-thread support and POSIX threads are available.
   33425             : #   include <pthread.h>
   33426             :     static pthread_mutex_t SgTypeFixed_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   33427             : #else
   33428             :      // Cause synchronization to be skipped.
   33429             : #    ifndef ALLOC_MUTEX
   33430             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   33431             : #    endif
   33432             : #    ifdef _REENTRANT
   33433             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   33434             : #       ifdef _MSC_VER
   33435             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   33436             : #       else
   33437             : #           warning "POSIX threads are not available; synchronization being skipped"
   33438             : #       endif
   33439             : #    endif
   33440             : #endif
   33441             : 
   33442             : #ifndef ROSE_ALLOC_TRACE
   33443             : #  define ROSE_ALLOC_TRACE 0
   33444             : #endif
   33445             : 
   33446             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   33447             : #define ROSE_ALLOC_TRACE_CNT
   33448             : #include "memory-pool-snapshot.h"
   33449             : unsigned long alloc_trace_cnt = 0;
   33450             : #endif
   33451             : 
   33452             : #if ROSE_ALLOC_TRACE
   33453             : const unsigned SgTypeFixed::pool_size = 5;
   33454             : #else
   33455             : const unsigned SgTypeFixed::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   33456             : #endif
   33457             : 
   33458             : #ifndef ROSE_ALLOC_MEMSET
   33459             : #  define ROSE_ALLOC_MEMSET 0
   33460             : #endif
   33461             : 
   33462             : #ifndef ROSE_PEDANTIC_ALLOC
   33463             : #  define ROSE_PEDANTIC_ALLOC 0
   33464             : #endif
   33465             : 
   33466             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   33467             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   33468             : #endif
   33469             : 
   33470             : #if !defined(SGNODE__ALL_POOLS)
   33471             : #define SGNODE__ALL_POOLS
   33472             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   33473             : #endif
   33474             : 
   33475             : SgTypeFixed* SgTypeFixed::next_node = nullptr;
   33476             : std::vector<unsigned char*> SgTypeFixed::pools;
   33477             : 
   33478             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   33479             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   33480             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   33481             : // around this macro definition rather than each use).
   33482             : #ifndef ALLOC_MUTEX
   33483             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   33484             :         do {                                                                     \
   33485             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   33486             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   33487             :                 abort();                                                         \
   33488             :             }                                                                    \
   33489             :         } while (0);
   33490             : #endif
   33491             : 
   33492             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   33493             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   33494             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   33495             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   33496             : 
   33497             : /*! \brief New operator for SgTypeFixed.
   33498             : 
   33499             :    This new operator implements memory pools to provide most efficent 
   33500             :    use of the heap within construction of large ASTs.
   33501             : 
   33502             : \internal The new and delete operators use the lower level C malloc/free
   33503             :    function calls for performance and to make sure that mixing of malloc/free
   33504             :    and new/delete by the used can be caught more readily.  This may change
   33505             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   33506             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   33507             :    deallocate memory allocated using ROSE_MALLOC.
   33508             : */
   33509           0 : void *SgTypeFixed::operator new ( size_t Size )
   33510             : {
   33511             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   33512             :      * returning or throwing an exception. */
   33513           0 :     ALLOC_MUTEX(SgTypeFixed, lock);
   33514             : 
   33515             : #if ROSE_ALLOC_TRACE == 2
   33516             : //    printf("SgTypeFixed::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgTypeFixed::next_node);
   33517             : #endif
   33518             : 
   33519             : #if USE_CPP_NEW_DELETE_OPERATORS
   33520             :     void *mem = ROSE_MALLOC(Size);
   33521             :     ALLOC_MUTEX(SgTypeFixed, unlock);
   33522             :     return mem;
   33523             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   33524             : #if ROSE_PEDANTIC_ALLOC
   33525             :     ROSE_ASSERT(Size == sizeof(SgTypeFixed));
   33526             : #else
   33527           0 :     if (Size != sizeof(SgTypeFixed)) {
   33528           0 :       void * object = ROSE_MALLOC(Size);
   33529           0 :       ALLOC_MUTEX(SgTypeFixed, unlock);
   33530             :       return object;
   33531             :     }
   33532             : #endif
   33533             : 
   33534           0 :     if (SgTypeFixed::next_node == nullptr) {
   33535           0 :         SgTypeFixed * alloc = (SgTypeFixed*) ROSE_MALLOC ( SgTypeFixed::pool_size * sizeof(SgTypeFixed) );
   33536           0 :         ROSE_ASSERT(alloc != nullptr);
   33537             : 
   33538             : #if ROSE_ALLOC_TRACE == 2
   33539             : //        printf("SgTypeFixed::alloc\n  block[%zi] = [ %p , %p [\n", SgTypeFixed::pools.size(), alloc, alloc + SgTypeFixed::pool_size);
   33540             : #endif
   33541             : 
   33542             : #if ROSE_ALLOC_MEMSET == 1
   33543             : #elif ROSE_ALLOC_MEMSET == 2
   33544             :         memset(alloc, 0x00, SgTypeFixed::pool_size * sizeof(SgTypeFixed));
   33545             : #elif ROSE_ALLOC_MEMSET == 3
   33546             :         memset(alloc, 0xAA, SgTypeFixed::pool_size * sizeof(SgTypeFixed));
   33547             : #endif
   33548           0 :         for (unsigned i=0; i < SgTypeFixed::pool_size-1; i++) {
   33549           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
   33550             :         }
   33551           0 :         alloc[SgTypeFixed::pool_size-1].p_freepointer = nullptr;
   33552             : 
   33553           0 :         SgTypeFixed::pools.push_back ( (unsigned char *) alloc );
   33554           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgTypeFixed::pool_size * sizeof(SgTypeFixed), V_SgTypeFixed ) );
   33555           0 :         SgTypeFixed::next_node = alloc;
   33556             :     }
   33557           0 :     ROSE_ASSERT(SgTypeFixed::next_node != nullptr);
   33558             : 
   33559           0 :     SgTypeFixed * object = SgTypeFixed::next_node;
   33560           0 :     SgTypeFixed::next_node = (SgTypeFixed*)(object->p_freepointer);
   33561             : 
   33562             : #if ROSE_ALLOC_TRACE == 2
   33563             :     printf("SgTypeFixed::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeFixed::next_node);
   33564             : #endif
   33565             : 
   33566           0 :     SgNode * fp = object->p_freepointer;
   33567             : #if ROSE_ALLOC_MEMSET == 1
   33568             : #elif ROSE_ALLOC_MEMSET == 2
   33569             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgTypeFixed) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   33570             : #elif ROSE_ALLOC_MEMSET == 3
   33571             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgTypeFixed) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   33572             : #endif
   33573           0 :     object->p_freepointer = fp;
   33574             : 
   33575             : #if ROSE_ALLOC_TRACE == 2
   33576             : //    printf("SgTypeFixed::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeFixed::next_node);
   33577             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   33578             :     Rose::MemPool::snapshot(oss.str());
   33579             :     alloc_trace_cnt++;
   33580             : #endif
   33581             : 
   33582           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   33583             : 
   33584           0 :     ALLOC_MUTEX(SgTypeFixed, unlock);
   33585             : 
   33586             :     return object;
   33587             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   33588             : }
   33589             : 
   33590             : 
   33591             : 
   33592             : /*! \brief Delete operator for SgTypeFixed.
   33593             : 
   33594             :    This delete operator implements deallocation using memory pools to 
   33595             :    provide most efficent use of the heap within construction of large ASTs.
   33596             : 
   33597             : \internal The new and delete operators use the lower level C malloc/free
   33598             :    function calls for performance and to make sure that mixing of malloc/free
   33599             :    and new/delete by the used can be caught more readily.  This may change
   33600             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   33601             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   33602             :    deallocate memory allocated using ROSE_MALLOC.
   33603             : */
   33604           0 : void SgTypeFixed::operator delete(void *Pointer, size_t Size)
   33605             : {
   33606             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   33607             :      * or throwing an exception. */
   33608           0 :     ALLOC_MUTEX(SgTypeFixed, lock);
   33609             : 
   33610             : #if USE_CPP_NEW_DELETE_OPERATORS
   33611             :     ROSE_FREE(Pointer);
   33612             : #else
   33613             : #if ROSE_PEDANTIC_ALLOC
   33614             :     ROSE_ASSERT(Size == sizeof(SgTypeFixed));
   33615             : #else
   33616           0 :     if (Size != sizeof(SgTypeFixed)) {
   33617           0 :       ROSE_FREE(Pointer);
   33618           0 :       ALLOC_MUTEX(SgTypeFixed, unlock);
   33619             :       return;
   33620             :     }
   33621             : #endif
   33622             : 
   33623           0 :     SgTypeFixed * object = (SgTypeFixed*) Pointer;
   33624           0 :     ROSE_ASSERT(object != nullptr);
   33625             : 
   33626             : #if ROSE_ALLOC_TRACE == 2
   33627             : //  printf("SgTypeFixed::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeFixed::next_node);
   33628             :     printf("SgTypeFixed::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeFixed::next_node);
   33629             : #endif
   33630             : 
   33631             : #if ROSE_PEDANTIC_ALLOC
   33632             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   33633             : #endif
   33634             : 
   33635             : #if ROSE_ALLOC_MEMSET == 1
   33636             : #elif ROSE_ALLOC_MEMSET == 2
   33637             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgTypeFixed) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   33638             : #elif ROSE_ALLOC_MEMSET == 3
   33639             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgTypeFixed) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   33640             : #endif
   33641             : 
   33642             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   33643             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   33644             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   33645             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   33646             : #else
   33647           0 :     object->p_freepointer = SgTypeFixed::next_node;
   33648           0 :     SgTypeFixed::next_node = object;
   33649             : #endif
   33650             : 
   33651             : #if ROSE_ALLOC_TRACE == 2
   33652             : //  printf("SgTypeFixed::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeFixed::next_node);
   33653             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   33654             :     Rose::MemPool::snapshot(oss.str());
   33655             :     alloc_trace_cnt++;
   33656             : #endif
   33657             : 
   33658             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   33659             : 
   33660           0 :     ALLOC_MUTEX(SgTypeFixed, unlock);
   33661             : }
   33662             : 
   33663             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   33664             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   33665             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   33666             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   33667             : // Also, note comment below from Robb (copied from the Common.code file).
   33668             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   33669             : //
   33670             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   33671             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   33672             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   33673             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   33674             : #if 0
   33675             : void SgTypeFixed::operator delete(void* pointer) { SgTypeFixed::operator delete (pointer, sizeof(SgTypeFixed)); };
   33676             : #endif
   33677             : /* #line 33678 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   33678             : 
   33679             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   33680             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   33681             : // obviously imply C++.
   33682             : 
   33683             : // This implements the support within ROSE for memory pools.  Memory pools
   33684             : // support the most condensed usage of memory within the construction of
   33685             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   33686             : // by a new operator written for each class.
   33687             : 
   33688             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   33689             :     // User wants multi-thread support and POSIX threads are available.
   33690             : #   include <pthread.h>
   33691             :     static pthread_mutex_t SgAutoType_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   33692             : #else
   33693             :      // Cause synchronization to be skipped.
   33694             : #    ifndef ALLOC_MUTEX
   33695             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   33696             : #    endif
   33697             : #    ifdef _REENTRANT
   33698             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   33699             : #       ifdef _MSC_VER
   33700             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   33701             : #       else
   33702             : #           warning "POSIX threads are not available; synchronization being skipped"
   33703             : #       endif
   33704             : #    endif
   33705             : #endif
   33706             : 
   33707             : #ifndef ROSE_ALLOC_TRACE
   33708             : #  define ROSE_ALLOC_TRACE 0
   33709             : #endif
   33710             : 
   33711             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   33712             : #define ROSE_ALLOC_TRACE_CNT
   33713             : #include "memory-pool-snapshot.h"
   33714             : unsigned long alloc_trace_cnt = 0;
   33715             : #endif
   33716             : 
   33717             : #if ROSE_ALLOC_TRACE
   33718             : const unsigned SgAutoType::pool_size = 5;
   33719             : #else
   33720             : const unsigned SgAutoType::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   33721             : #endif
   33722             : 
   33723             : #ifndef ROSE_ALLOC_MEMSET
   33724             : #  define ROSE_ALLOC_MEMSET 0
   33725             : #endif
   33726             : 
   33727             : #ifndef ROSE_PEDANTIC_ALLOC
   33728             : #  define ROSE_PEDANTIC_ALLOC 0
   33729             : #endif
   33730             : 
   33731             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   33732             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   33733             : #endif
   33734             : 
   33735             : #if !defined(SGNODE__ALL_POOLS)
   33736             : #define SGNODE__ALL_POOLS
   33737             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   33738             : #endif
   33739             : 
   33740             : SgAutoType* SgAutoType::next_node = nullptr;
   33741             : std::vector<unsigned char*> SgAutoType::pools;
   33742             : 
   33743             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   33744             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   33745             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   33746             : // around this macro definition rather than each use).
   33747             : #ifndef ALLOC_MUTEX
   33748             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   33749             :         do {                                                                     \
   33750             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   33751             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   33752             :                 abort();                                                         \
   33753             :             }                                                                    \
   33754             :         } while (0);
   33755             : #endif
   33756             : 
   33757             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   33758             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   33759             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   33760             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   33761             : 
   33762             : /*! \brief New operator for SgAutoType.
   33763             : 
   33764             :    This new operator implements memory pools to provide most efficent 
   33765             :    use of the heap within construction of large ASTs.
   33766             : 
   33767             : \internal The new and delete operators use the lower level C malloc/free
   33768             :    function calls for performance and to make sure that mixing of malloc/free
   33769             :    and new/delete by the used can be caught more readily.  This may change
   33770             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   33771             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   33772             :    deallocate memory allocated using ROSE_MALLOC.
   33773             : */
   33774         160 : void *SgAutoType::operator new ( size_t Size )
   33775             : {
   33776             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   33777             :      * returning or throwing an exception. */
   33778         160 :     ALLOC_MUTEX(SgAutoType, lock);
   33779             : 
   33780             : #if ROSE_ALLOC_TRACE == 2
   33781             : //    printf("SgAutoType::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgAutoType::next_node);
   33782             : #endif
   33783             : 
   33784             : #if USE_CPP_NEW_DELETE_OPERATORS
   33785             :     void *mem = ROSE_MALLOC(Size);
   33786             :     ALLOC_MUTEX(SgAutoType, unlock);
   33787             :     return mem;
   33788             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   33789             : #if ROSE_PEDANTIC_ALLOC
   33790             :     ROSE_ASSERT(Size == sizeof(SgAutoType));
   33791             : #else
   33792         160 :     if (Size != sizeof(SgAutoType)) {
   33793           0 :       void * object = ROSE_MALLOC(Size);
   33794           0 :       ALLOC_MUTEX(SgAutoType, unlock);
   33795             :       return object;
   33796             :     }
   33797             : #endif
   33798             : 
   33799         160 :     if (SgAutoType::next_node == nullptr) {
   33800          10 :         SgAutoType * alloc = (SgAutoType*) ROSE_MALLOC ( SgAutoType::pool_size * sizeof(SgAutoType) );
   33801          10 :         ROSE_ASSERT(alloc != nullptr);
   33802             : 
   33803             : #if ROSE_ALLOC_TRACE == 2
   33804             : //        printf("SgAutoType::alloc\n  block[%zi] = [ %p , %p [\n", SgAutoType::pools.size(), alloc, alloc + SgAutoType::pool_size);
   33805             : #endif
   33806             : 
   33807             : #if ROSE_ALLOC_MEMSET == 1
   33808             : #elif ROSE_ALLOC_MEMSET == 2
   33809             :         memset(alloc, 0x00, SgAutoType::pool_size * sizeof(SgAutoType));
   33810             : #elif ROSE_ALLOC_MEMSET == 3
   33811             :         memset(alloc, 0xAA, SgAutoType::pool_size * sizeof(SgAutoType));
   33812             : #endif
   33813       20000 :         for (unsigned i=0; i < SgAutoType::pool_size-1; i++) {
   33814       19990 :           alloc[i].p_freepointer = &(alloc[i+1]);
   33815             :         }
   33816          10 :         alloc[SgAutoType::pool_size-1].p_freepointer = nullptr;
   33817             : 
   33818          10 :         SgAutoType::pools.push_back ( (unsigned char *) alloc );
   33819          10 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgAutoType::pool_size * sizeof(SgAutoType), V_SgAutoType ) );
   33820          10 :         SgAutoType::next_node = alloc;
   33821             :     }
   33822         160 :     ROSE_ASSERT(SgAutoType::next_node != nullptr);
   33823             : 
   33824         160 :     SgAutoType * object = SgAutoType::next_node;
   33825         160 :     SgAutoType::next_node = (SgAutoType*)(object->p_freepointer);
   33826             : 
   33827             : #if ROSE_ALLOC_TRACE == 2
   33828             :     printf("SgAutoType::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgAutoType::next_node);
   33829             : #endif
   33830             : 
   33831         160 :     SgNode * fp = object->p_freepointer;
   33832             : #if ROSE_ALLOC_MEMSET == 1
   33833             : #elif ROSE_ALLOC_MEMSET == 2
   33834             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgAutoType) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   33835             : #elif ROSE_ALLOC_MEMSET == 3
   33836             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgAutoType) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   33837             : #endif
   33838         160 :     object->p_freepointer = fp;
   33839             : 
   33840             : #if ROSE_ALLOC_TRACE == 2
   33841             : //    printf("SgAutoType::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgAutoType::next_node);
   33842             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   33843             :     Rose::MemPool::snapshot(oss.str());
   33844             :     alloc_trace_cnt++;
   33845             : #endif
   33846             : 
   33847         160 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   33848             : 
   33849         160 :     ALLOC_MUTEX(SgAutoType, unlock);
   33850             : 
   33851             :     return object;
   33852             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   33853             : }
   33854             : 
   33855             : 
   33856             : 
   33857             : /*! \brief Delete operator for SgAutoType.
   33858             : 
   33859             :    This delete operator implements deallocation using memory pools to 
   33860             :    provide most efficent use of the heap within construction of large ASTs.
   33861             : 
   33862             : \internal The new and delete operators use the lower level C malloc/free
   33863             :    function calls for performance and to make sure that mixing of malloc/free
   33864             :    and new/delete by the used can be caught more readily.  This may change
   33865             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   33866             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   33867             :    deallocate memory allocated using ROSE_MALLOC.
   33868             : */
   33869          28 : void SgAutoType::operator delete(void *Pointer, size_t Size)
   33870             : {
   33871             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   33872             :      * or throwing an exception. */
   33873          28 :     ALLOC_MUTEX(SgAutoType, lock);
   33874             : 
   33875             : #if USE_CPP_NEW_DELETE_OPERATORS
   33876             :     ROSE_FREE(Pointer);
   33877             : #else
   33878             : #if ROSE_PEDANTIC_ALLOC
   33879             :     ROSE_ASSERT(Size == sizeof(SgAutoType));
   33880             : #else
   33881          28 :     if (Size != sizeof(SgAutoType)) {
   33882           0 :       ROSE_FREE(Pointer);
   33883           0 :       ALLOC_MUTEX(SgAutoType, unlock);
   33884             :       return;
   33885             :     }
   33886             : #endif
   33887             : 
   33888          28 :     SgAutoType * object = (SgAutoType*) Pointer;
   33889          28 :     ROSE_ASSERT(object != nullptr);
   33890             : 
   33891             : #if ROSE_ALLOC_TRACE == 2
   33892             : //  printf("SgAutoType::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgAutoType::next_node);
   33893             :     printf("SgAutoType::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgAutoType::next_node);
   33894             : #endif
   33895             : 
   33896             : #if ROSE_PEDANTIC_ALLOC
   33897             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   33898             : #endif
   33899             : 
   33900             : #if ROSE_ALLOC_MEMSET == 1
   33901             : #elif ROSE_ALLOC_MEMSET == 2
   33902             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgAutoType) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   33903             : #elif ROSE_ALLOC_MEMSET == 3
   33904             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgAutoType) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   33905             : #endif
   33906             : 
   33907             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   33908             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   33909             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   33910             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   33911             : #else
   33912          28 :     object->p_freepointer = SgAutoType::next_node;
   33913          28 :     SgAutoType::next_node = object;
   33914             : #endif
   33915             : 
   33916             : #if ROSE_ALLOC_TRACE == 2
   33917             : //  printf("SgAutoType::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgAutoType::next_node);
   33918             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   33919             :     Rose::MemPool::snapshot(oss.str());
   33920             :     alloc_trace_cnt++;
   33921             : #endif
   33922             : 
   33923             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   33924             : 
   33925          28 :     ALLOC_MUTEX(SgAutoType, unlock);
   33926             : }
   33927             : 
   33928             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   33929             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   33930             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   33931             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   33932             : // Also, note comment below from Robb (copied from the Common.code file).
   33933             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   33934             : //
   33935             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   33936             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   33937             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   33938             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   33939             : #if 0
   33940             : void SgAutoType::operator delete(void* pointer) { SgAutoType::operator delete (pointer, sizeof(SgAutoType)); };
   33941             : #endif
   33942             : /* #line 33943 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   33943             : 
   33944             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   33945             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   33946             : // obviously imply C++.
   33947             : 
   33948             : // This implements the support within ROSE for memory pools.  Memory pools
   33949             : // support the most condensed usage of memory within the construction of
   33950             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   33951             : // by a new operator written for each class.
   33952             : 
   33953             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   33954             :     // User wants multi-thread support and POSIX threads are available.
   33955             : #   include <pthread.h>
   33956             :     static pthread_mutex_t SgLocatedNode_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   33957             : #else
   33958             :      // Cause synchronization to be skipped.
   33959             : #    ifndef ALLOC_MUTEX
   33960             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   33961             : #    endif
   33962             : #    ifdef _REENTRANT
   33963             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   33964             : #       ifdef _MSC_VER
   33965             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   33966             : #       else
   33967             : #           warning "POSIX threads are not available; synchronization being skipped"
   33968             : #       endif
   33969             : #    endif
   33970             : #endif
   33971             : 
   33972             : #ifndef ROSE_ALLOC_TRACE
   33973             : #  define ROSE_ALLOC_TRACE 0
   33974             : #endif
   33975             : 
   33976             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   33977             : #define ROSE_ALLOC_TRACE_CNT
   33978             : #include "memory-pool-snapshot.h"
   33979             : unsigned long alloc_trace_cnt = 0;
   33980             : #endif
   33981             : 
   33982             : #if ROSE_ALLOC_TRACE
   33983             : const unsigned SgLocatedNode::pool_size = 5;
   33984             : #else
   33985             : const unsigned SgLocatedNode::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   33986             : #endif
   33987             : 
   33988             : #ifndef ROSE_ALLOC_MEMSET
   33989             : #  define ROSE_ALLOC_MEMSET 0
   33990             : #endif
   33991             : 
   33992             : #ifndef ROSE_PEDANTIC_ALLOC
   33993             : #  define ROSE_PEDANTIC_ALLOC 0
   33994             : #endif
   33995             : 
   33996             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   33997             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   33998             : #endif
   33999             : 
   34000             : #if !defined(SGNODE__ALL_POOLS)
   34001             : #define SGNODE__ALL_POOLS
   34002             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   34003             : #endif
   34004             : 
   34005             : SgLocatedNode* SgLocatedNode::next_node = nullptr;
   34006             : std::vector<unsigned char*> SgLocatedNode::pools;
   34007             : 
   34008             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   34009             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   34010             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   34011             : // around this macro definition rather than each use).
   34012             : #ifndef ALLOC_MUTEX
   34013             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   34014             :         do {                                                                     \
   34015             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   34016             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   34017             :                 abort();                                                         \
   34018             :             }                                                                    \
   34019             :         } while (0);
   34020             : #endif
   34021             : 
   34022             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   34023             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   34024             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   34025             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   34026             : 
   34027             : /*! \brief New operator for SgLocatedNode.
   34028             : 
   34029             :    This new operator implements memory pools to provide most efficent 
   34030             :    use of the heap within construction of large ASTs.
   34031             : 
   34032             : \internal The new and delete operators use the lower level C malloc/free
   34033             :    function calls for performance and to make sure that mixing of malloc/free
   34034             :    and new/delete by the used can be caught more readily.  This may change
   34035             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   34036             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   34037             :    deallocate memory allocated using ROSE_MALLOC.
   34038             : */
   34039           0 : void *SgLocatedNode::operator new ( size_t Size )
   34040             : {
   34041             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   34042             :      * returning or throwing an exception. */
   34043           0 :     ALLOC_MUTEX(SgLocatedNode, lock);
   34044             : 
   34045             : #if ROSE_ALLOC_TRACE == 2
   34046             : //    printf("SgLocatedNode::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgLocatedNode::next_node);
   34047             : #endif
   34048             : 
   34049             : #if USE_CPP_NEW_DELETE_OPERATORS
   34050             :     void *mem = ROSE_MALLOC(Size);
   34051             :     ALLOC_MUTEX(SgLocatedNode, unlock);
   34052             :     return mem;
   34053             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   34054             : #if ROSE_PEDANTIC_ALLOC
   34055             :     ROSE_ASSERT(Size == sizeof(SgLocatedNode));
   34056             : #else
   34057           0 :     if (Size != sizeof(SgLocatedNode)) {
   34058           0 :       void * object = ROSE_MALLOC(Size);
   34059           0 :       ALLOC_MUTEX(SgLocatedNode, unlock);
   34060             :       return object;
   34061             :     }
   34062             : #endif
   34063             : 
   34064           0 :     if (SgLocatedNode::next_node == nullptr) {
   34065           0 :         SgLocatedNode * alloc = (SgLocatedNode*) ROSE_MALLOC ( SgLocatedNode::pool_size * sizeof(SgLocatedNode) );
   34066           0 :         ROSE_ASSERT(alloc != nullptr);
   34067             : 
   34068             : #if ROSE_ALLOC_TRACE == 2
   34069             : //        printf("SgLocatedNode::alloc\n  block[%zi] = [ %p , %p [\n", SgLocatedNode::pools.size(), alloc, alloc + SgLocatedNode::pool_size);
   34070             : #endif
   34071             : 
   34072             : #if ROSE_ALLOC_MEMSET == 1
   34073             : #elif ROSE_ALLOC_MEMSET == 2
   34074             :         memset(alloc, 0x00, SgLocatedNode::pool_size * sizeof(SgLocatedNode));
   34075             : #elif ROSE_ALLOC_MEMSET == 3
   34076             :         memset(alloc, 0xAA, SgLocatedNode::pool_size * sizeof(SgLocatedNode));
   34077             : #endif
   34078           0 :         for (unsigned i=0; i < SgLocatedNode::pool_size-1; i++) {
   34079           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
   34080             :         }
   34081           0 :         alloc[SgLocatedNode::pool_size-1].p_freepointer = nullptr;
   34082             : 
   34083           0 :         SgLocatedNode::pools.push_back ( (unsigned char *) alloc );
   34084           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgLocatedNode::pool_size * sizeof(SgLocatedNode), V_SgLocatedNode ) );
   34085           0 :         SgLocatedNode::next_node = alloc;
   34086             :     }
   34087           0 :     ROSE_ASSERT(SgLocatedNode::next_node != nullptr);
   34088             : 
   34089           0 :     SgLocatedNode * object = SgLocatedNode::next_node;
   34090           0 :     SgLocatedNode::next_node = (SgLocatedNode*)(object->p_freepointer);
   34091             : 
   34092             : #if ROSE_ALLOC_TRACE == 2
   34093             :     printf("SgLocatedNode::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgLocatedNode::next_node);
   34094             : #endif
   34095             : 
   34096           0 :     SgNode * fp = object->p_freepointer;
   34097             : #if ROSE_ALLOC_MEMSET == 1
   34098             : #elif ROSE_ALLOC_MEMSET == 2
   34099             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgLocatedNode) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   34100             : #elif ROSE_ALLOC_MEMSET == 3
   34101             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgLocatedNode) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   34102             : #endif
   34103           0 :     object->p_freepointer = fp;
   34104             : 
   34105             : #if ROSE_ALLOC_TRACE == 2
   34106             : //    printf("SgLocatedNode::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgLocatedNode::next_node);
   34107             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   34108             :     Rose::MemPool::snapshot(oss.str());
   34109             :     alloc_trace_cnt++;
   34110             : #endif
   34111             : 
   34112           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   34113             : 
   34114           0 :     ALLOC_MUTEX(SgLocatedNode, unlock);
   34115             : 
   34116             :     return object;
   34117             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   34118             : }
   34119             : 
   34120             : 
   34121             : 
   34122             : /*! \brief Delete operator for SgLocatedNode.
   34123             : 
   34124             :    This delete operator implements deallocation using memory pools to 
   34125             :    provide most efficent use of the heap within construction of large ASTs.
   34126             : 
   34127             : \internal The new and delete operators use the lower level C malloc/free
   34128             :    function calls for performance and to make sure that mixing of malloc/free
   34129             :    and new/delete by the used can be caught more readily.  This may change
   34130             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   34131             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   34132             :    deallocate memory allocated using ROSE_MALLOC.
   34133             : */
   34134           0 : void SgLocatedNode::operator delete(void *Pointer, size_t Size)
   34135             : {
   34136             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   34137             :      * or throwing an exception. */
   34138           0 :     ALLOC_MUTEX(SgLocatedNode, lock);
   34139             : 
   34140             : #if USE_CPP_NEW_DELETE_OPERATORS
   34141             :     ROSE_FREE(Pointer);
   34142             : #else
   34143             : #if ROSE_PEDANTIC_ALLOC
   34144             :     ROSE_ASSERT(Size == sizeof(SgLocatedNode));
   34145             : #else
   34146           0 :     if (Size != sizeof(SgLocatedNode)) {
   34147           0 :       ROSE_FREE(Pointer);
   34148           0 :       ALLOC_MUTEX(SgLocatedNode, unlock);
   34149             :       return;
   34150             :     }
   34151             : #endif
   34152             : 
   34153           0 :     SgLocatedNode * object = (SgLocatedNode*) Pointer;
   34154           0 :     ROSE_ASSERT(object != nullptr);
   34155             : 
   34156             : #if ROSE_ALLOC_TRACE == 2
   34157             : //  printf("SgLocatedNode::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgLocatedNode::next_node);
   34158             :     printf("SgLocatedNode::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgLocatedNode::next_node);
   34159             : #endif
   34160             : 
   34161             : #if ROSE_PEDANTIC_ALLOC
   34162             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   34163             : #endif
   34164             : 
   34165             : #if ROSE_ALLOC_MEMSET == 1
   34166             : #elif ROSE_ALLOC_MEMSET == 2
   34167             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgLocatedNode) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   34168             : #elif ROSE_ALLOC_MEMSET == 3
   34169             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgLocatedNode) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   34170             : #endif
   34171             : 
   34172             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   34173             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   34174             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   34175             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   34176             : #else
   34177           0 :     object->p_freepointer = SgLocatedNode::next_node;
   34178           0 :     SgLocatedNode::next_node = object;
   34179             : #endif
   34180             : 
   34181             : #if ROSE_ALLOC_TRACE == 2
   34182             : //  printf("SgLocatedNode::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgLocatedNode::next_node);
   34183             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   34184             :     Rose::MemPool::snapshot(oss.str());
   34185             :     alloc_trace_cnt++;
   34186             : #endif
   34187             : 
   34188             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   34189             : 
   34190           0 :     ALLOC_MUTEX(SgLocatedNode, unlock);
   34191             : }
   34192             : 
   34193             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   34194             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   34195             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   34196             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   34197             : // Also, note comment below from Robb (copied from the Common.code file).
   34198             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   34199             : //
   34200             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   34201             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   34202             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   34203             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   34204             : #if 0
   34205             : void SgLocatedNode::operator delete(void* pointer) { SgLocatedNode::operator delete (pointer, sizeof(SgLocatedNode)); };
   34206             : #endif
   34207             : /* #line 34208 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   34208             : 
   34209             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   34210             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   34211             : // obviously imply C++.
   34212             : 
   34213             : // This implements the support within ROSE for memory pools.  Memory pools
   34214             : // support the most condensed usage of memory within the construction of
   34215             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   34216             : // by a new operator written for each class.
   34217             : 
   34218             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   34219             :     // User wants multi-thread support and POSIX threads are available.
   34220             : #   include <pthread.h>
   34221             :     static pthread_mutex_t SgToken_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   34222             : #else
   34223             :      // Cause synchronization to be skipped.
   34224             : #    ifndef ALLOC_MUTEX
   34225             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   34226             : #    endif
   34227             : #    ifdef _REENTRANT
   34228             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   34229             : #       ifdef _MSC_VER
   34230             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   34231             : #       else
   34232             : #           warning "POSIX threads are not available; synchronization being skipped"
   34233             : #       endif
   34234             : #    endif
   34235             : #endif
   34236             : 
   34237             : #ifndef ROSE_ALLOC_TRACE
   34238             : #  define ROSE_ALLOC_TRACE 0
   34239             : #endif
   34240             : 
   34241             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   34242             : #define ROSE_ALLOC_TRACE_CNT
   34243             : #include "memory-pool-snapshot.h"
   34244             : unsigned long alloc_trace_cnt = 0;
   34245             : #endif
   34246             : 
   34247             : #if ROSE_ALLOC_TRACE
   34248             : const unsigned SgToken::pool_size = 5;
   34249             : #else
   34250             : const unsigned SgToken::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   34251             : #endif
   34252             : 
   34253             : #ifndef ROSE_ALLOC_MEMSET
   34254             : #  define ROSE_ALLOC_MEMSET 0
   34255             : #endif
   34256             : 
   34257             : #ifndef ROSE_PEDANTIC_ALLOC
   34258             : #  define ROSE_PEDANTIC_ALLOC 0
   34259             : #endif
   34260             : 
   34261             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   34262             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   34263             : #endif
   34264             : 
   34265             : #if !defined(SGNODE__ALL_POOLS)
   34266             : #define SGNODE__ALL_POOLS
   34267             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   34268             : #endif
   34269             : 
   34270             : SgToken* SgToken::next_node = nullptr;
   34271             : std::vector<unsigned char*> SgToken::pools;
   34272             : 
   34273             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   34274             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   34275             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   34276             : // around this macro definition rather than each use).
   34277             : #ifndef ALLOC_MUTEX
   34278             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   34279             :         do {                                                                     \
   34280             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   34281             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   34282             :                 abort();                                                         \
   34283             :             }                                                                    \
   34284             :         } while (0);
   34285             : #endif
   34286             : 
   34287             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   34288             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   34289             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   34290             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   34291             : 
   34292             : /*! \brief New operator for SgToken.
   34293             : 
   34294             :    This new operator implements memory pools to provide most efficent 
   34295             :    use of the heap within construction of large ASTs.
   34296             : 
   34297             : \internal The new and delete operators use the lower level C malloc/free
   34298             :    function calls for performance and to make sure that mixing of malloc/free
   34299             :    and new/delete by the used can be caught more readily.  This may change
   34300             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   34301             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   34302             :    deallocate memory allocated using ROSE_MALLOC.
   34303             : */
   34304           0 : void *SgToken::operator new ( size_t Size )
   34305             : {
   34306             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   34307             :      * returning or throwing an exception. */
   34308           0 :     ALLOC_MUTEX(SgToken, lock);
   34309             : 
   34310             : #if ROSE_ALLOC_TRACE == 2
   34311             : //    printf("SgToken::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgToken::next_node);
   34312             : #endif
   34313             : 
   34314             : #if USE_CPP_NEW_DELETE_OPERATORS
   34315             :     void *mem = ROSE_MALLOC(Size);
   34316             :     ALLOC_MUTEX(SgToken, unlock);
   34317             :     return mem;
   34318             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   34319             : #if ROSE_PEDANTIC_ALLOC
   34320             :     ROSE_ASSERT(Size == sizeof(SgToken));
   34321             : #else
   34322           0 :     if (Size != sizeof(SgToken)) {
   34323           0 :       void * object = ROSE_MALLOC(Size);
   34324           0 :       ALLOC_MUTEX(SgToken, unlock);
   34325             :       return object;
   34326             :     }
   34327             : #endif
   34328             : 
   34329           0 :     if (SgToken::next_node == nullptr) {
   34330           0 :         SgToken * alloc = (SgToken*) ROSE_MALLOC ( SgToken::pool_size * sizeof(SgToken) );
   34331           0 :         ROSE_ASSERT(alloc != nullptr);
   34332             : 
   34333             : #if ROSE_ALLOC_TRACE == 2
   34334             : //        printf("SgToken::alloc\n  block[%zi] = [ %p , %p [\n", SgToken::pools.size(), alloc, alloc + SgToken::pool_size);
   34335             : #endif
   34336             : 
   34337             : #if ROSE_ALLOC_MEMSET == 1
   34338             : #elif ROSE_ALLOC_MEMSET == 2
   34339             :         memset(alloc, 0x00, SgToken::pool_size * sizeof(SgToken));
   34340             : #elif ROSE_ALLOC_MEMSET == 3
   34341             :         memset(alloc, 0xAA, SgToken::pool_size * sizeof(SgToken));
   34342             : #endif
   34343           0 :         for (unsigned i=0; i < SgToken::pool_size-1; i++) {
   34344           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
   34345             :         }
   34346           0 :         alloc[SgToken::pool_size-1].p_freepointer = nullptr;
   34347             : 
   34348           0 :         SgToken::pools.push_back ( (unsigned char *) alloc );
   34349           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgToken::pool_size * sizeof(SgToken), V_SgToken ) );
   34350           0 :         SgToken::next_node = alloc;
   34351             :     }
   34352           0 :     ROSE_ASSERT(SgToken::next_node != nullptr);
   34353             : 
   34354           0 :     SgToken * object = SgToken::next_node;
   34355           0 :     SgToken::next_node = (SgToken*)(object->p_freepointer);
   34356             : 
   34357             : #if ROSE_ALLOC_TRACE == 2
   34358             :     printf("SgToken::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgToken::next_node);
   34359             : #endif
   34360             : 
   34361           0 :     SgNode * fp = object->p_freepointer;
   34362             : #if ROSE_ALLOC_MEMSET == 1
   34363             : #elif ROSE_ALLOC_MEMSET == 2
   34364             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgToken) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   34365             : #elif ROSE_ALLOC_MEMSET == 3
   34366             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgToken) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   34367             : #endif
   34368           0 :     object->p_freepointer = fp;
   34369             : 
   34370             : #if ROSE_ALLOC_TRACE == 2
   34371             : //    printf("SgToken::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgToken::next_node);
   34372             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   34373             :     Rose::MemPool::snapshot(oss.str());
   34374             :     alloc_trace_cnt++;
   34375             : #endif
   34376             : 
   34377           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   34378             : 
   34379           0 :     ALLOC_MUTEX(SgToken, unlock);
   34380             : 
   34381             :     return object;
   34382             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   34383             : }
   34384             : 
   34385             : 
   34386             : 
   34387             : /*! \brief Delete operator for SgToken.
   34388             : 
   34389             :    This delete operator implements deallocation using memory pools to 
   34390             :    provide most efficent use of the heap within construction of large ASTs.
   34391             : 
   34392             : \internal The new and delete operators use the lower level C malloc/free
   34393             :    function calls for performance and to make sure that mixing of malloc/free
   34394             :    and new/delete by the used can be caught more readily.  This may change
   34395             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   34396             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   34397             :    deallocate memory allocated using ROSE_MALLOC.
   34398             : */
   34399           0 : void SgToken::operator delete(void *Pointer, size_t Size)
   34400             : {
   34401             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   34402             :      * or throwing an exception. */
   34403           0 :     ALLOC_MUTEX(SgToken, lock);
   34404             : 
   34405             : #if USE_CPP_NEW_DELETE_OPERATORS
   34406             :     ROSE_FREE(Pointer);
   34407             : #else
   34408             : #if ROSE_PEDANTIC_ALLOC
   34409             :     ROSE_ASSERT(Size == sizeof(SgToken));
   34410             : #else
   34411           0 :     if (Size != sizeof(SgToken)) {
   34412           0 :       ROSE_FREE(Pointer);
   34413           0 :       ALLOC_MUTEX(SgToken, unlock);
   34414             :       return;
   34415             :     }
   34416             : #endif
   34417             : 
   34418           0 :     SgToken * object = (SgToken*) Pointer;
   34419           0 :     ROSE_ASSERT(object != nullptr);
   34420             : 
   34421             : #if ROSE_ALLOC_TRACE == 2
   34422             : //  printf("SgToken::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgToken::next_node);
   34423             :     printf("SgToken::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgToken::next_node);
   34424             : #endif
   34425             : 
   34426             : #if ROSE_PEDANTIC_ALLOC
   34427             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   34428             : #endif
   34429             : 
   34430             : #if ROSE_ALLOC_MEMSET == 1
   34431             : #elif ROSE_ALLOC_MEMSET == 2
   34432             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgToken) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   34433             : #elif ROSE_ALLOC_MEMSET == 3
   34434             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgToken) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   34435             : #endif
   34436             : 
   34437             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   34438             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   34439             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   34440             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   34441             : #else
   34442           0 :     object->p_freepointer = SgToken::next_node;
   34443           0 :     SgToken::next_node = object;
   34444             : #endif
   34445             : 
   34446             : #if ROSE_ALLOC_TRACE == 2
   34447             : //  printf("SgToken::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgToken::next_node);
   34448             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   34449             :     Rose::MemPool::snapshot(oss.str());
   34450             :     alloc_trace_cnt++;
   34451             : #endif
   34452             : 
   34453             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   34454             : 
   34455           0 :     ALLOC_MUTEX(SgToken, unlock);
   34456             : }
   34457             : 
   34458             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   34459             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   34460             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   34461             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   34462             : // Also, note comment below from Robb (copied from the Common.code file).
   34463             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   34464             : //
   34465             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   34466             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   34467             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   34468             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   34469             : #if 0
   34470             : void SgToken::operator delete(void* pointer) { SgToken::operator delete (pointer, sizeof(SgToken)); };
   34471             : #endif
   34472             : /* #line 34473 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   34473             : 
   34474             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   34475             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   34476             : // obviously imply C++.
   34477             : 
   34478             : // This implements the support within ROSE for memory pools.  Memory pools
   34479             : // support the most condensed usage of memory within the construction of
   34480             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   34481             : // by a new operator written for each class.
   34482             : 
   34483             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   34484             :     // User wants multi-thread support and POSIX threads are available.
   34485             : #   include <pthread.h>
   34486             :     static pthread_mutex_t SgLocatedNodeSupport_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   34487             : #else
   34488             :      // Cause synchronization to be skipped.
   34489             : #    ifndef ALLOC_MUTEX
   34490             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   34491             : #    endif
   34492             : #    ifdef _REENTRANT
   34493             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   34494             : #       ifdef _MSC_VER
   34495             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   34496             : #       else
   34497             : #           warning "POSIX threads are not available; synchronization being skipped"
   34498             : #       endif
   34499             : #    endif
   34500             : #endif
   34501             : 
   34502             : #ifndef ROSE_ALLOC_TRACE
   34503             : #  define ROSE_ALLOC_TRACE 0
   34504             : #endif
   34505             : 
   34506             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   34507             : #define ROSE_ALLOC_TRACE_CNT
   34508             : #include "memory-pool-snapshot.h"
   34509             : unsigned long alloc_trace_cnt = 0;
   34510             : #endif
   34511             : 
   34512             : #if ROSE_ALLOC_TRACE
   34513             : const unsigned SgLocatedNodeSupport::pool_size = 5;
   34514             : #else
   34515             : const unsigned SgLocatedNodeSupport::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   34516             : #endif
   34517             : 
   34518             : #ifndef ROSE_ALLOC_MEMSET
   34519             : #  define ROSE_ALLOC_MEMSET 0
   34520             : #endif
   34521             : 
   34522             : #ifndef ROSE_PEDANTIC_ALLOC
   34523             : #  define ROSE_PEDANTIC_ALLOC 0
   34524             : #endif
   34525             : 
   34526             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   34527             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   34528             : #endif
   34529             : 
   34530             : #if !defined(SGNODE__ALL_POOLS)
   34531             : #define SGNODE__ALL_POOLS
   34532             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   34533             : #endif
   34534             : 
   34535             : SgLocatedNodeSupport* SgLocatedNodeSupport::next_node = nullptr;
   34536             : std::vector<unsigned char*> SgLocatedNodeSupport::pools;
   34537             : 
   34538             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   34539             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   34540             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   34541             : // around this macro definition rather than each use).
   34542             : #ifndef ALLOC_MUTEX
   34543             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   34544             :         do {                                                                     \
   34545             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   34546             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   34547             :                 abort();                                                         \
   34548             :             }                                                                    \
   34549             :         } while (0);
   34550             : #endif
   34551             : 
   34552             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   34553             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   34554             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   34555             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   34556             : 
   34557             : /*! \brief New operator for SgLocatedNodeSupport.
   34558             : 
   34559             :    This new operator implements memory pools to provide most efficent 
   34560             :    use of the heap within construction of large ASTs.
   34561             : 
   34562             : \internal The new and delete operators use the lower level C malloc/free
   34563             :    function calls for performance and to make sure that mixing of malloc/free
   34564             :    and new/delete by the used can be caught more readily.  This may change
   34565             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   34566             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   34567             :    deallocate memory allocated using ROSE_MALLOC.
   34568             : */
   34569           0 : void *SgLocatedNodeSupport::operator new ( size_t Size )
   34570             : {
   34571             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   34572             :      * returning or throwing an exception. */
   34573           0 :     ALLOC_MUTEX(SgLocatedNodeSupport, lock);
   34574             : 
   34575             : #if ROSE_ALLOC_TRACE == 2
   34576             : //    printf("SgLocatedNodeSupport::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgLocatedNodeSupport::next_node);
   34577             : #endif
   34578             : 
   34579             : #if USE_CPP_NEW_DELETE_OPERATORS
   34580             :     void *mem = ROSE_MALLOC(Size);
   34581             :     ALLOC_MUTEX(SgLocatedNodeSupport, unlock);
   34582             :     return mem;
   34583             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   34584             : #if ROSE_PEDANTIC_ALLOC
   34585             :     ROSE_ASSERT(Size == sizeof(SgLocatedNodeSupport));
   34586             : #else
   34587           0 :     if (Size != sizeof(SgLocatedNodeSupport)) {
   34588           0 :       void * object = ROSE_MALLOC(Size);
   34589           0 :       ALLOC_MUTEX(SgLocatedNodeSupport, unlock);
   34590             :       return object;
   34591             :     }
   34592             : #endif
   34593             : 
   34594           0 :     if (SgLocatedNodeSupport::next_node == nullptr) {
   34595           0 :         SgLocatedNodeSupport * alloc = (SgLocatedNodeSupport*) ROSE_MALLOC ( SgLocatedNodeSupport::pool_size * sizeof(SgLocatedNodeSupport) );
   34596           0 :         ROSE_ASSERT(alloc != nullptr);
   34597             : 
   34598             : #if ROSE_ALLOC_TRACE == 2
   34599             : //        printf("SgLocatedNodeSupport::alloc\n  block[%zi] = [ %p , %p [\n", SgLocatedNodeSupport::pools.size(), alloc, alloc + SgLocatedNodeSupport::pool_size);
   34600             : #endif
   34601             : 
   34602             : #if ROSE_ALLOC_MEMSET == 1
   34603             : #elif ROSE_ALLOC_MEMSET == 2
   34604             :         memset(alloc, 0x00, SgLocatedNodeSupport::pool_size * sizeof(SgLocatedNodeSupport));
   34605             : #elif ROSE_ALLOC_MEMSET == 3
   34606             :         memset(alloc, 0xAA, SgLocatedNodeSupport::pool_size * sizeof(SgLocatedNodeSupport));
   34607             : #endif
   34608           0 :         for (unsigned i=0; i < SgLocatedNodeSupport::pool_size-1; i++) {
   34609           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
   34610             :         }
   34611           0 :         alloc[SgLocatedNodeSupport::pool_size-1].p_freepointer = nullptr;
   34612             : 
   34613           0 :         SgLocatedNodeSupport::pools.push_back ( (unsigned char *) alloc );
   34614           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgLocatedNodeSupport::pool_size * sizeof(SgLocatedNodeSupport), V_SgLocatedNodeSupport ) );
   34615           0 :         SgLocatedNodeSupport::next_node = alloc;
   34616             :     }
   34617           0 :     ROSE_ASSERT(SgLocatedNodeSupport::next_node != nullptr);
   34618             : 
   34619           0 :     SgLocatedNodeSupport * object = SgLocatedNodeSupport::next_node;
   34620           0 :     SgLocatedNodeSupport::next_node = (SgLocatedNodeSupport*)(object->p_freepointer);
   34621             : 
   34622             : #if ROSE_ALLOC_TRACE == 2
   34623             :     printf("SgLocatedNodeSupport::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgLocatedNodeSupport::next_node);
   34624             : #endif
   34625             : 
   34626           0 :     SgNode * fp = object->p_freepointer;
   34627             : #if ROSE_ALLOC_MEMSET == 1
   34628             : #elif ROSE_ALLOC_MEMSET == 2
   34629             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgLocatedNodeSupport) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   34630             : #elif ROSE_ALLOC_MEMSET == 3
   34631             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgLocatedNodeSupport) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   34632             : #endif
   34633           0 :     object->p_freepointer = fp;
   34634             : 
   34635             : #if ROSE_ALLOC_TRACE == 2
   34636             : //    printf("SgLocatedNodeSupport::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgLocatedNodeSupport::next_node);
   34637             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   34638             :     Rose::MemPool::snapshot(oss.str());
   34639             :     alloc_trace_cnt++;
   34640             : #endif
   34641             : 
   34642           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   34643             : 
   34644           0 :     ALLOC_MUTEX(SgLocatedNodeSupport, unlock);
   34645             : 
   34646             :     return object;
   34647             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   34648             : }
   34649             : 
   34650             : 
   34651             : 
   34652             : /*! \brief Delete operator for SgLocatedNodeSupport.
   34653             : 
   34654             :    This delete operator implements deallocation using memory pools to 
   34655             :    provide most efficent use of the heap within construction of large ASTs.
   34656             : 
   34657             : \internal The new and delete operators use the lower level C malloc/free
   34658             :    function calls for performance and to make sure that mixing of malloc/free
   34659             :    and new/delete by the used can be caught more readily.  This may change
   34660             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   34661             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   34662             :    deallocate memory allocated using ROSE_MALLOC.
   34663             : */
   34664           0 : void SgLocatedNodeSupport::operator delete(void *Pointer, size_t Size)
   34665             : {
   34666             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   34667             :      * or throwing an exception. */
   34668           0 :     ALLOC_MUTEX(SgLocatedNodeSupport, lock);
   34669             : 
   34670             : #if USE_CPP_NEW_DELETE_OPERATORS
   34671             :     ROSE_FREE(Pointer);
   34672             : #else
   34673             : #if ROSE_PEDANTIC_ALLOC
   34674             :     ROSE_ASSERT(Size == sizeof(SgLocatedNodeSupport));
   34675             : #else
   34676           0 :     if (Size != sizeof(SgLocatedNodeSupport)) {
   34677           0 :       ROSE_FREE(Pointer);
   34678           0 :       ALLOC_MUTEX(SgLocatedNodeSupport, unlock);
   34679             :       return;
   34680             :     }
   34681             : #endif
   34682             : 
   34683           0 :     SgLocatedNodeSupport * object = (SgLocatedNodeSupport*) Pointer;
   34684           0 :     ROSE_ASSERT(object != nullptr);
   34685             : 
   34686             : #if ROSE_ALLOC_TRACE == 2
   34687             : //  printf("SgLocatedNodeSupport::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgLocatedNodeSupport::next_node);
   34688             :     printf("SgLocatedNodeSupport::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgLocatedNodeSupport::next_node);
   34689             : #endif
   34690             : 
   34691             : #if ROSE_PEDANTIC_ALLOC
   34692             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   34693             : #endif
   34694             : 
   34695             : #if ROSE_ALLOC_MEMSET == 1
   34696             : #elif ROSE_ALLOC_MEMSET == 2
   34697             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgLocatedNodeSupport) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   34698             : #elif ROSE_ALLOC_MEMSET == 3
   34699             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgLocatedNodeSupport) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   34700             : #endif
   34701             : 
   34702             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   34703             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   34704             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   34705             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   34706             : #else
   34707           0 :     object->p_freepointer = SgLocatedNodeSupport::next_node;
   34708           0 :     SgLocatedNodeSupport::next_node = object;
   34709             : #endif
   34710             : 
   34711             : #if ROSE_ALLOC_TRACE == 2
   34712             : //  printf("SgLocatedNodeSupport::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgLocatedNodeSupport::next_node);
   34713             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   34714             :     Rose::MemPool::snapshot(oss.str());
   34715             :     alloc_trace_cnt++;
   34716             : #endif
   34717             : 
   34718             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   34719             : 
   34720           0 :     ALLOC_MUTEX(SgLocatedNodeSupport, unlock);
   34721             : }
   34722             : 
   34723             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   34724             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   34725             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   34726             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   34727             : // Also, note comment below from Robb (copied from the Common.code file).
   34728             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   34729             : //
   34730             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   34731             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   34732             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   34733             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   34734             : #if 0
   34735             : void SgLocatedNodeSupport::operator delete(void* pointer) { SgLocatedNodeSupport::operator delete (pointer, sizeof(SgLocatedNodeSupport)); };
   34736             : #endif
   34737             : /* #line 34738 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   34738             : 
   34739             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   34740             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   34741             : // obviously imply C++.
   34742             : 
   34743             : // This implements the support within ROSE for memory pools.  Memory pools
   34744             : // support the most condensed usage of memory within the construction of
   34745             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   34746             : // by a new operator written for each class.
   34747             : 
   34748             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   34749             :     // User wants multi-thread support and POSIX threads are available.
   34750             : #   include <pthread.h>
   34751             :     static pthread_mutex_t SgCommonBlockObject_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   34752             : #else
   34753             :      // Cause synchronization to be skipped.
   34754             : #    ifndef ALLOC_MUTEX
   34755             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   34756             : #    endif
   34757             : #    ifdef _REENTRANT
   34758             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   34759             : #       ifdef _MSC_VER
   34760             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   34761             : #       else
   34762             : #           warning "POSIX threads are not available; synchronization being skipped"
   34763             : #       endif
   34764             : #    endif
   34765             : #endif
   34766             : 
   34767             : #ifndef ROSE_ALLOC_TRACE
   34768             : #  define ROSE_ALLOC_TRACE 0
   34769             : #endif
   34770             : 
   34771             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   34772             : #define ROSE_ALLOC_TRACE_CNT
   34773             : #include "memory-pool-snapshot.h"
   34774             : unsigned long alloc_trace_cnt = 0;
   34775             : #endif
   34776             : 
   34777             : #if ROSE_ALLOC_TRACE
   34778             : const unsigned SgCommonBlockObject::pool_size = 5;
   34779             : #else
   34780             : const unsigned SgCommonBlockObject::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   34781             : #endif
   34782             : 
   34783             : #ifndef ROSE_ALLOC_MEMSET
   34784             : #  define ROSE_ALLOC_MEMSET 0
   34785             : #endif
   34786             : 
   34787             : #ifndef ROSE_PEDANTIC_ALLOC
   34788             : #  define ROSE_PEDANTIC_ALLOC 0
   34789             : #endif
   34790             : 
   34791             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   34792             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   34793             : #endif
   34794             : 
   34795             : #if !defined(SGNODE__ALL_POOLS)
   34796             : #define SGNODE__ALL_POOLS
   34797             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   34798             : #endif
   34799             : 
   34800             : SgCommonBlockObject* SgCommonBlockObject::next_node = nullptr;
   34801             : std::vector<unsigned char*> SgCommonBlockObject::pools;
   34802             : 
   34803             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   34804             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   34805             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   34806             : // around this macro definition rather than each use).
   34807             : #ifndef ALLOC_MUTEX
   34808             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   34809             :         do {                                                                     \
   34810             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   34811             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   34812             :                 abort();                                                         \
   34813             :             }                                                                    \
   34814             :         } while (0);
   34815             : #endif
   34816             : 
   34817             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   34818             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   34819             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   34820             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   34821             : 
   34822             : /*! \brief New operator for SgCommonBlockObject.
   34823             : 
   34824             :    This new operator implements memory pools to provide most efficent 
   34825             :    use of the heap within construction of large ASTs.
   34826             : 
   34827             : \internal The new and delete operators use the lower level C malloc/free
   34828             :    function calls for performance and to make sure that mixing of malloc/free
   34829             :    and new/delete by the used can be caught more readily.  This may change
   34830             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   34831             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   34832             :    deallocate memory allocated using ROSE_MALLOC.
   34833             : */
   34834           6 : void *SgCommonBlockObject::operator new ( size_t Size )
   34835             : {
   34836             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   34837             :      * returning or throwing an exception. */
   34838           6 :     ALLOC_MUTEX(SgCommonBlockObject, lock);
   34839             : 
   34840             : #if ROSE_ALLOC_TRACE == 2
   34841             : //    printf("SgCommonBlockObject::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgCommonBlockObject::next_node);
   34842             : #endif
   34843             : 
   34844             : #if USE_CPP_NEW_DELETE_OPERATORS
   34845             :     void *mem = ROSE_MALLOC(Size);
   34846             :     ALLOC_MUTEX(SgCommonBlockObject, unlock);
   34847             :     return mem;
   34848             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   34849             : #if ROSE_PEDANTIC_ALLOC
   34850             :     ROSE_ASSERT(Size == sizeof(SgCommonBlockObject));
   34851             : #else
   34852           6 :     if (Size != sizeof(SgCommonBlockObject)) {
   34853           0 :       void * object = ROSE_MALLOC(Size);
   34854           0 :       ALLOC_MUTEX(SgCommonBlockObject, unlock);
   34855             :       return object;
   34856             :     }
   34857             : #endif
   34858             : 
   34859           6 :     if (SgCommonBlockObject::next_node == nullptr) {
   34860           3 :         SgCommonBlockObject * alloc = (SgCommonBlockObject*) ROSE_MALLOC ( SgCommonBlockObject::pool_size * sizeof(SgCommonBlockObject) );
   34861           3 :         ROSE_ASSERT(alloc != nullptr);
   34862             : 
   34863             : #if ROSE_ALLOC_TRACE == 2
   34864             : //        printf("SgCommonBlockObject::alloc\n  block[%zi] = [ %p , %p [\n", SgCommonBlockObject::pools.size(), alloc, alloc + SgCommonBlockObject::pool_size);
   34865             : #endif
   34866             : 
   34867             : #if ROSE_ALLOC_MEMSET == 1
   34868             : #elif ROSE_ALLOC_MEMSET == 2
   34869             :         memset(alloc, 0x00, SgCommonBlockObject::pool_size * sizeof(SgCommonBlockObject));
   34870             : #elif ROSE_ALLOC_MEMSET == 3
   34871             :         memset(alloc, 0xAA, SgCommonBlockObject::pool_size * sizeof(SgCommonBlockObject));
   34872             : #endif
   34873        6000 :         for (unsigned i=0; i < SgCommonBlockObject::pool_size-1; i++) {
   34874        5997 :           alloc[i].p_freepointer = &(alloc[i+1]);
   34875             :         }
   34876           3 :         alloc[SgCommonBlockObject::pool_size-1].p_freepointer = nullptr;
   34877             : 
   34878           3 :         SgCommonBlockObject::pools.push_back ( (unsigned char *) alloc );
   34879           3 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgCommonBlockObject::pool_size * sizeof(SgCommonBlockObject), V_SgCommonBlockObject ) );
   34880           3 :         SgCommonBlockObject::next_node = alloc;
   34881             :     }
   34882           6 :     ROSE_ASSERT(SgCommonBlockObject::next_node != nullptr);
   34883             : 
   34884           6 :     SgCommonBlockObject * object = SgCommonBlockObject::next_node;
   34885           6 :     SgCommonBlockObject::next_node = (SgCommonBlockObject*)(object->p_freepointer);
   34886             : 
   34887             : #if ROSE_ALLOC_TRACE == 2
   34888             :     printf("SgCommonBlockObject::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgCommonBlockObject::next_node);
   34889             : #endif
   34890             : 
   34891           6 :     SgNode * fp = object->p_freepointer;
   34892             : #if ROSE_ALLOC_MEMSET == 1
   34893             : #elif ROSE_ALLOC_MEMSET == 2
   34894             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgCommonBlockObject) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   34895             : #elif ROSE_ALLOC_MEMSET == 3
   34896             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgCommonBlockObject) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   34897             : #endif
   34898           6 :     object->p_freepointer = fp;
   34899             : 
   34900             : #if ROSE_ALLOC_TRACE == 2
   34901             : //    printf("SgCommonBlockObject::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgCommonBlockObject::next_node);
   34902             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   34903             :     Rose::MemPool::snapshot(oss.str());
   34904             :     alloc_trace_cnt++;
   34905             : #endif
   34906             : 
   34907           6 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   34908             : 
   34909           6 :     ALLOC_MUTEX(SgCommonBlockObject, unlock);
   34910             : 
   34911             :     return object;
   34912             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   34913             : }
   34914             : 
   34915             : 
   34916             : 
   34917             : /*! \brief Delete operator for SgCommonBlockObject.
   34918             : 
   34919             :    This delete operator implements deallocation using memory pools to 
   34920             :    provide most efficent use of the heap within construction of large ASTs.
   34921             : 
   34922             : \internal The new and delete operators use the lower level C malloc/free
   34923             :    function calls for performance and to make sure that mixing of malloc/free
   34924             :    and new/delete by the used can be caught more readily.  This may change
   34925             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   34926             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   34927             :    deallocate memory allocated using ROSE_MALLOC.
   34928             : */
   34929           0 : void SgCommonBlockObject::operator delete(void *Pointer, size_t Size)
   34930             : {
   34931             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   34932             :      * or throwing an exception. */
   34933           0 :     ALLOC_MUTEX(SgCommonBlockObject, lock);
   34934             : 
   34935             : #if USE_CPP_NEW_DELETE_OPERATORS
   34936             :     ROSE_FREE(Pointer);
   34937             : #else
   34938             : #if ROSE_PEDANTIC_ALLOC
   34939             :     ROSE_ASSERT(Size == sizeof(SgCommonBlockObject));
   34940             : #else
   34941           0 :     if (Size != sizeof(SgCommonBlockObject)) {
   34942           0 :       ROSE_FREE(Pointer);
   34943           0 :       ALLOC_MUTEX(SgCommonBlockObject, unlock);
   34944             :       return;
   34945             :     }
   34946             : #endif
   34947             : 
   34948           0 :     SgCommonBlockObject * object = (SgCommonBlockObject*) Pointer;
   34949           0 :     ROSE_ASSERT(object != nullptr);
   34950             : 
   34951             : #if ROSE_ALLOC_TRACE == 2
   34952             : //  printf("SgCommonBlockObject::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgCommonBlockObject::next_node);
   34953             :     printf("SgCommonBlockObject::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgCommonBlockObject::next_node);
   34954             : #endif
   34955             : 
   34956             : #if ROSE_PEDANTIC_ALLOC
   34957             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   34958             : #endif
   34959             : 
   34960             : #if ROSE_ALLOC_MEMSET == 1
   34961             : #elif ROSE_ALLOC_MEMSET == 2
   34962             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgCommonBlockObject) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   34963             : #elif ROSE_ALLOC_MEMSET == 3
   34964             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgCommonBlockObject) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   34965             : #endif
   34966             : 
   34967             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   34968             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   34969             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   34970             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   34971             : #else
   34972           0 :     object->p_freepointer = SgCommonBlockObject::next_node;
   34973           0 :     SgCommonBlockObject::next_node = object;
   34974             : #endif
   34975             : 
   34976             : #if ROSE_ALLOC_TRACE == 2
   34977             : //  printf("SgCommonBlockObject::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgCommonBlockObject::next_node);
   34978             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   34979             :     Rose::MemPool::snapshot(oss.str());
   34980             :     alloc_trace_cnt++;
   34981             : #endif
   34982             : 
   34983             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   34984             : 
   34985           0 :     ALLOC_MUTEX(SgCommonBlockObject, unlock);
   34986             : }
   34987             : 
   34988             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   34989             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   34990             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   34991             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   34992             : // Also, note comment below from Robb (copied from the Common.code file).
   34993             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   34994             : //
   34995             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   34996             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   34997             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   34998             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   34999             : #if 0
   35000             : void SgCommonBlockObject::operator delete(void* pointer) { SgCommonBlockObject::operator delete (pointer, sizeof(SgCommonBlockObject)); };
   35001             : #endif
   35002             : /* #line 35003 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   35003             : 
   35004             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   35005             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   35006             : // obviously imply C++.
   35007             : 
   35008             : // This implements the support within ROSE for memory pools.  Memory pools
   35009             : // support the most condensed usage of memory within the construction of
   35010             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   35011             : // by a new operator written for each class.
   35012             : 
   35013             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   35014             :     // User wants multi-thread support and POSIX threads are available.
   35015             : #   include <pthread.h>
   35016             :     static pthread_mutex_t SgInitializedName_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   35017             : #else
   35018             :      // Cause synchronization to be skipped.
   35019             : #    ifndef ALLOC_MUTEX
   35020             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   35021             : #    endif
   35022             : #    ifdef _REENTRANT
   35023             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   35024             : #       ifdef _MSC_VER
   35025             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   35026             : #       else
   35027             : #           warning "POSIX threads are not available; synchronization being skipped"
   35028             : #       endif
   35029             : #    endif
   35030             : #endif
   35031             : 
   35032             : #ifndef ROSE_ALLOC_TRACE
   35033             : #  define ROSE_ALLOC_TRACE 0
   35034             : #endif
   35035             : 
   35036             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   35037             : #define ROSE_ALLOC_TRACE_CNT
   35038             : #include "memory-pool-snapshot.h"
   35039             : unsigned long alloc_trace_cnt = 0;
   35040             : #endif
   35041             : 
   35042             : #if ROSE_ALLOC_TRACE
   35043             : const unsigned SgInitializedName::pool_size = 5;
   35044             : #else
   35045             : const unsigned SgInitializedName::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   35046             : #endif
   35047             : 
   35048             : #ifndef ROSE_ALLOC_MEMSET
   35049             : #  define ROSE_ALLOC_MEMSET 0
   35050             : #endif
   35051             : 
   35052             : #ifndef ROSE_PEDANTIC_ALLOC
   35053             : #  define ROSE_PEDANTIC_ALLOC 0
   35054             : #endif
   35055             : 
   35056             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   35057             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   35058             : #endif
   35059             : 
   35060             : #if !defined(SGNODE__ALL_POOLS)
   35061             : #define SGNODE__ALL_POOLS
   35062             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   35063             : #endif
   35064             : 
   35065             : SgInitializedName* SgInitializedName::next_node = nullptr;
   35066             : std::vector<unsigned char*> SgInitializedName::pools;
   35067             : 
   35068             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   35069             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   35070             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   35071             : // around this macro definition rather than each use).
   35072             : #ifndef ALLOC_MUTEX
   35073             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   35074             :         do {                                                                     \
   35075             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   35076             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   35077             :                 abort();                                                         \
   35078             :             }                                                                    \
   35079             :         } while (0);
   35080             : #endif
   35081             : 
   35082             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   35083             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   35084             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   35085             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   35086             : 
   35087             : /*! \brief New operator for SgInitializedName.
   35088             : 
   35089             :    This new operator implements memory pools to provide most efficent 
   35090             :    use of the heap within construction of large ASTs.
   35091             : 
   35092             : \internal The new and delete operators use the lower level C malloc/free
   35093             :    function calls for performance and to make sure that mixing of malloc/free
   35094             :    and new/delete by the used can be caught more readily.  This may change
   35095             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   35096             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   35097             :    deallocate memory allocated using ROSE_MALLOC.
   35098             : */
   35099     6428380 : void *SgInitializedName::operator new ( size_t Size )
   35100             : {
   35101             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   35102             :      * returning or throwing an exception. */
   35103     6428380 :     ALLOC_MUTEX(SgInitializedName, lock);
   35104             : 
   35105             : #if ROSE_ALLOC_TRACE == 2
   35106             : //    printf("SgInitializedName::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgInitializedName::next_node);
   35107             : #endif
   35108             : 
   35109             : #if USE_CPP_NEW_DELETE_OPERATORS
   35110             :     void *mem = ROSE_MALLOC(Size);
   35111             :     ALLOC_MUTEX(SgInitializedName, unlock);
   35112             :     return mem;
   35113             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   35114             : #if ROSE_PEDANTIC_ALLOC
   35115             :     ROSE_ASSERT(Size == sizeof(SgInitializedName));
   35116             : #else
   35117     6428380 :     if (Size != sizeof(SgInitializedName)) {
   35118           0 :       void * object = ROSE_MALLOC(Size);
   35119           0 :       ALLOC_MUTEX(SgInitializedName, unlock);
   35120             :       return object;
   35121             :     }
   35122             : #endif
   35123             : 
   35124     6428380 :     if (SgInitializedName::next_node == nullptr) {
   35125        3337 :         SgInitializedName * alloc = (SgInitializedName*) ROSE_MALLOC ( SgInitializedName::pool_size * sizeof(SgInitializedName) );
   35126        3337 :         ROSE_ASSERT(alloc != nullptr);
   35127             : 
   35128             : #if ROSE_ALLOC_TRACE == 2
   35129             : //        printf("SgInitializedName::alloc\n  block[%zi] = [ %p , %p [\n", SgInitializedName::pools.size(), alloc, alloc + SgInitializedName::pool_size);
   35130             : #endif
   35131             : 
   35132             : #if ROSE_ALLOC_MEMSET == 1
   35133             : #elif ROSE_ALLOC_MEMSET == 2
   35134             :         memset(alloc, 0x00, SgInitializedName::pool_size * sizeof(SgInitializedName));
   35135             : #elif ROSE_ALLOC_MEMSET == 3
   35136             :         memset(alloc, 0xAA, SgInitializedName::pool_size * sizeof(SgInitializedName));
   35137             : #endif
   35138     6674000 :         for (unsigned i=0; i < SgInitializedName::pool_size-1; i++) {
   35139     6670660 :           alloc[i].p_freepointer = &(alloc[i+1]);
   35140             :         }
   35141        3337 :         alloc[SgInitializedName::pool_size-1].p_freepointer = nullptr;
   35142             : 
   35143        3337 :         SgInitializedName::pools.push_back ( (unsigned char *) alloc );
   35144        3337 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgInitializedName::pool_size * sizeof(SgInitializedName), V_SgInitializedName ) );
   35145        3337 :         SgInitializedName::next_node = alloc;
   35146             :     }
   35147     6428380 :     ROSE_ASSERT(SgInitializedName::next_node != nullptr);
   35148             : 
   35149     6428380 :     SgInitializedName * object = SgInitializedName::next_node;
   35150     6428380 :     SgInitializedName::next_node = (SgInitializedName*)(object->p_freepointer);
   35151             : 
   35152             : #if ROSE_ALLOC_TRACE == 2
   35153             :     printf("SgInitializedName::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgInitializedName::next_node);
   35154             : #endif
   35155             : 
   35156     6428380 :     SgNode * fp = object->p_freepointer;
   35157             : #if ROSE_ALLOC_MEMSET == 1
   35158             : #elif ROSE_ALLOC_MEMSET == 2
   35159             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgInitializedName) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   35160             : #elif ROSE_ALLOC_MEMSET == 3
   35161             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgInitializedName) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   35162             : #endif
   35163     6428380 :     object->p_freepointer = fp;
   35164             : 
   35165             : #if ROSE_ALLOC_TRACE == 2
   35166             : //    printf("SgInitializedName::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgInitializedName::next_node);
   35167             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   35168             :     Rose::MemPool::snapshot(oss.str());
   35169             :     alloc_trace_cnt++;
   35170             : #endif
   35171             : 
   35172     6428380 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   35173             : 
   35174     6428380 :     ALLOC_MUTEX(SgInitializedName, unlock);
   35175             : 
   35176             :     return object;
   35177             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   35178             : }
   35179             : 
   35180             : 
   35181             : 
   35182             : /*! \brief Delete operator for SgInitializedName.
   35183             : 
   35184             :    This delete operator implements deallocation using memory pools to 
   35185             :    provide most efficent use of the heap within construction of large ASTs.
   35186             : 
   35187             : \internal The new and delete operators use the lower level C malloc/free
   35188             :    function calls for performance and to make sure that mixing of malloc/free
   35189             :    and new/delete by the used can be caught more readily.  This may change
   35190             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   35191             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   35192             :    deallocate memory allocated using ROSE_MALLOC.
   35193             : */
   35194      110459 : void SgInitializedName::operator delete(void *Pointer, size_t Size)
   35195             : {
   35196             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   35197             :      * or throwing an exception. */
   35198      110459 :     ALLOC_MUTEX(SgInitializedName, lock);
   35199             : 
   35200             : #if USE_CPP_NEW_DELETE_OPERATORS
   35201             :     ROSE_FREE(Pointer);
   35202             : #else
   35203             : #if ROSE_PEDANTIC_ALLOC
   35204             :     ROSE_ASSERT(Size == sizeof(SgInitializedName));
   35205             : #else
   35206      110459 :     if (Size != sizeof(SgInitializedName)) {
   35207           0 :       ROSE_FREE(Pointer);
   35208           0 :       ALLOC_MUTEX(SgInitializedName, unlock);
   35209             :       return;
   35210             :     }
   35211             : #endif
   35212             : 
   35213      110459 :     SgInitializedName * object = (SgInitializedName*) Pointer;
   35214      110459 :     ROSE_ASSERT(object != nullptr);
   35215             : 
   35216             : #if ROSE_ALLOC_TRACE == 2
   35217             : //  printf("SgInitializedName::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgInitializedName::next_node);
   35218             :     printf("SgInitializedName::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgInitializedName::next_node);
   35219             : #endif
   35220             : 
   35221             : #if ROSE_PEDANTIC_ALLOC
   35222             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   35223             : #endif
   35224             : 
   35225             : #if ROSE_ALLOC_MEMSET == 1
   35226             : #elif ROSE_ALLOC_MEMSET == 2
   35227             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgInitializedName) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   35228             : #elif ROSE_ALLOC_MEMSET == 3
   35229             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgInitializedName) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   35230             : #endif
   35231             : 
   35232             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   35233             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   35234             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   35235             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   35236             : #else
   35237      110459 :     object->p_freepointer = SgInitializedName::next_node;
   35238      110459 :     SgInitializedName::next_node = object;
   35239             : #endif
   35240             : 
   35241             : #if ROSE_ALLOC_TRACE == 2
   35242             : //  printf("SgInitializedName::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgInitializedName::next_node);
   35243             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   35244             :     Rose::MemPool::snapshot(oss.str());
   35245             :     alloc_trace_cnt++;
   35246             : #endif
   35247             : 
   35248             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   35249             : 
   35250      110459 :     ALLOC_MUTEX(SgInitializedName, unlock);
   35251             : }
   35252             : 
   35253             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   35254             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   35255             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   35256             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   35257             : // Also, note comment below from Robb (copied from the Common.code file).
   35258             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   35259             : //
   35260             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   35261             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   35262             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   35263             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   35264             : #if 0
   35265             : void SgInitializedName::operator delete(void* pointer) { SgInitializedName::operator delete (pointer, sizeof(SgInitializedName)); };
   35266             : #endif
   35267             : /* #line 35268 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   35268             : 
   35269             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   35270             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   35271             : // obviously imply C++.
   35272             : 
   35273             : // This implements the support within ROSE for memory pools.  Memory pools
   35274             : // support the most condensed usage of memory within the construction of
   35275             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   35276             : // by a new operator written for each class.
   35277             : 
   35278             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   35279             :     // User wants multi-thread support and POSIX threads are available.
   35280             : #   include <pthread.h>
   35281             :     static pthread_mutex_t SgInterfaceBody_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   35282             : #else
   35283             :      // Cause synchronization to be skipped.
   35284             : #    ifndef ALLOC_MUTEX
   35285             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   35286             : #    endif
   35287             : #    ifdef _REENTRANT
   35288             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   35289             : #       ifdef _MSC_VER
   35290             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   35291             : #       else
   35292             : #           warning "POSIX threads are not available; synchronization being skipped"
   35293             : #       endif
   35294             : #    endif
   35295             : #endif
   35296             : 
   35297             : #ifndef ROSE_ALLOC_TRACE
   35298             : #  define ROSE_ALLOC_TRACE 0
   35299             : #endif
   35300             : 
   35301             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   35302             : #define ROSE_ALLOC_TRACE_CNT
   35303             : #include "memory-pool-snapshot.h"
   35304             : unsigned long alloc_trace_cnt = 0;
   35305             : #endif
   35306             : 
   35307             : #if ROSE_ALLOC_TRACE
   35308             : const unsigned SgInterfaceBody::pool_size = 5;
   35309             : #else
   35310             : const unsigned SgInterfaceBody::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   35311             : #endif
   35312             : 
   35313             : #ifndef ROSE_ALLOC_MEMSET
   35314             : #  define ROSE_ALLOC_MEMSET 0
   35315             : #endif
   35316             : 
   35317             : #ifndef ROSE_PEDANTIC_ALLOC
   35318             : #  define ROSE_PEDANTIC_ALLOC 0
   35319             : #endif
   35320             : 
   35321             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   35322             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   35323             : #endif
   35324             : 
   35325             : #if !defined(SGNODE__ALL_POOLS)
   35326             : #define SGNODE__ALL_POOLS
   35327             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   35328             : #endif
   35329             : 
   35330             : SgInterfaceBody* SgInterfaceBody::next_node = nullptr;
   35331             : std::vector<unsigned char*> SgInterfaceBody::pools;
   35332             : 
   35333             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   35334             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   35335             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   35336             : // around this macro definition rather than each use).
   35337             : #ifndef ALLOC_MUTEX
   35338             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   35339             :         do {                                                                     \
   35340             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   35341             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   35342             :                 abort();                                                         \
   35343             :             }                                                                    \
   35344             :         } while (0);
   35345             : #endif
   35346             : 
   35347             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   35348             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   35349             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   35350             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   35351             : 
   35352             : /*! \brief New operator for SgInterfaceBody.
   35353             : 
   35354             :    This new operator implements memory pools to provide most efficent 
   35355             :    use of the heap within construction of large ASTs.
   35356             : 
   35357             : \internal The new and delete operators use the lower level C malloc/free
   35358             :    function calls for performance and to make sure that mixing of malloc/free
   35359             :    and new/delete by the used can be caught more readily.  This may change
   35360             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   35361             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   35362             :    deallocate memory allocated using ROSE_MALLOC.
   35363             : */
   35364           0 : void *SgInterfaceBody::operator new ( size_t Size )
   35365             : {
   35366             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   35367             :      * returning or throwing an exception. */
   35368           0 :     ALLOC_MUTEX(SgInterfaceBody, lock);
   35369             : 
   35370             : #if ROSE_ALLOC_TRACE == 2
   35371             : //    printf("SgInterfaceBody::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgInterfaceBody::next_node);
   35372             : #endif
   35373             : 
   35374             : #if USE_CPP_NEW_DELETE_OPERATORS
   35375             :     void *mem = ROSE_MALLOC(Size);
   35376             :     ALLOC_MUTEX(SgInterfaceBody, unlock);
   35377             :     return mem;
   35378             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   35379             : #if ROSE_PEDANTIC_ALLOC
   35380             :     ROSE_ASSERT(Size == sizeof(SgInterfaceBody));
   35381             : #else
   35382           0 :     if (Size != sizeof(SgInterfaceBody)) {
   35383           0 :       void * object = ROSE_MALLOC(Size);
   35384           0 :       ALLOC_MUTEX(SgInterfaceBody, unlock);
   35385             :       return object;
   35386             :     }
   35387             : #endif
   35388             : 
   35389           0 :     if (SgInterfaceBody::next_node == nullptr) {
   35390           0 :         SgInterfaceBody * alloc = (SgInterfaceBody*) ROSE_MALLOC ( SgInterfaceBody::pool_size * sizeof(SgInterfaceBody) );
   35391           0 :         ROSE_ASSERT(alloc != nullptr);
   35392             : 
   35393             : #if ROSE_ALLOC_TRACE == 2
   35394             : //        printf("SgInterfaceBody::alloc\n  block[%zi] = [ %p , %p [\n", SgInterfaceBody::pools.size(), alloc, alloc + SgInterfaceBody::pool_size);
   35395             : #endif
   35396             : 
   35397             : #if ROSE_ALLOC_MEMSET == 1
   35398             : #elif ROSE_ALLOC_MEMSET == 2
   35399             :         memset(alloc, 0x00, SgInterfaceBody::pool_size * sizeof(SgInterfaceBody));
   35400             : #elif ROSE_ALLOC_MEMSET == 3
   35401             :         memset(alloc, 0xAA, SgInterfaceBody::pool_size * sizeof(SgInterfaceBody));
   35402             : #endif
   35403           0 :         for (unsigned i=0; i < SgInterfaceBody::pool_size-1; i++) {
   35404           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
   35405             :         }
   35406           0 :         alloc[SgInterfaceBody::pool_size-1].p_freepointer = nullptr;
   35407             : 
   35408           0 :         SgInterfaceBody::pools.push_back ( (unsigned char *) alloc );
   35409           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgInterfaceBody::pool_size * sizeof(SgInterfaceBody), V_SgInterfaceBody ) );
   35410           0 :         SgInterfaceBody::next_node = alloc;
   35411             :     }
   35412           0 :     ROSE_ASSERT(SgInterfaceBody::next_node != nullptr);
   35413             : 
   35414           0 :     SgInterfaceBody * object = SgInterfaceBody::next_node;
   35415           0 :     SgInterfaceBody::next_node = (SgInterfaceBody*)(object->p_freepointer);
   35416             : 
   35417             : #if ROSE_ALLOC_TRACE == 2
   35418             :     printf("SgInterfaceBody::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgInterfaceBody::next_node);
   35419             : #endif
   35420             : 
   35421           0 :     SgNode * fp = object->p_freepointer;
   35422             : #if ROSE_ALLOC_MEMSET == 1
   35423             : #elif ROSE_ALLOC_MEMSET == 2
   35424             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgInterfaceBody) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   35425             : #elif ROSE_ALLOC_MEMSET == 3
   35426             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgInterfaceBody) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   35427             : #endif
   35428           0 :     object->p_freepointer = fp;
   35429             : 
   35430             : #if ROSE_ALLOC_TRACE == 2
   35431             : //    printf("SgInterfaceBody::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgInterfaceBody::next_node);
   35432             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   35433             :     Rose::MemPool::snapshot(oss.str());
   35434             :     alloc_trace_cnt++;
   35435             : #endif
   35436             : 
   35437           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   35438             : 
   35439           0 :     ALLOC_MUTEX(SgInterfaceBody, unlock);
   35440             : 
   35441             :     return object;
   35442             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   35443             : }
   35444             : 
   35445             : 
   35446             : 
   35447             : /*! \brief Delete operator for SgInterfaceBody.
   35448             : 
   35449             :    This delete operator implements deallocation using memory pools to 
   35450             :    provide most efficent use of the heap within construction of large ASTs.
   35451             : 
   35452             : \internal The new and delete operators use the lower level C malloc/free
   35453             :    function calls for performance and to make sure that mixing of malloc/free
   35454             :    and new/delete by the used can be caught more readily.  This may change
   35455             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   35456             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   35457             :    deallocate memory allocated using ROSE_MALLOC.
   35458             : */
   35459           0 : void SgInterfaceBody::operator delete(void *Pointer, size_t Size)
   35460             : {
   35461             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   35462             :      * or throwing an exception. */
   35463           0 :     ALLOC_MUTEX(SgInterfaceBody, lock);
   35464             : 
   35465             : #if USE_CPP_NEW_DELETE_OPERATORS
   35466             :     ROSE_FREE(Pointer);
   35467             : #else
   35468             : #if ROSE_PEDANTIC_ALLOC
   35469             :     ROSE_ASSERT(Size == sizeof(SgInterfaceBody));
   35470             : #else
   35471           0 :     if (Size != sizeof(SgInterfaceBody)) {
   35472           0 :       ROSE_FREE(Pointer);
   35473           0 :       ALLOC_MUTEX(SgInterfaceBody, unlock);
   35474             :       return;
   35475             :     }
   35476             : #endif
   35477             : 
   35478           0 :     SgInterfaceBody * object = (SgInterfaceBody*) Pointer;
   35479           0 :     ROSE_ASSERT(object != nullptr);
   35480             : 
   35481             : #if ROSE_ALLOC_TRACE == 2
   35482             : //  printf("SgInterfaceBody::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgInterfaceBody::next_node);
   35483             :     printf("SgInterfaceBody::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgInterfaceBody::next_node);
   35484             : #endif
   35485             : 
   35486             : #if ROSE_PEDANTIC_ALLOC
   35487             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   35488             : #endif
   35489             : 
   35490             : #if ROSE_ALLOC_MEMSET == 1
   35491             : #elif ROSE_ALLOC_MEMSET == 2
   35492             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgInterfaceBody) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   35493             : #elif ROSE_ALLOC_MEMSET == 3
   35494             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgInterfaceBody) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   35495             : #endif
   35496             : 
   35497             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   35498             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   35499             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   35500             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   35501             : #else
   35502           0 :     object->p_freepointer = SgInterfaceBody::next_node;
   35503           0 :     SgInterfaceBody::next_node = object;
   35504             : #endif
   35505             : 
   35506             : #if ROSE_ALLOC_TRACE == 2
   35507             : //  printf("SgInterfaceBody::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgInterfaceBody::next_node);
   35508             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   35509             :     Rose::MemPool::snapshot(oss.str());
   35510             :     alloc_trace_cnt++;
   35511             : #endif
   35512             : 
   35513             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   35514             : 
   35515           0 :     ALLOC_MUTEX(SgInterfaceBody, unlock);
   35516             : }
   35517             : 
   35518             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   35519             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   35520             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   35521             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   35522             : // Also, note comment below from Robb (copied from the Common.code file).
   35523             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   35524             : //
   35525             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   35526             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   35527             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   35528             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   35529             : #if 0
   35530             : void SgInterfaceBody::operator delete(void* pointer) { SgInterfaceBody::operator delete (pointer, sizeof(SgInterfaceBody)); };
   35531             : #endif
   35532             : /* #line 35533 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   35533             : 
   35534             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   35535             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   35536             : // obviously imply C++.
   35537             : 
   35538             : // This implements the support within ROSE for memory pools.  Memory pools
   35539             : // support the most condensed usage of memory within the construction of
   35540             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   35541             : // by a new operator written for each class.
   35542             : 
   35543             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   35544             :     // User wants multi-thread support and POSIX threads are available.
   35545             : #   include <pthread.h>
   35546             :     static pthread_mutex_t SgHeaderFileBody_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   35547             : #else
   35548             :      // Cause synchronization to be skipped.
   35549             : #    ifndef ALLOC_MUTEX
   35550             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   35551             : #    endif
   35552             : #    ifdef _REENTRANT
   35553             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   35554             : #       ifdef _MSC_VER
   35555             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   35556             : #       else
   35557             : #           warning "POSIX threads are not available; synchronization being skipped"
   35558             : #       endif
   35559             : #    endif
   35560             : #endif
   35561             : 
   35562             : #ifndef ROSE_ALLOC_TRACE
   35563             : #  define ROSE_ALLOC_TRACE 0
   35564             : #endif
   35565             : 
   35566             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   35567             : #define ROSE_ALLOC_TRACE_CNT
   35568             : #include "memory-pool-snapshot.h"
   35569             : unsigned long alloc_trace_cnt = 0;
   35570             : #endif
   35571             : 
   35572             : #if ROSE_ALLOC_TRACE
   35573             : const unsigned SgHeaderFileBody::pool_size = 5;
   35574             : #else
   35575             : const unsigned SgHeaderFileBody::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   35576             : #endif
   35577             : 
   35578             : #ifndef ROSE_ALLOC_MEMSET
   35579             : #  define ROSE_ALLOC_MEMSET 0
   35580             : #endif
   35581             : 
   35582             : #ifndef ROSE_PEDANTIC_ALLOC
   35583             : #  define ROSE_PEDANTIC_ALLOC 0
   35584             : #endif
   35585             : 
   35586             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   35587             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   35588             : #endif
   35589             : 
   35590             : #if !defined(SGNODE__ALL_POOLS)
   35591             : #define SGNODE__ALL_POOLS
   35592             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   35593             : #endif
   35594             : 
   35595             : SgHeaderFileBody* SgHeaderFileBody::next_node = nullptr;
   35596             : std::vector<unsigned char*> SgHeaderFileBody::pools;
   35597             : 
   35598             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   35599             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   35600             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   35601             : // around this macro definition rather than each use).
   35602             : #ifndef ALLOC_MUTEX
   35603             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   35604             :         do {                                                                     \
   35605             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   35606             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   35607             :                 abort();                                                         \
   35608             :             }                                                                    \
   35609             :         } while (0);
   35610             : #endif
   35611             : 
   35612             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   35613             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   35614             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   35615             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   35616             : 
   35617             : /*! \brief New operator for SgHeaderFileBody.
   35618             : 
   35619             :    This new operator implements memory pools to provide most efficent 
   35620             :    use of the heap within construction of large ASTs.
   35621             : 
   35622             : \internal The new and delete operators use the lower level C malloc/free
   35623             :    function calls for performance and to make sure that mixing of malloc/free
   35624             :    and new/delete by the used can be caught more readily.  This may change
   35625             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   35626             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   35627             :    deallocate memory allocated using ROSE_MALLOC.
   35628             : */
   35629           0 : void *SgHeaderFileBody::operator new ( size_t Size )
   35630             : {
   35631             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   35632             :      * returning or throwing an exception. */
   35633           0 :     ALLOC_MUTEX(SgHeaderFileBody, lock);
   35634             : 
   35635             : #if ROSE_ALLOC_TRACE == 2
   35636             : //    printf("SgHeaderFileBody::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgHeaderFileBody::next_node);
   35637             : #endif
   35638             : 
   35639             : #if USE_CPP_NEW_DELETE_OPERATORS
   35640             :     void *mem = ROSE_MALLOC(Size);
   35641             :     ALLOC_MUTEX(SgHeaderFileBody, unlock);
   35642             :     return mem;
   35643             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   35644             : #if ROSE_PEDANTIC_ALLOC
   35645             :     ROSE_ASSERT(Size == sizeof(SgHeaderFileBody));
   35646             : #else
   35647           0 :     if (Size != sizeof(SgHeaderFileBody)) {
   35648           0 :       void * object = ROSE_MALLOC(Size);
   35649           0 :       ALLOC_MUTEX(SgHeaderFileBody, unlock);
   35650             :       return object;
   35651             :     }
   35652             : #endif
   35653             : 
   35654           0 :     if (SgHeaderFileBody::next_node == nullptr) {
   35655           0 :         SgHeaderFileBody * alloc = (SgHeaderFileBody*) ROSE_MALLOC ( SgHeaderFileBody::pool_size * sizeof(SgHeaderFileBody) );
   35656           0 :         ROSE_ASSERT(alloc != nullptr);
   35657             : 
   35658             : #if ROSE_ALLOC_TRACE == 2
   35659             : //        printf("SgHeaderFileBody::alloc\n  block[%zi] = [ %p , %p [\n", SgHeaderFileBody::pools.size(), alloc, alloc + SgHeaderFileBody::pool_size);
   35660             : #endif
   35661             : 
   35662             : #if ROSE_ALLOC_MEMSET == 1
   35663             : #elif ROSE_ALLOC_MEMSET == 2
   35664             :         memset(alloc, 0x00, SgHeaderFileBody::pool_size * sizeof(SgHeaderFileBody));
   35665             : #elif ROSE_ALLOC_MEMSET == 3
   35666             :         memset(alloc, 0xAA, SgHeaderFileBody::pool_size * sizeof(SgHeaderFileBody));
   35667             : #endif
   35668           0 :         for (unsigned i=0; i < SgHeaderFileBody::pool_size-1; i++) {
   35669           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
   35670             :         }
   35671           0 :         alloc[SgHeaderFileBody::pool_size-1].p_freepointer = nullptr;
   35672             : 
   35673           0 :         SgHeaderFileBody::pools.push_back ( (unsigned char *) alloc );
   35674           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgHeaderFileBody::pool_size * sizeof(SgHeaderFileBody), V_SgHeaderFileBody ) );
   35675           0 :         SgHeaderFileBody::next_node = alloc;
   35676             :     }
   35677           0 :     ROSE_ASSERT(SgHeaderFileBody::next_node != nullptr);
   35678             : 
   35679           0 :     SgHeaderFileBody * object = SgHeaderFileBody::next_node;
   35680           0 :     SgHeaderFileBody::next_node = (SgHeaderFileBody*)(object->p_freepointer);
   35681             : 
   35682             : #if ROSE_ALLOC_TRACE == 2
   35683             :     printf("SgHeaderFileBody::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgHeaderFileBody::next_node);
   35684             : #endif
   35685             : 
   35686           0 :     SgNode * fp = object->p_freepointer;
   35687             : #if ROSE_ALLOC_MEMSET == 1
   35688             : #elif ROSE_ALLOC_MEMSET == 2
   35689             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgHeaderFileBody) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   35690             : #elif ROSE_ALLOC_MEMSET == 3
   35691             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgHeaderFileBody) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   35692             : #endif
   35693           0 :     object->p_freepointer = fp;
   35694             : 
   35695             : #if ROSE_ALLOC_TRACE == 2
   35696             : //    printf("SgHeaderFileBody::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgHeaderFileBody::next_node);
   35697             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   35698             :     Rose::MemPool::snapshot(oss.str());
   35699             :     alloc_trace_cnt++;
   35700             : #endif
   35701             : 
   35702           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   35703             : 
   35704           0 :     ALLOC_MUTEX(SgHeaderFileBody, unlock);
   35705             : 
   35706             :     return object;
   35707             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   35708             : }
   35709             : 
   35710             : 
   35711             : 
   35712             : /*! \brief Delete operator for SgHeaderFileBody.
   35713             : 
   35714             :    This delete operator implements deallocation using memory pools to 
   35715             :    provide most efficent use of the heap within construction of large ASTs.
   35716             : 
   35717             : \internal The new and delete operators use the lower level C malloc/free
   35718             :    function calls for performance and to make sure that mixing of malloc/free
   35719             :    and new/delete by the used can be caught more readily.  This may change
   35720             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   35721             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   35722             :    deallocate memory allocated using ROSE_MALLOC.
   35723             : */
   35724           0 : void SgHeaderFileBody::operator delete(void *Pointer, size_t Size)
   35725             : {
   35726             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   35727             :      * or throwing an exception. */
   35728           0 :     ALLOC_MUTEX(SgHeaderFileBody, lock);
   35729             : 
   35730             : #if USE_CPP_NEW_DELETE_OPERATORS
   35731             :     ROSE_FREE(Pointer);
   35732             : #else
   35733             : #if ROSE_PEDANTIC_ALLOC
   35734             :     ROSE_ASSERT(Size == sizeof(SgHeaderFileBody));
   35735             : #else
   35736           0 :     if (Size != sizeof(SgHeaderFileBody)) {
   35737           0 :       ROSE_FREE(Pointer);
   35738           0 :       ALLOC_MUTEX(SgHeaderFileBody, unlock);
   35739             :       return;
   35740             :     }
   35741             : #endif
   35742             : 
   35743           0 :     SgHeaderFileBody * object = (SgHeaderFileBody*) Pointer;
   35744           0 :     ROSE_ASSERT(object != nullptr);
   35745             : 
   35746             : #if ROSE_ALLOC_TRACE == 2
   35747             : //  printf("SgHeaderFileBody::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgHeaderFileBody::next_node);
   35748             :     printf("SgHeaderFileBody::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgHeaderFileBody::next_node);
   35749             : #endif
   35750             : 
   35751             : #if ROSE_PEDANTIC_ALLOC
   35752             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   35753             : #endif
   35754             : 
   35755             : #if ROSE_ALLOC_MEMSET == 1
   35756             : #elif ROSE_ALLOC_MEMSET == 2
   35757             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgHeaderFileBody) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   35758             : #elif ROSE_ALLOC_MEMSET == 3
   35759             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgHeaderFileBody) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   35760             : #endif
   35761             : 
   35762             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   35763             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   35764             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   35765             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   35766             : #else
   35767           0 :     object->p_freepointer = SgHeaderFileBody::next_node;
   35768           0 :     SgHeaderFileBody::next_node = object;
   35769             : #endif
   35770             : 
   35771             : #if ROSE_ALLOC_TRACE == 2
   35772             : //  printf("SgHeaderFileBody::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgHeaderFileBody::next_node);
   35773             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   35774             :     Rose::MemPool::snapshot(oss.str());
   35775             :     alloc_trace_cnt++;
   35776             : #endif
   35777             : 
   35778             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   35779             : 
   35780           0 :     ALLOC_MUTEX(SgHeaderFileBody, unlock);
   35781             : }
   35782             : 
   35783             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   35784             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   35785             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   35786             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   35787             : // Also, note comment below from Robb (copied from the Common.code file).
   35788             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   35789             : //
   35790             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   35791             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   35792             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   35793             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   35794             : #if 0
   35795             : void SgHeaderFileBody::operator delete(void* pointer) { SgHeaderFileBody::operator delete (pointer, sizeof(SgHeaderFileBody)); };
   35796             : #endif
   35797             : /* #line 35798 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   35798             : 
   35799             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   35800             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   35801             : // obviously imply C++.
   35802             : 
   35803             : // This implements the support within ROSE for memory pools.  Memory pools
   35804             : // support the most condensed usage of memory within the construction of
   35805             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   35806             : // by a new operator written for each class.
   35807             : 
   35808             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   35809             :     // User wants multi-thread support and POSIX threads are available.
   35810             : #   include <pthread.h>
   35811             :     static pthread_mutex_t SgRenamePair_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   35812             : #else
   35813             :      // Cause synchronization to be skipped.
   35814             : #    ifndef ALLOC_MUTEX
   35815             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   35816             : #    endif
   35817             : #    ifdef _REENTRANT
   35818             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   35819             : #       ifdef _MSC_VER
   35820             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   35821             : #       else
   35822             : #           warning "POSIX threads are not available; synchronization being skipped"
   35823             : #       endif
   35824             : #    endif
   35825             : #endif
   35826             : 
   35827             : #ifndef ROSE_ALLOC_TRACE
   35828             : #  define ROSE_ALLOC_TRACE 0
   35829             : #endif
   35830             : 
   35831             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   35832             : #define ROSE_ALLOC_TRACE_CNT
   35833             : #include "memory-pool-snapshot.h"
   35834             : unsigned long alloc_trace_cnt = 0;
   35835             : #endif
   35836             : 
   35837             : #if ROSE_ALLOC_TRACE
   35838             : const unsigned SgRenamePair::pool_size = 5;
   35839             : #else
   35840             : const unsigned SgRenamePair::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   35841             : #endif
   35842             : 
   35843             : #ifndef ROSE_ALLOC_MEMSET
   35844             : #  define ROSE_ALLOC_MEMSET 0
   35845             : #endif
   35846             : 
   35847             : #ifndef ROSE_PEDANTIC_ALLOC
   35848             : #  define ROSE_PEDANTIC_ALLOC 0
   35849             : #endif
   35850             : 
   35851             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   35852             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   35853             : #endif
   35854             : 
   35855             : #if !defined(SGNODE__ALL_POOLS)
   35856             : #define SGNODE__ALL_POOLS
   35857             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   35858             : #endif
   35859             : 
   35860             : SgRenamePair* SgRenamePair::next_node = nullptr;
   35861             : std::vector<unsigned char*> SgRenamePair::pools;
   35862             : 
   35863             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   35864             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   35865             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   35866             : // around this macro definition rather than each use).
   35867             : #ifndef ALLOC_MUTEX
   35868             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   35869             :         do {                                                                     \
   35870             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   35871             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   35872             :                 abort();                                                         \
   35873             :             }                                                                    \
   35874             :         } while (0);
   35875             : #endif
   35876             : 
   35877             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   35878             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   35879             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   35880             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   35881             : 
   35882             : /*! \brief New operator for SgRenamePair.
   35883             : 
   35884             :    This new operator implements memory pools to provide most efficent 
   35885             :    use of the heap within construction of large ASTs.
   35886             : 
   35887             : \internal The new and delete operators use the lower level C malloc/free
   35888             :    function calls for performance and to make sure that mixing of malloc/free
   35889             :    and new/delete by the used can be caught more readily.  This may change
   35890             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   35891             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   35892             :    deallocate memory allocated using ROSE_MALLOC.
   35893             : */
   35894           0 : void *SgRenamePair::operator new ( size_t Size )
   35895             : {
   35896             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   35897             :      * returning or throwing an exception. */
   35898           0 :     ALLOC_MUTEX(SgRenamePair, lock);
   35899             : 
   35900             : #if ROSE_ALLOC_TRACE == 2
   35901             : //    printf("SgRenamePair::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgRenamePair::next_node);
   35902             : #endif
   35903             : 
   35904             : #if USE_CPP_NEW_DELETE_OPERATORS
   35905             :     void *mem = ROSE_MALLOC(Size);
   35906             :     ALLOC_MUTEX(SgRenamePair, unlock);
   35907             :     return mem;
   35908             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   35909             : #if ROSE_PEDANTIC_ALLOC
   35910             :     ROSE_ASSERT(Size == sizeof(SgRenamePair));
   35911             : #else
   35912           0 :     if (Size != sizeof(SgRenamePair)) {
   35913           0 :       void * object = ROSE_MALLOC(Size);
   35914           0 :       ALLOC_MUTEX(SgRenamePair, unlock);
   35915             :       return object;
   35916             :     }
   35917             : #endif
   35918             : 
   35919           0 :     if (SgRenamePair::next_node == nullptr) {
   35920           0 :         SgRenamePair * alloc = (SgRenamePair*) ROSE_MALLOC ( SgRenamePair::pool_size * sizeof(SgRenamePair) );
   35921           0 :         ROSE_ASSERT(alloc != nullptr);
   35922             : 
   35923             : #if ROSE_ALLOC_TRACE == 2
   35924             : //        printf("SgRenamePair::alloc\n  block[%zi] = [ %p , %p [\n", SgRenamePair::pools.size(), alloc, alloc + SgRenamePair::pool_size);
   35925             : #endif
   35926             : 
   35927             : #if ROSE_ALLOC_MEMSET == 1
   35928             : #elif ROSE_ALLOC_MEMSET == 2
   35929             :         memset(alloc, 0x00, SgRenamePair::pool_size * sizeof(SgRenamePair));
   35930             : #elif ROSE_ALLOC_MEMSET == 3
   35931             :         memset(alloc, 0xAA, SgRenamePair::pool_size * sizeof(SgRenamePair));
   35932             : #endif
   35933           0 :         for (unsigned i=0; i < SgRenamePair::pool_size-1; i++) {
   35934           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
   35935             :         }
   35936           0 :         alloc[SgRenamePair::pool_size-1].p_freepointer = nullptr;
   35937             : 
   35938           0 :         SgRenamePair::pools.push_back ( (unsigned char *) alloc );
   35939           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgRenamePair::pool_size * sizeof(SgRenamePair), V_SgRenamePair ) );
   35940           0 :         SgRenamePair::next_node = alloc;
   35941             :     }
   35942           0 :     ROSE_ASSERT(SgRenamePair::next_node != nullptr);
   35943             : 
   35944           0 :     SgRenamePair * object = SgRenamePair::next_node;
   35945           0 :     SgRenamePair::next_node = (SgRenamePair*)(object->p_freepointer);
   35946             : 
   35947             : #if ROSE_ALLOC_TRACE == 2
   35948             :     printf("SgRenamePair::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgRenamePair::next_node);
   35949             : #endif
   35950             : 
   35951           0 :     SgNode * fp = object->p_freepointer;
   35952             : #if ROSE_ALLOC_MEMSET == 1
   35953             : #elif ROSE_ALLOC_MEMSET == 2
   35954             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgRenamePair) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   35955             : #elif ROSE_ALLOC_MEMSET == 3
   35956             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgRenamePair) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   35957             : #endif
   35958           0 :     object->p_freepointer = fp;
   35959             : 
   35960             : #if ROSE_ALLOC_TRACE == 2
   35961             : //    printf("SgRenamePair::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgRenamePair::next_node);
   35962             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   35963             :     Rose::MemPool::snapshot(oss.str());
   35964             :     alloc_trace_cnt++;
   35965             : #endif
   35966             : 
   35967           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   35968             : 
   35969           0 :     ALLOC_MUTEX(SgRenamePair, unlock);
   35970             : 
   35971             :     return object;
   35972             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   35973             : }
   35974             : 
   35975             : 
   35976             : 
   35977             : /*! \brief Delete operator for SgRenamePair.
   35978             : 
   35979             :    This delete operator implements deallocation using memory pools to 
   35980             :    provide most efficent use of the heap within construction of large ASTs.
   35981             : 
   35982             : \internal The new and delete operators use the lower level C malloc/free
   35983             :    function calls for performance and to make sure that mixing of malloc/free
   35984             :    and new/delete by the used can be caught more readily.  This may change
   35985             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   35986             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   35987             :    deallocate memory allocated using ROSE_MALLOC.
   35988             : */
   35989           0 : void SgRenamePair::operator delete(void *Pointer, size_t Size)
   35990             : {
   35991             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   35992             :      * or throwing an exception. */
   35993           0 :     ALLOC_MUTEX(SgRenamePair, lock);
   35994             : 
   35995             : #if USE_CPP_NEW_DELETE_OPERATORS
   35996             :     ROSE_FREE(Pointer);
   35997             : #else
   35998             : #if ROSE_PEDANTIC_ALLOC
   35999             :     ROSE_ASSERT(Size == sizeof(SgRenamePair));
   36000             : #else
   36001           0 :     if (Size != sizeof(SgRenamePair)) {
   36002           0 :       ROSE_FREE(Pointer);
   36003           0 :       ALLOC_MUTEX(SgRenamePair, unlock);
   36004             :       return;
   36005             :     }
   36006             : #endif
   36007             : 
   36008           0 :     SgRenamePair * object = (SgRenamePair*) Pointer;
   36009           0 :     ROSE_ASSERT(object != nullptr);
   36010             : 
   36011             : #if ROSE_ALLOC_TRACE == 2
   36012             : //  printf("SgRenamePair::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgRenamePair::next_node);
   36013             :     printf("SgRenamePair::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgRenamePair::next_node);
   36014             : #endif
   36015             : 
   36016             : #if ROSE_PEDANTIC_ALLOC
   36017             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   36018             : #endif
   36019             : 
   36020             : #if ROSE_ALLOC_MEMSET == 1
   36021             : #elif ROSE_ALLOC_MEMSET == 2
   36022             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgRenamePair) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   36023             : #elif ROSE_ALLOC_MEMSET == 3
   36024             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgRenamePair) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   36025             : #endif
   36026             : 
   36027             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   36028             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   36029             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   36030             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   36031             : #else
   36032           0 :     object->p_freepointer = SgRenamePair::next_node;
   36033           0 :     SgRenamePair::next_node = object;
   36034             : #endif
   36035             : 
   36036             : #if ROSE_ALLOC_TRACE == 2
   36037             : //  printf("SgRenamePair::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgRenamePair::next_node);
   36038             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   36039             :     Rose::MemPool::snapshot(oss.str());
   36040             :     alloc_trace_cnt++;
   36041             : #endif
   36042             : 
   36043             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   36044             : 
   36045           0 :     ALLOC_MUTEX(SgRenamePair, unlock);
   36046             : }
   36047             : 
   36048             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   36049             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   36050             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   36051             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   36052             : // Also, note comment below from Robb (copied from the Common.code file).
   36053             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   36054             : //
   36055             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   36056             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   36057             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   36058             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   36059             : #if 0
   36060             : void SgRenamePair::operator delete(void* pointer) { SgRenamePair::operator delete (pointer, sizeof(SgRenamePair)); };
   36061             : #endif
   36062             : /* #line 36063 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   36063             : 
   36064             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   36065             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   36066             : // obviously imply C++.
   36067             : 
   36068             : // This implements the support within ROSE for memory pools.  Memory pools
   36069             : // support the most condensed usage of memory within the construction of
   36070             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   36071             : // by a new operator written for each class.
   36072             : 
   36073             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   36074             :     // User wants multi-thread support and POSIX threads are available.
   36075             : #   include <pthread.h>
   36076             :     static pthread_mutex_t SgOmpClause_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   36077             : #else
   36078             :      // Cause synchronization to be skipped.
   36079             : #    ifndef ALLOC_MUTEX
   36080             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   36081             : #    endif
   36082             : #    ifdef _REENTRANT
   36083             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   36084             : #       ifdef _MSC_VER
   36085             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   36086             : #       else
   36087             : #           warning "POSIX threads are not available; synchronization being skipped"
   36088             : #       endif
   36089             : #    endif
   36090             : #endif
   36091             : 
   36092             : #ifndef ROSE_ALLOC_TRACE
   36093             : #  define ROSE_ALLOC_TRACE 0
   36094             : #endif
   36095             : 
   36096             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   36097             : #define ROSE_ALLOC_TRACE_CNT
   36098             : #include "memory-pool-snapshot.h"
   36099             : unsigned long alloc_trace_cnt = 0;
   36100             : #endif
   36101             : 
   36102             : #if ROSE_ALLOC_TRACE
   36103             : const unsigned SgOmpClause::pool_size = 5;
   36104             : #else
   36105             : const unsigned SgOmpClause::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   36106             : #endif
   36107             : 
   36108             : #ifndef ROSE_ALLOC_MEMSET
   36109             : #  define ROSE_ALLOC_MEMSET 0
   36110             : #endif
   36111             : 
   36112             : #ifndef ROSE_PEDANTIC_ALLOC
   36113             : #  define ROSE_PEDANTIC_ALLOC 0
   36114             : #endif
   36115             : 
   36116             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   36117             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   36118             : #endif
   36119             : 
   36120             : #if !defined(SGNODE__ALL_POOLS)
   36121             : #define SGNODE__ALL_POOLS
   36122             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   36123             : #endif
   36124             : 
   36125             : SgOmpClause* SgOmpClause::next_node = nullptr;
   36126             : std::vector<unsigned char*> SgOmpClause::pools;
   36127             : 
   36128             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   36129             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   36130             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   36131             : // around this macro definition rather than each use).
   36132             : #ifndef ALLOC_MUTEX
   36133             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   36134             :         do {                                                                     \
   36135             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   36136             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   36137             :                 abort();                                                         \
   36138             :             }                                                                    \
   36139             :         } while (0);
   36140             : #endif
   36141             : 
   36142             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   36143             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   36144             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   36145             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   36146             : 
   36147             : /*! \brief New operator for SgOmpClause.
   36148             : 
   36149             :    This new operator implements memory pools to provide most efficent 
   36150             :    use of the heap within construction of large ASTs.
   36151             : 
   36152             : \internal The new and delete operators use the lower level C malloc/free
   36153             :    function calls for performance and to make sure that mixing of malloc/free
   36154             :    and new/delete by the used can be caught more readily.  This may change
   36155             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   36156             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   36157             :    deallocate memory allocated using ROSE_MALLOC.
   36158             : */
   36159           0 : void *SgOmpClause::operator new ( size_t Size )
   36160             : {
   36161             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   36162             :      * returning or throwing an exception. */
   36163           0 :     ALLOC_MUTEX(SgOmpClause, lock);
   36164             : 
   36165             : #if ROSE_ALLOC_TRACE == 2
   36166             : //    printf("SgOmpClause::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgOmpClause::next_node);
   36167             : #endif
   36168             : 
   36169             : #if USE_CPP_NEW_DELETE_OPERATORS
   36170             :     void *mem = ROSE_MALLOC(Size);
   36171             :     ALLOC_MUTEX(SgOmpClause, unlock);
   36172             :     return mem;
   36173             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   36174             : #if ROSE_PEDANTIC_ALLOC
   36175             :     ROSE_ASSERT(Size == sizeof(SgOmpClause));
   36176             : #else
   36177           0 :     if (Size != sizeof(SgOmpClause)) {
   36178           0 :       void * object = ROSE_MALLOC(Size);
   36179           0 :       ALLOC_MUTEX(SgOmpClause, unlock);
   36180             :       return object;
   36181             :     }
   36182             : #endif
   36183             : 
   36184           0 :     if (SgOmpClause::next_node == nullptr) {
   36185           0 :         SgOmpClause * alloc = (SgOmpClause*) ROSE_MALLOC ( SgOmpClause::pool_size * sizeof(SgOmpClause) );
   36186           0 :         ROSE_ASSERT(alloc != nullptr);
   36187             : 
   36188             : #if ROSE_ALLOC_TRACE == 2
   36189             : //        printf("SgOmpClause::alloc\n  block[%zi] = [ %p , %p [\n", SgOmpClause::pools.size(), alloc, alloc + SgOmpClause::pool_size);
   36190             : #endif
   36191             : 
   36192             : #if ROSE_ALLOC_MEMSET == 1
   36193             : #elif ROSE_ALLOC_MEMSET == 2
   36194             :         memset(alloc, 0x00, SgOmpClause::pool_size * sizeof(SgOmpClause));
   36195             : #elif ROSE_ALLOC_MEMSET == 3
   36196             :         memset(alloc, 0xAA, SgOmpClause::pool_size * sizeof(SgOmpClause));
   36197             : #endif
   36198           0 :         for (unsigned i=0; i < SgOmpClause::pool_size-1; i++) {
   36199           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
   36200             :         }
   36201           0 :         alloc[SgOmpClause::pool_size-1].p_freepointer = nullptr;
   36202             : 
   36203           0 :         SgOmpClause::pools.push_back ( (unsigned char *) alloc );
   36204           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgOmpClause::pool_size * sizeof(SgOmpClause), V_SgOmpClause ) );
   36205           0 :         SgOmpClause::next_node = alloc;
   36206             :     }
   36207           0 :     ROSE_ASSERT(SgOmpClause::next_node != nullptr);
   36208             : 
   36209           0 :     SgOmpClause * object = SgOmpClause::next_node;
   36210           0 :     SgOmpClause::next_node = (SgOmpClause*)(object->p_freepointer);
   36211             : 
   36212             : #if ROSE_ALLOC_TRACE == 2
   36213             :     printf("SgOmpClause::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpClause::next_node);
   36214             : #endif
   36215             : 
   36216           0 :     SgNode * fp = object->p_freepointer;
   36217             : #if ROSE_ALLOC_MEMSET == 1
   36218             : #elif ROSE_ALLOC_MEMSET == 2
   36219             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   36220             : #elif ROSE_ALLOC_MEMSET == 3
   36221             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgOmpClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   36222             : #endif
   36223           0 :     object->p_freepointer = fp;
   36224             : 
   36225             : #if ROSE_ALLOC_TRACE == 2
   36226             : //    printf("SgOmpClause::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpClause::next_node);
   36227             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   36228             :     Rose::MemPool::snapshot(oss.str());
   36229             :     alloc_trace_cnt++;
   36230             : #endif
   36231             : 
   36232           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   36233             : 
   36234           0 :     ALLOC_MUTEX(SgOmpClause, unlock);
   36235             : 
   36236             :     return object;
   36237             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   36238             : }
   36239             : 
   36240             : 
   36241             : 
   36242             : /*! \brief Delete operator for SgOmpClause.
   36243             : 
   36244             :    This delete operator implements deallocation using memory pools to 
   36245             :    provide most efficent use of the heap within construction of large ASTs.
   36246             : 
   36247             : \internal The new and delete operators use the lower level C malloc/free
   36248             :    function calls for performance and to make sure that mixing of malloc/free
   36249             :    and new/delete by the used can be caught more readily.  This may change
   36250             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   36251             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   36252             :    deallocate memory allocated using ROSE_MALLOC.
   36253             : */
   36254           0 : void SgOmpClause::operator delete(void *Pointer, size_t Size)
   36255             : {
   36256             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   36257             :      * or throwing an exception. */
   36258           0 :     ALLOC_MUTEX(SgOmpClause, lock);
   36259             : 
   36260             : #if USE_CPP_NEW_DELETE_OPERATORS
   36261             :     ROSE_FREE(Pointer);
   36262             : #else
   36263             : #if ROSE_PEDANTIC_ALLOC
   36264             :     ROSE_ASSERT(Size == sizeof(SgOmpClause));
   36265             : #else
   36266           0 :     if (Size != sizeof(SgOmpClause)) {
   36267           0 :       ROSE_FREE(Pointer);
   36268           0 :       ALLOC_MUTEX(SgOmpClause, unlock);
   36269             :       return;
   36270             :     }
   36271             : #endif
   36272             : 
   36273           0 :     SgOmpClause * object = (SgOmpClause*) Pointer;
   36274           0 :     ROSE_ASSERT(object != nullptr);
   36275             : 
   36276             : #if ROSE_ALLOC_TRACE == 2
   36277             : //  printf("SgOmpClause::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpClause::next_node);
   36278             :     printf("SgOmpClause::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpClause::next_node);
   36279             : #endif
   36280             : 
   36281             : #if ROSE_PEDANTIC_ALLOC
   36282             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   36283             : #endif
   36284             : 
   36285             : #if ROSE_ALLOC_MEMSET == 1
   36286             : #elif ROSE_ALLOC_MEMSET == 2
   36287             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   36288             : #elif ROSE_ALLOC_MEMSET == 3
   36289             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgOmpClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   36290             : #endif
   36291             : 
   36292             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   36293             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   36294             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   36295             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   36296             : #else
   36297           0 :     object->p_freepointer = SgOmpClause::next_node;
   36298           0 :     SgOmpClause::next_node = object;
   36299             : #endif
   36300             : 
   36301             : #if ROSE_ALLOC_TRACE == 2
   36302             : //  printf("SgOmpClause::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpClause::next_node);
   36303             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   36304             :     Rose::MemPool::snapshot(oss.str());
   36305             :     alloc_trace_cnt++;
   36306             : #endif
   36307             : 
   36308             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   36309             : 
   36310           0 :     ALLOC_MUTEX(SgOmpClause, unlock);
   36311             : }
   36312             : 
   36313             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   36314             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   36315             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   36316             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   36317             : // Also, note comment below from Robb (copied from the Common.code file).
   36318             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   36319             : //
   36320             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   36321             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   36322             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   36323             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   36324             : #if 0
   36325             : void SgOmpClause::operator delete(void* pointer) { SgOmpClause::operator delete (pointer, sizeof(SgOmpClause)); };
   36326             : #endif
   36327             : /* #line 36328 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   36328             : 
   36329             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   36330             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   36331             : // obviously imply C++.
   36332             : 
   36333             : // This implements the support within ROSE for memory pools.  Memory pools
   36334             : // support the most condensed usage of memory within the construction of
   36335             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   36336             : // by a new operator written for each class.
   36337             : 
   36338             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   36339             :     // User wants multi-thread support and POSIX threads are available.
   36340             : #   include <pthread.h>
   36341             :     static pthread_mutex_t SgOmpNowaitClause_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   36342             : #else
   36343             :      // Cause synchronization to be skipped.
   36344             : #    ifndef ALLOC_MUTEX
   36345             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   36346             : #    endif
   36347             : #    ifdef _REENTRANT
   36348             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   36349             : #       ifdef _MSC_VER
   36350             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   36351             : #       else
   36352             : #           warning "POSIX threads are not available; synchronization being skipped"
   36353             : #       endif
   36354             : #    endif
   36355             : #endif
   36356             : 
   36357             : #ifndef ROSE_ALLOC_TRACE
   36358             : #  define ROSE_ALLOC_TRACE 0
   36359             : #endif
   36360             : 
   36361             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   36362             : #define ROSE_ALLOC_TRACE_CNT
   36363             : #include "memory-pool-snapshot.h"
   36364             : unsigned long alloc_trace_cnt = 0;
   36365             : #endif
   36366             : 
   36367             : #if ROSE_ALLOC_TRACE
   36368             : const unsigned SgOmpNowaitClause::pool_size = 5;
   36369             : #else
   36370             : const unsigned SgOmpNowaitClause::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   36371             : #endif
   36372             : 
   36373             : #ifndef ROSE_ALLOC_MEMSET
   36374             : #  define ROSE_ALLOC_MEMSET 0
   36375             : #endif
   36376             : 
   36377             : #ifndef ROSE_PEDANTIC_ALLOC
   36378             : #  define ROSE_PEDANTIC_ALLOC 0
   36379             : #endif
   36380             : 
   36381             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   36382             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   36383             : #endif
   36384             : 
   36385             : #if !defined(SGNODE__ALL_POOLS)
   36386             : #define SGNODE__ALL_POOLS
   36387             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   36388             : #endif
   36389             : 
   36390             : SgOmpNowaitClause* SgOmpNowaitClause::next_node = nullptr;
   36391             : std::vector<unsigned char*> SgOmpNowaitClause::pools;
   36392             : 
   36393             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   36394             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   36395             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   36396             : // around this macro definition rather than each use).
   36397             : #ifndef ALLOC_MUTEX
   36398             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   36399             :         do {                                                                     \
   36400             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   36401             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   36402             :                 abort();                                                         \
   36403             :             }                                                                    \
   36404             :         } while (0);
   36405             : #endif
   36406             : 
   36407             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   36408             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   36409             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   36410             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   36411             : 
   36412             : /*! \brief New operator for SgOmpNowaitClause.
   36413             : 
   36414             :    This new operator implements memory pools to provide most efficent 
   36415             :    use of the heap within construction of large ASTs.
   36416             : 
   36417             : \internal The new and delete operators use the lower level C malloc/free
   36418             :    function calls for performance and to make sure that mixing of malloc/free
   36419             :    and new/delete by the used can be caught more readily.  This may change
   36420             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   36421             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   36422             :    deallocate memory allocated using ROSE_MALLOC.
   36423             : */
   36424          25 : void *SgOmpNowaitClause::operator new ( size_t Size )
   36425             : {
   36426             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   36427             :      * returning or throwing an exception. */
   36428          25 :     ALLOC_MUTEX(SgOmpNowaitClause, lock);
   36429             : 
   36430             : #if ROSE_ALLOC_TRACE == 2
   36431             : //    printf("SgOmpNowaitClause::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgOmpNowaitClause::next_node);
   36432             : #endif
   36433             : 
   36434             : #if USE_CPP_NEW_DELETE_OPERATORS
   36435             :     void *mem = ROSE_MALLOC(Size);
   36436             :     ALLOC_MUTEX(SgOmpNowaitClause, unlock);
   36437             :     return mem;
   36438             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   36439             : #if ROSE_PEDANTIC_ALLOC
   36440             :     ROSE_ASSERT(Size == sizeof(SgOmpNowaitClause));
   36441             : #else
   36442          25 :     if (Size != sizeof(SgOmpNowaitClause)) {
   36443           0 :       void * object = ROSE_MALLOC(Size);
   36444           0 :       ALLOC_MUTEX(SgOmpNowaitClause, unlock);
   36445             :       return object;
   36446             :     }
   36447             : #endif
   36448             : 
   36449          25 :     if (SgOmpNowaitClause::next_node == nullptr) {
   36450          23 :         SgOmpNowaitClause * alloc = (SgOmpNowaitClause*) ROSE_MALLOC ( SgOmpNowaitClause::pool_size * sizeof(SgOmpNowaitClause) );
   36451          23 :         ROSE_ASSERT(alloc != nullptr);
   36452             : 
   36453             : #if ROSE_ALLOC_TRACE == 2
   36454             : //        printf("SgOmpNowaitClause::alloc\n  block[%zi] = [ %p , %p [\n", SgOmpNowaitClause::pools.size(), alloc, alloc + SgOmpNowaitClause::pool_size);
   36455             : #endif
   36456             : 
   36457             : #if ROSE_ALLOC_MEMSET == 1
   36458             : #elif ROSE_ALLOC_MEMSET == 2
   36459             :         memset(alloc, 0x00, SgOmpNowaitClause::pool_size * sizeof(SgOmpNowaitClause));
   36460             : #elif ROSE_ALLOC_MEMSET == 3
   36461             :         memset(alloc, 0xAA, SgOmpNowaitClause::pool_size * sizeof(SgOmpNowaitClause));
   36462             : #endif
   36463       46000 :         for (unsigned i=0; i < SgOmpNowaitClause::pool_size-1; i++) {
   36464       45977 :           alloc[i].p_freepointer = &(alloc[i+1]);
   36465             :         }
   36466          23 :         alloc[SgOmpNowaitClause::pool_size-1].p_freepointer = nullptr;
   36467             : 
   36468          23 :         SgOmpNowaitClause::pools.push_back ( (unsigned char *) alloc );
   36469          23 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgOmpNowaitClause::pool_size * sizeof(SgOmpNowaitClause), V_SgOmpNowaitClause ) );
   36470          23 :         SgOmpNowaitClause::next_node = alloc;
   36471             :     }
   36472          25 :     ROSE_ASSERT(SgOmpNowaitClause::next_node != nullptr);
   36473             : 
   36474          25 :     SgOmpNowaitClause * object = SgOmpNowaitClause::next_node;
   36475          25 :     SgOmpNowaitClause::next_node = (SgOmpNowaitClause*)(object->p_freepointer);
   36476             : 
   36477             : #if ROSE_ALLOC_TRACE == 2
   36478             :     printf("SgOmpNowaitClause::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpNowaitClause::next_node);
   36479             : #endif
   36480             : 
   36481          25 :     SgNode * fp = object->p_freepointer;
   36482             : #if ROSE_ALLOC_MEMSET == 1
   36483             : #elif ROSE_ALLOC_MEMSET == 2
   36484             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpNowaitClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   36485             : #elif ROSE_ALLOC_MEMSET == 3
   36486             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgOmpNowaitClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   36487             : #endif
   36488          25 :     object->p_freepointer = fp;
   36489             : 
   36490             : #if ROSE_ALLOC_TRACE == 2
   36491             : //    printf("SgOmpNowaitClause::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpNowaitClause::next_node);
   36492             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   36493             :     Rose::MemPool::snapshot(oss.str());
   36494             :     alloc_trace_cnt++;
   36495             : #endif
   36496             : 
   36497          25 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   36498             : 
   36499          25 :     ALLOC_MUTEX(SgOmpNowaitClause, unlock);
   36500             : 
   36501             :     return object;
   36502             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   36503             : }
   36504             : 
   36505             : 
   36506             : 
   36507             : /*! \brief Delete operator for SgOmpNowaitClause.
   36508             : 
   36509             :    This delete operator implements deallocation using memory pools to 
   36510             :    provide most efficent use of the heap within construction of large ASTs.
   36511             : 
   36512             : \internal The new and delete operators use the lower level C malloc/free
   36513             :    function calls for performance and to make sure that mixing of malloc/free
   36514             :    and new/delete by the used can be caught more readily.  This may change
   36515             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   36516             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   36517             :    deallocate memory allocated using ROSE_MALLOC.
   36518             : */
   36519           0 : void SgOmpNowaitClause::operator delete(void *Pointer, size_t Size)
   36520             : {
   36521             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   36522             :      * or throwing an exception. */
   36523           0 :     ALLOC_MUTEX(SgOmpNowaitClause, lock);
   36524             : 
   36525             : #if USE_CPP_NEW_DELETE_OPERATORS
   36526             :     ROSE_FREE(Pointer);
   36527             : #else
   36528             : #if ROSE_PEDANTIC_ALLOC
   36529             :     ROSE_ASSERT(Size == sizeof(SgOmpNowaitClause));
   36530             : #else
   36531           0 :     if (Size != sizeof(SgOmpNowaitClause)) {
   36532           0 :       ROSE_FREE(Pointer);
   36533           0 :       ALLOC_MUTEX(SgOmpNowaitClause, unlock);
   36534             :       return;
   36535             :     }
   36536             : #endif
   36537             : 
   36538           0 :     SgOmpNowaitClause * object = (SgOmpNowaitClause*) Pointer;
   36539           0 :     ROSE_ASSERT(object != nullptr);
   36540             : 
   36541             : #if ROSE_ALLOC_TRACE == 2
   36542             : //  printf("SgOmpNowaitClause::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpNowaitClause::next_node);
   36543             :     printf("SgOmpNowaitClause::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpNowaitClause::next_node);
   36544             : #endif
   36545             : 
   36546             : #if ROSE_PEDANTIC_ALLOC
   36547             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   36548             : #endif
   36549             : 
   36550             : #if ROSE_ALLOC_MEMSET == 1
   36551             : #elif ROSE_ALLOC_MEMSET == 2
   36552             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpNowaitClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   36553             : #elif ROSE_ALLOC_MEMSET == 3
   36554             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgOmpNowaitClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   36555             : #endif
   36556             : 
   36557             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   36558             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   36559             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   36560             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   36561             : #else
   36562           0 :     object->p_freepointer = SgOmpNowaitClause::next_node;
   36563           0 :     SgOmpNowaitClause::next_node = object;
   36564             : #endif
   36565             : 
   36566             : #if ROSE_ALLOC_TRACE == 2
   36567             : //  printf("SgOmpNowaitClause::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpNowaitClause::next_node);
   36568             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   36569             :     Rose::MemPool::snapshot(oss.str());
   36570             :     alloc_trace_cnt++;
   36571             : #endif
   36572             : 
   36573             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   36574             : 
   36575           0 :     ALLOC_MUTEX(SgOmpNowaitClause, unlock);
   36576             : }
   36577             : 
   36578             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   36579             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   36580             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   36581             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   36582             : // Also, note comment below from Robb (copied from the Common.code file).
   36583             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   36584             : //
   36585             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   36586             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   36587             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   36588             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   36589             : #if 0
   36590             : void SgOmpNowaitClause::operator delete(void* pointer) { SgOmpNowaitClause::operator delete (pointer, sizeof(SgOmpNowaitClause)); };
   36591             : #endif
   36592             : /* #line 36593 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   36593             : 
   36594             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   36595             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   36596             : // obviously imply C++.
   36597             : 
   36598             : // This implements the support within ROSE for memory pools.  Memory pools
   36599             : // support the most condensed usage of memory within the construction of
   36600             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   36601             : // by a new operator written for each class.
   36602             : 
   36603             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   36604             :     // User wants multi-thread support and POSIX threads are available.
   36605             : #   include <pthread.h>
   36606             :     static pthread_mutex_t SgOmpReadClause_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   36607             : #else
   36608             :      // Cause synchronization to be skipped.
   36609             : #    ifndef ALLOC_MUTEX
   36610             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   36611             : #    endif
   36612             : #    ifdef _REENTRANT
   36613             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   36614             : #       ifdef _MSC_VER
   36615             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   36616             : #       else
   36617             : #           warning "POSIX threads are not available; synchronization being skipped"
   36618             : #       endif
   36619             : #    endif
   36620             : #endif
   36621             : 
   36622             : #ifndef ROSE_ALLOC_TRACE
   36623             : #  define ROSE_ALLOC_TRACE 0
   36624             : #endif
   36625             : 
   36626             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   36627             : #define ROSE_ALLOC_TRACE_CNT
   36628             : #include "memory-pool-snapshot.h"
   36629             : unsigned long alloc_trace_cnt = 0;
   36630             : #endif
   36631             : 
   36632             : #if ROSE_ALLOC_TRACE
   36633             : const unsigned SgOmpReadClause::pool_size = 5;
   36634             : #else
   36635             : const unsigned SgOmpReadClause::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   36636             : #endif
   36637             : 
   36638             : #ifndef ROSE_ALLOC_MEMSET
   36639             : #  define ROSE_ALLOC_MEMSET 0
   36640             : #endif
   36641             : 
   36642             : #ifndef ROSE_PEDANTIC_ALLOC
   36643             : #  define ROSE_PEDANTIC_ALLOC 0
   36644             : #endif
   36645             : 
   36646             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   36647             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   36648             : #endif
   36649             : 
   36650             : #if !defined(SGNODE__ALL_POOLS)
   36651             : #define SGNODE__ALL_POOLS
   36652             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   36653             : #endif
   36654             : 
   36655             : SgOmpReadClause* SgOmpReadClause::next_node = nullptr;
   36656             : std::vector<unsigned char*> SgOmpReadClause::pools;
   36657             : 
   36658             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   36659             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   36660             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   36661             : // around this macro definition rather than each use).
   36662             : #ifndef ALLOC_MUTEX
   36663             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   36664             :         do {                                                                     \
   36665             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   36666             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   36667             :                 abort();                                                         \
   36668             :             }                                                                    \
   36669             :         } while (0);
   36670             : #endif
   36671             : 
   36672             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   36673             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   36674             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   36675             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   36676             : 
   36677             : /*! \brief New operator for SgOmpReadClause.
   36678             : 
   36679             :    This new operator implements memory pools to provide most efficent 
   36680             :    use of the heap within construction of large ASTs.
   36681             : 
   36682             : \internal The new and delete operators use the lower level C malloc/free
   36683             :    function calls for performance and to make sure that mixing of malloc/free
   36684             :    and new/delete by the used can be caught more readily.  This may change
   36685             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   36686             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   36687             :    deallocate memory allocated using ROSE_MALLOC.
   36688             : */
   36689           2 : void *SgOmpReadClause::operator new ( size_t Size )
   36690             : {
   36691             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   36692             :      * returning or throwing an exception. */
   36693           2 :     ALLOC_MUTEX(SgOmpReadClause, lock);
   36694             : 
   36695             : #if ROSE_ALLOC_TRACE == 2
   36696             : //    printf("SgOmpReadClause::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgOmpReadClause::next_node);
   36697             : #endif
   36698             : 
   36699             : #if USE_CPP_NEW_DELETE_OPERATORS
   36700             :     void *mem = ROSE_MALLOC(Size);
   36701             :     ALLOC_MUTEX(SgOmpReadClause, unlock);
   36702             :     return mem;
   36703             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   36704             : #if ROSE_PEDANTIC_ALLOC
   36705             :     ROSE_ASSERT(Size == sizeof(SgOmpReadClause));
   36706             : #else
   36707           2 :     if (Size != sizeof(SgOmpReadClause)) {
   36708           0 :       void * object = ROSE_MALLOC(Size);
   36709           0 :       ALLOC_MUTEX(SgOmpReadClause, unlock);
   36710             :       return object;
   36711             :     }
   36712             : #endif
   36713             : 
   36714           2 :     if (SgOmpReadClause::next_node == nullptr) {
   36715           2 :         SgOmpReadClause * alloc = (SgOmpReadClause*) ROSE_MALLOC ( SgOmpReadClause::pool_size * sizeof(SgOmpReadClause) );
   36716           2 :         ROSE_ASSERT(alloc != nullptr);
   36717             : 
   36718             : #if ROSE_ALLOC_TRACE == 2
   36719             : //        printf("SgOmpReadClause::alloc\n  block[%zi] = [ %p , %p [\n", SgOmpReadClause::pools.size(), alloc, alloc + SgOmpReadClause::pool_size);
   36720             : #endif
   36721             : 
   36722             : #if ROSE_ALLOC_MEMSET == 1
   36723             : #elif ROSE_ALLOC_MEMSET == 2
   36724             :         memset(alloc, 0x00, SgOmpReadClause::pool_size * sizeof(SgOmpReadClause));
   36725             : #elif ROSE_ALLOC_MEMSET == 3
   36726             :         memset(alloc, 0xAA, SgOmpReadClause::pool_size * sizeof(SgOmpReadClause));
   36727             : #endif
   36728        4000 :         for (unsigned i=0; i < SgOmpReadClause::pool_size-1; i++) {
   36729        3998 :           alloc[i].p_freepointer = &(alloc[i+1]);
   36730             :         }
   36731           2 :         alloc[SgOmpReadClause::pool_size-1].p_freepointer = nullptr;
   36732             : 
   36733           2 :         SgOmpReadClause::pools.push_back ( (unsigned char *) alloc );
   36734           2 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgOmpReadClause::pool_size * sizeof(SgOmpReadClause), V_SgOmpReadClause ) );
   36735           2 :         SgOmpReadClause::next_node = alloc;
   36736             :     }
   36737           2 :     ROSE_ASSERT(SgOmpReadClause::next_node != nullptr);
   36738             : 
   36739           2 :     SgOmpReadClause * object = SgOmpReadClause::next_node;
   36740           2 :     SgOmpReadClause::next_node = (SgOmpReadClause*)(object->p_freepointer);
   36741             : 
   36742             : #if ROSE_ALLOC_TRACE == 2
   36743             :     printf("SgOmpReadClause::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpReadClause::next_node);
   36744             : #endif
   36745             : 
   36746           2 :     SgNode * fp = object->p_freepointer;
   36747             : #if ROSE_ALLOC_MEMSET == 1
   36748             : #elif ROSE_ALLOC_MEMSET == 2
   36749             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpReadClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   36750             : #elif ROSE_ALLOC_MEMSET == 3
   36751             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgOmpReadClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   36752             : #endif
   36753           2 :     object->p_freepointer = fp;
   36754             : 
   36755             : #if ROSE_ALLOC_TRACE == 2
   36756             : //    printf("SgOmpReadClause::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpReadClause::next_node);
   36757             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   36758             :     Rose::MemPool::snapshot(oss.str());
   36759             :     alloc_trace_cnt++;
   36760             : #endif
   36761             : 
   36762           2 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   36763             : 
   36764           2 :     ALLOC_MUTEX(SgOmpReadClause, unlock);
   36765             : 
   36766             :     return object;
   36767             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   36768             : }
   36769             : 
   36770             : 
   36771             : 
   36772             : /*! \brief Delete operator for SgOmpReadClause.
   36773             : 
   36774             :    This delete operator implements deallocation using memory pools to 
   36775             :    provide most efficent use of the heap within construction of large ASTs.
   36776             : 
   36777             : \internal The new and delete operators use the lower level C malloc/free
   36778             :    function calls for performance and to make sure that mixing of malloc/free
   36779             :    and new/delete by the used can be caught more readily.  This may change
   36780             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   36781             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   36782             :    deallocate memory allocated using ROSE_MALLOC.
   36783             : */
   36784           0 : void SgOmpReadClause::operator delete(void *Pointer, size_t Size)
   36785             : {
   36786             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   36787             :      * or throwing an exception. */
   36788           0 :     ALLOC_MUTEX(SgOmpReadClause, lock);
   36789             : 
   36790             : #if USE_CPP_NEW_DELETE_OPERATORS
   36791             :     ROSE_FREE(Pointer);
   36792             : #else
   36793             : #if ROSE_PEDANTIC_ALLOC
   36794             :     ROSE_ASSERT(Size == sizeof(SgOmpReadClause));
   36795             : #else
   36796           0 :     if (Size != sizeof(SgOmpReadClause)) {
   36797           0 :       ROSE_FREE(Pointer);
   36798           0 :       ALLOC_MUTEX(SgOmpReadClause, unlock);
   36799             :       return;
   36800             :     }
   36801             : #endif
   36802             : 
   36803           0 :     SgOmpReadClause * object = (SgOmpReadClause*) Pointer;
   36804           0 :     ROSE_ASSERT(object != nullptr);
   36805             : 
   36806             : #if ROSE_ALLOC_TRACE == 2
   36807             : //  printf("SgOmpReadClause::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpReadClause::next_node);
   36808             :     printf("SgOmpReadClause::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpReadClause::next_node);
   36809             : #endif
   36810             : 
   36811             : #if ROSE_PEDANTIC_ALLOC
   36812             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   36813             : #endif
   36814             : 
   36815             : #if ROSE_ALLOC_MEMSET == 1
   36816             : #elif ROSE_ALLOC_MEMSET == 2
   36817             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpReadClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   36818             : #elif ROSE_ALLOC_MEMSET == 3
   36819             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgOmpReadClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   36820             : #endif
   36821             : 
   36822             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   36823             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   36824             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   36825             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   36826             : #else
   36827           0 :     object->p_freepointer = SgOmpReadClause::next_node;
   36828           0 :     SgOmpReadClause::next_node = object;
   36829             : #endif
   36830             : 
   36831             : #if ROSE_ALLOC_TRACE == 2
   36832             : //  printf("SgOmpReadClause::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpReadClause::next_node);
   36833             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   36834             :     Rose::MemPool::snapshot(oss.str());
   36835             :     alloc_trace_cnt++;
   36836             : #endif
   36837             : 
   36838             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   36839             : 
   36840           0 :     ALLOC_MUTEX(SgOmpReadClause, unlock);
   36841             : }
   36842             : 
   36843             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   36844             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   36845             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   36846             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   36847             : // Also, note comment below from Robb (copied from the Common.code file).
   36848             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   36849             : //
   36850             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   36851             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   36852             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   36853             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   36854             : #if 0
   36855             : void SgOmpReadClause::operator delete(void* pointer) { SgOmpReadClause::operator delete (pointer, sizeof(SgOmpReadClause)); };
   36856             : #endif
   36857             : /* #line 36858 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   36858             : 
   36859             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   36860             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   36861             : // obviously imply C++.
   36862             : 
   36863             : // This implements the support within ROSE for memory pools.  Memory pools
   36864             : // support the most condensed usage of memory within the construction of
   36865             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   36866             : // by a new operator written for each class.
   36867             : 
   36868             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   36869             :     // User wants multi-thread support and POSIX threads are available.
   36870             : #   include <pthread.h>
   36871             :     static pthread_mutex_t SgOmpThreadsClause_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   36872             : #else
   36873             :      // Cause synchronization to be skipped.
   36874             : #    ifndef ALLOC_MUTEX
   36875             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   36876             : #    endif
   36877             : #    ifdef _REENTRANT
   36878             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   36879             : #       ifdef _MSC_VER
   36880             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   36881             : #       else
   36882             : #           warning "POSIX threads are not available; synchronization being skipped"
   36883             : #       endif
   36884             : #    endif
   36885             : #endif
   36886             : 
   36887             : #ifndef ROSE_ALLOC_TRACE
   36888             : #  define ROSE_ALLOC_TRACE 0
   36889             : #endif
   36890             : 
   36891             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   36892             : #define ROSE_ALLOC_TRACE_CNT
   36893             : #include "memory-pool-snapshot.h"
   36894             : unsigned long alloc_trace_cnt = 0;
   36895             : #endif
   36896             : 
   36897             : #if ROSE_ALLOC_TRACE
   36898             : const unsigned SgOmpThreadsClause::pool_size = 5;
   36899             : #else
   36900             : const unsigned SgOmpThreadsClause::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   36901             : #endif
   36902             : 
   36903             : #ifndef ROSE_ALLOC_MEMSET
   36904             : #  define ROSE_ALLOC_MEMSET 0
   36905             : #endif
   36906             : 
   36907             : #ifndef ROSE_PEDANTIC_ALLOC
   36908             : #  define ROSE_PEDANTIC_ALLOC 0
   36909             : #endif
   36910             : 
   36911             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   36912             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   36913             : #endif
   36914             : 
   36915             : #if !defined(SGNODE__ALL_POOLS)
   36916             : #define SGNODE__ALL_POOLS
   36917             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   36918             : #endif
   36919             : 
   36920             : SgOmpThreadsClause* SgOmpThreadsClause::next_node = nullptr;
   36921             : std::vector<unsigned char*> SgOmpThreadsClause::pools;
   36922             : 
   36923             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   36924             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   36925             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   36926             : // around this macro definition rather than each use).
   36927             : #ifndef ALLOC_MUTEX
   36928             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   36929             :         do {                                                                     \
   36930             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   36931             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   36932             :                 abort();                                                         \
   36933             :             }                                                                    \
   36934             :         } while (0);
   36935             : #endif
   36936             : 
   36937             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   36938             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   36939             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   36940             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   36941             : 
   36942             : /*! \brief New operator for SgOmpThreadsClause.
   36943             : 
   36944             :    This new operator implements memory pools to provide most efficent 
   36945             :    use of the heap within construction of large ASTs.
   36946             : 
   36947             : \internal The new and delete operators use the lower level C malloc/free
   36948             :    function calls for performance and to make sure that mixing of malloc/free
   36949             :    and new/delete by the used can be caught more readily.  This may change
   36950             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   36951             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   36952             :    deallocate memory allocated using ROSE_MALLOC.
   36953             : */
   36954           0 : void *SgOmpThreadsClause::operator new ( size_t Size )
   36955             : {
   36956             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   36957             :      * returning or throwing an exception. */
   36958           0 :     ALLOC_MUTEX(SgOmpThreadsClause, lock);
   36959             : 
   36960             : #if ROSE_ALLOC_TRACE == 2
   36961             : //    printf("SgOmpThreadsClause::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgOmpThreadsClause::next_node);
   36962             : #endif
   36963             : 
   36964             : #if USE_CPP_NEW_DELETE_OPERATORS
   36965             :     void *mem = ROSE_MALLOC(Size);
   36966             :     ALLOC_MUTEX(SgOmpThreadsClause, unlock);
   36967             :     return mem;
   36968             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   36969             : #if ROSE_PEDANTIC_ALLOC
   36970             :     ROSE_ASSERT(Size == sizeof(SgOmpThreadsClause));
   36971             : #else
   36972           0 :     if (Size != sizeof(SgOmpThreadsClause)) {
   36973           0 :       void * object = ROSE_MALLOC(Size);
   36974           0 :       ALLOC_MUTEX(SgOmpThreadsClause, unlock);
   36975             :       return object;
   36976             :     }
   36977             : #endif
   36978             : 
   36979           0 :     if (SgOmpThreadsClause::next_node == nullptr) {
   36980           0 :         SgOmpThreadsClause * alloc = (SgOmpThreadsClause*) ROSE_MALLOC ( SgOmpThreadsClause::pool_size * sizeof(SgOmpThreadsClause) );
   36981           0 :         ROSE_ASSERT(alloc != nullptr);
   36982             : 
   36983             : #if ROSE_ALLOC_TRACE == 2
   36984             : //        printf("SgOmpThreadsClause::alloc\n  block[%zi] = [ %p , %p [\n", SgOmpThreadsClause::pools.size(), alloc, alloc + SgOmpThreadsClause::pool_size);
   36985             : #endif
   36986             : 
   36987             : #if ROSE_ALLOC_MEMSET == 1
   36988             : #elif ROSE_ALLOC_MEMSET == 2
   36989             :         memset(alloc, 0x00, SgOmpThreadsClause::pool_size * sizeof(SgOmpThreadsClause));
   36990             : #elif ROSE_ALLOC_MEMSET == 3
   36991             :         memset(alloc, 0xAA, SgOmpThreadsClause::pool_size * sizeof(SgOmpThreadsClause));
   36992             : #endif
   36993           0 :         for (unsigned i=0; i < SgOmpThreadsClause::pool_size-1; i++) {
   36994           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
   36995             :         }
   36996           0 :         alloc[SgOmpThreadsClause::pool_size-1].p_freepointer = nullptr;
   36997             : 
   36998           0 :         SgOmpThreadsClause::pools.push_back ( (unsigned char *) alloc );
   36999           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgOmpThreadsClause::pool_size * sizeof(SgOmpThreadsClause), V_SgOmpThreadsClause ) );
   37000           0 :         SgOmpThreadsClause::next_node = alloc;
   37001             :     }
   37002           0 :     ROSE_ASSERT(SgOmpThreadsClause::next_node != nullptr);
   37003             : 
   37004           0 :     SgOmpThreadsClause * object = SgOmpThreadsClause::next_node;
   37005           0 :     SgOmpThreadsClause::next_node = (SgOmpThreadsClause*)(object->p_freepointer);
   37006             : 
   37007             : #if ROSE_ALLOC_TRACE == 2
   37008             :     printf("SgOmpThreadsClause::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpThreadsClause::next_node);
   37009             : #endif
   37010             : 
   37011           0 :     SgNode * fp = object->p_freepointer;
   37012             : #if ROSE_ALLOC_MEMSET == 1
   37013             : #elif ROSE_ALLOC_MEMSET == 2
   37014             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpThreadsClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   37015             : #elif ROSE_ALLOC_MEMSET == 3
   37016             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgOmpThreadsClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   37017             : #endif
   37018           0 :     object->p_freepointer = fp;
   37019             : 
   37020             : #if ROSE_ALLOC_TRACE == 2
   37021             : //    printf("SgOmpThreadsClause::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpThreadsClause::next_node);
   37022             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   37023             :     Rose::MemPool::snapshot(oss.str());
   37024             :     alloc_trace_cnt++;
   37025             : #endif
   37026             : 
   37027           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   37028             : 
   37029           0 :     ALLOC_MUTEX(SgOmpThreadsClause, unlock);
   37030             : 
   37031             :     return object;
   37032             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   37033             : }
   37034             : 
   37035             : 
   37036             : 
   37037             : /*! \brief Delete operator for SgOmpThreadsClause.
   37038             : 
   37039             :    This delete operator implements deallocation using memory pools to 
   37040             :    provide most efficent use of the heap within construction of large ASTs.
   37041             : 
   37042             : \internal The new and delete operators use the lower level C malloc/free
   37043             :    function calls for performance and to make sure that mixing of malloc/free
   37044             :    and new/delete by the used can be caught more readily.  This may change
   37045             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   37046             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   37047             :    deallocate memory allocated using ROSE_MALLOC.
   37048             : */
   37049           0 : void SgOmpThreadsClause::operator delete(void *Pointer, size_t Size)
   37050             : {
   37051             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   37052             :      * or throwing an exception. */
   37053           0 :     ALLOC_MUTEX(SgOmpThreadsClause, lock);
   37054             : 
   37055             : #if USE_CPP_NEW_DELETE_OPERATORS
   37056             :     ROSE_FREE(Pointer);
   37057             : #else
   37058             : #if ROSE_PEDANTIC_ALLOC
   37059             :     ROSE_ASSERT(Size == sizeof(SgOmpThreadsClause));
   37060             : #else
   37061           0 :     if (Size != sizeof(SgOmpThreadsClause)) {
   37062           0 :       ROSE_FREE(Pointer);
   37063           0 :       ALLOC_MUTEX(SgOmpThreadsClause, unlock);
   37064             :       return;
   37065             :     }
   37066             : #endif
   37067             : 
   37068           0 :     SgOmpThreadsClause * object = (SgOmpThreadsClause*) Pointer;
   37069           0 :     ROSE_ASSERT(object != nullptr);
   37070             : 
   37071             : #if ROSE_ALLOC_TRACE == 2
   37072             : //  printf("SgOmpThreadsClause::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpThreadsClause::next_node);
   37073             :     printf("SgOmpThreadsClause::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpThreadsClause::next_node);
   37074             : #endif
   37075             : 
   37076             : #if ROSE_PEDANTIC_ALLOC
   37077             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   37078             : #endif
   37079             : 
   37080             : #if ROSE_ALLOC_MEMSET == 1
   37081             : #elif ROSE_ALLOC_MEMSET == 2
   37082             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpThreadsClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   37083             : #elif ROSE_ALLOC_MEMSET == 3
   37084             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgOmpThreadsClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   37085             : #endif
   37086             : 
   37087             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   37088             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   37089             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   37090             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   37091             : #else
   37092           0 :     object->p_freepointer = SgOmpThreadsClause::next_node;
   37093           0 :     SgOmpThreadsClause::next_node = object;
   37094             : #endif
   37095             : 
   37096             : #if ROSE_ALLOC_TRACE == 2
   37097             : //  printf("SgOmpThreadsClause::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpThreadsClause::next_node);
   37098             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   37099             :     Rose::MemPool::snapshot(oss.str());
   37100             :     alloc_trace_cnt++;
   37101             : #endif
   37102             : 
   37103             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   37104             : 
   37105           0 :     ALLOC_MUTEX(SgOmpThreadsClause, unlock);
   37106             : }
   37107             : 
   37108             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   37109             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   37110             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   37111             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   37112             : // Also, note comment below from Robb (copied from the Common.code file).
   37113             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   37114             : //
   37115             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   37116             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   37117             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   37118             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   37119             : #if 0
   37120             : void SgOmpThreadsClause::operator delete(void* pointer) { SgOmpThreadsClause::operator delete (pointer, sizeof(SgOmpThreadsClause)); };
   37121             : #endif
   37122             : /* #line 37123 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   37123             : 
   37124             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   37125             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   37126             : // obviously imply C++.
   37127             : 
   37128             : // This implements the support within ROSE for memory pools.  Memory pools
   37129             : // support the most condensed usage of memory within the construction of
   37130             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   37131             : // by a new operator written for each class.
   37132             : 
   37133             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   37134             :     // User wants multi-thread support and POSIX threads are available.
   37135             : #   include <pthread.h>
   37136             :     static pthread_mutex_t SgOmpSimdClause_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   37137             : #else
   37138             :      // Cause synchronization to be skipped.
   37139             : #    ifndef ALLOC_MUTEX
   37140             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   37141             : #    endif
   37142             : #    ifdef _REENTRANT
   37143             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   37144             : #       ifdef _MSC_VER
   37145             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   37146             : #       else
   37147             : #           warning "POSIX threads are not available; synchronization being skipped"
   37148             : #       endif
   37149             : #    endif
   37150             : #endif
   37151             : 
   37152             : #ifndef ROSE_ALLOC_TRACE
   37153             : #  define ROSE_ALLOC_TRACE 0
   37154             : #endif
   37155             : 
   37156             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   37157             : #define ROSE_ALLOC_TRACE_CNT
   37158             : #include "memory-pool-snapshot.h"
   37159             : unsigned long alloc_trace_cnt = 0;
   37160             : #endif
   37161             : 
   37162             : #if ROSE_ALLOC_TRACE
   37163             : const unsigned SgOmpSimdClause::pool_size = 5;
   37164             : #else
   37165             : const unsigned SgOmpSimdClause::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   37166             : #endif
   37167             : 
   37168             : #ifndef ROSE_ALLOC_MEMSET
   37169             : #  define ROSE_ALLOC_MEMSET 0
   37170             : #endif
   37171             : 
   37172             : #ifndef ROSE_PEDANTIC_ALLOC
   37173             : #  define ROSE_PEDANTIC_ALLOC 0
   37174             : #endif
   37175             : 
   37176             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   37177             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   37178             : #endif
   37179             : 
   37180             : #if !defined(SGNODE__ALL_POOLS)
   37181             : #define SGNODE__ALL_POOLS
   37182             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   37183             : #endif
   37184             : 
   37185             : SgOmpSimdClause* SgOmpSimdClause::next_node = nullptr;
   37186             : std::vector<unsigned char*> SgOmpSimdClause::pools;
   37187             : 
   37188             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   37189             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   37190             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   37191             : // around this macro definition rather than each use).
   37192             : #ifndef ALLOC_MUTEX
   37193             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   37194             :         do {                                                                     \
   37195             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   37196             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   37197             :                 abort();                                                         \
   37198             :             }                                                                    \
   37199             :         } while (0);
   37200             : #endif
   37201             : 
   37202             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   37203             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   37204             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   37205             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   37206             : 
   37207             : /*! \brief New operator for SgOmpSimdClause.
   37208             : 
   37209             :    This new operator implements memory pools to provide most efficent 
   37210             :    use of the heap within construction of large ASTs.
   37211             : 
   37212             : \internal The new and delete operators use the lower level C malloc/free
   37213             :    function calls for performance and to make sure that mixing of malloc/free
   37214             :    and new/delete by the used can be caught more readily.  This may change
   37215             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   37216             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   37217             :    deallocate memory allocated using ROSE_MALLOC.
   37218             : */
   37219           0 : void *SgOmpSimdClause::operator new ( size_t Size )
   37220             : {
   37221             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   37222             :      * returning or throwing an exception. */
   37223           0 :     ALLOC_MUTEX(SgOmpSimdClause, lock);
   37224             : 
   37225             : #if ROSE_ALLOC_TRACE == 2
   37226             : //    printf("SgOmpSimdClause::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgOmpSimdClause::next_node);
   37227             : #endif
   37228             : 
   37229             : #if USE_CPP_NEW_DELETE_OPERATORS
   37230             :     void *mem = ROSE_MALLOC(Size);
   37231             :     ALLOC_MUTEX(SgOmpSimdClause, unlock);
   37232             :     return mem;
   37233             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   37234             : #if ROSE_PEDANTIC_ALLOC
   37235             :     ROSE_ASSERT(Size == sizeof(SgOmpSimdClause));
   37236             : #else
   37237           0 :     if (Size != sizeof(SgOmpSimdClause)) {
   37238           0 :       void * object = ROSE_MALLOC(Size);
   37239           0 :       ALLOC_MUTEX(SgOmpSimdClause, unlock);
   37240             :       return object;
   37241             :     }
   37242             : #endif
   37243             : 
   37244           0 :     if (SgOmpSimdClause::next_node == nullptr) {
   37245           0 :         SgOmpSimdClause * alloc = (SgOmpSimdClause*) ROSE_MALLOC ( SgOmpSimdClause::pool_size * sizeof(SgOmpSimdClause) );
   37246           0 :         ROSE_ASSERT(alloc != nullptr);
   37247             : 
   37248             : #if ROSE_ALLOC_TRACE == 2
   37249             : //        printf("SgOmpSimdClause::alloc\n  block[%zi] = [ %p , %p [\n", SgOmpSimdClause::pools.size(), alloc, alloc + SgOmpSimdClause::pool_size);
   37250             : #endif
   37251             : 
   37252             : #if ROSE_ALLOC_MEMSET == 1
   37253             : #elif ROSE_ALLOC_MEMSET == 2
   37254             :         memset(alloc, 0x00, SgOmpSimdClause::pool_size * sizeof(SgOmpSimdClause));
   37255             : #elif ROSE_ALLOC_MEMSET == 3
   37256             :         memset(alloc, 0xAA, SgOmpSimdClause::pool_size * sizeof(SgOmpSimdClause));
   37257             : #endif
   37258           0 :         for (unsigned i=0; i < SgOmpSimdClause::pool_size-1; i++) {
   37259           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
   37260             :         }
   37261           0 :         alloc[SgOmpSimdClause::pool_size-1].p_freepointer = nullptr;
   37262             : 
   37263           0 :         SgOmpSimdClause::pools.push_back ( (unsigned char *) alloc );
   37264           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgOmpSimdClause::pool_size * sizeof(SgOmpSimdClause), V_SgOmpSimdClause ) );
   37265           0 :         SgOmpSimdClause::next_node = alloc;
   37266             :     }
   37267           0 :     ROSE_ASSERT(SgOmpSimdClause::next_node != nullptr);
   37268             : 
   37269           0 :     SgOmpSimdClause * object = SgOmpSimdClause::next_node;
   37270           0 :     SgOmpSimdClause::next_node = (SgOmpSimdClause*)(object->p_freepointer);
   37271             : 
   37272             : #if ROSE_ALLOC_TRACE == 2
   37273             :     printf("SgOmpSimdClause::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpSimdClause::next_node);
   37274             : #endif
   37275             : 
   37276           0 :     SgNode * fp = object->p_freepointer;
   37277             : #if ROSE_ALLOC_MEMSET == 1
   37278             : #elif ROSE_ALLOC_MEMSET == 2
   37279             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpSimdClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   37280             : #elif ROSE_ALLOC_MEMSET == 3
   37281             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgOmpSimdClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   37282             : #endif
   37283           0 :     object->p_freepointer = fp;
   37284             : 
   37285             : #if ROSE_ALLOC_TRACE == 2
   37286             : //    printf("SgOmpSimdClause::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpSimdClause::next_node);
   37287             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   37288             :     Rose::MemPool::snapshot(oss.str());
   37289             :     alloc_trace_cnt++;
   37290             : #endif
   37291             : 
   37292           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   37293             : 
   37294           0 :     ALLOC_MUTEX(SgOmpSimdClause, unlock);
   37295             : 
   37296             :     return object;
   37297             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   37298             : }
   37299             : 
   37300             : 
   37301             : 
   37302             : /*! \brief Delete operator for SgOmpSimdClause.
   37303             : 
   37304             :    This delete operator implements deallocation using memory pools to 
   37305             :    provide most efficent use of the heap within construction of large ASTs.
   37306             : 
   37307             : \internal The new and delete operators use the lower level C malloc/free
   37308             :    function calls for performance and to make sure that mixing of malloc/free
   37309             :    and new/delete by the used can be caught more readily.  This may change
   37310             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   37311             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   37312             :    deallocate memory allocated using ROSE_MALLOC.
   37313             : */
   37314           0 : void SgOmpSimdClause::operator delete(void *Pointer, size_t Size)
   37315             : {
   37316             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   37317             :      * or throwing an exception. */
   37318           0 :     ALLOC_MUTEX(SgOmpSimdClause, lock);
   37319             : 
   37320             : #if USE_CPP_NEW_DELETE_OPERATORS
   37321             :     ROSE_FREE(Pointer);
   37322             : #else
   37323             : #if ROSE_PEDANTIC_ALLOC
   37324             :     ROSE_ASSERT(Size == sizeof(SgOmpSimdClause));
   37325             : #else
   37326           0 :     if (Size != sizeof(SgOmpSimdClause)) {
   37327           0 :       ROSE_FREE(Pointer);
   37328           0 :       ALLOC_MUTEX(SgOmpSimdClause, unlock);
   37329             :       return;
   37330             :     }
   37331             : #endif
   37332             : 
   37333           0 :     SgOmpSimdClause * object = (SgOmpSimdClause*) Pointer;
   37334           0 :     ROSE_ASSERT(object != nullptr);
   37335             : 
   37336             : #if ROSE_ALLOC_TRACE == 2
   37337             : //  printf("SgOmpSimdClause::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpSimdClause::next_node);
   37338             :     printf("SgOmpSimdClause::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpSimdClause::next_node);
   37339             : #endif
   37340             : 
   37341             : #if ROSE_PEDANTIC_ALLOC
   37342             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   37343             : #endif
   37344             : 
   37345             : #if ROSE_ALLOC_MEMSET == 1
   37346             : #elif ROSE_ALLOC_MEMSET == 2
   37347             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpSimdClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   37348             : #elif ROSE_ALLOC_MEMSET == 3
   37349             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgOmpSimdClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   37350             : #endif
   37351             : 
   37352             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   37353             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   37354             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   37355             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   37356             : #else
   37357           0 :     object->p_freepointer = SgOmpSimdClause::next_node;
   37358           0 :     SgOmpSimdClause::next_node = object;
   37359             : #endif
   37360             : 
   37361             : #if ROSE_ALLOC_TRACE == 2
   37362             : //  printf("SgOmpSimdClause::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpSimdClause::next_node);
   37363             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   37364             :     Rose::MemPool::snapshot(oss.str());
   37365             :     alloc_trace_cnt++;
   37366             : #endif
   37367             : 
   37368             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   37369             : 
   37370           0 :     ALLOC_MUTEX(SgOmpSimdClause, unlock);
   37371             : }
   37372             : 
   37373             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   37374             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   37375             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   37376             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   37377             : // Also, note comment below from Robb (copied from the Common.code file).
   37378             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   37379             : //
   37380             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   37381             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   37382             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   37383             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   37384             : #if 0
   37385             : void SgOmpSimdClause::operator delete(void* pointer) { SgOmpSimdClause::operator delete (pointer, sizeof(SgOmpSimdClause)); };
   37386             : #endif
   37387             : /* #line 37388 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   37388             : 
   37389             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   37390             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   37391             : // obviously imply C++.
   37392             : 
   37393             : // This implements the support within ROSE for memory pools.  Memory pools
   37394             : // support the most condensed usage of memory within the construction of
   37395             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   37396             : // by a new operator written for each class.
   37397             : 
   37398             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   37399             :     // User wants multi-thread support and POSIX threads are available.
   37400             : #   include <pthread.h>
   37401             :     static pthread_mutex_t SgOmpWriteClause_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   37402             : #else
   37403             :      // Cause synchronization to be skipped.
   37404             : #    ifndef ALLOC_MUTEX
   37405             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   37406             : #    endif
   37407             : #    ifdef _REENTRANT
   37408             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   37409             : #       ifdef _MSC_VER
   37410             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   37411             : #       else
   37412             : #           warning "POSIX threads are not available; synchronization being skipped"
   37413             : #       endif
   37414             : #    endif
   37415             : #endif
   37416             : 
   37417             : #ifndef ROSE_ALLOC_TRACE
   37418             : #  define ROSE_ALLOC_TRACE 0
   37419             : #endif
   37420             : 
   37421             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   37422             : #define ROSE_ALLOC_TRACE_CNT
   37423             : #include "memory-pool-snapshot.h"
   37424             : unsigned long alloc_trace_cnt = 0;
   37425             : #endif
   37426             : 
   37427             : #if ROSE_ALLOC_TRACE
   37428             : const unsigned SgOmpWriteClause::pool_size = 5;
   37429             : #else
   37430             : const unsigned SgOmpWriteClause::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   37431             : #endif
   37432             : 
   37433             : #ifndef ROSE_ALLOC_MEMSET
   37434             : #  define ROSE_ALLOC_MEMSET 0
   37435             : #endif
   37436             : 
   37437             : #ifndef ROSE_PEDANTIC_ALLOC
   37438             : #  define ROSE_PEDANTIC_ALLOC 0
   37439             : #endif
   37440             : 
   37441             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   37442             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   37443             : #endif
   37444             : 
   37445             : #if !defined(SGNODE__ALL_POOLS)
   37446             : #define SGNODE__ALL_POOLS
   37447             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   37448             : #endif
   37449             : 
   37450             : SgOmpWriteClause* SgOmpWriteClause::next_node = nullptr;
   37451             : std::vector<unsigned char*> SgOmpWriteClause::pools;
   37452             : 
   37453             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   37454             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   37455             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   37456             : // around this macro definition rather than each use).
   37457             : #ifndef ALLOC_MUTEX
   37458             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   37459             :         do {                                                                     \
   37460             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   37461             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   37462             :                 abort();                                                         \
   37463             :             }                                                                    \
   37464             :         } while (0);
   37465             : #endif
   37466             : 
   37467             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   37468             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   37469             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   37470             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   37471             : 
   37472             : /*! \brief New operator for SgOmpWriteClause.
   37473             : 
   37474             :    This new operator implements memory pools to provide most efficent 
   37475             :    use of the heap within construction of large ASTs.
   37476             : 
   37477             : \internal The new and delete operators use the lower level C malloc/free
   37478             :    function calls for performance and to make sure that mixing of malloc/free
   37479             :    and new/delete by the used can be caught more readily.  This may change
   37480             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   37481             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   37482             :    deallocate memory allocated using ROSE_MALLOC.
   37483             : */
   37484           1 : void *SgOmpWriteClause::operator new ( size_t Size )
   37485             : {
   37486             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   37487             :      * returning or throwing an exception. */
   37488           1 :     ALLOC_MUTEX(SgOmpWriteClause, lock);
   37489             : 
   37490             : #if ROSE_ALLOC_TRACE == 2
   37491             : //    printf("SgOmpWriteClause::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgOmpWriteClause::next_node);
   37492             : #endif
   37493             : 
   37494             : #if USE_CPP_NEW_DELETE_OPERATORS
   37495             :     void *mem = ROSE_MALLOC(Size);
   37496             :     ALLOC_MUTEX(SgOmpWriteClause, unlock);
   37497             :     return mem;
   37498             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   37499             : #if ROSE_PEDANTIC_ALLOC
   37500             :     ROSE_ASSERT(Size == sizeof(SgOmpWriteClause));
   37501             : #else
   37502           1 :     if (Size != sizeof(SgOmpWriteClause)) {
   37503           0 :       void * object = ROSE_MALLOC(Size);
   37504           0 :       ALLOC_MUTEX(SgOmpWriteClause, unlock);
   37505             :       return object;
   37506             :     }
   37507             : #endif
   37508             : 
   37509           1 :     if (SgOmpWriteClause::next_node == nullptr) {
   37510           1 :         SgOmpWriteClause * alloc = (SgOmpWriteClause*) ROSE_MALLOC ( SgOmpWriteClause::pool_size * sizeof(SgOmpWriteClause) );
   37511           1 :         ROSE_ASSERT(alloc != nullptr);
   37512             : 
   37513             : #if ROSE_ALLOC_TRACE == 2
   37514             : //        printf("SgOmpWriteClause::alloc\n  block[%zi] = [ %p , %p [\n", SgOmpWriteClause::pools.size(), alloc, alloc + SgOmpWriteClause::pool_size);
   37515             : #endif
   37516             : 
   37517             : #if ROSE_ALLOC_MEMSET == 1
   37518             : #elif ROSE_ALLOC_MEMSET == 2
   37519             :         memset(alloc, 0x00, SgOmpWriteClause::pool_size * sizeof(SgOmpWriteClause));
   37520             : #elif ROSE_ALLOC_MEMSET == 3
   37521             :         memset(alloc, 0xAA, SgOmpWriteClause::pool_size * sizeof(SgOmpWriteClause));
   37522             : #endif
   37523        2000 :         for (unsigned i=0; i < SgOmpWriteClause::pool_size-1; i++) {
   37524        1999 :           alloc[i].p_freepointer = &(alloc[i+1]);
   37525             :         }
   37526           1 :         alloc[SgOmpWriteClause::pool_size-1].p_freepointer = nullptr;
   37527             : 
   37528           1 :         SgOmpWriteClause::pools.push_back ( (unsigned char *) alloc );
   37529           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgOmpWriteClause::pool_size * sizeof(SgOmpWriteClause), V_SgOmpWriteClause ) );
   37530           1 :         SgOmpWriteClause::next_node = alloc;
   37531             :     }
   37532           1 :     ROSE_ASSERT(SgOmpWriteClause::next_node != nullptr);
   37533             : 
   37534           1 :     SgOmpWriteClause * object = SgOmpWriteClause::next_node;
   37535           1 :     SgOmpWriteClause::next_node = (SgOmpWriteClause*)(object->p_freepointer);
   37536             : 
   37537             : #if ROSE_ALLOC_TRACE == 2
   37538             :     printf("SgOmpWriteClause::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpWriteClause::next_node);
   37539             : #endif
   37540             : 
   37541           1 :     SgNode * fp = object->p_freepointer;
   37542             : #if ROSE_ALLOC_MEMSET == 1
   37543             : #elif ROSE_ALLOC_MEMSET == 2
   37544             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpWriteClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   37545             : #elif ROSE_ALLOC_MEMSET == 3
   37546             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgOmpWriteClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   37547             : #endif
   37548           1 :     object->p_freepointer = fp;
   37549             : 
   37550             : #if ROSE_ALLOC_TRACE == 2
   37551             : //    printf("SgOmpWriteClause::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpWriteClause::next_node);
   37552             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   37553             :     Rose::MemPool::snapshot(oss.str());
   37554             :     alloc_trace_cnt++;
   37555             : #endif
   37556             : 
   37557           1 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   37558             : 
   37559           1 :     ALLOC_MUTEX(SgOmpWriteClause, unlock);
   37560             : 
   37561             :     return object;
   37562             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   37563             : }
   37564             : 
   37565             : 
   37566             : 
   37567             : /*! \brief Delete operator for SgOmpWriteClause.
   37568             : 
   37569             :    This delete operator implements deallocation using memory pools to 
   37570             :    provide most efficent use of the heap within construction of large ASTs.
   37571             : 
   37572             : \internal The new and delete operators use the lower level C malloc/free
   37573             :    function calls for performance and to make sure that mixing of malloc/free
   37574             :    and new/delete by the used can be caught more readily.  This may change
   37575             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   37576             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   37577             :    deallocate memory allocated using ROSE_MALLOC.
   37578             : */
   37579           0 : void SgOmpWriteClause::operator delete(void *Pointer, size_t Size)
   37580             : {
   37581             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   37582             :      * or throwing an exception. */
   37583           0 :     ALLOC_MUTEX(SgOmpWriteClause, lock);
   37584             : 
   37585             : #if USE_CPP_NEW_DELETE_OPERATORS
   37586             :     ROSE_FREE(Pointer);
   37587             : #else
   37588             : #if ROSE_PEDANTIC_ALLOC
   37589             :     ROSE_ASSERT(Size == sizeof(SgOmpWriteClause));
   37590             : #else
   37591           0 :     if (Size != sizeof(SgOmpWriteClause)) {
   37592           0 :       ROSE_FREE(Pointer);
   37593           0 :       ALLOC_MUTEX(SgOmpWriteClause, unlock);
   37594             :       return;
   37595             :     }
   37596             : #endif
   37597             : 
   37598           0 :     SgOmpWriteClause * object = (SgOmpWriteClause*) Pointer;
   37599           0 :     ROSE_ASSERT(object != nullptr);
   37600             : 
   37601             : #if ROSE_ALLOC_TRACE == 2
   37602             : //  printf("SgOmpWriteClause::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpWriteClause::next_node);
   37603             :     printf("SgOmpWriteClause::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpWriteClause::next_node);
   37604             : #endif
   37605             : 
   37606             : #if ROSE_PEDANTIC_ALLOC
   37607             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   37608             : #endif
   37609             : 
   37610             : #if ROSE_ALLOC_MEMSET == 1
   37611             : #elif ROSE_ALLOC_MEMSET == 2
   37612             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpWriteClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   37613             : #elif ROSE_ALLOC_MEMSET == 3
   37614             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgOmpWriteClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   37615             : #endif
   37616             : 
   37617             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   37618             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   37619             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   37620             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   37621             : #else
   37622           0 :     object->p_freepointer = SgOmpWriteClause::next_node;
   37623           0 :     SgOmpWriteClause::next_node = object;
   37624             : #endif
   37625             : 
   37626             : #if ROSE_ALLOC_TRACE == 2
   37627             : //  printf("SgOmpWriteClause::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpWriteClause::next_node);
   37628             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   37629             :     Rose::MemPool::snapshot(oss.str());
   37630             :     alloc_trace_cnt++;
   37631             : #endif
   37632             : 
   37633             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   37634             : 
   37635           0 :     ALLOC_MUTEX(SgOmpWriteClause, unlock);
   37636             : }
   37637             : 
   37638             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   37639             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   37640             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   37641             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   37642             : // Also, note comment below from Robb (copied from the Common.code file).
   37643             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   37644             : //
   37645             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   37646             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   37647             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   37648             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   37649             : #if 0
   37650             : void SgOmpWriteClause::operator delete(void* pointer) { SgOmpWriteClause::operator delete (pointer, sizeof(SgOmpWriteClause)); };
   37651             : #endif
   37652             : /* #line 37653 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   37653             : 
   37654             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   37655             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   37656             : // obviously imply C++.
   37657             : 
   37658             : // This implements the support within ROSE for memory pools.  Memory pools
   37659             : // support the most condensed usage of memory within the construction of
   37660             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   37661             : // by a new operator written for each class.
   37662             : 
   37663             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   37664             :     // User wants multi-thread support and POSIX threads are available.
   37665             : #   include <pthread.h>
   37666             :     static pthread_mutex_t SgOmpUpdateClause_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   37667             : #else
   37668             :      // Cause synchronization to be skipped.
   37669             : #    ifndef ALLOC_MUTEX
   37670             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   37671             : #    endif
   37672             : #    ifdef _REENTRANT
   37673             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   37674             : #       ifdef _MSC_VER
   37675             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   37676             : #       else
   37677             : #           warning "POSIX threads are not available; synchronization being skipped"
   37678             : #       endif
   37679             : #    endif
   37680             : #endif
   37681             : 
   37682             : #ifndef ROSE_ALLOC_TRACE
   37683             : #  define ROSE_ALLOC_TRACE 0
   37684             : #endif
   37685             : 
   37686             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   37687             : #define ROSE_ALLOC_TRACE_CNT
   37688             : #include "memory-pool-snapshot.h"
   37689             : unsigned long alloc_trace_cnt = 0;
   37690             : #endif
   37691             : 
   37692             : #if ROSE_ALLOC_TRACE
   37693             : const unsigned SgOmpUpdateClause::pool_size = 5;
   37694             : #else
   37695             : const unsigned SgOmpUpdateClause::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   37696             : #endif
   37697             : 
   37698             : #ifndef ROSE_ALLOC_MEMSET
   37699             : #  define ROSE_ALLOC_MEMSET 0
   37700             : #endif
   37701             : 
   37702             : #ifndef ROSE_PEDANTIC_ALLOC
   37703             : #  define ROSE_PEDANTIC_ALLOC 0
   37704             : #endif
   37705             : 
   37706             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   37707             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   37708             : #endif
   37709             : 
   37710             : #if !defined(SGNODE__ALL_POOLS)
   37711             : #define SGNODE__ALL_POOLS
   37712             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   37713             : #endif
   37714             : 
   37715             : SgOmpUpdateClause* SgOmpUpdateClause::next_node = nullptr;
   37716             : std::vector<unsigned char*> SgOmpUpdateClause::pools;
   37717             : 
   37718             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   37719             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   37720             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   37721             : // around this macro definition rather than each use).
   37722             : #ifndef ALLOC_MUTEX
   37723             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   37724             :         do {                                                                     \
   37725             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   37726             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   37727             :                 abort();                                                         \
   37728             :             }                                                                    \
   37729             :         } while (0);
   37730             : #endif
   37731             : 
   37732             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   37733             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   37734             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   37735             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   37736             : 
   37737             : /*! \brief New operator for SgOmpUpdateClause.
   37738             : 
   37739             :    This new operator implements memory pools to provide most efficent 
   37740             :    use of the heap within construction of large ASTs.
   37741             : 
   37742             : \internal The new and delete operators use the lower level C malloc/free
   37743             :    function calls for performance and to make sure that mixing of malloc/free
   37744             :    and new/delete by the used can be caught more readily.  This may change
   37745             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   37746             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   37747             :    deallocate memory allocated using ROSE_MALLOC.
   37748             : */
   37749           1 : void *SgOmpUpdateClause::operator new ( size_t Size )
   37750             : {
   37751             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   37752             :      * returning or throwing an exception. */
   37753           1 :     ALLOC_MUTEX(SgOmpUpdateClause, lock);
   37754             : 
   37755             : #if ROSE_ALLOC_TRACE == 2
   37756             : //    printf("SgOmpUpdateClause::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgOmpUpdateClause::next_node);
   37757             : #endif
   37758             : 
   37759             : #if USE_CPP_NEW_DELETE_OPERATORS
   37760             :     void *mem = ROSE_MALLOC(Size);
   37761             :     ALLOC_MUTEX(SgOmpUpdateClause, unlock);
   37762             :     return mem;
   37763             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   37764             : #if ROSE_PEDANTIC_ALLOC
   37765             :     ROSE_ASSERT(Size == sizeof(SgOmpUpdateClause));
   37766             : #else
   37767           1 :     if (Size != sizeof(SgOmpUpdateClause)) {
   37768           0 :       void * object = ROSE_MALLOC(Size);
   37769           0 :       ALLOC_MUTEX(SgOmpUpdateClause, unlock);
   37770             :       return object;
   37771             :     }
   37772             : #endif
   37773             : 
   37774           1 :     if (SgOmpUpdateClause::next_node == nullptr) {
   37775           1 :         SgOmpUpdateClause * alloc = (SgOmpUpdateClause*) ROSE_MALLOC ( SgOmpUpdateClause::pool_size * sizeof(SgOmpUpdateClause) );
   37776           1 :         ROSE_ASSERT(alloc != nullptr);
   37777             : 
   37778             : #if ROSE_ALLOC_TRACE == 2
   37779             : //        printf("SgOmpUpdateClause::alloc\n  block[%zi] = [ %p , %p [\n", SgOmpUpdateClause::pools.size(), alloc, alloc + SgOmpUpdateClause::pool_size);
   37780             : #endif
   37781             : 
   37782             : #if ROSE_ALLOC_MEMSET == 1
   37783             : #elif ROSE_ALLOC_MEMSET == 2
   37784             :         memset(alloc, 0x00, SgOmpUpdateClause::pool_size * sizeof(SgOmpUpdateClause));
   37785             : #elif ROSE_ALLOC_MEMSET == 3
   37786             :         memset(alloc, 0xAA, SgOmpUpdateClause::pool_size * sizeof(SgOmpUpdateClause));
   37787             : #endif
   37788        2000 :         for (unsigned i=0; i < SgOmpUpdateClause::pool_size-1; i++) {
   37789        1999 :           alloc[i].p_freepointer = &(alloc[i+1]);
   37790             :         }
   37791           1 :         alloc[SgOmpUpdateClause::pool_size-1].p_freepointer = nullptr;
   37792             : 
   37793           1 :         SgOmpUpdateClause::pools.push_back ( (unsigned char *) alloc );
   37794           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgOmpUpdateClause::pool_size * sizeof(SgOmpUpdateClause), V_SgOmpUpdateClause ) );
   37795           1 :         SgOmpUpdateClause::next_node = alloc;
   37796             :     }
   37797           1 :     ROSE_ASSERT(SgOmpUpdateClause::next_node != nullptr);
   37798             : 
   37799           1 :     SgOmpUpdateClause * object = SgOmpUpdateClause::next_node;
   37800           1 :     SgOmpUpdateClause::next_node = (SgOmpUpdateClause*)(object->p_freepointer);
   37801             : 
   37802             : #if ROSE_ALLOC_TRACE == 2
   37803             :     printf("SgOmpUpdateClause::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpUpdateClause::next_node);
   37804             : #endif
   37805             : 
   37806           1 :     SgNode * fp = object->p_freepointer;
   37807             : #if ROSE_ALLOC_MEMSET == 1
   37808             : #elif ROSE_ALLOC_MEMSET == 2
   37809             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpUpdateClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   37810             : #elif ROSE_ALLOC_MEMSET == 3
   37811             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgOmpUpdateClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   37812             : #endif
   37813           1 :     object->p_freepointer = fp;
   37814             : 
   37815             : #if ROSE_ALLOC_TRACE == 2
   37816             : //    printf("SgOmpUpdateClause::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpUpdateClause::next_node);
   37817             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   37818             :     Rose::MemPool::snapshot(oss.str());
   37819             :     alloc_trace_cnt++;
   37820             : #endif
   37821             : 
   37822           1 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   37823             : 
   37824           1 :     ALLOC_MUTEX(SgOmpUpdateClause, unlock);
   37825             : 
   37826             :     return object;
   37827             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   37828             : }
   37829             : 
   37830             : 
   37831             : 
   37832             : /*! \brief Delete operator for SgOmpUpdateClause.
   37833             : 
   37834             :    This delete operator implements deallocation using memory pools to 
   37835             :    provide most efficent use of the heap within construction of large ASTs.
   37836             : 
   37837             : \internal The new and delete operators use the lower level C malloc/free
   37838             :    function calls for performance and to make sure that mixing of malloc/free
   37839             :    and new/delete by the used can be caught more readily.  This may change
   37840             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   37841             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   37842             :    deallocate memory allocated using ROSE_MALLOC.
   37843             : */
   37844           0 : void SgOmpUpdateClause::operator delete(void *Pointer, size_t Size)
   37845             : {
   37846             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   37847             :      * or throwing an exception. */
   37848           0 :     ALLOC_MUTEX(SgOmpUpdateClause, lock);
   37849             : 
   37850             : #if USE_CPP_NEW_DELETE_OPERATORS
   37851             :     ROSE_FREE(Pointer);
   37852             : #else
   37853             : #if ROSE_PEDANTIC_ALLOC
   37854             :     ROSE_ASSERT(Size == sizeof(SgOmpUpdateClause));
   37855             : #else
   37856           0 :     if (Size != sizeof(SgOmpUpdateClause)) {
   37857           0 :       ROSE_FREE(Pointer);
   37858           0 :       ALLOC_MUTEX(SgOmpUpdateClause, unlock);
   37859             :       return;
   37860             :     }
   37861             : #endif
   37862             : 
   37863           0 :     SgOmpUpdateClause * object = (SgOmpUpdateClause*) Pointer;
   37864           0 :     ROSE_ASSERT(object != nullptr);
   37865             : 
   37866             : #if ROSE_ALLOC_TRACE == 2
   37867             : //  printf("SgOmpUpdateClause::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpUpdateClause::next_node);
   37868             :     printf("SgOmpUpdateClause::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpUpdateClause::next_node);
   37869             : #endif
   37870             : 
   37871             : #if ROSE_PEDANTIC_ALLOC
   37872             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   37873             : #endif
   37874             : 
   37875             : #if ROSE_ALLOC_MEMSET == 1
   37876             : #elif ROSE_ALLOC_MEMSET == 2
   37877             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpUpdateClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   37878             : #elif ROSE_ALLOC_MEMSET == 3
   37879             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgOmpUpdateClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   37880             : #endif
   37881             : 
   37882             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   37883             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   37884             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   37885             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   37886             : #else
   37887           0 :     object->p_freepointer = SgOmpUpdateClause::next_node;
   37888           0 :     SgOmpUpdateClause::next_node = object;
   37889             : #endif
   37890             : 
   37891             : #if ROSE_ALLOC_TRACE == 2
   37892             : //  printf("SgOmpUpdateClause::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpUpdateClause::next_node);
   37893             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   37894             :     Rose::MemPool::snapshot(oss.str());
   37895             :     alloc_trace_cnt++;
   37896             : #endif
   37897             : 
   37898             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   37899             : 
   37900           0 :     ALLOC_MUTEX(SgOmpUpdateClause, unlock);
   37901             : }
   37902             : 
   37903             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   37904             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   37905             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   37906             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   37907             : // Also, note comment below from Robb (copied from the Common.code file).
   37908             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   37909             : //
   37910             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   37911             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   37912             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   37913             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   37914             : #if 0
   37915             : void SgOmpUpdateClause::operator delete(void* pointer) { SgOmpUpdateClause::operator delete (pointer, sizeof(SgOmpUpdateClause)); };
   37916             : #endif
   37917             : /* #line 37918 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   37918             : 
   37919             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   37920             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   37921             : // obviously imply C++.
   37922             : 
   37923             : // This implements the support within ROSE for memory pools.  Memory pools
   37924             : // support the most condensed usage of memory within the construction of
   37925             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   37926             : // by a new operator written for each class.
   37927             : 
   37928             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   37929             :     // User wants multi-thread support and POSIX threads are available.
   37930             : #   include <pthread.h>
   37931             :     static pthread_mutex_t SgOmpDepobjUpdateClause_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   37932             : #else
   37933             :      // Cause synchronization to be skipped.
   37934             : #    ifndef ALLOC_MUTEX
   37935             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   37936             : #    endif
   37937             : #    ifdef _REENTRANT
   37938             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   37939             : #       ifdef _MSC_VER
   37940             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   37941             : #       else
   37942             : #           warning "POSIX threads are not available; synchronization being skipped"
   37943             : #       endif
   37944             : #    endif
   37945             : #endif
   37946             : 
   37947             : #ifndef ROSE_ALLOC_TRACE
   37948             : #  define ROSE_ALLOC_TRACE 0
   37949             : #endif
   37950             : 
   37951             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   37952             : #define ROSE_ALLOC_TRACE_CNT
   37953             : #include "memory-pool-snapshot.h"
   37954             : unsigned long alloc_trace_cnt = 0;
   37955             : #endif
   37956             : 
   37957             : #if ROSE_ALLOC_TRACE
   37958             : const unsigned SgOmpDepobjUpdateClause::pool_size = 5;
   37959             : #else
   37960             : const unsigned SgOmpDepobjUpdateClause::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   37961             : #endif
   37962             : 
   37963             : #ifndef ROSE_ALLOC_MEMSET
   37964             : #  define ROSE_ALLOC_MEMSET 0
   37965             : #endif
   37966             : 
   37967             : #ifndef ROSE_PEDANTIC_ALLOC
   37968             : #  define ROSE_PEDANTIC_ALLOC 0
   37969             : #endif
   37970             : 
   37971             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   37972             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   37973             : #endif
   37974             : 
   37975             : #if !defined(SGNODE__ALL_POOLS)
   37976             : #define SGNODE__ALL_POOLS
   37977             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   37978             : #endif
   37979             : 
   37980             : SgOmpDepobjUpdateClause* SgOmpDepobjUpdateClause::next_node = nullptr;
   37981             : std::vector<unsigned char*> SgOmpDepobjUpdateClause::pools;
   37982             : 
   37983             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   37984             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   37985             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   37986             : // around this macro definition rather than each use).
   37987             : #ifndef ALLOC_MUTEX
   37988             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   37989             :         do {                                                                     \
   37990             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   37991             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   37992             :                 abort();                                                         \
   37993             :             }                                                                    \
   37994             :         } while (0);
   37995             : #endif
   37996             : 
   37997             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   37998             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   37999             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   38000             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   38001             : 
   38002             : /*! \brief New operator for SgOmpDepobjUpdateClause.
   38003             : 
   38004             :    This new operator implements memory pools to provide most efficent 
   38005             :    use of the heap within construction of large ASTs.
   38006             : 
   38007             : \internal The new and delete operators use the lower level C malloc/free
   38008             :    function calls for performance and to make sure that mixing of malloc/free
   38009             :    and new/delete by the used can be caught more readily.  This may change
   38010             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   38011             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   38012             :    deallocate memory allocated using ROSE_MALLOC.
   38013             : */
   38014           1 : void *SgOmpDepobjUpdateClause::operator new ( size_t Size )
   38015             : {
   38016             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   38017             :      * returning or throwing an exception. */
   38018           1 :     ALLOC_MUTEX(SgOmpDepobjUpdateClause, lock);
   38019             : 
   38020             : #if ROSE_ALLOC_TRACE == 2
   38021             : //    printf("SgOmpDepobjUpdateClause::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgOmpDepobjUpdateClause::next_node);
   38022             : #endif
   38023             : 
   38024             : #if USE_CPP_NEW_DELETE_OPERATORS
   38025             :     void *mem = ROSE_MALLOC(Size);
   38026             :     ALLOC_MUTEX(SgOmpDepobjUpdateClause, unlock);
   38027             :     return mem;
   38028             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   38029             : #if ROSE_PEDANTIC_ALLOC
   38030             :     ROSE_ASSERT(Size == sizeof(SgOmpDepobjUpdateClause));
   38031             : #else
   38032           1 :     if (Size != sizeof(SgOmpDepobjUpdateClause)) {
   38033           0 :       void * object = ROSE_MALLOC(Size);
   38034           0 :       ALLOC_MUTEX(SgOmpDepobjUpdateClause, unlock);
   38035             :       return object;
   38036             :     }
   38037             : #endif
   38038             : 
   38039           1 :     if (SgOmpDepobjUpdateClause::next_node == nullptr) {
   38040           1 :         SgOmpDepobjUpdateClause * alloc = (SgOmpDepobjUpdateClause*) ROSE_MALLOC ( SgOmpDepobjUpdateClause::pool_size * sizeof(SgOmpDepobjUpdateClause) );
   38041           1 :         ROSE_ASSERT(alloc != nullptr);
   38042             : 
   38043             : #if ROSE_ALLOC_TRACE == 2
   38044             : //        printf("SgOmpDepobjUpdateClause::alloc\n  block[%zi] = [ %p , %p [\n", SgOmpDepobjUpdateClause::pools.size(), alloc, alloc + SgOmpDepobjUpdateClause::pool_size);
   38045             : #endif
   38046             : 
   38047             : #if ROSE_ALLOC_MEMSET == 1
   38048             : #elif ROSE_ALLOC_MEMSET == 2
   38049             :         memset(alloc, 0x00, SgOmpDepobjUpdateClause::pool_size * sizeof(SgOmpDepobjUpdateClause));
   38050             : #elif ROSE_ALLOC_MEMSET == 3
   38051             :         memset(alloc, 0xAA, SgOmpDepobjUpdateClause::pool_size * sizeof(SgOmpDepobjUpdateClause));
   38052             : #endif
   38053        2000 :         for (unsigned i=0; i < SgOmpDepobjUpdateClause::pool_size-1; i++) {
   38054        1999 :           alloc[i].p_freepointer = &(alloc[i+1]);
   38055             :         }
   38056           1 :         alloc[SgOmpDepobjUpdateClause::pool_size-1].p_freepointer = nullptr;
   38057             : 
   38058           1 :         SgOmpDepobjUpdateClause::pools.push_back ( (unsigned char *) alloc );
   38059           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgOmpDepobjUpdateClause::pool_size * sizeof(SgOmpDepobjUpdateClause), V_SgOmpDepobjUpdateClause ) );
   38060           1 :         SgOmpDepobjUpdateClause::next_node = alloc;
   38061             :     }
   38062           1 :     ROSE_ASSERT(SgOmpDepobjUpdateClause::next_node != nullptr);
   38063             : 
   38064           1 :     SgOmpDepobjUpdateClause * object = SgOmpDepobjUpdateClause::next_node;
   38065           1 :     SgOmpDepobjUpdateClause::next_node = (SgOmpDepobjUpdateClause*)(object->p_freepointer);
   38066             : 
   38067             : #if ROSE_ALLOC_TRACE == 2
   38068             :     printf("SgOmpDepobjUpdateClause::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpDepobjUpdateClause::next_node);
   38069             : #endif
   38070             : 
   38071           1 :     SgNode * fp = object->p_freepointer;
   38072             : #if ROSE_ALLOC_MEMSET == 1
   38073             : #elif ROSE_ALLOC_MEMSET == 2
   38074             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpDepobjUpdateClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   38075             : #elif ROSE_ALLOC_MEMSET == 3
   38076             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgOmpDepobjUpdateClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   38077             : #endif
   38078           1 :     object->p_freepointer = fp;
   38079             : 
   38080             : #if ROSE_ALLOC_TRACE == 2
   38081             : //    printf("SgOmpDepobjUpdateClause::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpDepobjUpdateClause::next_node);
   38082             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   38083             :     Rose::MemPool::snapshot(oss.str());
   38084             :     alloc_trace_cnt++;
   38085             : #endif
   38086             : 
   38087           1 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   38088             : 
   38089           1 :     ALLOC_MUTEX(SgOmpDepobjUpdateClause, unlock);
   38090             : 
   38091             :     return object;
   38092             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   38093             : }
   38094             : 
   38095             : 
   38096             : 
   38097             : /*! \brief Delete operator for SgOmpDepobjUpdateClause.
   38098             : 
   38099             :    This delete operator implements deallocation using memory pools to 
   38100             :    provide most efficent use of the heap within construction of large ASTs.
   38101             : 
   38102             : \internal The new and delete operators use the lower level C malloc/free
   38103             :    function calls for performance and to make sure that mixing of malloc/free
   38104             :    and new/delete by the used can be caught more readily.  This may change
   38105             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   38106             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   38107             :    deallocate memory allocated using ROSE_MALLOC.
   38108             : */
   38109           0 : void SgOmpDepobjUpdateClause::operator delete(void *Pointer, size_t Size)
   38110             : {
   38111             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   38112             :      * or throwing an exception. */
   38113           0 :     ALLOC_MUTEX(SgOmpDepobjUpdateClause, lock);
   38114             : 
   38115             : #if USE_CPP_NEW_DELETE_OPERATORS
   38116             :     ROSE_FREE(Pointer);
   38117             : #else
   38118             : #if ROSE_PEDANTIC_ALLOC
   38119             :     ROSE_ASSERT(Size == sizeof(SgOmpDepobjUpdateClause));
   38120             : #else
   38121           0 :     if (Size != sizeof(SgOmpDepobjUpdateClause)) {
   38122           0 :       ROSE_FREE(Pointer);
   38123           0 :       ALLOC_MUTEX(SgOmpDepobjUpdateClause, unlock);
   38124             :       return;
   38125             :     }
   38126             : #endif
   38127             : 
   38128           0 :     SgOmpDepobjUpdateClause * object = (SgOmpDepobjUpdateClause*) Pointer;
   38129           0 :     ROSE_ASSERT(object != nullptr);
   38130             : 
   38131             : #if ROSE_ALLOC_TRACE == 2
   38132             : //  printf("SgOmpDepobjUpdateClause::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpDepobjUpdateClause::next_node);
   38133             :     printf("SgOmpDepobjUpdateClause::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpDepobjUpdateClause::next_node);
   38134             : #endif
   38135             : 
   38136             : #if ROSE_PEDANTIC_ALLOC
   38137             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   38138             : #endif
   38139             : 
   38140             : #if ROSE_ALLOC_MEMSET == 1
   38141             : #elif ROSE_ALLOC_MEMSET == 2
   38142             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpDepobjUpdateClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   38143             : #elif ROSE_ALLOC_MEMSET == 3
   38144             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgOmpDepobjUpdateClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   38145             : #endif
   38146             : 
   38147             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   38148             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   38149             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   38150             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   38151             : #else
   38152           0 :     object->p_freepointer = SgOmpDepobjUpdateClause::next_node;
   38153           0 :     SgOmpDepobjUpdateClause::next_node = object;
   38154             : #endif
   38155             : 
   38156             : #if ROSE_ALLOC_TRACE == 2
   38157             : //  printf("SgOmpDepobjUpdateClause::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpDepobjUpdateClause::next_node);
   38158             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   38159             :     Rose::MemPool::snapshot(oss.str());
   38160             :     alloc_trace_cnt++;
   38161             : #endif
   38162             : 
   38163             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   38164             : 
   38165           0 :     ALLOC_MUTEX(SgOmpDepobjUpdateClause, unlock);
   38166             : }
   38167             : 
   38168             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   38169             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   38170             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   38171             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   38172             : // Also, note comment below from Robb (copied from the Common.code file).
   38173             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   38174             : //
   38175             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   38176             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   38177             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   38178             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   38179             : #if 0
   38180             : void SgOmpDepobjUpdateClause::operator delete(void* pointer) { SgOmpDepobjUpdateClause::operator delete (pointer, sizeof(SgOmpDepobjUpdateClause)); };
   38181             : #endif
   38182             : /* #line 38183 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   38183             : 
   38184             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   38185             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   38186             : // obviously imply C++.
   38187             : 
   38188             : // This implements the support within ROSE for memory pools.  Memory pools
   38189             : // support the most condensed usage of memory within the construction of
   38190             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   38191             : // by a new operator written for each class.
   38192             : 
   38193             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   38194             :     // User wants multi-thread support and POSIX threads are available.
   38195             : #   include <pthread.h>
   38196             :     static pthread_mutex_t SgOmpDestroyClause_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   38197             : #else
   38198             :      // Cause synchronization to be skipped.
   38199             : #    ifndef ALLOC_MUTEX
   38200             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   38201             : #    endif
   38202             : #    ifdef _REENTRANT
   38203             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   38204             : #       ifdef _MSC_VER
   38205             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   38206             : #       else
   38207             : #           warning "POSIX threads are not available; synchronization being skipped"
   38208             : #       endif
   38209             : #    endif
   38210             : #endif
   38211             : 
   38212             : #ifndef ROSE_ALLOC_TRACE
   38213             : #  define ROSE_ALLOC_TRACE 0
   38214             : #endif
   38215             : 
   38216             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   38217             : #define ROSE_ALLOC_TRACE_CNT
   38218             : #include "memory-pool-snapshot.h"
   38219             : unsigned long alloc_trace_cnt = 0;
   38220             : #endif
   38221             : 
   38222             : #if ROSE_ALLOC_TRACE
   38223             : const unsigned SgOmpDestroyClause::pool_size = 5;
   38224             : #else
   38225             : const unsigned SgOmpDestroyClause::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   38226             : #endif
   38227             : 
   38228             : #ifndef ROSE_ALLOC_MEMSET
   38229             : #  define ROSE_ALLOC_MEMSET 0
   38230             : #endif
   38231             : 
   38232             : #ifndef ROSE_PEDANTIC_ALLOC
   38233             : #  define ROSE_PEDANTIC_ALLOC 0
   38234             : #endif
   38235             : 
   38236             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   38237             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   38238             : #endif
   38239             : 
   38240             : #if !defined(SGNODE__ALL_POOLS)
   38241             : #define SGNODE__ALL_POOLS
   38242             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   38243             : #endif
   38244             : 
   38245             : SgOmpDestroyClause* SgOmpDestroyClause::next_node = nullptr;
   38246             : std::vector<unsigned char*> SgOmpDestroyClause::pools;
   38247             : 
   38248             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   38249             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   38250             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   38251             : // around this macro definition rather than each use).
   38252             : #ifndef ALLOC_MUTEX
   38253             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   38254             :         do {                                                                     \
   38255             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   38256             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   38257             :                 abort();                                                         \
   38258             :             }                                                                    \
   38259             :         } while (0);
   38260             : #endif
   38261             : 
   38262             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   38263             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   38264             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   38265             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   38266             : 
   38267             : /*! \brief New operator for SgOmpDestroyClause.
   38268             : 
   38269             :    This new operator implements memory pools to provide most efficent 
   38270             :    use of the heap within construction of large ASTs.
   38271             : 
   38272             : \internal The new and delete operators use the lower level C malloc/free
   38273             :    function calls for performance and to make sure that mixing of malloc/free
   38274             :    and new/delete by the used can be caught more readily.  This may change
   38275             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   38276             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   38277             :    deallocate memory allocated using ROSE_MALLOC.
   38278             : */
   38279           1 : void *SgOmpDestroyClause::operator new ( size_t Size )
   38280             : {
   38281             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   38282             :      * returning or throwing an exception. */
   38283           1 :     ALLOC_MUTEX(SgOmpDestroyClause, lock);
   38284             : 
   38285             : #if ROSE_ALLOC_TRACE == 2
   38286             : //    printf("SgOmpDestroyClause::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgOmpDestroyClause::next_node);
   38287             : #endif
   38288             : 
   38289             : #if USE_CPP_NEW_DELETE_OPERATORS
   38290             :     void *mem = ROSE_MALLOC(Size);
   38291             :     ALLOC_MUTEX(SgOmpDestroyClause, unlock);
   38292             :     return mem;
   38293             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   38294             : #if ROSE_PEDANTIC_ALLOC
   38295             :     ROSE_ASSERT(Size == sizeof(SgOmpDestroyClause));
   38296             : #else
   38297           1 :     if (Size != sizeof(SgOmpDestroyClause)) {
   38298           0 :       void * object = ROSE_MALLOC(Size);
   38299           0 :       ALLOC_MUTEX(SgOmpDestroyClause, unlock);
   38300             :       return object;
   38301             :     }
   38302             : #endif
   38303             : 
   38304           1 :     if (SgOmpDestroyClause::next_node == nullptr) {
   38305           1 :         SgOmpDestroyClause * alloc = (SgOmpDestroyClause*) ROSE_MALLOC ( SgOmpDestroyClause::pool_size * sizeof(SgOmpDestroyClause) );
   38306           1 :         ROSE_ASSERT(alloc != nullptr);
   38307             : 
   38308             : #if ROSE_ALLOC_TRACE == 2
   38309             : //        printf("SgOmpDestroyClause::alloc\n  block[%zi] = [ %p , %p [\n", SgOmpDestroyClause::pools.size(), alloc, alloc + SgOmpDestroyClause::pool_size);
   38310             : #endif
   38311             : 
   38312             : #if ROSE_ALLOC_MEMSET == 1
   38313             : #elif ROSE_ALLOC_MEMSET == 2
   38314             :         memset(alloc, 0x00, SgOmpDestroyClause::pool_size * sizeof(SgOmpDestroyClause));
   38315             : #elif ROSE_ALLOC_MEMSET == 3
   38316             :         memset(alloc, 0xAA, SgOmpDestroyClause::pool_size * sizeof(SgOmpDestroyClause));
   38317             : #endif
   38318        2000 :         for (unsigned i=0; i < SgOmpDestroyClause::pool_size-1; i++) {
   38319        1999 :           alloc[i].p_freepointer = &(alloc[i+1]);
   38320             :         }
   38321           1 :         alloc[SgOmpDestroyClause::pool_size-1].p_freepointer = nullptr;
   38322             : 
   38323           1 :         SgOmpDestroyClause::pools.push_back ( (unsigned char *) alloc );
   38324           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgOmpDestroyClause::pool_size * sizeof(SgOmpDestroyClause), V_SgOmpDestroyClause ) );
   38325           1 :         SgOmpDestroyClause::next_node = alloc;
   38326             :     }
   38327           1 :     ROSE_ASSERT(SgOmpDestroyClause::next_node != nullptr);
   38328             : 
   38329           1 :     SgOmpDestroyClause * object = SgOmpDestroyClause::next_node;
   38330           1 :     SgOmpDestroyClause::next_node = (SgOmpDestroyClause*)(object->p_freepointer);
   38331             : 
   38332             : #if ROSE_ALLOC_TRACE == 2
   38333             :     printf("SgOmpDestroyClause::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpDestroyClause::next_node);
   38334             : #endif
   38335             : 
   38336           1 :     SgNode * fp = object->p_freepointer;
   38337             : #if ROSE_ALLOC_MEMSET == 1
   38338             : #elif ROSE_ALLOC_MEMSET == 2
   38339             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpDestroyClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   38340             : #elif ROSE_ALLOC_MEMSET == 3
   38341             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgOmpDestroyClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   38342             : #endif
   38343           1 :     object->p_freepointer = fp;
   38344             : 
   38345             : #if ROSE_ALLOC_TRACE == 2
   38346             : //    printf("SgOmpDestroyClause::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpDestroyClause::next_node);
   38347             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   38348             :     Rose::MemPool::snapshot(oss.str());
   38349             :     alloc_trace_cnt++;
   38350             : #endif
   38351             : 
   38352           1 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   38353             : 
   38354           1 :     ALLOC_MUTEX(SgOmpDestroyClause, unlock);
   38355             : 
   38356             :     return object;
   38357             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   38358             : }
   38359             : 
   38360             : 
   38361             : 
   38362             : /*! \brief Delete operator for SgOmpDestroyClause.
   38363             : 
   38364             :    This delete operator implements deallocation using memory pools to 
   38365             :    provide most efficent use of the heap within construction of large ASTs.
   38366             : 
   38367             : \internal The new and delete operators use the lower level C malloc/free
   38368             :    function calls for performance and to make sure that mixing of malloc/free
   38369             :    and new/delete by the used can be caught more readily.  This may change
   38370             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   38371             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   38372             :    deallocate memory allocated using ROSE_MALLOC.
   38373             : */
   38374           0 : void SgOmpDestroyClause::operator delete(void *Pointer, size_t Size)
   38375             : {
   38376             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   38377             :      * or throwing an exception. */
   38378           0 :     ALLOC_MUTEX(SgOmpDestroyClause, lock);
   38379             : 
   38380             : #if USE_CPP_NEW_DELETE_OPERATORS
   38381             :     ROSE_FREE(Pointer);
   38382             : #else
   38383             : #if ROSE_PEDANTIC_ALLOC
   38384             :     ROSE_ASSERT(Size == sizeof(SgOmpDestroyClause));
   38385             : #else
   38386           0 :     if (Size != sizeof(SgOmpDestroyClause)) {
   38387           0 :       ROSE_FREE(Pointer);
   38388           0 :       ALLOC_MUTEX(SgOmpDestroyClause, unlock);
   38389             :       return;
   38390             :     }
   38391             : #endif
   38392             : 
   38393           0 :     SgOmpDestroyClause * object = (SgOmpDestroyClause*) Pointer;
   38394           0 :     ROSE_ASSERT(object != nullptr);
   38395             : 
   38396             : #if ROSE_ALLOC_TRACE == 2
   38397             : //  printf("SgOmpDestroyClause::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpDestroyClause::next_node);
   38398             :     printf("SgOmpDestroyClause::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpDestroyClause::next_node);
   38399             : #endif
   38400             : 
   38401             : #if ROSE_PEDANTIC_ALLOC
   38402             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   38403             : #endif
   38404             : 
   38405             : #if ROSE_ALLOC_MEMSET == 1
   38406             : #elif ROSE_ALLOC_MEMSET == 2
   38407             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpDestroyClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   38408             : #elif ROSE_ALLOC_MEMSET == 3
   38409             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgOmpDestroyClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   38410             : #endif
   38411             : 
   38412             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   38413             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   38414             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   38415             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   38416             : #else
   38417           0 :     object->p_freepointer = SgOmpDestroyClause::next_node;
   38418           0 :     SgOmpDestroyClause::next_node = object;
   38419             : #endif
   38420             : 
   38421             : #if ROSE_ALLOC_TRACE == 2
   38422             : //  printf("SgOmpDestroyClause::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpDestroyClause::next_node);
   38423             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   38424             :     Rose::MemPool::snapshot(oss.str());
   38425             :     alloc_trace_cnt++;
   38426             : #endif
   38427             : 
   38428             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   38429             : 
   38430           0 :     ALLOC_MUTEX(SgOmpDestroyClause, unlock);
   38431             : }
   38432             : 
   38433             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   38434             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   38435             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   38436             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   38437             : // Also, note comment below from Robb (copied from the Common.code file).
   38438             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   38439             : //
   38440             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   38441             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   38442             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   38443             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   38444             : #if 0
   38445             : void SgOmpDestroyClause::operator delete(void* pointer) { SgOmpDestroyClause::operator delete (pointer, sizeof(SgOmpDestroyClause)); };
   38446             : #endif
   38447             : /* #line 38448 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   38448             : 
   38449             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   38450             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   38451             : // obviously imply C++.
   38452             : 
   38453             : // This implements the support within ROSE for memory pools.  Memory pools
   38454             : // support the most condensed usage of memory within the construction of
   38455             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   38456             : // by a new operator written for each class.
   38457             : 
   38458             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   38459             :     // User wants multi-thread support and POSIX threads are available.
   38460             : #   include <pthread.h>
   38461             :     static pthread_mutex_t SgOmpCaptureClause_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   38462             : #else
   38463             :      // Cause synchronization to be skipped.
   38464             : #    ifndef ALLOC_MUTEX
   38465             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   38466             : #    endif
   38467             : #    ifdef _REENTRANT
   38468             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   38469             : #       ifdef _MSC_VER
   38470             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   38471             : #       else
   38472             : #           warning "POSIX threads are not available; synchronization being skipped"
   38473             : #       endif
   38474             : #    endif
   38475             : #endif
   38476             : 
   38477             : #ifndef ROSE_ALLOC_TRACE
   38478             : #  define ROSE_ALLOC_TRACE 0
   38479             : #endif
   38480             : 
   38481             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   38482             : #define ROSE_ALLOC_TRACE_CNT
   38483             : #include "memory-pool-snapshot.h"
   38484             : unsigned long alloc_trace_cnt = 0;
   38485             : #endif
   38486             : 
   38487             : #if ROSE_ALLOC_TRACE
   38488             : const unsigned SgOmpCaptureClause::pool_size = 5;
   38489             : #else
   38490             : const unsigned SgOmpCaptureClause::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   38491             : #endif
   38492             : 
   38493             : #ifndef ROSE_ALLOC_MEMSET
   38494             : #  define ROSE_ALLOC_MEMSET 0
   38495             : #endif
   38496             : 
   38497             : #ifndef ROSE_PEDANTIC_ALLOC
   38498             : #  define ROSE_PEDANTIC_ALLOC 0
   38499             : #endif
   38500             : 
   38501             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   38502             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   38503             : #endif
   38504             : 
   38505             : #if !defined(SGNODE__ALL_POOLS)
   38506             : #define SGNODE__ALL_POOLS
   38507             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   38508             : #endif
   38509             : 
   38510             : SgOmpCaptureClause* SgOmpCaptureClause::next_node = nullptr;
   38511             : std::vector<unsigned char*> SgOmpCaptureClause::pools;
   38512             : 
   38513             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   38514             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   38515             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   38516             : // around this macro definition rather than each use).
   38517             : #ifndef ALLOC_MUTEX
   38518             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   38519             :         do {                                                                     \
   38520             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   38521             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   38522             :                 abort();                                                         \
   38523             :             }                                                                    \
   38524             :         } while (0);
   38525             : #endif
   38526             : 
   38527             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   38528             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   38529             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   38530             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   38531             : 
   38532             : /*! \brief New operator for SgOmpCaptureClause.
   38533             : 
   38534             :    This new operator implements memory pools to provide most efficent 
   38535             :    use of the heap within construction of large ASTs.
   38536             : 
   38537             : \internal The new and delete operators use the lower level C malloc/free
   38538             :    function calls for performance and to make sure that mixing of malloc/free
   38539             :    and new/delete by the used can be caught more readily.  This may change
   38540             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   38541             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   38542             :    deallocate memory allocated using ROSE_MALLOC.
   38543             : */
   38544           1 : void *SgOmpCaptureClause::operator new ( size_t Size )
   38545             : {
   38546             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   38547             :      * returning or throwing an exception. */
   38548           1 :     ALLOC_MUTEX(SgOmpCaptureClause, lock);
   38549             : 
   38550             : #if ROSE_ALLOC_TRACE == 2
   38551             : //    printf("SgOmpCaptureClause::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgOmpCaptureClause::next_node);
   38552             : #endif
   38553             : 
   38554             : #if USE_CPP_NEW_DELETE_OPERATORS
   38555             :     void *mem = ROSE_MALLOC(Size);
   38556             :     ALLOC_MUTEX(SgOmpCaptureClause, unlock);
   38557             :     return mem;
   38558             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   38559             : #if ROSE_PEDANTIC_ALLOC
   38560             :     ROSE_ASSERT(Size == sizeof(SgOmpCaptureClause));
   38561             : #else
   38562           1 :     if (Size != sizeof(SgOmpCaptureClause)) {
   38563           0 :       void * object = ROSE_MALLOC(Size);
   38564           0 :       ALLOC_MUTEX(SgOmpCaptureClause, unlock);
   38565             :       return object;
   38566             :     }
   38567             : #endif
   38568             : 
   38569           1 :     if (SgOmpCaptureClause::next_node == nullptr) {
   38570           1 :         SgOmpCaptureClause * alloc = (SgOmpCaptureClause*) ROSE_MALLOC ( SgOmpCaptureClause::pool_size * sizeof(SgOmpCaptureClause) );
   38571           1 :         ROSE_ASSERT(alloc != nullptr);
   38572             : 
   38573             : #if ROSE_ALLOC_TRACE == 2
   38574             : //        printf("SgOmpCaptureClause::alloc\n  block[%zi] = [ %p , %p [\n", SgOmpCaptureClause::pools.size(), alloc, alloc + SgOmpCaptureClause::pool_size);
   38575             : #endif
   38576             : 
   38577             : #if ROSE_ALLOC_MEMSET == 1
   38578             : #elif ROSE_ALLOC_MEMSET == 2
   38579             :         memset(alloc, 0x00, SgOmpCaptureClause::pool_size * sizeof(SgOmpCaptureClause));
   38580             : #elif ROSE_ALLOC_MEMSET == 3
   38581             :         memset(alloc, 0xAA, SgOmpCaptureClause::pool_size * sizeof(SgOmpCaptureClause));
   38582             : #endif
   38583        2000 :         for (unsigned i=0; i < SgOmpCaptureClause::pool_size-1; i++) {
   38584        1999 :           alloc[i].p_freepointer = &(alloc[i+1]);
   38585             :         }
   38586           1 :         alloc[SgOmpCaptureClause::pool_size-1].p_freepointer = nullptr;
   38587             : 
   38588           1 :         SgOmpCaptureClause::pools.push_back ( (unsigned char *) alloc );
   38589           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgOmpCaptureClause::pool_size * sizeof(SgOmpCaptureClause), V_SgOmpCaptureClause ) );
   38590           1 :         SgOmpCaptureClause::next_node = alloc;
   38591             :     }
   38592           1 :     ROSE_ASSERT(SgOmpCaptureClause::next_node != nullptr);
   38593             : 
   38594           1 :     SgOmpCaptureClause * object = SgOmpCaptureClause::next_node;
   38595           1 :     SgOmpCaptureClause::next_node = (SgOmpCaptureClause*)(object->p_freepointer);
   38596             : 
   38597             : #if ROSE_ALLOC_TRACE == 2
   38598             :     printf("SgOmpCaptureClause::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpCaptureClause::next_node);
   38599             : #endif
   38600             : 
   38601           1 :     SgNode * fp = object->p_freepointer;
   38602             : #if ROSE_ALLOC_MEMSET == 1
   38603             : #elif ROSE_ALLOC_MEMSET == 2
   38604             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpCaptureClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   38605             : #elif ROSE_ALLOC_MEMSET == 3
   38606             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgOmpCaptureClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   38607             : #endif
   38608           1 :     object->p_freepointer = fp;
   38609             : 
   38610             : #if ROSE_ALLOC_TRACE == 2
   38611             : //    printf("SgOmpCaptureClause::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpCaptureClause::next_node);
   38612             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   38613             :     Rose::MemPool::snapshot(oss.str());
   38614             :     alloc_trace_cnt++;
   38615             : #endif
   38616             : 
   38617           1 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   38618             : 
   38619           1 :     ALLOC_MUTEX(SgOmpCaptureClause, unlock);
   38620             : 
   38621             :     return object;
   38622             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   38623             : }
   38624             : 
   38625             : 
   38626             : 
   38627             : /*! \brief Delete operator for SgOmpCaptureClause.
   38628             : 
   38629             :    This delete operator implements deallocation using memory pools to 
   38630             :    provide most efficent use of the heap within construction of large ASTs.
   38631             : 
   38632             : \internal The new and delete operators use the lower level C malloc/free
   38633             :    function calls for performance and to make sure that mixing of malloc/free
   38634             :    and new/delete by the used can be caught more readily.  This may change
   38635             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   38636             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   38637             :    deallocate memory allocated using ROSE_MALLOC.
   38638             : */
   38639           0 : void SgOmpCaptureClause::operator delete(void *Pointer, size_t Size)
   38640             : {
   38641             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   38642             :      * or throwing an exception. */
   38643           0 :     ALLOC_MUTEX(SgOmpCaptureClause, lock);
   38644             : 
   38645             : #if USE_CPP_NEW_DELETE_OPERATORS
   38646             :     ROSE_FREE(Pointer);
   38647             : #else
   38648             : #if ROSE_PEDANTIC_ALLOC
   38649             :     ROSE_ASSERT(Size == sizeof(SgOmpCaptureClause));
   38650             : #else
   38651           0 :     if (Size != sizeof(SgOmpCaptureClause)) {
   38652           0 :       ROSE_FREE(Pointer);
   38653           0 :       ALLOC_MUTEX(SgOmpCaptureClause, unlock);
   38654             :       return;
   38655             :     }
   38656             : #endif
   38657             : 
   38658           0 :     SgOmpCaptureClause * object = (SgOmpCaptureClause*) Pointer;
   38659           0 :     ROSE_ASSERT(object != nullptr);
   38660             : 
   38661             : #if ROSE_ALLOC_TRACE == 2
   38662             : //  printf("SgOmpCaptureClause::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpCaptureClause::next_node);
   38663             :     printf("SgOmpCaptureClause::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpCaptureClause::next_node);
   38664             : #endif
   38665             : 
   38666             : #if ROSE_PEDANTIC_ALLOC
   38667             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   38668             : #endif
   38669             : 
   38670             : #if ROSE_ALLOC_MEMSET == 1
   38671             : #elif ROSE_ALLOC_MEMSET == 2
   38672             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpCaptureClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   38673             : #elif ROSE_ALLOC_MEMSET == 3
   38674             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgOmpCaptureClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   38675             : #endif
   38676             : 
   38677             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   38678             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   38679             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   38680             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   38681             : #else
   38682           0 :     object->p_freepointer = SgOmpCaptureClause::next_node;
   38683           0 :     SgOmpCaptureClause::next_node = object;
   38684             : #endif
   38685             : 
   38686             : #if ROSE_ALLOC_TRACE == 2
   38687             : //  printf("SgOmpCaptureClause::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpCaptureClause::next_node);
   38688             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   38689             :     Rose::MemPool::snapshot(oss.str());
   38690             :     alloc_trace_cnt++;
   38691             : #endif
   38692             : 
   38693             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   38694             : 
   38695           0 :     ALLOC_MUTEX(SgOmpCaptureClause, unlock);
   38696             : }
   38697             : 
   38698             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   38699             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   38700             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   38701             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   38702             : // Also, note comment below from Robb (copied from the Common.code file).
   38703             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   38704             : //
   38705             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   38706             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   38707             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   38708             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   38709             : #if 0
   38710             : void SgOmpCaptureClause::operator delete(void* pointer) { SgOmpCaptureClause::operator delete (pointer, sizeof(SgOmpCaptureClause)); };
   38711             : #endif
   38712             : /* #line 38713 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   38713             : 
   38714             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   38715             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   38716             : // obviously imply C++.
   38717             : 
   38718             : // This implements the support within ROSE for memory pools.  Memory pools
   38719             : // support the most condensed usage of memory within the construction of
   38720             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   38721             : // by a new operator written for each class.
   38722             : 
   38723             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   38724             :     // User wants multi-thread support and POSIX threads are available.
   38725             : #   include <pthread.h>
   38726             :     static pthread_mutex_t SgOmpBeginClause_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   38727             : #else
   38728             :      // Cause synchronization to be skipped.
   38729             : #    ifndef ALLOC_MUTEX
   38730             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   38731             : #    endif
   38732             : #    ifdef _REENTRANT
   38733             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   38734             : #       ifdef _MSC_VER
   38735             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   38736             : #       else
   38737             : #           warning "POSIX threads are not available; synchronization being skipped"
   38738             : #       endif
   38739             : #    endif
   38740             : #endif
   38741             : 
   38742             : #ifndef ROSE_ALLOC_TRACE
   38743             : #  define ROSE_ALLOC_TRACE 0
   38744             : #endif
   38745             : 
   38746             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   38747             : #define ROSE_ALLOC_TRACE_CNT
   38748             : #include "memory-pool-snapshot.h"
   38749             : unsigned long alloc_trace_cnt = 0;
   38750             : #endif
   38751             : 
   38752             : #if ROSE_ALLOC_TRACE
   38753             : const unsigned SgOmpBeginClause::pool_size = 5;
   38754             : #else
   38755             : const unsigned SgOmpBeginClause::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   38756             : #endif
   38757             : 
   38758             : #ifndef ROSE_ALLOC_MEMSET
   38759             : #  define ROSE_ALLOC_MEMSET 0
   38760             : #endif
   38761             : 
   38762             : #ifndef ROSE_PEDANTIC_ALLOC
   38763             : #  define ROSE_PEDANTIC_ALLOC 0
   38764             : #endif
   38765             : 
   38766             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   38767             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   38768             : #endif
   38769             : 
   38770             : #if !defined(SGNODE__ALL_POOLS)
   38771             : #define SGNODE__ALL_POOLS
   38772             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   38773             : #endif
   38774             : 
   38775             : SgOmpBeginClause* SgOmpBeginClause::next_node = nullptr;
   38776             : std::vector<unsigned char*> SgOmpBeginClause::pools;
   38777             : 
   38778             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   38779             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   38780             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   38781             : // around this macro definition rather than each use).
   38782             : #ifndef ALLOC_MUTEX
   38783             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   38784             :         do {                                                                     \
   38785             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   38786             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   38787             :                 abort();                                                         \
   38788             :             }                                                                    \
   38789             :         } while (0);
   38790             : #endif
   38791             : 
   38792             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   38793             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   38794             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   38795             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   38796             : 
   38797             : /*! \brief New operator for SgOmpBeginClause.
   38798             : 
   38799             :    This new operator implements memory pools to provide most efficent 
   38800             :    use of the heap within construction of large ASTs.
   38801             : 
   38802             : \internal The new and delete operators use the lower level C malloc/free
   38803             :    function calls for performance and to make sure that mixing of malloc/free
   38804             :    and new/delete by the used can be caught more readily.  This may change
   38805             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   38806             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   38807             :    deallocate memory allocated using ROSE_MALLOC.
   38808             : */
   38809           0 : void *SgOmpBeginClause::operator new ( size_t Size )
   38810             : {
   38811             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   38812             :      * returning or throwing an exception. */
   38813           0 :     ALLOC_MUTEX(SgOmpBeginClause, lock);
   38814             : 
   38815             : #if ROSE_ALLOC_TRACE == 2
   38816             : //    printf("SgOmpBeginClause::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgOmpBeginClause::next_node);
   38817             : #endif
   38818             : 
   38819             : #if USE_CPP_NEW_DELETE_OPERATORS
   38820             :     void *mem = ROSE_MALLOC(Size);
   38821             :     ALLOC_MUTEX(SgOmpBeginClause, unlock);
   38822             :     return mem;
   38823             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   38824             : #if ROSE_PEDANTIC_ALLOC
   38825             :     ROSE_ASSERT(Size == sizeof(SgOmpBeginClause));
   38826             : #else
   38827           0 :     if (Size != sizeof(SgOmpBeginClause)) {
   38828           0 :       void * object = ROSE_MALLOC(Size);
   38829           0 :       ALLOC_MUTEX(SgOmpBeginClause, unlock);
   38830             :       return object;
   38831             :     }
   38832             : #endif
   38833             : 
   38834           0 :     if (SgOmpBeginClause::next_node == nullptr) {
   38835           0 :         SgOmpBeginClause * alloc = (SgOmpBeginClause*) ROSE_MALLOC ( SgOmpBeginClause::pool_size * sizeof(SgOmpBeginClause) );
   38836           0 :         ROSE_ASSERT(alloc != nullptr);
   38837             : 
   38838             : #if ROSE_ALLOC_TRACE == 2
   38839             : //        printf("SgOmpBeginClause::alloc\n  block[%zi] = [ %p , %p [\n", SgOmpBeginClause::pools.size(), alloc, alloc + SgOmpBeginClause::pool_size);
   38840             : #endif
   38841             : 
   38842             : #if ROSE_ALLOC_MEMSET == 1
   38843             : #elif ROSE_ALLOC_MEMSET == 2
   38844             :         memset(alloc, 0x00, SgOmpBeginClause::pool_size * sizeof(SgOmpBeginClause));
   38845             : #elif ROSE_ALLOC_MEMSET == 3
   38846             :         memset(alloc, 0xAA, SgOmpBeginClause::pool_size * sizeof(SgOmpBeginClause));
   38847             : #endif
   38848           0 :         for (unsigned i=0; i < SgOmpBeginClause::pool_size-1; i++) {
   38849           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
   38850             :         }
   38851           0 :         alloc[SgOmpBeginClause::pool_size-1].p_freepointer = nullptr;
   38852             : 
   38853           0 :         SgOmpBeginClause::pools.push_back ( (unsigned char *) alloc );
   38854           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgOmpBeginClause::pool_size * sizeof(SgOmpBeginClause), V_SgOmpBeginClause ) );
   38855           0 :         SgOmpBeginClause::next_node = alloc;
   38856             :     }
   38857           0 :     ROSE_ASSERT(SgOmpBeginClause::next_node != nullptr);
   38858             : 
   38859           0 :     SgOmpBeginClause * object = SgOmpBeginClause::next_node;
   38860           0 :     SgOmpBeginClause::next_node = (SgOmpBeginClause*)(object->p_freepointer);
   38861             : 
   38862             : #if ROSE_ALLOC_TRACE == 2
   38863             :     printf("SgOmpBeginClause::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpBeginClause::next_node);
   38864             : #endif
   38865             : 
   38866           0 :     SgNode * fp = object->p_freepointer;
   38867             : #if ROSE_ALLOC_MEMSET == 1
   38868             : #elif ROSE_ALLOC_MEMSET == 2
   38869             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpBeginClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   38870             : #elif ROSE_ALLOC_MEMSET == 3
   38871             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgOmpBeginClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   38872             : #endif
   38873           0 :     object->p_freepointer = fp;
   38874             : 
   38875             : #if ROSE_ALLOC_TRACE == 2
   38876             : //    printf("SgOmpBeginClause::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpBeginClause::next_node);
   38877             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   38878             :     Rose::MemPool::snapshot(oss.str());
   38879             :     alloc_trace_cnt++;
   38880             : #endif
   38881             : 
   38882           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   38883             : 
   38884           0 :     ALLOC_MUTEX(SgOmpBeginClause, unlock);
   38885             : 
   38886             :     return object;
   38887             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   38888             : }
   38889             : 
   38890             : 
   38891             : 
   38892             : /*! \brief Delete operator for SgOmpBeginClause.
   38893             : 
   38894             :    This delete operator implements deallocation using memory pools to 
   38895             :    provide most efficent use of the heap within construction of large ASTs.
   38896             : 
   38897             : \internal The new and delete operators use the lower level C malloc/free
   38898             :    function calls for performance and to make sure that mixing of malloc/free
   38899             :    and new/delete by the used can be caught more readily.  This may change
   38900             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   38901             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   38902             :    deallocate memory allocated using ROSE_MALLOC.
   38903             : */
   38904           0 : void SgOmpBeginClause::operator delete(void *Pointer, size_t Size)
   38905             : {
   38906             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   38907             :      * or throwing an exception. */
   38908           0 :     ALLOC_MUTEX(SgOmpBeginClause, lock);
   38909             : 
   38910             : #if USE_CPP_NEW_DELETE_OPERATORS
   38911             :     ROSE_FREE(Pointer);
   38912             : #else
   38913             : #if ROSE_PEDANTIC_ALLOC
   38914             :     ROSE_ASSERT(Size == sizeof(SgOmpBeginClause));
   38915             : #else
   38916           0 :     if (Size != sizeof(SgOmpBeginClause)) {
   38917           0 :       ROSE_FREE(Pointer);
   38918           0 :       ALLOC_MUTEX(SgOmpBeginClause, unlock);
   38919             :       return;
   38920             :     }
   38921             : #endif
   38922             : 
   38923           0 :     SgOmpBeginClause * object = (SgOmpBeginClause*) Pointer;
   38924           0 :     ROSE_ASSERT(object != nullptr);
   38925             : 
   38926             : #if ROSE_ALLOC_TRACE == 2
   38927             : //  printf("SgOmpBeginClause::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpBeginClause::next_node);
   38928             :     printf("SgOmpBeginClause::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpBeginClause::next_node);
   38929             : #endif
   38930             : 
   38931             : #if ROSE_PEDANTIC_ALLOC
   38932             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   38933             : #endif
   38934             : 
   38935             : #if ROSE_ALLOC_MEMSET == 1
   38936             : #elif ROSE_ALLOC_MEMSET == 2
   38937             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpBeginClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   38938             : #elif ROSE_ALLOC_MEMSET == 3
   38939             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgOmpBeginClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   38940             : #endif
   38941             : 
   38942             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   38943             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   38944             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   38945             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   38946             : #else
   38947           0 :     object->p_freepointer = SgOmpBeginClause::next_node;
   38948           0 :     SgOmpBeginClause::next_node = object;
   38949             : #endif
   38950             : 
   38951             : #if ROSE_ALLOC_TRACE == 2
   38952             : //  printf("SgOmpBeginClause::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpBeginClause::next_node);
   38953             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   38954             :     Rose::MemPool::snapshot(oss.str());
   38955             :     alloc_trace_cnt++;
   38956             : #endif
   38957             : 
   38958             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   38959             : 
   38960           0 :     ALLOC_MUTEX(SgOmpBeginClause, unlock);
   38961             : }
   38962             : 
   38963             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   38964             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   38965             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   38966             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   38967             : // Also, note comment below from Robb (copied from the Common.code file).
   38968             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   38969             : //
   38970             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   38971             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   38972             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   38973             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   38974             : #if 0
   38975             : void SgOmpBeginClause::operator delete(void* pointer) { SgOmpBeginClause::operator delete (pointer, sizeof(SgOmpBeginClause)); };
   38976             : #endif
   38977             : /* #line 38978 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   38978             : 
   38979             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   38980             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   38981             : // obviously imply C++.
   38982             : 
   38983             : // This implements the support within ROSE for memory pools.  Memory pools
   38984             : // support the most condensed usage of memory within the construction of
   38985             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   38986             : // by a new operator written for each class.
   38987             : 
   38988             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   38989             :     // User wants multi-thread support and POSIX threads are available.
   38990             : #   include <pthread.h>
   38991             :     static pthread_mutex_t SgOmpEndClause_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   38992             : #else
   38993             :      // Cause synchronization to be skipped.
   38994             : #    ifndef ALLOC_MUTEX
   38995             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   38996             : #    endif
   38997             : #    ifdef _REENTRANT
   38998             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   38999             : #       ifdef _MSC_VER
   39000             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   39001             : #       else
   39002             : #           warning "POSIX threads are not available; synchronization being skipped"
   39003             : #       endif
   39004             : #    endif
   39005             : #endif
   39006             : 
   39007             : #ifndef ROSE_ALLOC_TRACE
   39008             : #  define ROSE_ALLOC_TRACE 0
   39009             : #endif
   39010             : 
   39011             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   39012             : #define ROSE_ALLOC_TRACE_CNT
   39013             : #include "memory-pool-snapshot.h"
   39014             : unsigned long alloc_trace_cnt = 0;
   39015             : #endif
   39016             : 
   39017             : #if ROSE_ALLOC_TRACE
   39018             : const unsigned SgOmpEndClause::pool_size = 5;
   39019             : #else
   39020             : const unsigned SgOmpEndClause::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   39021             : #endif
   39022             : 
   39023             : #ifndef ROSE_ALLOC_MEMSET
   39024             : #  define ROSE_ALLOC_MEMSET 0
   39025             : #endif
   39026             : 
   39027             : #ifndef ROSE_PEDANTIC_ALLOC
   39028             : #  define ROSE_PEDANTIC_ALLOC 0
   39029             : #endif
   39030             : 
   39031             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   39032             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   39033             : #endif
   39034             : 
   39035             : #if !defined(SGNODE__ALL_POOLS)
   39036             : #define SGNODE__ALL_POOLS
   39037             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   39038             : #endif
   39039             : 
   39040             : SgOmpEndClause* SgOmpEndClause::next_node = nullptr;
   39041             : std::vector<unsigned char*> SgOmpEndClause::pools;
   39042             : 
   39043             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   39044             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   39045             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   39046             : // around this macro definition rather than each use).
   39047             : #ifndef ALLOC_MUTEX
   39048             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   39049             :         do {                                                                     \
   39050             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   39051             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   39052             :                 abort();                                                         \
   39053             :             }                                                                    \
   39054             :         } while (0);
   39055             : #endif
   39056             : 
   39057             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   39058             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   39059             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   39060             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   39061             : 
   39062             : /*! \brief New operator for SgOmpEndClause.
   39063             : 
   39064             :    This new operator implements memory pools to provide most efficent 
   39065             :    use of the heap within construction of large ASTs.
   39066             : 
   39067             : \internal The new and delete operators use the lower level C malloc/free
   39068             :    function calls for performance and to make sure that mixing of malloc/free
   39069             :    and new/delete by the used can be caught more readily.  This may change
   39070             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   39071             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   39072             :    deallocate memory allocated using ROSE_MALLOC.
   39073             : */
   39074           0 : void *SgOmpEndClause::operator new ( size_t Size )
   39075             : {
   39076             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   39077             :      * returning or throwing an exception. */
   39078           0 :     ALLOC_MUTEX(SgOmpEndClause, lock);
   39079             : 
   39080             : #if ROSE_ALLOC_TRACE == 2
   39081             : //    printf("SgOmpEndClause::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgOmpEndClause::next_node);
   39082             : #endif
   39083             : 
   39084             : #if USE_CPP_NEW_DELETE_OPERATORS
   39085             :     void *mem = ROSE_MALLOC(Size);
   39086             :     ALLOC_MUTEX(SgOmpEndClause, unlock);
   39087             :     return mem;
   39088             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   39089             : #if ROSE_PEDANTIC_ALLOC
   39090             :     ROSE_ASSERT(Size == sizeof(SgOmpEndClause));
   39091             : #else
   39092           0 :     if (Size != sizeof(SgOmpEndClause)) {
   39093           0 :       void * object = ROSE_MALLOC(Size);
   39094           0 :       ALLOC_MUTEX(SgOmpEndClause, unlock);
   39095             :       return object;
   39096             :     }
   39097             : #endif
   39098             : 
   39099           0 :     if (SgOmpEndClause::next_node == nullptr) {
   39100           0 :         SgOmpEndClause * alloc = (SgOmpEndClause*) ROSE_MALLOC ( SgOmpEndClause::pool_size * sizeof(SgOmpEndClause) );
   39101           0 :         ROSE_ASSERT(alloc != nullptr);
   39102             : 
   39103             : #if ROSE_ALLOC_TRACE == 2
   39104             : //        printf("SgOmpEndClause::alloc\n  block[%zi] = [ %p , %p [\n", SgOmpEndClause::pools.size(), alloc, alloc + SgOmpEndClause::pool_size);
   39105             : #endif
   39106             : 
   39107             : #if ROSE_ALLOC_MEMSET == 1
   39108             : #elif ROSE_ALLOC_MEMSET == 2
   39109             :         memset(alloc, 0x00, SgOmpEndClause::pool_size * sizeof(SgOmpEndClause));
   39110             : #elif ROSE_ALLOC_MEMSET == 3
   39111             :         memset(alloc, 0xAA, SgOmpEndClause::pool_size * sizeof(SgOmpEndClause));
   39112             : #endif
   39113           0 :         for (unsigned i=0; i < SgOmpEndClause::pool_size-1; i++) {
   39114           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
   39115             :         }
   39116           0 :         alloc[SgOmpEndClause::pool_size-1].p_freepointer = nullptr;
   39117             : 
   39118           0 :         SgOmpEndClause::pools.push_back ( (unsigned char *) alloc );
   39119           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgOmpEndClause::pool_size * sizeof(SgOmpEndClause), V_SgOmpEndClause ) );
   39120           0 :         SgOmpEndClause::next_node = alloc;
   39121             :     }
   39122           0 :     ROSE_ASSERT(SgOmpEndClause::next_node != nullptr);
   39123             : 
   39124           0 :     SgOmpEndClause * object = SgOmpEndClause::next_node;
   39125           0 :     SgOmpEndClause::next_node = (SgOmpEndClause*)(object->p_freepointer);
   39126             : 
   39127             : #if ROSE_ALLOC_TRACE == 2
   39128             :     printf("SgOmpEndClause::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpEndClause::next_node);
   39129             : #endif
   39130             : 
   39131           0 :     SgNode * fp = object->p_freepointer;
   39132             : #if ROSE_ALLOC_MEMSET == 1
   39133             : #elif ROSE_ALLOC_MEMSET == 2
   39134             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpEndClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   39135             : #elif ROSE_ALLOC_MEMSET == 3
   39136             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgOmpEndClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   39137             : #endif
   39138           0 :     object->p_freepointer = fp;
   39139             : 
   39140             : #if ROSE_ALLOC_TRACE == 2
   39141             : //    printf("SgOmpEndClause::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpEndClause::next_node);
   39142             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   39143             :     Rose::MemPool::snapshot(oss.str());
   39144             :     alloc_trace_cnt++;
   39145             : #endif
   39146             : 
   39147           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   39148             : 
   39149           0 :     ALLOC_MUTEX(SgOmpEndClause, unlock);
   39150             : 
   39151             :     return object;
   39152             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   39153             : }
   39154             : 
   39155             : 
   39156             : 
   39157             : /*! \brief Delete operator for SgOmpEndClause.
   39158             : 
   39159             :    This delete operator implements deallocation using memory pools to 
   39160             :    provide most efficent use of the heap within construction of large ASTs.
   39161             : 
   39162             : \internal The new and delete operators use the lower level C malloc/free
   39163             :    function calls for performance and to make sure that mixing of malloc/free
   39164             :    and new/delete by the used can be caught more readily.  This may change
   39165             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   39166             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   39167             :    deallocate memory allocated using ROSE_MALLOC.
   39168             : */
   39169           0 : void SgOmpEndClause::operator delete(void *Pointer, size_t Size)
   39170             : {
   39171             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   39172             :      * or throwing an exception. */
   39173           0 :     ALLOC_MUTEX(SgOmpEndClause, lock);
   39174             : 
   39175             : #if USE_CPP_NEW_DELETE_OPERATORS
   39176             :     ROSE_FREE(Pointer);
   39177             : #else
   39178             : #if ROSE_PEDANTIC_ALLOC
   39179             :     ROSE_ASSERT(Size == sizeof(SgOmpEndClause));
   39180             : #else
   39181           0 :     if (Size != sizeof(SgOmpEndClause)) {
   39182           0 :       ROSE_FREE(Pointer);
   39183           0 :       ALLOC_MUTEX(SgOmpEndClause, unlock);
   39184             :       return;
   39185             :     }
   39186             : #endif
   39187             : 
   39188           0 :     SgOmpEndClause * object = (SgOmpEndClause*) Pointer;
   39189           0 :     ROSE_ASSERT(object != nullptr);
   39190             : 
   39191             : #if ROSE_ALLOC_TRACE == 2
   39192             : //  printf("SgOmpEndClause::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpEndClause::next_node);
   39193             :     printf("SgOmpEndClause::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpEndClause::next_node);
   39194             : #endif
   39195             : 
   39196             : #if ROSE_PEDANTIC_ALLOC
   39197             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   39198             : #endif
   39199             : 
   39200             : #if ROSE_ALLOC_MEMSET == 1
   39201             : #elif ROSE_ALLOC_MEMSET == 2
   39202             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpEndClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   39203             : #elif ROSE_ALLOC_MEMSET == 3
   39204             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgOmpEndClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   39205             : #endif
   39206             : 
   39207             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   39208             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   39209             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   39210             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   39211             : #else
   39212           0 :     object->p_freepointer = SgOmpEndClause::next_node;
   39213           0 :     SgOmpEndClause::next_node = object;
   39214             : #endif
   39215             : 
   39216             : #if ROSE_ALLOC_TRACE == 2
   39217             : //  printf("SgOmpEndClause::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpEndClause::next_node);
   39218             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   39219             :     Rose::MemPool::snapshot(oss.str());
   39220             :     alloc_trace_cnt++;
   39221             : #endif
   39222             : 
   39223             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   39224             : 
   39225           0 :     ALLOC_MUTEX(SgOmpEndClause, unlock);
   39226             : }
   39227             : 
   39228             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   39229             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   39230             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   39231             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   39232             : // Also, note comment below from Robb (copied from the Common.code file).
   39233             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   39234             : //
   39235             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   39236             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   39237             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   39238             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   39239             : #if 0
   39240             : void SgOmpEndClause::operator delete(void* pointer) { SgOmpEndClause::operator delete (pointer, sizeof(SgOmpEndClause)); };
   39241             : #endif
   39242             : /* #line 39243 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   39243             : 
   39244             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   39245             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   39246             : // obviously imply C++.
   39247             : 
   39248             : // This implements the support within ROSE for memory pools.  Memory pools
   39249             : // support the most condensed usage of memory within the construction of
   39250             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   39251             : // by a new operator written for each class.
   39252             : 
   39253             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   39254             :     // User wants multi-thread support and POSIX threads are available.
   39255             : #   include <pthread.h>
   39256             :     static pthread_mutex_t SgOmpUntiedClause_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   39257             : #else
   39258             :      // Cause synchronization to be skipped.
   39259             : #    ifndef ALLOC_MUTEX
   39260             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   39261             : #    endif
   39262             : #    ifdef _REENTRANT
   39263             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   39264             : #       ifdef _MSC_VER
   39265             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   39266             : #       else
   39267             : #           warning "POSIX threads are not available; synchronization being skipped"
   39268             : #       endif
   39269             : #    endif
   39270             : #endif
   39271             : 
   39272             : #ifndef ROSE_ALLOC_TRACE
   39273             : #  define ROSE_ALLOC_TRACE 0
   39274             : #endif
   39275             : 
   39276             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   39277             : #define ROSE_ALLOC_TRACE_CNT
   39278             : #include "memory-pool-snapshot.h"
   39279             : unsigned long alloc_trace_cnt = 0;
   39280             : #endif
   39281             : 
   39282             : #if ROSE_ALLOC_TRACE
   39283             : const unsigned SgOmpUntiedClause::pool_size = 5;
   39284             : #else
   39285             : const unsigned SgOmpUntiedClause::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   39286             : #endif
   39287             : 
   39288             : #ifndef ROSE_ALLOC_MEMSET
   39289             : #  define ROSE_ALLOC_MEMSET 0
   39290             : #endif
   39291             : 
   39292             : #ifndef ROSE_PEDANTIC_ALLOC
   39293             : #  define ROSE_PEDANTIC_ALLOC 0
   39294             : #endif
   39295             : 
   39296             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   39297             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   39298             : #endif
   39299             : 
   39300             : #if !defined(SGNODE__ALL_POOLS)
   39301             : #define SGNODE__ALL_POOLS
   39302             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   39303             : #endif
   39304             : 
   39305             : SgOmpUntiedClause* SgOmpUntiedClause::next_node = nullptr;
   39306             : std::vector<unsigned char*> SgOmpUntiedClause::pools;
   39307             : 
   39308             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   39309             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   39310             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   39311             : // around this macro definition rather than each use).
   39312             : #ifndef ALLOC_MUTEX
   39313             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   39314             :         do {                                                                     \
   39315             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   39316             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   39317             :                 abort();                                                         \
   39318             :             }                                                                    \
   39319             :         } while (0);
   39320             : #endif
   39321             : 
   39322             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   39323             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   39324             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   39325             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   39326             : 
   39327             : /*! \brief New operator for SgOmpUntiedClause.
   39328             : 
   39329             :    This new operator implements memory pools to provide most efficent 
   39330             :    use of the heap within construction of large ASTs.
   39331             : 
   39332             : \internal The new and delete operators use the lower level C malloc/free
   39333             :    function calls for performance and to make sure that mixing of malloc/free
   39334             :    and new/delete by the used can be caught more readily.  This may change
   39335             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   39336             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   39337             :    deallocate memory allocated using ROSE_MALLOC.
   39338             : */
   39339           5 : void *SgOmpUntiedClause::operator new ( size_t Size )
   39340             : {
   39341             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   39342             :      * returning or throwing an exception. */
   39343           5 :     ALLOC_MUTEX(SgOmpUntiedClause, lock);
   39344             : 
   39345             : #if ROSE_ALLOC_TRACE == 2
   39346             : //    printf("SgOmpUntiedClause::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgOmpUntiedClause::next_node);
   39347             : #endif
   39348             : 
   39349             : #if USE_CPP_NEW_DELETE_OPERATORS
   39350             :     void *mem = ROSE_MALLOC(Size);
   39351             :     ALLOC_MUTEX(SgOmpUntiedClause, unlock);
   39352             :     return mem;
   39353             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   39354             : #if ROSE_PEDANTIC_ALLOC
   39355             :     ROSE_ASSERT(Size == sizeof(SgOmpUntiedClause));
   39356             : #else
   39357           5 :     if (Size != sizeof(SgOmpUntiedClause)) {
   39358           0 :       void * object = ROSE_MALLOC(Size);
   39359           0 :       ALLOC_MUTEX(SgOmpUntiedClause, unlock);
   39360             :       return object;
   39361             :     }
   39362             : #endif
   39363             : 
   39364           5 :     if (SgOmpUntiedClause::next_node == nullptr) {
   39365           5 :         SgOmpUntiedClause * alloc = (SgOmpUntiedClause*) ROSE_MALLOC ( SgOmpUntiedClause::pool_size * sizeof(SgOmpUntiedClause) );
   39366           5 :         ROSE_ASSERT(alloc != nullptr);
   39367             : 
   39368             : #if ROSE_ALLOC_TRACE == 2
   39369             : //        printf("SgOmpUntiedClause::alloc\n  block[%zi] = [ %p , %p [\n", SgOmpUntiedClause::pools.size(), alloc, alloc + SgOmpUntiedClause::pool_size);
   39370             : #endif
   39371             : 
   39372             : #if ROSE_ALLOC_MEMSET == 1
   39373             : #elif ROSE_ALLOC_MEMSET == 2
   39374             :         memset(alloc, 0x00, SgOmpUntiedClause::pool_size * sizeof(SgOmpUntiedClause));
   39375             : #elif ROSE_ALLOC_MEMSET == 3
   39376             :         memset(alloc, 0xAA, SgOmpUntiedClause::pool_size * sizeof(SgOmpUntiedClause));
   39377             : #endif
   39378       10000 :         for (unsigned i=0; i < SgOmpUntiedClause::pool_size-1; i++) {
   39379        9995 :           alloc[i].p_freepointer = &(alloc[i+1]);
   39380             :         }
   39381           5 :         alloc[SgOmpUntiedClause::pool_size-1].p_freepointer = nullptr;
   39382             : 
   39383           5 :         SgOmpUntiedClause::pools.push_back ( (unsigned char *) alloc );
   39384           5 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgOmpUntiedClause::pool_size * sizeof(SgOmpUntiedClause), V_SgOmpUntiedClause ) );
   39385           5 :         SgOmpUntiedClause::next_node = alloc;
   39386             :     }
   39387           5 :     ROSE_ASSERT(SgOmpUntiedClause::next_node != nullptr);
   39388             : 
   39389           5 :     SgOmpUntiedClause * object = SgOmpUntiedClause::next_node;
   39390           5 :     SgOmpUntiedClause::next_node = (SgOmpUntiedClause*)(object->p_freepointer);
   39391             : 
   39392             : #if ROSE_ALLOC_TRACE == 2
   39393             :     printf("SgOmpUntiedClause::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpUntiedClause::next_node);
   39394             : #endif
   39395             : 
   39396           5 :     SgNode * fp = object->p_freepointer;
   39397             : #if ROSE_ALLOC_MEMSET == 1
   39398             : #elif ROSE_ALLOC_MEMSET == 2
   39399             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpUntiedClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   39400             : #elif ROSE_ALLOC_MEMSET == 3
   39401             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgOmpUntiedClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   39402             : #endif
   39403           5 :     object->p_freepointer = fp;
   39404             : 
   39405             : #if ROSE_ALLOC_TRACE == 2
   39406             : //    printf("SgOmpUntiedClause::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpUntiedClause::next_node);
   39407             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   39408             :     Rose::MemPool::snapshot(oss.str());
   39409             :     alloc_trace_cnt++;
   39410             : #endif
   39411             : 
   39412           5 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   39413             : 
   39414           5 :     ALLOC_MUTEX(SgOmpUntiedClause, unlock);
   39415             : 
   39416             :     return object;
   39417             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   39418             : }
   39419             : 
   39420             : 
   39421             : 
   39422             : /*! \brief Delete operator for SgOmpUntiedClause.
   39423             : 
   39424             :    This delete operator implements deallocation using memory pools to 
   39425             :    provide most efficent use of the heap within construction of large ASTs.
   39426             : 
   39427             : \internal The new and delete operators use the lower level C malloc/free
   39428             :    function calls for performance and to make sure that mixing of malloc/free
   39429             :    and new/delete by the used can be caught more readily.  This may change
   39430             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   39431             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   39432             :    deallocate memory allocated using ROSE_MALLOC.
   39433             : */
   39434           0 : void SgOmpUntiedClause::operator delete(void *Pointer, size_t Size)
   39435             : {
   39436             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   39437             :      * or throwing an exception. */
   39438           0 :     ALLOC_MUTEX(SgOmpUntiedClause, lock);
   39439             : 
   39440             : #if USE_CPP_NEW_DELETE_OPERATORS
   39441             :     ROSE_FREE(Pointer);
   39442             : #else
   39443             : #if ROSE_PEDANTIC_ALLOC
   39444             :     ROSE_ASSERT(Size == sizeof(SgOmpUntiedClause));
   39445             : #else
   39446           0 :     if (Size != sizeof(SgOmpUntiedClause)) {
   39447           0 :       ROSE_FREE(Pointer);
   39448           0 :       ALLOC_MUTEX(SgOmpUntiedClause, unlock);
   39449             :       return;
   39450             :     }
   39451             : #endif
   39452             : 
   39453           0 :     SgOmpUntiedClause * object = (SgOmpUntiedClause*) Pointer;
   39454           0 :     ROSE_ASSERT(object != nullptr);
   39455             : 
   39456             : #if ROSE_ALLOC_TRACE == 2
   39457             : //  printf("SgOmpUntiedClause::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpUntiedClause::next_node);
   39458             :     printf("SgOmpUntiedClause::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpUntiedClause::next_node);
   39459             : #endif
   39460             : 
   39461             : #if ROSE_PEDANTIC_ALLOC
   39462             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   39463             : #endif
   39464             : 
   39465             : #if ROSE_ALLOC_MEMSET == 1
   39466             : #elif ROSE_ALLOC_MEMSET == 2
   39467             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpUntiedClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   39468             : #elif ROSE_ALLOC_MEMSET == 3
   39469             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgOmpUntiedClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   39470             : #endif
   39471             : 
   39472             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   39473             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   39474             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   39475             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   39476             : #else
   39477           0 :     object->p_freepointer = SgOmpUntiedClause::next_node;
   39478           0 :     SgOmpUntiedClause::next_node = object;
   39479             : #endif
   39480             : 
   39481             : #if ROSE_ALLOC_TRACE == 2
   39482             : //  printf("SgOmpUntiedClause::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpUntiedClause::next_node);
   39483             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   39484             :     Rose::MemPool::snapshot(oss.str());
   39485             :     alloc_trace_cnt++;
   39486             : #endif
   39487             : 
   39488             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   39489             : 
   39490           0 :     ALLOC_MUTEX(SgOmpUntiedClause, unlock);
   39491             : }
   39492             : 
   39493             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   39494             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   39495             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   39496             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   39497             : // Also, note comment below from Robb (copied from the Common.code file).
   39498             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   39499             : //
   39500             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   39501             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   39502             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   39503             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   39504             : #if 0
   39505             : void SgOmpUntiedClause::operator delete(void* pointer) { SgOmpUntiedClause::operator delete (pointer, sizeof(SgOmpUntiedClause)); };
   39506             : #endif
   39507             : /* #line 39508 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   39508             : 
   39509             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   39510             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   39511             : // obviously imply C++.
   39512             : 
   39513             : // This implements the support within ROSE for memory pools.  Memory pools
   39514             : // support the most condensed usage of memory within the construction of
   39515             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   39516             : // by a new operator written for each class.
   39517             : 
   39518             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   39519             :     // User wants multi-thread support and POSIX threads are available.
   39520             : #   include <pthread.h>
   39521             :     static pthread_mutex_t SgOmpSeqCstClause_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   39522             : #else
   39523             :      // Cause synchronization to be skipped.
   39524             : #    ifndef ALLOC_MUTEX
   39525             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   39526             : #    endif
   39527             : #    ifdef _REENTRANT
   39528             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   39529             : #       ifdef _MSC_VER
   39530             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   39531             : #       else
   39532             : #           warning "POSIX threads are not available; synchronization being skipped"
   39533             : #       endif
   39534             : #    endif
   39535             : #endif
   39536             : 
   39537             : #ifndef ROSE_ALLOC_TRACE
   39538             : #  define ROSE_ALLOC_TRACE 0
   39539             : #endif
   39540             : 
   39541             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   39542             : #define ROSE_ALLOC_TRACE_CNT
   39543             : #include "memory-pool-snapshot.h"
   39544             : unsigned long alloc_trace_cnt = 0;
   39545             : #endif
   39546             : 
   39547             : #if ROSE_ALLOC_TRACE
   39548             : const unsigned SgOmpSeqCstClause::pool_size = 5;
   39549             : #else
   39550             : const unsigned SgOmpSeqCstClause::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   39551             : #endif
   39552             : 
   39553             : #ifndef ROSE_ALLOC_MEMSET
   39554             : #  define ROSE_ALLOC_MEMSET 0
   39555             : #endif
   39556             : 
   39557             : #ifndef ROSE_PEDANTIC_ALLOC
   39558             : #  define ROSE_PEDANTIC_ALLOC 0
   39559             : #endif
   39560             : 
   39561             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   39562             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   39563             : #endif
   39564             : 
   39565             : #if !defined(SGNODE__ALL_POOLS)
   39566             : #define SGNODE__ALL_POOLS
   39567             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   39568             : #endif
   39569             : 
   39570             : SgOmpSeqCstClause* SgOmpSeqCstClause::next_node = nullptr;
   39571             : std::vector<unsigned char*> SgOmpSeqCstClause::pools;
   39572             : 
   39573             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   39574             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   39575             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   39576             : // around this macro definition rather than each use).
   39577             : #ifndef ALLOC_MUTEX
   39578             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   39579             :         do {                                                                     \
   39580             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   39581             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   39582             :                 abort();                                                         \
   39583             :             }                                                                    \
   39584             :         } while (0);
   39585             : #endif
   39586             : 
   39587             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   39588             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   39589             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   39590             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   39591             : 
   39592             : /*! \brief New operator for SgOmpSeqCstClause.
   39593             : 
   39594             :    This new operator implements memory pools to provide most efficent 
   39595             :    use of the heap within construction of large ASTs.
   39596             : 
   39597             : \internal The new and delete operators use the lower level C malloc/free
   39598             :    function calls for performance and to make sure that mixing of malloc/free
   39599             :    and new/delete by the used can be caught more readily.  This may change
   39600             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   39601             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   39602             :    deallocate memory allocated using ROSE_MALLOC.
   39603             : */
   39604           0 : void *SgOmpSeqCstClause::operator new ( size_t Size )
   39605             : {
   39606             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   39607             :      * returning or throwing an exception. */
   39608           0 :     ALLOC_MUTEX(SgOmpSeqCstClause, lock);
   39609             : 
   39610             : #if ROSE_ALLOC_TRACE == 2
   39611             : //    printf("SgOmpSeqCstClause::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgOmpSeqCstClause::next_node);
   39612             : #endif
   39613             : 
   39614             : #if USE_CPP_NEW_DELETE_OPERATORS
   39615             :     void *mem = ROSE_MALLOC(Size);
   39616             :     ALLOC_MUTEX(SgOmpSeqCstClause, unlock);
   39617             :     return mem;
   39618             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   39619             : #if ROSE_PEDANTIC_ALLOC
   39620             :     ROSE_ASSERT(Size == sizeof(SgOmpSeqCstClause));
   39621             : #else
   39622           0 :     if (Size != sizeof(SgOmpSeqCstClause)) {
   39623           0 :       void * object = ROSE_MALLOC(Size);
   39624           0 :       ALLOC_MUTEX(SgOmpSeqCstClause, unlock);
   39625             :       return object;
   39626             :     }
   39627             : #endif
   39628             : 
   39629           0 :     if (SgOmpSeqCstClause::next_node == nullptr) {
   39630           0 :         SgOmpSeqCstClause * alloc = (SgOmpSeqCstClause*) ROSE_MALLOC ( SgOmpSeqCstClause::pool_size * sizeof(SgOmpSeqCstClause) );
   39631           0 :         ROSE_ASSERT(alloc != nullptr);
   39632             : 
   39633             : #if ROSE_ALLOC_TRACE == 2
   39634             : //        printf("SgOmpSeqCstClause::alloc\n  block[%zi] = [ %p , %p [\n", SgOmpSeqCstClause::pools.size(), alloc, alloc + SgOmpSeqCstClause::pool_size);
   39635             : #endif
   39636             : 
   39637             : #if ROSE_ALLOC_MEMSET == 1
   39638             : #elif ROSE_ALLOC_MEMSET == 2
   39639             :         memset(alloc, 0x00, SgOmpSeqCstClause::pool_size * sizeof(SgOmpSeqCstClause));
   39640             : #elif ROSE_ALLOC_MEMSET == 3
   39641             :         memset(alloc, 0xAA, SgOmpSeqCstClause::pool_size * sizeof(SgOmpSeqCstClause));
   39642             : #endif
   39643           0 :         for (unsigned i=0; i < SgOmpSeqCstClause::pool_size-1; i++) {
   39644           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
   39645             :         }
   39646           0 :         alloc[SgOmpSeqCstClause::pool_size-1].p_freepointer = nullptr;
   39647             : 
   39648           0 :         SgOmpSeqCstClause::pools.push_back ( (unsigned char *) alloc );
   39649           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgOmpSeqCstClause::pool_size * sizeof(SgOmpSeqCstClause), V_SgOmpSeqCstClause ) );
   39650           0 :         SgOmpSeqCstClause::next_node = alloc;
   39651             :     }
   39652           0 :     ROSE_ASSERT(SgOmpSeqCstClause::next_node != nullptr);
   39653             : 
   39654           0 :     SgOmpSeqCstClause * object = SgOmpSeqCstClause::next_node;
   39655           0 :     SgOmpSeqCstClause::next_node = (SgOmpSeqCstClause*)(object->p_freepointer);
   39656             : 
   39657             : #if ROSE_ALLOC_TRACE == 2
   39658             :     printf("SgOmpSeqCstClause::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpSeqCstClause::next_node);
   39659             : #endif
   39660             : 
   39661           0 :     SgNode * fp = object->p_freepointer;
   39662             : #if ROSE_ALLOC_MEMSET == 1
   39663             : #elif ROSE_ALLOC_MEMSET == 2
   39664             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpSeqCstClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   39665             : #elif ROSE_ALLOC_MEMSET == 3
   39666             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgOmpSeqCstClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   39667             : #endif
   39668           0 :     object->p_freepointer = fp;
   39669             : 
   39670             : #if ROSE_ALLOC_TRACE == 2
   39671             : //    printf("SgOmpSeqCstClause::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpSeqCstClause::next_node);
   39672             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   39673             :     Rose::MemPool::snapshot(oss.str());
   39674             :     alloc_trace_cnt++;
   39675             : #endif
   39676             : 
   39677           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   39678             : 
   39679           0 :     ALLOC_MUTEX(SgOmpSeqCstClause, unlock);
   39680             : 
   39681             :     return object;
   39682             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   39683             : }
   39684             : 
   39685             : 
   39686             : 
   39687             : /*! \brief Delete operator for SgOmpSeqCstClause.
   39688             : 
   39689             :    This delete operator implements deallocation using memory pools to 
   39690             :    provide most efficent use of the heap within construction of large ASTs.
   39691             : 
   39692             : \internal The new and delete operators use the lower level C malloc/free
   39693             :    function calls for performance and to make sure that mixing of malloc/free
   39694             :    and new/delete by the used can be caught more readily.  This may change
   39695             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   39696             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   39697             :    deallocate memory allocated using ROSE_MALLOC.
   39698             : */
   39699           0 : void SgOmpSeqCstClause::operator delete(void *Pointer, size_t Size)
   39700             : {
   39701             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   39702             :      * or throwing an exception. */
   39703           0 :     ALLOC_MUTEX(SgOmpSeqCstClause, lock);
   39704             : 
   39705             : #if USE_CPP_NEW_DELETE_OPERATORS
   39706             :     ROSE_FREE(Pointer);
   39707             : #else
   39708             : #if ROSE_PEDANTIC_ALLOC
   39709             :     ROSE_ASSERT(Size == sizeof(SgOmpSeqCstClause));
   39710             : #else
   39711           0 :     if (Size != sizeof(SgOmpSeqCstClause)) {
   39712           0 :       ROSE_FREE(Pointer);
   39713           0 :       ALLOC_MUTEX(SgOmpSeqCstClause, unlock);
   39714             :       return;
   39715             :     }
   39716             : #endif
   39717             : 
   39718           0 :     SgOmpSeqCstClause * object = (SgOmpSeqCstClause*) Pointer;
   39719           0 :     ROSE_ASSERT(object != nullptr);
   39720             : 
   39721             : #if ROSE_ALLOC_TRACE == 2
   39722             : //  printf("SgOmpSeqCstClause::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpSeqCstClause::next_node);
   39723             :     printf("SgOmpSeqCstClause::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpSeqCstClause::next_node);
   39724             : #endif
   39725             : 
   39726             : #if ROSE_PEDANTIC_ALLOC
   39727             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   39728             : #endif
   39729             : 
   39730             : #if ROSE_ALLOC_MEMSET == 1
   39731             : #elif ROSE_ALLOC_MEMSET == 2
   39732             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpSeqCstClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   39733             : #elif ROSE_ALLOC_MEMSET == 3
   39734             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgOmpSeqCstClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   39735             : #endif
   39736             : 
   39737             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   39738             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   39739             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   39740             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   39741             : #else
   39742           0 :     object->p_freepointer = SgOmpSeqCstClause::next_node;
   39743           0 :     SgOmpSeqCstClause::next_node = object;
   39744             : #endif
   39745             : 
   39746             : #if ROSE_ALLOC_TRACE == 2
   39747             : //  printf("SgOmpSeqCstClause::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpSeqCstClause::next_node);
   39748             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   39749             :     Rose::MemPool::snapshot(oss.str());
   39750             :     alloc_trace_cnt++;
   39751             : #endif
   39752             : 
   39753             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   39754             : 
   39755           0 :     ALLOC_MUTEX(SgOmpSeqCstClause, unlock);
   39756             : }
   39757             : 
   39758             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   39759             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   39760             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   39761             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   39762             : // Also, note comment below from Robb (copied from the Common.code file).
   39763             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   39764             : //
   39765             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   39766             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   39767             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   39768             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   39769             : #if 0
   39770             : void SgOmpSeqCstClause::operator delete(void* pointer) { SgOmpSeqCstClause::operator delete (pointer, sizeof(SgOmpSeqCstClause)); };
   39771             : #endif
   39772             : /* #line 39773 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   39773             : 
   39774             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   39775             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   39776             : // obviously imply C++.
   39777             : 
   39778             : // This implements the support within ROSE for memory pools.  Memory pools
   39779             : // support the most condensed usage of memory within the construction of
   39780             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   39781             : // by a new operator written for each class.
   39782             : 
   39783             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   39784             :     // User wants multi-thread support and POSIX threads are available.
   39785             : #   include <pthread.h>
   39786             :     static pthread_mutex_t SgOmpAcqRelClause_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   39787             : #else
   39788             :      // Cause synchronization to be skipped.
   39789             : #    ifndef ALLOC_MUTEX
   39790             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   39791             : #    endif
   39792             : #    ifdef _REENTRANT
   39793             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   39794             : #       ifdef _MSC_VER
   39795             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   39796             : #       else
   39797             : #           warning "POSIX threads are not available; synchronization being skipped"
   39798             : #       endif
   39799             : #    endif
   39800             : #endif
   39801             : 
   39802             : #ifndef ROSE_ALLOC_TRACE
   39803             : #  define ROSE_ALLOC_TRACE 0
   39804             : #endif
   39805             : 
   39806             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   39807             : #define ROSE_ALLOC_TRACE_CNT
   39808             : #include "memory-pool-snapshot.h"
   39809             : unsigned long alloc_trace_cnt = 0;
   39810             : #endif
   39811             : 
   39812             : #if ROSE_ALLOC_TRACE
   39813             : const unsigned SgOmpAcqRelClause::pool_size = 5;
   39814             : #else
   39815             : const unsigned SgOmpAcqRelClause::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   39816             : #endif
   39817             : 
   39818             : #ifndef ROSE_ALLOC_MEMSET
   39819             : #  define ROSE_ALLOC_MEMSET 0
   39820             : #endif
   39821             : 
   39822             : #ifndef ROSE_PEDANTIC_ALLOC
   39823             : #  define ROSE_PEDANTIC_ALLOC 0
   39824             : #endif
   39825             : 
   39826             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   39827             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   39828             : #endif
   39829             : 
   39830             : #if !defined(SGNODE__ALL_POOLS)
   39831             : #define SGNODE__ALL_POOLS
   39832             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   39833             : #endif
   39834             : 
   39835             : SgOmpAcqRelClause* SgOmpAcqRelClause::next_node = nullptr;
   39836             : std::vector<unsigned char*> SgOmpAcqRelClause::pools;
   39837             : 
   39838             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   39839             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   39840             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   39841             : // around this macro definition rather than each use).
   39842             : #ifndef ALLOC_MUTEX
   39843             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   39844             :         do {                                                                     \
   39845             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   39846             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   39847             :                 abort();                                                         \
   39848             :             }                                                                    \
   39849             :         } while (0);
   39850             : #endif
   39851             : 
   39852             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   39853             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   39854             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   39855             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   39856             : 
   39857             : /*! \brief New operator for SgOmpAcqRelClause.
   39858             : 
   39859             :    This new operator implements memory pools to provide most efficent 
   39860             :    use of the heap within construction of large ASTs.
   39861             : 
   39862             : \internal The new and delete operators use the lower level C malloc/free
   39863             :    function calls for performance and to make sure that mixing of malloc/free
   39864             :    and new/delete by the used can be caught more readily.  This may change
   39865             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   39866             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   39867             :    deallocate memory allocated using ROSE_MALLOC.
   39868             : */
   39869           1 : void *SgOmpAcqRelClause::operator new ( size_t Size )
   39870             : {
   39871             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   39872             :      * returning or throwing an exception. */
   39873           1 :     ALLOC_MUTEX(SgOmpAcqRelClause, lock);
   39874             : 
   39875             : #if ROSE_ALLOC_TRACE == 2
   39876             : //    printf("SgOmpAcqRelClause::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgOmpAcqRelClause::next_node);
   39877             : #endif
   39878             : 
   39879             : #if USE_CPP_NEW_DELETE_OPERATORS
   39880             :     void *mem = ROSE_MALLOC(Size);
   39881             :     ALLOC_MUTEX(SgOmpAcqRelClause, unlock);
   39882             :     return mem;
   39883             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   39884             : #if ROSE_PEDANTIC_ALLOC
   39885             :     ROSE_ASSERT(Size == sizeof(SgOmpAcqRelClause));
   39886             : #else
   39887           1 :     if (Size != sizeof(SgOmpAcqRelClause)) {
   39888           0 :       void * object = ROSE_MALLOC(Size);
   39889           0 :       ALLOC_MUTEX(SgOmpAcqRelClause, unlock);
   39890             :       return object;
   39891             :     }
   39892             : #endif
   39893             : 
   39894           1 :     if (SgOmpAcqRelClause::next_node == nullptr) {
   39895           1 :         SgOmpAcqRelClause * alloc = (SgOmpAcqRelClause*) ROSE_MALLOC ( SgOmpAcqRelClause::pool_size * sizeof(SgOmpAcqRelClause) );
   39896           1 :         ROSE_ASSERT(alloc != nullptr);
   39897             : 
   39898             : #if ROSE_ALLOC_TRACE == 2
   39899             : //        printf("SgOmpAcqRelClause::alloc\n  block[%zi] = [ %p , %p [\n", SgOmpAcqRelClause::pools.size(), alloc, alloc + SgOmpAcqRelClause::pool_size);
   39900             : #endif
   39901             : 
   39902             : #if ROSE_ALLOC_MEMSET == 1
   39903             : #elif ROSE_ALLOC_MEMSET == 2
   39904             :         memset(alloc, 0x00, SgOmpAcqRelClause::pool_size * sizeof(SgOmpAcqRelClause));
   39905             : #elif ROSE_ALLOC_MEMSET == 3
   39906             :         memset(alloc, 0xAA, SgOmpAcqRelClause::pool_size * sizeof(SgOmpAcqRelClause));
   39907             : #endif
   39908        2000 :         for (unsigned i=0; i < SgOmpAcqRelClause::pool_size-1; i++) {
   39909        1999 :           alloc[i].p_freepointer = &(alloc[i+1]);
   39910             :         }
   39911           1 :         alloc[SgOmpAcqRelClause::pool_size-1].p_freepointer = nullptr;
   39912             : 
   39913           1 :         SgOmpAcqRelClause::pools.push_back ( (unsigned char *) alloc );
   39914           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgOmpAcqRelClause::pool_size * sizeof(SgOmpAcqRelClause), V_SgOmpAcqRelClause ) );
   39915           1 :         SgOmpAcqRelClause::next_node = alloc;
   39916             :     }
   39917           1 :     ROSE_ASSERT(SgOmpAcqRelClause::next_node != nullptr);
   39918             : 
   39919           1 :     SgOmpAcqRelClause * object = SgOmpAcqRelClause::next_node;
   39920           1 :     SgOmpAcqRelClause::next_node = (SgOmpAcqRelClause*)(object->p_freepointer);
   39921             : 
   39922             : #if ROSE_ALLOC_TRACE == 2
   39923             :     printf("SgOmpAcqRelClause::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpAcqRelClause::next_node);
   39924             : #endif
   39925             : 
   39926           1 :     SgNode * fp = object->p_freepointer;
   39927             : #if ROSE_ALLOC_MEMSET == 1
   39928             : #elif ROSE_ALLOC_MEMSET == 2
   39929             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpAcqRelClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   39930             : #elif ROSE_ALLOC_MEMSET == 3
   39931             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgOmpAcqRelClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   39932             : #endif
   39933           1 :     object->p_freepointer = fp;
   39934             : 
   39935             : #if ROSE_ALLOC_TRACE == 2
   39936             : //    printf("SgOmpAcqRelClause::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpAcqRelClause::next_node);
   39937             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   39938             :     Rose::MemPool::snapshot(oss.str());
   39939             :     alloc_trace_cnt++;
   39940             : #endif
   39941             : 
   39942           1 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   39943             : 
   39944           1 :     ALLOC_MUTEX(SgOmpAcqRelClause, unlock);
   39945             : 
   39946             :     return object;
   39947             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   39948             : }
   39949             : 
   39950             : 
   39951             : 
   39952             : /*! \brief Delete operator for SgOmpAcqRelClause.
   39953             : 
   39954             :    This delete operator implements deallocation using memory pools to 
   39955             :    provide most efficent use of the heap within construction of large ASTs.
   39956             : 
   39957             : \internal The new and delete operators use the lower level C malloc/free
   39958             :    function calls for performance and to make sure that mixing of malloc/free
   39959             :    and new/delete by the used can be caught more readily.  This may change
   39960             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   39961             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   39962             :    deallocate memory allocated using ROSE_MALLOC.
   39963             : */
   39964           0 : void SgOmpAcqRelClause::operator delete(void *Pointer, size_t Size)
   39965             : {
   39966             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   39967             :      * or throwing an exception. */
   39968           0 :     ALLOC_MUTEX(SgOmpAcqRelClause, lock);
   39969             : 
   39970             : #if USE_CPP_NEW_DELETE_OPERATORS
   39971             :     ROSE_FREE(Pointer);
   39972             : #else
   39973             : #if ROSE_PEDANTIC_ALLOC
   39974             :     ROSE_ASSERT(Size == sizeof(SgOmpAcqRelClause));
   39975             : #else
   39976           0 :     if (Size != sizeof(SgOmpAcqRelClause)) {
   39977           0 :       ROSE_FREE(Pointer);
   39978           0 :       ALLOC_MUTEX(SgOmpAcqRelClause, unlock);
   39979             :       return;
   39980             :     }
   39981             : #endif
   39982             : 
   39983           0 :     SgOmpAcqRelClause * object = (SgOmpAcqRelClause*) Pointer;
   39984           0 :     ROSE_ASSERT(object != nullptr);
   39985             : 
   39986             : #if ROSE_ALLOC_TRACE == 2
   39987             : //  printf("SgOmpAcqRelClause::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpAcqRelClause::next_node);
   39988             :     printf("SgOmpAcqRelClause::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpAcqRelClause::next_node);
   39989             : #endif
   39990             : 
   39991             : #if ROSE_PEDANTIC_ALLOC
   39992             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   39993             : #endif
   39994             : 
   39995             : #if ROSE_ALLOC_MEMSET == 1
   39996             : #elif ROSE_ALLOC_MEMSET == 2
   39997             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpAcqRelClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   39998             : #elif ROSE_ALLOC_MEMSET == 3
   39999             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgOmpAcqRelClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   40000             : #endif
   40001             : 
   40002             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   40003             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   40004             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   40005             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   40006             : #else
   40007           0 :     object->p_freepointer = SgOmpAcqRelClause::next_node;
   40008           0 :     SgOmpAcqRelClause::next_node = object;
   40009             : #endif
   40010             : 
   40011             : #if ROSE_ALLOC_TRACE == 2
   40012             : //  printf("SgOmpAcqRelClause::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpAcqRelClause::next_node);
   40013             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   40014             :     Rose::MemPool::snapshot(oss.str());
   40015             :     alloc_trace_cnt++;
   40016             : #endif
   40017             : 
   40018             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   40019             : 
   40020           0 :     ALLOC_MUTEX(SgOmpAcqRelClause, unlock);
   40021             : }
   40022             : 
   40023             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   40024             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   40025             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   40026             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   40027             : // Also, note comment below from Robb (copied from the Common.code file).
   40028             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   40029             : //
   40030             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   40031             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   40032             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   40033             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   40034             : #if 0
   40035             : void SgOmpAcqRelClause::operator delete(void* pointer) { SgOmpAcqRelClause::operator delete (pointer, sizeof(SgOmpAcqRelClause)); };
   40036             : #endif
   40037             : /* #line 40038 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   40038             : 
   40039             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   40040             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   40041             : // obviously imply C++.
   40042             : 
   40043             : // This implements the support within ROSE for memory pools.  Memory pools
   40044             : // support the most condensed usage of memory within the construction of
   40045             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   40046             : // by a new operator written for each class.
   40047             : 
   40048             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   40049             :     // User wants multi-thread support and POSIX threads are available.
   40050             : #   include <pthread.h>
   40051             :     static pthread_mutex_t SgOmpReleaseClause_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   40052             : #else
   40053             :      // Cause synchronization to be skipped.
   40054             : #    ifndef ALLOC_MUTEX
   40055             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   40056             : #    endif
   40057             : #    ifdef _REENTRANT
   40058             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   40059             : #       ifdef _MSC_VER
   40060             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   40061             : #       else
   40062             : #           warning "POSIX threads are not available; synchronization being skipped"
   40063             : #       endif
   40064             : #    endif
   40065             : #endif
   40066             : 
   40067             : #ifndef ROSE_ALLOC_TRACE
   40068             : #  define ROSE_ALLOC_TRACE 0
   40069             : #endif
   40070             : 
   40071             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   40072             : #define ROSE_ALLOC_TRACE_CNT
   40073             : #include "memory-pool-snapshot.h"
   40074             : unsigned long alloc_trace_cnt = 0;
   40075             : #endif
   40076             : 
   40077             : #if ROSE_ALLOC_TRACE
   40078             : const unsigned SgOmpReleaseClause::pool_size = 5;
   40079             : #else
   40080             : const unsigned SgOmpReleaseClause::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   40081             : #endif
   40082             : 
   40083             : #ifndef ROSE_ALLOC_MEMSET
   40084             : #  define ROSE_ALLOC_MEMSET 0
   40085             : #endif
   40086             : 
   40087             : #ifndef ROSE_PEDANTIC_ALLOC
   40088             : #  define ROSE_PEDANTIC_ALLOC 0
   40089             : #endif
   40090             : 
   40091             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   40092             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   40093             : #endif
   40094             : 
   40095             : #if !defined(SGNODE__ALL_POOLS)
   40096             : #define SGNODE__ALL_POOLS
   40097             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   40098             : #endif
   40099             : 
   40100             : SgOmpReleaseClause* SgOmpReleaseClause::next_node = nullptr;
   40101             : std::vector<unsigned char*> SgOmpReleaseClause::pools;
   40102             : 
   40103             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   40104             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   40105             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   40106             : // around this macro definition rather than each use).
   40107             : #ifndef ALLOC_MUTEX
   40108             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   40109             :         do {                                                                     \
   40110             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   40111             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   40112             :                 abort();                                                         \
   40113             :             }                                                                    \
   40114             :         } while (0);
   40115             : #endif
   40116             : 
   40117             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   40118             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   40119             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   40120             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   40121             : 
   40122             : /*! \brief New operator for SgOmpReleaseClause.
   40123             : 
   40124             :    This new operator implements memory pools to provide most efficent 
   40125             :    use of the heap within construction of large ASTs.
   40126             : 
   40127             : \internal The new and delete operators use the lower level C malloc/free
   40128             :    function calls for performance and to make sure that mixing of malloc/free
   40129             :    and new/delete by the used can be caught more readily.  This may change
   40130             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   40131             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   40132             :    deallocate memory allocated using ROSE_MALLOC.
   40133             : */
   40134           1 : void *SgOmpReleaseClause::operator new ( size_t Size )
   40135             : {
   40136             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   40137             :      * returning or throwing an exception. */
   40138           1 :     ALLOC_MUTEX(SgOmpReleaseClause, lock);
   40139             : 
   40140             : #if ROSE_ALLOC_TRACE == 2
   40141             : //    printf("SgOmpReleaseClause::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgOmpReleaseClause::next_node);
   40142             : #endif
   40143             : 
   40144             : #if USE_CPP_NEW_DELETE_OPERATORS
   40145             :     void *mem = ROSE_MALLOC(Size);
   40146             :     ALLOC_MUTEX(SgOmpReleaseClause, unlock);
   40147             :     return mem;
   40148             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   40149             : #if ROSE_PEDANTIC_ALLOC
   40150             :     ROSE_ASSERT(Size == sizeof(SgOmpReleaseClause));
   40151             : #else
   40152           1 :     if (Size != sizeof(SgOmpReleaseClause)) {
   40153           0 :       void * object = ROSE_MALLOC(Size);
   40154           0 :       ALLOC_MUTEX(SgOmpReleaseClause, unlock);
   40155             :       return object;
   40156             :     }
   40157             : #endif
   40158             : 
   40159           1 :     if (SgOmpReleaseClause::next_node == nullptr) {
   40160           1 :         SgOmpReleaseClause * alloc = (SgOmpReleaseClause*) ROSE_MALLOC ( SgOmpReleaseClause::pool_size * sizeof(SgOmpReleaseClause) );
   40161           1 :         ROSE_ASSERT(alloc != nullptr);
   40162             : 
   40163             : #if ROSE_ALLOC_TRACE == 2
   40164             : //        printf("SgOmpReleaseClause::alloc\n  block[%zi] = [ %p , %p [\n", SgOmpReleaseClause::pools.size(), alloc, alloc + SgOmpReleaseClause::pool_size);
   40165             : #endif
   40166             : 
   40167             : #if ROSE_ALLOC_MEMSET == 1
   40168             : #elif ROSE_ALLOC_MEMSET == 2
   40169             :         memset(alloc, 0x00, SgOmpReleaseClause::pool_size * sizeof(SgOmpReleaseClause));
   40170             : #elif ROSE_ALLOC_MEMSET == 3
   40171             :         memset(alloc, 0xAA, SgOmpReleaseClause::pool_size * sizeof(SgOmpReleaseClause));
   40172             : #endif
   40173        2000 :         for (unsigned i=0; i < SgOmpReleaseClause::pool_size-1; i++) {
   40174        1999 :           alloc[i].p_freepointer = &(alloc[i+1]);
   40175             :         }
   40176           1 :         alloc[SgOmpReleaseClause::pool_size-1].p_freepointer = nullptr;
   40177             : 
   40178           1 :         SgOmpReleaseClause::pools.push_back ( (unsigned char *) alloc );
   40179           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgOmpReleaseClause::pool_size * sizeof(SgOmpReleaseClause), V_SgOmpReleaseClause ) );
   40180           1 :         SgOmpReleaseClause::next_node = alloc;
   40181             :     }
   40182           1 :     ROSE_ASSERT(SgOmpReleaseClause::next_node != nullptr);
   40183             : 
   40184           1 :     SgOmpReleaseClause * object = SgOmpReleaseClause::next_node;
   40185           1 :     SgOmpReleaseClause::next_node = (SgOmpReleaseClause*)(object->p_freepointer);
   40186             : 
   40187             : #if ROSE_ALLOC_TRACE == 2
   40188             :     printf("SgOmpReleaseClause::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpReleaseClause::next_node);
   40189             : #endif
   40190             : 
   40191           1 :     SgNode * fp = object->p_freepointer;
   40192             : #if ROSE_ALLOC_MEMSET == 1
   40193             : #elif ROSE_ALLOC_MEMSET == 2
   40194             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpReleaseClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   40195             : #elif ROSE_ALLOC_MEMSET == 3
   40196             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgOmpReleaseClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   40197             : #endif
   40198           1 :     object->p_freepointer = fp;
   40199             : 
   40200             : #if ROSE_ALLOC_TRACE == 2
   40201             : //    printf("SgOmpReleaseClause::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpReleaseClause::next_node);
   40202             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   40203             :     Rose::MemPool::snapshot(oss.str());
   40204             :     alloc_trace_cnt++;
   40205             : #endif
   40206             : 
   40207           1 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   40208             : 
   40209           1 :     ALLOC_MUTEX(SgOmpReleaseClause, unlock);
   40210             : 
   40211             :     return object;
   40212             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   40213             : }
   40214             : 
   40215             : 
   40216             : 
   40217             : /*! \brief Delete operator for SgOmpReleaseClause.
   40218             : 
   40219             :    This delete operator implements deallocation using memory pools to 
   40220             :    provide most efficent use of the heap within construction of large ASTs.
   40221             : 
   40222             : \internal The new and delete operators use the lower level C malloc/free
   40223             :    function calls for performance and to make sure that mixing of malloc/free
   40224             :    and new/delete by the used can be caught more readily.  This may change
   40225             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   40226             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   40227             :    deallocate memory allocated using ROSE_MALLOC.
   40228             : */
   40229           0 : void SgOmpReleaseClause::operator delete(void *Pointer, size_t Size)
   40230             : {
   40231             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   40232             :      * or throwing an exception. */
   40233           0 :     ALLOC_MUTEX(SgOmpReleaseClause, lock);
   40234             : 
   40235             : #if USE_CPP_NEW_DELETE_OPERATORS
   40236             :     ROSE_FREE(Pointer);
   40237             : #else
   40238             : #if ROSE_PEDANTIC_ALLOC
   40239             :     ROSE_ASSERT(Size == sizeof(SgOmpReleaseClause));
   40240             : #else
   40241           0 :     if (Size != sizeof(SgOmpReleaseClause)) {
   40242           0 :       ROSE_FREE(Pointer);
   40243           0 :       ALLOC_MUTEX(SgOmpReleaseClause, unlock);
   40244             :       return;
   40245             :     }
   40246             : #endif
   40247             : 
   40248           0 :     SgOmpReleaseClause * object = (SgOmpReleaseClause*) Pointer;
   40249           0 :     ROSE_ASSERT(object != nullptr);
   40250             : 
   40251             : #if ROSE_ALLOC_TRACE == 2
   40252             : //  printf("SgOmpReleaseClause::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpReleaseClause::next_node);
   40253             :     printf("SgOmpReleaseClause::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpReleaseClause::next_node);
   40254             : #endif
   40255             : 
   40256             : #if ROSE_PEDANTIC_ALLOC
   40257             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   40258             : #endif
   40259             : 
   40260             : #if ROSE_ALLOC_MEMSET == 1
   40261             : #elif ROSE_ALLOC_MEMSET == 2
   40262             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpReleaseClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   40263             : #elif ROSE_ALLOC_MEMSET == 3
   40264             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgOmpReleaseClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   40265             : #endif
   40266             : 
   40267             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   40268             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   40269             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   40270             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   40271             : #else
   40272           0 :     object->p_freepointer = SgOmpReleaseClause::next_node;
   40273           0 :     SgOmpReleaseClause::next_node = object;
   40274             : #endif
   40275             : 
   40276             : #if ROSE_ALLOC_TRACE == 2
   40277             : //  printf("SgOmpReleaseClause::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpReleaseClause::next_node);
   40278             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   40279             :     Rose::MemPool::snapshot(oss.str());
   40280             :     alloc_trace_cnt++;
   40281             : #endif
   40282             : 
   40283             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   40284             : 
   40285           0 :     ALLOC_MUTEX(SgOmpReleaseClause, unlock);
   40286             : }
   40287             : 
   40288             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   40289             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   40290             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   40291             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   40292             : // Also, note comment below from Robb (copied from the Common.code file).
   40293             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   40294             : //
   40295             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   40296             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   40297             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   40298             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   40299             : #if 0
   40300             : void SgOmpReleaseClause::operator delete(void* pointer) { SgOmpReleaseClause::operator delete (pointer, sizeof(SgOmpReleaseClause)); };
   40301             : #endif
   40302             : /* #line 40303 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   40303             : 
   40304             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   40305             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   40306             : // obviously imply C++.
   40307             : 
   40308             : // This implements the support within ROSE for memory pools.  Memory pools
   40309             : // support the most condensed usage of memory within the construction of
   40310             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   40311             : // by a new operator written for each class.
   40312             : 
   40313             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   40314             :     // User wants multi-thread support and POSIX threads are available.
   40315             : #   include <pthread.h>
   40316             :     static pthread_mutex_t SgOmpAcquireClause_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   40317             : #else
   40318             :      // Cause synchronization to be skipped.
   40319             : #    ifndef ALLOC_MUTEX
   40320             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   40321             : #    endif
   40322             : #    ifdef _REENTRANT
   40323             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   40324             : #       ifdef _MSC_VER
   40325             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   40326             : #       else
   40327             : #           warning "POSIX threads are not available; synchronization being skipped"
   40328             : #       endif
   40329             : #    endif
   40330             : #endif
   40331             : 
   40332             : #ifndef ROSE_ALLOC_TRACE
   40333             : #  define ROSE_ALLOC_TRACE 0
   40334             : #endif
   40335             : 
   40336             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   40337             : #define ROSE_ALLOC_TRACE_CNT
   40338             : #include "memory-pool-snapshot.h"
   40339             : unsigned long alloc_trace_cnt = 0;
   40340             : #endif
   40341             : 
   40342             : #if ROSE_ALLOC_TRACE
   40343             : const unsigned SgOmpAcquireClause::pool_size = 5;
   40344             : #else
   40345             : const unsigned SgOmpAcquireClause::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   40346             : #endif
   40347             : 
   40348             : #ifndef ROSE_ALLOC_MEMSET
   40349             : #  define ROSE_ALLOC_MEMSET 0
   40350             : #endif
   40351             : 
   40352             : #ifndef ROSE_PEDANTIC_ALLOC
   40353             : #  define ROSE_PEDANTIC_ALLOC 0
   40354             : #endif
   40355             : 
   40356             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   40357             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   40358             : #endif
   40359             : 
   40360             : #if !defined(SGNODE__ALL_POOLS)
   40361             : #define SGNODE__ALL_POOLS
   40362             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   40363             : #endif
   40364             : 
   40365             : SgOmpAcquireClause* SgOmpAcquireClause::next_node = nullptr;
   40366             : std::vector<unsigned char*> SgOmpAcquireClause::pools;
   40367             : 
   40368             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   40369             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   40370             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   40371             : // around this macro definition rather than each use).
   40372             : #ifndef ALLOC_MUTEX
   40373             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   40374             :         do {                                                                     \
   40375             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   40376             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   40377             :                 abort();                                                         \
   40378             :             }                                                                    \
   40379             :         } while (0);
   40380             : #endif
   40381             : 
   40382             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   40383             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   40384             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   40385             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   40386             : 
   40387             : /*! \brief New operator for SgOmpAcquireClause.
   40388             : 
   40389             :    This new operator implements memory pools to provide most efficent 
   40390             :    use of the heap within construction of large ASTs.
   40391             : 
   40392             : \internal The new and delete operators use the lower level C malloc/free
   40393             :    function calls for performance and to make sure that mixing of malloc/free
   40394             :    and new/delete by the used can be caught more readily.  This may change
   40395             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   40396             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   40397             :    deallocate memory allocated using ROSE_MALLOC.
   40398             : */
   40399           0 : void *SgOmpAcquireClause::operator new ( size_t Size )
   40400             : {
   40401             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   40402             :      * returning or throwing an exception. */
   40403           0 :     ALLOC_MUTEX(SgOmpAcquireClause, lock);
   40404             : 
   40405             : #if ROSE_ALLOC_TRACE == 2
   40406             : //    printf("SgOmpAcquireClause::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgOmpAcquireClause::next_node);
   40407             : #endif
   40408             : 
   40409             : #if USE_CPP_NEW_DELETE_OPERATORS
   40410             :     void *mem = ROSE_MALLOC(Size);
   40411             :     ALLOC_MUTEX(SgOmpAcquireClause, unlock);
   40412             :     return mem;
   40413             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   40414             : #if ROSE_PEDANTIC_ALLOC
   40415             :     ROSE_ASSERT(Size == sizeof(SgOmpAcquireClause));
   40416             : #else
   40417           0 :     if (Size != sizeof(SgOmpAcquireClause)) {
   40418           0 :       void * object = ROSE_MALLOC(Size);
   40419           0 :       ALLOC_MUTEX(SgOmpAcquireClause, unlock);
   40420             :       return object;
   40421             :     }
   40422             : #endif
   40423             : 
   40424           0 :     if (SgOmpAcquireClause::next_node == nullptr) {
   40425           0 :         SgOmpAcquireClause * alloc = (SgOmpAcquireClause*) ROSE_MALLOC ( SgOmpAcquireClause::pool_size * sizeof(SgOmpAcquireClause) );
   40426           0 :         ROSE_ASSERT(alloc != nullptr);
   40427             : 
   40428             : #if ROSE_ALLOC_TRACE == 2
   40429             : //        printf("SgOmpAcquireClause::alloc\n  block[%zi] = [ %p , %p [\n", SgOmpAcquireClause::pools.size(), alloc, alloc + SgOmpAcquireClause::pool_size);
   40430             : #endif
   40431             : 
   40432             : #if ROSE_ALLOC_MEMSET == 1
   40433             : #elif ROSE_ALLOC_MEMSET == 2
   40434             :         memset(alloc, 0x00, SgOmpAcquireClause::pool_size * sizeof(SgOmpAcquireClause));
   40435             : #elif ROSE_ALLOC_MEMSET == 3
   40436             :         memset(alloc, 0xAA, SgOmpAcquireClause::pool_size * sizeof(SgOmpAcquireClause));
   40437             : #endif
   40438           0 :         for (unsigned i=0; i < SgOmpAcquireClause::pool_size-1; i++) {
   40439           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
   40440             :         }
   40441           0 :         alloc[SgOmpAcquireClause::pool_size-1].p_freepointer = nullptr;
   40442             : 
   40443           0 :         SgOmpAcquireClause::pools.push_back ( (unsigned char *) alloc );
   40444           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgOmpAcquireClause::pool_size * sizeof(SgOmpAcquireClause), V_SgOmpAcquireClause ) );
   40445           0 :         SgOmpAcquireClause::next_node = alloc;
   40446             :     }
   40447           0 :     ROSE_ASSERT(SgOmpAcquireClause::next_node != nullptr);
   40448             : 
   40449           0 :     SgOmpAcquireClause * object = SgOmpAcquireClause::next_node;
   40450           0 :     SgOmpAcquireClause::next_node = (SgOmpAcquireClause*)(object->p_freepointer);
   40451             : 
   40452             : #if ROSE_ALLOC_TRACE == 2
   40453             :     printf("SgOmpAcquireClause::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpAcquireClause::next_node);
   40454             : #endif
   40455             : 
   40456           0 :     SgNode * fp = object->p_freepointer;
   40457             : #if ROSE_ALLOC_MEMSET == 1
   40458             : #elif ROSE_ALLOC_MEMSET == 2
   40459             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpAcquireClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   40460             : #elif ROSE_ALLOC_MEMSET == 3
   40461             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgOmpAcquireClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   40462             : #endif
   40463           0 :     object->p_freepointer = fp;
   40464             : 
   40465             : #if ROSE_ALLOC_TRACE == 2
   40466             : //    printf("SgOmpAcquireClause::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpAcquireClause::next_node);
   40467             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   40468             :     Rose::MemPool::snapshot(oss.str());
   40469             :     alloc_trace_cnt++;
   40470             : #endif
   40471             : 
   40472           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   40473             : 
   40474           0 :     ALLOC_MUTEX(SgOmpAcquireClause, unlock);
   40475             : 
   40476             :     return object;
   40477             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   40478             : }
   40479             : 
   40480             : 
   40481             : 
   40482             : /*! \brief Delete operator for SgOmpAcquireClause.
   40483             : 
   40484             :    This delete operator implements deallocation using memory pools to 
   40485             :    provide most efficent use of the heap within construction of large ASTs.
   40486             : 
   40487             : \internal The new and delete operators use the lower level C malloc/free
   40488             :    function calls for performance and to make sure that mixing of malloc/free
   40489             :    and new/delete by the used can be caught more readily.  This may change
   40490             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   40491             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   40492             :    deallocate memory allocated using ROSE_MALLOC.
   40493             : */
   40494           0 : void SgOmpAcquireClause::operator delete(void *Pointer, size_t Size)
   40495             : {
   40496             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   40497             :      * or throwing an exception. */
   40498           0 :     ALLOC_MUTEX(SgOmpAcquireClause, lock);
   40499             : 
   40500             : #if USE_CPP_NEW_DELETE_OPERATORS
   40501             :     ROSE_FREE(Pointer);
   40502             : #else
   40503             : #if ROSE_PEDANTIC_ALLOC
   40504             :     ROSE_ASSERT(Size == sizeof(SgOmpAcquireClause));
   40505             : #else
   40506           0 :     if (Size != sizeof(SgOmpAcquireClause)) {
   40507           0 :       ROSE_FREE(Pointer);
   40508           0 :       ALLOC_MUTEX(SgOmpAcquireClause, unlock);
   40509             :       return;
   40510             :     }
   40511             : #endif
   40512             : 
   40513           0 :     SgOmpAcquireClause * object = (SgOmpAcquireClause*) Pointer;
   40514           0 :     ROSE_ASSERT(object != nullptr);
   40515             : 
   40516             : #if ROSE_ALLOC_TRACE == 2
   40517             : //  printf("SgOmpAcquireClause::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpAcquireClause::next_node);
   40518             :     printf("SgOmpAcquireClause::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpAcquireClause::next_node);
   40519             : #endif
   40520             : 
   40521             : #if ROSE_PEDANTIC_ALLOC
   40522             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   40523             : #endif
   40524             : 
   40525             : #if ROSE_ALLOC_MEMSET == 1
   40526             : #elif ROSE_ALLOC_MEMSET == 2
   40527             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpAcquireClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   40528             : #elif ROSE_ALLOC_MEMSET == 3
   40529             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgOmpAcquireClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   40530             : #endif
   40531             : 
   40532             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   40533             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   40534             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   40535             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   40536             : #else
   40537           0 :     object->p_freepointer = SgOmpAcquireClause::next_node;
   40538           0 :     SgOmpAcquireClause::next_node = object;
   40539             : #endif
   40540             : 
   40541             : #if ROSE_ALLOC_TRACE == 2
   40542             : //  printf("SgOmpAcquireClause::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpAcquireClause::next_node);
   40543             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   40544             :     Rose::MemPool::snapshot(oss.str());
   40545             :     alloc_trace_cnt++;
   40546             : #endif
   40547             : 
   40548             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   40549             : 
   40550           0 :     ALLOC_MUTEX(SgOmpAcquireClause, unlock);
   40551             : }
   40552             : 
   40553             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   40554             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   40555             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   40556             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   40557             : // Also, note comment below from Robb (copied from the Common.code file).
   40558             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   40559             : //
   40560             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   40561             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   40562             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   40563             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   40564             : #if 0
   40565             : void SgOmpAcquireClause::operator delete(void* pointer) { SgOmpAcquireClause::operator delete (pointer, sizeof(SgOmpAcquireClause)); };
   40566             : #endif
   40567             : /* #line 40568 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   40568             : 
   40569             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   40570             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   40571             : // obviously imply C++.
   40572             : 
   40573             : // This implements the support within ROSE for memory pools.  Memory pools
   40574             : // support the most condensed usage of memory within the construction of
   40575             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   40576             : // by a new operator written for each class.
   40577             : 
   40578             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   40579             :     // User wants multi-thread support and POSIX threads are available.
   40580             : #   include <pthread.h>
   40581             :     static pthread_mutex_t SgOmpRelaxedClause_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   40582             : #else
   40583             :      // Cause synchronization to be skipped.
   40584             : #    ifndef ALLOC_MUTEX
   40585             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   40586             : #    endif
   40587             : #    ifdef _REENTRANT
   40588             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   40589             : #       ifdef _MSC_VER
   40590             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   40591             : #       else
   40592             : #           warning "POSIX threads are not available; synchronization being skipped"
   40593             : #       endif
   40594             : #    endif
   40595             : #endif
   40596             : 
   40597             : #ifndef ROSE_ALLOC_TRACE
   40598             : #  define ROSE_ALLOC_TRACE 0
   40599             : #endif
   40600             : 
   40601             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   40602             : #define ROSE_ALLOC_TRACE_CNT
   40603             : #include "memory-pool-snapshot.h"
   40604             : unsigned long alloc_trace_cnt = 0;
   40605             : #endif
   40606             : 
   40607             : #if ROSE_ALLOC_TRACE
   40608             : const unsigned SgOmpRelaxedClause::pool_size = 5;
   40609             : #else
   40610             : const unsigned SgOmpRelaxedClause::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   40611             : #endif
   40612             : 
   40613             : #ifndef ROSE_ALLOC_MEMSET
   40614             : #  define ROSE_ALLOC_MEMSET 0
   40615             : #endif
   40616             : 
   40617             : #ifndef ROSE_PEDANTIC_ALLOC
   40618             : #  define ROSE_PEDANTIC_ALLOC 0
   40619             : #endif
   40620             : 
   40621             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   40622             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   40623             : #endif
   40624             : 
   40625             : #if !defined(SGNODE__ALL_POOLS)
   40626             : #define SGNODE__ALL_POOLS
   40627             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   40628             : #endif
   40629             : 
   40630             : SgOmpRelaxedClause* SgOmpRelaxedClause::next_node = nullptr;
   40631             : std::vector<unsigned char*> SgOmpRelaxedClause::pools;
   40632             : 
   40633             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   40634             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   40635             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   40636             : // around this macro definition rather than each use).
   40637             : #ifndef ALLOC_MUTEX
   40638             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   40639             :         do {                                                                     \
   40640             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   40641             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   40642             :                 abort();                                                         \
   40643             :             }                                                                    \
   40644             :         } while (0);
   40645             : #endif
   40646             : 
   40647             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   40648             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   40649             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   40650             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   40651             : 
   40652             : /*! \brief New operator for SgOmpRelaxedClause.
   40653             : 
   40654             :    This new operator implements memory pools to provide most efficent 
   40655             :    use of the heap within construction of large ASTs.
   40656             : 
   40657             : \internal The new and delete operators use the lower level C malloc/free
   40658             :    function calls for performance and to make sure that mixing of malloc/free
   40659             :    and new/delete by the used can be caught more readily.  This may change
   40660             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   40661             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   40662             :    deallocate memory allocated using ROSE_MALLOC.
   40663             : */
   40664           0 : void *SgOmpRelaxedClause::operator new ( size_t Size )
   40665             : {
   40666             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   40667             :      * returning or throwing an exception. */
   40668           0 :     ALLOC_MUTEX(SgOmpRelaxedClause, lock);
   40669             : 
   40670             : #if ROSE_ALLOC_TRACE == 2
   40671             : //    printf("SgOmpRelaxedClause::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgOmpRelaxedClause::next_node);
   40672             : #endif
   40673             : 
   40674             : #if USE_CPP_NEW_DELETE_OPERATORS
   40675             :     void *mem = ROSE_MALLOC(Size);
   40676             :     ALLOC_MUTEX(SgOmpRelaxedClause, unlock);
   40677             :     return mem;
   40678             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   40679             : #if ROSE_PEDANTIC_ALLOC
   40680             :     ROSE_ASSERT(Size == sizeof(SgOmpRelaxedClause));
   40681             : #else
   40682           0 :     if (Size != sizeof(SgOmpRelaxedClause)) {
   40683           0 :       void * object = ROSE_MALLOC(Size);
   40684           0 :       ALLOC_MUTEX(SgOmpRelaxedClause, unlock);
   40685             :       return object;
   40686             :     }
   40687             : #endif
   40688             : 
   40689           0 :     if (SgOmpRelaxedClause::next_node == nullptr) {
   40690           0 :         SgOmpRelaxedClause * alloc = (SgOmpRelaxedClause*) ROSE_MALLOC ( SgOmpRelaxedClause::pool_size * sizeof(SgOmpRelaxedClause) );
   40691           0 :         ROSE_ASSERT(alloc != nullptr);
   40692             : 
   40693             : #if ROSE_ALLOC_TRACE == 2
   40694             : //        printf("SgOmpRelaxedClause::alloc\n  block[%zi] = [ %p , %p [\n", SgOmpRelaxedClause::pools.size(), alloc, alloc + SgOmpRelaxedClause::pool_size);
   40695             : #endif
   40696             : 
   40697             : #if ROSE_ALLOC_MEMSET == 1
   40698             : #elif ROSE_ALLOC_MEMSET == 2
   40699             :         memset(alloc, 0x00, SgOmpRelaxedClause::pool_size * sizeof(SgOmpRelaxedClause));
   40700             : #elif ROSE_ALLOC_MEMSET == 3
   40701             :         memset(alloc, 0xAA, SgOmpRelaxedClause::pool_size * sizeof(SgOmpRelaxedClause));
   40702             : #endif
   40703           0 :         for (unsigned i=0; i < SgOmpRelaxedClause::pool_size-1; i++) {
   40704           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
   40705             :         }
   40706           0 :         alloc[SgOmpRelaxedClause::pool_size-1].p_freepointer = nullptr;
   40707             : 
   40708           0 :         SgOmpRelaxedClause::pools.push_back ( (unsigned char *) alloc );
   40709           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgOmpRelaxedClause::pool_size * sizeof(SgOmpRelaxedClause), V_SgOmpRelaxedClause ) );
   40710           0 :         SgOmpRelaxedClause::next_node = alloc;
   40711             :     }
   40712           0 :     ROSE_ASSERT(SgOmpRelaxedClause::next_node != nullptr);
   40713             : 
   40714           0 :     SgOmpRelaxedClause * object = SgOmpRelaxedClause::next_node;
   40715           0 :     SgOmpRelaxedClause::next_node = (SgOmpRelaxedClause*)(object->p_freepointer);
   40716             : 
   40717             : #if ROSE_ALLOC_TRACE == 2
   40718             :     printf("SgOmpRelaxedClause::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpRelaxedClause::next_node);
   40719             : #endif
   40720             : 
   40721           0 :     SgNode * fp = object->p_freepointer;
   40722             : #if ROSE_ALLOC_MEMSET == 1
   40723             : #elif ROSE_ALLOC_MEMSET == 2
   40724             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpRelaxedClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   40725             : #elif ROSE_ALLOC_MEMSET == 3
   40726             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgOmpRelaxedClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   40727             : #endif
   40728           0 :     object->p_freepointer = fp;
   40729             : 
   40730             : #if ROSE_ALLOC_TRACE == 2
   40731             : //    printf("SgOmpRelaxedClause::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpRelaxedClause::next_node);
   40732             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   40733             :     Rose::MemPool::snapshot(oss.str());
   40734             :     alloc_trace_cnt++;
   40735             : #endif
   40736             : 
   40737           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   40738             : 
   40739           0 :     ALLOC_MUTEX(SgOmpRelaxedClause, unlock);
   40740             : 
   40741             :     return object;
   40742             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   40743             : }
   40744             : 
   40745             : 
   40746             : 
   40747             : /*! \brief Delete operator for SgOmpRelaxedClause.
   40748             : 
   40749             :    This delete operator implements deallocation using memory pools to 
   40750             :    provide most efficent use of the heap within construction of large ASTs.
   40751             : 
   40752             : \internal The new and delete operators use the lower level C malloc/free
   40753             :    function calls for performance and to make sure that mixing of malloc/free
   40754             :    and new/delete by the used can be caught more readily.  This may change
   40755             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   40756             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   40757             :    deallocate memory allocated using ROSE_MALLOC.
   40758             : */
   40759           0 : void SgOmpRelaxedClause::operator delete(void *Pointer, size_t Size)
   40760             : {
   40761             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   40762             :      * or throwing an exception. */
   40763           0 :     ALLOC_MUTEX(SgOmpRelaxedClause, lock);
   40764             : 
   40765             : #if USE_CPP_NEW_DELETE_OPERATORS
   40766             :     ROSE_FREE(Pointer);
   40767             : #else
   40768             : #if ROSE_PEDANTIC_ALLOC
   40769             :     ROSE_ASSERT(Size == sizeof(SgOmpRelaxedClause));
   40770             : #else
   40771           0 :     if (Size != sizeof(SgOmpRelaxedClause)) {
   40772           0 :       ROSE_FREE(Pointer);
   40773           0 :       ALLOC_MUTEX(SgOmpRelaxedClause, unlock);
   40774             :       return;
   40775             :     }
   40776             : #endif
   40777             : 
   40778           0 :     SgOmpRelaxedClause * object = (SgOmpRelaxedClause*) Pointer;
   40779           0 :     ROSE_ASSERT(object != nullptr);
   40780             : 
   40781             : #if ROSE_ALLOC_TRACE == 2
   40782             : //  printf("SgOmpRelaxedClause::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpRelaxedClause::next_node);
   40783             :     printf("SgOmpRelaxedClause::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpRelaxedClause::next_node);
   40784             : #endif
   40785             : 
   40786             : #if ROSE_PEDANTIC_ALLOC
   40787             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   40788             : #endif
   40789             : 
   40790             : #if ROSE_ALLOC_MEMSET == 1
   40791             : #elif ROSE_ALLOC_MEMSET == 2
   40792             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpRelaxedClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   40793             : #elif ROSE_ALLOC_MEMSET == 3
   40794             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgOmpRelaxedClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   40795             : #endif
   40796             : 
   40797             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   40798             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   40799             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   40800             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   40801             : #else
   40802           0 :     object->p_freepointer = SgOmpRelaxedClause::next_node;
   40803           0 :     SgOmpRelaxedClause::next_node = object;
   40804             : #endif
   40805             : 
   40806             : #if ROSE_ALLOC_TRACE == 2
   40807             : //  printf("SgOmpRelaxedClause::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpRelaxedClause::next_node);
   40808             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   40809             :     Rose::MemPool::snapshot(oss.str());
   40810             :     alloc_trace_cnt++;
   40811             : #endif
   40812             : 
   40813             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   40814             : 
   40815           0 :     ALLOC_MUTEX(SgOmpRelaxedClause, unlock);
   40816             : }
   40817             : 
   40818             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   40819             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   40820             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   40821             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   40822             : // Also, note comment below from Robb (copied from the Common.code file).
   40823             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   40824             : //
   40825             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   40826             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   40827             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   40828             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   40829             : #if 0
   40830             : void SgOmpRelaxedClause::operator delete(void* pointer) { SgOmpRelaxedClause::operator delete (pointer, sizeof(SgOmpRelaxedClause)); };
   40831             : #endif
   40832             : /* #line 40833 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   40833             : 
   40834             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   40835             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   40836             : // obviously imply C++.
   40837             : 
   40838             : // This implements the support within ROSE for memory pools.  Memory pools
   40839             : // support the most condensed usage of memory within the construction of
   40840             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   40841             : // by a new operator written for each class.
   40842             : 
   40843             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   40844             :     // User wants multi-thread support and POSIX threads are available.
   40845             : #   include <pthread.h>
   40846             :     static pthread_mutex_t SgOmpReverseOffloadClause_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   40847             : #else
   40848             :      // Cause synchronization to be skipped.
   40849             : #    ifndef ALLOC_MUTEX
   40850             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   40851             : #    endif
   40852             : #    ifdef _REENTRANT
   40853             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   40854             : #       ifdef _MSC_VER
   40855             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   40856             : #       else
   40857             : #           warning "POSIX threads are not available; synchronization being skipped"
   40858             : #       endif
   40859             : #    endif
   40860             : #endif
   40861             : 
   40862             : #ifndef ROSE_ALLOC_TRACE
   40863             : #  define ROSE_ALLOC_TRACE 0
   40864             : #endif
   40865             : 
   40866             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   40867             : #define ROSE_ALLOC_TRACE_CNT
   40868             : #include "memory-pool-snapshot.h"
   40869             : unsigned long alloc_trace_cnt = 0;
   40870             : #endif
   40871             : 
   40872             : #if ROSE_ALLOC_TRACE
   40873             : const unsigned SgOmpReverseOffloadClause::pool_size = 5;
   40874             : #else
   40875             : const unsigned SgOmpReverseOffloadClause::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   40876             : #endif
   40877             : 
   40878             : #ifndef ROSE_ALLOC_MEMSET
   40879             : #  define ROSE_ALLOC_MEMSET 0
   40880             : #endif
   40881             : 
   40882             : #ifndef ROSE_PEDANTIC_ALLOC
   40883             : #  define ROSE_PEDANTIC_ALLOC 0
   40884             : #endif
   40885             : 
   40886             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   40887             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   40888             : #endif
   40889             : 
   40890             : #if !defined(SGNODE__ALL_POOLS)
   40891             : #define SGNODE__ALL_POOLS
   40892             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   40893             : #endif
   40894             : 
   40895             : SgOmpReverseOffloadClause* SgOmpReverseOffloadClause::next_node = nullptr;
   40896             : std::vector<unsigned char*> SgOmpReverseOffloadClause::pools;
   40897             : 
   40898             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   40899             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   40900             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   40901             : // around this macro definition rather than each use).
   40902             : #ifndef ALLOC_MUTEX
   40903             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   40904             :         do {                                                                     \
   40905             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   40906             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   40907             :                 abort();                                                         \
   40908             :             }                                                                    \
   40909             :         } while (0);
   40910             : #endif
   40911             : 
   40912             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   40913             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   40914             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   40915             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   40916             : 
   40917             : /*! \brief New operator for SgOmpReverseOffloadClause.
   40918             : 
   40919             :    This new operator implements memory pools to provide most efficent 
   40920             :    use of the heap within construction of large ASTs.
   40921             : 
   40922             : \internal The new and delete operators use the lower level C malloc/free
   40923             :    function calls for performance and to make sure that mixing of malloc/free
   40924             :    and new/delete by the used can be caught more readily.  This may change
   40925             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   40926             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   40927             :    deallocate memory allocated using ROSE_MALLOC.
   40928             : */
   40929           2 : void *SgOmpReverseOffloadClause::operator new ( size_t Size )
   40930             : {
   40931             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   40932             :      * returning or throwing an exception. */
   40933           2 :     ALLOC_MUTEX(SgOmpReverseOffloadClause, lock);
   40934             : 
   40935             : #if ROSE_ALLOC_TRACE == 2
   40936             : //    printf("SgOmpReverseOffloadClause::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgOmpReverseOffloadClause::next_node);
   40937             : #endif
   40938             : 
   40939             : #if USE_CPP_NEW_DELETE_OPERATORS
   40940             :     void *mem = ROSE_MALLOC(Size);
   40941             :     ALLOC_MUTEX(SgOmpReverseOffloadClause, unlock);
   40942             :     return mem;
   40943             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   40944             : #if ROSE_PEDANTIC_ALLOC
   40945             :     ROSE_ASSERT(Size == sizeof(SgOmpReverseOffloadClause));
   40946             : #else
   40947           2 :     if (Size != sizeof(SgOmpReverseOffloadClause)) {
   40948           0 :       void * object = ROSE_MALLOC(Size);
   40949           0 :       ALLOC_MUTEX(SgOmpReverseOffloadClause, unlock);
   40950             :       return object;
   40951             :     }
   40952             : #endif
   40953             : 
   40954           2 :     if (SgOmpReverseOffloadClause::next_node == nullptr) {
   40955           2 :         SgOmpReverseOffloadClause * alloc = (SgOmpReverseOffloadClause*) ROSE_MALLOC ( SgOmpReverseOffloadClause::pool_size * sizeof(SgOmpReverseOffloadClause) );
   40956           2 :         ROSE_ASSERT(alloc != nullptr);
   40957             : 
   40958             : #if ROSE_ALLOC_TRACE == 2
   40959             : //        printf("SgOmpReverseOffloadClause::alloc\n  block[%zi] = [ %p , %p [\n", SgOmpReverseOffloadClause::pools.size(), alloc, alloc + SgOmpReverseOffloadClause::pool_size);
   40960             : #endif
   40961             : 
   40962             : #if ROSE_ALLOC_MEMSET == 1
   40963             : #elif ROSE_ALLOC_MEMSET == 2
   40964             :         memset(alloc, 0x00, SgOmpReverseOffloadClause::pool_size * sizeof(SgOmpReverseOffloadClause));
   40965             : #elif ROSE_ALLOC_MEMSET == 3
   40966             :         memset(alloc, 0xAA, SgOmpReverseOffloadClause::pool_size * sizeof(SgOmpReverseOffloadClause));
   40967             : #endif
   40968        4000 :         for (unsigned i=0; i < SgOmpReverseOffloadClause::pool_size-1; i++) {
   40969        3998 :           alloc[i].p_freepointer = &(alloc[i+1]);
   40970             :         }
   40971           2 :         alloc[SgOmpReverseOffloadClause::pool_size-1].p_freepointer = nullptr;
   40972             : 
   40973           2 :         SgOmpReverseOffloadClause::pools.push_back ( (unsigned char *) alloc );
   40974           2 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgOmpReverseOffloadClause::pool_size * sizeof(SgOmpReverseOffloadClause), V_SgOmpReverseOffloadClause ) );
   40975           2 :         SgOmpReverseOffloadClause::next_node = alloc;
   40976             :     }
   40977           2 :     ROSE_ASSERT(SgOmpReverseOffloadClause::next_node != nullptr);
   40978             : 
   40979           2 :     SgOmpReverseOffloadClause * object = SgOmpReverseOffloadClause::next_node;
   40980           2 :     SgOmpReverseOffloadClause::next_node = (SgOmpReverseOffloadClause*)(object->p_freepointer);
   40981             : 
   40982             : #if ROSE_ALLOC_TRACE == 2
   40983             :     printf("SgOmpReverseOffloadClause::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpReverseOffloadClause::next_node);
   40984             : #endif
   40985             : 
   40986           2 :     SgNode * fp = object->p_freepointer;
   40987             : #if ROSE_ALLOC_MEMSET == 1
   40988             : #elif ROSE_ALLOC_MEMSET == 2
   40989             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpReverseOffloadClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   40990             : #elif ROSE_ALLOC_MEMSET == 3
   40991             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgOmpReverseOffloadClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   40992             : #endif
   40993           2 :     object->p_freepointer = fp;
   40994             : 
   40995             : #if ROSE_ALLOC_TRACE == 2
   40996             : //    printf("SgOmpReverseOffloadClause::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpReverseOffloadClause::next_node);
   40997             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   40998             :     Rose::MemPool::snapshot(oss.str());
   40999             :     alloc_trace_cnt++;
   41000             : #endif
   41001             : 
   41002           2 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   41003             : 
   41004           2 :     ALLOC_MUTEX(SgOmpReverseOffloadClause, unlock);
   41005             : 
   41006             :     return object;
   41007             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   41008             : }
   41009             : 
   41010             : 
   41011             : 
   41012             : /*! \brief Delete operator for SgOmpReverseOffloadClause.
   41013             : 
   41014             :    This delete operator implements deallocation using memory pools to 
   41015             :    provide most efficent use of the heap within construction of large ASTs.
   41016             : 
   41017             : \internal The new and delete operators use the lower level C malloc/free
   41018             :    function calls for performance and to make sure that mixing of malloc/free
   41019             :    and new/delete by the used can be caught more readily.  This may change
   41020             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   41021             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   41022             :    deallocate memory allocated using ROSE_MALLOC.
   41023             : */
   41024           0 : void SgOmpReverseOffloadClause::operator delete(void *Pointer, size_t Size)
   41025             : {
   41026             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   41027             :      * or throwing an exception. */
   41028           0 :     ALLOC_MUTEX(SgOmpReverseOffloadClause, lock);
   41029             : 
   41030             : #if USE_CPP_NEW_DELETE_OPERATORS
   41031             :     ROSE_FREE(Pointer);
   41032             : #else
   41033             : #if ROSE_PEDANTIC_ALLOC
   41034             :     ROSE_ASSERT(Size == sizeof(SgOmpReverseOffloadClause));
   41035             : #else
   41036           0 :     if (Size != sizeof(SgOmpReverseOffloadClause)) {
   41037           0 :       ROSE_FREE(Pointer);
   41038           0 :       ALLOC_MUTEX(SgOmpReverseOffloadClause, unlock);
   41039             :       return;
   41040             :     }
   41041             : #endif
   41042             : 
   41043           0 :     SgOmpReverseOffloadClause * object = (SgOmpReverseOffloadClause*) Pointer;
   41044           0 :     ROSE_ASSERT(object != nullptr);
   41045             : 
   41046             : #if ROSE_ALLOC_TRACE == 2
   41047             : //  printf("SgOmpReverseOffloadClause::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpReverseOffloadClause::next_node);
   41048             :     printf("SgOmpReverseOffloadClause::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpReverseOffloadClause::next_node);
   41049             : #endif
   41050             : 
   41051             : #if ROSE_PEDANTIC_ALLOC
   41052             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   41053             : #endif
   41054             : 
   41055             : #if ROSE_ALLOC_MEMSET == 1
   41056             : #elif ROSE_ALLOC_MEMSET == 2
   41057             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpReverseOffloadClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   41058             : #elif ROSE_ALLOC_MEMSET == 3
   41059             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgOmpReverseOffloadClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   41060             : #endif
   41061             : 
   41062             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   41063             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   41064             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   41065             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   41066             : #else
   41067           0 :     object->p_freepointer = SgOmpReverseOffloadClause::next_node;
   41068           0 :     SgOmpReverseOffloadClause::next_node = object;
   41069             : #endif
   41070             : 
   41071             : #if ROSE_ALLOC_TRACE == 2
   41072             : //  printf("SgOmpReverseOffloadClause::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpReverseOffloadClause::next_node);
   41073             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   41074             :     Rose::MemPool::snapshot(oss.str());
   41075             :     alloc_trace_cnt++;
   41076             : #endif
   41077             : 
   41078             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   41079             : 
   41080           0 :     ALLOC_MUTEX(SgOmpReverseOffloadClause, unlock);
   41081             : }
   41082             : 
   41083             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   41084             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   41085             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   41086             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   41087             : // Also, note comment below from Robb (copied from the Common.code file).
   41088             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   41089             : //
   41090             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   41091             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   41092             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   41093             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   41094             : #if 0
   41095             : void SgOmpReverseOffloadClause::operator delete(void* pointer) { SgOmpReverseOffloadClause::operator delete (pointer, sizeof(SgOmpReverseOffloadClause)); };
   41096             : #endif
   41097             : /* #line 41098 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   41098             : 
   41099             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   41100             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   41101             : // obviously imply C++.
   41102             : 
   41103             : // This implements the support within ROSE for memory pools.  Memory pools
   41104             : // support the most condensed usage of memory within the construction of
   41105             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   41106             : // by a new operator written for each class.
   41107             : 
   41108             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   41109             :     // User wants multi-thread support and POSIX threads are available.
   41110             : #   include <pthread.h>
   41111             :     static pthread_mutex_t SgOmpUnifiedAddressClause_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   41112             : #else
   41113             :      // Cause synchronization to be skipped.
   41114             : #    ifndef ALLOC_MUTEX
   41115             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   41116             : #    endif
   41117             : #    ifdef _REENTRANT
   41118             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   41119             : #       ifdef _MSC_VER
   41120             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   41121             : #       else
   41122             : #           warning "POSIX threads are not available; synchronization being skipped"
   41123             : #       endif
   41124             : #    endif
   41125             : #endif
   41126             : 
   41127             : #ifndef ROSE_ALLOC_TRACE
   41128             : #  define ROSE_ALLOC_TRACE 0
   41129             : #endif
   41130             : 
   41131             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   41132             : #define ROSE_ALLOC_TRACE_CNT
   41133             : #include "memory-pool-snapshot.h"
   41134             : unsigned long alloc_trace_cnt = 0;
   41135             : #endif
   41136             : 
   41137             : #if ROSE_ALLOC_TRACE
   41138             : const unsigned SgOmpUnifiedAddressClause::pool_size = 5;
   41139             : #else
   41140             : const unsigned SgOmpUnifiedAddressClause::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   41141             : #endif
   41142             : 
   41143             : #ifndef ROSE_ALLOC_MEMSET
   41144             : #  define ROSE_ALLOC_MEMSET 0
   41145             : #endif
   41146             : 
   41147             : #ifndef ROSE_PEDANTIC_ALLOC
   41148             : #  define ROSE_PEDANTIC_ALLOC 0
   41149             : #endif
   41150             : 
   41151             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   41152             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   41153             : #endif
   41154             : 
   41155             : #if !defined(SGNODE__ALL_POOLS)
   41156             : #define SGNODE__ALL_POOLS
   41157             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   41158             : #endif
   41159             : 
   41160             : SgOmpUnifiedAddressClause* SgOmpUnifiedAddressClause::next_node = nullptr;
   41161             : std::vector<unsigned char*> SgOmpUnifiedAddressClause::pools;
   41162             : 
   41163             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   41164             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   41165             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   41166             : // around this macro definition rather than each use).
   41167             : #ifndef ALLOC_MUTEX
   41168             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   41169             :         do {                                                                     \
   41170             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   41171             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   41172             :                 abort();                                                         \
   41173             :             }                                                                    \
   41174             :         } while (0);
   41175             : #endif
   41176             : 
   41177             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   41178             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   41179             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   41180             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   41181             : 
   41182             : /*! \brief New operator for SgOmpUnifiedAddressClause.
   41183             : 
   41184             :    This new operator implements memory pools to provide most efficent 
   41185             :    use of the heap within construction of large ASTs.
   41186             : 
   41187             : \internal The new and delete operators use the lower level C malloc/free
   41188             :    function calls for performance and to make sure that mixing of malloc/free
   41189             :    and new/delete by the used can be caught more readily.  This may change
   41190             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   41191             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   41192             :    deallocate memory allocated using ROSE_MALLOC.
   41193             : */
   41194           1 : void *SgOmpUnifiedAddressClause::operator new ( size_t Size )
   41195             : {
   41196             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   41197             :      * returning or throwing an exception. */
   41198           1 :     ALLOC_MUTEX(SgOmpUnifiedAddressClause, lock);
   41199             : 
   41200             : #if ROSE_ALLOC_TRACE == 2
   41201             : //    printf("SgOmpUnifiedAddressClause::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgOmpUnifiedAddressClause::next_node);
   41202             : #endif
   41203             : 
   41204             : #if USE_CPP_NEW_DELETE_OPERATORS
   41205             :     void *mem = ROSE_MALLOC(Size);
   41206             :     ALLOC_MUTEX(SgOmpUnifiedAddressClause, unlock);
   41207             :     return mem;
   41208             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   41209             : #if ROSE_PEDANTIC_ALLOC
   41210             :     ROSE_ASSERT(Size == sizeof(SgOmpUnifiedAddressClause));
   41211             : #else
   41212           1 :     if (Size != sizeof(SgOmpUnifiedAddressClause)) {
   41213           0 :       void * object = ROSE_MALLOC(Size);
   41214           0 :       ALLOC_MUTEX(SgOmpUnifiedAddressClause, unlock);
   41215             :       return object;
   41216             :     }
   41217             : #endif
   41218             : 
   41219           1 :     if (SgOmpUnifiedAddressClause::next_node == nullptr) {
   41220           1 :         SgOmpUnifiedAddressClause * alloc = (SgOmpUnifiedAddressClause*) ROSE_MALLOC ( SgOmpUnifiedAddressClause::pool_size * sizeof(SgOmpUnifiedAddressClause) );
   41221           1 :         ROSE_ASSERT(alloc != nullptr);
   41222             : 
   41223             : #if ROSE_ALLOC_TRACE == 2
   41224             : //        printf("SgOmpUnifiedAddressClause::alloc\n  block[%zi] = [ %p , %p [\n", SgOmpUnifiedAddressClause::pools.size(), alloc, alloc + SgOmpUnifiedAddressClause::pool_size);
   41225             : #endif
   41226             : 
   41227             : #if ROSE_ALLOC_MEMSET == 1
   41228             : #elif ROSE_ALLOC_MEMSET == 2
   41229             :         memset(alloc, 0x00, SgOmpUnifiedAddressClause::pool_size * sizeof(SgOmpUnifiedAddressClause));
   41230             : #elif ROSE_ALLOC_MEMSET == 3
   41231             :         memset(alloc, 0xAA, SgOmpUnifiedAddressClause::pool_size * sizeof(SgOmpUnifiedAddressClause));
   41232             : #endif
   41233        2000 :         for (unsigned i=0; i < SgOmpUnifiedAddressClause::pool_size-1; i++) {
   41234        1999 :           alloc[i].p_freepointer = &(alloc[i+1]);
   41235             :         }
   41236           1 :         alloc[SgOmpUnifiedAddressClause::pool_size-1].p_freepointer = nullptr;
   41237             : 
   41238           1 :         SgOmpUnifiedAddressClause::pools.push_back ( (unsigned char *) alloc );
   41239           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgOmpUnifiedAddressClause::pool_size * sizeof(SgOmpUnifiedAddressClause), V_SgOmpUnifiedAddressClause ) );
   41240           1 :         SgOmpUnifiedAddressClause::next_node = alloc;
   41241             :     }
   41242           1 :     ROSE_ASSERT(SgOmpUnifiedAddressClause::next_node != nullptr);
   41243             : 
   41244           1 :     SgOmpUnifiedAddressClause * object = SgOmpUnifiedAddressClause::next_node;
   41245           1 :     SgOmpUnifiedAddressClause::next_node = (SgOmpUnifiedAddressClause*)(object->p_freepointer);
   41246             : 
   41247             : #if ROSE_ALLOC_TRACE == 2
   41248             :     printf("SgOmpUnifiedAddressClause::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpUnifiedAddressClause::next_node);
   41249             : #endif
   41250             : 
   41251           1 :     SgNode * fp = object->p_freepointer;
   41252             : #if ROSE_ALLOC_MEMSET == 1
   41253             : #elif ROSE_ALLOC_MEMSET == 2
   41254             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpUnifiedAddressClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   41255             : #elif ROSE_ALLOC_MEMSET == 3
   41256             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgOmpUnifiedAddressClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   41257             : #endif
   41258           1 :     object->p_freepointer = fp;
   41259             : 
   41260             : #if ROSE_ALLOC_TRACE == 2
   41261             : //    printf("SgOmpUnifiedAddressClause::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpUnifiedAddressClause::next_node);
   41262             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   41263             :     Rose::MemPool::snapshot(oss.str());
   41264             :     alloc_trace_cnt++;
   41265             : #endif
   41266             : 
   41267           1 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   41268             : 
   41269           1 :     ALLOC_MUTEX(SgOmpUnifiedAddressClause, unlock);
   41270             : 
   41271             :     return object;
   41272             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   41273             : }
   41274             : 
   41275             : 
   41276             : 
   41277             : /*! \brief Delete operator for SgOmpUnifiedAddressClause.
   41278             : 
   41279             :    This delete operator implements deallocation using memory pools to 
   41280             :    provide most efficent use of the heap within construction of large ASTs.
   41281             : 
   41282             : \internal The new and delete operators use the lower level C malloc/free
   41283             :    function calls for performance and to make sure that mixing of malloc/free
   41284             :    and new/delete by the used can be caught more readily.  This may change
   41285             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   41286             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   41287             :    deallocate memory allocated using ROSE_MALLOC.
   41288             : */
   41289           0 : void SgOmpUnifiedAddressClause::operator delete(void *Pointer, size_t Size)
   41290             : {
   41291             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   41292             :      * or throwing an exception. */
   41293           0 :     ALLOC_MUTEX(SgOmpUnifiedAddressClause, lock);
   41294             : 
   41295             : #if USE_CPP_NEW_DELETE_OPERATORS
   41296             :     ROSE_FREE(Pointer);
   41297             : #else
   41298             : #if ROSE_PEDANTIC_ALLOC
   41299             :     ROSE_ASSERT(Size == sizeof(SgOmpUnifiedAddressClause));
   41300             : #else
   41301           0 :     if (Size != sizeof(SgOmpUnifiedAddressClause)) {
   41302           0 :       ROSE_FREE(Pointer);
   41303           0 :       ALLOC_MUTEX(SgOmpUnifiedAddressClause, unlock);
   41304             :       return;
   41305             :     }
   41306             : #endif
   41307             : 
   41308           0 :     SgOmpUnifiedAddressClause * object = (SgOmpUnifiedAddressClause*) Pointer;
   41309           0 :     ROSE_ASSERT(object != nullptr);
   41310             : 
   41311             : #if ROSE_ALLOC_TRACE == 2
   41312             : //  printf("SgOmpUnifiedAddressClause::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpUnifiedAddressClause::next_node);
   41313             :     printf("SgOmpUnifiedAddressClause::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpUnifiedAddressClause::next_node);
   41314             : #endif
   41315             : 
   41316             : #if ROSE_PEDANTIC_ALLOC
   41317             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   41318             : #endif
   41319             : 
   41320             : #if ROSE_ALLOC_MEMSET == 1
   41321             : #elif ROSE_ALLOC_MEMSET == 2
   41322             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpUnifiedAddressClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   41323             : #elif ROSE_ALLOC_MEMSET == 3
   41324             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgOmpUnifiedAddressClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   41325             : #endif
   41326             : 
   41327             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   41328             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   41329             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   41330             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   41331             : #else
   41332           0 :     object->p_freepointer = SgOmpUnifiedAddressClause::next_node;
   41333           0 :     SgOmpUnifiedAddressClause::next_node = object;
   41334             : #endif
   41335             : 
   41336             : #if ROSE_ALLOC_TRACE == 2
   41337             : //  printf("SgOmpUnifiedAddressClause::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpUnifiedAddressClause::next_node);
   41338             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   41339             :     Rose::MemPool::snapshot(oss.str());
   41340             :     alloc_trace_cnt++;
   41341             : #endif
   41342             : 
   41343             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   41344             : 
   41345           0 :     ALLOC_MUTEX(SgOmpUnifiedAddressClause, unlock);
   41346             : }
   41347             : 
   41348             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   41349             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   41350             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   41351             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   41352             : // Also, note comment below from Robb (copied from the Common.code file).
   41353             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   41354             : //
   41355             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   41356             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   41357             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   41358             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   41359             : #if 0
   41360             : void SgOmpUnifiedAddressClause::operator delete(void* pointer) { SgOmpUnifiedAddressClause::operator delete (pointer, sizeof(SgOmpUnifiedAddressClause)); };
   41361             : #endif
   41362             : /* #line 41363 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   41363             : 
   41364             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   41365             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   41366             : // obviously imply C++.
   41367             : 
   41368             : // This implements the support within ROSE for memory pools.  Memory pools
   41369             : // support the most condensed usage of memory within the construction of
   41370             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   41371             : // by a new operator written for each class.
   41372             : 
   41373             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   41374             :     // User wants multi-thread support and POSIX threads are available.
   41375             : #   include <pthread.h>
   41376             :     static pthread_mutex_t SgOmpUnifiedSharedMemoryClause_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   41377             : #else
   41378             :      // Cause synchronization to be skipped.
   41379             : #    ifndef ALLOC_MUTEX
   41380             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   41381             : #    endif
   41382             : #    ifdef _REENTRANT
   41383             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   41384             : #       ifdef _MSC_VER
   41385             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   41386             : #       else
   41387             : #           warning "POSIX threads are not available; synchronization being skipped"
   41388             : #       endif
   41389             : #    endif
   41390             : #endif
   41391             : 
   41392             : #ifndef ROSE_ALLOC_TRACE
   41393             : #  define ROSE_ALLOC_TRACE 0
   41394             : #endif
   41395             : 
   41396             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   41397             : #define ROSE_ALLOC_TRACE_CNT
   41398             : #include "memory-pool-snapshot.h"
   41399             : unsigned long alloc_trace_cnt = 0;
   41400             : #endif
   41401             : 
   41402             : #if ROSE_ALLOC_TRACE
   41403             : const unsigned SgOmpUnifiedSharedMemoryClause::pool_size = 5;
   41404             : #else
   41405             : const unsigned SgOmpUnifiedSharedMemoryClause::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   41406             : #endif
   41407             : 
   41408             : #ifndef ROSE_ALLOC_MEMSET
   41409             : #  define ROSE_ALLOC_MEMSET 0
   41410             : #endif
   41411             : 
   41412             : #ifndef ROSE_PEDANTIC_ALLOC
   41413             : #  define ROSE_PEDANTIC_ALLOC 0
   41414             : #endif
   41415             : 
   41416             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   41417             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   41418             : #endif
   41419             : 
   41420             : #if !defined(SGNODE__ALL_POOLS)
   41421             : #define SGNODE__ALL_POOLS
   41422             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   41423             : #endif
   41424             : 
   41425             : SgOmpUnifiedSharedMemoryClause* SgOmpUnifiedSharedMemoryClause::next_node = nullptr;
   41426             : std::vector<unsigned char*> SgOmpUnifiedSharedMemoryClause::pools;
   41427             : 
   41428             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   41429             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   41430             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   41431             : // around this macro definition rather than each use).
   41432             : #ifndef ALLOC_MUTEX
   41433             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   41434             :         do {                                                                     \
   41435             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   41436             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   41437             :                 abort();                                                         \
   41438             :             }                                                                    \
   41439             :         } while (0);
   41440             : #endif
   41441             : 
   41442             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   41443             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   41444             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   41445             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   41446             : 
   41447             : /*! \brief New operator for SgOmpUnifiedSharedMemoryClause.
   41448             : 
   41449             :    This new operator implements memory pools to provide most efficent 
   41450             :    use of the heap within construction of large ASTs.
   41451             : 
   41452             : \internal The new and delete operators use the lower level C malloc/free
   41453             :    function calls for performance and to make sure that mixing of malloc/free
   41454             :    and new/delete by the used can be caught more readily.  This may change
   41455             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   41456             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   41457             :    deallocate memory allocated using ROSE_MALLOC.
   41458             : */
   41459           1 : void *SgOmpUnifiedSharedMemoryClause::operator new ( size_t Size )
   41460             : {
   41461             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   41462             :      * returning or throwing an exception. */
   41463           1 :     ALLOC_MUTEX(SgOmpUnifiedSharedMemoryClause, lock);
   41464             : 
   41465             : #if ROSE_ALLOC_TRACE == 2
   41466             : //    printf("SgOmpUnifiedSharedMemoryClause::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgOmpUnifiedSharedMemoryClause::next_node);
   41467             : #endif
   41468             : 
   41469             : #if USE_CPP_NEW_DELETE_OPERATORS
   41470             :     void *mem = ROSE_MALLOC(Size);
   41471             :     ALLOC_MUTEX(SgOmpUnifiedSharedMemoryClause, unlock);
   41472             :     return mem;
   41473             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   41474             : #if ROSE_PEDANTIC_ALLOC
   41475             :     ROSE_ASSERT(Size == sizeof(SgOmpUnifiedSharedMemoryClause));
   41476             : #else
   41477           1 :     if (Size != sizeof(SgOmpUnifiedSharedMemoryClause)) {
   41478           0 :       void * object = ROSE_MALLOC(Size);
   41479           0 :       ALLOC_MUTEX(SgOmpUnifiedSharedMemoryClause, unlock);
   41480             :       return object;
   41481             :     }
   41482             : #endif
   41483             : 
   41484           1 :     if (SgOmpUnifiedSharedMemoryClause::next_node == nullptr) {
   41485           1 :         SgOmpUnifiedSharedMemoryClause * alloc = (SgOmpUnifiedSharedMemoryClause*) ROSE_MALLOC ( SgOmpUnifiedSharedMemoryClause::pool_size * sizeof(SgOmpUnifiedSharedMemoryClause) );
   41486           1 :         ROSE_ASSERT(alloc != nullptr);
   41487             : 
   41488             : #if ROSE_ALLOC_TRACE == 2
   41489             : //        printf("SgOmpUnifiedSharedMemoryClause::alloc\n  block[%zi] = [ %p , %p [\n", SgOmpUnifiedSharedMemoryClause::pools.size(), alloc, alloc + SgOmpUnifiedSharedMemoryClause::pool_size);
   41490             : #endif
   41491             : 
   41492             : #if ROSE_ALLOC_MEMSET == 1
   41493             : #elif ROSE_ALLOC_MEMSET == 2
   41494             :         memset(alloc, 0x00, SgOmpUnifiedSharedMemoryClause::pool_size * sizeof(SgOmpUnifiedSharedMemoryClause));
   41495             : #elif ROSE_ALLOC_MEMSET == 3
   41496             :         memset(alloc, 0xAA, SgOmpUnifiedSharedMemoryClause::pool_size * sizeof(SgOmpUnifiedSharedMemoryClause));
   41497             : #endif
   41498        2000 :         for (unsigned i=0; i < SgOmpUnifiedSharedMemoryClause::pool_size-1; i++) {
   41499        1999 :           alloc[i].p_freepointer = &(alloc[i+1]);
   41500             :         }
   41501           1 :         alloc[SgOmpUnifiedSharedMemoryClause::pool_size-1].p_freepointer = nullptr;
   41502             : 
   41503           1 :         SgOmpUnifiedSharedMemoryClause::pools.push_back ( (unsigned char *) alloc );
   41504           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgOmpUnifiedSharedMemoryClause::pool_size * sizeof(SgOmpUnifiedSharedMemoryClause), V_SgOmpUnifiedSharedMemoryClause ) );
   41505           1 :         SgOmpUnifiedSharedMemoryClause::next_node = alloc;
   41506             :     }
   41507           1 :     ROSE_ASSERT(SgOmpUnifiedSharedMemoryClause::next_node != nullptr);
   41508             : 
   41509           1 :     SgOmpUnifiedSharedMemoryClause * object = SgOmpUnifiedSharedMemoryClause::next_node;
   41510           1 :     SgOmpUnifiedSharedMemoryClause::next_node = (SgOmpUnifiedSharedMemoryClause*)(object->p_freepointer);
   41511             : 
   41512             : #if ROSE_ALLOC_TRACE == 2
   41513             :     printf("SgOmpUnifiedSharedMemoryClause::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpUnifiedSharedMemoryClause::next_node);
   41514             : #endif
   41515             : 
   41516           1 :     SgNode * fp = object->p_freepointer;
   41517             : #if ROSE_ALLOC_MEMSET == 1
   41518             : #elif ROSE_ALLOC_MEMSET == 2
   41519             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpUnifiedSharedMemoryClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   41520             : #elif ROSE_ALLOC_MEMSET == 3
   41521             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgOmpUnifiedSharedMemoryClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   41522             : #endif
   41523           1 :     object->p_freepointer = fp;
   41524             : 
   41525             : #if ROSE_ALLOC_TRACE == 2
   41526             : //    printf("SgOmpUnifiedSharedMemoryClause::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpUnifiedSharedMemoryClause::next_node);
   41527             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   41528             :     Rose::MemPool::snapshot(oss.str());
   41529             :     alloc_trace_cnt++;
   41530             : #endif
   41531             : 
   41532           1 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   41533             : 
   41534           1 :     ALLOC_MUTEX(SgOmpUnifiedSharedMemoryClause, unlock);
   41535             : 
   41536             :     return object;
   41537             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   41538             : }
   41539             : 
   41540             : 
   41541             : 
   41542             : /*! \brief Delete operator for SgOmpUnifiedSharedMemoryClause.
   41543             : 
   41544             :    This delete operator implements deallocation using memory pools to 
   41545             :    provide most efficent use of the heap within construction of large ASTs.
   41546             : 
   41547             : \internal The new and delete operators use the lower level C malloc/free
   41548             :    function calls for performance and to make sure that mixing of malloc/free
   41549             :    and new/delete by the used can be caught more readily.  This may change
   41550             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   41551             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   41552             :    deallocate memory allocated using ROSE_MALLOC.
   41553             : */
   41554           0 : void SgOmpUnifiedSharedMemoryClause::operator delete(void *Pointer, size_t Size)
   41555             : {
   41556             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   41557             :      * or throwing an exception. */
   41558           0 :     ALLOC_MUTEX(SgOmpUnifiedSharedMemoryClause, lock);
   41559             : 
   41560             : #if USE_CPP_NEW_DELETE_OPERATORS
   41561             :     ROSE_FREE(Pointer);
   41562             : #else
   41563             : #if ROSE_PEDANTIC_ALLOC
   41564             :     ROSE_ASSERT(Size == sizeof(SgOmpUnifiedSharedMemoryClause));
   41565             : #else
   41566           0 :     if (Size != sizeof(SgOmpUnifiedSharedMemoryClause)) {
   41567           0 :       ROSE_FREE(Pointer);
   41568           0 :       ALLOC_MUTEX(SgOmpUnifiedSharedMemoryClause, unlock);
   41569             :       return;
   41570             :     }
   41571             : #endif
   41572             : 
   41573           0 :     SgOmpUnifiedSharedMemoryClause * object = (SgOmpUnifiedSharedMemoryClause*) Pointer;
   41574           0 :     ROSE_ASSERT(object != nullptr);
   41575             : 
   41576             : #if ROSE_ALLOC_TRACE == 2
   41577             : //  printf("SgOmpUnifiedSharedMemoryClause::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpUnifiedSharedMemoryClause::next_node);
   41578             :     printf("SgOmpUnifiedSharedMemoryClause::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpUnifiedSharedMemoryClause::next_node);
   41579             : #endif
   41580             : 
   41581             : #if ROSE_PEDANTIC_ALLOC
   41582             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   41583             : #endif
   41584             : 
   41585             : #if ROSE_ALLOC_MEMSET == 1
   41586             : #elif ROSE_ALLOC_MEMSET == 2
   41587             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpUnifiedSharedMemoryClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   41588             : #elif ROSE_ALLOC_MEMSET == 3
   41589             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgOmpUnifiedSharedMemoryClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   41590             : #endif
   41591             : 
   41592             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   41593             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   41594             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   41595             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   41596             : #else
   41597           0 :     object->p_freepointer = SgOmpUnifiedSharedMemoryClause::next_node;
   41598           0 :     SgOmpUnifiedSharedMemoryClause::next_node = object;
   41599             : #endif
   41600             : 
   41601             : #if ROSE_ALLOC_TRACE == 2
   41602             : //  printf("SgOmpUnifiedSharedMemoryClause::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpUnifiedSharedMemoryClause::next_node);
   41603             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   41604             :     Rose::MemPool::snapshot(oss.str());
   41605             :     alloc_trace_cnt++;
   41606             : #endif
   41607             : 
   41608             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   41609             : 
   41610           0 :     ALLOC_MUTEX(SgOmpUnifiedSharedMemoryClause, unlock);
   41611             : }
   41612             : 
   41613             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   41614             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   41615             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   41616             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   41617             : // Also, note comment below from Robb (copied from the Common.code file).
   41618             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   41619             : //
   41620             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   41621             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   41622             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   41623             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   41624             : #if 0
   41625             : void SgOmpUnifiedSharedMemoryClause::operator delete(void* pointer) { SgOmpUnifiedSharedMemoryClause::operator delete (pointer, sizeof(SgOmpUnifiedSharedMemoryClause)); };
   41626             : #endif
   41627             : /* #line 41628 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   41628             : 
   41629             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   41630             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   41631             : // obviously imply C++.
   41632             : 
   41633             : // This implements the support within ROSE for memory pools.  Memory pools
   41634             : // support the most condensed usage of memory within the construction of
   41635             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   41636             : // by a new operator written for each class.
   41637             : 
   41638             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   41639             :     // User wants multi-thread support and POSIX threads are available.
   41640             : #   include <pthread.h>
   41641             :     static pthread_mutex_t SgOmpDynamicAllocatorsClause_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   41642             : #else
   41643             :      // Cause synchronization to be skipped.
   41644             : #    ifndef ALLOC_MUTEX
   41645             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   41646             : #    endif
   41647             : #    ifdef _REENTRANT
   41648             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   41649             : #       ifdef _MSC_VER
   41650             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   41651             : #       else
   41652             : #           warning "POSIX threads are not available; synchronization being skipped"
   41653             : #       endif
   41654             : #    endif
   41655             : #endif
   41656             : 
   41657             : #ifndef ROSE_ALLOC_TRACE
   41658             : #  define ROSE_ALLOC_TRACE 0
   41659             : #endif
   41660             : 
   41661             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   41662             : #define ROSE_ALLOC_TRACE_CNT
   41663             : #include "memory-pool-snapshot.h"
   41664             : unsigned long alloc_trace_cnt = 0;
   41665             : #endif
   41666             : 
   41667             : #if ROSE_ALLOC_TRACE
   41668             : const unsigned SgOmpDynamicAllocatorsClause::pool_size = 5;
   41669             : #else
   41670             : const unsigned SgOmpDynamicAllocatorsClause::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   41671             : #endif
   41672             : 
   41673             : #ifndef ROSE_ALLOC_MEMSET
   41674             : #  define ROSE_ALLOC_MEMSET 0
   41675             : #endif
   41676             : 
   41677             : #ifndef ROSE_PEDANTIC_ALLOC
   41678             : #  define ROSE_PEDANTIC_ALLOC 0
   41679             : #endif
   41680             : 
   41681             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   41682             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   41683             : #endif
   41684             : 
   41685             : #if !defined(SGNODE__ALL_POOLS)
   41686             : #define SGNODE__ALL_POOLS
   41687             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   41688             : #endif
   41689             : 
   41690             : SgOmpDynamicAllocatorsClause* SgOmpDynamicAllocatorsClause::next_node = nullptr;
   41691             : std::vector<unsigned char*> SgOmpDynamicAllocatorsClause::pools;
   41692             : 
   41693             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   41694             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   41695             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   41696             : // around this macro definition rather than each use).
   41697             : #ifndef ALLOC_MUTEX
   41698             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   41699             :         do {                                                                     \
   41700             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   41701             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   41702             :                 abort();                                                         \
   41703             :             }                                                                    \
   41704             :         } while (0);
   41705             : #endif
   41706             : 
   41707             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   41708             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   41709             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   41710             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   41711             : 
   41712             : /*! \brief New operator for SgOmpDynamicAllocatorsClause.
   41713             : 
   41714             :    This new operator implements memory pools to provide most efficent 
   41715             :    use of the heap within construction of large ASTs.
   41716             : 
   41717             : \internal The new and delete operators use the lower level C malloc/free
   41718             :    function calls for performance and to make sure that mixing of malloc/free
   41719             :    and new/delete by the used can be caught more readily.  This may change
   41720             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   41721             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   41722             :    deallocate memory allocated using ROSE_MALLOC.
   41723             : */
   41724           1 : void *SgOmpDynamicAllocatorsClause::operator new ( size_t Size )
   41725             : {
   41726             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   41727             :      * returning or throwing an exception. */
   41728           1 :     ALLOC_MUTEX(SgOmpDynamicAllocatorsClause, lock);
   41729             : 
   41730             : #if ROSE_ALLOC_TRACE == 2
   41731             : //    printf("SgOmpDynamicAllocatorsClause::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgOmpDynamicAllocatorsClause::next_node);
   41732             : #endif
   41733             : 
   41734             : #if USE_CPP_NEW_DELETE_OPERATORS
   41735             :     void *mem = ROSE_MALLOC(Size);
   41736             :     ALLOC_MUTEX(SgOmpDynamicAllocatorsClause, unlock);
   41737             :     return mem;
   41738             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   41739             : #if ROSE_PEDANTIC_ALLOC
   41740             :     ROSE_ASSERT(Size == sizeof(SgOmpDynamicAllocatorsClause));
   41741             : #else
   41742           1 :     if (Size != sizeof(SgOmpDynamicAllocatorsClause)) {
   41743           0 :       void * object = ROSE_MALLOC(Size);
   41744           0 :       ALLOC_MUTEX(SgOmpDynamicAllocatorsClause, unlock);
   41745             :       return object;
   41746             :     }
   41747             : #endif
   41748             : 
   41749           1 :     if (SgOmpDynamicAllocatorsClause::next_node == nullptr) {
   41750           1 :         SgOmpDynamicAllocatorsClause * alloc = (SgOmpDynamicAllocatorsClause*) ROSE_MALLOC ( SgOmpDynamicAllocatorsClause::pool_size * sizeof(SgOmpDynamicAllocatorsClause) );
   41751           1 :         ROSE_ASSERT(alloc != nullptr);
   41752             : 
   41753             : #if ROSE_ALLOC_TRACE == 2
   41754             : //        printf("SgOmpDynamicAllocatorsClause::alloc\n  block[%zi] = [ %p , %p [\n", SgOmpDynamicAllocatorsClause::pools.size(), alloc, alloc + SgOmpDynamicAllocatorsClause::pool_size);
   41755             : #endif
   41756             : 
   41757             : #if ROSE_ALLOC_MEMSET == 1
   41758             : #elif ROSE_ALLOC_MEMSET == 2
   41759             :         memset(alloc, 0x00, SgOmpDynamicAllocatorsClause::pool_size * sizeof(SgOmpDynamicAllocatorsClause));
   41760             : #elif ROSE_ALLOC_MEMSET == 3
   41761             :         memset(alloc, 0xAA, SgOmpDynamicAllocatorsClause::pool_size * sizeof(SgOmpDynamicAllocatorsClause));
   41762             : #endif
   41763        2000 :         for (unsigned i=0; i < SgOmpDynamicAllocatorsClause::pool_size-1; i++) {
   41764        1999 :           alloc[i].p_freepointer = &(alloc[i+1]);
   41765             :         }
   41766           1 :         alloc[SgOmpDynamicAllocatorsClause::pool_size-1].p_freepointer = nullptr;
   41767             : 
   41768           1 :         SgOmpDynamicAllocatorsClause::pools.push_back ( (unsigned char *) alloc );
   41769           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgOmpDynamicAllocatorsClause::pool_size * sizeof(SgOmpDynamicAllocatorsClause), V_SgOmpDynamicAllocatorsClause ) );
   41770           1 :         SgOmpDynamicAllocatorsClause::next_node = alloc;
   41771             :     }
   41772           1 :     ROSE_ASSERT(SgOmpDynamicAllocatorsClause::next_node != nullptr);
   41773             : 
   41774           1 :     SgOmpDynamicAllocatorsClause * object = SgOmpDynamicAllocatorsClause::next_node;
   41775           1 :     SgOmpDynamicAllocatorsClause::next_node = (SgOmpDynamicAllocatorsClause*)(object->p_freepointer);
   41776             : 
   41777             : #if ROSE_ALLOC_TRACE == 2
   41778             :     printf("SgOmpDynamicAllocatorsClause::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpDynamicAllocatorsClause::next_node);
   41779             : #endif
   41780             : 
   41781           1 :     SgNode * fp = object->p_freepointer;
   41782             : #if ROSE_ALLOC_MEMSET == 1
   41783             : #elif ROSE_ALLOC_MEMSET == 2
   41784             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpDynamicAllocatorsClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   41785             : #elif ROSE_ALLOC_MEMSET == 3
   41786             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgOmpDynamicAllocatorsClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   41787             : #endif
   41788           1 :     object->p_freepointer = fp;
   41789             : 
   41790             : #if ROSE_ALLOC_TRACE == 2
   41791             : //    printf("SgOmpDynamicAllocatorsClause::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpDynamicAllocatorsClause::next_node);
   41792             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   41793             :     Rose::MemPool::snapshot(oss.str());
   41794             :     alloc_trace_cnt++;
   41795             : #endif
   41796             : 
   41797           1 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   41798             : 
   41799           1 :     ALLOC_MUTEX(SgOmpDynamicAllocatorsClause, unlock);
   41800             : 
   41801             :     return object;
   41802             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   41803             : }
   41804             : 
   41805             : 
   41806             : 
   41807             : /*! \brief Delete operator for SgOmpDynamicAllocatorsClause.
   41808             : 
   41809             :    This delete operator implements deallocation using memory pools to 
   41810             :    provide most efficent use of the heap within construction of large ASTs.
   41811             : 
   41812             : \internal The new and delete operators use the lower level C malloc/free
   41813             :    function calls for performance and to make sure that mixing of malloc/free
   41814             :    and new/delete by the used can be caught more readily.  This may change
   41815             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   41816             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   41817             :    deallocate memory allocated using ROSE_MALLOC.
   41818             : */
   41819           0 : void SgOmpDynamicAllocatorsClause::operator delete(void *Pointer, size_t Size)
   41820             : {
   41821             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   41822             :      * or throwing an exception. */
   41823           0 :     ALLOC_MUTEX(SgOmpDynamicAllocatorsClause, lock);
   41824             : 
   41825             : #if USE_CPP_NEW_DELETE_OPERATORS
   41826             :     ROSE_FREE(Pointer);
   41827             : #else
   41828             : #if ROSE_PEDANTIC_ALLOC
   41829             :     ROSE_ASSERT(Size == sizeof(SgOmpDynamicAllocatorsClause));
   41830             : #else
   41831           0 :     if (Size != sizeof(SgOmpDynamicAllocatorsClause)) {
   41832           0 :       ROSE_FREE(Pointer);
   41833           0 :       ALLOC_MUTEX(SgOmpDynamicAllocatorsClause, unlock);
   41834             :       return;
   41835             :     }
   41836             : #endif
   41837             : 
   41838           0 :     SgOmpDynamicAllocatorsClause * object = (SgOmpDynamicAllocatorsClause*) Pointer;
   41839           0 :     ROSE_ASSERT(object != nullptr);
   41840             : 
   41841             : #if ROSE_ALLOC_TRACE == 2
   41842             : //  printf("SgOmpDynamicAllocatorsClause::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpDynamicAllocatorsClause::next_node);
   41843             :     printf("SgOmpDynamicAllocatorsClause::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpDynamicAllocatorsClause::next_node);
   41844             : #endif
   41845             : 
   41846             : #if ROSE_PEDANTIC_ALLOC
   41847             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   41848             : #endif
   41849             : 
   41850             : #if ROSE_ALLOC_MEMSET == 1
   41851             : #elif ROSE_ALLOC_MEMSET == 2
   41852             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpDynamicAllocatorsClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   41853             : #elif ROSE_ALLOC_MEMSET == 3
   41854             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgOmpDynamicAllocatorsClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   41855             : #endif
   41856             : 
   41857             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   41858             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   41859             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   41860             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   41861             : #else
   41862           0 :     object->p_freepointer = SgOmpDynamicAllocatorsClause::next_node;
   41863           0 :     SgOmpDynamicAllocatorsClause::next_node = object;
   41864             : #endif
   41865             : 
   41866             : #if ROSE_ALLOC_TRACE == 2
   41867             : //  printf("SgOmpDynamicAllocatorsClause::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpDynamicAllocatorsClause::next_node);
   41868             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   41869             :     Rose::MemPool::snapshot(oss.str());
   41870             :     alloc_trace_cnt++;
   41871             : #endif
   41872             : 
   41873             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   41874             : 
   41875           0 :     ALLOC_MUTEX(SgOmpDynamicAllocatorsClause, unlock);
   41876             : }
   41877             : 
   41878             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   41879             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   41880             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   41881             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   41882             : // Also, note comment below from Robb (copied from the Common.code file).
   41883             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   41884             : //
   41885             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   41886             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   41887             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   41888             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   41889             : #if 0
   41890             : void SgOmpDynamicAllocatorsClause::operator delete(void* pointer) { SgOmpDynamicAllocatorsClause::operator delete (pointer, sizeof(SgOmpDynamicAllocatorsClause)); };
   41891             : #endif
   41892             : /* #line 41893 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   41893             : 
   41894             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   41895             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   41896             : // obviously imply C++.
   41897             : 
   41898             : // This implements the support within ROSE for memory pools.  Memory pools
   41899             : // support the most condensed usage of memory within the construction of
   41900             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   41901             : // by a new operator written for each class.
   41902             : 
   41903             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   41904             :     // User wants multi-thread support and POSIX threads are available.
   41905             : #   include <pthread.h>
   41906             :     static pthread_mutex_t SgOmpParallelClause_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   41907             : #else
   41908             :      // Cause synchronization to be skipped.
   41909             : #    ifndef ALLOC_MUTEX
   41910             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   41911             : #    endif
   41912             : #    ifdef _REENTRANT
   41913             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   41914             : #       ifdef _MSC_VER
   41915             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   41916             : #       else
   41917             : #           warning "POSIX threads are not available; synchronization being skipped"
   41918             : #       endif
   41919             : #    endif
   41920             : #endif
   41921             : 
   41922             : #ifndef ROSE_ALLOC_TRACE
   41923             : #  define ROSE_ALLOC_TRACE 0
   41924             : #endif
   41925             : 
   41926             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   41927             : #define ROSE_ALLOC_TRACE_CNT
   41928             : #include "memory-pool-snapshot.h"
   41929             : unsigned long alloc_trace_cnt = 0;
   41930             : #endif
   41931             : 
   41932             : #if ROSE_ALLOC_TRACE
   41933             : const unsigned SgOmpParallelClause::pool_size = 5;
   41934             : #else
   41935             : const unsigned SgOmpParallelClause::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   41936             : #endif
   41937             : 
   41938             : #ifndef ROSE_ALLOC_MEMSET
   41939             : #  define ROSE_ALLOC_MEMSET 0
   41940             : #endif
   41941             : 
   41942             : #ifndef ROSE_PEDANTIC_ALLOC
   41943             : #  define ROSE_PEDANTIC_ALLOC 0
   41944             : #endif
   41945             : 
   41946             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   41947             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   41948             : #endif
   41949             : 
   41950             : #if !defined(SGNODE__ALL_POOLS)
   41951             : #define SGNODE__ALL_POOLS
   41952             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   41953             : #endif
   41954             : 
   41955             : SgOmpParallelClause* SgOmpParallelClause::next_node = nullptr;
   41956             : std::vector<unsigned char*> SgOmpParallelClause::pools;
   41957             : 
   41958             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   41959             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   41960             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   41961             : // around this macro definition rather than each use).
   41962             : #ifndef ALLOC_MUTEX
   41963             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   41964             :         do {                                                                     \
   41965             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   41966             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   41967             :                 abort();                                                         \
   41968             :             }                                                                    \
   41969             :         } while (0);
   41970             : #endif
   41971             : 
   41972             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   41973             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   41974             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   41975             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   41976             : 
   41977             : /*! \brief New operator for SgOmpParallelClause.
   41978             : 
   41979             :    This new operator implements memory pools to provide most efficent 
   41980             :    use of the heap within construction of large ASTs.
   41981             : 
   41982             : \internal The new and delete operators use the lower level C malloc/free
   41983             :    function calls for performance and to make sure that mixing of malloc/free
   41984             :    and new/delete by the used can be caught more readily.  This may change
   41985             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   41986             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   41987             :    deallocate memory allocated using ROSE_MALLOC.
   41988             : */
   41989           2 : void *SgOmpParallelClause::operator new ( size_t Size )
   41990             : {
   41991             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   41992             :      * returning or throwing an exception. */
   41993           2 :     ALLOC_MUTEX(SgOmpParallelClause, lock);
   41994             : 
   41995             : #if ROSE_ALLOC_TRACE == 2
   41996             : //    printf("SgOmpParallelClause::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgOmpParallelClause::next_node);
   41997             : #endif
   41998             : 
   41999             : #if USE_CPP_NEW_DELETE_OPERATORS
   42000             :     void *mem = ROSE_MALLOC(Size);
   42001             :     ALLOC_MUTEX(SgOmpParallelClause, unlock);
   42002             :     return mem;
   42003             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   42004             : #if ROSE_PEDANTIC_ALLOC
   42005             :     ROSE_ASSERT(Size == sizeof(SgOmpParallelClause));
   42006             : #else
   42007           2 :     if (Size != sizeof(SgOmpParallelClause)) {
   42008           0 :       void * object = ROSE_MALLOC(Size);
   42009           0 :       ALLOC_MUTEX(SgOmpParallelClause, unlock);
   42010             :       return object;
   42011             :     }
   42012             : #endif
   42013             : 
   42014           2 :     if (SgOmpParallelClause::next_node == nullptr) {
   42015           2 :         SgOmpParallelClause * alloc = (SgOmpParallelClause*) ROSE_MALLOC ( SgOmpParallelClause::pool_size * sizeof(SgOmpParallelClause) );
   42016           2 :         ROSE_ASSERT(alloc != nullptr);
   42017             : 
   42018             : #if ROSE_ALLOC_TRACE == 2
   42019             : //        printf("SgOmpParallelClause::alloc\n  block[%zi] = [ %p , %p [\n", SgOmpParallelClause::pools.size(), alloc, alloc + SgOmpParallelClause::pool_size);
   42020             : #endif
   42021             : 
   42022             : #if ROSE_ALLOC_MEMSET == 1
   42023             : #elif ROSE_ALLOC_MEMSET == 2
   42024             :         memset(alloc, 0x00, SgOmpParallelClause::pool_size * sizeof(SgOmpParallelClause));
   42025             : #elif ROSE_ALLOC_MEMSET == 3
   42026             :         memset(alloc, 0xAA, SgOmpParallelClause::pool_size * sizeof(SgOmpParallelClause));
   42027             : #endif
   42028        4000 :         for (unsigned i=0; i < SgOmpParallelClause::pool_size-1; i++) {
   42029        3998 :           alloc[i].p_freepointer = &(alloc[i+1]);
   42030             :         }
   42031           2 :         alloc[SgOmpParallelClause::pool_size-1].p_freepointer = nullptr;
   42032             : 
   42033           2 :         SgOmpParallelClause::pools.push_back ( (unsigned char *) alloc );
   42034           2 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgOmpParallelClause::pool_size * sizeof(SgOmpParallelClause), V_SgOmpParallelClause ) );
   42035           2 :         SgOmpParallelClause::next_node = alloc;
   42036             :     }
   42037           2 :     ROSE_ASSERT(SgOmpParallelClause::next_node != nullptr);
   42038             : 
   42039           2 :     SgOmpParallelClause * object = SgOmpParallelClause::next_node;
   42040           2 :     SgOmpParallelClause::next_node = (SgOmpParallelClause*)(object->p_freepointer);
   42041             : 
   42042             : #if ROSE_ALLOC_TRACE == 2
   42043             :     printf("SgOmpParallelClause::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpParallelClause::next_node);
   42044             : #endif
   42045             : 
   42046           2 :     SgNode * fp = object->p_freepointer;
   42047             : #if ROSE_ALLOC_MEMSET == 1
   42048             : #elif ROSE_ALLOC_MEMSET == 2
   42049             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpParallelClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   42050             : #elif ROSE_ALLOC_MEMSET == 3
   42051             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgOmpParallelClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   42052             : #endif
   42053           2 :     object->p_freepointer = fp;
   42054             : 
   42055             : #if ROSE_ALLOC_TRACE == 2
   42056             : //    printf("SgOmpParallelClause::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpParallelClause::next_node);
   42057             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   42058             :     Rose::MemPool::snapshot(oss.str());
   42059             :     alloc_trace_cnt++;
   42060             : #endif
   42061             : 
   42062           2 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   42063             : 
   42064           2 :     ALLOC_MUTEX(SgOmpParallelClause, unlock);
   42065             : 
   42066             :     return object;
   42067             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   42068             : }
   42069             : 
   42070             : 
   42071             : 
   42072             : /*! \brief Delete operator for SgOmpParallelClause.
   42073             : 
   42074             :    This delete operator implements deallocation using memory pools to 
   42075             :    provide most efficent use of the heap within construction of large ASTs.
   42076             : 
   42077             : \internal The new and delete operators use the lower level C malloc/free
   42078             :    function calls for performance and to make sure that mixing of malloc/free
   42079             :    and new/delete by the used can be caught more readily.  This may change
   42080             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   42081             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   42082             :    deallocate memory allocated using ROSE_MALLOC.
   42083             : */
   42084           0 : void SgOmpParallelClause::operator delete(void *Pointer, size_t Size)
   42085             : {
   42086             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   42087             :      * or throwing an exception. */
   42088           0 :     ALLOC_MUTEX(SgOmpParallelClause, lock);
   42089             : 
   42090             : #if USE_CPP_NEW_DELETE_OPERATORS
   42091             :     ROSE_FREE(Pointer);
   42092             : #else
   42093             : #if ROSE_PEDANTIC_ALLOC
   42094             :     ROSE_ASSERT(Size == sizeof(SgOmpParallelClause));
   42095             : #else
   42096           0 :     if (Size != sizeof(SgOmpParallelClause)) {
   42097           0 :       ROSE_FREE(Pointer);
   42098           0 :       ALLOC_MUTEX(SgOmpParallelClause, unlock);
   42099             :       return;
   42100             :     }
   42101             : #endif
   42102             : 
   42103           0 :     SgOmpParallelClause * object = (SgOmpParallelClause*) Pointer;
   42104           0 :     ROSE_ASSERT(object != nullptr);
   42105             : 
   42106             : #if ROSE_ALLOC_TRACE == 2
   42107             : //  printf("SgOmpParallelClause::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpParallelClause::next_node);
   42108             :     printf("SgOmpParallelClause::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpParallelClause::next_node);
   42109             : #endif
   42110             : 
   42111             : #if ROSE_PEDANTIC_ALLOC
   42112             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   42113             : #endif
   42114             : 
   42115             : #if ROSE_ALLOC_MEMSET == 1
   42116             : #elif ROSE_ALLOC_MEMSET == 2
   42117             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpParallelClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   42118             : #elif ROSE_ALLOC_MEMSET == 3
   42119             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgOmpParallelClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   42120             : #endif
   42121             : 
   42122             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   42123             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   42124             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   42125             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   42126             : #else
   42127           0 :     object->p_freepointer = SgOmpParallelClause::next_node;
   42128           0 :     SgOmpParallelClause::next_node = object;
   42129             : #endif
   42130             : 
   42131             : #if ROSE_ALLOC_TRACE == 2
   42132             : //  printf("SgOmpParallelClause::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpParallelClause::next_node);
   42133             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   42134             :     Rose::MemPool::snapshot(oss.str());
   42135             :     alloc_trace_cnt++;
   42136             : #endif
   42137             : 
   42138             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   42139             : 
   42140           0 :     ALLOC_MUTEX(SgOmpParallelClause, unlock);
   42141             : }
   42142             : 
   42143             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   42144             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   42145             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   42146             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   42147             : // Also, note comment below from Robb (copied from the Common.code file).
   42148             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   42149             : //
   42150             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   42151             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   42152             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   42153             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   42154             : #if 0
   42155             : void SgOmpParallelClause::operator delete(void* pointer) { SgOmpParallelClause::operator delete (pointer, sizeof(SgOmpParallelClause)); };
   42156             : #endif
   42157             : /* #line 42158 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   42158             : 
   42159             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   42160             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   42161             : // obviously imply C++.
   42162             : 
   42163             : // This implements the support within ROSE for memory pools.  Memory pools
   42164             : // support the most condensed usage of memory within the construction of
   42165             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   42166             : // by a new operator written for each class.
   42167             : 
   42168             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   42169             :     // User wants multi-thread support and POSIX threads are available.
   42170             : #   include <pthread.h>
   42171             :     static pthread_mutex_t SgOmpSectionsClause_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   42172             : #else
   42173             :      // Cause synchronization to be skipped.
   42174             : #    ifndef ALLOC_MUTEX
   42175             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   42176             : #    endif
   42177             : #    ifdef _REENTRANT
   42178             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   42179             : #       ifdef _MSC_VER
   42180             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   42181             : #       else
   42182             : #           warning "POSIX threads are not available; synchronization being skipped"
   42183             : #       endif
   42184             : #    endif
   42185             : #endif
   42186             : 
   42187             : #ifndef ROSE_ALLOC_TRACE
   42188             : #  define ROSE_ALLOC_TRACE 0
   42189             : #endif
   42190             : 
   42191             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   42192             : #define ROSE_ALLOC_TRACE_CNT
   42193             : #include "memory-pool-snapshot.h"
   42194             : unsigned long alloc_trace_cnt = 0;
   42195             : #endif
   42196             : 
   42197             : #if ROSE_ALLOC_TRACE
   42198             : const unsigned SgOmpSectionsClause::pool_size = 5;
   42199             : #else
   42200             : const unsigned SgOmpSectionsClause::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   42201             : #endif
   42202             : 
   42203             : #ifndef ROSE_ALLOC_MEMSET
   42204             : #  define ROSE_ALLOC_MEMSET 0
   42205             : #endif
   42206             : 
   42207             : #ifndef ROSE_PEDANTIC_ALLOC
   42208             : #  define ROSE_PEDANTIC_ALLOC 0
   42209             : #endif
   42210             : 
   42211             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   42212             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   42213             : #endif
   42214             : 
   42215             : #if !defined(SGNODE__ALL_POOLS)
   42216             : #define SGNODE__ALL_POOLS
   42217             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   42218             : #endif
   42219             : 
   42220             : SgOmpSectionsClause* SgOmpSectionsClause::next_node = nullptr;
   42221             : std::vector<unsigned char*> SgOmpSectionsClause::pools;
   42222             : 
   42223             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   42224             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   42225             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   42226             : // around this macro definition rather than each use).
   42227             : #ifndef ALLOC_MUTEX
   42228             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   42229             :         do {                                                                     \
   42230             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   42231             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   42232             :                 abort();                                                         \
   42233             :             }                                                                    \
   42234             :         } while (0);
   42235             : #endif
   42236             : 
   42237             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   42238             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   42239             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   42240             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   42241             : 
   42242             : /*! \brief New operator for SgOmpSectionsClause.
   42243             : 
   42244             :    This new operator implements memory pools to provide most efficent 
   42245             :    use of the heap within construction of large ASTs.
   42246             : 
   42247             : \internal The new and delete operators use the lower level C malloc/free
   42248             :    function calls for performance and to make sure that mixing of malloc/free
   42249             :    and new/delete by the used can be caught more readily.  This may change
   42250             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   42251             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   42252             :    deallocate memory allocated using ROSE_MALLOC.
   42253             : */
   42254           0 : void *SgOmpSectionsClause::operator new ( size_t Size )
   42255             : {
   42256             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   42257             :      * returning or throwing an exception. */
   42258           0 :     ALLOC_MUTEX(SgOmpSectionsClause, lock);
   42259             : 
   42260             : #if ROSE_ALLOC_TRACE == 2
   42261             : //    printf("SgOmpSectionsClause::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgOmpSectionsClause::next_node);
   42262             : #endif
   42263             : 
   42264             : #if USE_CPP_NEW_DELETE_OPERATORS
   42265             :     void *mem = ROSE_MALLOC(Size);
   42266             :     ALLOC_MUTEX(SgOmpSectionsClause, unlock);
   42267             :     return mem;
   42268             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   42269             : #if ROSE_PEDANTIC_ALLOC
   42270             :     ROSE_ASSERT(Size == sizeof(SgOmpSectionsClause));
   42271             : #else
   42272           0 :     if (Size != sizeof(SgOmpSectionsClause)) {
   42273           0 :       void * object = ROSE_MALLOC(Size);
   42274           0 :       ALLOC_MUTEX(SgOmpSectionsClause, unlock);
   42275             :       return object;
   42276             :     }
   42277             : #endif
   42278             : 
   42279           0 :     if (SgOmpSectionsClause::next_node == nullptr) {
   42280           0 :         SgOmpSectionsClause * alloc = (SgOmpSectionsClause*) ROSE_MALLOC ( SgOmpSectionsClause::pool_size * sizeof(SgOmpSectionsClause) );
   42281           0 :         ROSE_ASSERT(alloc != nullptr);
   42282             : 
   42283             : #if ROSE_ALLOC_TRACE == 2
   42284             : //        printf("SgOmpSectionsClause::alloc\n  block[%zi] = [ %p , %p [\n", SgOmpSectionsClause::pools.size(), alloc, alloc + SgOmpSectionsClause::pool_size);
   42285             : #endif
   42286             : 
   42287             : #if ROSE_ALLOC_MEMSET == 1
   42288             : #elif ROSE_ALLOC_MEMSET == 2
   42289             :         memset(alloc, 0x00, SgOmpSectionsClause::pool_size * sizeof(SgOmpSectionsClause));
   42290             : #elif ROSE_ALLOC_MEMSET == 3
   42291             :         memset(alloc, 0xAA, SgOmpSectionsClause::pool_size * sizeof(SgOmpSectionsClause));
   42292             : #endif
   42293           0 :         for (unsigned i=0; i < SgOmpSectionsClause::pool_size-1; i++) {
   42294           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
   42295             :         }
   42296           0 :         alloc[SgOmpSectionsClause::pool_size-1].p_freepointer = nullptr;
   42297             : 
   42298           0 :         SgOmpSectionsClause::pools.push_back ( (unsigned char *) alloc );
   42299           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgOmpSectionsClause::pool_size * sizeof(SgOmpSectionsClause), V_SgOmpSectionsClause ) );
   42300           0 :         SgOmpSectionsClause::next_node = alloc;
   42301             :     }
   42302           0 :     ROSE_ASSERT(SgOmpSectionsClause::next_node != nullptr);
   42303             : 
   42304           0 :     SgOmpSectionsClause * object = SgOmpSectionsClause::next_node;
   42305           0 :     SgOmpSectionsClause::next_node = (SgOmpSectionsClause*)(object->p_freepointer);
   42306             : 
   42307             : #if ROSE_ALLOC_TRACE == 2
   42308             :     printf("SgOmpSectionsClause::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpSectionsClause::next_node);
   42309             : #endif
   42310             : 
   42311           0 :     SgNode * fp = object->p_freepointer;
   42312             : #if ROSE_ALLOC_MEMSET == 1
   42313             : #elif ROSE_ALLOC_MEMSET == 2
   42314             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpSectionsClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   42315             : #elif ROSE_ALLOC_MEMSET == 3
   42316             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgOmpSectionsClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   42317             : #endif
   42318           0 :     object->p_freepointer = fp;
   42319             : 
   42320             : #if ROSE_ALLOC_TRACE == 2
   42321             : //    printf("SgOmpSectionsClause::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpSectionsClause::next_node);
   42322             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   42323             :     Rose::MemPool::snapshot(oss.str());
   42324             :     alloc_trace_cnt++;
   42325             : #endif
   42326             : 
   42327           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   42328             : 
   42329           0 :     ALLOC_MUTEX(SgOmpSectionsClause, unlock);
   42330             : 
   42331             :     return object;
   42332             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   42333             : }
   42334             : 
   42335             : 
   42336             : 
   42337             : /*! \brief Delete operator for SgOmpSectionsClause.
   42338             : 
   42339             :    This delete operator implements deallocation using memory pools to 
   42340             :    provide most efficent use of the heap within construction of large ASTs.
   42341             : 
   42342             : \internal The new and delete operators use the lower level C malloc/free
   42343             :    function calls for performance and to make sure that mixing of malloc/free
   42344             :    and new/delete by the used can be caught more readily.  This may change
   42345             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   42346             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   42347             :    deallocate memory allocated using ROSE_MALLOC.
   42348             : */
   42349           0 : void SgOmpSectionsClause::operator delete(void *Pointer, size_t Size)
   42350             : {
   42351             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   42352             :      * or throwing an exception. */
   42353           0 :     ALLOC_MUTEX(SgOmpSectionsClause, lock);
   42354             : 
   42355             : #if USE_CPP_NEW_DELETE_OPERATORS
   42356             :     ROSE_FREE(Pointer);
   42357             : #else
   42358             : #if ROSE_PEDANTIC_ALLOC
   42359             :     ROSE_ASSERT(Size == sizeof(SgOmpSectionsClause));
   42360             : #else
   42361           0 :     if (Size != sizeof(SgOmpSectionsClause)) {
   42362           0 :       ROSE_FREE(Pointer);
   42363           0 :       ALLOC_MUTEX(SgOmpSectionsClause, unlock);
   42364             :       return;
   42365             :     }
   42366             : #endif
   42367             : 
   42368           0 :     SgOmpSectionsClause * object = (SgOmpSectionsClause*) Pointer;
   42369           0 :     ROSE_ASSERT(object != nullptr);
   42370             : 
   42371             : #if ROSE_ALLOC_TRACE == 2
   42372             : //  printf("SgOmpSectionsClause::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpSectionsClause::next_node);
   42373             :     printf("SgOmpSectionsClause::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpSectionsClause::next_node);
   42374             : #endif
   42375             : 
   42376             : #if ROSE_PEDANTIC_ALLOC
   42377             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   42378             : #endif
   42379             : 
   42380             : #if ROSE_ALLOC_MEMSET == 1
   42381             : #elif ROSE_ALLOC_MEMSET == 2
   42382             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpSectionsClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   42383             : #elif ROSE_ALLOC_MEMSET == 3
   42384             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgOmpSectionsClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   42385             : #endif
   42386             : 
   42387             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   42388             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   42389             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   42390             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   42391             : #else
   42392           0 :     object->p_freepointer = SgOmpSectionsClause::next_node;
   42393           0 :     SgOmpSectionsClause::next_node = object;
   42394             : #endif
   42395             : 
   42396             : #if ROSE_ALLOC_TRACE == 2
   42397             : //  printf("SgOmpSectionsClause::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpSectionsClause::next_node);
   42398             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   42399             :     Rose::MemPool::snapshot(oss.str());
   42400             :     alloc_trace_cnt++;
   42401             : #endif
   42402             : 
   42403             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   42404             : 
   42405           0 :     ALLOC_MUTEX(SgOmpSectionsClause, unlock);
   42406             : }
   42407             : 
   42408             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   42409             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   42410             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   42411             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   42412             : // Also, note comment below from Robb (copied from the Common.code file).
   42413             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   42414             : //
   42415             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   42416             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   42417             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   42418             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   42419             : #if 0
   42420             : void SgOmpSectionsClause::operator delete(void* pointer) { SgOmpSectionsClause::operator delete (pointer, sizeof(SgOmpSectionsClause)); };
   42421             : #endif
   42422             : /* #line 42423 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   42423             : 
   42424             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   42425             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   42426             : // obviously imply C++.
   42427             : 
   42428             : // This implements the support within ROSE for memory pools.  Memory pools
   42429             : // support the most condensed usage of memory within the construction of
   42430             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   42431             : // by a new operator written for each class.
   42432             : 
   42433             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   42434             :     // User wants multi-thread support and POSIX threads are available.
   42435             : #   include <pthread.h>
   42436             :     static pthread_mutex_t SgOmpForClause_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   42437             : #else
   42438             :      // Cause synchronization to be skipped.
   42439             : #    ifndef ALLOC_MUTEX
   42440             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   42441             : #    endif
   42442             : #    ifdef _REENTRANT
   42443             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   42444             : #       ifdef _MSC_VER
   42445             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   42446             : #       else
   42447             : #           warning "POSIX threads are not available; synchronization being skipped"
   42448             : #       endif
   42449             : #    endif
   42450             : #endif
   42451             : 
   42452             : #ifndef ROSE_ALLOC_TRACE
   42453             : #  define ROSE_ALLOC_TRACE 0
   42454             : #endif
   42455             : 
   42456             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   42457             : #define ROSE_ALLOC_TRACE_CNT
   42458             : #include "memory-pool-snapshot.h"
   42459             : unsigned long alloc_trace_cnt = 0;
   42460             : #endif
   42461             : 
   42462             : #if ROSE_ALLOC_TRACE
   42463             : const unsigned SgOmpForClause::pool_size = 5;
   42464             : #else
   42465             : const unsigned SgOmpForClause::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   42466             : #endif
   42467             : 
   42468             : #ifndef ROSE_ALLOC_MEMSET
   42469             : #  define ROSE_ALLOC_MEMSET 0
   42470             : #endif
   42471             : 
   42472             : #ifndef ROSE_PEDANTIC_ALLOC
   42473             : #  define ROSE_PEDANTIC_ALLOC 0
   42474             : #endif
   42475             : 
   42476             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   42477             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   42478             : #endif
   42479             : 
   42480             : #if !defined(SGNODE__ALL_POOLS)
   42481             : #define SGNODE__ALL_POOLS
   42482             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   42483             : #endif
   42484             : 
   42485             : SgOmpForClause* SgOmpForClause::next_node = nullptr;
   42486             : std::vector<unsigned char*> SgOmpForClause::pools;
   42487             : 
   42488             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   42489             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   42490             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   42491             : // around this macro definition rather than each use).
   42492             : #ifndef ALLOC_MUTEX
   42493             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   42494             :         do {                                                                     \
   42495             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   42496             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   42497             :                 abort();                                                         \
   42498             :             }                                                                    \
   42499             :         } while (0);
   42500             : #endif
   42501             : 
   42502             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   42503             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   42504             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   42505             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   42506             : 
   42507             : /*! \brief New operator for SgOmpForClause.
   42508             : 
   42509             :    This new operator implements memory pools to provide most efficent 
   42510             :    use of the heap within construction of large ASTs.
   42511             : 
   42512             : \internal The new and delete operators use the lower level C malloc/free
   42513             :    function calls for performance and to make sure that mixing of malloc/free
   42514             :    and new/delete by the used can be caught more readily.  This may change
   42515             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   42516             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   42517             :    deallocate memory allocated using ROSE_MALLOC.
   42518             : */
   42519           0 : void *SgOmpForClause::operator new ( size_t Size )
   42520             : {
   42521             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   42522             :      * returning or throwing an exception. */
   42523           0 :     ALLOC_MUTEX(SgOmpForClause, lock);
   42524             : 
   42525             : #if ROSE_ALLOC_TRACE == 2
   42526             : //    printf("SgOmpForClause::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgOmpForClause::next_node);
   42527             : #endif
   42528             : 
   42529             : #if USE_CPP_NEW_DELETE_OPERATORS
   42530             :     void *mem = ROSE_MALLOC(Size);
   42531             :     ALLOC_MUTEX(SgOmpForClause, unlock);
   42532             :     return mem;
   42533             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   42534             : #if ROSE_PEDANTIC_ALLOC
   42535             :     ROSE_ASSERT(Size == sizeof(SgOmpForClause));
   42536             : #else
   42537           0 :     if (Size != sizeof(SgOmpForClause)) {
   42538           0 :       void * object = ROSE_MALLOC(Size);
   42539           0 :       ALLOC_MUTEX(SgOmpForClause, unlock);
   42540             :       return object;
   42541             :     }
   42542             : #endif
   42543             : 
   42544           0 :     if (SgOmpForClause::next_node == nullptr) {
   42545           0 :         SgOmpForClause * alloc = (SgOmpForClause*) ROSE_MALLOC ( SgOmpForClause::pool_size * sizeof(SgOmpForClause) );
   42546           0 :         ROSE_ASSERT(alloc != nullptr);
   42547             : 
   42548             : #if ROSE_ALLOC_TRACE == 2
   42549             : //        printf("SgOmpForClause::alloc\n  block[%zi] = [ %p , %p [\n", SgOmpForClause::pools.size(), alloc, alloc + SgOmpForClause::pool_size);
   42550             : #endif
   42551             : 
   42552             : #if ROSE_ALLOC_MEMSET == 1
   42553             : #elif ROSE_ALLOC_MEMSET == 2
   42554             :         memset(alloc, 0x00, SgOmpForClause::pool_size * sizeof(SgOmpForClause));
   42555             : #elif ROSE_ALLOC_MEMSET == 3
   42556             :         memset(alloc, 0xAA, SgOmpForClause::pool_size * sizeof(SgOmpForClause));
   42557             : #endif
   42558           0 :         for (unsigned i=0; i < SgOmpForClause::pool_size-1; i++) {
   42559           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
   42560             :         }
   42561           0 :         alloc[SgOmpForClause::pool_size-1].p_freepointer = nullptr;
   42562             : 
   42563           0 :         SgOmpForClause::pools.push_back ( (unsigned char *) alloc );
   42564           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgOmpForClause::pool_size * sizeof(SgOmpForClause), V_SgOmpForClause ) );
   42565           0 :         SgOmpForClause::next_node = alloc;
   42566             :     }
   42567           0 :     ROSE_ASSERT(SgOmpForClause::next_node != nullptr);
   42568             : 
   42569           0 :     SgOmpForClause * object = SgOmpForClause::next_node;
   42570           0 :     SgOmpForClause::next_node = (SgOmpForClause*)(object->p_freepointer);
   42571             : 
   42572             : #if ROSE_ALLOC_TRACE == 2
   42573             :     printf("SgOmpForClause::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpForClause::next_node);
   42574             : #endif
   42575             : 
   42576           0 :     SgNode * fp = object->p_freepointer;
   42577             : #if ROSE_ALLOC_MEMSET == 1
   42578             : #elif ROSE_ALLOC_MEMSET == 2
   42579             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpForClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   42580             : #elif ROSE_ALLOC_MEMSET == 3
   42581             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgOmpForClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   42582             : #endif
   42583           0 :     object->p_freepointer = fp;
   42584             : 
   42585             : #if ROSE_ALLOC_TRACE == 2
   42586             : //    printf("SgOmpForClause::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpForClause::next_node);
   42587             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   42588             :     Rose::MemPool::snapshot(oss.str());
   42589             :     alloc_trace_cnt++;
   42590             : #endif
   42591             : 
   42592           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   42593             : 
   42594           0 :     ALLOC_MUTEX(SgOmpForClause, unlock);
   42595             : 
   42596             :     return object;
   42597             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   42598             : }
   42599             : 
   42600             : 
   42601             : 
   42602             : /*! \brief Delete operator for SgOmpForClause.
   42603             : 
   42604             :    This delete operator implements deallocation using memory pools to 
   42605             :    provide most efficent use of the heap within construction of large ASTs.
   42606             : 
   42607             : \internal The new and delete operators use the lower level C malloc/free
   42608             :    function calls for performance and to make sure that mixing of malloc/free
   42609             :    and new/delete by the used can be caught more readily.  This may change
   42610             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   42611             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   42612             :    deallocate memory allocated using ROSE_MALLOC.
   42613             : */
   42614           0 : void SgOmpForClause::operator delete(void *Pointer, size_t Size)
   42615             : {
   42616             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   42617             :      * or throwing an exception. */
   42618           0 :     ALLOC_MUTEX(SgOmpForClause, lock);
   42619             : 
   42620             : #if USE_CPP_NEW_DELETE_OPERATORS
   42621             :     ROSE_FREE(Pointer);
   42622             : #else
   42623             : #if ROSE_PEDANTIC_ALLOC
   42624             :     ROSE_ASSERT(Size == sizeof(SgOmpForClause));
   42625             : #else
   42626           0 :     if (Size != sizeof(SgOmpForClause)) {
   42627           0 :       ROSE_FREE(Pointer);
   42628           0 :       ALLOC_MUTEX(SgOmpForClause, unlock);
   42629             :       return;
   42630             :     }
   42631             : #endif
   42632             : 
   42633           0 :     SgOmpForClause * object = (SgOmpForClause*) Pointer;
   42634           0 :     ROSE_ASSERT(object != nullptr);
   42635             : 
   42636             : #if ROSE_ALLOC_TRACE == 2
   42637             : //  printf("SgOmpForClause::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpForClause::next_node);
   42638             :     printf("SgOmpForClause::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpForClause::next_node);
   42639             : #endif
   42640             : 
   42641             : #if ROSE_PEDANTIC_ALLOC
   42642             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   42643             : #endif
   42644             : 
   42645             : #if ROSE_ALLOC_MEMSET == 1
   42646             : #elif ROSE_ALLOC_MEMSET == 2
   42647             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpForClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   42648             : #elif ROSE_ALLOC_MEMSET == 3
   42649             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgOmpForClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   42650             : #endif
   42651             : 
   42652             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   42653             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   42654             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   42655             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   42656             : #else
   42657           0 :     object->p_freepointer = SgOmpForClause::next_node;
   42658           0 :     SgOmpForClause::next_node = object;
   42659             : #endif
   42660             : 
   42661             : #if ROSE_ALLOC_TRACE == 2
   42662             : //  printf("SgOmpForClause::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpForClause::next_node);
   42663             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   42664             :     Rose::MemPool::snapshot(oss.str());
   42665             :     alloc_trace_cnt++;
   42666             : #endif
   42667             : 
   42668             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   42669             : 
   42670           0 :     ALLOC_MUTEX(SgOmpForClause, unlock);
   42671             : }
   42672             : 
   42673             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   42674             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   42675             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   42676             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   42677             : // Also, note comment below from Robb (copied from the Common.code file).
   42678             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   42679             : //
   42680             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   42681             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   42682             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   42683             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   42684             : #if 0
   42685             : void SgOmpForClause::operator delete(void* pointer) { SgOmpForClause::operator delete (pointer, sizeof(SgOmpForClause)); };
   42686             : #endif
   42687             : /* #line 42688 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   42688             : 
   42689             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   42690             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   42691             : // obviously imply C++.
   42692             : 
   42693             : // This implements the support within ROSE for memory pools.  Memory pools
   42694             : // support the most condensed usage of memory within the construction of
   42695             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   42696             : // by a new operator written for each class.
   42697             : 
   42698             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   42699             :     // User wants multi-thread support and POSIX threads are available.
   42700             : #   include <pthread.h>
   42701             :     static pthread_mutex_t SgOmpTaskgroupClause_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   42702             : #else
   42703             :      // Cause synchronization to be skipped.
   42704             : #    ifndef ALLOC_MUTEX
   42705             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   42706             : #    endif
   42707             : #    ifdef _REENTRANT
   42708             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   42709             : #       ifdef _MSC_VER
   42710             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   42711             : #       else
   42712             : #           warning "POSIX threads are not available; synchronization being skipped"
   42713             : #       endif
   42714             : #    endif
   42715             : #endif
   42716             : 
   42717             : #ifndef ROSE_ALLOC_TRACE
   42718             : #  define ROSE_ALLOC_TRACE 0
   42719             : #endif
   42720             : 
   42721             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   42722             : #define ROSE_ALLOC_TRACE_CNT
   42723             : #include "memory-pool-snapshot.h"
   42724             : unsigned long alloc_trace_cnt = 0;
   42725             : #endif
   42726             : 
   42727             : #if ROSE_ALLOC_TRACE
   42728             : const unsigned SgOmpTaskgroupClause::pool_size = 5;
   42729             : #else
   42730             : const unsigned SgOmpTaskgroupClause::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   42731             : #endif
   42732             : 
   42733             : #ifndef ROSE_ALLOC_MEMSET
   42734             : #  define ROSE_ALLOC_MEMSET 0
   42735             : #endif
   42736             : 
   42737             : #ifndef ROSE_PEDANTIC_ALLOC
   42738             : #  define ROSE_PEDANTIC_ALLOC 0
   42739             : #endif
   42740             : 
   42741             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   42742             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   42743             : #endif
   42744             : 
   42745             : #if !defined(SGNODE__ALL_POOLS)
   42746             : #define SGNODE__ALL_POOLS
   42747             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   42748             : #endif
   42749             : 
   42750             : SgOmpTaskgroupClause* SgOmpTaskgroupClause::next_node = nullptr;
   42751             : std::vector<unsigned char*> SgOmpTaskgroupClause::pools;
   42752             : 
   42753             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   42754             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   42755             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   42756             : // around this macro definition rather than each use).
   42757             : #ifndef ALLOC_MUTEX
   42758             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   42759             :         do {                                                                     \
   42760             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   42761             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   42762             :                 abort();                                                         \
   42763             :             }                                                                    \
   42764             :         } while (0);
   42765             : #endif
   42766             : 
   42767             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   42768             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   42769             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   42770             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   42771             : 
   42772             : /*! \brief New operator for SgOmpTaskgroupClause.
   42773             : 
   42774             :    This new operator implements memory pools to provide most efficent 
   42775             :    use of the heap within construction of large ASTs.
   42776             : 
   42777             : \internal The new and delete operators use the lower level C malloc/free
   42778             :    function calls for performance and to make sure that mixing of malloc/free
   42779             :    and new/delete by the used can be caught more readily.  This may change
   42780             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   42781             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   42782             :    deallocate memory allocated using ROSE_MALLOC.
   42783             : */
   42784           0 : void *SgOmpTaskgroupClause::operator new ( size_t Size )
   42785             : {
   42786             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   42787             :      * returning or throwing an exception. */
   42788           0 :     ALLOC_MUTEX(SgOmpTaskgroupClause, lock);
   42789             : 
   42790             : #if ROSE_ALLOC_TRACE == 2
   42791             : //    printf("SgOmpTaskgroupClause::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgOmpTaskgroupClause::next_node);
   42792             : #endif
   42793             : 
   42794             : #if USE_CPP_NEW_DELETE_OPERATORS
   42795             :     void *mem = ROSE_MALLOC(Size);
   42796             :     ALLOC_MUTEX(SgOmpTaskgroupClause, unlock);
   42797             :     return mem;
   42798             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   42799             : #if ROSE_PEDANTIC_ALLOC
   42800             :     ROSE_ASSERT(Size == sizeof(SgOmpTaskgroupClause));
   42801             : #else
   42802           0 :     if (Size != sizeof(SgOmpTaskgroupClause)) {
   42803           0 :       void * object = ROSE_MALLOC(Size);
   42804           0 :       ALLOC_MUTEX(SgOmpTaskgroupClause, unlock);
   42805             :       return object;
   42806             :     }
   42807             : #endif
   42808             : 
   42809           0 :     if (SgOmpTaskgroupClause::next_node == nullptr) {
   42810           0 :         SgOmpTaskgroupClause * alloc = (SgOmpTaskgroupClause*) ROSE_MALLOC ( SgOmpTaskgroupClause::pool_size * sizeof(SgOmpTaskgroupClause) );
   42811           0 :         ROSE_ASSERT(alloc != nullptr);
   42812             : 
   42813             : #if ROSE_ALLOC_TRACE == 2
   42814             : //        printf("SgOmpTaskgroupClause::alloc\n  block[%zi] = [ %p , %p [\n", SgOmpTaskgroupClause::pools.size(), alloc, alloc + SgOmpTaskgroupClause::pool_size);
   42815             : #endif
   42816             : 
   42817             : #if ROSE_ALLOC_MEMSET == 1
   42818             : #elif ROSE_ALLOC_MEMSET == 2
   42819             :         memset(alloc, 0x00, SgOmpTaskgroupClause::pool_size * sizeof(SgOmpTaskgroupClause));
   42820             : #elif ROSE_ALLOC_MEMSET == 3
   42821             :         memset(alloc, 0xAA, SgOmpTaskgroupClause::pool_size * sizeof(SgOmpTaskgroupClause));
   42822             : #endif
   42823           0 :         for (unsigned i=0; i < SgOmpTaskgroupClause::pool_size-1; i++) {
   42824           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
   42825             :         }
   42826           0 :         alloc[SgOmpTaskgroupClause::pool_size-1].p_freepointer = nullptr;
   42827             : 
   42828           0 :         SgOmpTaskgroupClause::pools.push_back ( (unsigned char *) alloc );
   42829           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgOmpTaskgroupClause::pool_size * sizeof(SgOmpTaskgroupClause), V_SgOmpTaskgroupClause ) );
   42830           0 :         SgOmpTaskgroupClause::next_node = alloc;
   42831             :     }
   42832           0 :     ROSE_ASSERT(SgOmpTaskgroupClause::next_node != nullptr);
   42833             : 
   42834           0 :     SgOmpTaskgroupClause * object = SgOmpTaskgroupClause::next_node;
   42835           0 :     SgOmpTaskgroupClause::next_node = (SgOmpTaskgroupClause*)(object->p_freepointer);
   42836             : 
   42837             : #if ROSE_ALLOC_TRACE == 2
   42838             :     printf("SgOmpTaskgroupClause::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpTaskgroupClause::next_node);
   42839             : #endif
   42840             : 
   42841           0 :     SgNode * fp = object->p_freepointer;
   42842             : #if ROSE_ALLOC_MEMSET == 1
   42843             : #elif ROSE_ALLOC_MEMSET == 2
   42844             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpTaskgroupClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   42845             : #elif ROSE_ALLOC_MEMSET == 3
   42846             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgOmpTaskgroupClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   42847             : #endif
   42848           0 :     object->p_freepointer = fp;
   42849             : 
   42850             : #if ROSE_ALLOC_TRACE == 2
   42851             : //    printf("SgOmpTaskgroupClause::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpTaskgroupClause::next_node);
   42852             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   42853             :     Rose::MemPool::snapshot(oss.str());
   42854             :     alloc_trace_cnt++;
   42855             : #endif
   42856             : 
   42857           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   42858             : 
   42859           0 :     ALLOC_MUTEX(SgOmpTaskgroupClause, unlock);
   42860             : 
   42861             :     return object;
   42862             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   42863             : }
   42864             : 
   42865             : 
   42866             : 
   42867             : /*! \brief Delete operator for SgOmpTaskgroupClause.
   42868             : 
   42869             :    This delete operator implements deallocation using memory pools to 
   42870             :    provide most efficent use of the heap within construction of large ASTs.
   42871             : 
   42872             : \internal The new and delete operators use the lower level C malloc/free
   42873             :    function calls for performance and to make sure that mixing of malloc/free
   42874             :    and new/delete by the used can be caught more readily.  This may change
   42875             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   42876             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   42877             :    deallocate memory allocated using ROSE_MALLOC.
   42878             : */
   42879           0 : void SgOmpTaskgroupClause::operator delete(void *Pointer, size_t Size)
   42880             : {
   42881             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   42882             :      * or throwing an exception. */
   42883           0 :     ALLOC_MUTEX(SgOmpTaskgroupClause, lock);
   42884             : 
   42885             : #if USE_CPP_NEW_DELETE_OPERATORS
   42886             :     ROSE_FREE(Pointer);
   42887             : #else
   42888             : #if ROSE_PEDANTIC_ALLOC
   42889             :     ROSE_ASSERT(Size == sizeof(SgOmpTaskgroupClause));
   42890             : #else
   42891           0 :     if (Size != sizeof(SgOmpTaskgroupClause)) {
   42892           0 :       ROSE_FREE(Pointer);
   42893           0 :       ALLOC_MUTEX(SgOmpTaskgroupClause, unlock);
   42894             :       return;
   42895             :     }
   42896             : #endif
   42897             : 
   42898           0 :     SgOmpTaskgroupClause * object = (SgOmpTaskgroupClause*) Pointer;
   42899           0 :     ROSE_ASSERT(object != nullptr);
   42900             : 
   42901             : #if ROSE_ALLOC_TRACE == 2
   42902             : //  printf("SgOmpTaskgroupClause::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpTaskgroupClause::next_node);
   42903             :     printf("SgOmpTaskgroupClause::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpTaskgroupClause::next_node);
   42904             : #endif
   42905             : 
   42906             : #if ROSE_PEDANTIC_ALLOC
   42907             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   42908             : #endif
   42909             : 
   42910             : #if ROSE_ALLOC_MEMSET == 1
   42911             : #elif ROSE_ALLOC_MEMSET == 2
   42912             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpTaskgroupClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   42913             : #elif ROSE_ALLOC_MEMSET == 3
   42914             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgOmpTaskgroupClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   42915             : #endif
   42916             : 
   42917             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   42918             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   42919             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   42920             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   42921             : #else
   42922           0 :     object->p_freepointer = SgOmpTaskgroupClause::next_node;
   42923           0 :     SgOmpTaskgroupClause::next_node = object;
   42924             : #endif
   42925             : 
   42926             : #if ROSE_ALLOC_TRACE == 2
   42927             : //  printf("SgOmpTaskgroupClause::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpTaskgroupClause::next_node);
   42928             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   42929             :     Rose::MemPool::snapshot(oss.str());
   42930             :     alloc_trace_cnt++;
   42931             : #endif
   42932             : 
   42933             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   42934             : 
   42935           0 :     ALLOC_MUTEX(SgOmpTaskgroupClause, unlock);
   42936             : }
   42937             : 
   42938             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   42939             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   42940             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   42941             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   42942             : // Also, note comment below from Robb (copied from the Common.code file).
   42943             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   42944             : //
   42945             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   42946             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   42947             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   42948             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   42949             : #if 0
   42950             : void SgOmpTaskgroupClause::operator delete(void* pointer) { SgOmpTaskgroupClause::operator delete (pointer, sizeof(SgOmpTaskgroupClause)); };
   42951             : #endif
   42952             : /* #line 42953 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   42953             : 
   42954             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   42955             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   42956             : // obviously imply C++.
   42957             : 
   42958             : // This implements the support within ROSE for memory pools.  Memory pools
   42959             : // support the most condensed usage of memory within the construction of
   42960             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   42961             : // by a new operator written for each class.
   42962             : 
   42963             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   42964             :     // User wants multi-thread support and POSIX threads are available.
   42965             : #   include <pthread.h>
   42966             :     static pthread_mutex_t SgOmpNogroupClause_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   42967             : #else
   42968             :      // Cause synchronization to be skipped.
   42969             : #    ifndef ALLOC_MUTEX
   42970             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   42971             : #    endif
   42972             : #    ifdef _REENTRANT
   42973             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   42974             : #       ifdef _MSC_VER
   42975             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   42976             : #       else
   42977             : #           warning "POSIX threads are not available; synchronization being skipped"
   42978             : #       endif
   42979             : #    endif
   42980             : #endif
   42981             : 
   42982             : #ifndef ROSE_ALLOC_TRACE
   42983             : #  define ROSE_ALLOC_TRACE 0
   42984             : #endif
   42985             : 
   42986             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   42987             : #define ROSE_ALLOC_TRACE_CNT
   42988             : #include "memory-pool-snapshot.h"
   42989             : unsigned long alloc_trace_cnt = 0;
   42990             : #endif
   42991             : 
   42992             : #if ROSE_ALLOC_TRACE
   42993             : const unsigned SgOmpNogroupClause::pool_size = 5;
   42994             : #else
   42995             : const unsigned SgOmpNogroupClause::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   42996             : #endif
   42997             : 
   42998             : #ifndef ROSE_ALLOC_MEMSET
   42999             : #  define ROSE_ALLOC_MEMSET 0
   43000             : #endif
   43001             : 
   43002             : #ifndef ROSE_PEDANTIC_ALLOC
   43003             : #  define ROSE_PEDANTIC_ALLOC 0
   43004             : #endif
   43005             : 
   43006             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   43007             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   43008             : #endif
   43009             : 
   43010             : #if !defined(SGNODE__ALL_POOLS)
   43011             : #define SGNODE__ALL_POOLS
   43012             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   43013             : #endif
   43014             : 
   43015             : SgOmpNogroupClause* SgOmpNogroupClause::next_node = nullptr;
   43016             : std::vector<unsigned char*> SgOmpNogroupClause::pools;
   43017             : 
   43018             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   43019             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   43020             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   43021             : // around this macro definition rather than each use).
   43022             : #ifndef ALLOC_MUTEX
   43023             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   43024             :         do {                                                                     \
   43025             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   43026             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   43027             :                 abort();                                                         \
   43028             :             }                                                                    \
   43029             :         } while (0);
   43030             : #endif
   43031             : 
   43032             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   43033             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   43034             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   43035             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   43036             : 
   43037             : /*! \brief New operator for SgOmpNogroupClause.
   43038             : 
   43039             :    This new operator implements memory pools to provide most efficent 
   43040             :    use of the heap within construction of large ASTs.
   43041             : 
   43042             : \internal The new and delete operators use the lower level C malloc/free
   43043             :    function calls for performance and to make sure that mixing of malloc/free
   43044             :    and new/delete by the used can be caught more readily.  This may change
   43045             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   43046             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   43047             :    deallocate memory allocated using ROSE_MALLOC.
   43048             : */
   43049           1 : void *SgOmpNogroupClause::operator new ( size_t Size )
   43050             : {
   43051             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   43052             :      * returning or throwing an exception. */
   43053           1 :     ALLOC_MUTEX(SgOmpNogroupClause, lock);
   43054             : 
   43055             : #if ROSE_ALLOC_TRACE == 2
   43056             : //    printf("SgOmpNogroupClause::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgOmpNogroupClause::next_node);
   43057             : #endif
   43058             : 
   43059             : #if USE_CPP_NEW_DELETE_OPERATORS
   43060             :     void *mem = ROSE_MALLOC(Size);
   43061             :     ALLOC_MUTEX(SgOmpNogroupClause, unlock);
   43062             :     return mem;
   43063             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   43064             : #if ROSE_PEDANTIC_ALLOC
   43065             :     ROSE_ASSERT(Size == sizeof(SgOmpNogroupClause));
   43066             : #else
   43067           1 :     if (Size != sizeof(SgOmpNogroupClause)) {
   43068           0 :       void * object = ROSE_MALLOC(Size);
   43069           0 :       ALLOC_MUTEX(SgOmpNogroupClause, unlock);
   43070             :       return object;
   43071             :     }
   43072             : #endif
   43073             : 
   43074           1 :     if (SgOmpNogroupClause::next_node == nullptr) {
   43075           1 :         SgOmpNogroupClause * alloc = (SgOmpNogroupClause*) ROSE_MALLOC ( SgOmpNogroupClause::pool_size * sizeof(SgOmpNogroupClause) );
   43076           1 :         ROSE_ASSERT(alloc != nullptr);
   43077             : 
   43078             : #if ROSE_ALLOC_TRACE == 2
   43079             : //        printf("SgOmpNogroupClause::alloc\n  block[%zi] = [ %p , %p [\n", SgOmpNogroupClause::pools.size(), alloc, alloc + SgOmpNogroupClause::pool_size);
   43080             : #endif
   43081             : 
   43082             : #if ROSE_ALLOC_MEMSET == 1
   43083             : #elif ROSE_ALLOC_MEMSET == 2
   43084             :         memset(alloc, 0x00, SgOmpNogroupClause::pool_size * sizeof(SgOmpNogroupClause));
   43085             : #elif ROSE_ALLOC_MEMSET == 3
   43086             :         memset(alloc, 0xAA, SgOmpNogroupClause::pool_size * sizeof(SgOmpNogroupClause));
   43087             : #endif
   43088        2000 :         for (unsigned i=0; i < SgOmpNogroupClause::pool_size-1; i++) {
   43089        1999 :           alloc[i].p_freepointer = &(alloc[i+1]);
   43090             :         }
   43091           1 :         alloc[SgOmpNogroupClause::pool_size-1].p_freepointer = nullptr;
   43092             : 
   43093           1 :         SgOmpNogroupClause::pools.push_back ( (unsigned char *) alloc );
   43094           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgOmpNogroupClause::pool_size * sizeof(SgOmpNogroupClause), V_SgOmpNogroupClause ) );
   43095           1 :         SgOmpNogroupClause::next_node = alloc;
   43096             :     }
   43097           1 :     ROSE_ASSERT(SgOmpNogroupClause::next_node != nullptr);
   43098             : 
   43099           1 :     SgOmpNogroupClause * object = SgOmpNogroupClause::next_node;
   43100           1 :     SgOmpNogroupClause::next_node = (SgOmpNogroupClause*)(object->p_freepointer);
   43101             : 
   43102             : #if ROSE_ALLOC_TRACE == 2
   43103             :     printf("SgOmpNogroupClause::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpNogroupClause::next_node);
   43104             : #endif
   43105             : 
   43106           1 :     SgNode * fp = object->p_freepointer;
   43107             : #if ROSE_ALLOC_MEMSET == 1
   43108             : #elif ROSE_ALLOC_MEMSET == 2
   43109             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpNogroupClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   43110             : #elif ROSE_ALLOC_MEMSET == 3
   43111             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgOmpNogroupClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   43112             : #endif
   43113           1 :     object->p_freepointer = fp;
   43114             : 
   43115             : #if ROSE_ALLOC_TRACE == 2
   43116             : //    printf("SgOmpNogroupClause::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpNogroupClause::next_node);
   43117             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   43118             :     Rose::MemPool::snapshot(oss.str());
   43119             :     alloc_trace_cnt++;
   43120             : #endif
   43121             : 
   43122           1 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   43123             : 
   43124           1 :     ALLOC_MUTEX(SgOmpNogroupClause, unlock);
   43125             : 
   43126             :     return object;
   43127             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   43128             : }
   43129             : 
   43130             : 
   43131             : 
   43132             : /*! \brief Delete operator for SgOmpNogroupClause.
   43133             : 
   43134             :    This delete operator implements deallocation using memory pools to 
   43135             :    provide most efficent use of the heap within construction of large ASTs.
   43136             : 
   43137             : \internal The new and delete operators use the lower level C malloc/free
   43138             :    function calls for performance and to make sure that mixing of malloc/free
   43139             :    and new/delete by the used can be caught more readily.  This may change
   43140             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   43141             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   43142             :    deallocate memory allocated using ROSE_MALLOC.
   43143             : */
   43144           0 : void SgOmpNogroupClause::operator delete(void *Pointer, size_t Size)
   43145             : {
   43146             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   43147             :      * or throwing an exception. */
   43148           0 :     ALLOC_MUTEX(SgOmpNogroupClause, lock);
   43149             : 
   43150             : #if USE_CPP_NEW_DELETE_OPERATORS
   43151             :     ROSE_FREE(Pointer);
   43152             : #else
   43153             : #if ROSE_PEDANTIC_ALLOC
   43154             :     ROSE_ASSERT(Size == sizeof(SgOmpNogroupClause));
   43155             : #else
   43156           0 :     if (Size != sizeof(SgOmpNogroupClause)) {
   43157           0 :       ROSE_FREE(Pointer);
   43158           0 :       ALLOC_MUTEX(SgOmpNogroupClause, unlock);
   43159             :       return;
   43160             :     }
   43161             : #endif
   43162             : 
   43163           0 :     SgOmpNogroupClause * object = (SgOmpNogroupClause*) Pointer;
   43164           0 :     ROSE_ASSERT(object != nullptr);
   43165             : 
   43166             : #if ROSE_ALLOC_TRACE == 2
   43167             : //  printf("SgOmpNogroupClause::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpNogroupClause::next_node);
   43168             :     printf("SgOmpNogroupClause::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpNogroupClause::next_node);
   43169             : #endif
   43170             : 
   43171             : #if ROSE_PEDANTIC_ALLOC
   43172             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   43173             : #endif
   43174             : 
   43175             : #if ROSE_ALLOC_MEMSET == 1
   43176             : #elif ROSE_ALLOC_MEMSET == 2
   43177             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpNogroupClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   43178             : #elif ROSE_ALLOC_MEMSET == 3
   43179             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgOmpNogroupClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   43180             : #endif
   43181             : 
   43182             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   43183             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   43184             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   43185             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   43186             : #else
   43187           0 :     object->p_freepointer = SgOmpNogroupClause::next_node;
   43188           0 :     SgOmpNogroupClause::next_node = object;
   43189             : #endif
   43190             : 
   43191             : #if ROSE_ALLOC_TRACE == 2
   43192             : //  printf("SgOmpNogroupClause::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpNogroupClause::next_node);
   43193             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   43194             :     Rose::MemPool::snapshot(oss.str());
   43195             :     alloc_trace_cnt++;
   43196             : #endif
   43197             : 
   43198             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   43199             : 
   43200           0 :     ALLOC_MUTEX(SgOmpNogroupClause, unlock);
   43201             : }
   43202             : 
   43203             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   43204             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   43205             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   43206             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   43207             : // Also, note comment below from Robb (copied from the Common.code file).
   43208             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   43209             : //
   43210             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   43211             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   43212             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   43213             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   43214             : #if 0
   43215             : void SgOmpNogroupClause::operator delete(void* pointer) { SgOmpNogroupClause::operator delete (pointer, sizeof(SgOmpNogroupClause)); };
   43216             : #endif
   43217             : /* #line 43218 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   43218             : 
   43219             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   43220             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   43221             : // obviously imply C++.
   43222             : 
   43223             : // This implements the support within ROSE for memory pools.  Memory pools
   43224             : // support the most condensed usage of memory within the construction of
   43225             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   43226             : // by a new operator written for each class.
   43227             : 
   43228             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   43229             :     // User wants multi-thread support and POSIX threads are available.
   43230             : #   include <pthread.h>
   43231             :     static pthread_mutex_t SgOmpDefaultClause_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   43232             : #else
   43233             :      // Cause synchronization to be skipped.
   43234             : #    ifndef ALLOC_MUTEX
   43235             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   43236             : #    endif
   43237             : #    ifdef _REENTRANT
   43238             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   43239             : #       ifdef _MSC_VER
   43240             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   43241             : #       else
   43242             : #           warning "POSIX threads are not available; synchronization being skipped"
   43243             : #       endif
   43244             : #    endif
   43245             : #endif
   43246             : 
   43247             : #ifndef ROSE_ALLOC_TRACE
   43248             : #  define ROSE_ALLOC_TRACE 0
   43249             : #endif
   43250             : 
   43251             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   43252             : #define ROSE_ALLOC_TRACE_CNT
   43253             : #include "memory-pool-snapshot.h"
   43254             : unsigned long alloc_trace_cnt = 0;
   43255             : #endif
   43256             : 
   43257             : #if ROSE_ALLOC_TRACE
   43258             : const unsigned SgOmpDefaultClause::pool_size = 5;
   43259             : #else
   43260             : const unsigned SgOmpDefaultClause::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   43261             : #endif
   43262             : 
   43263             : #ifndef ROSE_ALLOC_MEMSET
   43264             : #  define ROSE_ALLOC_MEMSET 0
   43265             : #endif
   43266             : 
   43267             : #ifndef ROSE_PEDANTIC_ALLOC
   43268             : #  define ROSE_PEDANTIC_ALLOC 0
   43269             : #endif
   43270             : 
   43271             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   43272             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   43273             : #endif
   43274             : 
   43275             : #if !defined(SGNODE__ALL_POOLS)
   43276             : #define SGNODE__ALL_POOLS
   43277             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   43278             : #endif
   43279             : 
   43280             : SgOmpDefaultClause* SgOmpDefaultClause::next_node = nullptr;
   43281             : std::vector<unsigned char*> SgOmpDefaultClause::pools;
   43282             : 
   43283             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   43284             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   43285             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   43286             : // around this macro definition rather than each use).
   43287             : #ifndef ALLOC_MUTEX
   43288             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   43289             :         do {                                                                     \
   43290             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   43291             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   43292             :                 abort();                                                         \
   43293             :             }                                                                    \
   43294             :         } while (0);
   43295             : #endif
   43296             : 
   43297             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   43298             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   43299             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   43300             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   43301             : 
   43302             : /*! \brief New operator for SgOmpDefaultClause.
   43303             : 
   43304             :    This new operator implements memory pools to provide most efficent 
   43305             :    use of the heap within construction of large ASTs.
   43306             : 
   43307             : \internal The new and delete operators use the lower level C malloc/free
   43308             :    function calls for performance and to make sure that mixing of malloc/free
   43309             :    and new/delete by the used can be caught more readily.  This may change
   43310             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   43311             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   43312             :    deallocate memory allocated using ROSE_MALLOC.
   43313             : */
   43314           5 : void *SgOmpDefaultClause::operator new ( size_t Size )
   43315             : {
   43316             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   43317             :      * returning or throwing an exception. */
   43318           5 :     ALLOC_MUTEX(SgOmpDefaultClause, lock);
   43319             : 
   43320             : #if ROSE_ALLOC_TRACE == 2
   43321             : //    printf("SgOmpDefaultClause::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgOmpDefaultClause::next_node);
   43322             : #endif
   43323             : 
   43324             : #if USE_CPP_NEW_DELETE_OPERATORS
   43325             :     void *mem = ROSE_MALLOC(Size);
   43326             :     ALLOC_MUTEX(SgOmpDefaultClause, unlock);
   43327             :     return mem;
   43328             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   43329             : #if ROSE_PEDANTIC_ALLOC
   43330             :     ROSE_ASSERT(Size == sizeof(SgOmpDefaultClause));
   43331             : #else
   43332           5 :     if (Size != sizeof(SgOmpDefaultClause)) {
   43333           0 :       void * object = ROSE_MALLOC(Size);
   43334           0 :       ALLOC_MUTEX(SgOmpDefaultClause, unlock);
   43335             :       return object;
   43336             :     }
   43337             : #endif
   43338             : 
   43339           5 :     if (SgOmpDefaultClause::next_node == nullptr) {
   43340           5 :         SgOmpDefaultClause * alloc = (SgOmpDefaultClause*) ROSE_MALLOC ( SgOmpDefaultClause::pool_size * sizeof(SgOmpDefaultClause) );
   43341           5 :         ROSE_ASSERT(alloc != nullptr);
   43342             : 
   43343             : #if ROSE_ALLOC_TRACE == 2
   43344             : //        printf("SgOmpDefaultClause::alloc\n  block[%zi] = [ %p , %p [\n", SgOmpDefaultClause::pools.size(), alloc, alloc + SgOmpDefaultClause::pool_size);
   43345             : #endif
   43346             : 
   43347             : #if ROSE_ALLOC_MEMSET == 1
   43348             : #elif ROSE_ALLOC_MEMSET == 2
   43349             :         memset(alloc, 0x00, SgOmpDefaultClause::pool_size * sizeof(SgOmpDefaultClause));
   43350             : #elif ROSE_ALLOC_MEMSET == 3
   43351             :         memset(alloc, 0xAA, SgOmpDefaultClause::pool_size * sizeof(SgOmpDefaultClause));
   43352             : #endif
   43353       10000 :         for (unsigned i=0; i < SgOmpDefaultClause::pool_size-1; i++) {
   43354        9995 :           alloc[i].p_freepointer = &(alloc[i+1]);
   43355             :         }
   43356           5 :         alloc[SgOmpDefaultClause::pool_size-1].p_freepointer = nullptr;
   43357             : 
   43358           5 :         SgOmpDefaultClause::pools.push_back ( (unsigned char *) alloc );
   43359           5 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgOmpDefaultClause::pool_size * sizeof(SgOmpDefaultClause), V_SgOmpDefaultClause ) );
   43360           5 :         SgOmpDefaultClause::next_node = alloc;
   43361             :     }
   43362           5 :     ROSE_ASSERT(SgOmpDefaultClause::next_node != nullptr);
   43363             : 
   43364           5 :     SgOmpDefaultClause * object = SgOmpDefaultClause::next_node;
   43365           5 :     SgOmpDefaultClause::next_node = (SgOmpDefaultClause*)(object->p_freepointer);
   43366             : 
   43367             : #if ROSE_ALLOC_TRACE == 2
   43368             :     printf("SgOmpDefaultClause::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpDefaultClause::next_node);
   43369             : #endif
   43370             : 
   43371           5 :     SgNode * fp = object->p_freepointer;
   43372             : #if ROSE_ALLOC_MEMSET == 1
   43373             : #elif ROSE_ALLOC_MEMSET == 2
   43374             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpDefaultClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   43375             : #elif ROSE_ALLOC_MEMSET == 3
   43376             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgOmpDefaultClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   43377             : #endif
   43378           5 :     object->p_freepointer = fp;
   43379             : 
   43380             : #if ROSE_ALLOC_TRACE == 2
   43381             : //    printf("SgOmpDefaultClause::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpDefaultClause::next_node);
   43382             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   43383             :     Rose::MemPool::snapshot(oss.str());
   43384             :     alloc_trace_cnt++;
   43385             : #endif
   43386             : 
   43387           5 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   43388             : 
   43389           5 :     ALLOC_MUTEX(SgOmpDefaultClause, unlock);
   43390             : 
   43391             :     return object;
   43392             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   43393             : }
   43394             : 
   43395             : 
   43396             : 
   43397             : /*! \brief Delete operator for SgOmpDefaultClause.
   43398             : 
   43399             :    This delete operator implements deallocation using memory pools to 
   43400             :    provide most efficent use of the heap within construction of large ASTs.
   43401             : 
   43402             : \internal The new and delete operators use the lower level C malloc/free
   43403             :    function calls for performance and to make sure that mixing of malloc/free
   43404             :    and new/delete by the used can be caught more readily.  This may change
   43405             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   43406             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   43407             :    deallocate memory allocated using ROSE_MALLOC.
   43408             : */
   43409           0 : void SgOmpDefaultClause::operator delete(void *Pointer, size_t Size)
   43410             : {
   43411             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   43412             :      * or throwing an exception. */
   43413           0 :     ALLOC_MUTEX(SgOmpDefaultClause, lock);
   43414             : 
   43415             : #if USE_CPP_NEW_DELETE_OPERATORS
   43416             :     ROSE_FREE(Pointer);
   43417             : #else
   43418             : #if ROSE_PEDANTIC_ALLOC
   43419             :     ROSE_ASSERT(Size == sizeof(SgOmpDefaultClause));
   43420             : #else
   43421           0 :     if (Size != sizeof(SgOmpDefaultClause)) {
   43422           0 :       ROSE_FREE(Pointer);
   43423           0 :       ALLOC_MUTEX(SgOmpDefaultClause, unlock);
   43424             :       return;
   43425             :     }
   43426             : #endif
   43427             : 
   43428           0 :     SgOmpDefaultClause * object = (SgOmpDefaultClause*) Pointer;
   43429           0 :     ROSE_ASSERT(object != nullptr);
   43430             : 
   43431             : #if ROSE_ALLOC_TRACE == 2
   43432             : //  printf("SgOmpDefaultClause::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpDefaultClause::next_node);
   43433             :     printf("SgOmpDefaultClause::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpDefaultClause::next_node);
   43434             : #endif
   43435             : 
   43436             : #if ROSE_PEDANTIC_ALLOC
   43437             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   43438             : #endif
   43439             : 
   43440             : #if ROSE_ALLOC_MEMSET == 1
   43441             : #elif ROSE_ALLOC_MEMSET == 2
   43442             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpDefaultClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   43443             : #elif ROSE_ALLOC_MEMSET == 3
   43444             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgOmpDefaultClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   43445             : #endif
   43446             : 
   43447             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   43448             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   43449             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   43450             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   43451             : #else
   43452           0 :     object->p_freepointer = SgOmpDefaultClause::next_node;
   43453           0 :     SgOmpDefaultClause::next_node = object;
   43454             : #endif
   43455             : 
   43456             : #if ROSE_ALLOC_TRACE == 2
   43457             : //  printf("SgOmpDefaultClause::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpDefaultClause::next_node);
   43458             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   43459             :     Rose::MemPool::snapshot(oss.str());
   43460             :     alloc_trace_cnt++;
   43461             : #endif
   43462             : 
   43463             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   43464             : 
   43465           0 :     ALLOC_MUTEX(SgOmpDefaultClause, unlock);
   43466             : }
   43467             : 
   43468             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   43469             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   43470             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   43471             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   43472             : // Also, note comment below from Robb (copied from the Common.code file).
   43473             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   43474             : //
   43475             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   43476             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   43477             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   43478             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   43479             : #if 0
   43480             : void SgOmpDefaultClause::operator delete(void* pointer) { SgOmpDefaultClause::operator delete (pointer, sizeof(SgOmpDefaultClause)); };
   43481             : #endif
   43482             : /* #line 43483 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   43483             : 
   43484             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   43485             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   43486             : // obviously imply C++.
   43487             : 
   43488             : // This implements the support within ROSE for memory pools.  Memory pools
   43489             : // support the most condensed usage of memory within the construction of
   43490             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   43491             : // by a new operator written for each class.
   43492             : 
   43493             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   43494             :     // User wants multi-thread support and POSIX threads are available.
   43495             : #   include <pthread.h>
   43496             :     static pthread_mutex_t SgOmpAllocatorClause_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   43497             : #else
   43498             :      // Cause synchronization to be skipped.
   43499             : #    ifndef ALLOC_MUTEX
   43500             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   43501             : #    endif
   43502             : #    ifdef _REENTRANT
   43503             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   43504             : #       ifdef _MSC_VER
   43505             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   43506             : #       else
   43507             : #           warning "POSIX threads are not available; synchronization being skipped"
   43508             : #       endif
   43509             : #    endif
   43510             : #endif
   43511             : 
   43512             : #ifndef ROSE_ALLOC_TRACE
   43513             : #  define ROSE_ALLOC_TRACE 0
   43514             : #endif
   43515             : 
   43516             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   43517             : #define ROSE_ALLOC_TRACE_CNT
   43518             : #include "memory-pool-snapshot.h"
   43519             : unsigned long alloc_trace_cnt = 0;
   43520             : #endif
   43521             : 
   43522             : #if ROSE_ALLOC_TRACE
   43523             : const unsigned SgOmpAllocatorClause::pool_size = 5;
   43524             : #else
   43525             : const unsigned SgOmpAllocatorClause::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   43526             : #endif
   43527             : 
   43528             : #ifndef ROSE_ALLOC_MEMSET
   43529             : #  define ROSE_ALLOC_MEMSET 0
   43530             : #endif
   43531             : 
   43532             : #ifndef ROSE_PEDANTIC_ALLOC
   43533             : #  define ROSE_PEDANTIC_ALLOC 0
   43534             : #endif
   43535             : 
   43536             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   43537             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   43538             : #endif
   43539             : 
   43540             : #if !defined(SGNODE__ALL_POOLS)
   43541             : #define SGNODE__ALL_POOLS
   43542             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   43543             : #endif
   43544             : 
   43545             : SgOmpAllocatorClause* SgOmpAllocatorClause::next_node = nullptr;
   43546             : std::vector<unsigned char*> SgOmpAllocatorClause::pools;
   43547             : 
   43548             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   43549             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   43550             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   43551             : // around this macro definition rather than each use).
   43552             : #ifndef ALLOC_MUTEX
   43553             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   43554             :         do {                                                                     \
   43555             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   43556             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   43557             :                 abort();                                                         \
   43558             :             }                                                                    \
   43559             :         } while (0);
   43560             : #endif
   43561             : 
   43562             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   43563             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   43564             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   43565             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   43566             : 
   43567             : /*! \brief New operator for SgOmpAllocatorClause.
   43568             : 
   43569             :    This new operator implements memory pools to provide most efficent 
   43570             :    use of the heap within construction of large ASTs.
   43571             : 
   43572             : \internal The new and delete operators use the lower level C malloc/free
   43573             :    function calls for performance and to make sure that mixing of malloc/free
   43574             :    and new/delete by the used can be caught more readily.  This may change
   43575             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   43576             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   43577             :    deallocate memory allocated using ROSE_MALLOC.
   43578             : */
   43579           1 : void *SgOmpAllocatorClause::operator new ( size_t Size )
   43580             : {
   43581             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   43582             :      * returning or throwing an exception. */
   43583           1 :     ALLOC_MUTEX(SgOmpAllocatorClause, lock);
   43584             : 
   43585             : #if ROSE_ALLOC_TRACE == 2
   43586             : //    printf("SgOmpAllocatorClause::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgOmpAllocatorClause::next_node);
   43587             : #endif
   43588             : 
   43589             : #if USE_CPP_NEW_DELETE_OPERATORS
   43590             :     void *mem = ROSE_MALLOC(Size);
   43591             :     ALLOC_MUTEX(SgOmpAllocatorClause, unlock);
   43592             :     return mem;
   43593             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   43594             : #if ROSE_PEDANTIC_ALLOC
   43595             :     ROSE_ASSERT(Size == sizeof(SgOmpAllocatorClause));
   43596             : #else
   43597           1 :     if (Size != sizeof(SgOmpAllocatorClause)) {
   43598           0 :       void * object = ROSE_MALLOC(Size);
   43599           0 :       ALLOC_MUTEX(SgOmpAllocatorClause, unlock);
   43600             :       return object;
   43601             :     }
   43602             : #endif
   43603             : 
   43604           1 :     if (SgOmpAllocatorClause::next_node == nullptr) {
   43605           1 :         SgOmpAllocatorClause * alloc = (SgOmpAllocatorClause*) ROSE_MALLOC ( SgOmpAllocatorClause::pool_size * sizeof(SgOmpAllocatorClause) );
   43606           1 :         ROSE_ASSERT(alloc != nullptr);
   43607             : 
   43608             : #if ROSE_ALLOC_TRACE == 2
   43609             : //        printf("SgOmpAllocatorClause::alloc\n  block[%zi] = [ %p , %p [\n", SgOmpAllocatorClause::pools.size(), alloc, alloc + SgOmpAllocatorClause::pool_size);
   43610             : #endif
   43611             : 
   43612             : #if ROSE_ALLOC_MEMSET == 1
   43613             : #elif ROSE_ALLOC_MEMSET == 2
   43614             :         memset(alloc, 0x00, SgOmpAllocatorClause::pool_size * sizeof(SgOmpAllocatorClause));
   43615             : #elif ROSE_ALLOC_MEMSET == 3
   43616             :         memset(alloc, 0xAA, SgOmpAllocatorClause::pool_size * sizeof(SgOmpAllocatorClause));
   43617             : #endif
   43618        2000 :         for (unsigned i=0; i < SgOmpAllocatorClause::pool_size-1; i++) {
   43619        1999 :           alloc[i].p_freepointer = &(alloc[i+1]);
   43620             :         }
   43621           1 :         alloc[SgOmpAllocatorClause::pool_size-1].p_freepointer = nullptr;
   43622             : 
   43623           1 :         SgOmpAllocatorClause::pools.push_back ( (unsigned char *) alloc );
   43624           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgOmpAllocatorClause::pool_size * sizeof(SgOmpAllocatorClause), V_SgOmpAllocatorClause ) );
   43625           1 :         SgOmpAllocatorClause::next_node = alloc;
   43626             :     }
   43627           1 :     ROSE_ASSERT(SgOmpAllocatorClause::next_node != nullptr);
   43628             : 
   43629           1 :     SgOmpAllocatorClause * object = SgOmpAllocatorClause::next_node;
   43630           1 :     SgOmpAllocatorClause::next_node = (SgOmpAllocatorClause*)(object->p_freepointer);
   43631             : 
   43632             : #if ROSE_ALLOC_TRACE == 2
   43633             :     printf("SgOmpAllocatorClause::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpAllocatorClause::next_node);
   43634             : #endif
   43635             : 
   43636           1 :     SgNode * fp = object->p_freepointer;
   43637             : #if ROSE_ALLOC_MEMSET == 1
   43638             : #elif ROSE_ALLOC_MEMSET == 2
   43639             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpAllocatorClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   43640             : #elif ROSE_ALLOC_MEMSET == 3
   43641             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgOmpAllocatorClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   43642             : #endif
   43643           1 :     object->p_freepointer = fp;
   43644             : 
   43645             : #if ROSE_ALLOC_TRACE == 2
   43646             : //    printf("SgOmpAllocatorClause::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpAllocatorClause::next_node);
   43647             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   43648             :     Rose::MemPool::snapshot(oss.str());
   43649             :     alloc_trace_cnt++;
   43650             : #endif
   43651             : 
   43652           1 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   43653             : 
   43654           1 :     ALLOC_MUTEX(SgOmpAllocatorClause, unlock);
   43655             : 
   43656             :     return object;
   43657             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   43658             : }
   43659             : 
   43660             : 
   43661             : 
   43662             : /*! \brief Delete operator for SgOmpAllocatorClause.
   43663             : 
   43664             :    This delete operator implements deallocation using memory pools to 
   43665             :    provide most efficent use of the heap within construction of large ASTs.
   43666             : 
   43667             : \internal The new and delete operators use the lower level C malloc/free
   43668             :    function calls for performance and to make sure that mixing of malloc/free
   43669             :    and new/delete by the used can be caught more readily.  This may change
   43670             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   43671             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   43672             :    deallocate memory allocated using ROSE_MALLOC.
   43673             : */
   43674           0 : void SgOmpAllocatorClause::operator delete(void *Pointer, size_t Size)
   43675             : {
   43676             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   43677             :      * or throwing an exception. */
   43678           0 :     ALLOC_MUTEX(SgOmpAllocatorClause, lock);
   43679             : 
   43680             : #if USE_CPP_NEW_DELETE_OPERATORS
   43681             :     ROSE_FREE(Pointer);
   43682             : #else
   43683             : #if ROSE_PEDANTIC_ALLOC
   43684             :     ROSE_ASSERT(Size == sizeof(SgOmpAllocatorClause));
   43685             : #else
   43686           0 :     if (Size != sizeof(SgOmpAllocatorClause)) {
   43687           0 :       ROSE_FREE(Pointer);
   43688           0 :       ALLOC_MUTEX(SgOmpAllocatorClause, unlock);
   43689             :       return;
   43690             :     }
   43691             : #endif
   43692             : 
   43693           0 :     SgOmpAllocatorClause * object = (SgOmpAllocatorClause*) Pointer;
   43694           0 :     ROSE_ASSERT(object != nullptr);
   43695             : 
   43696             : #if ROSE_ALLOC_TRACE == 2
   43697             : //  printf("SgOmpAllocatorClause::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpAllocatorClause::next_node);
   43698             :     printf("SgOmpAllocatorClause::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpAllocatorClause::next_node);
   43699             : #endif
   43700             : 
   43701             : #if ROSE_PEDANTIC_ALLOC
   43702             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   43703             : #endif
   43704             : 
   43705             : #if ROSE_ALLOC_MEMSET == 1
   43706             : #elif ROSE_ALLOC_MEMSET == 2
   43707             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpAllocatorClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   43708             : #elif ROSE_ALLOC_MEMSET == 3
   43709             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgOmpAllocatorClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   43710             : #endif
   43711             : 
   43712             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   43713             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   43714             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   43715             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   43716             : #else
   43717           0 :     object->p_freepointer = SgOmpAllocatorClause::next_node;
   43718           0 :     SgOmpAllocatorClause::next_node = object;
   43719             : #endif
   43720             : 
   43721             : #if ROSE_ALLOC_TRACE == 2
   43722             : //  printf("SgOmpAllocatorClause::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpAllocatorClause::next_node);
   43723             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   43724             :     Rose::MemPool::snapshot(oss.str());
   43725             :     alloc_trace_cnt++;
   43726             : #endif
   43727             : 
   43728             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   43729             : 
   43730           0 :     ALLOC_MUTEX(SgOmpAllocatorClause, unlock);
   43731             : }
   43732             : 
   43733             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   43734             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   43735             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   43736             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   43737             : // Also, note comment below from Robb (copied from the Common.code file).
   43738             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   43739             : //
   43740             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   43741             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   43742             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   43743             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   43744             : #if 0
   43745             : void SgOmpAllocatorClause::operator delete(void* pointer) { SgOmpAllocatorClause::operator delete (pointer, sizeof(SgOmpAllocatorClause)); };
   43746             : #endif
   43747             : /* #line 43748 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   43748             : 
   43749             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   43750             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   43751             : // obviously imply C++.
   43752             : 
   43753             : // This implements the support within ROSE for memory pools.  Memory pools
   43754             : // support the most condensed usage of memory within the construction of
   43755             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   43756             : // by a new operator written for each class.
   43757             : 
   43758             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   43759             :     // User wants multi-thread support and POSIX threads are available.
   43760             : #   include <pthread.h>
   43761             :     static pthread_mutex_t SgOmpAtomicClause_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   43762             : #else
   43763             :      // Cause synchronization to be skipped.
   43764             : #    ifndef ALLOC_MUTEX
   43765             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   43766             : #    endif
   43767             : #    ifdef _REENTRANT
   43768             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   43769             : #       ifdef _MSC_VER
   43770             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   43771             : #       else
   43772             : #           warning "POSIX threads are not available; synchronization being skipped"
   43773             : #       endif
   43774             : #    endif
   43775             : #endif
   43776             : 
   43777             : #ifndef ROSE_ALLOC_TRACE
   43778             : #  define ROSE_ALLOC_TRACE 0
   43779             : #endif
   43780             : 
   43781             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   43782             : #define ROSE_ALLOC_TRACE_CNT
   43783             : #include "memory-pool-snapshot.h"
   43784             : unsigned long alloc_trace_cnt = 0;
   43785             : #endif
   43786             : 
   43787             : #if ROSE_ALLOC_TRACE
   43788             : const unsigned SgOmpAtomicClause::pool_size = 5;
   43789             : #else
   43790             : const unsigned SgOmpAtomicClause::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   43791             : #endif
   43792             : 
   43793             : #ifndef ROSE_ALLOC_MEMSET
   43794             : #  define ROSE_ALLOC_MEMSET 0
   43795             : #endif
   43796             : 
   43797             : #ifndef ROSE_PEDANTIC_ALLOC
   43798             : #  define ROSE_PEDANTIC_ALLOC 0
   43799             : #endif
   43800             : 
   43801             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   43802             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   43803             : #endif
   43804             : 
   43805             : #if !defined(SGNODE__ALL_POOLS)
   43806             : #define SGNODE__ALL_POOLS
   43807             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   43808             : #endif
   43809             : 
   43810             : SgOmpAtomicClause* SgOmpAtomicClause::next_node = nullptr;
   43811             : std::vector<unsigned char*> SgOmpAtomicClause::pools;
   43812             : 
   43813             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   43814             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   43815             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   43816             : // around this macro definition rather than each use).
   43817             : #ifndef ALLOC_MUTEX
   43818             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   43819             :         do {                                                                     \
   43820             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   43821             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   43822             :                 abort();                                                         \
   43823             :             }                                                                    \
   43824             :         } while (0);
   43825             : #endif
   43826             : 
   43827             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   43828             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   43829             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   43830             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   43831             : 
   43832             : /*! \brief New operator for SgOmpAtomicClause.
   43833             : 
   43834             :    This new operator implements memory pools to provide most efficent 
   43835             :    use of the heap within construction of large ASTs.
   43836             : 
   43837             : \internal The new and delete operators use the lower level C malloc/free
   43838             :    function calls for performance and to make sure that mixing of malloc/free
   43839             :    and new/delete by the used can be caught more readily.  This may change
   43840             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   43841             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   43842             :    deallocate memory allocated using ROSE_MALLOC.
   43843             : */
   43844           0 : void *SgOmpAtomicClause::operator new ( size_t Size )
   43845             : {
   43846             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   43847             :      * returning or throwing an exception. */
   43848           0 :     ALLOC_MUTEX(SgOmpAtomicClause, lock);
   43849             : 
   43850             : #if ROSE_ALLOC_TRACE == 2
   43851             : //    printf("SgOmpAtomicClause::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgOmpAtomicClause::next_node);
   43852             : #endif
   43853             : 
   43854             : #if USE_CPP_NEW_DELETE_OPERATORS
   43855             :     void *mem = ROSE_MALLOC(Size);
   43856             :     ALLOC_MUTEX(SgOmpAtomicClause, unlock);
   43857             :     return mem;
   43858             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   43859             : #if ROSE_PEDANTIC_ALLOC
   43860             :     ROSE_ASSERT(Size == sizeof(SgOmpAtomicClause));
   43861             : #else
   43862           0 :     if (Size != sizeof(SgOmpAtomicClause)) {
   43863           0 :       void * object = ROSE_MALLOC(Size);
   43864           0 :       ALLOC_MUTEX(SgOmpAtomicClause, unlock);
   43865             :       return object;
   43866             :     }
   43867             : #endif
   43868             : 
   43869           0 :     if (SgOmpAtomicClause::next_node == nullptr) {
   43870           0 :         SgOmpAtomicClause * alloc = (SgOmpAtomicClause*) ROSE_MALLOC ( SgOmpAtomicClause::pool_size * sizeof(SgOmpAtomicClause) );
   43871           0 :         ROSE_ASSERT(alloc != nullptr);
   43872             : 
   43873             : #if ROSE_ALLOC_TRACE == 2
   43874             : //        printf("SgOmpAtomicClause::alloc\n  block[%zi] = [ %p , %p [\n", SgOmpAtomicClause::pools.size(), alloc, alloc + SgOmpAtomicClause::pool_size);
   43875             : #endif
   43876             : 
   43877             : #if ROSE_ALLOC_MEMSET == 1
   43878             : #elif ROSE_ALLOC_MEMSET == 2
   43879             :         memset(alloc, 0x00, SgOmpAtomicClause::pool_size * sizeof(SgOmpAtomicClause));
   43880             : #elif ROSE_ALLOC_MEMSET == 3
   43881             :         memset(alloc, 0xAA, SgOmpAtomicClause::pool_size * sizeof(SgOmpAtomicClause));
   43882             : #endif
   43883           0 :         for (unsigned i=0; i < SgOmpAtomicClause::pool_size-1; i++) {
   43884           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
   43885             :         }
   43886           0 :         alloc[SgOmpAtomicClause::pool_size-1].p_freepointer = nullptr;
   43887             : 
   43888           0 :         SgOmpAtomicClause::pools.push_back ( (unsigned char *) alloc );
   43889           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgOmpAtomicClause::pool_size * sizeof(SgOmpAtomicClause), V_SgOmpAtomicClause ) );
   43890           0 :         SgOmpAtomicClause::next_node = alloc;
   43891             :     }
   43892           0 :     ROSE_ASSERT(SgOmpAtomicClause::next_node != nullptr);
   43893             : 
   43894           0 :     SgOmpAtomicClause * object = SgOmpAtomicClause::next_node;
   43895           0 :     SgOmpAtomicClause::next_node = (SgOmpAtomicClause*)(object->p_freepointer);
   43896             : 
   43897             : #if ROSE_ALLOC_TRACE == 2
   43898             :     printf("SgOmpAtomicClause::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpAtomicClause::next_node);
   43899             : #endif
   43900             : 
   43901           0 :     SgNode * fp = object->p_freepointer;
   43902             : #if ROSE_ALLOC_MEMSET == 1
   43903             : #elif ROSE_ALLOC_MEMSET == 2
   43904             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpAtomicClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   43905             : #elif ROSE_ALLOC_MEMSET == 3
   43906             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgOmpAtomicClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   43907             : #endif
   43908           0 :     object->p_freepointer = fp;
   43909             : 
   43910             : #if ROSE_ALLOC_TRACE == 2
   43911             : //    printf("SgOmpAtomicClause::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpAtomicClause::next_node);
   43912             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   43913             :     Rose::MemPool::snapshot(oss.str());
   43914             :     alloc_trace_cnt++;
   43915             : #endif
   43916             : 
   43917           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   43918             : 
   43919           0 :     ALLOC_MUTEX(SgOmpAtomicClause, unlock);
   43920             : 
   43921             :     return object;
   43922             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   43923             : }
   43924             : 
   43925             : 
   43926             : 
   43927             : /*! \brief Delete operator for SgOmpAtomicClause.
   43928             : 
   43929             :    This delete operator implements deallocation using memory pools to 
   43930             :    provide most efficent use of the heap within construction of large ASTs.
   43931             : 
   43932             : \internal The new and delete operators use the lower level C malloc/free
   43933             :    function calls for performance and to make sure that mixing of malloc/free
   43934             :    and new/delete by the used can be caught more readily.  This may change
   43935             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   43936             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   43937             :    deallocate memory allocated using ROSE_MALLOC.
   43938             : */
   43939           0 : void SgOmpAtomicClause::operator delete(void *Pointer, size_t Size)
   43940             : {
   43941             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   43942             :      * or throwing an exception. */
   43943           0 :     ALLOC_MUTEX(SgOmpAtomicClause, lock);
   43944             : 
   43945             : #if USE_CPP_NEW_DELETE_OPERATORS
   43946             :     ROSE_FREE(Pointer);
   43947             : #else
   43948             : #if ROSE_PEDANTIC_ALLOC
   43949             :     ROSE_ASSERT(Size == sizeof(SgOmpAtomicClause));
   43950             : #else
   43951           0 :     if (Size != sizeof(SgOmpAtomicClause)) {
   43952           0 :       ROSE_FREE(Pointer);
   43953           0 :       ALLOC_MUTEX(SgOmpAtomicClause, unlock);
   43954             :       return;
   43955             :     }
   43956             : #endif
   43957             : 
   43958           0 :     SgOmpAtomicClause * object = (SgOmpAtomicClause*) Pointer;
   43959           0 :     ROSE_ASSERT(object != nullptr);
   43960             : 
   43961             : #if ROSE_ALLOC_TRACE == 2
   43962             : //  printf("SgOmpAtomicClause::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpAtomicClause::next_node);
   43963             :     printf("SgOmpAtomicClause::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpAtomicClause::next_node);
   43964             : #endif
   43965             : 
   43966             : #if ROSE_PEDANTIC_ALLOC
   43967             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   43968             : #endif
   43969             : 
   43970             : #if ROSE_ALLOC_MEMSET == 1
   43971             : #elif ROSE_ALLOC_MEMSET == 2
   43972             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpAtomicClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   43973             : #elif ROSE_ALLOC_MEMSET == 3
   43974             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgOmpAtomicClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   43975             : #endif
   43976             : 
   43977             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   43978             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   43979             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   43980             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   43981             : #else
   43982           0 :     object->p_freepointer = SgOmpAtomicClause::next_node;
   43983           0 :     SgOmpAtomicClause::next_node = object;
   43984             : #endif
   43985             : 
   43986             : #if ROSE_ALLOC_TRACE == 2
   43987             : //  printf("SgOmpAtomicClause::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpAtomicClause::next_node);
   43988             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   43989             :     Rose::MemPool::snapshot(oss.str());
   43990             :     alloc_trace_cnt++;
   43991             : #endif
   43992             : 
   43993             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   43994             : 
   43995           0 :     ALLOC_MUTEX(SgOmpAtomicClause, unlock);
   43996             : }
   43997             : 
   43998             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   43999             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   44000             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   44001             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   44002             : // Also, note comment below from Robb (copied from the Common.code file).
   44003             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   44004             : //
   44005             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   44006             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   44007             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   44008             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   44009             : #if 0
   44010             : void SgOmpAtomicClause::operator delete(void* pointer) { SgOmpAtomicClause::operator delete (pointer, sizeof(SgOmpAtomicClause)); };
   44011             : #endif
   44012             : /* #line 44013 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   44013             : 
   44014             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   44015             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   44016             : // obviously imply C++.
   44017             : 
   44018             : // This implements the support within ROSE for memory pools.  Memory pools
   44019             : // support the most condensed usage of memory within the construction of
   44020             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   44021             : // by a new operator written for each class.
   44022             : 
   44023             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   44024             :     // User wants multi-thread support and POSIX threads are available.
   44025             : #   include <pthread.h>
   44026             :     static pthread_mutex_t SgOmpProcBindClause_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   44027             : #else
   44028             :      // Cause synchronization to be skipped.
   44029             : #    ifndef ALLOC_MUTEX
   44030             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   44031             : #    endif
   44032             : #    ifdef _REENTRANT
   44033             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   44034             : #       ifdef _MSC_VER
   44035             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   44036             : #       else
   44037             : #           warning "POSIX threads are not available; synchronization being skipped"
   44038             : #       endif
   44039             : #    endif
   44040             : #endif
   44041             : 
   44042             : #ifndef ROSE_ALLOC_TRACE
   44043             : #  define ROSE_ALLOC_TRACE 0
   44044             : #endif
   44045             : 
   44046             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   44047             : #define ROSE_ALLOC_TRACE_CNT
   44048             : #include "memory-pool-snapshot.h"
   44049             : unsigned long alloc_trace_cnt = 0;
   44050             : #endif
   44051             : 
   44052             : #if ROSE_ALLOC_TRACE
   44053             : const unsigned SgOmpProcBindClause::pool_size = 5;
   44054             : #else
   44055             : const unsigned SgOmpProcBindClause::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   44056             : #endif
   44057             : 
   44058             : #ifndef ROSE_ALLOC_MEMSET
   44059             : #  define ROSE_ALLOC_MEMSET 0
   44060             : #endif
   44061             : 
   44062             : #ifndef ROSE_PEDANTIC_ALLOC
   44063             : #  define ROSE_PEDANTIC_ALLOC 0
   44064             : #endif
   44065             : 
   44066             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   44067             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   44068             : #endif
   44069             : 
   44070             : #if !defined(SGNODE__ALL_POOLS)
   44071             : #define SGNODE__ALL_POOLS
   44072             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   44073             : #endif
   44074             : 
   44075             : SgOmpProcBindClause* SgOmpProcBindClause::next_node = nullptr;
   44076             : std::vector<unsigned char*> SgOmpProcBindClause::pools;
   44077             : 
   44078             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   44079             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   44080             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   44081             : // around this macro definition rather than each use).
   44082             : #ifndef ALLOC_MUTEX
   44083             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   44084             :         do {                                                                     \
   44085             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   44086             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   44087             :                 abort();                                                         \
   44088             :             }                                                                    \
   44089             :         } while (0);
   44090             : #endif
   44091             : 
   44092             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   44093             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   44094             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   44095             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   44096             : 
   44097             : /*! \brief New operator for SgOmpProcBindClause.
   44098             : 
   44099             :    This new operator implements memory pools to provide most efficent 
   44100             :    use of the heap within construction of large ASTs.
   44101             : 
   44102             : \internal The new and delete operators use the lower level C malloc/free
   44103             :    function calls for performance and to make sure that mixing of malloc/free
   44104             :    and new/delete by the used can be caught more readily.  This may change
   44105             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   44106             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   44107             :    deallocate memory allocated using ROSE_MALLOC.
   44108             : */
   44109           3 : void *SgOmpProcBindClause::operator new ( size_t Size )
   44110             : {
   44111             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   44112             :      * returning or throwing an exception. */
   44113           3 :     ALLOC_MUTEX(SgOmpProcBindClause, lock);
   44114             : 
   44115             : #if ROSE_ALLOC_TRACE == 2
   44116             : //    printf("SgOmpProcBindClause::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgOmpProcBindClause::next_node);
   44117             : #endif
   44118             : 
   44119             : #if USE_CPP_NEW_DELETE_OPERATORS
   44120             :     void *mem = ROSE_MALLOC(Size);
   44121             :     ALLOC_MUTEX(SgOmpProcBindClause, unlock);
   44122             :     return mem;
   44123             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   44124             : #if ROSE_PEDANTIC_ALLOC
   44125             :     ROSE_ASSERT(Size == sizeof(SgOmpProcBindClause));
   44126             : #else
   44127           3 :     if (Size != sizeof(SgOmpProcBindClause)) {
   44128           0 :       void * object = ROSE_MALLOC(Size);
   44129           0 :       ALLOC_MUTEX(SgOmpProcBindClause, unlock);
   44130             :       return object;
   44131             :     }
   44132             : #endif
   44133             : 
   44134           3 :     if (SgOmpProcBindClause::next_node == nullptr) {
   44135           1 :         SgOmpProcBindClause * alloc = (SgOmpProcBindClause*) ROSE_MALLOC ( SgOmpProcBindClause::pool_size * sizeof(SgOmpProcBindClause) );
   44136           1 :         ROSE_ASSERT(alloc != nullptr);
   44137             : 
   44138             : #if ROSE_ALLOC_TRACE == 2
   44139             : //        printf("SgOmpProcBindClause::alloc\n  block[%zi] = [ %p , %p [\n", SgOmpProcBindClause::pools.size(), alloc, alloc + SgOmpProcBindClause::pool_size);
   44140             : #endif
   44141             : 
   44142             : #if ROSE_ALLOC_MEMSET == 1
   44143             : #elif ROSE_ALLOC_MEMSET == 2
   44144             :         memset(alloc, 0x00, SgOmpProcBindClause::pool_size * sizeof(SgOmpProcBindClause));
   44145             : #elif ROSE_ALLOC_MEMSET == 3
   44146             :         memset(alloc, 0xAA, SgOmpProcBindClause::pool_size * sizeof(SgOmpProcBindClause));
   44147             : #endif
   44148        2000 :         for (unsigned i=0; i < SgOmpProcBindClause::pool_size-1; i++) {
   44149        1999 :           alloc[i].p_freepointer = &(alloc[i+1]);
   44150             :         }
   44151           1 :         alloc[SgOmpProcBindClause::pool_size-1].p_freepointer = nullptr;
   44152             : 
   44153           1 :         SgOmpProcBindClause::pools.push_back ( (unsigned char *) alloc );
   44154           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgOmpProcBindClause::pool_size * sizeof(SgOmpProcBindClause), V_SgOmpProcBindClause ) );
   44155           1 :         SgOmpProcBindClause::next_node = alloc;
   44156             :     }
   44157           3 :     ROSE_ASSERT(SgOmpProcBindClause::next_node != nullptr);
   44158             : 
   44159           3 :     SgOmpProcBindClause * object = SgOmpProcBindClause::next_node;
   44160           3 :     SgOmpProcBindClause::next_node = (SgOmpProcBindClause*)(object->p_freepointer);
   44161             : 
   44162             : #if ROSE_ALLOC_TRACE == 2
   44163             :     printf("SgOmpProcBindClause::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpProcBindClause::next_node);
   44164             : #endif
   44165             : 
   44166           3 :     SgNode * fp = object->p_freepointer;
   44167             : #if ROSE_ALLOC_MEMSET == 1
   44168             : #elif ROSE_ALLOC_MEMSET == 2
   44169             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpProcBindClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   44170             : #elif ROSE_ALLOC_MEMSET == 3
   44171             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgOmpProcBindClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   44172             : #endif
   44173           3 :     object->p_freepointer = fp;
   44174             : 
   44175             : #if ROSE_ALLOC_TRACE == 2
   44176             : //    printf("SgOmpProcBindClause::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpProcBindClause::next_node);
   44177             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   44178             :     Rose::MemPool::snapshot(oss.str());
   44179             :     alloc_trace_cnt++;
   44180             : #endif
   44181             : 
   44182           3 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   44183             : 
   44184           3 :     ALLOC_MUTEX(SgOmpProcBindClause, unlock);
   44185             : 
   44186             :     return object;
   44187             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   44188             : }
   44189             : 
   44190             : 
   44191             : 
   44192             : /*! \brief Delete operator for SgOmpProcBindClause.
   44193             : 
   44194             :    This delete operator implements deallocation using memory pools to 
   44195             :    provide most efficent use of the heap within construction of large ASTs.
   44196             : 
   44197             : \internal The new and delete operators use the lower level C malloc/free
   44198             :    function calls for performance and to make sure that mixing of malloc/free
   44199             :    and new/delete by the used can be caught more readily.  This may change
   44200             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   44201             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   44202             :    deallocate memory allocated using ROSE_MALLOC.
   44203             : */
   44204           0 : void SgOmpProcBindClause::operator delete(void *Pointer, size_t Size)
   44205             : {
   44206             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   44207             :      * or throwing an exception. */
   44208           0 :     ALLOC_MUTEX(SgOmpProcBindClause, lock);
   44209             : 
   44210             : #if USE_CPP_NEW_DELETE_OPERATORS
   44211             :     ROSE_FREE(Pointer);
   44212             : #else
   44213             : #if ROSE_PEDANTIC_ALLOC
   44214             :     ROSE_ASSERT(Size == sizeof(SgOmpProcBindClause));
   44215             : #else
   44216           0 :     if (Size != sizeof(SgOmpProcBindClause)) {
   44217           0 :       ROSE_FREE(Pointer);
   44218           0 :       ALLOC_MUTEX(SgOmpProcBindClause, unlock);
   44219             :       return;
   44220             :     }
   44221             : #endif
   44222             : 
   44223           0 :     SgOmpProcBindClause * object = (SgOmpProcBindClause*) Pointer;
   44224           0 :     ROSE_ASSERT(object != nullptr);
   44225             : 
   44226             : #if ROSE_ALLOC_TRACE == 2
   44227             : //  printf("SgOmpProcBindClause::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpProcBindClause::next_node);
   44228             :     printf("SgOmpProcBindClause::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpProcBindClause::next_node);
   44229             : #endif
   44230             : 
   44231             : #if ROSE_PEDANTIC_ALLOC
   44232             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   44233             : #endif
   44234             : 
   44235             : #if ROSE_ALLOC_MEMSET == 1
   44236             : #elif ROSE_ALLOC_MEMSET == 2
   44237             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpProcBindClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   44238             : #elif ROSE_ALLOC_MEMSET == 3
   44239             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgOmpProcBindClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   44240             : #endif
   44241             : 
   44242             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   44243             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   44244             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   44245             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   44246             : #else
   44247           0 :     object->p_freepointer = SgOmpProcBindClause::next_node;
   44248           0 :     SgOmpProcBindClause::next_node = object;
   44249             : #endif
   44250             : 
   44251             : #if ROSE_ALLOC_TRACE == 2
   44252             : //  printf("SgOmpProcBindClause::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpProcBindClause::next_node);
   44253             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   44254             :     Rose::MemPool::snapshot(oss.str());
   44255             :     alloc_trace_cnt++;
   44256             : #endif
   44257             : 
   44258             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   44259             : 
   44260           0 :     ALLOC_MUTEX(SgOmpProcBindClause, unlock);
   44261             : }
   44262             : 
   44263             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   44264             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   44265             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   44266             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   44267             : // Also, note comment below from Robb (copied from the Common.code file).
   44268             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   44269             : //
   44270             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   44271             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   44272             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   44273             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   44274             : #if 0
   44275             : void SgOmpProcBindClause::operator delete(void* pointer) { SgOmpProcBindClause::operator delete (pointer, sizeof(SgOmpProcBindClause)); };
   44276             : #endif
   44277             : /* #line 44278 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   44278             : 
   44279             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   44280             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   44281             : // obviously imply C++.
   44282             : 
   44283             : // This implements the support within ROSE for memory pools.  Memory pools
   44284             : // support the most condensed usage of memory within the construction of
   44285             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   44286             : // by a new operator written for each class.
   44287             : 
   44288             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   44289             :     // User wants multi-thread support and POSIX threads are available.
   44290             : #   include <pthread.h>
   44291             :     static pthread_mutex_t SgOmpBindClause_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   44292             : #else
   44293             :      // Cause synchronization to be skipped.
   44294             : #    ifndef ALLOC_MUTEX
   44295             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   44296             : #    endif
   44297             : #    ifdef _REENTRANT
   44298             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   44299             : #       ifdef _MSC_VER
   44300             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   44301             : #       else
   44302             : #           warning "POSIX threads are not available; synchronization being skipped"
   44303             : #       endif
   44304             : #    endif
   44305             : #endif
   44306             : 
   44307             : #ifndef ROSE_ALLOC_TRACE
   44308             : #  define ROSE_ALLOC_TRACE 0
   44309             : #endif
   44310             : 
   44311             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   44312             : #define ROSE_ALLOC_TRACE_CNT
   44313             : #include "memory-pool-snapshot.h"
   44314             : unsigned long alloc_trace_cnt = 0;
   44315             : #endif
   44316             : 
   44317             : #if ROSE_ALLOC_TRACE
   44318             : const unsigned SgOmpBindClause::pool_size = 5;
   44319             : #else
   44320             : const unsigned SgOmpBindClause::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   44321             : #endif
   44322             : 
   44323             : #ifndef ROSE_ALLOC_MEMSET
   44324             : #  define ROSE_ALLOC_MEMSET 0
   44325             : #endif
   44326             : 
   44327             : #ifndef ROSE_PEDANTIC_ALLOC
   44328             : #  define ROSE_PEDANTIC_ALLOC 0
   44329             : #endif
   44330             : 
   44331             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   44332             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   44333             : #endif
   44334             : 
   44335             : #if !defined(SGNODE__ALL_POOLS)
   44336             : #define SGNODE__ALL_POOLS
   44337             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   44338             : #endif
   44339             : 
   44340             : SgOmpBindClause* SgOmpBindClause::next_node = nullptr;
   44341             : std::vector<unsigned char*> SgOmpBindClause::pools;
   44342             : 
   44343             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   44344             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   44345             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   44346             : // around this macro definition rather than each use).
   44347             : #ifndef ALLOC_MUTEX
   44348             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   44349             :         do {                                                                     \
   44350             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   44351             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   44352             :                 abort();                                                         \
   44353             :             }                                                                    \
   44354             :         } while (0);
   44355             : #endif
   44356             : 
   44357             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   44358             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   44359             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   44360             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   44361             : 
   44362             : /*! \brief New operator for SgOmpBindClause.
   44363             : 
   44364             :    This new operator implements memory pools to provide most efficent 
   44365             :    use of the heap within construction of large ASTs.
   44366             : 
   44367             : \internal The new and delete operators use the lower level C malloc/free
   44368             :    function calls for performance and to make sure that mixing of malloc/free
   44369             :    and new/delete by the used can be caught more readily.  This may change
   44370             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   44371             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   44372             :    deallocate memory allocated using ROSE_MALLOC.
   44373             : */
   44374           1 : void *SgOmpBindClause::operator new ( size_t Size )
   44375             : {
   44376             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   44377             :      * returning or throwing an exception. */
   44378           1 :     ALLOC_MUTEX(SgOmpBindClause, lock);
   44379             : 
   44380             : #if ROSE_ALLOC_TRACE == 2
   44381             : //    printf("SgOmpBindClause::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgOmpBindClause::next_node);
   44382             : #endif
   44383             : 
   44384             : #if USE_CPP_NEW_DELETE_OPERATORS
   44385             :     void *mem = ROSE_MALLOC(Size);
   44386             :     ALLOC_MUTEX(SgOmpBindClause, unlock);
   44387             :     return mem;
   44388             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   44389             : #if ROSE_PEDANTIC_ALLOC
   44390             :     ROSE_ASSERT(Size == sizeof(SgOmpBindClause));
   44391             : #else
   44392           1 :     if (Size != sizeof(SgOmpBindClause)) {
   44393           0 :       void * object = ROSE_MALLOC(Size);
   44394           0 :       ALLOC_MUTEX(SgOmpBindClause, unlock);
   44395             :       return object;
   44396             :     }
   44397             : #endif
   44398             : 
   44399           1 :     if (SgOmpBindClause::next_node == nullptr) {
   44400           1 :         SgOmpBindClause * alloc = (SgOmpBindClause*) ROSE_MALLOC ( SgOmpBindClause::pool_size * sizeof(SgOmpBindClause) );
   44401           1 :         ROSE_ASSERT(alloc != nullptr);
   44402             : 
   44403             : #if ROSE_ALLOC_TRACE == 2
   44404             : //        printf("SgOmpBindClause::alloc\n  block[%zi] = [ %p , %p [\n", SgOmpBindClause::pools.size(), alloc, alloc + SgOmpBindClause::pool_size);
   44405             : #endif
   44406             : 
   44407             : #if ROSE_ALLOC_MEMSET == 1
   44408             : #elif ROSE_ALLOC_MEMSET == 2
   44409             :         memset(alloc, 0x00, SgOmpBindClause::pool_size * sizeof(SgOmpBindClause));
   44410             : #elif ROSE_ALLOC_MEMSET == 3
   44411             :         memset(alloc, 0xAA, SgOmpBindClause::pool_size * sizeof(SgOmpBindClause));
   44412             : #endif
   44413        2000 :         for (unsigned i=0; i < SgOmpBindClause::pool_size-1; i++) {
   44414        1999 :           alloc[i].p_freepointer = &(alloc[i+1]);
   44415             :         }
   44416           1 :         alloc[SgOmpBindClause::pool_size-1].p_freepointer = nullptr;
   44417             : 
   44418           1 :         SgOmpBindClause::pools.push_back ( (unsigned char *) alloc );
   44419           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgOmpBindClause::pool_size * sizeof(SgOmpBindClause), V_SgOmpBindClause ) );
   44420           1 :         SgOmpBindClause::next_node = alloc;
   44421             :     }
   44422           1 :     ROSE_ASSERT(SgOmpBindClause::next_node != nullptr);
   44423             : 
   44424           1 :     SgOmpBindClause * object = SgOmpBindClause::next_node;
   44425           1 :     SgOmpBindClause::next_node = (SgOmpBindClause*)(object->p_freepointer);
   44426             : 
   44427             : #if ROSE_ALLOC_TRACE == 2
   44428             :     printf("SgOmpBindClause::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpBindClause::next_node);
   44429             : #endif
   44430             : 
   44431           1 :     SgNode * fp = object->p_freepointer;
   44432             : #if ROSE_ALLOC_MEMSET == 1
   44433             : #elif ROSE_ALLOC_MEMSET == 2
   44434             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpBindClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   44435             : #elif ROSE_ALLOC_MEMSET == 3
   44436             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgOmpBindClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   44437             : #endif
   44438           1 :     object->p_freepointer = fp;
   44439             : 
   44440             : #if ROSE_ALLOC_TRACE == 2
   44441             : //    printf("SgOmpBindClause::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpBindClause::next_node);
   44442             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   44443             :     Rose::MemPool::snapshot(oss.str());
   44444             :     alloc_trace_cnt++;
   44445             : #endif
   44446             : 
   44447           1 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   44448             : 
   44449           1 :     ALLOC_MUTEX(SgOmpBindClause, unlock);
   44450             : 
   44451             :     return object;
   44452             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   44453             : }
   44454             : 
   44455             : 
   44456             : 
   44457             : /*! \brief Delete operator for SgOmpBindClause.
   44458             : 
   44459             :    This delete operator implements deallocation using memory pools to 
   44460             :    provide most efficent use of the heap within construction of large ASTs.
   44461             : 
   44462             : \internal The new and delete operators use the lower level C malloc/free
   44463             :    function calls for performance and to make sure that mixing of malloc/free
   44464             :    and new/delete by the used can be caught more readily.  This may change
   44465             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   44466             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   44467             :    deallocate memory allocated using ROSE_MALLOC.
   44468             : */
   44469           0 : void SgOmpBindClause::operator delete(void *Pointer, size_t Size)
   44470             : {
   44471             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   44472             :      * or throwing an exception. */
   44473           0 :     ALLOC_MUTEX(SgOmpBindClause, lock);
   44474             : 
   44475             : #if USE_CPP_NEW_DELETE_OPERATORS
   44476             :     ROSE_FREE(Pointer);
   44477             : #else
   44478             : #if ROSE_PEDANTIC_ALLOC
   44479             :     ROSE_ASSERT(Size == sizeof(SgOmpBindClause));
   44480             : #else
   44481           0 :     if (Size != sizeof(SgOmpBindClause)) {
   44482           0 :       ROSE_FREE(Pointer);
   44483           0 :       ALLOC_MUTEX(SgOmpBindClause, unlock);
   44484             :       return;
   44485             :     }
   44486             : #endif
   44487             : 
   44488           0 :     SgOmpBindClause * object = (SgOmpBindClause*) Pointer;
   44489           0 :     ROSE_ASSERT(object != nullptr);
   44490             : 
   44491             : #if ROSE_ALLOC_TRACE == 2
   44492             : //  printf("SgOmpBindClause::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpBindClause::next_node);
   44493             :     printf("SgOmpBindClause::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpBindClause::next_node);
   44494             : #endif
   44495             : 
   44496             : #if ROSE_PEDANTIC_ALLOC
   44497             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   44498             : #endif
   44499             : 
   44500             : #if ROSE_ALLOC_MEMSET == 1
   44501             : #elif ROSE_ALLOC_MEMSET == 2
   44502             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpBindClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   44503             : #elif ROSE_ALLOC_MEMSET == 3
   44504             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgOmpBindClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   44505             : #endif
   44506             : 
   44507             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   44508             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   44509             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   44510             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   44511             : #else
   44512           0 :     object->p_freepointer = SgOmpBindClause::next_node;
   44513           0 :     SgOmpBindClause::next_node = object;
   44514             : #endif
   44515             : 
   44516             : #if ROSE_ALLOC_TRACE == 2
   44517             : //  printf("SgOmpBindClause::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpBindClause::next_node);
   44518             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   44519             :     Rose::MemPool::snapshot(oss.str());
   44520             :     alloc_trace_cnt++;
   44521             : #endif
   44522             : 
   44523             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   44524             : 
   44525           0 :     ALLOC_MUTEX(SgOmpBindClause, unlock);
   44526             : }
   44527             : 
   44528             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   44529             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   44530             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   44531             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   44532             : // Also, note comment below from Robb (copied from the Common.code file).
   44533             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   44534             : //
   44535             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   44536             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   44537             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   44538             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   44539             : #if 0
   44540             : void SgOmpBindClause::operator delete(void* pointer) { SgOmpBindClause::operator delete (pointer, sizeof(SgOmpBindClause)); };
   44541             : #endif
   44542             : /* #line 44543 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   44543             : 
   44544             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   44545             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   44546             : // obviously imply C++.
   44547             : 
   44548             : // This implements the support within ROSE for memory pools.  Memory pools
   44549             : // support the most condensed usage of memory within the construction of
   44550             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   44551             : // by a new operator written for each class.
   44552             : 
   44553             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   44554             :     // User wants multi-thread support and POSIX threads are available.
   44555             : #   include <pthread.h>
   44556             :     static pthread_mutex_t SgOmpOrderClause_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   44557             : #else
   44558             :      // Cause synchronization to be skipped.
   44559             : #    ifndef ALLOC_MUTEX
   44560             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   44561             : #    endif
   44562             : #    ifdef _REENTRANT
   44563             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   44564             : #       ifdef _MSC_VER
   44565             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   44566             : #       else
   44567             : #           warning "POSIX threads are not available; synchronization being skipped"
   44568             : #       endif
   44569             : #    endif
   44570             : #endif
   44571             : 
   44572             : #ifndef ROSE_ALLOC_TRACE
   44573             : #  define ROSE_ALLOC_TRACE 0
   44574             : #endif
   44575             : 
   44576             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   44577             : #define ROSE_ALLOC_TRACE_CNT
   44578             : #include "memory-pool-snapshot.h"
   44579             : unsigned long alloc_trace_cnt = 0;
   44580             : #endif
   44581             : 
   44582             : #if ROSE_ALLOC_TRACE
   44583             : const unsigned SgOmpOrderClause::pool_size = 5;
   44584             : #else
   44585             : const unsigned SgOmpOrderClause::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   44586             : #endif
   44587             : 
   44588             : #ifndef ROSE_ALLOC_MEMSET
   44589             : #  define ROSE_ALLOC_MEMSET 0
   44590             : #endif
   44591             : 
   44592             : #ifndef ROSE_PEDANTIC_ALLOC
   44593             : #  define ROSE_PEDANTIC_ALLOC 0
   44594             : #endif
   44595             : 
   44596             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   44597             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   44598             : #endif
   44599             : 
   44600             : #if !defined(SGNODE__ALL_POOLS)
   44601             : #define SGNODE__ALL_POOLS
   44602             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   44603             : #endif
   44604             : 
   44605             : SgOmpOrderClause* SgOmpOrderClause::next_node = nullptr;
   44606             : std::vector<unsigned char*> SgOmpOrderClause::pools;
   44607             : 
   44608             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   44609             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   44610             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   44611             : // around this macro definition rather than each use).
   44612             : #ifndef ALLOC_MUTEX
   44613             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   44614             :         do {                                                                     \
   44615             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   44616             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   44617             :                 abort();                                                         \
   44618             :             }                                                                    \
   44619             :         } while (0);
   44620             : #endif
   44621             : 
   44622             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   44623             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   44624             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   44625             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   44626             : 
   44627             : /*! \brief New operator for SgOmpOrderClause.
   44628             : 
   44629             :    This new operator implements memory pools to provide most efficent 
   44630             :    use of the heap within construction of large ASTs.
   44631             : 
   44632             : \internal The new and delete operators use the lower level C malloc/free
   44633             :    function calls for performance and to make sure that mixing of malloc/free
   44634             :    and new/delete by the used can be caught more readily.  This may change
   44635             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   44636             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   44637             :    deallocate memory allocated using ROSE_MALLOC.
   44638             : */
   44639           1 : void *SgOmpOrderClause::operator new ( size_t Size )
   44640             : {
   44641             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   44642             :      * returning or throwing an exception. */
   44643           1 :     ALLOC_MUTEX(SgOmpOrderClause, lock);
   44644             : 
   44645             : #if ROSE_ALLOC_TRACE == 2
   44646             : //    printf("SgOmpOrderClause::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgOmpOrderClause::next_node);
   44647             : #endif
   44648             : 
   44649             : #if USE_CPP_NEW_DELETE_OPERATORS
   44650             :     void *mem = ROSE_MALLOC(Size);
   44651             :     ALLOC_MUTEX(SgOmpOrderClause, unlock);
   44652             :     return mem;
   44653             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   44654             : #if ROSE_PEDANTIC_ALLOC
   44655             :     ROSE_ASSERT(Size == sizeof(SgOmpOrderClause));
   44656             : #else
   44657           1 :     if (Size != sizeof(SgOmpOrderClause)) {
   44658           0 :       void * object = ROSE_MALLOC(Size);
   44659           0 :       ALLOC_MUTEX(SgOmpOrderClause, unlock);
   44660             :       return object;
   44661             :     }
   44662             : #endif
   44663             : 
   44664           1 :     if (SgOmpOrderClause::next_node == nullptr) {
   44665           1 :         SgOmpOrderClause * alloc = (SgOmpOrderClause*) ROSE_MALLOC ( SgOmpOrderClause::pool_size * sizeof(SgOmpOrderClause) );
   44666           1 :         ROSE_ASSERT(alloc != nullptr);
   44667             : 
   44668             : #if ROSE_ALLOC_TRACE == 2
   44669             : //        printf("SgOmpOrderClause::alloc\n  block[%zi] = [ %p , %p [\n", SgOmpOrderClause::pools.size(), alloc, alloc + SgOmpOrderClause::pool_size);
   44670             : #endif
   44671             : 
   44672             : #if ROSE_ALLOC_MEMSET == 1
   44673             : #elif ROSE_ALLOC_MEMSET == 2
   44674             :         memset(alloc, 0x00, SgOmpOrderClause::pool_size * sizeof(SgOmpOrderClause));
   44675             : #elif ROSE_ALLOC_MEMSET == 3
   44676             :         memset(alloc, 0xAA, SgOmpOrderClause::pool_size * sizeof(SgOmpOrderClause));
   44677             : #endif
   44678        2000 :         for (unsigned i=0; i < SgOmpOrderClause::pool_size-1; i++) {
   44679        1999 :           alloc[i].p_freepointer = &(alloc[i+1]);
   44680             :         }
   44681           1 :         alloc[SgOmpOrderClause::pool_size-1].p_freepointer = nullptr;
   44682             : 
   44683           1 :         SgOmpOrderClause::pools.push_back ( (unsigned char *) alloc );
   44684           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgOmpOrderClause::pool_size * sizeof(SgOmpOrderClause), V_SgOmpOrderClause ) );
   44685           1 :         SgOmpOrderClause::next_node = alloc;
   44686             :     }
   44687           1 :     ROSE_ASSERT(SgOmpOrderClause::next_node != nullptr);
   44688             : 
   44689           1 :     SgOmpOrderClause * object = SgOmpOrderClause::next_node;
   44690           1 :     SgOmpOrderClause::next_node = (SgOmpOrderClause*)(object->p_freepointer);
   44691             : 
   44692             : #if ROSE_ALLOC_TRACE == 2
   44693             :     printf("SgOmpOrderClause::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpOrderClause::next_node);
   44694             : #endif
   44695             : 
   44696           1 :     SgNode * fp = object->p_freepointer;
   44697             : #if ROSE_ALLOC_MEMSET == 1
   44698             : #elif ROSE_ALLOC_MEMSET == 2
   44699             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpOrderClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   44700             : #elif ROSE_ALLOC_MEMSET == 3
   44701             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgOmpOrderClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   44702             : #endif
   44703           1 :     object->p_freepointer = fp;
   44704             : 
   44705             : #if ROSE_ALLOC_TRACE == 2
   44706             : //    printf("SgOmpOrderClause::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpOrderClause::next_node);
   44707             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   44708             :     Rose::MemPool::snapshot(oss.str());
   44709             :     alloc_trace_cnt++;
   44710             : #endif
   44711             : 
   44712           1 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   44713             : 
   44714           1 :     ALLOC_MUTEX(SgOmpOrderClause, unlock);
   44715             : 
   44716             :     return object;
   44717             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   44718             : }
   44719             : 
   44720             : 
   44721             : 
   44722             : /*! \brief Delete operator for SgOmpOrderClause.
   44723             : 
   44724             :    This delete operator implements deallocation using memory pools to 
   44725             :    provide most efficent use of the heap within construction of large ASTs.
   44726             : 
   44727             : \internal The new and delete operators use the lower level C malloc/free
   44728             :    function calls for performance and to make sure that mixing of malloc/free
   44729             :    and new/delete by the used can be caught more readily.  This may change
   44730             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   44731             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   44732             :    deallocate memory allocated using ROSE_MALLOC.
   44733             : */
   44734           0 : void SgOmpOrderClause::operator delete(void *Pointer, size_t Size)
   44735             : {
   44736             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   44737             :      * or throwing an exception. */
   44738           0 :     ALLOC_MUTEX(SgOmpOrderClause, lock);
   44739             : 
   44740             : #if USE_CPP_NEW_DELETE_OPERATORS
   44741             :     ROSE_FREE(Pointer);
   44742             : #else
   44743             : #if ROSE_PEDANTIC_ALLOC
   44744             :     ROSE_ASSERT(Size == sizeof(SgOmpOrderClause));
   44745             : #else
   44746           0 :     if (Size != sizeof(SgOmpOrderClause)) {
   44747           0 :       ROSE_FREE(Pointer);
   44748           0 :       ALLOC_MUTEX(SgOmpOrderClause, unlock);
   44749             :       return;
   44750             :     }
   44751             : #endif
   44752             : 
   44753           0 :     SgOmpOrderClause * object = (SgOmpOrderClause*) Pointer;
   44754           0 :     ROSE_ASSERT(object != nullptr);
   44755             : 
   44756             : #if ROSE_ALLOC_TRACE == 2
   44757             : //  printf("SgOmpOrderClause::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpOrderClause::next_node);
   44758             :     printf("SgOmpOrderClause::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpOrderClause::next_node);
   44759             : #endif
   44760             : 
   44761             : #if ROSE_PEDANTIC_ALLOC
   44762             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   44763             : #endif
   44764             : 
   44765             : #if ROSE_ALLOC_MEMSET == 1
   44766             : #elif ROSE_ALLOC_MEMSET == 2
   44767             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpOrderClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   44768             : #elif ROSE_ALLOC_MEMSET == 3
   44769             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgOmpOrderClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   44770             : #endif
   44771             : 
   44772             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   44773             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   44774             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   44775             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   44776             : #else
   44777           0 :     object->p_freepointer = SgOmpOrderClause::next_node;
   44778           0 :     SgOmpOrderClause::next_node = object;
   44779             : #endif
   44780             : 
   44781             : #if ROSE_ALLOC_TRACE == 2
   44782             : //  printf("SgOmpOrderClause::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpOrderClause::next_node);
   44783             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   44784             :     Rose::MemPool::snapshot(oss.str());
   44785             :     alloc_trace_cnt++;
   44786             : #endif
   44787             : 
   44788             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   44789             : 
   44790           0 :     ALLOC_MUTEX(SgOmpOrderClause, unlock);
   44791             : }
   44792             : 
   44793             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   44794             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   44795             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   44796             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   44797             : // Also, note comment below from Robb (copied from the Common.code file).
   44798             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   44799             : //
   44800             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   44801             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   44802             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   44803             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   44804             : #if 0
   44805             : void SgOmpOrderClause::operator delete(void* pointer) { SgOmpOrderClause::operator delete (pointer, sizeof(SgOmpOrderClause)); };
   44806             : #endif
   44807             : /* #line 44808 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   44808             : 
   44809             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   44810             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   44811             : // obviously imply C++.
   44812             : 
   44813             : // This implements the support within ROSE for memory pools.  Memory pools
   44814             : // support the most condensed usage of memory within the construction of
   44815             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   44816             : // by a new operator written for each class.
   44817             : 
   44818             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   44819             :     // User wants multi-thread support and POSIX threads are available.
   44820             : #   include <pthread.h>
   44821             :     static pthread_mutex_t SgOmpDistScheduleClause_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   44822             : #else
   44823             :      // Cause synchronization to be skipped.
   44824             : #    ifndef ALLOC_MUTEX
   44825             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   44826             : #    endif
   44827             : #    ifdef _REENTRANT
   44828             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   44829             : #       ifdef _MSC_VER
   44830             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   44831             : #       else
   44832             : #           warning "POSIX threads are not available; synchronization being skipped"
   44833             : #       endif
   44834             : #    endif
   44835             : #endif
   44836             : 
   44837             : #ifndef ROSE_ALLOC_TRACE
   44838             : #  define ROSE_ALLOC_TRACE 0
   44839             : #endif
   44840             : 
   44841             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   44842             : #define ROSE_ALLOC_TRACE_CNT
   44843             : #include "memory-pool-snapshot.h"
   44844             : unsigned long alloc_trace_cnt = 0;
   44845             : #endif
   44846             : 
   44847             : #if ROSE_ALLOC_TRACE
   44848             : const unsigned SgOmpDistScheduleClause::pool_size = 5;
   44849             : #else
   44850             : const unsigned SgOmpDistScheduleClause::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   44851             : #endif
   44852             : 
   44853             : #ifndef ROSE_ALLOC_MEMSET
   44854             : #  define ROSE_ALLOC_MEMSET 0
   44855             : #endif
   44856             : 
   44857             : #ifndef ROSE_PEDANTIC_ALLOC
   44858             : #  define ROSE_PEDANTIC_ALLOC 0
   44859             : #endif
   44860             : 
   44861             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   44862             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   44863             : #endif
   44864             : 
   44865             : #if !defined(SGNODE__ALL_POOLS)
   44866             : #define SGNODE__ALL_POOLS
   44867             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   44868             : #endif
   44869             : 
   44870             : SgOmpDistScheduleClause* SgOmpDistScheduleClause::next_node = nullptr;
   44871             : std::vector<unsigned char*> SgOmpDistScheduleClause::pools;
   44872             : 
   44873             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   44874             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   44875             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   44876             : // around this macro definition rather than each use).
   44877             : #ifndef ALLOC_MUTEX
   44878             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   44879             :         do {                                                                     \
   44880             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   44881             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   44882             :                 abort();                                                         \
   44883             :             }                                                                    \
   44884             :         } while (0);
   44885             : #endif
   44886             : 
   44887             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   44888             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   44889             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   44890             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   44891             : 
   44892             : /*! \brief New operator for SgOmpDistScheduleClause.
   44893             : 
   44894             :    This new operator implements memory pools to provide most efficent 
   44895             :    use of the heap within construction of large ASTs.
   44896             : 
   44897             : \internal The new and delete operators use the lower level C malloc/free
   44898             :    function calls for performance and to make sure that mixing of malloc/free
   44899             :    and new/delete by the used can be caught more readily.  This may change
   44900             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   44901             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   44902             :    deallocate memory allocated using ROSE_MALLOC.
   44903             : */
   44904           1 : void *SgOmpDistScheduleClause::operator new ( size_t Size )
   44905             : {
   44906             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   44907             :      * returning or throwing an exception. */
   44908           1 :     ALLOC_MUTEX(SgOmpDistScheduleClause, lock);
   44909             : 
   44910             : #if ROSE_ALLOC_TRACE == 2
   44911             : //    printf("SgOmpDistScheduleClause::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgOmpDistScheduleClause::next_node);
   44912             : #endif
   44913             : 
   44914             : #if USE_CPP_NEW_DELETE_OPERATORS
   44915             :     void *mem = ROSE_MALLOC(Size);
   44916             :     ALLOC_MUTEX(SgOmpDistScheduleClause, unlock);
   44917             :     return mem;
   44918             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   44919             : #if ROSE_PEDANTIC_ALLOC
   44920             :     ROSE_ASSERT(Size == sizeof(SgOmpDistScheduleClause));
   44921             : #else
   44922           1 :     if (Size != sizeof(SgOmpDistScheduleClause)) {
   44923           0 :       void * object = ROSE_MALLOC(Size);
   44924           0 :       ALLOC_MUTEX(SgOmpDistScheduleClause, unlock);
   44925             :       return object;
   44926             :     }
   44927             : #endif
   44928             : 
   44929           1 :     if (SgOmpDistScheduleClause::next_node == nullptr) {
   44930           1 :         SgOmpDistScheduleClause * alloc = (SgOmpDistScheduleClause*) ROSE_MALLOC ( SgOmpDistScheduleClause::pool_size * sizeof(SgOmpDistScheduleClause) );
   44931           1 :         ROSE_ASSERT(alloc != nullptr);
   44932             : 
   44933             : #if ROSE_ALLOC_TRACE == 2
   44934             : //        printf("SgOmpDistScheduleClause::alloc\n  block[%zi] = [ %p , %p [\n", SgOmpDistScheduleClause::pools.size(), alloc, alloc + SgOmpDistScheduleClause::pool_size);
   44935             : #endif
   44936             : 
   44937             : #if ROSE_ALLOC_MEMSET == 1
   44938             : #elif ROSE_ALLOC_MEMSET == 2
   44939             :         memset(alloc, 0x00, SgOmpDistScheduleClause::pool_size * sizeof(SgOmpDistScheduleClause));
   44940             : #elif ROSE_ALLOC_MEMSET == 3
   44941             :         memset(alloc, 0xAA, SgOmpDistScheduleClause::pool_size * sizeof(SgOmpDistScheduleClause));
   44942             : #endif
   44943        2000 :         for (unsigned i=0; i < SgOmpDistScheduleClause::pool_size-1; i++) {
   44944        1999 :           alloc[i].p_freepointer = &(alloc[i+1]);
   44945             :         }
   44946           1 :         alloc[SgOmpDistScheduleClause::pool_size-1].p_freepointer = nullptr;
   44947             : 
   44948           1 :         SgOmpDistScheduleClause::pools.push_back ( (unsigned char *) alloc );
   44949           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgOmpDistScheduleClause::pool_size * sizeof(SgOmpDistScheduleClause), V_SgOmpDistScheduleClause ) );
   44950           1 :         SgOmpDistScheduleClause::next_node = alloc;
   44951             :     }
   44952           1 :     ROSE_ASSERT(SgOmpDistScheduleClause::next_node != nullptr);
   44953             : 
   44954           1 :     SgOmpDistScheduleClause * object = SgOmpDistScheduleClause::next_node;
   44955           1 :     SgOmpDistScheduleClause::next_node = (SgOmpDistScheduleClause*)(object->p_freepointer);
   44956             : 
   44957             : #if ROSE_ALLOC_TRACE == 2
   44958             :     printf("SgOmpDistScheduleClause::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpDistScheduleClause::next_node);
   44959             : #endif
   44960             : 
   44961           1 :     SgNode * fp = object->p_freepointer;
   44962             : #if ROSE_ALLOC_MEMSET == 1
   44963             : #elif ROSE_ALLOC_MEMSET == 2
   44964             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpDistScheduleClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   44965             : #elif ROSE_ALLOC_MEMSET == 3
   44966             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgOmpDistScheduleClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   44967             : #endif
   44968           1 :     object->p_freepointer = fp;
   44969             : 
   44970             : #if ROSE_ALLOC_TRACE == 2
   44971             : //    printf("SgOmpDistScheduleClause::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpDistScheduleClause::next_node);
   44972             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   44973             :     Rose::MemPool::snapshot(oss.str());
   44974             :     alloc_trace_cnt++;
   44975             : #endif
   44976             : 
   44977           1 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   44978             : 
   44979           1 :     ALLOC_MUTEX(SgOmpDistScheduleClause, unlock);
   44980             : 
   44981             :     return object;
   44982             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   44983             : }
   44984             : 
   44985             : 
   44986             : 
   44987             : /*! \brief Delete operator for SgOmpDistScheduleClause.
   44988             : 
   44989             :    This delete operator implements deallocation using memory pools to 
   44990             :    provide most efficent use of the heap within construction of large ASTs.
   44991             : 
   44992             : \internal The new and delete operators use the lower level C malloc/free
   44993             :    function calls for performance and to make sure that mixing of malloc/free
   44994             :    and new/delete by the used can be caught more readily.  This may change
   44995             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   44996             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   44997             :    deallocate memory allocated using ROSE_MALLOC.
   44998             : */
   44999           0 : void SgOmpDistScheduleClause::operator delete(void *Pointer, size_t Size)
   45000             : {
   45001             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   45002             :      * or throwing an exception. */
   45003           0 :     ALLOC_MUTEX(SgOmpDistScheduleClause, lock);
   45004             : 
   45005             : #if USE_CPP_NEW_DELETE_OPERATORS
   45006             :     ROSE_FREE(Pointer);
   45007             : #else
   45008             : #if ROSE_PEDANTIC_ALLOC
   45009             :     ROSE_ASSERT(Size == sizeof(SgOmpDistScheduleClause));
   45010             : #else
   45011           0 :     if (Size != sizeof(SgOmpDistScheduleClause)) {
   45012           0 :       ROSE_FREE(Pointer);
   45013           0 :       ALLOC_MUTEX(SgOmpDistScheduleClause, unlock);
   45014             :       return;
   45015             :     }
   45016             : #endif
   45017             : 
   45018           0 :     SgOmpDistScheduleClause * object = (SgOmpDistScheduleClause*) Pointer;
   45019           0 :     ROSE_ASSERT(object != nullptr);
   45020             : 
   45021             : #if ROSE_ALLOC_TRACE == 2
   45022             : //  printf("SgOmpDistScheduleClause::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpDistScheduleClause::next_node);
   45023             :     printf("SgOmpDistScheduleClause::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpDistScheduleClause::next_node);
   45024             : #endif
   45025             : 
   45026             : #if ROSE_PEDANTIC_ALLOC
   45027             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   45028             : #endif
   45029             : 
   45030             : #if ROSE_ALLOC_MEMSET == 1
   45031             : #elif ROSE_ALLOC_MEMSET == 2
   45032             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpDistScheduleClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   45033             : #elif ROSE_ALLOC_MEMSET == 3
   45034             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgOmpDistScheduleClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   45035             : #endif
   45036             : 
   45037             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   45038             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   45039             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   45040             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   45041             : #else
   45042           0 :     object->p_freepointer = SgOmpDistScheduleClause::next_node;
   45043           0 :     SgOmpDistScheduleClause::next_node = object;
   45044             : #endif
   45045             : 
   45046             : #if ROSE_ALLOC_TRACE == 2
   45047             : //  printf("SgOmpDistScheduleClause::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpDistScheduleClause::next_node);
   45048             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   45049             :     Rose::MemPool::snapshot(oss.str());
   45050             :     alloc_trace_cnt++;
   45051             : #endif
   45052             : 
   45053             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   45054             : 
   45055           0 :     ALLOC_MUTEX(SgOmpDistScheduleClause, unlock);
   45056             : }
   45057             : 
   45058             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   45059             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   45060             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   45061             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   45062             : // Also, note comment below from Robb (copied from the Common.code file).
   45063             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   45064             : //
   45065             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   45066             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   45067             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   45068             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   45069             : #if 0
   45070             : void SgOmpDistScheduleClause::operator delete(void* pointer) { SgOmpDistScheduleClause::operator delete (pointer, sizeof(SgOmpDistScheduleClause)); };
   45071             : #endif
   45072             : /* #line 45073 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   45073             : 
   45074             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   45075             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   45076             : // obviously imply C++.
   45077             : 
   45078             : // This implements the support within ROSE for memory pools.  Memory pools
   45079             : // support the most condensed usage of memory within the construction of
   45080             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   45081             : // by a new operator written for each class.
   45082             : 
   45083             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   45084             :     // User wants multi-thread support and POSIX threads are available.
   45085             : #   include <pthread.h>
   45086             :     static pthread_mutex_t SgOmpExpressionClause_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   45087             : #else
   45088             :      // Cause synchronization to be skipped.
   45089             : #    ifndef ALLOC_MUTEX
   45090             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   45091             : #    endif
   45092             : #    ifdef _REENTRANT
   45093             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   45094             : #       ifdef _MSC_VER
   45095             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   45096             : #       else
   45097             : #           warning "POSIX threads are not available; synchronization being skipped"
   45098             : #       endif
   45099             : #    endif
   45100             : #endif
   45101             : 
   45102             : #ifndef ROSE_ALLOC_TRACE
   45103             : #  define ROSE_ALLOC_TRACE 0
   45104             : #endif
   45105             : 
   45106             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   45107             : #define ROSE_ALLOC_TRACE_CNT
   45108             : #include "memory-pool-snapshot.h"
   45109             : unsigned long alloc_trace_cnt = 0;
   45110             : #endif
   45111             : 
   45112             : #if ROSE_ALLOC_TRACE
   45113             : const unsigned SgOmpExpressionClause::pool_size = 5;
   45114             : #else
   45115             : const unsigned SgOmpExpressionClause::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   45116             : #endif
   45117             : 
   45118             : #ifndef ROSE_ALLOC_MEMSET
   45119             : #  define ROSE_ALLOC_MEMSET 0
   45120             : #endif
   45121             : 
   45122             : #ifndef ROSE_PEDANTIC_ALLOC
   45123             : #  define ROSE_PEDANTIC_ALLOC 0
   45124             : #endif
   45125             : 
   45126             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   45127             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   45128             : #endif
   45129             : 
   45130             : #if !defined(SGNODE__ALL_POOLS)
   45131             : #define SGNODE__ALL_POOLS
   45132             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   45133             : #endif
   45134             : 
   45135             : SgOmpExpressionClause* SgOmpExpressionClause::next_node = nullptr;
   45136             : std::vector<unsigned char*> SgOmpExpressionClause::pools;
   45137             : 
   45138             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   45139             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   45140             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   45141             : // around this macro definition rather than each use).
   45142             : #ifndef ALLOC_MUTEX
   45143             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   45144             :         do {                                                                     \
   45145             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   45146             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   45147             :                 abort();                                                         \
   45148             :             }                                                                    \
   45149             :         } while (0);
   45150             : #endif
   45151             : 
   45152             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   45153             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   45154             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   45155             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   45156             : 
   45157             : /*! \brief New operator for SgOmpExpressionClause.
   45158             : 
   45159             :    This new operator implements memory pools to provide most efficent 
   45160             :    use of the heap within construction of large ASTs.
   45161             : 
   45162             : \internal The new and delete operators use the lower level C malloc/free
   45163             :    function calls for performance and to make sure that mixing of malloc/free
   45164             :    and new/delete by the used can be caught more readily.  This may change
   45165             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   45166             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   45167             :    deallocate memory allocated using ROSE_MALLOC.
   45168             : */
   45169           0 : void *SgOmpExpressionClause::operator new ( size_t Size )
   45170             : {
   45171             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   45172             :      * returning or throwing an exception. */
   45173           0 :     ALLOC_MUTEX(SgOmpExpressionClause, lock);
   45174             : 
   45175             : #if ROSE_ALLOC_TRACE == 2
   45176             : //    printf("SgOmpExpressionClause::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgOmpExpressionClause::next_node);
   45177             : #endif
   45178             : 
   45179             : #if USE_CPP_NEW_DELETE_OPERATORS
   45180             :     void *mem = ROSE_MALLOC(Size);
   45181             :     ALLOC_MUTEX(SgOmpExpressionClause, unlock);
   45182             :     return mem;
   45183             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   45184             : #if ROSE_PEDANTIC_ALLOC
   45185             :     ROSE_ASSERT(Size == sizeof(SgOmpExpressionClause));
   45186             : #else
   45187           0 :     if (Size != sizeof(SgOmpExpressionClause)) {
   45188           0 :       void * object = ROSE_MALLOC(Size);
   45189           0 :       ALLOC_MUTEX(SgOmpExpressionClause, unlock);
   45190             :       return object;
   45191             :     }
   45192             : #endif
   45193             : 
   45194           0 :     if (SgOmpExpressionClause::next_node == nullptr) {
   45195           0 :         SgOmpExpressionClause * alloc = (SgOmpExpressionClause*) ROSE_MALLOC ( SgOmpExpressionClause::pool_size * sizeof(SgOmpExpressionClause) );
   45196           0 :         ROSE_ASSERT(alloc != nullptr);
   45197             : 
   45198             : #if ROSE_ALLOC_TRACE == 2
   45199             : //        printf("SgOmpExpressionClause::alloc\n  block[%zi] = [ %p , %p [\n", SgOmpExpressionClause::pools.size(), alloc, alloc + SgOmpExpressionClause::pool_size);
   45200             : #endif
   45201             : 
   45202             : #if ROSE_ALLOC_MEMSET == 1
   45203             : #elif ROSE_ALLOC_MEMSET == 2
   45204             :         memset(alloc, 0x00, SgOmpExpressionClause::pool_size * sizeof(SgOmpExpressionClause));
   45205             : #elif ROSE_ALLOC_MEMSET == 3
   45206             :         memset(alloc, 0xAA, SgOmpExpressionClause::pool_size * sizeof(SgOmpExpressionClause));
   45207             : #endif
   45208           0 :         for (unsigned i=0; i < SgOmpExpressionClause::pool_size-1; i++) {
   45209           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
   45210             :         }
   45211           0 :         alloc[SgOmpExpressionClause::pool_size-1].p_freepointer = nullptr;
   45212             : 
   45213           0 :         SgOmpExpressionClause::pools.push_back ( (unsigned char *) alloc );
   45214           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgOmpExpressionClause::pool_size * sizeof(SgOmpExpressionClause), V_SgOmpExpressionClause ) );
   45215           0 :         SgOmpExpressionClause::next_node = alloc;
   45216             :     }
   45217           0 :     ROSE_ASSERT(SgOmpExpressionClause::next_node != nullptr);
   45218             : 
   45219           0 :     SgOmpExpressionClause * object = SgOmpExpressionClause::next_node;
   45220           0 :     SgOmpExpressionClause::next_node = (SgOmpExpressionClause*)(object->p_freepointer);
   45221             : 
   45222             : #if ROSE_ALLOC_TRACE == 2
   45223             :     printf("SgOmpExpressionClause::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpExpressionClause::next_node);
   45224             : #endif
   45225             : 
   45226           0 :     SgNode * fp = object->p_freepointer;
   45227             : #if ROSE_ALLOC_MEMSET == 1
   45228             : #elif ROSE_ALLOC_MEMSET == 2
   45229             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpExpressionClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   45230             : #elif ROSE_ALLOC_MEMSET == 3
   45231             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgOmpExpressionClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   45232             : #endif
   45233           0 :     object->p_freepointer = fp;
   45234             : 
   45235             : #if ROSE_ALLOC_TRACE == 2
   45236             : //    printf("SgOmpExpressionClause::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpExpressionClause::next_node);
   45237             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   45238             :     Rose::MemPool::snapshot(oss.str());
   45239             :     alloc_trace_cnt++;
   45240             : #endif
   45241             : 
   45242           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   45243             : 
   45244           0 :     ALLOC_MUTEX(SgOmpExpressionClause, unlock);
   45245             : 
   45246             :     return object;
   45247             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   45248             : }
   45249             : 
   45250             : 
   45251             : 
   45252             : /*! \brief Delete operator for SgOmpExpressionClause.
   45253             : 
   45254             :    This delete operator implements deallocation using memory pools to 
   45255             :    provide most efficent use of the heap within construction of large ASTs.
   45256             : 
   45257             : \internal The new and delete operators use the lower level C malloc/free
   45258             :    function calls for performance and to make sure that mixing of malloc/free
   45259             :    and new/delete by the used can be caught more readily.  This may change
   45260             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   45261             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   45262             :    deallocate memory allocated using ROSE_MALLOC.
   45263             : */
   45264           0 : void SgOmpExpressionClause::operator delete(void *Pointer, size_t Size)
   45265             : {
   45266             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   45267             :      * or throwing an exception. */
   45268           0 :     ALLOC_MUTEX(SgOmpExpressionClause, lock);
   45269             : 
   45270             : #if USE_CPP_NEW_DELETE_OPERATORS
   45271             :     ROSE_FREE(Pointer);
   45272             : #else
   45273             : #if ROSE_PEDANTIC_ALLOC
   45274             :     ROSE_ASSERT(Size == sizeof(SgOmpExpressionClause));
   45275             : #else
   45276           0 :     if (Size != sizeof(SgOmpExpressionClause)) {
   45277           0 :       ROSE_FREE(Pointer);
   45278           0 :       ALLOC_MUTEX(SgOmpExpressionClause, unlock);
   45279             :       return;
   45280             :     }
   45281             : #endif
   45282             : 
   45283           0 :     SgOmpExpressionClause * object = (SgOmpExpressionClause*) Pointer;
   45284           0 :     ROSE_ASSERT(object != nullptr);
   45285             : 
   45286             : #if ROSE_ALLOC_TRACE == 2
   45287             : //  printf("SgOmpExpressionClause::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpExpressionClause::next_node);
   45288             :     printf("SgOmpExpressionClause::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpExpressionClause::next_node);
   45289             : #endif
   45290             : 
   45291             : #if ROSE_PEDANTIC_ALLOC
   45292             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   45293             : #endif
   45294             : 
   45295             : #if ROSE_ALLOC_MEMSET == 1
   45296             : #elif ROSE_ALLOC_MEMSET == 2
   45297             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpExpressionClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   45298             : #elif ROSE_ALLOC_MEMSET == 3
   45299             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgOmpExpressionClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   45300             : #endif
   45301             : 
   45302             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   45303             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   45304             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   45305             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   45306             : #else
   45307           0 :     object->p_freepointer = SgOmpExpressionClause::next_node;
   45308           0 :     SgOmpExpressionClause::next_node = object;
   45309             : #endif
   45310             : 
   45311             : #if ROSE_ALLOC_TRACE == 2
   45312             : //  printf("SgOmpExpressionClause::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpExpressionClause::next_node);
   45313             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   45314             :     Rose::MemPool::snapshot(oss.str());
   45315             :     alloc_trace_cnt++;
   45316             : #endif
   45317             : 
   45318             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   45319             : 
   45320           0 :     ALLOC_MUTEX(SgOmpExpressionClause, unlock);
   45321             : }
   45322             : 
   45323             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   45324             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   45325             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   45326             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   45327             : // Also, note comment below from Robb (copied from the Common.code file).
   45328             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   45329             : //
   45330             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   45331             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   45332             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   45333             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   45334             : #if 0
   45335             : void SgOmpExpressionClause::operator delete(void* pointer) { SgOmpExpressionClause::operator delete (pointer, sizeof(SgOmpExpressionClause)); };
   45336             : #endif
   45337             : /* #line 45338 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   45338             : 
   45339             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   45340             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   45341             : // obviously imply C++.
   45342             : 
   45343             : // This implements the support within ROSE for memory pools.  Memory pools
   45344             : // support the most condensed usage of memory within the construction of
   45345             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   45346             : // by a new operator written for each class.
   45347             : 
   45348             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   45349             :     // User wants multi-thread support and POSIX threads are available.
   45350             : #   include <pthread.h>
   45351             :     static pthread_mutex_t SgOmpOrderedClause_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   45352             : #else
   45353             :      // Cause synchronization to be skipped.
   45354             : #    ifndef ALLOC_MUTEX
   45355             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   45356             : #    endif
   45357             : #    ifdef _REENTRANT
   45358             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   45359             : #       ifdef _MSC_VER
   45360             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   45361             : #       else
   45362             : #           warning "POSIX threads are not available; synchronization being skipped"
   45363             : #       endif
   45364             : #    endif
   45365             : #endif
   45366             : 
   45367             : #ifndef ROSE_ALLOC_TRACE
   45368             : #  define ROSE_ALLOC_TRACE 0
   45369             : #endif
   45370             : 
   45371             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   45372             : #define ROSE_ALLOC_TRACE_CNT
   45373             : #include "memory-pool-snapshot.h"
   45374             : unsigned long alloc_trace_cnt = 0;
   45375             : #endif
   45376             : 
   45377             : #if ROSE_ALLOC_TRACE
   45378             : const unsigned SgOmpOrderedClause::pool_size = 5;
   45379             : #else
   45380             : const unsigned SgOmpOrderedClause::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   45381             : #endif
   45382             : 
   45383             : #ifndef ROSE_ALLOC_MEMSET
   45384             : #  define ROSE_ALLOC_MEMSET 0
   45385             : #endif
   45386             : 
   45387             : #ifndef ROSE_PEDANTIC_ALLOC
   45388             : #  define ROSE_PEDANTIC_ALLOC 0
   45389             : #endif
   45390             : 
   45391             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   45392             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   45393             : #endif
   45394             : 
   45395             : #if !defined(SGNODE__ALL_POOLS)
   45396             : #define SGNODE__ALL_POOLS
   45397             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   45398             : #endif
   45399             : 
   45400             : SgOmpOrderedClause* SgOmpOrderedClause::next_node = nullptr;
   45401             : std::vector<unsigned char*> SgOmpOrderedClause::pools;
   45402             : 
   45403             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   45404             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   45405             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   45406             : // around this macro definition rather than each use).
   45407             : #ifndef ALLOC_MUTEX
   45408             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   45409             :         do {                                                                     \
   45410             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   45411             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   45412             :                 abort();                                                         \
   45413             :             }                                                                    \
   45414             :         } while (0);
   45415             : #endif
   45416             : 
   45417             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   45418             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   45419             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   45420             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   45421             : 
   45422             : /*! \brief New operator for SgOmpOrderedClause.
   45423             : 
   45424             :    This new operator implements memory pools to provide most efficent 
   45425             :    use of the heap within construction of large ASTs.
   45426             : 
   45427             : \internal The new and delete operators use the lower level C malloc/free
   45428             :    function calls for performance and to make sure that mixing of malloc/free
   45429             :    and new/delete by the used can be caught more readily.  This may change
   45430             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   45431             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   45432             :    deallocate memory allocated using ROSE_MALLOC.
   45433             : */
   45434          13 : void *SgOmpOrderedClause::operator new ( size_t Size )
   45435             : {
   45436             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   45437             :      * returning or throwing an exception. */
   45438          13 :     ALLOC_MUTEX(SgOmpOrderedClause, lock);
   45439             : 
   45440             : #if ROSE_ALLOC_TRACE == 2
   45441             : //    printf("SgOmpOrderedClause::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgOmpOrderedClause::next_node);
   45442             : #endif
   45443             : 
   45444             : #if USE_CPP_NEW_DELETE_OPERATORS
   45445             :     void *mem = ROSE_MALLOC(Size);
   45446             :     ALLOC_MUTEX(SgOmpOrderedClause, unlock);
   45447             :     return mem;
   45448             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   45449             : #if ROSE_PEDANTIC_ALLOC
   45450             :     ROSE_ASSERT(Size == sizeof(SgOmpOrderedClause));
   45451             : #else
   45452          13 :     if (Size != sizeof(SgOmpOrderedClause)) {
   45453           0 :       void * object = ROSE_MALLOC(Size);
   45454           0 :       ALLOC_MUTEX(SgOmpOrderedClause, unlock);
   45455             :       return object;
   45456             :     }
   45457             : #endif
   45458             : 
   45459          13 :     if (SgOmpOrderedClause::next_node == nullptr) {
   45460          11 :         SgOmpOrderedClause * alloc = (SgOmpOrderedClause*) ROSE_MALLOC ( SgOmpOrderedClause::pool_size * sizeof(SgOmpOrderedClause) );
   45461          11 :         ROSE_ASSERT(alloc != nullptr);
   45462             : 
   45463             : #if ROSE_ALLOC_TRACE == 2
   45464             : //        printf("SgOmpOrderedClause::alloc\n  block[%zi] = [ %p , %p [\n", SgOmpOrderedClause::pools.size(), alloc, alloc + SgOmpOrderedClause::pool_size);
   45465             : #endif
   45466             : 
   45467             : #if ROSE_ALLOC_MEMSET == 1
   45468             : #elif ROSE_ALLOC_MEMSET == 2
   45469             :         memset(alloc, 0x00, SgOmpOrderedClause::pool_size * sizeof(SgOmpOrderedClause));
   45470             : #elif ROSE_ALLOC_MEMSET == 3
   45471             :         memset(alloc, 0xAA, SgOmpOrderedClause::pool_size * sizeof(SgOmpOrderedClause));
   45472             : #endif
   45473       22000 :         for (unsigned i=0; i < SgOmpOrderedClause::pool_size-1; i++) {
   45474       21989 :           alloc[i].p_freepointer = &(alloc[i+1]);
   45475             :         }
   45476          11 :         alloc[SgOmpOrderedClause::pool_size-1].p_freepointer = nullptr;
   45477             : 
   45478          11 :         SgOmpOrderedClause::pools.push_back ( (unsigned char *) alloc );
   45479          11 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgOmpOrderedClause::pool_size * sizeof(SgOmpOrderedClause), V_SgOmpOrderedClause ) );
   45480          11 :         SgOmpOrderedClause::next_node = alloc;
   45481             :     }
   45482          13 :     ROSE_ASSERT(SgOmpOrderedClause::next_node != nullptr);
   45483             : 
   45484          13 :     SgOmpOrderedClause * object = SgOmpOrderedClause::next_node;
   45485          13 :     SgOmpOrderedClause::next_node = (SgOmpOrderedClause*)(object->p_freepointer);
   45486             : 
   45487             : #if ROSE_ALLOC_TRACE == 2
   45488             :     printf("SgOmpOrderedClause::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpOrderedClause::next_node);
   45489             : #endif
   45490             : 
   45491          13 :     SgNode * fp = object->p_freepointer;
   45492             : #if ROSE_ALLOC_MEMSET == 1
   45493             : #elif ROSE_ALLOC_MEMSET == 2
   45494             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpOrderedClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   45495             : #elif ROSE_ALLOC_MEMSET == 3
   45496             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgOmpOrderedClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   45497             : #endif
   45498          13 :     object->p_freepointer = fp;
   45499             : 
   45500             : #if ROSE_ALLOC_TRACE == 2
   45501             : //    printf("SgOmpOrderedClause::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpOrderedClause::next_node);
   45502             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   45503             :     Rose::MemPool::snapshot(oss.str());
   45504             :     alloc_trace_cnt++;
   45505             : #endif
   45506             : 
   45507          13 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   45508             : 
   45509          13 :     ALLOC_MUTEX(SgOmpOrderedClause, unlock);
   45510             : 
   45511             :     return object;
   45512             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   45513             : }
   45514             : 
   45515             : 
   45516             : 
   45517             : /*! \brief Delete operator for SgOmpOrderedClause.
   45518             : 
   45519             :    This delete operator implements deallocation using memory pools to 
   45520             :    provide most efficent use of the heap within construction of large ASTs.
   45521             : 
   45522             : \internal The new and delete operators use the lower level C malloc/free
   45523             :    function calls for performance and to make sure that mixing of malloc/free
   45524             :    and new/delete by the used can be caught more readily.  This may change
   45525             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   45526             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   45527             :    deallocate memory allocated using ROSE_MALLOC.
   45528             : */
   45529           0 : void SgOmpOrderedClause::operator delete(void *Pointer, size_t Size)
   45530             : {
   45531             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   45532             :      * or throwing an exception. */
   45533           0 :     ALLOC_MUTEX(SgOmpOrderedClause, lock);
   45534             : 
   45535             : #if USE_CPP_NEW_DELETE_OPERATORS
   45536             :     ROSE_FREE(Pointer);
   45537             : #else
   45538             : #if ROSE_PEDANTIC_ALLOC
   45539             :     ROSE_ASSERT(Size == sizeof(SgOmpOrderedClause));
   45540             : #else
   45541           0 :     if (Size != sizeof(SgOmpOrderedClause)) {
   45542           0 :       ROSE_FREE(Pointer);
   45543           0 :       ALLOC_MUTEX(SgOmpOrderedClause, unlock);
   45544             :       return;
   45545             :     }
   45546             : #endif
   45547             : 
   45548           0 :     SgOmpOrderedClause * object = (SgOmpOrderedClause*) Pointer;
   45549           0 :     ROSE_ASSERT(object != nullptr);
   45550             : 
   45551             : #if ROSE_ALLOC_TRACE == 2
   45552             : //  printf("SgOmpOrderedClause::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpOrderedClause::next_node);
   45553             :     printf("SgOmpOrderedClause::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpOrderedClause::next_node);
   45554             : #endif
   45555             : 
   45556             : #if ROSE_PEDANTIC_ALLOC
   45557             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   45558             : #endif
   45559             : 
   45560             : #if ROSE_ALLOC_MEMSET == 1
   45561             : #elif ROSE_ALLOC_MEMSET == 2
   45562             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpOrderedClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   45563             : #elif ROSE_ALLOC_MEMSET == 3
   45564             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgOmpOrderedClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   45565             : #endif
   45566             : 
   45567             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   45568             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   45569             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   45570             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   45571             : #else
   45572           0 :     object->p_freepointer = SgOmpOrderedClause::next_node;
   45573           0 :     SgOmpOrderedClause::next_node = object;
   45574             : #endif
   45575             : 
   45576             : #if ROSE_ALLOC_TRACE == 2
   45577             : //  printf("SgOmpOrderedClause::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpOrderedClause::next_node);
   45578             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   45579             :     Rose::MemPool::snapshot(oss.str());
   45580             :     alloc_trace_cnt++;
   45581             : #endif
   45582             : 
   45583             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   45584             : 
   45585           0 :     ALLOC_MUTEX(SgOmpOrderedClause, unlock);
   45586             : }
   45587             : 
   45588             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   45589             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   45590             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   45591             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   45592             : // Also, note comment below from Robb (copied from the Common.code file).
   45593             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   45594             : //
   45595             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   45596             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   45597             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   45598             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   45599             : #if 0
   45600             : void SgOmpOrderedClause::operator delete(void* pointer) { SgOmpOrderedClause::operator delete (pointer, sizeof(SgOmpOrderedClause)); };
   45601             : #endif
   45602             : /* #line 45603 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   45603             : 
   45604             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   45605             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   45606             : // obviously imply C++.
   45607             : 
   45608             : // This implements the support within ROSE for memory pools.  Memory pools
   45609             : // support the most condensed usage of memory within the construction of
   45610             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   45611             : // by a new operator written for each class.
   45612             : 
   45613             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   45614             :     // User wants multi-thread support and POSIX threads are available.
   45615             : #   include <pthread.h>
   45616             :     static pthread_mutex_t SgOmpCollapseClause_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   45617             : #else
   45618             :      // Cause synchronization to be skipped.
   45619             : #    ifndef ALLOC_MUTEX
   45620             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   45621             : #    endif
   45622             : #    ifdef _REENTRANT
   45623             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   45624             : #       ifdef _MSC_VER
   45625             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   45626             : #       else
   45627             : #           warning "POSIX threads are not available; synchronization being skipped"
   45628             : #       endif
   45629             : #    endif
   45630             : #endif
   45631             : 
   45632             : #ifndef ROSE_ALLOC_TRACE
   45633             : #  define ROSE_ALLOC_TRACE 0
   45634             : #endif
   45635             : 
   45636             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   45637             : #define ROSE_ALLOC_TRACE_CNT
   45638             : #include "memory-pool-snapshot.h"
   45639             : unsigned long alloc_trace_cnt = 0;
   45640             : #endif
   45641             : 
   45642             : #if ROSE_ALLOC_TRACE
   45643             : const unsigned SgOmpCollapseClause::pool_size = 5;
   45644             : #else
   45645             : const unsigned SgOmpCollapseClause::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   45646             : #endif
   45647             : 
   45648             : #ifndef ROSE_ALLOC_MEMSET
   45649             : #  define ROSE_ALLOC_MEMSET 0
   45650             : #endif
   45651             : 
   45652             : #ifndef ROSE_PEDANTIC_ALLOC
   45653             : #  define ROSE_PEDANTIC_ALLOC 0
   45654             : #endif
   45655             : 
   45656             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   45657             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   45658             : #endif
   45659             : 
   45660             : #if !defined(SGNODE__ALL_POOLS)
   45661             : #define SGNODE__ALL_POOLS
   45662             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   45663             : #endif
   45664             : 
   45665             : SgOmpCollapseClause* SgOmpCollapseClause::next_node = nullptr;
   45666             : std::vector<unsigned char*> SgOmpCollapseClause::pools;
   45667             : 
   45668             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   45669             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   45670             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   45671             : // around this macro definition rather than each use).
   45672             : #ifndef ALLOC_MUTEX
   45673             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   45674             :         do {                                                                     \
   45675             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   45676             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   45677             :                 abort();                                                         \
   45678             :             }                                                                    \
   45679             :         } while (0);
   45680             : #endif
   45681             : 
   45682             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   45683             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   45684             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   45685             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   45686             : 
   45687             : /*! \brief New operator for SgOmpCollapseClause.
   45688             : 
   45689             :    This new operator implements memory pools to provide most efficent 
   45690             :    use of the heap within construction of large ASTs.
   45691             : 
   45692             : \internal The new and delete operators use the lower level C malloc/free
   45693             :    function calls for performance and to make sure that mixing of malloc/free
   45694             :    and new/delete by the used can be caught more readily.  This may change
   45695             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   45696             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   45697             :    deallocate memory allocated using ROSE_MALLOC.
   45698             : */
   45699          11 : void *SgOmpCollapseClause::operator new ( size_t Size )
   45700             : {
   45701             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   45702             :      * returning or throwing an exception. */
   45703          11 :     ALLOC_MUTEX(SgOmpCollapseClause, lock);
   45704             : 
   45705             : #if ROSE_ALLOC_TRACE == 2
   45706             : //    printf("SgOmpCollapseClause::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgOmpCollapseClause::next_node);
   45707             : #endif
   45708             : 
   45709             : #if USE_CPP_NEW_DELETE_OPERATORS
   45710             :     void *mem = ROSE_MALLOC(Size);
   45711             :     ALLOC_MUTEX(SgOmpCollapseClause, unlock);
   45712             :     return mem;
   45713             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   45714             : #if ROSE_PEDANTIC_ALLOC
   45715             :     ROSE_ASSERT(Size == sizeof(SgOmpCollapseClause));
   45716             : #else
   45717          11 :     if (Size != sizeof(SgOmpCollapseClause)) {
   45718           0 :       void * object = ROSE_MALLOC(Size);
   45719           0 :       ALLOC_MUTEX(SgOmpCollapseClause, unlock);
   45720             :       return object;
   45721             :     }
   45722             : #endif
   45723             : 
   45724          11 :     if (SgOmpCollapseClause::next_node == nullptr) {
   45725           7 :         SgOmpCollapseClause * alloc = (SgOmpCollapseClause*) ROSE_MALLOC ( SgOmpCollapseClause::pool_size * sizeof(SgOmpCollapseClause) );
   45726           7 :         ROSE_ASSERT(alloc != nullptr);
   45727             : 
   45728             : #if ROSE_ALLOC_TRACE == 2
   45729             : //        printf("SgOmpCollapseClause::alloc\n  block[%zi] = [ %p , %p [\n", SgOmpCollapseClause::pools.size(), alloc, alloc + SgOmpCollapseClause::pool_size);
   45730             : #endif
   45731             : 
   45732             : #if ROSE_ALLOC_MEMSET == 1
   45733             : #elif ROSE_ALLOC_MEMSET == 2
   45734             :         memset(alloc, 0x00, SgOmpCollapseClause::pool_size * sizeof(SgOmpCollapseClause));
   45735             : #elif ROSE_ALLOC_MEMSET == 3
   45736             :         memset(alloc, 0xAA, SgOmpCollapseClause::pool_size * sizeof(SgOmpCollapseClause));
   45737             : #endif
   45738       14000 :         for (unsigned i=0; i < SgOmpCollapseClause::pool_size-1; i++) {
   45739       13993 :           alloc[i].p_freepointer = &(alloc[i+1]);
   45740             :         }
   45741           7 :         alloc[SgOmpCollapseClause::pool_size-1].p_freepointer = nullptr;
   45742             : 
   45743           7 :         SgOmpCollapseClause::pools.push_back ( (unsigned char *) alloc );
   45744           7 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgOmpCollapseClause::pool_size * sizeof(SgOmpCollapseClause), V_SgOmpCollapseClause ) );
   45745           7 :         SgOmpCollapseClause::next_node = alloc;
   45746             :     }
   45747          11 :     ROSE_ASSERT(SgOmpCollapseClause::next_node != nullptr);
   45748             : 
   45749          11 :     SgOmpCollapseClause * object = SgOmpCollapseClause::next_node;
   45750          11 :     SgOmpCollapseClause::next_node = (SgOmpCollapseClause*)(object->p_freepointer);
   45751             : 
   45752             : #if ROSE_ALLOC_TRACE == 2
   45753             :     printf("SgOmpCollapseClause::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpCollapseClause::next_node);
   45754             : #endif
   45755             : 
   45756          11 :     SgNode * fp = object->p_freepointer;
   45757             : #if ROSE_ALLOC_MEMSET == 1
   45758             : #elif ROSE_ALLOC_MEMSET == 2
   45759             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpCollapseClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   45760             : #elif ROSE_ALLOC_MEMSET == 3
   45761             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgOmpCollapseClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   45762             : #endif
   45763          11 :     object->p_freepointer = fp;
   45764             : 
   45765             : #if ROSE_ALLOC_TRACE == 2
   45766             : //    printf("SgOmpCollapseClause::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpCollapseClause::next_node);
   45767             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   45768             :     Rose::MemPool::snapshot(oss.str());
   45769             :     alloc_trace_cnt++;
   45770             : #endif
   45771             : 
   45772          11 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   45773             : 
   45774          11 :     ALLOC_MUTEX(SgOmpCollapseClause, unlock);
   45775             : 
   45776             :     return object;
   45777             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   45778             : }
   45779             : 
   45780             : 
   45781             : 
   45782             : /*! \brief Delete operator for SgOmpCollapseClause.
   45783             : 
   45784             :    This delete operator implements deallocation using memory pools to 
   45785             :    provide most efficent use of the heap within construction of large ASTs.
   45786             : 
   45787             : \internal The new and delete operators use the lower level C malloc/free
   45788             :    function calls for performance and to make sure that mixing of malloc/free
   45789             :    and new/delete by the used can be caught more readily.  This may change
   45790             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   45791             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   45792             :    deallocate memory allocated using ROSE_MALLOC.
   45793             : */
   45794           0 : void SgOmpCollapseClause::operator delete(void *Pointer, size_t Size)
   45795             : {
   45796             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   45797             :      * or throwing an exception. */
   45798           0 :     ALLOC_MUTEX(SgOmpCollapseClause, lock);
   45799             : 
   45800             : #if USE_CPP_NEW_DELETE_OPERATORS
   45801             :     ROSE_FREE(Pointer);
   45802             : #else
   45803             : #if ROSE_PEDANTIC_ALLOC
   45804             :     ROSE_ASSERT(Size == sizeof(SgOmpCollapseClause));
   45805             : #else
   45806           0 :     if (Size != sizeof(SgOmpCollapseClause)) {
   45807           0 :       ROSE_FREE(Pointer);
   45808           0 :       ALLOC_MUTEX(SgOmpCollapseClause, unlock);
   45809             :       return;
   45810             :     }
   45811             : #endif
   45812             : 
   45813           0 :     SgOmpCollapseClause * object = (SgOmpCollapseClause*) Pointer;
   45814           0 :     ROSE_ASSERT(object != nullptr);
   45815             : 
   45816             : #if ROSE_ALLOC_TRACE == 2
   45817             : //  printf("SgOmpCollapseClause::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpCollapseClause::next_node);
   45818             :     printf("SgOmpCollapseClause::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpCollapseClause::next_node);
   45819             : #endif
   45820             : 
   45821             : #if ROSE_PEDANTIC_ALLOC
   45822             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   45823             : #endif
   45824             : 
   45825             : #if ROSE_ALLOC_MEMSET == 1
   45826             : #elif ROSE_ALLOC_MEMSET == 2
   45827             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpCollapseClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   45828             : #elif ROSE_ALLOC_MEMSET == 3
   45829             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgOmpCollapseClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   45830             : #endif
   45831             : 
   45832             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   45833             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   45834             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   45835             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   45836             : #else
   45837           0 :     object->p_freepointer = SgOmpCollapseClause::next_node;
   45838           0 :     SgOmpCollapseClause::next_node = object;
   45839             : #endif
   45840             : 
   45841             : #if ROSE_ALLOC_TRACE == 2
   45842             : //  printf("SgOmpCollapseClause::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpCollapseClause::next_node);
   45843             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   45844             :     Rose::MemPool::snapshot(oss.str());
   45845             :     alloc_trace_cnt++;
   45846             : #endif
   45847             : 
   45848             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   45849             : 
   45850           0 :     ALLOC_MUTEX(SgOmpCollapseClause, unlock);
   45851             : }
   45852             : 
   45853             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   45854             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   45855             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   45856             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   45857             : // Also, note comment below from Robb (copied from the Common.code file).
   45858             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   45859             : //
   45860             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   45861             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   45862             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   45863             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   45864             : #if 0
   45865             : void SgOmpCollapseClause::operator delete(void* pointer) { SgOmpCollapseClause::operator delete (pointer, sizeof(SgOmpCollapseClause)); };
   45866             : #endif
   45867             : /* #line 45868 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   45868             : 
   45869             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   45870             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   45871             : // obviously imply C++.
   45872             : 
   45873             : // This implements the support within ROSE for memory pools.  Memory pools
   45874             : // support the most condensed usage of memory within the construction of
   45875             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   45876             : // by a new operator written for each class.
   45877             : 
   45878             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   45879             :     // User wants multi-thread support and POSIX threads are available.
   45880             : #   include <pthread.h>
   45881             :     static pthread_mutex_t SgOmpIfClause_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   45882             : #else
   45883             :      // Cause synchronization to be skipped.
   45884             : #    ifndef ALLOC_MUTEX
   45885             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   45886             : #    endif
   45887             : #    ifdef _REENTRANT
   45888             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   45889             : #       ifdef _MSC_VER
   45890             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   45891             : #       else
   45892             : #           warning "POSIX threads are not available; synchronization being skipped"
   45893             : #       endif
   45894             : #    endif
   45895             : #endif
   45896             : 
   45897             : #ifndef ROSE_ALLOC_TRACE
   45898             : #  define ROSE_ALLOC_TRACE 0
   45899             : #endif
   45900             : 
   45901             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   45902             : #define ROSE_ALLOC_TRACE_CNT
   45903             : #include "memory-pool-snapshot.h"
   45904             : unsigned long alloc_trace_cnt = 0;
   45905             : #endif
   45906             : 
   45907             : #if ROSE_ALLOC_TRACE
   45908             : const unsigned SgOmpIfClause::pool_size = 5;
   45909             : #else
   45910             : const unsigned SgOmpIfClause::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   45911             : #endif
   45912             : 
   45913             : #ifndef ROSE_ALLOC_MEMSET
   45914             : #  define ROSE_ALLOC_MEMSET 0
   45915             : #endif
   45916             : 
   45917             : #ifndef ROSE_PEDANTIC_ALLOC
   45918             : #  define ROSE_PEDANTIC_ALLOC 0
   45919             : #endif
   45920             : 
   45921             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   45922             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   45923             : #endif
   45924             : 
   45925             : #if !defined(SGNODE__ALL_POOLS)
   45926             : #define SGNODE__ALL_POOLS
   45927             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   45928             : #endif
   45929             : 
   45930             : SgOmpIfClause* SgOmpIfClause::next_node = nullptr;
   45931             : std::vector<unsigned char*> SgOmpIfClause::pools;
   45932             : 
   45933             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   45934             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   45935             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   45936             : // around this macro definition rather than each use).
   45937             : #ifndef ALLOC_MUTEX
   45938             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   45939             :         do {                                                                     \
   45940             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   45941             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   45942             :                 abort();                                                         \
   45943             :             }                                                                    \
   45944             :         } while (0);
   45945             : #endif
   45946             : 
   45947             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   45948             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   45949             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   45950             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   45951             : 
   45952             : /*! \brief New operator for SgOmpIfClause.
   45953             : 
   45954             :    This new operator implements memory pools to provide most efficent 
   45955             :    use of the heap within construction of large ASTs.
   45956             : 
   45957             : \internal The new and delete operators use the lower level C malloc/free
   45958             :    function calls for performance and to make sure that mixing of malloc/free
   45959             :    and new/delete by the used can be caught more readily.  This may change
   45960             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   45961             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   45962             :    deallocate memory allocated using ROSE_MALLOC.
   45963             : */
   45964          37 : void *SgOmpIfClause::operator new ( size_t Size )
   45965             : {
   45966             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   45967             :      * returning or throwing an exception. */
   45968          37 :     ALLOC_MUTEX(SgOmpIfClause, lock);
   45969             : 
   45970             : #if ROSE_ALLOC_TRACE == 2
   45971             : //    printf("SgOmpIfClause::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgOmpIfClause::next_node);
   45972             : #endif
   45973             : 
   45974             : #if USE_CPP_NEW_DELETE_OPERATORS
   45975             :     void *mem = ROSE_MALLOC(Size);
   45976             :     ALLOC_MUTEX(SgOmpIfClause, unlock);
   45977             :     return mem;
   45978             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   45979             : #if ROSE_PEDANTIC_ALLOC
   45980             :     ROSE_ASSERT(Size == sizeof(SgOmpIfClause));
   45981             : #else
   45982          37 :     if (Size != sizeof(SgOmpIfClause)) {
   45983           0 :       void * object = ROSE_MALLOC(Size);
   45984           0 :       ALLOC_MUTEX(SgOmpIfClause, unlock);
   45985             :       return object;
   45986             :     }
   45987             : #endif
   45988             : 
   45989          37 :     if (SgOmpIfClause::next_node == nullptr) {
   45990          26 :         SgOmpIfClause * alloc = (SgOmpIfClause*) ROSE_MALLOC ( SgOmpIfClause::pool_size * sizeof(SgOmpIfClause) );
   45991          26 :         ROSE_ASSERT(alloc != nullptr);
   45992             : 
   45993             : #if ROSE_ALLOC_TRACE == 2
   45994             : //        printf("SgOmpIfClause::alloc\n  block[%zi] = [ %p , %p [\n", SgOmpIfClause::pools.size(), alloc, alloc + SgOmpIfClause::pool_size);
   45995             : #endif
   45996             : 
   45997             : #if ROSE_ALLOC_MEMSET == 1
   45998             : #elif ROSE_ALLOC_MEMSET == 2
   45999             :         memset(alloc, 0x00, SgOmpIfClause::pool_size * sizeof(SgOmpIfClause));
   46000             : #elif ROSE_ALLOC_MEMSET == 3
   46001             :         memset(alloc, 0xAA, SgOmpIfClause::pool_size * sizeof(SgOmpIfClause));
   46002             : #endif
   46003       52000 :         for (unsigned i=0; i < SgOmpIfClause::pool_size-1; i++) {
   46004       51974 :           alloc[i].p_freepointer = &(alloc[i+1]);
   46005             :         }
   46006          26 :         alloc[SgOmpIfClause::pool_size-1].p_freepointer = nullptr;
   46007             : 
   46008          26 :         SgOmpIfClause::pools.push_back ( (unsigned char *) alloc );
   46009          26 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgOmpIfClause::pool_size * sizeof(SgOmpIfClause), V_SgOmpIfClause ) );
   46010          26 :         SgOmpIfClause::next_node = alloc;
   46011             :     }
   46012          37 :     ROSE_ASSERT(SgOmpIfClause::next_node != nullptr);
   46013             : 
   46014          37 :     SgOmpIfClause * object = SgOmpIfClause::next_node;
   46015          37 :     SgOmpIfClause::next_node = (SgOmpIfClause*)(object->p_freepointer);
   46016             : 
   46017             : #if ROSE_ALLOC_TRACE == 2
   46018             :     printf("SgOmpIfClause::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpIfClause::next_node);
   46019             : #endif
   46020             : 
   46021          37 :     SgNode * fp = object->p_freepointer;
   46022             : #if ROSE_ALLOC_MEMSET == 1
   46023             : #elif ROSE_ALLOC_MEMSET == 2
   46024             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpIfClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   46025             : #elif ROSE_ALLOC_MEMSET == 3
   46026             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgOmpIfClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   46027             : #endif
   46028          37 :     object->p_freepointer = fp;
   46029             : 
   46030             : #if ROSE_ALLOC_TRACE == 2
   46031             : //    printf("SgOmpIfClause::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpIfClause::next_node);
   46032             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   46033             :     Rose::MemPool::snapshot(oss.str());
   46034             :     alloc_trace_cnt++;
   46035             : #endif
   46036             : 
   46037          37 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   46038             : 
   46039          37 :     ALLOC_MUTEX(SgOmpIfClause, unlock);
   46040             : 
   46041             :     return object;
   46042             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   46043             : }
   46044             : 
   46045             : 
   46046             : 
   46047             : /*! \brief Delete operator for SgOmpIfClause.
   46048             : 
   46049             :    This delete operator implements deallocation using memory pools to 
   46050             :    provide most efficent use of the heap within construction of large ASTs.
   46051             : 
   46052             : \internal The new and delete operators use the lower level C malloc/free
   46053             :    function calls for performance and to make sure that mixing of malloc/free
   46054             :    and new/delete by the used can be caught more readily.  This may change
   46055             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   46056             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   46057             :    deallocate memory allocated using ROSE_MALLOC.
   46058             : */
   46059           0 : void SgOmpIfClause::operator delete(void *Pointer, size_t Size)
   46060             : {
   46061             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   46062             :      * or throwing an exception. */
   46063           0 :     ALLOC_MUTEX(SgOmpIfClause, lock);
   46064             : 
   46065             : #if USE_CPP_NEW_DELETE_OPERATORS
   46066             :     ROSE_FREE(Pointer);
   46067             : #else
   46068             : #if ROSE_PEDANTIC_ALLOC
   46069             :     ROSE_ASSERT(Size == sizeof(SgOmpIfClause));
   46070             : #else
   46071           0 :     if (Size != sizeof(SgOmpIfClause)) {
   46072           0 :       ROSE_FREE(Pointer);
   46073           0 :       ALLOC_MUTEX(SgOmpIfClause, unlock);
   46074             :       return;
   46075             :     }
   46076             : #endif
   46077             : 
   46078           0 :     SgOmpIfClause * object = (SgOmpIfClause*) Pointer;
   46079           0 :     ROSE_ASSERT(object != nullptr);
   46080             : 
   46081             : #if ROSE_ALLOC_TRACE == 2
   46082             : //  printf("SgOmpIfClause::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpIfClause::next_node);
   46083             :     printf("SgOmpIfClause::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpIfClause::next_node);
   46084             : #endif
   46085             : 
   46086             : #if ROSE_PEDANTIC_ALLOC
   46087             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   46088             : #endif
   46089             : 
   46090             : #if ROSE_ALLOC_MEMSET == 1
   46091             : #elif ROSE_ALLOC_MEMSET == 2
   46092             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpIfClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   46093             : #elif ROSE_ALLOC_MEMSET == 3
   46094             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgOmpIfClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   46095             : #endif
   46096             : 
   46097             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   46098             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   46099             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   46100             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   46101             : #else
   46102           0 :     object->p_freepointer = SgOmpIfClause::next_node;
   46103           0 :     SgOmpIfClause::next_node = object;
   46104             : #endif
   46105             : 
   46106             : #if ROSE_ALLOC_TRACE == 2
   46107             : //  printf("SgOmpIfClause::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpIfClause::next_node);
   46108             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   46109             :     Rose::MemPool::snapshot(oss.str());
   46110             :     alloc_trace_cnt++;
   46111             : #endif
   46112             : 
   46113             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   46114             : 
   46115           0 :     ALLOC_MUTEX(SgOmpIfClause, unlock);
   46116             : }
   46117             : 
   46118             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   46119             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   46120             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   46121             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   46122             : // Also, note comment below from Robb (copied from the Common.code file).
   46123             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   46124             : //
   46125             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   46126             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   46127             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   46128             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   46129             : #if 0
   46130             : void SgOmpIfClause::operator delete(void* pointer) { SgOmpIfClause::operator delete (pointer, sizeof(SgOmpIfClause)); };
   46131             : #endif
   46132             : /* #line 46133 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   46133             : 
   46134             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   46135             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   46136             : // obviously imply C++.
   46137             : 
   46138             : // This implements the support within ROSE for memory pools.  Memory pools
   46139             : // support the most condensed usage of memory within the construction of
   46140             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   46141             : // by a new operator written for each class.
   46142             : 
   46143             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   46144             :     // User wants multi-thread support and POSIX threads are available.
   46145             : #   include <pthread.h>
   46146             :     static pthread_mutex_t SgUpirNumUnitsField_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   46147             : #else
   46148             :      // Cause synchronization to be skipped.
   46149             : #    ifndef ALLOC_MUTEX
   46150             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   46151             : #    endif
   46152             : #    ifdef _REENTRANT
   46153             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   46154             : #       ifdef _MSC_VER
   46155             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   46156             : #       else
   46157             : #           warning "POSIX threads are not available; synchronization being skipped"
   46158             : #       endif
   46159             : #    endif
   46160             : #endif
   46161             : 
   46162             : #ifndef ROSE_ALLOC_TRACE
   46163             : #  define ROSE_ALLOC_TRACE 0
   46164             : #endif
   46165             : 
   46166             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   46167             : #define ROSE_ALLOC_TRACE_CNT
   46168             : #include "memory-pool-snapshot.h"
   46169             : unsigned long alloc_trace_cnt = 0;
   46170             : #endif
   46171             : 
   46172             : #if ROSE_ALLOC_TRACE
   46173             : const unsigned SgUpirNumUnitsField::pool_size = 5;
   46174             : #else
   46175             : const unsigned SgUpirNumUnitsField::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   46176             : #endif
   46177             : 
   46178             : #ifndef ROSE_ALLOC_MEMSET
   46179             : #  define ROSE_ALLOC_MEMSET 0
   46180             : #endif
   46181             : 
   46182             : #ifndef ROSE_PEDANTIC_ALLOC
   46183             : #  define ROSE_PEDANTIC_ALLOC 0
   46184             : #endif
   46185             : 
   46186             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   46187             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   46188             : #endif
   46189             : 
   46190             : #if !defined(SGNODE__ALL_POOLS)
   46191             : #define SGNODE__ALL_POOLS
   46192             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   46193             : #endif
   46194             : 
   46195             : SgUpirNumUnitsField* SgUpirNumUnitsField::next_node = nullptr;
   46196             : std::vector<unsigned char*> SgUpirNumUnitsField::pools;
   46197             : 
   46198             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   46199             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   46200             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   46201             : // around this macro definition rather than each use).
   46202             : #ifndef ALLOC_MUTEX
   46203             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   46204             :         do {                                                                     \
   46205             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   46206             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   46207             :                 abort();                                                         \
   46208             :             }                                                                    \
   46209             :         } while (0);
   46210             : #endif
   46211             : 
   46212             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   46213             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   46214             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   46215             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   46216             : 
   46217             : /*! \brief New operator for SgUpirNumUnitsField.
   46218             : 
   46219             :    This new operator implements memory pools to provide most efficent 
   46220             :    use of the heap within construction of large ASTs.
   46221             : 
   46222             : \internal The new and delete operators use the lower level C malloc/free
   46223             :    function calls for performance and to make sure that mixing of malloc/free
   46224             :    and new/delete by the used can be caught more readily.  This may change
   46225             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   46226             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   46227             :    deallocate memory allocated using ROSE_MALLOC.
   46228             : */
   46229          18 : void *SgUpirNumUnitsField::operator new ( size_t Size )
   46230             : {
   46231             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   46232             :      * returning or throwing an exception. */
   46233          18 :     ALLOC_MUTEX(SgUpirNumUnitsField, lock);
   46234             : 
   46235             : #if ROSE_ALLOC_TRACE == 2
   46236             : //    printf("SgUpirNumUnitsField::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgUpirNumUnitsField::next_node);
   46237             : #endif
   46238             : 
   46239             : #if USE_CPP_NEW_DELETE_OPERATORS
   46240             :     void *mem = ROSE_MALLOC(Size);
   46241             :     ALLOC_MUTEX(SgUpirNumUnitsField, unlock);
   46242             :     return mem;
   46243             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   46244             : #if ROSE_PEDANTIC_ALLOC
   46245             :     ROSE_ASSERT(Size == sizeof(SgUpirNumUnitsField));
   46246             : #else
   46247          18 :     if (Size != sizeof(SgUpirNumUnitsField)) {
   46248           0 :       void * object = ROSE_MALLOC(Size);
   46249           0 :       ALLOC_MUTEX(SgUpirNumUnitsField, unlock);
   46250             :       return object;
   46251             :     }
   46252             : #endif
   46253             : 
   46254          18 :     if (SgUpirNumUnitsField::next_node == nullptr) {
   46255          11 :         SgUpirNumUnitsField * alloc = (SgUpirNumUnitsField*) ROSE_MALLOC ( SgUpirNumUnitsField::pool_size * sizeof(SgUpirNumUnitsField) );
   46256          11 :         ROSE_ASSERT(alloc != nullptr);
   46257             : 
   46258             : #if ROSE_ALLOC_TRACE == 2
   46259             : //        printf("SgUpirNumUnitsField::alloc\n  block[%zi] = [ %p , %p [\n", SgUpirNumUnitsField::pools.size(), alloc, alloc + SgUpirNumUnitsField::pool_size);
   46260             : #endif
   46261             : 
   46262             : #if ROSE_ALLOC_MEMSET == 1
   46263             : #elif ROSE_ALLOC_MEMSET == 2
   46264             :         memset(alloc, 0x00, SgUpirNumUnitsField::pool_size * sizeof(SgUpirNumUnitsField));
   46265             : #elif ROSE_ALLOC_MEMSET == 3
   46266             :         memset(alloc, 0xAA, SgUpirNumUnitsField::pool_size * sizeof(SgUpirNumUnitsField));
   46267             : #endif
   46268       22000 :         for (unsigned i=0; i < SgUpirNumUnitsField::pool_size-1; i++) {
   46269       21989 :           alloc[i].p_freepointer = &(alloc[i+1]);
   46270             :         }
   46271          11 :         alloc[SgUpirNumUnitsField::pool_size-1].p_freepointer = nullptr;
   46272             : 
   46273          11 :         SgUpirNumUnitsField::pools.push_back ( (unsigned char *) alloc );
   46274          11 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgUpirNumUnitsField::pool_size * sizeof(SgUpirNumUnitsField), V_SgUpirNumUnitsField ) );
   46275          11 :         SgUpirNumUnitsField::next_node = alloc;
   46276             :     }
   46277          18 :     ROSE_ASSERT(SgUpirNumUnitsField::next_node != nullptr);
   46278             : 
   46279          18 :     SgUpirNumUnitsField * object = SgUpirNumUnitsField::next_node;
   46280          18 :     SgUpirNumUnitsField::next_node = (SgUpirNumUnitsField*)(object->p_freepointer);
   46281             : 
   46282             : #if ROSE_ALLOC_TRACE == 2
   46283             :     printf("SgUpirNumUnitsField::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUpirNumUnitsField::next_node);
   46284             : #endif
   46285             : 
   46286          18 :     SgNode * fp = object->p_freepointer;
   46287             : #if ROSE_ALLOC_MEMSET == 1
   46288             : #elif ROSE_ALLOC_MEMSET == 2
   46289             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgUpirNumUnitsField) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   46290             : #elif ROSE_ALLOC_MEMSET == 3
   46291             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgUpirNumUnitsField) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   46292             : #endif
   46293          18 :     object->p_freepointer = fp;
   46294             : 
   46295             : #if ROSE_ALLOC_TRACE == 2
   46296             : //    printf("SgUpirNumUnitsField::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUpirNumUnitsField::next_node);
   46297             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   46298             :     Rose::MemPool::snapshot(oss.str());
   46299             :     alloc_trace_cnt++;
   46300             : #endif
   46301             : 
   46302          18 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   46303             : 
   46304          18 :     ALLOC_MUTEX(SgUpirNumUnitsField, unlock);
   46305             : 
   46306             :     return object;
   46307             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   46308             : }
   46309             : 
   46310             : 
   46311             : 
   46312             : /*! \brief Delete operator for SgUpirNumUnitsField.
   46313             : 
   46314             :    This delete operator implements deallocation using memory pools to 
   46315             :    provide most efficent use of the heap within construction of large ASTs.
   46316             : 
   46317             : \internal The new and delete operators use the lower level C malloc/free
   46318             :    function calls for performance and to make sure that mixing of malloc/free
   46319             :    and new/delete by the used can be caught more readily.  This may change
   46320             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   46321             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   46322             :    deallocate memory allocated using ROSE_MALLOC.
   46323             : */
   46324           0 : void SgUpirNumUnitsField::operator delete(void *Pointer, size_t Size)
   46325             : {
   46326             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   46327             :      * or throwing an exception. */
   46328           0 :     ALLOC_MUTEX(SgUpirNumUnitsField, lock);
   46329             : 
   46330             : #if USE_CPP_NEW_DELETE_OPERATORS
   46331             :     ROSE_FREE(Pointer);
   46332             : #else
   46333             : #if ROSE_PEDANTIC_ALLOC
   46334             :     ROSE_ASSERT(Size == sizeof(SgUpirNumUnitsField));
   46335             : #else
   46336           0 :     if (Size != sizeof(SgUpirNumUnitsField)) {
   46337           0 :       ROSE_FREE(Pointer);
   46338           0 :       ALLOC_MUTEX(SgUpirNumUnitsField, unlock);
   46339             :       return;
   46340             :     }
   46341             : #endif
   46342             : 
   46343           0 :     SgUpirNumUnitsField * object = (SgUpirNumUnitsField*) Pointer;
   46344           0 :     ROSE_ASSERT(object != nullptr);
   46345             : 
   46346             : #if ROSE_ALLOC_TRACE == 2
   46347             : //  printf("SgUpirNumUnitsField::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUpirNumUnitsField::next_node);
   46348             :     printf("SgUpirNumUnitsField::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUpirNumUnitsField::next_node);
   46349             : #endif
   46350             : 
   46351             : #if ROSE_PEDANTIC_ALLOC
   46352             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   46353             : #endif
   46354             : 
   46355             : #if ROSE_ALLOC_MEMSET == 1
   46356             : #elif ROSE_ALLOC_MEMSET == 2
   46357             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgUpirNumUnitsField) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   46358             : #elif ROSE_ALLOC_MEMSET == 3
   46359             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgUpirNumUnitsField) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   46360             : #endif
   46361             : 
   46362             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   46363             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   46364             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   46365             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   46366             : #else
   46367           0 :     object->p_freepointer = SgUpirNumUnitsField::next_node;
   46368           0 :     SgUpirNumUnitsField::next_node = object;
   46369             : #endif
   46370             : 
   46371             : #if ROSE_ALLOC_TRACE == 2
   46372             : //  printf("SgUpirNumUnitsField::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUpirNumUnitsField::next_node);
   46373             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   46374             :     Rose::MemPool::snapshot(oss.str());
   46375             :     alloc_trace_cnt++;
   46376             : #endif
   46377             : 
   46378             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   46379             : 
   46380           0 :     ALLOC_MUTEX(SgUpirNumUnitsField, unlock);
   46381             : }
   46382             : 
   46383             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   46384             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   46385             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   46386             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   46387             : // Also, note comment below from Robb (copied from the Common.code file).
   46388             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   46389             : //
   46390             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   46391             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   46392             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   46393             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   46394             : #if 0
   46395             : void SgUpirNumUnitsField::operator delete(void* pointer) { SgUpirNumUnitsField::operator delete (pointer, sizeof(SgUpirNumUnitsField)); };
   46396             : #endif
   46397             : /* #line 46398 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   46398             : 
   46399             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   46400             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   46401             : // obviously imply C++.
   46402             : 
   46403             : // This implements the support within ROSE for memory pools.  Memory pools
   46404             : // support the most condensed usage of memory within the construction of
   46405             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   46406             : // by a new operator written for each class.
   46407             : 
   46408             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   46409             :     // User wants multi-thread support and POSIX threads are available.
   46410             : #   include <pthread.h>
   46411             :     static pthread_mutex_t SgOmpNumTeamsClause_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   46412             : #else
   46413             :      // Cause synchronization to be skipped.
   46414             : #    ifndef ALLOC_MUTEX
   46415             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   46416             : #    endif
   46417             : #    ifdef _REENTRANT
   46418             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   46419             : #       ifdef _MSC_VER
   46420             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   46421             : #       else
   46422             : #           warning "POSIX threads are not available; synchronization being skipped"
   46423             : #       endif
   46424             : #    endif
   46425             : #endif
   46426             : 
   46427             : #ifndef ROSE_ALLOC_TRACE
   46428             : #  define ROSE_ALLOC_TRACE 0
   46429             : #endif
   46430             : 
   46431             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   46432             : #define ROSE_ALLOC_TRACE_CNT
   46433             : #include "memory-pool-snapshot.h"
   46434             : unsigned long alloc_trace_cnt = 0;
   46435             : #endif
   46436             : 
   46437             : #if ROSE_ALLOC_TRACE
   46438             : const unsigned SgOmpNumTeamsClause::pool_size = 5;
   46439             : #else
   46440             : const unsigned SgOmpNumTeamsClause::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   46441             : #endif
   46442             : 
   46443             : #ifndef ROSE_ALLOC_MEMSET
   46444             : #  define ROSE_ALLOC_MEMSET 0
   46445             : #endif
   46446             : 
   46447             : #ifndef ROSE_PEDANTIC_ALLOC
   46448             : #  define ROSE_PEDANTIC_ALLOC 0
   46449             : #endif
   46450             : 
   46451             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   46452             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   46453             : #endif
   46454             : 
   46455             : #if !defined(SGNODE__ALL_POOLS)
   46456             : #define SGNODE__ALL_POOLS
   46457             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   46458             : #endif
   46459             : 
   46460             : SgOmpNumTeamsClause* SgOmpNumTeamsClause::next_node = nullptr;
   46461             : std::vector<unsigned char*> SgOmpNumTeamsClause::pools;
   46462             : 
   46463             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   46464             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   46465             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   46466             : // around this macro definition rather than each use).
   46467             : #ifndef ALLOC_MUTEX
   46468             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   46469             :         do {                                                                     \
   46470             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   46471             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   46472             :                 abort();                                                         \
   46473             :             }                                                                    \
   46474             :         } while (0);
   46475             : #endif
   46476             : 
   46477             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   46478             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   46479             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   46480             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   46481             : 
   46482             : /*! \brief New operator for SgOmpNumTeamsClause.
   46483             : 
   46484             :    This new operator implements memory pools to provide most efficent 
   46485             :    use of the heap within construction of large ASTs.
   46486             : 
   46487             : \internal The new and delete operators use the lower level C malloc/free
   46488             :    function calls for performance and to make sure that mixing of malloc/free
   46489             :    and new/delete by the used can be caught more readily.  This may change
   46490             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   46491             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   46492             :    deallocate memory allocated using ROSE_MALLOC.
   46493             : */
   46494           8 : void *SgOmpNumTeamsClause::operator new ( size_t Size )
   46495             : {
   46496             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   46497             :      * returning or throwing an exception. */
   46498           8 :     ALLOC_MUTEX(SgOmpNumTeamsClause, lock);
   46499             : 
   46500             : #if ROSE_ALLOC_TRACE == 2
   46501             : //    printf("SgOmpNumTeamsClause::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgOmpNumTeamsClause::next_node);
   46502             : #endif
   46503             : 
   46504             : #if USE_CPP_NEW_DELETE_OPERATORS
   46505             :     void *mem = ROSE_MALLOC(Size);
   46506             :     ALLOC_MUTEX(SgOmpNumTeamsClause, unlock);
   46507             :     return mem;
   46508             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   46509             : #if ROSE_PEDANTIC_ALLOC
   46510             :     ROSE_ASSERT(Size == sizeof(SgOmpNumTeamsClause));
   46511             : #else
   46512           8 :     if (Size != sizeof(SgOmpNumTeamsClause)) {
   46513           0 :       void * object = ROSE_MALLOC(Size);
   46514           0 :       ALLOC_MUTEX(SgOmpNumTeamsClause, unlock);
   46515             :       return object;
   46516             :     }
   46517             : #endif
   46518             : 
   46519           8 :     if (SgOmpNumTeamsClause::next_node == nullptr) {
   46520           8 :         SgOmpNumTeamsClause * alloc = (SgOmpNumTeamsClause*) ROSE_MALLOC ( SgOmpNumTeamsClause::pool_size * sizeof(SgOmpNumTeamsClause) );
   46521           8 :         ROSE_ASSERT(alloc != nullptr);
   46522             : 
   46523             : #if ROSE_ALLOC_TRACE == 2
   46524             : //        printf("SgOmpNumTeamsClause::alloc\n  block[%zi] = [ %p , %p [\n", SgOmpNumTeamsClause::pools.size(), alloc, alloc + SgOmpNumTeamsClause::pool_size);
   46525             : #endif
   46526             : 
   46527             : #if ROSE_ALLOC_MEMSET == 1
   46528             : #elif ROSE_ALLOC_MEMSET == 2
   46529             :         memset(alloc, 0x00, SgOmpNumTeamsClause::pool_size * sizeof(SgOmpNumTeamsClause));
   46530             : #elif ROSE_ALLOC_MEMSET == 3
   46531             :         memset(alloc, 0xAA, SgOmpNumTeamsClause::pool_size * sizeof(SgOmpNumTeamsClause));
   46532             : #endif
   46533       16000 :         for (unsigned i=0; i < SgOmpNumTeamsClause::pool_size-1; i++) {
   46534       15992 :           alloc[i].p_freepointer = &(alloc[i+1]);
   46535             :         }
   46536           8 :         alloc[SgOmpNumTeamsClause::pool_size-1].p_freepointer = nullptr;
   46537             : 
   46538           8 :         SgOmpNumTeamsClause::pools.push_back ( (unsigned char *) alloc );
   46539           8 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgOmpNumTeamsClause::pool_size * sizeof(SgOmpNumTeamsClause), V_SgOmpNumTeamsClause ) );
   46540           8 :         SgOmpNumTeamsClause::next_node = alloc;
   46541             :     }
   46542           8 :     ROSE_ASSERT(SgOmpNumTeamsClause::next_node != nullptr);
   46543             : 
   46544           8 :     SgOmpNumTeamsClause * object = SgOmpNumTeamsClause::next_node;
   46545           8 :     SgOmpNumTeamsClause::next_node = (SgOmpNumTeamsClause*)(object->p_freepointer);
   46546             : 
   46547             : #if ROSE_ALLOC_TRACE == 2
   46548             :     printf("SgOmpNumTeamsClause::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpNumTeamsClause::next_node);
   46549             : #endif
   46550             : 
   46551           8 :     SgNode * fp = object->p_freepointer;
   46552             : #if ROSE_ALLOC_MEMSET == 1
   46553             : #elif ROSE_ALLOC_MEMSET == 2
   46554             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpNumTeamsClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   46555             : #elif ROSE_ALLOC_MEMSET == 3
   46556             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgOmpNumTeamsClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   46557             : #endif
   46558           8 :     object->p_freepointer = fp;
   46559             : 
   46560             : #if ROSE_ALLOC_TRACE == 2
   46561             : //    printf("SgOmpNumTeamsClause::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpNumTeamsClause::next_node);
   46562             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   46563             :     Rose::MemPool::snapshot(oss.str());
   46564             :     alloc_trace_cnt++;
   46565             : #endif
   46566             : 
   46567           8 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   46568             : 
   46569           8 :     ALLOC_MUTEX(SgOmpNumTeamsClause, unlock);
   46570             : 
   46571             :     return object;
   46572             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   46573             : }
   46574             : 
   46575             : 
   46576             : 
   46577             : /*! \brief Delete operator for SgOmpNumTeamsClause.
   46578             : 
   46579             :    This delete operator implements deallocation using memory pools to 
   46580             :    provide most efficent use of the heap within construction of large ASTs.
   46581             : 
   46582             : \internal The new and delete operators use the lower level C malloc/free
   46583             :    function calls for performance and to make sure that mixing of malloc/free
   46584             :    and new/delete by the used can be caught more readily.  This may change
   46585             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   46586             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   46587             :    deallocate memory allocated using ROSE_MALLOC.
   46588             : */
   46589           0 : void SgOmpNumTeamsClause::operator delete(void *Pointer, size_t Size)
   46590             : {
   46591             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   46592             :      * or throwing an exception. */
   46593           0 :     ALLOC_MUTEX(SgOmpNumTeamsClause, lock);
   46594             : 
   46595             : #if USE_CPP_NEW_DELETE_OPERATORS
   46596             :     ROSE_FREE(Pointer);
   46597             : #else
   46598             : #if ROSE_PEDANTIC_ALLOC
   46599             :     ROSE_ASSERT(Size == sizeof(SgOmpNumTeamsClause));
   46600             : #else
   46601           0 :     if (Size != sizeof(SgOmpNumTeamsClause)) {
   46602           0 :       ROSE_FREE(Pointer);
   46603           0 :       ALLOC_MUTEX(SgOmpNumTeamsClause, unlock);
   46604             :       return;
   46605             :     }
   46606             : #endif
   46607             : 
   46608           0 :     SgOmpNumTeamsClause * object = (SgOmpNumTeamsClause*) Pointer;
   46609           0 :     ROSE_ASSERT(object != nullptr);
   46610             : 
   46611             : #if ROSE_ALLOC_TRACE == 2
   46612             : //  printf("SgOmpNumTeamsClause::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpNumTeamsClause::next_node);
   46613             :     printf("SgOmpNumTeamsClause::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpNumTeamsClause::next_node);
   46614             : #endif
   46615             : 
   46616             : #if ROSE_PEDANTIC_ALLOC
   46617             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   46618             : #endif
   46619             : 
   46620             : #if ROSE_ALLOC_MEMSET == 1
   46621             : #elif ROSE_ALLOC_MEMSET == 2
   46622             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpNumTeamsClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   46623             : #elif ROSE_ALLOC_MEMSET == 3
   46624             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgOmpNumTeamsClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   46625             : #endif
   46626             : 
   46627             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   46628             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   46629             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   46630             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   46631             : #else
   46632           0 :     object->p_freepointer = SgOmpNumTeamsClause::next_node;
   46633           0 :     SgOmpNumTeamsClause::next_node = object;
   46634             : #endif
   46635             : 
   46636             : #if ROSE_ALLOC_TRACE == 2
   46637             : //  printf("SgOmpNumTeamsClause::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpNumTeamsClause::next_node);
   46638             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   46639             :     Rose::MemPool::snapshot(oss.str());
   46640             :     alloc_trace_cnt++;
   46641             : #endif
   46642             : 
   46643             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   46644             : 
   46645           0 :     ALLOC_MUTEX(SgOmpNumTeamsClause, unlock);
   46646             : }
   46647             : 
   46648             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   46649             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   46650             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   46651             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   46652             : // Also, note comment below from Robb (copied from the Common.code file).
   46653             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   46654             : //
   46655             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   46656             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   46657             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   46658             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   46659             : #if 0
   46660             : void SgOmpNumTeamsClause::operator delete(void* pointer) { SgOmpNumTeamsClause::operator delete (pointer, sizeof(SgOmpNumTeamsClause)); };
   46661             : #endif
   46662             : /* #line 46663 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   46663             : 
   46664             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   46665             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   46666             : // obviously imply C++.
   46667             : 
   46668             : // This implements the support within ROSE for memory pools.  Memory pools
   46669             : // support the most condensed usage of memory within the construction of
   46670             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   46671             : // by a new operator written for each class.
   46672             : 
   46673             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   46674             :     // User wants multi-thread support and POSIX threads are available.
   46675             : #   include <pthread.h>
   46676             :     static pthread_mutex_t SgOmpThreadLimitClause_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   46677             : #else
   46678             :      // Cause synchronization to be skipped.
   46679             : #    ifndef ALLOC_MUTEX
   46680             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   46681             : #    endif
   46682             : #    ifdef _REENTRANT
   46683             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   46684             : #       ifdef _MSC_VER
   46685             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   46686             : #       else
   46687             : #           warning "POSIX threads are not available; synchronization being skipped"
   46688             : #       endif
   46689             : #    endif
   46690             : #endif
   46691             : 
   46692             : #ifndef ROSE_ALLOC_TRACE
   46693             : #  define ROSE_ALLOC_TRACE 0
   46694             : #endif
   46695             : 
   46696             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   46697             : #define ROSE_ALLOC_TRACE_CNT
   46698             : #include "memory-pool-snapshot.h"
   46699             : unsigned long alloc_trace_cnt = 0;
   46700             : #endif
   46701             : 
   46702             : #if ROSE_ALLOC_TRACE
   46703             : const unsigned SgOmpThreadLimitClause::pool_size = 5;
   46704             : #else
   46705             : const unsigned SgOmpThreadLimitClause::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   46706             : #endif
   46707             : 
   46708             : #ifndef ROSE_ALLOC_MEMSET
   46709             : #  define ROSE_ALLOC_MEMSET 0
   46710             : #endif
   46711             : 
   46712             : #ifndef ROSE_PEDANTIC_ALLOC
   46713             : #  define ROSE_PEDANTIC_ALLOC 0
   46714             : #endif
   46715             : 
   46716             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   46717             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   46718             : #endif
   46719             : 
   46720             : #if !defined(SGNODE__ALL_POOLS)
   46721             : #define SGNODE__ALL_POOLS
   46722             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   46723             : #endif
   46724             : 
   46725             : SgOmpThreadLimitClause* SgOmpThreadLimitClause::next_node = nullptr;
   46726             : std::vector<unsigned char*> SgOmpThreadLimitClause::pools;
   46727             : 
   46728             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   46729             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   46730             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   46731             : // around this macro definition rather than each use).
   46732             : #ifndef ALLOC_MUTEX
   46733             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   46734             :         do {                                                                     \
   46735             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   46736             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   46737             :                 abort();                                                         \
   46738             :             }                                                                    \
   46739             :         } while (0);
   46740             : #endif
   46741             : 
   46742             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   46743             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   46744             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   46745             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   46746             : 
   46747             : /*! \brief New operator for SgOmpThreadLimitClause.
   46748             : 
   46749             :    This new operator implements memory pools to provide most efficent 
   46750             :    use of the heap within construction of large ASTs.
   46751             : 
   46752             : \internal The new and delete operators use the lower level C malloc/free
   46753             :    function calls for performance and to make sure that mixing of malloc/free
   46754             :    and new/delete by the used can be caught more readily.  This may change
   46755             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   46756             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   46757             :    deallocate memory allocated using ROSE_MALLOC.
   46758             : */
   46759           2 : void *SgOmpThreadLimitClause::operator new ( size_t Size )
   46760             : {
   46761             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   46762             :      * returning or throwing an exception. */
   46763           2 :     ALLOC_MUTEX(SgOmpThreadLimitClause, lock);
   46764             : 
   46765             : #if ROSE_ALLOC_TRACE == 2
   46766             : //    printf("SgOmpThreadLimitClause::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgOmpThreadLimitClause::next_node);
   46767             : #endif
   46768             : 
   46769             : #if USE_CPP_NEW_DELETE_OPERATORS
   46770             :     void *mem = ROSE_MALLOC(Size);
   46771             :     ALLOC_MUTEX(SgOmpThreadLimitClause, unlock);
   46772             :     return mem;
   46773             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   46774             : #if ROSE_PEDANTIC_ALLOC
   46775             :     ROSE_ASSERT(Size == sizeof(SgOmpThreadLimitClause));
   46776             : #else
   46777           2 :     if (Size != sizeof(SgOmpThreadLimitClause)) {
   46778           0 :       void * object = ROSE_MALLOC(Size);
   46779           0 :       ALLOC_MUTEX(SgOmpThreadLimitClause, unlock);
   46780             :       return object;
   46781             :     }
   46782             : #endif
   46783             : 
   46784           2 :     if (SgOmpThreadLimitClause::next_node == nullptr) {
   46785           2 :         SgOmpThreadLimitClause * alloc = (SgOmpThreadLimitClause*) ROSE_MALLOC ( SgOmpThreadLimitClause::pool_size * sizeof(SgOmpThreadLimitClause) );
   46786           2 :         ROSE_ASSERT(alloc != nullptr);
   46787             : 
   46788             : #if ROSE_ALLOC_TRACE == 2
   46789             : //        printf("SgOmpThreadLimitClause::alloc\n  block[%zi] = [ %p , %p [\n", SgOmpThreadLimitClause::pools.size(), alloc, alloc + SgOmpThreadLimitClause::pool_size);
   46790             : #endif
   46791             : 
   46792             : #if ROSE_ALLOC_MEMSET == 1
   46793             : #elif ROSE_ALLOC_MEMSET == 2
   46794             :         memset(alloc, 0x00, SgOmpThreadLimitClause::pool_size * sizeof(SgOmpThreadLimitClause));
   46795             : #elif ROSE_ALLOC_MEMSET == 3
   46796             :         memset(alloc, 0xAA, SgOmpThreadLimitClause::pool_size * sizeof(SgOmpThreadLimitClause));
   46797             : #endif
   46798        4000 :         for (unsigned i=0; i < SgOmpThreadLimitClause::pool_size-1; i++) {
   46799        3998 :           alloc[i].p_freepointer = &(alloc[i+1]);
   46800             :         }
   46801           2 :         alloc[SgOmpThreadLimitClause::pool_size-1].p_freepointer = nullptr;
   46802             : 
   46803           2 :         SgOmpThreadLimitClause::pools.push_back ( (unsigned char *) alloc );
   46804           2 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgOmpThreadLimitClause::pool_size * sizeof(SgOmpThreadLimitClause), V_SgOmpThreadLimitClause ) );
   46805           2 :         SgOmpThreadLimitClause::next_node = alloc;
   46806             :     }
   46807           2 :     ROSE_ASSERT(SgOmpThreadLimitClause::next_node != nullptr);
   46808             : 
   46809           2 :     SgOmpThreadLimitClause * object = SgOmpThreadLimitClause::next_node;
   46810           2 :     SgOmpThreadLimitClause::next_node = (SgOmpThreadLimitClause*)(object->p_freepointer);
   46811             : 
   46812             : #if ROSE_ALLOC_TRACE == 2
   46813             :     printf("SgOmpThreadLimitClause::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpThreadLimitClause::next_node);
   46814             : #endif
   46815             : 
   46816           2 :     SgNode * fp = object->p_freepointer;
   46817             : #if ROSE_ALLOC_MEMSET == 1
   46818             : #elif ROSE_ALLOC_MEMSET == 2
   46819             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpThreadLimitClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   46820             : #elif ROSE_ALLOC_MEMSET == 3
   46821             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgOmpThreadLimitClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   46822             : #endif
   46823           2 :     object->p_freepointer = fp;
   46824             : 
   46825             : #if ROSE_ALLOC_TRACE == 2
   46826             : //    printf("SgOmpThreadLimitClause::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpThreadLimitClause::next_node);
   46827             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   46828             :     Rose::MemPool::snapshot(oss.str());
   46829             :     alloc_trace_cnt++;
   46830             : #endif
   46831             : 
   46832           2 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   46833             : 
   46834           2 :     ALLOC_MUTEX(SgOmpThreadLimitClause, unlock);
   46835             : 
   46836             :     return object;
   46837             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   46838             : }
   46839             : 
   46840             : 
   46841             : 
   46842             : /*! \brief Delete operator for SgOmpThreadLimitClause.
   46843             : 
   46844             :    This delete operator implements deallocation using memory pools to 
   46845             :    provide most efficent use of the heap within construction of large ASTs.
   46846             : 
   46847             : \internal The new and delete operators use the lower level C malloc/free
   46848             :    function calls for performance and to make sure that mixing of malloc/free
   46849             :    and new/delete by the used can be caught more readily.  This may change
   46850             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   46851             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   46852             :    deallocate memory allocated using ROSE_MALLOC.
   46853             : */
   46854           0 : void SgOmpThreadLimitClause::operator delete(void *Pointer, size_t Size)
   46855             : {
   46856             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   46857             :      * or throwing an exception. */
   46858           0 :     ALLOC_MUTEX(SgOmpThreadLimitClause, lock);
   46859             : 
   46860             : #if USE_CPP_NEW_DELETE_OPERATORS
   46861             :     ROSE_FREE(Pointer);
   46862             : #else
   46863             : #if ROSE_PEDANTIC_ALLOC
   46864             :     ROSE_ASSERT(Size == sizeof(SgOmpThreadLimitClause));
   46865             : #else
   46866           0 :     if (Size != sizeof(SgOmpThreadLimitClause)) {
   46867           0 :       ROSE_FREE(Pointer);
   46868           0 :       ALLOC_MUTEX(SgOmpThreadLimitClause, unlock);
   46869             :       return;
   46870             :     }
   46871             : #endif
   46872             : 
   46873           0 :     SgOmpThreadLimitClause * object = (SgOmpThreadLimitClause*) Pointer;
   46874           0 :     ROSE_ASSERT(object != nullptr);
   46875             : 
   46876             : #if ROSE_ALLOC_TRACE == 2
   46877             : //  printf("SgOmpThreadLimitClause::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpThreadLimitClause::next_node);
   46878             :     printf("SgOmpThreadLimitClause::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpThreadLimitClause::next_node);
   46879             : #endif
   46880             : 
   46881             : #if ROSE_PEDANTIC_ALLOC
   46882             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   46883             : #endif
   46884             : 
   46885             : #if ROSE_ALLOC_MEMSET == 1
   46886             : #elif ROSE_ALLOC_MEMSET == 2
   46887             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpThreadLimitClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   46888             : #elif ROSE_ALLOC_MEMSET == 3
   46889             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgOmpThreadLimitClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   46890             : #endif
   46891             : 
   46892             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   46893             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   46894             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   46895             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   46896             : #else
   46897           0 :     object->p_freepointer = SgOmpThreadLimitClause::next_node;
   46898           0 :     SgOmpThreadLimitClause::next_node = object;
   46899             : #endif
   46900             : 
   46901             : #if ROSE_ALLOC_TRACE == 2
   46902             : //  printf("SgOmpThreadLimitClause::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpThreadLimitClause::next_node);
   46903             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   46904             :     Rose::MemPool::snapshot(oss.str());
   46905             :     alloc_trace_cnt++;
   46906             : #endif
   46907             : 
   46908             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   46909             : 
   46910           0 :     ALLOC_MUTEX(SgOmpThreadLimitClause, unlock);
   46911             : }
   46912             : 
   46913             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   46914             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   46915             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   46916             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   46917             : // Also, note comment below from Robb (copied from the Common.code file).
   46918             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   46919             : //
   46920             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   46921             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   46922             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   46923             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   46924             : #if 0
   46925             : void SgOmpThreadLimitClause::operator delete(void* pointer) { SgOmpThreadLimitClause::operator delete (pointer, sizeof(SgOmpThreadLimitClause)); };
   46926             : #endif
   46927             : /* #line 46928 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   46928             : 
   46929             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   46930             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   46931             : // obviously imply C++.
   46932             : 
   46933             : // This implements the support within ROSE for memory pools.  Memory pools
   46934             : // support the most condensed usage of memory within the construction of
   46935             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   46936             : // by a new operator written for each class.
   46937             : 
   46938             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   46939             :     // User wants multi-thread support and POSIX threads are available.
   46940             : #   include <pthread.h>
   46941             :     static pthread_mutex_t SgOmpDeviceClause_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   46942             : #else
   46943             :      // Cause synchronization to be skipped.
   46944             : #    ifndef ALLOC_MUTEX
   46945             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   46946             : #    endif
   46947             : #    ifdef _REENTRANT
   46948             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   46949             : #       ifdef _MSC_VER
   46950             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   46951             : #       else
   46952             : #           warning "POSIX threads are not available; synchronization being skipped"
   46953             : #       endif
   46954             : #    endif
   46955             : #endif
   46956             : 
   46957             : #ifndef ROSE_ALLOC_TRACE
   46958             : #  define ROSE_ALLOC_TRACE 0
   46959             : #endif
   46960             : 
   46961             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   46962             : #define ROSE_ALLOC_TRACE_CNT
   46963             : #include "memory-pool-snapshot.h"
   46964             : unsigned long alloc_trace_cnt = 0;
   46965             : #endif
   46966             : 
   46967             : #if ROSE_ALLOC_TRACE
   46968             : const unsigned SgOmpDeviceClause::pool_size = 5;
   46969             : #else
   46970             : const unsigned SgOmpDeviceClause::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   46971             : #endif
   46972             : 
   46973             : #ifndef ROSE_ALLOC_MEMSET
   46974             : #  define ROSE_ALLOC_MEMSET 0
   46975             : #endif
   46976             : 
   46977             : #ifndef ROSE_PEDANTIC_ALLOC
   46978             : #  define ROSE_PEDANTIC_ALLOC 0
   46979             : #endif
   46980             : 
   46981             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   46982             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   46983             : #endif
   46984             : 
   46985             : #if !defined(SGNODE__ALL_POOLS)
   46986             : #define SGNODE__ALL_POOLS
   46987             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   46988             : #endif
   46989             : 
   46990             : SgOmpDeviceClause* SgOmpDeviceClause::next_node = nullptr;
   46991             : std::vector<unsigned char*> SgOmpDeviceClause::pools;
   46992             : 
   46993             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   46994             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   46995             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   46996             : // around this macro definition rather than each use).
   46997             : #ifndef ALLOC_MUTEX
   46998             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   46999             :         do {                                                                     \
   47000             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   47001             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   47002             :                 abort();                                                         \
   47003             :             }                                                                    \
   47004             :         } while (0);
   47005             : #endif
   47006             : 
   47007             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   47008             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   47009             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   47010             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   47011             : 
   47012             : /*! \brief New operator for SgOmpDeviceClause.
   47013             : 
   47014             :    This new operator implements memory pools to provide most efficent 
   47015             :    use of the heap within construction of large ASTs.
   47016             : 
   47017             : \internal The new and delete operators use the lower level C malloc/free
   47018             :    function calls for performance and to make sure that mixing of malloc/free
   47019             :    and new/delete by the used can be caught more readily.  This may change
   47020             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   47021             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   47022             :    deallocate memory allocated using ROSE_MALLOC.
   47023             : */
   47024           9 : void *SgOmpDeviceClause::operator new ( size_t Size )
   47025             : {
   47026             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   47027             :      * returning or throwing an exception. */
   47028           9 :     ALLOC_MUTEX(SgOmpDeviceClause, lock);
   47029             : 
   47030             : #if ROSE_ALLOC_TRACE == 2
   47031             : //    printf("SgOmpDeviceClause::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgOmpDeviceClause::next_node);
   47032             : #endif
   47033             : 
   47034             : #if USE_CPP_NEW_DELETE_OPERATORS
   47035             :     void *mem = ROSE_MALLOC(Size);
   47036             :     ALLOC_MUTEX(SgOmpDeviceClause, unlock);
   47037             :     return mem;
   47038             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   47039             : #if ROSE_PEDANTIC_ALLOC
   47040             :     ROSE_ASSERT(Size == sizeof(SgOmpDeviceClause));
   47041             : #else
   47042           9 :     if (Size != sizeof(SgOmpDeviceClause)) {
   47043           0 :       void * object = ROSE_MALLOC(Size);
   47044           0 :       ALLOC_MUTEX(SgOmpDeviceClause, unlock);
   47045             :       return object;
   47046             :     }
   47047             : #endif
   47048             : 
   47049           9 :     if (SgOmpDeviceClause::next_node == nullptr) {
   47050           7 :         SgOmpDeviceClause * alloc = (SgOmpDeviceClause*) ROSE_MALLOC ( SgOmpDeviceClause::pool_size * sizeof(SgOmpDeviceClause) );
   47051           7 :         ROSE_ASSERT(alloc != nullptr);
   47052             : 
   47053             : #if ROSE_ALLOC_TRACE == 2
   47054             : //        printf("SgOmpDeviceClause::alloc\n  block[%zi] = [ %p , %p [\n", SgOmpDeviceClause::pools.size(), alloc, alloc + SgOmpDeviceClause::pool_size);
   47055             : #endif
   47056             : 
   47057             : #if ROSE_ALLOC_MEMSET == 1
   47058             : #elif ROSE_ALLOC_MEMSET == 2
   47059             :         memset(alloc, 0x00, SgOmpDeviceClause::pool_size * sizeof(SgOmpDeviceClause));
   47060             : #elif ROSE_ALLOC_MEMSET == 3
   47061             :         memset(alloc, 0xAA, SgOmpDeviceClause::pool_size * sizeof(SgOmpDeviceClause));
   47062             : #endif
   47063       14000 :         for (unsigned i=0; i < SgOmpDeviceClause::pool_size-1; i++) {
   47064       13993 :           alloc[i].p_freepointer = &(alloc[i+1]);
   47065             :         }
   47066           7 :         alloc[SgOmpDeviceClause::pool_size-1].p_freepointer = nullptr;
   47067             : 
   47068           7 :         SgOmpDeviceClause::pools.push_back ( (unsigned char *) alloc );
   47069           7 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgOmpDeviceClause::pool_size * sizeof(SgOmpDeviceClause), V_SgOmpDeviceClause ) );
   47070           7 :         SgOmpDeviceClause::next_node = alloc;
   47071             :     }
   47072           9 :     ROSE_ASSERT(SgOmpDeviceClause::next_node != nullptr);
   47073             : 
   47074           9 :     SgOmpDeviceClause * object = SgOmpDeviceClause::next_node;
   47075           9 :     SgOmpDeviceClause::next_node = (SgOmpDeviceClause*)(object->p_freepointer);
   47076             : 
   47077             : #if ROSE_ALLOC_TRACE == 2
   47078             :     printf("SgOmpDeviceClause::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpDeviceClause::next_node);
   47079             : #endif
   47080             : 
   47081           9 :     SgNode * fp = object->p_freepointer;
   47082             : #if ROSE_ALLOC_MEMSET == 1
   47083             : #elif ROSE_ALLOC_MEMSET == 2
   47084             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpDeviceClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   47085             : #elif ROSE_ALLOC_MEMSET == 3
   47086             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgOmpDeviceClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   47087             : #endif
   47088           9 :     object->p_freepointer = fp;
   47089             : 
   47090             : #if ROSE_ALLOC_TRACE == 2
   47091             : //    printf("SgOmpDeviceClause::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpDeviceClause::next_node);
   47092             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   47093             :     Rose::MemPool::snapshot(oss.str());
   47094             :     alloc_trace_cnt++;
   47095             : #endif
   47096             : 
   47097           9 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   47098             : 
   47099           9 :     ALLOC_MUTEX(SgOmpDeviceClause, unlock);
   47100             : 
   47101             :     return object;
   47102             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   47103             : }
   47104             : 
   47105             : 
   47106             : 
   47107             : /*! \brief Delete operator for SgOmpDeviceClause.
   47108             : 
   47109             :    This delete operator implements deallocation using memory pools to 
   47110             :    provide most efficent use of the heap within construction of large ASTs.
   47111             : 
   47112             : \internal The new and delete operators use the lower level C malloc/free
   47113             :    function calls for performance and to make sure that mixing of malloc/free
   47114             :    and new/delete by the used can be caught more readily.  This may change
   47115             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   47116             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   47117             :    deallocate memory allocated using ROSE_MALLOC.
   47118             : */
   47119           0 : void SgOmpDeviceClause::operator delete(void *Pointer, size_t Size)
   47120             : {
   47121             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   47122             :      * or throwing an exception. */
   47123           0 :     ALLOC_MUTEX(SgOmpDeviceClause, lock);
   47124             : 
   47125             : #if USE_CPP_NEW_DELETE_OPERATORS
   47126             :     ROSE_FREE(Pointer);
   47127             : #else
   47128             : #if ROSE_PEDANTIC_ALLOC
   47129             :     ROSE_ASSERT(Size == sizeof(SgOmpDeviceClause));
   47130             : #else
   47131           0 :     if (Size != sizeof(SgOmpDeviceClause)) {
   47132           0 :       ROSE_FREE(Pointer);
   47133           0 :       ALLOC_MUTEX(SgOmpDeviceClause, unlock);
   47134             :       return;
   47135             :     }
   47136             : #endif
   47137             : 
   47138           0 :     SgOmpDeviceClause * object = (SgOmpDeviceClause*) Pointer;
   47139           0 :     ROSE_ASSERT(object != nullptr);
   47140             : 
   47141             : #if ROSE_ALLOC_TRACE == 2
   47142             : //  printf("SgOmpDeviceClause::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpDeviceClause::next_node);
   47143             :     printf("SgOmpDeviceClause::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpDeviceClause::next_node);
   47144             : #endif
   47145             : 
   47146             : #if ROSE_PEDANTIC_ALLOC
   47147             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   47148             : #endif
   47149             : 
   47150             : #if ROSE_ALLOC_MEMSET == 1
   47151             : #elif ROSE_ALLOC_MEMSET == 2
   47152             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpDeviceClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   47153             : #elif ROSE_ALLOC_MEMSET == 3
   47154             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgOmpDeviceClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   47155             : #endif
   47156             : 
   47157             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   47158             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   47159             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   47160             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   47161             : #else
   47162           0 :     object->p_freepointer = SgOmpDeviceClause::next_node;
   47163           0 :     SgOmpDeviceClause::next_node = object;
   47164             : #endif
   47165             : 
   47166             : #if ROSE_ALLOC_TRACE == 2
   47167             : //  printf("SgOmpDeviceClause::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpDeviceClause::next_node);
   47168             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   47169             :     Rose::MemPool::snapshot(oss.str());
   47170             :     alloc_trace_cnt++;
   47171             : #endif
   47172             : 
   47173             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   47174             : 
   47175           0 :     ALLOC_MUTEX(SgOmpDeviceClause, unlock);
   47176             : }
   47177             : 
   47178             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   47179             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   47180             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   47181             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   47182             : // Also, note comment below from Robb (copied from the Common.code file).
   47183             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   47184             : //
   47185             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   47186             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   47187             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   47188             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   47189             : #if 0
   47190             : void SgOmpDeviceClause::operator delete(void* pointer) { SgOmpDeviceClause::operator delete (pointer, sizeof(SgOmpDeviceClause)); };
   47191             : #endif
   47192             : /* #line 47193 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   47193             : 
   47194             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   47195             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   47196             : // obviously imply C++.
   47197             : 
   47198             : // This implements the support within ROSE for memory pools.  Memory pools
   47199             : // support the most condensed usage of memory within the construction of
   47200             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   47201             : // by a new operator written for each class.
   47202             : 
   47203             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   47204             :     // User wants multi-thread support and POSIX threads are available.
   47205             : #   include <pthread.h>
   47206             :     static pthread_mutex_t SgOmpHintClause_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   47207             : #else
   47208             :      // Cause synchronization to be skipped.
   47209             : #    ifndef ALLOC_MUTEX
   47210             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   47211             : #    endif
   47212             : #    ifdef _REENTRANT
   47213             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   47214             : #       ifdef _MSC_VER
   47215             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   47216             : #       else
   47217             : #           warning "POSIX threads are not available; synchronization being skipped"
   47218             : #       endif
   47219             : #    endif
   47220             : #endif
   47221             : 
   47222             : #ifndef ROSE_ALLOC_TRACE
   47223             : #  define ROSE_ALLOC_TRACE 0
   47224             : #endif
   47225             : 
   47226             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   47227             : #define ROSE_ALLOC_TRACE_CNT
   47228             : #include "memory-pool-snapshot.h"
   47229             : unsigned long alloc_trace_cnt = 0;
   47230             : #endif
   47231             : 
   47232             : #if ROSE_ALLOC_TRACE
   47233             : const unsigned SgOmpHintClause::pool_size = 5;
   47234             : #else
   47235             : const unsigned SgOmpHintClause::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   47236             : #endif
   47237             : 
   47238             : #ifndef ROSE_ALLOC_MEMSET
   47239             : #  define ROSE_ALLOC_MEMSET 0
   47240             : #endif
   47241             : 
   47242             : #ifndef ROSE_PEDANTIC_ALLOC
   47243             : #  define ROSE_PEDANTIC_ALLOC 0
   47244             : #endif
   47245             : 
   47246             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   47247             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   47248             : #endif
   47249             : 
   47250             : #if !defined(SGNODE__ALL_POOLS)
   47251             : #define SGNODE__ALL_POOLS
   47252             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   47253             : #endif
   47254             : 
   47255             : SgOmpHintClause* SgOmpHintClause::next_node = nullptr;
   47256             : std::vector<unsigned char*> SgOmpHintClause::pools;
   47257             : 
   47258             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   47259             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   47260             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   47261             : // around this macro definition rather than each use).
   47262             : #ifndef ALLOC_MUTEX
   47263             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   47264             :         do {                                                                     \
   47265             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   47266             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   47267             :                 abort();                                                         \
   47268             :             }                                                                    \
   47269             :         } while (0);
   47270             : #endif
   47271             : 
   47272             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   47273             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   47274             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   47275             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   47276             : 
   47277             : /*! \brief New operator for SgOmpHintClause.
   47278             : 
   47279             :    This new operator implements memory pools to provide most efficent 
   47280             :    use of the heap within construction of large ASTs.
   47281             : 
   47282             : \internal The new and delete operators use the lower level C malloc/free
   47283             :    function calls for performance and to make sure that mixing of malloc/free
   47284             :    and new/delete by the used can be caught more readily.  This may change
   47285             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   47286             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   47287             :    deallocate memory allocated using ROSE_MALLOC.
   47288             : */
   47289           3 : void *SgOmpHintClause::operator new ( size_t Size )
   47290             : {
   47291             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   47292             :      * returning or throwing an exception. */
   47293           3 :     ALLOC_MUTEX(SgOmpHintClause, lock);
   47294             : 
   47295             : #if ROSE_ALLOC_TRACE == 2
   47296             : //    printf("SgOmpHintClause::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgOmpHintClause::next_node);
   47297             : #endif
   47298             : 
   47299             : #if USE_CPP_NEW_DELETE_OPERATORS
   47300             :     void *mem = ROSE_MALLOC(Size);
   47301             :     ALLOC_MUTEX(SgOmpHintClause, unlock);
   47302             :     return mem;
   47303             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   47304             : #if ROSE_PEDANTIC_ALLOC
   47305             :     ROSE_ASSERT(Size == sizeof(SgOmpHintClause));
   47306             : #else
   47307           3 :     if (Size != sizeof(SgOmpHintClause)) {
   47308           0 :       void * object = ROSE_MALLOC(Size);
   47309           0 :       ALLOC_MUTEX(SgOmpHintClause, unlock);
   47310             :       return object;
   47311             :     }
   47312             : #endif
   47313             : 
   47314           3 :     if (SgOmpHintClause::next_node == nullptr) {
   47315           2 :         SgOmpHintClause * alloc = (SgOmpHintClause*) ROSE_MALLOC ( SgOmpHintClause::pool_size * sizeof(SgOmpHintClause) );
   47316           2 :         ROSE_ASSERT(alloc != nullptr);
   47317             : 
   47318             : #if ROSE_ALLOC_TRACE == 2
   47319             : //        printf("SgOmpHintClause::alloc\n  block[%zi] = [ %p , %p [\n", SgOmpHintClause::pools.size(), alloc, alloc + SgOmpHintClause::pool_size);
   47320             : #endif
   47321             : 
   47322             : #if ROSE_ALLOC_MEMSET == 1
   47323             : #elif ROSE_ALLOC_MEMSET == 2
   47324             :         memset(alloc, 0x00, SgOmpHintClause::pool_size * sizeof(SgOmpHintClause));
   47325             : #elif ROSE_ALLOC_MEMSET == 3
   47326             :         memset(alloc, 0xAA, SgOmpHintClause::pool_size * sizeof(SgOmpHintClause));
   47327             : #endif
   47328        4000 :         for (unsigned i=0; i < SgOmpHintClause::pool_size-1; i++) {
   47329        3998 :           alloc[i].p_freepointer = &(alloc[i+1]);
   47330             :         }
   47331           2 :         alloc[SgOmpHintClause::pool_size-1].p_freepointer = nullptr;
   47332             : 
   47333           2 :         SgOmpHintClause::pools.push_back ( (unsigned char *) alloc );
   47334           2 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgOmpHintClause::pool_size * sizeof(SgOmpHintClause), V_SgOmpHintClause ) );
   47335           2 :         SgOmpHintClause::next_node = alloc;
   47336             :     }
   47337           3 :     ROSE_ASSERT(SgOmpHintClause::next_node != nullptr);
   47338             : 
   47339           3 :     SgOmpHintClause * object = SgOmpHintClause::next_node;
   47340           3 :     SgOmpHintClause::next_node = (SgOmpHintClause*)(object->p_freepointer);
   47341             : 
   47342             : #if ROSE_ALLOC_TRACE == 2
   47343             :     printf("SgOmpHintClause::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpHintClause::next_node);
   47344             : #endif
   47345             : 
   47346           3 :     SgNode * fp = object->p_freepointer;
   47347             : #if ROSE_ALLOC_MEMSET == 1
   47348             : #elif ROSE_ALLOC_MEMSET == 2
   47349             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpHintClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   47350             : #elif ROSE_ALLOC_MEMSET == 3
   47351             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgOmpHintClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   47352             : #endif
   47353           3 :     object->p_freepointer = fp;
   47354             : 
   47355             : #if ROSE_ALLOC_TRACE == 2
   47356             : //    printf("SgOmpHintClause::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpHintClause::next_node);
   47357             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   47358             :     Rose::MemPool::snapshot(oss.str());
   47359             :     alloc_trace_cnt++;
   47360             : #endif
   47361             : 
   47362           3 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   47363             : 
   47364           3 :     ALLOC_MUTEX(SgOmpHintClause, unlock);
   47365             : 
   47366             :     return object;
   47367             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   47368             : }
   47369             : 
   47370             : 
   47371             : 
   47372             : /*! \brief Delete operator for SgOmpHintClause.
   47373             : 
   47374             :    This delete operator implements deallocation using memory pools to 
   47375             :    provide most efficent use of the heap within construction of large ASTs.
   47376             : 
   47377             : \internal The new and delete operators use the lower level C malloc/free
   47378             :    function calls for performance and to make sure that mixing of malloc/free
   47379             :    and new/delete by the used can be caught more readily.  This may change
   47380             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   47381             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   47382             :    deallocate memory allocated using ROSE_MALLOC.
   47383             : */
   47384           0 : void SgOmpHintClause::operator delete(void *Pointer, size_t Size)
   47385             : {
   47386             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   47387             :      * or throwing an exception. */
   47388           0 :     ALLOC_MUTEX(SgOmpHintClause, lock);
   47389             : 
   47390             : #if USE_CPP_NEW_DELETE_OPERATORS
   47391             :     ROSE_FREE(Pointer);
   47392             : #else
   47393             : #if ROSE_PEDANTIC_ALLOC
   47394             :     ROSE_ASSERT(Size == sizeof(SgOmpHintClause));
   47395             : #else
   47396           0 :     if (Size != sizeof(SgOmpHintClause)) {
   47397           0 :       ROSE_FREE(Pointer);
   47398           0 :       ALLOC_MUTEX(SgOmpHintClause, unlock);
   47399             :       return;
   47400             :     }
   47401             : #endif
   47402             : 
   47403           0 :     SgOmpHintClause * object = (SgOmpHintClause*) Pointer;
   47404           0 :     ROSE_ASSERT(object != nullptr);
   47405             : 
   47406             : #if ROSE_ALLOC_TRACE == 2
   47407             : //  printf("SgOmpHintClause::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpHintClause::next_node);
   47408             :     printf("SgOmpHintClause::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpHintClause::next_node);
   47409             : #endif
   47410             : 
   47411             : #if ROSE_PEDANTIC_ALLOC
   47412             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   47413             : #endif
   47414             : 
   47415             : #if ROSE_ALLOC_MEMSET == 1
   47416             : #elif ROSE_ALLOC_MEMSET == 2
   47417             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpHintClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   47418             : #elif ROSE_ALLOC_MEMSET == 3
   47419             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgOmpHintClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   47420             : #endif
   47421             : 
   47422             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   47423             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   47424             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   47425             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   47426             : #else
   47427           0 :     object->p_freepointer = SgOmpHintClause::next_node;
   47428           0 :     SgOmpHintClause::next_node = object;
   47429             : #endif
   47430             : 
   47431             : #if ROSE_ALLOC_TRACE == 2
   47432             : //  printf("SgOmpHintClause::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpHintClause::next_node);
   47433             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   47434             :     Rose::MemPool::snapshot(oss.str());
   47435             :     alloc_trace_cnt++;
   47436             : #endif
   47437             : 
   47438             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   47439             : 
   47440           0 :     ALLOC_MUTEX(SgOmpHintClause, unlock);
   47441             : }
   47442             : 
   47443             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   47444             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   47445             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   47446             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   47447             : // Also, note comment below from Robb (copied from the Common.code file).
   47448             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   47449             : //
   47450             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   47451             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   47452             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   47453             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   47454             : #if 0
   47455             : void SgOmpHintClause::operator delete(void* pointer) { SgOmpHintClause::operator delete (pointer, sizeof(SgOmpHintClause)); };
   47456             : #endif
   47457             : /* #line 47458 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   47458             : 
   47459             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   47460             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   47461             : // obviously imply C++.
   47462             : 
   47463             : // This implements the support within ROSE for memory pools.  Memory pools
   47464             : // support the most condensed usage of memory within the construction of
   47465             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   47466             : // by a new operator written for each class.
   47467             : 
   47468             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   47469             :     // User wants multi-thread support and POSIX threads are available.
   47470             : #   include <pthread.h>
   47471             :     static pthread_mutex_t SgOmpGrainsizeClause_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   47472             : #else
   47473             :      // Cause synchronization to be skipped.
   47474             : #    ifndef ALLOC_MUTEX
   47475             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   47476             : #    endif
   47477             : #    ifdef _REENTRANT
   47478             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   47479             : #       ifdef _MSC_VER
   47480             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   47481             : #       else
   47482             : #           warning "POSIX threads are not available; synchronization being skipped"
   47483             : #       endif
   47484             : #    endif
   47485             : #endif
   47486             : 
   47487             : #ifndef ROSE_ALLOC_TRACE
   47488             : #  define ROSE_ALLOC_TRACE 0
   47489             : #endif
   47490             : 
   47491             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   47492             : #define ROSE_ALLOC_TRACE_CNT
   47493             : #include "memory-pool-snapshot.h"
   47494             : unsigned long alloc_trace_cnt = 0;
   47495             : #endif
   47496             : 
   47497             : #if ROSE_ALLOC_TRACE
   47498             : const unsigned SgOmpGrainsizeClause::pool_size = 5;
   47499             : #else
   47500             : const unsigned SgOmpGrainsizeClause::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   47501             : #endif
   47502             : 
   47503             : #ifndef ROSE_ALLOC_MEMSET
   47504             : #  define ROSE_ALLOC_MEMSET 0
   47505             : #endif
   47506             : 
   47507             : #ifndef ROSE_PEDANTIC_ALLOC
   47508             : #  define ROSE_PEDANTIC_ALLOC 0
   47509             : #endif
   47510             : 
   47511             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   47512             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   47513             : #endif
   47514             : 
   47515             : #if !defined(SGNODE__ALL_POOLS)
   47516             : #define SGNODE__ALL_POOLS
   47517             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   47518             : #endif
   47519             : 
   47520             : SgOmpGrainsizeClause* SgOmpGrainsizeClause::next_node = nullptr;
   47521             : std::vector<unsigned char*> SgOmpGrainsizeClause::pools;
   47522             : 
   47523             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   47524             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   47525             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   47526             : // around this macro definition rather than each use).
   47527             : #ifndef ALLOC_MUTEX
   47528             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   47529             :         do {                                                                     \
   47530             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   47531             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   47532             :                 abort();                                                         \
   47533             :             }                                                                    \
   47534             :         } while (0);
   47535             : #endif
   47536             : 
   47537             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   47538             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   47539             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   47540             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   47541             : 
   47542             : /*! \brief New operator for SgOmpGrainsizeClause.
   47543             : 
   47544             :    This new operator implements memory pools to provide most efficent 
   47545             :    use of the heap within construction of large ASTs.
   47546             : 
   47547             : \internal The new and delete operators use the lower level C malloc/free
   47548             :    function calls for performance and to make sure that mixing of malloc/free
   47549             :    and new/delete by the used can be caught more readily.  This may change
   47550             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   47551             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   47552             :    deallocate memory allocated using ROSE_MALLOC.
   47553             : */
   47554           0 : void *SgOmpGrainsizeClause::operator new ( size_t Size )
   47555             : {
   47556             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   47557             :      * returning or throwing an exception. */
   47558           0 :     ALLOC_MUTEX(SgOmpGrainsizeClause, lock);
   47559             : 
   47560             : #if ROSE_ALLOC_TRACE == 2
   47561             : //    printf("SgOmpGrainsizeClause::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgOmpGrainsizeClause::next_node);
   47562             : #endif
   47563             : 
   47564             : #if USE_CPP_NEW_DELETE_OPERATORS
   47565             :     void *mem = ROSE_MALLOC(Size);
   47566             :     ALLOC_MUTEX(SgOmpGrainsizeClause, unlock);
   47567             :     return mem;
   47568             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   47569             : #if ROSE_PEDANTIC_ALLOC
   47570             :     ROSE_ASSERT(Size == sizeof(SgOmpGrainsizeClause));
   47571             : #else
   47572           0 :     if (Size != sizeof(SgOmpGrainsizeClause)) {
   47573           0 :       void * object = ROSE_MALLOC(Size);
   47574           0 :       ALLOC_MUTEX(SgOmpGrainsizeClause, unlock);
   47575             :       return object;
   47576             :     }
   47577             : #endif
   47578             : 
   47579           0 :     if (SgOmpGrainsizeClause::next_node == nullptr) {
   47580           0 :         SgOmpGrainsizeClause * alloc = (SgOmpGrainsizeClause*) ROSE_MALLOC ( SgOmpGrainsizeClause::pool_size * sizeof(SgOmpGrainsizeClause) );
   47581           0 :         ROSE_ASSERT(alloc != nullptr);
   47582             : 
   47583             : #if ROSE_ALLOC_TRACE == 2
   47584             : //        printf("SgOmpGrainsizeClause::alloc\n  block[%zi] = [ %p , %p [\n", SgOmpGrainsizeClause::pools.size(), alloc, alloc + SgOmpGrainsizeClause::pool_size);
   47585             : #endif
   47586             : 
   47587             : #if ROSE_ALLOC_MEMSET == 1
   47588             : #elif ROSE_ALLOC_MEMSET == 2
   47589             :         memset(alloc, 0x00, SgOmpGrainsizeClause::pool_size * sizeof(SgOmpGrainsizeClause));
   47590             : #elif ROSE_ALLOC_MEMSET == 3
   47591             :         memset(alloc, 0xAA, SgOmpGrainsizeClause::pool_size * sizeof(SgOmpGrainsizeClause));
   47592             : #endif
   47593           0 :         for (unsigned i=0; i < SgOmpGrainsizeClause::pool_size-1; i++) {
   47594           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
   47595             :         }
   47596           0 :         alloc[SgOmpGrainsizeClause::pool_size-1].p_freepointer = nullptr;
   47597             : 
   47598           0 :         SgOmpGrainsizeClause::pools.push_back ( (unsigned char *) alloc );
   47599           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgOmpGrainsizeClause::pool_size * sizeof(SgOmpGrainsizeClause), V_SgOmpGrainsizeClause ) );
   47600           0 :         SgOmpGrainsizeClause::next_node = alloc;
   47601             :     }
   47602           0 :     ROSE_ASSERT(SgOmpGrainsizeClause::next_node != nullptr);
   47603             : 
   47604           0 :     SgOmpGrainsizeClause * object = SgOmpGrainsizeClause::next_node;
   47605           0 :     SgOmpGrainsizeClause::next_node = (SgOmpGrainsizeClause*)(object->p_freepointer);
   47606             : 
   47607             : #if ROSE_ALLOC_TRACE == 2
   47608             :     printf("SgOmpGrainsizeClause::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpGrainsizeClause::next_node);
   47609             : #endif
   47610             : 
   47611           0 :     SgNode * fp = object->p_freepointer;
   47612             : #if ROSE_ALLOC_MEMSET == 1
   47613             : #elif ROSE_ALLOC_MEMSET == 2
   47614             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpGrainsizeClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   47615             : #elif ROSE_ALLOC_MEMSET == 3
   47616             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgOmpGrainsizeClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   47617             : #endif
   47618           0 :     object->p_freepointer = fp;
   47619             : 
   47620             : #if ROSE_ALLOC_TRACE == 2
   47621             : //    printf("SgOmpGrainsizeClause::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpGrainsizeClause::next_node);
   47622             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   47623             :     Rose::MemPool::snapshot(oss.str());
   47624             :     alloc_trace_cnt++;
   47625             : #endif
   47626             : 
   47627           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   47628             : 
   47629           0 :     ALLOC_MUTEX(SgOmpGrainsizeClause, unlock);
   47630             : 
   47631             :     return object;
   47632             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   47633             : }
   47634             : 
   47635             : 
   47636             : 
   47637             : /*! \brief Delete operator for SgOmpGrainsizeClause.
   47638             : 
   47639             :    This delete operator implements deallocation using memory pools to 
   47640             :    provide most efficent use of the heap within construction of large ASTs.
   47641             : 
   47642             : \internal The new and delete operators use the lower level C malloc/free
   47643             :    function calls for performance and to make sure that mixing of malloc/free
   47644             :    and new/delete by the used can be caught more readily.  This may change
   47645             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   47646             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   47647             :    deallocate memory allocated using ROSE_MALLOC.
   47648             : */
   47649           0 : void SgOmpGrainsizeClause::operator delete(void *Pointer, size_t Size)
   47650             : {
   47651             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   47652             :      * or throwing an exception. */
   47653           0 :     ALLOC_MUTEX(SgOmpGrainsizeClause, lock);
   47654             : 
   47655             : #if USE_CPP_NEW_DELETE_OPERATORS
   47656             :     ROSE_FREE(Pointer);
   47657             : #else
   47658             : #if ROSE_PEDANTIC_ALLOC
   47659             :     ROSE_ASSERT(Size == sizeof(SgOmpGrainsizeClause));
   47660             : #else
   47661           0 :     if (Size != sizeof(SgOmpGrainsizeClause)) {
   47662           0 :       ROSE_FREE(Pointer);
   47663           0 :       ALLOC_MUTEX(SgOmpGrainsizeClause, unlock);
   47664             :       return;
   47665             :     }
   47666             : #endif
   47667             : 
   47668           0 :     SgOmpGrainsizeClause * object = (SgOmpGrainsizeClause*) Pointer;
   47669           0 :     ROSE_ASSERT(object != nullptr);
   47670             : 
   47671             : #if ROSE_ALLOC_TRACE == 2
   47672             : //  printf("SgOmpGrainsizeClause::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpGrainsizeClause::next_node);
   47673             :     printf("SgOmpGrainsizeClause::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpGrainsizeClause::next_node);
   47674             : #endif
   47675             : 
   47676             : #if ROSE_PEDANTIC_ALLOC
   47677             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   47678             : #endif
   47679             : 
   47680             : #if ROSE_ALLOC_MEMSET == 1
   47681             : #elif ROSE_ALLOC_MEMSET == 2
   47682             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpGrainsizeClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   47683             : #elif ROSE_ALLOC_MEMSET == 3
   47684             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgOmpGrainsizeClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   47685             : #endif
   47686             : 
   47687             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   47688             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   47689             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   47690             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   47691             : #else
   47692           0 :     object->p_freepointer = SgOmpGrainsizeClause::next_node;
   47693           0 :     SgOmpGrainsizeClause::next_node = object;
   47694             : #endif
   47695             : 
   47696             : #if ROSE_ALLOC_TRACE == 2
   47697             : //  printf("SgOmpGrainsizeClause::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpGrainsizeClause::next_node);
   47698             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   47699             :     Rose::MemPool::snapshot(oss.str());
   47700             :     alloc_trace_cnt++;
   47701             : #endif
   47702             : 
   47703             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   47704             : 
   47705           0 :     ALLOC_MUTEX(SgOmpGrainsizeClause, unlock);
   47706             : }
   47707             : 
   47708             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   47709             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   47710             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   47711             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   47712             : // Also, note comment below from Robb (copied from the Common.code file).
   47713             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   47714             : //
   47715             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   47716             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   47717             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   47718             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   47719             : #if 0
   47720             : void SgOmpGrainsizeClause::operator delete(void* pointer) { SgOmpGrainsizeClause::operator delete (pointer, sizeof(SgOmpGrainsizeClause)); };
   47721             : #endif
   47722             : /* #line 47723 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   47723             : 
   47724             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   47725             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   47726             : // obviously imply C++.
   47727             : 
   47728             : // This implements the support within ROSE for memory pools.  Memory pools
   47729             : // support the most condensed usage of memory within the construction of
   47730             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   47731             : // by a new operator written for each class.
   47732             : 
   47733             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   47734             :     // User wants multi-thread support and POSIX threads are available.
   47735             : #   include <pthread.h>
   47736             :     static pthread_mutex_t SgOmpNumTasksClause_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   47737             : #else
   47738             :      // Cause synchronization to be skipped.
   47739             : #    ifndef ALLOC_MUTEX
   47740             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   47741             : #    endif
   47742             : #    ifdef _REENTRANT
   47743             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   47744             : #       ifdef _MSC_VER
   47745             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   47746             : #       else
   47747             : #           warning "POSIX threads are not available; synchronization being skipped"
   47748             : #       endif
   47749             : #    endif
   47750             : #endif
   47751             : 
   47752             : #ifndef ROSE_ALLOC_TRACE
   47753             : #  define ROSE_ALLOC_TRACE 0
   47754             : #endif
   47755             : 
   47756             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   47757             : #define ROSE_ALLOC_TRACE_CNT
   47758             : #include "memory-pool-snapshot.h"
   47759             : unsigned long alloc_trace_cnt = 0;
   47760             : #endif
   47761             : 
   47762             : #if ROSE_ALLOC_TRACE
   47763             : const unsigned SgOmpNumTasksClause::pool_size = 5;
   47764             : #else
   47765             : const unsigned SgOmpNumTasksClause::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   47766             : #endif
   47767             : 
   47768             : #ifndef ROSE_ALLOC_MEMSET
   47769             : #  define ROSE_ALLOC_MEMSET 0
   47770             : #endif
   47771             : 
   47772             : #ifndef ROSE_PEDANTIC_ALLOC
   47773             : #  define ROSE_PEDANTIC_ALLOC 0
   47774             : #endif
   47775             : 
   47776             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   47777             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   47778             : #endif
   47779             : 
   47780             : #if !defined(SGNODE__ALL_POOLS)
   47781             : #define SGNODE__ALL_POOLS
   47782             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   47783             : #endif
   47784             : 
   47785             : SgOmpNumTasksClause* SgOmpNumTasksClause::next_node = nullptr;
   47786             : std::vector<unsigned char*> SgOmpNumTasksClause::pools;
   47787             : 
   47788             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   47789             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   47790             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   47791             : // around this macro definition rather than each use).
   47792             : #ifndef ALLOC_MUTEX
   47793             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   47794             :         do {                                                                     \
   47795             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   47796             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   47797             :                 abort();                                                         \
   47798             :             }                                                                    \
   47799             :         } while (0);
   47800             : #endif
   47801             : 
   47802             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   47803             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   47804             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   47805             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   47806             : 
   47807             : /*! \brief New operator for SgOmpNumTasksClause.
   47808             : 
   47809             :    This new operator implements memory pools to provide most efficent 
   47810             :    use of the heap within construction of large ASTs.
   47811             : 
   47812             : \internal The new and delete operators use the lower level C malloc/free
   47813             :    function calls for performance and to make sure that mixing of malloc/free
   47814             :    and new/delete by the used can be caught more readily.  This may change
   47815             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   47816             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   47817             :    deallocate memory allocated using ROSE_MALLOC.
   47818             : */
   47819           0 : void *SgOmpNumTasksClause::operator new ( size_t Size )
   47820             : {
   47821             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   47822             :      * returning or throwing an exception. */
   47823           0 :     ALLOC_MUTEX(SgOmpNumTasksClause, lock);
   47824             : 
   47825             : #if ROSE_ALLOC_TRACE == 2
   47826             : //    printf("SgOmpNumTasksClause::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgOmpNumTasksClause::next_node);
   47827             : #endif
   47828             : 
   47829             : #if USE_CPP_NEW_DELETE_OPERATORS
   47830             :     void *mem = ROSE_MALLOC(Size);
   47831             :     ALLOC_MUTEX(SgOmpNumTasksClause, unlock);
   47832             :     return mem;
   47833             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   47834             : #if ROSE_PEDANTIC_ALLOC
   47835             :     ROSE_ASSERT(Size == sizeof(SgOmpNumTasksClause));
   47836             : #else
   47837           0 :     if (Size != sizeof(SgOmpNumTasksClause)) {
   47838           0 :       void * object = ROSE_MALLOC(Size);
   47839           0 :       ALLOC_MUTEX(SgOmpNumTasksClause, unlock);
   47840             :       return object;
   47841             :     }
   47842             : #endif
   47843             : 
   47844           0 :     if (SgOmpNumTasksClause::next_node == nullptr) {
   47845           0 :         SgOmpNumTasksClause * alloc = (SgOmpNumTasksClause*) ROSE_MALLOC ( SgOmpNumTasksClause::pool_size * sizeof(SgOmpNumTasksClause) );
   47846           0 :         ROSE_ASSERT(alloc != nullptr);
   47847             : 
   47848             : #if ROSE_ALLOC_TRACE == 2
   47849             : //        printf("SgOmpNumTasksClause::alloc\n  block[%zi] = [ %p , %p [\n", SgOmpNumTasksClause::pools.size(), alloc, alloc + SgOmpNumTasksClause::pool_size);
   47850             : #endif
   47851             : 
   47852             : #if ROSE_ALLOC_MEMSET == 1
   47853             : #elif ROSE_ALLOC_MEMSET == 2
   47854             :         memset(alloc, 0x00, SgOmpNumTasksClause::pool_size * sizeof(SgOmpNumTasksClause));
   47855             : #elif ROSE_ALLOC_MEMSET == 3
   47856             :         memset(alloc, 0xAA, SgOmpNumTasksClause::pool_size * sizeof(SgOmpNumTasksClause));
   47857             : #endif
   47858           0 :         for (unsigned i=0; i < SgOmpNumTasksClause::pool_size-1; i++) {
   47859           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
   47860             :         }
   47861           0 :         alloc[SgOmpNumTasksClause::pool_size-1].p_freepointer = nullptr;
   47862             : 
   47863           0 :         SgOmpNumTasksClause::pools.push_back ( (unsigned char *) alloc );
   47864           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgOmpNumTasksClause::pool_size * sizeof(SgOmpNumTasksClause), V_SgOmpNumTasksClause ) );
   47865           0 :         SgOmpNumTasksClause::next_node = alloc;
   47866             :     }
   47867           0 :     ROSE_ASSERT(SgOmpNumTasksClause::next_node != nullptr);
   47868             : 
   47869           0 :     SgOmpNumTasksClause * object = SgOmpNumTasksClause::next_node;
   47870           0 :     SgOmpNumTasksClause::next_node = (SgOmpNumTasksClause*)(object->p_freepointer);
   47871             : 
   47872             : #if ROSE_ALLOC_TRACE == 2
   47873             :     printf("SgOmpNumTasksClause::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpNumTasksClause::next_node);
   47874             : #endif
   47875             : 
   47876           0 :     SgNode * fp = object->p_freepointer;
   47877             : #if ROSE_ALLOC_MEMSET == 1
   47878             : #elif ROSE_ALLOC_MEMSET == 2
   47879             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpNumTasksClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   47880             : #elif ROSE_ALLOC_MEMSET == 3
   47881             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgOmpNumTasksClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   47882             : #endif
   47883           0 :     object->p_freepointer = fp;
   47884             : 
   47885             : #if ROSE_ALLOC_TRACE == 2
   47886             : //    printf("SgOmpNumTasksClause::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpNumTasksClause::next_node);
   47887             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   47888             :     Rose::MemPool::snapshot(oss.str());
   47889             :     alloc_trace_cnt++;
   47890             : #endif
   47891             : 
   47892           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   47893             : 
   47894           0 :     ALLOC_MUTEX(SgOmpNumTasksClause, unlock);
   47895             : 
   47896             :     return object;
   47897             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   47898             : }
   47899             : 
   47900             : 
   47901             : 
   47902             : /*! \brief Delete operator for SgOmpNumTasksClause.
   47903             : 
   47904             :    This delete operator implements deallocation using memory pools to 
   47905             :    provide most efficent use of the heap within construction of large ASTs.
   47906             : 
   47907             : \internal The new and delete operators use the lower level C malloc/free
   47908             :    function calls for performance and to make sure that mixing of malloc/free
   47909             :    and new/delete by the used can be caught more readily.  This may change
   47910             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   47911             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   47912             :    deallocate memory allocated using ROSE_MALLOC.
   47913             : */
   47914           0 : void SgOmpNumTasksClause::operator delete(void *Pointer, size_t Size)
   47915             : {
   47916             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   47917             :      * or throwing an exception. */
   47918           0 :     ALLOC_MUTEX(SgOmpNumTasksClause, lock);
   47919             : 
   47920             : #if USE_CPP_NEW_DELETE_OPERATORS
   47921             :     ROSE_FREE(Pointer);
   47922             : #else
   47923             : #if ROSE_PEDANTIC_ALLOC
   47924             :     ROSE_ASSERT(Size == sizeof(SgOmpNumTasksClause));
   47925             : #else
   47926           0 :     if (Size != sizeof(SgOmpNumTasksClause)) {
   47927           0 :       ROSE_FREE(Pointer);
   47928           0 :       ALLOC_MUTEX(SgOmpNumTasksClause, unlock);
   47929             :       return;
   47930             :     }
   47931             : #endif
   47932             : 
   47933           0 :     SgOmpNumTasksClause * object = (SgOmpNumTasksClause*) Pointer;
   47934           0 :     ROSE_ASSERT(object != nullptr);
   47935             : 
   47936             : #if ROSE_ALLOC_TRACE == 2
   47937             : //  printf("SgOmpNumTasksClause::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpNumTasksClause::next_node);
   47938             :     printf("SgOmpNumTasksClause::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpNumTasksClause::next_node);
   47939             : #endif
   47940             : 
   47941             : #if ROSE_PEDANTIC_ALLOC
   47942             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   47943             : #endif
   47944             : 
   47945             : #if ROSE_ALLOC_MEMSET == 1
   47946             : #elif ROSE_ALLOC_MEMSET == 2
   47947             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpNumTasksClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   47948             : #elif ROSE_ALLOC_MEMSET == 3
   47949             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgOmpNumTasksClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   47950             : #endif
   47951             : 
   47952             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   47953             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   47954             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   47955             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   47956             : #else
   47957           0 :     object->p_freepointer = SgOmpNumTasksClause::next_node;
   47958           0 :     SgOmpNumTasksClause::next_node = object;
   47959             : #endif
   47960             : 
   47961             : #if ROSE_ALLOC_TRACE == 2
   47962             : //  printf("SgOmpNumTasksClause::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpNumTasksClause::next_node);
   47963             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   47964             :     Rose::MemPool::snapshot(oss.str());
   47965             :     alloc_trace_cnt++;
   47966             : #endif
   47967             : 
   47968             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   47969             : 
   47970           0 :     ALLOC_MUTEX(SgOmpNumTasksClause, unlock);
   47971             : }
   47972             : 
   47973             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   47974             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   47975             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   47976             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   47977             : // Also, note comment below from Robb (copied from the Common.code file).
   47978             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   47979             : //
   47980             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   47981             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   47982             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   47983             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   47984             : #if 0
   47985             : void SgOmpNumTasksClause::operator delete(void* pointer) { SgOmpNumTasksClause::operator delete (pointer, sizeof(SgOmpNumTasksClause)); };
   47986             : #endif
   47987             : /* #line 47988 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   47988             : 
   47989             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   47990             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   47991             : // obviously imply C++.
   47992             : 
   47993             : // This implements the support within ROSE for memory pools.  Memory pools
   47994             : // support the most condensed usage of memory within the construction of
   47995             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   47996             : // by a new operator written for each class.
   47997             : 
   47998             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   47999             :     // User wants multi-thread support and POSIX threads are available.
   48000             : #   include <pthread.h>
   48001             :     static pthread_mutex_t SgOmpDetachClause_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   48002             : #else
   48003             :      // Cause synchronization to be skipped.
   48004             : #    ifndef ALLOC_MUTEX
   48005             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   48006             : #    endif
   48007             : #    ifdef _REENTRANT
   48008             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   48009             : #       ifdef _MSC_VER
   48010             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   48011             : #       else
   48012             : #           warning "POSIX threads are not available; synchronization being skipped"
   48013             : #       endif
   48014             : #    endif
   48015             : #endif
   48016             : 
   48017             : #ifndef ROSE_ALLOC_TRACE
   48018             : #  define ROSE_ALLOC_TRACE 0
   48019             : #endif
   48020             : 
   48021             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   48022             : #define ROSE_ALLOC_TRACE_CNT
   48023             : #include "memory-pool-snapshot.h"
   48024             : unsigned long alloc_trace_cnt = 0;
   48025             : #endif
   48026             : 
   48027             : #if ROSE_ALLOC_TRACE
   48028             : const unsigned SgOmpDetachClause::pool_size = 5;
   48029             : #else
   48030             : const unsigned SgOmpDetachClause::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   48031             : #endif
   48032             : 
   48033             : #ifndef ROSE_ALLOC_MEMSET
   48034             : #  define ROSE_ALLOC_MEMSET 0
   48035             : #endif
   48036             : 
   48037             : #ifndef ROSE_PEDANTIC_ALLOC
   48038             : #  define ROSE_PEDANTIC_ALLOC 0
   48039             : #endif
   48040             : 
   48041             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   48042             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   48043             : #endif
   48044             : 
   48045             : #if !defined(SGNODE__ALL_POOLS)
   48046             : #define SGNODE__ALL_POOLS
   48047             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   48048             : #endif
   48049             : 
   48050             : SgOmpDetachClause* SgOmpDetachClause::next_node = nullptr;
   48051             : std::vector<unsigned char*> SgOmpDetachClause::pools;
   48052             : 
   48053             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   48054             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   48055             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   48056             : // around this macro definition rather than each use).
   48057             : #ifndef ALLOC_MUTEX
   48058             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   48059             :         do {                                                                     \
   48060             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   48061             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   48062             :                 abort();                                                         \
   48063             :             }                                                                    \
   48064             :         } while (0);
   48065             : #endif
   48066             : 
   48067             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   48068             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   48069             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   48070             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   48071             : 
   48072             : /*! \brief New operator for SgOmpDetachClause.
   48073             : 
   48074             :    This new operator implements memory pools to provide most efficent 
   48075             :    use of the heap within construction of large ASTs.
   48076             : 
   48077             : \internal The new and delete operators use the lower level C malloc/free
   48078             :    function calls for performance and to make sure that mixing of malloc/free
   48079             :    and new/delete by the used can be caught more readily.  This may change
   48080             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   48081             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   48082             :    deallocate memory allocated using ROSE_MALLOC.
   48083             : */
   48084           0 : void *SgOmpDetachClause::operator new ( size_t Size )
   48085             : {
   48086             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   48087             :      * returning or throwing an exception. */
   48088           0 :     ALLOC_MUTEX(SgOmpDetachClause, lock);
   48089             : 
   48090             : #if ROSE_ALLOC_TRACE == 2
   48091             : //    printf("SgOmpDetachClause::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgOmpDetachClause::next_node);
   48092             : #endif
   48093             : 
   48094             : #if USE_CPP_NEW_DELETE_OPERATORS
   48095             :     void *mem = ROSE_MALLOC(Size);
   48096             :     ALLOC_MUTEX(SgOmpDetachClause, unlock);
   48097             :     return mem;
   48098             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   48099             : #if ROSE_PEDANTIC_ALLOC
   48100             :     ROSE_ASSERT(Size == sizeof(SgOmpDetachClause));
   48101             : #else
   48102           0 :     if (Size != sizeof(SgOmpDetachClause)) {
   48103           0 :       void * object = ROSE_MALLOC(Size);
   48104           0 :       ALLOC_MUTEX(SgOmpDetachClause, unlock);
   48105             :       return object;
   48106             :     }
   48107             : #endif
   48108             : 
   48109           0 :     if (SgOmpDetachClause::next_node == nullptr) {
   48110           0 :         SgOmpDetachClause * alloc = (SgOmpDetachClause*) ROSE_MALLOC ( SgOmpDetachClause::pool_size * sizeof(SgOmpDetachClause) );
   48111           0 :         ROSE_ASSERT(alloc != nullptr);
   48112             : 
   48113             : #if ROSE_ALLOC_TRACE == 2
   48114             : //        printf("SgOmpDetachClause::alloc\n  block[%zi] = [ %p , %p [\n", SgOmpDetachClause::pools.size(), alloc, alloc + SgOmpDetachClause::pool_size);
   48115             : #endif
   48116             : 
   48117             : #if ROSE_ALLOC_MEMSET == 1
   48118             : #elif ROSE_ALLOC_MEMSET == 2
   48119             :         memset(alloc, 0x00, SgOmpDetachClause::pool_size * sizeof(SgOmpDetachClause));
   48120             : #elif ROSE_ALLOC_MEMSET == 3
   48121             :         memset(alloc, 0xAA, SgOmpDetachClause::pool_size * sizeof(SgOmpDetachClause));
   48122             : #endif
   48123           0 :         for (unsigned i=0; i < SgOmpDetachClause::pool_size-1; i++) {
   48124           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
   48125             :         }
   48126           0 :         alloc[SgOmpDetachClause::pool_size-1].p_freepointer = nullptr;
   48127             : 
   48128           0 :         SgOmpDetachClause::pools.push_back ( (unsigned char *) alloc );
   48129           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgOmpDetachClause::pool_size * sizeof(SgOmpDetachClause), V_SgOmpDetachClause ) );
   48130           0 :         SgOmpDetachClause::next_node = alloc;
   48131             :     }
   48132           0 :     ROSE_ASSERT(SgOmpDetachClause::next_node != nullptr);
   48133             : 
   48134           0 :     SgOmpDetachClause * object = SgOmpDetachClause::next_node;
   48135           0 :     SgOmpDetachClause::next_node = (SgOmpDetachClause*)(object->p_freepointer);
   48136             : 
   48137             : #if ROSE_ALLOC_TRACE == 2
   48138             :     printf("SgOmpDetachClause::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpDetachClause::next_node);
   48139             : #endif
   48140             : 
   48141           0 :     SgNode * fp = object->p_freepointer;
   48142             : #if ROSE_ALLOC_MEMSET == 1
   48143             : #elif ROSE_ALLOC_MEMSET == 2
   48144             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpDetachClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   48145             : #elif ROSE_ALLOC_MEMSET == 3
   48146             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgOmpDetachClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   48147             : #endif
   48148           0 :     object->p_freepointer = fp;
   48149             : 
   48150             : #if ROSE_ALLOC_TRACE == 2
   48151             : //    printf("SgOmpDetachClause::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpDetachClause::next_node);
   48152             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   48153             :     Rose::MemPool::snapshot(oss.str());
   48154             :     alloc_trace_cnt++;
   48155             : #endif
   48156             : 
   48157           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   48158             : 
   48159           0 :     ALLOC_MUTEX(SgOmpDetachClause, unlock);
   48160             : 
   48161             :     return object;
   48162             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   48163             : }
   48164             : 
   48165             : 
   48166             : 
   48167             : /*! \brief Delete operator for SgOmpDetachClause.
   48168             : 
   48169             :    This delete operator implements deallocation using memory pools to 
   48170             :    provide most efficent use of the heap within construction of large ASTs.
   48171             : 
   48172             : \internal The new and delete operators use the lower level C malloc/free
   48173             :    function calls for performance and to make sure that mixing of malloc/free
   48174             :    and new/delete by the used can be caught more readily.  This may change
   48175             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   48176             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   48177             :    deallocate memory allocated using ROSE_MALLOC.
   48178             : */
   48179           0 : void SgOmpDetachClause::operator delete(void *Pointer, size_t Size)
   48180             : {
   48181             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   48182             :      * or throwing an exception. */
   48183           0 :     ALLOC_MUTEX(SgOmpDetachClause, lock);
   48184             : 
   48185             : #if USE_CPP_NEW_DELETE_OPERATORS
   48186             :     ROSE_FREE(Pointer);
   48187             : #else
   48188             : #if ROSE_PEDANTIC_ALLOC
   48189             :     ROSE_ASSERT(Size == sizeof(SgOmpDetachClause));
   48190             : #else
   48191           0 :     if (Size != sizeof(SgOmpDetachClause)) {
   48192           0 :       ROSE_FREE(Pointer);
   48193           0 :       ALLOC_MUTEX(SgOmpDetachClause, unlock);
   48194             :       return;
   48195             :     }
   48196             : #endif
   48197             : 
   48198           0 :     SgOmpDetachClause * object = (SgOmpDetachClause*) Pointer;
   48199           0 :     ROSE_ASSERT(object != nullptr);
   48200             : 
   48201             : #if ROSE_ALLOC_TRACE == 2
   48202             : //  printf("SgOmpDetachClause::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpDetachClause::next_node);
   48203             :     printf("SgOmpDetachClause::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpDetachClause::next_node);
   48204             : #endif
   48205             : 
   48206             : #if ROSE_PEDANTIC_ALLOC
   48207             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   48208             : #endif
   48209             : 
   48210             : #if ROSE_ALLOC_MEMSET == 1
   48211             : #elif ROSE_ALLOC_MEMSET == 2
   48212             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpDetachClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   48213             : #elif ROSE_ALLOC_MEMSET == 3
   48214             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgOmpDetachClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   48215             : #endif
   48216             : 
   48217             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   48218             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   48219             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   48220             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   48221             : #else
   48222           0 :     object->p_freepointer = SgOmpDetachClause::next_node;
   48223           0 :     SgOmpDetachClause::next_node = object;
   48224             : #endif
   48225             : 
   48226             : #if ROSE_ALLOC_TRACE == 2
   48227             : //  printf("SgOmpDetachClause::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpDetachClause::next_node);
   48228             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   48229             :     Rose::MemPool::snapshot(oss.str());
   48230             :     alloc_trace_cnt++;
   48231             : #endif
   48232             : 
   48233             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   48234             : 
   48235           0 :     ALLOC_MUTEX(SgOmpDetachClause, unlock);
   48236             : }
   48237             : 
   48238             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   48239             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   48240             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   48241             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   48242             : // Also, note comment below from Robb (copied from the Common.code file).
   48243             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   48244             : //
   48245             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   48246             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   48247             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   48248             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   48249             : #if 0
   48250             : void SgOmpDetachClause::operator delete(void* pointer) { SgOmpDetachClause::operator delete (pointer, sizeof(SgOmpDetachClause)); };
   48251             : #endif
   48252             : /* #line 48253 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   48253             : 
   48254             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   48255             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   48256             : // obviously imply C++.
   48257             : 
   48258             : // This implements the support within ROSE for memory pools.  Memory pools
   48259             : // support the most condensed usage of memory within the construction of
   48260             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   48261             : // by a new operator written for each class.
   48262             : 
   48263             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   48264             :     // User wants multi-thread support and POSIX threads are available.
   48265             : #   include <pthread.h>
   48266             :     static pthread_mutex_t SgOmpSafelenClause_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   48267             : #else
   48268             :      // Cause synchronization to be skipped.
   48269             : #    ifndef ALLOC_MUTEX
   48270             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   48271             : #    endif
   48272             : #    ifdef _REENTRANT
   48273             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   48274             : #       ifdef _MSC_VER
   48275             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   48276             : #       else
   48277             : #           warning "POSIX threads are not available; synchronization being skipped"
   48278             : #       endif
   48279             : #    endif
   48280             : #endif
   48281             : 
   48282             : #ifndef ROSE_ALLOC_TRACE
   48283             : #  define ROSE_ALLOC_TRACE 0
   48284             : #endif
   48285             : 
   48286             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   48287             : #define ROSE_ALLOC_TRACE_CNT
   48288             : #include "memory-pool-snapshot.h"
   48289             : unsigned long alloc_trace_cnt = 0;
   48290             : #endif
   48291             : 
   48292             : #if ROSE_ALLOC_TRACE
   48293             : const unsigned SgOmpSafelenClause::pool_size = 5;
   48294             : #else
   48295             : const unsigned SgOmpSafelenClause::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   48296             : #endif
   48297             : 
   48298             : #ifndef ROSE_ALLOC_MEMSET
   48299             : #  define ROSE_ALLOC_MEMSET 0
   48300             : #endif
   48301             : 
   48302             : #ifndef ROSE_PEDANTIC_ALLOC
   48303             : #  define ROSE_PEDANTIC_ALLOC 0
   48304             : #endif
   48305             : 
   48306             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   48307             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   48308             : #endif
   48309             : 
   48310             : #if !defined(SGNODE__ALL_POOLS)
   48311             : #define SGNODE__ALL_POOLS
   48312             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   48313             : #endif
   48314             : 
   48315             : SgOmpSafelenClause* SgOmpSafelenClause::next_node = nullptr;
   48316             : std::vector<unsigned char*> SgOmpSafelenClause::pools;
   48317             : 
   48318             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   48319             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   48320             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   48321             : // around this macro definition rather than each use).
   48322             : #ifndef ALLOC_MUTEX
   48323             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   48324             :         do {                                                                     \
   48325             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   48326             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   48327             :                 abort();                                                         \
   48328             :             }                                                                    \
   48329             :         } while (0);
   48330             : #endif
   48331             : 
   48332             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   48333             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   48334             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   48335             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   48336             : 
   48337             : /*! \brief New operator for SgOmpSafelenClause.
   48338             : 
   48339             :    This new operator implements memory pools to provide most efficent 
   48340             :    use of the heap within construction of large ASTs.
   48341             : 
   48342             : \internal The new and delete operators use the lower level C malloc/free
   48343             :    function calls for performance and to make sure that mixing of malloc/free
   48344             :    and new/delete by the used can be caught more readily.  This may change
   48345             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   48346             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   48347             :    deallocate memory allocated using ROSE_MALLOC.
   48348             : */
   48349           2 : void *SgOmpSafelenClause::operator new ( size_t Size )
   48350             : {
   48351             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   48352             :      * returning or throwing an exception. */
   48353           2 :     ALLOC_MUTEX(SgOmpSafelenClause, lock);
   48354             : 
   48355             : #if ROSE_ALLOC_TRACE == 2
   48356             : //    printf("SgOmpSafelenClause::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgOmpSafelenClause::next_node);
   48357             : #endif
   48358             : 
   48359             : #if USE_CPP_NEW_DELETE_OPERATORS
   48360             :     void *mem = ROSE_MALLOC(Size);
   48361             :     ALLOC_MUTEX(SgOmpSafelenClause, unlock);
   48362             :     return mem;
   48363             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   48364             : #if ROSE_PEDANTIC_ALLOC
   48365             :     ROSE_ASSERT(Size == sizeof(SgOmpSafelenClause));
   48366             : #else
   48367           2 :     if (Size != sizeof(SgOmpSafelenClause)) {
   48368           0 :       void * object = ROSE_MALLOC(Size);
   48369           0 :       ALLOC_MUTEX(SgOmpSafelenClause, unlock);
   48370             :       return object;
   48371             :     }
   48372             : #endif
   48373             : 
   48374           2 :     if (SgOmpSafelenClause::next_node == nullptr) {
   48375           2 :         SgOmpSafelenClause * alloc = (SgOmpSafelenClause*) ROSE_MALLOC ( SgOmpSafelenClause::pool_size * sizeof(SgOmpSafelenClause) );
   48376           2 :         ROSE_ASSERT(alloc != nullptr);
   48377             : 
   48378             : #if ROSE_ALLOC_TRACE == 2
   48379             : //        printf("SgOmpSafelenClause::alloc\n  block[%zi] = [ %p , %p [\n", SgOmpSafelenClause::pools.size(), alloc, alloc + SgOmpSafelenClause::pool_size);
   48380             : #endif
   48381             : 
   48382             : #if ROSE_ALLOC_MEMSET == 1
   48383             : #elif ROSE_ALLOC_MEMSET == 2
   48384             :         memset(alloc, 0x00, SgOmpSafelenClause::pool_size * sizeof(SgOmpSafelenClause));
   48385             : #elif ROSE_ALLOC_MEMSET == 3
   48386             :         memset(alloc, 0xAA, SgOmpSafelenClause::pool_size * sizeof(SgOmpSafelenClause));
   48387             : #endif
   48388        4000 :         for (unsigned i=0; i < SgOmpSafelenClause::pool_size-1; i++) {
   48389        3998 :           alloc[i].p_freepointer = &(alloc[i+1]);
   48390             :         }
   48391           2 :         alloc[SgOmpSafelenClause::pool_size-1].p_freepointer = nullptr;
   48392             : 
   48393           2 :         SgOmpSafelenClause::pools.push_back ( (unsigned char *) alloc );
   48394           2 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgOmpSafelenClause::pool_size * sizeof(SgOmpSafelenClause), V_SgOmpSafelenClause ) );
   48395           2 :         SgOmpSafelenClause::next_node = alloc;
   48396             :     }
   48397           2 :     ROSE_ASSERT(SgOmpSafelenClause::next_node != nullptr);
   48398             : 
   48399           2 :     SgOmpSafelenClause * object = SgOmpSafelenClause::next_node;
   48400           2 :     SgOmpSafelenClause::next_node = (SgOmpSafelenClause*)(object->p_freepointer);
   48401             : 
   48402             : #if ROSE_ALLOC_TRACE == 2
   48403             :     printf("SgOmpSafelenClause::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpSafelenClause::next_node);
   48404             : #endif
   48405             : 
   48406           2 :     SgNode * fp = object->p_freepointer;
   48407             : #if ROSE_ALLOC_MEMSET == 1
   48408             : #elif ROSE_ALLOC_MEMSET == 2
   48409             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpSafelenClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   48410             : #elif ROSE_ALLOC_MEMSET == 3
   48411             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgOmpSafelenClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   48412             : #endif
   48413           2 :     object->p_freepointer = fp;
   48414             : 
   48415             : #if ROSE_ALLOC_TRACE == 2
   48416             : //    printf("SgOmpSafelenClause::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpSafelenClause::next_node);
   48417             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   48418             :     Rose::MemPool::snapshot(oss.str());
   48419             :     alloc_trace_cnt++;
   48420             : #endif
   48421             : 
   48422           2 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   48423             : 
   48424           2 :     ALLOC_MUTEX(SgOmpSafelenClause, unlock);
   48425             : 
   48426             :     return object;
   48427             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   48428             : }
   48429             : 
   48430             : 
   48431             : 
   48432             : /*! \brief Delete operator for SgOmpSafelenClause.
   48433             : 
   48434             :    This delete operator implements deallocation using memory pools to 
   48435             :    provide most efficent use of the heap within construction of large ASTs.
   48436             : 
   48437             : \internal The new and delete operators use the lower level C malloc/free
   48438             :    function calls for performance and to make sure that mixing of malloc/free
   48439             :    and new/delete by the used can be caught more readily.  This may change
   48440             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   48441             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   48442             :    deallocate memory allocated using ROSE_MALLOC.
   48443             : */
   48444           0 : void SgOmpSafelenClause::operator delete(void *Pointer, size_t Size)
   48445             : {
   48446             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   48447             :      * or throwing an exception. */
   48448           0 :     ALLOC_MUTEX(SgOmpSafelenClause, lock);
   48449             : 
   48450             : #if USE_CPP_NEW_DELETE_OPERATORS
   48451             :     ROSE_FREE(Pointer);
   48452             : #else
   48453             : #if ROSE_PEDANTIC_ALLOC
   48454             :     ROSE_ASSERT(Size == sizeof(SgOmpSafelenClause));
   48455             : #else
   48456           0 :     if (Size != sizeof(SgOmpSafelenClause)) {
   48457           0 :       ROSE_FREE(Pointer);
   48458           0 :       ALLOC_MUTEX(SgOmpSafelenClause, unlock);
   48459             :       return;
   48460             :     }
   48461             : #endif
   48462             : 
   48463           0 :     SgOmpSafelenClause * object = (SgOmpSafelenClause*) Pointer;
   48464           0 :     ROSE_ASSERT(object != nullptr);
   48465             : 
   48466             : #if ROSE_ALLOC_TRACE == 2
   48467             : //  printf("SgOmpSafelenClause::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpSafelenClause::next_node);
   48468             :     printf("SgOmpSafelenClause::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpSafelenClause::next_node);
   48469             : #endif
   48470             : 
   48471             : #if ROSE_PEDANTIC_ALLOC
   48472             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   48473             : #endif
   48474             : 
   48475             : #if ROSE_ALLOC_MEMSET == 1
   48476             : #elif ROSE_ALLOC_MEMSET == 2
   48477             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpSafelenClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   48478             : #elif ROSE_ALLOC_MEMSET == 3
   48479             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgOmpSafelenClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   48480             : #endif
   48481             : 
   48482             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   48483             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   48484             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   48485             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   48486             : #else
   48487           0 :     object->p_freepointer = SgOmpSafelenClause::next_node;
   48488           0 :     SgOmpSafelenClause::next_node = object;
   48489             : #endif
   48490             : 
   48491             : #if ROSE_ALLOC_TRACE == 2
   48492             : //  printf("SgOmpSafelenClause::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpSafelenClause::next_node);
   48493             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   48494             :     Rose::MemPool::snapshot(oss.str());
   48495             :     alloc_trace_cnt++;
   48496             : #endif
   48497             : 
   48498             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   48499             : 
   48500           0 :     ALLOC_MUTEX(SgOmpSafelenClause, unlock);
   48501             : }
   48502             : 
   48503             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   48504             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   48505             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   48506             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   48507             : // Also, note comment below from Robb (copied from the Common.code file).
   48508             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   48509             : //
   48510             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   48511             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   48512             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   48513             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   48514             : #if 0
   48515             : void SgOmpSafelenClause::operator delete(void* pointer) { SgOmpSafelenClause::operator delete (pointer, sizeof(SgOmpSafelenClause)); };
   48516             : #endif
   48517             : /* #line 48518 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   48518             : 
   48519             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   48520             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   48521             : // obviously imply C++.
   48522             : 
   48523             : // This implements the support within ROSE for memory pools.  Memory pools
   48524             : // support the most condensed usage of memory within the construction of
   48525             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   48526             : // by a new operator written for each class.
   48527             : 
   48528             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   48529             :     // User wants multi-thread support and POSIX threads are available.
   48530             : #   include <pthread.h>
   48531             :     static pthread_mutex_t SgOmpSimdlenClause_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   48532             : #else
   48533             :      // Cause synchronization to be skipped.
   48534             : #    ifndef ALLOC_MUTEX
   48535             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   48536             : #    endif
   48537             : #    ifdef _REENTRANT
   48538             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   48539             : #       ifdef _MSC_VER
   48540             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   48541             : #       else
   48542             : #           warning "POSIX threads are not available; synchronization being skipped"
   48543             : #       endif
   48544             : #    endif
   48545             : #endif
   48546             : 
   48547             : #ifndef ROSE_ALLOC_TRACE
   48548             : #  define ROSE_ALLOC_TRACE 0
   48549             : #endif
   48550             : 
   48551             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   48552             : #define ROSE_ALLOC_TRACE_CNT
   48553             : #include "memory-pool-snapshot.h"
   48554             : unsigned long alloc_trace_cnt = 0;
   48555             : #endif
   48556             : 
   48557             : #if ROSE_ALLOC_TRACE
   48558             : const unsigned SgOmpSimdlenClause::pool_size = 5;
   48559             : #else
   48560             : const unsigned SgOmpSimdlenClause::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   48561             : #endif
   48562             : 
   48563             : #ifndef ROSE_ALLOC_MEMSET
   48564             : #  define ROSE_ALLOC_MEMSET 0
   48565             : #endif
   48566             : 
   48567             : #ifndef ROSE_PEDANTIC_ALLOC
   48568             : #  define ROSE_PEDANTIC_ALLOC 0
   48569             : #endif
   48570             : 
   48571             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   48572             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   48573             : #endif
   48574             : 
   48575             : #if !defined(SGNODE__ALL_POOLS)
   48576             : #define SGNODE__ALL_POOLS
   48577             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   48578             : #endif
   48579             : 
   48580             : SgOmpSimdlenClause* SgOmpSimdlenClause::next_node = nullptr;
   48581             : std::vector<unsigned char*> SgOmpSimdlenClause::pools;
   48582             : 
   48583             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   48584             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   48585             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   48586             : // around this macro definition rather than each use).
   48587             : #ifndef ALLOC_MUTEX
   48588             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   48589             :         do {                                                                     \
   48590             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   48591             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   48592             :                 abort();                                                         \
   48593             :             }                                                                    \
   48594             :         } while (0);
   48595             : #endif
   48596             : 
   48597             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   48598             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   48599             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   48600             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   48601             : 
   48602             : /*! \brief New operator for SgOmpSimdlenClause.
   48603             : 
   48604             :    This new operator implements memory pools to provide most efficent 
   48605             :    use of the heap within construction of large ASTs.
   48606             : 
   48607             : \internal The new and delete operators use the lower level C malloc/free
   48608             :    function calls for performance and to make sure that mixing of malloc/free
   48609             :    and new/delete by the used can be caught more readily.  This may change
   48610             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   48611             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   48612             :    deallocate memory allocated using ROSE_MALLOC.
   48613             : */
   48614           2 : void *SgOmpSimdlenClause::operator new ( size_t Size )
   48615             : {
   48616             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   48617             :      * returning or throwing an exception. */
   48618           2 :     ALLOC_MUTEX(SgOmpSimdlenClause, lock);
   48619             : 
   48620             : #if ROSE_ALLOC_TRACE == 2
   48621             : //    printf("SgOmpSimdlenClause::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgOmpSimdlenClause::next_node);
   48622             : #endif
   48623             : 
   48624             : #if USE_CPP_NEW_DELETE_OPERATORS
   48625             :     void *mem = ROSE_MALLOC(Size);
   48626             :     ALLOC_MUTEX(SgOmpSimdlenClause, unlock);
   48627             :     return mem;
   48628             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   48629             : #if ROSE_PEDANTIC_ALLOC
   48630             :     ROSE_ASSERT(Size == sizeof(SgOmpSimdlenClause));
   48631             : #else
   48632           2 :     if (Size != sizeof(SgOmpSimdlenClause)) {
   48633           0 :       void * object = ROSE_MALLOC(Size);
   48634           0 :       ALLOC_MUTEX(SgOmpSimdlenClause, unlock);
   48635             :       return object;
   48636             :     }
   48637             : #endif
   48638             : 
   48639           2 :     if (SgOmpSimdlenClause::next_node == nullptr) {
   48640           2 :         SgOmpSimdlenClause * alloc = (SgOmpSimdlenClause*) ROSE_MALLOC ( SgOmpSimdlenClause::pool_size * sizeof(SgOmpSimdlenClause) );
   48641           2 :         ROSE_ASSERT(alloc != nullptr);
   48642             : 
   48643             : #if ROSE_ALLOC_TRACE == 2
   48644             : //        printf("SgOmpSimdlenClause::alloc\n  block[%zi] = [ %p , %p [\n", SgOmpSimdlenClause::pools.size(), alloc, alloc + SgOmpSimdlenClause::pool_size);
   48645             : #endif
   48646             : 
   48647             : #if ROSE_ALLOC_MEMSET == 1
   48648             : #elif ROSE_ALLOC_MEMSET == 2
   48649             :         memset(alloc, 0x00, SgOmpSimdlenClause::pool_size * sizeof(SgOmpSimdlenClause));
   48650             : #elif ROSE_ALLOC_MEMSET == 3
   48651             :         memset(alloc, 0xAA, SgOmpSimdlenClause::pool_size * sizeof(SgOmpSimdlenClause));
   48652             : #endif
   48653        4000 :         for (unsigned i=0; i < SgOmpSimdlenClause::pool_size-1; i++) {
   48654        3998 :           alloc[i].p_freepointer = &(alloc[i+1]);
   48655             :         }
   48656           2 :         alloc[SgOmpSimdlenClause::pool_size-1].p_freepointer = nullptr;
   48657             : 
   48658           2 :         SgOmpSimdlenClause::pools.push_back ( (unsigned char *) alloc );
   48659           2 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgOmpSimdlenClause::pool_size * sizeof(SgOmpSimdlenClause), V_SgOmpSimdlenClause ) );
   48660           2 :         SgOmpSimdlenClause::next_node = alloc;
   48661             :     }
   48662           2 :     ROSE_ASSERT(SgOmpSimdlenClause::next_node != nullptr);
   48663             : 
   48664           2 :     SgOmpSimdlenClause * object = SgOmpSimdlenClause::next_node;
   48665           2 :     SgOmpSimdlenClause::next_node = (SgOmpSimdlenClause*)(object->p_freepointer);
   48666             : 
   48667             : #if ROSE_ALLOC_TRACE == 2
   48668             :     printf("SgOmpSimdlenClause::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpSimdlenClause::next_node);
   48669             : #endif
   48670             : 
   48671           2 :     SgNode * fp = object->p_freepointer;
   48672             : #if ROSE_ALLOC_MEMSET == 1
   48673             : #elif ROSE_ALLOC_MEMSET == 2
   48674             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpSimdlenClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   48675             : #elif ROSE_ALLOC_MEMSET == 3
   48676             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgOmpSimdlenClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   48677             : #endif
   48678           2 :     object->p_freepointer = fp;
   48679             : 
   48680             : #if ROSE_ALLOC_TRACE == 2
   48681             : //    printf("SgOmpSimdlenClause::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpSimdlenClause::next_node);
   48682             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   48683             :     Rose::MemPool::snapshot(oss.str());
   48684             :     alloc_trace_cnt++;
   48685             : #endif
   48686             : 
   48687           2 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   48688             : 
   48689           2 :     ALLOC_MUTEX(SgOmpSimdlenClause, unlock);
   48690             : 
   48691             :     return object;
   48692             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   48693             : }
   48694             : 
   48695             : 
   48696             : 
   48697             : /*! \brief Delete operator for SgOmpSimdlenClause.
   48698             : 
   48699             :    This delete operator implements deallocation using memory pools to 
   48700             :    provide most efficent use of the heap within construction of large ASTs.
   48701             : 
   48702             : \internal The new and delete operators use the lower level C malloc/free
   48703             :    function calls for performance and to make sure that mixing of malloc/free
   48704             :    and new/delete by the used can be caught more readily.  This may change
   48705             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   48706             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   48707             :    deallocate memory allocated using ROSE_MALLOC.
   48708             : */
   48709           0 : void SgOmpSimdlenClause::operator delete(void *Pointer, size_t Size)
   48710             : {
   48711             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   48712             :      * or throwing an exception. */
   48713           0 :     ALLOC_MUTEX(SgOmpSimdlenClause, lock);
   48714             : 
   48715             : #if USE_CPP_NEW_DELETE_OPERATORS
   48716             :     ROSE_FREE(Pointer);
   48717             : #else
   48718             : #if ROSE_PEDANTIC_ALLOC
   48719             :     ROSE_ASSERT(Size == sizeof(SgOmpSimdlenClause));
   48720             : #else
   48721           0 :     if (Size != sizeof(SgOmpSimdlenClause)) {
   48722           0 :       ROSE_FREE(Pointer);
   48723           0 :       ALLOC_MUTEX(SgOmpSimdlenClause, unlock);
   48724             :       return;
   48725             :     }
   48726             : #endif
   48727             : 
   48728           0 :     SgOmpSimdlenClause * object = (SgOmpSimdlenClause*) Pointer;
   48729           0 :     ROSE_ASSERT(object != nullptr);
   48730             : 
   48731             : #if ROSE_ALLOC_TRACE == 2
   48732             : //  printf("SgOmpSimdlenClause::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpSimdlenClause::next_node);
   48733             :     printf("SgOmpSimdlenClause::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpSimdlenClause::next_node);
   48734             : #endif
   48735             : 
   48736             : #if ROSE_PEDANTIC_ALLOC
   48737             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   48738             : #endif
   48739             : 
   48740             : #if ROSE_ALLOC_MEMSET == 1
   48741             : #elif ROSE_ALLOC_MEMSET == 2
   48742             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpSimdlenClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   48743             : #elif ROSE_ALLOC_MEMSET == 3
   48744             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgOmpSimdlenClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   48745             : #endif
   48746             : 
   48747             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   48748             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   48749             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   48750             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   48751             : #else
   48752           0 :     object->p_freepointer = SgOmpSimdlenClause::next_node;
   48753           0 :     SgOmpSimdlenClause::next_node = object;
   48754             : #endif
   48755             : 
   48756             : #if ROSE_ALLOC_TRACE == 2
   48757             : //  printf("SgOmpSimdlenClause::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpSimdlenClause::next_node);
   48758             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   48759             :     Rose::MemPool::snapshot(oss.str());
   48760             :     alloc_trace_cnt++;
   48761             : #endif
   48762             : 
   48763             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   48764             : 
   48765           0 :     ALLOC_MUTEX(SgOmpSimdlenClause, unlock);
   48766             : }
   48767             : 
   48768             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   48769             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   48770             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   48771             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   48772             : // Also, note comment below from Robb (copied from the Common.code file).
   48773             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   48774             : //
   48775             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   48776             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   48777             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   48778             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   48779             : #if 0
   48780             : void SgOmpSimdlenClause::operator delete(void* pointer) { SgOmpSimdlenClause::operator delete (pointer, sizeof(SgOmpSimdlenClause)); };
   48781             : #endif
   48782             : /* #line 48783 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   48783             : 
   48784             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   48785             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   48786             : // obviously imply C++.
   48787             : 
   48788             : // This implements the support within ROSE for memory pools.  Memory pools
   48789             : // support the most condensed usage of memory within the construction of
   48790             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   48791             : // by a new operator written for each class.
   48792             : 
   48793             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   48794             :     // User wants multi-thread support and POSIX threads are available.
   48795             : #   include <pthread.h>
   48796             :     static pthread_mutex_t SgOmpFinalClause_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   48797             : #else
   48798             :      // Cause synchronization to be skipped.
   48799             : #    ifndef ALLOC_MUTEX
   48800             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   48801             : #    endif
   48802             : #    ifdef _REENTRANT
   48803             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   48804             : #       ifdef _MSC_VER
   48805             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   48806             : #       else
   48807             : #           warning "POSIX threads are not available; synchronization being skipped"
   48808             : #       endif
   48809             : #    endif
   48810             : #endif
   48811             : 
   48812             : #ifndef ROSE_ALLOC_TRACE
   48813             : #  define ROSE_ALLOC_TRACE 0
   48814             : #endif
   48815             : 
   48816             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   48817             : #define ROSE_ALLOC_TRACE_CNT
   48818             : #include "memory-pool-snapshot.h"
   48819             : unsigned long alloc_trace_cnt = 0;
   48820             : #endif
   48821             : 
   48822             : #if ROSE_ALLOC_TRACE
   48823             : const unsigned SgOmpFinalClause::pool_size = 5;
   48824             : #else
   48825             : const unsigned SgOmpFinalClause::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   48826             : #endif
   48827             : 
   48828             : #ifndef ROSE_ALLOC_MEMSET
   48829             : #  define ROSE_ALLOC_MEMSET 0
   48830             : #endif
   48831             : 
   48832             : #ifndef ROSE_PEDANTIC_ALLOC
   48833             : #  define ROSE_PEDANTIC_ALLOC 0
   48834             : #endif
   48835             : 
   48836             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   48837             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   48838             : #endif
   48839             : 
   48840             : #if !defined(SGNODE__ALL_POOLS)
   48841             : #define SGNODE__ALL_POOLS
   48842             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   48843             : #endif
   48844             : 
   48845             : SgOmpFinalClause* SgOmpFinalClause::next_node = nullptr;
   48846             : std::vector<unsigned char*> SgOmpFinalClause::pools;
   48847             : 
   48848             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   48849             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   48850             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   48851             : // around this macro definition rather than each use).
   48852             : #ifndef ALLOC_MUTEX
   48853             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   48854             :         do {                                                                     \
   48855             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   48856             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   48857             :                 abort();                                                         \
   48858             :             }                                                                    \
   48859             :         } while (0);
   48860             : #endif
   48861             : 
   48862             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   48863             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   48864             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   48865             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   48866             : 
   48867             : /*! \brief New operator for SgOmpFinalClause.
   48868             : 
   48869             :    This new operator implements memory pools to provide most efficent 
   48870             :    use of the heap within construction of large ASTs.
   48871             : 
   48872             : \internal The new and delete operators use the lower level C malloc/free
   48873             :    function calls for performance and to make sure that mixing of malloc/free
   48874             :    and new/delete by the used can be caught more readily.  This may change
   48875             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   48876             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   48877             :    deallocate memory allocated using ROSE_MALLOC.
   48878             : */
   48879           3 : void *SgOmpFinalClause::operator new ( size_t Size )
   48880             : {
   48881             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   48882             :      * returning or throwing an exception. */
   48883           3 :     ALLOC_MUTEX(SgOmpFinalClause, lock);
   48884             : 
   48885             : #if ROSE_ALLOC_TRACE == 2
   48886             : //    printf("SgOmpFinalClause::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgOmpFinalClause::next_node);
   48887             : #endif
   48888             : 
   48889             : #if USE_CPP_NEW_DELETE_OPERATORS
   48890             :     void *mem = ROSE_MALLOC(Size);
   48891             :     ALLOC_MUTEX(SgOmpFinalClause, unlock);
   48892             :     return mem;
   48893             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   48894             : #if ROSE_PEDANTIC_ALLOC
   48895             :     ROSE_ASSERT(Size == sizeof(SgOmpFinalClause));
   48896             : #else
   48897           3 :     if (Size != sizeof(SgOmpFinalClause)) {
   48898           0 :       void * object = ROSE_MALLOC(Size);
   48899           0 :       ALLOC_MUTEX(SgOmpFinalClause, unlock);
   48900             :       return object;
   48901             :     }
   48902             : #endif
   48903             : 
   48904           3 :     if (SgOmpFinalClause::next_node == nullptr) {
   48905           2 :         SgOmpFinalClause * alloc = (SgOmpFinalClause*) ROSE_MALLOC ( SgOmpFinalClause::pool_size * sizeof(SgOmpFinalClause) );
   48906           2 :         ROSE_ASSERT(alloc != nullptr);
   48907             : 
   48908             : #if ROSE_ALLOC_TRACE == 2
   48909             : //        printf("SgOmpFinalClause::alloc\n  block[%zi] = [ %p , %p [\n", SgOmpFinalClause::pools.size(), alloc, alloc + SgOmpFinalClause::pool_size);
   48910             : #endif
   48911             : 
   48912             : #if ROSE_ALLOC_MEMSET == 1
   48913             : #elif ROSE_ALLOC_MEMSET == 2
   48914             :         memset(alloc, 0x00, SgOmpFinalClause::pool_size * sizeof(SgOmpFinalClause));
   48915             : #elif ROSE_ALLOC_MEMSET == 3
   48916             :         memset(alloc, 0xAA, SgOmpFinalClause::pool_size * sizeof(SgOmpFinalClause));
   48917             : #endif
   48918        4000 :         for (unsigned i=0; i < SgOmpFinalClause::pool_size-1; i++) {
   48919        3998 :           alloc[i].p_freepointer = &(alloc[i+1]);
   48920             :         }
   48921           2 :         alloc[SgOmpFinalClause::pool_size-1].p_freepointer = nullptr;
   48922             : 
   48923           2 :         SgOmpFinalClause::pools.push_back ( (unsigned char *) alloc );
   48924           2 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgOmpFinalClause::pool_size * sizeof(SgOmpFinalClause), V_SgOmpFinalClause ) );
   48925           2 :         SgOmpFinalClause::next_node = alloc;
   48926             :     }
   48927           3 :     ROSE_ASSERT(SgOmpFinalClause::next_node != nullptr);
   48928             : 
   48929           3 :     SgOmpFinalClause * object = SgOmpFinalClause::next_node;
   48930           3 :     SgOmpFinalClause::next_node = (SgOmpFinalClause*)(object->p_freepointer);
   48931             : 
   48932             : #if ROSE_ALLOC_TRACE == 2
   48933             :     printf("SgOmpFinalClause::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpFinalClause::next_node);
   48934             : #endif
   48935             : 
   48936           3 :     SgNode * fp = object->p_freepointer;
   48937             : #if ROSE_ALLOC_MEMSET == 1
   48938             : #elif ROSE_ALLOC_MEMSET == 2
   48939             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpFinalClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   48940             : #elif ROSE_ALLOC_MEMSET == 3
   48941             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgOmpFinalClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   48942             : #endif
   48943           3 :     object->p_freepointer = fp;
   48944             : 
   48945             : #if ROSE_ALLOC_TRACE == 2
   48946             : //    printf("SgOmpFinalClause::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpFinalClause::next_node);
   48947             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   48948             :     Rose::MemPool::snapshot(oss.str());
   48949             :     alloc_trace_cnt++;
   48950             : #endif
   48951             : 
   48952           3 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   48953             : 
   48954           3 :     ALLOC_MUTEX(SgOmpFinalClause, unlock);
   48955             : 
   48956             :     return object;
   48957             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   48958             : }
   48959             : 
   48960             : 
   48961             : 
   48962             : /*! \brief Delete operator for SgOmpFinalClause.
   48963             : 
   48964             :    This delete operator implements deallocation using memory pools to 
   48965             :    provide most efficent use of the heap within construction of large ASTs.
   48966             : 
   48967             : \internal The new and delete operators use the lower level C malloc/free
   48968             :    function calls for performance and to make sure that mixing of malloc/free
   48969             :    and new/delete by the used can be caught more readily.  This may change
   48970             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   48971             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   48972             :    deallocate memory allocated using ROSE_MALLOC.
   48973             : */
   48974           0 : void SgOmpFinalClause::operator delete(void *Pointer, size_t Size)
   48975             : {
   48976             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   48977             :      * or throwing an exception. */
   48978           0 :     ALLOC_MUTEX(SgOmpFinalClause, lock);
   48979             : 
   48980             : #if USE_CPP_NEW_DELETE_OPERATORS
   48981             :     ROSE_FREE(Pointer);
   48982             : #else
   48983             : #if ROSE_PEDANTIC_ALLOC
   48984             :     ROSE_ASSERT(Size == sizeof(SgOmpFinalClause));
   48985             : #else
   48986           0 :     if (Size != sizeof(SgOmpFinalClause)) {
   48987           0 :       ROSE_FREE(Pointer);
   48988           0 :       ALLOC_MUTEX(SgOmpFinalClause, unlock);
   48989             :       return;
   48990             :     }
   48991             : #endif
   48992             : 
   48993           0 :     SgOmpFinalClause * object = (SgOmpFinalClause*) Pointer;
   48994           0 :     ROSE_ASSERT(object != nullptr);
   48995             : 
   48996             : #if ROSE_ALLOC_TRACE == 2
   48997             : //  printf("SgOmpFinalClause::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpFinalClause::next_node);
   48998             :     printf("SgOmpFinalClause::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpFinalClause::next_node);
   48999             : #endif
   49000             : 
   49001             : #if ROSE_PEDANTIC_ALLOC
   49002             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   49003             : #endif
   49004             : 
   49005             : #if ROSE_ALLOC_MEMSET == 1
   49006             : #elif ROSE_ALLOC_MEMSET == 2
   49007             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpFinalClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   49008             : #elif ROSE_ALLOC_MEMSET == 3
   49009             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgOmpFinalClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   49010             : #endif
   49011             : 
   49012             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   49013             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   49014             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   49015             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   49016             : #else
   49017           0 :     object->p_freepointer = SgOmpFinalClause::next_node;
   49018           0 :     SgOmpFinalClause::next_node = object;
   49019             : #endif
   49020             : 
   49021             : #if ROSE_ALLOC_TRACE == 2
   49022             : //  printf("SgOmpFinalClause::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpFinalClause::next_node);
   49023             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   49024             :     Rose::MemPool::snapshot(oss.str());
   49025             :     alloc_trace_cnt++;
   49026             : #endif
   49027             : 
   49028             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   49029             : 
   49030           0 :     ALLOC_MUTEX(SgOmpFinalClause, unlock);
   49031             : }
   49032             : 
   49033             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   49034             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   49035             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   49036             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   49037             : // Also, note comment below from Robb (copied from the Common.code file).
   49038             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   49039             : //
   49040             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   49041             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   49042             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   49043             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   49044             : #if 0
   49045             : void SgOmpFinalClause::operator delete(void* pointer) { SgOmpFinalClause::operator delete (pointer, sizeof(SgOmpFinalClause)); };
   49046             : #endif
   49047             : /* #line 49048 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   49048             : 
   49049             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   49050             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   49051             : // obviously imply C++.
   49052             : 
   49053             : // This implements the support within ROSE for memory pools.  Memory pools
   49054             : // support the most condensed usage of memory within the construction of
   49055             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   49056             : // by a new operator written for each class.
   49057             : 
   49058             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   49059             :     // User wants multi-thread support and POSIX threads are available.
   49060             : #   include <pthread.h>
   49061             :     static pthread_mutex_t SgOmpPriorityClause_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   49062             : #else
   49063             :      // Cause synchronization to be skipped.
   49064             : #    ifndef ALLOC_MUTEX
   49065             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   49066             : #    endif
   49067             : #    ifdef _REENTRANT
   49068             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   49069             : #       ifdef _MSC_VER
   49070             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   49071             : #       else
   49072             : #           warning "POSIX threads are not available; synchronization being skipped"
   49073             : #       endif
   49074             : #    endif
   49075             : #endif
   49076             : 
   49077             : #ifndef ROSE_ALLOC_TRACE
   49078             : #  define ROSE_ALLOC_TRACE 0
   49079             : #endif
   49080             : 
   49081             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   49082             : #define ROSE_ALLOC_TRACE_CNT
   49083             : #include "memory-pool-snapshot.h"
   49084             : unsigned long alloc_trace_cnt = 0;
   49085             : #endif
   49086             : 
   49087             : #if ROSE_ALLOC_TRACE
   49088             : const unsigned SgOmpPriorityClause::pool_size = 5;
   49089             : #else
   49090             : const unsigned SgOmpPriorityClause::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   49091             : #endif
   49092             : 
   49093             : #ifndef ROSE_ALLOC_MEMSET
   49094             : #  define ROSE_ALLOC_MEMSET 0
   49095             : #endif
   49096             : 
   49097             : #ifndef ROSE_PEDANTIC_ALLOC
   49098             : #  define ROSE_PEDANTIC_ALLOC 0
   49099             : #endif
   49100             : 
   49101             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   49102             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   49103             : #endif
   49104             : 
   49105             : #if !defined(SGNODE__ALL_POOLS)
   49106             : #define SGNODE__ALL_POOLS
   49107             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   49108             : #endif
   49109             : 
   49110             : SgOmpPriorityClause* SgOmpPriorityClause::next_node = nullptr;
   49111             : std::vector<unsigned char*> SgOmpPriorityClause::pools;
   49112             : 
   49113             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   49114             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   49115             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   49116             : // around this macro definition rather than each use).
   49117             : #ifndef ALLOC_MUTEX
   49118             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   49119             :         do {                                                                     \
   49120             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   49121             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   49122             :                 abort();                                                         \
   49123             :             }                                                                    \
   49124             :         } while (0);
   49125             : #endif
   49126             : 
   49127             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   49128             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   49129             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   49130             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   49131             : 
   49132             : /*! \brief New operator for SgOmpPriorityClause.
   49133             : 
   49134             :    This new operator implements memory pools to provide most efficent 
   49135             :    use of the heap within construction of large ASTs.
   49136             : 
   49137             : \internal The new and delete operators use the lower level C malloc/free
   49138             :    function calls for performance and to make sure that mixing of malloc/free
   49139             :    and new/delete by the used can be caught more readily.  This may change
   49140             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   49141             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   49142             :    deallocate memory allocated using ROSE_MALLOC.
   49143             : */
   49144           1 : void *SgOmpPriorityClause::operator new ( size_t Size )
   49145             : {
   49146             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   49147             :      * returning or throwing an exception. */
   49148           1 :     ALLOC_MUTEX(SgOmpPriorityClause, lock);
   49149             : 
   49150             : #if ROSE_ALLOC_TRACE == 2
   49151             : //    printf("SgOmpPriorityClause::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgOmpPriorityClause::next_node);
   49152             : #endif
   49153             : 
   49154             : #if USE_CPP_NEW_DELETE_OPERATORS
   49155             :     void *mem = ROSE_MALLOC(Size);
   49156             :     ALLOC_MUTEX(SgOmpPriorityClause, unlock);
   49157             :     return mem;
   49158             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   49159             : #if ROSE_PEDANTIC_ALLOC
   49160             :     ROSE_ASSERT(Size == sizeof(SgOmpPriorityClause));
   49161             : #else
   49162           1 :     if (Size != sizeof(SgOmpPriorityClause)) {
   49163           0 :       void * object = ROSE_MALLOC(Size);
   49164           0 :       ALLOC_MUTEX(SgOmpPriorityClause, unlock);
   49165             :       return object;
   49166             :     }
   49167             : #endif
   49168             : 
   49169           1 :     if (SgOmpPriorityClause::next_node == nullptr) {
   49170           1 :         SgOmpPriorityClause * alloc = (SgOmpPriorityClause*) ROSE_MALLOC ( SgOmpPriorityClause::pool_size * sizeof(SgOmpPriorityClause) );
   49171           1 :         ROSE_ASSERT(alloc != nullptr);
   49172             : 
   49173             : #if ROSE_ALLOC_TRACE == 2
   49174             : //        printf("SgOmpPriorityClause::alloc\n  block[%zi] = [ %p , %p [\n", SgOmpPriorityClause::pools.size(), alloc, alloc + SgOmpPriorityClause::pool_size);
   49175             : #endif
   49176             : 
   49177             : #if ROSE_ALLOC_MEMSET == 1
   49178             : #elif ROSE_ALLOC_MEMSET == 2
   49179             :         memset(alloc, 0x00, SgOmpPriorityClause::pool_size * sizeof(SgOmpPriorityClause));
   49180             : #elif ROSE_ALLOC_MEMSET == 3
   49181             :         memset(alloc, 0xAA, SgOmpPriorityClause::pool_size * sizeof(SgOmpPriorityClause));
   49182             : #endif
   49183        2000 :         for (unsigned i=0; i < SgOmpPriorityClause::pool_size-1; i++) {
   49184        1999 :           alloc[i].p_freepointer = &(alloc[i+1]);
   49185             :         }
   49186           1 :         alloc[SgOmpPriorityClause::pool_size-1].p_freepointer = nullptr;
   49187             : 
   49188           1 :         SgOmpPriorityClause::pools.push_back ( (unsigned char *) alloc );
   49189           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgOmpPriorityClause::pool_size * sizeof(SgOmpPriorityClause), V_SgOmpPriorityClause ) );
   49190           1 :         SgOmpPriorityClause::next_node = alloc;
   49191             :     }
   49192           1 :     ROSE_ASSERT(SgOmpPriorityClause::next_node != nullptr);
   49193             : 
   49194           1 :     SgOmpPriorityClause * object = SgOmpPriorityClause::next_node;
   49195           1 :     SgOmpPriorityClause::next_node = (SgOmpPriorityClause*)(object->p_freepointer);
   49196             : 
   49197             : #if ROSE_ALLOC_TRACE == 2
   49198             :     printf("SgOmpPriorityClause::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpPriorityClause::next_node);
   49199             : #endif
   49200             : 
   49201           1 :     SgNode * fp = object->p_freepointer;
   49202             : #if ROSE_ALLOC_MEMSET == 1
   49203             : #elif ROSE_ALLOC_MEMSET == 2
   49204             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpPriorityClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   49205             : #elif ROSE_ALLOC_MEMSET == 3
   49206             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgOmpPriorityClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   49207             : #endif
   49208           1 :     object->p_freepointer = fp;
   49209             : 
   49210             : #if ROSE_ALLOC_TRACE == 2
   49211             : //    printf("SgOmpPriorityClause::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpPriorityClause::next_node);
   49212             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   49213             :     Rose::MemPool::snapshot(oss.str());
   49214             :     alloc_trace_cnt++;
   49215             : #endif
   49216             : 
   49217           1 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   49218             : 
   49219           1 :     ALLOC_MUTEX(SgOmpPriorityClause, unlock);
   49220             : 
   49221             :     return object;
   49222             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   49223             : }
   49224             : 
   49225             : 
   49226             : 
   49227             : /*! \brief Delete operator for SgOmpPriorityClause.
   49228             : 
   49229             :    This delete operator implements deallocation using memory pools to 
   49230             :    provide most efficent use of the heap within construction of large ASTs.
   49231             : 
   49232             : \internal The new and delete operators use the lower level C malloc/free
   49233             :    function calls for performance and to make sure that mixing of malloc/free
   49234             :    and new/delete by the used can be caught more readily.  This may change
   49235             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   49236             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   49237             :    deallocate memory allocated using ROSE_MALLOC.
   49238             : */
   49239           0 : void SgOmpPriorityClause::operator delete(void *Pointer, size_t Size)
   49240             : {
   49241             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   49242             :      * or throwing an exception. */
   49243           0 :     ALLOC_MUTEX(SgOmpPriorityClause, lock);
   49244             : 
   49245             : #if USE_CPP_NEW_DELETE_OPERATORS
   49246             :     ROSE_FREE(Pointer);
   49247             : #else
   49248             : #if ROSE_PEDANTIC_ALLOC
   49249             :     ROSE_ASSERT(Size == sizeof(SgOmpPriorityClause));
   49250             : #else
   49251           0 :     if (Size != sizeof(SgOmpPriorityClause)) {
   49252           0 :       ROSE_FREE(Pointer);
   49253           0 :       ALLOC_MUTEX(SgOmpPriorityClause, unlock);
   49254             :       return;
   49255             :     }
   49256             : #endif
   49257             : 
   49258           0 :     SgOmpPriorityClause * object = (SgOmpPriorityClause*) Pointer;
   49259           0 :     ROSE_ASSERT(object != nullptr);
   49260             : 
   49261             : #if ROSE_ALLOC_TRACE == 2
   49262             : //  printf("SgOmpPriorityClause::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpPriorityClause::next_node);
   49263             :     printf("SgOmpPriorityClause::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpPriorityClause::next_node);
   49264             : #endif
   49265             : 
   49266             : #if ROSE_PEDANTIC_ALLOC
   49267             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   49268             : #endif
   49269             : 
   49270             : #if ROSE_ALLOC_MEMSET == 1
   49271             : #elif ROSE_ALLOC_MEMSET == 2
   49272             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpPriorityClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   49273             : #elif ROSE_ALLOC_MEMSET == 3
   49274             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgOmpPriorityClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   49275             : #endif
   49276             : 
   49277             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   49278             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   49279             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   49280             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   49281             : #else
   49282           0 :     object->p_freepointer = SgOmpPriorityClause::next_node;
   49283           0 :     SgOmpPriorityClause::next_node = object;
   49284             : #endif
   49285             : 
   49286             : #if ROSE_ALLOC_TRACE == 2
   49287             : //  printf("SgOmpPriorityClause::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpPriorityClause::next_node);
   49288             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   49289             :     Rose::MemPool::snapshot(oss.str());
   49290             :     alloc_trace_cnt++;
   49291             : #endif
   49292             : 
   49293             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   49294             : 
   49295           0 :     ALLOC_MUTEX(SgOmpPriorityClause, unlock);
   49296             : }
   49297             : 
   49298             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   49299             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   49300             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   49301             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   49302             : // Also, note comment below from Robb (copied from the Common.code file).
   49303             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   49304             : //
   49305             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   49306             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   49307             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   49308             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   49309             : #if 0
   49310             : void SgOmpPriorityClause::operator delete(void* pointer) { SgOmpPriorityClause::operator delete (pointer, sizeof(SgOmpPriorityClause)); };
   49311             : #endif
   49312             : /* #line 49313 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   49313             : 
   49314             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   49315             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   49316             : // obviously imply C++.
   49317             : 
   49318             : // This implements the support within ROSE for memory pools.  Memory pools
   49319             : // support the most condensed usage of memory within the construction of
   49320             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   49321             : // by a new operator written for each class.
   49322             : 
   49323             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   49324             :     // User wants multi-thread support and POSIX threads are available.
   49325             : #   include <pthread.h>
   49326             :     static pthread_mutex_t SgOmpPartialClause_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   49327             : #else
   49328             :      // Cause synchronization to be skipped.
   49329             : #    ifndef ALLOC_MUTEX
   49330             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   49331             : #    endif
   49332             : #    ifdef _REENTRANT
   49333             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   49334             : #       ifdef _MSC_VER
   49335             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   49336             : #       else
   49337             : #           warning "POSIX threads are not available; synchronization being skipped"
   49338             : #       endif
   49339             : #    endif
   49340             : #endif
   49341             : 
   49342             : #ifndef ROSE_ALLOC_TRACE
   49343             : #  define ROSE_ALLOC_TRACE 0
   49344             : #endif
   49345             : 
   49346             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   49347             : #define ROSE_ALLOC_TRACE_CNT
   49348             : #include "memory-pool-snapshot.h"
   49349             : unsigned long alloc_trace_cnt = 0;
   49350             : #endif
   49351             : 
   49352             : #if ROSE_ALLOC_TRACE
   49353             : const unsigned SgOmpPartialClause::pool_size = 5;
   49354             : #else
   49355             : const unsigned SgOmpPartialClause::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   49356             : #endif
   49357             : 
   49358             : #ifndef ROSE_ALLOC_MEMSET
   49359             : #  define ROSE_ALLOC_MEMSET 0
   49360             : #endif
   49361             : 
   49362             : #ifndef ROSE_PEDANTIC_ALLOC
   49363             : #  define ROSE_PEDANTIC_ALLOC 0
   49364             : #endif
   49365             : 
   49366             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   49367             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   49368             : #endif
   49369             : 
   49370             : #if !defined(SGNODE__ALL_POOLS)
   49371             : #define SGNODE__ALL_POOLS
   49372             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   49373             : #endif
   49374             : 
   49375             : SgOmpPartialClause* SgOmpPartialClause::next_node = nullptr;
   49376             : std::vector<unsigned char*> SgOmpPartialClause::pools;
   49377             : 
   49378             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   49379             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   49380             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   49381             : // around this macro definition rather than each use).
   49382             : #ifndef ALLOC_MUTEX
   49383             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   49384             :         do {                                                                     \
   49385             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   49386             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   49387             :                 abort();                                                         \
   49388             :             }                                                                    \
   49389             :         } while (0);
   49390             : #endif
   49391             : 
   49392             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   49393             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   49394             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   49395             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   49396             : 
   49397             : /*! \brief New operator for SgOmpPartialClause.
   49398             : 
   49399             :    This new operator implements memory pools to provide most efficent 
   49400             :    use of the heap within construction of large ASTs.
   49401             : 
   49402             : \internal The new and delete operators use the lower level C malloc/free
   49403             :    function calls for performance and to make sure that mixing of malloc/free
   49404             :    and new/delete by the used can be caught more readily.  This may change
   49405             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   49406             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   49407             :    deallocate memory allocated using ROSE_MALLOC.
   49408             : */
   49409           0 : void *SgOmpPartialClause::operator new ( size_t Size )
   49410             : {
   49411             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   49412             :      * returning or throwing an exception. */
   49413           0 :     ALLOC_MUTEX(SgOmpPartialClause, lock);
   49414             : 
   49415             : #if ROSE_ALLOC_TRACE == 2
   49416             : //    printf("SgOmpPartialClause::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgOmpPartialClause::next_node);
   49417             : #endif
   49418             : 
   49419             : #if USE_CPP_NEW_DELETE_OPERATORS
   49420             :     void *mem = ROSE_MALLOC(Size);
   49421             :     ALLOC_MUTEX(SgOmpPartialClause, unlock);
   49422             :     return mem;
   49423             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   49424             : #if ROSE_PEDANTIC_ALLOC
   49425             :     ROSE_ASSERT(Size == sizeof(SgOmpPartialClause));
   49426             : #else
   49427           0 :     if (Size != sizeof(SgOmpPartialClause)) {
   49428           0 :       void * object = ROSE_MALLOC(Size);
   49429           0 :       ALLOC_MUTEX(SgOmpPartialClause, unlock);
   49430             :       return object;
   49431             :     }
   49432             : #endif
   49433             : 
   49434           0 :     if (SgOmpPartialClause::next_node == nullptr) {
   49435           0 :         SgOmpPartialClause * alloc = (SgOmpPartialClause*) ROSE_MALLOC ( SgOmpPartialClause::pool_size * sizeof(SgOmpPartialClause) );
   49436           0 :         ROSE_ASSERT(alloc != nullptr);
   49437             : 
   49438             : #if ROSE_ALLOC_TRACE == 2
   49439             : //        printf("SgOmpPartialClause::alloc\n  block[%zi] = [ %p , %p [\n", SgOmpPartialClause::pools.size(), alloc, alloc + SgOmpPartialClause::pool_size);
   49440             : #endif
   49441             : 
   49442             : #if ROSE_ALLOC_MEMSET == 1
   49443             : #elif ROSE_ALLOC_MEMSET == 2
   49444             :         memset(alloc, 0x00, SgOmpPartialClause::pool_size * sizeof(SgOmpPartialClause));
   49445             : #elif ROSE_ALLOC_MEMSET == 3
   49446             :         memset(alloc, 0xAA, SgOmpPartialClause::pool_size * sizeof(SgOmpPartialClause));
   49447             : #endif
   49448           0 :         for (unsigned i=0; i < SgOmpPartialClause::pool_size-1; i++) {
   49449           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
   49450             :         }
   49451           0 :         alloc[SgOmpPartialClause::pool_size-1].p_freepointer = nullptr;
   49452             : 
   49453           0 :         SgOmpPartialClause::pools.push_back ( (unsigned char *) alloc );
   49454           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgOmpPartialClause::pool_size * sizeof(SgOmpPartialClause), V_SgOmpPartialClause ) );
   49455           0 :         SgOmpPartialClause::next_node = alloc;
   49456             :     }
   49457           0 :     ROSE_ASSERT(SgOmpPartialClause::next_node != nullptr);
   49458             : 
   49459           0 :     SgOmpPartialClause * object = SgOmpPartialClause::next_node;
   49460           0 :     SgOmpPartialClause::next_node = (SgOmpPartialClause*)(object->p_freepointer);
   49461             : 
   49462             : #if ROSE_ALLOC_TRACE == 2
   49463             :     printf("SgOmpPartialClause::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpPartialClause::next_node);
   49464             : #endif
   49465             : 
   49466           0 :     SgNode * fp = object->p_freepointer;
   49467             : #if ROSE_ALLOC_MEMSET == 1
   49468             : #elif ROSE_ALLOC_MEMSET == 2
   49469             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpPartialClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   49470             : #elif ROSE_ALLOC_MEMSET == 3
   49471             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgOmpPartialClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   49472             : #endif
   49473           0 :     object->p_freepointer = fp;
   49474             : 
   49475             : #if ROSE_ALLOC_TRACE == 2
   49476             : //    printf("SgOmpPartialClause::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpPartialClause::next_node);
   49477             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   49478             :     Rose::MemPool::snapshot(oss.str());
   49479             :     alloc_trace_cnt++;
   49480             : #endif
   49481             : 
   49482           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   49483             : 
   49484           0 :     ALLOC_MUTEX(SgOmpPartialClause, unlock);
   49485             : 
   49486             :     return object;
   49487             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   49488             : }
   49489             : 
   49490             : 
   49491             : 
   49492             : /*! \brief Delete operator for SgOmpPartialClause.
   49493             : 
   49494             :    This delete operator implements deallocation using memory pools to 
   49495             :    provide most efficent use of the heap within construction of large ASTs.
   49496             : 
   49497             : \internal The new and delete operators use the lower level C malloc/free
   49498             :    function calls for performance and to make sure that mixing of malloc/free
   49499             :    and new/delete by the used can be caught more readily.  This may change
   49500             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   49501             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   49502             :    deallocate memory allocated using ROSE_MALLOC.
   49503             : */
   49504           0 : void SgOmpPartialClause::operator delete(void *Pointer, size_t Size)
   49505             : {
   49506             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   49507             :      * or throwing an exception. */
   49508           0 :     ALLOC_MUTEX(SgOmpPartialClause, lock);
   49509             : 
   49510             : #if USE_CPP_NEW_DELETE_OPERATORS
   49511             :     ROSE_FREE(Pointer);
   49512             : #else
   49513             : #if ROSE_PEDANTIC_ALLOC
   49514             :     ROSE_ASSERT(Size == sizeof(SgOmpPartialClause));
   49515             : #else
   49516           0 :     if (Size != sizeof(SgOmpPartialClause)) {
   49517           0 :       ROSE_FREE(Pointer);
   49518           0 :       ALLOC_MUTEX(SgOmpPartialClause, unlock);
   49519             :       return;
   49520             :     }
   49521             : #endif
   49522             : 
   49523           0 :     SgOmpPartialClause * object = (SgOmpPartialClause*) Pointer;
   49524           0 :     ROSE_ASSERT(object != nullptr);
   49525             : 
   49526             : #if ROSE_ALLOC_TRACE == 2
   49527             : //  printf("SgOmpPartialClause::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpPartialClause::next_node);
   49528             :     printf("SgOmpPartialClause::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpPartialClause::next_node);
   49529             : #endif
   49530             : 
   49531             : #if ROSE_PEDANTIC_ALLOC
   49532             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   49533             : #endif
   49534             : 
   49535             : #if ROSE_ALLOC_MEMSET == 1
   49536             : #elif ROSE_ALLOC_MEMSET == 2
   49537             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpPartialClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   49538             : #elif ROSE_ALLOC_MEMSET == 3
   49539             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgOmpPartialClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   49540             : #endif
   49541             : 
   49542             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   49543             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   49544             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   49545             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   49546             : #else
   49547           0 :     object->p_freepointer = SgOmpPartialClause::next_node;
   49548           0 :     SgOmpPartialClause::next_node = object;
   49549             : #endif
   49550             : 
   49551             : #if ROSE_ALLOC_TRACE == 2
   49552             : //  printf("SgOmpPartialClause::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpPartialClause::next_node);
   49553             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   49554             :     Rose::MemPool::snapshot(oss.str());
   49555             :     alloc_trace_cnt++;
   49556             : #endif
   49557             : 
   49558             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   49559             : 
   49560           0 :     ALLOC_MUTEX(SgOmpPartialClause, unlock);
   49561             : }
   49562             : 
   49563             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   49564             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   49565             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   49566             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   49567             : // Also, note comment below from Robb (copied from the Common.code file).
   49568             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   49569             : //
   49570             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   49571             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   49572             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   49573             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   49574             : #if 0
   49575             : void SgOmpPartialClause::operator delete(void* pointer) { SgOmpPartialClause::operator delete (pointer, sizeof(SgOmpPartialClause)); };
   49576             : #endif
   49577             : /* #line 49578 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   49578             : 
   49579             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   49580             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   49581             : // obviously imply C++.
   49582             : 
   49583             : // This implements the support within ROSE for memory pools.  Memory pools
   49584             : // support the most condensed usage of memory within the construction of
   49585             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   49586             : // by a new operator written for each class.
   49587             : 
   49588             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   49589             :     // User wants multi-thread support and POSIX threads are available.
   49590             : #   include <pthread.h>
   49591             :     static pthread_mutex_t SgOmpSizesClause_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   49592             : #else
   49593             :      // Cause synchronization to be skipped.
   49594             : #    ifndef ALLOC_MUTEX
   49595             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   49596             : #    endif
   49597             : #    ifdef _REENTRANT
   49598             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   49599             : #       ifdef _MSC_VER
   49600             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   49601             : #       else
   49602             : #           warning "POSIX threads are not available; synchronization being skipped"
   49603             : #       endif
   49604             : #    endif
   49605             : #endif
   49606             : 
   49607             : #ifndef ROSE_ALLOC_TRACE
   49608             : #  define ROSE_ALLOC_TRACE 0
   49609             : #endif
   49610             : 
   49611             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   49612             : #define ROSE_ALLOC_TRACE_CNT
   49613             : #include "memory-pool-snapshot.h"
   49614             : unsigned long alloc_trace_cnt = 0;
   49615             : #endif
   49616             : 
   49617             : #if ROSE_ALLOC_TRACE
   49618             : const unsigned SgOmpSizesClause::pool_size = 5;
   49619             : #else
   49620             : const unsigned SgOmpSizesClause::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   49621             : #endif
   49622             : 
   49623             : #ifndef ROSE_ALLOC_MEMSET
   49624             : #  define ROSE_ALLOC_MEMSET 0
   49625             : #endif
   49626             : 
   49627             : #ifndef ROSE_PEDANTIC_ALLOC
   49628             : #  define ROSE_PEDANTIC_ALLOC 0
   49629             : #endif
   49630             : 
   49631             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   49632             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   49633             : #endif
   49634             : 
   49635             : #if !defined(SGNODE__ALL_POOLS)
   49636             : #define SGNODE__ALL_POOLS
   49637             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   49638             : #endif
   49639             : 
   49640             : SgOmpSizesClause* SgOmpSizesClause::next_node = nullptr;
   49641             : std::vector<unsigned char*> SgOmpSizesClause::pools;
   49642             : 
   49643             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   49644             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   49645             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   49646             : // around this macro definition rather than each use).
   49647             : #ifndef ALLOC_MUTEX
   49648             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   49649             :         do {                                                                     \
   49650             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   49651             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   49652             :                 abort();                                                         \
   49653             :             }                                                                    \
   49654             :         } while (0);
   49655             : #endif
   49656             : 
   49657             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   49658             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   49659             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   49660             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   49661             : 
   49662             : /*! \brief New operator for SgOmpSizesClause.
   49663             : 
   49664             :    This new operator implements memory pools to provide most efficent 
   49665             :    use of the heap within construction of large ASTs.
   49666             : 
   49667             : \internal The new and delete operators use the lower level C malloc/free
   49668             :    function calls for performance and to make sure that mixing of malloc/free
   49669             :    and new/delete by the used can be caught more readily.  This may change
   49670             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   49671             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   49672             :    deallocate memory allocated using ROSE_MALLOC.
   49673             : */
   49674           0 : void *SgOmpSizesClause::operator new ( size_t Size )
   49675             : {
   49676             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   49677             :      * returning or throwing an exception. */
   49678           0 :     ALLOC_MUTEX(SgOmpSizesClause, lock);
   49679             : 
   49680             : #if ROSE_ALLOC_TRACE == 2
   49681             : //    printf("SgOmpSizesClause::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgOmpSizesClause::next_node);
   49682             : #endif
   49683             : 
   49684             : #if USE_CPP_NEW_DELETE_OPERATORS
   49685             :     void *mem = ROSE_MALLOC(Size);
   49686             :     ALLOC_MUTEX(SgOmpSizesClause, unlock);
   49687             :     return mem;
   49688             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   49689             : #if ROSE_PEDANTIC_ALLOC
   49690             :     ROSE_ASSERT(Size == sizeof(SgOmpSizesClause));
   49691             : #else
   49692           0 :     if (Size != sizeof(SgOmpSizesClause)) {
   49693           0 :       void * object = ROSE_MALLOC(Size);
   49694           0 :       ALLOC_MUTEX(SgOmpSizesClause, unlock);
   49695             :       return object;
   49696             :     }
   49697             : #endif
   49698             : 
   49699           0 :     if (SgOmpSizesClause::next_node == nullptr) {
   49700           0 :         SgOmpSizesClause * alloc = (SgOmpSizesClause*) ROSE_MALLOC ( SgOmpSizesClause::pool_size * sizeof(SgOmpSizesClause) );
   49701           0 :         ROSE_ASSERT(alloc != nullptr);
   49702             : 
   49703             : #if ROSE_ALLOC_TRACE == 2
   49704             : //        printf("SgOmpSizesClause::alloc\n  block[%zi] = [ %p , %p [\n", SgOmpSizesClause::pools.size(), alloc, alloc + SgOmpSizesClause::pool_size);
   49705             : #endif
   49706             : 
   49707             : #if ROSE_ALLOC_MEMSET == 1
   49708             : #elif ROSE_ALLOC_MEMSET == 2
   49709             :         memset(alloc, 0x00, SgOmpSizesClause::pool_size * sizeof(SgOmpSizesClause));
   49710             : #elif ROSE_ALLOC_MEMSET == 3
   49711             :         memset(alloc, 0xAA, SgOmpSizesClause::pool_size * sizeof(SgOmpSizesClause));
   49712             : #endif
   49713           0 :         for (unsigned i=0; i < SgOmpSizesClause::pool_size-1; i++) {
   49714           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
   49715             :         }
   49716           0 :         alloc[SgOmpSizesClause::pool_size-1].p_freepointer = nullptr;
   49717             : 
   49718           0 :         SgOmpSizesClause::pools.push_back ( (unsigned char *) alloc );
   49719           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgOmpSizesClause::pool_size * sizeof(SgOmpSizesClause), V_SgOmpSizesClause ) );
   49720           0 :         SgOmpSizesClause::next_node = alloc;
   49721             :     }
   49722           0 :     ROSE_ASSERT(SgOmpSizesClause::next_node != nullptr);
   49723             : 
   49724           0 :     SgOmpSizesClause * object = SgOmpSizesClause::next_node;
   49725           0 :     SgOmpSizesClause::next_node = (SgOmpSizesClause*)(object->p_freepointer);
   49726             : 
   49727             : #if ROSE_ALLOC_TRACE == 2
   49728             :     printf("SgOmpSizesClause::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpSizesClause::next_node);
   49729             : #endif
   49730             : 
   49731           0 :     SgNode * fp = object->p_freepointer;
   49732             : #if ROSE_ALLOC_MEMSET == 1
   49733             : #elif ROSE_ALLOC_MEMSET == 2
   49734             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpSizesClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   49735             : #elif ROSE_ALLOC_MEMSET == 3
   49736             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgOmpSizesClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   49737             : #endif
   49738           0 :     object->p_freepointer = fp;
   49739             : 
   49740             : #if ROSE_ALLOC_TRACE == 2
   49741             : //    printf("SgOmpSizesClause::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpSizesClause::next_node);
   49742             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   49743             :     Rose::MemPool::snapshot(oss.str());
   49744             :     alloc_trace_cnt++;
   49745             : #endif
   49746             : 
   49747           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   49748             : 
   49749           0 :     ALLOC_MUTEX(SgOmpSizesClause, unlock);
   49750             : 
   49751             :     return object;
   49752             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   49753             : }
   49754             : 
   49755             : 
   49756             : 
   49757             : /*! \brief Delete operator for SgOmpSizesClause.
   49758             : 
   49759             :    This delete operator implements deallocation using memory pools to 
   49760             :    provide most efficent use of the heap within construction of large ASTs.
   49761             : 
   49762             : \internal The new and delete operators use the lower level C malloc/free
   49763             :    function calls for performance and to make sure that mixing of malloc/free
   49764             :    and new/delete by the used can be caught more readily.  This may change
   49765             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   49766             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   49767             :    deallocate memory allocated using ROSE_MALLOC.
   49768             : */
   49769           0 : void SgOmpSizesClause::operator delete(void *Pointer, size_t Size)
   49770             : {
   49771             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   49772             :      * or throwing an exception. */
   49773           0 :     ALLOC_MUTEX(SgOmpSizesClause, lock);
   49774             : 
   49775             : #if USE_CPP_NEW_DELETE_OPERATORS
   49776             :     ROSE_FREE(Pointer);
   49777             : #else
   49778             : #if ROSE_PEDANTIC_ALLOC
   49779             :     ROSE_ASSERT(Size == sizeof(SgOmpSizesClause));
   49780             : #else
   49781           0 :     if (Size != sizeof(SgOmpSizesClause)) {
   49782           0 :       ROSE_FREE(Pointer);
   49783           0 :       ALLOC_MUTEX(SgOmpSizesClause, unlock);
   49784             :       return;
   49785             :     }
   49786             : #endif
   49787             : 
   49788           0 :     SgOmpSizesClause * object = (SgOmpSizesClause*) Pointer;
   49789           0 :     ROSE_ASSERT(object != nullptr);
   49790             : 
   49791             : #if ROSE_ALLOC_TRACE == 2
   49792             : //  printf("SgOmpSizesClause::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpSizesClause::next_node);
   49793             :     printf("SgOmpSizesClause::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpSizesClause::next_node);
   49794             : #endif
   49795             : 
   49796             : #if ROSE_PEDANTIC_ALLOC
   49797             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   49798             : #endif
   49799             : 
   49800             : #if ROSE_ALLOC_MEMSET == 1
   49801             : #elif ROSE_ALLOC_MEMSET == 2
   49802             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpSizesClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   49803             : #elif ROSE_ALLOC_MEMSET == 3
   49804             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgOmpSizesClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   49805             : #endif
   49806             : 
   49807             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   49808             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   49809             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   49810             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   49811             : #else
   49812           0 :     object->p_freepointer = SgOmpSizesClause::next_node;
   49813           0 :     SgOmpSizesClause::next_node = object;
   49814             : #endif
   49815             : 
   49816             : #if ROSE_ALLOC_TRACE == 2
   49817             : //  printf("SgOmpSizesClause::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpSizesClause::next_node);
   49818             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   49819             :     Rose::MemPool::snapshot(oss.str());
   49820             :     alloc_trace_cnt++;
   49821             : #endif
   49822             : 
   49823             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   49824             : 
   49825           0 :     ALLOC_MUTEX(SgOmpSizesClause, unlock);
   49826             : }
   49827             : 
   49828             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   49829             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   49830             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   49831             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   49832             : // Also, note comment below from Robb (copied from the Common.code file).
   49833             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   49834             : //
   49835             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   49836             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   49837             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   49838             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   49839             : #if 0
   49840             : void SgOmpSizesClause::operator delete(void* pointer) { SgOmpSizesClause::operator delete (pointer, sizeof(SgOmpSizesClause)); };
   49841             : #endif
   49842             : /* #line 49843 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   49843             : 
   49844             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   49845             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   49846             : // obviously imply C++.
   49847             : 
   49848             : // This implements the support within ROSE for memory pools.  Memory pools
   49849             : // support the most condensed usage of memory within the construction of
   49850             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   49851             : // by a new operator written for each class.
   49852             : 
   49853             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   49854             :     // User wants multi-thread support and POSIX threads are available.
   49855             : #   include <pthread.h>
   49856             :     static pthread_mutex_t SgOmpInbranchClause_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   49857             : #else
   49858             :      // Cause synchronization to be skipped.
   49859             : #    ifndef ALLOC_MUTEX
   49860             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   49861             : #    endif
   49862             : #    ifdef _REENTRANT
   49863             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   49864             : #       ifdef _MSC_VER
   49865             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   49866             : #       else
   49867             : #           warning "POSIX threads are not available; synchronization being skipped"
   49868             : #       endif
   49869             : #    endif
   49870             : #endif
   49871             : 
   49872             : #ifndef ROSE_ALLOC_TRACE
   49873             : #  define ROSE_ALLOC_TRACE 0
   49874             : #endif
   49875             : 
   49876             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   49877             : #define ROSE_ALLOC_TRACE_CNT
   49878             : #include "memory-pool-snapshot.h"
   49879             : unsigned long alloc_trace_cnt = 0;
   49880             : #endif
   49881             : 
   49882             : #if ROSE_ALLOC_TRACE
   49883             : const unsigned SgOmpInbranchClause::pool_size = 5;
   49884             : #else
   49885             : const unsigned SgOmpInbranchClause::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   49886             : #endif
   49887             : 
   49888             : #ifndef ROSE_ALLOC_MEMSET
   49889             : #  define ROSE_ALLOC_MEMSET 0
   49890             : #endif
   49891             : 
   49892             : #ifndef ROSE_PEDANTIC_ALLOC
   49893             : #  define ROSE_PEDANTIC_ALLOC 0
   49894             : #endif
   49895             : 
   49896             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   49897             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   49898             : #endif
   49899             : 
   49900             : #if !defined(SGNODE__ALL_POOLS)
   49901             : #define SGNODE__ALL_POOLS
   49902             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   49903             : #endif
   49904             : 
   49905             : SgOmpInbranchClause* SgOmpInbranchClause::next_node = nullptr;
   49906             : std::vector<unsigned char*> SgOmpInbranchClause::pools;
   49907             : 
   49908             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   49909             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   49910             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   49911             : // around this macro definition rather than each use).
   49912             : #ifndef ALLOC_MUTEX
   49913             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   49914             :         do {                                                                     \
   49915             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   49916             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   49917             :                 abort();                                                         \
   49918             :             }                                                                    \
   49919             :         } while (0);
   49920             : #endif
   49921             : 
   49922             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   49923             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   49924             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   49925             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   49926             : 
   49927             : /*! \brief New operator for SgOmpInbranchClause.
   49928             : 
   49929             :    This new operator implements memory pools to provide most efficent 
   49930             :    use of the heap within construction of large ASTs.
   49931             : 
   49932             : \internal The new and delete operators use the lower level C malloc/free
   49933             :    function calls for performance and to make sure that mixing of malloc/free
   49934             :    and new/delete by the used can be caught more readily.  This may change
   49935             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   49936             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   49937             :    deallocate memory allocated using ROSE_MALLOC.
   49938             : */
   49939           0 : void *SgOmpInbranchClause::operator new ( size_t Size )
   49940             : {
   49941             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   49942             :      * returning or throwing an exception. */
   49943           0 :     ALLOC_MUTEX(SgOmpInbranchClause, lock);
   49944             : 
   49945             : #if ROSE_ALLOC_TRACE == 2
   49946             : //    printf("SgOmpInbranchClause::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgOmpInbranchClause::next_node);
   49947             : #endif
   49948             : 
   49949             : #if USE_CPP_NEW_DELETE_OPERATORS
   49950             :     void *mem = ROSE_MALLOC(Size);
   49951             :     ALLOC_MUTEX(SgOmpInbranchClause, unlock);
   49952             :     return mem;
   49953             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   49954             : #if ROSE_PEDANTIC_ALLOC
   49955             :     ROSE_ASSERT(Size == sizeof(SgOmpInbranchClause));
   49956             : #else
   49957           0 :     if (Size != sizeof(SgOmpInbranchClause)) {
   49958           0 :       void * object = ROSE_MALLOC(Size);
   49959           0 :       ALLOC_MUTEX(SgOmpInbranchClause, unlock);
   49960             :       return object;
   49961             :     }
   49962             : #endif
   49963             : 
   49964           0 :     if (SgOmpInbranchClause::next_node == nullptr) {
   49965           0 :         SgOmpInbranchClause * alloc = (SgOmpInbranchClause*) ROSE_MALLOC ( SgOmpInbranchClause::pool_size * sizeof(SgOmpInbranchClause) );
   49966           0 :         ROSE_ASSERT(alloc != nullptr);
   49967             : 
   49968             : #if ROSE_ALLOC_TRACE == 2
   49969             : //        printf("SgOmpInbranchClause::alloc\n  block[%zi] = [ %p , %p [\n", SgOmpInbranchClause::pools.size(), alloc, alloc + SgOmpInbranchClause::pool_size);
   49970             : #endif
   49971             : 
   49972             : #if ROSE_ALLOC_MEMSET == 1
   49973             : #elif ROSE_ALLOC_MEMSET == 2
   49974             :         memset(alloc, 0x00, SgOmpInbranchClause::pool_size * sizeof(SgOmpInbranchClause));
   49975             : #elif ROSE_ALLOC_MEMSET == 3
   49976             :         memset(alloc, 0xAA, SgOmpInbranchClause::pool_size * sizeof(SgOmpInbranchClause));
   49977             : #endif
   49978           0 :         for (unsigned i=0; i < SgOmpInbranchClause::pool_size-1; i++) {
   49979           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
   49980             :         }
   49981           0 :         alloc[SgOmpInbranchClause::pool_size-1].p_freepointer = nullptr;
   49982             : 
   49983           0 :         SgOmpInbranchClause::pools.push_back ( (unsigned char *) alloc );
   49984           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgOmpInbranchClause::pool_size * sizeof(SgOmpInbranchClause), V_SgOmpInbranchClause ) );
   49985           0 :         SgOmpInbranchClause::next_node = alloc;
   49986             :     }
   49987           0 :     ROSE_ASSERT(SgOmpInbranchClause::next_node != nullptr);
   49988             : 
   49989           0 :     SgOmpInbranchClause * object = SgOmpInbranchClause::next_node;
   49990           0 :     SgOmpInbranchClause::next_node = (SgOmpInbranchClause*)(object->p_freepointer);
   49991             : 
   49992             : #if ROSE_ALLOC_TRACE == 2
   49993             :     printf("SgOmpInbranchClause::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpInbranchClause::next_node);
   49994             : #endif
   49995             : 
   49996           0 :     SgNode * fp = object->p_freepointer;
   49997             : #if ROSE_ALLOC_MEMSET == 1
   49998             : #elif ROSE_ALLOC_MEMSET == 2
   49999             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpInbranchClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   50000             : #elif ROSE_ALLOC_MEMSET == 3
   50001             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgOmpInbranchClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   50002             : #endif
   50003           0 :     object->p_freepointer = fp;
   50004             : 
   50005             : #if ROSE_ALLOC_TRACE == 2
   50006             : //    printf("SgOmpInbranchClause::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpInbranchClause::next_node);
   50007             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   50008             :     Rose::MemPool::snapshot(oss.str());
   50009             :     alloc_trace_cnt++;
   50010             : #endif
   50011             : 
   50012           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   50013             : 
   50014           0 :     ALLOC_MUTEX(SgOmpInbranchClause, unlock);
   50015             : 
   50016             :     return object;
   50017             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   50018             : }
   50019             : 
   50020             : 
   50021             : 
   50022             : /*! \brief Delete operator for SgOmpInbranchClause.
   50023             : 
   50024             :    This delete operator implements deallocation using memory pools to 
   50025             :    provide most efficent use of the heap within construction of large ASTs.
   50026             : 
   50027             : \internal The new and delete operators use the lower level C malloc/free
   50028             :    function calls for performance and to make sure that mixing of malloc/free
   50029             :    and new/delete by the used can be caught more readily.  This may change
   50030             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   50031             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   50032             :    deallocate memory allocated using ROSE_MALLOC.
   50033             : */
   50034           0 : void SgOmpInbranchClause::operator delete(void *Pointer, size_t Size)
   50035             : {
   50036             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   50037             :      * or throwing an exception. */
   50038           0 :     ALLOC_MUTEX(SgOmpInbranchClause, lock);
   50039             : 
   50040             : #if USE_CPP_NEW_DELETE_OPERATORS
   50041             :     ROSE_FREE(Pointer);
   50042             : #else
   50043             : #if ROSE_PEDANTIC_ALLOC
   50044             :     ROSE_ASSERT(Size == sizeof(SgOmpInbranchClause));
   50045             : #else
   50046           0 :     if (Size != sizeof(SgOmpInbranchClause)) {
   50047           0 :       ROSE_FREE(Pointer);
   50048           0 :       ALLOC_MUTEX(SgOmpInbranchClause, unlock);
   50049             :       return;
   50050             :     }
   50051             : #endif
   50052             : 
   50053           0 :     SgOmpInbranchClause * object = (SgOmpInbranchClause*) Pointer;
   50054           0 :     ROSE_ASSERT(object != nullptr);
   50055             : 
   50056             : #if ROSE_ALLOC_TRACE == 2
   50057             : //  printf("SgOmpInbranchClause::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpInbranchClause::next_node);
   50058             :     printf("SgOmpInbranchClause::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpInbranchClause::next_node);
   50059             : #endif
   50060             : 
   50061             : #if ROSE_PEDANTIC_ALLOC
   50062             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   50063             : #endif
   50064             : 
   50065             : #if ROSE_ALLOC_MEMSET == 1
   50066             : #elif ROSE_ALLOC_MEMSET == 2
   50067             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpInbranchClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   50068             : #elif ROSE_ALLOC_MEMSET == 3
   50069             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgOmpInbranchClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   50070             : #endif
   50071             : 
   50072             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   50073             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   50074             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   50075             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   50076             : #else
   50077           0 :     object->p_freepointer = SgOmpInbranchClause::next_node;
   50078           0 :     SgOmpInbranchClause::next_node = object;
   50079             : #endif
   50080             : 
   50081             : #if ROSE_ALLOC_TRACE == 2
   50082             : //  printf("SgOmpInbranchClause::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpInbranchClause::next_node);
   50083             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   50084             :     Rose::MemPool::snapshot(oss.str());
   50085             :     alloc_trace_cnt++;
   50086             : #endif
   50087             : 
   50088             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   50089             : 
   50090           0 :     ALLOC_MUTEX(SgOmpInbranchClause, unlock);
   50091             : }
   50092             : 
   50093             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   50094             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   50095             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   50096             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   50097             : // Also, note comment below from Robb (copied from the Common.code file).
   50098             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   50099             : //
   50100             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   50101             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   50102             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   50103             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   50104             : #if 0
   50105             : void SgOmpInbranchClause::operator delete(void* pointer) { SgOmpInbranchClause::operator delete (pointer, sizeof(SgOmpInbranchClause)); };
   50106             : #endif
   50107             : /* #line 50108 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   50108             : 
   50109             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   50110             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   50111             : // obviously imply C++.
   50112             : 
   50113             : // This implements the support within ROSE for memory pools.  Memory pools
   50114             : // support the most condensed usage of memory within the construction of
   50115             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   50116             : // by a new operator written for each class.
   50117             : 
   50118             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   50119             :     // User wants multi-thread support and POSIX threads are available.
   50120             : #   include <pthread.h>
   50121             :     static pthread_mutex_t SgOmpNotinbranchClause_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   50122             : #else
   50123             :      // Cause synchronization to be skipped.
   50124             : #    ifndef ALLOC_MUTEX
   50125             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   50126             : #    endif
   50127             : #    ifdef _REENTRANT
   50128             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   50129             : #       ifdef _MSC_VER
   50130             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   50131             : #       else
   50132             : #           warning "POSIX threads are not available; synchronization being skipped"
   50133             : #       endif
   50134             : #    endif
   50135             : #endif
   50136             : 
   50137             : #ifndef ROSE_ALLOC_TRACE
   50138             : #  define ROSE_ALLOC_TRACE 0
   50139             : #endif
   50140             : 
   50141             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   50142             : #define ROSE_ALLOC_TRACE_CNT
   50143             : #include "memory-pool-snapshot.h"
   50144             : unsigned long alloc_trace_cnt = 0;
   50145             : #endif
   50146             : 
   50147             : #if ROSE_ALLOC_TRACE
   50148             : const unsigned SgOmpNotinbranchClause::pool_size = 5;
   50149             : #else
   50150             : const unsigned SgOmpNotinbranchClause::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   50151             : #endif
   50152             : 
   50153             : #ifndef ROSE_ALLOC_MEMSET
   50154             : #  define ROSE_ALLOC_MEMSET 0
   50155             : #endif
   50156             : 
   50157             : #ifndef ROSE_PEDANTIC_ALLOC
   50158             : #  define ROSE_PEDANTIC_ALLOC 0
   50159             : #endif
   50160             : 
   50161             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   50162             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   50163             : #endif
   50164             : 
   50165             : #if !defined(SGNODE__ALL_POOLS)
   50166             : #define SGNODE__ALL_POOLS
   50167             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   50168             : #endif
   50169             : 
   50170             : SgOmpNotinbranchClause* SgOmpNotinbranchClause::next_node = nullptr;
   50171             : std::vector<unsigned char*> SgOmpNotinbranchClause::pools;
   50172             : 
   50173             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   50174             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   50175             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   50176             : // around this macro definition rather than each use).
   50177             : #ifndef ALLOC_MUTEX
   50178             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   50179             :         do {                                                                     \
   50180             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   50181             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   50182             :                 abort();                                                         \
   50183             :             }                                                                    \
   50184             :         } while (0);
   50185             : #endif
   50186             : 
   50187             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   50188             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   50189             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   50190             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   50191             : 
   50192             : /*! \brief New operator for SgOmpNotinbranchClause.
   50193             : 
   50194             :    This new operator implements memory pools to provide most efficent 
   50195             :    use of the heap within construction of large ASTs.
   50196             : 
   50197             : \internal The new and delete operators use the lower level C malloc/free
   50198             :    function calls for performance and to make sure that mixing of malloc/free
   50199             :    and new/delete by the used can be caught more readily.  This may change
   50200             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   50201             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   50202             :    deallocate memory allocated using ROSE_MALLOC.
   50203             : */
   50204           0 : void *SgOmpNotinbranchClause::operator new ( size_t Size )
   50205             : {
   50206             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   50207             :      * returning or throwing an exception. */
   50208           0 :     ALLOC_MUTEX(SgOmpNotinbranchClause, lock);
   50209             : 
   50210             : #if ROSE_ALLOC_TRACE == 2
   50211             : //    printf("SgOmpNotinbranchClause::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgOmpNotinbranchClause::next_node);
   50212             : #endif
   50213             : 
   50214             : #if USE_CPP_NEW_DELETE_OPERATORS
   50215             :     void *mem = ROSE_MALLOC(Size);
   50216             :     ALLOC_MUTEX(SgOmpNotinbranchClause, unlock);
   50217             :     return mem;
   50218             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   50219             : #if ROSE_PEDANTIC_ALLOC
   50220             :     ROSE_ASSERT(Size == sizeof(SgOmpNotinbranchClause));
   50221             : #else
   50222           0 :     if (Size != sizeof(SgOmpNotinbranchClause)) {
   50223           0 :       void * object = ROSE_MALLOC(Size);
   50224           0 :       ALLOC_MUTEX(SgOmpNotinbranchClause, unlock);
   50225             :       return object;
   50226             :     }
   50227             : #endif
   50228             : 
   50229           0 :     if (SgOmpNotinbranchClause::next_node == nullptr) {
   50230           0 :         SgOmpNotinbranchClause * alloc = (SgOmpNotinbranchClause*) ROSE_MALLOC ( SgOmpNotinbranchClause::pool_size * sizeof(SgOmpNotinbranchClause) );
   50231           0 :         ROSE_ASSERT(alloc != nullptr);
   50232             : 
   50233             : #if ROSE_ALLOC_TRACE == 2
   50234             : //        printf("SgOmpNotinbranchClause::alloc\n  block[%zi] = [ %p , %p [\n", SgOmpNotinbranchClause::pools.size(), alloc, alloc + SgOmpNotinbranchClause::pool_size);
   50235             : #endif
   50236             : 
   50237             : #if ROSE_ALLOC_MEMSET == 1
   50238             : #elif ROSE_ALLOC_MEMSET == 2
   50239             :         memset(alloc, 0x00, SgOmpNotinbranchClause::pool_size * sizeof(SgOmpNotinbranchClause));
   50240             : #elif ROSE_ALLOC_MEMSET == 3
   50241             :         memset(alloc, 0xAA, SgOmpNotinbranchClause::pool_size * sizeof(SgOmpNotinbranchClause));
   50242             : #endif
   50243           0 :         for (unsigned i=0; i < SgOmpNotinbranchClause::pool_size-1; i++) {
   50244           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
   50245             :         }
   50246           0 :         alloc[SgOmpNotinbranchClause::pool_size-1].p_freepointer = nullptr;
   50247             : 
   50248           0 :         SgOmpNotinbranchClause::pools.push_back ( (unsigned char *) alloc );
   50249           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgOmpNotinbranchClause::pool_size * sizeof(SgOmpNotinbranchClause), V_SgOmpNotinbranchClause ) );
   50250           0 :         SgOmpNotinbranchClause::next_node = alloc;
   50251             :     }
   50252           0 :     ROSE_ASSERT(SgOmpNotinbranchClause::next_node != nullptr);
   50253             : 
   50254           0 :     SgOmpNotinbranchClause * object = SgOmpNotinbranchClause::next_node;
   50255           0 :     SgOmpNotinbranchClause::next_node = (SgOmpNotinbranchClause*)(object->p_freepointer);
   50256             : 
   50257             : #if ROSE_ALLOC_TRACE == 2
   50258             :     printf("SgOmpNotinbranchClause::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpNotinbranchClause::next_node);
   50259             : #endif
   50260             : 
   50261           0 :     SgNode * fp = object->p_freepointer;
   50262             : #if ROSE_ALLOC_MEMSET == 1
   50263             : #elif ROSE_ALLOC_MEMSET == 2
   50264             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpNotinbranchClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   50265             : #elif ROSE_ALLOC_MEMSET == 3
   50266             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgOmpNotinbranchClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   50267             : #endif
   50268           0 :     object->p_freepointer = fp;
   50269             : 
   50270             : #if ROSE_ALLOC_TRACE == 2
   50271             : //    printf("SgOmpNotinbranchClause::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpNotinbranchClause::next_node);
   50272             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   50273             :     Rose::MemPool::snapshot(oss.str());
   50274             :     alloc_trace_cnt++;
   50275             : #endif
   50276             : 
   50277           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   50278             : 
   50279           0 :     ALLOC_MUTEX(SgOmpNotinbranchClause, unlock);
   50280             : 
   50281             :     return object;
   50282             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   50283             : }
   50284             : 
   50285             : 
   50286             : 
   50287             : /*! \brief Delete operator for SgOmpNotinbranchClause.
   50288             : 
   50289             :    This delete operator implements deallocation using memory pools to 
   50290             :    provide most efficent use of the heap within construction of large ASTs.
   50291             : 
   50292             : \internal The new and delete operators use the lower level C malloc/free
   50293             :    function calls for performance and to make sure that mixing of malloc/free
   50294             :    and new/delete by the used can be caught more readily.  This may change
   50295             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   50296             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   50297             :    deallocate memory allocated using ROSE_MALLOC.
   50298             : */
   50299           0 : void SgOmpNotinbranchClause::operator delete(void *Pointer, size_t Size)
   50300             : {
   50301             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   50302             :      * or throwing an exception. */
   50303           0 :     ALLOC_MUTEX(SgOmpNotinbranchClause, lock);
   50304             : 
   50305             : #if USE_CPP_NEW_DELETE_OPERATORS
   50306             :     ROSE_FREE(Pointer);
   50307             : #else
   50308             : #if ROSE_PEDANTIC_ALLOC
   50309             :     ROSE_ASSERT(Size == sizeof(SgOmpNotinbranchClause));
   50310             : #else
   50311           0 :     if (Size != sizeof(SgOmpNotinbranchClause)) {
   50312           0 :       ROSE_FREE(Pointer);
   50313           0 :       ALLOC_MUTEX(SgOmpNotinbranchClause, unlock);
   50314             :       return;
   50315             :     }
   50316             : #endif
   50317             : 
   50318           0 :     SgOmpNotinbranchClause * object = (SgOmpNotinbranchClause*) Pointer;
   50319           0 :     ROSE_ASSERT(object != nullptr);
   50320             : 
   50321             : #if ROSE_ALLOC_TRACE == 2
   50322             : //  printf("SgOmpNotinbranchClause::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpNotinbranchClause::next_node);
   50323             :     printf("SgOmpNotinbranchClause::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpNotinbranchClause::next_node);
   50324             : #endif
   50325             : 
   50326             : #if ROSE_PEDANTIC_ALLOC
   50327             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   50328             : #endif
   50329             : 
   50330             : #if ROSE_ALLOC_MEMSET == 1
   50331             : #elif ROSE_ALLOC_MEMSET == 2
   50332             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpNotinbranchClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   50333             : #elif ROSE_ALLOC_MEMSET == 3
   50334             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgOmpNotinbranchClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   50335             : #endif
   50336             : 
   50337             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   50338             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   50339             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   50340             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   50341             : #else
   50342           0 :     object->p_freepointer = SgOmpNotinbranchClause::next_node;
   50343           0 :     SgOmpNotinbranchClause::next_node = object;
   50344             : #endif
   50345             : 
   50346             : #if ROSE_ALLOC_TRACE == 2
   50347             : //  printf("SgOmpNotinbranchClause::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpNotinbranchClause::next_node);
   50348             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   50349             :     Rose::MemPool::snapshot(oss.str());
   50350             :     alloc_trace_cnt++;
   50351             : #endif
   50352             : 
   50353             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   50354             : 
   50355           0 :     ALLOC_MUTEX(SgOmpNotinbranchClause, unlock);
   50356             : }
   50357             : 
   50358             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   50359             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   50360             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   50361             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   50362             : // Also, note comment below from Robb (copied from the Common.code file).
   50363             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   50364             : //
   50365             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   50366             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   50367             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   50368             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   50369             : #if 0
   50370             : void SgOmpNotinbranchClause::operator delete(void* pointer) { SgOmpNotinbranchClause::operator delete (pointer, sizeof(SgOmpNotinbranchClause)); };
   50371             : #endif
   50372             : /* #line 50373 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   50373             : 
   50374             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   50375             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   50376             : // obviously imply C++.
   50377             : 
   50378             : // This implements the support within ROSE for memory pools.  Memory pools
   50379             : // support the most condensed usage of memory within the construction of
   50380             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   50381             : // by a new operator written for each class.
   50382             : 
   50383             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   50384             :     // User wants multi-thread support and POSIX threads are available.
   50385             : #   include <pthread.h>
   50386             :     static pthread_mutex_t SgOmpDefaultmapClause_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   50387             : #else
   50388             :      // Cause synchronization to be skipped.
   50389             : #    ifndef ALLOC_MUTEX
   50390             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   50391             : #    endif
   50392             : #    ifdef _REENTRANT
   50393             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   50394             : #       ifdef _MSC_VER
   50395             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   50396             : #       else
   50397             : #           warning "POSIX threads are not available; synchronization being skipped"
   50398             : #       endif
   50399             : #    endif
   50400             : #endif
   50401             : 
   50402             : #ifndef ROSE_ALLOC_TRACE
   50403             : #  define ROSE_ALLOC_TRACE 0
   50404             : #endif
   50405             : 
   50406             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   50407             : #define ROSE_ALLOC_TRACE_CNT
   50408             : #include "memory-pool-snapshot.h"
   50409             : unsigned long alloc_trace_cnt = 0;
   50410             : #endif
   50411             : 
   50412             : #if ROSE_ALLOC_TRACE
   50413             : const unsigned SgOmpDefaultmapClause::pool_size = 5;
   50414             : #else
   50415             : const unsigned SgOmpDefaultmapClause::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   50416             : #endif
   50417             : 
   50418             : #ifndef ROSE_ALLOC_MEMSET
   50419             : #  define ROSE_ALLOC_MEMSET 0
   50420             : #endif
   50421             : 
   50422             : #ifndef ROSE_PEDANTIC_ALLOC
   50423             : #  define ROSE_PEDANTIC_ALLOC 0
   50424             : #endif
   50425             : 
   50426             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   50427             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   50428             : #endif
   50429             : 
   50430             : #if !defined(SGNODE__ALL_POOLS)
   50431             : #define SGNODE__ALL_POOLS
   50432             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   50433             : #endif
   50434             : 
   50435             : SgOmpDefaultmapClause* SgOmpDefaultmapClause::next_node = nullptr;
   50436             : std::vector<unsigned char*> SgOmpDefaultmapClause::pools;
   50437             : 
   50438             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   50439             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   50440             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   50441             : // around this macro definition rather than each use).
   50442             : #ifndef ALLOC_MUTEX
   50443             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   50444             :         do {                                                                     \
   50445             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   50446             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   50447             :                 abort();                                                         \
   50448             :             }                                                                    \
   50449             :         } while (0);
   50450             : #endif
   50451             : 
   50452             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   50453             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   50454             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   50455             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   50456             : 
   50457             : /*! \brief New operator for SgOmpDefaultmapClause.
   50458             : 
   50459             :    This new operator implements memory pools to provide most efficent 
   50460             :    use of the heap within construction of large ASTs.
   50461             : 
   50462             : \internal The new and delete operators use the lower level C malloc/free
   50463             :    function calls for performance and to make sure that mixing of malloc/free
   50464             :    and new/delete by the used can be caught more readily.  This may change
   50465             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   50466             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   50467             :    deallocate memory allocated using ROSE_MALLOC.
   50468             : */
   50469           1 : void *SgOmpDefaultmapClause::operator new ( size_t Size )
   50470             : {
   50471             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   50472             :      * returning or throwing an exception. */
   50473           1 :     ALLOC_MUTEX(SgOmpDefaultmapClause, lock);
   50474             : 
   50475             : #if ROSE_ALLOC_TRACE == 2
   50476             : //    printf("SgOmpDefaultmapClause::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgOmpDefaultmapClause::next_node);
   50477             : #endif
   50478             : 
   50479             : #if USE_CPP_NEW_DELETE_OPERATORS
   50480             :     void *mem = ROSE_MALLOC(Size);
   50481             :     ALLOC_MUTEX(SgOmpDefaultmapClause, unlock);
   50482             :     return mem;
   50483             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   50484             : #if ROSE_PEDANTIC_ALLOC
   50485             :     ROSE_ASSERT(Size == sizeof(SgOmpDefaultmapClause));
   50486             : #else
   50487           1 :     if (Size != sizeof(SgOmpDefaultmapClause)) {
   50488           0 :       void * object = ROSE_MALLOC(Size);
   50489           0 :       ALLOC_MUTEX(SgOmpDefaultmapClause, unlock);
   50490             :       return object;
   50491             :     }
   50492             : #endif
   50493             : 
   50494           1 :     if (SgOmpDefaultmapClause::next_node == nullptr) {
   50495           1 :         SgOmpDefaultmapClause * alloc = (SgOmpDefaultmapClause*) ROSE_MALLOC ( SgOmpDefaultmapClause::pool_size * sizeof(SgOmpDefaultmapClause) );
   50496           1 :         ROSE_ASSERT(alloc != nullptr);
   50497             : 
   50498             : #if ROSE_ALLOC_TRACE == 2
   50499             : //        printf("SgOmpDefaultmapClause::alloc\n  block[%zi] = [ %p , %p [\n", SgOmpDefaultmapClause::pools.size(), alloc, alloc + SgOmpDefaultmapClause::pool_size);
   50500             : #endif
   50501             : 
   50502             : #if ROSE_ALLOC_MEMSET == 1
   50503             : #elif ROSE_ALLOC_MEMSET == 2
   50504             :         memset(alloc, 0x00, SgOmpDefaultmapClause::pool_size * sizeof(SgOmpDefaultmapClause));
   50505             : #elif ROSE_ALLOC_MEMSET == 3
   50506             :         memset(alloc, 0xAA, SgOmpDefaultmapClause::pool_size * sizeof(SgOmpDefaultmapClause));
   50507             : #endif
   50508        2000 :         for (unsigned i=0; i < SgOmpDefaultmapClause::pool_size-1; i++) {
   50509        1999 :           alloc[i].p_freepointer = &(alloc[i+1]);
   50510             :         }
   50511           1 :         alloc[SgOmpDefaultmapClause::pool_size-1].p_freepointer = nullptr;
   50512             : 
   50513           1 :         SgOmpDefaultmapClause::pools.push_back ( (unsigned char *) alloc );
   50514           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgOmpDefaultmapClause::pool_size * sizeof(SgOmpDefaultmapClause), V_SgOmpDefaultmapClause ) );
   50515           1 :         SgOmpDefaultmapClause::next_node = alloc;
   50516             :     }
   50517           1 :     ROSE_ASSERT(SgOmpDefaultmapClause::next_node != nullptr);
   50518             : 
   50519           1 :     SgOmpDefaultmapClause * object = SgOmpDefaultmapClause::next_node;
   50520           1 :     SgOmpDefaultmapClause::next_node = (SgOmpDefaultmapClause*)(object->p_freepointer);
   50521             : 
   50522             : #if ROSE_ALLOC_TRACE == 2
   50523             :     printf("SgOmpDefaultmapClause::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpDefaultmapClause::next_node);
   50524             : #endif
   50525             : 
   50526           1 :     SgNode * fp = object->p_freepointer;
   50527             : #if ROSE_ALLOC_MEMSET == 1
   50528             : #elif ROSE_ALLOC_MEMSET == 2
   50529             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpDefaultmapClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   50530             : #elif ROSE_ALLOC_MEMSET == 3
   50531             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgOmpDefaultmapClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   50532             : #endif
   50533           1 :     object->p_freepointer = fp;
   50534             : 
   50535             : #if ROSE_ALLOC_TRACE == 2
   50536             : //    printf("SgOmpDefaultmapClause::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpDefaultmapClause::next_node);
   50537             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   50538             :     Rose::MemPool::snapshot(oss.str());
   50539             :     alloc_trace_cnt++;
   50540             : #endif
   50541             : 
   50542           1 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   50543             : 
   50544           1 :     ALLOC_MUTEX(SgOmpDefaultmapClause, unlock);
   50545             : 
   50546             :     return object;
   50547             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   50548             : }
   50549             : 
   50550             : 
   50551             : 
   50552             : /*! \brief Delete operator for SgOmpDefaultmapClause.
   50553             : 
   50554             :    This delete operator implements deallocation using memory pools to 
   50555             :    provide most efficent use of the heap within construction of large ASTs.
   50556             : 
   50557             : \internal The new and delete operators use the lower level C malloc/free
   50558             :    function calls for performance and to make sure that mixing of malloc/free
   50559             :    and new/delete by the used can be caught more readily.  This may change
   50560             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   50561             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   50562             :    deallocate memory allocated using ROSE_MALLOC.
   50563             : */
   50564           0 : void SgOmpDefaultmapClause::operator delete(void *Pointer, size_t Size)
   50565             : {
   50566             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   50567             :      * or throwing an exception. */
   50568           0 :     ALLOC_MUTEX(SgOmpDefaultmapClause, lock);
   50569             : 
   50570             : #if USE_CPP_NEW_DELETE_OPERATORS
   50571             :     ROSE_FREE(Pointer);
   50572             : #else
   50573             : #if ROSE_PEDANTIC_ALLOC
   50574             :     ROSE_ASSERT(Size == sizeof(SgOmpDefaultmapClause));
   50575             : #else
   50576           0 :     if (Size != sizeof(SgOmpDefaultmapClause)) {
   50577           0 :       ROSE_FREE(Pointer);
   50578           0 :       ALLOC_MUTEX(SgOmpDefaultmapClause, unlock);
   50579             :       return;
   50580             :     }
   50581             : #endif
   50582             : 
   50583           0 :     SgOmpDefaultmapClause * object = (SgOmpDefaultmapClause*) Pointer;
   50584           0 :     ROSE_ASSERT(object != nullptr);
   50585             : 
   50586             : #if ROSE_ALLOC_TRACE == 2
   50587             : //  printf("SgOmpDefaultmapClause::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpDefaultmapClause::next_node);
   50588             :     printf("SgOmpDefaultmapClause::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpDefaultmapClause::next_node);
   50589             : #endif
   50590             : 
   50591             : #if ROSE_PEDANTIC_ALLOC
   50592             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   50593             : #endif
   50594             : 
   50595             : #if ROSE_ALLOC_MEMSET == 1
   50596             : #elif ROSE_ALLOC_MEMSET == 2
   50597             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpDefaultmapClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   50598             : #elif ROSE_ALLOC_MEMSET == 3
   50599             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgOmpDefaultmapClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   50600             : #endif
   50601             : 
   50602             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   50603             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   50604             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   50605             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   50606             : #else
   50607           0 :     object->p_freepointer = SgOmpDefaultmapClause::next_node;
   50608           0 :     SgOmpDefaultmapClause::next_node = object;
   50609             : #endif
   50610             : 
   50611             : #if ROSE_ALLOC_TRACE == 2
   50612             : //  printf("SgOmpDefaultmapClause::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpDefaultmapClause::next_node);
   50613             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   50614             :     Rose::MemPool::snapshot(oss.str());
   50615             :     alloc_trace_cnt++;
   50616             : #endif
   50617             : 
   50618             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   50619             : 
   50620           0 :     ALLOC_MUTEX(SgOmpDefaultmapClause, unlock);
   50621             : }
   50622             : 
   50623             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   50624             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   50625             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   50626             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   50627             : // Also, note comment below from Robb (copied from the Common.code file).
   50628             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   50629             : //
   50630             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   50631             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   50632             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   50633             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   50634             : #if 0
   50635             : void SgOmpDefaultmapClause::operator delete(void* pointer) { SgOmpDefaultmapClause::operator delete (pointer, sizeof(SgOmpDefaultmapClause)); };
   50636             : #endif
   50637             : /* #line 50638 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   50638             : 
   50639             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   50640             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   50641             : // obviously imply C++.
   50642             : 
   50643             : // This implements the support within ROSE for memory pools.  Memory pools
   50644             : // support the most condensed usage of memory within the construction of
   50645             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   50646             : // by a new operator written for each class.
   50647             : 
   50648             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   50649             :     // User wants multi-thread support and POSIX threads are available.
   50650             : #   include <pthread.h>
   50651             :     static pthread_mutex_t SgOmpAtomicDefaultMemOrderClause_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   50652             : #else
   50653             :      // Cause synchronization to be skipped.
   50654             : #    ifndef ALLOC_MUTEX
   50655             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   50656             : #    endif
   50657             : #    ifdef _REENTRANT
   50658             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   50659             : #       ifdef _MSC_VER
   50660             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   50661             : #       else
   50662             : #           warning "POSIX threads are not available; synchronization being skipped"
   50663             : #       endif
   50664             : #    endif
   50665             : #endif
   50666             : 
   50667             : #ifndef ROSE_ALLOC_TRACE
   50668             : #  define ROSE_ALLOC_TRACE 0
   50669             : #endif
   50670             : 
   50671             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   50672             : #define ROSE_ALLOC_TRACE_CNT
   50673             : #include "memory-pool-snapshot.h"
   50674             : unsigned long alloc_trace_cnt = 0;
   50675             : #endif
   50676             : 
   50677             : #if ROSE_ALLOC_TRACE
   50678             : const unsigned SgOmpAtomicDefaultMemOrderClause::pool_size = 5;
   50679             : #else
   50680             : const unsigned SgOmpAtomicDefaultMemOrderClause::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   50681             : #endif
   50682             : 
   50683             : #ifndef ROSE_ALLOC_MEMSET
   50684             : #  define ROSE_ALLOC_MEMSET 0
   50685             : #endif
   50686             : 
   50687             : #ifndef ROSE_PEDANTIC_ALLOC
   50688             : #  define ROSE_PEDANTIC_ALLOC 0
   50689             : #endif
   50690             : 
   50691             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   50692             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   50693             : #endif
   50694             : 
   50695             : #if !defined(SGNODE__ALL_POOLS)
   50696             : #define SGNODE__ALL_POOLS
   50697             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   50698             : #endif
   50699             : 
   50700             : SgOmpAtomicDefaultMemOrderClause* SgOmpAtomicDefaultMemOrderClause::next_node = nullptr;
   50701             : std::vector<unsigned char*> SgOmpAtomicDefaultMemOrderClause::pools;
   50702             : 
   50703             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   50704             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   50705             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   50706             : // around this macro definition rather than each use).
   50707             : #ifndef ALLOC_MUTEX
   50708             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   50709             :         do {                                                                     \
   50710             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   50711             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   50712             :                 abort();                                                         \
   50713             :             }                                                                    \
   50714             :         } while (0);
   50715             : #endif
   50716             : 
   50717             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   50718             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   50719             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   50720             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   50721             : 
   50722             : /*! \brief New operator for SgOmpAtomicDefaultMemOrderClause.
   50723             : 
   50724             :    This new operator implements memory pools to provide most efficent 
   50725             :    use of the heap within construction of large ASTs.
   50726             : 
   50727             : \internal The new and delete operators use the lower level C malloc/free
   50728             :    function calls for performance and to make sure that mixing of malloc/free
   50729             :    and new/delete by the used can be caught more readily.  This may change
   50730             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   50731             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   50732             :    deallocate memory allocated using ROSE_MALLOC.
   50733             : */
   50734           1 : void *SgOmpAtomicDefaultMemOrderClause::operator new ( size_t Size )
   50735             : {
   50736             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   50737             :      * returning or throwing an exception. */
   50738           1 :     ALLOC_MUTEX(SgOmpAtomicDefaultMemOrderClause, lock);
   50739             : 
   50740             : #if ROSE_ALLOC_TRACE == 2
   50741             : //    printf("SgOmpAtomicDefaultMemOrderClause::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgOmpAtomicDefaultMemOrderClause::next_node);
   50742             : #endif
   50743             : 
   50744             : #if USE_CPP_NEW_DELETE_OPERATORS
   50745             :     void *mem = ROSE_MALLOC(Size);
   50746             :     ALLOC_MUTEX(SgOmpAtomicDefaultMemOrderClause, unlock);
   50747             :     return mem;
   50748             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   50749             : #if ROSE_PEDANTIC_ALLOC
   50750             :     ROSE_ASSERT(Size == sizeof(SgOmpAtomicDefaultMemOrderClause));
   50751             : #else
   50752           1 :     if (Size != sizeof(SgOmpAtomicDefaultMemOrderClause)) {
   50753           0 :       void * object = ROSE_MALLOC(Size);
   50754           0 :       ALLOC_MUTEX(SgOmpAtomicDefaultMemOrderClause, unlock);
   50755             :       return object;
   50756             :     }
   50757             : #endif
   50758             : 
   50759           1 :     if (SgOmpAtomicDefaultMemOrderClause::next_node == nullptr) {
   50760           1 :         SgOmpAtomicDefaultMemOrderClause * alloc = (SgOmpAtomicDefaultMemOrderClause*) ROSE_MALLOC ( SgOmpAtomicDefaultMemOrderClause::pool_size * sizeof(SgOmpAtomicDefaultMemOrderClause) );
   50761           1 :         ROSE_ASSERT(alloc != nullptr);
   50762             : 
   50763             : #if ROSE_ALLOC_TRACE == 2
   50764             : //        printf("SgOmpAtomicDefaultMemOrderClause::alloc\n  block[%zi] = [ %p , %p [\n", SgOmpAtomicDefaultMemOrderClause::pools.size(), alloc, alloc + SgOmpAtomicDefaultMemOrderClause::pool_size);
   50765             : #endif
   50766             : 
   50767             : #if ROSE_ALLOC_MEMSET == 1
   50768             : #elif ROSE_ALLOC_MEMSET == 2
   50769             :         memset(alloc, 0x00, SgOmpAtomicDefaultMemOrderClause::pool_size * sizeof(SgOmpAtomicDefaultMemOrderClause));
   50770             : #elif ROSE_ALLOC_MEMSET == 3
   50771             :         memset(alloc, 0xAA, SgOmpAtomicDefaultMemOrderClause::pool_size * sizeof(SgOmpAtomicDefaultMemOrderClause));
   50772             : #endif
   50773        2000 :         for (unsigned i=0; i < SgOmpAtomicDefaultMemOrderClause::pool_size-1; i++) {
   50774        1999 :           alloc[i].p_freepointer = &(alloc[i+1]);
   50775             :         }
   50776           1 :         alloc[SgOmpAtomicDefaultMemOrderClause::pool_size-1].p_freepointer = nullptr;
   50777             : 
   50778           1 :         SgOmpAtomicDefaultMemOrderClause::pools.push_back ( (unsigned char *) alloc );
   50779           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgOmpAtomicDefaultMemOrderClause::pool_size * sizeof(SgOmpAtomicDefaultMemOrderClause), V_SgOmpAtomicDefaultMemOrderClause ) );
   50780           1 :         SgOmpAtomicDefaultMemOrderClause::next_node = alloc;
   50781             :     }
   50782           1 :     ROSE_ASSERT(SgOmpAtomicDefaultMemOrderClause::next_node != nullptr);
   50783             : 
   50784           1 :     SgOmpAtomicDefaultMemOrderClause * object = SgOmpAtomicDefaultMemOrderClause::next_node;
   50785           1 :     SgOmpAtomicDefaultMemOrderClause::next_node = (SgOmpAtomicDefaultMemOrderClause*)(object->p_freepointer);
   50786             : 
   50787             : #if ROSE_ALLOC_TRACE == 2
   50788             :     printf("SgOmpAtomicDefaultMemOrderClause::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpAtomicDefaultMemOrderClause::next_node);
   50789             : #endif
   50790             : 
   50791           1 :     SgNode * fp = object->p_freepointer;
   50792             : #if ROSE_ALLOC_MEMSET == 1
   50793             : #elif ROSE_ALLOC_MEMSET == 2
   50794             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpAtomicDefaultMemOrderClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   50795             : #elif ROSE_ALLOC_MEMSET == 3
   50796             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgOmpAtomicDefaultMemOrderClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   50797             : #endif
   50798           1 :     object->p_freepointer = fp;
   50799             : 
   50800             : #if ROSE_ALLOC_TRACE == 2
   50801             : //    printf("SgOmpAtomicDefaultMemOrderClause::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpAtomicDefaultMemOrderClause::next_node);
   50802             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   50803             :     Rose::MemPool::snapshot(oss.str());
   50804             :     alloc_trace_cnt++;
   50805             : #endif
   50806             : 
   50807           1 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   50808             : 
   50809           1 :     ALLOC_MUTEX(SgOmpAtomicDefaultMemOrderClause, unlock);
   50810             : 
   50811             :     return object;
   50812             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   50813             : }
   50814             : 
   50815             : 
   50816             : 
   50817             : /*! \brief Delete operator for SgOmpAtomicDefaultMemOrderClause.
   50818             : 
   50819             :    This delete operator implements deallocation using memory pools to 
   50820             :    provide most efficent use of the heap within construction of large ASTs.
   50821             : 
   50822             : \internal The new and delete operators use the lower level C malloc/free
   50823             :    function calls for performance and to make sure that mixing of malloc/free
   50824             :    and new/delete by the used can be caught more readily.  This may change
   50825             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   50826             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   50827             :    deallocate memory allocated using ROSE_MALLOC.
   50828             : */
   50829           0 : void SgOmpAtomicDefaultMemOrderClause::operator delete(void *Pointer, size_t Size)
   50830             : {
   50831             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   50832             :      * or throwing an exception. */
   50833           0 :     ALLOC_MUTEX(SgOmpAtomicDefaultMemOrderClause, lock);
   50834             : 
   50835             : #if USE_CPP_NEW_DELETE_OPERATORS
   50836             :     ROSE_FREE(Pointer);
   50837             : #else
   50838             : #if ROSE_PEDANTIC_ALLOC
   50839             :     ROSE_ASSERT(Size == sizeof(SgOmpAtomicDefaultMemOrderClause));
   50840             : #else
   50841           0 :     if (Size != sizeof(SgOmpAtomicDefaultMemOrderClause)) {
   50842           0 :       ROSE_FREE(Pointer);
   50843           0 :       ALLOC_MUTEX(SgOmpAtomicDefaultMemOrderClause, unlock);
   50844             :       return;
   50845             :     }
   50846             : #endif
   50847             : 
   50848           0 :     SgOmpAtomicDefaultMemOrderClause * object = (SgOmpAtomicDefaultMemOrderClause*) Pointer;
   50849           0 :     ROSE_ASSERT(object != nullptr);
   50850             : 
   50851             : #if ROSE_ALLOC_TRACE == 2
   50852             : //  printf("SgOmpAtomicDefaultMemOrderClause::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpAtomicDefaultMemOrderClause::next_node);
   50853             :     printf("SgOmpAtomicDefaultMemOrderClause::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpAtomicDefaultMemOrderClause::next_node);
   50854             : #endif
   50855             : 
   50856             : #if ROSE_PEDANTIC_ALLOC
   50857             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   50858             : #endif
   50859             : 
   50860             : #if ROSE_ALLOC_MEMSET == 1
   50861             : #elif ROSE_ALLOC_MEMSET == 2
   50862             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpAtomicDefaultMemOrderClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   50863             : #elif ROSE_ALLOC_MEMSET == 3
   50864             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgOmpAtomicDefaultMemOrderClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   50865             : #endif
   50866             : 
   50867             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   50868             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   50869             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   50870             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   50871             : #else
   50872           0 :     object->p_freepointer = SgOmpAtomicDefaultMemOrderClause::next_node;
   50873           0 :     SgOmpAtomicDefaultMemOrderClause::next_node = object;
   50874             : #endif
   50875             : 
   50876             : #if ROSE_ALLOC_TRACE == 2
   50877             : //  printf("SgOmpAtomicDefaultMemOrderClause::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpAtomicDefaultMemOrderClause::next_node);
   50878             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   50879             :     Rose::MemPool::snapshot(oss.str());
   50880             :     alloc_trace_cnt++;
   50881             : #endif
   50882             : 
   50883             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   50884             : 
   50885           0 :     ALLOC_MUTEX(SgOmpAtomicDefaultMemOrderClause, unlock);
   50886             : }
   50887             : 
   50888             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   50889             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   50890             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   50891             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   50892             : // Also, note comment below from Robb (copied from the Common.code file).
   50893             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   50894             : //
   50895             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   50896             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   50897             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   50898             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   50899             : #if 0
   50900             : void SgOmpAtomicDefaultMemOrderClause::operator delete(void* pointer) { SgOmpAtomicDefaultMemOrderClause::operator delete (pointer, sizeof(SgOmpAtomicDefaultMemOrderClause)); };
   50901             : #endif
   50902             : /* #line 50903 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   50903             : 
   50904             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   50905             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   50906             : // obviously imply C++.
   50907             : 
   50908             : // This implements the support within ROSE for memory pools.  Memory pools
   50909             : // support the most condensed usage of memory within the construction of
   50910             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   50911             : // by a new operator written for each class.
   50912             : 
   50913             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   50914             :     // User wants multi-thread support and POSIX threads are available.
   50915             : #   include <pthread.h>
   50916             :     static pthread_mutex_t SgOmpExtImplementationDefinedRequirementClause_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   50917             : #else
   50918             :      // Cause synchronization to be skipped.
   50919             : #    ifndef ALLOC_MUTEX
   50920             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   50921             : #    endif
   50922             : #    ifdef _REENTRANT
   50923             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   50924             : #       ifdef _MSC_VER
   50925             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   50926             : #       else
   50927             : #           warning "POSIX threads are not available; synchronization being skipped"
   50928             : #       endif
   50929             : #    endif
   50930             : #endif
   50931             : 
   50932             : #ifndef ROSE_ALLOC_TRACE
   50933             : #  define ROSE_ALLOC_TRACE 0
   50934             : #endif
   50935             : 
   50936             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   50937             : #define ROSE_ALLOC_TRACE_CNT
   50938             : #include "memory-pool-snapshot.h"
   50939             : unsigned long alloc_trace_cnt = 0;
   50940             : #endif
   50941             : 
   50942             : #if ROSE_ALLOC_TRACE
   50943             : const unsigned SgOmpExtImplementationDefinedRequirementClause::pool_size = 5;
   50944             : #else
   50945             : const unsigned SgOmpExtImplementationDefinedRequirementClause::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   50946             : #endif
   50947             : 
   50948             : #ifndef ROSE_ALLOC_MEMSET
   50949             : #  define ROSE_ALLOC_MEMSET 0
   50950             : #endif
   50951             : 
   50952             : #ifndef ROSE_PEDANTIC_ALLOC
   50953             : #  define ROSE_PEDANTIC_ALLOC 0
   50954             : #endif
   50955             : 
   50956             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   50957             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   50958             : #endif
   50959             : 
   50960             : #if !defined(SGNODE__ALL_POOLS)
   50961             : #define SGNODE__ALL_POOLS
   50962             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   50963             : #endif
   50964             : 
   50965             : SgOmpExtImplementationDefinedRequirementClause* SgOmpExtImplementationDefinedRequirementClause::next_node = nullptr;
   50966             : std::vector<unsigned char*> SgOmpExtImplementationDefinedRequirementClause::pools;
   50967             : 
   50968             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   50969             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   50970             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   50971             : // around this macro definition rather than each use).
   50972             : #ifndef ALLOC_MUTEX
   50973             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   50974             :         do {                                                                     \
   50975             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   50976             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   50977             :                 abort();                                                         \
   50978             :             }                                                                    \
   50979             :         } while (0);
   50980             : #endif
   50981             : 
   50982             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   50983             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   50984             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   50985             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   50986             : 
   50987             : /*! \brief New operator for SgOmpExtImplementationDefinedRequirementClause.
   50988             : 
   50989             :    This new operator implements memory pools to provide most efficent 
   50990             :    use of the heap within construction of large ASTs.
   50991             : 
   50992             : \internal The new and delete operators use the lower level C malloc/free
   50993             :    function calls for performance and to make sure that mixing of malloc/free
   50994             :    and new/delete by the used can be caught more readily.  This may change
   50995             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   50996             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   50997             :    deallocate memory allocated using ROSE_MALLOC.
   50998             : */
   50999           2 : void *SgOmpExtImplementationDefinedRequirementClause::operator new ( size_t Size )
   51000             : {
   51001             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   51002             :      * returning or throwing an exception. */
   51003           2 :     ALLOC_MUTEX(SgOmpExtImplementationDefinedRequirementClause, lock);
   51004             : 
   51005             : #if ROSE_ALLOC_TRACE == 2
   51006             : //    printf("SgOmpExtImplementationDefinedRequirementClause::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgOmpExtImplementationDefinedRequirementClause::next_node);
   51007             : #endif
   51008             : 
   51009             : #if USE_CPP_NEW_DELETE_OPERATORS
   51010             :     void *mem = ROSE_MALLOC(Size);
   51011             :     ALLOC_MUTEX(SgOmpExtImplementationDefinedRequirementClause, unlock);
   51012             :     return mem;
   51013             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   51014             : #if ROSE_PEDANTIC_ALLOC
   51015             :     ROSE_ASSERT(Size == sizeof(SgOmpExtImplementationDefinedRequirementClause));
   51016             : #else
   51017           2 :     if (Size != sizeof(SgOmpExtImplementationDefinedRequirementClause)) {
   51018           0 :       void * object = ROSE_MALLOC(Size);
   51019           0 :       ALLOC_MUTEX(SgOmpExtImplementationDefinedRequirementClause, unlock);
   51020             :       return object;
   51021             :     }
   51022             : #endif
   51023             : 
   51024           2 :     if (SgOmpExtImplementationDefinedRequirementClause::next_node == nullptr) {
   51025           1 :         SgOmpExtImplementationDefinedRequirementClause * alloc = (SgOmpExtImplementationDefinedRequirementClause*) ROSE_MALLOC ( SgOmpExtImplementationDefinedRequirementClause::pool_size * sizeof(SgOmpExtImplementationDefinedRequirementClause) );
   51026           1 :         ROSE_ASSERT(alloc != nullptr);
   51027             : 
   51028             : #if ROSE_ALLOC_TRACE == 2
   51029             : //        printf("SgOmpExtImplementationDefinedRequirementClause::alloc\n  block[%zi] = [ %p , %p [\n", SgOmpExtImplementationDefinedRequirementClause::pools.size(), alloc, alloc + SgOmpExtImplementationDefinedRequirementClause::pool_size);
   51030             : #endif
   51031             : 
   51032             : #if ROSE_ALLOC_MEMSET == 1
   51033             : #elif ROSE_ALLOC_MEMSET == 2
   51034             :         memset(alloc, 0x00, SgOmpExtImplementationDefinedRequirementClause::pool_size * sizeof(SgOmpExtImplementationDefinedRequirementClause));
   51035             : #elif ROSE_ALLOC_MEMSET == 3
   51036             :         memset(alloc, 0xAA, SgOmpExtImplementationDefinedRequirementClause::pool_size * sizeof(SgOmpExtImplementationDefinedRequirementClause));
   51037             : #endif
   51038        2000 :         for (unsigned i=0; i < SgOmpExtImplementationDefinedRequirementClause::pool_size-1; i++) {
   51039        1999 :           alloc[i].p_freepointer = &(alloc[i+1]);
   51040             :         }
   51041           1 :         alloc[SgOmpExtImplementationDefinedRequirementClause::pool_size-1].p_freepointer = nullptr;
   51042             : 
   51043           1 :         SgOmpExtImplementationDefinedRequirementClause::pools.push_back ( (unsigned char *) alloc );
   51044           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgOmpExtImplementationDefinedRequirementClause::pool_size * sizeof(SgOmpExtImplementationDefinedRequirementClause), V_SgOmpExtImplementationDefinedRequirementClause ) );
   51045           1 :         SgOmpExtImplementationDefinedRequirementClause::next_node = alloc;
   51046             :     }
   51047           2 :     ROSE_ASSERT(SgOmpExtImplementationDefinedRequirementClause::next_node != nullptr);
   51048             : 
   51049           2 :     SgOmpExtImplementationDefinedRequirementClause * object = SgOmpExtImplementationDefinedRequirementClause::next_node;
   51050           2 :     SgOmpExtImplementationDefinedRequirementClause::next_node = (SgOmpExtImplementationDefinedRequirementClause*)(object->p_freepointer);
   51051             : 
   51052             : #if ROSE_ALLOC_TRACE == 2
   51053             :     printf("SgOmpExtImplementationDefinedRequirementClause::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpExtImplementationDefinedRequirementClause::next_node);
   51054             : #endif
   51055             : 
   51056           2 :     SgNode * fp = object->p_freepointer;
   51057             : #if ROSE_ALLOC_MEMSET == 1
   51058             : #elif ROSE_ALLOC_MEMSET == 2
   51059             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpExtImplementationDefinedRequirementClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   51060             : #elif ROSE_ALLOC_MEMSET == 3
   51061             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgOmpExtImplementationDefinedRequirementClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   51062             : #endif
   51063           2 :     object->p_freepointer = fp;
   51064             : 
   51065             : #if ROSE_ALLOC_TRACE == 2
   51066             : //    printf("SgOmpExtImplementationDefinedRequirementClause::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpExtImplementationDefinedRequirementClause::next_node);
   51067             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   51068             :     Rose::MemPool::snapshot(oss.str());
   51069             :     alloc_trace_cnt++;
   51070             : #endif
   51071             : 
   51072           2 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   51073             : 
   51074           2 :     ALLOC_MUTEX(SgOmpExtImplementationDefinedRequirementClause, unlock);
   51075             : 
   51076             :     return object;
   51077             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   51078             : }
   51079             : 
   51080             : 
   51081             : 
   51082             : /*! \brief Delete operator for SgOmpExtImplementationDefinedRequirementClause.
   51083             : 
   51084             :    This delete operator implements deallocation using memory pools to 
   51085             :    provide most efficent use of the heap within construction of large ASTs.
   51086             : 
   51087             : \internal The new and delete operators use the lower level C malloc/free
   51088             :    function calls for performance and to make sure that mixing of malloc/free
   51089             :    and new/delete by the used can be caught more readily.  This may change
   51090             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   51091             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   51092             :    deallocate memory allocated using ROSE_MALLOC.
   51093             : */
   51094           0 : void SgOmpExtImplementationDefinedRequirementClause::operator delete(void *Pointer, size_t Size)
   51095             : {
   51096             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   51097             :      * or throwing an exception. */
   51098           0 :     ALLOC_MUTEX(SgOmpExtImplementationDefinedRequirementClause, lock);
   51099             : 
   51100             : #if USE_CPP_NEW_DELETE_OPERATORS
   51101             :     ROSE_FREE(Pointer);
   51102             : #else
   51103             : #if ROSE_PEDANTIC_ALLOC
   51104             :     ROSE_ASSERT(Size == sizeof(SgOmpExtImplementationDefinedRequirementClause));
   51105             : #else
   51106           0 :     if (Size != sizeof(SgOmpExtImplementationDefinedRequirementClause)) {
   51107           0 :       ROSE_FREE(Pointer);
   51108           0 :       ALLOC_MUTEX(SgOmpExtImplementationDefinedRequirementClause, unlock);
   51109             :       return;
   51110             :     }
   51111             : #endif
   51112             : 
   51113           0 :     SgOmpExtImplementationDefinedRequirementClause * object = (SgOmpExtImplementationDefinedRequirementClause*) Pointer;
   51114           0 :     ROSE_ASSERT(object != nullptr);
   51115             : 
   51116             : #if ROSE_ALLOC_TRACE == 2
   51117             : //  printf("SgOmpExtImplementationDefinedRequirementClause::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpExtImplementationDefinedRequirementClause::next_node);
   51118             :     printf("SgOmpExtImplementationDefinedRequirementClause::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpExtImplementationDefinedRequirementClause::next_node);
   51119             : #endif
   51120             : 
   51121             : #if ROSE_PEDANTIC_ALLOC
   51122             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   51123             : #endif
   51124             : 
   51125             : #if ROSE_ALLOC_MEMSET == 1
   51126             : #elif ROSE_ALLOC_MEMSET == 2
   51127             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpExtImplementationDefinedRequirementClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   51128             : #elif ROSE_ALLOC_MEMSET == 3
   51129             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgOmpExtImplementationDefinedRequirementClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   51130             : #endif
   51131             : 
   51132             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   51133             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   51134             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   51135             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   51136             : #else
   51137           0 :     object->p_freepointer = SgOmpExtImplementationDefinedRequirementClause::next_node;
   51138           0 :     SgOmpExtImplementationDefinedRequirementClause::next_node = object;
   51139             : #endif
   51140             : 
   51141             : #if ROSE_ALLOC_TRACE == 2
   51142             : //  printf("SgOmpExtImplementationDefinedRequirementClause::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpExtImplementationDefinedRequirementClause::next_node);
   51143             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   51144             :     Rose::MemPool::snapshot(oss.str());
   51145             :     alloc_trace_cnt++;
   51146             : #endif
   51147             : 
   51148             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   51149             : 
   51150           0 :     ALLOC_MUTEX(SgOmpExtImplementationDefinedRequirementClause, unlock);
   51151             : }
   51152             : 
   51153             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   51154             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   51155             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   51156             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   51157             : // Also, note comment below from Robb (copied from the Common.code file).
   51158             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   51159             : //
   51160             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   51161             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   51162             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   51163             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   51164             : #if 0
   51165             : void SgOmpExtImplementationDefinedRequirementClause::operator delete(void* pointer) { SgOmpExtImplementationDefinedRequirementClause::operator delete (pointer, sizeof(SgOmpExtImplementationDefinedRequirementClause)); };
   51166             : #endif
   51167             : /* #line 51168 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   51168             : 
   51169             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   51170             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   51171             : // obviously imply C++.
   51172             : 
   51173             : // This implements the support within ROSE for memory pools.  Memory pools
   51174             : // support the most condensed usage of memory within the construction of
   51175             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   51176             : // by a new operator written for each class.
   51177             : 
   51178             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   51179             :     // User wants multi-thread support and POSIX threads are available.
   51180             : #   include <pthread.h>
   51181             :     static pthread_mutex_t SgOmpUsesAllocatorsDefination_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   51182             : #else
   51183             :      // Cause synchronization to be skipped.
   51184             : #    ifndef ALLOC_MUTEX
   51185             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   51186             : #    endif
   51187             : #    ifdef _REENTRANT
   51188             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   51189             : #       ifdef _MSC_VER
   51190             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   51191             : #       else
   51192             : #           warning "POSIX threads are not available; synchronization being skipped"
   51193             : #       endif
   51194             : #    endif
   51195             : #endif
   51196             : 
   51197             : #ifndef ROSE_ALLOC_TRACE
   51198             : #  define ROSE_ALLOC_TRACE 0
   51199             : #endif
   51200             : 
   51201             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   51202             : #define ROSE_ALLOC_TRACE_CNT
   51203             : #include "memory-pool-snapshot.h"
   51204             : unsigned long alloc_trace_cnt = 0;
   51205             : #endif
   51206             : 
   51207             : #if ROSE_ALLOC_TRACE
   51208             : const unsigned SgOmpUsesAllocatorsDefination::pool_size = 5;
   51209             : #else
   51210             : const unsigned SgOmpUsesAllocatorsDefination::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   51211             : #endif
   51212             : 
   51213             : #ifndef ROSE_ALLOC_MEMSET
   51214             : #  define ROSE_ALLOC_MEMSET 0
   51215             : #endif
   51216             : 
   51217             : #ifndef ROSE_PEDANTIC_ALLOC
   51218             : #  define ROSE_PEDANTIC_ALLOC 0
   51219             : #endif
   51220             : 
   51221             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   51222             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   51223             : #endif
   51224             : 
   51225             : #if !defined(SGNODE__ALL_POOLS)
   51226             : #define SGNODE__ALL_POOLS
   51227             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   51228             : #endif
   51229             : 
   51230             : SgOmpUsesAllocatorsDefination* SgOmpUsesAllocatorsDefination::next_node = nullptr;
   51231             : std::vector<unsigned char*> SgOmpUsesAllocatorsDefination::pools;
   51232             : 
   51233             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   51234             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   51235             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   51236             : // around this macro definition rather than each use).
   51237             : #ifndef ALLOC_MUTEX
   51238             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   51239             :         do {                                                                     \
   51240             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   51241             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   51242             :                 abort();                                                         \
   51243             :             }                                                                    \
   51244             :         } while (0);
   51245             : #endif
   51246             : 
   51247             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   51248             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   51249             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   51250             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   51251             : 
   51252             : /*! \brief New operator for SgOmpUsesAllocatorsDefination.
   51253             : 
   51254             :    This new operator implements memory pools to provide most efficent 
   51255             :    use of the heap within construction of large ASTs.
   51256             : 
   51257             : \internal The new and delete operators use the lower level C malloc/free
   51258             :    function calls for performance and to make sure that mixing of malloc/free
   51259             :    and new/delete by the used can be caught more readily.  This may change
   51260             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   51261             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   51262             :    deallocate memory allocated using ROSE_MALLOC.
   51263             : */
   51264           2 : void *SgOmpUsesAllocatorsDefination::operator new ( size_t Size )
   51265             : {
   51266             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   51267             :      * returning or throwing an exception. */
   51268           2 :     ALLOC_MUTEX(SgOmpUsesAllocatorsDefination, lock);
   51269             : 
   51270             : #if ROSE_ALLOC_TRACE == 2
   51271             : //    printf("SgOmpUsesAllocatorsDefination::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgOmpUsesAllocatorsDefination::next_node);
   51272             : #endif
   51273             : 
   51274             : #if USE_CPP_NEW_DELETE_OPERATORS
   51275             :     void *mem = ROSE_MALLOC(Size);
   51276             :     ALLOC_MUTEX(SgOmpUsesAllocatorsDefination, unlock);
   51277             :     return mem;
   51278             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   51279             : #if ROSE_PEDANTIC_ALLOC
   51280             :     ROSE_ASSERT(Size == sizeof(SgOmpUsesAllocatorsDefination));
   51281             : #else
   51282           2 :     if (Size != sizeof(SgOmpUsesAllocatorsDefination)) {
   51283           0 :       void * object = ROSE_MALLOC(Size);
   51284           0 :       ALLOC_MUTEX(SgOmpUsesAllocatorsDefination, unlock);
   51285             :       return object;
   51286             :     }
   51287             : #endif
   51288             : 
   51289           2 :     if (SgOmpUsesAllocatorsDefination::next_node == nullptr) {
   51290           1 :         SgOmpUsesAllocatorsDefination * alloc = (SgOmpUsesAllocatorsDefination*) ROSE_MALLOC ( SgOmpUsesAllocatorsDefination::pool_size * sizeof(SgOmpUsesAllocatorsDefination) );
   51291           1 :         ROSE_ASSERT(alloc != nullptr);
   51292             : 
   51293             : #if ROSE_ALLOC_TRACE == 2
   51294             : //        printf("SgOmpUsesAllocatorsDefination::alloc\n  block[%zi] = [ %p , %p [\n", SgOmpUsesAllocatorsDefination::pools.size(), alloc, alloc + SgOmpUsesAllocatorsDefination::pool_size);
   51295             : #endif
   51296             : 
   51297             : #if ROSE_ALLOC_MEMSET == 1
   51298             : #elif ROSE_ALLOC_MEMSET == 2
   51299             :         memset(alloc, 0x00, SgOmpUsesAllocatorsDefination::pool_size * sizeof(SgOmpUsesAllocatorsDefination));
   51300             : #elif ROSE_ALLOC_MEMSET == 3
   51301             :         memset(alloc, 0xAA, SgOmpUsesAllocatorsDefination::pool_size * sizeof(SgOmpUsesAllocatorsDefination));
   51302             : #endif
   51303        2000 :         for (unsigned i=0; i < SgOmpUsesAllocatorsDefination::pool_size-1; i++) {
   51304        1999 :           alloc[i].p_freepointer = &(alloc[i+1]);
   51305             :         }
   51306           1 :         alloc[SgOmpUsesAllocatorsDefination::pool_size-1].p_freepointer = nullptr;
   51307             : 
   51308           1 :         SgOmpUsesAllocatorsDefination::pools.push_back ( (unsigned char *) alloc );
   51309           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgOmpUsesAllocatorsDefination::pool_size * sizeof(SgOmpUsesAllocatorsDefination), V_SgOmpUsesAllocatorsDefination ) );
   51310           1 :         SgOmpUsesAllocatorsDefination::next_node = alloc;
   51311             :     }
   51312           2 :     ROSE_ASSERT(SgOmpUsesAllocatorsDefination::next_node != nullptr);
   51313             : 
   51314           2 :     SgOmpUsesAllocatorsDefination * object = SgOmpUsesAllocatorsDefination::next_node;
   51315           2 :     SgOmpUsesAllocatorsDefination::next_node = (SgOmpUsesAllocatorsDefination*)(object->p_freepointer);
   51316             : 
   51317             : #if ROSE_ALLOC_TRACE == 2
   51318             :     printf("SgOmpUsesAllocatorsDefination::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpUsesAllocatorsDefination::next_node);
   51319             : #endif
   51320             : 
   51321           2 :     SgNode * fp = object->p_freepointer;
   51322             : #if ROSE_ALLOC_MEMSET == 1
   51323             : #elif ROSE_ALLOC_MEMSET == 2
   51324             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpUsesAllocatorsDefination) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   51325             : #elif ROSE_ALLOC_MEMSET == 3
   51326             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgOmpUsesAllocatorsDefination) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   51327             : #endif
   51328           2 :     object->p_freepointer = fp;
   51329             : 
   51330             : #if ROSE_ALLOC_TRACE == 2
   51331             : //    printf("SgOmpUsesAllocatorsDefination::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpUsesAllocatorsDefination::next_node);
   51332             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   51333             :     Rose::MemPool::snapshot(oss.str());
   51334             :     alloc_trace_cnt++;
   51335             : #endif
   51336             : 
   51337           2 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   51338             : 
   51339           2 :     ALLOC_MUTEX(SgOmpUsesAllocatorsDefination, unlock);
   51340             : 
   51341             :     return object;
   51342             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   51343             : }
   51344             : 
   51345             : 
   51346             : 
   51347             : /*! \brief Delete operator for SgOmpUsesAllocatorsDefination.
   51348             : 
   51349             :    This delete operator implements deallocation using memory pools to 
   51350             :    provide most efficent use of the heap within construction of large ASTs.
   51351             : 
   51352             : \internal The new and delete operators use the lower level C malloc/free
   51353             :    function calls for performance and to make sure that mixing of malloc/free
   51354             :    and new/delete by the used can be caught more readily.  This may change
   51355             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   51356             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   51357             :    deallocate memory allocated using ROSE_MALLOC.
   51358             : */
   51359           0 : void SgOmpUsesAllocatorsDefination::operator delete(void *Pointer, size_t Size)
   51360             : {
   51361             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   51362             :      * or throwing an exception. */
   51363           0 :     ALLOC_MUTEX(SgOmpUsesAllocatorsDefination, lock);
   51364             : 
   51365             : #if USE_CPP_NEW_DELETE_OPERATORS
   51366             :     ROSE_FREE(Pointer);
   51367             : #else
   51368             : #if ROSE_PEDANTIC_ALLOC
   51369             :     ROSE_ASSERT(Size == sizeof(SgOmpUsesAllocatorsDefination));
   51370             : #else
   51371           0 :     if (Size != sizeof(SgOmpUsesAllocatorsDefination)) {
   51372           0 :       ROSE_FREE(Pointer);
   51373           0 :       ALLOC_MUTEX(SgOmpUsesAllocatorsDefination, unlock);
   51374             :       return;
   51375             :     }
   51376             : #endif
   51377             : 
   51378           0 :     SgOmpUsesAllocatorsDefination * object = (SgOmpUsesAllocatorsDefination*) Pointer;
   51379           0 :     ROSE_ASSERT(object != nullptr);
   51380             : 
   51381             : #if ROSE_ALLOC_TRACE == 2
   51382             : //  printf("SgOmpUsesAllocatorsDefination::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpUsesAllocatorsDefination::next_node);
   51383             :     printf("SgOmpUsesAllocatorsDefination::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpUsesAllocatorsDefination::next_node);
   51384             : #endif
   51385             : 
   51386             : #if ROSE_PEDANTIC_ALLOC
   51387             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   51388             : #endif
   51389             : 
   51390             : #if ROSE_ALLOC_MEMSET == 1
   51391             : #elif ROSE_ALLOC_MEMSET == 2
   51392             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpUsesAllocatorsDefination) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   51393             : #elif ROSE_ALLOC_MEMSET == 3
   51394             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgOmpUsesAllocatorsDefination) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   51395             : #endif
   51396             : 
   51397             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   51398             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   51399             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   51400             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   51401             : #else
   51402           0 :     object->p_freepointer = SgOmpUsesAllocatorsDefination::next_node;
   51403           0 :     SgOmpUsesAllocatorsDefination::next_node = object;
   51404             : #endif
   51405             : 
   51406             : #if ROSE_ALLOC_TRACE == 2
   51407             : //  printf("SgOmpUsesAllocatorsDefination::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpUsesAllocatorsDefination::next_node);
   51408             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   51409             :     Rose::MemPool::snapshot(oss.str());
   51410             :     alloc_trace_cnt++;
   51411             : #endif
   51412             : 
   51413             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   51414             : 
   51415           0 :     ALLOC_MUTEX(SgOmpUsesAllocatorsDefination, unlock);
   51416             : }
   51417             : 
   51418             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   51419             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   51420             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   51421             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   51422             : // Also, note comment below from Robb (copied from the Common.code file).
   51423             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   51424             : //
   51425             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   51426             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   51427             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   51428             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   51429             : #if 0
   51430             : void SgOmpUsesAllocatorsDefination::operator delete(void* pointer) { SgOmpUsesAllocatorsDefination::operator delete (pointer, sizeof(SgOmpUsesAllocatorsDefination)); };
   51431             : #endif
   51432             : /* #line 51433 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   51433             : 
   51434             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   51435             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   51436             : // obviously imply C++.
   51437             : 
   51438             : // This implements the support within ROSE for memory pools.  Memory pools
   51439             : // support the most condensed usage of memory within the construction of
   51440             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   51441             : // by a new operator written for each class.
   51442             : 
   51443             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   51444             :     // User wants multi-thread support and POSIX threads are available.
   51445             : #   include <pthread.h>
   51446             :     static pthread_mutex_t SgOmpVariablesClause_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   51447             : #else
   51448             :      // Cause synchronization to be skipped.
   51449             : #    ifndef ALLOC_MUTEX
   51450             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   51451             : #    endif
   51452             : #    ifdef _REENTRANT
   51453             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   51454             : #       ifdef _MSC_VER
   51455             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   51456             : #       else
   51457             : #           warning "POSIX threads are not available; synchronization being skipped"
   51458             : #       endif
   51459             : #    endif
   51460             : #endif
   51461             : 
   51462             : #ifndef ROSE_ALLOC_TRACE
   51463             : #  define ROSE_ALLOC_TRACE 0
   51464             : #endif
   51465             : 
   51466             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   51467             : #define ROSE_ALLOC_TRACE_CNT
   51468             : #include "memory-pool-snapshot.h"
   51469             : unsigned long alloc_trace_cnt = 0;
   51470             : #endif
   51471             : 
   51472             : #if ROSE_ALLOC_TRACE
   51473             : const unsigned SgOmpVariablesClause::pool_size = 5;
   51474             : #else
   51475             : const unsigned SgOmpVariablesClause::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   51476             : #endif
   51477             : 
   51478             : #ifndef ROSE_ALLOC_MEMSET
   51479             : #  define ROSE_ALLOC_MEMSET 0
   51480             : #endif
   51481             : 
   51482             : #ifndef ROSE_PEDANTIC_ALLOC
   51483             : #  define ROSE_PEDANTIC_ALLOC 0
   51484             : #endif
   51485             : 
   51486             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   51487             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   51488             : #endif
   51489             : 
   51490             : #if !defined(SGNODE__ALL_POOLS)
   51491             : #define SGNODE__ALL_POOLS
   51492             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   51493             : #endif
   51494             : 
   51495             : SgOmpVariablesClause* SgOmpVariablesClause::next_node = nullptr;
   51496             : std::vector<unsigned char*> SgOmpVariablesClause::pools;
   51497             : 
   51498             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   51499             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   51500             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   51501             : // around this macro definition rather than each use).
   51502             : #ifndef ALLOC_MUTEX
   51503             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   51504             :         do {                                                                     \
   51505             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   51506             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   51507             :                 abort();                                                         \
   51508             :             }                                                                    \
   51509             :         } while (0);
   51510             : #endif
   51511             : 
   51512             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   51513             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   51514             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   51515             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   51516             : 
   51517             : /*! \brief New operator for SgOmpVariablesClause.
   51518             : 
   51519             :    This new operator implements memory pools to provide most efficent 
   51520             :    use of the heap within construction of large ASTs.
   51521             : 
   51522             : \internal The new and delete operators use the lower level C malloc/free
   51523             :    function calls for performance and to make sure that mixing of malloc/free
   51524             :    and new/delete by the used can be caught more readily.  This may change
   51525             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   51526             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   51527             :    deallocate memory allocated using ROSE_MALLOC.
   51528             : */
   51529           0 : void *SgOmpVariablesClause::operator new ( size_t Size )
   51530             : {
   51531             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   51532             :      * returning or throwing an exception. */
   51533           0 :     ALLOC_MUTEX(SgOmpVariablesClause, lock);
   51534             : 
   51535             : #if ROSE_ALLOC_TRACE == 2
   51536             : //    printf("SgOmpVariablesClause::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgOmpVariablesClause::next_node);
   51537             : #endif
   51538             : 
   51539             : #if USE_CPP_NEW_DELETE_OPERATORS
   51540             :     void *mem = ROSE_MALLOC(Size);
   51541             :     ALLOC_MUTEX(SgOmpVariablesClause, unlock);
   51542             :     return mem;
   51543             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   51544             : #if ROSE_PEDANTIC_ALLOC
   51545             :     ROSE_ASSERT(Size == sizeof(SgOmpVariablesClause));
   51546             : #else
   51547           0 :     if (Size != sizeof(SgOmpVariablesClause)) {
   51548           0 :       void * object = ROSE_MALLOC(Size);
   51549           0 :       ALLOC_MUTEX(SgOmpVariablesClause, unlock);
   51550             :       return object;
   51551             :     }
   51552             : #endif
   51553             : 
   51554           0 :     if (SgOmpVariablesClause::next_node == nullptr) {
   51555           0 :         SgOmpVariablesClause * alloc = (SgOmpVariablesClause*) ROSE_MALLOC ( SgOmpVariablesClause::pool_size * sizeof(SgOmpVariablesClause) );
   51556           0 :         ROSE_ASSERT(alloc != nullptr);
   51557             : 
   51558             : #if ROSE_ALLOC_TRACE == 2
   51559             : //        printf("SgOmpVariablesClause::alloc\n  block[%zi] = [ %p , %p [\n", SgOmpVariablesClause::pools.size(), alloc, alloc + SgOmpVariablesClause::pool_size);
   51560             : #endif
   51561             : 
   51562             : #if ROSE_ALLOC_MEMSET == 1
   51563             : #elif ROSE_ALLOC_MEMSET == 2
   51564             :         memset(alloc, 0x00, SgOmpVariablesClause::pool_size * sizeof(SgOmpVariablesClause));
   51565             : #elif ROSE_ALLOC_MEMSET == 3
   51566             :         memset(alloc, 0xAA, SgOmpVariablesClause::pool_size * sizeof(SgOmpVariablesClause));
   51567             : #endif
   51568           0 :         for (unsigned i=0; i < SgOmpVariablesClause::pool_size-1; i++) {
   51569           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
   51570             :         }
   51571           0 :         alloc[SgOmpVariablesClause::pool_size-1].p_freepointer = nullptr;
   51572             : 
   51573           0 :         SgOmpVariablesClause::pools.push_back ( (unsigned char *) alloc );
   51574           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgOmpVariablesClause::pool_size * sizeof(SgOmpVariablesClause), V_SgOmpVariablesClause ) );
   51575           0 :         SgOmpVariablesClause::next_node = alloc;
   51576             :     }
   51577           0 :     ROSE_ASSERT(SgOmpVariablesClause::next_node != nullptr);
   51578             : 
   51579           0 :     SgOmpVariablesClause * object = SgOmpVariablesClause::next_node;
   51580           0 :     SgOmpVariablesClause::next_node = (SgOmpVariablesClause*)(object->p_freepointer);
   51581             : 
   51582             : #if ROSE_ALLOC_TRACE == 2
   51583             :     printf("SgOmpVariablesClause::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpVariablesClause::next_node);
   51584             : #endif
   51585             : 
   51586           0 :     SgNode * fp = object->p_freepointer;
   51587             : #if ROSE_ALLOC_MEMSET == 1
   51588             : #elif ROSE_ALLOC_MEMSET == 2
   51589             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpVariablesClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   51590             : #elif ROSE_ALLOC_MEMSET == 3
   51591             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgOmpVariablesClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   51592             : #endif
   51593           0 :     object->p_freepointer = fp;
   51594             : 
   51595             : #if ROSE_ALLOC_TRACE == 2
   51596             : //    printf("SgOmpVariablesClause::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpVariablesClause::next_node);
   51597             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   51598             :     Rose::MemPool::snapshot(oss.str());
   51599             :     alloc_trace_cnt++;
   51600             : #endif
   51601             : 
   51602           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   51603             : 
   51604           0 :     ALLOC_MUTEX(SgOmpVariablesClause, unlock);
   51605             : 
   51606             :     return object;
   51607             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   51608             : }
   51609             : 
   51610             : 
   51611             : 
   51612             : /*! \brief Delete operator for SgOmpVariablesClause.
   51613             : 
   51614             :    This delete operator implements deallocation using memory pools to 
   51615             :    provide most efficent use of the heap within construction of large ASTs.
   51616             : 
   51617             : \internal The new and delete operators use the lower level C malloc/free
   51618             :    function calls for performance and to make sure that mixing of malloc/free
   51619             :    and new/delete by the used can be caught more readily.  This may change
   51620             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   51621             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   51622             :    deallocate memory allocated using ROSE_MALLOC.
   51623             : */
   51624           0 : void SgOmpVariablesClause::operator delete(void *Pointer, size_t Size)
   51625             : {
   51626             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   51627             :      * or throwing an exception. */
   51628           0 :     ALLOC_MUTEX(SgOmpVariablesClause, lock);
   51629             : 
   51630             : #if USE_CPP_NEW_DELETE_OPERATORS
   51631             :     ROSE_FREE(Pointer);
   51632             : #else
   51633             : #if ROSE_PEDANTIC_ALLOC
   51634             :     ROSE_ASSERT(Size == sizeof(SgOmpVariablesClause));
   51635             : #else
   51636           0 :     if (Size != sizeof(SgOmpVariablesClause)) {
   51637           0 :       ROSE_FREE(Pointer);
   51638           0 :       ALLOC_MUTEX(SgOmpVariablesClause, unlock);
   51639             :       return;
   51640             :     }
   51641             : #endif
   51642             : 
   51643           0 :     SgOmpVariablesClause * object = (SgOmpVariablesClause*) Pointer;
   51644           0 :     ROSE_ASSERT(object != nullptr);
   51645             : 
   51646             : #if ROSE_ALLOC_TRACE == 2
   51647             : //  printf("SgOmpVariablesClause::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpVariablesClause::next_node);
   51648             :     printf("SgOmpVariablesClause::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpVariablesClause::next_node);
   51649             : #endif
   51650             : 
   51651             : #if ROSE_PEDANTIC_ALLOC
   51652             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   51653             : #endif
   51654             : 
   51655             : #if ROSE_ALLOC_MEMSET == 1
   51656             : #elif ROSE_ALLOC_MEMSET == 2
   51657             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpVariablesClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   51658             : #elif ROSE_ALLOC_MEMSET == 3
   51659             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgOmpVariablesClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   51660             : #endif
   51661             : 
   51662             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   51663             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   51664             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   51665             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   51666             : #else
   51667           0 :     object->p_freepointer = SgOmpVariablesClause::next_node;
   51668           0 :     SgOmpVariablesClause::next_node = object;
   51669             : #endif
   51670             : 
   51671             : #if ROSE_ALLOC_TRACE == 2
   51672             : //  printf("SgOmpVariablesClause::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpVariablesClause::next_node);
   51673             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   51674             :     Rose::MemPool::snapshot(oss.str());
   51675             :     alloc_trace_cnt++;
   51676             : #endif
   51677             : 
   51678             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   51679             : 
   51680           0 :     ALLOC_MUTEX(SgOmpVariablesClause, unlock);
   51681             : }
   51682             : 
   51683             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   51684             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   51685             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   51686             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   51687             : // Also, note comment below from Robb (copied from the Common.code file).
   51688             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   51689             : //
   51690             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   51691             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   51692             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   51693             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   51694             : #if 0
   51695             : void SgOmpVariablesClause::operator delete(void* pointer) { SgOmpVariablesClause::operator delete (pointer, sizeof(SgOmpVariablesClause)); };
   51696             : #endif
   51697             : /* #line 51698 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   51698             : 
   51699             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   51700             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   51701             : // obviously imply C++.
   51702             : 
   51703             : // This implements the support within ROSE for memory pools.  Memory pools
   51704             : // support the most condensed usage of memory within the construction of
   51705             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   51706             : // by a new operator written for each class.
   51707             : 
   51708             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   51709             :     // User wants multi-thread support and POSIX threads are available.
   51710             : #   include <pthread.h>
   51711             :     static pthread_mutex_t SgOmpCopyprivateClause_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   51712             : #else
   51713             :      // Cause synchronization to be skipped.
   51714             : #    ifndef ALLOC_MUTEX
   51715             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   51716             : #    endif
   51717             : #    ifdef _REENTRANT
   51718             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   51719             : #       ifdef _MSC_VER
   51720             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   51721             : #       else
   51722             : #           warning "POSIX threads are not available; synchronization being skipped"
   51723             : #       endif
   51724             : #    endif
   51725             : #endif
   51726             : 
   51727             : #ifndef ROSE_ALLOC_TRACE
   51728             : #  define ROSE_ALLOC_TRACE 0
   51729             : #endif
   51730             : 
   51731             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   51732             : #define ROSE_ALLOC_TRACE_CNT
   51733             : #include "memory-pool-snapshot.h"
   51734             : unsigned long alloc_trace_cnt = 0;
   51735             : #endif
   51736             : 
   51737             : #if ROSE_ALLOC_TRACE
   51738             : const unsigned SgOmpCopyprivateClause::pool_size = 5;
   51739             : #else
   51740             : const unsigned SgOmpCopyprivateClause::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   51741             : #endif
   51742             : 
   51743             : #ifndef ROSE_ALLOC_MEMSET
   51744             : #  define ROSE_ALLOC_MEMSET 0
   51745             : #endif
   51746             : 
   51747             : #ifndef ROSE_PEDANTIC_ALLOC
   51748             : #  define ROSE_PEDANTIC_ALLOC 0
   51749             : #endif
   51750             : 
   51751             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   51752             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   51753             : #endif
   51754             : 
   51755             : #if !defined(SGNODE__ALL_POOLS)
   51756             : #define SGNODE__ALL_POOLS
   51757             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   51758             : #endif
   51759             : 
   51760             : SgOmpCopyprivateClause* SgOmpCopyprivateClause::next_node = nullptr;
   51761             : std::vector<unsigned char*> SgOmpCopyprivateClause::pools;
   51762             : 
   51763             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   51764             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   51765             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   51766             : // around this macro definition rather than each use).
   51767             : #ifndef ALLOC_MUTEX
   51768             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   51769             :         do {                                                                     \
   51770             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   51771             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   51772             :                 abort();                                                         \
   51773             :             }                                                                    \
   51774             :         } while (0);
   51775             : #endif
   51776             : 
   51777             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   51778             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   51779             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   51780             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   51781             : 
   51782             : /*! \brief New operator for SgOmpCopyprivateClause.
   51783             : 
   51784             :    This new operator implements memory pools to provide most efficent 
   51785             :    use of the heap within construction of large ASTs.
   51786             : 
   51787             : \internal The new and delete operators use the lower level C malloc/free
   51788             :    function calls for performance and to make sure that mixing of malloc/free
   51789             :    and new/delete by the used can be caught more readily.  This may change
   51790             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   51791             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   51792             :    deallocate memory allocated using ROSE_MALLOC.
   51793             : */
   51794           6 : void *SgOmpCopyprivateClause::operator new ( size_t Size )
   51795             : {
   51796             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   51797             :      * returning or throwing an exception. */
   51798           6 :     ALLOC_MUTEX(SgOmpCopyprivateClause, lock);
   51799             : 
   51800             : #if ROSE_ALLOC_TRACE == 2
   51801             : //    printf("SgOmpCopyprivateClause::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgOmpCopyprivateClause::next_node);
   51802             : #endif
   51803             : 
   51804             : #if USE_CPP_NEW_DELETE_OPERATORS
   51805             :     void *mem = ROSE_MALLOC(Size);
   51806             :     ALLOC_MUTEX(SgOmpCopyprivateClause, unlock);
   51807             :     return mem;
   51808             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   51809             : #if ROSE_PEDANTIC_ALLOC
   51810             :     ROSE_ASSERT(Size == sizeof(SgOmpCopyprivateClause));
   51811             : #else
   51812           6 :     if (Size != sizeof(SgOmpCopyprivateClause)) {
   51813           0 :       void * object = ROSE_MALLOC(Size);
   51814           0 :       ALLOC_MUTEX(SgOmpCopyprivateClause, unlock);
   51815             :       return object;
   51816             :     }
   51817             : #endif
   51818             : 
   51819           6 :     if (SgOmpCopyprivateClause::next_node == nullptr) {
   51820           6 :         SgOmpCopyprivateClause * alloc = (SgOmpCopyprivateClause*) ROSE_MALLOC ( SgOmpCopyprivateClause::pool_size * sizeof(SgOmpCopyprivateClause) );
   51821           6 :         ROSE_ASSERT(alloc != nullptr);
   51822             : 
   51823             : #if ROSE_ALLOC_TRACE == 2
   51824             : //        printf("SgOmpCopyprivateClause::alloc\n  block[%zi] = [ %p , %p [\n", SgOmpCopyprivateClause::pools.size(), alloc, alloc + SgOmpCopyprivateClause::pool_size);
   51825             : #endif
   51826             : 
   51827             : #if ROSE_ALLOC_MEMSET == 1
   51828             : #elif ROSE_ALLOC_MEMSET == 2
   51829             :         memset(alloc, 0x00, SgOmpCopyprivateClause::pool_size * sizeof(SgOmpCopyprivateClause));
   51830             : #elif ROSE_ALLOC_MEMSET == 3
   51831             :         memset(alloc, 0xAA, SgOmpCopyprivateClause::pool_size * sizeof(SgOmpCopyprivateClause));
   51832             : #endif
   51833       12000 :         for (unsigned i=0; i < SgOmpCopyprivateClause::pool_size-1; i++) {
   51834       11994 :           alloc[i].p_freepointer = &(alloc[i+1]);
   51835             :         }
   51836           6 :         alloc[SgOmpCopyprivateClause::pool_size-1].p_freepointer = nullptr;
   51837             : 
   51838           6 :         SgOmpCopyprivateClause::pools.push_back ( (unsigned char *) alloc );
   51839           6 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgOmpCopyprivateClause::pool_size * sizeof(SgOmpCopyprivateClause), V_SgOmpCopyprivateClause ) );
   51840           6 :         SgOmpCopyprivateClause::next_node = alloc;
   51841             :     }
   51842           6 :     ROSE_ASSERT(SgOmpCopyprivateClause::next_node != nullptr);
   51843             : 
   51844           6 :     SgOmpCopyprivateClause * object = SgOmpCopyprivateClause::next_node;
   51845           6 :     SgOmpCopyprivateClause::next_node = (SgOmpCopyprivateClause*)(object->p_freepointer);
   51846             : 
   51847             : #if ROSE_ALLOC_TRACE == 2
   51848             :     printf("SgOmpCopyprivateClause::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpCopyprivateClause::next_node);
   51849             : #endif
   51850             : 
   51851           6 :     SgNode * fp = object->p_freepointer;
   51852             : #if ROSE_ALLOC_MEMSET == 1
   51853             : #elif ROSE_ALLOC_MEMSET == 2
   51854             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpCopyprivateClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   51855             : #elif ROSE_ALLOC_MEMSET == 3
   51856             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgOmpCopyprivateClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   51857             : #endif
   51858           6 :     object->p_freepointer = fp;
   51859             : 
   51860             : #if ROSE_ALLOC_TRACE == 2
   51861             : //    printf("SgOmpCopyprivateClause::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpCopyprivateClause::next_node);
   51862             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   51863             :     Rose::MemPool::snapshot(oss.str());
   51864             :     alloc_trace_cnt++;
   51865             : #endif
   51866             : 
   51867           6 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   51868             : 
   51869           6 :     ALLOC_MUTEX(SgOmpCopyprivateClause, unlock);
   51870             : 
   51871             :     return object;
   51872             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   51873             : }
   51874             : 
   51875             : 
   51876             : 
   51877             : /*! \brief Delete operator for SgOmpCopyprivateClause.
   51878             : 
   51879             :    This delete operator implements deallocation using memory pools to 
   51880             :    provide most efficent use of the heap within construction of large ASTs.
   51881             : 
   51882             : \internal The new and delete operators use the lower level C malloc/free
   51883             :    function calls for performance and to make sure that mixing of malloc/free
   51884             :    and new/delete by the used can be caught more readily.  This may change
   51885             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   51886             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   51887             :    deallocate memory allocated using ROSE_MALLOC.
   51888             : */
   51889           0 : void SgOmpCopyprivateClause::operator delete(void *Pointer, size_t Size)
   51890             : {
   51891             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   51892             :      * or throwing an exception. */
   51893           0 :     ALLOC_MUTEX(SgOmpCopyprivateClause, lock);
   51894             : 
   51895             : #if USE_CPP_NEW_DELETE_OPERATORS
   51896             :     ROSE_FREE(Pointer);
   51897             : #else
   51898             : #if ROSE_PEDANTIC_ALLOC
   51899             :     ROSE_ASSERT(Size == sizeof(SgOmpCopyprivateClause));
   51900             : #else
   51901           0 :     if (Size != sizeof(SgOmpCopyprivateClause)) {
   51902           0 :       ROSE_FREE(Pointer);
   51903           0 :       ALLOC_MUTEX(SgOmpCopyprivateClause, unlock);
   51904             :       return;
   51905             :     }
   51906             : #endif
   51907             : 
   51908           0 :     SgOmpCopyprivateClause * object = (SgOmpCopyprivateClause*) Pointer;
   51909           0 :     ROSE_ASSERT(object != nullptr);
   51910             : 
   51911             : #if ROSE_ALLOC_TRACE == 2
   51912             : //  printf("SgOmpCopyprivateClause::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpCopyprivateClause::next_node);
   51913             :     printf("SgOmpCopyprivateClause::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpCopyprivateClause::next_node);
   51914             : #endif
   51915             : 
   51916             : #if ROSE_PEDANTIC_ALLOC
   51917             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   51918             : #endif
   51919             : 
   51920             : #if ROSE_ALLOC_MEMSET == 1
   51921             : #elif ROSE_ALLOC_MEMSET == 2
   51922             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpCopyprivateClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   51923             : #elif ROSE_ALLOC_MEMSET == 3
   51924             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgOmpCopyprivateClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   51925             : #endif
   51926             : 
   51927             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   51928             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   51929             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   51930             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   51931             : #else
   51932           0 :     object->p_freepointer = SgOmpCopyprivateClause::next_node;
   51933           0 :     SgOmpCopyprivateClause::next_node = object;
   51934             : #endif
   51935             : 
   51936             : #if ROSE_ALLOC_TRACE == 2
   51937             : //  printf("SgOmpCopyprivateClause::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpCopyprivateClause::next_node);
   51938             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   51939             :     Rose::MemPool::snapshot(oss.str());
   51940             :     alloc_trace_cnt++;
   51941             : #endif
   51942             : 
   51943             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   51944             : 
   51945           0 :     ALLOC_MUTEX(SgOmpCopyprivateClause, unlock);
   51946             : }
   51947             : 
   51948             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   51949             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   51950             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   51951             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   51952             : // Also, note comment below from Robb (copied from the Common.code file).
   51953             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   51954             : //
   51955             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   51956             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   51957             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   51958             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   51959             : #if 0
   51960             : void SgOmpCopyprivateClause::operator delete(void* pointer) { SgOmpCopyprivateClause::operator delete (pointer, sizeof(SgOmpCopyprivateClause)); };
   51961             : #endif
   51962             : /* #line 51963 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   51963             : 
   51964             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   51965             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   51966             : // obviously imply C++.
   51967             : 
   51968             : // This implements the support within ROSE for memory pools.  Memory pools
   51969             : // support the most condensed usage of memory within the construction of
   51970             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   51971             : // by a new operator written for each class.
   51972             : 
   51973             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   51974             :     // User wants multi-thread support and POSIX threads are available.
   51975             : #   include <pthread.h>
   51976             :     static pthread_mutex_t SgOmpPrivateClause_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   51977             : #else
   51978             :      // Cause synchronization to be skipped.
   51979             : #    ifndef ALLOC_MUTEX
   51980             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   51981             : #    endif
   51982             : #    ifdef _REENTRANT
   51983             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   51984             : #       ifdef _MSC_VER
   51985             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   51986             : #       else
   51987             : #           warning "POSIX threads are not available; synchronization being skipped"
   51988             : #       endif
   51989             : #    endif
   51990             : #endif
   51991             : 
   51992             : #ifndef ROSE_ALLOC_TRACE
   51993             : #  define ROSE_ALLOC_TRACE 0
   51994             : #endif
   51995             : 
   51996             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   51997             : #define ROSE_ALLOC_TRACE_CNT
   51998             : #include "memory-pool-snapshot.h"
   51999             : unsigned long alloc_trace_cnt = 0;
   52000             : #endif
   52001             : 
   52002             : #if ROSE_ALLOC_TRACE
   52003             : const unsigned SgOmpPrivateClause::pool_size = 5;
   52004             : #else
   52005             : const unsigned SgOmpPrivateClause::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   52006             : #endif
   52007             : 
   52008             : #ifndef ROSE_ALLOC_MEMSET
   52009             : #  define ROSE_ALLOC_MEMSET 0
   52010             : #endif
   52011             : 
   52012             : #ifndef ROSE_PEDANTIC_ALLOC
   52013             : #  define ROSE_PEDANTIC_ALLOC 0
   52014             : #endif
   52015             : 
   52016             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   52017             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   52018             : #endif
   52019             : 
   52020             : #if !defined(SGNODE__ALL_POOLS)
   52021             : #define SGNODE__ALL_POOLS
   52022             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   52023             : #endif
   52024             : 
   52025             : SgOmpPrivateClause* SgOmpPrivateClause::next_node = nullptr;
   52026             : std::vector<unsigned char*> SgOmpPrivateClause::pools;
   52027             : 
   52028             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   52029             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   52030             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   52031             : // around this macro definition rather than each use).
   52032             : #ifndef ALLOC_MUTEX
   52033             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   52034             :         do {                                                                     \
   52035             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   52036             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   52037             :                 abort();                                                         \
   52038             :             }                                                                    \
   52039             :         } while (0);
   52040             : #endif
   52041             : 
   52042             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   52043             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   52044             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   52045             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   52046             : 
   52047             : /*! \brief New operator for SgOmpPrivateClause.
   52048             : 
   52049             :    This new operator implements memory pools to provide most efficent 
   52050             :    use of the heap within construction of large ASTs.
   52051             : 
   52052             : \internal The new and delete operators use the lower level C malloc/free
   52053             :    function calls for performance and to make sure that mixing of malloc/free
   52054             :    and new/delete by the used can be caught more readily.  This may change
   52055             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   52056             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   52057             :    deallocate memory allocated using ROSE_MALLOC.
   52058             : */
   52059         103 : void *SgOmpPrivateClause::operator new ( size_t Size )
   52060             : {
   52061             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   52062             :      * returning or throwing an exception. */
   52063         103 :     ALLOC_MUTEX(SgOmpPrivateClause, lock);
   52064             : 
   52065             : #if ROSE_ALLOC_TRACE == 2
   52066             : //    printf("SgOmpPrivateClause::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgOmpPrivateClause::next_node);
   52067             : #endif
   52068             : 
   52069             : #if USE_CPP_NEW_DELETE_OPERATORS
   52070             :     void *mem = ROSE_MALLOC(Size);
   52071             :     ALLOC_MUTEX(SgOmpPrivateClause, unlock);
   52072             :     return mem;
   52073             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   52074             : #if ROSE_PEDANTIC_ALLOC
   52075             :     ROSE_ASSERT(Size == sizeof(SgOmpPrivateClause));
   52076             : #else
   52077         103 :     if (Size != sizeof(SgOmpPrivateClause)) {
   52078           0 :       void * object = ROSE_MALLOC(Size);
   52079           0 :       ALLOC_MUTEX(SgOmpPrivateClause, unlock);
   52080             :       return object;
   52081             :     }
   52082             : #endif
   52083             : 
   52084         103 :     if (SgOmpPrivateClause::next_node == nullptr) {
   52085          73 :         SgOmpPrivateClause * alloc = (SgOmpPrivateClause*) ROSE_MALLOC ( SgOmpPrivateClause::pool_size * sizeof(SgOmpPrivateClause) );
   52086          73 :         ROSE_ASSERT(alloc != nullptr);
   52087             : 
   52088             : #if ROSE_ALLOC_TRACE == 2
   52089             : //        printf("SgOmpPrivateClause::alloc\n  block[%zi] = [ %p , %p [\n", SgOmpPrivateClause::pools.size(), alloc, alloc + SgOmpPrivateClause::pool_size);
   52090             : #endif
   52091             : 
   52092             : #if ROSE_ALLOC_MEMSET == 1
   52093             : #elif ROSE_ALLOC_MEMSET == 2
   52094             :         memset(alloc, 0x00, SgOmpPrivateClause::pool_size * sizeof(SgOmpPrivateClause));
   52095             : #elif ROSE_ALLOC_MEMSET == 3
   52096             :         memset(alloc, 0xAA, SgOmpPrivateClause::pool_size * sizeof(SgOmpPrivateClause));
   52097             : #endif
   52098      146000 :         for (unsigned i=0; i < SgOmpPrivateClause::pool_size-1; i++) {
   52099      145927 :           alloc[i].p_freepointer = &(alloc[i+1]);
   52100             :         }
   52101          73 :         alloc[SgOmpPrivateClause::pool_size-1].p_freepointer = nullptr;
   52102             : 
   52103          73 :         SgOmpPrivateClause::pools.push_back ( (unsigned char *) alloc );
   52104          73 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgOmpPrivateClause::pool_size * sizeof(SgOmpPrivateClause), V_SgOmpPrivateClause ) );
   52105          73 :         SgOmpPrivateClause::next_node = alloc;
   52106             :     }
   52107         103 :     ROSE_ASSERT(SgOmpPrivateClause::next_node != nullptr);
   52108             : 
   52109         103 :     SgOmpPrivateClause * object = SgOmpPrivateClause::next_node;
   52110         103 :     SgOmpPrivateClause::next_node = (SgOmpPrivateClause*)(object->p_freepointer);
   52111             : 
   52112             : #if ROSE_ALLOC_TRACE == 2
   52113             :     printf("SgOmpPrivateClause::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpPrivateClause::next_node);
   52114             : #endif
   52115             : 
   52116         103 :     SgNode * fp = object->p_freepointer;
   52117             : #if ROSE_ALLOC_MEMSET == 1
   52118             : #elif ROSE_ALLOC_MEMSET == 2
   52119             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpPrivateClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   52120             : #elif ROSE_ALLOC_MEMSET == 3
   52121             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgOmpPrivateClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   52122             : #endif
   52123         103 :     object->p_freepointer = fp;
   52124             : 
   52125             : #if ROSE_ALLOC_TRACE == 2
   52126             : //    printf("SgOmpPrivateClause::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpPrivateClause::next_node);
   52127             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   52128             :     Rose::MemPool::snapshot(oss.str());
   52129             :     alloc_trace_cnt++;
   52130             : #endif
   52131             : 
   52132         103 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   52133             : 
   52134         103 :     ALLOC_MUTEX(SgOmpPrivateClause, unlock);
   52135             : 
   52136             :     return object;
   52137             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   52138             : }
   52139             : 
   52140             : 
   52141             : 
   52142             : /*! \brief Delete operator for SgOmpPrivateClause.
   52143             : 
   52144             :    This delete operator implements deallocation using memory pools to 
   52145             :    provide most efficent use of the heap within construction of large ASTs.
   52146             : 
   52147             : \internal The new and delete operators use the lower level C malloc/free
   52148             :    function calls for performance and to make sure that mixing of malloc/free
   52149             :    and new/delete by the used can be caught more readily.  This may change
   52150             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   52151             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   52152             :    deallocate memory allocated using ROSE_MALLOC.
   52153             : */
   52154           0 : void SgOmpPrivateClause::operator delete(void *Pointer, size_t Size)
   52155             : {
   52156             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   52157             :      * or throwing an exception. */
   52158           0 :     ALLOC_MUTEX(SgOmpPrivateClause, lock);
   52159             : 
   52160             : #if USE_CPP_NEW_DELETE_OPERATORS
   52161             :     ROSE_FREE(Pointer);
   52162             : #else
   52163             : #if ROSE_PEDANTIC_ALLOC
   52164             :     ROSE_ASSERT(Size == sizeof(SgOmpPrivateClause));
   52165             : #else
   52166           0 :     if (Size != sizeof(SgOmpPrivateClause)) {
   52167           0 :       ROSE_FREE(Pointer);
   52168           0 :       ALLOC_MUTEX(SgOmpPrivateClause, unlock);
   52169             :       return;
   52170             :     }
   52171             : #endif
   52172             : 
   52173           0 :     SgOmpPrivateClause * object = (SgOmpPrivateClause*) Pointer;
   52174           0 :     ROSE_ASSERT(object != nullptr);
   52175             : 
   52176             : #if ROSE_ALLOC_TRACE == 2
   52177             : //  printf("SgOmpPrivateClause::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpPrivateClause::next_node);
   52178             :     printf("SgOmpPrivateClause::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpPrivateClause::next_node);
   52179             : #endif
   52180             : 
   52181             : #if ROSE_PEDANTIC_ALLOC
   52182             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   52183             : #endif
   52184             : 
   52185             : #if ROSE_ALLOC_MEMSET == 1
   52186             : #elif ROSE_ALLOC_MEMSET == 2
   52187             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpPrivateClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   52188             : #elif ROSE_ALLOC_MEMSET == 3
   52189             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgOmpPrivateClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   52190             : #endif
   52191             : 
   52192             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   52193             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   52194             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   52195             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   52196             : #else
   52197           0 :     object->p_freepointer = SgOmpPrivateClause::next_node;
   52198           0 :     SgOmpPrivateClause::next_node = object;
   52199             : #endif
   52200             : 
   52201             : #if ROSE_ALLOC_TRACE == 2
   52202             : //  printf("SgOmpPrivateClause::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpPrivateClause::next_node);
   52203             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   52204             :     Rose::MemPool::snapshot(oss.str());
   52205             :     alloc_trace_cnt++;
   52206             : #endif
   52207             : 
   52208             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   52209             : 
   52210           0 :     ALLOC_MUTEX(SgOmpPrivateClause, unlock);
   52211             : }
   52212             : 
   52213             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   52214             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   52215             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   52216             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   52217             : // Also, note comment below from Robb (copied from the Common.code file).
   52218             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   52219             : //
   52220             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   52221             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   52222             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   52223             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   52224             : #if 0
   52225             : void SgOmpPrivateClause::operator delete(void* pointer) { SgOmpPrivateClause::operator delete (pointer, sizeof(SgOmpPrivateClause)); };
   52226             : #endif
   52227             : /* #line 52228 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   52228             : 
   52229             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   52230             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   52231             : // obviously imply C++.
   52232             : 
   52233             : // This implements the support within ROSE for memory pools.  Memory pools
   52234             : // support the most condensed usage of memory within the construction of
   52235             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   52236             : // by a new operator written for each class.
   52237             : 
   52238             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   52239             :     // User wants multi-thread support and POSIX threads are available.
   52240             : #   include <pthread.h>
   52241             :     static pthread_mutex_t SgOmpFirstprivateClause_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   52242             : #else
   52243             :      // Cause synchronization to be skipped.
   52244             : #    ifndef ALLOC_MUTEX
   52245             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   52246             : #    endif
   52247             : #    ifdef _REENTRANT
   52248             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   52249             : #       ifdef _MSC_VER
   52250             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   52251             : #       else
   52252             : #           warning "POSIX threads are not available; synchronization being skipped"
   52253             : #       endif
   52254             : #    endif
   52255             : #endif
   52256             : 
   52257             : #ifndef ROSE_ALLOC_TRACE
   52258             : #  define ROSE_ALLOC_TRACE 0
   52259             : #endif
   52260             : 
   52261             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   52262             : #define ROSE_ALLOC_TRACE_CNT
   52263             : #include "memory-pool-snapshot.h"
   52264             : unsigned long alloc_trace_cnt = 0;
   52265             : #endif
   52266             : 
   52267             : #if ROSE_ALLOC_TRACE
   52268             : const unsigned SgOmpFirstprivateClause::pool_size = 5;
   52269             : #else
   52270             : const unsigned SgOmpFirstprivateClause::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   52271             : #endif
   52272             : 
   52273             : #ifndef ROSE_ALLOC_MEMSET
   52274             : #  define ROSE_ALLOC_MEMSET 0
   52275             : #endif
   52276             : 
   52277             : #ifndef ROSE_PEDANTIC_ALLOC
   52278             : #  define ROSE_PEDANTIC_ALLOC 0
   52279             : #endif
   52280             : 
   52281             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   52282             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   52283             : #endif
   52284             : 
   52285             : #if !defined(SGNODE__ALL_POOLS)
   52286             : #define SGNODE__ALL_POOLS
   52287             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   52288             : #endif
   52289             : 
   52290             : SgOmpFirstprivateClause* SgOmpFirstprivateClause::next_node = nullptr;
   52291             : std::vector<unsigned char*> SgOmpFirstprivateClause::pools;
   52292             : 
   52293             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   52294             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   52295             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   52296             : // around this macro definition rather than each use).
   52297             : #ifndef ALLOC_MUTEX
   52298             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   52299             :         do {                                                                     \
   52300             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   52301             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   52302             :                 abort();                                                         \
   52303             :             }                                                                    \
   52304             :         } while (0);
   52305             : #endif
   52306             : 
   52307             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   52308             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   52309             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   52310             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   52311             : 
   52312             : /*! \brief New operator for SgOmpFirstprivateClause.
   52313             : 
   52314             :    This new operator implements memory pools to provide most efficent 
   52315             :    use of the heap within construction of large ASTs.
   52316             : 
   52317             : \internal The new and delete operators use the lower level C malloc/free
   52318             :    function calls for performance and to make sure that mixing of malloc/free
   52319             :    and new/delete by the used can be caught more readily.  This may change
   52320             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   52321             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   52322             :    deallocate memory allocated using ROSE_MALLOC.
   52323             : */
   52324          37 : void *SgOmpFirstprivateClause::operator new ( size_t Size )
   52325             : {
   52326             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   52327             :      * returning or throwing an exception. */
   52328          37 :     ALLOC_MUTEX(SgOmpFirstprivateClause, lock);
   52329             : 
   52330             : #if ROSE_ALLOC_TRACE == 2
   52331             : //    printf("SgOmpFirstprivateClause::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgOmpFirstprivateClause::next_node);
   52332             : #endif
   52333             : 
   52334             : #if USE_CPP_NEW_DELETE_OPERATORS
   52335             :     void *mem = ROSE_MALLOC(Size);
   52336             :     ALLOC_MUTEX(SgOmpFirstprivateClause, unlock);
   52337             :     return mem;
   52338             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   52339             : #if ROSE_PEDANTIC_ALLOC
   52340             :     ROSE_ASSERT(Size == sizeof(SgOmpFirstprivateClause));
   52341             : #else
   52342          37 :     if (Size != sizeof(SgOmpFirstprivateClause)) {
   52343           0 :       void * object = ROSE_MALLOC(Size);
   52344           0 :       ALLOC_MUTEX(SgOmpFirstprivateClause, unlock);
   52345             :       return object;
   52346             :     }
   52347             : #endif
   52348             : 
   52349          37 :     if (SgOmpFirstprivateClause::next_node == nullptr) {
   52350          22 :         SgOmpFirstprivateClause * alloc = (SgOmpFirstprivateClause*) ROSE_MALLOC ( SgOmpFirstprivateClause::pool_size * sizeof(SgOmpFirstprivateClause) );
   52351          22 :         ROSE_ASSERT(alloc != nullptr);
   52352             : 
   52353             : #if ROSE_ALLOC_TRACE == 2
   52354             : //        printf("SgOmpFirstprivateClause::alloc\n  block[%zi] = [ %p , %p [\n", SgOmpFirstprivateClause::pools.size(), alloc, alloc + SgOmpFirstprivateClause::pool_size);
   52355             : #endif
   52356             : 
   52357             : #if ROSE_ALLOC_MEMSET == 1
   52358             : #elif ROSE_ALLOC_MEMSET == 2
   52359             :         memset(alloc, 0x00, SgOmpFirstprivateClause::pool_size * sizeof(SgOmpFirstprivateClause));
   52360             : #elif ROSE_ALLOC_MEMSET == 3
   52361             :         memset(alloc, 0xAA, SgOmpFirstprivateClause::pool_size * sizeof(SgOmpFirstprivateClause));
   52362             : #endif
   52363       44000 :         for (unsigned i=0; i < SgOmpFirstprivateClause::pool_size-1; i++) {
   52364       43978 :           alloc[i].p_freepointer = &(alloc[i+1]);
   52365             :         }
   52366          22 :         alloc[SgOmpFirstprivateClause::pool_size-1].p_freepointer = nullptr;
   52367             : 
   52368          22 :         SgOmpFirstprivateClause::pools.push_back ( (unsigned char *) alloc );
   52369          22 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgOmpFirstprivateClause::pool_size * sizeof(SgOmpFirstprivateClause), V_SgOmpFirstprivateClause ) );
   52370          22 :         SgOmpFirstprivateClause::next_node = alloc;
   52371             :     }
   52372          37 :     ROSE_ASSERT(SgOmpFirstprivateClause::next_node != nullptr);
   52373             : 
   52374          37 :     SgOmpFirstprivateClause * object = SgOmpFirstprivateClause::next_node;
   52375          37 :     SgOmpFirstprivateClause::next_node = (SgOmpFirstprivateClause*)(object->p_freepointer);
   52376             : 
   52377             : #if ROSE_ALLOC_TRACE == 2
   52378             :     printf("SgOmpFirstprivateClause::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpFirstprivateClause::next_node);
   52379             : #endif
   52380             : 
   52381          37 :     SgNode * fp = object->p_freepointer;
   52382             : #if ROSE_ALLOC_MEMSET == 1
   52383             : #elif ROSE_ALLOC_MEMSET == 2
   52384             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpFirstprivateClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   52385             : #elif ROSE_ALLOC_MEMSET == 3
   52386             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgOmpFirstprivateClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   52387             : #endif
   52388          37 :     object->p_freepointer = fp;
   52389             : 
   52390             : #if ROSE_ALLOC_TRACE == 2
   52391             : //    printf("SgOmpFirstprivateClause::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpFirstprivateClause::next_node);
   52392             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   52393             :     Rose::MemPool::snapshot(oss.str());
   52394             :     alloc_trace_cnt++;
   52395             : #endif
   52396             : 
   52397          37 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   52398             : 
   52399          37 :     ALLOC_MUTEX(SgOmpFirstprivateClause, unlock);
   52400             : 
   52401             :     return object;
   52402             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   52403             : }
   52404             : 
   52405             : 
   52406             : 
   52407             : /*! \brief Delete operator for SgOmpFirstprivateClause.
   52408             : 
   52409             :    This delete operator implements deallocation using memory pools to 
   52410             :    provide most efficent use of the heap within construction of large ASTs.
   52411             : 
   52412             : \internal The new and delete operators use the lower level C malloc/free
   52413             :    function calls for performance and to make sure that mixing of malloc/free
   52414             :    and new/delete by the used can be caught more readily.  This may change
   52415             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   52416             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   52417             :    deallocate memory allocated using ROSE_MALLOC.
   52418             : */
   52419           0 : void SgOmpFirstprivateClause::operator delete(void *Pointer, size_t Size)
   52420             : {
   52421             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   52422             :      * or throwing an exception. */
   52423           0 :     ALLOC_MUTEX(SgOmpFirstprivateClause, lock);
   52424             : 
   52425             : #if USE_CPP_NEW_DELETE_OPERATORS
   52426             :     ROSE_FREE(Pointer);
   52427             : #else
   52428             : #if ROSE_PEDANTIC_ALLOC
   52429             :     ROSE_ASSERT(Size == sizeof(SgOmpFirstprivateClause));
   52430             : #else
   52431           0 :     if (Size != sizeof(SgOmpFirstprivateClause)) {
   52432           0 :       ROSE_FREE(Pointer);
   52433           0 :       ALLOC_MUTEX(SgOmpFirstprivateClause, unlock);
   52434             :       return;
   52435             :     }
   52436             : #endif
   52437             : 
   52438           0 :     SgOmpFirstprivateClause * object = (SgOmpFirstprivateClause*) Pointer;
   52439           0 :     ROSE_ASSERT(object != nullptr);
   52440             : 
   52441             : #if ROSE_ALLOC_TRACE == 2
   52442             : //  printf("SgOmpFirstprivateClause::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpFirstprivateClause::next_node);
   52443             :     printf("SgOmpFirstprivateClause::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpFirstprivateClause::next_node);
   52444             : #endif
   52445             : 
   52446             : #if ROSE_PEDANTIC_ALLOC
   52447             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   52448             : #endif
   52449             : 
   52450             : #if ROSE_ALLOC_MEMSET == 1
   52451             : #elif ROSE_ALLOC_MEMSET == 2
   52452             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpFirstprivateClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   52453             : #elif ROSE_ALLOC_MEMSET == 3
   52454             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgOmpFirstprivateClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   52455             : #endif
   52456             : 
   52457             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   52458             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   52459             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   52460             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   52461             : #else
   52462           0 :     object->p_freepointer = SgOmpFirstprivateClause::next_node;
   52463           0 :     SgOmpFirstprivateClause::next_node = object;
   52464             : #endif
   52465             : 
   52466             : #if ROSE_ALLOC_TRACE == 2
   52467             : //  printf("SgOmpFirstprivateClause::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpFirstprivateClause::next_node);
   52468             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   52469             :     Rose::MemPool::snapshot(oss.str());
   52470             :     alloc_trace_cnt++;
   52471             : #endif
   52472             : 
   52473             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   52474             : 
   52475           0 :     ALLOC_MUTEX(SgOmpFirstprivateClause, unlock);
   52476             : }
   52477             : 
   52478             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   52479             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   52480             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   52481             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   52482             : // Also, note comment below from Robb (copied from the Common.code file).
   52483             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   52484             : //
   52485             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   52486             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   52487             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   52488             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   52489             : #if 0
   52490             : void SgOmpFirstprivateClause::operator delete(void* pointer) { SgOmpFirstprivateClause::operator delete (pointer, sizeof(SgOmpFirstprivateClause)); };
   52491             : #endif
   52492             : /* #line 52493 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   52493             : 
   52494             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   52495             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   52496             : // obviously imply C++.
   52497             : 
   52498             : // This implements the support within ROSE for memory pools.  Memory pools
   52499             : // support the most condensed usage of memory within the construction of
   52500             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   52501             : // by a new operator written for each class.
   52502             : 
   52503             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   52504             :     // User wants multi-thread support and POSIX threads are available.
   52505             : #   include <pthread.h>
   52506             :     static pthread_mutex_t SgOmpNontemporalClause_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   52507             : #else
   52508             :      // Cause synchronization to be skipped.
   52509             : #    ifndef ALLOC_MUTEX
   52510             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   52511             : #    endif
   52512             : #    ifdef _REENTRANT
   52513             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   52514             : #       ifdef _MSC_VER
   52515             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   52516             : #       else
   52517             : #           warning "POSIX threads are not available; synchronization being skipped"
   52518             : #       endif
   52519             : #    endif
   52520             : #endif
   52521             : 
   52522             : #ifndef ROSE_ALLOC_TRACE
   52523             : #  define ROSE_ALLOC_TRACE 0
   52524             : #endif
   52525             : 
   52526             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   52527             : #define ROSE_ALLOC_TRACE_CNT
   52528             : #include "memory-pool-snapshot.h"
   52529             : unsigned long alloc_trace_cnt = 0;
   52530             : #endif
   52531             : 
   52532             : #if ROSE_ALLOC_TRACE
   52533             : const unsigned SgOmpNontemporalClause::pool_size = 5;
   52534             : #else
   52535             : const unsigned SgOmpNontemporalClause::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   52536             : #endif
   52537             : 
   52538             : #ifndef ROSE_ALLOC_MEMSET
   52539             : #  define ROSE_ALLOC_MEMSET 0
   52540             : #endif
   52541             : 
   52542             : #ifndef ROSE_PEDANTIC_ALLOC
   52543             : #  define ROSE_PEDANTIC_ALLOC 0
   52544             : #endif
   52545             : 
   52546             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   52547             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   52548             : #endif
   52549             : 
   52550             : #if !defined(SGNODE__ALL_POOLS)
   52551             : #define SGNODE__ALL_POOLS
   52552             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   52553             : #endif
   52554             : 
   52555             : SgOmpNontemporalClause* SgOmpNontemporalClause::next_node = nullptr;
   52556             : std::vector<unsigned char*> SgOmpNontemporalClause::pools;
   52557             : 
   52558             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   52559             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   52560             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   52561             : // around this macro definition rather than each use).
   52562             : #ifndef ALLOC_MUTEX
   52563             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   52564             :         do {                                                                     \
   52565             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   52566             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   52567             :                 abort();                                                         \
   52568             :             }                                                                    \
   52569             :         } while (0);
   52570             : #endif
   52571             : 
   52572             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   52573             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   52574             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   52575             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   52576             : 
   52577             : /*! \brief New operator for SgOmpNontemporalClause.
   52578             : 
   52579             :    This new operator implements memory pools to provide most efficent 
   52580             :    use of the heap within construction of large ASTs.
   52581             : 
   52582             : \internal The new and delete operators use the lower level C malloc/free
   52583             :    function calls for performance and to make sure that mixing of malloc/free
   52584             :    and new/delete by the used can be caught more readily.  This may change
   52585             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   52586             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   52587             :    deallocate memory allocated using ROSE_MALLOC.
   52588             : */
   52589           0 : void *SgOmpNontemporalClause::operator new ( size_t Size )
   52590             : {
   52591             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   52592             :      * returning or throwing an exception. */
   52593           0 :     ALLOC_MUTEX(SgOmpNontemporalClause, lock);
   52594             : 
   52595             : #if ROSE_ALLOC_TRACE == 2
   52596             : //    printf("SgOmpNontemporalClause::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgOmpNontemporalClause::next_node);
   52597             : #endif
   52598             : 
   52599             : #if USE_CPP_NEW_DELETE_OPERATORS
   52600             :     void *mem = ROSE_MALLOC(Size);
   52601             :     ALLOC_MUTEX(SgOmpNontemporalClause, unlock);
   52602             :     return mem;
   52603             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   52604             : #if ROSE_PEDANTIC_ALLOC
   52605             :     ROSE_ASSERT(Size == sizeof(SgOmpNontemporalClause));
   52606             : #else
   52607           0 :     if (Size != sizeof(SgOmpNontemporalClause)) {
   52608           0 :       void * object = ROSE_MALLOC(Size);
   52609           0 :       ALLOC_MUTEX(SgOmpNontemporalClause, unlock);
   52610             :       return object;
   52611             :     }
   52612             : #endif
   52613             : 
   52614           0 :     if (SgOmpNontemporalClause::next_node == nullptr) {
   52615           0 :         SgOmpNontemporalClause * alloc = (SgOmpNontemporalClause*) ROSE_MALLOC ( SgOmpNontemporalClause::pool_size * sizeof(SgOmpNontemporalClause) );
   52616           0 :         ROSE_ASSERT(alloc != nullptr);
   52617             : 
   52618             : #if ROSE_ALLOC_TRACE == 2
   52619             : //        printf("SgOmpNontemporalClause::alloc\n  block[%zi] = [ %p , %p [\n", SgOmpNontemporalClause::pools.size(), alloc, alloc + SgOmpNontemporalClause::pool_size);
   52620             : #endif
   52621             : 
   52622             : #if ROSE_ALLOC_MEMSET == 1
   52623             : #elif ROSE_ALLOC_MEMSET == 2
   52624             :         memset(alloc, 0x00, SgOmpNontemporalClause::pool_size * sizeof(SgOmpNontemporalClause));
   52625             : #elif ROSE_ALLOC_MEMSET == 3
   52626             :         memset(alloc, 0xAA, SgOmpNontemporalClause::pool_size * sizeof(SgOmpNontemporalClause));
   52627             : #endif
   52628           0 :         for (unsigned i=0; i < SgOmpNontemporalClause::pool_size-1; i++) {
   52629           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
   52630             :         }
   52631           0 :         alloc[SgOmpNontemporalClause::pool_size-1].p_freepointer = nullptr;
   52632             : 
   52633           0 :         SgOmpNontemporalClause::pools.push_back ( (unsigned char *) alloc );
   52634           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgOmpNontemporalClause::pool_size * sizeof(SgOmpNontemporalClause), V_SgOmpNontemporalClause ) );
   52635           0 :         SgOmpNontemporalClause::next_node = alloc;
   52636             :     }
   52637           0 :     ROSE_ASSERT(SgOmpNontemporalClause::next_node != nullptr);
   52638             : 
   52639           0 :     SgOmpNontemporalClause * object = SgOmpNontemporalClause::next_node;
   52640           0 :     SgOmpNontemporalClause::next_node = (SgOmpNontemporalClause*)(object->p_freepointer);
   52641             : 
   52642             : #if ROSE_ALLOC_TRACE == 2
   52643             :     printf("SgOmpNontemporalClause::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpNontemporalClause::next_node);
   52644             : #endif
   52645             : 
   52646           0 :     SgNode * fp = object->p_freepointer;
   52647             : #if ROSE_ALLOC_MEMSET == 1
   52648             : #elif ROSE_ALLOC_MEMSET == 2
   52649             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpNontemporalClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   52650             : #elif ROSE_ALLOC_MEMSET == 3
   52651             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgOmpNontemporalClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   52652             : #endif
   52653           0 :     object->p_freepointer = fp;
   52654             : 
   52655             : #if ROSE_ALLOC_TRACE == 2
   52656             : //    printf("SgOmpNontemporalClause::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpNontemporalClause::next_node);
   52657             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   52658             :     Rose::MemPool::snapshot(oss.str());
   52659             :     alloc_trace_cnt++;
   52660             : #endif
   52661             : 
   52662           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   52663             : 
   52664           0 :     ALLOC_MUTEX(SgOmpNontemporalClause, unlock);
   52665             : 
   52666             :     return object;
   52667             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   52668             : }
   52669             : 
   52670             : 
   52671             : 
   52672             : /*! \brief Delete operator for SgOmpNontemporalClause.
   52673             : 
   52674             :    This delete operator implements deallocation using memory pools to 
   52675             :    provide most efficent use of the heap within construction of large ASTs.
   52676             : 
   52677             : \internal The new and delete operators use the lower level C malloc/free
   52678             :    function calls for performance and to make sure that mixing of malloc/free
   52679             :    and new/delete by the used can be caught more readily.  This may change
   52680             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   52681             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   52682             :    deallocate memory allocated using ROSE_MALLOC.
   52683             : */
   52684           0 : void SgOmpNontemporalClause::operator delete(void *Pointer, size_t Size)
   52685             : {
   52686             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   52687             :      * or throwing an exception. */
   52688           0 :     ALLOC_MUTEX(SgOmpNontemporalClause, lock);
   52689             : 
   52690             : #if USE_CPP_NEW_DELETE_OPERATORS
   52691             :     ROSE_FREE(Pointer);
   52692             : #else
   52693             : #if ROSE_PEDANTIC_ALLOC
   52694             :     ROSE_ASSERT(Size == sizeof(SgOmpNontemporalClause));
   52695             : #else
   52696           0 :     if (Size != sizeof(SgOmpNontemporalClause)) {
   52697           0 :       ROSE_FREE(Pointer);
   52698           0 :       ALLOC_MUTEX(SgOmpNontemporalClause, unlock);
   52699             :       return;
   52700             :     }
   52701             : #endif
   52702             : 
   52703           0 :     SgOmpNontemporalClause * object = (SgOmpNontemporalClause*) Pointer;
   52704           0 :     ROSE_ASSERT(object != nullptr);
   52705             : 
   52706             : #if ROSE_ALLOC_TRACE == 2
   52707             : //  printf("SgOmpNontemporalClause::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpNontemporalClause::next_node);
   52708             :     printf("SgOmpNontemporalClause::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpNontemporalClause::next_node);
   52709             : #endif
   52710             : 
   52711             : #if ROSE_PEDANTIC_ALLOC
   52712             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   52713             : #endif
   52714             : 
   52715             : #if ROSE_ALLOC_MEMSET == 1
   52716             : #elif ROSE_ALLOC_MEMSET == 2
   52717             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpNontemporalClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   52718             : #elif ROSE_ALLOC_MEMSET == 3
   52719             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgOmpNontemporalClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   52720             : #endif
   52721             : 
   52722             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   52723             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   52724             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   52725             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   52726             : #else
   52727           0 :     object->p_freepointer = SgOmpNontemporalClause::next_node;
   52728           0 :     SgOmpNontemporalClause::next_node = object;
   52729             : #endif
   52730             : 
   52731             : #if ROSE_ALLOC_TRACE == 2
   52732             : //  printf("SgOmpNontemporalClause::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpNontemporalClause::next_node);
   52733             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   52734             :     Rose::MemPool::snapshot(oss.str());
   52735             :     alloc_trace_cnt++;
   52736             : #endif
   52737             : 
   52738             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   52739             : 
   52740           0 :     ALLOC_MUTEX(SgOmpNontemporalClause, unlock);
   52741             : }
   52742             : 
   52743             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   52744             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   52745             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   52746             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   52747             : // Also, note comment below from Robb (copied from the Common.code file).
   52748             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   52749             : //
   52750             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   52751             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   52752             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   52753             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   52754             : #if 0
   52755             : void SgOmpNontemporalClause::operator delete(void* pointer) { SgOmpNontemporalClause::operator delete (pointer, sizeof(SgOmpNontemporalClause)); };
   52756             : #endif
   52757             : /* #line 52758 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   52758             : 
   52759             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   52760             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   52761             : // obviously imply C++.
   52762             : 
   52763             : // This implements the support within ROSE for memory pools.  Memory pools
   52764             : // support the most condensed usage of memory within the construction of
   52765             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   52766             : // by a new operator written for each class.
   52767             : 
   52768             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   52769             :     // User wants multi-thread support and POSIX threads are available.
   52770             : #   include <pthread.h>
   52771             :     static pthread_mutex_t SgOmpInclusiveClause_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   52772             : #else
   52773             :      // Cause synchronization to be skipped.
   52774             : #    ifndef ALLOC_MUTEX
   52775             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   52776             : #    endif
   52777             : #    ifdef _REENTRANT
   52778             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   52779             : #       ifdef _MSC_VER
   52780             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   52781             : #       else
   52782             : #           warning "POSIX threads are not available; synchronization being skipped"
   52783             : #       endif
   52784             : #    endif
   52785             : #endif
   52786             : 
   52787             : #ifndef ROSE_ALLOC_TRACE
   52788             : #  define ROSE_ALLOC_TRACE 0
   52789             : #endif
   52790             : 
   52791             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   52792             : #define ROSE_ALLOC_TRACE_CNT
   52793             : #include "memory-pool-snapshot.h"
   52794             : unsigned long alloc_trace_cnt = 0;
   52795             : #endif
   52796             : 
   52797             : #if ROSE_ALLOC_TRACE
   52798             : const unsigned SgOmpInclusiveClause::pool_size = 5;
   52799             : #else
   52800             : const unsigned SgOmpInclusiveClause::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   52801             : #endif
   52802             : 
   52803             : #ifndef ROSE_ALLOC_MEMSET
   52804             : #  define ROSE_ALLOC_MEMSET 0
   52805             : #endif
   52806             : 
   52807             : #ifndef ROSE_PEDANTIC_ALLOC
   52808             : #  define ROSE_PEDANTIC_ALLOC 0
   52809             : #endif
   52810             : 
   52811             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   52812             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   52813             : #endif
   52814             : 
   52815             : #if !defined(SGNODE__ALL_POOLS)
   52816             : #define SGNODE__ALL_POOLS
   52817             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   52818             : #endif
   52819             : 
   52820             : SgOmpInclusiveClause* SgOmpInclusiveClause::next_node = nullptr;
   52821             : std::vector<unsigned char*> SgOmpInclusiveClause::pools;
   52822             : 
   52823             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   52824             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   52825             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   52826             : // around this macro definition rather than each use).
   52827             : #ifndef ALLOC_MUTEX
   52828             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   52829             :         do {                                                                     \
   52830             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   52831             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   52832             :                 abort();                                                         \
   52833             :             }                                                                    \
   52834             :         } while (0);
   52835             : #endif
   52836             : 
   52837             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   52838             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   52839             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   52840             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   52841             : 
   52842             : /*! \brief New operator for SgOmpInclusiveClause.
   52843             : 
   52844             :    This new operator implements memory pools to provide most efficent 
   52845             :    use of the heap within construction of large ASTs.
   52846             : 
   52847             : \internal The new and delete operators use the lower level C malloc/free
   52848             :    function calls for performance and to make sure that mixing of malloc/free
   52849             :    and new/delete by the used can be caught more readily.  This may change
   52850             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   52851             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   52852             :    deallocate memory allocated using ROSE_MALLOC.
   52853             : */
   52854           0 : void *SgOmpInclusiveClause::operator new ( size_t Size )
   52855             : {
   52856             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   52857             :      * returning or throwing an exception. */
   52858           0 :     ALLOC_MUTEX(SgOmpInclusiveClause, lock);
   52859             : 
   52860             : #if ROSE_ALLOC_TRACE == 2
   52861             : //    printf("SgOmpInclusiveClause::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgOmpInclusiveClause::next_node);
   52862             : #endif
   52863             : 
   52864             : #if USE_CPP_NEW_DELETE_OPERATORS
   52865             :     void *mem = ROSE_MALLOC(Size);
   52866             :     ALLOC_MUTEX(SgOmpInclusiveClause, unlock);
   52867             :     return mem;
   52868             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   52869             : #if ROSE_PEDANTIC_ALLOC
   52870             :     ROSE_ASSERT(Size == sizeof(SgOmpInclusiveClause));
   52871             : #else
   52872           0 :     if (Size != sizeof(SgOmpInclusiveClause)) {
   52873           0 :       void * object = ROSE_MALLOC(Size);
   52874           0 :       ALLOC_MUTEX(SgOmpInclusiveClause, unlock);
   52875             :       return object;
   52876             :     }
   52877             : #endif
   52878             : 
   52879           0 :     if (SgOmpInclusiveClause::next_node == nullptr) {
   52880           0 :         SgOmpInclusiveClause * alloc = (SgOmpInclusiveClause*) ROSE_MALLOC ( SgOmpInclusiveClause::pool_size * sizeof(SgOmpInclusiveClause) );
   52881           0 :         ROSE_ASSERT(alloc != nullptr);
   52882             : 
   52883             : #if ROSE_ALLOC_TRACE == 2
   52884             : //        printf("SgOmpInclusiveClause::alloc\n  block[%zi] = [ %p , %p [\n", SgOmpInclusiveClause::pools.size(), alloc, alloc + SgOmpInclusiveClause::pool_size);
   52885             : #endif
   52886             : 
   52887             : #if ROSE_ALLOC_MEMSET == 1
   52888             : #elif ROSE_ALLOC_MEMSET == 2
   52889             :         memset(alloc, 0x00, SgOmpInclusiveClause::pool_size * sizeof(SgOmpInclusiveClause));
   52890             : #elif ROSE_ALLOC_MEMSET == 3
   52891             :         memset(alloc, 0xAA, SgOmpInclusiveClause::pool_size * sizeof(SgOmpInclusiveClause));
   52892             : #endif
   52893           0 :         for (unsigned i=0; i < SgOmpInclusiveClause::pool_size-1; i++) {
   52894           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
   52895             :         }
   52896           0 :         alloc[SgOmpInclusiveClause::pool_size-1].p_freepointer = nullptr;
   52897             : 
   52898           0 :         SgOmpInclusiveClause::pools.push_back ( (unsigned char *) alloc );
   52899           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgOmpInclusiveClause::pool_size * sizeof(SgOmpInclusiveClause), V_SgOmpInclusiveClause ) );
   52900           0 :         SgOmpInclusiveClause::next_node = alloc;
   52901             :     }
   52902           0 :     ROSE_ASSERT(SgOmpInclusiveClause::next_node != nullptr);
   52903             : 
   52904           0 :     SgOmpInclusiveClause * object = SgOmpInclusiveClause::next_node;
   52905           0 :     SgOmpInclusiveClause::next_node = (SgOmpInclusiveClause*)(object->p_freepointer);
   52906             : 
   52907             : #if ROSE_ALLOC_TRACE == 2
   52908             :     printf("SgOmpInclusiveClause::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpInclusiveClause::next_node);
   52909             : #endif
   52910             : 
   52911           0 :     SgNode * fp = object->p_freepointer;
   52912             : #if ROSE_ALLOC_MEMSET == 1
   52913             : #elif ROSE_ALLOC_MEMSET == 2
   52914             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpInclusiveClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   52915             : #elif ROSE_ALLOC_MEMSET == 3
   52916             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgOmpInclusiveClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   52917             : #endif
   52918           0 :     object->p_freepointer = fp;
   52919             : 
   52920             : #if ROSE_ALLOC_TRACE == 2
   52921             : //    printf("SgOmpInclusiveClause::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpInclusiveClause::next_node);
   52922             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   52923             :     Rose::MemPool::snapshot(oss.str());
   52924             :     alloc_trace_cnt++;
   52925             : #endif
   52926             : 
   52927           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   52928             : 
   52929           0 :     ALLOC_MUTEX(SgOmpInclusiveClause, unlock);
   52930             : 
   52931             :     return object;
   52932             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   52933             : }
   52934             : 
   52935             : 
   52936             : 
   52937             : /*! \brief Delete operator for SgOmpInclusiveClause.
   52938             : 
   52939             :    This delete operator implements deallocation using memory pools to 
   52940             :    provide most efficent use of the heap within construction of large ASTs.
   52941             : 
   52942             : \internal The new and delete operators use the lower level C malloc/free
   52943             :    function calls for performance and to make sure that mixing of malloc/free
   52944             :    and new/delete by the used can be caught more readily.  This may change
   52945             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   52946             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   52947             :    deallocate memory allocated using ROSE_MALLOC.
   52948             : */
   52949           0 : void SgOmpInclusiveClause::operator delete(void *Pointer, size_t Size)
   52950             : {
   52951             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   52952             :      * or throwing an exception. */
   52953           0 :     ALLOC_MUTEX(SgOmpInclusiveClause, lock);
   52954             : 
   52955             : #if USE_CPP_NEW_DELETE_OPERATORS
   52956             :     ROSE_FREE(Pointer);
   52957             : #else
   52958             : #if ROSE_PEDANTIC_ALLOC
   52959             :     ROSE_ASSERT(Size == sizeof(SgOmpInclusiveClause));
   52960             : #else
   52961           0 :     if (Size != sizeof(SgOmpInclusiveClause)) {
   52962           0 :       ROSE_FREE(Pointer);
   52963           0 :       ALLOC_MUTEX(SgOmpInclusiveClause, unlock);
   52964             :       return;
   52965             :     }
   52966             : #endif
   52967             : 
   52968           0 :     SgOmpInclusiveClause * object = (SgOmpInclusiveClause*) Pointer;
   52969           0 :     ROSE_ASSERT(object != nullptr);
   52970             : 
   52971             : #if ROSE_ALLOC_TRACE == 2
   52972             : //  printf("SgOmpInclusiveClause::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpInclusiveClause::next_node);
   52973             :     printf("SgOmpInclusiveClause::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpInclusiveClause::next_node);
   52974             : #endif
   52975             : 
   52976             : #if ROSE_PEDANTIC_ALLOC
   52977             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   52978             : #endif
   52979             : 
   52980             : #if ROSE_ALLOC_MEMSET == 1
   52981             : #elif ROSE_ALLOC_MEMSET == 2
   52982             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpInclusiveClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   52983             : #elif ROSE_ALLOC_MEMSET == 3
   52984             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgOmpInclusiveClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   52985             : #endif
   52986             : 
   52987             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   52988             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   52989             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   52990             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   52991             : #else
   52992           0 :     object->p_freepointer = SgOmpInclusiveClause::next_node;
   52993           0 :     SgOmpInclusiveClause::next_node = object;
   52994             : #endif
   52995             : 
   52996             : #if ROSE_ALLOC_TRACE == 2
   52997             : //  printf("SgOmpInclusiveClause::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpInclusiveClause::next_node);
   52998             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   52999             :     Rose::MemPool::snapshot(oss.str());
   53000             :     alloc_trace_cnt++;
   53001             : #endif
   53002             : 
   53003             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   53004             : 
   53005           0 :     ALLOC_MUTEX(SgOmpInclusiveClause, unlock);
   53006             : }
   53007             : 
   53008             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   53009             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   53010             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   53011             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   53012             : // Also, note comment below from Robb (copied from the Common.code file).
   53013             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   53014             : //
   53015             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   53016             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   53017             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   53018             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   53019             : #if 0
   53020             : void SgOmpInclusiveClause::operator delete(void* pointer) { SgOmpInclusiveClause::operator delete (pointer, sizeof(SgOmpInclusiveClause)); };
   53021             : #endif
   53022             : /* #line 53023 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   53023             : 
   53024             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   53025             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   53026             : // obviously imply C++.
   53027             : 
   53028             : // This implements the support within ROSE for memory pools.  Memory pools
   53029             : // support the most condensed usage of memory within the construction of
   53030             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   53031             : // by a new operator written for each class.
   53032             : 
   53033             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   53034             :     // User wants multi-thread support and POSIX threads are available.
   53035             : #   include <pthread.h>
   53036             :     static pthread_mutex_t SgOmpExclusiveClause_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   53037             : #else
   53038             :      // Cause synchronization to be skipped.
   53039             : #    ifndef ALLOC_MUTEX
   53040             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   53041             : #    endif
   53042             : #    ifdef _REENTRANT
   53043             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   53044             : #       ifdef _MSC_VER
   53045             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   53046             : #       else
   53047             : #           warning "POSIX threads are not available; synchronization being skipped"
   53048             : #       endif
   53049             : #    endif
   53050             : #endif
   53051             : 
   53052             : #ifndef ROSE_ALLOC_TRACE
   53053             : #  define ROSE_ALLOC_TRACE 0
   53054             : #endif
   53055             : 
   53056             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   53057             : #define ROSE_ALLOC_TRACE_CNT
   53058             : #include "memory-pool-snapshot.h"
   53059             : unsigned long alloc_trace_cnt = 0;
   53060             : #endif
   53061             : 
   53062             : #if ROSE_ALLOC_TRACE
   53063             : const unsigned SgOmpExclusiveClause::pool_size = 5;
   53064             : #else
   53065             : const unsigned SgOmpExclusiveClause::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   53066             : #endif
   53067             : 
   53068             : #ifndef ROSE_ALLOC_MEMSET
   53069             : #  define ROSE_ALLOC_MEMSET 0
   53070             : #endif
   53071             : 
   53072             : #ifndef ROSE_PEDANTIC_ALLOC
   53073             : #  define ROSE_PEDANTIC_ALLOC 0
   53074             : #endif
   53075             : 
   53076             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   53077             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   53078             : #endif
   53079             : 
   53080             : #if !defined(SGNODE__ALL_POOLS)
   53081             : #define SGNODE__ALL_POOLS
   53082             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   53083             : #endif
   53084             : 
   53085             : SgOmpExclusiveClause* SgOmpExclusiveClause::next_node = nullptr;
   53086             : std::vector<unsigned char*> SgOmpExclusiveClause::pools;
   53087             : 
   53088             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   53089             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   53090             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   53091             : // around this macro definition rather than each use).
   53092             : #ifndef ALLOC_MUTEX
   53093             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   53094             :         do {                                                                     \
   53095             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   53096             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   53097             :                 abort();                                                         \
   53098             :             }                                                                    \
   53099             :         } while (0);
   53100             : #endif
   53101             : 
   53102             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   53103             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   53104             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   53105             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   53106             : 
   53107             : /*! \brief New operator for SgOmpExclusiveClause.
   53108             : 
   53109             :    This new operator implements memory pools to provide most efficent 
   53110             :    use of the heap within construction of large ASTs.
   53111             : 
   53112             : \internal The new and delete operators use the lower level C malloc/free
   53113             :    function calls for performance and to make sure that mixing of malloc/free
   53114             :    and new/delete by the used can be caught more readily.  This may change
   53115             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   53116             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   53117             :    deallocate memory allocated using ROSE_MALLOC.
   53118             : */
   53119           1 : void *SgOmpExclusiveClause::operator new ( size_t Size )
   53120             : {
   53121             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   53122             :      * returning or throwing an exception. */
   53123           1 :     ALLOC_MUTEX(SgOmpExclusiveClause, lock);
   53124             : 
   53125             : #if ROSE_ALLOC_TRACE == 2
   53126             : //    printf("SgOmpExclusiveClause::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgOmpExclusiveClause::next_node);
   53127             : #endif
   53128             : 
   53129             : #if USE_CPP_NEW_DELETE_OPERATORS
   53130             :     void *mem = ROSE_MALLOC(Size);
   53131             :     ALLOC_MUTEX(SgOmpExclusiveClause, unlock);
   53132             :     return mem;
   53133             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   53134             : #if ROSE_PEDANTIC_ALLOC
   53135             :     ROSE_ASSERT(Size == sizeof(SgOmpExclusiveClause));
   53136             : #else
   53137           1 :     if (Size != sizeof(SgOmpExclusiveClause)) {
   53138           0 :       void * object = ROSE_MALLOC(Size);
   53139           0 :       ALLOC_MUTEX(SgOmpExclusiveClause, unlock);
   53140             :       return object;
   53141             :     }
   53142             : #endif
   53143             : 
   53144           1 :     if (SgOmpExclusiveClause::next_node == nullptr) {
   53145           1 :         SgOmpExclusiveClause * alloc = (SgOmpExclusiveClause*) ROSE_MALLOC ( SgOmpExclusiveClause::pool_size * sizeof(SgOmpExclusiveClause) );
   53146           1 :         ROSE_ASSERT(alloc != nullptr);
   53147             : 
   53148             : #if ROSE_ALLOC_TRACE == 2
   53149             : //        printf("SgOmpExclusiveClause::alloc\n  block[%zi] = [ %p , %p [\n", SgOmpExclusiveClause::pools.size(), alloc, alloc + SgOmpExclusiveClause::pool_size);
   53150             : #endif
   53151             : 
   53152             : #if ROSE_ALLOC_MEMSET == 1
   53153             : #elif ROSE_ALLOC_MEMSET == 2
   53154             :         memset(alloc, 0x00, SgOmpExclusiveClause::pool_size * sizeof(SgOmpExclusiveClause));
   53155             : #elif ROSE_ALLOC_MEMSET == 3
   53156             :         memset(alloc, 0xAA, SgOmpExclusiveClause::pool_size * sizeof(SgOmpExclusiveClause));
   53157             : #endif
   53158        2000 :         for (unsigned i=0; i < SgOmpExclusiveClause::pool_size-1; i++) {
   53159        1999 :           alloc[i].p_freepointer = &(alloc[i+1]);
   53160             :         }
   53161           1 :         alloc[SgOmpExclusiveClause::pool_size-1].p_freepointer = nullptr;
   53162             : 
   53163           1 :         SgOmpExclusiveClause::pools.push_back ( (unsigned char *) alloc );
   53164           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgOmpExclusiveClause::pool_size * sizeof(SgOmpExclusiveClause), V_SgOmpExclusiveClause ) );
   53165           1 :         SgOmpExclusiveClause::next_node = alloc;
   53166             :     }
   53167           1 :     ROSE_ASSERT(SgOmpExclusiveClause::next_node != nullptr);
   53168             : 
   53169           1 :     SgOmpExclusiveClause * object = SgOmpExclusiveClause::next_node;
   53170           1 :     SgOmpExclusiveClause::next_node = (SgOmpExclusiveClause*)(object->p_freepointer);
   53171             : 
   53172             : #if ROSE_ALLOC_TRACE == 2
   53173             :     printf("SgOmpExclusiveClause::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpExclusiveClause::next_node);
   53174             : #endif
   53175             : 
   53176           1 :     SgNode * fp = object->p_freepointer;
   53177             : #if ROSE_ALLOC_MEMSET == 1
   53178             : #elif ROSE_ALLOC_MEMSET == 2
   53179             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpExclusiveClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   53180             : #elif ROSE_ALLOC_MEMSET == 3
   53181             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgOmpExclusiveClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   53182             : #endif
   53183           1 :     object->p_freepointer = fp;
   53184             : 
   53185             : #if ROSE_ALLOC_TRACE == 2
   53186             : //    printf("SgOmpExclusiveClause::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpExclusiveClause::next_node);
   53187             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   53188             :     Rose::MemPool::snapshot(oss.str());
   53189             :     alloc_trace_cnt++;
   53190             : #endif
   53191             : 
   53192           1 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   53193             : 
   53194           1 :     ALLOC_MUTEX(SgOmpExclusiveClause, unlock);
   53195             : 
   53196             :     return object;
   53197             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   53198             : }
   53199             : 
   53200             : 
   53201             : 
   53202             : /*! \brief Delete operator for SgOmpExclusiveClause.
   53203             : 
   53204             :    This delete operator implements deallocation using memory pools to 
   53205             :    provide most efficent use of the heap within construction of large ASTs.
   53206             : 
   53207             : \internal The new and delete operators use the lower level C malloc/free
   53208             :    function calls for performance and to make sure that mixing of malloc/free
   53209             :    and new/delete by the used can be caught more readily.  This may change
   53210             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   53211             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   53212             :    deallocate memory allocated using ROSE_MALLOC.
   53213             : */
   53214           0 : void SgOmpExclusiveClause::operator delete(void *Pointer, size_t Size)
   53215             : {
   53216             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   53217             :      * or throwing an exception. */
   53218           0 :     ALLOC_MUTEX(SgOmpExclusiveClause, lock);
   53219             : 
   53220             : #if USE_CPP_NEW_DELETE_OPERATORS
   53221             :     ROSE_FREE(Pointer);
   53222             : #else
   53223             : #if ROSE_PEDANTIC_ALLOC
   53224             :     ROSE_ASSERT(Size == sizeof(SgOmpExclusiveClause));
   53225             : #else
   53226           0 :     if (Size != sizeof(SgOmpExclusiveClause)) {
   53227           0 :       ROSE_FREE(Pointer);
   53228           0 :       ALLOC_MUTEX(SgOmpExclusiveClause, unlock);
   53229             :       return;
   53230             :     }
   53231             : #endif
   53232             : 
   53233           0 :     SgOmpExclusiveClause * object = (SgOmpExclusiveClause*) Pointer;
   53234           0 :     ROSE_ASSERT(object != nullptr);
   53235             : 
   53236             : #if ROSE_ALLOC_TRACE == 2
   53237             : //  printf("SgOmpExclusiveClause::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpExclusiveClause::next_node);
   53238             :     printf("SgOmpExclusiveClause::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpExclusiveClause::next_node);
   53239             : #endif
   53240             : 
   53241             : #if ROSE_PEDANTIC_ALLOC
   53242             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   53243             : #endif
   53244             : 
   53245             : #if ROSE_ALLOC_MEMSET == 1
   53246             : #elif ROSE_ALLOC_MEMSET == 2
   53247             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpExclusiveClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   53248             : #elif ROSE_ALLOC_MEMSET == 3
   53249             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgOmpExclusiveClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   53250             : #endif
   53251             : 
   53252             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   53253             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   53254             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   53255             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   53256             : #else
   53257           0 :     object->p_freepointer = SgOmpExclusiveClause::next_node;
   53258           0 :     SgOmpExclusiveClause::next_node = object;
   53259             : #endif
   53260             : 
   53261             : #if ROSE_ALLOC_TRACE == 2
   53262             : //  printf("SgOmpExclusiveClause::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpExclusiveClause::next_node);
   53263             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   53264             :     Rose::MemPool::snapshot(oss.str());
   53265             :     alloc_trace_cnt++;
   53266             : #endif
   53267             : 
   53268             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   53269             : 
   53270           0 :     ALLOC_MUTEX(SgOmpExclusiveClause, unlock);
   53271             : }
   53272             : 
   53273             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   53274             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   53275             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   53276             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   53277             : // Also, note comment below from Robb (copied from the Common.code file).
   53278             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   53279             : //
   53280             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   53281             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   53282             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   53283             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   53284             : #if 0
   53285             : void SgOmpExclusiveClause::operator delete(void* pointer) { SgOmpExclusiveClause::operator delete (pointer, sizeof(SgOmpExclusiveClause)); };
   53286             : #endif
   53287             : /* #line 53288 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   53288             : 
   53289             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   53290             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   53291             : // obviously imply C++.
   53292             : 
   53293             : // This implements the support within ROSE for memory pools.  Memory pools
   53294             : // support the most condensed usage of memory within the construction of
   53295             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   53296             : // by a new operator written for each class.
   53297             : 
   53298             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   53299             :     // User wants multi-thread support and POSIX threads are available.
   53300             : #   include <pthread.h>
   53301             :     static pthread_mutex_t SgOmpIsDevicePtrClause_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   53302             : #else
   53303             :      // Cause synchronization to be skipped.
   53304             : #    ifndef ALLOC_MUTEX
   53305             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   53306             : #    endif
   53307             : #    ifdef _REENTRANT
   53308             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   53309             : #       ifdef _MSC_VER
   53310             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   53311             : #       else
   53312             : #           warning "POSIX threads are not available; synchronization being skipped"
   53313             : #       endif
   53314             : #    endif
   53315             : #endif
   53316             : 
   53317             : #ifndef ROSE_ALLOC_TRACE
   53318             : #  define ROSE_ALLOC_TRACE 0
   53319             : #endif
   53320             : 
   53321             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   53322             : #define ROSE_ALLOC_TRACE_CNT
   53323             : #include "memory-pool-snapshot.h"
   53324             : unsigned long alloc_trace_cnt = 0;
   53325             : #endif
   53326             : 
   53327             : #if ROSE_ALLOC_TRACE
   53328             : const unsigned SgOmpIsDevicePtrClause::pool_size = 5;
   53329             : #else
   53330             : const unsigned SgOmpIsDevicePtrClause::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   53331             : #endif
   53332             : 
   53333             : #ifndef ROSE_ALLOC_MEMSET
   53334             : #  define ROSE_ALLOC_MEMSET 0
   53335             : #endif
   53336             : 
   53337             : #ifndef ROSE_PEDANTIC_ALLOC
   53338             : #  define ROSE_PEDANTIC_ALLOC 0
   53339             : #endif
   53340             : 
   53341             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   53342             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   53343             : #endif
   53344             : 
   53345             : #if !defined(SGNODE__ALL_POOLS)
   53346             : #define SGNODE__ALL_POOLS
   53347             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   53348             : #endif
   53349             : 
   53350             : SgOmpIsDevicePtrClause* SgOmpIsDevicePtrClause::next_node = nullptr;
   53351             : std::vector<unsigned char*> SgOmpIsDevicePtrClause::pools;
   53352             : 
   53353             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   53354             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   53355             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   53356             : // around this macro definition rather than each use).
   53357             : #ifndef ALLOC_MUTEX
   53358             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   53359             :         do {                                                                     \
   53360             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   53361             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   53362             :                 abort();                                                         \
   53363             :             }                                                                    \
   53364             :         } while (0);
   53365             : #endif
   53366             : 
   53367             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   53368             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   53369             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   53370             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   53371             : 
   53372             : /*! \brief New operator for SgOmpIsDevicePtrClause.
   53373             : 
   53374             :    This new operator implements memory pools to provide most efficent 
   53375             :    use of the heap within construction of large ASTs.
   53376             : 
   53377             : \internal The new and delete operators use the lower level C malloc/free
   53378             :    function calls for performance and to make sure that mixing of malloc/free
   53379             :    and new/delete by the used can be caught more readily.  This may change
   53380             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   53381             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   53382             :    deallocate memory allocated using ROSE_MALLOC.
   53383             : */
   53384           0 : void *SgOmpIsDevicePtrClause::operator new ( size_t Size )
   53385             : {
   53386             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   53387             :      * returning or throwing an exception. */
   53388           0 :     ALLOC_MUTEX(SgOmpIsDevicePtrClause, lock);
   53389             : 
   53390             : #if ROSE_ALLOC_TRACE == 2
   53391             : //    printf("SgOmpIsDevicePtrClause::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgOmpIsDevicePtrClause::next_node);
   53392             : #endif
   53393             : 
   53394             : #if USE_CPP_NEW_DELETE_OPERATORS
   53395             :     void *mem = ROSE_MALLOC(Size);
   53396             :     ALLOC_MUTEX(SgOmpIsDevicePtrClause, unlock);
   53397             :     return mem;
   53398             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   53399             : #if ROSE_PEDANTIC_ALLOC
   53400             :     ROSE_ASSERT(Size == sizeof(SgOmpIsDevicePtrClause));
   53401             : #else
   53402           0 :     if (Size != sizeof(SgOmpIsDevicePtrClause)) {
   53403           0 :       void * object = ROSE_MALLOC(Size);
   53404           0 :       ALLOC_MUTEX(SgOmpIsDevicePtrClause, unlock);
   53405             :       return object;
   53406             :     }
   53407             : #endif
   53408             : 
   53409           0 :     if (SgOmpIsDevicePtrClause::next_node == nullptr) {
   53410           0 :         SgOmpIsDevicePtrClause * alloc = (SgOmpIsDevicePtrClause*) ROSE_MALLOC ( SgOmpIsDevicePtrClause::pool_size * sizeof(SgOmpIsDevicePtrClause) );
   53411           0 :         ROSE_ASSERT(alloc != nullptr);
   53412             : 
   53413             : #if ROSE_ALLOC_TRACE == 2
   53414             : //        printf("SgOmpIsDevicePtrClause::alloc\n  block[%zi] = [ %p , %p [\n", SgOmpIsDevicePtrClause::pools.size(), alloc, alloc + SgOmpIsDevicePtrClause::pool_size);
   53415             : #endif
   53416             : 
   53417             : #if ROSE_ALLOC_MEMSET == 1
   53418             : #elif ROSE_ALLOC_MEMSET == 2
   53419             :         memset(alloc, 0x00, SgOmpIsDevicePtrClause::pool_size * sizeof(SgOmpIsDevicePtrClause));
   53420             : #elif ROSE_ALLOC_MEMSET == 3
   53421             :         memset(alloc, 0xAA, SgOmpIsDevicePtrClause::pool_size * sizeof(SgOmpIsDevicePtrClause));
   53422             : #endif
   53423           0 :         for (unsigned i=0; i < SgOmpIsDevicePtrClause::pool_size-1; i++) {
   53424           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
   53425             :         }
   53426           0 :         alloc[SgOmpIsDevicePtrClause::pool_size-1].p_freepointer = nullptr;
   53427             : 
   53428           0 :         SgOmpIsDevicePtrClause::pools.push_back ( (unsigned char *) alloc );
   53429           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgOmpIsDevicePtrClause::pool_size * sizeof(SgOmpIsDevicePtrClause), V_SgOmpIsDevicePtrClause ) );
   53430           0 :         SgOmpIsDevicePtrClause::next_node = alloc;
   53431             :     }
   53432           0 :     ROSE_ASSERT(SgOmpIsDevicePtrClause::next_node != nullptr);
   53433             : 
   53434           0 :     SgOmpIsDevicePtrClause * object = SgOmpIsDevicePtrClause::next_node;
   53435           0 :     SgOmpIsDevicePtrClause::next_node = (SgOmpIsDevicePtrClause*)(object->p_freepointer);
   53436             : 
   53437             : #if ROSE_ALLOC_TRACE == 2
   53438             :     printf("SgOmpIsDevicePtrClause::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpIsDevicePtrClause::next_node);
   53439             : #endif
   53440             : 
   53441           0 :     SgNode * fp = object->p_freepointer;
   53442             : #if ROSE_ALLOC_MEMSET == 1
   53443             : #elif ROSE_ALLOC_MEMSET == 2
   53444             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpIsDevicePtrClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   53445             : #elif ROSE_ALLOC_MEMSET == 3
   53446             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgOmpIsDevicePtrClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   53447             : #endif
   53448           0 :     object->p_freepointer = fp;
   53449             : 
   53450             : #if ROSE_ALLOC_TRACE == 2
   53451             : //    printf("SgOmpIsDevicePtrClause::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpIsDevicePtrClause::next_node);
   53452             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   53453             :     Rose::MemPool::snapshot(oss.str());
   53454             :     alloc_trace_cnt++;
   53455             : #endif
   53456             : 
   53457           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   53458             : 
   53459           0 :     ALLOC_MUTEX(SgOmpIsDevicePtrClause, unlock);
   53460             : 
   53461             :     return object;
   53462             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   53463             : }
   53464             : 
   53465             : 
   53466             : 
   53467             : /*! \brief Delete operator for SgOmpIsDevicePtrClause.
   53468             : 
   53469             :    This delete operator implements deallocation using memory pools to 
   53470             :    provide most efficent use of the heap within construction of large ASTs.
   53471             : 
   53472             : \internal The new and delete operators use the lower level C malloc/free
   53473             :    function calls for performance and to make sure that mixing of malloc/free
   53474             :    and new/delete by the used can be caught more readily.  This may change
   53475             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   53476             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   53477             :    deallocate memory allocated using ROSE_MALLOC.
   53478             : */
   53479           0 : void SgOmpIsDevicePtrClause::operator delete(void *Pointer, size_t Size)
   53480             : {
   53481             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   53482             :      * or throwing an exception. */
   53483           0 :     ALLOC_MUTEX(SgOmpIsDevicePtrClause, lock);
   53484             : 
   53485             : #if USE_CPP_NEW_DELETE_OPERATORS
   53486             :     ROSE_FREE(Pointer);
   53487             : #else
   53488             : #if ROSE_PEDANTIC_ALLOC
   53489             :     ROSE_ASSERT(Size == sizeof(SgOmpIsDevicePtrClause));
   53490             : #else
   53491           0 :     if (Size != sizeof(SgOmpIsDevicePtrClause)) {
   53492           0 :       ROSE_FREE(Pointer);
   53493           0 :       ALLOC_MUTEX(SgOmpIsDevicePtrClause, unlock);
   53494             :       return;
   53495             :     }
   53496             : #endif
   53497             : 
   53498           0 :     SgOmpIsDevicePtrClause * object = (SgOmpIsDevicePtrClause*) Pointer;
   53499           0 :     ROSE_ASSERT(object != nullptr);
   53500             : 
   53501             : #if ROSE_ALLOC_TRACE == 2
   53502             : //  printf("SgOmpIsDevicePtrClause::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpIsDevicePtrClause::next_node);
   53503             :     printf("SgOmpIsDevicePtrClause::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpIsDevicePtrClause::next_node);
   53504             : #endif
   53505             : 
   53506             : #if ROSE_PEDANTIC_ALLOC
   53507             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   53508             : #endif
   53509             : 
   53510             : #if ROSE_ALLOC_MEMSET == 1
   53511             : #elif ROSE_ALLOC_MEMSET == 2
   53512             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpIsDevicePtrClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   53513             : #elif ROSE_ALLOC_MEMSET == 3
   53514             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgOmpIsDevicePtrClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   53515             : #endif
   53516             : 
   53517             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   53518             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   53519             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   53520             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   53521             : #else
   53522           0 :     object->p_freepointer = SgOmpIsDevicePtrClause::next_node;
   53523           0 :     SgOmpIsDevicePtrClause::next_node = object;
   53524             : #endif
   53525             : 
   53526             : #if ROSE_ALLOC_TRACE == 2
   53527             : //  printf("SgOmpIsDevicePtrClause::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpIsDevicePtrClause::next_node);
   53528             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   53529             :     Rose::MemPool::snapshot(oss.str());
   53530             :     alloc_trace_cnt++;
   53531             : #endif
   53532             : 
   53533             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   53534             : 
   53535           0 :     ALLOC_MUTEX(SgOmpIsDevicePtrClause, unlock);
   53536             : }
   53537             : 
   53538             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   53539             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   53540             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   53541             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   53542             : // Also, note comment below from Robb (copied from the Common.code file).
   53543             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   53544             : //
   53545             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   53546             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   53547             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   53548             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   53549             : #if 0
   53550             : void SgOmpIsDevicePtrClause::operator delete(void* pointer) { SgOmpIsDevicePtrClause::operator delete (pointer, sizeof(SgOmpIsDevicePtrClause)); };
   53551             : #endif
   53552             : /* #line 53553 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   53553             : 
   53554             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   53555             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   53556             : // obviously imply C++.
   53557             : 
   53558             : // This implements the support within ROSE for memory pools.  Memory pools
   53559             : // support the most condensed usage of memory within the construction of
   53560             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   53561             : // by a new operator written for each class.
   53562             : 
   53563             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   53564             :     // User wants multi-thread support and POSIX threads are available.
   53565             : #   include <pthread.h>
   53566             :     static pthread_mutex_t SgOmpUseDevicePtrClause_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   53567             : #else
   53568             :      // Cause synchronization to be skipped.
   53569             : #    ifndef ALLOC_MUTEX
   53570             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   53571             : #    endif
   53572             : #    ifdef _REENTRANT
   53573             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   53574             : #       ifdef _MSC_VER
   53575             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   53576             : #       else
   53577             : #           warning "POSIX threads are not available; synchronization being skipped"
   53578             : #       endif
   53579             : #    endif
   53580             : #endif
   53581             : 
   53582             : #ifndef ROSE_ALLOC_TRACE
   53583             : #  define ROSE_ALLOC_TRACE 0
   53584             : #endif
   53585             : 
   53586             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   53587             : #define ROSE_ALLOC_TRACE_CNT
   53588             : #include "memory-pool-snapshot.h"
   53589             : unsigned long alloc_trace_cnt = 0;
   53590             : #endif
   53591             : 
   53592             : #if ROSE_ALLOC_TRACE
   53593             : const unsigned SgOmpUseDevicePtrClause::pool_size = 5;
   53594             : #else
   53595             : const unsigned SgOmpUseDevicePtrClause::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   53596             : #endif
   53597             : 
   53598             : #ifndef ROSE_ALLOC_MEMSET
   53599             : #  define ROSE_ALLOC_MEMSET 0
   53600             : #endif
   53601             : 
   53602             : #ifndef ROSE_PEDANTIC_ALLOC
   53603             : #  define ROSE_PEDANTIC_ALLOC 0
   53604             : #endif
   53605             : 
   53606             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   53607             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   53608             : #endif
   53609             : 
   53610             : #if !defined(SGNODE__ALL_POOLS)
   53611             : #define SGNODE__ALL_POOLS
   53612             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   53613             : #endif
   53614             : 
   53615             : SgOmpUseDevicePtrClause* SgOmpUseDevicePtrClause::next_node = nullptr;
   53616             : std::vector<unsigned char*> SgOmpUseDevicePtrClause::pools;
   53617             : 
   53618             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   53619             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   53620             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   53621             : // around this macro definition rather than each use).
   53622             : #ifndef ALLOC_MUTEX
   53623             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   53624             :         do {                                                                     \
   53625             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   53626             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   53627             :                 abort();                                                         \
   53628             :             }                                                                    \
   53629             :         } while (0);
   53630             : #endif
   53631             : 
   53632             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   53633             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   53634             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   53635             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   53636             : 
   53637             : /*! \brief New operator for SgOmpUseDevicePtrClause.
   53638             : 
   53639             :    This new operator implements memory pools to provide most efficent 
   53640             :    use of the heap within construction of large ASTs.
   53641             : 
   53642             : \internal The new and delete operators use the lower level C malloc/free
   53643             :    function calls for performance and to make sure that mixing of malloc/free
   53644             :    and new/delete by the used can be caught more readily.  This may change
   53645             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   53646             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   53647             :    deallocate memory allocated using ROSE_MALLOC.
   53648             : */
   53649           0 : void *SgOmpUseDevicePtrClause::operator new ( size_t Size )
   53650             : {
   53651             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   53652             :      * returning or throwing an exception. */
   53653           0 :     ALLOC_MUTEX(SgOmpUseDevicePtrClause, lock);
   53654             : 
   53655             : #if ROSE_ALLOC_TRACE == 2
   53656             : //    printf("SgOmpUseDevicePtrClause::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgOmpUseDevicePtrClause::next_node);
   53657             : #endif
   53658             : 
   53659             : #if USE_CPP_NEW_DELETE_OPERATORS
   53660             :     void *mem = ROSE_MALLOC(Size);
   53661             :     ALLOC_MUTEX(SgOmpUseDevicePtrClause, unlock);
   53662             :     return mem;
   53663             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   53664             : #if ROSE_PEDANTIC_ALLOC
   53665             :     ROSE_ASSERT(Size == sizeof(SgOmpUseDevicePtrClause));
   53666             : #else
   53667           0 :     if (Size != sizeof(SgOmpUseDevicePtrClause)) {
   53668           0 :       void * object = ROSE_MALLOC(Size);
   53669           0 :       ALLOC_MUTEX(SgOmpUseDevicePtrClause, unlock);
   53670             :       return object;
   53671             :     }
   53672             : #endif
   53673             : 
   53674           0 :     if (SgOmpUseDevicePtrClause::next_node == nullptr) {
   53675           0 :         SgOmpUseDevicePtrClause * alloc = (SgOmpUseDevicePtrClause*) ROSE_MALLOC ( SgOmpUseDevicePtrClause::pool_size * sizeof(SgOmpUseDevicePtrClause) );
   53676           0 :         ROSE_ASSERT(alloc != nullptr);
   53677             : 
   53678             : #if ROSE_ALLOC_TRACE == 2
   53679             : //        printf("SgOmpUseDevicePtrClause::alloc\n  block[%zi] = [ %p , %p [\n", SgOmpUseDevicePtrClause::pools.size(), alloc, alloc + SgOmpUseDevicePtrClause::pool_size);
   53680             : #endif
   53681             : 
   53682             : #if ROSE_ALLOC_MEMSET == 1
   53683             : #elif ROSE_ALLOC_MEMSET == 2
   53684             :         memset(alloc, 0x00, SgOmpUseDevicePtrClause::pool_size * sizeof(SgOmpUseDevicePtrClause));
   53685             : #elif ROSE_ALLOC_MEMSET == 3
   53686             :         memset(alloc, 0xAA, SgOmpUseDevicePtrClause::pool_size * sizeof(SgOmpUseDevicePtrClause));
   53687             : #endif
   53688           0 :         for (unsigned i=0; i < SgOmpUseDevicePtrClause::pool_size-1; i++) {
   53689           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
   53690             :         }
   53691           0 :         alloc[SgOmpUseDevicePtrClause::pool_size-1].p_freepointer = nullptr;
   53692             : 
   53693           0 :         SgOmpUseDevicePtrClause::pools.push_back ( (unsigned char *) alloc );
   53694           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgOmpUseDevicePtrClause::pool_size * sizeof(SgOmpUseDevicePtrClause), V_SgOmpUseDevicePtrClause ) );
   53695           0 :         SgOmpUseDevicePtrClause::next_node = alloc;
   53696             :     }
   53697           0 :     ROSE_ASSERT(SgOmpUseDevicePtrClause::next_node != nullptr);
   53698             : 
   53699           0 :     SgOmpUseDevicePtrClause * object = SgOmpUseDevicePtrClause::next_node;
   53700           0 :     SgOmpUseDevicePtrClause::next_node = (SgOmpUseDevicePtrClause*)(object->p_freepointer);
   53701             : 
   53702             : #if ROSE_ALLOC_TRACE == 2
   53703             :     printf("SgOmpUseDevicePtrClause::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpUseDevicePtrClause::next_node);
   53704             : #endif
   53705             : 
   53706           0 :     SgNode * fp = object->p_freepointer;
   53707             : #if ROSE_ALLOC_MEMSET == 1
   53708             : #elif ROSE_ALLOC_MEMSET == 2
   53709             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpUseDevicePtrClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   53710             : #elif ROSE_ALLOC_MEMSET == 3
   53711             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgOmpUseDevicePtrClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   53712             : #endif
   53713           0 :     object->p_freepointer = fp;
   53714             : 
   53715             : #if ROSE_ALLOC_TRACE == 2
   53716             : //    printf("SgOmpUseDevicePtrClause::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpUseDevicePtrClause::next_node);
   53717             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   53718             :     Rose::MemPool::snapshot(oss.str());
   53719             :     alloc_trace_cnt++;
   53720             : #endif
   53721             : 
   53722           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   53723             : 
   53724           0 :     ALLOC_MUTEX(SgOmpUseDevicePtrClause, unlock);
   53725             : 
   53726             :     return object;
   53727             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   53728             : }
   53729             : 
   53730             : 
   53731             : 
   53732             : /*! \brief Delete operator for SgOmpUseDevicePtrClause.
   53733             : 
   53734             :    This delete operator implements deallocation using memory pools to 
   53735             :    provide most efficent use of the heap within construction of large ASTs.
   53736             : 
   53737             : \internal The new and delete operators use the lower level C malloc/free
   53738             :    function calls for performance and to make sure that mixing of malloc/free
   53739             :    and new/delete by the used can be caught more readily.  This may change
   53740             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   53741             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   53742             :    deallocate memory allocated using ROSE_MALLOC.
   53743             : */
   53744           0 : void SgOmpUseDevicePtrClause::operator delete(void *Pointer, size_t Size)
   53745             : {
   53746             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   53747             :      * or throwing an exception. */
   53748           0 :     ALLOC_MUTEX(SgOmpUseDevicePtrClause, lock);
   53749             : 
   53750             : #if USE_CPP_NEW_DELETE_OPERATORS
   53751             :     ROSE_FREE(Pointer);
   53752             : #else
   53753             : #if ROSE_PEDANTIC_ALLOC
   53754             :     ROSE_ASSERT(Size == sizeof(SgOmpUseDevicePtrClause));
   53755             : #else
   53756           0 :     if (Size != sizeof(SgOmpUseDevicePtrClause)) {
   53757           0 :       ROSE_FREE(Pointer);
   53758           0 :       ALLOC_MUTEX(SgOmpUseDevicePtrClause, unlock);
   53759             :       return;
   53760             :     }
   53761             : #endif
   53762             : 
   53763           0 :     SgOmpUseDevicePtrClause * object = (SgOmpUseDevicePtrClause*) Pointer;
   53764           0 :     ROSE_ASSERT(object != nullptr);
   53765             : 
   53766             : #if ROSE_ALLOC_TRACE == 2
   53767             : //  printf("SgOmpUseDevicePtrClause::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpUseDevicePtrClause::next_node);
   53768             :     printf("SgOmpUseDevicePtrClause::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpUseDevicePtrClause::next_node);
   53769             : #endif
   53770             : 
   53771             : #if ROSE_PEDANTIC_ALLOC
   53772             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   53773             : #endif
   53774             : 
   53775             : #if ROSE_ALLOC_MEMSET == 1
   53776             : #elif ROSE_ALLOC_MEMSET == 2
   53777             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpUseDevicePtrClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   53778             : #elif ROSE_ALLOC_MEMSET == 3
   53779             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgOmpUseDevicePtrClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   53780             : #endif
   53781             : 
   53782             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   53783             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   53784             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   53785             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   53786             : #else
   53787           0 :     object->p_freepointer = SgOmpUseDevicePtrClause::next_node;
   53788           0 :     SgOmpUseDevicePtrClause::next_node = object;
   53789             : #endif
   53790             : 
   53791             : #if ROSE_ALLOC_TRACE == 2
   53792             : //  printf("SgOmpUseDevicePtrClause::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpUseDevicePtrClause::next_node);
   53793             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   53794             :     Rose::MemPool::snapshot(oss.str());
   53795             :     alloc_trace_cnt++;
   53796             : #endif
   53797             : 
   53798             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   53799             : 
   53800           0 :     ALLOC_MUTEX(SgOmpUseDevicePtrClause, unlock);
   53801             : }
   53802             : 
   53803             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   53804             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   53805             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   53806             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   53807             : // Also, note comment below from Robb (copied from the Common.code file).
   53808             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   53809             : //
   53810             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   53811             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   53812             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   53813             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   53814             : #if 0
   53815             : void SgOmpUseDevicePtrClause::operator delete(void* pointer) { SgOmpUseDevicePtrClause::operator delete (pointer, sizeof(SgOmpUseDevicePtrClause)); };
   53816             : #endif
   53817             : /* #line 53818 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   53818             : 
   53819             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   53820             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   53821             : // obviously imply C++.
   53822             : 
   53823             : // This implements the support within ROSE for memory pools.  Memory pools
   53824             : // support the most condensed usage of memory within the construction of
   53825             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   53826             : // by a new operator written for each class.
   53827             : 
   53828             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   53829             :     // User wants multi-thread support and POSIX threads are available.
   53830             : #   include <pthread.h>
   53831             :     static pthread_mutex_t SgOmpUseDeviceAddrClause_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   53832             : #else
   53833             :      // Cause synchronization to be skipped.
   53834             : #    ifndef ALLOC_MUTEX
   53835             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   53836             : #    endif
   53837             : #    ifdef _REENTRANT
   53838             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   53839             : #       ifdef _MSC_VER
   53840             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   53841             : #       else
   53842             : #           warning "POSIX threads are not available; synchronization being skipped"
   53843             : #       endif
   53844             : #    endif
   53845             : #endif
   53846             : 
   53847             : #ifndef ROSE_ALLOC_TRACE
   53848             : #  define ROSE_ALLOC_TRACE 0
   53849             : #endif
   53850             : 
   53851             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   53852             : #define ROSE_ALLOC_TRACE_CNT
   53853             : #include "memory-pool-snapshot.h"
   53854             : unsigned long alloc_trace_cnt = 0;
   53855             : #endif
   53856             : 
   53857             : #if ROSE_ALLOC_TRACE
   53858             : const unsigned SgOmpUseDeviceAddrClause::pool_size = 5;
   53859             : #else
   53860             : const unsigned SgOmpUseDeviceAddrClause::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   53861             : #endif
   53862             : 
   53863             : #ifndef ROSE_ALLOC_MEMSET
   53864             : #  define ROSE_ALLOC_MEMSET 0
   53865             : #endif
   53866             : 
   53867             : #ifndef ROSE_PEDANTIC_ALLOC
   53868             : #  define ROSE_PEDANTIC_ALLOC 0
   53869             : #endif
   53870             : 
   53871             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   53872             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   53873             : #endif
   53874             : 
   53875             : #if !defined(SGNODE__ALL_POOLS)
   53876             : #define SGNODE__ALL_POOLS
   53877             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   53878             : #endif
   53879             : 
   53880             : SgOmpUseDeviceAddrClause* SgOmpUseDeviceAddrClause::next_node = nullptr;
   53881             : std::vector<unsigned char*> SgOmpUseDeviceAddrClause::pools;
   53882             : 
   53883             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   53884             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   53885             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   53886             : // around this macro definition rather than each use).
   53887             : #ifndef ALLOC_MUTEX
   53888             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   53889             :         do {                                                                     \
   53890             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   53891             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   53892             :                 abort();                                                         \
   53893             :             }                                                                    \
   53894             :         } while (0);
   53895             : #endif
   53896             : 
   53897             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   53898             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   53899             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   53900             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   53901             : 
   53902             : /*! \brief New operator for SgOmpUseDeviceAddrClause.
   53903             : 
   53904             :    This new operator implements memory pools to provide most efficent 
   53905             :    use of the heap within construction of large ASTs.
   53906             : 
   53907             : \internal The new and delete operators use the lower level C malloc/free
   53908             :    function calls for performance and to make sure that mixing of malloc/free
   53909             :    and new/delete by the used can be caught more readily.  This may change
   53910             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   53911             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   53912             :    deallocate memory allocated using ROSE_MALLOC.
   53913             : */
   53914           0 : void *SgOmpUseDeviceAddrClause::operator new ( size_t Size )
   53915             : {
   53916             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   53917             :      * returning or throwing an exception. */
   53918           0 :     ALLOC_MUTEX(SgOmpUseDeviceAddrClause, lock);
   53919             : 
   53920             : #if ROSE_ALLOC_TRACE == 2
   53921             : //    printf("SgOmpUseDeviceAddrClause::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgOmpUseDeviceAddrClause::next_node);
   53922             : #endif
   53923             : 
   53924             : #if USE_CPP_NEW_DELETE_OPERATORS
   53925             :     void *mem = ROSE_MALLOC(Size);
   53926             :     ALLOC_MUTEX(SgOmpUseDeviceAddrClause, unlock);
   53927             :     return mem;
   53928             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   53929             : #if ROSE_PEDANTIC_ALLOC
   53930             :     ROSE_ASSERT(Size == sizeof(SgOmpUseDeviceAddrClause));
   53931             : #else
   53932           0 :     if (Size != sizeof(SgOmpUseDeviceAddrClause)) {
   53933           0 :       void * object = ROSE_MALLOC(Size);
   53934           0 :       ALLOC_MUTEX(SgOmpUseDeviceAddrClause, unlock);
   53935             :       return object;
   53936             :     }
   53937             : #endif
   53938             : 
   53939           0 :     if (SgOmpUseDeviceAddrClause::next_node == nullptr) {
   53940           0 :         SgOmpUseDeviceAddrClause * alloc = (SgOmpUseDeviceAddrClause*) ROSE_MALLOC ( SgOmpUseDeviceAddrClause::pool_size * sizeof(SgOmpUseDeviceAddrClause) );
   53941           0 :         ROSE_ASSERT(alloc != nullptr);
   53942             : 
   53943             : #if ROSE_ALLOC_TRACE == 2
   53944             : //        printf("SgOmpUseDeviceAddrClause::alloc\n  block[%zi] = [ %p , %p [\n", SgOmpUseDeviceAddrClause::pools.size(), alloc, alloc + SgOmpUseDeviceAddrClause::pool_size);
   53945             : #endif
   53946             : 
   53947             : #if ROSE_ALLOC_MEMSET == 1
   53948             : #elif ROSE_ALLOC_MEMSET == 2
   53949             :         memset(alloc, 0x00, SgOmpUseDeviceAddrClause::pool_size * sizeof(SgOmpUseDeviceAddrClause));
   53950             : #elif ROSE_ALLOC_MEMSET == 3
   53951             :         memset(alloc, 0xAA, SgOmpUseDeviceAddrClause::pool_size * sizeof(SgOmpUseDeviceAddrClause));
   53952             : #endif
   53953           0 :         for (unsigned i=0; i < SgOmpUseDeviceAddrClause::pool_size-1; i++) {
   53954           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
   53955             :         }
   53956           0 :         alloc[SgOmpUseDeviceAddrClause::pool_size-1].p_freepointer = nullptr;
   53957             : 
   53958           0 :         SgOmpUseDeviceAddrClause::pools.push_back ( (unsigned char *) alloc );
   53959           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgOmpUseDeviceAddrClause::pool_size * sizeof(SgOmpUseDeviceAddrClause), V_SgOmpUseDeviceAddrClause ) );
   53960           0 :         SgOmpUseDeviceAddrClause::next_node = alloc;
   53961             :     }
   53962           0 :     ROSE_ASSERT(SgOmpUseDeviceAddrClause::next_node != nullptr);
   53963             : 
   53964           0 :     SgOmpUseDeviceAddrClause * object = SgOmpUseDeviceAddrClause::next_node;
   53965           0 :     SgOmpUseDeviceAddrClause::next_node = (SgOmpUseDeviceAddrClause*)(object->p_freepointer);
   53966             : 
   53967             : #if ROSE_ALLOC_TRACE == 2
   53968             :     printf("SgOmpUseDeviceAddrClause::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpUseDeviceAddrClause::next_node);
   53969             : #endif
   53970             : 
   53971           0 :     SgNode * fp = object->p_freepointer;
   53972             : #if ROSE_ALLOC_MEMSET == 1
   53973             : #elif ROSE_ALLOC_MEMSET == 2
   53974             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpUseDeviceAddrClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   53975             : #elif ROSE_ALLOC_MEMSET == 3
   53976             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgOmpUseDeviceAddrClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   53977             : #endif
   53978           0 :     object->p_freepointer = fp;
   53979             : 
   53980             : #if ROSE_ALLOC_TRACE == 2
   53981             : //    printf("SgOmpUseDeviceAddrClause::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpUseDeviceAddrClause::next_node);
   53982             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   53983             :     Rose::MemPool::snapshot(oss.str());
   53984             :     alloc_trace_cnt++;
   53985             : #endif
   53986             : 
   53987           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   53988             : 
   53989           0 :     ALLOC_MUTEX(SgOmpUseDeviceAddrClause, unlock);
   53990             : 
   53991             :     return object;
   53992             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   53993             : }
   53994             : 
   53995             : 
   53996             : 
   53997             : /*! \brief Delete operator for SgOmpUseDeviceAddrClause.
   53998             : 
   53999             :    This delete operator implements deallocation using memory pools to 
   54000             :    provide most efficent use of the heap within construction of large ASTs.
   54001             : 
   54002             : \internal The new and delete operators use the lower level C malloc/free
   54003             :    function calls for performance and to make sure that mixing of malloc/free
   54004             :    and new/delete by the used can be caught more readily.  This may change
   54005             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   54006             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   54007             :    deallocate memory allocated using ROSE_MALLOC.
   54008             : */
   54009           0 : void SgOmpUseDeviceAddrClause::operator delete(void *Pointer, size_t Size)
   54010             : {
   54011             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   54012             :      * or throwing an exception. */
   54013           0 :     ALLOC_MUTEX(SgOmpUseDeviceAddrClause, lock);
   54014             : 
   54015             : #if USE_CPP_NEW_DELETE_OPERATORS
   54016             :     ROSE_FREE(Pointer);
   54017             : #else
   54018             : #if ROSE_PEDANTIC_ALLOC
   54019             :     ROSE_ASSERT(Size == sizeof(SgOmpUseDeviceAddrClause));
   54020             : #else
   54021           0 :     if (Size != sizeof(SgOmpUseDeviceAddrClause)) {
   54022           0 :       ROSE_FREE(Pointer);
   54023           0 :       ALLOC_MUTEX(SgOmpUseDeviceAddrClause, unlock);
   54024             :       return;
   54025             :     }
   54026             : #endif
   54027             : 
   54028           0 :     SgOmpUseDeviceAddrClause * object = (SgOmpUseDeviceAddrClause*) Pointer;
   54029           0 :     ROSE_ASSERT(object != nullptr);
   54030             : 
   54031             : #if ROSE_ALLOC_TRACE == 2
   54032             : //  printf("SgOmpUseDeviceAddrClause::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpUseDeviceAddrClause::next_node);
   54033             :     printf("SgOmpUseDeviceAddrClause::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpUseDeviceAddrClause::next_node);
   54034             : #endif
   54035             : 
   54036             : #if ROSE_PEDANTIC_ALLOC
   54037             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   54038             : #endif
   54039             : 
   54040             : #if ROSE_ALLOC_MEMSET == 1
   54041             : #elif ROSE_ALLOC_MEMSET == 2
   54042             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpUseDeviceAddrClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   54043             : #elif ROSE_ALLOC_MEMSET == 3
   54044             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgOmpUseDeviceAddrClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   54045             : #endif
   54046             : 
   54047             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   54048             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   54049             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   54050             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   54051             : #else
   54052           0 :     object->p_freepointer = SgOmpUseDeviceAddrClause::next_node;
   54053           0 :     SgOmpUseDeviceAddrClause::next_node = object;
   54054             : #endif
   54055             : 
   54056             : #if ROSE_ALLOC_TRACE == 2
   54057             : //  printf("SgOmpUseDeviceAddrClause::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpUseDeviceAddrClause::next_node);
   54058             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   54059             :     Rose::MemPool::snapshot(oss.str());
   54060             :     alloc_trace_cnt++;
   54061             : #endif
   54062             : 
   54063             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   54064             : 
   54065           0 :     ALLOC_MUTEX(SgOmpUseDeviceAddrClause, unlock);
   54066             : }
   54067             : 
   54068             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   54069             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   54070             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   54071             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   54072             : // Also, note comment below from Robb (copied from the Common.code file).
   54073             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   54074             : //
   54075             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   54076             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   54077             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   54078             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   54079             : #if 0
   54080             : void SgOmpUseDeviceAddrClause::operator delete(void* pointer) { SgOmpUseDeviceAddrClause::operator delete (pointer, sizeof(SgOmpUseDeviceAddrClause)); };
   54081             : #endif
   54082             : /* #line 54083 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   54083             : 
   54084             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   54085             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   54086             : // obviously imply C++.
   54087             : 
   54088             : // This implements the support within ROSE for memory pools.  Memory pools
   54089             : // support the most condensed usage of memory within the construction of
   54090             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   54091             : // by a new operator written for each class.
   54092             : 
   54093             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   54094             :     // User wants multi-thread support and POSIX threads are available.
   54095             : #   include <pthread.h>
   54096             :     static pthread_mutex_t SgOmpSharedClause_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   54097             : #else
   54098             :      // Cause synchronization to be skipped.
   54099             : #    ifndef ALLOC_MUTEX
   54100             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   54101             : #    endif
   54102             : #    ifdef _REENTRANT
   54103             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   54104             : #       ifdef _MSC_VER
   54105             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   54106             : #       else
   54107             : #           warning "POSIX threads are not available; synchronization being skipped"
   54108             : #       endif
   54109             : #    endif
   54110             : #endif
   54111             : 
   54112             : #ifndef ROSE_ALLOC_TRACE
   54113             : #  define ROSE_ALLOC_TRACE 0
   54114             : #endif
   54115             : 
   54116             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   54117             : #define ROSE_ALLOC_TRACE_CNT
   54118             : #include "memory-pool-snapshot.h"
   54119             : unsigned long alloc_trace_cnt = 0;
   54120             : #endif
   54121             : 
   54122             : #if ROSE_ALLOC_TRACE
   54123             : const unsigned SgOmpSharedClause::pool_size = 5;
   54124             : #else
   54125             : const unsigned SgOmpSharedClause::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   54126             : #endif
   54127             : 
   54128             : #ifndef ROSE_ALLOC_MEMSET
   54129             : #  define ROSE_ALLOC_MEMSET 0
   54130             : #endif
   54131             : 
   54132             : #ifndef ROSE_PEDANTIC_ALLOC
   54133             : #  define ROSE_PEDANTIC_ALLOC 0
   54134             : #endif
   54135             : 
   54136             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   54137             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   54138             : #endif
   54139             : 
   54140             : #if !defined(SGNODE__ALL_POOLS)
   54141             : #define SGNODE__ALL_POOLS
   54142             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   54143             : #endif
   54144             : 
   54145             : SgOmpSharedClause* SgOmpSharedClause::next_node = nullptr;
   54146             : std::vector<unsigned char*> SgOmpSharedClause::pools;
   54147             : 
   54148             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   54149             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   54150             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   54151             : // around this macro definition rather than each use).
   54152             : #ifndef ALLOC_MUTEX
   54153             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   54154             :         do {                                                                     \
   54155             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   54156             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   54157             :                 abort();                                                         \
   54158             :             }                                                                    \
   54159             :         } while (0);
   54160             : #endif
   54161             : 
   54162             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   54163             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   54164             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   54165             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   54166             : 
   54167             : /*! \brief New operator for SgOmpSharedClause.
   54168             : 
   54169             :    This new operator implements memory pools to provide most efficent 
   54170             :    use of the heap within construction of large ASTs.
   54171             : 
   54172             : \internal The new and delete operators use the lower level C malloc/free
   54173             :    function calls for performance and to make sure that mixing of malloc/free
   54174             :    and new/delete by the used can be caught more readily.  This may change
   54175             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   54176             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   54177             :    deallocate memory allocated using ROSE_MALLOC.
   54178             : */
   54179          51 : void *SgOmpSharedClause::operator new ( size_t Size )
   54180             : {
   54181             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   54182             :      * returning or throwing an exception. */
   54183          51 :     ALLOC_MUTEX(SgOmpSharedClause, lock);
   54184             : 
   54185             : #if ROSE_ALLOC_TRACE == 2
   54186             : //    printf("SgOmpSharedClause::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgOmpSharedClause::next_node);
   54187             : #endif
   54188             : 
   54189             : #if USE_CPP_NEW_DELETE_OPERATORS
   54190             :     void *mem = ROSE_MALLOC(Size);
   54191             :     ALLOC_MUTEX(SgOmpSharedClause, unlock);
   54192             :     return mem;
   54193             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   54194             : #if ROSE_PEDANTIC_ALLOC
   54195             :     ROSE_ASSERT(Size == sizeof(SgOmpSharedClause));
   54196             : #else
   54197          51 :     if (Size != sizeof(SgOmpSharedClause)) {
   54198           0 :       void * object = ROSE_MALLOC(Size);
   54199           0 :       ALLOC_MUTEX(SgOmpSharedClause, unlock);
   54200             :       return object;
   54201             :     }
   54202             : #endif
   54203             : 
   54204          51 :     if (SgOmpSharedClause::next_node == nullptr) {
   54205          26 :         SgOmpSharedClause * alloc = (SgOmpSharedClause*) ROSE_MALLOC ( SgOmpSharedClause::pool_size * sizeof(SgOmpSharedClause) );
   54206          26 :         ROSE_ASSERT(alloc != nullptr);
   54207             : 
   54208             : #if ROSE_ALLOC_TRACE == 2
   54209             : //        printf("SgOmpSharedClause::alloc\n  block[%zi] = [ %p , %p [\n", SgOmpSharedClause::pools.size(), alloc, alloc + SgOmpSharedClause::pool_size);
   54210             : #endif
   54211             : 
   54212             : #if ROSE_ALLOC_MEMSET == 1
   54213             : #elif ROSE_ALLOC_MEMSET == 2
   54214             :         memset(alloc, 0x00, SgOmpSharedClause::pool_size * sizeof(SgOmpSharedClause));
   54215             : #elif ROSE_ALLOC_MEMSET == 3
   54216             :         memset(alloc, 0xAA, SgOmpSharedClause::pool_size * sizeof(SgOmpSharedClause));
   54217             : #endif
   54218       52000 :         for (unsigned i=0; i < SgOmpSharedClause::pool_size-1; i++) {
   54219       51974 :           alloc[i].p_freepointer = &(alloc[i+1]);
   54220             :         }
   54221          26 :         alloc[SgOmpSharedClause::pool_size-1].p_freepointer = nullptr;
   54222             : 
   54223          26 :         SgOmpSharedClause::pools.push_back ( (unsigned char *) alloc );
   54224          26 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgOmpSharedClause::pool_size * sizeof(SgOmpSharedClause), V_SgOmpSharedClause ) );
   54225          26 :         SgOmpSharedClause::next_node = alloc;
   54226             :     }
   54227          51 :     ROSE_ASSERT(SgOmpSharedClause::next_node != nullptr);
   54228             : 
   54229          51 :     SgOmpSharedClause * object = SgOmpSharedClause::next_node;
   54230          51 :     SgOmpSharedClause::next_node = (SgOmpSharedClause*)(object->p_freepointer);
   54231             : 
   54232             : #if ROSE_ALLOC_TRACE == 2
   54233             :     printf("SgOmpSharedClause::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpSharedClause::next_node);
   54234             : #endif
   54235             : 
   54236          51 :     SgNode * fp = object->p_freepointer;
   54237             : #if ROSE_ALLOC_MEMSET == 1
   54238             : #elif ROSE_ALLOC_MEMSET == 2
   54239             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpSharedClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   54240             : #elif ROSE_ALLOC_MEMSET == 3
   54241             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgOmpSharedClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   54242             : #endif
   54243          51 :     object->p_freepointer = fp;
   54244             : 
   54245             : #if ROSE_ALLOC_TRACE == 2
   54246             : //    printf("SgOmpSharedClause::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpSharedClause::next_node);
   54247             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   54248             :     Rose::MemPool::snapshot(oss.str());
   54249             :     alloc_trace_cnt++;
   54250             : #endif
   54251             : 
   54252          51 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   54253             : 
   54254          51 :     ALLOC_MUTEX(SgOmpSharedClause, unlock);
   54255             : 
   54256             :     return object;
   54257             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   54258             : }
   54259             : 
   54260             : 
   54261             : 
   54262             : /*! \brief Delete operator for SgOmpSharedClause.
   54263             : 
   54264             :    This delete operator implements deallocation using memory pools to 
   54265             :    provide most efficent use of the heap within construction of large ASTs.
   54266             : 
   54267             : \internal The new and delete operators use the lower level C malloc/free
   54268             :    function calls for performance and to make sure that mixing of malloc/free
   54269             :    and new/delete by the used can be caught more readily.  This may change
   54270             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   54271             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   54272             :    deallocate memory allocated using ROSE_MALLOC.
   54273             : */
   54274           0 : void SgOmpSharedClause::operator delete(void *Pointer, size_t Size)
   54275             : {
   54276             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   54277             :      * or throwing an exception. */
   54278           0 :     ALLOC_MUTEX(SgOmpSharedClause, lock);
   54279             : 
   54280             : #if USE_CPP_NEW_DELETE_OPERATORS
   54281             :     ROSE_FREE(Pointer);
   54282             : #else
   54283             : #if ROSE_PEDANTIC_ALLOC
   54284             :     ROSE_ASSERT(Size == sizeof(SgOmpSharedClause));
   54285             : #else
   54286           0 :     if (Size != sizeof(SgOmpSharedClause)) {
   54287           0 :       ROSE_FREE(Pointer);
   54288           0 :       ALLOC_MUTEX(SgOmpSharedClause, unlock);
   54289             :       return;
   54290             :     }
   54291             : #endif
   54292             : 
   54293           0 :     SgOmpSharedClause * object = (SgOmpSharedClause*) Pointer;
   54294           0 :     ROSE_ASSERT(object != nullptr);
   54295             : 
   54296             : #if ROSE_ALLOC_TRACE == 2
   54297             : //  printf("SgOmpSharedClause::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpSharedClause::next_node);
   54298             :     printf("SgOmpSharedClause::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpSharedClause::next_node);
   54299             : #endif
   54300             : 
   54301             : #if ROSE_PEDANTIC_ALLOC
   54302             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   54303             : #endif
   54304             : 
   54305             : #if ROSE_ALLOC_MEMSET == 1
   54306             : #elif ROSE_ALLOC_MEMSET == 2
   54307             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpSharedClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   54308             : #elif ROSE_ALLOC_MEMSET == 3
   54309             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgOmpSharedClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   54310             : #endif
   54311             : 
   54312             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   54313             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   54314             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   54315             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   54316             : #else
   54317           0 :     object->p_freepointer = SgOmpSharedClause::next_node;
   54318           0 :     SgOmpSharedClause::next_node = object;
   54319             : #endif
   54320             : 
   54321             : #if ROSE_ALLOC_TRACE == 2
   54322             : //  printf("SgOmpSharedClause::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpSharedClause::next_node);
   54323             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   54324             :     Rose::MemPool::snapshot(oss.str());
   54325             :     alloc_trace_cnt++;
   54326             : #endif
   54327             : 
   54328             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   54329             : 
   54330           0 :     ALLOC_MUTEX(SgOmpSharedClause, unlock);
   54331             : }
   54332             : 
   54333             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   54334             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   54335             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   54336             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   54337             : // Also, note comment below from Robb (copied from the Common.code file).
   54338             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   54339             : //
   54340             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   54341             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   54342             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   54343             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   54344             : #if 0
   54345             : void SgOmpSharedClause::operator delete(void* pointer) { SgOmpSharedClause::operator delete (pointer, sizeof(SgOmpSharedClause)); };
   54346             : #endif
   54347             : /* #line 54348 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   54348             : 
   54349             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   54350             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   54351             : // obviously imply C++.
   54352             : 
   54353             : // This implements the support within ROSE for memory pools.  Memory pools
   54354             : // support the most condensed usage of memory within the construction of
   54355             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   54356             : // by a new operator written for each class.
   54357             : 
   54358             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   54359             :     // User wants multi-thread support and POSIX threads are available.
   54360             : #   include <pthread.h>
   54361             :     static pthread_mutex_t SgOmpCopyinClause_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   54362             : #else
   54363             :      // Cause synchronization to be skipped.
   54364             : #    ifndef ALLOC_MUTEX
   54365             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   54366             : #    endif
   54367             : #    ifdef _REENTRANT
   54368             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   54369             : #       ifdef _MSC_VER
   54370             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   54371             : #       else
   54372             : #           warning "POSIX threads are not available; synchronization being skipped"
   54373             : #       endif
   54374             : #    endif
   54375             : #endif
   54376             : 
   54377             : #ifndef ROSE_ALLOC_TRACE
   54378             : #  define ROSE_ALLOC_TRACE 0
   54379             : #endif
   54380             : 
   54381             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   54382             : #define ROSE_ALLOC_TRACE_CNT
   54383             : #include "memory-pool-snapshot.h"
   54384             : unsigned long alloc_trace_cnt = 0;
   54385             : #endif
   54386             : 
   54387             : #if ROSE_ALLOC_TRACE
   54388             : const unsigned SgOmpCopyinClause::pool_size = 5;
   54389             : #else
   54390             : const unsigned SgOmpCopyinClause::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   54391             : #endif
   54392             : 
   54393             : #ifndef ROSE_ALLOC_MEMSET
   54394             : #  define ROSE_ALLOC_MEMSET 0
   54395             : #endif
   54396             : 
   54397             : #ifndef ROSE_PEDANTIC_ALLOC
   54398             : #  define ROSE_PEDANTIC_ALLOC 0
   54399             : #endif
   54400             : 
   54401             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   54402             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   54403             : #endif
   54404             : 
   54405             : #if !defined(SGNODE__ALL_POOLS)
   54406             : #define SGNODE__ALL_POOLS
   54407             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   54408             : #endif
   54409             : 
   54410             : SgOmpCopyinClause* SgOmpCopyinClause::next_node = nullptr;
   54411             : std::vector<unsigned char*> SgOmpCopyinClause::pools;
   54412             : 
   54413             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   54414             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   54415             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   54416             : // around this macro definition rather than each use).
   54417             : #ifndef ALLOC_MUTEX
   54418             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   54419             :         do {                                                                     \
   54420             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   54421             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   54422             :                 abort();                                                         \
   54423             :             }                                                                    \
   54424             :         } while (0);
   54425             : #endif
   54426             : 
   54427             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   54428             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   54429             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   54430             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   54431             : 
   54432             : /*! \brief New operator for SgOmpCopyinClause.
   54433             : 
   54434             :    This new operator implements memory pools to provide most efficent 
   54435             :    use of the heap within construction of large ASTs.
   54436             : 
   54437             : \internal The new and delete operators use the lower level C malloc/free
   54438             :    function calls for performance and to make sure that mixing of malloc/free
   54439             :    and new/delete by the used can be caught more readily.  This may change
   54440             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   54441             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   54442             :    deallocate memory allocated using ROSE_MALLOC.
   54443             : */
   54444           1 : void *SgOmpCopyinClause::operator new ( size_t Size )
   54445             : {
   54446             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   54447             :      * returning or throwing an exception. */
   54448           1 :     ALLOC_MUTEX(SgOmpCopyinClause, lock);
   54449             : 
   54450             : #if ROSE_ALLOC_TRACE == 2
   54451             : //    printf("SgOmpCopyinClause::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgOmpCopyinClause::next_node);
   54452             : #endif
   54453             : 
   54454             : #if USE_CPP_NEW_DELETE_OPERATORS
   54455             :     void *mem = ROSE_MALLOC(Size);
   54456             :     ALLOC_MUTEX(SgOmpCopyinClause, unlock);
   54457             :     return mem;
   54458             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   54459             : #if ROSE_PEDANTIC_ALLOC
   54460             :     ROSE_ASSERT(Size == sizeof(SgOmpCopyinClause));
   54461             : #else
   54462           1 :     if (Size != sizeof(SgOmpCopyinClause)) {
   54463           0 :       void * object = ROSE_MALLOC(Size);
   54464           0 :       ALLOC_MUTEX(SgOmpCopyinClause, unlock);
   54465             :       return object;
   54466             :     }
   54467             : #endif
   54468             : 
   54469           1 :     if (SgOmpCopyinClause::next_node == nullptr) {
   54470           1 :         SgOmpCopyinClause * alloc = (SgOmpCopyinClause*) ROSE_MALLOC ( SgOmpCopyinClause::pool_size * sizeof(SgOmpCopyinClause) );
   54471           1 :         ROSE_ASSERT(alloc != nullptr);
   54472             : 
   54473             : #if ROSE_ALLOC_TRACE == 2
   54474             : //        printf("SgOmpCopyinClause::alloc\n  block[%zi] = [ %p , %p [\n", SgOmpCopyinClause::pools.size(), alloc, alloc + SgOmpCopyinClause::pool_size);
   54475             : #endif
   54476             : 
   54477             : #if ROSE_ALLOC_MEMSET == 1
   54478             : #elif ROSE_ALLOC_MEMSET == 2
   54479             :         memset(alloc, 0x00, SgOmpCopyinClause::pool_size * sizeof(SgOmpCopyinClause));
   54480             : #elif ROSE_ALLOC_MEMSET == 3
   54481             :         memset(alloc, 0xAA, SgOmpCopyinClause::pool_size * sizeof(SgOmpCopyinClause));
   54482             : #endif
   54483        2000 :         for (unsigned i=0; i < SgOmpCopyinClause::pool_size-1; i++) {
   54484        1999 :           alloc[i].p_freepointer = &(alloc[i+1]);
   54485             :         }
   54486           1 :         alloc[SgOmpCopyinClause::pool_size-1].p_freepointer = nullptr;
   54487             : 
   54488           1 :         SgOmpCopyinClause::pools.push_back ( (unsigned char *) alloc );
   54489           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgOmpCopyinClause::pool_size * sizeof(SgOmpCopyinClause), V_SgOmpCopyinClause ) );
   54490           1 :         SgOmpCopyinClause::next_node = alloc;
   54491             :     }
   54492           1 :     ROSE_ASSERT(SgOmpCopyinClause::next_node != nullptr);
   54493             : 
   54494           1 :     SgOmpCopyinClause * object = SgOmpCopyinClause::next_node;
   54495           1 :     SgOmpCopyinClause::next_node = (SgOmpCopyinClause*)(object->p_freepointer);
   54496             : 
   54497             : #if ROSE_ALLOC_TRACE == 2
   54498             :     printf("SgOmpCopyinClause::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpCopyinClause::next_node);
   54499             : #endif
   54500             : 
   54501           1 :     SgNode * fp = object->p_freepointer;
   54502             : #if ROSE_ALLOC_MEMSET == 1
   54503             : #elif ROSE_ALLOC_MEMSET == 2
   54504             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpCopyinClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   54505             : #elif ROSE_ALLOC_MEMSET == 3
   54506             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgOmpCopyinClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   54507             : #endif
   54508           1 :     object->p_freepointer = fp;
   54509             : 
   54510             : #if ROSE_ALLOC_TRACE == 2
   54511             : //    printf("SgOmpCopyinClause::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpCopyinClause::next_node);
   54512             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   54513             :     Rose::MemPool::snapshot(oss.str());
   54514             :     alloc_trace_cnt++;
   54515             : #endif
   54516             : 
   54517           1 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   54518             : 
   54519           1 :     ALLOC_MUTEX(SgOmpCopyinClause, unlock);
   54520             : 
   54521             :     return object;
   54522             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   54523             : }
   54524             : 
   54525             : 
   54526             : 
   54527             : /*! \brief Delete operator for SgOmpCopyinClause.
   54528             : 
   54529             :    This delete operator implements deallocation using memory pools to 
   54530             :    provide most efficent use of the heap within construction of large ASTs.
   54531             : 
   54532             : \internal The new and delete operators use the lower level C malloc/free
   54533             :    function calls for performance and to make sure that mixing of malloc/free
   54534             :    and new/delete by the used can be caught more readily.  This may change
   54535             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   54536             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   54537             :    deallocate memory allocated using ROSE_MALLOC.
   54538             : */
   54539           0 : void SgOmpCopyinClause::operator delete(void *Pointer, size_t Size)
   54540             : {
   54541             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   54542             :      * or throwing an exception. */
   54543           0 :     ALLOC_MUTEX(SgOmpCopyinClause, lock);
   54544             : 
   54545             : #if USE_CPP_NEW_DELETE_OPERATORS
   54546             :     ROSE_FREE(Pointer);
   54547             : #else
   54548             : #if ROSE_PEDANTIC_ALLOC
   54549             :     ROSE_ASSERT(Size == sizeof(SgOmpCopyinClause));
   54550             : #else
   54551           0 :     if (Size != sizeof(SgOmpCopyinClause)) {
   54552           0 :       ROSE_FREE(Pointer);
   54553           0 :       ALLOC_MUTEX(SgOmpCopyinClause, unlock);
   54554             :       return;
   54555             :     }
   54556             : #endif
   54557             : 
   54558           0 :     SgOmpCopyinClause * object = (SgOmpCopyinClause*) Pointer;
   54559           0 :     ROSE_ASSERT(object != nullptr);
   54560             : 
   54561             : #if ROSE_ALLOC_TRACE == 2
   54562             : //  printf("SgOmpCopyinClause::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpCopyinClause::next_node);
   54563             :     printf("SgOmpCopyinClause::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpCopyinClause::next_node);
   54564             : #endif
   54565             : 
   54566             : #if ROSE_PEDANTIC_ALLOC
   54567             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   54568             : #endif
   54569             : 
   54570             : #if ROSE_ALLOC_MEMSET == 1
   54571             : #elif ROSE_ALLOC_MEMSET == 2
   54572             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpCopyinClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   54573             : #elif ROSE_ALLOC_MEMSET == 3
   54574             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgOmpCopyinClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   54575             : #endif
   54576             : 
   54577             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   54578             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   54579             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   54580             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   54581             : #else
   54582           0 :     object->p_freepointer = SgOmpCopyinClause::next_node;
   54583           0 :     SgOmpCopyinClause::next_node = object;
   54584             : #endif
   54585             : 
   54586             : #if ROSE_ALLOC_TRACE == 2
   54587             : //  printf("SgOmpCopyinClause::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpCopyinClause::next_node);
   54588             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   54589             :     Rose::MemPool::snapshot(oss.str());
   54590             :     alloc_trace_cnt++;
   54591             : #endif
   54592             : 
   54593             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   54594             : 
   54595           0 :     ALLOC_MUTEX(SgOmpCopyinClause, unlock);
   54596             : }
   54597             : 
   54598             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   54599             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   54600             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   54601             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   54602             : // Also, note comment below from Robb (copied from the Common.code file).
   54603             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   54604             : //
   54605             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   54606             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   54607             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   54608             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   54609             : #if 0
   54610             : void SgOmpCopyinClause::operator delete(void* pointer) { SgOmpCopyinClause::operator delete (pointer, sizeof(SgOmpCopyinClause)); };
   54611             : #endif
   54612             : /* #line 54613 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   54613             : 
   54614             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   54615             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   54616             : // obviously imply C++.
   54617             : 
   54618             : // This implements the support within ROSE for memory pools.  Memory pools
   54619             : // support the most condensed usage of memory within the construction of
   54620             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   54621             : // by a new operator written for each class.
   54622             : 
   54623             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   54624             :     // User wants multi-thread support and POSIX threads are available.
   54625             : #   include <pthread.h>
   54626             :     static pthread_mutex_t SgOmpLastprivateClause_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   54627             : #else
   54628             :      // Cause synchronization to be skipped.
   54629             : #    ifndef ALLOC_MUTEX
   54630             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   54631             : #    endif
   54632             : #    ifdef _REENTRANT
   54633             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   54634             : #       ifdef _MSC_VER
   54635             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   54636             : #       else
   54637             : #           warning "POSIX threads are not available; synchronization being skipped"
   54638             : #       endif
   54639             : #    endif
   54640             : #endif
   54641             : 
   54642             : #ifndef ROSE_ALLOC_TRACE
   54643             : #  define ROSE_ALLOC_TRACE 0
   54644             : #endif
   54645             : 
   54646             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   54647             : #define ROSE_ALLOC_TRACE_CNT
   54648             : #include "memory-pool-snapshot.h"
   54649             : unsigned long alloc_trace_cnt = 0;
   54650             : #endif
   54651             : 
   54652             : #if ROSE_ALLOC_TRACE
   54653             : const unsigned SgOmpLastprivateClause::pool_size = 5;
   54654             : #else
   54655             : const unsigned SgOmpLastprivateClause::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   54656             : #endif
   54657             : 
   54658             : #ifndef ROSE_ALLOC_MEMSET
   54659             : #  define ROSE_ALLOC_MEMSET 0
   54660             : #endif
   54661             : 
   54662             : #ifndef ROSE_PEDANTIC_ALLOC
   54663             : #  define ROSE_PEDANTIC_ALLOC 0
   54664             : #endif
   54665             : 
   54666             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   54667             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   54668             : #endif
   54669             : 
   54670             : #if !defined(SGNODE__ALL_POOLS)
   54671             : #define SGNODE__ALL_POOLS
   54672             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   54673             : #endif
   54674             : 
   54675             : SgOmpLastprivateClause* SgOmpLastprivateClause::next_node = nullptr;
   54676             : std::vector<unsigned char*> SgOmpLastprivateClause::pools;
   54677             : 
   54678             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   54679             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   54680             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   54681             : // around this macro definition rather than each use).
   54682             : #ifndef ALLOC_MUTEX
   54683             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   54684             :         do {                                                                     \
   54685             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   54686             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   54687             :                 abort();                                                         \
   54688             :             }                                                                    \
   54689             :         } while (0);
   54690             : #endif
   54691             : 
   54692             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   54693             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   54694             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   54695             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   54696             : 
   54697             : /*! \brief New operator for SgOmpLastprivateClause.
   54698             : 
   54699             :    This new operator implements memory pools to provide most efficent 
   54700             :    use of the heap within construction of large ASTs.
   54701             : 
   54702             : \internal The new and delete operators use the lower level C malloc/free
   54703             :    function calls for performance and to make sure that mixing of malloc/free
   54704             :    and new/delete by the used can be caught more readily.  This may change
   54705             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   54706             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   54707             :    deallocate memory allocated using ROSE_MALLOC.
   54708             : */
   54709          14 : void *SgOmpLastprivateClause::operator new ( size_t Size )
   54710             : {
   54711             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   54712             :      * returning or throwing an exception. */
   54713          14 :     ALLOC_MUTEX(SgOmpLastprivateClause, lock);
   54714             : 
   54715             : #if ROSE_ALLOC_TRACE == 2
   54716             : //    printf("SgOmpLastprivateClause::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgOmpLastprivateClause::next_node);
   54717             : #endif
   54718             : 
   54719             : #if USE_CPP_NEW_DELETE_OPERATORS
   54720             :     void *mem = ROSE_MALLOC(Size);
   54721             :     ALLOC_MUTEX(SgOmpLastprivateClause, unlock);
   54722             :     return mem;
   54723             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   54724             : #if ROSE_PEDANTIC_ALLOC
   54725             :     ROSE_ASSERT(Size == sizeof(SgOmpLastprivateClause));
   54726             : #else
   54727          14 :     if (Size != sizeof(SgOmpLastprivateClause)) {
   54728           0 :       void * object = ROSE_MALLOC(Size);
   54729           0 :       ALLOC_MUTEX(SgOmpLastprivateClause, unlock);
   54730             :       return object;
   54731             :     }
   54732             : #endif
   54733             : 
   54734          14 :     if (SgOmpLastprivateClause::next_node == nullptr) {
   54735          13 :         SgOmpLastprivateClause * alloc = (SgOmpLastprivateClause*) ROSE_MALLOC ( SgOmpLastprivateClause::pool_size * sizeof(SgOmpLastprivateClause) );
   54736          13 :         ROSE_ASSERT(alloc != nullptr);
   54737             : 
   54738             : #if ROSE_ALLOC_TRACE == 2
   54739             : //        printf("SgOmpLastprivateClause::alloc\n  block[%zi] = [ %p , %p [\n", SgOmpLastprivateClause::pools.size(), alloc, alloc + SgOmpLastprivateClause::pool_size);
   54740             : #endif
   54741             : 
   54742             : #if ROSE_ALLOC_MEMSET == 1
   54743             : #elif ROSE_ALLOC_MEMSET == 2
   54744             :         memset(alloc, 0x00, SgOmpLastprivateClause::pool_size * sizeof(SgOmpLastprivateClause));
   54745             : #elif ROSE_ALLOC_MEMSET == 3
   54746             :         memset(alloc, 0xAA, SgOmpLastprivateClause::pool_size * sizeof(SgOmpLastprivateClause));
   54747             : #endif
   54748       26000 :         for (unsigned i=0; i < SgOmpLastprivateClause::pool_size-1; i++) {
   54749       25987 :           alloc[i].p_freepointer = &(alloc[i+1]);
   54750             :         }
   54751          13 :         alloc[SgOmpLastprivateClause::pool_size-1].p_freepointer = nullptr;
   54752             : 
   54753          13 :         SgOmpLastprivateClause::pools.push_back ( (unsigned char *) alloc );
   54754          13 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgOmpLastprivateClause::pool_size * sizeof(SgOmpLastprivateClause), V_SgOmpLastprivateClause ) );
   54755          13 :         SgOmpLastprivateClause::next_node = alloc;
   54756             :     }
   54757          14 :     ROSE_ASSERT(SgOmpLastprivateClause::next_node != nullptr);
   54758             : 
   54759          14 :     SgOmpLastprivateClause * object = SgOmpLastprivateClause::next_node;
   54760          14 :     SgOmpLastprivateClause::next_node = (SgOmpLastprivateClause*)(object->p_freepointer);
   54761             : 
   54762             : #if ROSE_ALLOC_TRACE == 2
   54763             :     printf("SgOmpLastprivateClause::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpLastprivateClause::next_node);
   54764             : #endif
   54765             : 
   54766          14 :     SgNode * fp = object->p_freepointer;
   54767             : #if ROSE_ALLOC_MEMSET == 1
   54768             : #elif ROSE_ALLOC_MEMSET == 2
   54769             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpLastprivateClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   54770             : #elif ROSE_ALLOC_MEMSET == 3
   54771             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgOmpLastprivateClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   54772             : #endif
   54773          14 :     object->p_freepointer = fp;
   54774             : 
   54775             : #if ROSE_ALLOC_TRACE == 2
   54776             : //    printf("SgOmpLastprivateClause::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpLastprivateClause::next_node);
   54777             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   54778             :     Rose::MemPool::snapshot(oss.str());
   54779             :     alloc_trace_cnt++;
   54780             : #endif
   54781             : 
   54782          14 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   54783             : 
   54784          14 :     ALLOC_MUTEX(SgOmpLastprivateClause, unlock);
   54785             : 
   54786             :     return object;
   54787             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   54788             : }
   54789             : 
   54790             : 
   54791             : 
   54792             : /*! \brief Delete operator for SgOmpLastprivateClause.
   54793             : 
   54794             :    This delete operator implements deallocation using memory pools to 
   54795             :    provide most efficent use of the heap within construction of large ASTs.
   54796             : 
   54797             : \internal The new and delete operators use the lower level C malloc/free
   54798             :    function calls for performance and to make sure that mixing of malloc/free
   54799             :    and new/delete by the used can be caught more readily.  This may change
   54800             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   54801             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   54802             :    deallocate memory allocated using ROSE_MALLOC.
   54803             : */
   54804           0 : void SgOmpLastprivateClause::operator delete(void *Pointer, size_t Size)
   54805             : {
   54806             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   54807             :      * or throwing an exception. */
   54808           0 :     ALLOC_MUTEX(SgOmpLastprivateClause, lock);
   54809             : 
   54810             : #if USE_CPP_NEW_DELETE_OPERATORS
   54811             :     ROSE_FREE(Pointer);
   54812             : #else
   54813             : #if ROSE_PEDANTIC_ALLOC
   54814             :     ROSE_ASSERT(Size == sizeof(SgOmpLastprivateClause));
   54815             : #else
   54816           0 :     if (Size != sizeof(SgOmpLastprivateClause)) {
   54817           0 :       ROSE_FREE(Pointer);
   54818           0 :       ALLOC_MUTEX(SgOmpLastprivateClause, unlock);
   54819             :       return;
   54820             :     }
   54821             : #endif
   54822             : 
   54823           0 :     SgOmpLastprivateClause * object = (SgOmpLastprivateClause*) Pointer;
   54824           0 :     ROSE_ASSERT(object != nullptr);
   54825             : 
   54826             : #if ROSE_ALLOC_TRACE == 2
   54827             : //  printf("SgOmpLastprivateClause::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpLastprivateClause::next_node);
   54828             :     printf("SgOmpLastprivateClause::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpLastprivateClause::next_node);
   54829             : #endif
   54830             : 
   54831             : #if ROSE_PEDANTIC_ALLOC
   54832             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   54833             : #endif
   54834             : 
   54835             : #if ROSE_ALLOC_MEMSET == 1
   54836             : #elif ROSE_ALLOC_MEMSET == 2
   54837             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpLastprivateClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   54838             : #elif ROSE_ALLOC_MEMSET == 3
   54839             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgOmpLastprivateClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   54840             : #endif
   54841             : 
   54842             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   54843             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   54844             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   54845             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   54846             : #else
   54847           0 :     object->p_freepointer = SgOmpLastprivateClause::next_node;
   54848           0 :     SgOmpLastprivateClause::next_node = object;
   54849             : #endif
   54850             : 
   54851             : #if ROSE_ALLOC_TRACE == 2
   54852             : //  printf("SgOmpLastprivateClause::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpLastprivateClause::next_node);
   54853             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   54854             :     Rose::MemPool::snapshot(oss.str());
   54855             :     alloc_trace_cnt++;
   54856             : #endif
   54857             : 
   54858             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   54859             : 
   54860           0 :     ALLOC_MUTEX(SgOmpLastprivateClause, unlock);
   54861             : }
   54862             : 
   54863             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   54864             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   54865             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   54866             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   54867             : // Also, note comment below from Robb (copied from the Common.code file).
   54868             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   54869             : //
   54870             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   54871             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   54872             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   54873             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   54874             : #if 0
   54875             : void SgOmpLastprivateClause::operator delete(void* pointer) { SgOmpLastprivateClause::operator delete (pointer, sizeof(SgOmpLastprivateClause)); };
   54876             : #endif
   54877             : /* #line 54878 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   54878             : 
   54879             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   54880             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   54881             : // obviously imply C++.
   54882             : 
   54883             : // This implements the support within ROSE for memory pools.  Memory pools
   54884             : // support the most condensed usage of memory within the construction of
   54885             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   54886             : // by a new operator written for each class.
   54887             : 
   54888             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   54889             :     // User wants multi-thread support and POSIX threads are available.
   54890             : #   include <pthread.h>
   54891             :     static pthread_mutex_t SgOmpReductionClause_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   54892             : #else
   54893             :      // Cause synchronization to be skipped.
   54894             : #    ifndef ALLOC_MUTEX
   54895             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   54896             : #    endif
   54897             : #    ifdef _REENTRANT
   54898             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   54899             : #       ifdef _MSC_VER
   54900             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   54901             : #       else
   54902             : #           warning "POSIX threads are not available; synchronization being skipped"
   54903             : #       endif
   54904             : #    endif
   54905             : #endif
   54906             : 
   54907             : #ifndef ROSE_ALLOC_TRACE
   54908             : #  define ROSE_ALLOC_TRACE 0
   54909             : #endif
   54910             : 
   54911             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   54912             : #define ROSE_ALLOC_TRACE_CNT
   54913             : #include "memory-pool-snapshot.h"
   54914             : unsigned long alloc_trace_cnt = 0;
   54915             : #endif
   54916             : 
   54917             : #if ROSE_ALLOC_TRACE
   54918             : const unsigned SgOmpReductionClause::pool_size = 5;
   54919             : #else
   54920             : const unsigned SgOmpReductionClause::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   54921             : #endif
   54922             : 
   54923             : #ifndef ROSE_ALLOC_MEMSET
   54924             : #  define ROSE_ALLOC_MEMSET 0
   54925             : #endif
   54926             : 
   54927             : #ifndef ROSE_PEDANTIC_ALLOC
   54928             : #  define ROSE_PEDANTIC_ALLOC 0
   54929             : #endif
   54930             : 
   54931             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   54932             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   54933             : #endif
   54934             : 
   54935             : #if !defined(SGNODE__ALL_POOLS)
   54936             : #define SGNODE__ALL_POOLS
   54937             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   54938             : #endif
   54939             : 
   54940             : SgOmpReductionClause* SgOmpReductionClause::next_node = nullptr;
   54941             : std::vector<unsigned char*> SgOmpReductionClause::pools;
   54942             : 
   54943             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   54944             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   54945             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   54946             : // around this macro definition rather than each use).
   54947             : #ifndef ALLOC_MUTEX
   54948             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   54949             :         do {                                                                     \
   54950             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   54951             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   54952             :                 abort();                                                         \
   54953             :             }                                                                    \
   54954             :         } while (0);
   54955             : #endif
   54956             : 
   54957             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   54958             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   54959             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   54960             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   54961             : 
   54962             : /*! \brief New operator for SgOmpReductionClause.
   54963             : 
   54964             :    This new operator implements memory pools to provide most efficent 
   54965             :    use of the heap within construction of large ASTs.
   54966             : 
   54967             : \internal The new and delete operators use the lower level C malloc/free
   54968             :    function calls for performance and to make sure that mixing of malloc/free
   54969             :    and new/delete by the used can be caught more readily.  This may change
   54970             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   54971             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   54972             :    deallocate memory allocated using ROSE_MALLOC.
   54973             : */
   54974          89 : void *SgOmpReductionClause::operator new ( size_t Size )
   54975             : {
   54976             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   54977             :      * returning or throwing an exception. */
   54978          89 :     ALLOC_MUTEX(SgOmpReductionClause, lock);
   54979             : 
   54980             : #if ROSE_ALLOC_TRACE == 2
   54981             : //    printf("SgOmpReductionClause::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgOmpReductionClause::next_node);
   54982             : #endif
   54983             : 
   54984             : #if USE_CPP_NEW_DELETE_OPERATORS
   54985             :     void *mem = ROSE_MALLOC(Size);
   54986             :     ALLOC_MUTEX(SgOmpReductionClause, unlock);
   54987             :     return mem;
   54988             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   54989             : #if ROSE_PEDANTIC_ALLOC
   54990             :     ROSE_ASSERT(Size == sizeof(SgOmpReductionClause));
   54991             : #else
   54992          89 :     if (Size != sizeof(SgOmpReductionClause)) {
   54993           0 :       void * object = ROSE_MALLOC(Size);
   54994           0 :       ALLOC_MUTEX(SgOmpReductionClause, unlock);
   54995             :       return object;
   54996             :     }
   54997             : #endif
   54998             : 
   54999          89 :     if (SgOmpReductionClause::next_node == nullptr) {
   55000          42 :         SgOmpReductionClause * alloc = (SgOmpReductionClause*) ROSE_MALLOC ( SgOmpReductionClause::pool_size * sizeof(SgOmpReductionClause) );
   55001          42 :         ROSE_ASSERT(alloc != nullptr);
   55002             : 
   55003             : #if ROSE_ALLOC_TRACE == 2
   55004             : //        printf("SgOmpReductionClause::alloc\n  block[%zi] = [ %p , %p [\n", SgOmpReductionClause::pools.size(), alloc, alloc + SgOmpReductionClause::pool_size);
   55005             : #endif
   55006             : 
   55007             : #if ROSE_ALLOC_MEMSET == 1
   55008             : #elif ROSE_ALLOC_MEMSET == 2
   55009             :         memset(alloc, 0x00, SgOmpReductionClause::pool_size * sizeof(SgOmpReductionClause));
   55010             : #elif ROSE_ALLOC_MEMSET == 3
   55011             :         memset(alloc, 0xAA, SgOmpReductionClause::pool_size * sizeof(SgOmpReductionClause));
   55012             : #endif
   55013       84000 :         for (unsigned i=0; i < SgOmpReductionClause::pool_size-1; i++) {
   55014       83958 :           alloc[i].p_freepointer = &(alloc[i+1]);
   55015             :         }
   55016          42 :         alloc[SgOmpReductionClause::pool_size-1].p_freepointer = nullptr;
   55017             : 
   55018          42 :         SgOmpReductionClause::pools.push_back ( (unsigned char *) alloc );
   55019          42 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgOmpReductionClause::pool_size * sizeof(SgOmpReductionClause), V_SgOmpReductionClause ) );
   55020          42 :         SgOmpReductionClause::next_node = alloc;
   55021             :     }
   55022          89 :     ROSE_ASSERT(SgOmpReductionClause::next_node != nullptr);
   55023             : 
   55024          89 :     SgOmpReductionClause * object = SgOmpReductionClause::next_node;
   55025          89 :     SgOmpReductionClause::next_node = (SgOmpReductionClause*)(object->p_freepointer);
   55026             : 
   55027             : #if ROSE_ALLOC_TRACE == 2
   55028             :     printf("SgOmpReductionClause::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpReductionClause::next_node);
   55029             : #endif
   55030             : 
   55031          89 :     SgNode * fp = object->p_freepointer;
   55032             : #if ROSE_ALLOC_MEMSET == 1
   55033             : #elif ROSE_ALLOC_MEMSET == 2
   55034             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpReductionClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   55035             : #elif ROSE_ALLOC_MEMSET == 3
   55036             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgOmpReductionClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   55037             : #endif
   55038          89 :     object->p_freepointer = fp;
   55039             : 
   55040             : #if ROSE_ALLOC_TRACE == 2
   55041             : //    printf("SgOmpReductionClause::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpReductionClause::next_node);
   55042             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   55043             :     Rose::MemPool::snapshot(oss.str());
   55044             :     alloc_trace_cnt++;
   55045             : #endif
   55046             : 
   55047          89 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   55048             : 
   55049          89 :     ALLOC_MUTEX(SgOmpReductionClause, unlock);
   55050             : 
   55051             :     return object;
   55052             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   55053             : }
   55054             : 
   55055             : 
   55056             : 
   55057             : /*! \brief Delete operator for SgOmpReductionClause.
   55058             : 
   55059             :    This delete operator implements deallocation using memory pools to 
   55060             :    provide most efficent use of the heap within construction of large ASTs.
   55061             : 
   55062             : \internal The new and delete operators use the lower level C malloc/free
   55063             :    function calls for performance and to make sure that mixing of malloc/free
   55064             :    and new/delete by the used can be caught more readily.  This may change
   55065             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   55066             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   55067             :    deallocate memory allocated using ROSE_MALLOC.
   55068             : */
   55069           0 : void SgOmpReductionClause::operator delete(void *Pointer, size_t Size)
   55070             : {
   55071             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   55072             :      * or throwing an exception. */
   55073           0 :     ALLOC_MUTEX(SgOmpReductionClause, lock);
   55074             : 
   55075             : #if USE_CPP_NEW_DELETE_OPERATORS
   55076             :     ROSE_FREE(Pointer);
   55077             : #else
   55078             : #if ROSE_PEDANTIC_ALLOC
   55079             :     ROSE_ASSERT(Size == sizeof(SgOmpReductionClause));
   55080             : #else
   55081           0 :     if (Size != sizeof(SgOmpReductionClause)) {
   55082           0 :       ROSE_FREE(Pointer);
   55083           0 :       ALLOC_MUTEX(SgOmpReductionClause, unlock);
   55084             :       return;
   55085             :     }
   55086             : #endif
   55087             : 
   55088           0 :     SgOmpReductionClause * object = (SgOmpReductionClause*) Pointer;
   55089           0 :     ROSE_ASSERT(object != nullptr);
   55090             : 
   55091             : #if ROSE_ALLOC_TRACE == 2
   55092             : //  printf("SgOmpReductionClause::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpReductionClause::next_node);
   55093             :     printf("SgOmpReductionClause::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpReductionClause::next_node);
   55094             : #endif
   55095             : 
   55096             : #if ROSE_PEDANTIC_ALLOC
   55097             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   55098             : #endif
   55099             : 
   55100             : #if ROSE_ALLOC_MEMSET == 1
   55101             : #elif ROSE_ALLOC_MEMSET == 2
   55102             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpReductionClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   55103             : #elif ROSE_ALLOC_MEMSET == 3
   55104             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgOmpReductionClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   55105             : #endif
   55106             : 
   55107             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   55108             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   55109             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   55110             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   55111             : #else
   55112           0 :     object->p_freepointer = SgOmpReductionClause::next_node;
   55113           0 :     SgOmpReductionClause::next_node = object;
   55114             : #endif
   55115             : 
   55116             : #if ROSE_ALLOC_TRACE == 2
   55117             : //  printf("SgOmpReductionClause::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpReductionClause::next_node);
   55118             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   55119             :     Rose::MemPool::snapshot(oss.str());
   55120             :     alloc_trace_cnt++;
   55121             : #endif
   55122             : 
   55123             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   55124             : 
   55125           0 :     ALLOC_MUTEX(SgOmpReductionClause, unlock);
   55126             : }
   55127             : 
   55128             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   55129             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   55130             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   55131             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   55132             : // Also, note comment below from Robb (copied from the Common.code file).
   55133             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   55134             : //
   55135             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   55136             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   55137             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   55138             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   55139             : #if 0
   55140             : void SgOmpReductionClause::operator delete(void* pointer) { SgOmpReductionClause::operator delete (pointer, sizeof(SgOmpReductionClause)); };
   55141             : #endif
   55142             : /* #line 55143 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   55143             : 
   55144             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   55145             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   55146             : // obviously imply C++.
   55147             : 
   55148             : // This implements the support within ROSE for memory pools.  Memory pools
   55149             : // support the most condensed usage of memory within the construction of
   55150             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   55151             : // by a new operator written for each class.
   55152             : 
   55153             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   55154             :     // User wants multi-thread support and POSIX threads are available.
   55155             : #   include <pthread.h>
   55156             :     static pthread_mutex_t SgOmpInReductionClause_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   55157             : #else
   55158             :      // Cause synchronization to be skipped.
   55159             : #    ifndef ALLOC_MUTEX
   55160             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   55161             : #    endif
   55162             : #    ifdef _REENTRANT
   55163             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   55164             : #       ifdef _MSC_VER
   55165             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   55166             : #       else
   55167             : #           warning "POSIX threads are not available; synchronization being skipped"
   55168             : #       endif
   55169             : #    endif
   55170             : #endif
   55171             : 
   55172             : #ifndef ROSE_ALLOC_TRACE
   55173             : #  define ROSE_ALLOC_TRACE 0
   55174             : #endif
   55175             : 
   55176             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   55177             : #define ROSE_ALLOC_TRACE_CNT
   55178             : #include "memory-pool-snapshot.h"
   55179             : unsigned long alloc_trace_cnt = 0;
   55180             : #endif
   55181             : 
   55182             : #if ROSE_ALLOC_TRACE
   55183             : const unsigned SgOmpInReductionClause::pool_size = 5;
   55184             : #else
   55185             : const unsigned SgOmpInReductionClause::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   55186             : #endif
   55187             : 
   55188             : #ifndef ROSE_ALLOC_MEMSET
   55189             : #  define ROSE_ALLOC_MEMSET 0
   55190             : #endif
   55191             : 
   55192             : #ifndef ROSE_PEDANTIC_ALLOC
   55193             : #  define ROSE_PEDANTIC_ALLOC 0
   55194             : #endif
   55195             : 
   55196             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   55197             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   55198             : #endif
   55199             : 
   55200             : #if !defined(SGNODE__ALL_POOLS)
   55201             : #define SGNODE__ALL_POOLS
   55202             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   55203             : #endif
   55204             : 
   55205             : SgOmpInReductionClause* SgOmpInReductionClause::next_node = nullptr;
   55206             : std::vector<unsigned char*> SgOmpInReductionClause::pools;
   55207             : 
   55208             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   55209             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   55210             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   55211             : // around this macro definition rather than each use).
   55212             : #ifndef ALLOC_MUTEX
   55213             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   55214             :         do {                                                                     \
   55215             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   55216             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   55217             :                 abort();                                                         \
   55218             :             }                                                                    \
   55219             :         } while (0);
   55220             : #endif
   55221             : 
   55222             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   55223             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   55224             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   55225             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   55226             : 
   55227             : /*! \brief New operator for SgOmpInReductionClause.
   55228             : 
   55229             :    This new operator implements memory pools to provide most efficent 
   55230             :    use of the heap within construction of large ASTs.
   55231             : 
   55232             : \internal The new and delete operators use the lower level C malloc/free
   55233             :    function calls for performance and to make sure that mixing of malloc/free
   55234             :    and new/delete by the used can be caught more readily.  This may change
   55235             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   55236             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   55237             :    deallocate memory allocated using ROSE_MALLOC.
   55238             : */
   55239           6 : void *SgOmpInReductionClause::operator new ( size_t Size )
   55240             : {
   55241             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   55242             :      * returning or throwing an exception. */
   55243           6 :     ALLOC_MUTEX(SgOmpInReductionClause, lock);
   55244             : 
   55245             : #if ROSE_ALLOC_TRACE == 2
   55246             : //    printf("SgOmpInReductionClause::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgOmpInReductionClause::next_node);
   55247             : #endif
   55248             : 
   55249             : #if USE_CPP_NEW_DELETE_OPERATORS
   55250             :     void *mem = ROSE_MALLOC(Size);
   55251             :     ALLOC_MUTEX(SgOmpInReductionClause, unlock);
   55252             :     return mem;
   55253             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   55254             : #if ROSE_PEDANTIC_ALLOC
   55255             :     ROSE_ASSERT(Size == sizeof(SgOmpInReductionClause));
   55256             : #else
   55257           6 :     if (Size != sizeof(SgOmpInReductionClause)) {
   55258           0 :       void * object = ROSE_MALLOC(Size);
   55259           0 :       ALLOC_MUTEX(SgOmpInReductionClause, unlock);
   55260             :       return object;
   55261             :     }
   55262             : #endif
   55263             : 
   55264           6 :     if (SgOmpInReductionClause::next_node == nullptr) {
   55265           3 :         SgOmpInReductionClause * alloc = (SgOmpInReductionClause*) ROSE_MALLOC ( SgOmpInReductionClause::pool_size * sizeof(SgOmpInReductionClause) );
   55266           3 :         ROSE_ASSERT(alloc != nullptr);
   55267             : 
   55268             : #if ROSE_ALLOC_TRACE == 2
   55269             : //        printf("SgOmpInReductionClause::alloc\n  block[%zi] = [ %p , %p [\n", SgOmpInReductionClause::pools.size(), alloc, alloc + SgOmpInReductionClause::pool_size);
   55270             : #endif
   55271             : 
   55272             : #if ROSE_ALLOC_MEMSET == 1
   55273             : #elif ROSE_ALLOC_MEMSET == 2
   55274             :         memset(alloc, 0x00, SgOmpInReductionClause::pool_size * sizeof(SgOmpInReductionClause));
   55275             : #elif ROSE_ALLOC_MEMSET == 3
   55276             :         memset(alloc, 0xAA, SgOmpInReductionClause::pool_size * sizeof(SgOmpInReductionClause));
   55277             : #endif
   55278        6000 :         for (unsigned i=0; i < SgOmpInReductionClause::pool_size-1; i++) {
   55279        5997 :           alloc[i].p_freepointer = &(alloc[i+1]);
   55280             :         }
   55281           3 :         alloc[SgOmpInReductionClause::pool_size-1].p_freepointer = nullptr;
   55282             : 
   55283           3 :         SgOmpInReductionClause::pools.push_back ( (unsigned char *) alloc );
   55284           3 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgOmpInReductionClause::pool_size * sizeof(SgOmpInReductionClause), V_SgOmpInReductionClause ) );
   55285           3 :         SgOmpInReductionClause::next_node = alloc;
   55286             :     }
   55287           6 :     ROSE_ASSERT(SgOmpInReductionClause::next_node != nullptr);
   55288             : 
   55289           6 :     SgOmpInReductionClause * object = SgOmpInReductionClause::next_node;
   55290           6 :     SgOmpInReductionClause::next_node = (SgOmpInReductionClause*)(object->p_freepointer);
   55291             : 
   55292             : #if ROSE_ALLOC_TRACE == 2
   55293             :     printf("SgOmpInReductionClause::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpInReductionClause::next_node);
   55294             : #endif
   55295             : 
   55296           6 :     SgNode * fp = object->p_freepointer;
   55297             : #if ROSE_ALLOC_MEMSET == 1
   55298             : #elif ROSE_ALLOC_MEMSET == 2
   55299             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpInReductionClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   55300             : #elif ROSE_ALLOC_MEMSET == 3
   55301             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgOmpInReductionClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   55302             : #endif
   55303           6 :     object->p_freepointer = fp;
   55304             : 
   55305             : #if ROSE_ALLOC_TRACE == 2
   55306             : //    printf("SgOmpInReductionClause::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpInReductionClause::next_node);
   55307             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   55308             :     Rose::MemPool::snapshot(oss.str());
   55309             :     alloc_trace_cnt++;
   55310             : #endif
   55311             : 
   55312           6 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   55313             : 
   55314           6 :     ALLOC_MUTEX(SgOmpInReductionClause, unlock);
   55315             : 
   55316             :     return object;
   55317             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   55318             : }
   55319             : 
   55320             : 
   55321             : 
   55322             : /*! \brief Delete operator for SgOmpInReductionClause.
   55323             : 
   55324             :    This delete operator implements deallocation using memory pools to 
   55325             :    provide most efficent use of the heap within construction of large ASTs.
   55326             : 
   55327             : \internal The new and delete operators use the lower level C malloc/free
   55328             :    function calls for performance and to make sure that mixing of malloc/free
   55329             :    and new/delete by the used can be caught more readily.  This may change
   55330             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   55331             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   55332             :    deallocate memory allocated using ROSE_MALLOC.
   55333             : */
   55334           0 : void SgOmpInReductionClause::operator delete(void *Pointer, size_t Size)
   55335             : {
   55336             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   55337             :      * or throwing an exception. */
   55338           0 :     ALLOC_MUTEX(SgOmpInReductionClause, lock);
   55339             : 
   55340             : #if USE_CPP_NEW_DELETE_OPERATORS
   55341             :     ROSE_FREE(Pointer);
   55342             : #else
   55343             : #if ROSE_PEDANTIC_ALLOC
   55344             :     ROSE_ASSERT(Size == sizeof(SgOmpInReductionClause));
   55345             : #else
   55346           0 :     if (Size != sizeof(SgOmpInReductionClause)) {
   55347           0 :       ROSE_FREE(Pointer);
   55348           0 :       ALLOC_MUTEX(SgOmpInReductionClause, unlock);
   55349             :       return;
   55350             :     }
   55351             : #endif
   55352             : 
   55353           0 :     SgOmpInReductionClause * object = (SgOmpInReductionClause*) Pointer;
   55354           0 :     ROSE_ASSERT(object != nullptr);
   55355             : 
   55356             : #if ROSE_ALLOC_TRACE == 2
   55357             : //  printf("SgOmpInReductionClause::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpInReductionClause::next_node);
   55358             :     printf("SgOmpInReductionClause::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpInReductionClause::next_node);
   55359             : #endif
   55360             : 
   55361             : #if ROSE_PEDANTIC_ALLOC
   55362             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   55363             : #endif
   55364             : 
   55365             : #if ROSE_ALLOC_MEMSET == 1
   55366             : #elif ROSE_ALLOC_MEMSET == 2
   55367             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpInReductionClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   55368             : #elif ROSE_ALLOC_MEMSET == 3
   55369             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgOmpInReductionClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   55370             : #endif
   55371             : 
   55372             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   55373             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   55374             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   55375             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   55376             : #else
   55377           0 :     object->p_freepointer = SgOmpInReductionClause::next_node;
   55378           0 :     SgOmpInReductionClause::next_node = object;
   55379             : #endif
   55380             : 
   55381             : #if ROSE_ALLOC_TRACE == 2
   55382             : //  printf("SgOmpInReductionClause::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpInReductionClause::next_node);
   55383             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   55384             :     Rose::MemPool::snapshot(oss.str());
   55385             :     alloc_trace_cnt++;
   55386             : #endif
   55387             : 
   55388             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   55389             : 
   55390           0 :     ALLOC_MUTEX(SgOmpInReductionClause, unlock);
   55391             : }
   55392             : 
   55393             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   55394             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   55395             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   55396             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   55397             : // Also, note comment below from Robb (copied from the Common.code file).
   55398             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   55399             : //
   55400             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   55401             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   55402             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   55403             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   55404             : #if 0
   55405             : void SgOmpInReductionClause::operator delete(void* pointer) { SgOmpInReductionClause::operator delete (pointer, sizeof(SgOmpInReductionClause)); };
   55406             : #endif
   55407             : /* #line 55408 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   55408             : 
   55409             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   55410             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   55411             : // obviously imply C++.
   55412             : 
   55413             : // This implements the support within ROSE for memory pools.  Memory pools
   55414             : // support the most condensed usage of memory within the construction of
   55415             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   55416             : // by a new operator written for each class.
   55417             : 
   55418             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   55419             :     // User wants multi-thread support and POSIX threads are available.
   55420             : #   include <pthread.h>
   55421             :     static pthread_mutex_t SgOmpTaskReductionClause_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   55422             : #else
   55423             :      // Cause synchronization to be skipped.
   55424             : #    ifndef ALLOC_MUTEX
   55425             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   55426             : #    endif
   55427             : #    ifdef _REENTRANT
   55428             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   55429             : #       ifdef _MSC_VER
   55430             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   55431             : #       else
   55432             : #           warning "POSIX threads are not available; synchronization being skipped"
   55433             : #       endif
   55434             : #    endif
   55435             : #endif
   55436             : 
   55437             : #ifndef ROSE_ALLOC_TRACE
   55438             : #  define ROSE_ALLOC_TRACE 0
   55439             : #endif
   55440             : 
   55441             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   55442             : #define ROSE_ALLOC_TRACE_CNT
   55443             : #include "memory-pool-snapshot.h"
   55444             : unsigned long alloc_trace_cnt = 0;
   55445             : #endif
   55446             : 
   55447             : #if ROSE_ALLOC_TRACE
   55448             : const unsigned SgOmpTaskReductionClause::pool_size = 5;
   55449             : #else
   55450             : const unsigned SgOmpTaskReductionClause::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   55451             : #endif
   55452             : 
   55453             : #ifndef ROSE_ALLOC_MEMSET
   55454             : #  define ROSE_ALLOC_MEMSET 0
   55455             : #endif
   55456             : 
   55457             : #ifndef ROSE_PEDANTIC_ALLOC
   55458             : #  define ROSE_PEDANTIC_ALLOC 0
   55459             : #endif
   55460             : 
   55461             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   55462             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   55463             : #endif
   55464             : 
   55465             : #if !defined(SGNODE__ALL_POOLS)
   55466             : #define SGNODE__ALL_POOLS
   55467             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   55468             : #endif
   55469             : 
   55470             : SgOmpTaskReductionClause* SgOmpTaskReductionClause::next_node = nullptr;
   55471             : std::vector<unsigned char*> SgOmpTaskReductionClause::pools;
   55472             : 
   55473             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   55474             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   55475             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   55476             : // around this macro definition rather than each use).
   55477             : #ifndef ALLOC_MUTEX
   55478             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   55479             :         do {                                                                     \
   55480             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   55481             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   55482             :                 abort();                                                         \
   55483             :             }                                                                    \
   55484             :         } while (0);
   55485             : #endif
   55486             : 
   55487             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   55488             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   55489             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   55490             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   55491             : 
   55492             : /*! \brief New operator for SgOmpTaskReductionClause.
   55493             : 
   55494             :    This new operator implements memory pools to provide most efficent 
   55495             :    use of the heap within construction of large ASTs.
   55496             : 
   55497             : \internal The new and delete operators use the lower level C malloc/free
   55498             :    function calls for performance and to make sure that mixing of malloc/free
   55499             :    and new/delete by the used can be caught more readily.  This may change
   55500             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   55501             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   55502             :    deallocate memory allocated using ROSE_MALLOC.
   55503             : */
   55504           0 : void *SgOmpTaskReductionClause::operator new ( size_t Size )
   55505             : {
   55506             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   55507             :      * returning or throwing an exception. */
   55508           0 :     ALLOC_MUTEX(SgOmpTaskReductionClause, lock);
   55509             : 
   55510             : #if ROSE_ALLOC_TRACE == 2
   55511             : //    printf("SgOmpTaskReductionClause::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgOmpTaskReductionClause::next_node);
   55512             : #endif
   55513             : 
   55514             : #if USE_CPP_NEW_DELETE_OPERATORS
   55515             :     void *mem = ROSE_MALLOC(Size);
   55516             :     ALLOC_MUTEX(SgOmpTaskReductionClause, unlock);
   55517             :     return mem;
   55518             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   55519             : #if ROSE_PEDANTIC_ALLOC
   55520             :     ROSE_ASSERT(Size == sizeof(SgOmpTaskReductionClause));
   55521             : #else
   55522           0 :     if (Size != sizeof(SgOmpTaskReductionClause)) {
   55523           0 :       void * object = ROSE_MALLOC(Size);
   55524           0 :       ALLOC_MUTEX(SgOmpTaskReductionClause, unlock);
   55525             :       return object;
   55526             :     }
   55527             : #endif
   55528             : 
   55529           0 :     if (SgOmpTaskReductionClause::next_node == nullptr) {
   55530           0 :         SgOmpTaskReductionClause * alloc = (SgOmpTaskReductionClause*) ROSE_MALLOC ( SgOmpTaskReductionClause::pool_size * sizeof(SgOmpTaskReductionClause) );
   55531           0 :         ROSE_ASSERT(alloc != nullptr);
   55532             : 
   55533             : #if ROSE_ALLOC_TRACE == 2
   55534             : //        printf("SgOmpTaskReductionClause::alloc\n  block[%zi] = [ %p , %p [\n", SgOmpTaskReductionClause::pools.size(), alloc, alloc + SgOmpTaskReductionClause::pool_size);
   55535             : #endif
   55536             : 
   55537             : #if ROSE_ALLOC_MEMSET == 1
   55538             : #elif ROSE_ALLOC_MEMSET == 2
   55539             :         memset(alloc, 0x00, SgOmpTaskReductionClause::pool_size * sizeof(SgOmpTaskReductionClause));
   55540             : #elif ROSE_ALLOC_MEMSET == 3
   55541             :         memset(alloc, 0xAA, SgOmpTaskReductionClause::pool_size * sizeof(SgOmpTaskReductionClause));
   55542             : #endif
   55543           0 :         for (unsigned i=0; i < SgOmpTaskReductionClause::pool_size-1; i++) {
   55544           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
   55545             :         }
   55546           0 :         alloc[SgOmpTaskReductionClause::pool_size-1].p_freepointer = nullptr;
   55547             : 
   55548           0 :         SgOmpTaskReductionClause::pools.push_back ( (unsigned char *) alloc );
   55549           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgOmpTaskReductionClause::pool_size * sizeof(SgOmpTaskReductionClause), V_SgOmpTaskReductionClause ) );
   55550           0 :         SgOmpTaskReductionClause::next_node = alloc;
   55551             :     }
   55552           0 :     ROSE_ASSERT(SgOmpTaskReductionClause::next_node != nullptr);
   55553             : 
   55554           0 :     SgOmpTaskReductionClause * object = SgOmpTaskReductionClause::next_node;
   55555           0 :     SgOmpTaskReductionClause::next_node = (SgOmpTaskReductionClause*)(object->p_freepointer);
   55556             : 
   55557             : #if ROSE_ALLOC_TRACE == 2
   55558             :     printf("SgOmpTaskReductionClause::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpTaskReductionClause::next_node);
   55559             : #endif
   55560             : 
   55561           0 :     SgNode * fp = object->p_freepointer;
   55562             : #if ROSE_ALLOC_MEMSET == 1
   55563             : #elif ROSE_ALLOC_MEMSET == 2
   55564             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpTaskReductionClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   55565             : #elif ROSE_ALLOC_MEMSET == 3
   55566             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgOmpTaskReductionClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   55567             : #endif
   55568           0 :     object->p_freepointer = fp;
   55569             : 
   55570             : #if ROSE_ALLOC_TRACE == 2
   55571             : //    printf("SgOmpTaskReductionClause::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpTaskReductionClause::next_node);
   55572             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   55573             :     Rose::MemPool::snapshot(oss.str());
   55574             :     alloc_trace_cnt++;
   55575             : #endif
   55576             : 
   55577           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   55578             : 
   55579           0 :     ALLOC_MUTEX(SgOmpTaskReductionClause, unlock);
   55580             : 
   55581             :     return object;
   55582             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   55583             : }
   55584             : 
   55585             : 
   55586             : 
   55587             : /*! \brief Delete operator for SgOmpTaskReductionClause.
   55588             : 
   55589             :    This delete operator implements deallocation using memory pools to 
   55590             :    provide most efficent use of the heap within construction of large ASTs.
   55591             : 
   55592             : \internal The new and delete operators use the lower level C malloc/free
   55593             :    function calls for performance and to make sure that mixing of malloc/free
   55594             :    and new/delete by the used can be caught more readily.  This may change
   55595             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   55596             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   55597             :    deallocate memory allocated using ROSE_MALLOC.
   55598             : */
   55599           0 : void SgOmpTaskReductionClause::operator delete(void *Pointer, size_t Size)
   55600             : {
   55601             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   55602             :      * or throwing an exception. */
   55603           0 :     ALLOC_MUTEX(SgOmpTaskReductionClause, lock);
   55604             : 
   55605             : #if USE_CPP_NEW_DELETE_OPERATORS
   55606             :     ROSE_FREE(Pointer);
   55607             : #else
   55608             : #if ROSE_PEDANTIC_ALLOC
   55609             :     ROSE_ASSERT(Size == sizeof(SgOmpTaskReductionClause));
   55610             : #else
   55611           0 :     if (Size != sizeof(SgOmpTaskReductionClause)) {
   55612           0 :       ROSE_FREE(Pointer);
   55613           0 :       ALLOC_MUTEX(SgOmpTaskReductionClause, unlock);
   55614             :       return;
   55615             :     }
   55616             : #endif
   55617             : 
   55618           0 :     SgOmpTaskReductionClause * object = (SgOmpTaskReductionClause*) Pointer;
   55619           0 :     ROSE_ASSERT(object != nullptr);
   55620             : 
   55621             : #if ROSE_ALLOC_TRACE == 2
   55622             : //  printf("SgOmpTaskReductionClause::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpTaskReductionClause::next_node);
   55623             :     printf("SgOmpTaskReductionClause::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpTaskReductionClause::next_node);
   55624             : #endif
   55625             : 
   55626             : #if ROSE_PEDANTIC_ALLOC
   55627             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   55628             : #endif
   55629             : 
   55630             : #if ROSE_ALLOC_MEMSET == 1
   55631             : #elif ROSE_ALLOC_MEMSET == 2
   55632             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpTaskReductionClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   55633             : #elif ROSE_ALLOC_MEMSET == 3
   55634             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgOmpTaskReductionClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   55635             : #endif
   55636             : 
   55637             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   55638             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   55639             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   55640             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   55641             : #else
   55642           0 :     object->p_freepointer = SgOmpTaskReductionClause::next_node;
   55643           0 :     SgOmpTaskReductionClause::next_node = object;
   55644             : #endif
   55645             : 
   55646             : #if ROSE_ALLOC_TRACE == 2
   55647             : //  printf("SgOmpTaskReductionClause::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpTaskReductionClause::next_node);
   55648             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   55649             :     Rose::MemPool::snapshot(oss.str());
   55650             :     alloc_trace_cnt++;
   55651             : #endif
   55652             : 
   55653             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   55654             : 
   55655           0 :     ALLOC_MUTEX(SgOmpTaskReductionClause, unlock);
   55656             : }
   55657             : 
   55658             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   55659             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   55660             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   55661             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   55662             : // Also, note comment below from Robb (copied from the Common.code file).
   55663             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   55664             : //
   55665             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   55666             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   55667             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   55668             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   55669             : #if 0
   55670             : void SgOmpTaskReductionClause::operator delete(void* pointer) { SgOmpTaskReductionClause::operator delete (pointer, sizeof(SgOmpTaskReductionClause)); };
   55671             : #endif
   55672             : /* #line 55673 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   55673             : 
   55674             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   55675             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   55676             : // obviously imply C++.
   55677             : 
   55678             : // This implements the support within ROSE for memory pools.  Memory pools
   55679             : // support the most condensed usage of memory within the construction of
   55680             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   55681             : // by a new operator written for each class.
   55682             : 
   55683             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   55684             :     // User wants multi-thread support and POSIX threads are available.
   55685             : #   include <pthread.h>
   55686             :     static pthread_mutex_t SgOmpMapClause_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   55687             : #else
   55688             :      // Cause synchronization to be skipped.
   55689             : #    ifndef ALLOC_MUTEX
   55690             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   55691             : #    endif
   55692             : #    ifdef _REENTRANT
   55693             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   55694             : #       ifdef _MSC_VER
   55695             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   55696             : #       else
   55697             : #           warning "POSIX threads are not available; synchronization being skipped"
   55698             : #       endif
   55699             : #    endif
   55700             : #endif
   55701             : 
   55702             : #ifndef ROSE_ALLOC_TRACE
   55703             : #  define ROSE_ALLOC_TRACE 0
   55704             : #endif
   55705             : 
   55706             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   55707             : #define ROSE_ALLOC_TRACE_CNT
   55708             : #include "memory-pool-snapshot.h"
   55709             : unsigned long alloc_trace_cnt = 0;
   55710             : #endif
   55711             : 
   55712             : #if ROSE_ALLOC_TRACE
   55713             : const unsigned SgOmpMapClause::pool_size = 5;
   55714             : #else
   55715             : const unsigned SgOmpMapClause::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   55716             : #endif
   55717             : 
   55718             : #ifndef ROSE_ALLOC_MEMSET
   55719             : #  define ROSE_ALLOC_MEMSET 0
   55720             : #endif
   55721             : 
   55722             : #ifndef ROSE_PEDANTIC_ALLOC
   55723             : #  define ROSE_PEDANTIC_ALLOC 0
   55724             : #endif
   55725             : 
   55726             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   55727             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   55728             : #endif
   55729             : 
   55730             : #if !defined(SGNODE__ALL_POOLS)
   55731             : #define SGNODE__ALL_POOLS
   55732             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   55733             : #endif
   55734             : 
   55735             : SgOmpMapClause* SgOmpMapClause::next_node = nullptr;
   55736             : std::vector<unsigned char*> SgOmpMapClause::pools;
   55737             : 
   55738             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   55739             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   55740             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   55741             : // around this macro definition rather than each use).
   55742             : #ifndef ALLOC_MUTEX
   55743             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   55744             :         do {                                                                     \
   55745             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   55746             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   55747             :                 abort();                                                         \
   55748             :             }                                                                    \
   55749             :         } while (0);
   55750             : #endif
   55751             : 
   55752             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   55753             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   55754             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   55755             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   55756             : 
   55757             : /*! \brief New operator for SgOmpMapClause.
   55758             : 
   55759             :    This new operator implements memory pools to provide most efficent 
   55760             :    use of the heap within construction of large ASTs.
   55761             : 
   55762             : \internal The new and delete operators use the lower level C malloc/free
   55763             :    function calls for performance and to make sure that mixing of malloc/free
   55764             :    and new/delete by the used can be caught more readily.  This may change
   55765             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   55766             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   55767             :    deallocate memory allocated using ROSE_MALLOC.
   55768             : */
   55769          43 : void *SgOmpMapClause::operator new ( size_t Size )
   55770             : {
   55771             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   55772             :      * returning or throwing an exception. */
   55773          43 :     ALLOC_MUTEX(SgOmpMapClause, lock);
   55774             : 
   55775             : #if ROSE_ALLOC_TRACE == 2
   55776             : //    printf("SgOmpMapClause::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgOmpMapClause::next_node);
   55777             : #endif
   55778             : 
   55779             : #if USE_CPP_NEW_DELETE_OPERATORS
   55780             :     void *mem = ROSE_MALLOC(Size);
   55781             :     ALLOC_MUTEX(SgOmpMapClause, unlock);
   55782             :     return mem;
   55783             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   55784             : #if ROSE_PEDANTIC_ALLOC
   55785             :     ROSE_ASSERT(Size == sizeof(SgOmpMapClause));
   55786             : #else
   55787          43 :     if (Size != sizeof(SgOmpMapClause)) {
   55788           0 :       void * object = ROSE_MALLOC(Size);
   55789           0 :       ALLOC_MUTEX(SgOmpMapClause, unlock);
   55790             :       return object;
   55791             :     }
   55792             : #endif
   55793             : 
   55794          43 :     if (SgOmpMapClause::next_node == nullptr) {
   55795          14 :         SgOmpMapClause * alloc = (SgOmpMapClause*) ROSE_MALLOC ( SgOmpMapClause::pool_size * sizeof(SgOmpMapClause) );
   55796          14 :         ROSE_ASSERT(alloc != nullptr);
   55797             : 
   55798             : #if ROSE_ALLOC_TRACE == 2
   55799             : //        printf("SgOmpMapClause::alloc\n  block[%zi] = [ %p , %p [\n", SgOmpMapClause::pools.size(), alloc, alloc + SgOmpMapClause::pool_size);
   55800             : #endif
   55801             : 
   55802             : #if ROSE_ALLOC_MEMSET == 1
   55803             : #elif ROSE_ALLOC_MEMSET == 2
   55804             :         memset(alloc, 0x00, SgOmpMapClause::pool_size * sizeof(SgOmpMapClause));
   55805             : #elif ROSE_ALLOC_MEMSET == 3
   55806             :         memset(alloc, 0xAA, SgOmpMapClause::pool_size * sizeof(SgOmpMapClause));
   55807             : #endif
   55808       28000 :         for (unsigned i=0; i < SgOmpMapClause::pool_size-1; i++) {
   55809       27986 :           alloc[i].p_freepointer = &(alloc[i+1]);
   55810             :         }
   55811          14 :         alloc[SgOmpMapClause::pool_size-1].p_freepointer = nullptr;
   55812             : 
   55813          14 :         SgOmpMapClause::pools.push_back ( (unsigned char *) alloc );
   55814          14 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgOmpMapClause::pool_size * sizeof(SgOmpMapClause), V_SgOmpMapClause ) );
   55815          14 :         SgOmpMapClause::next_node = alloc;
   55816             :     }
   55817          43 :     ROSE_ASSERT(SgOmpMapClause::next_node != nullptr);
   55818             : 
   55819          43 :     SgOmpMapClause * object = SgOmpMapClause::next_node;
   55820          43 :     SgOmpMapClause::next_node = (SgOmpMapClause*)(object->p_freepointer);
   55821             : 
   55822             : #if ROSE_ALLOC_TRACE == 2
   55823             :     printf("SgOmpMapClause::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpMapClause::next_node);
   55824             : #endif
   55825             : 
   55826          43 :     SgNode * fp = object->p_freepointer;
   55827             : #if ROSE_ALLOC_MEMSET == 1
   55828             : #elif ROSE_ALLOC_MEMSET == 2
   55829             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpMapClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   55830             : #elif ROSE_ALLOC_MEMSET == 3
   55831             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgOmpMapClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   55832             : #endif
   55833          43 :     object->p_freepointer = fp;
   55834             : 
   55835             : #if ROSE_ALLOC_TRACE == 2
   55836             : //    printf("SgOmpMapClause::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpMapClause::next_node);
   55837             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   55838             :     Rose::MemPool::snapshot(oss.str());
   55839             :     alloc_trace_cnt++;
   55840             : #endif
   55841             : 
   55842          43 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   55843             : 
   55844          43 :     ALLOC_MUTEX(SgOmpMapClause, unlock);
   55845             : 
   55846             :     return object;
   55847             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   55848             : }
   55849             : 
   55850             : 
   55851             : 
   55852             : /*! \brief Delete operator for SgOmpMapClause.
   55853             : 
   55854             :    This delete operator implements deallocation using memory pools to 
   55855             :    provide most efficent use of the heap within construction of large ASTs.
   55856             : 
   55857             : \internal The new and delete operators use the lower level C malloc/free
   55858             :    function calls for performance and to make sure that mixing of malloc/free
   55859             :    and new/delete by the used can be caught more readily.  This may change
   55860             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   55861             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   55862             :    deallocate memory allocated using ROSE_MALLOC.
   55863             : */
   55864           0 : void SgOmpMapClause::operator delete(void *Pointer, size_t Size)
   55865             : {
   55866             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   55867             :      * or throwing an exception. */
   55868           0 :     ALLOC_MUTEX(SgOmpMapClause, lock);
   55869             : 
   55870             : #if USE_CPP_NEW_DELETE_OPERATORS
   55871             :     ROSE_FREE(Pointer);
   55872             : #else
   55873             : #if ROSE_PEDANTIC_ALLOC
   55874             :     ROSE_ASSERT(Size == sizeof(SgOmpMapClause));
   55875             : #else
   55876           0 :     if (Size != sizeof(SgOmpMapClause)) {
   55877           0 :       ROSE_FREE(Pointer);
   55878           0 :       ALLOC_MUTEX(SgOmpMapClause, unlock);
   55879             :       return;
   55880             :     }
   55881             : #endif
   55882             : 
   55883           0 :     SgOmpMapClause * object = (SgOmpMapClause*) Pointer;
   55884           0 :     ROSE_ASSERT(object != nullptr);
   55885             : 
   55886             : #if ROSE_ALLOC_TRACE == 2
   55887             : //  printf("SgOmpMapClause::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpMapClause::next_node);
   55888             :     printf("SgOmpMapClause::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpMapClause::next_node);
   55889             : #endif
   55890             : 
   55891             : #if ROSE_PEDANTIC_ALLOC
   55892             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   55893             : #endif
   55894             : 
   55895             : #if ROSE_ALLOC_MEMSET == 1
   55896             : #elif ROSE_ALLOC_MEMSET == 2
   55897             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpMapClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   55898             : #elif ROSE_ALLOC_MEMSET == 3
   55899             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgOmpMapClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   55900             : #endif
   55901             : 
   55902             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   55903             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   55904             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   55905             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   55906             : #else
   55907           0 :     object->p_freepointer = SgOmpMapClause::next_node;
   55908           0 :     SgOmpMapClause::next_node = object;
   55909             : #endif
   55910             : 
   55911             : #if ROSE_ALLOC_TRACE == 2
   55912             : //  printf("SgOmpMapClause::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpMapClause::next_node);
   55913             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   55914             :     Rose::MemPool::snapshot(oss.str());
   55915             :     alloc_trace_cnt++;
   55916             : #endif
   55917             : 
   55918             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   55919             : 
   55920           0 :     ALLOC_MUTEX(SgOmpMapClause, unlock);
   55921             : }
   55922             : 
   55923             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   55924             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   55925             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   55926             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   55927             : // Also, note comment below from Robb (copied from the Common.code file).
   55928             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   55929             : //
   55930             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   55931             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   55932             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   55933             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   55934             : #if 0
   55935             : void SgOmpMapClause::operator delete(void* pointer) { SgOmpMapClause::operator delete (pointer, sizeof(SgOmpMapClause)); };
   55936             : #endif
   55937             : /* #line 55938 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   55938             : 
   55939             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   55940             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   55941             : // obviously imply C++.
   55942             : 
   55943             : // This implements the support within ROSE for memory pools.  Memory pools
   55944             : // support the most condensed usage of memory within the construction of
   55945             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   55946             : // by a new operator written for each class.
   55947             : 
   55948             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   55949             :     // User wants multi-thread support and POSIX threads are available.
   55950             : #   include <pthread.h>
   55951             :     static pthread_mutex_t SgOmpAllocateClause_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   55952             : #else
   55953             :      // Cause synchronization to be skipped.
   55954             : #    ifndef ALLOC_MUTEX
   55955             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   55956             : #    endif
   55957             : #    ifdef _REENTRANT
   55958             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   55959             : #       ifdef _MSC_VER
   55960             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   55961             : #       else
   55962             : #           warning "POSIX threads are not available; synchronization being skipped"
   55963             : #       endif
   55964             : #    endif
   55965             : #endif
   55966             : 
   55967             : #ifndef ROSE_ALLOC_TRACE
   55968             : #  define ROSE_ALLOC_TRACE 0
   55969             : #endif
   55970             : 
   55971             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   55972             : #define ROSE_ALLOC_TRACE_CNT
   55973             : #include "memory-pool-snapshot.h"
   55974             : unsigned long alloc_trace_cnt = 0;
   55975             : #endif
   55976             : 
   55977             : #if ROSE_ALLOC_TRACE
   55978             : const unsigned SgOmpAllocateClause::pool_size = 5;
   55979             : #else
   55980             : const unsigned SgOmpAllocateClause::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   55981             : #endif
   55982             : 
   55983             : #ifndef ROSE_ALLOC_MEMSET
   55984             : #  define ROSE_ALLOC_MEMSET 0
   55985             : #endif
   55986             : 
   55987             : #ifndef ROSE_PEDANTIC_ALLOC
   55988             : #  define ROSE_PEDANTIC_ALLOC 0
   55989             : #endif
   55990             : 
   55991             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   55992             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   55993             : #endif
   55994             : 
   55995             : #if !defined(SGNODE__ALL_POOLS)
   55996             : #define SGNODE__ALL_POOLS
   55997             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   55998             : #endif
   55999             : 
   56000             : SgOmpAllocateClause* SgOmpAllocateClause::next_node = nullptr;
   56001             : std::vector<unsigned char*> SgOmpAllocateClause::pools;
   56002             : 
   56003             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   56004             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   56005             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   56006             : // around this macro definition rather than each use).
   56007             : #ifndef ALLOC_MUTEX
   56008             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   56009             :         do {                                                                     \
   56010             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   56011             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   56012             :                 abort();                                                         \
   56013             :             }                                                                    \
   56014             :         } while (0);
   56015             : #endif
   56016             : 
   56017             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   56018             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   56019             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   56020             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   56021             : 
   56022             : /*! \brief New operator for SgOmpAllocateClause.
   56023             : 
   56024             :    This new operator implements memory pools to provide most efficent 
   56025             :    use of the heap within construction of large ASTs.
   56026             : 
   56027             : \internal The new and delete operators use the lower level C malloc/free
   56028             :    function calls for performance and to make sure that mixing of malloc/free
   56029             :    and new/delete by the used can be caught more readily.  This may change
   56030             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   56031             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   56032             :    deallocate memory allocated using ROSE_MALLOC.
   56033             : */
   56034          34 : void *SgOmpAllocateClause::operator new ( size_t Size )
   56035             : {
   56036             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   56037             :      * returning or throwing an exception. */
   56038          34 :     ALLOC_MUTEX(SgOmpAllocateClause, lock);
   56039             : 
   56040             : #if ROSE_ALLOC_TRACE == 2
   56041             : //    printf("SgOmpAllocateClause::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgOmpAllocateClause::next_node);
   56042             : #endif
   56043             : 
   56044             : #if USE_CPP_NEW_DELETE_OPERATORS
   56045             :     void *mem = ROSE_MALLOC(Size);
   56046             :     ALLOC_MUTEX(SgOmpAllocateClause, unlock);
   56047             :     return mem;
   56048             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   56049             : #if ROSE_PEDANTIC_ALLOC
   56050             :     ROSE_ASSERT(Size == sizeof(SgOmpAllocateClause));
   56051             : #else
   56052          34 :     if (Size != sizeof(SgOmpAllocateClause)) {
   56053           0 :       void * object = ROSE_MALLOC(Size);
   56054           0 :       ALLOC_MUTEX(SgOmpAllocateClause, unlock);
   56055             :       return object;
   56056             :     }
   56057             : #endif
   56058             : 
   56059          34 :     if (SgOmpAllocateClause::next_node == nullptr) {
   56060           4 :         SgOmpAllocateClause * alloc = (SgOmpAllocateClause*) ROSE_MALLOC ( SgOmpAllocateClause::pool_size * sizeof(SgOmpAllocateClause) );
   56061           4 :         ROSE_ASSERT(alloc != nullptr);
   56062             : 
   56063             : #if ROSE_ALLOC_TRACE == 2
   56064             : //        printf("SgOmpAllocateClause::alloc\n  block[%zi] = [ %p , %p [\n", SgOmpAllocateClause::pools.size(), alloc, alloc + SgOmpAllocateClause::pool_size);
   56065             : #endif
   56066             : 
   56067             : #if ROSE_ALLOC_MEMSET == 1
   56068             : #elif ROSE_ALLOC_MEMSET == 2
   56069             :         memset(alloc, 0x00, SgOmpAllocateClause::pool_size * sizeof(SgOmpAllocateClause));
   56070             : #elif ROSE_ALLOC_MEMSET == 3
   56071             :         memset(alloc, 0xAA, SgOmpAllocateClause::pool_size * sizeof(SgOmpAllocateClause));
   56072             : #endif
   56073        8000 :         for (unsigned i=0; i < SgOmpAllocateClause::pool_size-1; i++) {
   56074        7996 :           alloc[i].p_freepointer = &(alloc[i+1]);
   56075             :         }
   56076           4 :         alloc[SgOmpAllocateClause::pool_size-1].p_freepointer = nullptr;
   56077             : 
   56078           4 :         SgOmpAllocateClause::pools.push_back ( (unsigned char *) alloc );
   56079           4 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgOmpAllocateClause::pool_size * sizeof(SgOmpAllocateClause), V_SgOmpAllocateClause ) );
   56080           4 :         SgOmpAllocateClause::next_node = alloc;
   56081             :     }
   56082          34 :     ROSE_ASSERT(SgOmpAllocateClause::next_node != nullptr);
   56083             : 
   56084          34 :     SgOmpAllocateClause * object = SgOmpAllocateClause::next_node;
   56085          34 :     SgOmpAllocateClause::next_node = (SgOmpAllocateClause*)(object->p_freepointer);
   56086             : 
   56087             : #if ROSE_ALLOC_TRACE == 2
   56088             :     printf("SgOmpAllocateClause::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpAllocateClause::next_node);
   56089             : #endif
   56090             : 
   56091          34 :     SgNode * fp = object->p_freepointer;
   56092             : #if ROSE_ALLOC_MEMSET == 1
   56093             : #elif ROSE_ALLOC_MEMSET == 2
   56094             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpAllocateClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   56095             : #elif ROSE_ALLOC_MEMSET == 3
   56096             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgOmpAllocateClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   56097             : #endif
   56098          34 :     object->p_freepointer = fp;
   56099             : 
   56100             : #if ROSE_ALLOC_TRACE == 2
   56101             : //    printf("SgOmpAllocateClause::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpAllocateClause::next_node);
   56102             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   56103             :     Rose::MemPool::snapshot(oss.str());
   56104             :     alloc_trace_cnt++;
   56105             : #endif
   56106             : 
   56107          34 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   56108             : 
   56109          34 :     ALLOC_MUTEX(SgOmpAllocateClause, unlock);
   56110             : 
   56111             :     return object;
   56112             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   56113             : }
   56114             : 
   56115             : 
   56116             : 
   56117             : /*! \brief Delete operator for SgOmpAllocateClause.
   56118             : 
   56119             :    This delete operator implements deallocation using memory pools to 
   56120             :    provide most efficent use of the heap within construction of large ASTs.
   56121             : 
   56122             : \internal The new and delete operators use the lower level C malloc/free
   56123             :    function calls for performance and to make sure that mixing of malloc/free
   56124             :    and new/delete by the used can be caught more readily.  This may change
   56125             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   56126             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   56127             :    deallocate memory allocated using ROSE_MALLOC.
   56128             : */
   56129           0 : void SgOmpAllocateClause::operator delete(void *Pointer, size_t Size)
   56130             : {
   56131             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   56132             :      * or throwing an exception. */
   56133           0 :     ALLOC_MUTEX(SgOmpAllocateClause, lock);
   56134             : 
   56135             : #if USE_CPP_NEW_DELETE_OPERATORS
   56136             :     ROSE_FREE(Pointer);
   56137             : #else
   56138             : #if ROSE_PEDANTIC_ALLOC
   56139             :     ROSE_ASSERT(Size == sizeof(SgOmpAllocateClause));
   56140             : #else
   56141           0 :     if (Size != sizeof(SgOmpAllocateClause)) {
   56142           0 :       ROSE_FREE(Pointer);
   56143           0 :       ALLOC_MUTEX(SgOmpAllocateClause, unlock);
   56144             :       return;
   56145             :     }
   56146             : #endif
   56147             : 
   56148           0 :     SgOmpAllocateClause * object = (SgOmpAllocateClause*) Pointer;
   56149           0 :     ROSE_ASSERT(object != nullptr);
   56150             : 
   56151             : #if ROSE_ALLOC_TRACE == 2
   56152             : //  printf("SgOmpAllocateClause::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpAllocateClause::next_node);
   56153             :     printf("SgOmpAllocateClause::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpAllocateClause::next_node);
   56154             : #endif
   56155             : 
   56156             : #if ROSE_PEDANTIC_ALLOC
   56157             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   56158             : #endif
   56159             : 
   56160             : #if ROSE_ALLOC_MEMSET == 1
   56161             : #elif ROSE_ALLOC_MEMSET == 2
   56162             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpAllocateClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   56163             : #elif ROSE_ALLOC_MEMSET == 3
   56164             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgOmpAllocateClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   56165             : #endif
   56166             : 
   56167             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   56168             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   56169             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   56170             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   56171             : #else
   56172           0 :     object->p_freepointer = SgOmpAllocateClause::next_node;
   56173           0 :     SgOmpAllocateClause::next_node = object;
   56174             : #endif
   56175             : 
   56176             : #if ROSE_ALLOC_TRACE == 2
   56177             : //  printf("SgOmpAllocateClause::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpAllocateClause::next_node);
   56178             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   56179             :     Rose::MemPool::snapshot(oss.str());
   56180             :     alloc_trace_cnt++;
   56181             : #endif
   56182             : 
   56183             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   56184             : 
   56185           0 :     ALLOC_MUTEX(SgOmpAllocateClause, unlock);
   56186             : }
   56187             : 
   56188             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   56189             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   56190             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   56191             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   56192             : // Also, note comment below from Robb (copied from the Common.code file).
   56193             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   56194             : //
   56195             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   56196             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   56197             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   56198             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   56199             : #if 0
   56200             : void SgOmpAllocateClause::operator delete(void* pointer) { SgOmpAllocateClause::operator delete (pointer, sizeof(SgOmpAllocateClause)); };
   56201             : #endif
   56202             : /* #line 56203 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   56203             : 
   56204             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   56205             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   56206             : // obviously imply C++.
   56207             : 
   56208             : // This implements the support within ROSE for memory pools.  Memory pools
   56209             : // support the most condensed usage of memory within the construction of
   56210             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   56211             : // by a new operator written for each class.
   56212             : 
   56213             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   56214             :     // User wants multi-thread support and POSIX threads are available.
   56215             : #   include <pthread.h>
   56216             :     static pthread_mutex_t SgOmpUniformClause_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   56217             : #else
   56218             :      // Cause synchronization to be skipped.
   56219             : #    ifndef ALLOC_MUTEX
   56220             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   56221             : #    endif
   56222             : #    ifdef _REENTRANT
   56223             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   56224             : #       ifdef _MSC_VER
   56225             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   56226             : #       else
   56227             : #           warning "POSIX threads are not available; synchronization being skipped"
   56228             : #       endif
   56229             : #    endif
   56230             : #endif
   56231             : 
   56232             : #ifndef ROSE_ALLOC_TRACE
   56233             : #  define ROSE_ALLOC_TRACE 0
   56234             : #endif
   56235             : 
   56236             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   56237             : #define ROSE_ALLOC_TRACE_CNT
   56238             : #include "memory-pool-snapshot.h"
   56239             : unsigned long alloc_trace_cnt = 0;
   56240             : #endif
   56241             : 
   56242             : #if ROSE_ALLOC_TRACE
   56243             : const unsigned SgOmpUniformClause::pool_size = 5;
   56244             : #else
   56245             : const unsigned SgOmpUniformClause::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   56246             : #endif
   56247             : 
   56248             : #ifndef ROSE_ALLOC_MEMSET
   56249             : #  define ROSE_ALLOC_MEMSET 0
   56250             : #endif
   56251             : 
   56252             : #ifndef ROSE_PEDANTIC_ALLOC
   56253             : #  define ROSE_PEDANTIC_ALLOC 0
   56254             : #endif
   56255             : 
   56256             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   56257             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   56258             : #endif
   56259             : 
   56260             : #if !defined(SGNODE__ALL_POOLS)
   56261             : #define SGNODE__ALL_POOLS
   56262             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   56263             : #endif
   56264             : 
   56265             : SgOmpUniformClause* SgOmpUniformClause::next_node = nullptr;
   56266             : std::vector<unsigned char*> SgOmpUniformClause::pools;
   56267             : 
   56268             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   56269             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   56270             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   56271             : // around this macro definition rather than each use).
   56272             : #ifndef ALLOC_MUTEX
   56273             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   56274             :         do {                                                                     \
   56275             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   56276             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   56277             :                 abort();                                                         \
   56278             :             }                                                                    \
   56279             :         } while (0);
   56280             : #endif
   56281             : 
   56282             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   56283             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   56284             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   56285             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   56286             : 
   56287             : /*! \brief New operator for SgOmpUniformClause.
   56288             : 
   56289             :    This new operator implements memory pools to provide most efficent 
   56290             :    use of the heap within construction of large ASTs.
   56291             : 
   56292             : \internal The new and delete operators use the lower level C malloc/free
   56293             :    function calls for performance and to make sure that mixing of malloc/free
   56294             :    and new/delete by the used can be caught more readily.  This may change
   56295             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   56296             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   56297             :    deallocate memory allocated using ROSE_MALLOC.
   56298             : */
   56299           3 : void *SgOmpUniformClause::operator new ( size_t Size )
   56300             : {
   56301             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   56302             :      * returning or throwing an exception. */
   56303           3 :     ALLOC_MUTEX(SgOmpUniformClause, lock);
   56304             : 
   56305             : #if ROSE_ALLOC_TRACE == 2
   56306             : //    printf("SgOmpUniformClause::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgOmpUniformClause::next_node);
   56307             : #endif
   56308             : 
   56309             : #if USE_CPP_NEW_DELETE_OPERATORS
   56310             :     void *mem = ROSE_MALLOC(Size);
   56311             :     ALLOC_MUTEX(SgOmpUniformClause, unlock);
   56312             :     return mem;
   56313             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   56314             : #if ROSE_PEDANTIC_ALLOC
   56315             :     ROSE_ASSERT(Size == sizeof(SgOmpUniformClause));
   56316             : #else
   56317           3 :     if (Size != sizeof(SgOmpUniformClause)) {
   56318           0 :       void * object = ROSE_MALLOC(Size);
   56319           0 :       ALLOC_MUTEX(SgOmpUniformClause, unlock);
   56320             :       return object;
   56321             :     }
   56322             : #endif
   56323             : 
   56324           3 :     if (SgOmpUniformClause::next_node == nullptr) {
   56325           1 :         SgOmpUniformClause * alloc = (SgOmpUniformClause*) ROSE_MALLOC ( SgOmpUniformClause::pool_size * sizeof(SgOmpUniformClause) );
   56326           1 :         ROSE_ASSERT(alloc != nullptr);
   56327             : 
   56328             : #if ROSE_ALLOC_TRACE == 2
   56329             : //        printf("SgOmpUniformClause::alloc\n  block[%zi] = [ %p , %p [\n", SgOmpUniformClause::pools.size(), alloc, alloc + SgOmpUniformClause::pool_size);
   56330             : #endif
   56331             : 
   56332             : #if ROSE_ALLOC_MEMSET == 1
   56333             : #elif ROSE_ALLOC_MEMSET == 2
   56334             :         memset(alloc, 0x00, SgOmpUniformClause::pool_size * sizeof(SgOmpUniformClause));
   56335             : #elif ROSE_ALLOC_MEMSET == 3
   56336             :         memset(alloc, 0xAA, SgOmpUniformClause::pool_size * sizeof(SgOmpUniformClause));
   56337             : #endif
   56338        2000 :         for (unsigned i=0; i < SgOmpUniformClause::pool_size-1; i++) {
   56339        1999 :           alloc[i].p_freepointer = &(alloc[i+1]);
   56340             :         }
   56341           1 :         alloc[SgOmpUniformClause::pool_size-1].p_freepointer = nullptr;
   56342             : 
   56343           1 :         SgOmpUniformClause::pools.push_back ( (unsigned char *) alloc );
   56344           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgOmpUniformClause::pool_size * sizeof(SgOmpUniformClause), V_SgOmpUniformClause ) );
   56345           1 :         SgOmpUniformClause::next_node = alloc;
   56346             :     }
   56347           3 :     ROSE_ASSERT(SgOmpUniformClause::next_node != nullptr);
   56348             : 
   56349           3 :     SgOmpUniformClause * object = SgOmpUniformClause::next_node;
   56350           3 :     SgOmpUniformClause::next_node = (SgOmpUniformClause*)(object->p_freepointer);
   56351             : 
   56352             : #if ROSE_ALLOC_TRACE == 2
   56353             :     printf("SgOmpUniformClause::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpUniformClause::next_node);
   56354             : #endif
   56355             : 
   56356           3 :     SgNode * fp = object->p_freepointer;
   56357             : #if ROSE_ALLOC_MEMSET == 1
   56358             : #elif ROSE_ALLOC_MEMSET == 2
   56359             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpUniformClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   56360             : #elif ROSE_ALLOC_MEMSET == 3
   56361             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgOmpUniformClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   56362             : #endif
   56363           3 :     object->p_freepointer = fp;
   56364             : 
   56365             : #if ROSE_ALLOC_TRACE == 2
   56366             : //    printf("SgOmpUniformClause::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpUniformClause::next_node);
   56367             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   56368             :     Rose::MemPool::snapshot(oss.str());
   56369             :     alloc_trace_cnt++;
   56370             : #endif
   56371             : 
   56372           3 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   56373             : 
   56374           3 :     ALLOC_MUTEX(SgOmpUniformClause, unlock);
   56375             : 
   56376             :     return object;
   56377             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   56378             : }
   56379             : 
   56380             : 
   56381             : 
   56382             : /*! \brief Delete operator for SgOmpUniformClause.
   56383             : 
   56384             :    This delete operator implements deallocation using memory pools to 
   56385             :    provide most efficent use of the heap within construction of large ASTs.
   56386             : 
   56387             : \internal The new and delete operators use the lower level C malloc/free
   56388             :    function calls for performance and to make sure that mixing of malloc/free
   56389             :    and new/delete by the used can be caught more readily.  This may change
   56390             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   56391             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   56392             :    deallocate memory allocated using ROSE_MALLOC.
   56393             : */
   56394           0 : void SgOmpUniformClause::operator delete(void *Pointer, size_t Size)
   56395             : {
   56396             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   56397             :      * or throwing an exception. */
   56398           0 :     ALLOC_MUTEX(SgOmpUniformClause, lock);
   56399             : 
   56400             : #if USE_CPP_NEW_DELETE_OPERATORS
   56401             :     ROSE_FREE(Pointer);
   56402             : #else
   56403             : #if ROSE_PEDANTIC_ALLOC
   56404             :     ROSE_ASSERT(Size == sizeof(SgOmpUniformClause));
   56405             : #else
   56406           0 :     if (Size != sizeof(SgOmpUniformClause)) {
   56407           0 :       ROSE_FREE(Pointer);
   56408           0 :       ALLOC_MUTEX(SgOmpUniformClause, unlock);
   56409             :       return;
   56410             :     }
   56411             : #endif
   56412             : 
   56413           0 :     SgOmpUniformClause * object = (SgOmpUniformClause*) Pointer;
   56414           0 :     ROSE_ASSERT(object != nullptr);
   56415             : 
   56416             : #if ROSE_ALLOC_TRACE == 2
   56417             : //  printf("SgOmpUniformClause::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpUniformClause::next_node);
   56418             :     printf("SgOmpUniformClause::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpUniformClause::next_node);
   56419             : #endif
   56420             : 
   56421             : #if ROSE_PEDANTIC_ALLOC
   56422             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   56423             : #endif
   56424             : 
   56425             : #if ROSE_ALLOC_MEMSET == 1
   56426             : #elif ROSE_ALLOC_MEMSET == 2
   56427             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpUniformClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   56428             : #elif ROSE_ALLOC_MEMSET == 3
   56429             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgOmpUniformClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   56430             : #endif
   56431             : 
   56432             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   56433             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   56434             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   56435             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   56436             : #else
   56437           0 :     object->p_freepointer = SgOmpUniformClause::next_node;
   56438           0 :     SgOmpUniformClause::next_node = object;
   56439             : #endif
   56440             : 
   56441             : #if ROSE_ALLOC_TRACE == 2
   56442             : //  printf("SgOmpUniformClause::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpUniformClause::next_node);
   56443             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   56444             :     Rose::MemPool::snapshot(oss.str());
   56445             :     alloc_trace_cnt++;
   56446             : #endif
   56447             : 
   56448             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   56449             : 
   56450           0 :     ALLOC_MUTEX(SgOmpUniformClause, unlock);
   56451             : }
   56452             : 
   56453             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   56454             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   56455             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   56456             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   56457             : // Also, note comment below from Robb (copied from the Common.code file).
   56458             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   56459             : //
   56460             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   56461             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   56462             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   56463             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   56464             : #if 0
   56465             : void SgOmpUniformClause::operator delete(void* pointer) { SgOmpUniformClause::operator delete (pointer, sizeof(SgOmpUniformClause)); };
   56466             : #endif
   56467             : /* #line 56468 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   56468             : 
   56469             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   56470             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   56471             : // obviously imply C++.
   56472             : 
   56473             : // This implements the support within ROSE for memory pools.  Memory pools
   56474             : // support the most condensed usage of memory within the construction of
   56475             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   56476             : // by a new operator written for each class.
   56477             : 
   56478             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   56479             :     // User wants multi-thread support and POSIX threads are available.
   56480             : #   include <pthread.h>
   56481             :     static pthread_mutex_t SgOmpAlignedClause_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   56482             : #else
   56483             :      // Cause synchronization to be skipped.
   56484             : #    ifndef ALLOC_MUTEX
   56485             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   56486             : #    endif
   56487             : #    ifdef _REENTRANT
   56488             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   56489             : #       ifdef _MSC_VER
   56490             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   56491             : #       else
   56492             : #           warning "POSIX threads are not available; synchronization being skipped"
   56493             : #       endif
   56494             : #    endif
   56495             : #endif
   56496             : 
   56497             : #ifndef ROSE_ALLOC_TRACE
   56498             : #  define ROSE_ALLOC_TRACE 0
   56499             : #endif
   56500             : 
   56501             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   56502             : #define ROSE_ALLOC_TRACE_CNT
   56503             : #include "memory-pool-snapshot.h"
   56504             : unsigned long alloc_trace_cnt = 0;
   56505             : #endif
   56506             : 
   56507             : #if ROSE_ALLOC_TRACE
   56508             : const unsigned SgOmpAlignedClause::pool_size = 5;
   56509             : #else
   56510             : const unsigned SgOmpAlignedClause::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   56511             : #endif
   56512             : 
   56513             : #ifndef ROSE_ALLOC_MEMSET
   56514             : #  define ROSE_ALLOC_MEMSET 0
   56515             : #endif
   56516             : 
   56517             : #ifndef ROSE_PEDANTIC_ALLOC
   56518             : #  define ROSE_PEDANTIC_ALLOC 0
   56519             : #endif
   56520             : 
   56521             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   56522             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   56523             : #endif
   56524             : 
   56525             : #if !defined(SGNODE__ALL_POOLS)
   56526             : #define SGNODE__ALL_POOLS
   56527             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   56528             : #endif
   56529             : 
   56530             : SgOmpAlignedClause* SgOmpAlignedClause::next_node = nullptr;
   56531             : std::vector<unsigned char*> SgOmpAlignedClause::pools;
   56532             : 
   56533             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   56534             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   56535             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   56536             : // around this macro definition rather than each use).
   56537             : #ifndef ALLOC_MUTEX
   56538             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   56539             :         do {                                                                     \
   56540             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   56541             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   56542             :                 abort();                                                         \
   56543             :             }                                                                    \
   56544             :         } while (0);
   56545             : #endif
   56546             : 
   56547             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   56548             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   56549             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   56550             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   56551             : 
   56552             : /*! \brief New operator for SgOmpAlignedClause.
   56553             : 
   56554             :    This new operator implements memory pools to provide most efficent 
   56555             :    use of the heap within construction of large ASTs.
   56556             : 
   56557             : \internal The new and delete operators use the lower level C malloc/free
   56558             :    function calls for performance and to make sure that mixing of malloc/free
   56559             :    and new/delete by the used can be caught more readily.  This may change
   56560             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   56561             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   56562             :    deallocate memory allocated using ROSE_MALLOC.
   56563             : */
   56564           2 : void *SgOmpAlignedClause::operator new ( size_t Size )
   56565             : {
   56566             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   56567             :      * returning or throwing an exception. */
   56568           2 :     ALLOC_MUTEX(SgOmpAlignedClause, lock);
   56569             : 
   56570             : #if ROSE_ALLOC_TRACE == 2
   56571             : //    printf("SgOmpAlignedClause::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgOmpAlignedClause::next_node);
   56572             : #endif
   56573             : 
   56574             : #if USE_CPP_NEW_DELETE_OPERATORS
   56575             :     void *mem = ROSE_MALLOC(Size);
   56576             :     ALLOC_MUTEX(SgOmpAlignedClause, unlock);
   56577             :     return mem;
   56578             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   56579             : #if ROSE_PEDANTIC_ALLOC
   56580             :     ROSE_ASSERT(Size == sizeof(SgOmpAlignedClause));
   56581             : #else
   56582           2 :     if (Size != sizeof(SgOmpAlignedClause)) {
   56583           0 :       void * object = ROSE_MALLOC(Size);
   56584           0 :       ALLOC_MUTEX(SgOmpAlignedClause, unlock);
   56585             :       return object;
   56586             :     }
   56587             : #endif
   56588             : 
   56589           2 :     if (SgOmpAlignedClause::next_node == nullptr) {
   56590           1 :         SgOmpAlignedClause * alloc = (SgOmpAlignedClause*) ROSE_MALLOC ( SgOmpAlignedClause::pool_size * sizeof(SgOmpAlignedClause) );
   56591           1 :         ROSE_ASSERT(alloc != nullptr);
   56592             : 
   56593             : #if ROSE_ALLOC_TRACE == 2
   56594             : //        printf("SgOmpAlignedClause::alloc\n  block[%zi] = [ %p , %p [\n", SgOmpAlignedClause::pools.size(), alloc, alloc + SgOmpAlignedClause::pool_size);
   56595             : #endif
   56596             : 
   56597             : #if ROSE_ALLOC_MEMSET == 1
   56598             : #elif ROSE_ALLOC_MEMSET == 2
   56599             :         memset(alloc, 0x00, SgOmpAlignedClause::pool_size * sizeof(SgOmpAlignedClause));
   56600             : #elif ROSE_ALLOC_MEMSET == 3
   56601             :         memset(alloc, 0xAA, SgOmpAlignedClause::pool_size * sizeof(SgOmpAlignedClause));
   56602             : #endif
   56603        2000 :         for (unsigned i=0; i < SgOmpAlignedClause::pool_size-1; i++) {
   56604        1999 :           alloc[i].p_freepointer = &(alloc[i+1]);
   56605             :         }
   56606           1 :         alloc[SgOmpAlignedClause::pool_size-1].p_freepointer = nullptr;
   56607             : 
   56608           1 :         SgOmpAlignedClause::pools.push_back ( (unsigned char *) alloc );
   56609           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgOmpAlignedClause::pool_size * sizeof(SgOmpAlignedClause), V_SgOmpAlignedClause ) );
   56610           1 :         SgOmpAlignedClause::next_node = alloc;
   56611             :     }
   56612           2 :     ROSE_ASSERT(SgOmpAlignedClause::next_node != nullptr);
   56613             : 
   56614           2 :     SgOmpAlignedClause * object = SgOmpAlignedClause::next_node;
   56615           2 :     SgOmpAlignedClause::next_node = (SgOmpAlignedClause*)(object->p_freepointer);
   56616             : 
   56617             : #if ROSE_ALLOC_TRACE == 2
   56618             :     printf("SgOmpAlignedClause::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpAlignedClause::next_node);
   56619             : #endif
   56620             : 
   56621           2 :     SgNode * fp = object->p_freepointer;
   56622             : #if ROSE_ALLOC_MEMSET == 1
   56623             : #elif ROSE_ALLOC_MEMSET == 2
   56624             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpAlignedClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   56625             : #elif ROSE_ALLOC_MEMSET == 3
   56626             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgOmpAlignedClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   56627             : #endif
   56628           2 :     object->p_freepointer = fp;
   56629             : 
   56630             : #if ROSE_ALLOC_TRACE == 2
   56631             : //    printf("SgOmpAlignedClause::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpAlignedClause::next_node);
   56632             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   56633             :     Rose::MemPool::snapshot(oss.str());
   56634             :     alloc_trace_cnt++;
   56635             : #endif
   56636             : 
   56637           2 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   56638             : 
   56639           2 :     ALLOC_MUTEX(SgOmpAlignedClause, unlock);
   56640             : 
   56641             :     return object;
   56642             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   56643             : }
   56644             : 
   56645             : 
   56646             : 
   56647             : /*! \brief Delete operator for SgOmpAlignedClause.
   56648             : 
   56649             :    This delete operator implements deallocation using memory pools to 
   56650             :    provide most efficent use of the heap within construction of large ASTs.
   56651             : 
   56652             : \internal The new and delete operators use the lower level C malloc/free
   56653             :    function calls for performance and to make sure that mixing of malloc/free
   56654             :    and new/delete by the used can be caught more readily.  This may change
   56655             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   56656             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   56657             :    deallocate memory allocated using ROSE_MALLOC.
   56658             : */
   56659           0 : void SgOmpAlignedClause::operator delete(void *Pointer, size_t Size)
   56660             : {
   56661             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   56662             :      * or throwing an exception. */
   56663           0 :     ALLOC_MUTEX(SgOmpAlignedClause, lock);
   56664             : 
   56665             : #if USE_CPP_NEW_DELETE_OPERATORS
   56666             :     ROSE_FREE(Pointer);
   56667             : #else
   56668             : #if ROSE_PEDANTIC_ALLOC
   56669             :     ROSE_ASSERT(Size == sizeof(SgOmpAlignedClause));
   56670             : #else
   56671           0 :     if (Size != sizeof(SgOmpAlignedClause)) {
   56672           0 :       ROSE_FREE(Pointer);
   56673           0 :       ALLOC_MUTEX(SgOmpAlignedClause, unlock);
   56674             :       return;
   56675             :     }
   56676             : #endif
   56677             : 
   56678           0 :     SgOmpAlignedClause * object = (SgOmpAlignedClause*) Pointer;
   56679           0 :     ROSE_ASSERT(object != nullptr);
   56680             : 
   56681             : #if ROSE_ALLOC_TRACE == 2
   56682             : //  printf("SgOmpAlignedClause::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpAlignedClause::next_node);
   56683             :     printf("SgOmpAlignedClause::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpAlignedClause::next_node);
   56684             : #endif
   56685             : 
   56686             : #if ROSE_PEDANTIC_ALLOC
   56687             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   56688             : #endif
   56689             : 
   56690             : #if ROSE_ALLOC_MEMSET == 1
   56691             : #elif ROSE_ALLOC_MEMSET == 2
   56692             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpAlignedClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   56693             : #elif ROSE_ALLOC_MEMSET == 3
   56694             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgOmpAlignedClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   56695             : #endif
   56696             : 
   56697             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   56698             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   56699             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   56700             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   56701             : #else
   56702           0 :     object->p_freepointer = SgOmpAlignedClause::next_node;
   56703           0 :     SgOmpAlignedClause::next_node = object;
   56704             : #endif
   56705             : 
   56706             : #if ROSE_ALLOC_TRACE == 2
   56707             : //  printf("SgOmpAlignedClause::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpAlignedClause::next_node);
   56708             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   56709             :     Rose::MemPool::snapshot(oss.str());
   56710             :     alloc_trace_cnt++;
   56711             : #endif
   56712             : 
   56713             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   56714             : 
   56715           0 :     ALLOC_MUTEX(SgOmpAlignedClause, unlock);
   56716             : }
   56717             : 
   56718             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   56719             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   56720             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   56721             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   56722             : // Also, note comment below from Robb (copied from the Common.code file).
   56723             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   56724             : //
   56725             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   56726             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   56727             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   56728             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   56729             : #if 0
   56730             : void SgOmpAlignedClause::operator delete(void* pointer) { SgOmpAlignedClause::operator delete (pointer, sizeof(SgOmpAlignedClause)); };
   56731             : #endif
   56732             : /* #line 56733 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   56733             : 
   56734             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   56735             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   56736             : // obviously imply C++.
   56737             : 
   56738             : // This implements the support within ROSE for memory pools.  Memory pools
   56739             : // support the most condensed usage of memory within the construction of
   56740             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   56741             : // by a new operator written for each class.
   56742             : 
   56743             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   56744             :     // User wants multi-thread support and POSIX threads are available.
   56745             : #   include <pthread.h>
   56746             :     static pthread_mutex_t SgOmpLinearClause_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   56747             : #else
   56748             :      // Cause synchronization to be skipped.
   56749             : #    ifndef ALLOC_MUTEX
   56750             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   56751             : #    endif
   56752             : #    ifdef _REENTRANT
   56753             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   56754             : #       ifdef _MSC_VER
   56755             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   56756             : #       else
   56757             : #           warning "POSIX threads are not available; synchronization being skipped"
   56758             : #       endif
   56759             : #    endif
   56760             : #endif
   56761             : 
   56762             : #ifndef ROSE_ALLOC_TRACE
   56763             : #  define ROSE_ALLOC_TRACE 0
   56764             : #endif
   56765             : 
   56766             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   56767             : #define ROSE_ALLOC_TRACE_CNT
   56768             : #include "memory-pool-snapshot.h"
   56769             : unsigned long alloc_trace_cnt = 0;
   56770             : #endif
   56771             : 
   56772             : #if ROSE_ALLOC_TRACE
   56773             : const unsigned SgOmpLinearClause::pool_size = 5;
   56774             : #else
   56775             : const unsigned SgOmpLinearClause::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   56776             : #endif
   56777             : 
   56778             : #ifndef ROSE_ALLOC_MEMSET
   56779             : #  define ROSE_ALLOC_MEMSET 0
   56780             : #endif
   56781             : 
   56782             : #ifndef ROSE_PEDANTIC_ALLOC
   56783             : #  define ROSE_PEDANTIC_ALLOC 0
   56784             : #endif
   56785             : 
   56786             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   56787             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   56788             : #endif
   56789             : 
   56790             : #if !defined(SGNODE__ALL_POOLS)
   56791             : #define SGNODE__ALL_POOLS
   56792             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   56793             : #endif
   56794             : 
   56795             : SgOmpLinearClause* SgOmpLinearClause::next_node = nullptr;
   56796             : std::vector<unsigned char*> SgOmpLinearClause::pools;
   56797             : 
   56798             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   56799             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   56800             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   56801             : // around this macro definition rather than each use).
   56802             : #ifndef ALLOC_MUTEX
   56803             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   56804             :         do {                                                                     \
   56805             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   56806             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   56807             :                 abort();                                                         \
   56808             :             }                                                                    \
   56809             :         } while (0);
   56810             : #endif
   56811             : 
   56812             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   56813             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   56814             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   56815             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   56816             : 
   56817             : /*! \brief New operator for SgOmpLinearClause.
   56818             : 
   56819             :    This new operator implements memory pools to provide most efficent 
   56820             :    use of the heap within construction of large ASTs.
   56821             : 
   56822             : \internal The new and delete operators use the lower level C malloc/free
   56823             :    function calls for performance and to make sure that mixing of malloc/free
   56824             :    and new/delete by the used can be caught more readily.  This may change
   56825             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   56826             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   56827             :    deallocate memory allocated using ROSE_MALLOC.
   56828             : */
   56829           6 : void *SgOmpLinearClause::operator new ( size_t Size )
   56830             : {
   56831             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   56832             :      * returning or throwing an exception. */
   56833           6 :     ALLOC_MUTEX(SgOmpLinearClause, lock);
   56834             : 
   56835             : #if ROSE_ALLOC_TRACE == 2
   56836             : //    printf("SgOmpLinearClause::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgOmpLinearClause::next_node);
   56837             : #endif
   56838             : 
   56839             : #if USE_CPP_NEW_DELETE_OPERATORS
   56840             :     void *mem = ROSE_MALLOC(Size);
   56841             :     ALLOC_MUTEX(SgOmpLinearClause, unlock);
   56842             :     return mem;
   56843             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   56844             : #if ROSE_PEDANTIC_ALLOC
   56845             :     ROSE_ASSERT(Size == sizeof(SgOmpLinearClause));
   56846             : #else
   56847           6 :     if (Size != sizeof(SgOmpLinearClause)) {
   56848           0 :       void * object = ROSE_MALLOC(Size);
   56849           0 :       ALLOC_MUTEX(SgOmpLinearClause, unlock);
   56850             :       return object;
   56851             :     }
   56852             : #endif
   56853             : 
   56854           6 :     if (SgOmpLinearClause::next_node == nullptr) {
   56855           4 :         SgOmpLinearClause * alloc = (SgOmpLinearClause*) ROSE_MALLOC ( SgOmpLinearClause::pool_size * sizeof(SgOmpLinearClause) );
   56856           4 :         ROSE_ASSERT(alloc != nullptr);
   56857             : 
   56858             : #if ROSE_ALLOC_TRACE == 2
   56859             : //        printf("SgOmpLinearClause::alloc\n  block[%zi] = [ %p , %p [\n", SgOmpLinearClause::pools.size(), alloc, alloc + SgOmpLinearClause::pool_size);
   56860             : #endif
   56861             : 
   56862             : #if ROSE_ALLOC_MEMSET == 1
   56863             : #elif ROSE_ALLOC_MEMSET == 2
   56864             :         memset(alloc, 0x00, SgOmpLinearClause::pool_size * sizeof(SgOmpLinearClause));
   56865             : #elif ROSE_ALLOC_MEMSET == 3
   56866             :         memset(alloc, 0xAA, SgOmpLinearClause::pool_size * sizeof(SgOmpLinearClause));
   56867             : #endif
   56868        8000 :         for (unsigned i=0; i < SgOmpLinearClause::pool_size-1; i++) {
   56869        7996 :           alloc[i].p_freepointer = &(alloc[i+1]);
   56870             :         }
   56871           4 :         alloc[SgOmpLinearClause::pool_size-1].p_freepointer = nullptr;
   56872             : 
   56873           4 :         SgOmpLinearClause::pools.push_back ( (unsigned char *) alloc );
   56874           4 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgOmpLinearClause::pool_size * sizeof(SgOmpLinearClause), V_SgOmpLinearClause ) );
   56875           4 :         SgOmpLinearClause::next_node = alloc;
   56876             :     }
   56877           6 :     ROSE_ASSERT(SgOmpLinearClause::next_node != nullptr);
   56878             : 
   56879           6 :     SgOmpLinearClause * object = SgOmpLinearClause::next_node;
   56880           6 :     SgOmpLinearClause::next_node = (SgOmpLinearClause*)(object->p_freepointer);
   56881             : 
   56882             : #if ROSE_ALLOC_TRACE == 2
   56883             :     printf("SgOmpLinearClause::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpLinearClause::next_node);
   56884             : #endif
   56885             : 
   56886           6 :     SgNode * fp = object->p_freepointer;
   56887             : #if ROSE_ALLOC_MEMSET == 1
   56888             : #elif ROSE_ALLOC_MEMSET == 2
   56889             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpLinearClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   56890             : #elif ROSE_ALLOC_MEMSET == 3
   56891             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgOmpLinearClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   56892             : #endif
   56893           6 :     object->p_freepointer = fp;
   56894             : 
   56895             : #if ROSE_ALLOC_TRACE == 2
   56896             : //    printf("SgOmpLinearClause::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpLinearClause::next_node);
   56897             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   56898             :     Rose::MemPool::snapshot(oss.str());
   56899             :     alloc_trace_cnt++;
   56900             : #endif
   56901             : 
   56902           6 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   56903             : 
   56904           6 :     ALLOC_MUTEX(SgOmpLinearClause, unlock);
   56905             : 
   56906             :     return object;
   56907             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   56908             : }
   56909             : 
   56910             : 
   56911             : 
   56912             : /*! \brief Delete operator for SgOmpLinearClause.
   56913             : 
   56914             :    This delete operator implements deallocation using memory pools to 
   56915             :    provide most efficent use of the heap within construction of large ASTs.
   56916             : 
   56917             : \internal The new and delete operators use the lower level C malloc/free
   56918             :    function calls for performance and to make sure that mixing of malloc/free
   56919             :    and new/delete by the used can be caught more readily.  This may change
   56920             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   56921             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   56922             :    deallocate memory allocated using ROSE_MALLOC.
   56923             : */
   56924           0 : void SgOmpLinearClause::operator delete(void *Pointer, size_t Size)
   56925             : {
   56926             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   56927             :      * or throwing an exception. */
   56928           0 :     ALLOC_MUTEX(SgOmpLinearClause, lock);
   56929             : 
   56930             : #if USE_CPP_NEW_DELETE_OPERATORS
   56931             :     ROSE_FREE(Pointer);
   56932             : #else
   56933             : #if ROSE_PEDANTIC_ALLOC
   56934             :     ROSE_ASSERT(Size == sizeof(SgOmpLinearClause));
   56935             : #else
   56936           0 :     if (Size != sizeof(SgOmpLinearClause)) {
   56937           0 :       ROSE_FREE(Pointer);
   56938           0 :       ALLOC_MUTEX(SgOmpLinearClause, unlock);
   56939             :       return;
   56940             :     }
   56941             : #endif
   56942             : 
   56943           0 :     SgOmpLinearClause * object = (SgOmpLinearClause*) Pointer;
   56944           0 :     ROSE_ASSERT(object != nullptr);
   56945             : 
   56946             : #if ROSE_ALLOC_TRACE == 2
   56947             : //  printf("SgOmpLinearClause::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpLinearClause::next_node);
   56948             :     printf("SgOmpLinearClause::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpLinearClause::next_node);
   56949             : #endif
   56950             : 
   56951             : #if ROSE_PEDANTIC_ALLOC
   56952             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   56953             : #endif
   56954             : 
   56955             : #if ROSE_ALLOC_MEMSET == 1
   56956             : #elif ROSE_ALLOC_MEMSET == 2
   56957             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpLinearClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   56958             : #elif ROSE_ALLOC_MEMSET == 3
   56959             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgOmpLinearClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   56960             : #endif
   56961             : 
   56962             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   56963             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   56964             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   56965             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   56966             : #else
   56967           0 :     object->p_freepointer = SgOmpLinearClause::next_node;
   56968           0 :     SgOmpLinearClause::next_node = object;
   56969             : #endif
   56970             : 
   56971             : #if ROSE_ALLOC_TRACE == 2
   56972             : //  printf("SgOmpLinearClause::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpLinearClause::next_node);
   56973             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   56974             :     Rose::MemPool::snapshot(oss.str());
   56975             :     alloc_trace_cnt++;
   56976             : #endif
   56977             : 
   56978             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   56979             : 
   56980           0 :     ALLOC_MUTEX(SgOmpLinearClause, unlock);
   56981             : }
   56982             : 
   56983             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   56984             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   56985             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   56986             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   56987             : // Also, note comment below from Robb (copied from the Common.code file).
   56988             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   56989             : //
   56990             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   56991             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   56992             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   56993             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   56994             : #if 0
   56995             : void SgOmpLinearClause::operator delete(void* pointer) { SgOmpLinearClause::operator delete (pointer, sizeof(SgOmpLinearClause)); };
   56996             : #endif
   56997             : /* #line 56998 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   56998             : 
   56999             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   57000             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   57001             : // obviously imply C++.
   57002             : 
   57003             : // This implements the support within ROSE for memory pools.  Memory pools
   57004             : // support the most condensed usage of memory within the construction of
   57005             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   57006             : // by a new operator written for each class.
   57007             : 
   57008             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   57009             :     // User wants multi-thread support and POSIX threads are available.
   57010             : #   include <pthread.h>
   57011             :     static pthread_mutex_t SgOmpDependClause_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   57012             : #else
   57013             :      // Cause synchronization to be skipped.
   57014             : #    ifndef ALLOC_MUTEX
   57015             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   57016             : #    endif
   57017             : #    ifdef _REENTRANT
   57018             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   57019             : #       ifdef _MSC_VER
   57020             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   57021             : #       else
   57022             : #           warning "POSIX threads are not available; synchronization being skipped"
   57023             : #       endif
   57024             : #    endif
   57025             : #endif
   57026             : 
   57027             : #ifndef ROSE_ALLOC_TRACE
   57028             : #  define ROSE_ALLOC_TRACE 0
   57029             : #endif
   57030             : 
   57031             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   57032             : #define ROSE_ALLOC_TRACE_CNT
   57033             : #include "memory-pool-snapshot.h"
   57034             : unsigned long alloc_trace_cnt = 0;
   57035             : #endif
   57036             : 
   57037             : #if ROSE_ALLOC_TRACE
   57038             : const unsigned SgOmpDependClause::pool_size = 5;
   57039             : #else
   57040             : const unsigned SgOmpDependClause::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   57041             : #endif
   57042             : 
   57043             : #ifndef ROSE_ALLOC_MEMSET
   57044             : #  define ROSE_ALLOC_MEMSET 0
   57045             : #endif
   57046             : 
   57047             : #ifndef ROSE_PEDANTIC_ALLOC
   57048             : #  define ROSE_PEDANTIC_ALLOC 0
   57049             : #endif
   57050             : 
   57051             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   57052             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   57053             : #endif
   57054             : 
   57055             : #if !defined(SGNODE__ALL_POOLS)
   57056             : #define SGNODE__ALL_POOLS
   57057             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   57058             : #endif
   57059             : 
   57060             : SgOmpDependClause* SgOmpDependClause::next_node = nullptr;
   57061             : std::vector<unsigned char*> SgOmpDependClause::pools;
   57062             : 
   57063             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   57064             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   57065             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   57066             : // around this macro definition rather than each use).
   57067             : #ifndef ALLOC_MUTEX
   57068             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   57069             :         do {                                                                     \
   57070             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   57071             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   57072             :                 abort();                                                         \
   57073             :             }                                                                    \
   57074             :         } while (0);
   57075             : #endif
   57076             : 
   57077             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   57078             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   57079             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   57080             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   57081             : 
   57082             : /*! \brief New operator for SgOmpDependClause.
   57083             : 
   57084             :    This new operator implements memory pools to provide most efficent 
   57085             :    use of the heap within construction of large ASTs.
   57086             : 
   57087             : \internal The new and delete operators use the lower level C malloc/free
   57088             :    function calls for performance and to make sure that mixing of malloc/free
   57089             :    and new/delete by the used can be caught more readily.  This may change
   57090             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   57091             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   57092             :    deallocate memory allocated using ROSE_MALLOC.
   57093             : */
   57094          19 : void *SgOmpDependClause::operator new ( size_t Size )
   57095             : {
   57096             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   57097             :      * returning or throwing an exception. */
   57098          19 :     ALLOC_MUTEX(SgOmpDependClause, lock);
   57099             : 
   57100             : #if ROSE_ALLOC_TRACE == 2
   57101             : //    printf("SgOmpDependClause::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgOmpDependClause::next_node);
   57102             : #endif
   57103             : 
   57104             : #if USE_CPP_NEW_DELETE_OPERATORS
   57105             :     void *mem = ROSE_MALLOC(Size);
   57106             :     ALLOC_MUTEX(SgOmpDependClause, unlock);
   57107             :     return mem;
   57108             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   57109             : #if ROSE_PEDANTIC_ALLOC
   57110             :     ROSE_ASSERT(Size == sizeof(SgOmpDependClause));
   57111             : #else
   57112          19 :     if (Size != sizeof(SgOmpDependClause)) {
   57113           0 :       void * object = ROSE_MALLOC(Size);
   57114           0 :       ALLOC_MUTEX(SgOmpDependClause, unlock);
   57115             :       return object;
   57116             :     }
   57117             : #endif
   57118             : 
   57119          19 :     if (SgOmpDependClause::next_node == nullptr) {
   57120           9 :         SgOmpDependClause * alloc = (SgOmpDependClause*) ROSE_MALLOC ( SgOmpDependClause::pool_size * sizeof(SgOmpDependClause) );
   57121           9 :         ROSE_ASSERT(alloc != nullptr);
   57122             : 
   57123             : #if ROSE_ALLOC_TRACE == 2
   57124             : //        printf("SgOmpDependClause::alloc\n  block[%zi] = [ %p , %p [\n", SgOmpDependClause::pools.size(), alloc, alloc + SgOmpDependClause::pool_size);
   57125             : #endif
   57126             : 
   57127             : #if ROSE_ALLOC_MEMSET == 1
   57128             : #elif ROSE_ALLOC_MEMSET == 2
   57129             :         memset(alloc, 0x00, SgOmpDependClause::pool_size * sizeof(SgOmpDependClause));
   57130             : #elif ROSE_ALLOC_MEMSET == 3
   57131             :         memset(alloc, 0xAA, SgOmpDependClause::pool_size * sizeof(SgOmpDependClause));
   57132             : #endif
   57133       18000 :         for (unsigned i=0; i < SgOmpDependClause::pool_size-1; i++) {
   57134       17991 :           alloc[i].p_freepointer = &(alloc[i+1]);
   57135             :         }
   57136           9 :         alloc[SgOmpDependClause::pool_size-1].p_freepointer = nullptr;
   57137             : 
   57138           9 :         SgOmpDependClause::pools.push_back ( (unsigned char *) alloc );
   57139           9 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgOmpDependClause::pool_size * sizeof(SgOmpDependClause), V_SgOmpDependClause ) );
   57140           9 :         SgOmpDependClause::next_node = alloc;
   57141             :     }
   57142          19 :     ROSE_ASSERT(SgOmpDependClause::next_node != nullptr);
   57143             : 
   57144          19 :     SgOmpDependClause * object = SgOmpDependClause::next_node;
   57145          19 :     SgOmpDependClause::next_node = (SgOmpDependClause*)(object->p_freepointer);
   57146             : 
   57147             : #if ROSE_ALLOC_TRACE == 2
   57148             :     printf("SgOmpDependClause::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpDependClause::next_node);
   57149             : #endif
   57150             : 
   57151          19 :     SgNode * fp = object->p_freepointer;
   57152             : #if ROSE_ALLOC_MEMSET == 1
   57153             : #elif ROSE_ALLOC_MEMSET == 2
   57154             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpDependClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   57155             : #elif ROSE_ALLOC_MEMSET == 3
   57156             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgOmpDependClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   57157             : #endif
   57158          19 :     object->p_freepointer = fp;
   57159             : 
   57160             : #if ROSE_ALLOC_TRACE == 2
   57161             : //    printf("SgOmpDependClause::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpDependClause::next_node);
   57162             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   57163             :     Rose::MemPool::snapshot(oss.str());
   57164             :     alloc_trace_cnt++;
   57165             : #endif
   57166             : 
   57167          19 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   57168             : 
   57169          19 :     ALLOC_MUTEX(SgOmpDependClause, unlock);
   57170             : 
   57171             :     return object;
   57172             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   57173             : }
   57174             : 
   57175             : 
   57176             : 
   57177             : /*! \brief Delete operator for SgOmpDependClause.
   57178             : 
   57179             :    This delete operator implements deallocation using memory pools to 
   57180             :    provide most efficent use of the heap within construction of large ASTs.
   57181             : 
   57182             : \internal The new and delete operators use the lower level C malloc/free
   57183             :    function calls for performance and to make sure that mixing of malloc/free
   57184             :    and new/delete by the used can be caught more readily.  This may change
   57185             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   57186             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   57187             :    deallocate memory allocated using ROSE_MALLOC.
   57188             : */
   57189           0 : void SgOmpDependClause::operator delete(void *Pointer, size_t Size)
   57190             : {
   57191             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   57192             :      * or throwing an exception. */
   57193           0 :     ALLOC_MUTEX(SgOmpDependClause, lock);
   57194             : 
   57195             : #if USE_CPP_NEW_DELETE_OPERATORS
   57196             :     ROSE_FREE(Pointer);
   57197             : #else
   57198             : #if ROSE_PEDANTIC_ALLOC
   57199             :     ROSE_ASSERT(Size == sizeof(SgOmpDependClause));
   57200             : #else
   57201           0 :     if (Size != sizeof(SgOmpDependClause)) {
   57202           0 :       ROSE_FREE(Pointer);
   57203           0 :       ALLOC_MUTEX(SgOmpDependClause, unlock);
   57204             :       return;
   57205             :     }
   57206             : #endif
   57207             : 
   57208           0 :     SgOmpDependClause * object = (SgOmpDependClause*) Pointer;
   57209           0 :     ROSE_ASSERT(object != nullptr);
   57210             : 
   57211             : #if ROSE_ALLOC_TRACE == 2
   57212             : //  printf("SgOmpDependClause::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpDependClause::next_node);
   57213             :     printf("SgOmpDependClause::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpDependClause::next_node);
   57214             : #endif
   57215             : 
   57216             : #if ROSE_PEDANTIC_ALLOC
   57217             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   57218             : #endif
   57219             : 
   57220             : #if ROSE_ALLOC_MEMSET == 1
   57221             : #elif ROSE_ALLOC_MEMSET == 2
   57222             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpDependClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   57223             : #elif ROSE_ALLOC_MEMSET == 3
   57224             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgOmpDependClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   57225             : #endif
   57226             : 
   57227             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   57228             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   57229             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   57230             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   57231             : #else
   57232           0 :     object->p_freepointer = SgOmpDependClause::next_node;
   57233           0 :     SgOmpDependClause::next_node = object;
   57234             : #endif
   57235             : 
   57236             : #if ROSE_ALLOC_TRACE == 2
   57237             : //  printf("SgOmpDependClause::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpDependClause::next_node);
   57238             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   57239             :     Rose::MemPool::snapshot(oss.str());
   57240             :     alloc_trace_cnt++;
   57241             : #endif
   57242             : 
   57243             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   57244             : 
   57245           0 :     ALLOC_MUTEX(SgOmpDependClause, unlock);
   57246             : }
   57247             : 
   57248             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   57249             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   57250             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   57251             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   57252             : // Also, note comment below from Robb (copied from the Common.code file).
   57253             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   57254             : //
   57255             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   57256             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   57257             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   57258             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   57259             : #if 0
   57260             : void SgOmpDependClause::operator delete(void* pointer) { SgOmpDependClause::operator delete (pointer, sizeof(SgOmpDependClause)); };
   57261             : #endif
   57262             : /* #line 57263 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   57263             : 
   57264             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   57265             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   57266             : // obviously imply C++.
   57267             : 
   57268             : // This implements the support within ROSE for memory pools.  Memory pools
   57269             : // support the most condensed usage of memory within the construction of
   57270             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   57271             : // by a new operator written for each class.
   57272             : 
   57273             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   57274             :     // User wants multi-thread support and POSIX threads are available.
   57275             : #   include <pthread.h>
   57276             :     static pthread_mutex_t SgOmpAffinityClause_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   57277             : #else
   57278             :      // Cause synchronization to be skipped.
   57279             : #    ifndef ALLOC_MUTEX
   57280             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   57281             : #    endif
   57282             : #    ifdef _REENTRANT
   57283             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   57284             : #       ifdef _MSC_VER
   57285             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   57286             : #       else
   57287             : #           warning "POSIX threads are not available; synchronization being skipped"
   57288             : #       endif
   57289             : #    endif
   57290             : #endif
   57291             : 
   57292             : #ifndef ROSE_ALLOC_TRACE
   57293             : #  define ROSE_ALLOC_TRACE 0
   57294             : #endif
   57295             : 
   57296             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   57297             : #define ROSE_ALLOC_TRACE_CNT
   57298             : #include "memory-pool-snapshot.h"
   57299             : unsigned long alloc_trace_cnt = 0;
   57300             : #endif
   57301             : 
   57302             : #if ROSE_ALLOC_TRACE
   57303             : const unsigned SgOmpAffinityClause::pool_size = 5;
   57304             : #else
   57305             : const unsigned SgOmpAffinityClause::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   57306             : #endif
   57307             : 
   57308             : #ifndef ROSE_ALLOC_MEMSET
   57309             : #  define ROSE_ALLOC_MEMSET 0
   57310             : #endif
   57311             : 
   57312             : #ifndef ROSE_PEDANTIC_ALLOC
   57313             : #  define ROSE_PEDANTIC_ALLOC 0
   57314             : #endif
   57315             : 
   57316             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   57317             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   57318             : #endif
   57319             : 
   57320             : #if !defined(SGNODE__ALL_POOLS)
   57321             : #define SGNODE__ALL_POOLS
   57322             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   57323             : #endif
   57324             : 
   57325             : SgOmpAffinityClause* SgOmpAffinityClause::next_node = nullptr;
   57326             : std::vector<unsigned char*> SgOmpAffinityClause::pools;
   57327             : 
   57328             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   57329             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   57330             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   57331             : // around this macro definition rather than each use).
   57332             : #ifndef ALLOC_MUTEX
   57333             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   57334             :         do {                                                                     \
   57335             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   57336             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   57337             :                 abort();                                                         \
   57338             :             }                                                                    \
   57339             :         } while (0);
   57340             : #endif
   57341             : 
   57342             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   57343             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   57344             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   57345             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   57346             : 
   57347             : /*! \brief New operator for SgOmpAffinityClause.
   57348             : 
   57349             :    This new operator implements memory pools to provide most efficent 
   57350             :    use of the heap within construction of large ASTs.
   57351             : 
   57352             : \internal The new and delete operators use the lower level C malloc/free
   57353             :    function calls for performance and to make sure that mixing of malloc/free
   57354             :    and new/delete by the used can be caught more readily.  This may change
   57355             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   57356             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   57357             :    deallocate memory allocated using ROSE_MALLOC.
   57358             : */
   57359           4 : void *SgOmpAffinityClause::operator new ( size_t Size )
   57360             : {
   57361             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   57362             :      * returning or throwing an exception. */
   57363           4 :     ALLOC_MUTEX(SgOmpAffinityClause, lock);
   57364             : 
   57365             : #if ROSE_ALLOC_TRACE == 2
   57366             : //    printf("SgOmpAffinityClause::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgOmpAffinityClause::next_node);
   57367             : #endif
   57368             : 
   57369             : #if USE_CPP_NEW_DELETE_OPERATORS
   57370             :     void *mem = ROSE_MALLOC(Size);
   57371             :     ALLOC_MUTEX(SgOmpAffinityClause, unlock);
   57372             :     return mem;
   57373             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   57374             : #if ROSE_PEDANTIC_ALLOC
   57375             :     ROSE_ASSERT(Size == sizeof(SgOmpAffinityClause));
   57376             : #else
   57377           4 :     if (Size != sizeof(SgOmpAffinityClause)) {
   57378           0 :       void * object = ROSE_MALLOC(Size);
   57379           0 :       ALLOC_MUTEX(SgOmpAffinityClause, unlock);
   57380             :       return object;
   57381             :     }
   57382             : #endif
   57383             : 
   57384           4 :     if (SgOmpAffinityClause::next_node == nullptr) {
   57385           2 :         SgOmpAffinityClause * alloc = (SgOmpAffinityClause*) ROSE_MALLOC ( SgOmpAffinityClause::pool_size * sizeof(SgOmpAffinityClause) );
   57386           2 :         ROSE_ASSERT(alloc != nullptr);
   57387             : 
   57388             : #if ROSE_ALLOC_TRACE == 2
   57389             : //        printf("SgOmpAffinityClause::alloc\n  block[%zi] = [ %p , %p [\n", SgOmpAffinityClause::pools.size(), alloc, alloc + SgOmpAffinityClause::pool_size);
   57390             : #endif
   57391             : 
   57392             : #if ROSE_ALLOC_MEMSET == 1
   57393             : #elif ROSE_ALLOC_MEMSET == 2
   57394             :         memset(alloc, 0x00, SgOmpAffinityClause::pool_size * sizeof(SgOmpAffinityClause));
   57395             : #elif ROSE_ALLOC_MEMSET == 3
   57396             :         memset(alloc, 0xAA, SgOmpAffinityClause::pool_size * sizeof(SgOmpAffinityClause));
   57397             : #endif
   57398        4000 :         for (unsigned i=0; i < SgOmpAffinityClause::pool_size-1; i++) {
   57399        3998 :           alloc[i].p_freepointer = &(alloc[i+1]);
   57400             :         }
   57401           2 :         alloc[SgOmpAffinityClause::pool_size-1].p_freepointer = nullptr;
   57402             : 
   57403           2 :         SgOmpAffinityClause::pools.push_back ( (unsigned char *) alloc );
   57404           2 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgOmpAffinityClause::pool_size * sizeof(SgOmpAffinityClause), V_SgOmpAffinityClause ) );
   57405           2 :         SgOmpAffinityClause::next_node = alloc;
   57406             :     }
   57407           4 :     ROSE_ASSERT(SgOmpAffinityClause::next_node != nullptr);
   57408             : 
   57409           4 :     SgOmpAffinityClause * object = SgOmpAffinityClause::next_node;
   57410           4 :     SgOmpAffinityClause::next_node = (SgOmpAffinityClause*)(object->p_freepointer);
   57411             : 
   57412             : #if ROSE_ALLOC_TRACE == 2
   57413             :     printf("SgOmpAffinityClause::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpAffinityClause::next_node);
   57414             : #endif
   57415             : 
   57416           4 :     SgNode * fp = object->p_freepointer;
   57417             : #if ROSE_ALLOC_MEMSET == 1
   57418             : #elif ROSE_ALLOC_MEMSET == 2
   57419             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpAffinityClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   57420             : #elif ROSE_ALLOC_MEMSET == 3
   57421             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgOmpAffinityClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   57422             : #endif
   57423           4 :     object->p_freepointer = fp;
   57424             : 
   57425             : #if ROSE_ALLOC_TRACE == 2
   57426             : //    printf("SgOmpAffinityClause::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpAffinityClause::next_node);
   57427             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   57428             :     Rose::MemPool::snapshot(oss.str());
   57429             :     alloc_trace_cnt++;
   57430             : #endif
   57431             : 
   57432           4 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   57433             : 
   57434           4 :     ALLOC_MUTEX(SgOmpAffinityClause, unlock);
   57435             : 
   57436             :     return object;
   57437             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   57438             : }
   57439             : 
   57440             : 
   57441             : 
   57442             : /*! \brief Delete operator for SgOmpAffinityClause.
   57443             : 
   57444             :    This delete operator implements deallocation using memory pools to 
   57445             :    provide most efficent use of the heap within construction of large ASTs.
   57446             : 
   57447             : \internal The new and delete operators use the lower level C malloc/free
   57448             :    function calls for performance and to make sure that mixing of malloc/free
   57449             :    and new/delete by the used can be caught more readily.  This may change
   57450             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   57451             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   57452             :    deallocate memory allocated using ROSE_MALLOC.
   57453             : */
   57454           0 : void SgOmpAffinityClause::operator delete(void *Pointer, size_t Size)
   57455             : {
   57456             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   57457             :      * or throwing an exception. */
   57458           0 :     ALLOC_MUTEX(SgOmpAffinityClause, lock);
   57459             : 
   57460             : #if USE_CPP_NEW_DELETE_OPERATORS
   57461             :     ROSE_FREE(Pointer);
   57462             : #else
   57463             : #if ROSE_PEDANTIC_ALLOC
   57464             :     ROSE_ASSERT(Size == sizeof(SgOmpAffinityClause));
   57465             : #else
   57466           0 :     if (Size != sizeof(SgOmpAffinityClause)) {
   57467           0 :       ROSE_FREE(Pointer);
   57468           0 :       ALLOC_MUTEX(SgOmpAffinityClause, unlock);
   57469             :       return;
   57470             :     }
   57471             : #endif
   57472             : 
   57473           0 :     SgOmpAffinityClause * object = (SgOmpAffinityClause*) Pointer;
   57474           0 :     ROSE_ASSERT(object != nullptr);
   57475             : 
   57476             : #if ROSE_ALLOC_TRACE == 2
   57477             : //  printf("SgOmpAffinityClause::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpAffinityClause::next_node);
   57478             :     printf("SgOmpAffinityClause::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpAffinityClause::next_node);
   57479             : #endif
   57480             : 
   57481             : #if ROSE_PEDANTIC_ALLOC
   57482             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   57483             : #endif
   57484             : 
   57485             : #if ROSE_ALLOC_MEMSET == 1
   57486             : #elif ROSE_ALLOC_MEMSET == 2
   57487             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpAffinityClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   57488             : #elif ROSE_ALLOC_MEMSET == 3
   57489             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgOmpAffinityClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   57490             : #endif
   57491             : 
   57492             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   57493             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   57494             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   57495             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   57496             : #else
   57497           0 :     object->p_freepointer = SgOmpAffinityClause::next_node;
   57498           0 :     SgOmpAffinityClause::next_node = object;
   57499             : #endif
   57500             : 
   57501             : #if ROSE_ALLOC_TRACE == 2
   57502             : //  printf("SgOmpAffinityClause::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpAffinityClause::next_node);
   57503             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   57504             :     Rose::MemPool::snapshot(oss.str());
   57505             :     alloc_trace_cnt++;
   57506             : #endif
   57507             : 
   57508             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   57509             : 
   57510           0 :     ALLOC_MUTEX(SgOmpAffinityClause, unlock);
   57511             : }
   57512             : 
   57513             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   57514             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   57515             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   57516             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   57517             : // Also, note comment below from Robb (copied from the Common.code file).
   57518             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   57519             : //
   57520             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   57521             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   57522             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   57523             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   57524             : #if 0
   57525             : void SgOmpAffinityClause::operator delete(void* pointer) { SgOmpAffinityClause::operator delete (pointer, sizeof(SgOmpAffinityClause)); };
   57526             : #endif
   57527             : /* #line 57528 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   57528             : 
   57529             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   57530             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   57531             : // obviously imply C++.
   57532             : 
   57533             : // This implements the support within ROSE for memory pools.  Memory pools
   57534             : // support the most condensed usage of memory within the construction of
   57535             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   57536             : // by a new operator written for each class.
   57537             : 
   57538             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   57539             :     // User wants multi-thread support and POSIX threads are available.
   57540             : #   include <pthread.h>
   57541             :     static pthread_mutex_t SgOmpToClause_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   57542             : #else
   57543             :      // Cause synchronization to be skipped.
   57544             : #    ifndef ALLOC_MUTEX
   57545             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   57546             : #    endif
   57547             : #    ifdef _REENTRANT
   57548             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   57549             : #       ifdef _MSC_VER
   57550             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   57551             : #       else
   57552             : #           warning "POSIX threads are not available; synchronization being skipped"
   57553             : #       endif
   57554             : #    endif
   57555             : #endif
   57556             : 
   57557             : #ifndef ROSE_ALLOC_TRACE
   57558             : #  define ROSE_ALLOC_TRACE 0
   57559             : #endif
   57560             : 
   57561             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   57562             : #define ROSE_ALLOC_TRACE_CNT
   57563             : #include "memory-pool-snapshot.h"
   57564             : unsigned long alloc_trace_cnt = 0;
   57565             : #endif
   57566             : 
   57567             : #if ROSE_ALLOC_TRACE
   57568             : const unsigned SgOmpToClause::pool_size = 5;
   57569             : #else
   57570             : const unsigned SgOmpToClause::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   57571             : #endif
   57572             : 
   57573             : #ifndef ROSE_ALLOC_MEMSET
   57574             : #  define ROSE_ALLOC_MEMSET 0
   57575             : #endif
   57576             : 
   57577             : #ifndef ROSE_PEDANTIC_ALLOC
   57578             : #  define ROSE_PEDANTIC_ALLOC 0
   57579             : #endif
   57580             : 
   57581             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   57582             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   57583             : #endif
   57584             : 
   57585             : #if !defined(SGNODE__ALL_POOLS)
   57586             : #define SGNODE__ALL_POOLS
   57587             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   57588             : #endif
   57589             : 
   57590             : SgOmpToClause* SgOmpToClause::next_node = nullptr;
   57591             : std::vector<unsigned char*> SgOmpToClause::pools;
   57592             : 
   57593             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   57594             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   57595             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   57596             : // around this macro definition rather than each use).
   57597             : #ifndef ALLOC_MUTEX
   57598             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   57599             :         do {                                                                     \
   57600             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   57601             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   57602             :                 abort();                                                         \
   57603             :             }                                                                    \
   57604             :         } while (0);
   57605             : #endif
   57606             : 
   57607             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   57608             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   57609             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   57610             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   57611             : 
   57612             : /*! \brief New operator for SgOmpToClause.
   57613             : 
   57614             :    This new operator implements memory pools to provide most efficent 
   57615             :    use of the heap within construction of large ASTs.
   57616             : 
   57617             : \internal The new and delete operators use the lower level C malloc/free
   57618             :    function calls for performance and to make sure that mixing of malloc/free
   57619             :    and new/delete by the used can be caught more readily.  This may change
   57620             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   57621             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   57622             :    deallocate memory allocated using ROSE_MALLOC.
   57623             : */
   57624           2 : void *SgOmpToClause::operator new ( size_t Size )
   57625             : {
   57626             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   57627             :      * returning or throwing an exception. */
   57628           2 :     ALLOC_MUTEX(SgOmpToClause, lock);
   57629             : 
   57630             : #if ROSE_ALLOC_TRACE == 2
   57631             : //    printf("SgOmpToClause::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgOmpToClause::next_node);
   57632             : #endif
   57633             : 
   57634             : #if USE_CPP_NEW_DELETE_OPERATORS
   57635             :     void *mem = ROSE_MALLOC(Size);
   57636             :     ALLOC_MUTEX(SgOmpToClause, unlock);
   57637             :     return mem;
   57638             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   57639             : #if ROSE_PEDANTIC_ALLOC
   57640             :     ROSE_ASSERT(Size == sizeof(SgOmpToClause));
   57641             : #else
   57642           2 :     if (Size != sizeof(SgOmpToClause)) {
   57643           0 :       void * object = ROSE_MALLOC(Size);
   57644           0 :       ALLOC_MUTEX(SgOmpToClause, unlock);
   57645             :       return object;
   57646             :     }
   57647             : #endif
   57648             : 
   57649           2 :     if (SgOmpToClause::next_node == nullptr) {
   57650           2 :         SgOmpToClause * alloc = (SgOmpToClause*) ROSE_MALLOC ( SgOmpToClause::pool_size * sizeof(SgOmpToClause) );
   57651           2 :         ROSE_ASSERT(alloc != nullptr);
   57652             : 
   57653             : #if ROSE_ALLOC_TRACE == 2
   57654             : //        printf("SgOmpToClause::alloc\n  block[%zi] = [ %p , %p [\n", SgOmpToClause::pools.size(), alloc, alloc + SgOmpToClause::pool_size);
   57655             : #endif
   57656             : 
   57657             : #if ROSE_ALLOC_MEMSET == 1
   57658             : #elif ROSE_ALLOC_MEMSET == 2
   57659             :         memset(alloc, 0x00, SgOmpToClause::pool_size * sizeof(SgOmpToClause));
   57660             : #elif ROSE_ALLOC_MEMSET == 3
   57661             :         memset(alloc, 0xAA, SgOmpToClause::pool_size * sizeof(SgOmpToClause));
   57662             : #endif
   57663        4000 :         for (unsigned i=0; i < SgOmpToClause::pool_size-1; i++) {
   57664        3998 :           alloc[i].p_freepointer = &(alloc[i+1]);
   57665             :         }
   57666           2 :         alloc[SgOmpToClause::pool_size-1].p_freepointer = nullptr;
   57667             : 
   57668           2 :         SgOmpToClause::pools.push_back ( (unsigned char *) alloc );
   57669           2 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgOmpToClause::pool_size * sizeof(SgOmpToClause), V_SgOmpToClause ) );
   57670           2 :         SgOmpToClause::next_node = alloc;
   57671             :     }
   57672           2 :     ROSE_ASSERT(SgOmpToClause::next_node != nullptr);
   57673             : 
   57674           2 :     SgOmpToClause * object = SgOmpToClause::next_node;
   57675           2 :     SgOmpToClause::next_node = (SgOmpToClause*)(object->p_freepointer);
   57676             : 
   57677             : #if ROSE_ALLOC_TRACE == 2
   57678             :     printf("SgOmpToClause::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpToClause::next_node);
   57679             : #endif
   57680             : 
   57681           2 :     SgNode * fp = object->p_freepointer;
   57682             : #if ROSE_ALLOC_MEMSET == 1
   57683             : #elif ROSE_ALLOC_MEMSET == 2
   57684             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpToClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   57685             : #elif ROSE_ALLOC_MEMSET == 3
   57686             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgOmpToClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   57687             : #endif
   57688           2 :     object->p_freepointer = fp;
   57689             : 
   57690             : #if ROSE_ALLOC_TRACE == 2
   57691             : //    printf("SgOmpToClause::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpToClause::next_node);
   57692             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   57693             :     Rose::MemPool::snapshot(oss.str());
   57694             :     alloc_trace_cnt++;
   57695             : #endif
   57696             : 
   57697           2 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   57698             : 
   57699           2 :     ALLOC_MUTEX(SgOmpToClause, unlock);
   57700             : 
   57701             :     return object;
   57702             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   57703             : }
   57704             : 
   57705             : 
   57706             : 
   57707             : /*! \brief Delete operator for SgOmpToClause.
   57708             : 
   57709             :    This delete operator implements deallocation using memory pools to 
   57710             :    provide most efficent use of the heap within construction of large ASTs.
   57711             : 
   57712             : \internal The new and delete operators use the lower level C malloc/free
   57713             :    function calls for performance and to make sure that mixing of malloc/free
   57714             :    and new/delete by the used can be caught more readily.  This may change
   57715             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   57716             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   57717             :    deallocate memory allocated using ROSE_MALLOC.
   57718             : */
   57719           0 : void SgOmpToClause::operator delete(void *Pointer, size_t Size)
   57720             : {
   57721             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   57722             :      * or throwing an exception. */
   57723           0 :     ALLOC_MUTEX(SgOmpToClause, lock);
   57724             : 
   57725             : #if USE_CPP_NEW_DELETE_OPERATORS
   57726             :     ROSE_FREE(Pointer);
   57727             : #else
   57728             : #if ROSE_PEDANTIC_ALLOC
   57729             :     ROSE_ASSERT(Size == sizeof(SgOmpToClause));
   57730             : #else
   57731           0 :     if (Size != sizeof(SgOmpToClause)) {
   57732           0 :       ROSE_FREE(Pointer);
   57733           0 :       ALLOC_MUTEX(SgOmpToClause, unlock);
   57734             :       return;
   57735             :     }
   57736             : #endif
   57737             : 
   57738           0 :     SgOmpToClause * object = (SgOmpToClause*) Pointer;
   57739           0 :     ROSE_ASSERT(object != nullptr);
   57740             : 
   57741             : #if ROSE_ALLOC_TRACE == 2
   57742             : //  printf("SgOmpToClause::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpToClause::next_node);
   57743             :     printf("SgOmpToClause::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpToClause::next_node);
   57744             : #endif
   57745             : 
   57746             : #if ROSE_PEDANTIC_ALLOC
   57747             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   57748             : #endif
   57749             : 
   57750             : #if ROSE_ALLOC_MEMSET == 1
   57751             : #elif ROSE_ALLOC_MEMSET == 2
   57752             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpToClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   57753             : #elif ROSE_ALLOC_MEMSET == 3
   57754             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgOmpToClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   57755             : #endif
   57756             : 
   57757             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   57758             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   57759             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   57760             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   57761             : #else
   57762           0 :     object->p_freepointer = SgOmpToClause::next_node;
   57763           0 :     SgOmpToClause::next_node = object;
   57764             : #endif
   57765             : 
   57766             : #if ROSE_ALLOC_TRACE == 2
   57767             : //  printf("SgOmpToClause::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpToClause::next_node);
   57768             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   57769             :     Rose::MemPool::snapshot(oss.str());
   57770             :     alloc_trace_cnt++;
   57771             : #endif
   57772             : 
   57773             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   57774             : 
   57775           0 :     ALLOC_MUTEX(SgOmpToClause, unlock);
   57776             : }
   57777             : 
   57778             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   57779             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   57780             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   57781             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   57782             : // Also, note comment below from Robb (copied from the Common.code file).
   57783             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   57784             : //
   57785             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   57786             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   57787             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   57788             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   57789             : #if 0
   57790             : void SgOmpToClause::operator delete(void* pointer) { SgOmpToClause::operator delete (pointer, sizeof(SgOmpToClause)); };
   57791             : #endif
   57792             : /* #line 57793 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   57793             : 
   57794             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   57795             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   57796             : // obviously imply C++.
   57797             : 
   57798             : // This implements the support within ROSE for memory pools.  Memory pools
   57799             : // support the most condensed usage of memory within the construction of
   57800             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   57801             : // by a new operator written for each class.
   57802             : 
   57803             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   57804             :     // User wants multi-thread support and POSIX threads are available.
   57805             : #   include <pthread.h>
   57806             :     static pthread_mutex_t SgOmpFromClause_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   57807             : #else
   57808             :      // Cause synchronization to be skipped.
   57809             : #    ifndef ALLOC_MUTEX
   57810             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   57811             : #    endif
   57812             : #    ifdef _REENTRANT
   57813             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   57814             : #       ifdef _MSC_VER
   57815             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   57816             : #       else
   57817             : #           warning "POSIX threads are not available; synchronization being skipped"
   57818             : #       endif
   57819             : #    endif
   57820             : #endif
   57821             : 
   57822             : #ifndef ROSE_ALLOC_TRACE
   57823             : #  define ROSE_ALLOC_TRACE 0
   57824             : #endif
   57825             : 
   57826             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   57827             : #define ROSE_ALLOC_TRACE_CNT
   57828             : #include "memory-pool-snapshot.h"
   57829             : unsigned long alloc_trace_cnt = 0;
   57830             : #endif
   57831             : 
   57832             : #if ROSE_ALLOC_TRACE
   57833             : const unsigned SgOmpFromClause::pool_size = 5;
   57834             : #else
   57835             : const unsigned SgOmpFromClause::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   57836             : #endif
   57837             : 
   57838             : #ifndef ROSE_ALLOC_MEMSET
   57839             : #  define ROSE_ALLOC_MEMSET 0
   57840             : #endif
   57841             : 
   57842             : #ifndef ROSE_PEDANTIC_ALLOC
   57843             : #  define ROSE_PEDANTIC_ALLOC 0
   57844             : #endif
   57845             : 
   57846             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   57847             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   57848             : #endif
   57849             : 
   57850             : #if !defined(SGNODE__ALL_POOLS)
   57851             : #define SGNODE__ALL_POOLS
   57852             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   57853             : #endif
   57854             : 
   57855             : SgOmpFromClause* SgOmpFromClause::next_node = nullptr;
   57856             : std::vector<unsigned char*> SgOmpFromClause::pools;
   57857             : 
   57858             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   57859             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   57860             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   57861             : // around this macro definition rather than each use).
   57862             : #ifndef ALLOC_MUTEX
   57863             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   57864             :         do {                                                                     \
   57865             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   57866             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   57867             :                 abort();                                                         \
   57868             :             }                                                                    \
   57869             :         } while (0);
   57870             : #endif
   57871             : 
   57872             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   57873             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   57874             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   57875             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   57876             : 
   57877             : /*! \brief New operator for SgOmpFromClause.
   57878             : 
   57879             :    This new operator implements memory pools to provide most efficent 
   57880             :    use of the heap within construction of large ASTs.
   57881             : 
   57882             : \internal The new and delete operators use the lower level C malloc/free
   57883             :    function calls for performance and to make sure that mixing of malloc/free
   57884             :    and new/delete by the used can be caught more readily.  This may change
   57885             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   57886             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   57887             :    deallocate memory allocated using ROSE_MALLOC.
   57888             : */
   57889           1 : void *SgOmpFromClause::operator new ( size_t Size )
   57890             : {
   57891             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   57892             :      * returning or throwing an exception. */
   57893           1 :     ALLOC_MUTEX(SgOmpFromClause, lock);
   57894             : 
   57895             : #if ROSE_ALLOC_TRACE == 2
   57896             : //    printf("SgOmpFromClause::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgOmpFromClause::next_node);
   57897             : #endif
   57898             : 
   57899             : #if USE_CPP_NEW_DELETE_OPERATORS
   57900             :     void *mem = ROSE_MALLOC(Size);
   57901             :     ALLOC_MUTEX(SgOmpFromClause, unlock);
   57902             :     return mem;
   57903             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   57904             : #if ROSE_PEDANTIC_ALLOC
   57905             :     ROSE_ASSERT(Size == sizeof(SgOmpFromClause));
   57906             : #else
   57907           1 :     if (Size != sizeof(SgOmpFromClause)) {
   57908           0 :       void * object = ROSE_MALLOC(Size);
   57909           0 :       ALLOC_MUTEX(SgOmpFromClause, unlock);
   57910             :       return object;
   57911             :     }
   57912             : #endif
   57913             : 
   57914           1 :     if (SgOmpFromClause::next_node == nullptr) {
   57915           1 :         SgOmpFromClause * alloc = (SgOmpFromClause*) ROSE_MALLOC ( SgOmpFromClause::pool_size * sizeof(SgOmpFromClause) );
   57916           1 :         ROSE_ASSERT(alloc != nullptr);
   57917             : 
   57918             : #if ROSE_ALLOC_TRACE == 2
   57919             : //        printf("SgOmpFromClause::alloc\n  block[%zi] = [ %p , %p [\n", SgOmpFromClause::pools.size(), alloc, alloc + SgOmpFromClause::pool_size);
   57920             : #endif
   57921             : 
   57922             : #if ROSE_ALLOC_MEMSET == 1
   57923             : #elif ROSE_ALLOC_MEMSET == 2
   57924             :         memset(alloc, 0x00, SgOmpFromClause::pool_size * sizeof(SgOmpFromClause));
   57925             : #elif ROSE_ALLOC_MEMSET == 3
   57926             :         memset(alloc, 0xAA, SgOmpFromClause::pool_size * sizeof(SgOmpFromClause));
   57927             : #endif
   57928        2000 :         for (unsigned i=0; i < SgOmpFromClause::pool_size-1; i++) {
   57929        1999 :           alloc[i].p_freepointer = &(alloc[i+1]);
   57930             :         }
   57931           1 :         alloc[SgOmpFromClause::pool_size-1].p_freepointer = nullptr;
   57932             : 
   57933           1 :         SgOmpFromClause::pools.push_back ( (unsigned char *) alloc );
   57934           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgOmpFromClause::pool_size * sizeof(SgOmpFromClause), V_SgOmpFromClause ) );
   57935           1 :         SgOmpFromClause::next_node = alloc;
   57936             :     }
   57937           1 :     ROSE_ASSERT(SgOmpFromClause::next_node != nullptr);
   57938             : 
   57939           1 :     SgOmpFromClause * object = SgOmpFromClause::next_node;
   57940           1 :     SgOmpFromClause::next_node = (SgOmpFromClause*)(object->p_freepointer);
   57941             : 
   57942             : #if ROSE_ALLOC_TRACE == 2
   57943             :     printf("SgOmpFromClause::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpFromClause::next_node);
   57944             : #endif
   57945             : 
   57946           1 :     SgNode * fp = object->p_freepointer;
   57947             : #if ROSE_ALLOC_MEMSET == 1
   57948             : #elif ROSE_ALLOC_MEMSET == 2
   57949             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpFromClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   57950             : #elif ROSE_ALLOC_MEMSET == 3
   57951             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgOmpFromClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   57952             : #endif
   57953           1 :     object->p_freepointer = fp;
   57954             : 
   57955             : #if ROSE_ALLOC_TRACE == 2
   57956             : //    printf("SgOmpFromClause::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpFromClause::next_node);
   57957             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   57958             :     Rose::MemPool::snapshot(oss.str());
   57959             :     alloc_trace_cnt++;
   57960             : #endif
   57961             : 
   57962           1 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   57963             : 
   57964           1 :     ALLOC_MUTEX(SgOmpFromClause, unlock);
   57965             : 
   57966             :     return object;
   57967             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   57968             : }
   57969             : 
   57970             : 
   57971             : 
   57972             : /*! \brief Delete operator for SgOmpFromClause.
   57973             : 
   57974             :    This delete operator implements deallocation using memory pools to 
   57975             :    provide most efficent use of the heap within construction of large ASTs.
   57976             : 
   57977             : \internal The new and delete operators use the lower level C malloc/free
   57978             :    function calls for performance and to make sure that mixing of malloc/free
   57979             :    and new/delete by the used can be caught more readily.  This may change
   57980             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   57981             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   57982             :    deallocate memory allocated using ROSE_MALLOC.
   57983             : */
   57984           0 : void SgOmpFromClause::operator delete(void *Pointer, size_t Size)
   57985             : {
   57986             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   57987             :      * or throwing an exception. */
   57988           0 :     ALLOC_MUTEX(SgOmpFromClause, lock);
   57989             : 
   57990             : #if USE_CPP_NEW_DELETE_OPERATORS
   57991             :     ROSE_FREE(Pointer);
   57992             : #else
   57993             : #if ROSE_PEDANTIC_ALLOC
   57994             :     ROSE_ASSERT(Size == sizeof(SgOmpFromClause));
   57995             : #else
   57996           0 :     if (Size != sizeof(SgOmpFromClause)) {
   57997           0 :       ROSE_FREE(Pointer);
   57998           0 :       ALLOC_MUTEX(SgOmpFromClause, unlock);
   57999             :       return;
   58000             :     }
   58001             : #endif
   58002             : 
   58003           0 :     SgOmpFromClause * object = (SgOmpFromClause*) Pointer;
   58004           0 :     ROSE_ASSERT(object != nullptr);
   58005             : 
   58006             : #if ROSE_ALLOC_TRACE == 2
   58007             : //  printf("SgOmpFromClause::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpFromClause::next_node);
   58008             :     printf("SgOmpFromClause::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpFromClause::next_node);
   58009             : #endif
   58010             : 
   58011             : #if ROSE_PEDANTIC_ALLOC
   58012             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   58013             : #endif
   58014             : 
   58015             : #if ROSE_ALLOC_MEMSET == 1
   58016             : #elif ROSE_ALLOC_MEMSET == 2
   58017             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpFromClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   58018             : #elif ROSE_ALLOC_MEMSET == 3
   58019             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgOmpFromClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   58020             : #endif
   58021             : 
   58022             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   58023             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   58024             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   58025             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   58026             : #else
   58027           0 :     object->p_freepointer = SgOmpFromClause::next_node;
   58028           0 :     SgOmpFromClause::next_node = object;
   58029             : #endif
   58030             : 
   58031             : #if ROSE_ALLOC_TRACE == 2
   58032             : //  printf("SgOmpFromClause::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpFromClause::next_node);
   58033             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   58034             :     Rose::MemPool::snapshot(oss.str());
   58035             :     alloc_trace_cnt++;
   58036             : #endif
   58037             : 
   58038             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   58039             : 
   58040           0 :     ALLOC_MUTEX(SgOmpFromClause, unlock);
   58041             : }
   58042             : 
   58043             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   58044             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   58045             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   58046             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   58047             : // Also, note comment below from Robb (copied from the Common.code file).
   58048             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   58049             : //
   58050             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   58051             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   58052             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   58053             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   58054             : #if 0
   58055             : void SgOmpFromClause::operator delete(void* pointer) { SgOmpFromClause::operator delete (pointer, sizeof(SgOmpFromClause)); };
   58056             : #endif
   58057             : /* #line 58058 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   58058             : 
   58059             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   58060             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   58061             : // obviously imply C++.
   58062             : 
   58063             : // This implements the support within ROSE for memory pools.  Memory pools
   58064             : // support the most condensed usage of memory within the construction of
   58065             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   58066             : // by a new operator written for each class.
   58067             : 
   58068             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   58069             :     // User wants multi-thread support and POSIX threads are available.
   58070             : #   include <pthread.h>
   58071             :     static pthread_mutex_t SgOmpScheduleClause_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   58072             : #else
   58073             :      // Cause synchronization to be skipped.
   58074             : #    ifndef ALLOC_MUTEX
   58075             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   58076             : #    endif
   58077             : #    ifdef _REENTRANT
   58078             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   58079             : #       ifdef _MSC_VER
   58080             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   58081             : #       else
   58082             : #           warning "POSIX threads are not available; synchronization being skipped"
   58083             : #       endif
   58084             : #    endif
   58085             : #endif
   58086             : 
   58087             : #ifndef ROSE_ALLOC_TRACE
   58088             : #  define ROSE_ALLOC_TRACE 0
   58089             : #endif
   58090             : 
   58091             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   58092             : #define ROSE_ALLOC_TRACE_CNT
   58093             : #include "memory-pool-snapshot.h"
   58094             : unsigned long alloc_trace_cnt = 0;
   58095             : #endif
   58096             : 
   58097             : #if ROSE_ALLOC_TRACE
   58098             : const unsigned SgOmpScheduleClause::pool_size = 5;
   58099             : #else
   58100             : const unsigned SgOmpScheduleClause::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   58101             : #endif
   58102             : 
   58103             : #ifndef ROSE_ALLOC_MEMSET
   58104             : #  define ROSE_ALLOC_MEMSET 0
   58105             : #endif
   58106             : 
   58107             : #ifndef ROSE_PEDANTIC_ALLOC
   58108             : #  define ROSE_PEDANTIC_ALLOC 0
   58109             : #endif
   58110             : 
   58111             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   58112             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   58113             : #endif
   58114             : 
   58115             : #if !defined(SGNODE__ALL_POOLS)
   58116             : #define SGNODE__ALL_POOLS
   58117             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   58118             : #endif
   58119             : 
   58120             : SgOmpScheduleClause* SgOmpScheduleClause::next_node = nullptr;
   58121             : std::vector<unsigned char*> SgOmpScheduleClause::pools;
   58122             : 
   58123             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   58124             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   58125             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   58126             : // around this macro definition rather than each use).
   58127             : #ifndef ALLOC_MUTEX
   58128             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   58129             :         do {                                                                     \
   58130             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   58131             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   58132             :                 abort();                                                         \
   58133             :             }                                                                    \
   58134             :         } while (0);
   58135             : #endif
   58136             : 
   58137             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   58138             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   58139             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   58140             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   58141             : 
   58142             : /*! \brief New operator for SgOmpScheduleClause.
   58143             : 
   58144             :    This new operator implements memory pools to provide most efficent 
   58145             :    use of the heap within construction of large ASTs.
   58146             : 
   58147             : \internal The new and delete operators use the lower level C malloc/free
   58148             :    function calls for performance and to make sure that mixing of malloc/free
   58149             :    and new/delete by the used can be caught more readily.  This may change
   58150             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   58151             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   58152             :    deallocate memory allocated using ROSE_MALLOC.
   58153             : */
   58154          95 : void *SgOmpScheduleClause::operator new ( size_t Size )
   58155             : {
   58156             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   58157             :      * returning or throwing an exception. */
   58158          95 :     ALLOC_MUTEX(SgOmpScheduleClause, lock);
   58159             : 
   58160             : #if ROSE_ALLOC_TRACE == 2
   58161             : //    printf("SgOmpScheduleClause::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgOmpScheduleClause::next_node);
   58162             : #endif
   58163             : 
   58164             : #if USE_CPP_NEW_DELETE_OPERATORS
   58165             :     void *mem = ROSE_MALLOC(Size);
   58166             :     ALLOC_MUTEX(SgOmpScheduleClause, unlock);
   58167             :     return mem;
   58168             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   58169             : #if ROSE_PEDANTIC_ALLOC
   58170             :     ROSE_ASSERT(Size == sizeof(SgOmpScheduleClause));
   58171             : #else
   58172          95 :     if (Size != sizeof(SgOmpScheduleClause)) {
   58173           0 :       void * object = ROSE_MALLOC(Size);
   58174           0 :       ALLOC_MUTEX(SgOmpScheduleClause, unlock);
   58175             :       return object;
   58176             :     }
   58177             : #endif
   58178             : 
   58179          95 :     if (SgOmpScheduleClause::next_node == nullptr) {
   58180          27 :         SgOmpScheduleClause * alloc = (SgOmpScheduleClause*) ROSE_MALLOC ( SgOmpScheduleClause::pool_size * sizeof(SgOmpScheduleClause) );
   58181          27 :         ROSE_ASSERT(alloc != nullptr);
   58182             : 
   58183             : #if ROSE_ALLOC_TRACE == 2
   58184             : //        printf("SgOmpScheduleClause::alloc\n  block[%zi] = [ %p , %p [\n", SgOmpScheduleClause::pools.size(), alloc, alloc + SgOmpScheduleClause::pool_size);
   58185             : #endif
   58186             : 
   58187             : #if ROSE_ALLOC_MEMSET == 1
   58188             : #elif ROSE_ALLOC_MEMSET == 2
   58189             :         memset(alloc, 0x00, SgOmpScheduleClause::pool_size * sizeof(SgOmpScheduleClause));
   58190             : #elif ROSE_ALLOC_MEMSET == 3
   58191             :         memset(alloc, 0xAA, SgOmpScheduleClause::pool_size * sizeof(SgOmpScheduleClause));
   58192             : #endif
   58193       54000 :         for (unsigned i=0; i < SgOmpScheduleClause::pool_size-1; i++) {
   58194       53973 :           alloc[i].p_freepointer = &(alloc[i+1]);
   58195             :         }
   58196          27 :         alloc[SgOmpScheduleClause::pool_size-1].p_freepointer = nullptr;
   58197             : 
   58198          27 :         SgOmpScheduleClause::pools.push_back ( (unsigned char *) alloc );
   58199          27 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgOmpScheduleClause::pool_size * sizeof(SgOmpScheduleClause), V_SgOmpScheduleClause ) );
   58200          27 :         SgOmpScheduleClause::next_node = alloc;
   58201             :     }
   58202          95 :     ROSE_ASSERT(SgOmpScheduleClause::next_node != nullptr);
   58203             : 
   58204          95 :     SgOmpScheduleClause * object = SgOmpScheduleClause::next_node;
   58205          95 :     SgOmpScheduleClause::next_node = (SgOmpScheduleClause*)(object->p_freepointer);
   58206             : 
   58207             : #if ROSE_ALLOC_TRACE == 2
   58208             :     printf("SgOmpScheduleClause::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpScheduleClause::next_node);
   58209             : #endif
   58210             : 
   58211          95 :     SgNode * fp = object->p_freepointer;
   58212             : #if ROSE_ALLOC_MEMSET == 1
   58213             : #elif ROSE_ALLOC_MEMSET == 2
   58214             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpScheduleClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   58215             : #elif ROSE_ALLOC_MEMSET == 3
   58216             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgOmpScheduleClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   58217             : #endif
   58218          95 :     object->p_freepointer = fp;
   58219             : 
   58220             : #if ROSE_ALLOC_TRACE == 2
   58221             : //    printf("SgOmpScheduleClause::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpScheduleClause::next_node);
   58222             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   58223             :     Rose::MemPool::snapshot(oss.str());
   58224             :     alloc_trace_cnt++;
   58225             : #endif
   58226             : 
   58227          95 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   58228             : 
   58229          95 :     ALLOC_MUTEX(SgOmpScheduleClause, unlock);
   58230             : 
   58231             :     return object;
   58232             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   58233             : }
   58234             : 
   58235             : 
   58236             : 
   58237             : /*! \brief Delete operator for SgOmpScheduleClause.
   58238             : 
   58239             :    This delete operator implements deallocation using memory pools to 
   58240             :    provide most efficent use of the heap within construction of large ASTs.
   58241             : 
   58242             : \internal The new and delete operators use the lower level C malloc/free
   58243             :    function calls for performance and to make sure that mixing of malloc/free
   58244             :    and new/delete by the used can be caught more readily.  This may change
   58245             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   58246             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   58247             :    deallocate memory allocated using ROSE_MALLOC.
   58248             : */
   58249           0 : void SgOmpScheduleClause::operator delete(void *Pointer, size_t Size)
   58250             : {
   58251             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   58252             :      * or throwing an exception. */
   58253           0 :     ALLOC_MUTEX(SgOmpScheduleClause, lock);
   58254             : 
   58255             : #if USE_CPP_NEW_DELETE_OPERATORS
   58256             :     ROSE_FREE(Pointer);
   58257             : #else
   58258             : #if ROSE_PEDANTIC_ALLOC
   58259             :     ROSE_ASSERT(Size == sizeof(SgOmpScheduleClause));
   58260             : #else
   58261           0 :     if (Size != sizeof(SgOmpScheduleClause)) {
   58262           0 :       ROSE_FREE(Pointer);
   58263           0 :       ALLOC_MUTEX(SgOmpScheduleClause, unlock);
   58264             :       return;
   58265             :     }
   58266             : #endif
   58267             : 
   58268           0 :     SgOmpScheduleClause * object = (SgOmpScheduleClause*) Pointer;
   58269           0 :     ROSE_ASSERT(object != nullptr);
   58270             : 
   58271             : #if ROSE_ALLOC_TRACE == 2
   58272             : //  printf("SgOmpScheduleClause::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpScheduleClause::next_node);
   58273             :     printf("SgOmpScheduleClause::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpScheduleClause::next_node);
   58274             : #endif
   58275             : 
   58276             : #if ROSE_PEDANTIC_ALLOC
   58277             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   58278             : #endif
   58279             : 
   58280             : #if ROSE_ALLOC_MEMSET == 1
   58281             : #elif ROSE_ALLOC_MEMSET == 2
   58282             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpScheduleClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   58283             : #elif ROSE_ALLOC_MEMSET == 3
   58284             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgOmpScheduleClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   58285             : #endif
   58286             : 
   58287             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   58288             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   58289             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   58290             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   58291             : #else
   58292           0 :     object->p_freepointer = SgOmpScheduleClause::next_node;
   58293           0 :     SgOmpScheduleClause::next_node = object;
   58294             : #endif
   58295             : 
   58296             : #if ROSE_ALLOC_TRACE == 2
   58297             : //  printf("SgOmpScheduleClause::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpScheduleClause::next_node);
   58298             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   58299             :     Rose::MemPool::snapshot(oss.str());
   58300             :     alloc_trace_cnt++;
   58301             : #endif
   58302             : 
   58303             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   58304             : 
   58305           0 :     ALLOC_MUTEX(SgOmpScheduleClause, unlock);
   58306             : }
   58307             : 
   58308             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   58309             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   58310             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   58311             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   58312             : // Also, note comment below from Robb (copied from the Common.code file).
   58313             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   58314             : //
   58315             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   58316             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   58317             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   58318             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   58319             : #if 0
   58320             : void SgOmpScheduleClause::operator delete(void* pointer) { SgOmpScheduleClause::operator delete (pointer, sizeof(SgOmpScheduleClause)); };
   58321             : #endif
   58322             : /* #line 58323 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   58323             : 
   58324             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   58325             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   58326             : // obviously imply C++.
   58327             : 
   58328             : // This implements the support within ROSE for memory pools.  Memory pools
   58329             : // support the most condensed usage of memory within the construction of
   58330             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   58331             : // by a new operator written for each class.
   58332             : 
   58333             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   58334             :     // User wants multi-thread support and POSIX threads are available.
   58335             : #   include <pthread.h>
   58336             :     static pthread_mutex_t SgOmpMergeableClause_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   58337             : #else
   58338             :      // Cause synchronization to be skipped.
   58339             : #    ifndef ALLOC_MUTEX
   58340             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   58341             : #    endif
   58342             : #    ifdef _REENTRANT
   58343             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   58344             : #       ifdef _MSC_VER
   58345             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   58346             : #       else
   58347             : #           warning "POSIX threads are not available; synchronization being skipped"
   58348             : #       endif
   58349             : #    endif
   58350             : #endif
   58351             : 
   58352             : #ifndef ROSE_ALLOC_TRACE
   58353             : #  define ROSE_ALLOC_TRACE 0
   58354             : #endif
   58355             : 
   58356             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   58357             : #define ROSE_ALLOC_TRACE_CNT
   58358             : #include "memory-pool-snapshot.h"
   58359             : unsigned long alloc_trace_cnt = 0;
   58360             : #endif
   58361             : 
   58362             : #if ROSE_ALLOC_TRACE
   58363             : const unsigned SgOmpMergeableClause::pool_size = 5;
   58364             : #else
   58365             : const unsigned SgOmpMergeableClause::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   58366             : #endif
   58367             : 
   58368             : #ifndef ROSE_ALLOC_MEMSET
   58369             : #  define ROSE_ALLOC_MEMSET 0
   58370             : #endif
   58371             : 
   58372             : #ifndef ROSE_PEDANTIC_ALLOC
   58373             : #  define ROSE_PEDANTIC_ALLOC 0
   58374             : #endif
   58375             : 
   58376             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   58377             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   58378             : #endif
   58379             : 
   58380             : #if !defined(SGNODE__ALL_POOLS)
   58381             : #define SGNODE__ALL_POOLS
   58382             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   58383             : #endif
   58384             : 
   58385             : SgOmpMergeableClause* SgOmpMergeableClause::next_node = nullptr;
   58386             : std::vector<unsigned char*> SgOmpMergeableClause::pools;
   58387             : 
   58388             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   58389             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   58390             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   58391             : // around this macro definition rather than each use).
   58392             : #ifndef ALLOC_MUTEX
   58393             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   58394             :         do {                                                                     \
   58395             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   58396             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   58397             :                 abort();                                                         \
   58398             :             }                                                                    \
   58399             :         } while (0);
   58400             : #endif
   58401             : 
   58402             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   58403             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   58404             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   58405             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   58406             : 
   58407             : /*! \brief New operator for SgOmpMergeableClause.
   58408             : 
   58409             :    This new operator implements memory pools to provide most efficent 
   58410             :    use of the heap within construction of large ASTs.
   58411             : 
   58412             : \internal The new and delete operators use the lower level C malloc/free
   58413             :    function calls for performance and to make sure that mixing of malloc/free
   58414             :    and new/delete by the used can be caught more readily.  This may change
   58415             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   58416             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   58417             :    deallocate memory allocated using ROSE_MALLOC.
   58418             : */
   58419           4 : void *SgOmpMergeableClause::operator new ( size_t Size )
   58420             : {
   58421             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   58422             :      * returning or throwing an exception. */
   58423           4 :     ALLOC_MUTEX(SgOmpMergeableClause, lock);
   58424             : 
   58425             : #if ROSE_ALLOC_TRACE == 2
   58426             : //    printf("SgOmpMergeableClause::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgOmpMergeableClause::next_node);
   58427             : #endif
   58428             : 
   58429             : #if USE_CPP_NEW_DELETE_OPERATORS
   58430             :     void *mem = ROSE_MALLOC(Size);
   58431             :     ALLOC_MUTEX(SgOmpMergeableClause, unlock);
   58432             :     return mem;
   58433             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   58434             : #if ROSE_PEDANTIC_ALLOC
   58435             :     ROSE_ASSERT(Size == sizeof(SgOmpMergeableClause));
   58436             : #else
   58437           4 :     if (Size != sizeof(SgOmpMergeableClause)) {
   58438           0 :       void * object = ROSE_MALLOC(Size);
   58439           0 :       ALLOC_MUTEX(SgOmpMergeableClause, unlock);
   58440             :       return object;
   58441             :     }
   58442             : #endif
   58443             : 
   58444           4 :     if (SgOmpMergeableClause::next_node == nullptr) {
   58445           3 :         SgOmpMergeableClause * alloc = (SgOmpMergeableClause*) ROSE_MALLOC ( SgOmpMergeableClause::pool_size * sizeof(SgOmpMergeableClause) );
   58446           3 :         ROSE_ASSERT(alloc != nullptr);
   58447             : 
   58448             : #if ROSE_ALLOC_TRACE == 2
   58449             : //        printf("SgOmpMergeableClause::alloc\n  block[%zi] = [ %p , %p [\n", SgOmpMergeableClause::pools.size(), alloc, alloc + SgOmpMergeableClause::pool_size);
   58450             : #endif
   58451             : 
   58452             : #if ROSE_ALLOC_MEMSET == 1
   58453             : #elif ROSE_ALLOC_MEMSET == 2
   58454             :         memset(alloc, 0x00, SgOmpMergeableClause::pool_size * sizeof(SgOmpMergeableClause));
   58455             : #elif ROSE_ALLOC_MEMSET == 3
   58456             :         memset(alloc, 0xAA, SgOmpMergeableClause::pool_size * sizeof(SgOmpMergeableClause));
   58457             : #endif
   58458        6000 :         for (unsigned i=0; i < SgOmpMergeableClause::pool_size-1; i++) {
   58459        5997 :           alloc[i].p_freepointer = &(alloc[i+1]);
   58460             :         }
   58461           3 :         alloc[SgOmpMergeableClause::pool_size-1].p_freepointer = nullptr;
   58462             : 
   58463           3 :         SgOmpMergeableClause::pools.push_back ( (unsigned char *) alloc );
   58464           3 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgOmpMergeableClause::pool_size * sizeof(SgOmpMergeableClause), V_SgOmpMergeableClause ) );
   58465           3 :         SgOmpMergeableClause::next_node = alloc;
   58466             :     }
   58467           4 :     ROSE_ASSERT(SgOmpMergeableClause::next_node != nullptr);
   58468             : 
   58469           4 :     SgOmpMergeableClause * object = SgOmpMergeableClause::next_node;
   58470           4 :     SgOmpMergeableClause::next_node = (SgOmpMergeableClause*)(object->p_freepointer);
   58471             : 
   58472             : #if ROSE_ALLOC_TRACE == 2
   58473             :     printf("SgOmpMergeableClause::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpMergeableClause::next_node);
   58474             : #endif
   58475             : 
   58476           4 :     SgNode * fp = object->p_freepointer;
   58477             : #if ROSE_ALLOC_MEMSET == 1
   58478             : #elif ROSE_ALLOC_MEMSET == 2
   58479             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpMergeableClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   58480             : #elif ROSE_ALLOC_MEMSET == 3
   58481             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgOmpMergeableClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   58482             : #endif
   58483           4 :     object->p_freepointer = fp;
   58484             : 
   58485             : #if ROSE_ALLOC_TRACE == 2
   58486             : //    printf("SgOmpMergeableClause::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpMergeableClause::next_node);
   58487             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   58488             :     Rose::MemPool::snapshot(oss.str());
   58489             :     alloc_trace_cnt++;
   58490             : #endif
   58491             : 
   58492           4 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   58493             : 
   58494           4 :     ALLOC_MUTEX(SgOmpMergeableClause, unlock);
   58495             : 
   58496             :     return object;
   58497             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   58498             : }
   58499             : 
   58500             : 
   58501             : 
   58502             : /*! \brief Delete operator for SgOmpMergeableClause.
   58503             : 
   58504             :    This delete operator implements deallocation using memory pools to 
   58505             :    provide most efficent use of the heap within construction of large ASTs.
   58506             : 
   58507             : \internal The new and delete operators use the lower level C malloc/free
   58508             :    function calls for performance and to make sure that mixing of malloc/free
   58509             :    and new/delete by the used can be caught more readily.  This may change
   58510             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   58511             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   58512             :    deallocate memory allocated using ROSE_MALLOC.
   58513             : */
   58514           0 : void SgOmpMergeableClause::operator delete(void *Pointer, size_t Size)
   58515             : {
   58516             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   58517             :      * or throwing an exception. */
   58518           0 :     ALLOC_MUTEX(SgOmpMergeableClause, lock);
   58519             : 
   58520             : #if USE_CPP_NEW_DELETE_OPERATORS
   58521             :     ROSE_FREE(Pointer);
   58522             : #else
   58523             : #if ROSE_PEDANTIC_ALLOC
   58524             :     ROSE_ASSERT(Size == sizeof(SgOmpMergeableClause));
   58525             : #else
   58526           0 :     if (Size != sizeof(SgOmpMergeableClause)) {
   58527           0 :       ROSE_FREE(Pointer);
   58528           0 :       ALLOC_MUTEX(SgOmpMergeableClause, unlock);
   58529             :       return;
   58530             :     }
   58531             : #endif
   58532             : 
   58533           0 :     SgOmpMergeableClause * object = (SgOmpMergeableClause*) Pointer;
   58534           0 :     ROSE_ASSERT(object != nullptr);
   58535             : 
   58536             : #if ROSE_ALLOC_TRACE == 2
   58537             : //  printf("SgOmpMergeableClause::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpMergeableClause::next_node);
   58538             :     printf("SgOmpMergeableClause::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpMergeableClause::next_node);
   58539             : #endif
   58540             : 
   58541             : #if ROSE_PEDANTIC_ALLOC
   58542             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   58543             : #endif
   58544             : 
   58545             : #if ROSE_ALLOC_MEMSET == 1
   58546             : #elif ROSE_ALLOC_MEMSET == 2
   58547             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpMergeableClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   58548             : #elif ROSE_ALLOC_MEMSET == 3
   58549             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgOmpMergeableClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   58550             : #endif
   58551             : 
   58552             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   58553             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   58554             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   58555             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   58556             : #else
   58557           0 :     object->p_freepointer = SgOmpMergeableClause::next_node;
   58558           0 :     SgOmpMergeableClause::next_node = object;
   58559             : #endif
   58560             : 
   58561             : #if ROSE_ALLOC_TRACE == 2
   58562             : //  printf("SgOmpMergeableClause::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpMergeableClause::next_node);
   58563             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   58564             :     Rose::MemPool::snapshot(oss.str());
   58565             :     alloc_trace_cnt++;
   58566             : #endif
   58567             : 
   58568             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   58569             : 
   58570           0 :     ALLOC_MUTEX(SgOmpMergeableClause, unlock);
   58571             : }
   58572             : 
   58573             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   58574             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   58575             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   58576             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   58577             : // Also, note comment below from Robb (copied from the Common.code file).
   58578             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   58579             : //
   58580             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   58581             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   58582             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   58583             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   58584             : #if 0
   58585             : void SgOmpMergeableClause::operator delete(void* pointer) { SgOmpMergeableClause::operator delete (pointer, sizeof(SgOmpMergeableClause)); };
   58586             : #endif
   58587             : /* #line 58588 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   58588             : 
   58589             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   58590             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   58591             : // obviously imply C++.
   58592             : 
   58593             : // This implements the support within ROSE for memory pools.  Memory pools
   58594             : // support the most condensed usage of memory within the construction of
   58595             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   58596             : // by a new operator written for each class.
   58597             : 
   58598             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   58599             :     // User wants multi-thread support and POSIX threads are available.
   58600             : #   include <pthread.h>
   58601             :     static pthread_mutex_t SgOmpWhenClause_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   58602             : #else
   58603             :      // Cause synchronization to be skipped.
   58604             : #    ifndef ALLOC_MUTEX
   58605             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   58606             : #    endif
   58607             : #    ifdef _REENTRANT
   58608             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   58609             : #       ifdef _MSC_VER
   58610             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   58611             : #       else
   58612             : #           warning "POSIX threads are not available; synchronization being skipped"
   58613             : #       endif
   58614             : #    endif
   58615             : #endif
   58616             : 
   58617             : #ifndef ROSE_ALLOC_TRACE
   58618             : #  define ROSE_ALLOC_TRACE 0
   58619             : #endif
   58620             : 
   58621             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   58622             : #define ROSE_ALLOC_TRACE_CNT
   58623             : #include "memory-pool-snapshot.h"
   58624             : unsigned long alloc_trace_cnt = 0;
   58625             : #endif
   58626             : 
   58627             : #if ROSE_ALLOC_TRACE
   58628             : const unsigned SgOmpWhenClause::pool_size = 5;
   58629             : #else
   58630             : const unsigned SgOmpWhenClause::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   58631             : #endif
   58632             : 
   58633             : #ifndef ROSE_ALLOC_MEMSET
   58634             : #  define ROSE_ALLOC_MEMSET 0
   58635             : #endif
   58636             : 
   58637             : #ifndef ROSE_PEDANTIC_ALLOC
   58638             : #  define ROSE_PEDANTIC_ALLOC 0
   58639             : #endif
   58640             : 
   58641             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   58642             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   58643             : #endif
   58644             : 
   58645             : #if !defined(SGNODE__ALL_POOLS)
   58646             : #define SGNODE__ALL_POOLS
   58647             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   58648             : #endif
   58649             : 
   58650             : SgOmpWhenClause* SgOmpWhenClause::next_node = nullptr;
   58651             : std::vector<unsigned char*> SgOmpWhenClause::pools;
   58652             : 
   58653             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   58654             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   58655             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   58656             : // around this macro definition rather than each use).
   58657             : #ifndef ALLOC_MUTEX
   58658             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   58659             :         do {                                                                     \
   58660             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   58661             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   58662             :                 abort();                                                         \
   58663             :             }                                                                    \
   58664             :         } while (0);
   58665             : #endif
   58666             : 
   58667             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   58668             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   58669             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   58670             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   58671             : 
   58672             : /*! \brief New operator for SgOmpWhenClause.
   58673             : 
   58674             :    This new operator implements memory pools to provide most efficent 
   58675             :    use of the heap within construction of large ASTs.
   58676             : 
   58677             : \internal The new and delete operators use the lower level C malloc/free
   58678             :    function calls for performance and to make sure that mixing of malloc/free
   58679             :    and new/delete by the used can be caught more readily.  This may change
   58680             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   58681             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   58682             :    deallocate memory allocated using ROSE_MALLOC.
   58683             : */
   58684           0 : void *SgOmpWhenClause::operator new ( size_t Size )
   58685             : {
   58686             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   58687             :      * returning or throwing an exception. */
   58688           0 :     ALLOC_MUTEX(SgOmpWhenClause, lock);
   58689             : 
   58690             : #if ROSE_ALLOC_TRACE == 2
   58691             : //    printf("SgOmpWhenClause::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgOmpWhenClause::next_node);
   58692             : #endif
   58693             : 
   58694             : #if USE_CPP_NEW_DELETE_OPERATORS
   58695             :     void *mem = ROSE_MALLOC(Size);
   58696             :     ALLOC_MUTEX(SgOmpWhenClause, unlock);
   58697             :     return mem;
   58698             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   58699             : #if ROSE_PEDANTIC_ALLOC
   58700             :     ROSE_ASSERT(Size == sizeof(SgOmpWhenClause));
   58701             : #else
   58702           0 :     if (Size != sizeof(SgOmpWhenClause)) {
   58703           0 :       void * object = ROSE_MALLOC(Size);
   58704           0 :       ALLOC_MUTEX(SgOmpWhenClause, unlock);
   58705             :       return object;
   58706             :     }
   58707             : #endif
   58708             : 
   58709           0 :     if (SgOmpWhenClause::next_node == nullptr) {
   58710           0 :         SgOmpWhenClause * alloc = (SgOmpWhenClause*) ROSE_MALLOC ( SgOmpWhenClause::pool_size * sizeof(SgOmpWhenClause) );
   58711           0 :         ROSE_ASSERT(alloc != nullptr);
   58712             : 
   58713             : #if ROSE_ALLOC_TRACE == 2
   58714             : //        printf("SgOmpWhenClause::alloc\n  block[%zi] = [ %p , %p [\n", SgOmpWhenClause::pools.size(), alloc, alloc + SgOmpWhenClause::pool_size);
   58715             : #endif
   58716             : 
   58717             : #if ROSE_ALLOC_MEMSET == 1
   58718             : #elif ROSE_ALLOC_MEMSET == 2
   58719             :         memset(alloc, 0x00, SgOmpWhenClause::pool_size * sizeof(SgOmpWhenClause));
   58720             : #elif ROSE_ALLOC_MEMSET == 3
   58721             :         memset(alloc, 0xAA, SgOmpWhenClause::pool_size * sizeof(SgOmpWhenClause));
   58722             : #endif
   58723           0 :         for (unsigned i=0; i < SgOmpWhenClause::pool_size-1; i++) {
   58724           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
   58725             :         }
   58726           0 :         alloc[SgOmpWhenClause::pool_size-1].p_freepointer = nullptr;
   58727             : 
   58728           0 :         SgOmpWhenClause::pools.push_back ( (unsigned char *) alloc );
   58729           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgOmpWhenClause::pool_size * sizeof(SgOmpWhenClause), V_SgOmpWhenClause ) );
   58730           0 :         SgOmpWhenClause::next_node = alloc;
   58731             :     }
   58732           0 :     ROSE_ASSERT(SgOmpWhenClause::next_node != nullptr);
   58733             : 
   58734           0 :     SgOmpWhenClause * object = SgOmpWhenClause::next_node;
   58735           0 :     SgOmpWhenClause::next_node = (SgOmpWhenClause*)(object->p_freepointer);
   58736             : 
   58737             : #if ROSE_ALLOC_TRACE == 2
   58738             :     printf("SgOmpWhenClause::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpWhenClause::next_node);
   58739             : #endif
   58740             : 
   58741           0 :     SgNode * fp = object->p_freepointer;
   58742             : #if ROSE_ALLOC_MEMSET == 1
   58743             : #elif ROSE_ALLOC_MEMSET == 2
   58744             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpWhenClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   58745             : #elif ROSE_ALLOC_MEMSET == 3
   58746             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgOmpWhenClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   58747             : #endif
   58748           0 :     object->p_freepointer = fp;
   58749             : 
   58750             : #if ROSE_ALLOC_TRACE == 2
   58751             : //    printf("SgOmpWhenClause::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpWhenClause::next_node);
   58752             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   58753             :     Rose::MemPool::snapshot(oss.str());
   58754             :     alloc_trace_cnt++;
   58755             : #endif
   58756             : 
   58757           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   58758             : 
   58759           0 :     ALLOC_MUTEX(SgOmpWhenClause, unlock);
   58760             : 
   58761             :     return object;
   58762             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   58763             : }
   58764             : 
   58765             : 
   58766             : 
   58767             : /*! \brief Delete operator for SgOmpWhenClause.
   58768             : 
   58769             :    This delete operator implements deallocation using memory pools to 
   58770             :    provide most efficent use of the heap within construction of large ASTs.
   58771             : 
   58772             : \internal The new and delete operators use the lower level C malloc/free
   58773             :    function calls for performance and to make sure that mixing of malloc/free
   58774             :    and new/delete by the used can be caught more readily.  This may change
   58775             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   58776             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   58777             :    deallocate memory allocated using ROSE_MALLOC.
   58778             : */
   58779           0 : void SgOmpWhenClause::operator delete(void *Pointer, size_t Size)
   58780             : {
   58781             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   58782             :      * or throwing an exception. */
   58783           0 :     ALLOC_MUTEX(SgOmpWhenClause, lock);
   58784             : 
   58785             : #if USE_CPP_NEW_DELETE_OPERATORS
   58786             :     ROSE_FREE(Pointer);
   58787             : #else
   58788             : #if ROSE_PEDANTIC_ALLOC
   58789             :     ROSE_ASSERT(Size == sizeof(SgOmpWhenClause));
   58790             : #else
   58791           0 :     if (Size != sizeof(SgOmpWhenClause)) {
   58792           0 :       ROSE_FREE(Pointer);
   58793           0 :       ALLOC_MUTEX(SgOmpWhenClause, unlock);
   58794             :       return;
   58795             :     }
   58796             : #endif
   58797             : 
   58798           0 :     SgOmpWhenClause * object = (SgOmpWhenClause*) Pointer;
   58799           0 :     ROSE_ASSERT(object != nullptr);
   58800             : 
   58801             : #if ROSE_ALLOC_TRACE == 2
   58802             : //  printf("SgOmpWhenClause::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpWhenClause::next_node);
   58803             :     printf("SgOmpWhenClause::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpWhenClause::next_node);
   58804             : #endif
   58805             : 
   58806             : #if ROSE_PEDANTIC_ALLOC
   58807             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   58808             : #endif
   58809             : 
   58810             : #if ROSE_ALLOC_MEMSET == 1
   58811             : #elif ROSE_ALLOC_MEMSET == 2
   58812             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpWhenClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   58813             : #elif ROSE_ALLOC_MEMSET == 3
   58814             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgOmpWhenClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   58815             : #endif
   58816             : 
   58817             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   58818             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   58819             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   58820             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   58821             : #else
   58822           0 :     object->p_freepointer = SgOmpWhenClause::next_node;
   58823           0 :     SgOmpWhenClause::next_node = object;
   58824             : #endif
   58825             : 
   58826             : #if ROSE_ALLOC_TRACE == 2
   58827             : //  printf("SgOmpWhenClause::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpWhenClause::next_node);
   58828             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   58829             :     Rose::MemPool::snapshot(oss.str());
   58830             :     alloc_trace_cnt++;
   58831             : #endif
   58832             : 
   58833             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   58834             : 
   58835           0 :     ALLOC_MUTEX(SgOmpWhenClause, unlock);
   58836             : }
   58837             : 
   58838             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   58839             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   58840             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   58841             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   58842             : // Also, note comment below from Robb (copied from the Common.code file).
   58843             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   58844             : //
   58845             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   58846             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   58847             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   58848             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   58849             : #if 0
   58850             : void SgOmpWhenClause::operator delete(void* pointer) { SgOmpWhenClause::operator delete (pointer, sizeof(SgOmpWhenClause)); };
   58851             : #endif
   58852             : /* #line 58853 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   58853             : 
   58854             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   58855             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   58856             : // obviously imply C++.
   58857             : 
   58858             : // This implements the support within ROSE for memory pools.  Memory pools
   58859             : // support the most condensed usage of memory within the construction of
   58860             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   58861             : // by a new operator written for each class.
   58862             : 
   58863             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   58864             :     // User wants multi-thread support and POSIX threads are available.
   58865             : #   include <pthread.h>
   58866             :     static pthread_mutex_t SgOmpUsesAllocatorsClause_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   58867             : #else
   58868             :      // Cause synchronization to be skipped.
   58869             : #    ifndef ALLOC_MUTEX
   58870             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   58871             : #    endif
   58872             : #    ifdef _REENTRANT
   58873             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   58874             : #       ifdef _MSC_VER
   58875             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   58876             : #       else
   58877             : #           warning "POSIX threads are not available; synchronization being skipped"
   58878             : #       endif
   58879             : #    endif
   58880             : #endif
   58881             : 
   58882             : #ifndef ROSE_ALLOC_TRACE
   58883             : #  define ROSE_ALLOC_TRACE 0
   58884             : #endif
   58885             : 
   58886             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   58887             : #define ROSE_ALLOC_TRACE_CNT
   58888             : #include "memory-pool-snapshot.h"
   58889             : unsigned long alloc_trace_cnt = 0;
   58890             : #endif
   58891             : 
   58892             : #if ROSE_ALLOC_TRACE
   58893             : const unsigned SgOmpUsesAllocatorsClause::pool_size = 5;
   58894             : #else
   58895             : const unsigned SgOmpUsesAllocatorsClause::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   58896             : #endif
   58897             : 
   58898             : #ifndef ROSE_ALLOC_MEMSET
   58899             : #  define ROSE_ALLOC_MEMSET 0
   58900             : #endif
   58901             : 
   58902             : #ifndef ROSE_PEDANTIC_ALLOC
   58903             : #  define ROSE_PEDANTIC_ALLOC 0
   58904             : #endif
   58905             : 
   58906             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   58907             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   58908             : #endif
   58909             : 
   58910             : #if !defined(SGNODE__ALL_POOLS)
   58911             : #define SGNODE__ALL_POOLS
   58912             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   58913             : #endif
   58914             : 
   58915             : SgOmpUsesAllocatorsClause* SgOmpUsesAllocatorsClause::next_node = nullptr;
   58916             : std::vector<unsigned char*> SgOmpUsesAllocatorsClause::pools;
   58917             : 
   58918             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   58919             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   58920             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   58921             : // around this macro definition rather than each use).
   58922             : #ifndef ALLOC_MUTEX
   58923             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   58924             :         do {                                                                     \
   58925             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   58926             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   58927             :                 abort();                                                         \
   58928             :             }                                                                    \
   58929             :         } while (0);
   58930             : #endif
   58931             : 
   58932             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   58933             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   58934             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   58935             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   58936             : 
   58937             : /*! \brief New operator for SgOmpUsesAllocatorsClause.
   58938             : 
   58939             :    This new operator implements memory pools to provide most efficent 
   58940             :    use of the heap within construction of large ASTs.
   58941             : 
   58942             : \internal The new and delete operators use the lower level C malloc/free
   58943             :    function calls for performance and to make sure that mixing of malloc/free
   58944             :    and new/delete by the used can be caught more readily.  This may change
   58945             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   58946             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   58947             :    deallocate memory allocated using ROSE_MALLOC.
   58948             : */
   58949           1 : void *SgOmpUsesAllocatorsClause::operator new ( size_t Size )
   58950             : {
   58951             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   58952             :      * returning or throwing an exception. */
   58953           1 :     ALLOC_MUTEX(SgOmpUsesAllocatorsClause, lock);
   58954             : 
   58955             : #if ROSE_ALLOC_TRACE == 2
   58956             : //    printf("SgOmpUsesAllocatorsClause::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgOmpUsesAllocatorsClause::next_node);
   58957             : #endif
   58958             : 
   58959             : #if USE_CPP_NEW_DELETE_OPERATORS
   58960             :     void *mem = ROSE_MALLOC(Size);
   58961             :     ALLOC_MUTEX(SgOmpUsesAllocatorsClause, unlock);
   58962             :     return mem;
   58963             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   58964             : #if ROSE_PEDANTIC_ALLOC
   58965             :     ROSE_ASSERT(Size == sizeof(SgOmpUsesAllocatorsClause));
   58966             : #else
   58967           1 :     if (Size != sizeof(SgOmpUsesAllocatorsClause)) {
   58968           0 :       void * object = ROSE_MALLOC(Size);
   58969           0 :       ALLOC_MUTEX(SgOmpUsesAllocatorsClause, unlock);
   58970             :       return object;
   58971             :     }
   58972             : #endif
   58973             : 
   58974           1 :     if (SgOmpUsesAllocatorsClause::next_node == nullptr) {
   58975           1 :         SgOmpUsesAllocatorsClause * alloc = (SgOmpUsesAllocatorsClause*) ROSE_MALLOC ( SgOmpUsesAllocatorsClause::pool_size * sizeof(SgOmpUsesAllocatorsClause) );
   58976           1 :         ROSE_ASSERT(alloc != nullptr);
   58977             : 
   58978             : #if ROSE_ALLOC_TRACE == 2
   58979             : //        printf("SgOmpUsesAllocatorsClause::alloc\n  block[%zi] = [ %p , %p [\n", SgOmpUsesAllocatorsClause::pools.size(), alloc, alloc + SgOmpUsesAllocatorsClause::pool_size);
   58980             : #endif
   58981             : 
   58982             : #if ROSE_ALLOC_MEMSET == 1
   58983             : #elif ROSE_ALLOC_MEMSET == 2
   58984             :         memset(alloc, 0x00, SgOmpUsesAllocatorsClause::pool_size * sizeof(SgOmpUsesAllocatorsClause));
   58985             : #elif ROSE_ALLOC_MEMSET == 3
   58986             :         memset(alloc, 0xAA, SgOmpUsesAllocatorsClause::pool_size * sizeof(SgOmpUsesAllocatorsClause));
   58987             : #endif
   58988        2000 :         for (unsigned i=0; i < SgOmpUsesAllocatorsClause::pool_size-1; i++) {
   58989        1999 :           alloc[i].p_freepointer = &(alloc[i+1]);
   58990             :         }
   58991           1 :         alloc[SgOmpUsesAllocatorsClause::pool_size-1].p_freepointer = nullptr;
   58992             : 
   58993           1 :         SgOmpUsesAllocatorsClause::pools.push_back ( (unsigned char *) alloc );
   58994           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgOmpUsesAllocatorsClause::pool_size * sizeof(SgOmpUsesAllocatorsClause), V_SgOmpUsesAllocatorsClause ) );
   58995           1 :         SgOmpUsesAllocatorsClause::next_node = alloc;
   58996             :     }
   58997           1 :     ROSE_ASSERT(SgOmpUsesAllocatorsClause::next_node != nullptr);
   58998             : 
   58999           1 :     SgOmpUsesAllocatorsClause * object = SgOmpUsesAllocatorsClause::next_node;
   59000           1 :     SgOmpUsesAllocatorsClause::next_node = (SgOmpUsesAllocatorsClause*)(object->p_freepointer);
   59001             : 
   59002             : #if ROSE_ALLOC_TRACE == 2
   59003             :     printf("SgOmpUsesAllocatorsClause::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpUsesAllocatorsClause::next_node);
   59004             : #endif
   59005             : 
   59006           1 :     SgNode * fp = object->p_freepointer;
   59007             : #if ROSE_ALLOC_MEMSET == 1
   59008             : #elif ROSE_ALLOC_MEMSET == 2
   59009             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpUsesAllocatorsClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   59010             : #elif ROSE_ALLOC_MEMSET == 3
   59011             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgOmpUsesAllocatorsClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   59012             : #endif
   59013           1 :     object->p_freepointer = fp;
   59014             : 
   59015             : #if ROSE_ALLOC_TRACE == 2
   59016             : //    printf("SgOmpUsesAllocatorsClause::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpUsesAllocatorsClause::next_node);
   59017             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   59018             :     Rose::MemPool::snapshot(oss.str());
   59019             :     alloc_trace_cnt++;
   59020             : #endif
   59021             : 
   59022           1 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   59023             : 
   59024           1 :     ALLOC_MUTEX(SgOmpUsesAllocatorsClause, unlock);
   59025             : 
   59026             :     return object;
   59027             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   59028             : }
   59029             : 
   59030             : 
   59031             : 
   59032             : /*! \brief Delete operator for SgOmpUsesAllocatorsClause.
   59033             : 
   59034             :    This delete operator implements deallocation using memory pools to 
   59035             :    provide most efficent use of the heap within construction of large ASTs.
   59036             : 
   59037             : \internal The new and delete operators use the lower level C malloc/free
   59038             :    function calls for performance and to make sure that mixing of malloc/free
   59039             :    and new/delete by the used can be caught more readily.  This may change
   59040             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   59041             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   59042             :    deallocate memory allocated using ROSE_MALLOC.
   59043             : */
   59044           0 : void SgOmpUsesAllocatorsClause::operator delete(void *Pointer, size_t Size)
   59045             : {
   59046             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   59047             :      * or throwing an exception. */
   59048           0 :     ALLOC_MUTEX(SgOmpUsesAllocatorsClause, lock);
   59049             : 
   59050             : #if USE_CPP_NEW_DELETE_OPERATORS
   59051             :     ROSE_FREE(Pointer);
   59052             : #else
   59053             : #if ROSE_PEDANTIC_ALLOC
   59054             :     ROSE_ASSERT(Size == sizeof(SgOmpUsesAllocatorsClause));
   59055             : #else
   59056           0 :     if (Size != sizeof(SgOmpUsesAllocatorsClause)) {
   59057           0 :       ROSE_FREE(Pointer);
   59058           0 :       ALLOC_MUTEX(SgOmpUsesAllocatorsClause, unlock);
   59059             :       return;
   59060             :     }
   59061             : #endif
   59062             : 
   59063           0 :     SgOmpUsesAllocatorsClause * object = (SgOmpUsesAllocatorsClause*) Pointer;
   59064           0 :     ROSE_ASSERT(object != nullptr);
   59065             : 
   59066             : #if ROSE_ALLOC_TRACE == 2
   59067             : //  printf("SgOmpUsesAllocatorsClause::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpUsesAllocatorsClause::next_node);
   59068             :     printf("SgOmpUsesAllocatorsClause::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpUsesAllocatorsClause::next_node);
   59069             : #endif
   59070             : 
   59071             : #if ROSE_PEDANTIC_ALLOC
   59072             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   59073             : #endif
   59074             : 
   59075             : #if ROSE_ALLOC_MEMSET == 1
   59076             : #elif ROSE_ALLOC_MEMSET == 2
   59077             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpUsesAllocatorsClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   59078             : #elif ROSE_ALLOC_MEMSET == 3
   59079             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgOmpUsesAllocatorsClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   59080             : #endif
   59081             : 
   59082             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   59083             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   59084             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   59085             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   59086             : #else
   59087           0 :     object->p_freepointer = SgOmpUsesAllocatorsClause::next_node;
   59088           0 :     SgOmpUsesAllocatorsClause::next_node = object;
   59089             : #endif
   59090             : 
   59091             : #if ROSE_ALLOC_TRACE == 2
   59092             : //  printf("SgOmpUsesAllocatorsClause::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpUsesAllocatorsClause::next_node);
   59093             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   59094             :     Rose::MemPool::snapshot(oss.str());
   59095             :     alloc_trace_cnt++;
   59096             : #endif
   59097             : 
   59098             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   59099             : 
   59100           0 :     ALLOC_MUTEX(SgOmpUsesAllocatorsClause, unlock);
   59101             : }
   59102             : 
   59103             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   59104             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   59105             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   59106             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   59107             : // Also, note comment below from Robb (copied from the Common.code file).
   59108             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   59109             : //
   59110             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   59111             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   59112             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   59113             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   59114             : #if 0
   59115             : void SgOmpUsesAllocatorsClause::operator delete(void* pointer) { SgOmpUsesAllocatorsClause::operator delete (pointer, sizeof(SgOmpUsesAllocatorsClause)); };
   59116             : #endif
   59117             : /* #line 59118 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   59118             : 
   59119             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   59120             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   59121             : // obviously imply C++.
   59122             : 
   59123             : // This implements the support within ROSE for memory pools.  Memory pools
   59124             : // support the most condensed usage of memory within the construction of
   59125             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   59126             : // by a new operator written for each class.
   59127             : 
   59128             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   59129             :     // User wants multi-thread support and POSIX threads are available.
   59130             : #   include <pthread.h>
   59131             :     static pthread_mutex_t SgOmpFullClause_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   59132             : #else
   59133             :      // Cause synchronization to be skipped.
   59134             : #    ifndef ALLOC_MUTEX
   59135             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   59136             : #    endif
   59137             : #    ifdef _REENTRANT
   59138             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   59139             : #       ifdef _MSC_VER
   59140             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   59141             : #       else
   59142             : #           warning "POSIX threads are not available; synchronization being skipped"
   59143             : #       endif
   59144             : #    endif
   59145             : #endif
   59146             : 
   59147             : #ifndef ROSE_ALLOC_TRACE
   59148             : #  define ROSE_ALLOC_TRACE 0
   59149             : #endif
   59150             : 
   59151             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   59152             : #define ROSE_ALLOC_TRACE_CNT
   59153             : #include "memory-pool-snapshot.h"
   59154             : unsigned long alloc_trace_cnt = 0;
   59155             : #endif
   59156             : 
   59157             : #if ROSE_ALLOC_TRACE
   59158             : const unsigned SgOmpFullClause::pool_size = 5;
   59159             : #else
   59160             : const unsigned SgOmpFullClause::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   59161             : #endif
   59162             : 
   59163             : #ifndef ROSE_ALLOC_MEMSET
   59164             : #  define ROSE_ALLOC_MEMSET 0
   59165             : #endif
   59166             : 
   59167             : #ifndef ROSE_PEDANTIC_ALLOC
   59168             : #  define ROSE_PEDANTIC_ALLOC 0
   59169             : #endif
   59170             : 
   59171             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   59172             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   59173             : #endif
   59174             : 
   59175             : #if !defined(SGNODE__ALL_POOLS)
   59176             : #define SGNODE__ALL_POOLS
   59177             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   59178             : #endif
   59179             : 
   59180             : SgOmpFullClause* SgOmpFullClause::next_node = nullptr;
   59181             : std::vector<unsigned char*> SgOmpFullClause::pools;
   59182             : 
   59183             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   59184             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   59185             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   59186             : // around this macro definition rather than each use).
   59187             : #ifndef ALLOC_MUTEX
   59188             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   59189             :         do {                                                                     \
   59190             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   59191             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   59192             :                 abort();                                                         \
   59193             :             }                                                                    \
   59194             :         } while (0);
   59195             : #endif
   59196             : 
   59197             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   59198             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   59199             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   59200             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   59201             : 
   59202             : /*! \brief New operator for SgOmpFullClause.
   59203             : 
   59204             :    This new operator implements memory pools to provide most efficent 
   59205             :    use of the heap within construction of large ASTs.
   59206             : 
   59207             : \internal The new and delete operators use the lower level C malloc/free
   59208             :    function calls for performance and to make sure that mixing of malloc/free
   59209             :    and new/delete by the used can be caught more readily.  This may change
   59210             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   59211             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   59212             :    deallocate memory allocated using ROSE_MALLOC.
   59213             : */
   59214           0 : void *SgOmpFullClause::operator new ( size_t Size )
   59215             : {
   59216             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   59217             :      * returning or throwing an exception. */
   59218           0 :     ALLOC_MUTEX(SgOmpFullClause, lock);
   59219             : 
   59220             : #if ROSE_ALLOC_TRACE == 2
   59221             : //    printf("SgOmpFullClause::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgOmpFullClause::next_node);
   59222             : #endif
   59223             : 
   59224             : #if USE_CPP_NEW_DELETE_OPERATORS
   59225             :     void *mem = ROSE_MALLOC(Size);
   59226             :     ALLOC_MUTEX(SgOmpFullClause, unlock);
   59227             :     return mem;
   59228             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   59229             : #if ROSE_PEDANTIC_ALLOC
   59230             :     ROSE_ASSERT(Size == sizeof(SgOmpFullClause));
   59231             : #else
   59232           0 :     if (Size != sizeof(SgOmpFullClause)) {
   59233           0 :       void * object = ROSE_MALLOC(Size);
   59234           0 :       ALLOC_MUTEX(SgOmpFullClause, unlock);
   59235             :       return object;
   59236             :     }
   59237             : #endif
   59238             : 
   59239           0 :     if (SgOmpFullClause::next_node == nullptr) {
   59240           0 :         SgOmpFullClause * alloc = (SgOmpFullClause*) ROSE_MALLOC ( SgOmpFullClause::pool_size * sizeof(SgOmpFullClause) );
   59241           0 :         ROSE_ASSERT(alloc != nullptr);
   59242             : 
   59243             : #if ROSE_ALLOC_TRACE == 2
   59244             : //        printf("SgOmpFullClause::alloc\n  block[%zi] = [ %p , %p [\n", SgOmpFullClause::pools.size(), alloc, alloc + SgOmpFullClause::pool_size);
   59245             : #endif
   59246             : 
   59247             : #if ROSE_ALLOC_MEMSET == 1
   59248             : #elif ROSE_ALLOC_MEMSET == 2
   59249             :         memset(alloc, 0x00, SgOmpFullClause::pool_size * sizeof(SgOmpFullClause));
   59250             : #elif ROSE_ALLOC_MEMSET == 3
   59251             :         memset(alloc, 0xAA, SgOmpFullClause::pool_size * sizeof(SgOmpFullClause));
   59252             : #endif
   59253           0 :         for (unsigned i=0; i < SgOmpFullClause::pool_size-1; i++) {
   59254           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
   59255             :         }
   59256           0 :         alloc[SgOmpFullClause::pool_size-1].p_freepointer = nullptr;
   59257             : 
   59258           0 :         SgOmpFullClause::pools.push_back ( (unsigned char *) alloc );
   59259           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgOmpFullClause::pool_size * sizeof(SgOmpFullClause), V_SgOmpFullClause ) );
   59260           0 :         SgOmpFullClause::next_node = alloc;
   59261             :     }
   59262           0 :     ROSE_ASSERT(SgOmpFullClause::next_node != nullptr);
   59263             : 
   59264           0 :     SgOmpFullClause * object = SgOmpFullClause::next_node;
   59265           0 :     SgOmpFullClause::next_node = (SgOmpFullClause*)(object->p_freepointer);
   59266             : 
   59267             : #if ROSE_ALLOC_TRACE == 2
   59268             :     printf("SgOmpFullClause::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpFullClause::next_node);
   59269             : #endif
   59270             : 
   59271           0 :     SgNode * fp = object->p_freepointer;
   59272             : #if ROSE_ALLOC_MEMSET == 1
   59273             : #elif ROSE_ALLOC_MEMSET == 2
   59274             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpFullClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   59275             : #elif ROSE_ALLOC_MEMSET == 3
   59276             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgOmpFullClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   59277             : #endif
   59278           0 :     object->p_freepointer = fp;
   59279             : 
   59280             : #if ROSE_ALLOC_TRACE == 2
   59281             : //    printf("SgOmpFullClause::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpFullClause::next_node);
   59282             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   59283             :     Rose::MemPool::snapshot(oss.str());
   59284             :     alloc_trace_cnt++;
   59285             : #endif
   59286             : 
   59287           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   59288             : 
   59289           0 :     ALLOC_MUTEX(SgOmpFullClause, unlock);
   59290             : 
   59291             :     return object;
   59292             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   59293             : }
   59294             : 
   59295             : 
   59296             : 
   59297             : /*! \brief Delete operator for SgOmpFullClause.
   59298             : 
   59299             :    This delete operator implements deallocation using memory pools to 
   59300             :    provide most efficent use of the heap within construction of large ASTs.
   59301             : 
   59302             : \internal The new and delete operators use the lower level C malloc/free
   59303             :    function calls for performance and to make sure that mixing of malloc/free
   59304             :    and new/delete by the used can be caught more readily.  This may change
   59305             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   59306             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   59307             :    deallocate memory allocated using ROSE_MALLOC.
   59308             : */
   59309           0 : void SgOmpFullClause::operator delete(void *Pointer, size_t Size)
   59310             : {
   59311             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   59312             :      * or throwing an exception. */
   59313           0 :     ALLOC_MUTEX(SgOmpFullClause, lock);
   59314             : 
   59315             : #if USE_CPP_NEW_DELETE_OPERATORS
   59316             :     ROSE_FREE(Pointer);
   59317             : #else
   59318             : #if ROSE_PEDANTIC_ALLOC
   59319             :     ROSE_ASSERT(Size == sizeof(SgOmpFullClause));
   59320             : #else
   59321           0 :     if (Size != sizeof(SgOmpFullClause)) {
   59322           0 :       ROSE_FREE(Pointer);
   59323           0 :       ALLOC_MUTEX(SgOmpFullClause, unlock);
   59324             :       return;
   59325             :     }
   59326             : #endif
   59327             : 
   59328           0 :     SgOmpFullClause * object = (SgOmpFullClause*) Pointer;
   59329           0 :     ROSE_ASSERT(object != nullptr);
   59330             : 
   59331             : #if ROSE_ALLOC_TRACE == 2
   59332             : //  printf("SgOmpFullClause::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpFullClause::next_node);
   59333             :     printf("SgOmpFullClause::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpFullClause::next_node);
   59334             : #endif
   59335             : 
   59336             : #if ROSE_PEDANTIC_ALLOC
   59337             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   59338             : #endif
   59339             : 
   59340             : #if ROSE_ALLOC_MEMSET == 1
   59341             : #elif ROSE_ALLOC_MEMSET == 2
   59342             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpFullClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   59343             : #elif ROSE_ALLOC_MEMSET == 3
   59344             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgOmpFullClause) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   59345             : #endif
   59346             : 
   59347             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   59348             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   59349             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   59350             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   59351             : #else
   59352           0 :     object->p_freepointer = SgOmpFullClause::next_node;
   59353           0 :     SgOmpFullClause::next_node = object;
   59354             : #endif
   59355             : 
   59356             : #if ROSE_ALLOC_TRACE == 2
   59357             : //  printf("SgOmpFullClause::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpFullClause::next_node);
   59358             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   59359             :     Rose::MemPool::snapshot(oss.str());
   59360             :     alloc_trace_cnt++;
   59361             : #endif
   59362             : 
   59363             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   59364             : 
   59365           0 :     ALLOC_MUTEX(SgOmpFullClause, unlock);
   59366             : }
   59367             : 
   59368             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   59369             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   59370             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   59371             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   59372             : // Also, note comment below from Robb (copied from the Common.code file).
   59373             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   59374             : //
   59375             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   59376             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   59377             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   59378             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   59379             : #if 0
   59380             : void SgOmpFullClause::operator delete(void* pointer) { SgOmpFullClause::operator delete (pointer, sizeof(SgOmpFullClause)); };
   59381             : #endif
   59382             : /* #line 59383 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   59383             : 
   59384             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   59385             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   59386             : // obviously imply C++.
   59387             : 
   59388             : // This implements the support within ROSE for memory pools.  Memory pools
   59389             : // support the most condensed usage of memory within the construction of
   59390             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   59391             : // by a new operator written for each class.
   59392             : 
   59393             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   59394             :     // User wants multi-thread support and POSIX threads are available.
   59395             : #   include <pthread.h>
   59396             :     static pthread_mutex_t SgUpirBranchField_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   59397             : #else
   59398             :      // Cause synchronization to be skipped.
   59399             : #    ifndef ALLOC_MUTEX
   59400             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   59401             : #    endif
   59402             : #    ifdef _REENTRANT
   59403             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   59404             : #       ifdef _MSC_VER
   59405             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   59406             : #       else
   59407             : #           warning "POSIX threads are not available; synchronization being skipped"
   59408             : #       endif
   59409             : #    endif
   59410             : #endif
   59411             : 
   59412             : #ifndef ROSE_ALLOC_TRACE
   59413             : #  define ROSE_ALLOC_TRACE 0
   59414             : #endif
   59415             : 
   59416             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   59417             : #define ROSE_ALLOC_TRACE_CNT
   59418             : #include "memory-pool-snapshot.h"
   59419             : unsigned long alloc_trace_cnt = 0;
   59420             : #endif
   59421             : 
   59422             : #if ROSE_ALLOC_TRACE
   59423             : const unsigned SgUpirBranchField::pool_size = 5;
   59424             : #else
   59425             : const unsigned SgUpirBranchField::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   59426             : #endif
   59427             : 
   59428             : #ifndef ROSE_ALLOC_MEMSET
   59429             : #  define ROSE_ALLOC_MEMSET 0
   59430             : #endif
   59431             : 
   59432             : #ifndef ROSE_PEDANTIC_ALLOC
   59433             : #  define ROSE_PEDANTIC_ALLOC 0
   59434             : #endif
   59435             : 
   59436             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   59437             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   59438             : #endif
   59439             : 
   59440             : #if !defined(SGNODE__ALL_POOLS)
   59441             : #define SGNODE__ALL_POOLS
   59442             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   59443             : #endif
   59444             : 
   59445             : SgUpirBranchField* SgUpirBranchField::next_node = nullptr;
   59446             : std::vector<unsigned char*> SgUpirBranchField::pools;
   59447             : 
   59448             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   59449             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   59450             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   59451             : // around this macro definition rather than each use).
   59452             : #ifndef ALLOC_MUTEX
   59453             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   59454             :         do {                                                                     \
   59455             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   59456             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   59457             :                 abort();                                                         \
   59458             :             }                                                                    \
   59459             :         } while (0);
   59460             : #endif
   59461             : 
   59462             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   59463             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   59464             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   59465             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   59466             : 
   59467             : /*! \brief New operator for SgUpirBranchField.
   59468             : 
   59469             :    This new operator implements memory pools to provide most efficent 
   59470             :    use of the heap within construction of large ASTs.
   59471             : 
   59472             : \internal The new and delete operators use the lower level C malloc/free
   59473             :    function calls for performance and to make sure that mixing of malloc/free
   59474             :    and new/delete by the used can be caught more readily.  This may change
   59475             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   59476             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   59477             :    deallocate memory allocated using ROSE_MALLOC.
   59478             : */
   59479           0 : void *SgUpirBranchField::operator new ( size_t Size )
   59480             : {
   59481             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   59482             :      * returning or throwing an exception. */
   59483           0 :     ALLOC_MUTEX(SgUpirBranchField, lock);
   59484             : 
   59485             : #if ROSE_ALLOC_TRACE == 2
   59486             : //    printf("SgUpirBranchField::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgUpirBranchField::next_node);
   59487             : #endif
   59488             : 
   59489             : #if USE_CPP_NEW_DELETE_OPERATORS
   59490             :     void *mem = ROSE_MALLOC(Size);
   59491             :     ALLOC_MUTEX(SgUpirBranchField, unlock);
   59492             :     return mem;
   59493             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   59494             : #if ROSE_PEDANTIC_ALLOC
   59495             :     ROSE_ASSERT(Size == sizeof(SgUpirBranchField));
   59496             : #else
   59497           0 :     if (Size != sizeof(SgUpirBranchField)) {
   59498           0 :       void * object = ROSE_MALLOC(Size);
   59499           0 :       ALLOC_MUTEX(SgUpirBranchField, unlock);
   59500             :       return object;
   59501             :     }
   59502             : #endif
   59503             : 
   59504           0 :     if (SgUpirBranchField::next_node == nullptr) {
   59505           0 :         SgUpirBranchField * alloc = (SgUpirBranchField*) ROSE_MALLOC ( SgUpirBranchField::pool_size * sizeof(SgUpirBranchField) );
   59506           0 :         ROSE_ASSERT(alloc != nullptr);
   59507             : 
   59508             : #if ROSE_ALLOC_TRACE == 2
   59509             : //        printf("SgUpirBranchField::alloc\n  block[%zi] = [ %p , %p [\n", SgUpirBranchField::pools.size(), alloc, alloc + SgUpirBranchField::pool_size);
   59510             : #endif
   59511             : 
   59512             : #if ROSE_ALLOC_MEMSET == 1
   59513             : #elif ROSE_ALLOC_MEMSET == 2
   59514             :         memset(alloc, 0x00, SgUpirBranchField::pool_size * sizeof(SgUpirBranchField));
   59515             : #elif ROSE_ALLOC_MEMSET == 3
   59516             :         memset(alloc, 0xAA, SgUpirBranchField::pool_size * sizeof(SgUpirBranchField));
   59517             : #endif
   59518           0 :         for (unsigned i=0; i < SgUpirBranchField::pool_size-1; i++) {
   59519           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
   59520             :         }
   59521           0 :         alloc[SgUpirBranchField::pool_size-1].p_freepointer = nullptr;
   59522             : 
   59523           0 :         SgUpirBranchField::pools.push_back ( (unsigned char *) alloc );
   59524           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgUpirBranchField::pool_size * sizeof(SgUpirBranchField), V_SgUpirBranchField ) );
   59525           0 :         SgUpirBranchField::next_node = alloc;
   59526             :     }
   59527           0 :     ROSE_ASSERT(SgUpirBranchField::next_node != nullptr);
   59528             : 
   59529           0 :     SgUpirBranchField * object = SgUpirBranchField::next_node;
   59530           0 :     SgUpirBranchField::next_node = (SgUpirBranchField*)(object->p_freepointer);
   59531             : 
   59532             : #if ROSE_ALLOC_TRACE == 2
   59533             :     printf("SgUpirBranchField::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUpirBranchField::next_node);
   59534             : #endif
   59535             : 
   59536           0 :     SgNode * fp = object->p_freepointer;
   59537             : #if ROSE_ALLOC_MEMSET == 1
   59538             : #elif ROSE_ALLOC_MEMSET == 2
   59539             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgUpirBranchField) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   59540             : #elif ROSE_ALLOC_MEMSET == 3
   59541             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgUpirBranchField) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   59542             : #endif
   59543           0 :     object->p_freepointer = fp;
   59544             : 
   59545             : #if ROSE_ALLOC_TRACE == 2
   59546             : //    printf("SgUpirBranchField::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUpirBranchField::next_node);
   59547             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   59548             :     Rose::MemPool::snapshot(oss.str());
   59549             :     alloc_trace_cnt++;
   59550             : #endif
   59551             : 
   59552           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   59553             : 
   59554           0 :     ALLOC_MUTEX(SgUpirBranchField, unlock);
   59555             : 
   59556             :     return object;
   59557             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   59558             : }
   59559             : 
   59560             : 
   59561             : 
   59562             : /*! \brief Delete operator for SgUpirBranchField.
   59563             : 
   59564             :    This delete operator implements deallocation using memory pools to 
   59565             :    provide most efficent use of the heap within construction of large ASTs.
   59566             : 
   59567             : \internal The new and delete operators use the lower level C malloc/free
   59568             :    function calls for performance and to make sure that mixing of malloc/free
   59569             :    and new/delete by the used can be caught more readily.  This may change
   59570             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   59571             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   59572             :    deallocate memory allocated using ROSE_MALLOC.
   59573             : */
   59574           0 : void SgUpirBranchField::operator delete(void *Pointer, size_t Size)
   59575             : {
   59576             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   59577             :      * or throwing an exception. */
   59578           0 :     ALLOC_MUTEX(SgUpirBranchField, lock);
   59579             : 
   59580             : #if USE_CPP_NEW_DELETE_OPERATORS
   59581             :     ROSE_FREE(Pointer);
   59582             : #else
   59583             : #if ROSE_PEDANTIC_ALLOC
   59584             :     ROSE_ASSERT(Size == sizeof(SgUpirBranchField));
   59585             : #else
   59586           0 :     if (Size != sizeof(SgUpirBranchField)) {
   59587           0 :       ROSE_FREE(Pointer);
   59588           0 :       ALLOC_MUTEX(SgUpirBranchField, unlock);
   59589             :       return;
   59590             :     }
   59591             : #endif
   59592             : 
   59593           0 :     SgUpirBranchField * object = (SgUpirBranchField*) Pointer;
   59594           0 :     ROSE_ASSERT(object != nullptr);
   59595             : 
   59596             : #if ROSE_ALLOC_TRACE == 2
   59597             : //  printf("SgUpirBranchField::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUpirBranchField::next_node);
   59598             :     printf("SgUpirBranchField::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUpirBranchField::next_node);
   59599             : #endif
   59600             : 
   59601             : #if ROSE_PEDANTIC_ALLOC
   59602             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   59603             : #endif
   59604             : 
   59605             : #if ROSE_ALLOC_MEMSET == 1
   59606             : #elif ROSE_ALLOC_MEMSET == 2
   59607             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgUpirBranchField) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   59608             : #elif ROSE_ALLOC_MEMSET == 3
   59609             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgUpirBranchField) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   59610             : #endif
   59611             : 
   59612             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   59613             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   59614             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   59615             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   59616             : #else
   59617           0 :     object->p_freepointer = SgUpirBranchField::next_node;
   59618           0 :     SgUpirBranchField::next_node = object;
   59619             : #endif
   59620             : 
   59621             : #if ROSE_ALLOC_TRACE == 2
   59622             : //  printf("SgUpirBranchField::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUpirBranchField::next_node);
   59623             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   59624             :     Rose::MemPool::snapshot(oss.str());
   59625             :     alloc_trace_cnt++;
   59626             : #endif
   59627             : 
   59628             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   59629             : 
   59630           0 :     ALLOC_MUTEX(SgUpirBranchField, unlock);
   59631             : }
   59632             : 
   59633             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   59634             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   59635             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   59636             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   59637             : // Also, note comment below from Robb (copied from the Common.code file).
   59638             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   59639             : //
   59640             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   59641             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   59642             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   59643             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   59644             : #if 0
   59645             : void SgUpirBranchField::operator delete(void* pointer) { SgUpirBranchField::operator delete (pointer, sizeof(SgUpirBranchField)); };
   59646             : #endif
   59647             : /* #line 59648 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   59648             : 
   59649             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   59650             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   59651             : // obviously imply C++.
   59652             : 
   59653             : // This implements the support within ROSE for memory pools.  Memory pools
   59654             : // support the most condensed usage of memory within the construction of
   59655             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   59656             : // by a new operator written for each class.
   59657             : 
   59658             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   59659             :     // User wants multi-thread support and POSIX threads are available.
   59660             : #   include <pthread.h>
   59661             :     static pthread_mutex_t SgUpirNestedLevelField_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   59662             : #else
   59663             :      // Cause synchronization to be skipped.
   59664             : #    ifndef ALLOC_MUTEX
   59665             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   59666             : #    endif
   59667             : #    ifdef _REENTRANT
   59668             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   59669             : #       ifdef _MSC_VER
   59670             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   59671             : #       else
   59672             : #           warning "POSIX threads are not available; synchronization being skipped"
   59673             : #       endif
   59674             : #    endif
   59675             : #endif
   59676             : 
   59677             : #ifndef ROSE_ALLOC_TRACE
   59678             : #  define ROSE_ALLOC_TRACE 0
   59679             : #endif
   59680             : 
   59681             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   59682             : #define ROSE_ALLOC_TRACE_CNT
   59683             : #include "memory-pool-snapshot.h"
   59684             : unsigned long alloc_trace_cnt = 0;
   59685             : #endif
   59686             : 
   59687             : #if ROSE_ALLOC_TRACE
   59688             : const unsigned SgUpirNestedLevelField::pool_size = 5;
   59689             : #else
   59690             : const unsigned SgUpirNestedLevelField::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   59691             : #endif
   59692             : 
   59693             : #ifndef ROSE_ALLOC_MEMSET
   59694             : #  define ROSE_ALLOC_MEMSET 0
   59695             : #endif
   59696             : 
   59697             : #ifndef ROSE_PEDANTIC_ALLOC
   59698             : #  define ROSE_PEDANTIC_ALLOC 0
   59699             : #endif
   59700             : 
   59701             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   59702             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   59703             : #endif
   59704             : 
   59705             : #if !defined(SGNODE__ALL_POOLS)
   59706             : #define SGNODE__ALL_POOLS
   59707             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   59708             : #endif
   59709             : 
   59710             : SgUpirNestedLevelField* SgUpirNestedLevelField::next_node = nullptr;
   59711             : std::vector<unsigned char*> SgUpirNestedLevelField::pools;
   59712             : 
   59713             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   59714             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   59715             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   59716             : // around this macro definition rather than each use).
   59717             : #ifndef ALLOC_MUTEX
   59718             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   59719             :         do {                                                                     \
   59720             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   59721             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   59722             :                 abort();                                                         \
   59723             :             }                                                                    \
   59724             :         } while (0);
   59725             : #endif
   59726             : 
   59727             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   59728             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   59729             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   59730             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   59731             : 
   59732             : /*! \brief New operator for SgUpirNestedLevelField.
   59733             : 
   59734             :    This new operator implements memory pools to provide most efficent 
   59735             :    use of the heap within construction of large ASTs.
   59736             : 
   59737             : \internal The new and delete operators use the lower level C malloc/free
   59738             :    function calls for performance and to make sure that mixing of malloc/free
   59739             :    and new/delete by the used can be caught more readily.  This may change
   59740             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   59741             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   59742             :    deallocate memory allocated using ROSE_MALLOC.
   59743             : */
   59744           0 : void *SgUpirNestedLevelField::operator new ( size_t Size )
   59745             : {
   59746             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   59747             :      * returning or throwing an exception. */
   59748           0 :     ALLOC_MUTEX(SgUpirNestedLevelField, lock);
   59749             : 
   59750             : #if ROSE_ALLOC_TRACE == 2
   59751             : //    printf("SgUpirNestedLevelField::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgUpirNestedLevelField::next_node);
   59752             : #endif
   59753             : 
   59754             : #if USE_CPP_NEW_DELETE_OPERATORS
   59755             :     void *mem = ROSE_MALLOC(Size);
   59756             :     ALLOC_MUTEX(SgUpirNestedLevelField, unlock);
   59757             :     return mem;
   59758             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   59759             : #if ROSE_PEDANTIC_ALLOC
   59760             :     ROSE_ASSERT(Size == sizeof(SgUpirNestedLevelField));
   59761             : #else
   59762           0 :     if (Size != sizeof(SgUpirNestedLevelField)) {
   59763           0 :       void * object = ROSE_MALLOC(Size);
   59764           0 :       ALLOC_MUTEX(SgUpirNestedLevelField, unlock);
   59765             :       return object;
   59766             :     }
   59767             : #endif
   59768             : 
   59769           0 :     if (SgUpirNestedLevelField::next_node == nullptr) {
   59770           0 :         SgUpirNestedLevelField * alloc = (SgUpirNestedLevelField*) ROSE_MALLOC ( SgUpirNestedLevelField::pool_size * sizeof(SgUpirNestedLevelField) );
   59771           0 :         ROSE_ASSERT(alloc != nullptr);
   59772             : 
   59773             : #if ROSE_ALLOC_TRACE == 2
   59774             : //        printf("SgUpirNestedLevelField::alloc\n  block[%zi] = [ %p , %p [\n", SgUpirNestedLevelField::pools.size(), alloc, alloc + SgUpirNestedLevelField::pool_size);
   59775             : #endif
   59776             : 
   59777             : #if ROSE_ALLOC_MEMSET == 1
   59778             : #elif ROSE_ALLOC_MEMSET == 2
   59779             :         memset(alloc, 0x00, SgUpirNestedLevelField::pool_size * sizeof(SgUpirNestedLevelField));
   59780             : #elif ROSE_ALLOC_MEMSET == 3
   59781             :         memset(alloc, 0xAA, SgUpirNestedLevelField::pool_size * sizeof(SgUpirNestedLevelField));
   59782             : #endif
   59783           0 :         for (unsigned i=0; i < SgUpirNestedLevelField::pool_size-1; i++) {
   59784           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
   59785             :         }
   59786           0 :         alloc[SgUpirNestedLevelField::pool_size-1].p_freepointer = nullptr;
   59787             : 
   59788           0 :         SgUpirNestedLevelField::pools.push_back ( (unsigned char *) alloc );
   59789           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgUpirNestedLevelField::pool_size * sizeof(SgUpirNestedLevelField), V_SgUpirNestedLevelField ) );
   59790           0 :         SgUpirNestedLevelField::next_node = alloc;
   59791             :     }
   59792           0 :     ROSE_ASSERT(SgUpirNestedLevelField::next_node != nullptr);
   59793             : 
   59794           0 :     SgUpirNestedLevelField * object = SgUpirNestedLevelField::next_node;
   59795           0 :     SgUpirNestedLevelField::next_node = (SgUpirNestedLevelField*)(object->p_freepointer);
   59796             : 
   59797             : #if ROSE_ALLOC_TRACE == 2
   59798             :     printf("SgUpirNestedLevelField::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUpirNestedLevelField::next_node);
   59799             : #endif
   59800             : 
   59801           0 :     SgNode * fp = object->p_freepointer;
   59802             : #if ROSE_ALLOC_MEMSET == 1
   59803             : #elif ROSE_ALLOC_MEMSET == 2
   59804             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgUpirNestedLevelField) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   59805             : #elif ROSE_ALLOC_MEMSET == 3
   59806             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgUpirNestedLevelField) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   59807             : #endif
   59808           0 :     object->p_freepointer = fp;
   59809             : 
   59810             : #if ROSE_ALLOC_TRACE == 2
   59811             : //    printf("SgUpirNestedLevelField::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUpirNestedLevelField::next_node);
   59812             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   59813             :     Rose::MemPool::snapshot(oss.str());
   59814             :     alloc_trace_cnt++;
   59815             : #endif
   59816             : 
   59817           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   59818             : 
   59819           0 :     ALLOC_MUTEX(SgUpirNestedLevelField, unlock);
   59820             : 
   59821             :     return object;
   59822             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   59823             : }
   59824             : 
   59825             : 
   59826             : 
   59827             : /*! \brief Delete operator for SgUpirNestedLevelField.
   59828             : 
   59829             :    This delete operator implements deallocation using memory pools to 
   59830             :    provide most efficent use of the heap within construction of large ASTs.
   59831             : 
   59832             : \internal The new and delete operators use the lower level C malloc/free
   59833             :    function calls for performance and to make sure that mixing of malloc/free
   59834             :    and new/delete by the used can be caught more readily.  This may change
   59835             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   59836             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   59837             :    deallocate memory allocated using ROSE_MALLOC.
   59838             : */
   59839           0 : void SgUpirNestedLevelField::operator delete(void *Pointer, size_t Size)
   59840             : {
   59841             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   59842             :      * or throwing an exception. */
   59843           0 :     ALLOC_MUTEX(SgUpirNestedLevelField, lock);
   59844             : 
   59845             : #if USE_CPP_NEW_DELETE_OPERATORS
   59846             :     ROSE_FREE(Pointer);
   59847             : #else
   59848             : #if ROSE_PEDANTIC_ALLOC
   59849             :     ROSE_ASSERT(Size == sizeof(SgUpirNestedLevelField));
   59850             : #else
   59851           0 :     if (Size != sizeof(SgUpirNestedLevelField)) {
   59852           0 :       ROSE_FREE(Pointer);
   59853           0 :       ALLOC_MUTEX(SgUpirNestedLevelField, unlock);
   59854             :       return;
   59855             :     }
   59856             : #endif
   59857             : 
   59858           0 :     SgUpirNestedLevelField * object = (SgUpirNestedLevelField*) Pointer;
   59859           0 :     ROSE_ASSERT(object != nullptr);
   59860             : 
   59861             : #if ROSE_ALLOC_TRACE == 2
   59862             : //  printf("SgUpirNestedLevelField::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUpirNestedLevelField::next_node);
   59863             :     printf("SgUpirNestedLevelField::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUpirNestedLevelField::next_node);
   59864             : #endif
   59865             : 
   59866             : #if ROSE_PEDANTIC_ALLOC
   59867             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   59868             : #endif
   59869             : 
   59870             : #if ROSE_ALLOC_MEMSET == 1
   59871             : #elif ROSE_ALLOC_MEMSET == 2
   59872             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgUpirNestedLevelField) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   59873             : #elif ROSE_ALLOC_MEMSET == 3
   59874             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgUpirNestedLevelField) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   59875             : #endif
   59876             : 
   59877             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   59878             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   59879             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   59880             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   59881             : #else
   59882           0 :     object->p_freepointer = SgUpirNestedLevelField::next_node;
   59883           0 :     SgUpirNestedLevelField::next_node = object;
   59884             : #endif
   59885             : 
   59886             : #if ROSE_ALLOC_TRACE == 2
   59887             : //  printf("SgUpirNestedLevelField::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUpirNestedLevelField::next_node);
   59888             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   59889             :     Rose::MemPool::snapshot(oss.str());
   59890             :     alloc_trace_cnt++;
   59891             : #endif
   59892             : 
   59893             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   59894             : 
   59895           0 :     ALLOC_MUTEX(SgUpirNestedLevelField, unlock);
   59896             : }
   59897             : 
   59898             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   59899             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   59900             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   59901             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   59902             : // Also, note comment below from Robb (copied from the Common.code file).
   59903             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   59904             : //
   59905             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   59906             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   59907             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   59908             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   59909             : #if 0
   59910             : void SgUpirNestedLevelField::operator delete(void* pointer) { SgUpirNestedLevelField::operator delete (pointer, sizeof(SgUpirNestedLevelField)); };
   59911             : #endif
   59912             : /* #line 59913 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   59913             : 
   59914             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   59915             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   59916             : // obviously imply C++.
   59917             : 
   59918             : // This implements the support within ROSE for memory pools.  Memory pools
   59919             : // support the most condensed usage of memory within the construction of
   59920             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   59921             : // by a new operator written for each class.
   59922             : 
   59923             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   59924             :     // User wants multi-thread support and POSIX threads are available.
   59925             : #   include <pthread.h>
   59926             :     static pthread_mutex_t SgUpirNestedParentField_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   59927             : #else
   59928             :      // Cause synchronization to be skipped.
   59929             : #    ifndef ALLOC_MUTEX
   59930             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   59931             : #    endif
   59932             : #    ifdef _REENTRANT
   59933             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   59934             : #       ifdef _MSC_VER
   59935             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   59936             : #       else
   59937             : #           warning "POSIX threads are not available; synchronization being skipped"
   59938             : #       endif
   59939             : #    endif
   59940             : #endif
   59941             : 
   59942             : #ifndef ROSE_ALLOC_TRACE
   59943             : #  define ROSE_ALLOC_TRACE 0
   59944             : #endif
   59945             : 
   59946             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   59947             : #define ROSE_ALLOC_TRACE_CNT
   59948             : #include "memory-pool-snapshot.h"
   59949             : unsigned long alloc_trace_cnt = 0;
   59950             : #endif
   59951             : 
   59952             : #if ROSE_ALLOC_TRACE
   59953             : const unsigned SgUpirNestedParentField::pool_size = 5;
   59954             : #else
   59955             : const unsigned SgUpirNestedParentField::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   59956             : #endif
   59957             : 
   59958             : #ifndef ROSE_ALLOC_MEMSET
   59959             : #  define ROSE_ALLOC_MEMSET 0
   59960             : #endif
   59961             : 
   59962             : #ifndef ROSE_PEDANTIC_ALLOC
   59963             : #  define ROSE_PEDANTIC_ALLOC 0
   59964             : #endif
   59965             : 
   59966             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   59967             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   59968             : #endif
   59969             : 
   59970             : #if !defined(SGNODE__ALL_POOLS)
   59971             : #define SGNODE__ALL_POOLS
   59972             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   59973             : #endif
   59974             : 
   59975             : SgUpirNestedParentField* SgUpirNestedParentField::next_node = nullptr;
   59976             : std::vector<unsigned char*> SgUpirNestedParentField::pools;
   59977             : 
   59978             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   59979             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   59980             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   59981             : // around this macro definition rather than each use).
   59982             : #ifndef ALLOC_MUTEX
   59983             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   59984             :         do {                                                                     \
   59985             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   59986             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   59987             :                 abort();                                                         \
   59988             :             }                                                                    \
   59989             :         } while (0);
   59990             : #endif
   59991             : 
   59992             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   59993             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   59994             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   59995             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   59996             : 
   59997             : /*! \brief New operator for SgUpirNestedParentField.
   59998             : 
   59999             :    This new operator implements memory pools to provide most efficent 
   60000             :    use of the heap within construction of large ASTs.
   60001             : 
   60002             : \internal The new and delete operators use the lower level C malloc/free
   60003             :    function calls for performance and to make sure that mixing of malloc/free
   60004             :    and new/delete by the used can be caught more readily.  This may change
   60005             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   60006             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   60007             :    deallocate memory allocated using ROSE_MALLOC.
   60008             : */
   60009           0 : void *SgUpirNestedParentField::operator new ( size_t Size )
   60010             : {
   60011             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   60012             :      * returning or throwing an exception. */
   60013           0 :     ALLOC_MUTEX(SgUpirNestedParentField, lock);
   60014             : 
   60015             : #if ROSE_ALLOC_TRACE == 2
   60016             : //    printf("SgUpirNestedParentField::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgUpirNestedParentField::next_node);
   60017             : #endif
   60018             : 
   60019             : #if USE_CPP_NEW_DELETE_OPERATORS
   60020             :     void *mem = ROSE_MALLOC(Size);
   60021             :     ALLOC_MUTEX(SgUpirNestedParentField, unlock);
   60022             :     return mem;
   60023             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   60024             : #if ROSE_PEDANTIC_ALLOC
   60025             :     ROSE_ASSERT(Size == sizeof(SgUpirNestedParentField));
   60026             : #else
   60027           0 :     if (Size != sizeof(SgUpirNestedParentField)) {
   60028           0 :       void * object = ROSE_MALLOC(Size);
   60029           0 :       ALLOC_MUTEX(SgUpirNestedParentField, unlock);
   60030             :       return object;
   60031             :     }
   60032             : #endif
   60033             : 
   60034           0 :     if (SgUpirNestedParentField::next_node == nullptr) {
   60035           0 :         SgUpirNestedParentField * alloc = (SgUpirNestedParentField*) ROSE_MALLOC ( SgUpirNestedParentField::pool_size * sizeof(SgUpirNestedParentField) );
   60036           0 :         ROSE_ASSERT(alloc != nullptr);
   60037             : 
   60038             : #if ROSE_ALLOC_TRACE == 2
   60039             : //        printf("SgUpirNestedParentField::alloc\n  block[%zi] = [ %p , %p [\n", SgUpirNestedParentField::pools.size(), alloc, alloc + SgUpirNestedParentField::pool_size);
   60040             : #endif
   60041             : 
   60042             : #if ROSE_ALLOC_MEMSET == 1
   60043             : #elif ROSE_ALLOC_MEMSET == 2
   60044             :         memset(alloc, 0x00, SgUpirNestedParentField::pool_size * sizeof(SgUpirNestedParentField));
   60045             : #elif ROSE_ALLOC_MEMSET == 3
   60046             :         memset(alloc, 0xAA, SgUpirNestedParentField::pool_size * sizeof(SgUpirNestedParentField));
   60047             : #endif
   60048           0 :         for (unsigned i=0; i < SgUpirNestedParentField::pool_size-1; i++) {
   60049           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
   60050             :         }
   60051           0 :         alloc[SgUpirNestedParentField::pool_size-1].p_freepointer = nullptr;
   60052             : 
   60053           0 :         SgUpirNestedParentField::pools.push_back ( (unsigned char *) alloc );
   60054           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgUpirNestedParentField::pool_size * sizeof(SgUpirNestedParentField), V_SgUpirNestedParentField ) );
   60055           0 :         SgUpirNestedParentField::next_node = alloc;
   60056             :     }
   60057           0 :     ROSE_ASSERT(SgUpirNestedParentField::next_node != nullptr);
   60058             : 
   60059           0 :     SgUpirNestedParentField * object = SgUpirNestedParentField::next_node;
   60060           0 :     SgUpirNestedParentField::next_node = (SgUpirNestedParentField*)(object->p_freepointer);
   60061             : 
   60062             : #if ROSE_ALLOC_TRACE == 2
   60063             :     printf("SgUpirNestedParentField::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUpirNestedParentField::next_node);
   60064             : #endif
   60065             : 
   60066           0 :     SgNode * fp = object->p_freepointer;
   60067             : #if ROSE_ALLOC_MEMSET == 1
   60068             : #elif ROSE_ALLOC_MEMSET == 2
   60069             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgUpirNestedParentField) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   60070             : #elif ROSE_ALLOC_MEMSET == 3
   60071             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgUpirNestedParentField) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   60072             : #endif
   60073           0 :     object->p_freepointer = fp;
   60074             : 
   60075             : #if ROSE_ALLOC_TRACE == 2
   60076             : //    printf("SgUpirNestedParentField::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUpirNestedParentField::next_node);
   60077             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   60078             :     Rose::MemPool::snapshot(oss.str());
   60079             :     alloc_trace_cnt++;
   60080             : #endif
   60081             : 
   60082           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   60083             : 
   60084           0 :     ALLOC_MUTEX(SgUpirNestedParentField, unlock);
   60085             : 
   60086             :     return object;
   60087             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   60088             : }
   60089             : 
   60090             : 
   60091             : 
   60092             : /*! \brief Delete operator for SgUpirNestedParentField.
   60093             : 
   60094             :    This delete operator implements deallocation using memory pools to 
   60095             :    provide most efficent use of the heap within construction of large ASTs.
   60096             : 
   60097             : \internal The new and delete operators use the lower level C malloc/free
   60098             :    function calls for performance and to make sure that mixing of malloc/free
   60099             :    and new/delete by the used can be caught more readily.  This may change
   60100             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   60101             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   60102             :    deallocate memory allocated using ROSE_MALLOC.
   60103             : */
   60104           0 : void SgUpirNestedParentField::operator delete(void *Pointer, size_t Size)
   60105             : {
   60106             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   60107             :      * or throwing an exception. */
   60108           0 :     ALLOC_MUTEX(SgUpirNestedParentField, lock);
   60109             : 
   60110             : #if USE_CPP_NEW_DELETE_OPERATORS
   60111             :     ROSE_FREE(Pointer);
   60112             : #else
   60113             : #if ROSE_PEDANTIC_ALLOC
   60114             :     ROSE_ASSERT(Size == sizeof(SgUpirNestedParentField));
   60115             : #else
   60116           0 :     if (Size != sizeof(SgUpirNestedParentField)) {
   60117           0 :       ROSE_FREE(Pointer);
   60118           0 :       ALLOC_MUTEX(SgUpirNestedParentField, unlock);
   60119             :       return;
   60120             :     }
   60121             : #endif
   60122             : 
   60123           0 :     SgUpirNestedParentField * object = (SgUpirNestedParentField*) Pointer;
   60124           0 :     ROSE_ASSERT(object != nullptr);
   60125             : 
   60126             : #if ROSE_ALLOC_TRACE == 2
   60127             : //  printf("SgUpirNestedParentField::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUpirNestedParentField::next_node);
   60128             :     printf("SgUpirNestedParentField::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUpirNestedParentField::next_node);
   60129             : #endif
   60130             : 
   60131             : #if ROSE_PEDANTIC_ALLOC
   60132             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   60133             : #endif
   60134             : 
   60135             : #if ROSE_ALLOC_MEMSET == 1
   60136             : #elif ROSE_ALLOC_MEMSET == 2
   60137             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgUpirNestedParentField) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   60138             : #elif ROSE_ALLOC_MEMSET == 3
   60139             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgUpirNestedParentField) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   60140             : #endif
   60141             : 
   60142             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   60143             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   60144             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   60145             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   60146             : #else
   60147           0 :     object->p_freepointer = SgUpirNestedParentField::next_node;
   60148           0 :     SgUpirNestedParentField::next_node = object;
   60149             : #endif
   60150             : 
   60151             : #if ROSE_ALLOC_TRACE == 2
   60152             : //  printf("SgUpirNestedParentField::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUpirNestedParentField::next_node);
   60153             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   60154             :     Rose::MemPool::snapshot(oss.str());
   60155             :     alloc_trace_cnt++;
   60156             : #endif
   60157             : 
   60158             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   60159             : 
   60160           0 :     ALLOC_MUTEX(SgUpirNestedParentField, unlock);
   60161             : }
   60162             : 
   60163             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   60164             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   60165             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   60166             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   60167             : // Also, note comment below from Robb (copied from the Common.code file).
   60168             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   60169             : //
   60170             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   60171             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   60172             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   60173             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   60174             : #if 0
   60175             : void SgUpirNestedParentField::operator delete(void* pointer) { SgUpirNestedParentField::operator delete (pointer, sizeof(SgUpirNestedParentField)); };
   60176             : #endif
   60177             : /* #line 60178 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   60178             : 
   60179             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   60180             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   60181             : // obviously imply C++.
   60182             : 
   60183             : // This implements the support within ROSE for memory pools.  Memory pools
   60184             : // support the most condensed usage of memory within the construction of
   60185             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   60186             : // by a new operator written for each class.
   60187             : 
   60188             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   60189             :     // User wants multi-thread support and POSIX threads are available.
   60190             : #   include <pthread.h>
   60191             :     static pthread_mutex_t SgUpirNestedChildField_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   60192             : #else
   60193             :      // Cause synchronization to be skipped.
   60194             : #    ifndef ALLOC_MUTEX
   60195             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   60196             : #    endif
   60197             : #    ifdef _REENTRANT
   60198             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   60199             : #       ifdef _MSC_VER
   60200             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   60201             : #       else
   60202             : #           warning "POSIX threads are not available; synchronization being skipped"
   60203             : #       endif
   60204             : #    endif
   60205             : #endif
   60206             : 
   60207             : #ifndef ROSE_ALLOC_TRACE
   60208             : #  define ROSE_ALLOC_TRACE 0
   60209             : #endif
   60210             : 
   60211             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   60212             : #define ROSE_ALLOC_TRACE_CNT
   60213             : #include "memory-pool-snapshot.h"
   60214             : unsigned long alloc_trace_cnt = 0;
   60215             : #endif
   60216             : 
   60217             : #if ROSE_ALLOC_TRACE
   60218             : const unsigned SgUpirNestedChildField::pool_size = 5;
   60219             : #else
   60220             : const unsigned SgUpirNestedChildField::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   60221             : #endif
   60222             : 
   60223             : #ifndef ROSE_ALLOC_MEMSET
   60224             : #  define ROSE_ALLOC_MEMSET 0
   60225             : #endif
   60226             : 
   60227             : #ifndef ROSE_PEDANTIC_ALLOC
   60228             : #  define ROSE_PEDANTIC_ALLOC 0
   60229             : #endif
   60230             : 
   60231             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   60232             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   60233             : #endif
   60234             : 
   60235             : #if !defined(SGNODE__ALL_POOLS)
   60236             : #define SGNODE__ALL_POOLS
   60237             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   60238             : #endif
   60239             : 
   60240             : SgUpirNestedChildField* SgUpirNestedChildField::next_node = nullptr;
   60241             : std::vector<unsigned char*> SgUpirNestedChildField::pools;
   60242             : 
   60243             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   60244             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   60245             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   60246             : // around this macro definition rather than each use).
   60247             : #ifndef ALLOC_MUTEX
   60248             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   60249             :         do {                                                                     \
   60250             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   60251             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   60252             :                 abort();                                                         \
   60253             :             }                                                                    \
   60254             :         } while (0);
   60255             : #endif
   60256             : 
   60257             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   60258             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   60259             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   60260             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   60261             : 
   60262             : /*! \brief New operator for SgUpirNestedChildField.
   60263             : 
   60264             :    This new operator implements memory pools to provide most efficent 
   60265             :    use of the heap within construction of large ASTs.
   60266             : 
   60267             : \internal The new and delete operators use the lower level C malloc/free
   60268             :    function calls for performance and to make sure that mixing of malloc/free
   60269             :    and new/delete by the used can be caught more readily.  This may change
   60270             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   60271             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   60272             :    deallocate memory allocated using ROSE_MALLOC.
   60273             : */
   60274           0 : void *SgUpirNestedChildField::operator new ( size_t Size )
   60275             : {
   60276             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   60277             :      * returning or throwing an exception. */
   60278           0 :     ALLOC_MUTEX(SgUpirNestedChildField, lock);
   60279             : 
   60280             : #if ROSE_ALLOC_TRACE == 2
   60281             : //    printf("SgUpirNestedChildField::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgUpirNestedChildField::next_node);
   60282             : #endif
   60283             : 
   60284             : #if USE_CPP_NEW_DELETE_OPERATORS
   60285             :     void *mem = ROSE_MALLOC(Size);
   60286             :     ALLOC_MUTEX(SgUpirNestedChildField, unlock);
   60287             :     return mem;
   60288             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   60289             : #if ROSE_PEDANTIC_ALLOC
   60290             :     ROSE_ASSERT(Size == sizeof(SgUpirNestedChildField));
   60291             : #else
   60292           0 :     if (Size != sizeof(SgUpirNestedChildField)) {
   60293           0 :       void * object = ROSE_MALLOC(Size);
   60294           0 :       ALLOC_MUTEX(SgUpirNestedChildField, unlock);
   60295             :       return object;
   60296             :     }
   60297             : #endif
   60298             : 
   60299           0 :     if (SgUpirNestedChildField::next_node == nullptr) {
   60300           0 :         SgUpirNestedChildField * alloc = (SgUpirNestedChildField*) ROSE_MALLOC ( SgUpirNestedChildField::pool_size * sizeof(SgUpirNestedChildField) );
   60301           0 :         ROSE_ASSERT(alloc != nullptr);
   60302             : 
   60303             : #if ROSE_ALLOC_TRACE == 2
   60304             : //        printf("SgUpirNestedChildField::alloc\n  block[%zi] = [ %p , %p [\n", SgUpirNestedChildField::pools.size(), alloc, alloc + SgUpirNestedChildField::pool_size);
   60305             : #endif
   60306             : 
   60307             : #if ROSE_ALLOC_MEMSET == 1
   60308             : #elif ROSE_ALLOC_MEMSET == 2
   60309             :         memset(alloc, 0x00, SgUpirNestedChildField::pool_size * sizeof(SgUpirNestedChildField));
   60310             : #elif ROSE_ALLOC_MEMSET == 3
   60311             :         memset(alloc, 0xAA, SgUpirNestedChildField::pool_size * sizeof(SgUpirNestedChildField));
   60312             : #endif
   60313           0 :         for (unsigned i=0; i < SgUpirNestedChildField::pool_size-1; i++) {
   60314           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
   60315             :         }
   60316           0 :         alloc[SgUpirNestedChildField::pool_size-1].p_freepointer = nullptr;
   60317             : 
   60318           0 :         SgUpirNestedChildField::pools.push_back ( (unsigned char *) alloc );
   60319           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgUpirNestedChildField::pool_size * sizeof(SgUpirNestedChildField), V_SgUpirNestedChildField ) );
   60320           0 :         SgUpirNestedChildField::next_node = alloc;
   60321             :     }
   60322           0 :     ROSE_ASSERT(SgUpirNestedChildField::next_node != nullptr);
   60323             : 
   60324           0 :     SgUpirNestedChildField * object = SgUpirNestedChildField::next_node;
   60325           0 :     SgUpirNestedChildField::next_node = (SgUpirNestedChildField*)(object->p_freepointer);
   60326             : 
   60327             : #if ROSE_ALLOC_TRACE == 2
   60328             :     printf("SgUpirNestedChildField::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUpirNestedChildField::next_node);
   60329             : #endif
   60330             : 
   60331           0 :     SgNode * fp = object->p_freepointer;
   60332             : #if ROSE_ALLOC_MEMSET == 1
   60333             : #elif ROSE_ALLOC_MEMSET == 2
   60334             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgUpirNestedChildField) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   60335             : #elif ROSE_ALLOC_MEMSET == 3
   60336             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgUpirNestedChildField) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   60337             : #endif
   60338           0 :     object->p_freepointer = fp;
   60339             : 
   60340             : #if ROSE_ALLOC_TRACE == 2
   60341             : //    printf("SgUpirNestedChildField::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUpirNestedChildField::next_node);
   60342             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   60343             :     Rose::MemPool::snapshot(oss.str());
   60344             :     alloc_trace_cnt++;
   60345             : #endif
   60346             : 
   60347           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   60348             : 
   60349           0 :     ALLOC_MUTEX(SgUpirNestedChildField, unlock);
   60350             : 
   60351             :     return object;
   60352             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   60353             : }
   60354             : 
   60355             : 
   60356             : 
   60357             : /*! \brief Delete operator for SgUpirNestedChildField.
   60358             : 
   60359             :    This delete operator implements deallocation using memory pools to 
   60360             :    provide most efficent use of the heap within construction of large ASTs.
   60361             : 
   60362             : \internal The new and delete operators use the lower level C malloc/free
   60363             :    function calls for performance and to make sure that mixing of malloc/free
   60364             :    and new/delete by the used can be caught more readily.  This may change
   60365             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   60366             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   60367             :    deallocate memory allocated using ROSE_MALLOC.
   60368             : */
   60369           0 : void SgUpirNestedChildField::operator delete(void *Pointer, size_t Size)
   60370             : {
   60371             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   60372             :      * or throwing an exception. */
   60373           0 :     ALLOC_MUTEX(SgUpirNestedChildField, lock);
   60374             : 
   60375             : #if USE_CPP_NEW_DELETE_OPERATORS
   60376             :     ROSE_FREE(Pointer);
   60377             : #else
   60378             : #if ROSE_PEDANTIC_ALLOC
   60379             :     ROSE_ASSERT(Size == sizeof(SgUpirNestedChildField));
   60380             : #else
   60381           0 :     if (Size != sizeof(SgUpirNestedChildField)) {
   60382           0 :       ROSE_FREE(Pointer);
   60383           0 :       ALLOC_MUTEX(SgUpirNestedChildField, unlock);
   60384             :       return;
   60385             :     }
   60386             : #endif
   60387             : 
   60388           0 :     SgUpirNestedChildField * object = (SgUpirNestedChildField*) Pointer;
   60389           0 :     ROSE_ASSERT(object != nullptr);
   60390             : 
   60391             : #if ROSE_ALLOC_TRACE == 2
   60392             : //  printf("SgUpirNestedChildField::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUpirNestedChildField::next_node);
   60393             :     printf("SgUpirNestedChildField::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUpirNestedChildField::next_node);
   60394             : #endif
   60395             : 
   60396             : #if ROSE_PEDANTIC_ALLOC
   60397             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   60398             : #endif
   60399             : 
   60400             : #if ROSE_ALLOC_MEMSET == 1
   60401             : #elif ROSE_ALLOC_MEMSET == 2
   60402             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgUpirNestedChildField) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   60403             : #elif ROSE_ALLOC_MEMSET == 3
   60404             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgUpirNestedChildField) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   60405             : #endif
   60406             : 
   60407             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   60408             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   60409             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   60410             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   60411             : #else
   60412           0 :     object->p_freepointer = SgUpirNestedChildField::next_node;
   60413           0 :     SgUpirNestedChildField::next_node = object;
   60414             : #endif
   60415             : 
   60416             : #if ROSE_ALLOC_TRACE == 2
   60417             : //  printf("SgUpirNestedChildField::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUpirNestedChildField::next_node);
   60418             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   60419             :     Rose::MemPool::snapshot(oss.str());
   60420             :     alloc_trace_cnt++;
   60421             : #endif
   60422             : 
   60423             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   60424             : 
   60425           0 :     ALLOC_MUTEX(SgUpirNestedChildField, unlock);
   60426             : }
   60427             : 
   60428             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   60429             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   60430             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   60431             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   60432             : // Also, note comment below from Robb (copied from the Common.code file).
   60433             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   60434             : //
   60435             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   60436             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   60437             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   60438             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   60439             : #if 0
   60440             : void SgUpirNestedChildField::operator delete(void* pointer) { SgUpirNestedChildField::operator delete (pointer, sizeof(SgUpirNestedChildField)); };
   60441             : #endif
   60442             : /* #line 60443 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   60443             : 
   60444             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   60445             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   60446             : // obviously imply C++.
   60447             : 
   60448             : // This implements the support within ROSE for memory pools.  Memory pools
   60449             : // support the most condensed usage of memory within the construction of
   60450             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   60451             : // by a new operator written for each class.
   60452             : 
   60453             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   60454             :     // User wants multi-thread support and POSIX threads are available.
   60455             : #   include <pthread.h>
   60456             :     static pthread_mutex_t SgUpirSyncField_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   60457             : #else
   60458             :      // Cause synchronization to be skipped.
   60459             : #    ifndef ALLOC_MUTEX
   60460             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   60461             : #    endif
   60462             : #    ifdef _REENTRANT
   60463             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   60464             : #       ifdef _MSC_VER
   60465             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   60466             : #       else
   60467             : #           warning "POSIX threads are not available; synchronization being skipped"
   60468             : #       endif
   60469             : #    endif
   60470             : #endif
   60471             : 
   60472             : #ifndef ROSE_ALLOC_TRACE
   60473             : #  define ROSE_ALLOC_TRACE 0
   60474             : #endif
   60475             : 
   60476             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   60477             : #define ROSE_ALLOC_TRACE_CNT
   60478             : #include "memory-pool-snapshot.h"
   60479             : unsigned long alloc_trace_cnt = 0;
   60480             : #endif
   60481             : 
   60482             : #if ROSE_ALLOC_TRACE
   60483             : const unsigned SgUpirSyncField::pool_size = 5;
   60484             : #else
   60485             : const unsigned SgUpirSyncField::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   60486             : #endif
   60487             : 
   60488             : #ifndef ROSE_ALLOC_MEMSET
   60489             : #  define ROSE_ALLOC_MEMSET 0
   60490             : #endif
   60491             : 
   60492             : #ifndef ROSE_PEDANTIC_ALLOC
   60493             : #  define ROSE_PEDANTIC_ALLOC 0
   60494             : #endif
   60495             : 
   60496             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   60497             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   60498             : #endif
   60499             : 
   60500             : #if !defined(SGNODE__ALL_POOLS)
   60501             : #define SGNODE__ALL_POOLS
   60502             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   60503             : #endif
   60504             : 
   60505             : SgUpirSyncField* SgUpirSyncField::next_node = nullptr;
   60506             : std::vector<unsigned char*> SgUpirSyncField::pools;
   60507             : 
   60508             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   60509             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   60510             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   60511             : // around this macro definition rather than each use).
   60512             : #ifndef ALLOC_MUTEX
   60513             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   60514             :         do {                                                                     \
   60515             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   60516             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   60517             :                 abort();                                                         \
   60518             :             }                                                                    \
   60519             :         } while (0);
   60520             : #endif
   60521             : 
   60522             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   60523             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   60524             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   60525             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   60526             : 
   60527             : /*! \brief New operator for SgUpirSyncField.
   60528             : 
   60529             :    This new operator implements memory pools to provide most efficent 
   60530             :    use of the heap within construction of large ASTs.
   60531             : 
   60532             : \internal The new and delete operators use the lower level C malloc/free
   60533             :    function calls for performance and to make sure that mixing of malloc/free
   60534             :    and new/delete by the used can be caught more readily.  This may change
   60535             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   60536             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   60537             :    deallocate memory allocated using ROSE_MALLOC.
   60538             : */
   60539           0 : void *SgUpirSyncField::operator new ( size_t Size )
   60540             : {
   60541             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   60542             :      * returning or throwing an exception. */
   60543           0 :     ALLOC_MUTEX(SgUpirSyncField, lock);
   60544             : 
   60545             : #if ROSE_ALLOC_TRACE == 2
   60546             : //    printf("SgUpirSyncField::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgUpirSyncField::next_node);
   60547             : #endif
   60548             : 
   60549             : #if USE_CPP_NEW_DELETE_OPERATORS
   60550             :     void *mem = ROSE_MALLOC(Size);
   60551             :     ALLOC_MUTEX(SgUpirSyncField, unlock);
   60552             :     return mem;
   60553             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   60554             : #if ROSE_PEDANTIC_ALLOC
   60555             :     ROSE_ASSERT(Size == sizeof(SgUpirSyncField));
   60556             : #else
   60557           0 :     if (Size != sizeof(SgUpirSyncField)) {
   60558           0 :       void * object = ROSE_MALLOC(Size);
   60559           0 :       ALLOC_MUTEX(SgUpirSyncField, unlock);
   60560             :       return object;
   60561             :     }
   60562             : #endif
   60563             : 
   60564           0 :     if (SgUpirSyncField::next_node == nullptr) {
   60565           0 :         SgUpirSyncField * alloc = (SgUpirSyncField*) ROSE_MALLOC ( SgUpirSyncField::pool_size * sizeof(SgUpirSyncField) );
   60566           0 :         ROSE_ASSERT(alloc != nullptr);
   60567             : 
   60568             : #if ROSE_ALLOC_TRACE == 2
   60569             : //        printf("SgUpirSyncField::alloc\n  block[%zi] = [ %p , %p [\n", SgUpirSyncField::pools.size(), alloc, alloc + SgUpirSyncField::pool_size);
   60570             : #endif
   60571             : 
   60572             : #if ROSE_ALLOC_MEMSET == 1
   60573             : #elif ROSE_ALLOC_MEMSET == 2
   60574             :         memset(alloc, 0x00, SgUpirSyncField::pool_size * sizeof(SgUpirSyncField));
   60575             : #elif ROSE_ALLOC_MEMSET == 3
   60576             :         memset(alloc, 0xAA, SgUpirSyncField::pool_size * sizeof(SgUpirSyncField));
   60577             : #endif
   60578           0 :         for (unsigned i=0; i < SgUpirSyncField::pool_size-1; i++) {
   60579           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
   60580             :         }
   60581           0 :         alloc[SgUpirSyncField::pool_size-1].p_freepointer = nullptr;
   60582             : 
   60583           0 :         SgUpirSyncField::pools.push_back ( (unsigned char *) alloc );
   60584           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgUpirSyncField::pool_size * sizeof(SgUpirSyncField), V_SgUpirSyncField ) );
   60585           0 :         SgUpirSyncField::next_node = alloc;
   60586             :     }
   60587           0 :     ROSE_ASSERT(SgUpirSyncField::next_node != nullptr);
   60588             : 
   60589           0 :     SgUpirSyncField * object = SgUpirSyncField::next_node;
   60590           0 :     SgUpirSyncField::next_node = (SgUpirSyncField*)(object->p_freepointer);
   60591             : 
   60592             : #if ROSE_ALLOC_TRACE == 2
   60593             :     printf("SgUpirSyncField::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUpirSyncField::next_node);
   60594             : #endif
   60595             : 
   60596           0 :     SgNode * fp = object->p_freepointer;
   60597             : #if ROSE_ALLOC_MEMSET == 1
   60598             : #elif ROSE_ALLOC_MEMSET == 2
   60599             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgUpirSyncField) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   60600             : #elif ROSE_ALLOC_MEMSET == 3
   60601             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgUpirSyncField) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   60602             : #endif
   60603           0 :     object->p_freepointer = fp;
   60604             : 
   60605             : #if ROSE_ALLOC_TRACE == 2
   60606             : //    printf("SgUpirSyncField::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUpirSyncField::next_node);
   60607             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   60608             :     Rose::MemPool::snapshot(oss.str());
   60609             :     alloc_trace_cnt++;
   60610             : #endif
   60611             : 
   60612           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   60613             : 
   60614           0 :     ALLOC_MUTEX(SgUpirSyncField, unlock);
   60615             : 
   60616             :     return object;
   60617             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   60618             : }
   60619             : 
   60620             : 
   60621             : 
   60622             : /*! \brief Delete operator for SgUpirSyncField.
   60623             : 
   60624             :    This delete operator implements deallocation using memory pools to 
   60625             :    provide most efficent use of the heap within construction of large ASTs.
   60626             : 
   60627             : \internal The new and delete operators use the lower level C malloc/free
   60628             :    function calls for performance and to make sure that mixing of malloc/free
   60629             :    and new/delete by the used can be caught more readily.  This may change
   60630             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   60631             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   60632             :    deallocate memory allocated using ROSE_MALLOC.
   60633             : */
   60634           0 : void SgUpirSyncField::operator delete(void *Pointer, size_t Size)
   60635             : {
   60636             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   60637             :      * or throwing an exception. */
   60638           0 :     ALLOC_MUTEX(SgUpirSyncField, lock);
   60639             : 
   60640             : #if USE_CPP_NEW_DELETE_OPERATORS
   60641             :     ROSE_FREE(Pointer);
   60642             : #else
   60643             : #if ROSE_PEDANTIC_ALLOC
   60644             :     ROSE_ASSERT(Size == sizeof(SgUpirSyncField));
   60645             : #else
   60646           0 :     if (Size != sizeof(SgUpirSyncField)) {
   60647           0 :       ROSE_FREE(Pointer);
   60648           0 :       ALLOC_MUTEX(SgUpirSyncField, unlock);
   60649             :       return;
   60650             :     }
   60651             : #endif
   60652             : 
   60653           0 :     SgUpirSyncField * object = (SgUpirSyncField*) Pointer;
   60654           0 :     ROSE_ASSERT(object != nullptr);
   60655             : 
   60656             : #if ROSE_ALLOC_TRACE == 2
   60657             : //  printf("SgUpirSyncField::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUpirSyncField::next_node);
   60658             :     printf("SgUpirSyncField::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUpirSyncField::next_node);
   60659             : #endif
   60660             : 
   60661             : #if ROSE_PEDANTIC_ALLOC
   60662             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   60663             : #endif
   60664             : 
   60665             : #if ROSE_ALLOC_MEMSET == 1
   60666             : #elif ROSE_ALLOC_MEMSET == 2
   60667             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgUpirSyncField) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   60668             : #elif ROSE_ALLOC_MEMSET == 3
   60669             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgUpirSyncField) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   60670             : #endif
   60671             : 
   60672             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   60673             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   60674             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   60675             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   60676             : #else
   60677           0 :     object->p_freepointer = SgUpirSyncField::next_node;
   60678           0 :     SgUpirSyncField::next_node = object;
   60679             : #endif
   60680             : 
   60681             : #if ROSE_ALLOC_TRACE == 2
   60682             : //  printf("SgUpirSyncField::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUpirSyncField::next_node);
   60683             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   60684             :     Rose::MemPool::snapshot(oss.str());
   60685             :     alloc_trace_cnt++;
   60686             : #endif
   60687             : 
   60688             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   60689             : 
   60690           0 :     ALLOC_MUTEX(SgUpirSyncField, unlock);
   60691             : }
   60692             : 
   60693             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   60694             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   60695             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   60696             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   60697             : // Also, note comment below from Robb (copied from the Common.code file).
   60698             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   60699             : //
   60700             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   60701             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   60702             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   60703             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   60704             : #if 0
   60705             : void SgUpirSyncField::operator delete(void* pointer) { SgUpirSyncField::operator delete (pointer, sizeof(SgUpirSyncField)); };
   60706             : #endif
   60707             : /* #line 60708 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   60708             : 
   60709             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   60710             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   60711             : // obviously imply C++.
   60712             : 
   60713             : // This implements the support within ROSE for memory pools.  Memory pools
   60714             : // support the most condensed usage of memory within the construction of
   60715             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   60716             : // by a new operator written for each class.
   60717             : 
   60718             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   60719             :     // User wants multi-thread support and POSIX threads are available.
   60720             : #   include <pthread.h>
   60721             :     static pthread_mutex_t SgUpirDataField_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   60722             : #else
   60723             :      // Cause synchronization to be skipped.
   60724             : #    ifndef ALLOC_MUTEX
   60725             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   60726             : #    endif
   60727             : #    ifdef _REENTRANT
   60728             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   60729             : #       ifdef _MSC_VER
   60730             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   60731             : #       else
   60732             : #           warning "POSIX threads are not available; synchronization being skipped"
   60733             : #       endif
   60734             : #    endif
   60735             : #endif
   60736             : 
   60737             : #ifndef ROSE_ALLOC_TRACE
   60738             : #  define ROSE_ALLOC_TRACE 0
   60739             : #endif
   60740             : 
   60741             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   60742             : #define ROSE_ALLOC_TRACE_CNT
   60743             : #include "memory-pool-snapshot.h"
   60744             : unsigned long alloc_trace_cnt = 0;
   60745             : #endif
   60746             : 
   60747             : #if ROSE_ALLOC_TRACE
   60748             : const unsigned SgUpirDataField::pool_size = 5;
   60749             : #else
   60750             : const unsigned SgUpirDataField::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   60751             : #endif
   60752             : 
   60753             : #ifndef ROSE_ALLOC_MEMSET
   60754             : #  define ROSE_ALLOC_MEMSET 0
   60755             : #endif
   60756             : 
   60757             : #ifndef ROSE_PEDANTIC_ALLOC
   60758             : #  define ROSE_PEDANTIC_ALLOC 0
   60759             : #endif
   60760             : 
   60761             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   60762             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   60763             : #endif
   60764             : 
   60765             : #if !defined(SGNODE__ALL_POOLS)
   60766             : #define SGNODE__ALL_POOLS
   60767             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   60768             : #endif
   60769             : 
   60770             : SgUpirDataField* SgUpirDataField::next_node = nullptr;
   60771             : std::vector<unsigned char*> SgUpirDataField::pools;
   60772             : 
   60773             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   60774             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   60775             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   60776             : // around this macro definition rather than each use).
   60777             : #ifndef ALLOC_MUTEX
   60778             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   60779             :         do {                                                                     \
   60780             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   60781             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   60782             :                 abort();                                                         \
   60783             :             }                                                                    \
   60784             :         } while (0);
   60785             : #endif
   60786             : 
   60787             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   60788             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   60789             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   60790             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   60791             : 
   60792             : /*! \brief New operator for SgUpirDataField.
   60793             : 
   60794             :    This new operator implements memory pools to provide most efficent 
   60795             :    use of the heap within construction of large ASTs.
   60796             : 
   60797             : \internal The new and delete operators use the lower level C malloc/free
   60798             :    function calls for performance and to make sure that mixing of malloc/free
   60799             :    and new/delete by the used can be caught more readily.  This may change
   60800             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   60801             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   60802             :    deallocate memory allocated using ROSE_MALLOC.
   60803             : */
   60804           0 : void *SgUpirDataField::operator new ( size_t Size )
   60805             : {
   60806             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   60807             :      * returning or throwing an exception. */
   60808           0 :     ALLOC_MUTEX(SgUpirDataField, lock);
   60809             : 
   60810             : #if ROSE_ALLOC_TRACE == 2
   60811             : //    printf("SgUpirDataField::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgUpirDataField::next_node);
   60812             : #endif
   60813             : 
   60814             : #if USE_CPP_NEW_DELETE_OPERATORS
   60815             :     void *mem = ROSE_MALLOC(Size);
   60816             :     ALLOC_MUTEX(SgUpirDataField, unlock);
   60817             :     return mem;
   60818             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   60819             : #if ROSE_PEDANTIC_ALLOC
   60820             :     ROSE_ASSERT(Size == sizeof(SgUpirDataField));
   60821             : #else
   60822           0 :     if (Size != sizeof(SgUpirDataField)) {
   60823           0 :       void * object = ROSE_MALLOC(Size);
   60824           0 :       ALLOC_MUTEX(SgUpirDataField, unlock);
   60825             :       return object;
   60826             :     }
   60827             : #endif
   60828             : 
   60829           0 :     if (SgUpirDataField::next_node == nullptr) {
   60830           0 :         SgUpirDataField * alloc = (SgUpirDataField*) ROSE_MALLOC ( SgUpirDataField::pool_size * sizeof(SgUpirDataField) );
   60831           0 :         ROSE_ASSERT(alloc != nullptr);
   60832             : 
   60833             : #if ROSE_ALLOC_TRACE == 2
   60834             : //        printf("SgUpirDataField::alloc\n  block[%zi] = [ %p , %p [\n", SgUpirDataField::pools.size(), alloc, alloc + SgUpirDataField::pool_size);
   60835             : #endif
   60836             : 
   60837             : #if ROSE_ALLOC_MEMSET == 1
   60838             : #elif ROSE_ALLOC_MEMSET == 2
   60839             :         memset(alloc, 0x00, SgUpirDataField::pool_size * sizeof(SgUpirDataField));
   60840             : #elif ROSE_ALLOC_MEMSET == 3
   60841             :         memset(alloc, 0xAA, SgUpirDataField::pool_size * sizeof(SgUpirDataField));
   60842             : #endif
   60843           0 :         for (unsigned i=0; i < SgUpirDataField::pool_size-1; i++) {
   60844           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
   60845             :         }
   60846           0 :         alloc[SgUpirDataField::pool_size-1].p_freepointer = nullptr;
   60847             : 
   60848           0 :         SgUpirDataField::pools.push_back ( (unsigned char *) alloc );
   60849           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgUpirDataField::pool_size * sizeof(SgUpirDataField), V_SgUpirDataField ) );
   60850           0 :         SgUpirDataField::next_node = alloc;
   60851             :     }
   60852           0 :     ROSE_ASSERT(SgUpirDataField::next_node != nullptr);
   60853             : 
   60854           0 :     SgUpirDataField * object = SgUpirDataField::next_node;
   60855           0 :     SgUpirDataField::next_node = (SgUpirDataField*)(object->p_freepointer);
   60856             : 
   60857             : #if ROSE_ALLOC_TRACE == 2
   60858             :     printf("SgUpirDataField::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUpirDataField::next_node);
   60859             : #endif
   60860             : 
   60861           0 :     SgNode * fp = object->p_freepointer;
   60862             : #if ROSE_ALLOC_MEMSET == 1
   60863             : #elif ROSE_ALLOC_MEMSET == 2
   60864             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgUpirDataField) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   60865             : #elif ROSE_ALLOC_MEMSET == 3
   60866             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgUpirDataField) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   60867             : #endif
   60868           0 :     object->p_freepointer = fp;
   60869             : 
   60870             : #if ROSE_ALLOC_TRACE == 2
   60871             : //    printf("SgUpirDataField::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUpirDataField::next_node);
   60872             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   60873             :     Rose::MemPool::snapshot(oss.str());
   60874             :     alloc_trace_cnt++;
   60875             : #endif
   60876             : 
   60877           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   60878             : 
   60879           0 :     ALLOC_MUTEX(SgUpirDataField, unlock);
   60880             : 
   60881             :     return object;
   60882             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   60883             : }
   60884             : 
   60885             : 
   60886             : 
   60887             : /*! \brief Delete operator for SgUpirDataField.
   60888             : 
   60889             :    This delete operator implements deallocation using memory pools to 
   60890             :    provide most efficent use of the heap within construction of large ASTs.
   60891             : 
   60892             : \internal The new and delete operators use the lower level C malloc/free
   60893             :    function calls for performance and to make sure that mixing of malloc/free
   60894             :    and new/delete by the used can be caught more readily.  This may change
   60895             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   60896             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   60897             :    deallocate memory allocated using ROSE_MALLOC.
   60898             : */
   60899           0 : void SgUpirDataField::operator delete(void *Pointer, size_t Size)
   60900             : {
   60901             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   60902             :      * or throwing an exception. */
   60903           0 :     ALLOC_MUTEX(SgUpirDataField, lock);
   60904             : 
   60905             : #if USE_CPP_NEW_DELETE_OPERATORS
   60906             :     ROSE_FREE(Pointer);
   60907             : #else
   60908             : #if ROSE_PEDANTIC_ALLOC
   60909             :     ROSE_ASSERT(Size == sizeof(SgUpirDataField));
   60910             : #else
   60911           0 :     if (Size != sizeof(SgUpirDataField)) {
   60912           0 :       ROSE_FREE(Pointer);
   60913           0 :       ALLOC_MUTEX(SgUpirDataField, unlock);
   60914             :       return;
   60915             :     }
   60916             : #endif
   60917             : 
   60918           0 :     SgUpirDataField * object = (SgUpirDataField*) Pointer;
   60919           0 :     ROSE_ASSERT(object != nullptr);
   60920             : 
   60921             : #if ROSE_ALLOC_TRACE == 2
   60922             : //  printf("SgUpirDataField::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUpirDataField::next_node);
   60923             :     printf("SgUpirDataField::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUpirDataField::next_node);
   60924             : #endif
   60925             : 
   60926             : #if ROSE_PEDANTIC_ALLOC
   60927             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   60928             : #endif
   60929             : 
   60930             : #if ROSE_ALLOC_MEMSET == 1
   60931             : #elif ROSE_ALLOC_MEMSET == 2
   60932             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgUpirDataField) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   60933             : #elif ROSE_ALLOC_MEMSET == 3
   60934             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgUpirDataField) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   60935             : #endif
   60936             : 
   60937             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   60938             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   60939             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   60940             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   60941             : #else
   60942           0 :     object->p_freepointer = SgUpirDataField::next_node;
   60943           0 :     SgUpirDataField::next_node = object;
   60944             : #endif
   60945             : 
   60946             : #if ROSE_ALLOC_TRACE == 2
   60947             : //  printf("SgUpirDataField::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUpirDataField::next_node);
   60948             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   60949             :     Rose::MemPool::snapshot(oss.str());
   60950             :     alloc_trace_cnt++;
   60951             : #endif
   60952             : 
   60953             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   60954             : 
   60955           0 :     ALLOC_MUTEX(SgUpirDataField, unlock);
   60956             : }
   60957             : 
   60958             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   60959             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   60960             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   60961             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   60962             : // Also, note comment below from Robb (copied from the Common.code file).
   60963             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   60964             : //
   60965             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   60966             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   60967             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   60968             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   60969             : #if 0
   60970             : void SgUpirDataField::operator delete(void* pointer) { SgUpirDataField::operator delete (pointer, sizeof(SgUpirDataField)); };
   60971             : #endif
   60972             : /* #line 60973 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   60973             : 
   60974             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   60975             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   60976             : // obviously imply C++.
   60977             : 
   60978             : // This implements the support within ROSE for memory pools.  Memory pools
   60979             : // support the most condensed usage of memory within the construction of
   60980             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   60981             : // by a new operator written for each class.
   60982             : 
   60983             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   60984             :     // User wants multi-thread support and POSIX threads are available.
   60985             : #   include <pthread.h>
   60986             :     static pthread_mutex_t SgUpirTargetField_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   60987             : #else
   60988             :      // Cause synchronization to be skipped.
   60989             : #    ifndef ALLOC_MUTEX
   60990             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   60991             : #    endif
   60992             : #    ifdef _REENTRANT
   60993             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   60994             : #       ifdef _MSC_VER
   60995             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   60996             : #       else
   60997             : #           warning "POSIX threads are not available; synchronization being skipped"
   60998             : #       endif
   60999             : #    endif
   61000             : #endif
   61001             : 
   61002             : #ifndef ROSE_ALLOC_TRACE
   61003             : #  define ROSE_ALLOC_TRACE 0
   61004             : #endif
   61005             : 
   61006             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   61007             : #define ROSE_ALLOC_TRACE_CNT
   61008             : #include "memory-pool-snapshot.h"
   61009             : unsigned long alloc_trace_cnt = 0;
   61010             : #endif
   61011             : 
   61012             : #if ROSE_ALLOC_TRACE
   61013             : const unsigned SgUpirTargetField::pool_size = 5;
   61014             : #else
   61015             : const unsigned SgUpirTargetField::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   61016             : #endif
   61017             : 
   61018             : #ifndef ROSE_ALLOC_MEMSET
   61019             : #  define ROSE_ALLOC_MEMSET 0
   61020             : #endif
   61021             : 
   61022             : #ifndef ROSE_PEDANTIC_ALLOC
   61023             : #  define ROSE_PEDANTIC_ALLOC 0
   61024             : #endif
   61025             : 
   61026             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   61027             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   61028             : #endif
   61029             : 
   61030             : #if !defined(SGNODE__ALL_POOLS)
   61031             : #define SGNODE__ALL_POOLS
   61032             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   61033             : #endif
   61034             : 
   61035             : SgUpirTargetField* SgUpirTargetField::next_node = nullptr;
   61036             : std::vector<unsigned char*> SgUpirTargetField::pools;
   61037             : 
   61038             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   61039             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   61040             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   61041             : // around this macro definition rather than each use).
   61042             : #ifndef ALLOC_MUTEX
   61043             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   61044             :         do {                                                                     \
   61045             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   61046             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   61047             :                 abort();                                                         \
   61048             :             }                                                                    \
   61049             :         } while (0);
   61050             : #endif
   61051             : 
   61052             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   61053             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   61054             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   61055             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   61056             : 
   61057             : /*! \brief New operator for SgUpirTargetField.
   61058             : 
   61059             :    This new operator implements memory pools to provide most efficent 
   61060             :    use of the heap within construction of large ASTs.
   61061             : 
   61062             : \internal The new and delete operators use the lower level C malloc/free
   61063             :    function calls for performance and to make sure that mixing of malloc/free
   61064             :    and new/delete by the used can be caught more readily.  This may change
   61065             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   61066             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   61067             :    deallocate memory allocated using ROSE_MALLOC.
   61068             : */
   61069           0 : void *SgUpirTargetField::operator new ( size_t Size )
   61070             : {
   61071             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   61072             :      * returning or throwing an exception. */
   61073           0 :     ALLOC_MUTEX(SgUpirTargetField, lock);
   61074             : 
   61075             : #if ROSE_ALLOC_TRACE == 2
   61076             : //    printf("SgUpirTargetField::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgUpirTargetField::next_node);
   61077             : #endif
   61078             : 
   61079             : #if USE_CPP_NEW_DELETE_OPERATORS
   61080             :     void *mem = ROSE_MALLOC(Size);
   61081             :     ALLOC_MUTEX(SgUpirTargetField, unlock);
   61082             :     return mem;
   61083             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   61084             : #if ROSE_PEDANTIC_ALLOC
   61085             :     ROSE_ASSERT(Size == sizeof(SgUpirTargetField));
   61086             : #else
   61087           0 :     if (Size != sizeof(SgUpirTargetField)) {
   61088           0 :       void * object = ROSE_MALLOC(Size);
   61089           0 :       ALLOC_MUTEX(SgUpirTargetField, unlock);
   61090             :       return object;
   61091             :     }
   61092             : #endif
   61093             : 
   61094           0 :     if (SgUpirTargetField::next_node == nullptr) {
   61095           0 :         SgUpirTargetField * alloc = (SgUpirTargetField*) ROSE_MALLOC ( SgUpirTargetField::pool_size * sizeof(SgUpirTargetField) );
   61096           0 :         ROSE_ASSERT(alloc != nullptr);
   61097             : 
   61098             : #if ROSE_ALLOC_TRACE == 2
   61099             : //        printf("SgUpirTargetField::alloc\n  block[%zi] = [ %p , %p [\n", SgUpirTargetField::pools.size(), alloc, alloc + SgUpirTargetField::pool_size);
   61100             : #endif
   61101             : 
   61102             : #if ROSE_ALLOC_MEMSET == 1
   61103             : #elif ROSE_ALLOC_MEMSET == 2
   61104             :         memset(alloc, 0x00, SgUpirTargetField::pool_size * sizeof(SgUpirTargetField));
   61105             : #elif ROSE_ALLOC_MEMSET == 3
   61106             :         memset(alloc, 0xAA, SgUpirTargetField::pool_size * sizeof(SgUpirTargetField));
   61107             : #endif
   61108           0 :         for (unsigned i=0; i < SgUpirTargetField::pool_size-1; i++) {
   61109           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
   61110             :         }
   61111           0 :         alloc[SgUpirTargetField::pool_size-1].p_freepointer = nullptr;
   61112             : 
   61113           0 :         SgUpirTargetField::pools.push_back ( (unsigned char *) alloc );
   61114           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgUpirTargetField::pool_size * sizeof(SgUpirTargetField), V_SgUpirTargetField ) );
   61115           0 :         SgUpirTargetField::next_node = alloc;
   61116             :     }
   61117           0 :     ROSE_ASSERT(SgUpirTargetField::next_node != nullptr);
   61118             : 
   61119           0 :     SgUpirTargetField * object = SgUpirTargetField::next_node;
   61120           0 :     SgUpirTargetField::next_node = (SgUpirTargetField*)(object->p_freepointer);
   61121             : 
   61122             : #if ROSE_ALLOC_TRACE == 2
   61123             :     printf("SgUpirTargetField::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUpirTargetField::next_node);
   61124             : #endif
   61125             : 
   61126           0 :     SgNode * fp = object->p_freepointer;
   61127             : #if ROSE_ALLOC_MEMSET == 1
   61128             : #elif ROSE_ALLOC_MEMSET == 2
   61129             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgUpirTargetField) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   61130             : #elif ROSE_ALLOC_MEMSET == 3
   61131             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgUpirTargetField) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   61132             : #endif
   61133           0 :     object->p_freepointer = fp;
   61134             : 
   61135             : #if ROSE_ALLOC_TRACE == 2
   61136             : //    printf("SgUpirTargetField::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUpirTargetField::next_node);
   61137             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   61138             :     Rose::MemPool::snapshot(oss.str());
   61139             :     alloc_trace_cnt++;
   61140             : #endif
   61141             : 
   61142           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   61143             : 
   61144           0 :     ALLOC_MUTEX(SgUpirTargetField, unlock);
   61145             : 
   61146             :     return object;
   61147             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   61148             : }
   61149             : 
   61150             : 
   61151             : 
   61152             : /*! \brief Delete operator for SgUpirTargetField.
   61153             : 
   61154             :    This delete operator implements deallocation using memory pools to 
   61155             :    provide most efficent use of the heap within construction of large ASTs.
   61156             : 
   61157             : \internal The new and delete operators use the lower level C malloc/free
   61158             :    function calls for performance and to make sure that mixing of malloc/free
   61159             :    and new/delete by the used can be caught more readily.  This may change
   61160             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   61161             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   61162             :    deallocate memory allocated using ROSE_MALLOC.
   61163             : */
   61164           0 : void SgUpirTargetField::operator delete(void *Pointer, size_t Size)
   61165             : {
   61166             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   61167             :      * or throwing an exception. */
   61168           0 :     ALLOC_MUTEX(SgUpirTargetField, lock);
   61169             : 
   61170             : #if USE_CPP_NEW_DELETE_OPERATORS
   61171             :     ROSE_FREE(Pointer);
   61172             : #else
   61173             : #if ROSE_PEDANTIC_ALLOC
   61174             :     ROSE_ASSERT(Size == sizeof(SgUpirTargetField));
   61175             : #else
   61176           0 :     if (Size != sizeof(SgUpirTargetField)) {
   61177           0 :       ROSE_FREE(Pointer);
   61178           0 :       ALLOC_MUTEX(SgUpirTargetField, unlock);
   61179             :       return;
   61180             :     }
   61181             : #endif
   61182             : 
   61183           0 :     SgUpirTargetField * object = (SgUpirTargetField*) Pointer;
   61184           0 :     ROSE_ASSERT(object != nullptr);
   61185             : 
   61186             : #if ROSE_ALLOC_TRACE == 2
   61187             : //  printf("SgUpirTargetField::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUpirTargetField::next_node);
   61188             :     printf("SgUpirTargetField::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUpirTargetField::next_node);
   61189             : #endif
   61190             : 
   61191             : #if ROSE_PEDANTIC_ALLOC
   61192             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   61193             : #endif
   61194             : 
   61195             : #if ROSE_ALLOC_MEMSET == 1
   61196             : #elif ROSE_ALLOC_MEMSET == 2
   61197             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgUpirTargetField) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   61198             : #elif ROSE_ALLOC_MEMSET == 3
   61199             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgUpirTargetField) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   61200             : #endif
   61201             : 
   61202             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   61203             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   61204             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   61205             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   61206             : #else
   61207           0 :     object->p_freepointer = SgUpirTargetField::next_node;
   61208           0 :     SgUpirTargetField::next_node = object;
   61209             : #endif
   61210             : 
   61211             : #if ROSE_ALLOC_TRACE == 2
   61212             : //  printf("SgUpirTargetField::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUpirTargetField::next_node);
   61213             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   61214             :     Rose::MemPool::snapshot(oss.str());
   61215             :     alloc_trace_cnt++;
   61216             : #endif
   61217             : 
   61218             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   61219             : 
   61220           0 :     ALLOC_MUTEX(SgUpirTargetField, unlock);
   61221             : }
   61222             : 
   61223             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   61224             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   61225             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   61226             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   61227             : // Also, note comment below from Robb (copied from the Common.code file).
   61228             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   61229             : //
   61230             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   61231             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   61232             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   61233             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   61234             : #if 0
   61235             : void SgUpirTargetField::operator delete(void* pointer) { SgUpirTargetField::operator delete (pointer, sizeof(SgUpirTargetField)); };
   61236             : #endif
   61237             : /* #line 61238 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   61238             : 
   61239             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   61240             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   61241             : // obviously imply C++.
   61242             : 
   61243             : // This implements the support within ROSE for memory pools.  Memory pools
   61244             : // support the most condensed usage of memory within the construction of
   61245             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   61246             : // by a new operator written for each class.
   61247             : 
   61248             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   61249             :     // User wants multi-thread support and POSIX threads are available.
   61250             : #   include <pthread.h>
   61251             :     static pthread_mutex_t SgUpirDataItemField_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   61252             : #else
   61253             :      // Cause synchronization to be skipped.
   61254             : #    ifndef ALLOC_MUTEX
   61255             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   61256             : #    endif
   61257             : #    ifdef _REENTRANT
   61258             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   61259             : #       ifdef _MSC_VER
   61260             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   61261             : #       else
   61262             : #           warning "POSIX threads are not available; synchronization being skipped"
   61263             : #       endif
   61264             : #    endif
   61265             : #endif
   61266             : 
   61267             : #ifndef ROSE_ALLOC_TRACE
   61268             : #  define ROSE_ALLOC_TRACE 0
   61269             : #endif
   61270             : 
   61271             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   61272             : #define ROSE_ALLOC_TRACE_CNT
   61273             : #include "memory-pool-snapshot.h"
   61274             : unsigned long alloc_trace_cnt = 0;
   61275             : #endif
   61276             : 
   61277             : #if ROSE_ALLOC_TRACE
   61278             : const unsigned SgUpirDataItemField::pool_size = 5;
   61279             : #else
   61280             : const unsigned SgUpirDataItemField::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   61281             : #endif
   61282             : 
   61283             : #ifndef ROSE_ALLOC_MEMSET
   61284             : #  define ROSE_ALLOC_MEMSET 0
   61285             : #endif
   61286             : 
   61287             : #ifndef ROSE_PEDANTIC_ALLOC
   61288             : #  define ROSE_PEDANTIC_ALLOC 0
   61289             : #endif
   61290             : 
   61291             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   61292             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   61293             : #endif
   61294             : 
   61295             : #if !defined(SGNODE__ALL_POOLS)
   61296             : #define SGNODE__ALL_POOLS
   61297             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   61298             : #endif
   61299             : 
   61300             : SgUpirDataItemField* SgUpirDataItemField::next_node = nullptr;
   61301             : std::vector<unsigned char*> SgUpirDataItemField::pools;
   61302             : 
   61303             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   61304             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   61305             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   61306             : // around this macro definition rather than each use).
   61307             : #ifndef ALLOC_MUTEX
   61308             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   61309             :         do {                                                                     \
   61310             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   61311             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   61312             :                 abort();                                                         \
   61313             :             }                                                                    \
   61314             :         } while (0);
   61315             : #endif
   61316             : 
   61317             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   61318             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   61319             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   61320             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   61321             : 
   61322             : /*! \brief New operator for SgUpirDataItemField.
   61323             : 
   61324             :    This new operator implements memory pools to provide most efficent 
   61325             :    use of the heap within construction of large ASTs.
   61326             : 
   61327             : \internal The new and delete operators use the lower level C malloc/free
   61328             :    function calls for performance and to make sure that mixing of malloc/free
   61329             :    and new/delete by the used can be caught more readily.  This may change
   61330             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   61331             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   61332             :    deallocate memory allocated using ROSE_MALLOC.
   61333             : */
   61334           0 : void *SgUpirDataItemField::operator new ( size_t Size )
   61335             : {
   61336             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   61337             :      * returning or throwing an exception. */
   61338           0 :     ALLOC_MUTEX(SgUpirDataItemField, lock);
   61339             : 
   61340             : #if ROSE_ALLOC_TRACE == 2
   61341             : //    printf("SgUpirDataItemField::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgUpirDataItemField::next_node);
   61342             : #endif
   61343             : 
   61344             : #if USE_CPP_NEW_DELETE_OPERATORS
   61345             :     void *mem = ROSE_MALLOC(Size);
   61346             :     ALLOC_MUTEX(SgUpirDataItemField, unlock);
   61347             :     return mem;
   61348             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   61349             : #if ROSE_PEDANTIC_ALLOC
   61350             :     ROSE_ASSERT(Size == sizeof(SgUpirDataItemField));
   61351             : #else
   61352           0 :     if (Size != sizeof(SgUpirDataItemField)) {
   61353           0 :       void * object = ROSE_MALLOC(Size);
   61354           0 :       ALLOC_MUTEX(SgUpirDataItemField, unlock);
   61355             :       return object;
   61356             :     }
   61357             : #endif
   61358             : 
   61359           0 :     if (SgUpirDataItemField::next_node == nullptr) {
   61360           0 :         SgUpirDataItemField * alloc = (SgUpirDataItemField*) ROSE_MALLOC ( SgUpirDataItemField::pool_size * sizeof(SgUpirDataItemField) );
   61361           0 :         ROSE_ASSERT(alloc != nullptr);
   61362             : 
   61363             : #if ROSE_ALLOC_TRACE == 2
   61364             : //        printf("SgUpirDataItemField::alloc\n  block[%zi] = [ %p , %p [\n", SgUpirDataItemField::pools.size(), alloc, alloc + SgUpirDataItemField::pool_size);
   61365             : #endif
   61366             : 
   61367             : #if ROSE_ALLOC_MEMSET == 1
   61368             : #elif ROSE_ALLOC_MEMSET == 2
   61369             :         memset(alloc, 0x00, SgUpirDataItemField::pool_size * sizeof(SgUpirDataItemField));
   61370             : #elif ROSE_ALLOC_MEMSET == 3
   61371             :         memset(alloc, 0xAA, SgUpirDataItemField::pool_size * sizeof(SgUpirDataItemField));
   61372             : #endif
   61373           0 :         for (unsigned i=0; i < SgUpirDataItemField::pool_size-1; i++) {
   61374           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
   61375             :         }
   61376           0 :         alloc[SgUpirDataItemField::pool_size-1].p_freepointer = nullptr;
   61377             : 
   61378           0 :         SgUpirDataItemField::pools.push_back ( (unsigned char *) alloc );
   61379           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgUpirDataItemField::pool_size * sizeof(SgUpirDataItemField), V_SgUpirDataItemField ) );
   61380           0 :         SgUpirDataItemField::next_node = alloc;
   61381             :     }
   61382           0 :     ROSE_ASSERT(SgUpirDataItemField::next_node != nullptr);
   61383             : 
   61384           0 :     SgUpirDataItemField * object = SgUpirDataItemField::next_node;
   61385           0 :     SgUpirDataItemField::next_node = (SgUpirDataItemField*)(object->p_freepointer);
   61386             : 
   61387             : #if ROSE_ALLOC_TRACE == 2
   61388             :     printf("SgUpirDataItemField::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUpirDataItemField::next_node);
   61389             : #endif
   61390             : 
   61391           0 :     SgNode * fp = object->p_freepointer;
   61392             : #if ROSE_ALLOC_MEMSET == 1
   61393             : #elif ROSE_ALLOC_MEMSET == 2
   61394             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgUpirDataItemField) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   61395             : #elif ROSE_ALLOC_MEMSET == 3
   61396             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgUpirDataItemField) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   61397             : #endif
   61398           0 :     object->p_freepointer = fp;
   61399             : 
   61400             : #if ROSE_ALLOC_TRACE == 2
   61401             : //    printf("SgUpirDataItemField::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUpirDataItemField::next_node);
   61402             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   61403             :     Rose::MemPool::snapshot(oss.str());
   61404             :     alloc_trace_cnt++;
   61405             : #endif
   61406             : 
   61407           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   61408             : 
   61409           0 :     ALLOC_MUTEX(SgUpirDataItemField, unlock);
   61410             : 
   61411             :     return object;
   61412             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   61413             : }
   61414             : 
   61415             : 
   61416             : 
   61417             : /*! \brief Delete operator for SgUpirDataItemField.
   61418             : 
   61419             :    This delete operator implements deallocation using memory pools to 
   61420             :    provide most efficent use of the heap within construction of large ASTs.
   61421             : 
   61422             : \internal The new and delete operators use the lower level C malloc/free
   61423             :    function calls for performance and to make sure that mixing of malloc/free
   61424             :    and new/delete by the used can be caught more readily.  This may change
   61425             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   61426             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   61427             :    deallocate memory allocated using ROSE_MALLOC.
   61428             : */
   61429           0 : void SgUpirDataItemField::operator delete(void *Pointer, size_t Size)
   61430             : {
   61431             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   61432             :      * or throwing an exception. */
   61433           0 :     ALLOC_MUTEX(SgUpirDataItemField, lock);
   61434             : 
   61435             : #if USE_CPP_NEW_DELETE_OPERATORS
   61436             :     ROSE_FREE(Pointer);
   61437             : #else
   61438             : #if ROSE_PEDANTIC_ALLOC
   61439             :     ROSE_ASSERT(Size == sizeof(SgUpirDataItemField));
   61440             : #else
   61441           0 :     if (Size != sizeof(SgUpirDataItemField)) {
   61442           0 :       ROSE_FREE(Pointer);
   61443           0 :       ALLOC_MUTEX(SgUpirDataItemField, unlock);
   61444             :       return;
   61445             :     }
   61446             : #endif
   61447             : 
   61448           0 :     SgUpirDataItemField * object = (SgUpirDataItemField*) Pointer;
   61449           0 :     ROSE_ASSERT(object != nullptr);
   61450             : 
   61451             : #if ROSE_ALLOC_TRACE == 2
   61452             : //  printf("SgUpirDataItemField::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUpirDataItemField::next_node);
   61453             :     printf("SgUpirDataItemField::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUpirDataItemField::next_node);
   61454             : #endif
   61455             : 
   61456             : #if ROSE_PEDANTIC_ALLOC
   61457             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   61458             : #endif
   61459             : 
   61460             : #if ROSE_ALLOC_MEMSET == 1
   61461             : #elif ROSE_ALLOC_MEMSET == 2
   61462             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgUpirDataItemField) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   61463             : #elif ROSE_ALLOC_MEMSET == 3
   61464             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgUpirDataItemField) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   61465             : #endif
   61466             : 
   61467             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   61468             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   61469             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   61470             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   61471             : #else
   61472           0 :     object->p_freepointer = SgUpirDataItemField::next_node;
   61473           0 :     SgUpirDataItemField::next_node = object;
   61474             : #endif
   61475             : 
   61476             : #if ROSE_ALLOC_TRACE == 2
   61477             : //  printf("SgUpirDataItemField::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUpirDataItemField::next_node);
   61478             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   61479             :     Rose::MemPool::snapshot(oss.str());
   61480             :     alloc_trace_cnt++;
   61481             : #endif
   61482             : 
   61483             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   61484             : 
   61485           0 :     ALLOC_MUTEX(SgUpirDataItemField, unlock);
   61486             : }
   61487             : 
   61488             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   61489             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   61490             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   61491             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   61492             : // Also, note comment below from Robb (copied from the Common.code file).
   61493             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   61494             : //
   61495             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   61496             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   61497             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   61498             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   61499             : #if 0
   61500             : void SgUpirDataItemField::operator delete(void* pointer) { SgUpirDataItemField::operator delete (pointer, sizeof(SgUpirDataItemField)); };
   61501             : #endif
   61502             : /* #line 61503 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   61503             : 
   61504             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   61505             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   61506             : // obviously imply C++.
   61507             : 
   61508             : // This implements the support within ROSE for memory pools.  Memory pools
   61509             : // support the most condensed usage of memory within the construction of
   61510             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   61511             : // by a new operator written for each class.
   61512             : 
   61513             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   61514             :     // User wants multi-thread support and POSIX threads are available.
   61515             : #   include <pthread.h>
   61516             :     static pthread_mutex_t SgLambdaCapture_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   61517             : #else
   61518             :      // Cause synchronization to be skipped.
   61519             : #    ifndef ALLOC_MUTEX
   61520             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   61521             : #    endif
   61522             : #    ifdef _REENTRANT
   61523             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   61524             : #       ifdef _MSC_VER
   61525             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   61526             : #       else
   61527             : #           warning "POSIX threads are not available; synchronization being skipped"
   61528             : #       endif
   61529             : #    endif
   61530             : #endif
   61531             : 
   61532             : #ifndef ROSE_ALLOC_TRACE
   61533             : #  define ROSE_ALLOC_TRACE 0
   61534             : #endif
   61535             : 
   61536             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   61537             : #define ROSE_ALLOC_TRACE_CNT
   61538             : #include "memory-pool-snapshot.h"
   61539             : unsigned long alloc_trace_cnt = 0;
   61540             : #endif
   61541             : 
   61542             : #if ROSE_ALLOC_TRACE
   61543             : const unsigned SgLambdaCapture::pool_size = 5;
   61544             : #else
   61545             : const unsigned SgLambdaCapture::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   61546             : #endif
   61547             : 
   61548             : #ifndef ROSE_ALLOC_MEMSET
   61549             : #  define ROSE_ALLOC_MEMSET 0
   61550             : #endif
   61551             : 
   61552             : #ifndef ROSE_PEDANTIC_ALLOC
   61553             : #  define ROSE_PEDANTIC_ALLOC 0
   61554             : #endif
   61555             : 
   61556             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   61557             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   61558             : #endif
   61559             : 
   61560             : #if !defined(SGNODE__ALL_POOLS)
   61561             : #define SGNODE__ALL_POOLS
   61562             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   61563             : #endif
   61564             : 
   61565             : SgLambdaCapture* SgLambdaCapture::next_node = nullptr;
   61566             : std::vector<unsigned char*> SgLambdaCapture::pools;
   61567             : 
   61568             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   61569             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   61570             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   61571             : // around this macro definition rather than each use).
   61572             : #ifndef ALLOC_MUTEX
   61573             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   61574             :         do {                                                                     \
   61575             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   61576             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   61577             :                 abort();                                                         \
   61578             :             }                                                                    \
   61579             :         } while (0);
   61580             : #endif
   61581             : 
   61582             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   61583             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   61584             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   61585             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   61586             : 
   61587             : /*! \brief New operator for SgLambdaCapture.
   61588             : 
   61589             :    This new operator implements memory pools to provide most efficent 
   61590             :    use of the heap within construction of large ASTs.
   61591             : 
   61592             : \internal The new and delete operators use the lower level C malloc/free
   61593             :    function calls for performance and to make sure that mixing of malloc/free
   61594             :    and new/delete by the used can be caught more readily.  This may change
   61595             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   61596             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   61597             :    deallocate memory allocated using ROSE_MALLOC.
   61598             : */
   61599           0 : void *SgLambdaCapture::operator new ( size_t Size )
   61600             : {
   61601             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   61602             :      * returning or throwing an exception. */
   61603           0 :     ALLOC_MUTEX(SgLambdaCapture, lock);
   61604             : 
   61605             : #if ROSE_ALLOC_TRACE == 2
   61606             : //    printf("SgLambdaCapture::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgLambdaCapture::next_node);
   61607             : #endif
   61608             : 
   61609             : #if USE_CPP_NEW_DELETE_OPERATORS
   61610             :     void *mem = ROSE_MALLOC(Size);
   61611             :     ALLOC_MUTEX(SgLambdaCapture, unlock);
   61612             :     return mem;
   61613             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   61614             : #if ROSE_PEDANTIC_ALLOC
   61615             :     ROSE_ASSERT(Size == sizeof(SgLambdaCapture));
   61616             : #else
   61617           0 :     if (Size != sizeof(SgLambdaCapture)) {
   61618           0 :       void * object = ROSE_MALLOC(Size);
   61619           0 :       ALLOC_MUTEX(SgLambdaCapture, unlock);
   61620             :       return object;
   61621             :     }
   61622             : #endif
   61623             : 
   61624           0 :     if (SgLambdaCapture::next_node == nullptr) {
   61625           0 :         SgLambdaCapture * alloc = (SgLambdaCapture*) ROSE_MALLOC ( SgLambdaCapture::pool_size * sizeof(SgLambdaCapture) );
   61626           0 :         ROSE_ASSERT(alloc != nullptr);
   61627             : 
   61628             : #if ROSE_ALLOC_TRACE == 2
   61629             : //        printf("SgLambdaCapture::alloc\n  block[%zi] = [ %p , %p [\n", SgLambdaCapture::pools.size(), alloc, alloc + SgLambdaCapture::pool_size);
   61630             : #endif
   61631             : 
   61632             : #if ROSE_ALLOC_MEMSET == 1
   61633             : #elif ROSE_ALLOC_MEMSET == 2
   61634             :         memset(alloc, 0x00, SgLambdaCapture::pool_size * sizeof(SgLambdaCapture));
   61635             : #elif ROSE_ALLOC_MEMSET == 3
   61636             :         memset(alloc, 0xAA, SgLambdaCapture::pool_size * sizeof(SgLambdaCapture));
   61637             : #endif
   61638           0 :         for (unsigned i=0; i < SgLambdaCapture::pool_size-1; i++) {
   61639           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
   61640             :         }
   61641           0 :         alloc[SgLambdaCapture::pool_size-1].p_freepointer = nullptr;
   61642             : 
   61643           0 :         SgLambdaCapture::pools.push_back ( (unsigned char *) alloc );
   61644           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgLambdaCapture::pool_size * sizeof(SgLambdaCapture), V_SgLambdaCapture ) );
   61645           0 :         SgLambdaCapture::next_node = alloc;
   61646             :     }
   61647           0 :     ROSE_ASSERT(SgLambdaCapture::next_node != nullptr);
   61648             : 
   61649           0 :     SgLambdaCapture * object = SgLambdaCapture::next_node;
   61650           0 :     SgLambdaCapture::next_node = (SgLambdaCapture*)(object->p_freepointer);
   61651             : 
   61652             : #if ROSE_ALLOC_TRACE == 2
   61653             :     printf("SgLambdaCapture::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgLambdaCapture::next_node);
   61654             : #endif
   61655             : 
   61656           0 :     SgNode * fp = object->p_freepointer;
   61657             : #if ROSE_ALLOC_MEMSET == 1
   61658             : #elif ROSE_ALLOC_MEMSET == 2
   61659             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgLambdaCapture) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   61660             : #elif ROSE_ALLOC_MEMSET == 3
   61661             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgLambdaCapture) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   61662             : #endif
   61663           0 :     object->p_freepointer = fp;
   61664             : 
   61665             : #if ROSE_ALLOC_TRACE == 2
   61666             : //    printf("SgLambdaCapture::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgLambdaCapture::next_node);
   61667             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   61668             :     Rose::MemPool::snapshot(oss.str());
   61669             :     alloc_trace_cnt++;
   61670             : #endif
   61671             : 
   61672           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   61673             : 
   61674           0 :     ALLOC_MUTEX(SgLambdaCapture, unlock);
   61675             : 
   61676             :     return object;
   61677             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   61678             : }
   61679             : 
   61680             : 
   61681             : 
   61682             : /*! \brief Delete operator for SgLambdaCapture.
   61683             : 
   61684             :    This delete operator implements deallocation using memory pools to 
   61685             :    provide most efficent use of the heap within construction of large ASTs.
   61686             : 
   61687             : \internal The new and delete operators use the lower level C malloc/free
   61688             :    function calls for performance and to make sure that mixing of malloc/free
   61689             :    and new/delete by the used can be caught more readily.  This may change
   61690             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   61691             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   61692             :    deallocate memory allocated using ROSE_MALLOC.
   61693             : */
   61694           0 : void SgLambdaCapture::operator delete(void *Pointer, size_t Size)
   61695             : {
   61696             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   61697             :      * or throwing an exception. */
   61698           0 :     ALLOC_MUTEX(SgLambdaCapture, lock);
   61699             : 
   61700             : #if USE_CPP_NEW_DELETE_OPERATORS
   61701             :     ROSE_FREE(Pointer);
   61702             : #else
   61703             : #if ROSE_PEDANTIC_ALLOC
   61704             :     ROSE_ASSERT(Size == sizeof(SgLambdaCapture));
   61705             : #else
   61706           0 :     if (Size != sizeof(SgLambdaCapture)) {
   61707           0 :       ROSE_FREE(Pointer);
   61708           0 :       ALLOC_MUTEX(SgLambdaCapture, unlock);
   61709             :       return;
   61710             :     }
   61711             : #endif
   61712             : 
   61713           0 :     SgLambdaCapture * object = (SgLambdaCapture*) Pointer;
   61714           0 :     ROSE_ASSERT(object != nullptr);
   61715             : 
   61716             : #if ROSE_ALLOC_TRACE == 2
   61717             : //  printf("SgLambdaCapture::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgLambdaCapture::next_node);
   61718             :     printf("SgLambdaCapture::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgLambdaCapture::next_node);
   61719             : #endif
   61720             : 
   61721             : #if ROSE_PEDANTIC_ALLOC
   61722             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   61723             : #endif
   61724             : 
   61725             : #if ROSE_ALLOC_MEMSET == 1
   61726             : #elif ROSE_ALLOC_MEMSET == 2
   61727             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgLambdaCapture) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   61728             : #elif ROSE_ALLOC_MEMSET == 3
   61729             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgLambdaCapture) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   61730             : #endif
   61731             : 
   61732             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   61733             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   61734             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   61735             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   61736             : #else
   61737           0 :     object->p_freepointer = SgLambdaCapture::next_node;
   61738           0 :     SgLambdaCapture::next_node = object;
   61739             : #endif
   61740             : 
   61741             : #if ROSE_ALLOC_TRACE == 2
   61742             : //  printf("SgLambdaCapture::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgLambdaCapture::next_node);
   61743             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   61744             :     Rose::MemPool::snapshot(oss.str());
   61745             :     alloc_trace_cnt++;
   61746             : #endif
   61747             : 
   61748             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   61749             : 
   61750           0 :     ALLOC_MUTEX(SgLambdaCapture, unlock);
   61751             : }
   61752             : 
   61753             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   61754             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   61755             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   61756             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   61757             : // Also, note comment below from Robb (copied from the Common.code file).
   61758             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   61759             : //
   61760             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   61761             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   61762             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   61763             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   61764             : #if 0
   61765             : void SgLambdaCapture::operator delete(void* pointer) { SgLambdaCapture::operator delete (pointer, sizeof(SgLambdaCapture)); };
   61766             : #endif
   61767             : /* #line 61768 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   61768             : 
   61769             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   61770             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   61771             : // obviously imply C++.
   61772             : 
   61773             : // This implements the support within ROSE for memory pools.  Memory pools
   61774             : // support the most condensed usage of memory within the construction of
   61775             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   61776             : // by a new operator written for each class.
   61777             : 
   61778             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   61779             :     // User wants multi-thread support and POSIX threads are available.
   61780             : #   include <pthread.h>
   61781             :     static pthread_mutex_t SgLambdaCaptureList_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   61782             : #else
   61783             :      // Cause synchronization to be skipped.
   61784             : #    ifndef ALLOC_MUTEX
   61785             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   61786             : #    endif
   61787             : #    ifdef _REENTRANT
   61788             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   61789             : #       ifdef _MSC_VER
   61790             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   61791             : #       else
   61792             : #           warning "POSIX threads are not available; synchronization being skipped"
   61793             : #       endif
   61794             : #    endif
   61795             : #endif
   61796             : 
   61797             : #ifndef ROSE_ALLOC_TRACE
   61798             : #  define ROSE_ALLOC_TRACE 0
   61799             : #endif
   61800             : 
   61801             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   61802             : #define ROSE_ALLOC_TRACE_CNT
   61803             : #include "memory-pool-snapshot.h"
   61804             : unsigned long alloc_trace_cnt = 0;
   61805             : #endif
   61806             : 
   61807             : #if ROSE_ALLOC_TRACE
   61808             : const unsigned SgLambdaCaptureList::pool_size = 5;
   61809             : #else
   61810             : const unsigned SgLambdaCaptureList::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   61811             : #endif
   61812             : 
   61813             : #ifndef ROSE_ALLOC_MEMSET
   61814             : #  define ROSE_ALLOC_MEMSET 0
   61815             : #endif
   61816             : 
   61817             : #ifndef ROSE_PEDANTIC_ALLOC
   61818             : #  define ROSE_PEDANTIC_ALLOC 0
   61819             : #endif
   61820             : 
   61821             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   61822             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   61823             : #endif
   61824             : 
   61825             : #if !defined(SGNODE__ALL_POOLS)
   61826             : #define SGNODE__ALL_POOLS
   61827             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   61828             : #endif
   61829             : 
   61830             : SgLambdaCaptureList* SgLambdaCaptureList::next_node = nullptr;
   61831             : std::vector<unsigned char*> SgLambdaCaptureList::pools;
   61832             : 
   61833             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   61834             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   61835             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   61836             : // around this macro definition rather than each use).
   61837             : #ifndef ALLOC_MUTEX
   61838             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   61839             :         do {                                                                     \
   61840             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   61841             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   61842             :                 abort();                                                         \
   61843             :             }                                                                    \
   61844             :         } while (0);
   61845             : #endif
   61846             : 
   61847             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   61848             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   61849             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   61850             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   61851             : 
   61852             : /*! \brief New operator for SgLambdaCaptureList.
   61853             : 
   61854             :    This new operator implements memory pools to provide most efficent 
   61855             :    use of the heap within construction of large ASTs.
   61856             : 
   61857             : \internal The new and delete operators use the lower level C malloc/free
   61858             :    function calls for performance and to make sure that mixing of malloc/free
   61859             :    and new/delete by the used can be caught more readily.  This may change
   61860             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   61861             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   61862             :    deallocate memory allocated using ROSE_MALLOC.
   61863             : */
   61864           0 : void *SgLambdaCaptureList::operator new ( size_t Size )
   61865             : {
   61866             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   61867             :      * returning or throwing an exception. */
   61868           0 :     ALLOC_MUTEX(SgLambdaCaptureList, lock);
   61869             : 
   61870             : #if ROSE_ALLOC_TRACE == 2
   61871             : //    printf("SgLambdaCaptureList::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgLambdaCaptureList::next_node);
   61872             : #endif
   61873             : 
   61874             : #if USE_CPP_NEW_DELETE_OPERATORS
   61875             :     void *mem = ROSE_MALLOC(Size);
   61876             :     ALLOC_MUTEX(SgLambdaCaptureList, unlock);
   61877             :     return mem;
   61878             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   61879             : #if ROSE_PEDANTIC_ALLOC
   61880             :     ROSE_ASSERT(Size == sizeof(SgLambdaCaptureList));
   61881             : #else
   61882           0 :     if (Size != sizeof(SgLambdaCaptureList)) {
   61883           0 :       void * object = ROSE_MALLOC(Size);
   61884           0 :       ALLOC_MUTEX(SgLambdaCaptureList, unlock);
   61885             :       return object;
   61886             :     }
   61887             : #endif
   61888             : 
   61889           0 :     if (SgLambdaCaptureList::next_node == nullptr) {
   61890           0 :         SgLambdaCaptureList * alloc = (SgLambdaCaptureList*) ROSE_MALLOC ( SgLambdaCaptureList::pool_size * sizeof(SgLambdaCaptureList) );
   61891           0 :         ROSE_ASSERT(alloc != nullptr);
   61892             : 
   61893             : #if ROSE_ALLOC_TRACE == 2
   61894             : //        printf("SgLambdaCaptureList::alloc\n  block[%zi] = [ %p , %p [\n", SgLambdaCaptureList::pools.size(), alloc, alloc + SgLambdaCaptureList::pool_size);
   61895             : #endif
   61896             : 
   61897             : #if ROSE_ALLOC_MEMSET == 1
   61898             : #elif ROSE_ALLOC_MEMSET == 2
   61899             :         memset(alloc, 0x00, SgLambdaCaptureList::pool_size * sizeof(SgLambdaCaptureList));
   61900             : #elif ROSE_ALLOC_MEMSET == 3
   61901             :         memset(alloc, 0xAA, SgLambdaCaptureList::pool_size * sizeof(SgLambdaCaptureList));
   61902             : #endif
   61903           0 :         for (unsigned i=0; i < SgLambdaCaptureList::pool_size-1; i++) {
   61904           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
   61905             :         }
   61906           0 :         alloc[SgLambdaCaptureList::pool_size-1].p_freepointer = nullptr;
   61907             : 
   61908           0 :         SgLambdaCaptureList::pools.push_back ( (unsigned char *) alloc );
   61909           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgLambdaCaptureList::pool_size * sizeof(SgLambdaCaptureList), V_SgLambdaCaptureList ) );
   61910           0 :         SgLambdaCaptureList::next_node = alloc;
   61911             :     }
   61912           0 :     ROSE_ASSERT(SgLambdaCaptureList::next_node != nullptr);
   61913             : 
   61914           0 :     SgLambdaCaptureList * object = SgLambdaCaptureList::next_node;
   61915           0 :     SgLambdaCaptureList::next_node = (SgLambdaCaptureList*)(object->p_freepointer);
   61916             : 
   61917             : #if ROSE_ALLOC_TRACE == 2
   61918             :     printf("SgLambdaCaptureList::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgLambdaCaptureList::next_node);
   61919             : #endif
   61920             : 
   61921           0 :     SgNode * fp = object->p_freepointer;
   61922             : #if ROSE_ALLOC_MEMSET == 1
   61923             : #elif ROSE_ALLOC_MEMSET == 2
   61924             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgLambdaCaptureList) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   61925             : #elif ROSE_ALLOC_MEMSET == 3
   61926             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgLambdaCaptureList) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   61927             : #endif
   61928           0 :     object->p_freepointer = fp;
   61929             : 
   61930             : #if ROSE_ALLOC_TRACE == 2
   61931             : //    printf("SgLambdaCaptureList::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgLambdaCaptureList::next_node);
   61932             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   61933             :     Rose::MemPool::snapshot(oss.str());
   61934             :     alloc_trace_cnt++;
   61935             : #endif
   61936             : 
   61937           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   61938             : 
   61939           0 :     ALLOC_MUTEX(SgLambdaCaptureList, unlock);
   61940             : 
   61941             :     return object;
   61942             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   61943             : }
   61944             : 
   61945             : 
   61946             : 
   61947             : /*! \brief Delete operator for SgLambdaCaptureList.
   61948             : 
   61949             :    This delete operator implements deallocation using memory pools to 
   61950             :    provide most efficent use of the heap within construction of large ASTs.
   61951             : 
   61952             : \internal The new and delete operators use the lower level C malloc/free
   61953             :    function calls for performance and to make sure that mixing of malloc/free
   61954             :    and new/delete by the used can be caught more readily.  This may change
   61955             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   61956             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   61957             :    deallocate memory allocated using ROSE_MALLOC.
   61958             : */
   61959           0 : void SgLambdaCaptureList::operator delete(void *Pointer, size_t Size)
   61960             : {
   61961             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   61962             :      * or throwing an exception. */
   61963           0 :     ALLOC_MUTEX(SgLambdaCaptureList, lock);
   61964             : 
   61965             : #if USE_CPP_NEW_DELETE_OPERATORS
   61966             :     ROSE_FREE(Pointer);
   61967             : #else
   61968             : #if ROSE_PEDANTIC_ALLOC
   61969             :     ROSE_ASSERT(Size == sizeof(SgLambdaCaptureList));
   61970             : #else
   61971           0 :     if (Size != sizeof(SgLambdaCaptureList)) {
   61972           0 :       ROSE_FREE(Pointer);
   61973           0 :       ALLOC_MUTEX(SgLambdaCaptureList, unlock);
   61974             :       return;
   61975             :     }
   61976             : #endif
   61977             : 
   61978           0 :     SgLambdaCaptureList * object = (SgLambdaCaptureList*) Pointer;
   61979           0 :     ROSE_ASSERT(object != nullptr);
   61980             : 
   61981             : #if ROSE_ALLOC_TRACE == 2
   61982             : //  printf("SgLambdaCaptureList::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgLambdaCaptureList::next_node);
   61983             :     printf("SgLambdaCaptureList::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgLambdaCaptureList::next_node);
   61984             : #endif
   61985             : 
   61986             : #if ROSE_PEDANTIC_ALLOC
   61987             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   61988             : #endif
   61989             : 
   61990             : #if ROSE_ALLOC_MEMSET == 1
   61991             : #elif ROSE_ALLOC_MEMSET == 2
   61992             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgLambdaCaptureList) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   61993             : #elif ROSE_ALLOC_MEMSET == 3
   61994             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgLambdaCaptureList) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   61995             : #endif
   61996             : 
   61997             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   61998             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   61999             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   62000             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   62001             : #else
   62002           0 :     object->p_freepointer = SgLambdaCaptureList::next_node;
   62003           0 :     SgLambdaCaptureList::next_node = object;
   62004             : #endif
   62005             : 
   62006             : #if ROSE_ALLOC_TRACE == 2
   62007             : //  printf("SgLambdaCaptureList::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgLambdaCaptureList::next_node);
   62008             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   62009             :     Rose::MemPool::snapshot(oss.str());
   62010             :     alloc_trace_cnt++;
   62011             : #endif
   62012             : 
   62013             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   62014             : 
   62015           0 :     ALLOC_MUTEX(SgLambdaCaptureList, unlock);
   62016             : }
   62017             : 
   62018             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   62019             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   62020             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   62021             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   62022             : // Also, note comment below from Robb (copied from the Common.code file).
   62023             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   62024             : //
   62025             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   62026             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   62027             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   62028             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   62029             : #if 0
   62030             : void SgLambdaCaptureList::operator delete(void* pointer) { SgLambdaCaptureList::operator delete (pointer, sizeof(SgLambdaCaptureList)); };
   62031             : #endif
   62032             : /* #line 62033 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   62033             : 
   62034             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   62035             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   62036             : // obviously imply C++.
   62037             : 
   62038             : // This implements the support within ROSE for memory pools.  Memory pools
   62039             : // support the most condensed usage of memory within the construction of
   62040             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   62041             : // by a new operator written for each class.
   62042             : 
   62043             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   62044             :     // User wants multi-thread support and POSIX threads are available.
   62045             : #   include <pthread.h>
   62046             :     static pthread_mutex_t SgStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   62047             : #else
   62048             :      // Cause synchronization to be skipped.
   62049             : #    ifndef ALLOC_MUTEX
   62050             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   62051             : #    endif
   62052             : #    ifdef _REENTRANT
   62053             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   62054             : #       ifdef _MSC_VER
   62055             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   62056             : #       else
   62057             : #           warning "POSIX threads are not available; synchronization being skipped"
   62058             : #       endif
   62059             : #    endif
   62060             : #endif
   62061             : 
   62062             : #ifndef ROSE_ALLOC_TRACE
   62063             : #  define ROSE_ALLOC_TRACE 0
   62064             : #endif
   62065             : 
   62066             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   62067             : #define ROSE_ALLOC_TRACE_CNT
   62068             : #include "memory-pool-snapshot.h"
   62069             : unsigned long alloc_trace_cnt = 0;
   62070             : #endif
   62071             : 
   62072             : #if ROSE_ALLOC_TRACE
   62073             : const unsigned SgStatement::pool_size = 5;
   62074             : #else
   62075             : const unsigned SgStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   62076             : #endif
   62077             : 
   62078             : #ifndef ROSE_ALLOC_MEMSET
   62079             : #  define ROSE_ALLOC_MEMSET 0
   62080             : #endif
   62081             : 
   62082             : #ifndef ROSE_PEDANTIC_ALLOC
   62083             : #  define ROSE_PEDANTIC_ALLOC 0
   62084             : #endif
   62085             : 
   62086             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   62087             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   62088             : #endif
   62089             : 
   62090             : #if !defined(SGNODE__ALL_POOLS)
   62091             : #define SGNODE__ALL_POOLS
   62092             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   62093             : #endif
   62094             : 
   62095             : SgStatement* SgStatement::next_node = nullptr;
   62096             : std::vector<unsigned char*> SgStatement::pools;
   62097             : 
   62098             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   62099             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   62100             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   62101             : // around this macro definition rather than each use).
   62102             : #ifndef ALLOC_MUTEX
   62103             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   62104             :         do {                                                                     \
   62105             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   62106             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   62107             :                 abort();                                                         \
   62108             :             }                                                                    \
   62109             :         } while (0);
   62110             : #endif
   62111             : 
   62112             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   62113             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   62114             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   62115             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   62116             : 
   62117             : /*! \brief New operator for SgStatement.
   62118             : 
   62119             :    This new operator implements memory pools to provide most efficent 
   62120             :    use of the heap within construction of large ASTs.
   62121             : 
   62122             : \internal The new and delete operators use the lower level C malloc/free
   62123             :    function calls for performance and to make sure that mixing of malloc/free
   62124             :    and new/delete by the used can be caught more readily.  This may change
   62125             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   62126             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   62127             :    deallocate memory allocated using ROSE_MALLOC.
   62128             : */
   62129           0 : void *SgStatement::operator new ( size_t Size )
   62130             : {
   62131             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   62132             :      * returning or throwing an exception. */
   62133           0 :     ALLOC_MUTEX(SgStatement, lock);
   62134             : 
   62135             : #if ROSE_ALLOC_TRACE == 2
   62136             : //    printf("SgStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgStatement::next_node);
   62137             : #endif
   62138             : 
   62139             : #if USE_CPP_NEW_DELETE_OPERATORS
   62140             :     void *mem = ROSE_MALLOC(Size);
   62141             :     ALLOC_MUTEX(SgStatement, unlock);
   62142             :     return mem;
   62143             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   62144             : #if ROSE_PEDANTIC_ALLOC
   62145             :     ROSE_ASSERT(Size == sizeof(SgStatement));
   62146             : #else
   62147           0 :     if (Size != sizeof(SgStatement)) {
   62148           0 :       void * object = ROSE_MALLOC(Size);
   62149           0 :       ALLOC_MUTEX(SgStatement, unlock);
   62150             :       return object;
   62151             :     }
   62152             : #endif
   62153             : 
   62154           0 :     if (SgStatement::next_node == nullptr) {
   62155           0 :         SgStatement * alloc = (SgStatement*) ROSE_MALLOC ( SgStatement::pool_size * sizeof(SgStatement) );
   62156           0 :         ROSE_ASSERT(alloc != nullptr);
   62157             : 
   62158             : #if ROSE_ALLOC_TRACE == 2
   62159             : //        printf("SgStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgStatement::pools.size(), alloc, alloc + SgStatement::pool_size);
   62160             : #endif
   62161             : 
   62162             : #if ROSE_ALLOC_MEMSET == 1
   62163             : #elif ROSE_ALLOC_MEMSET == 2
   62164             :         memset(alloc, 0x00, SgStatement::pool_size * sizeof(SgStatement));
   62165             : #elif ROSE_ALLOC_MEMSET == 3
   62166             :         memset(alloc, 0xAA, SgStatement::pool_size * sizeof(SgStatement));
   62167             : #endif
   62168           0 :         for (unsigned i=0; i < SgStatement::pool_size-1; i++) {
   62169           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
   62170             :         }
   62171           0 :         alloc[SgStatement::pool_size-1].p_freepointer = nullptr;
   62172             : 
   62173           0 :         SgStatement::pools.push_back ( (unsigned char *) alloc );
   62174           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgStatement::pool_size * sizeof(SgStatement), V_SgStatement ) );
   62175           0 :         SgStatement::next_node = alloc;
   62176             :     }
   62177           0 :     ROSE_ASSERT(SgStatement::next_node != nullptr);
   62178             : 
   62179           0 :     SgStatement * object = SgStatement::next_node;
   62180           0 :     SgStatement::next_node = (SgStatement*)(object->p_freepointer);
   62181             : 
   62182             : #if ROSE_ALLOC_TRACE == 2
   62183             :     printf("SgStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgStatement::next_node);
   62184             : #endif
   62185             : 
   62186           0 :     SgNode * fp = object->p_freepointer;
   62187             : #if ROSE_ALLOC_MEMSET == 1
   62188             : #elif ROSE_ALLOC_MEMSET == 2
   62189             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   62190             : #elif ROSE_ALLOC_MEMSET == 3
   62191             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   62192             : #endif
   62193           0 :     object->p_freepointer = fp;
   62194             : 
   62195             : #if ROSE_ALLOC_TRACE == 2
   62196             : //    printf("SgStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgStatement::next_node);
   62197             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   62198             :     Rose::MemPool::snapshot(oss.str());
   62199             :     alloc_trace_cnt++;
   62200             : #endif
   62201             : 
   62202           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   62203             : 
   62204           0 :     ALLOC_MUTEX(SgStatement, unlock);
   62205             : 
   62206             :     return object;
   62207             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   62208             : }
   62209             : 
   62210             : 
   62211             : 
   62212             : /*! \brief Delete operator for SgStatement.
   62213             : 
   62214             :    This delete operator implements deallocation using memory pools to 
   62215             :    provide most efficent use of the heap within construction of large ASTs.
   62216             : 
   62217             : \internal The new and delete operators use the lower level C malloc/free
   62218             :    function calls for performance and to make sure that mixing of malloc/free
   62219             :    and new/delete by the used can be caught more readily.  This may change
   62220             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   62221             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   62222             :    deallocate memory allocated using ROSE_MALLOC.
   62223             : */
   62224           0 : void SgStatement::operator delete(void *Pointer, size_t Size)
   62225             : {
   62226             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   62227             :      * or throwing an exception. */
   62228           0 :     ALLOC_MUTEX(SgStatement, lock);
   62229             : 
   62230             : #if USE_CPP_NEW_DELETE_OPERATORS
   62231             :     ROSE_FREE(Pointer);
   62232             : #else
   62233             : #if ROSE_PEDANTIC_ALLOC
   62234             :     ROSE_ASSERT(Size == sizeof(SgStatement));
   62235             : #else
   62236           0 :     if (Size != sizeof(SgStatement)) {
   62237           0 :       ROSE_FREE(Pointer);
   62238           0 :       ALLOC_MUTEX(SgStatement, unlock);
   62239             :       return;
   62240             :     }
   62241             : #endif
   62242             : 
   62243           0 :     SgStatement * object = (SgStatement*) Pointer;
   62244           0 :     ROSE_ASSERT(object != nullptr);
   62245             : 
   62246             : #if ROSE_ALLOC_TRACE == 2
   62247             : //  printf("SgStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgStatement::next_node);
   62248             :     printf("SgStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgStatement::next_node);
   62249             : #endif
   62250             : 
   62251             : #if ROSE_PEDANTIC_ALLOC
   62252             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   62253             : #endif
   62254             : 
   62255             : #if ROSE_ALLOC_MEMSET == 1
   62256             : #elif ROSE_ALLOC_MEMSET == 2
   62257             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   62258             : #elif ROSE_ALLOC_MEMSET == 3
   62259             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   62260             : #endif
   62261             : 
   62262             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   62263             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   62264             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   62265             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   62266             : #else
   62267           0 :     object->p_freepointer = SgStatement::next_node;
   62268           0 :     SgStatement::next_node = object;
   62269             : #endif
   62270             : 
   62271             : #if ROSE_ALLOC_TRACE == 2
   62272             : //  printf("SgStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgStatement::next_node);
   62273             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   62274             :     Rose::MemPool::snapshot(oss.str());
   62275             :     alloc_trace_cnt++;
   62276             : #endif
   62277             : 
   62278             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   62279             : 
   62280           0 :     ALLOC_MUTEX(SgStatement, unlock);
   62281             : }
   62282             : 
   62283             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   62284             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   62285             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   62286             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   62287             : // Also, note comment below from Robb (copied from the Common.code file).
   62288             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   62289             : //
   62290             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   62291             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   62292             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   62293             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   62294             : #if 0
   62295             : void SgStatement::operator delete(void* pointer) { SgStatement::operator delete (pointer, sizeof(SgStatement)); };
   62296             : #endif
   62297             : /* #line 62298 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   62298             : 
   62299             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   62300             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   62301             : // obviously imply C++.
   62302             : 
   62303             : // This implements the support within ROSE for memory pools.  Memory pools
   62304             : // support the most condensed usage of memory within the construction of
   62305             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   62306             : // by a new operator written for each class.
   62307             : 
   62308             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   62309             :     // User wants multi-thread support and POSIX threads are available.
   62310             : #   include <pthread.h>
   62311             :     static pthread_mutex_t SgScopeStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   62312             : #else
   62313             :      // Cause synchronization to be skipped.
   62314             : #    ifndef ALLOC_MUTEX
   62315             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   62316             : #    endif
   62317             : #    ifdef _REENTRANT
   62318             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   62319             : #       ifdef _MSC_VER
   62320             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   62321             : #       else
   62322             : #           warning "POSIX threads are not available; synchronization being skipped"
   62323             : #       endif
   62324             : #    endif
   62325             : #endif
   62326             : 
   62327             : #ifndef ROSE_ALLOC_TRACE
   62328             : #  define ROSE_ALLOC_TRACE 0
   62329             : #endif
   62330             : 
   62331             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   62332             : #define ROSE_ALLOC_TRACE_CNT
   62333             : #include "memory-pool-snapshot.h"
   62334             : unsigned long alloc_trace_cnt = 0;
   62335             : #endif
   62336             : 
   62337             : #if ROSE_ALLOC_TRACE
   62338             : const unsigned SgScopeStatement::pool_size = 5;
   62339             : #else
   62340             : const unsigned SgScopeStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   62341             : #endif
   62342             : 
   62343             : #ifndef ROSE_ALLOC_MEMSET
   62344             : #  define ROSE_ALLOC_MEMSET 0
   62345             : #endif
   62346             : 
   62347             : #ifndef ROSE_PEDANTIC_ALLOC
   62348             : #  define ROSE_PEDANTIC_ALLOC 0
   62349             : #endif
   62350             : 
   62351             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   62352             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   62353             : #endif
   62354             : 
   62355             : #if !defined(SGNODE__ALL_POOLS)
   62356             : #define SGNODE__ALL_POOLS
   62357             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   62358             : #endif
   62359             : 
   62360             : SgScopeStatement* SgScopeStatement::next_node = nullptr;
   62361             : std::vector<unsigned char*> SgScopeStatement::pools;
   62362             : 
   62363             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   62364             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   62365             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   62366             : // around this macro definition rather than each use).
   62367             : #ifndef ALLOC_MUTEX
   62368             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   62369             :         do {                                                                     \
   62370             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   62371             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   62372             :                 abort();                                                         \
   62373             :             }                                                                    \
   62374             :         } while (0);
   62375             : #endif
   62376             : 
   62377             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   62378             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   62379             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   62380             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   62381             : 
   62382             : /*! \brief New operator for SgScopeStatement.
   62383             : 
   62384             :    This new operator implements memory pools to provide most efficent 
   62385             :    use of the heap within construction of large ASTs.
   62386             : 
   62387             : \internal The new and delete operators use the lower level C malloc/free
   62388             :    function calls for performance and to make sure that mixing of malloc/free
   62389             :    and new/delete by the used can be caught more readily.  This may change
   62390             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   62391             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   62392             :    deallocate memory allocated using ROSE_MALLOC.
   62393             : */
   62394           0 : void *SgScopeStatement::operator new ( size_t Size )
   62395             : {
   62396             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   62397             :      * returning or throwing an exception. */
   62398           0 :     ALLOC_MUTEX(SgScopeStatement, lock);
   62399             : 
   62400             : #if ROSE_ALLOC_TRACE == 2
   62401             : //    printf("SgScopeStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgScopeStatement::next_node);
   62402             : #endif
   62403             : 
   62404             : #if USE_CPP_NEW_DELETE_OPERATORS
   62405             :     void *mem = ROSE_MALLOC(Size);
   62406             :     ALLOC_MUTEX(SgScopeStatement, unlock);
   62407             :     return mem;
   62408             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   62409             : #if ROSE_PEDANTIC_ALLOC
   62410             :     ROSE_ASSERT(Size == sizeof(SgScopeStatement));
   62411             : #else
   62412           0 :     if (Size != sizeof(SgScopeStatement)) {
   62413           0 :       void * object = ROSE_MALLOC(Size);
   62414           0 :       ALLOC_MUTEX(SgScopeStatement, unlock);
   62415             :       return object;
   62416             :     }
   62417             : #endif
   62418             : 
   62419           0 :     if (SgScopeStatement::next_node == nullptr) {
   62420           0 :         SgScopeStatement * alloc = (SgScopeStatement*) ROSE_MALLOC ( SgScopeStatement::pool_size * sizeof(SgScopeStatement) );
   62421           0 :         ROSE_ASSERT(alloc != nullptr);
   62422             : 
   62423             : #if ROSE_ALLOC_TRACE == 2
   62424             : //        printf("SgScopeStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgScopeStatement::pools.size(), alloc, alloc + SgScopeStatement::pool_size);
   62425             : #endif
   62426             : 
   62427             : #if ROSE_ALLOC_MEMSET == 1
   62428             : #elif ROSE_ALLOC_MEMSET == 2
   62429             :         memset(alloc, 0x00, SgScopeStatement::pool_size * sizeof(SgScopeStatement));
   62430             : #elif ROSE_ALLOC_MEMSET == 3
   62431             :         memset(alloc, 0xAA, SgScopeStatement::pool_size * sizeof(SgScopeStatement));
   62432             : #endif
   62433           0 :         for (unsigned i=0; i < SgScopeStatement::pool_size-1; i++) {
   62434           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
   62435             :         }
   62436           0 :         alloc[SgScopeStatement::pool_size-1].p_freepointer = nullptr;
   62437             : 
   62438           0 :         SgScopeStatement::pools.push_back ( (unsigned char *) alloc );
   62439           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgScopeStatement::pool_size * sizeof(SgScopeStatement), V_SgScopeStatement ) );
   62440           0 :         SgScopeStatement::next_node = alloc;
   62441             :     }
   62442           0 :     ROSE_ASSERT(SgScopeStatement::next_node != nullptr);
   62443             : 
   62444           0 :     SgScopeStatement * object = SgScopeStatement::next_node;
   62445           0 :     SgScopeStatement::next_node = (SgScopeStatement*)(object->p_freepointer);
   62446             : 
   62447             : #if ROSE_ALLOC_TRACE == 2
   62448             :     printf("SgScopeStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgScopeStatement::next_node);
   62449             : #endif
   62450             : 
   62451           0 :     SgNode * fp = object->p_freepointer;
   62452             : #if ROSE_ALLOC_MEMSET == 1
   62453             : #elif ROSE_ALLOC_MEMSET == 2
   62454             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgScopeStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   62455             : #elif ROSE_ALLOC_MEMSET == 3
   62456             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgScopeStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   62457             : #endif
   62458           0 :     object->p_freepointer = fp;
   62459             : 
   62460             : #if ROSE_ALLOC_TRACE == 2
   62461             : //    printf("SgScopeStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgScopeStatement::next_node);
   62462             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   62463             :     Rose::MemPool::snapshot(oss.str());
   62464             :     alloc_trace_cnt++;
   62465             : #endif
   62466             : 
   62467           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   62468             : 
   62469           0 :     ALLOC_MUTEX(SgScopeStatement, unlock);
   62470             : 
   62471             :     return object;
   62472             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   62473             : }
   62474             : 
   62475             : 
   62476             : 
   62477             : /*! \brief Delete operator for SgScopeStatement.
   62478             : 
   62479             :    This delete operator implements deallocation using memory pools to 
   62480             :    provide most efficent use of the heap within construction of large ASTs.
   62481             : 
   62482             : \internal The new and delete operators use the lower level C malloc/free
   62483             :    function calls for performance and to make sure that mixing of malloc/free
   62484             :    and new/delete by the used can be caught more readily.  This may change
   62485             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   62486             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   62487             :    deallocate memory allocated using ROSE_MALLOC.
   62488             : */
   62489           0 : void SgScopeStatement::operator delete(void *Pointer, size_t Size)
   62490             : {
   62491             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   62492             :      * or throwing an exception. */
   62493           0 :     ALLOC_MUTEX(SgScopeStatement, lock);
   62494             : 
   62495             : #if USE_CPP_NEW_DELETE_OPERATORS
   62496             :     ROSE_FREE(Pointer);
   62497             : #else
   62498             : #if ROSE_PEDANTIC_ALLOC
   62499             :     ROSE_ASSERT(Size == sizeof(SgScopeStatement));
   62500             : #else
   62501           0 :     if (Size != sizeof(SgScopeStatement)) {
   62502           0 :       ROSE_FREE(Pointer);
   62503           0 :       ALLOC_MUTEX(SgScopeStatement, unlock);
   62504             :       return;
   62505             :     }
   62506             : #endif
   62507             : 
   62508           0 :     SgScopeStatement * object = (SgScopeStatement*) Pointer;
   62509           0 :     ROSE_ASSERT(object != nullptr);
   62510             : 
   62511             : #if ROSE_ALLOC_TRACE == 2
   62512             : //  printf("SgScopeStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgScopeStatement::next_node);
   62513             :     printf("SgScopeStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgScopeStatement::next_node);
   62514             : #endif
   62515             : 
   62516             : #if ROSE_PEDANTIC_ALLOC
   62517             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   62518             : #endif
   62519             : 
   62520             : #if ROSE_ALLOC_MEMSET == 1
   62521             : #elif ROSE_ALLOC_MEMSET == 2
   62522             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgScopeStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   62523             : #elif ROSE_ALLOC_MEMSET == 3
   62524             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgScopeStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   62525             : #endif
   62526             : 
   62527             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   62528             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   62529             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   62530             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   62531             : #else
   62532           0 :     object->p_freepointer = SgScopeStatement::next_node;
   62533           0 :     SgScopeStatement::next_node = object;
   62534             : #endif
   62535             : 
   62536             : #if ROSE_ALLOC_TRACE == 2
   62537             : //  printf("SgScopeStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgScopeStatement::next_node);
   62538             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   62539             :     Rose::MemPool::snapshot(oss.str());
   62540             :     alloc_trace_cnt++;
   62541             : #endif
   62542             : 
   62543             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   62544             : 
   62545           0 :     ALLOC_MUTEX(SgScopeStatement, unlock);
   62546             : }
   62547             : 
   62548             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   62549             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   62550             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   62551             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   62552             : // Also, note comment below from Robb (copied from the Common.code file).
   62553             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   62554             : //
   62555             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   62556             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   62557             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   62558             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   62559             : #if 0
   62560             : void SgScopeStatement::operator delete(void* pointer) { SgScopeStatement::operator delete (pointer, sizeof(SgScopeStatement)); };
   62561             : #endif
   62562             : /* #line 62563 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   62563             : 
   62564             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   62565             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   62566             : // obviously imply C++.
   62567             : 
   62568             : // This implements the support within ROSE for memory pools.  Memory pools
   62569             : // support the most condensed usage of memory within the construction of
   62570             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   62571             : // by a new operator written for each class.
   62572             : 
   62573             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   62574             :     // User wants multi-thread support and POSIX threads are available.
   62575             : #   include <pthread.h>
   62576             :     static pthread_mutex_t SgGlobal_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   62577             : #else
   62578             :      // Cause synchronization to be skipped.
   62579             : #    ifndef ALLOC_MUTEX
   62580             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   62581             : #    endif
   62582             : #    ifdef _REENTRANT
   62583             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   62584             : #       ifdef _MSC_VER
   62585             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   62586             : #       else
   62587             : #           warning "POSIX threads are not available; synchronization being skipped"
   62588             : #       endif
   62589             : #    endif
   62590             : #endif
   62591             : 
   62592             : #ifndef ROSE_ALLOC_TRACE
   62593             : #  define ROSE_ALLOC_TRACE 0
   62594             : #endif
   62595             : 
   62596             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   62597             : #define ROSE_ALLOC_TRACE_CNT
   62598             : #include "memory-pool-snapshot.h"
   62599             : unsigned long alloc_trace_cnt = 0;
   62600             : #endif
   62601             : 
   62602             : #if ROSE_ALLOC_TRACE
   62603             : const unsigned SgGlobal::pool_size = 5;
   62604             : #else
   62605             : const unsigned SgGlobal::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   62606             : #endif
   62607             : 
   62608             : #ifndef ROSE_ALLOC_MEMSET
   62609             : #  define ROSE_ALLOC_MEMSET 0
   62610             : #endif
   62611             : 
   62612             : #ifndef ROSE_PEDANTIC_ALLOC
   62613             : #  define ROSE_PEDANTIC_ALLOC 0
   62614             : #endif
   62615             : 
   62616             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   62617             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   62618             : #endif
   62619             : 
   62620             : #if !defined(SGNODE__ALL_POOLS)
   62621             : #define SGNODE__ALL_POOLS
   62622             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   62623             : #endif
   62624             : 
   62625             : SgGlobal* SgGlobal::next_node = nullptr;
   62626             : std::vector<unsigned char*> SgGlobal::pools;
   62627             : 
   62628             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   62629             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   62630             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   62631             : // around this macro definition rather than each use).
   62632             : #ifndef ALLOC_MUTEX
   62633             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   62634             :         do {                                                                     \
   62635             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   62636             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   62637             :                 abort();                                                         \
   62638             :             }                                                                    \
   62639             :         } while (0);
   62640             : #endif
   62641             : 
   62642             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   62643             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   62644             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   62645             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   62646             : 
   62647             : /*! \brief New operator for SgGlobal.
   62648             : 
   62649             :    This new operator implements memory pools to provide most efficent 
   62650             :    use of the heap within construction of large ASTs.
   62651             : 
   62652             : \internal The new and delete operators use the lower level C malloc/free
   62653             :    function calls for performance and to make sure that mixing of malloc/free
   62654             :    and new/delete by the used can be caught more readily.  This may change
   62655             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   62656             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   62657             :    deallocate memory allocated using ROSE_MALLOC.
   62658             : */
   62659         718 : void *SgGlobal::operator new ( size_t Size )
   62660             : {
   62661             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   62662             :      * returning or throwing an exception. */
   62663         718 :     ALLOC_MUTEX(SgGlobal, lock);
   62664             : 
   62665             : #if ROSE_ALLOC_TRACE == 2
   62666             : //    printf("SgGlobal::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgGlobal::next_node);
   62667             : #endif
   62668             : 
   62669             : #if USE_CPP_NEW_DELETE_OPERATORS
   62670             :     void *mem = ROSE_MALLOC(Size);
   62671             :     ALLOC_MUTEX(SgGlobal, unlock);
   62672             :     return mem;
   62673             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   62674             : #if ROSE_PEDANTIC_ALLOC
   62675             :     ROSE_ASSERT(Size == sizeof(SgGlobal));
   62676             : #else
   62677         718 :     if (Size != sizeof(SgGlobal)) {
   62678           0 :       void * object = ROSE_MALLOC(Size);
   62679           0 :       ALLOC_MUTEX(SgGlobal, unlock);
   62680             :       return object;
   62681             :     }
   62682             : #endif
   62683             : 
   62684         718 :     if (SgGlobal::next_node == nullptr) {
   62685         355 :         SgGlobal * alloc = (SgGlobal*) ROSE_MALLOC ( SgGlobal::pool_size * sizeof(SgGlobal) );
   62686         355 :         ROSE_ASSERT(alloc != nullptr);
   62687             : 
   62688             : #if ROSE_ALLOC_TRACE == 2
   62689             : //        printf("SgGlobal::alloc\n  block[%zi] = [ %p , %p [\n", SgGlobal::pools.size(), alloc, alloc + SgGlobal::pool_size);
   62690             : #endif
   62691             : 
   62692             : #if ROSE_ALLOC_MEMSET == 1
   62693             : #elif ROSE_ALLOC_MEMSET == 2
   62694             :         memset(alloc, 0x00, SgGlobal::pool_size * sizeof(SgGlobal));
   62695             : #elif ROSE_ALLOC_MEMSET == 3
   62696             :         memset(alloc, 0xAA, SgGlobal::pool_size * sizeof(SgGlobal));
   62697             : #endif
   62698      710000 :         for (unsigned i=0; i < SgGlobal::pool_size-1; i++) {
   62699      709645 :           alloc[i].p_freepointer = &(alloc[i+1]);
   62700             :         }
   62701         355 :         alloc[SgGlobal::pool_size-1].p_freepointer = nullptr;
   62702             : 
   62703         355 :         SgGlobal::pools.push_back ( (unsigned char *) alloc );
   62704         355 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgGlobal::pool_size * sizeof(SgGlobal), V_SgGlobal ) );
   62705         355 :         SgGlobal::next_node = alloc;
   62706             :     }
   62707         718 :     ROSE_ASSERT(SgGlobal::next_node != nullptr);
   62708             : 
   62709         718 :     SgGlobal * object = SgGlobal::next_node;
   62710         718 :     SgGlobal::next_node = (SgGlobal*)(object->p_freepointer);
   62711             : 
   62712             : #if ROSE_ALLOC_TRACE == 2
   62713             :     printf("SgGlobal::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgGlobal::next_node);
   62714             : #endif
   62715             : 
   62716         718 :     SgNode * fp = object->p_freepointer;
   62717             : #if ROSE_ALLOC_MEMSET == 1
   62718             : #elif ROSE_ALLOC_MEMSET == 2
   62719             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgGlobal) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   62720             : #elif ROSE_ALLOC_MEMSET == 3
   62721             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgGlobal) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   62722             : #endif
   62723         718 :     object->p_freepointer = fp;
   62724             : 
   62725             : #if ROSE_ALLOC_TRACE == 2
   62726             : //    printf("SgGlobal::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgGlobal::next_node);
   62727             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   62728             :     Rose::MemPool::snapshot(oss.str());
   62729             :     alloc_trace_cnt++;
   62730             : #endif
   62731             : 
   62732         718 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   62733             : 
   62734         718 :     ALLOC_MUTEX(SgGlobal, unlock);
   62735             : 
   62736             :     return object;
   62737             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   62738             : }
   62739             : 
   62740             : 
   62741             : 
   62742             : /*! \brief Delete operator for SgGlobal.
   62743             : 
   62744             :    This delete operator implements deallocation using memory pools to 
   62745             :    provide most efficent use of the heap within construction of large ASTs.
   62746             : 
   62747             : \internal The new and delete operators use the lower level C malloc/free
   62748             :    function calls for performance and to make sure that mixing of malloc/free
   62749             :    and new/delete by the used can be caught more readily.  This may change
   62750             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   62751             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   62752             :    deallocate memory allocated using ROSE_MALLOC.
   62753             : */
   62754          12 : void SgGlobal::operator delete(void *Pointer, size_t Size)
   62755             : {
   62756             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   62757             :      * or throwing an exception. */
   62758          12 :     ALLOC_MUTEX(SgGlobal, lock);
   62759             : 
   62760             : #if USE_CPP_NEW_DELETE_OPERATORS
   62761             :     ROSE_FREE(Pointer);
   62762             : #else
   62763             : #if ROSE_PEDANTIC_ALLOC
   62764             :     ROSE_ASSERT(Size == sizeof(SgGlobal));
   62765             : #else
   62766          12 :     if (Size != sizeof(SgGlobal)) {
   62767           0 :       ROSE_FREE(Pointer);
   62768           0 :       ALLOC_MUTEX(SgGlobal, unlock);
   62769             :       return;
   62770             :     }
   62771             : #endif
   62772             : 
   62773          12 :     SgGlobal * object = (SgGlobal*) Pointer;
   62774          12 :     ROSE_ASSERT(object != nullptr);
   62775             : 
   62776             : #if ROSE_ALLOC_TRACE == 2
   62777             : //  printf("SgGlobal::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgGlobal::next_node);
   62778             :     printf("SgGlobal::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgGlobal::next_node);
   62779             : #endif
   62780             : 
   62781             : #if ROSE_PEDANTIC_ALLOC
   62782             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   62783             : #endif
   62784             : 
   62785             : #if ROSE_ALLOC_MEMSET == 1
   62786             : #elif ROSE_ALLOC_MEMSET == 2
   62787             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgGlobal) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   62788             : #elif ROSE_ALLOC_MEMSET == 3
   62789             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgGlobal) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   62790             : #endif
   62791             : 
   62792             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   62793             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   62794             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   62795             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   62796             : #else
   62797          12 :     object->p_freepointer = SgGlobal::next_node;
   62798          12 :     SgGlobal::next_node = object;
   62799             : #endif
   62800             : 
   62801             : #if ROSE_ALLOC_TRACE == 2
   62802             : //  printf("SgGlobal::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgGlobal::next_node);
   62803             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   62804             :     Rose::MemPool::snapshot(oss.str());
   62805             :     alloc_trace_cnt++;
   62806             : #endif
   62807             : 
   62808             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   62809             : 
   62810          12 :     ALLOC_MUTEX(SgGlobal, unlock);
   62811             : }
   62812             : 
   62813             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   62814             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   62815             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   62816             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   62817             : // Also, note comment below from Robb (copied from the Common.code file).
   62818             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   62819             : //
   62820             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   62821             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   62822             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   62823             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   62824             : #if 0
   62825             : void SgGlobal::operator delete(void* pointer) { SgGlobal::operator delete (pointer, sizeof(SgGlobal)); };
   62826             : #endif
   62827             : /* #line 62828 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   62828             : 
   62829             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   62830             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   62831             : // obviously imply C++.
   62832             : 
   62833             : // This implements the support within ROSE for memory pools.  Memory pools
   62834             : // support the most condensed usage of memory within the construction of
   62835             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   62836             : // by a new operator written for each class.
   62837             : 
   62838             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   62839             :     // User wants multi-thread support and POSIX threads are available.
   62840             : #   include <pthread.h>
   62841             :     static pthread_mutex_t SgBasicBlock_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   62842             : #else
   62843             :      // Cause synchronization to be skipped.
   62844             : #    ifndef ALLOC_MUTEX
   62845             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   62846             : #    endif
   62847             : #    ifdef _REENTRANT
   62848             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   62849             : #       ifdef _MSC_VER
   62850             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   62851             : #       else
   62852             : #           warning "POSIX threads are not available; synchronization being skipped"
   62853             : #       endif
   62854             : #    endif
   62855             : #endif
   62856             : 
   62857             : #ifndef ROSE_ALLOC_TRACE
   62858             : #  define ROSE_ALLOC_TRACE 0
   62859             : #endif
   62860             : 
   62861             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   62862             : #define ROSE_ALLOC_TRACE_CNT
   62863             : #include "memory-pool-snapshot.h"
   62864             : unsigned long alloc_trace_cnt = 0;
   62865             : #endif
   62866             : 
   62867             : #if ROSE_ALLOC_TRACE
   62868             : const unsigned SgBasicBlock::pool_size = 5;
   62869             : #else
   62870             : const unsigned SgBasicBlock::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   62871             : #endif
   62872             : 
   62873             : #ifndef ROSE_ALLOC_MEMSET
   62874             : #  define ROSE_ALLOC_MEMSET 0
   62875             : #endif
   62876             : 
   62877             : #ifndef ROSE_PEDANTIC_ALLOC
   62878             : #  define ROSE_PEDANTIC_ALLOC 0
   62879             : #endif
   62880             : 
   62881             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   62882             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   62883             : #endif
   62884             : 
   62885             : #if !defined(SGNODE__ALL_POOLS)
   62886             : #define SGNODE__ALL_POOLS
   62887             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   62888             : #endif
   62889             : 
   62890             : SgBasicBlock* SgBasicBlock::next_node = nullptr;
   62891             : std::vector<unsigned char*> SgBasicBlock::pools;
   62892             : 
   62893             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   62894             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   62895             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   62896             : // around this macro definition rather than each use).
   62897             : #ifndef ALLOC_MUTEX
   62898             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   62899             :         do {                                                                     \
   62900             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   62901             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   62902             :                 abort();                                                         \
   62903             :             }                                                                    \
   62904             :         } while (0);
   62905             : #endif
   62906             : 
   62907             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   62908             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   62909             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   62910             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   62911             : 
   62912             : /*! \brief New operator for SgBasicBlock.
   62913             : 
   62914             :    This new operator implements memory pools to provide most efficent 
   62915             :    use of the heap within construction of large ASTs.
   62916             : 
   62917             : \internal The new and delete operators use the lower level C malloc/free
   62918             :    function calls for performance and to make sure that mixing of malloc/free
   62919             :    and new/delete by the used can be caught more readily.  This may change
   62920             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   62921             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   62922             :    deallocate memory allocated using ROSE_MALLOC.
   62923             : */
   62924       31768 : void *SgBasicBlock::operator new ( size_t Size )
   62925             : {
   62926             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   62927             :      * returning or throwing an exception. */
   62928       31768 :     ALLOC_MUTEX(SgBasicBlock, lock);
   62929             : 
   62930             : #if ROSE_ALLOC_TRACE == 2
   62931             : //    printf("SgBasicBlock::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgBasicBlock::next_node);
   62932             : #endif
   62933             : 
   62934             : #if USE_CPP_NEW_DELETE_OPERATORS
   62935             :     void *mem = ROSE_MALLOC(Size);
   62936             :     ALLOC_MUTEX(SgBasicBlock, unlock);
   62937             :     return mem;
   62938             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   62939             : #if ROSE_PEDANTIC_ALLOC
   62940             :     ROSE_ASSERT(Size == sizeof(SgBasicBlock));
   62941             : #else
   62942       31768 :     if (Size != sizeof(SgBasicBlock)) {
   62943           0 :       void * object = ROSE_MALLOC(Size);
   62944           0 :       ALLOC_MUTEX(SgBasicBlock, unlock);
   62945             :       return object;
   62946             :     }
   62947             : #endif
   62948             : 
   62949       31768 :     if (SgBasicBlock::next_node == nullptr) {
   62950         338 :         SgBasicBlock * alloc = (SgBasicBlock*) ROSE_MALLOC ( SgBasicBlock::pool_size * sizeof(SgBasicBlock) );
   62951         338 :         ROSE_ASSERT(alloc != nullptr);
   62952             : 
   62953             : #if ROSE_ALLOC_TRACE == 2
   62954             : //        printf("SgBasicBlock::alloc\n  block[%zi] = [ %p , %p [\n", SgBasicBlock::pools.size(), alloc, alloc + SgBasicBlock::pool_size);
   62955             : #endif
   62956             : 
   62957             : #if ROSE_ALLOC_MEMSET == 1
   62958             : #elif ROSE_ALLOC_MEMSET == 2
   62959             :         memset(alloc, 0x00, SgBasicBlock::pool_size * sizeof(SgBasicBlock));
   62960             : #elif ROSE_ALLOC_MEMSET == 3
   62961             :         memset(alloc, 0xAA, SgBasicBlock::pool_size * sizeof(SgBasicBlock));
   62962             : #endif
   62963      676000 :         for (unsigned i=0; i < SgBasicBlock::pool_size-1; i++) {
   62964      675662 :           alloc[i].p_freepointer = &(alloc[i+1]);
   62965             :         }
   62966         338 :         alloc[SgBasicBlock::pool_size-1].p_freepointer = nullptr;
   62967             : 
   62968         338 :         SgBasicBlock::pools.push_back ( (unsigned char *) alloc );
   62969         338 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgBasicBlock::pool_size * sizeof(SgBasicBlock), V_SgBasicBlock ) );
   62970         338 :         SgBasicBlock::next_node = alloc;
   62971             :     }
   62972       31768 :     ROSE_ASSERT(SgBasicBlock::next_node != nullptr);
   62973             : 
   62974       31768 :     SgBasicBlock * object = SgBasicBlock::next_node;
   62975       31768 :     SgBasicBlock::next_node = (SgBasicBlock*)(object->p_freepointer);
   62976             : 
   62977             : #if ROSE_ALLOC_TRACE == 2
   62978             :     printf("SgBasicBlock::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgBasicBlock::next_node);
   62979             : #endif
   62980             : 
   62981       31768 :     SgNode * fp = object->p_freepointer;
   62982             : #if ROSE_ALLOC_MEMSET == 1
   62983             : #elif ROSE_ALLOC_MEMSET == 2
   62984             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgBasicBlock) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   62985             : #elif ROSE_ALLOC_MEMSET == 3
   62986             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgBasicBlock) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   62987             : #endif
   62988       31768 :     object->p_freepointer = fp;
   62989             : 
   62990             : #if ROSE_ALLOC_TRACE == 2
   62991             : //    printf("SgBasicBlock::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgBasicBlock::next_node);
   62992             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   62993             :     Rose::MemPool::snapshot(oss.str());
   62994             :     alloc_trace_cnt++;
   62995             : #endif
   62996             : 
   62997       31768 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   62998             : 
   62999       31768 :     ALLOC_MUTEX(SgBasicBlock, unlock);
   63000             : 
   63001             :     return object;
   63002             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   63003             : }
   63004             : 
   63005             : 
   63006             : 
   63007             : /*! \brief Delete operator for SgBasicBlock.
   63008             : 
   63009             :    This delete operator implements deallocation using memory pools to 
   63010             :    provide most efficent use of the heap within construction of large ASTs.
   63011             : 
   63012             : \internal The new and delete operators use the lower level C malloc/free
   63013             :    function calls for performance and to make sure that mixing of malloc/free
   63014             :    and new/delete by the used can be caught more readily.  This may change
   63015             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   63016             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   63017             :    deallocate memory allocated using ROSE_MALLOC.
   63018             : */
   63019        5731 : void SgBasicBlock::operator delete(void *Pointer, size_t Size)
   63020             : {
   63021             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   63022             :      * or throwing an exception. */
   63023        5731 :     ALLOC_MUTEX(SgBasicBlock, lock);
   63024             : 
   63025             : #if USE_CPP_NEW_DELETE_OPERATORS
   63026             :     ROSE_FREE(Pointer);
   63027             : #else
   63028             : #if ROSE_PEDANTIC_ALLOC
   63029             :     ROSE_ASSERT(Size == sizeof(SgBasicBlock));
   63030             : #else
   63031        5731 :     if (Size != sizeof(SgBasicBlock)) {
   63032           0 :       ROSE_FREE(Pointer);
   63033           0 :       ALLOC_MUTEX(SgBasicBlock, unlock);
   63034             :       return;
   63035             :     }
   63036             : #endif
   63037             : 
   63038        5731 :     SgBasicBlock * object = (SgBasicBlock*) Pointer;
   63039        5731 :     ROSE_ASSERT(object != nullptr);
   63040             : 
   63041             : #if ROSE_ALLOC_TRACE == 2
   63042             : //  printf("SgBasicBlock::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgBasicBlock::next_node);
   63043             :     printf("SgBasicBlock::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgBasicBlock::next_node);
   63044             : #endif
   63045             : 
   63046             : #if ROSE_PEDANTIC_ALLOC
   63047             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   63048             : #endif
   63049             : 
   63050             : #if ROSE_ALLOC_MEMSET == 1
   63051             : #elif ROSE_ALLOC_MEMSET == 2
   63052             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgBasicBlock) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   63053             : #elif ROSE_ALLOC_MEMSET == 3
   63054             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgBasicBlock) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   63055             : #endif
   63056             : 
   63057             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   63058             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   63059             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   63060             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   63061             : #else
   63062        5731 :     object->p_freepointer = SgBasicBlock::next_node;
   63063        5731 :     SgBasicBlock::next_node = object;
   63064             : #endif
   63065             : 
   63066             : #if ROSE_ALLOC_TRACE == 2
   63067             : //  printf("SgBasicBlock::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgBasicBlock::next_node);
   63068             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   63069             :     Rose::MemPool::snapshot(oss.str());
   63070             :     alloc_trace_cnt++;
   63071             : #endif
   63072             : 
   63073             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   63074             : 
   63075        5731 :     ALLOC_MUTEX(SgBasicBlock, unlock);
   63076             : }
   63077             : 
   63078             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   63079             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   63080             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   63081             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   63082             : // Also, note comment below from Robb (copied from the Common.code file).
   63083             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   63084             : //
   63085             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   63086             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   63087             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   63088             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   63089             : #if 0
   63090             : void SgBasicBlock::operator delete(void* pointer) { SgBasicBlock::operator delete (pointer, sizeof(SgBasicBlock)); };
   63091             : #endif
   63092             : /* #line 63093 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   63093             : 
   63094             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   63095             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   63096             : // obviously imply C++.
   63097             : 
   63098             : // This implements the support within ROSE for memory pools.  Memory pools
   63099             : // support the most condensed usage of memory within the construction of
   63100             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   63101             : // by a new operator written for each class.
   63102             : 
   63103             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   63104             :     // User wants multi-thread support and POSIX threads are available.
   63105             : #   include <pthread.h>
   63106             :     static pthread_mutex_t SgIfStmt_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   63107             : #else
   63108             :      // Cause synchronization to be skipped.
   63109             : #    ifndef ALLOC_MUTEX
   63110             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   63111             : #    endif
   63112             : #    ifdef _REENTRANT
   63113             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   63114             : #       ifdef _MSC_VER
   63115             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   63116             : #       else
   63117             : #           warning "POSIX threads are not available; synchronization being skipped"
   63118             : #       endif
   63119             : #    endif
   63120             : #endif
   63121             : 
   63122             : #ifndef ROSE_ALLOC_TRACE
   63123             : #  define ROSE_ALLOC_TRACE 0
   63124             : #endif
   63125             : 
   63126             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   63127             : #define ROSE_ALLOC_TRACE_CNT
   63128             : #include "memory-pool-snapshot.h"
   63129             : unsigned long alloc_trace_cnt = 0;
   63130             : #endif
   63131             : 
   63132             : #if ROSE_ALLOC_TRACE
   63133             : const unsigned SgIfStmt::pool_size = 5;
   63134             : #else
   63135             : const unsigned SgIfStmt::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   63136             : #endif
   63137             : 
   63138             : #ifndef ROSE_ALLOC_MEMSET
   63139             : #  define ROSE_ALLOC_MEMSET 0
   63140             : #endif
   63141             : 
   63142             : #ifndef ROSE_PEDANTIC_ALLOC
   63143             : #  define ROSE_PEDANTIC_ALLOC 0
   63144             : #endif
   63145             : 
   63146             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   63147             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   63148             : #endif
   63149             : 
   63150             : #if !defined(SGNODE__ALL_POOLS)
   63151             : #define SGNODE__ALL_POOLS
   63152             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   63153             : #endif
   63154             : 
   63155             : SgIfStmt* SgIfStmt::next_node = nullptr;
   63156             : std::vector<unsigned char*> SgIfStmt::pools;
   63157             : 
   63158             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   63159             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   63160             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   63161             : // around this macro definition rather than each use).
   63162             : #ifndef ALLOC_MUTEX
   63163             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   63164             :         do {                                                                     \
   63165             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   63166             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   63167             :                 abort();                                                         \
   63168             :             }                                                                    \
   63169             :         } while (0);
   63170             : #endif
   63171             : 
   63172             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   63173             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   63174             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   63175             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   63176             : 
   63177             : /*! \brief New operator for SgIfStmt.
   63178             : 
   63179             :    This new operator implements memory pools to provide most efficent 
   63180             :    use of the heap within construction of large ASTs.
   63181             : 
   63182             : \internal The new and delete operators use the lower level C malloc/free
   63183             :    function calls for performance and to make sure that mixing of malloc/free
   63184             :    and new/delete by the used can be caught more readily.  This may change
   63185             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   63186             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   63187             :    deallocate memory allocated using ROSE_MALLOC.
   63188             : */
   63189        5909 : void *SgIfStmt::operator new ( size_t Size )
   63190             : {
   63191             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   63192             :      * returning or throwing an exception. */
   63193        5909 :     ALLOC_MUTEX(SgIfStmt, lock);
   63194             : 
   63195             : #if ROSE_ALLOC_TRACE == 2
   63196             : //    printf("SgIfStmt::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgIfStmt::next_node);
   63197             : #endif
   63198             : 
   63199             : #if USE_CPP_NEW_DELETE_OPERATORS
   63200             :     void *mem = ROSE_MALLOC(Size);
   63201             :     ALLOC_MUTEX(SgIfStmt, unlock);
   63202             :     return mem;
   63203             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   63204             : #if ROSE_PEDANTIC_ALLOC
   63205             :     ROSE_ASSERT(Size == sizeof(SgIfStmt));
   63206             : #else
   63207        5909 :     if (Size != sizeof(SgIfStmt)) {
   63208           0 :       void * object = ROSE_MALLOC(Size);
   63209           0 :       ALLOC_MUTEX(SgIfStmt, unlock);
   63210             :       return object;
   63211             :     }
   63212             : #endif
   63213             : 
   63214        5909 :     if (SgIfStmt::next_node == nullptr) {
   63215          86 :         SgIfStmt * alloc = (SgIfStmt*) ROSE_MALLOC ( SgIfStmt::pool_size * sizeof(SgIfStmt) );
   63216          86 :         ROSE_ASSERT(alloc != nullptr);
   63217             : 
   63218             : #if ROSE_ALLOC_TRACE == 2
   63219             : //        printf("SgIfStmt::alloc\n  block[%zi] = [ %p , %p [\n", SgIfStmt::pools.size(), alloc, alloc + SgIfStmt::pool_size);
   63220             : #endif
   63221             : 
   63222             : #if ROSE_ALLOC_MEMSET == 1
   63223             : #elif ROSE_ALLOC_MEMSET == 2
   63224             :         memset(alloc, 0x00, SgIfStmt::pool_size * sizeof(SgIfStmt));
   63225             : #elif ROSE_ALLOC_MEMSET == 3
   63226             :         memset(alloc, 0xAA, SgIfStmt::pool_size * sizeof(SgIfStmt));
   63227             : #endif
   63228      172000 :         for (unsigned i=0; i < SgIfStmt::pool_size-1; i++) {
   63229      171914 :           alloc[i].p_freepointer = &(alloc[i+1]);
   63230             :         }
   63231          86 :         alloc[SgIfStmt::pool_size-1].p_freepointer = nullptr;
   63232             : 
   63233          86 :         SgIfStmt::pools.push_back ( (unsigned char *) alloc );
   63234          86 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgIfStmt::pool_size * sizeof(SgIfStmt), V_SgIfStmt ) );
   63235          86 :         SgIfStmt::next_node = alloc;
   63236             :     }
   63237        5909 :     ROSE_ASSERT(SgIfStmt::next_node != nullptr);
   63238             : 
   63239        5909 :     SgIfStmt * object = SgIfStmt::next_node;
   63240        5909 :     SgIfStmt::next_node = (SgIfStmt*)(object->p_freepointer);
   63241             : 
   63242             : #if ROSE_ALLOC_TRACE == 2
   63243             :     printf("SgIfStmt::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgIfStmt::next_node);
   63244             : #endif
   63245             : 
   63246        5909 :     SgNode * fp = object->p_freepointer;
   63247             : #if ROSE_ALLOC_MEMSET == 1
   63248             : #elif ROSE_ALLOC_MEMSET == 2
   63249             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgIfStmt) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   63250             : #elif ROSE_ALLOC_MEMSET == 3
   63251             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgIfStmt) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   63252             : #endif
   63253        5909 :     object->p_freepointer = fp;
   63254             : 
   63255             : #if ROSE_ALLOC_TRACE == 2
   63256             : //    printf("SgIfStmt::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgIfStmt::next_node);
   63257             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   63258             :     Rose::MemPool::snapshot(oss.str());
   63259             :     alloc_trace_cnt++;
   63260             : #endif
   63261             : 
   63262        5909 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   63263             : 
   63264        5909 :     ALLOC_MUTEX(SgIfStmt, unlock);
   63265             : 
   63266             :     return object;
   63267             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   63268             : }
   63269             : 
   63270             : 
   63271             : 
   63272             : /*! \brief Delete operator for SgIfStmt.
   63273             : 
   63274             :    This delete operator implements deallocation using memory pools to 
   63275             :    provide most efficent use of the heap within construction of large ASTs.
   63276             : 
   63277             : \internal The new and delete operators use the lower level C malloc/free
   63278             :    function calls for performance and to make sure that mixing of malloc/free
   63279             :    and new/delete by the used can be caught more readily.  This may change
   63280             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   63281             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   63282             :    deallocate memory allocated using ROSE_MALLOC.
   63283             : */
   63284        1184 : void SgIfStmt::operator delete(void *Pointer, size_t Size)
   63285             : {
   63286             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   63287             :      * or throwing an exception. */
   63288        1184 :     ALLOC_MUTEX(SgIfStmt, lock);
   63289             : 
   63290             : #if USE_CPP_NEW_DELETE_OPERATORS
   63291             :     ROSE_FREE(Pointer);
   63292             : #else
   63293             : #if ROSE_PEDANTIC_ALLOC
   63294             :     ROSE_ASSERT(Size == sizeof(SgIfStmt));
   63295             : #else
   63296        1184 :     if (Size != sizeof(SgIfStmt)) {
   63297           0 :       ROSE_FREE(Pointer);
   63298           0 :       ALLOC_MUTEX(SgIfStmt, unlock);
   63299             :       return;
   63300             :     }
   63301             : #endif
   63302             : 
   63303        1184 :     SgIfStmt * object = (SgIfStmt*) Pointer;
   63304        1184 :     ROSE_ASSERT(object != nullptr);
   63305             : 
   63306             : #if ROSE_ALLOC_TRACE == 2
   63307             : //  printf("SgIfStmt::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgIfStmt::next_node);
   63308             :     printf("SgIfStmt::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgIfStmt::next_node);
   63309             : #endif
   63310             : 
   63311             : #if ROSE_PEDANTIC_ALLOC
   63312             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   63313             : #endif
   63314             : 
   63315             : #if ROSE_ALLOC_MEMSET == 1
   63316             : #elif ROSE_ALLOC_MEMSET == 2
   63317             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgIfStmt) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   63318             : #elif ROSE_ALLOC_MEMSET == 3
   63319             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgIfStmt) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   63320             : #endif
   63321             : 
   63322             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   63323             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   63324             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   63325             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   63326             : #else
   63327        1184 :     object->p_freepointer = SgIfStmt::next_node;
   63328        1184 :     SgIfStmt::next_node = object;
   63329             : #endif
   63330             : 
   63331             : #if ROSE_ALLOC_TRACE == 2
   63332             : //  printf("SgIfStmt::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgIfStmt::next_node);
   63333             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   63334             :     Rose::MemPool::snapshot(oss.str());
   63335             :     alloc_trace_cnt++;
   63336             : #endif
   63337             : 
   63338             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   63339             : 
   63340        1184 :     ALLOC_MUTEX(SgIfStmt, unlock);
   63341             : }
   63342             : 
   63343             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   63344             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   63345             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   63346             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   63347             : // Also, note comment below from Robb (copied from the Common.code file).
   63348             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   63349             : //
   63350             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   63351             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   63352             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   63353             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   63354             : #if 0
   63355             : void SgIfStmt::operator delete(void* pointer) { SgIfStmt::operator delete (pointer, sizeof(SgIfStmt)); };
   63356             : #endif
   63357             : /* #line 63358 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   63358             : 
   63359             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   63360             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   63361             : // obviously imply C++.
   63362             : 
   63363             : // This implements the support within ROSE for memory pools.  Memory pools
   63364             : // support the most condensed usage of memory within the construction of
   63365             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   63366             : // by a new operator written for each class.
   63367             : 
   63368             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   63369             :     // User wants multi-thread support and POSIX threads are available.
   63370             : #   include <pthread.h>
   63371             :     static pthread_mutex_t SgForStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   63372             : #else
   63373             :      // Cause synchronization to be skipped.
   63374             : #    ifndef ALLOC_MUTEX
   63375             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   63376             : #    endif
   63377             : #    ifdef _REENTRANT
   63378             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   63379             : #       ifdef _MSC_VER
   63380             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   63381             : #       else
   63382             : #           warning "POSIX threads are not available; synchronization being skipped"
   63383             : #       endif
   63384             : #    endif
   63385             : #endif
   63386             : 
   63387             : #ifndef ROSE_ALLOC_TRACE
   63388             : #  define ROSE_ALLOC_TRACE 0
   63389             : #endif
   63390             : 
   63391             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   63392             : #define ROSE_ALLOC_TRACE_CNT
   63393             : #include "memory-pool-snapshot.h"
   63394             : unsigned long alloc_trace_cnt = 0;
   63395             : #endif
   63396             : 
   63397             : #if ROSE_ALLOC_TRACE
   63398             : const unsigned SgForStatement::pool_size = 5;
   63399             : #else
   63400             : const unsigned SgForStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   63401             : #endif
   63402             : 
   63403             : #ifndef ROSE_ALLOC_MEMSET
   63404             : #  define ROSE_ALLOC_MEMSET 0
   63405             : #endif
   63406             : 
   63407             : #ifndef ROSE_PEDANTIC_ALLOC
   63408             : #  define ROSE_PEDANTIC_ALLOC 0
   63409             : #endif
   63410             : 
   63411             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   63412             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   63413             : #endif
   63414             : 
   63415             : #if !defined(SGNODE__ALL_POOLS)
   63416             : #define SGNODE__ALL_POOLS
   63417             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   63418             : #endif
   63419             : 
   63420             : SgForStatement* SgForStatement::next_node = nullptr;
   63421             : std::vector<unsigned char*> SgForStatement::pools;
   63422             : 
   63423             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   63424             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   63425             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   63426             : // around this macro definition rather than each use).
   63427             : #ifndef ALLOC_MUTEX
   63428             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   63429             :         do {                                                                     \
   63430             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   63431             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   63432             :                 abort();                                                         \
   63433             :             }                                                                    \
   63434             :         } while (0);
   63435             : #endif
   63436             : 
   63437             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   63438             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   63439             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   63440             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   63441             : 
   63442             : /*! \brief New operator for SgForStatement.
   63443             : 
   63444             :    This new operator implements memory pools to provide most efficent 
   63445             :    use of the heap within construction of large ASTs.
   63446             : 
   63447             : \internal The new and delete operators use the lower level C malloc/free
   63448             :    function calls for performance and to make sure that mixing of malloc/free
   63449             :    and new/delete by the used can be caught more readily.  This may change
   63450             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   63451             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   63452             :    deallocate memory allocated using ROSE_MALLOC.
   63453             : */
   63454        1009 : void *SgForStatement::operator new ( size_t Size )
   63455             : {
   63456             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   63457             :      * returning or throwing an exception. */
   63458        1009 :     ALLOC_MUTEX(SgForStatement, lock);
   63459             : 
   63460             : #if ROSE_ALLOC_TRACE == 2
   63461             : //    printf("SgForStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgForStatement::next_node);
   63462             : #endif
   63463             : 
   63464             : #if USE_CPP_NEW_DELETE_OPERATORS
   63465             :     void *mem = ROSE_MALLOC(Size);
   63466             :     ALLOC_MUTEX(SgForStatement, unlock);
   63467             :     return mem;
   63468             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   63469             : #if ROSE_PEDANTIC_ALLOC
   63470             :     ROSE_ASSERT(Size == sizeof(SgForStatement));
   63471             : #else
   63472        1009 :     if (Size != sizeof(SgForStatement)) {
   63473           0 :       void * object = ROSE_MALLOC(Size);
   63474           0 :       ALLOC_MUTEX(SgForStatement, unlock);
   63475             :       return object;
   63476             :     }
   63477             : #endif
   63478             : 
   63479        1009 :     if (SgForStatement::next_node == nullptr) {
   63480         172 :         SgForStatement * alloc = (SgForStatement*) ROSE_MALLOC ( SgForStatement::pool_size * sizeof(SgForStatement) );
   63481         172 :         ROSE_ASSERT(alloc != nullptr);
   63482             : 
   63483             : #if ROSE_ALLOC_TRACE == 2
   63484             : //        printf("SgForStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgForStatement::pools.size(), alloc, alloc + SgForStatement::pool_size);
   63485             : #endif
   63486             : 
   63487             : #if ROSE_ALLOC_MEMSET == 1
   63488             : #elif ROSE_ALLOC_MEMSET == 2
   63489             :         memset(alloc, 0x00, SgForStatement::pool_size * sizeof(SgForStatement));
   63490             : #elif ROSE_ALLOC_MEMSET == 3
   63491             :         memset(alloc, 0xAA, SgForStatement::pool_size * sizeof(SgForStatement));
   63492             : #endif
   63493      344000 :         for (unsigned i=0; i < SgForStatement::pool_size-1; i++) {
   63494      343828 :           alloc[i].p_freepointer = &(alloc[i+1]);
   63495             :         }
   63496         172 :         alloc[SgForStatement::pool_size-1].p_freepointer = nullptr;
   63497             : 
   63498         172 :         SgForStatement::pools.push_back ( (unsigned char *) alloc );
   63499         172 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgForStatement::pool_size * sizeof(SgForStatement), V_SgForStatement ) );
   63500         172 :         SgForStatement::next_node = alloc;
   63501             :     }
   63502        1009 :     ROSE_ASSERT(SgForStatement::next_node != nullptr);
   63503             : 
   63504        1009 :     SgForStatement * object = SgForStatement::next_node;
   63505        1009 :     SgForStatement::next_node = (SgForStatement*)(object->p_freepointer);
   63506             : 
   63507             : #if ROSE_ALLOC_TRACE == 2
   63508             :     printf("SgForStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgForStatement::next_node);
   63509             : #endif
   63510             : 
   63511        1009 :     SgNode * fp = object->p_freepointer;
   63512             : #if ROSE_ALLOC_MEMSET == 1
   63513             : #elif ROSE_ALLOC_MEMSET == 2
   63514             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgForStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   63515             : #elif ROSE_ALLOC_MEMSET == 3
   63516             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgForStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   63517             : #endif
   63518        1009 :     object->p_freepointer = fp;
   63519             : 
   63520             : #if ROSE_ALLOC_TRACE == 2
   63521             : //    printf("SgForStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgForStatement::next_node);
   63522             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   63523             :     Rose::MemPool::snapshot(oss.str());
   63524             :     alloc_trace_cnt++;
   63525             : #endif
   63526             : 
   63527        1009 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   63528             : 
   63529        1009 :     ALLOC_MUTEX(SgForStatement, unlock);
   63530             : 
   63531             :     return object;
   63532             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   63533             : }
   63534             : 
   63535             : 
   63536             : 
   63537             : /*! \brief Delete operator for SgForStatement.
   63538             : 
   63539             :    This delete operator implements deallocation using memory pools to 
   63540             :    provide most efficent use of the heap within construction of large ASTs.
   63541             : 
   63542             : \internal The new and delete operators use the lower level C malloc/free
   63543             :    function calls for performance and to make sure that mixing of malloc/free
   63544             :    and new/delete by the used can be caught more readily.  This may change
   63545             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   63546             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   63547             :    deallocate memory allocated using ROSE_MALLOC.
   63548             : */
   63549          80 : void SgForStatement::operator delete(void *Pointer, size_t Size)
   63550             : {
   63551             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   63552             :      * or throwing an exception. */
   63553          80 :     ALLOC_MUTEX(SgForStatement, lock);
   63554             : 
   63555             : #if USE_CPP_NEW_DELETE_OPERATORS
   63556             :     ROSE_FREE(Pointer);
   63557             : #else
   63558             : #if ROSE_PEDANTIC_ALLOC
   63559             :     ROSE_ASSERT(Size == sizeof(SgForStatement));
   63560             : #else
   63561          80 :     if (Size != sizeof(SgForStatement)) {
   63562           0 :       ROSE_FREE(Pointer);
   63563           0 :       ALLOC_MUTEX(SgForStatement, unlock);
   63564             :       return;
   63565             :     }
   63566             : #endif
   63567             : 
   63568          80 :     SgForStatement * object = (SgForStatement*) Pointer;
   63569          80 :     ROSE_ASSERT(object != nullptr);
   63570             : 
   63571             : #if ROSE_ALLOC_TRACE == 2
   63572             : //  printf("SgForStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgForStatement::next_node);
   63573             :     printf("SgForStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgForStatement::next_node);
   63574             : #endif
   63575             : 
   63576             : #if ROSE_PEDANTIC_ALLOC
   63577             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   63578             : #endif
   63579             : 
   63580             : #if ROSE_ALLOC_MEMSET == 1
   63581             : #elif ROSE_ALLOC_MEMSET == 2
   63582             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgForStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   63583             : #elif ROSE_ALLOC_MEMSET == 3
   63584             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgForStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   63585             : #endif
   63586             : 
   63587             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   63588             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   63589             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   63590             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   63591             : #else
   63592          80 :     object->p_freepointer = SgForStatement::next_node;
   63593          80 :     SgForStatement::next_node = object;
   63594             : #endif
   63595             : 
   63596             : #if ROSE_ALLOC_TRACE == 2
   63597             : //  printf("SgForStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgForStatement::next_node);
   63598             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   63599             :     Rose::MemPool::snapshot(oss.str());
   63600             :     alloc_trace_cnt++;
   63601             : #endif
   63602             : 
   63603             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   63604             : 
   63605          80 :     ALLOC_MUTEX(SgForStatement, unlock);
   63606             : }
   63607             : 
   63608             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   63609             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   63610             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   63611             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   63612             : // Also, note comment below from Robb (copied from the Common.code file).
   63613             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   63614             : //
   63615             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   63616             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   63617             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   63618             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   63619             : #if 0
   63620             : void SgForStatement::operator delete(void* pointer) { SgForStatement::operator delete (pointer, sizeof(SgForStatement)); };
   63621             : #endif
   63622             : /* #line 63623 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   63623             : 
   63624             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   63625             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   63626             : // obviously imply C++.
   63627             : 
   63628             : // This implements the support within ROSE for memory pools.  Memory pools
   63629             : // support the most condensed usage of memory within the construction of
   63630             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   63631             : // by a new operator written for each class.
   63632             : 
   63633             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   63634             :     // User wants multi-thread support and POSIX threads are available.
   63635             : #   include <pthread.h>
   63636             :     static pthread_mutex_t SgFunctionDefinition_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   63637             : #else
   63638             :      // Cause synchronization to be skipped.
   63639             : #    ifndef ALLOC_MUTEX
   63640             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   63641             : #    endif
   63642             : #    ifdef _REENTRANT
   63643             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   63644             : #       ifdef _MSC_VER
   63645             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   63646             : #       else
   63647             : #           warning "POSIX threads are not available; synchronization being skipped"
   63648             : #       endif
   63649             : #    endif
   63650             : #endif
   63651             : 
   63652             : #ifndef ROSE_ALLOC_TRACE
   63653             : #  define ROSE_ALLOC_TRACE 0
   63654             : #endif
   63655             : 
   63656             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   63657             : #define ROSE_ALLOC_TRACE_CNT
   63658             : #include "memory-pool-snapshot.h"
   63659             : unsigned long alloc_trace_cnt = 0;
   63660             : #endif
   63661             : 
   63662             : #if ROSE_ALLOC_TRACE
   63663             : const unsigned SgFunctionDefinition::pool_size = 5;
   63664             : #else
   63665             : const unsigned SgFunctionDefinition::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   63666             : #endif
   63667             : 
   63668             : #ifndef ROSE_ALLOC_MEMSET
   63669             : #  define ROSE_ALLOC_MEMSET 0
   63670             : #endif
   63671             : 
   63672             : #ifndef ROSE_PEDANTIC_ALLOC
   63673             : #  define ROSE_PEDANTIC_ALLOC 0
   63674             : #endif
   63675             : 
   63676             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   63677             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   63678             : #endif
   63679             : 
   63680             : #if !defined(SGNODE__ALL_POOLS)
   63681             : #define SGNODE__ALL_POOLS
   63682             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   63683             : #endif
   63684             : 
   63685             : SgFunctionDefinition* SgFunctionDefinition::next_node = nullptr;
   63686             : std::vector<unsigned char*> SgFunctionDefinition::pools;
   63687             : 
   63688             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   63689             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   63690             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   63691             : // around this macro definition rather than each use).
   63692             : #ifndef ALLOC_MUTEX
   63693             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   63694             :         do {                                                                     \
   63695             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   63696             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   63697             :                 abort();                                                         \
   63698             :             }                                                                    \
   63699             :         } while (0);
   63700             : #endif
   63701             : 
   63702             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   63703             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   63704             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   63705             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   63706             : 
   63707             : /*! \brief New operator for SgFunctionDefinition.
   63708             : 
   63709             :    This new operator implements memory pools to provide most efficent 
   63710             :    use of the heap within construction of large ASTs.
   63711             : 
   63712             : \internal The new and delete operators use the lower level C malloc/free
   63713             :    function calls for performance and to make sure that mixing of malloc/free
   63714             :    and new/delete by the used can be caught more readily.  This may change
   63715             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   63716             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   63717             :    deallocate memory allocated using ROSE_MALLOC.
   63718             : */
   63719       17668 : void *SgFunctionDefinition::operator new ( size_t Size )
   63720             : {
   63721             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   63722             :      * returning or throwing an exception. */
   63723       17668 :     ALLOC_MUTEX(SgFunctionDefinition, lock);
   63724             : 
   63725             : #if ROSE_ALLOC_TRACE == 2
   63726             : //    printf("SgFunctionDefinition::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgFunctionDefinition::next_node);
   63727             : #endif
   63728             : 
   63729             : #if USE_CPP_NEW_DELETE_OPERATORS
   63730             :     void *mem = ROSE_MALLOC(Size);
   63731             :     ALLOC_MUTEX(SgFunctionDefinition, unlock);
   63732             :     return mem;
   63733             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   63734             : #if ROSE_PEDANTIC_ALLOC
   63735             :     ROSE_ASSERT(Size == sizeof(SgFunctionDefinition));
   63736             : #else
   63737       17668 :     if (Size != sizeof(SgFunctionDefinition)) {
   63738           0 :       void * object = ROSE_MALLOC(Size);
   63739           0 :       ALLOC_MUTEX(SgFunctionDefinition, unlock);
   63740             :       return object;
   63741             :     }
   63742             : #endif
   63743             : 
   63744       17668 :     if (SgFunctionDefinition::next_node == nullptr) {
   63745         330 :         SgFunctionDefinition * alloc = (SgFunctionDefinition*) ROSE_MALLOC ( SgFunctionDefinition::pool_size * sizeof(SgFunctionDefinition) );
   63746         330 :         ROSE_ASSERT(alloc != nullptr);
   63747             : 
   63748             : #if ROSE_ALLOC_TRACE == 2
   63749             : //        printf("SgFunctionDefinition::alloc\n  block[%zi] = [ %p , %p [\n", SgFunctionDefinition::pools.size(), alloc, alloc + SgFunctionDefinition::pool_size);
   63750             : #endif
   63751             : 
   63752             : #if ROSE_ALLOC_MEMSET == 1
   63753             : #elif ROSE_ALLOC_MEMSET == 2
   63754             :         memset(alloc, 0x00, SgFunctionDefinition::pool_size * sizeof(SgFunctionDefinition));
   63755             : #elif ROSE_ALLOC_MEMSET == 3
   63756             :         memset(alloc, 0xAA, SgFunctionDefinition::pool_size * sizeof(SgFunctionDefinition));
   63757             : #endif
   63758      660000 :         for (unsigned i=0; i < SgFunctionDefinition::pool_size-1; i++) {
   63759      659670 :           alloc[i].p_freepointer = &(alloc[i+1]);
   63760             :         }
   63761         330 :         alloc[SgFunctionDefinition::pool_size-1].p_freepointer = nullptr;
   63762             : 
   63763         330 :         SgFunctionDefinition::pools.push_back ( (unsigned char *) alloc );
   63764         330 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgFunctionDefinition::pool_size * sizeof(SgFunctionDefinition), V_SgFunctionDefinition ) );
   63765         330 :         SgFunctionDefinition::next_node = alloc;
   63766             :     }
   63767       17668 :     ROSE_ASSERT(SgFunctionDefinition::next_node != nullptr);
   63768             : 
   63769       17668 :     SgFunctionDefinition * object = SgFunctionDefinition::next_node;
   63770       17668 :     SgFunctionDefinition::next_node = (SgFunctionDefinition*)(object->p_freepointer);
   63771             : 
   63772             : #if ROSE_ALLOC_TRACE == 2
   63773             :     printf("SgFunctionDefinition::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgFunctionDefinition::next_node);
   63774             : #endif
   63775             : 
   63776       17668 :     SgNode * fp = object->p_freepointer;
   63777             : #if ROSE_ALLOC_MEMSET == 1
   63778             : #elif ROSE_ALLOC_MEMSET == 2
   63779             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgFunctionDefinition) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   63780             : #elif ROSE_ALLOC_MEMSET == 3
   63781             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgFunctionDefinition) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   63782             : #endif
   63783       17668 :     object->p_freepointer = fp;
   63784             : 
   63785             : #if ROSE_ALLOC_TRACE == 2
   63786             : //    printf("SgFunctionDefinition::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgFunctionDefinition::next_node);
   63787             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   63788             :     Rose::MemPool::snapshot(oss.str());
   63789             :     alloc_trace_cnt++;
   63790             : #endif
   63791             : 
   63792       17668 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   63793             : 
   63794       17668 :     ALLOC_MUTEX(SgFunctionDefinition, unlock);
   63795             : 
   63796             :     return object;
   63797             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   63798             : }
   63799             : 
   63800             : 
   63801             : 
   63802             : /*! \brief Delete operator for SgFunctionDefinition.
   63803             : 
   63804             :    This delete operator implements deallocation using memory pools to 
   63805             :    provide most efficent use of the heap within construction of large ASTs.
   63806             : 
   63807             : \internal The new and delete operators use the lower level C malloc/free
   63808             :    function calls for performance and to make sure that mixing of malloc/free
   63809             :    and new/delete by the used can be caught more readily.  This may change
   63810             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   63811             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   63812             :    deallocate memory allocated using ROSE_MALLOC.
   63813             : */
   63814        3165 : void SgFunctionDefinition::operator delete(void *Pointer, size_t Size)
   63815             : {
   63816             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   63817             :      * or throwing an exception. */
   63818        3165 :     ALLOC_MUTEX(SgFunctionDefinition, lock);
   63819             : 
   63820             : #if USE_CPP_NEW_DELETE_OPERATORS
   63821             :     ROSE_FREE(Pointer);
   63822             : #else
   63823             : #if ROSE_PEDANTIC_ALLOC
   63824             :     ROSE_ASSERT(Size == sizeof(SgFunctionDefinition));
   63825             : #else
   63826        3165 :     if (Size != sizeof(SgFunctionDefinition)) {
   63827           0 :       ROSE_FREE(Pointer);
   63828           0 :       ALLOC_MUTEX(SgFunctionDefinition, unlock);
   63829             :       return;
   63830             :     }
   63831             : #endif
   63832             : 
   63833        3165 :     SgFunctionDefinition * object = (SgFunctionDefinition*) Pointer;
   63834        3165 :     ROSE_ASSERT(object != nullptr);
   63835             : 
   63836             : #if ROSE_ALLOC_TRACE == 2
   63837             : //  printf("SgFunctionDefinition::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgFunctionDefinition::next_node);
   63838             :     printf("SgFunctionDefinition::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgFunctionDefinition::next_node);
   63839             : #endif
   63840             : 
   63841             : #if ROSE_PEDANTIC_ALLOC
   63842             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   63843             : #endif
   63844             : 
   63845             : #if ROSE_ALLOC_MEMSET == 1
   63846             : #elif ROSE_ALLOC_MEMSET == 2
   63847             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgFunctionDefinition) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   63848             : #elif ROSE_ALLOC_MEMSET == 3
   63849             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgFunctionDefinition) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   63850             : #endif
   63851             : 
   63852             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   63853             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   63854             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   63855             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   63856             : #else
   63857        3165 :     object->p_freepointer = SgFunctionDefinition::next_node;
   63858        3165 :     SgFunctionDefinition::next_node = object;
   63859             : #endif
   63860             : 
   63861             : #if ROSE_ALLOC_TRACE == 2
   63862             : //  printf("SgFunctionDefinition::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgFunctionDefinition::next_node);
   63863             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   63864             :     Rose::MemPool::snapshot(oss.str());
   63865             :     alloc_trace_cnt++;
   63866             : #endif
   63867             : 
   63868             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   63869             : 
   63870        3165 :     ALLOC_MUTEX(SgFunctionDefinition, unlock);
   63871             : }
   63872             : 
   63873             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   63874             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   63875             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   63876             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   63877             : // Also, note comment below from Robb (copied from the Common.code file).
   63878             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   63879             : //
   63880             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   63881             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   63882             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   63883             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   63884             : #if 0
   63885             : void SgFunctionDefinition::operator delete(void* pointer) { SgFunctionDefinition::operator delete (pointer, sizeof(SgFunctionDefinition)); };
   63886             : #endif
   63887             : /* #line 63888 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   63888             : 
   63889             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   63890             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   63891             : // obviously imply C++.
   63892             : 
   63893             : // This implements the support within ROSE for memory pools.  Memory pools
   63894             : // support the most condensed usage of memory within the construction of
   63895             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   63896             : // by a new operator written for each class.
   63897             : 
   63898             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   63899             :     // User wants multi-thread support and POSIX threads are available.
   63900             : #   include <pthread.h>
   63901             :     static pthread_mutex_t SgTemplateFunctionDefinition_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   63902             : #else
   63903             :      // Cause synchronization to be skipped.
   63904             : #    ifndef ALLOC_MUTEX
   63905             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   63906             : #    endif
   63907             : #    ifdef _REENTRANT
   63908             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   63909             : #       ifdef _MSC_VER
   63910             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   63911             : #       else
   63912             : #           warning "POSIX threads are not available; synchronization being skipped"
   63913             : #       endif
   63914             : #    endif
   63915             : #endif
   63916             : 
   63917             : #ifndef ROSE_ALLOC_TRACE
   63918             : #  define ROSE_ALLOC_TRACE 0
   63919             : #endif
   63920             : 
   63921             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   63922             : #define ROSE_ALLOC_TRACE_CNT
   63923             : #include "memory-pool-snapshot.h"
   63924             : unsigned long alloc_trace_cnt = 0;
   63925             : #endif
   63926             : 
   63927             : #if ROSE_ALLOC_TRACE
   63928             : const unsigned SgTemplateFunctionDefinition::pool_size = 5;
   63929             : #else
   63930             : const unsigned SgTemplateFunctionDefinition::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   63931             : #endif
   63932             : 
   63933             : #ifndef ROSE_ALLOC_MEMSET
   63934             : #  define ROSE_ALLOC_MEMSET 0
   63935             : #endif
   63936             : 
   63937             : #ifndef ROSE_PEDANTIC_ALLOC
   63938             : #  define ROSE_PEDANTIC_ALLOC 0
   63939             : #endif
   63940             : 
   63941             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   63942             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   63943             : #endif
   63944             : 
   63945             : #if !defined(SGNODE__ALL_POOLS)
   63946             : #define SGNODE__ALL_POOLS
   63947             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   63948             : #endif
   63949             : 
   63950             : SgTemplateFunctionDefinition* SgTemplateFunctionDefinition::next_node = nullptr;
   63951             : std::vector<unsigned char*> SgTemplateFunctionDefinition::pools;
   63952             : 
   63953             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   63954             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   63955             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   63956             : // around this macro definition rather than each use).
   63957             : #ifndef ALLOC_MUTEX
   63958             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   63959             :         do {                                                                     \
   63960             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   63961             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   63962             :                 abort();                                                         \
   63963             :             }                                                                    \
   63964             :         } while (0);
   63965             : #endif
   63966             : 
   63967             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   63968             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   63969             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   63970             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   63971             : 
   63972             : /*! \brief New operator for SgTemplateFunctionDefinition.
   63973             : 
   63974             :    This new operator implements memory pools to provide most efficent 
   63975             :    use of the heap within construction of large ASTs.
   63976             : 
   63977             : \internal The new and delete operators use the lower level C malloc/free
   63978             :    function calls for performance and to make sure that mixing of malloc/free
   63979             :    and new/delete by the used can be caught more readily.  This may change
   63980             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   63981             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   63982             :    deallocate memory allocated using ROSE_MALLOC.
   63983             : */
   63984        3514 : void *SgTemplateFunctionDefinition::operator new ( size_t Size )
   63985             : {
   63986             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   63987             :      * returning or throwing an exception. */
   63988        3514 :     ALLOC_MUTEX(SgTemplateFunctionDefinition, lock);
   63989             : 
   63990             : #if ROSE_ALLOC_TRACE == 2
   63991             : //    printf("SgTemplateFunctionDefinition::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgTemplateFunctionDefinition::next_node);
   63992             : #endif
   63993             : 
   63994             : #if USE_CPP_NEW_DELETE_OPERATORS
   63995             :     void *mem = ROSE_MALLOC(Size);
   63996             :     ALLOC_MUTEX(SgTemplateFunctionDefinition, unlock);
   63997             :     return mem;
   63998             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   63999             : #if ROSE_PEDANTIC_ALLOC
   64000             :     ROSE_ASSERT(Size == sizeof(SgTemplateFunctionDefinition));
   64001             : #else
   64002        3514 :     if (Size != sizeof(SgTemplateFunctionDefinition)) {
   64003           0 :       void * object = ROSE_MALLOC(Size);
   64004           0 :       ALLOC_MUTEX(SgTemplateFunctionDefinition, unlock);
   64005             :       return object;
   64006             :     }
   64007             : #endif
   64008             : 
   64009        3514 :     if (SgTemplateFunctionDefinition::next_node == nullptr) {
   64010          10 :         SgTemplateFunctionDefinition * alloc = (SgTemplateFunctionDefinition*) ROSE_MALLOC ( SgTemplateFunctionDefinition::pool_size * sizeof(SgTemplateFunctionDefinition) );
   64011          10 :         ROSE_ASSERT(alloc != nullptr);
   64012             : 
   64013             : #if ROSE_ALLOC_TRACE == 2
   64014             : //        printf("SgTemplateFunctionDefinition::alloc\n  block[%zi] = [ %p , %p [\n", SgTemplateFunctionDefinition::pools.size(), alloc, alloc + SgTemplateFunctionDefinition::pool_size);
   64015             : #endif
   64016             : 
   64017             : #if ROSE_ALLOC_MEMSET == 1
   64018             : #elif ROSE_ALLOC_MEMSET == 2
   64019             :         memset(alloc, 0x00, SgTemplateFunctionDefinition::pool_size * sizeof(SgTemplateFunctionDefinition));
   64020             : #elif ROSE_ALLOC_MEMSET == 3
   64021             :         memset(alloc, 0xAA, SgTemplateFunctionDefinition::pool_size * sizeof(SgTemplateFunctionDefinition));
   64022             : #endif
   64023       20000 :         for (unsigned i=0; i < SgTemplateFunctionDefinition::pool_size-1; i++) {
   64024       19990 :           alloc[i].p_freepointer = &(alloc[i+1]);
   64025             :         }
   64026          10 :         alloc[SgTemplateFunctionDefinition::pool_size-1].p_freepointer = nullptr;
   64027             : 
   64028          10 :         SgTemplateFunctionDefinition::pools.push_back ( (unsigned char *) alloc );
   64029          10 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgTemplateFunctionDefinition::pool_size * sizeof(SgTemplateFunctionDefinition), V_SgTemplateFunctionDefinition ) );
   64030          10 :         SgTemplateFunctionDefinition::next_node = alloc;
   64031             :     }
   64032        3514 :     ROSE_ASSERT(SgTemplateFunctionDefinition::next_node != nullptr);
   64033             : 
   64034        3514 :     SgTemplateFunctionDefinition * object = SgTemplateFunctionDefinition::next_node;
   64035        3514 :     SgTemplateFunctionDefinition::next_node = (SgTemplateFunctionDefinition*)(object->p_freepointer);
   64036             : 
   64037             : #if ROSE_ALLOC_TRACE == 2
   64038             :     printf("SgTemplateFunctionDefinition::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTemplateFunctionDefinition::next_node);
   64039             : #endif
   64040             : 
   64041        3514 :     SgNode * fp = object->p_freepointer;
   64042             : #if ROSE_ALLOC_MEMSET == 1
   64043             : #elif ROSE_ALLOC_MEMSET == 2
   64044             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgTemplateFunctionDefinition) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   64045             : #elif ROSE_ALLOC_MEMSET == 3
   64046             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgTemplateFunctionDefinition) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   64047             : #endif
   64048        3514 :     object->p_freepointer = fp;
   64049             : 
   64050             : #if ROSE_ALLOC_TRACE == 2
   64051             : //    printf("SgTemplateFunctionDefinition::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTemplateFunctionDefinition::next_node);
   64052             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   64053             :     Rose::MemPool::snapshot(oss.str());
   64054             :     alloc_trace_cnt++;
   64055             : #endif
   64056             : 
   64057        3514 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   64058             : 
   64059        3514 :     ALLOC_MUTEX(SgTemplateFunctionDefinition, unlock);
   64060             : 
   64061             :     return object;
   64062             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   64063             : }
   64064             : 
   64065             : 
   64066             : 
   64067             : /*! \brief Delete operator for SgTemplateFunctionDefinition.
   64068             : 
   64069             :    This delete operator implements deallocation using memory pools to 
   64070             :    provide most efficent use of the heap within construction of large ASTs.
   64071             : 
   64072             : \internal The new and delete operators use the lower level C malloc/free
   64073             :    function calls for performance and to make sure that mixing of malloc/free
   64074             :    and new/delete by the used can be caught more readily.  This may change
   64075             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   64076             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   64077             :    deallocate memory allocated using ROSE_MALLOC.
   64078             : */
   64079         630 : void SgTemplateFunctionDefinition::operator delete(void *Pointer, size_t Size)
   64080             : {
   64081             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   64082             :      * or throwing an exception. */
   64083         630 :     ALLOC_MUTEX(SgTemplateFunctionDefinition, lock);
   64084             : 
   64085             : #if USE_CPP_NEW_DELETE_OPERATORS
   64086             :     ROSE_FREE(Pointer);
   64087             : #else
   64088             : #if ROSE_PEDANTIC_ALLOC
   64089             :     ROSE_ASSERT(Size == sizeof(SgTemplateFunctionDefinition));
   64090             : #else
   64091         630 :     if (Size != sizeof(SgTemplateFunctionDefinition)) {
   64092           0 :       ROSE_FREE(Pointer);
   64093           0 :       ALLOC_MUTEX(SgTemplateFunctionDefinition, unlock);
   64094             :       return;
   64095             :     }
   64096             : #endif
   64097             : 
   64098         630 :     SgTemplateFunctionDefinition * object = (SgTemplateFunctionDefinition*) Pointer;
   64099         630 :     ROSE_ASSERT(object != nullptr);
   64100             : 
   64101             : #if ROSE_ALLOC_TRACE == 2
   64102             : //  printf("SgTemplateFunctionDefinition::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTemplateFunctionDefinition::next_node);
   64103             :     printf("SgTemplateFunctionDefinition::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTemplateFunctionDefinition::next_node);
   64104             : #endif
   64105             : 
   64106             : #if ROSE_PEDANTIC_ALLOC
   64107             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   64108             : #endif
   64109             : 
   64110             : #if ROSE_ALLOC_MEMSET == 1
   64111             : #elif ROSE_ALLOC_MEMSET == 2
   64112             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgTemplateFunctionDefinition) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   64113             : #elif ROSE_ALLOC_MEMSET == 3
   64114             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgTemplateFunctionDefinition) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   64115             : #endif
   64116             : 
   64117             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   64118             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   64119             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   64120             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   64121             : #else
   64122         630 :     object->p_freepointer = SgTemplateFunctionDefinition::next_node;
   64123         630 :     SgTemplateFunctionDefinition::next_node = object;
   64124             : #endif
   64125             : 
   64126             : #if ROSE_ALLOC_TRACE == 2
   64127             : //  printf("SgTemplateFunctionDefinition::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTemplateFunctionDefinition::next_node);
   64128             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   64129             :     Rose::MemPool::snapshot(oss.str());
   64130             :     alloc_trace_cnt++;
   64131             : #endif
   64132             : 
   64133             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   64134             : 
   64135         630 :     ALLOC_MUTEX(SgTemplateFunctionDefinition, unlock);
   64136             : }
   64137             : 
   64138             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   64139             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   64140             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   64141             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   64142             : // Also, note comment below from Robb (copied from the Common.code file).
   64143             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   64144             : //
   64145             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   64146             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   64147             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   64148             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   64149             : #if 0
   64150             : void SgTemplateFunctionDefinition::operator delete(void* pointer) { SgTemplateFunctionDefinition::operator delete (pointer, sizeof(SgTemplateFunctionDefinition)); };
   64151             : #endif
   64152             : /* #line 64153 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   64153             : 
   64154             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   64155             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   64156             : // obviously imply C++.
   64157             : 
   64158             : // This implements the support within ROSE for memory pools.  Memory pools
   64159             : // support the most condensed usage of memory within the construction of
   64160             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   64161             : // by a new operator written for each class.
   64162             : 
   64163             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   64164             :     // User wants multi-thread support and POSIX threads are available.
   64165             : #   include <pthread.h>
   64166             :     static pthread_mutex_t SgClassDefinition_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   64167             : #else
   64168             :      // Cause synchronization to be skipped.
   64169             : #    ifndef ALLOC_MUTEX
   64170             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   64171             : #    endif
   64172             : #    ifdef _REENTRANT
   64173             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   64174             : #       ifdef _MSC_VER
   64175             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   64176             : #       else
   64177             : #           warning "POSIX threads are not available; synchronization being skipped"
   64178             : #       endif
   64179             : #    endif
   64180             : #endif
   64181             : 
   64182             : #ifndef ROSE_ALLOC_TRACE
   64183             : #  define ROSE_ALLOC_TRACE 0
   64184             : #endif
   64185             : 
   64186             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   64187             : #define ROSE_ALLOC_TRACE_CNT
   64188             : #include "memory-pool-snapshot.h"
   64189             : unsigned long alloc_trace_cnt = 0;
   64190             : #endif
   64191             : 
   64192             : #if ROSE_ALLOC_TRACE
   64193             : const unsigned SgClassDefinition::pool_size = 5;
   64194             : #else
   64195             : const unsigned SgClassDefinition::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   64196             : #endif
   64197             : 
   64198             : #ifndef ROSE_ALLOC_MEMSET
   64199             : #  define ROSE_ALLOC_MEMSET 0
   64200             : #endif
   64201             : 
   64202             : #ifndef ROSE_PEDANTIC_ALLOC
   64203             : #  define ROSE_PEDANTIC_ALLOC 0
   64204             : #endif
   64205             : 
   64206             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   64207             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   64208             : #endif
   64209             : 
   64210             : #if !defined(SGNODE__ALL_POOLS)
   64211             : #define SGNODE__ALL_POOLS
   64212             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   64213             : #endif
   64214             : 
   64215             : SgClassDefinition* SgClassDefinition::next_node = nullptr;
   64216             : std::vector<unsigned char*> SgClassDefinition::pools;
   64217             : 
   64218             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   64219             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   64220             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   64221             : // around this macro definition rather than each use).
   64222             : #ifndef ALLOC_MUTEX
   64223             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   64224             :         do {                                                                     \
   64225             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   64226             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   64227             :                 abort();                                                         \
   64228             :             }                                                                    \
   64229             :         } while (0);
   64230             : #endif
   64231             : 
   64232             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   64233             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   64234             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   64235             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   64236             : 
   64237             : /*! \brief New operator for SgClassDefinition.
   64238             : 
   64239             :    This new operator implements memory pools to provide most efficent 
   64240             :    use of the heap within construction of large ASTs.
   64241             : 
   64242             : \internal The new and delete operators use the lower level C malloc/free
   64243             :    function calls for performance and to make sure that mixing of malloc/free
   64244             :    and new/delete by the used can be caught more readily.  This may change
   64245             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   64246             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   64247             :    deallocate memory allocated using ROSE_MALLOC.
   64248             : */
   64249        6960 : void *SgClassDefinition::operator new ( size_t Size )
   64250             : {
   64251             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   64252             :      * returning or throwing an exception. */
   64253        6960 :     ALLOC_MUTEX(SgClassDefinition, lock);
   64254             : 
   64255             : #if ROSE_ALLOC_TRACE == 2
   64256             : //    printf("SgClassDefinition::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgClassDefinition::next_node);
   64257             : #endif
   64258             : 
   64259             : #if USE_CPP_NEW_DELETE_OPERATORS
   64260             :     void *mem = ROSE_MALLOC(Size);
   64261             :     ALLOC_MUTEX(SgClassDefinition, unlock);
   64262             :     return mem;
   64263             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   64264             : #if ROSE_PEDANTIC_ALLOC
   64265             :     ROSE_ASSERT(Size == sizeof(SgClassDefinition));
   64266             : #else
   64267        6960 :     if (Size != sizeof(SgClassDefinition)) {
   64268           0 :       void * object = ROSE_MALLOC(Size);
   64269           0 :       ALLOC_MUTEX(SgClassDefinition, unlock);
   64270             :       return object;
   64271             :     }
   64272             : #endif
   64273             : 
   64274        6960 :     if (SgClassDefinition::next_node == nullptr) {
   64275         212 :         SgClassDefinition * alloc = (SgClassDefinition*) ROSE_MALLOC ( SgClassDefinition::pool_size * sizeof(SgClassDefinition) );
   64276         212 :         ROSE_ASSERT(alloc != nullptr);
   64277             : 
   64278             : #if ROSE_ALLOC_TRACE == 2
   64279             : //        printf("SgClassDefinition::alloc\n  block[%zi] = [ %p , %p [\n", SgClassDefinition::pools.size(), alloc, alloc + SgClassDefinition::pool_size);
   64280             : #endif
   64281             : 
   64282             : #if ROSE_ALLOC_MEMSET == 1
   64283             : #elif ROSE_ALLOC_MEMSET == 2
   64284             :         memset(alloc, 0x00, SgClassDefinition::pool_size * sizeof(SgClassDefinition));
   64285             : #elif ROSE_ALLOC_MEMSET == 3
   64286             :         memset(alloc, 0xAA, SgClassDefinition::pool_size * sizeof(SgClassDefinition));
   64287             : #endif
   64288      424000 :         for (unsigned i=0; i < SgClassDefinition::pool_size-1; i++) {
   64289      423788 :           alloc[i].p_freepointer = &(alloc[i+1]);
   64290             :         }
   64291         212 :         alloc[SgClassDefinition::pool_size-1].p_freepointer = nullptr;
   64292             : 
   64293         212 :         SgClassDefinition::pools.push_back ( (unsigned char *) alloc );
   64294         212 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgClassDefinition::pool_size * sizeof(SgClassDefinition), V_SgClassDefinition ) );
   64295         212 :         SgClassDefinition::next_node = alloc;
   64296             :     }
   64297        6960 :     ROSE_ASSERT(SgClassDefinition::next_node != nullptr);
   64298             : 
   64299        6960 :     SgClassDefinition * object = SgClassDefinition::next_node;
   64300        6960 :     SgClassDefinition::next_node = (SgClassDefinition*)(object->p_freepointer);
   64301             : 
   64302             : #if ROSE_ALLOC_TRACE == 2
   64303             :     printf("SgClassDefinition::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgClassDefinition::next_node);
   64304             : #endif
   64305             : 
   64306        6960 :     SgNode * fp = object->p_freepointer;
   64307             : #if ROSE_ALLOC_MEMSET == 1
   64308             : #elif ROSE_ALLOC_MEMSET == 2
   64309             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgClassDefinition) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   64310             : #elif ROSE_ALLOC_MEMSET == 3
   64311             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgClassDefinition) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   64312             : #endif
   64313        6960 :     object->p_freepointer = fp;
   64314             : 
   64315             : #if ROSE_ALLOC_TRACE == 2
   64316             : //    printf("SgClassDefinition::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgClassDefinition::next_node);
   64317             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   64318             :     Rose::MemPool::snapshot(oss.str());
   64319             :     alloc_trace_cnt++;
   64320             : #endif
   64321             : 
   64322        6960 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   64323             : 
   64324        6960 :     ALLOC_MUTEX(SgClassDefinition, unlock);
   64325             : 
   64326             :     return object;
   64327             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   64328             : }
   64329             : 
   64330             : 
   64331             : 
   64332             : /*! \brief Delete operator for SgClassDefinition.
   64333             : 
   64334             :    This delete operator implements deallocation using memory pools to 
   64335             :    provide most efficent use of the heap within construction of large ASTs.
   64336             : 
   64337             : \internal The new and delete operators use the lower level C malloc/free
   64338             :    function calls for performance and to make sure that mixing of malloc/free
   64339             :    and new/delete by the used can be caught more readily.  This may change
   64340             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   64341             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   64342             :    deallocate memory allocated using ROSE_MALLOC.
   64343             : */
   64344         336 : void SgClassDefinition::operator delete(void *Pointer, size_t Size)
   64345             : {
   64346             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   64347             :      * or throwing an exception. */
   64348         336 :     ALLOC_MUTEX(SgClassDefinition, lock);
   64349             : 
   64350             : #if USE_CPP_NEW_DELETE_OPERATORS
   64351             :     ROSE_FREE(Pointer);
   64352             : #else
   64353             : #if ROSE_PEDANTIC_ALLOC
   64354             :     ROSE_ASSERT(Size == sizeof(SgClassDefinition));
   64355             : #else
   64356         336 :     if (Size != sizeof(SgClassDefinition)) {
   64357           0 :       ROSE_FREE(Pointer);
   64358           0 :       ALLOC_MUTEX(SgClassDefinition, unlock);
   64359             :       return;
   64360             :     }
   64361             : #endif
   64362             : 
   64363         336 :     SgClassDefinition * object = (SgClassDefinition*) Pointer;
   64364         336 :     ROSE_ASSERT(object != nullptr);
   64365             : 
   64366             : #if ROSE_ALLOC_TRACE == 2
   64367             : //  printf("SgClassDefinition::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgClassDefinition::next_node);
   64368             :     printf("SgClassDefinition::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgClassDefinition::next_node);
   64369             : #endif
   64370             : 
   64371             : #if ROSE_PEDANTIC_ALLOC
   64372             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   64373             : #endif
   64374             : 
   64375             : #if ROSE_ALLOC_MEMSET == 1
   64376             : #elif ROSE_ALLOC_MEMSET == 2
   64377             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgClassDefinition) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   64378             : #elif ROSE_ALLOC_MEMSET == 3
   64379             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgClassDefinition) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   64380             : #endif
   64381             : 
   64382             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   64383             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   64384             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   64385             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   64386             : #else
   64387         336 :     object->p_freepointer = SgClassDefinition::next_node;
   64388         336 :     SgClassDefinition::next_node = object;
   64389             : #endif
   64390             : 
   64391             : #if ROSE_ALLOC_TRACE == 2
   64392             : //  printf("SgClassDefinition::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgClassDefinition::next_node);
   64393             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   64394             :     Rose::MemPool::snapshot(oss.str());
   64395             :     alloc_trace_cnt++;
   64396             : #endif
   64397             : 
   64398             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   64399             : 
   64400         336 :     ALLOC_MUTEX(SgClassDefinition, unlock);
   64401             : }
   64402             : 
   64403             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   64404             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   64405             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   64406             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   64407             : // Also, note comment below from Robb (copied from the Common.code file).
   64408             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   64409             : //
   64410             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   64411             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   64412             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   64413             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   64414             : #if 0
   64415             : void SgClassDefinition::operator delete(void* pointer) { SgClassDefinition::operator delete (pointer, sizeof(SgClassDefinition)); };
   64416             : #endif
   64417             : /* #line 64418 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   64418             : 
   64419             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   64420             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   64421             : // obviously imply C++.
   64422             : 
   64423             : // This implements the support within ROSE for memory pools.  Memory pools
   64424             : // support the most condensed usage of memory within the construction of
   64425             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   64426             : // by a new operator written for each class.
   64427             : 
   64428             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   64429             :     // User wants multi-thread support and POSIX threads are available.
   64430             : #   include <pthread.h>
   64431             :     static pthread_mutex_t SgTemplateInstantiationDefn_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   64432             : #else
   64433             :      // Cause synchronization to be skipped.
   64434             : #    ifndef ALLOC_MUTEX
   64435             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   64436             : #    endif
   64437             : #    ifdef _REENTRANT
   64438             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   64439             : #       ifdef _MSC_VER
   64440             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   64441             : #       else
   64442             : #           warning "POSIX threads are not available; synchronization being skipped"
   64443             : #       endif
   64444             : #    endif
   64445             : #endif
   64446             : 
   64447             : #ifndef ROSE_ALLOC_TRACE
   64448             : #  define ROSE_ALLOC_TRACE 0
   64449             : #endif
   64450             : 
   64451             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   64452             : #define ROSE_ALLOC_TRACE_CNT
   64453             : #include "memory-pool-snapshot.h"
   64454             : unsigned long alloc_trace_cnt = 0;
   64455             : #endif
   64456             : 
   64457             : #if ROSE_ALLOC_TRACE
   64458             : const unsigned SgTemplateInstantiationDefn::pool_size = 5;
   64459             : #else
   64460             : const unsigned SgTemplateInstantiationDefn::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   64461             : #endif
   64462             : 
   64463             : #ifndef ROSE_ALLOC_MEMSET
   64464             : #  define ROSE_ALLOC_MEMSET 0
   64465             : #endif
   64466             : 
   64467             : #ifndef ROSE_PEDANTIC_ALLOC
   64468             : #  define ROSE_PEDANTIC_ALLOC 0
   64469             : #endif
   64470             : 
   64471             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   64472             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   64473             : #endif
   64474             : 
   64475             : #if !defined(SGNODE__ALL_POOLS)
   64476             : #define SGNODE__ALL_POOLS
   64477             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   64478             : #endif
   64479             : 
   64480             : SgTemplateInstantiationDefn* SgTemplateInstantiationDefn::next_node = nullptr;
   64481             : std::vector<unsigned char*> SgTemplateInstantiationDefn::pools;
   64482             : 
   64483             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   64484             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   64485             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   64486             : // around this macro definition rather than each use).
   64487             : #ifndef ALLOC_MUTEX
   64488             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   64489             :         do {                                                                     \
   64490             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   64491             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   64492             :                 abort();                                                         \
   64493             :             }                                                                    \
   64494             :         } while (0);
   64495             : #endif
   64496             : 
   64497             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   64498             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   64499             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   64500             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   64501             : 
   64502             : /*! \brief New operator for SgTemplateInstantiationDefn.
   64503             : 
   64504             :    This new operator implements memory pools to provide most efficent 
   64505             :    use of the heap within construction of large ASTs.
   64506             : 
   64507             : \internal The new and delete operators use the lower level C malloc/free
   64508             :    function calls for performance and to make sure that mixing of malloc/free
   64509             :    and new/delete by the used can be caught more readily.  This may change
   64510             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   64511             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   64512             :    deallocate memory allocated using ROSE_MALLOC.
   64513             : */
   64514        6018 : void *SgTemplateInstantiationDefn::operator new ( size_t Size )
   64515             : {
   64516             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   64517             :      * returning or throwing an exception. */
   64518        6018 :     ALLOC_MUTEX(SgTemplateInstantiationDefn, lock);
   64519             : 
   64520             : #if ROSE_ALLOC_TRACE == 2
   64521             : //    printf("SgTemplateInstantiationDefn::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgTemplateInstantiationDefn::next_node);
   64522             : #endif
   64523             : 
   64524             : #if USE_CPP_NEW_DELETE_OPERATORS
   64525             :     void *mem = ROSE_MALLOC(Size);
   64526             :     ALLOC_MUTEX(SgTemplateInstantiationDefn, unlock);
   64527             :     return mem;
   64528             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   64529             : #if ROSE_PEDANTIC_ALLOC
   64530             :     ROSE_ASSERT(Size == sizeof(SgTemplateInstantiationDefn));
   64531             : #else
   64532        6018 :     if (Size != sizeof(SgTemplateInstantiationDefn)) {
   64533           0 :       void * object = ROSE_MALLOC(Size);
   64534           0 :       ALLOC_MUTEX(SgTemplateInstantiationDefn, unlock);
   64535             :       return object;
   64536             :     }
   64537             : #endif
   64538             : 
   64539        6018 :     if (SgTemplateInstantiationDefn::next_node == nullptr) {
   64540          10 :         SgTemplateInstantiationDefn * alloc = (SgTemplateInstantiationDefn*) ROSE_MALLOC ( SgTemplateInstantiationDefn::pool_size * sizeof(SgTemplateInstantiationDefn) );
   64541          10 :         ROSE_ASSERT(alloc != nullptr);
   64542             : 
   64543             : #if ROSE_ALLOC_TRACE == 2
   64544             : //        printf("SgTemplateInstantiationDefn::alloc\n  block[%zi] = [ %p , %p [\n", SgTemplateInstantiationDefn::pools.size(), alloc, alloc + SgTemplateInstantiationDefn::pool_size);
   64545             : #endif
   64546             : 
   64547             : #if ROSE_ALLOC_MEMSET == 1
   64548             : #elif ROSE_ALLOC_MEMSET == 2
   64549             :         memset(alloc, 0x00, SgTemplateInstantiationDefn::pool_size * sizeof(SgTemplateInstantiationDefn));
   64550             : #elif ROSE_ALLOC_MEMSET == 3
   64551             :         memset(alloc, 0xAA, SgTemplateInstantiationDefn::pool_size * sizeof(SgTemplateInstantiationDefn));
   64552             : #endif
   64553       20000 :         for (unsigned i=0; i < SgTemplateInstantiationDefn::pool_size-1; i++) {
   64554       19990 :           alloc[i].p_freepointer = &(alloc[i+1]);
   64555             :         }
   64556          10 :         alloc[SgTemplateInstantiationDefn::pool_size-1].p_freepointer = nullptr;
   64557             : 
   64558          10 :         SgTemplateInstantiationDefn::pools.push_back ( (unsigned char *) alloc );
   64559          10 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgTemplateInstantiationDefn::pool_size * sizeof(SgTemplateInstantiationDefn), V_SgTemplateInstantiationDefn ) );
   64560          10 :         SgTemplateInstantiationDefn::next_node = alloc;
   64561             :     }
   64562        6018 :     ROSE_ASSERT(SgTemplateInstantiationDefn::next_node != nullptr);
   64563             : 
   64564        6018 :     SgTemplateInstantiationDefn * object = SgTemplateInstantiationDefn::next_node;
   64565        6018 :     SgTemplateInstantiationDefn::next_node = (SgTemplateInstantiationDefn*)(object->p_freepointer);
   64566             : 
   64567             : #if ROSE_ALLOC_TRACE == 2
   64568             :     printf("SgTemplateInstantiationDefn::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTemplateInstantiationDefn::next_node);
   64569             : #endif
   64570             : 
   64571        6018 :     SgNode * fp = object->p_freepointer;
   64572             : #if ROSE_ALLOC_MEMSET == 1
   64573             : #elif ROSE_ALLOC_MEMSET == 2
   64574             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgTemplateInstantiationDefn) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   64575             : #elif ROSE_ALLOC_MEMSET == 3
   64576             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgTemplateInstantiationDefn) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   64577             : #endif
   64578        6018 :     object->p_freepointer = fp;
   64579             : 
   64580             : #if ROSE_ALLOC_TRACE == 2
   64581             : //    printf("SgTemplateInstantiationDefn::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTemplateInstantiationDefn::next_node);
   64582             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   64583             :     Rose::MemPool::snapshot(oss.str());
   64584             :     alloc_trace_cnt++;
   64585             : #endif
   64586             : 
   64587        6018 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   64588             : 
   64589        6018 :     ALLOC_MUTEX(SgTemplateInstantiationDefn, unlock);
   64590             : 
   64591             :     return object;
   64592             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   64593             : }
   64594             : 
   64595             : 
   64596             : 
   64597             : /*! \brief Delete operator for SgTemplateInstantiationDefn.
   64598             : 
   64599             :    This delete operator implements deallocation using memory pools to 
   64600             :    provide most efficent use of the heap within construction of large ASTs.
   64601             : 
   64602             : \internal The new and delete operators use the lower level C malloc/free
   64603             :    function calls for performance and to make sure that mixing of malloc/free
   64604             :    and new/delete by the used can be caught more readily.  This may change
   64605             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   64606             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   64607             :    deallocate memory allocated using ROSE_MALLOC.
   64608             : */
   64609        1202 : void SgTemplateInstantiationDefn::operator delete(void *Pointer, size_t Size)
   64610             : {
   64611             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   64612             :      * or throwing an exception. */
   64613        1202 :     ALLOC_MUTEX(SgTemplateInstantiationDefn, lock);
   64614             : 
   64615             : #if USE_CPP_NEW_DELETE_OPERATORS
   64616             :     ROSE_FREE(Pointer);
   64617             : #else
   64618             : #if ROSE_PEDANTIC_ALLOC
   64619             :     ROSE_ASSERT(Size == sizeof(SgTemplateInstantiationDefn));
   64620             : #else
   64621        1202 :     if (Size != sizeof(SgTemplateInstantiationDefn)) {
   64622           0 :       ROSE_FREE(Pointer);
   64623           0 :       ALLOC_MUTEX(SgTemplateInstantiationDefn, unlock);
   64624             :       return;
   64625             :     }
   64626             : #endif
   64627             : 
   64628        1202 :     SgTemplateInstantiationDefn * object = (SgTemplateInstantiationDefn*) Pointer;
   64629        1202 :     ROSE_ASSERT(object != nullptr);
   64630             : 
   64631             : #if ROSE_ALLOC_TRACE == 2
   64632             : //  printf("SgTemplateInstantiationDefn::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTemplateInstantiationDefn::next_node);
   64633             :     printf("SgTemplateInstantiationDefn::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTemplateInstantiationDefn::next_node);
   64634             : #endif
   64635             : 
   64636             : #if ROSE_PEDANTIC_ALLOC
   64637             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   64638             : #endif
   64639             : 
   64640             : #if ROSE_ALLOC_MEMSET == 1
   64641             : #elif ROSE_ALLOC_MEMSET == 2
   64642             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgTemplateInstantiationDefn) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   64643             : #elif ROSE_ALLOC_MEMSET == 3
   64644             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgTemplateInstantiationDefn) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   64645             : #endif
   64646             : 
   64647             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   64648             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   64649             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   64650             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   64651             : #else
   64652        1202 :     object->p_freepointer = SgTemplateInstantiationDefn::next_node;
   64653        1202 :     SgTemplateInstantiationDefn::next_node = object;
   64654             : #endif
   64655             : 
   64656             : #if ROSE_ALLOC_TRACE == 2
   64657             : //  printf("SgTemplateInstantiationDefn::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTemplateInstantiationDefn::next_node);
   64658             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   64659             :     Rose::MemPool::snapshot(oss.str());
   64660             :     alloc_trace_cnt++;
   64661             : #endif
   64662             : 
   64663             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   64664             : 
   64665        1202 :     ALLOC_MUTEX(SgTemplateInstantiationDefn, unlock);
   64666             : }
   64667             : 
   64668             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   64669             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   64670             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   64671             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   64672             : // Also, note comment below from Robb (copied from the Common.code file).
   64673             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   64674             : //
   64675             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   64676             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   64677             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   64678             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   64679             : #if 0
   64680             : void SgTemplateInstantiationDefn::operator delete(void* pointer) { SgTemplateInstantiationDefn::operator delete (pointer, sizeof(SgTemplateInstantiationDefn)); };
   64681             : #endif
   64682             : /* #line 64683 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   64683             : 
   64684             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   64685             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   64686             : // obviously imply C++.
   64687             : 
   64688             : // This implements the support within ROSE for memory pools.  Memory pools
   64689             : // support the most condensed usage of memory within the construction of
   64690             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   64691             : // by a new operator written for each class.
   64692             : 
   64693             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   64694             :     // User wants multi-thread support and POSIX threads are available.
   64695             : #   include <pthread.h>
   64696             :     static pthread_mutex_t SgTemplateClassDefinition_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   64697             : #else
   64698             :      // Cause synchronization to be skipped.
   64699             : #    ifndef ALLOC_MUTEX
   64700             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   64701             : #    endif
   64702             : #    ifdef _REENTRANT
   64703             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   64704             : #       ifdef _MSC_VER
   64705             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   64706             : #       else
   64707             : #           warning "POSIX threads are not available; synchronization being skipped"
   64708             : #       endif
   64709             : #    endif
   64710             : #endif
   64711             : 
   64712             : #ifndef ROSE_ALLOC_TRACE
   64713             : #  define ROSE_ALLOC_TRACE 0
   64714             : #endif
   64715             : 
   64716             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   64717             : #define ROSE_ALLOC_TRACE_CNT
   64718             : #include "memory-pool-snapshot.h"
   64719             : unsigned long alloc_trace_cnt = 0;
   64720             : #endif
   64721             : 
   64722             : #if ROSE_ALLOC_TRACE
   64723             : const unsigned SgTemplateClassDefinition::pool_size = 5;
   64724             : #else
   64725             : const unsigned SgTemplateClassDefinition::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   64726             : #endif
   64727             : 
   64728             : #ifndef ROSE_ALLOC_MEMSET
   64729             : #  define ROSE_ALLOC_MEMSET 0
   64730             : #endif
   64731             : 
   64732             : #ifndef ROSE_PEDANTIC_ALLOC
   64733             : #  define ROSE_PEDANTIC_ALLOC 0
   64734             : #endif
   64735             : 
   64736             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   64737             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   64738             : #endif
   64739             : 
   64740             : #if !defined(SGNODE__ALL_POOLS)
   64741             : #define SGNODE__ALL_POOLS
   64742             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   64743             : #endif
   64744             : 
   64745             : SgTemplateClassDefinition* SgTemplateClassDefinition::next_node = nullptr;
   64746             : std::vector<unsigned char*> SgTemplateClassDefinition::pools;
   64747             : 
   64748             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   64749             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   64750             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   64751             : // around this macro definition rather than each use).
   64752             : #ifndef ALLOC_MUTEX
   64753             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   64754             :         do {                                                                     \
   64755             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   64756             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   64757             :                 abort();                                                         \
   64758             :             }                                                                    \
   64759             :         } while (0);
   64760             : #endif
   64761             : 
   64762             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   64763             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   64764             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   64765             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   64766             : 
   64767             : /*! \brief New operator for SgTemplateClassDefinition.
   64768             : 
   64769             :    This new operator implements memory pools to provide most efficent 
   64770             :    use of the heap within construction of large ASTs.
   64771             : 
   64772             : \internal The new and delete operators use the lower level C malloc/free
   64773             :    function calls for performance and to make sure that mixing of malloc/free
   64774             :    and new/delete by the used can be caught more readily.  This may change
   64775             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   64776             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   64777             :    deallocate memory allocated using ROSE_MALLOC.
   64778             : */
   64779        5428 : void *SgTemplateClassDefinition::operator new ( size_t Size )
   64780             : {
   64781             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   64782             :      * returning or throwing an exception. */
   64783        5428 :     ALLOC_MUTEX(SgTemplateClassDefinition, lock);
   64784             : 
   64785             : #if ROSE_ALLOC_TRACE == 2
   64786             : //    printf("SgTemplateClassDefinition::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgTemplateClassDefinition::next_node);
   64787             : #endif
   64788             : 
   64789             : #if USE_CPP_NEW_DELETE_OPERATORS
   64790             :     void *mem = ROSE_MALLOC(Size);
   64791             :     ALLOC_MUTEX(SgTemplateClassDefinition, unlock);
   64792             :     return mem;
   64793             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   64794             : #if ROSE_PEDANTIC_ALLOC
   64795             :     ROSE_ASSERT(Size == sizeof(SgTemplateClassDefinition));
   64796             : #else
   64797        5428 :     if (Size != sizeof(SgTemplateClassDefinition)) {
   64798           0 :       void * object = ROSE_MALLOC(Size);
   64799           0 :       ALLOC_MUTEX(SgTemplateClassDefinition, unlock);
   64800             :       return object;
   64801             :     }
   64802             : #endif
   64803             : 
   64804        5428 :     if (SgTemplateClassDefinition::next_node == nullptr) {
   64805          11 :         SgTemplateClassDefinition * alloc = (SgTemplateClassDefinition*) ROSE_MALLOC ( SgTemplateClassDefinition::pool_size * sizeof(SgTemplateClassDefinition) );
   64806          11 :         ROSE_ASSERT(alloc != nullptr);
   64807             : 
   64808             : #if ROSE_ALLOC_TRACE == 2
   64809             : //        printf("SgTemplateClassDefinition::alloc\n  block[%zi] = [ %p , %p [\n", SgTemplateClassDefinition::pools.size(), alloc, alloc + SgTemplateClassDefinition::pool_size);
   64810             : #endif
   64811             : 
   64812             : #if ROSE_ALLOC_MEMSET == 1
   64813             : #elif ROSE_ALLOC_MEMSET == 2
   64814             :         memset(alloc, 0x00, SgTemplateClassDefinition::pool_size * sizeof(SgTemplateClassDefinition));
   64815             : #elif ROSE_ALLOC_MEMSET == 3
   64816             :         memset(alloc, 0xAA, SgTemplateClassDefinition::pool_size * sizeof(SgTemplateClassDefinition));
   64817             : #endif
   64818       22000 :         for (unsigned i=0; i < SgTemplateClassDefinition::pool_size-1; i++) {
   64819       21989 :           alloc[i].p_freepointer = &(alloc[i+1]);
   64820             :         }
   64821          11 :         alloc[SgTemplateClassDefinition::pool_size-1].p_freepointer = nullptr;
   64822             : 
   64823          11 :         SgTemplateClassDefinition::pools.push_back ( (unsigned char *) alloc );
   64824          11 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgTemplateClassDefinition::pool_size * sizeof(SgTemplateClassDefinition), V_SgTemplateClassDefinition ) );
   64825          11 :         SgTemplateClassDefinition::next_node = alloc;
   64826             :     }
   64827        5428 :     ROSE_ASSERT(SgTemplateClassDefinition::next_node != nullptr);
   64828             : 
   64829        5428 :     SgTemplateClassDefinition * object = SgTemplateClassDefinition::next_node;
   64830        5428 :     SgTemplateClassDefinition::next_node = (SgTemplateClassDefinition*)(object->p_freepointer);
   64831             : 
   64832             : #if ROSE_ALLOC_TRACE == 2
   64833             :     printf("SgTemplateClassDefinition::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTemplateClassDefinition::next_node);
   64834             : #endif
   64835             : 
   64836        5428 :     SgNode * fp = object->p_freepointer;
   64837             : #if ROSE_ALLOC_MEMSET == 1
   64838             : #elif ROSE_ALLOC_MEMSET == 2
   64839             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgTemplateClassDefinition) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   64840             : #elif ROSE_ALLOC_MEMSET == 3
   64841             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgTemplateClassDefinition) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   64842             : #endif
   64843        5428 :     object->p_freepointer = fp;
   64844             : 
   64845             : #if ROSE_ALLOC_TRACE == 2
   64846             : //    printf("SgTemplateClassDefinition::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTemplateClassDefinition::next_node);
   64847             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   64848             :     Rose::MemPool::snapshot(oss.str());
   64849             :     alloc_trace_cnt++;
   64850             : #endif
   64851             : 
   64852        5428 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   64853             : 
   64854        5428 :     ALLOC_MUTEX(SgTemplateClassDefinition, unlock);
   64855             : 
   64856             :     return object;
   64857             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   64858             : }
   64859             : 
   64860             : 
   64861             : 
   64862             : /*! \brief Delete operator for SgTemplateClassDefinition.
   64863             : 
   64864             :    This delete operator implements deallocation using memory pools to 
   64865             :    provide most efficent use of the heap within construction of large ASTs.
   64866             : 
   64867             : \internal The new and delete operators use the lower level C malloc/free
   64868             :    function calls for performance and to make sure that mixing of malloc/free
   64869             :    and new/delete by the used can be caught more readily.  This may change
   64870             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   64871             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   64872             :    deallocate memory allocated using ROSE_MALLOC.
   64873             : */
   64874        1012 : void SgTemplateClassDefinition::operator delete(void *Pointer, size_t Size)
   64875             : {
   64876             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   64877             :      * or throwing an exception. */
   64878        1012 :     ALLOC_MUTEX(SgTemplateClassDefinition, lock);
   64879             : 
   64880             : #if USE_CPP_NEW_DELETE_OPERATORS
   64881             :     ROSE_FREE(Pointer);
   64882             : #else
   64883             : #if ROSE_PEDANTIC_ALLOC
   64884             :     ROSE_ASSERT(Size == sizeof(SgTemplateClassDefinition));
   64885             : #else
   64886        1012 :     if (Size != sizeof(SgTemplateClassDefinition)) {
   64887           0 :       ROSE_FREE(Pointer);
   64888           0 :       ALLOC_MUTEX(SgTemplateClassDefinition, unlock);
   64889             :       return;
   64890             :     }
   64891             : #endif
   64892             : 
   64893        1012 :     SgTemplateClassDefinition * object = (SgTemplateClassDefinition*) Pointer;
   64894        1012 :     ROSE_ASSERT(object != nullptr);
   64895             : 
   64896             : #if ROSE_ALLOC_TRACE == 2
   64897             : //  printf("SgTemplateClassDefinition::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTemplateClassDefinition::next_node);
   64898             :     printf("SgTemplateClassDefinition::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTemplateClassDefinition::next_node);
   64899             : #endif
   64900             : 
   64901             : #if ROSE_PEDANTIC_ALLOC
   64902             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   64903             : #endif
   64904             : 
   64905             : #if ROSE_ALLOC_MEMSET == 1
   64906             : #elif ROSE_ALLOC_MEMSET == 2
   64907             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgTemplateClassDefinition) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   64908             : #elif ROSE_ALLOC_MEMSET == 3
   64909             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgTemplateClassDefinition) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   64910             : #endif
   64911             : 
   64912             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   64913             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   64914             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   64915             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   64916             : #else
   64917        1012 :     object->p_freepointer = SgTemplateClassDefinition::next_node;
   64918        1012 :     SgTemplateClassDefinition::next_node = object;
   64919             : #endif
   64920             : 
   64921             : #if ROSE_ALLOC_TRACE == 2
   64922             : //  printf("SgTemplateClassDefinition::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTemplateClassDefinition::next_node);
   64923             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   64924             :     Rose::MemPool::snapshot(oss.str());
   64925             :     alloc_trace_cnt++;
   64926             : #endif
   64927             : 
   64928             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   64929             : 
   64930        1012 :     ALLOC_MUTEX(SgTemplateClassDefinition, unlock);
   64931             : }
   64932             : 
   64933             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   64934             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   64935             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   64936             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   64937             : // Also, note comment below from Robb (copied from the Common.code file).
   64938             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   64939             : //
   64940             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   64941             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   64942             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   64943             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   64944             : #if 0
   64945             : void SgTemplateClassDefinition::operator delete(void* pointer) { SgTemplateClassDefinition::operator delete (pointer, sizeof(SgTemplateClassDefinition)); };
   64946             : #endif
   64947             : /* #line 64948 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   64948             : 
   64949             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   64950             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   64951             : // obviously imply C++.
   64952             : 
   64953             : // This implements the support within ROSE for memory pools.  Memory pools
   64954             : // support the most condensed usage of memory within the construction of
   64955             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   64956             : // by a new operator written for each class.
   64957             : 
   64958             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   64959             :     // User wants multi-thread support and POSIX threads are available.
   64960             : #   include <pthread.h>
   64961             :     static pthread_mutex_t SgWhileStmt_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   64962             : #else
   64963             :      // Cause synchronization to be skipped.
   64964             : #    ifndef ALLOC_MUTEX
   64965             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   64966             : #    endif
   64967             : #    ifdef _REENTRANT
   64968             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   64969             : #       ifdef _MSC_VER
   64970             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   64971             : #       else
   64972             : #           warning "POSIX threads are not available; synchronization being skipped"
   64973             : #       endif
   64974             : #    endif
   64975             : #endif
   64976             : 
   64977             : #ifndef ROSE_ALLOC_TRACE
   64978             : #  define ROSE_ALLOC_TRACE 0
   64979             : #endif
   64980             : 
   64981             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   64982             : #define ROSE_ALLOC_TRACE_CNT
   64983             : #include "memory-pool-snapshot.h"
   64984             : unsigned long alloc_trace_cnt = 0;
   64985             : #endif
   64986             : 
   64987             : #if ROSE_ALLOC_TRACE
   64988             : const unsigned SgWhileStmt::pool_size = 5;
   64989             : #else
   64990             : const unsigned SgWhileStmt::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   64991             : #endif
   64992             : 
   64993             : #ifndef ROSE_ALLOC_MEMSET
   64994             : #  define ROSE_ALLOC_MEMSET 0
   64995             : #endif
   64996             : 
   64997             : #ifndef ROSE_PEDANTIC_ALLOC
   64998             : #  define ROSE_PEDANTIC_ALLOC 0
   64999             : #endif
   65000             : 
   65001             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   65002             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   65003             : #endif
   65004             : 
   65005             : #if !defined(SGNODE__ALL_POOLS)
   65006             : #define SGNODE__ALL_POOLS
   65007             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   65008             : #endif
   65009             : 
   65010             : SgWhileStmt* SgWhileStmt::next_node = nullptr;
   65011             : std::vector<unsigned char*> SgWhileStmt::pools;
   65012             : 
   65013             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   65014             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   65015             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   65016             : // around this macro definition rather than each use).
   65017             : #ifndef ALLOC_MUTEX
   65018             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   65019             :         do {                                                                     \
   65020             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   65021             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   65022             :                 abort();                                                         \
   65023             :             }                                                                    \
   65024             :         } while (0);
   65025             : #endif
   65026             : 
   65027             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   65028             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   65029             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   65030             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   65031             : 
   65032             : /*! \brief New operator for SgWhileStmt.
   65033             : 
   65034             :    This new operator implements memory pools to provide most efficent 
   65035             :    use of the heap within construction of large ASTs.
   65036             : 
   65037             : \internal The new and delete operators use the lower level C malloc/free
   65038             :    function calls for performance and to make sure that mixing of malloc/free
   65039             :    and new/delete by the used can be caught more readily.  This may change
   65040             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   65041             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   65042             :    deallocate memory allocated using ROSE_MALLOC.
   65043             : */
   65044         462 : void *SgWhileStmt::operator new ( size_t Size )
   65045             : {
   65046             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   65047             :      * returning or throwing an exception. */
   65048         462 :     ALLOC_MUTEX(SgWhileStmt, lock);
   65049             : 
   65050             : #if ROSE_ALLOC_TRACE == 2
   65051             : //    printf("SgWhileStmt::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgWhileStmt::next_node);
   65052             : #endif
   65053             : 
   65054             : #if USE_CPP_NEW_DELETE_OPERATORS
   65055             :     void *mem = ROSE_MALLOC(Size);
   65056             :     ALLOC_MUTEX(SgWhileStmt, unlock);
   65057             :     return mem;
   65058             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   65059             : #if ROSE_PEDANTIC_ALLOC
   65060             :     ROSE_ASSERT(Size == sizeof(SgWhileStmt));
   65061             : #else
   65062         462 :     if (Size != sizeof(SgWhileStmt)) {
   65063           0 :       void * object = ROSE_MALLOC(Size);
   65064           0 :       ALLOC_MUTEX(SgWhileStmt, unlock);
   65065             :       return object;
   65066             :     }
   65067             : #endif
   65068             : 
   65069         462 :     if (SgWhileStmt::next_node == nullptr) {
   65070          28 :         SgWhileStmt * alloc = (SgWhileStmt*) ROSE_MALLOC ( SgWhileStmt::pool_size * sizeof(SgWhileStmt) );
   65071          28 :         ROSE_ASSERT(alloc != nullptr);
   65072             : 
   65073             : #if ROSE_ALLOC_TRACE == 2
   65074             : //        printf("SgWhileStmt::alloc\n  block[%zi] = [ %p , %p [\n", SgWhileStmt::pools.size(), alloc, alloc + SgWhileStmt::pool_size);
   65075             : #endif
   65076             : 
   65077             : #if ROSE_ALLOC_MEMSET == 1
   65078             : #elif ROSE_ALLOC_MEMSET == 2
   65079             :         memset(alloc, 0x00, SgWhileStmt::pool_size * sizeof(SgWhileStmt));
   65080             : #elif ROSE_ALLOC_MEMSET == 3
   65081             :         memset(alloc, 0xAA, SgWhileStmt::pool_size * sizeof(SgWhileStmt));
   65082             : #endif
   65083       56000 :         for (unsigned i=0; i < SgWhileStmt::pool_size-1; i++) {
   65084       55972 :           alloc[i].p_freepointer = &(alloc[i+1]);
   65085             :         }
   65086          28 :         alloc[SgWhileStmt::pool_size-1].p_freepointer = nullptr;
   65087             : 
   65088          28 :         SgWhileStmt::pools.push_back ( (unsigned char *) alloc );
   65089          28 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgWhileStmt::pool_size * sizeof(SgWhileStmt), V_SgWhileStmt ) );
   65090          28 :         SgWhileStmt::next_node = alloc;
   65091             :     }
   65092         462 :     ROSE_ASSERT(SgWhileStmt::next_node != nullptr);
   65093             : 
   65094         462 :     SgWhileStmt * object = SgWhileStmt::next_node;
   65095         462 :     SgWhileStmt::next_node = (SgWhileStmt*)(object->p_freepointer);
   65096             : 
   65097             : #if ROSE_ALLOC_TRACE == 2
   65098             :     printf("SgWhileStmt::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgWhileStmt::next_node);
   65099             : #endif
   65100             : 
   65101         462 :     SgNode * fp = object->p_freepointer;
   65102             : #if ROSE_ALLOC_MEMSET == 1
   65103             : #elif ROSE_ALLOC_MEMSET == 2
   65104             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgWhileStmt) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   65105             : #elif ROSE_ALLOC_MEMSET == 3
   65106             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgWhileStmt) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   65107             : #endif
   65108         462 :     object->p_freepointer = fp;
   65109             : 
   65110             : #if ROSE_ALLOC_TRACE == 2
   65111             : //    printf("SgWhileStmt::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgWhileStmt::next_node);
   65112             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   65113             :     Rose::MemPool::snapshot(oss.str());
   65114             :     alloc_trace_cnt++;
   65115             : #endif
   65116             : 
   65117         462 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   65118             : 
   65119         462 :     ALLOC_MUTEX(SgWhileStmt, unlock);
   65120             : 
   65121             :     return object;
   65122             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   65123             : }
   65124             : 
   65125             : 
   65126             : 
   65127             : /*! \brief Delete operator for SgWhileStmt.
   65128             : 
   65129             :    This delete operator implements deallocation using memory pools to 
   65130             :    provide most efficent use of the heap within construction of large ASTs.
   65131             : 
   65132             : \internal The new and delete operators use the lower level C malloc/free
   65133             :    function calls for performance and to make sure that mixing of malloc/free
   65134             :    and new/delete by the used can be caught more readily.  This may change
   65135             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   65136             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   65137             :    deallocate memory allocated using ROSE_MALLOC.
   65138             : */
   65139          94 : void SgWhileStmt::operator delete(void *Pointer, size_t Size)
   65140             : {
   65141             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   65142             :      * or throwing an exception. */
   65143          94 :     ALLOC_MUTEX(SgWhileStmt, lock);
   65144             : 
   65145             : #if USE_CPP_NEW_DELETE_OPERATORS
   65146             :     ROSE_FREE(Pointer);
   65147             : #else
   65148             : #if ROSE_PEDANTIC_ALLOC
   65149             :     ROSE_ASSERT(Size == sizeof(SgWhileStmt));
   65150             : #else
   65151          94 :     if (Size != sizeof(SgWhileStmt)) {
   65152           0 :       ROSE_FREE(Pointer);
   65153           0 :       ALLOC_MUTEX(SgWhileStmt, unlock);
   65154             :       return;
   65155             :     }
   65156             : #endif
   65157             : 
   65158          94 :     SgWhileStmt * object = (SgWhileStmt*) Pointer;
   65159          94 :     ROSE_ASSERT(object != nullptr);
   65160             : 
   65161             : #if ROSE_ALLOC_TRACE == 2
   65162             : //  printf("SgWhileStmt::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgWhileStmt::next_node);
   65163             :     printf("SgWhileStmt::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgWhileStmt::next_node);
   65164             : #endif
   65165             : 
   65166             : #if ROSE_PEDANTIC_ALLOC
   65167             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   65168             : #endif
   65169             : 
   65170             : #if ROSE_ALLOC_MEMSET == 1
   65171             : #elif ROSE_ALLOC_MEMSET == 2
   65172             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgWhileStmt) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   65173             : #elif ROSE_ALLOC_MEMSET == 3
   65174             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgWhileStmt) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   65175             : #endif
   65176             : 
   65177             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   65178             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   65179             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   65180             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   65181             : #else
   65182          94 :     object->p_freepointer = SgWhileStmt::next_node;
   65183          94 :     SgWhileStmt::next_node = object;
   65184             : #endif
   65185             : 
   65186             : #if ROSE_ALLOC_TRACE == 2
   65187             : //  printf("SgWhileStmt::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgWhileStmt::next_node);
   65188             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   65189             :     Rose::MemPool::snapshot(oss.str());
   65190             :     alloc_trace_cnt++;
   65191             : #endif
   65192             : 
   65193             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   65194             : 
   65195          94 :     ALLOC_MUTEX(SgWhileStmt, unlock);
   65196             : }
   65197             : 
   65198             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   65199             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   65200             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   65201             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   65202             : // Also, note comment below from Robb (copied from the Common.code file).
   65203             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   65204             : //
   65205             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   65206             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   65207             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   65208             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   65209             : #if 0
   65210             : void SgWhileStmt::operator delete(void* pointer) { SgWhileStmt::operator delete (pointer, sizeof(SgWhileStmt)); };
   65211             : #endif
   65212             : /* #line 65213 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   65213             : 
   65214             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   65215             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   65216             : // obviously imply C++.
   65217             : 
   65218             : // This implements the support within ROSE for memory pools.  Memory pools
   65219             : // support the most condensed usage of memory within the construction of
   65220             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   65221             : // by a new operator written for each class.
   65222             : 
   65223             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   65224             :     // User wants multi-thread support and POSIX threads are available.
   65225             : #   include <pthread.h>
   65226             :     static pthread_mutex_t SgDoWhileStmt_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   65227             : #else
   65228             :      // Cause synchronization to be skipped.
   65229             : #    ifndef ALLOC_MUTEX
   65230             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   65231             : #    endif
   65232             : #    ifdef _REENTRANT
   65233             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   65234             : #       ifdef _MSC_VER
   65235             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   65236             : #       else
   65237             : #           warning "POSIX threads are not available; synchronization being skipped"
   65238             : #       endif
   65239             : #    endif
   65240             : #endif
   65241             : 
   65242             : #ifndef ROSE_ALLOC_TRACE
   65243             : #  define ROSE_ALLOC_TRACE 0
   65244             : #endif
   65245             : 
   65246             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   65247             : #define ROSE_ALLOC_TRACE_CNT
   65248             : #include "memory-pool-snapshot.h"
   65249             : unsigned long alloc_trace_cnt = 0;
   65250             : #endif
   65251             : 
   65252             : #if ROSE_ALLOC_TRACE
   65253             : const unsigned SgDoWhileStmt::pool_size = 5;
   65254             : #else
   65255             : const unsigned SgDoWhileStmt::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   65256             : #endif
   65257             : 
   65258             : #ifndef ROSE_ALLOC_MEMSET
   65259             : #  define ROSE_ALLOC_MEMSET 0
   65260             : #endif
   65261             : 
   65262             : #ifndef ROSE_PEDANTIC_ALLOC
   65263             : #  define ROSE_PEDANTIC_ALLOC 0
   65264             : #endif
   65265             : 
   65266             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   65267             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   65268             : #endif
   65269             : 
   65270             : #if !defined(SGNODE__ALL_POOLS)
   65271             : #define SGNODE__ALL_POOLS
   65272             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   65273             : #endif
   65274             : 
   65275             : SgDoWhileStmt* SgDoWhileStmt::next_node = nullptr;
   65276             : std::vector<unsigned char*> SgDoWhileStmt::pools;
   65277             : 
   65278             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   65279             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   65280             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   65281             : // around this macro definition rather than each use).
   65282             : #ifndef ALLOC_MUTEX
   65283             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   65284             :         do {                                                                     \
   65285             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   65286             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   65287             :                 abort();                                                         \
   65288             :             }                                                                    \
   65289             :         } while (0);
   65290             : #endif
   65291             : 
   65292             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   65293             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   65294             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   65295             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   65296             : 
   65297             : /*! \brief New operator for SgDoWhileStmt.
   65298             : 
   65299             :    This new operator implements memory pools to provide most efficent 
   65300             :    use of the heap within construction of large ASTs.
   65301             : 
   65302             : \internal The new and delete operators use the lower level C malloc/free
   65303             :    function calls for performance and to make sure that mixing of malloc/free
   65304             :    and new/delete by the used can be caught more readily.  This may change
   65305             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   65306             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   65307             :    deallocate memory allocated using ROSE_MALLOC.
   65308             : */
   65309          65 : void *SgDoWhileStmt::operator new ( size_t Size )
   65310             : {
   65311             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   65312             :      * returning or throwing an exception. */
   65313          65 :     ALLOC_MUTEX(SgDoWhileStmt, lock);
   65314             : 
   65315             : #if ROSE_ALLOC_TRACE == 2
   65316             : //    printf("SgDoWhileStmt::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgDoWhileStmt::next_node);
   65317             : #endif
   65318             : 
   65319             : #if USE_CPP_NEW_DELETE_OPERATORS
   65320             :     void *mem = ROSE_MALLOC(Size);
   65321             :     ALLOC_MUTEX(SgDoWhileStmt, unlock);
   65322             :     return mem;
   65323             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   65324             : #if ROSE_PEDANTIC_ALLOC
   65325             :     ROSE_ASSERT(Size == sizeof(SgDoWhileStmt));
   65326             : #else
   65327          65 :     if (Size != sizeof(SgDoWhileStmt)) {
   65328           0 :       void * object = ROSE_MALLOC(Size);
   65329           0 :       ALLOC_MUTEX(SgDoWhileStmt, unlock);
   65330             :       return object;
   65331             :     }
   65332             : #endif
   65333             : 
   65334          65 :     if (SgDoWhileStmt::next_node == nullptr) {
   65335           9 :         SgDoWhileStmt * alloc = (SgDoWhileStmt*) ROSE_MALLOC ( SgDoWhileStmt::pool_size * sizeof(SgDoWhileStmt) );
   65336           9 :         ROSE_ASSERT(alloc != nullptr);
   65337             : 
   65338             : #if ROSE_ALLOC_TRACE == 2
   65339             : //        printf("SgDoWhileStmt::alloc\n  block[%zi] = [ %p , %p [\n", SgDoWhileStmt::pools.size(), alloc, alloc + SgDoWhileStmt::pool_size);
   65340             : #endif
   65341             : 
   65342             : #if ROSE_ALLOC_MEMSET == 1
   65343             : #elif ROSE_ALLOC_MEMSET == 2
   65344             :         memset(alloc, 0x00, SgDoWhileStmt::pool_size * sizeof(SgDoWhileStmt));
   65345             : #elif ROSE_ALLOC_MEMSET == 3
   65346             :         memset(alloc, 0xAA, SgDoWhileStmt::pool_size * sizeof(SgDoWhileStmt));
   65347             : #endif
   65348       18000 :         for (unsigned i=0; i < SgDoWhileStmt::pool_size-1; i++) {
   65349       17991 :           alloc[i].p_freepointer = &(alloc[i+1]);
   65350             :         }
   65351           9 :         alloc[SgDoWhileStmt::pool_size-1].p_freepointer = nullptr;
   65352             : 
   65353           9 :         SgDoWhileStmt::pools.push_back ( (unsigned char *) alloc );
   65354           9 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgDoWhileStmt::pool_size * sizeof(SgDoWhileStmt), V_SgDoWhileStmt ) );
   65355           9 :         SgDoWhileStmt::next_node = alloc;
   65356             :     }
   65357          65 :     ROSE_ASSERT(SgDoWhileStmt::next_node != nullptr);
   65358             : 
   65359          65 :     SgDoWhileStmt * object = SgDoWhileStmt::next_node;
   65360          65 :     SgDoWhileStmt::next_node = (SgDoWhileStmt*)(object->p_freepointer);
   65361             : 
   65362             : #if ROSE_ALLOC_TRACE == 2
   65363             :     printf("SgDoWhileStmt::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgDoWhileStmt::next_node);
   65364             : #endif
   65365             : 
   65366          65 :     SgNode * fp = object->p_freepointer;
   65367             : #if ROSE_ALLOC_MEMSET == 1
   65368             : #elif ROSE_ALLOC_MEMSET == 2
   65369             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgDoWhileStmt) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   65370             : #elif ROSE_ALLOC_MEMSET == 3
   65371             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgDoWhileStmt) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   65372             : #endif
   65373          65 :     object->p_freepointer = fp;
   65374             : 
   65375             : #if ROSE_ALLOC_TRACE == 2
   65376             : //    printf("SgDoWhileStmt::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgDoWhileStmt::next_node);
   65377             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   65378             :     Rose::MemPool::snapshot(oss.str());
   65379             :     alloc_trace_cnt++;
   65380             : #endif
   65381             : 
   65382          65 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   65383             : 
   65384          65 :     ALLOC_MUTEX(SgDoWhileStmt, unlock);
   65385             : 
   65386             :     return object;
   65387             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   65388             : }
   65389             : 
   65390             : 
   65391             : 
   65392             : /*! \brief Delete operator for SgDoWhileStmt.
   65393             : 
   65394             :    This delete operator implements deallocation using memory pools to 
   65395             :    provide most efficent use of the heap within construction of large ASTs.
   65396             : 
   65397             : \internal The new and delete operators use the lower level C malloc/free
   65398             :    function calls for performance and to make sure that mixing of malloc/free
   65399             :    and new/delete by the used can be caught more readily.  This may change
   65400             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   65401             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   65402             :    deallocate memory allocated using ROSE_MALLOC.
   65403             : */
   65404          14 : void SgDoWhileStmt::operator delete(void *Pointer, size_t Size)
   65405             : {
   65406             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   65407             :      * or throwing an exception. */
   65408          14 :     ALLOC_MUTEX(SgDoWhileStmt, lock);
   65409             : 
   65410             : #if USE_CPP_NEW_DELETE_OPERATORS
   65411             :     ROSE_FREE(Pointer);
   65412             : #else
   65413             : #if ROSE_PEDANTIC_ALLOC
   65414             :     ROSE_ASSERT(Size == sizeof(SgDoWhileStmt));
   65415             : #else
   65416          14 :     if (Size != sizeof(SgDoWhileStmt)) {
   65417           0 :       ROSE_FREE(Pointer);
   65418           0 :       ALLOC_MUTEX(SgDoWhileStmt, unlock);
   65419             :       return;
   65420             :     }
   65421             : #endif
   65422             : 
   65423          14 :     SgDoWhileStmt * object = (SgDoWhileStmt*) Pointer;
   65424          14 :     ROSE_ASSERT(object != nullptr);
   65425             : 
   65426             : #if ROSE_ALLOC_TRACE == 2
   65427             : //  printf("SgDoWhileStmt::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgDoWhileStmt::next_node);
   65428             :     printf("SgDoWhileStmt::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgDoWhileStmt::next_node);
   65429             : #endif
   65430             : 
   65431             : #if ROSE_PEDANTIC_ALLOC
   65432             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   65433             : #endif
   65434             : 
   65435             : #if ROSE_ALLOC_MEMSET == 1
   65436             : #elif ROSE_ALLOC_MEMSET == 2
   65437             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgDoWhileStmt) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   65438             : #elif ROSE_ALLOC_MEMSET == 3
   65439             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgDoWhileStmt) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   65440             : #endif
   65441             : 
   65442             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   65443             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   65444             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   65445             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   65446             : #else
   65447          14 :     object->p_freepointer = SgDoWhileStmt::next_node;
   65448          14 :     SgDoWhileStmt::next_node = object;
   65449             : #endif
   65450             : 
   65451             : #if ROSE_ALLOC_TRACE == 2
   65452             : //  printf("SgDoWhileStmt::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgDoWhileStmt::next_node);
   65453             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   65454             :     Rose::MemPool::snapshot(oss.str());
   65455             :     alloc_trace_cnt++;
   65456             : #endif
   65457             : 
   65458             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   65459             : 
   65460          14 :     ALLOC_MUTEX(SgDoWhileStmt, unlock);
   65461             : }
   65462             : 
   65463             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   65464             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   65465             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   65466             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   65467             : // Also, note comment below from Robb (copied from the Common.code file).
   65468             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   65469             : //
   65470             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   65471             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   65472             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   65473             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   65474             : #if 0
   65475             : void SgDoWhileStmt::operator delete(void* pointer) { SgDoWhileStmt::operator delete (pointer, sizeof(SgDoWhileStmt)); };
   65476             : #endif
   65477             : /* #line 65478 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   65478             : 
   65479             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   65480             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   65481             : // obviously imply C++.
   65482             : 
   65483             : // This implements the support within ROSE for memory pools.  Memory pools
   65484             : // support the most condensed usage of memory within the construction of
   65485             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   65486             : // by a new operator written for each class.
   65487             : 
   65488             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   65489             :     // User wants multi-thread support and POSIX threads are available.
   65490             : #   include <pthread.h>
   65491             :     static pthread_mutex_t SgSwitchStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   65492             : #else
   65493             :      // Cause synchronization to be skipped.
   65494             : #    ifndef ALLOC_MUTEX
   65495             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   65496             : #    endif
   65497             : #    ifdef _REENTRANT
   65498             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   65499             : #       ifdef _MSC_VER
   65500             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   65501             : #       else
   65502             : #           warning "POSIX threads are not available; synchronization being skipped"
   65503             : #       endif
   65504             : #    endif
   65505             : #endif
   65506             : 
   65507             : #ifndef ROSE_ALLOC_TRACE
   65508             : #  define ROSE_ALLOC_TRACE 0
   65509             : #endif
   65510             : 
   65511             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   65512             : #define ROSE_ALLOC_TRACE_CNT
   65513             : #include "memory-pool-snapshot.h"
   65514             : unsigned long alloc_trace_cnt = 0;
   65515             : #endif
   65516             : 
   65517             : #if ROSE_ALLOC_TRACE
   65518             : const unsigned SgSwitchStatement::pool_size = 5;
   65519             : #else
   65520             : const unsigned SgSwitchStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   65521             : #endif
   65522             : 
   65523             : #ifndef ROSE_ALLOC_MEMSET
   65524             : #  define ROSE_ALLOC_MEMSET 0
   65525             : #endif
   65526             : 
   65527             : #ifndef ROSE_PEDANTIC_ALLOC
   65528             : #  define ROSE_PEDANTIC_ALLOC 0
   65529             : #endif
   65530             : 
   65531             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   65532             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   65533             : #endif
   65534             : 
   65535             : #if !defined(SGNODE__ALL_POOLS)
   65536             : #define SGNODE__ALL_POOLS
   65537             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   65538             : #endif
   65539             : 
   65540             : SgSwitchStatement* SgSwitchStatement::next_node = nullptr;
   65541             : std::vector<unsigned char*> SgSwitchStatement::pools;
   65542             : 
   65543             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   65544             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   65545             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   65546             : // around this macro definition rather than each use).
   65547             : #ifndef ALLOC_MUTEX
   65548             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   65549             :         do {                                                                     \
   65550             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   65551             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   65552             :                 abort();                                                         \
   65553             :             }                                                                    \
   65554             :         } while (0);
   65555             : #endif
   65556             : 
   65557             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   65558             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   65559             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   65560             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   65561             : 
   65562             : /*! \brief New operator for SgSwitchStatement.
   65563             : 
   65564             :    This new operator implements memory pools to provide most efficent 
   65565             :    use of the heap within construction of large ASTs.
   65566             : 
   65567             : \internal The new and delete operators use the lower level C malloc/free
   65568             :    function calls for performance and to make sure that mixing of malloc/free
   65569             :    and new/delete by the used can be caught more readily.  This may change
   65570             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   65571             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   65572             :    deallocate memory allocated using ROSE_MALLOC.
   65573             : */
   65574           1 : void *SgSwitchStatement::operator new ( size_t Size )
   65575             : {
   65576             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   65577             :      * returning or throwing an exception. */
   65578           1 :     ALLOC_MUTEX(SgSwitchStatement, lock);
   65579             : 
   65580             : #if ROSE_ALLOC_TRACE == 2
   65581             : //    printf("SgSwitchStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgSwitchStatement::next_node);
   65582             : #endif
   65583             : 
   65584             : #if USE_CPP_NEW_DELETE_OPERATORS
   65585             :     void *mem = ROSE_MALLOC(Size);
   65586             :     ALLOC_MUTEX(SgSwitchStatement, unlock);
   65587             :     return mem;
   65588             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   65589             : #if ROSE_PEDANTIC_ALLOC
   65590             :     ROSE_ASSERT(Size == sizeof(SgSwitchStatement));
   65591             : #else
   65592           1 :     if (Size != sizeof(SgSwitchStatement)) {
   65593           0 :       void * object = ROSE_MALLOC(Size);
   65594           0 :       ALLOC_MUTEX(SgSwitchStatement, unlock);
   65595             :       return object;
   65596             :     }
   65597             : #endif
   65598             : 
   65599           1 :     if (SgSwitchStatement::next_node == nullptr) {
   65600           1 :         SgSwitchStatement * alloc = (SgSwitchStatement*) ROSE_MALLOC ( SgSwitchStatement::pool_size * sizeof(SgSwitchStatement) );
   65601           1 :         ROSE_ASSERT(alloc != nullptr);
   65602             : 
   65603             : #if ROSE_ALLOC_TRACE == 2
   65604             : //        printf("SgSwitchStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgSwitchStatement::pools.size(), alloc, alloc + SgSwitchStatement::pool_size);
   65605             : #endif
   65606             : 
   65607             : #if ROSE_ALLOC_MEMSET == 1
   65608             : #elif ROSE_ALLOC_MEMSET == 2
   65609             :         memset(alloc, 0x00, SgSwitchStatement::pool_size * sizeof(SgSwitchStatement));
   65610             : #elif ROSE_ALLOC_MEMSET == 3
   65611             :         memset(alloc, 0xAA, SgSwitchStatement::pool_size * sizeof(SgSwitchStatement));
   65612             : #endif
   65613        2000 :         for (unsigned i=0; i < SgSwitchStatement::pool_size-1; i++) {
   65614        1999 :           alloc[i].p_freepointer = &(alloc[i+1]);
   65615             :         }
   65616           1 :         alloc[SgSwitchStatement::pool_size-1].p_freepointer = nullptr;
   65617             : 
   65618           1 :         SgSwitchStatement::pools.push_back ( (unsigned char *) alloc );
   65619           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgSwitchStatement::pool_size * sizeof(SgSwitchStatement), V_SgSwitchStatement ) );
   65620           1 :         SgSwitchStatement::next_node = alloc;
   65621             :     }
   65622           1 :     ROSE_ASSERT(SgSwitchStatement::next_node != nullptr);
   65623             : 
   65624           1 :     SgSwitchStatement * object = SgSwitchStatement::next_node;
   65625           1 :     SgSwitchStatement::next_node = (SgSwitchStatement*)(object->p_freepointer);
   65626             : 
   65627             : #if ROSE_ALLOC_TRACE == 2
   65628             :     printf("SgSwitchStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgSwitchStatement::next_node);
   65629             : #endif
   65630             : 
   65631           1 :     SgNode * fp = object->p_freepointer;
   65632             : #if ROSE_ALLOC_MEMSET == 1
   65633             : #elif ROSE_ALLOC_MEMSET == 2
   65634             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgSwitchStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   65635             : #elif ROSE_ALLOC_MEMSET == 3
   65636             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgSwitchStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   65637             : #endif
   65638           1 :     object->p_freepointer = fp;
   65639             : 
   65640             : #if ROSE_ALLOC_TRACE == 2
   65641             : //    printf("SgSwitchStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgSwitchStatement::next_node);
   65642             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   65643             :     Rose::MemPool::snapshot(oss.str());
   65644             :     alloc_trace_cnt++;
   65645             : #endif
   65646             : 
   65647           1 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   65648             : 
   65649           1 :     ALLOC_MUTEX(SgSwitchStatement, unlock);
   65650             : 
   65651             :     return object;
   65652             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   65653             : }
   65654             : 
   65655             : 
   65656             : 
   65657             : /*! \brief Delete operator for SgSwitchStatement.
   65658             : 
   65659             :    This delete operator implements deallocation using memory pools to 
   65660             :    provide most efficent use of the heap within construction of large ASTs.
   65661             : 
   65662             : \internal The new and delete operators use the lower level C malloc/free
   65663             :    function calls for performance and to make sure that mixing of malloc/free
   65664             :    and new/delete by the used can be caught more readily.  This may change
   65665             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   65666             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   65667             :    deallocate memory allocated using ROSE_MALLOC.
   65668             : */
   65669           0 : void SgSwitchStatement::operator delete(void *Pointer, size_t Size)
   65670             : {
   65671             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   65672             :      * or throwing an exception. */
   65673           0 :     ALLOC_MUTEX(SgSwitchStatement, lock);
   65674             : 
   65675             : #if USE_CPP_NEW_DELETE_OPERATORS
   65676             :     ROSE_FREE(Pointer);
   65677             : #else
   65678             : #if ROSE_PEDANTIC_ALLOC
   65679             :     ROSE_ASSERT(Size == sizeof(SgSwitchStatement));
   65680             : #else
   65681           0 :     if (Size != sizeof(SgSwitchStatement)) {
   65682           0 :       ROSE_FREE(Pointer);
   65683           0 :       ALLOC_MUTEX(SgSwitchStatement, unlock);
   65684             :       return;
   65685             :     }
   65686             : #endif
   65687             : 
   65688           0 :     SgSwitchStatement * object = (SgSwitchStatement*) Pointer;
   65689           0 :     ROSE_ASSERT(object != nullptr);
   65690             : 
   65691             : #if ROSE_ALLOC_TRACE == 2
   65692             : //  printf("SgSwitchStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgSwitchStatement::next_node);
   65693             :     printf("SgSwitchStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgSwitchStatement::next_node);
   65694             : #endif
   65695             : 
   65696             : #if ROSE_PEDANTIC_ALLOC
   65697             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   65698             : #endif
   65699             : 
   65700             : #if ROSE_ALLOC_MEMSET == 1
   65701             : #elif ROSE_ALLOC_MEMSET == 2
   65702             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgSwitchStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   65703             : #elif ROSE_ALLOC_MEMSET == 3
   65704             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgSwitchStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   65705             : #endif
   65706             : 
   65707             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   65708             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   65709             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   65710             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   65711             : #else
   65712           0 :     object->p_freepointer = SgSwitchStatement::next_node;
   65713           0 :     SgSwitchStatement::next_node = object;
   65714             : #endif
   65715             : 
   65716             : #if ROSE_ALLOC_TRACE == 2
   65717             : //  printf("SgSwitchStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgSwitchStatement::next_node);
   65718             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   65719             :     Rose::MemPool::snapshot(oss.str());
   65720             :     alloc_trace_cnt++;
   65721             : #endif
   65722             : 
   65723             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   65724             : 
   65725           0 :     ALLOC_MUTEX(SgSwitchStatement, unlock);
   65726             : }
   65727             : 
   65728             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   65729             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   65730             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   65731             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   65732             : // Also, note comment below from Robb (copied from the Common.code file).
   65733             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   65734             : //
   65735             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   65736             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   65737             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   65738             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   65739             : #if 0
   65740             : void SgSwitchStatement::operator delete(void* pointer) { SgSwitchStatement::operator delete (pointer, sizeof(SgSwitchStatement)); };
   65741             : #endif
   65742             : /* #line 65743 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   65743             : 
   65744             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   65745             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   65746             : // obviously imply C++.
   65747             : 
   65748             : // This implements the support within ROSE for memory pools.  Memory pools
   65749             : // support the most condensed usage of memory within the construction of
   65750             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   65751             : // by a new operator written for each class.
   65752             : 
   65753             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   65754             :     // User wants multi-thread support and POSIX threads are available.
   65755             : #   include <pthread.h>
   65756             :     static pthread_mutex_t SgCatchOptionStmt_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   65757             : #else
   65758             :      // Cause synchronization to be skipped.
   65759             : #    ifndef ALLOC_MUTEX
   65760             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   65761             : #    endif
   65762             : #    ifdef _REENTRANT
   65763             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   65764             : #       ifdef _MSC_VER
   65765             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   65766             : #       else
   65767             : #           warning "POSIX threads are not available; synchronization being skipped"
   65768             : #       endif
   65769             : #    endif
   65770             : #endif
   65771             : 
   65772             : #ifndef ROSE_ALLOC_TRACE
   65773             : #  define ROSE_ALLOC_TRACE 0
   65774             : #endif
   65775             : 
   65776             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   65777             : #define ROSE_ALLOC_TRACE_CNT
   65778             : #include "memory-pool-snapshot.h"
   65779             : unsigned long alloc_trace_cnt = 0;
   65780             : #endif
   65781             : 
   65782             : #if ROSE_ALLOC_TRACE
   65783             : const unsigned SgCatchOptionStmt::pool_size = 5;
   65784             : #else
   65785             : const unsigned SgCatchOptionStmt::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   65786             : #endif
   65787             : 
   65788             : #ifndef ROSE_ALLOC_MEMSET
   65789             : #  define ROSE_ALLOC_MEMSET 0
   65790             : #endif
   65791             : 
   65792             : #ifndef ROSE_PEDANTIC_ALLOC
   65793             : #  define ROSE_PEDANTIC_ALLOC 0
   65794             : #endif
   65795             : 
   65796             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   65797             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   65798             : #endif
   65799             : 
   65800             : #if !defined(SGNODE__ALL_POOLS)
   65801             : #define SGNODE__ALL_POOLS
   65802             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   65803             : #endif
   65804             : 
   65805             : SgCatchOptionStmt* SgCatchOptionStmt::next_node = nullptr;
   65806             : std::vector<unsigned char*> SgCatchOptionStmt::pools;
   65807             : 
   65808             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   65809             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   65810             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   65811             : // around this macro definition rather than each use).
   65812             : #ifndef ALLOC_MUTEX
   65813             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   65814             :         do {                                                                     \
   65815             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   65816             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   65817             :                 abort();                                                         \
   65818             :             }                                                                    \
   65819             :         } while (0);
   65820             : #endif
   65821             : 
   65822             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   65823             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   65824             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   65825             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   65826             : 
   65827             : /*! \brief New operator for SgCatchOptionStmt.
   65828             : 
   65829             :    This new operator implements memory pools to provide most efficent 
   65830             :    use of the heap within construction of large ASTs.
   65831             : 
   65832             : \internal The new and delete operators use the lower level C malloc/free
   65833             :    function calls for performance and to make sure that mixing of malloc/free
   65834             :    and new/delete by the used can be caught more readily.  This may change
   65835             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   65836             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   65837             :    deallocate memory allocated using ROSE_MALLOC.
   65838             : */
   65839         892 : void *SgCatchOptionStmt::operator new ( size_t Size )
   65840             : {
   65841             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   65842             :      * returning or throwing an exception. */
   65843         892 :     ALLOC_MUTEX(SgCatchOptionStmt, lock);
   65844             : 
   65845             : #if ROSE_ALLOC_TRACE == 2
   65846             : //    printf("SgCatchOptionStmt::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgCatchOptionStmt::next_node);
   65847             : #endif
   65848             : 
   65849             : #if USE_CPP_NEW_DELETE_OPERATORS
   65850             :     void *mem = ROSE_MALLOC(Size);
   65851             :     ALLOC_MUTEX(SgCatchOptionStmt, unlock);
   65852             :     return mem;
   65853             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   65854             : #if ROSE_PEDANTIC_ALLOC
   65855             :     ROSE_ASSERT(Size == sizeof(SgCatchOptionStmt));
   65856             : #else
   65857         892 :     if (Size != sizeof(SgCatchOptionStmt)) {
   65858           0 :       void * object = ROSE_MALLOC(Size);
   65859           0 :       ALLOC_MUTEX(SgCatchOptionStmt, unlock);
   65860             :       return object;
   65861             :     }
   65862             : #endif
   65863             : 
   65864         892 :     if (SgCatchOptionStmt::next_node == nullptr) {
   65865          10 :         SgCatchOptionStmt * alloc = (SgCatchOptionStmt*) ROSE_MALLOC ( SgCatchOptionStmt::pool_size * sizeof(SgCatchOptionStmt) );
   65866          10 :         ROSE_ASSERT(alloc != nullptr);
   65867             : 
   65868             : #if ROSE_ALLOC_TRACE == 2
   65869             : //        printf("SgCatchOptionStmt::alloc\n  block[%zi] = [ %p , %p [\n", SgCatchOptionStmt::pools.size(), alloc, alloc + SgCatchOptionStmt::pool_size);
   65870             : #endif
   65871             : 
   65872             : #if ROSE_ALLOC_MEMSET == 1
   65873             : #elif ROSE_ALLOC_MEMSET == 2
   65874             :         memset(alloc, 0x00, SgCatchOptionStmt::pool_size * sizeof(SgCatchOptionStmt));
   65875             : #elif ROSE_ALLOC_MEMSET == 3
   65876             :         memset(alloc, 0xAA, SgCatchOptionStmt::pool_size * sizeof(SgCatchOptionStmt));
   65877             : #endif
   65878       20000 :         for (unsigned i=0; i < SgCatchOptionStmt::pool_size-1; i++) {
   65879       19990 :           alloc[i].p_freepointer = &(alloc[i+1]);
   65880             :         }
   65881          10 :         alloc[SgCatchOptionStmt::pool_size-1].p_freepointer = nullptr;
   65882             : 
   65883          10 :         SgCatchOptionStmt::pools.push_back ( (unsigned char *) alloc );
   65884          10 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgCatchOptionStmt::pool_size * sizeof(SgCatchOptionStmt), V_SgCatchOptionStmt ) );
   65885          10 :         SgCatchOptionStmt::next_node = alloc;
   65886             :     }
   65887         892 :     ROSE_ASSERT(SgCatchOptionStmt::next_node != nullptr);
   65888             : 
   65889         892 :     SgCatchOptionStmt * object = SgCatchOptionStmt::next_node;
   65890         892 :     SgCatchOptionStmt::next_node = (SgCatchOptionStmt*)(object->p_freepointer);
   65891             : 
   65892             : #if ROSE_ALLOC_TRACE == 2
   65893             :     printf("SgCatchOptionStmt::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgCatchOptionStmt::next_node);
   65894             : #endif
   65895             : 
   65896         892 :     SgNode * fp = object->p_freepointer;
   65897             : #if ROSE_ALLOC_MEMSET == 1
   65898             : #elif ROSE_ALLOC_MEMSET == 2
   65899             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgCatchOptionStmt) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   65900             : #elif ROSE_ALLOC_MEMSET == 3
   65901             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgCatchOptionStmt) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   65902             : #endif
   65903         892 :     object->p_freepointer = fp;
   65904             : 
   65905             : #if ROSE_ALLOC_TRACE == 2
   65906             : //    printf("SgCatchOptionStmt::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgCatchOptionStmt::next_node);
   65907             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   65908             :     Rose::MemPool::snapshot(oss.str());
   65909             :     alloc_trace_cnt++;
   65910             : #endif
   65911             : 
   65912         892 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   65913             : 
   65914         892 :     ALLOC_MUTEX(SgCatchOptionStmt, unlock);
   65915             : 
   65916             :     return object;
   65917             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   65918             : }
   65919             : 
   65920             : 
   65921             : 
   65922             : /*! \brief Delete operator for SgCatchOptionStmt.
   65923             : 
   65924             :    This delete operator implements deallocation using memory pools to 
   65925             :    provide most efficent use of the heap within construction of large ASTs.
   65926             : 
   65927             : \internal The new and delete operators use the lower level C malloc/free
   65928             :    function calls for performance and to make sure that mixing of malloc/free
   65929             :    and new/delete by the used can be caught more readily.  This may change
   65930             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   65931             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   65932             :    deallocate memory allocated using ROSE_MALLOC.
   65933             : */
   65934         180 : void SgCatchOptionStmt::operator delete(void *Pointer, size_t Size)
   65935             : {
   65936             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   65937             :      * or throwing an exception. */
   65938         180 :     ALLOC_MUTEX(SgCatchOptionStmt, lock);
   65939             : 
   65940             : #if USE_CPP_NEW_DELETE_OPERATORS
   65941             :     ROSE_FREE(Pointer);
   65942             : #else
   65943             : #if ROSE_PEDANTIC_ALLOC
   65944             :     ROSE_ASSERT(Size == sizeof(SgCatchOptionStmt));
   65945             : #else
   65946         180 :     if (Size != sizeof(SgCatchOptionStmt)) {
   65947           0 :       ROSE_FREE(Pointer);
   65948           0 :       ALLOC_MUTEX(SgCatchOptionStmt, unlock);
   65949             :       return;
   65950             :     }
   65951             : #endif
   65952             : 
   65953         180 :     SgCatchOptionStmt * object = (SgCatchOptionStmt*) Pointer;
   65954         180 :     ROSE_ASSERT(object != nullptr);
   65955             : 
   65956             : #if ROSE_ALLOC_TRACE == 2
   65957             : //  printf("SgCatchOptionStmt::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgCatchOptionStmt::next_node);
   65958             :     printf("SgCatchOptionStmt::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgCatchOptionStmt::next_node);
   65959             : #endif
   65960             : 
   65961             : #if ROSE_PEDANTIC_ALLOC
   65962             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   65963             : #endif
   65964             : 
   65965             : #if ROSE_ALLOC_MEMSET == 1
   65966             : #elif ROSE_ALLOC_MEMSET == 2
   65967             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgCatchOptionStmt) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   65968             : #elif ROSE_ALLOC_MEMSET == 3
   65969             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgCatchOptionStmt) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   65970             : #endif
   65971             : 
   65972             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   65973             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   65974             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   65975             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   65976             : #else
   65977         180 :     object->p_freepointer = SgCatchOptionStmt::next_node;
   65978         180 :     SgCatchOptionStmt::next_node = object;
   65979             : #endif
   65980             : 
   65981             : #if ROSE_ALLOC_TRACE == 2
   65982             : //  printf("SgCatchOptionStmt::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgCatchOptionStmt::next_node);
   65983             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   65984             :     Rose::MemPool::snapshot(oss.str());
   65985             :     alloc_trace_cnt++;
   65986             : #endif
   65987             : 
   65988             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   65989             : 
   65990         180 :     ALLOC_MUTEX(SgCatchOptionStmt, unlock);
   65991             : }
   65992             : 
   65993             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   65994             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   65995             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   65996             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   65997             : // Also, note comment below from Robb (copied from the Common.code file).
   65998             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   65999             : //
   66000             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   66001             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   66002             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   66003             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   66004             : #if 0
   66005             : void SgCatchOptionStmt::operator delete(void* pointer) { SgCatchOptionStmt::operator delete (pointer, sizeof(SgCatchOptionStmt)); };
   66006             : #endif
   66007             : /* #line 66008 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   66008             : 
   66009             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   66010             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   66011             : // obviously imply C++.
   66012             : 
   66013             : // This implements the support within ROSE for memory pools.  Memory pools
   66014             : // support the most condensed usage of memory within the construction of
   66015             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   66016             : // by a new operator written for each class.
   66017             : 
   66018             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   66019             :     // User wants multi-thread support and POSIX threads are available.
   66020             : #   include <pthread.h>
   66021             :     static pthread_mutex_t SgNamespaceDefinitionStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   66022             : #else
   66023             :      // Cause synchronization to be skipped.
   66024             : #    ifndef ALLOC_MUTEX
   66025             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   66026             : #    endif
   66027             : #    ifdef _REENTRANT
   66028             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   66029             : #       ifdef _MSC_VER
   66030             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   66031             : #       else
   66032             : #           warning "POSIX threads are not available; synchronization being skipped"
   66033             : #       endif
   66034             : #    endif
   66035             : #endif
   66036             : 
   66037             : #ifndef ROSE_ALLOC_TRACE
   66038             : #  define ROSE_ALLOC_TRACE 0
   66039             : #endif
   66040             : 
   66041             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   66042             : #define ROSE_ALLOC_TRACE_CNT
   66043             : #include "memory-pool-snapshot.h"
   66044             : unsigned long alloc_trace_cnt = 0;
   66045             : #endif
   66046             : 
   66047             : #if ROSE_ALLOC_TRACE
   66048             : const unsigned SgNamespaceDefinitionStatement::pool_size = 5;
   66049             : #else
   66050             : const unsigned SgNamespaceDefinitionStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   66051             : #endif
   66052             : 
   66053             : #ifndef ROSE_ALLOC_MEMSET
   66054             : #  define ROSE_ALLOC_MEMSET 0
   66055             : #endif
   66056             : 
   66057             : #ifndef ROSE_PEDANTIC_ALLOC
   66058             : #  define ROSE_PEDANTIC_ALLOC 0
   66059             : #endif
   66060             : 
   66061             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   66062             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   66063             : #endif
   66064             : 
   66065             : #if !defined(SGNODE__ALL_POOLS)
   66066             : #define SGNODE__ALL_POOLS
   66067             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   66068             : #endif
   66069             : 
   66070             : SgNamespaceDefinitionStatement* SgNamespaceDefinitionStatement::next_node = nullptr;
   66071             : std::vector<unsigned char*> SgNamespaceDefinitionStatement::pools;
   66072             : 
   66073             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   66074             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   66075             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   66076             : // around this macro definition rather than each use).
   66077             : #ifndef ALLOC_MUTEX
   66078             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   66079             :         do {                                                                     \
   66080             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   66081             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   66082             :                 abort();                                                         \
   66083             :             }                                                                    \
   66084             :         } while (0);
   66085             : #endif
   66086             : 
   66087             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   66088             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   66089             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   66090             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   66091             : 
   66092             : /*! \brief New operator for SgNamespaceDefinitionStatement.
   66093             : 
   66094             :    This new operator implements memory pools to provide most efficent 
   66095             :    use of the heap within construction of large ASTs.
   66096             : 
   66097             : \internal The new and delete operators use the lower level C malloc/free
   66098             :    function calls for performance and to make sure that mixing of malloc/free
   66099             :    and new/delete by the used can be caught more readily.  This may change
   66100             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   66101             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   66102             :    deallocate memory allocated using ROSE_MALLOC.
   66103             : */
   66104        1411 : void *SgNamespaceDefinitionStatement::operator new ( size_t Size )
   66105             : {
   66106             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   66107             :      * returning or throwing an exception. */
   66108        1411 :     ALLOC_MUTEX(SgNamespaceDefinitionStatement, lock);
   66109             : 
   66110             : #if ROSE_ALLOC_TRACE == 2
   66111             : //    printf("SgNamespaceDefinitionStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgNamespaceDefinitionStatement::next_node);
   66112             : #endif
   66113             : 
   66114             : #if USE_CPP_NEW_DELETE_OPERATORS
   66115             :     void *mem = ROSE_MALLOC(Size);
   66116             :     ALLOC_MUTEX(SgNamespaceDefinitionStatement, unlock);
   66117             :     return mem;
   66118             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   66119             : #if ROSE_PEDANTIC_ALLOC
   66120             :     ROSE_ASSERT(Size == sizeof(SgNamespaceDefinitionStatement));
   66121             : #else
   66122        1411 :     if (Size != sizeof(SgNamespaceDefinitionStatement)) {
   66123           0 :       void * object = ROSE_MALLOC(Size);
   66124           0 :       ALLOC_MUTEX(SgNamespaceDefinitionStatement, unlock);
   66125             :       return object;
   66126             :     }
   66127             : #endif
   66128             : 
   66129        1411 :     if (SgNamespaceDefinitionStatement::next_node == nullptr) {
   66130          16 :         SgNamespaceDefinitionStatement * alloc = (SgNamespaceDefinitionStatement*) ROSE_MALLOC ( SgNamespaceDefinitionStatement::pool_size * sizeof(SgNamespaceDefinitionStatement) );
   66131          16 :         ROSE_ASSERT(alloc != nullptr);
   66132             : 
   66133             : #if ROSE_ALLOC_TRACE == 2
   66134             : //        printf("SgNamespaceDefinitionStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgNamespaceDefinitionStatement::pools.size(), alloc, alloc + SgNamespaceDefinitionStatement::pool_size);
   66135             : #endif
   66136             : 
   66137             : #if ROSE_ALLOC_MEMSET == 1
   66138             : #elif ROSE_ALLOC_MEMSET == 2
   66139             :         memset(alloc, 0x00, SgNamespaceDefinitionStatement::pool_size * sizeof(SgNamespaceDefinitionStatement));
   66140             : #elif ROSE_ALLOC_MEMSET == 3
   66141             :         memset(alloc, 0xAA, SgNamespaceDefinitionStatement::pool_size * sizeof(SgNamespaceDefinitionStatement));
   66142             : #endif
   66143       32000 :         for (unsigned i=0; i < SgNamespaceDefinitionStatement::pool_size-1; i++) {
   66144       31984 :           alloc[i].p_freepointer = &(alloc[i+1]);
   66145             :         }
   66146          16 :         alloc[SgNamespaceDefinitionStatement::pool_size-1].p_freepointer = nullptr;
   66147             : 
   66148          16 :         SgNamespaceDefinitionStatement::pools.push_back ( (unsigned char *) alloc );
   66149          16 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgNamespaceDefinitionStatement::pool_size * sizeof(SgNamespaceDefinitionStatement), V_SgNamespaceDefinitionStatement ) );
   66150          16 :         SgNamespaceDefinitionStatement::next_node = alloc;
   66151             :     }
   66152        1411 :     ROSE_ASSERT(SgNamespaceDefinitionStatement::next_node != nullptr);
   66153             : 
   66154        1411 :     SgNamespaceDefinitionStatement * object = SgNamespaceDefinitionStatement::next_node;
   66155        1411 :     SgNamespaceDefinitionStatement::next_node = (SgNamespaceDefinitionStatement*)(object->p_freepointer);
   66156             : 
   66157             : #if ROSE_ALLOC_TRACE == 2
   66158             :     printf("SgNamespaceDefinitionStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgNamespaceDefinitionStatement::next_node);
   66159             : #endif
   66160             : 
   66161        1411 :     SgNode * fp = object->p_freepointer;
   66162             : #if ROSE_ALLOC_MEMSET == 1
   66163             : #elif ROSE_ALLOC_MEMSET == 2
   66164             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgNamespaceDefinitionStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   66165             : #elif ROSE_ALLOC_MEMSET == 3
   66166             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgNamespaceDefinitionStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   66167             : #endif
   66168        1411 :     object->p_freepointer = fp;
   66169             : 
   66170             : #if ROSE_ALLOC_TRACE == 2
   66171             : //    printf("SgNamespaceDefinitionStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgNamespaceDefinitionStatement::next_node);
   66172             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   66173             :     Rose::MemPool::snapshot(oss.str());
   66174             :     alloc_trace_cnt++;
   66175             : #endif
   66176             : 
   66177        1411 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   66178             : 
   66179        1411 :     ALLOC_MUTEX(SgNamespaceDefinitionStatement, unlock);
   66180             : 
   66181             :     return object;
   66182             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   66183             : }
   66184             : 
   66185             : 
   66186             : 
   66187             : /*! \brief Delete operator for SgNamespaceDefinitionStatement.
   66188             : 
   66189             :    This delete operator implements deallocation using memory pools to 
   66190             :    provide most efficent use of the heap within construction of large ASTs.
   66191             : 
   66192             : \internal The new and delete operators use the lower level C malloc/free
   66193             :    function calls for performance and to make sure that mixing of malloc/free
   66194             :    and new/delete by the used can be caught more readily.  This may change
   66195             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   66196             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   66197             :    deallocate memory allocated using ROSE_MALLOC.
   66198             : */
   66199         270 : void SgNamespaceDefinitionStatement::operator delete(void *Pointer, size_t Size)
   66200             : {
   66201             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   66202             :      * or throwing an exception. */
   66203         270 :     ALLOC_MUTEX(SgNamespaceDefinitionStatement, lock);
   66204             : 
   66205             : #if USE_CPP_NEW_DELETE_OPERATORS
   66206             :     ROSE_FREE(Pointer);
   66207             : #else
   66208             : #if ROSE_PEDANTIC_ALLOC
   66209             :     ROSE_ASSERT(Size == sizeof(SgNamespaceDefinitionStatement));
   66210             : #else
   66211         270 :     if (Size != sizeof(SgNamespaceDefinitionStatement)) {
   66212           0 :       ROSE_FREE(Pointer);
   66213           0 :       ALLOC_MUTEX(SgNamespaceDefinitionStatement, unlock);
   66214             :       return;
   66215             :     }
   66216             : #endif
   66217             : 
   66218         270 :     SgNamespaceDefinitionStatement * object = (SgNamespaceDefinitionStatement*) Pointer;
   66219         270 :     ROSE_ASSERT(object != nullptr);
   66220             : 
   66221             : #if ROSE_ALLOC_TRACE == 2
   66222             : //  printf("SgNamespaceDefinitionStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgNamespaceDefinitionStatement::next_node);
   66223             :     printf("SgNamespaceDefinitionStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgNamespaceDefinitionStatement::next_node);
   66224             : #endif
   66225             : 
   66226             : #if ROSE_PEDANTIC_ALLOC
   66227             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   66228             : #endif
   66229             : 
   66230             : #if ROSE_ALLOC_MEMSET == 1
   66231             : #elif ROSE_ALLOC_MEMSET == 2
   66232             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgNamespaceDefinitionStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   66233             : #elif ROSE_ALLOC_MEMSET == 3
   66234             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgNamespaceDefinitionStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   66235             : #endif
   66236             : 
   66237             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   66238             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   66239             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   66240             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   66241             : #else
   66242         270 :     object->p_freepointer = SgNamespaceDefinitionStatement::next_node;
   66243         270 :     SgNamespaceDefinitionStatement::next_node = object;
   66244             : #endif
   66245             : 
   66246             : #if ROSE_ALLOC_TRACE == 2
   66247             : //  printf("SgNamespaceDefinitionStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgNamespaceDefinitionStatement::next_node);
   66248             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   66249             :     Rose::MemPool::snapshot(oss.str());
   66250             :     alloc_trace_cnt++;
   66251             : #endif
   66252             : 
   66253             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   66254             : 
   66255         270 :     ALLOC_MUTEX(SgNamespaceDefinitionStatement, unlock);
   66256             : }
   66257             : 
   66258             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   66259             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   66260             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   66261             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   66262             : // Also, note comment below from Robb (copied from the Common.code file).
   66263             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   66264             : //
   66265             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   66266             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   66267             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   66268             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   66269             : #if 0
   66270             : void SgNamespaceDefinitionStatement::operator delete(void* pointer) { SgNamespaceDefinitionStatement::operator delete (pointer, sizeof(SgNamespaceDefinitionStatement)); };
   66271             : #endif
   66272             : /* #line 66273 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   66273             : 
   66274             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   66275             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   66276             : // obviously imply C++.
   66277             : 
   66278             : // This implements the support within ROSE for memory pools.  Memory pools
   66279             : // support the most condensed usage of memory within the construction of
   66280             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   66281             : // by a new operator written for each class.
   66282             : 
   66283             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   66284             :     // User wants multi-thread support and POSIX threads are available.
   66285             : #   include <pthread.h>
   66286             :     static pthread_mutex_t SgBlockDataStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   66287             : #else
   66288             :      // Cause synchronization to be skipped.
   66289             : #    ifndef ALLOC_MUTEX
   66290             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   66291             : #    endif
   66292             : #    ifdef _REENTRANT
   66293             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   66294             : #       ifdef _MSC_VER
   66295             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   66296             : #       else
   66297             : #           warning "POSIX threads are not available; synchronization being skipped"
   66298             : #       endif
   66299             : #    endif
   66300             : #endif
   66301             : 
   66302             : #ifndef ROSE_ALLOC_TRACE
   66303             : #  define ROSE_ALLOC_TRACE 0
   66304             : #endif
   66305             : 
   66306             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   66307             : #define ROSE_ALLOC_TRACE_CNT
   66308             : #include "memory-pool-snapshot.h"
   66309             : unsigned long alloc_trace_cnt = 0;
   66310             : #endif
   66311             : 
   66312             : #if ROSE_ALLOC_TRACE
   66313             : const unsigned SgBlockDataStatement::pool_size = 5;
   66314             : #else
   66315             : const unsigned SgBlockDataStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   66316             : #endif
   66317             : 
   66318             : #ifndef ROSE_ALLOC_MEMSET
   66319             : #  define ROSE_ALLOC_MEMSET 0
   66320             : #endif
   66321             : 
   66322             : #ifndef ROSE_PEDANTIC_ALLOC
   66323             : #  define ROSE_PEDANTIC_ALLOC 0
   66324             : #endif
   66325             : 
   66326             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   66327             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   66328             : #endif
   66329             : 
   66330             : #if !defined(SGNODE__ALL_POOLS)
   66331             : #define SGNODE__ALL_POOLS
   66332             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   66333             : #endif
   66334             : 
   66335             : SgBlockDataStatement* SgBlockDataStatement::next_node = nullptr;
   66336             : std::vector<unsigned char*> SgBlockDataStatement::pools;
   66337             : 
   66338             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   66339             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   66340             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   66341             : // around this macro definition rather than each use).
   66342             : #ifndef ALLOC_MUTEX
   66343             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   66344             :         do {                                                                     \
   66345             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   66346             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   66347             :                 abort();                                                         \
   66348             :             }                                                                    \
   66349             :         } while (0);
   66350             : #endif
   66351             : 
   66352             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   66353             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   66354             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   66355             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   66356             : 
   66357             : /*! \brief New operator for SgBlockDataStatement.
   66358             : 
   66359             :    This new operator implements memory pools to provide most efficent 
   66360             :    use of the heap within construction of large ASTs.
   66361             : 
   66362             : \internal The new and delete operators use the lower level C malloc/free
   66363             :    function calls for performance and to make sure that mixing of malloc/free
   66364             :    and new/delete by the used can be caught more readily.  This may change
   66365             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   66366             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   66367             :    deallocate memory allocated using ROSE_MALLOC.
   66368             : */
   66369           0 : void *SgBlockDataStatement::operator new ( size_t Size )
   66370             : {
   66371             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   66372             :      * returning or throwing an exception. */
   66373           0 :     ALLOC_MUTEX(SgBlockDataStatement, lock);
   66374             : 
   66375             : #if ROSE_ALLOC_TRACE == 2
   66376             : //    printf("SgBlockDataStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgBlockDataStatement::next_node);
   66377             : #endif
   66378             : 
   66379             : #if USE_CPP_NEW_DELETE_OPERATORS
   66380             :     void *mem = ROSE_MALLOC(Size);
   66381             :     ALLOC_MUTEX(SgBlockDataStatement, unlock);
   66382             :     return mem;
   66383             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   66384             : #if ROSE_PEDANTIC_ALLOC
   66385             :     ROSE_ASSERT(Size == sizeof(SgBlockDataStatement));
   66386             : #else
   66387           0 :     if (Size != sizeof(SgBlockDataStatement)) {
   66388           0 :       void * object = ROSE_MALLOC(Size);
   66389           0 :       ALLOC_MUTEX(SgBlockDataStatement, unlock);
   66390             :       return object;
   66391             :     }
   66392             : #endif
   66393             : 
   66394           0 :     if (SgBlockDataStatement::next_node == nullptr) {
   66395           0 :         SgBlockDataStatement * alloc = (SgBlockDataStatement*) ROSE_MALLOC ( SgBlockDataStatement::pool_size * sizeof(SgBlockDataStatement) );
   66396           0 :         ROSE_ASSERT(alloc != nullptr);
   66397             : 
   66398             : #if ROSE_ALLOC_TRACE == 2
   66399             : //        printf("SgBlockDataStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgBlockDataStatement::pools.size(), alloc, alloc + SgBlockDataStatement::pool_size);
   66400             : #endif
   66401             : 
   66402             : #if ROSE_ALLOC_MEMSET == 1
   66403             : #elif ROSE_ALLOC_MEMSET == 2
   66404             :         memset(alloc, 0x00, SgBlockDataStatement::pool_size * sizeof(SgBlockDataStatement));
   66405             : #elif ROSE_ALLOC_MEMSET == 3
   66406             :         memset(alloc, 0xAA, SgBlockDataStatement::pool_size * sizeof(SgBlockDataStatement));
   66407             : #endif
   66408           0 :         for (unsigned i=0; i < SgBlockDataStatement::pool_size-1; i++) {
   66409           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
   66410             :         }
   66411           0 :         alloc[SgBlockDataStatement::pool_size-1].p_freepointer = nullptr;
   66412             : 
   66413           0 :         SgBlockDataStatement::pools.push_back ( (unsigned char *) alloc );
   66414           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgBlockDataStatement::pool_size * sizeof(SgBlockDataStatement), V_SgBlockDataStatement ) );
   66415           0 :         SgBlockDataStatement::next_node = alloc;
   66416             :     }
   66417           0 :     ROSE_ASSERT(SgBlockDataStatement::next_node != nullptr);
   66418             : 
   66419           0 :     SgBlockDataStatement * object = SgBlockDataStatement::next_node;
   66420           0 :     SgBlockDataStatement::next_node = (SgBlockDataStatement*)(object->p_freepointer);
   66421             : 
   66422             : #if ROSE_ALLOC_TRACE == 2
   66423             :     printf("SgBlockDataStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgBlockDataStatement::next_node);
   66424             : #endif
   66425             : 
   66426           0 :     SgNode * fp = object->p_freepointer;
   66427             : #if ROSE_ALLOC_MEMSET == 1
   66428             : #elif ROSE_ALLOC_MEMSET == 2
   66429             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgBlockDataStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   66430             : #elif ROSE_ALLOC_MEMSET == 3
   66431             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgBlockDataStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   66432             : #endif
   66433           0 :     object->p_freepointer = fp;
   66434             : 
   66435             : #if ROSE_ALLOC_TRACE == 2
   66436             : //    printf("SgBlockDataStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgBlockDataStatement::next_node);
   66437             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   66438             :     Rose::MemPool::snapshot(oss.str());
   66439             :     alloc_trace_cnt++;
   66440             : #endif
   66441             : 
   66442           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   66443             : 
   66444           0 :     ALLOC_MUTEX(SgBlockDataStatement, unlock);
   66445             : 
   66446             :     return object;
   66447             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   66448             : }
   66449             : 
   66450             : 
   66451             : 
   66452             : /*! \brief Delete operator for SgBlockDataStatement.
   66453             : 
   66454             :    This delete operator implements deallocation using memory pools to 
   66455             :    provide most efficent use of the heap within construction of large ASTs.
   66456             : 
   66457             : \internal The new and delete operators use the lower level C malloc/free
   66458             :    function calls for performance and to make sure that mixing of malloc/free
   66459             :    and new/delete by the used can be caught more readily.  This may change
   66460             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   66461             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   66462             :    deallocate memory allocated using ROSE_MALLOC.
   66463             : */
   66464           0 : void SgBlockDataStatement::operator delete(void *Pointer, size_t Size)
   66465             : {
   66466             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   66467             :      * or throwing an exception. */
   66468           0 :     ALLOC_MUTEX(SgBlockDataStatement, lock);
   66469             : 
   66470             : #if USE_CPP_NEW_DELETE_OPERATORS
   66471             :     ROSE_FREE(Pointer);
   66472             : #else
   66473             : #if ROSE_PEDANTIC_ALLOC
   66474             :     ROSE_ASSERT(Size == sizeof(SgBlockDataStatement));
   66475             : #else
   66476           0 :     if (Size != sizeof(SgBlockDataStatement)) {
   66477           0 :       ROSE_FREE(Pointer);
   66478           0 :       ALLOC_MUTEX(SgBlockDataStatement, unlock);
   66479             :       return;
   66480             :     }
   66481             : #endif
   66482             : 
   66483           0 :     SgBlockDataStatement * object = (SgBlockDataStatement*) Pointer;
   66484           0 :     ROSE_ASSERT(object != nullptr);
   66485             : 
   66486             : #if ROSE_ALLOC_TRACE == 2
   66487             : //  printf("SgBlockDataStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgBlockDataStatement::next_node);
   66488             :     printf("SgBlockDataStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgBlockDataStatement::next_node);
   66489             : #endif
   66490             : 
   66491             : #if ROSE_PEDANTIC_ALLOC
   66492             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   66493             : #endif
   66494             : 
   66495             : #if ROSE_ALLOC_MEMSET == 1
   66496             : #elif ROSE_ALLOC_MEMSET == 2
   66497             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgBlockDataStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   66498             : #elif ROSE_ALLOC_MEMSET == 3
   66499             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgBlockDataStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   66500             : #endif
   66501             : 
   66502             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   66503             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   66504             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   66505             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   66506             : #else
   66507           0 :     object->p_freepointer = SgBlockDataStatement::next_node;
   66508           0 :     SgBlockDataStatement::next_node = object;
   66509             : #endif
   66510             : 
   66511             : #if ROSE_ALLOC_TRACE == 2
   66512             : //  printf("SgBlockDataStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgBlockDataStatement::next_node);
   66513             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   66514             :     Rose::MemPool::snapshot(oss.str());
   66515             :     alloc_trace_cnt++;
   66516             : #endif
   66517             : 
   66518             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   66519             : 
   66520           0 :     ALLOC_MUTEX(SgBlockDataStatement, unlock);
   66521             : }
   66522             : 
   66523             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   66524             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   66525             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   66526             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   66527             : // Also, note comment below from Robb (copied from the Common.code file).
   66528             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   66529             : //
   66530             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   66531             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   66532             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   66533             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   66534             : #if 0
   66535             : void SgBlockDataStatement::operator delete(void* pointer) { SgBlockDataStatement::operator delete (pointer, sizeof(SgBlockDataStatement)); };
   66536             : #endif
   66537             : /* #line 66538 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   66538             : 
   66539             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   66540             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   66541             : // obviously imply C++.
   66542             : 
   66543             : // This implements the support within ROSE for memory pools.  Memory pools
   66544             : // support the most condensed usage of memory within the construction of
   66545             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   66546             : // by a new operator written for each class.
   66547             : 
   66548             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   66549             :     // User wants multi-thread support and POSIX threads are available.
   66550             : #   include <pthread.h>
   66551             :     static pthread_mutex_t SgAssociateStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   66552             : #else
   66553             :      // Cause synchronization to be skipped.
   66554             : #    ifndef ALLOC_MUTEX
   66555             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   66556             : #    endif
   66557             : #    ifdef _REENTRANT
   66558             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   66559             : #       ifdef _MSC_VER
   66560             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   66561             : #       else
   66562             : #           warning "POSIX threads are not available; synchronization being skipped"
   66563             : #       endif
   66564             : #    endif
   66565             : #endif
   66566             : 
   66567             : #ifndef ROSE_ALLOC_TRACE
   66568             : #  define ROSE_ALLOC_TRACE 0
   66569             : #endif
   66570             : 
   66571             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   66572             : #define ROSE_ALLOC_TRACE_CNT
   66573             : #include "memory-pool-snapshot.h"
   66574             : unsigned long alloc_trace_cnt = 0;
   66575             : #endif
   66576             : 
   66577             : #if ROSE_ALLOC_TRACE
   66578             : const unsigned SgAssociateStatement::pool_size = 5;
   66579             : #else
   66580             : const unsigned SgAssociateStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   66581             : #endif
   66582             : 
   66583             : #ifndef ROSE_ALLOC_MEMSET
   66584             : #  define ROSE_ALLOC_MEMSET 0
   66585             : #endif
   66586             : 
   66587             : #ifndef ROSE_PEDANTIC_ALLOC
   66588             : #  define ROSE_PEDANTIC_ALLOC 0
   66589             : #endif
   66590             : 
   66591             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   66592             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   66593             : #endif
   66594             : 
   66595             : #if !defined(SGNODE__ALL_POOLS)
   66596             : #define SGNODE__ALL_POOLS
   66597             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   66598             : #endif
   66599             : 
   66600             : SgAssociateStatement* SgAssociateStatement::next_node = nullptr;
   66601             : std::vector<unsigned char*> SgAssociateStatement::pools;
   66602             : 
   66603             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   66604             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   66605             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   66606             : // around this macro definition rather than each use).
   66607             : #ifndef ALLOC_MUTEX
   66608             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   66609             :         do {                                                                     \
   66610             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   66611             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   66612             :                 abort();                                                         \
   66613             :             }                                                                    \
   66614             :         } while (0);
   66615             : #endif
   66616             : 
   66617             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   66618             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   66619             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   66620             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   66621             : 
   66622             : /*! \brief New operator for SgAssociateStatement.
   66623             : 
   66624             :    This new operator implements memory pools to provide most efficent 
   66625             :    use of the heap within construction of large ASTs.
   66626             : 
   66627             : \internal The new and delete operators use the lower level C malloc/free
   66628             :    function calls for performance and to make sure that mixing of malloc/free
   66629             :    and new/delete by the used can be caught more readily.  This may change
   66630             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   66631             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   66632             :    deallocate memory allocated using ROSE_MALLOC.
   66633             : */
   66634           0 : void *SgAssociateStatement::operator new ( size_t Size )
   66635             : {
   66636             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   66637             :      * returning or throwing an exception. */
   66638           0 :     ALLOC_MUTEX(SgAssociateStatement, lock);
   66639             : 
   66640             : #if ROSE_ALLOC_TRACE == 2
   66641             : //    printf("SgAssociateStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgAssociateStatement::next_node);
   66642             : #endif
   66643             : 
   66644             : #if USE_CPP_NEW_DELETE_OPERATORS
   66645             :     void *mem = ROSE_MALLOC(Size);
   66646             :     ALLOC_MUTEX(SgAssociateStatement, unlock);
   66647             :     return mem;
   66648             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   66649             : #if ROSE_PEDANTIC_ALLOC
   66650             :     ROSE_ASSERT(Size == sizeof(SgAssociateStatement));
   66651             : #else
   66652           0 :     if (Size != sizeof(SgAssociateStatement)) {
   66653           0 :       void * object = ROSE_MALLOC(Size);
   66654           0 :       ALLOC_MUTEX(SgAssociateStatement, unlock);
   66655             :       return object;
   66656             :     }
   66657             : #endif
   66658             : 
   66659           0 :     if (SgAssociateStatement::next_node == nullptr) {
   66660           0 :         SgAssociateStatement * alloc = (SgAssociateStatement*) ROSE_MALLOC ( SgAssociateStatement::pool_size * sizeof(SgAssociateStatement) );
   66661           0 :         ROSE_ASSERT(alloc != nullptr);
   66662             : 
   66663             : #if ROSE_ALLOC_TRACE == 2
   66664             : //        printf("SgAssociateStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgAssociateStatement::pools.size(), alloc, alloc + SgAssociateStatement::pool_size);
   66665             : #endif
   66666             : 
   66667             : #if ROSE_ALLOC_MEMSET == 1
   66668             : #elif ROSE_ALLOC_MEMSET == 2
   66669             :         memset(alloc, 0x00, SgAssociateStatement::pool_size * sizeof(SgAssociateStatement));
   66670             : #elif ROSE_ALLOC_MEMSET == 3
   66671             :         memset(alloc, 0xAA, SgAssociateStatement::pool_size * sizeof(SgAssociateStatement));
   66672             : #endif
   66673           0 :         for (unsigned i=0; i < SgAssociateStatement::pool_size-1; i++) {
   66674           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
   66675             :         }
   66676           0 :         alloc[SgAssociateStatement::pool_size-1].p_freepointer = nullptr;
   66677             : 
   66678           0 :         SgAssociateStatement::pools.push_back ( (unsigned char *) alloc );
   66679           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgAssociateStatement::pool_size * sizeof(SgAssociateStatement), V_SgAssociateStatement ) );
   66680           0 :         SgAssociateStatement::next_node = alloc;
   66681             :     }
   66682           0 :     ROSE_ASSERT(SgAssociateStatement::next_node != nullptr);
   66683             : 
   66684           0 :     SgAssociateStatement * object = SgAssociateStatement::next_node;
   66685           0 :     SgAssociateStatement::next_node = (SgAssociateStatement*)(object->p_freepointer);
   66686             : 
   66687             : #if ROSE_ALLOC_TRACE == 2
   66688             :     printf("SgAssociateStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgAssociateStatement::next_node);
   66689             : #endif
   66690             : 
   66691           0 :     SgNode * fp = object->p_freepointer;
   66692             : #if ROSE_ALLOC_MEMSET == 1
   66693             : #elif ROSE_ALLOC_MEMSET == 2
   66694             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgAssociateStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   66695             : #elif ROSE_ALLOC_MEMSET == 3
   66696             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgAssociateStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   66697             : #endif
   66698           0 :     object->p_freepointer = fp;
   66699             : 
   66700             : #if ROSE_ALLOC_TRACE == 2
   66701             : //    printf("SgAssociateStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgAssociateStatement::next_node);
   66702             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   66703             :     Rose::MemPool::snapshot(oss.str());
   66704             :     alloc_trace_cnt++;
   66705             : #endif
   66706             : 
   66707           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   66708             : 
   66709           0 :     ALLOC_MUTEX(SgAssociateStatement, unlock);
   66710             : 
   66711             :     return object;
   66712             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   66713             : }
   66714             : 
   66715             : 
   66716             : 
   66717             : /*! \brief Delete operator for SgAssociateStatement.
   66718             : 
   66719             :    This delete operator implements deallocation using memory pools to 
   66720             :    provide most efficent use of the heap within construction of large ASTs.
   66721             : 
   66722             : \internal The new and delete operators use the lower level C malloc/free
   66723             :    function calls for performance and to make sure that mixing of malloc/free
   66724             :    and new/delete by the used can be caught more readily.  This may change
   66725             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   66726             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   66727             :    deallocate memory allocated using ROSE_MALLOC.
   66728             : */
   66729           0 : void SgAssociateStatement::operator delete(void *Pointer, size_t Size)
   66730             : {
   66731             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   66732             :      * or throwing an exception. */
   66733           0 :     ALLOC_MUTEX(SgAssociateStatement, lock);
   66734             : 
   66735             : #if USE_CPP_NEW_DELETE_OPERATORS
   66736             :     ROSE_FREE(Pointer);
   66737             : #else
   66738             : #if ROSE_PEDANTIC_ALLOC
   66739             :     ROSE_ASSERT(Size == sizeof(SgAssociateStatement));
   66740             : #else
   66741           0 :     if (Size != sizeof(SgAssociateStatement)) {
   66742           0 :       ROSE_FREE(Pointer);
   66743           0 :       ALLOC_MUTEX(SgAssociateStatement, unlock);
   66744             :       return;
   66745             :     }
   66746             : #endif
   66747             : 
   66748           0 :     SgAssociateStatement * object = (SgAssociateStatement*) Pointer;
   66749           0 :     ROSE_ASSERT(object != nullptr);
   66750             : 
   66751             : #if ROSE_ALLOC_TRACE == 2
   66752             : //  printf("SgAssociateStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgAssociateStatement::next_node);
   66753             :     printf("SgAssociateStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgAssociateStatement::next_node);
   66754             : #endif
   66755             : 
   66756             : #if ROSE_PEDANTIC_ALLOC
   66757             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   66758             : #endif
   66759             : 
   66760             : #if ROSE_ALLOC_MEMSET == 1
   66761             : #elif ROSE_ALLOC_MEMSET == 2
   66762             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgAssociateStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   66763             : #elif ROSE_ALLOC_MEMSET == 3
   66764             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgAssociateStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   66765             : #endif
   66766             : 
   66767             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   66768             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   66769             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   66770             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   66771             : #else
   66772           0 :     object->p_freepointer = SgAssociateStatement::next_node;
   66773           0 :     SgAssociateStatement::next_node = object;
   66774             : #endif
   66775             : 
   66776             : #if ROSE_ALLOC_TRACE == 2
   66777             : //  printf("SgAssociateStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgAssociateStatement::next_node);
   66778             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   66779             :     Rose::MemPool::snapshot(oss.str());
   66780             :     alloc_trace_cnt++;
   66781             : #endif
   66782             : 
   66783             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   66784             : 
   66785           0 :     ALLOC_MUTEX(SgAssociateStatement, unlock);
   66786             : }
   66787             : 
   66788             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   66789             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   66790             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   66791             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   66792             : // Also, note comment below from Robb (copied from the Common.code file).
   66793             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   66794             : //
   66795             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   66796             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   66797             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   66798             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   66799             : #if 0
   66800             : void SgAssociateStatement::operator delete(void* pointer) { SgAssociateStatement::operator delete (pointer, sizeof(SgAssociateStatement)); };
   66801             : #endif
   66802             : /* #line 66803 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   66803             : 
   66804             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   66805             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   66806             : // obviously imply C++.
   66807             : 
   66808             : // This implements the support within ROSE for memory pools.  Memory pools
   66809             : // support the most condensed usage of memory within the construction of
   66810             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   66811             : // by a new operator written for each class.
   66812             : 
   66813             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   66814             :     // User wants multi-thread support and POSIX threads are available.
   66815             : #   include <pthread.h>
   66816             :     static pthread_mutex_t SgFortranDo_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   66817             : #else
   66818             :      // Cause synchronization to be skipped.
   66819             : #    ifndef ALLOC_MUTEX
   66820             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   66821             : #    endif
   66822             : #    ifdef _REENTRANT
   66823             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   66824             : #       ifdef _MSC_VER
   66825             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   66826             : #       else
   66827             : #           warning "POSIX threads are not available; synchronization being skipped"
   66828             : #       endif
   66829             : #    endif
   66830             : #endif
   66831             : 
   66832             : #ifndef ROSE_ALLOC_TRACE
   66833             : #  define ROSE_ALLOC_TRACE 0
   66834             : #endif
   66835             : 
   66836             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   66837             : #define ROSE_ALLOC_TRACE_CNT
   66838             : #include "memory-pool-snapshot.h"
   66839             : unsigned long alloc_trace_cnt = 0;
   66840             : #endif
   66841             : 
   66842             : #if ROSE_ALLOC_TRACE
   66843             : const unsigned SgFortranDo::pool_size = 5;
   66844             : #else
   66845             : const unsigned SgFortranDo::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   66846             : #endif
   66847             : 
   66848             : #ifndef ROSE_ALLOC_MEMSET
   66849             : #  define ROSE_ALLOC_MEMSET 0
   66850             : #endif
   66851             : 
   66852             : #ifndef ROSE_PEDANTIC_ALLOC
   66853             : #  define ROSE_PEDANTIC_ALLOC 0
   66854             : #endif
   66855             : 
   66856             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   66857             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   66858             : #endif
   66859             : 
   66860             : #if !defined(SGNODE__ALL_POOLS)
   66861             : #define SGNODE__ALL_POOLS
   66862             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   66863             : #endif
   66864             : 
   66865             : SgFortranDo* SgFortranDo::next_node = nullptr;
   66866             : std::vector<unsigned char*> SgFortranDo::pools;
   66867             : 
   66868             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   66869             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   66870             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   66871             : // around this macro definition rather than each use).
   66872             : #ifndef ALLOC_MUTEX
   66873             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   66874             :         do {                                                                     \
   66875             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   66876             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   66877             :                 abort();                                                         \
   66878             :             }                                                                    \
   66879             :         } while (0);
   66880             : #endif
   66881             : 
   66882             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   66883             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   66884             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   66885             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   66886             : 
   66887             : /*! \brief New operator for SgFortranDo.
   66888             : 
   66889             :    This new operator implements memory pools to provide most efficent 
   66890             :    use of the heap within construction of large ASTs.
   66891             : 
   66892             : \internal The new and delete operators use the lower level C malloc/free
   66893             :    function calls for performance and to make sure that mixing of malloc/free
   66894             :    and new/delete by the used can be caught more readily.  This may change
   66895             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   66896             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   66897             :    deallocate memory allocated using ROSE_MALLOC.
   66898             : */
   66899          21 : void *SgFortranDo::operator new ( size_t Size )
   66900             : {
   66901             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   66902             :      * returning or throwing an exception. */
   66903          21 :     ALLOC_MUTEX(SgFortranDo, lock);
   66904             : 
   66905             : #if ROSE_ALLOC_TRACE == 2
   66906             : //    printf("SgFortranDo::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgFortranDo::next_node);
   66907             : #endif
   66908             : 
   66909             : #if USE_CPP_NEW_DELETE_OPERATORS
   66910             :     void *mem = ROSE_MALLOC(Size);
   66911             :     ALLOC_MUTEX(SgFortranDo, unlock);
   66912             :     return mem;
   66913             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   66914             : #if ROSE_PEDANTIC_ALLOC
   66915             :     ROSE_ASSERT(Size == sizeof(SgFortranDo));
   66916             : #else
   66917          21 :     if (Size != sizeof(SgFortranDo)) {
   66918           0 :       void * object = ROSE_MALLOC(Size);
   66919           0 :       ALLOC_MUTEX(SgFortranDo, unlock);
   66920             :       return object;
   66921             :     }
   66922             : #endif
   66923             : 
   66924          21 :     if (SgFortranDo::next_node == nullptr) {
   66925          14 :         SgFortranDo * alloc = (SgFortranDo*) ROSE_MALLOC ( SgFortranDo::pool_size * sizeof(SgFortranDo) );
   66926          14 :         ROSE_ASSERT(alloc != nullptr);
   66927             : 
   66928             : #if ROSE_ALLOC_TRACE == 2
   66929             : //        printf("SgFortranDo::alloc\n  block[%zi] = [ %p , %p [\n", SgFortranDo::pools.size(), alloc, alloc + SgFortranDo::pool_size);
   66930             : #endif
   66931             : 
   66932             : #if ROSE_ALLOC_MEMSET == 1
   66933             : #elif ROSE_ALLOC_MEMSET == 2
   66934             :         memset(alloc, 0x00, SgFortranDo::pool_size * sizeof(SgFortranDo));
   66935             : #elif ROSE_ALLOC_MEMSET == 3
   66936             :         memset(alloc, 0xAA, SgFortranDo::pool_size * sizeof(SgFortranDo));
   66937             : #endif
   66938       28000 :         for (unsigned i=0; i < SgFortranDo::pool_size-1; i++) {
   66939       27986 :           alloc[i].p_freepointer = &(alloc[i+1]);
   66940             :         }
   66941          14 :         alloc[SgFortranDo::pool_size-1].p_freepointer = nullptr;
   66942             : 
   66943          14 :         SgFortranDo::pools.push_back ( (unsigned char *) alloc );
   66944          14 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgFortranDo::pool_size * sizeof(SgFortranDo), V_SgFortranDo ) );
   66945          14 :         SgFortranDo::next_node = alloc;
   66946             :     }
   66947          21 :     ROSE_ASSERT(SgFortranDo::next_node != nullptr);
   66948             : 
   66949          21 :     SgFortranDo * object = SgFortranDo::next_node;
   66950          21 :     SgFortranDo::next_node = (SgFortranDo*)(object->p_freepointer);
   66951             : 
   66952             : #if ROSE_ALLOC_TRACE == 2
   66953             :     printf("SgFortranDo::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgFortranDo::next_node);
   66954             : #endif
   66955             : 
   66956          21 :     SgNode * fp = object->p_freepointer;
   66957             : #if ROSE_ALLOC_MEMSET == 1
   66958             : #elif ROSE_ALLOC_MEMSET == 2
   66959             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgFortranDo) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   66960             : #elif ROSE_ALLOC_MEMSET == 3
   66961             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgFortranDo) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   66962             : #endif
   66963          21 :     object->p_freepointer = fp;
   66964             : 
   66965             : #if ROSE_ALLOC_TRACE == 2
   66966             : //    printf("SgFortranDo::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgFortranDo::next_node);
   66967             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   66968             :     Rose::MemPool::snapshot(oss.str());
   66969             :     alloc_trace_cnt++;
   66970             : #endif
   66971             : 
   66972          21 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   66973             : 
   66974          21 :     ALLOC_MUTEX(SgFortranDo, unlock);
   66975             : 
   66976             :     return object;
   66977             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   66978             : }
   66979             : 
   66980             : 
   66981             : 
   66982             : /*! \brief Delete operator for SgFortranDo.
   66983             : 
   66984             :    This delete operator implements deallocation using memory pools to 
   66985             :    provide most efficent use of the heap within construction of large ASTs.
   66986             : 
   66987             : \internal The new and delete operators use the lower level C malloc/free
   66988             :    function calls for performance and to make sure that mixing of malloc/free
   66989             :    and new/delete by the used can be caught more readily.  This may change
   66990             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   66991             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   66992             :    deallocate memory allocated using ROSE_MALLOC.
   66993             : */
   66994           0 : void SgFortranDo::operator delete(void *Pointer, size_t Size)
   66995             : {
   66996             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   66997             :      * or throwing an exception. */
   66998           0 :     ALLOC_MUTEX(SgFortranDo, lock);
   66999             : 
   67000             : #if USE_CPP_NEW_DELETE_OPERATORS
   67001             :     ROSE_FREE(Pointer);
   67002             : #else
   67003             : #if ROSE_PEDANTIC_ALLOC
   67004             :     ROSE_ASSERT(Size == sizeof(SgFortranDo));
   67005             : #else
   67006           0 :     if (Size != sizeof(SgFortranDo)) {
   67007           0 :       ROSE_FREE(Pointer);
   67008           0 :       ALLOC_MUTEX(SgFortranDo, unlock);
   67009             :       return;
   67010             :     }
   67011             : #endif
   67012             : 
   67013           0 :     SgFortranDo * object = (SgFortranDo*) Pointer;
   67014           0 :     ROSE_ASSERT(object != nullptr);
   67015             : 
   67016             : #if ROSE_ALLOC_TRACE == 2
   67017             : //  printf("SgFortranDo::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgFortranDo::next_node);
   67018             :     printf("SgFortranDo::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgFortranDo::next_node);
   67019             : #endif
   67020             : 
   67021             : #if ROSE_PEDANTIC_ALLOC
   67022             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   67023             : #endif
   67024             : 
   67025             : #if ROSE_ALLOC_MEMSET == 1
   67026             : #elif ROSE_ALLOC_MEMSET == 2
   67027             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgFortranDo) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   67028             : #elif ROSE_ALLOC_MEMSET == 3
   67029             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgFortranDo) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   67030             : #endif
   67031             : 
   67032             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   67033             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   67034             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   67035             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   67036             : #else
   67037           0 :     object->p_freepointer = SgFortranDo::next_node;
   67038           0 :     SgFortranDo::next_node = object;
   67039             : #endif
   67040             : 
   67041             : #if ROSE_ALLOC_TRACE == 2
   67042             : //  printf("SgFortranDo::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgFortranDo::next_node);
   67043             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   67044             :     Rose::MemPool::snapshot(oss.str());
   67045             :     alloc_trace_cnt++;
   67046             : #endif
   67047             : 
   67048             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   67049             : 
   67050           0 :     ALLOC_MUTEX(SgFortranDo, unlock);
   67051             : }
   67052             : 
   67053             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   67054             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   67055             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   67056             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   67057             : // Also, note comment below from Robb (copied from the Common.code file).
   67058             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   67059             : //
   67060             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   67061             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   67062             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   67063             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   67064             : #if 0
   67065             : void SgFortranDo::operator delete(void* pointer) { SgFortranDo::operator delete (pointer, sizeof(SgFortranDo)); };
   67066             : #endif
   67067             : /* #line 67068 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   67068             : 
   67069             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   67070             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   67071             : // obviously imply C++.
   67072             : 
   67073             : // This implements the support within ROSE for memory pools.  Memory pools
   67074             : // support the most condensed usage of memory within the construction of
   67075             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   67076             : // by a new operator written for each class.
   67077             : 
   67078             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   67079             :     // User wants multi-thread support and POSIX threads are available.
   67080             : #   include <pthread.h>
   67081             :     static pthread_mutex_t SgFortranNonblockedDo_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   67082             : #else
   67083             :      // Cause synchronization to be skipped.
   67084             : #    ifndef ALLOC_MUTEX
   67085             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   67086             : #    endif
   67087             : #    ifdef _REENTRANT
   67088             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   67089             : #       ifdef _MSC_VER
   67090             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   67091             : #       else
   67092             : #           warning "POSIX threads are not available; synchronization being skipped"
   67093             : #       endif
   67094             : #    endif
   67095             : #endif
   67096             : 
   67097             : #ifndef ROSE_ALLOC_TRACE
   67098             : #  define ROSE_ALLOC_TRACE 0
   67099             : #endif
   67100             : 
   67101             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   67102             : #define ROSE_ALLOC_TRACE_CNT
   67103             : #include "memory-pool-snapshot.h"
   67104             : unsigned long alloc_trace_cnt = 0;
   67105             : #endif
   67106             : 
   67107             : #if ROSE_ALLOC_TRACE
   67108             : const unsigned SgFortranNonblockedDo::pool_size = 5;
   67109             : #else
   67110             : const unsigned SgFortranNonblockedDo::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   67111             : #endif
   67112             : 
   67113             : #ifndef ROSE_ALLOC_MEMSET
   67114             : #  define ROSE_ALLOC_MEMSET 0
   67115             : #endif
   67116             : 
   67117             : #ifndef ROSE_PEDANTIC_ALLOC
   67118             : #  define ROSE_PEDANTIC_ALLOC 0
   67119             : #endif
   67120             : 
   67121             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   67122             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   67123             : #endif
   67124             : 
   67125             : #if !defined(SGNODE__ALL_POOLS)
   67126             : #define SGNODE__ALL_POOLS
   67127             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   67128             : #endif
   67129             : 
   67130             : SgFortranNonblockedDo* SgFortranNonblockedDo::next_node = nullptr;
   67131             : std::vector<unsigned char*> SgFortranNonblockedDo::pools;
   67132             : 
   67133             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   67134             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   67135             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   67136             : // around this macro definition rather than each use).
   67137             : #ifndef ALLOC_MUTEX
   67138             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   67139             :         do {                                                                     \
   67140             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   67141             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   67142             :                 abort();                                                         \
   67143             :             }                                                                    \
   67144             :         } while (0);
   67145             : #endif
   67146             : 
   67147             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   67148             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   67149             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   67150             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   67151             : 
   67152             : /*! \brief New operator for SgFortranNonblockedDo.
   67153             : 
   67154             :    This new operator implements memory pools to provide most efficent 
   67155             :    use of the heap within construction of large ASTs.
   67156             : 
   67157             : \internal The new and delete operators use the lower level C malloc/free
   67158             :    function calls for performance and to make sure that mixing of malloc/free
   67159             :    and new/delete by the used can be caught more readily.  This may change
   67160             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   67161             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   67162             :    deallocate memory allocated using ROSE_MALLOC.
   67163             : */
   67164           0 : void *SgFortranNonblockedDo::operator new ( size_t Size )
   67165             : {
   67166             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   67167             :      * returning or throwing an exception. */
   67168           0 :     ALLOC_MUTEX(SgFortranNonblockedDo, lock);
   67169             : 
   67170             : #if ROSE_ALLOC_TRACE == 2
   67171             : //    printf("SgFortranNonblockedDo::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgFortranNonblockedDo::next_node);
   67172             : #endif
   67173             : 
   67174             : #if USE_CPP_NEW_DELETE_OPERATORS
   67175             :     void *mem = ROSE_MALLOC(Size);
   67176             :     ALLOC_MUTEX(SgFortranNonblockedDo, unlock);
   67177             :     return mem;
   67178             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   67179             : #if ROSE_PEDANTIC_ALLOC
   67180             :     ROSE_ASSERT(Size == sizeof(SgFortranNonblockedDo));
   67181             : #else
   67182           0 :     if (Size != sizeof(SgFortranNonblockedDo)) {
   67183           0 :       void * object = ROSE_MALLOC(Size);
   67184           0 :       ALLOC_MUTEX(SgFortranNonblockedDo, unlock);
   67185             :       return object;
   67186             :     }
   67187             : #endif
   67188             : 
   67189           0 :     if (SgFortranNonblockedDo::next_node == nullptr) {
   67190           0 :         SgFortranNonblockedDo * alloc = (SgFortranNonblockedDo*) ROSE_MALLOC ( SgFortranNonblockedDo::pool_size * sizeof(SgFortranNonblockedDo) );
   67191           0 :         ROSE_ASSERT(alloc != nullptr);
   67192             : 
   67193             : #if ROSE_ALLOC_TRACE == 2
   67194             : //        printf("SgFortranNonblockedDo::alloc\n  block[%zi] = [ %p , %p [\n", SgFortranNonblockedDo::pools.size(), alloc, alloc + SgFortranNonblockedDo::pool_size);
   67195             : #endif
   67196             : 
   67197             : #if ROSE_ALLOC_MEMSET == 1
   67198             : #elif ROSE_ALLOC_MEMSET == 2
   67199             :         memset(alloc, 0x00, SgFortranNonblockedDo::pool_size * sizeof(SgFortranNonblockedDo));
   67200             : #elif ROSE_ALLOC_MEMSET == 3
   67201             :         memset(alloc, 0xAA, SgFortranNonblockedDo::pool_size * sizeof(SgFortranNonblockedDo));
   67202             : #endif
   67203           0 :         for (unsigned i=0; i < SgFortranNonblockedDo::pool_size-1; i++) {
   67204           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
   67205             :         }
   67206           0 :         alloc[SgFortranNonblockedDo::pool_size-1].p_freepointer = nullptr;
   67207             : 
   67208           0 :         SgFortranNonblockedDo::pools.push_back ( (unsigned char *) alloc );
   67209           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgFortranNonblockedDo::pool_size * sizeof(SgFortranNonblockedDo), V_SgFortranNonblockedDo ) );
   67210           0 :         SgFortranNonblockedDo::next_node = alloc;
   67211             :     }
   67212           0 :     ROSE_ASSERT(SgFortranNonblockedDo::next_node != nullptr);
   67213             : 
   67214           0 :     SgFortranNonblockedDo * object = SgFortranNonblockedDo::next_node;
   67215           0 :     SgFortranNonblockedDo::next_node = (SgFortranNonblockedDo*)(object->p_freepointer);
   67216             : 
   67217             : #if ROSE_ALLOC_TRACE == 2
   67218             :     printf("SgFortranNonblockedDo::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgFortranNonblockedDo::next_node);
   67219             : #endif
   67220             : 
   67221           0 :     SgNode * fp = object->p_freepointer;
   67222             : #if ROSE_ALLOC_MEMSET == 1
   67223             : #elif ROSE_ALLOC_MEMSET == 2
   67224             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgFortranNonblockedDo) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   67225             : #elif ROSE_ALLOC_MEMSET == 3
   67226             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgFortranNonblockedDo) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   67227             : #endif
   67228           0 :     object->p_freepointer = fp;
   67229             : 
   67230             : #if ROSE_ALLOC_TRACE == 2
   67231             : //    printf("SgFortranNonblockedDo::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgFortranNonblockedDo::next_node);
   67232             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   67233             :     Rose::MemPool::snapshot(oss.str());
   67234             :     alloc_trace_cnt++;
   67235             : #endif
   67236             : 
   67237           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   67238             : 
   67239           0 :     ALLOC_MUTEX(SgFortranNonblockedDo, unlock);
   67240             : 
   67241             :     return object;
   67242             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   67243             : }
   67244             : 
   67245             : 
   67246             : 
   67247             : /*! \brief Delete operator for SgFortranNonblockedDo.
   67248             : 
   67249             :    This delete operator implements deallocation using memory pools to 
   67250             :    provide most efficent use of the heap within construction of large ASTs.
   67251             : 
   67252             : \internal The new and delete operators use the lower level C malloc/free
   67253             :    function calls for performance and to make sure that mixing of malloc/free
   67254             :    and new/delete by the used can be caught more readily.  This may change
   67255             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   67256             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   67257             :    deallocate memory allocated using ROSE_MALLOC.
   67258             : */
   67259           0 : void SgFortranNonblockedDo::operator delete(void *Pointer, size_t Size)
   67260             : {
   67261             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   67262             :      * or throwing an exception. */
   67263           0 :     ALLOC_MUTEX(SgFortranNonblockedDo, lock);
   67264             : 
   67265             : #if USE_CPP_NEW_DELETE_OPERATORS
   67266             :     ROSE_FREE(Pointer);
   67267             : #else
   67268             : #if ROSE_PEDANTIC_ALLOC
   67269             :     ROSE_ASSERT(Size == sizeof(SgFortranNonblockedDo));
   67270             : #else
   67271           0 :     if (Size != sizeof(SgFortranNonblockedDo)) {
   67272           0 :       ROSE_FREE(Pointer);
   67273           0 :       ALLOC_MUTEX(SgFortranNonblockedDo, unlock);
   67274             :       return;
   67275             :     }
   67276             : #endif
   67277             : 
   67278           0 :     SgFortranNonblockedDo * object = (SgFortranNonblockedDo*) Pointer;
   67279           0 :     ROSE_ASSERT(object != nullptr);
   67280             : 
   67281             : #if ROSE_ALLOC_TRACE == 2
   67282             : //  printf("SgFortranNonblockedDo::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgFortranNonblockedDo::next_node);
   67283             :     printf("SgFortranNonblockedDo::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgFortranNonblockedDo::next_node);
   67284             : #endif
   67285             : 
   67286             : #if ROSE_PEDANTIC_ALLOC
   67287             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   67288             : #endif
   67289             : 
   67290             : #if ROSE_ALLOC_MEMSET == 1
   67291             : #elif ROSE_ALLOC_MEMSET == 2
   67292             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgFortranNonblockedDo) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   67293             : #elif ROSE_ALLOC_MEMSET == 3
   67294             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgFortranNonblockedDo) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   67295             : #endif
   67296             : 
   67297             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   67298             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   67299             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   67300             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   67301             : #else
   67302           0 :     object->p_freepointer = SgFortranNonblockedDo::next_node;
   67303           0 :     SgFortranNonblockedDo::next_node = object;
   67304             : #endif
   67305             : 
   67306             : #if ROSE_ALLOC_TRACE == 2
   67307             : //  printf("SgFortranNonblockedDo::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgFortranNonblockedDo::next_node);
   67308             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   67309             :     Rose::MemPool::snapshot(oss.str());
   67310             :     alloc_trace_cnt++;
   67311             : #endif
   67312             : 
   67313             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   67314             : 
   67315           0 :     ALLOC_MUTEX(SgFortranNonblockedDo, unlock);
   67316             : }
   67317             : 
   67318             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   67319             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   67320             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   67321             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   67322             : // Also, note comment below from Robb (copied from the Common.code file).
   67323             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   67324             : //
   67325             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   67326             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   67327             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   67328             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   67329             : #if 0
   67330             : void SgFortranNonblockedDo::operator delete(void* pointer) { SgFortranNonblockedDo::operator delete (pointer, sizeof(SgFortranNonblockedDo)); };
   67331             : #endif
   67332             : /* #line 67333 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   67333             : 
   67334             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   67335             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   67336             : // obviously imply C++.
   67337             : 
   67338             : // This implements the support within ROSE for memory pools.  Memory pools
   67339             : // support the most condensed usage of memory within the construction of
   67340             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   67341             : // by a new operator written for each class.
   67342             : 
   67343             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   67344             :     // User wants multi-thread support and POSIX threads are available.
   67345             : #   include <pthread.h>
   67346             :     static pthread_mutex_t SgForAllStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   67347             : #else
   67348             :      // Cause synchronization to be skipped.
   67349             : #    ifndef ALLOC_MUTEX
   67350             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   67351             : #    endif
   67352             : #    ifdef _REENTRANT
   67353             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   67354             : #       ifdef _MSC_VER
   67355             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   67356             : #       else
   67357             : #           warning "POSIX threads are not available; synchronization being skipped"
   67358             : #       endif
   67359             : #    endif
   67360             : #endif
   67361             : 
   67362             : #ifndef ROSE_ALLOC_TRACE
   67363             : #  define ROSE_ALLOC_TRACE 0
   67364             : #endif
   67365             : 
   67366             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   67367             : #define ROSE_ALLOC_TRACE_CNT
   67368             : #include "memory-pool-snapshot.h"
   67369             : unsigned long alloc_trace_cnt = 0;
   67370             : #endif
   67371             : 
   67372             : #if ROSE_ALLOC_TRACE
   67373             : const unsigned SgForAllStatement::pool_size = 5;
   67374             : #else
   67375             : const unsigned SgForAllStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   67376             : #endif
   67377             : 
   67378             : #ifndef ROSE_ALLOC_MEMSET
   67379             : #  define ROSE_ALLOC_MEMSET 0
   67380             : #endif
   67381             : 
   67382             : #ifndef ROSE_PEDANTIC_ALLOC
   67383             : #  define ROSE_PEDANTIC_ALLOC 0
   67384             : #endif
   67385             : 
   67386             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   67387             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   67388             : #endif
   67389             : 
   67390             : #if !defined(SGNODE__ALL_POOLS)
   67391             : #define SGNODE__ALL_POOLS
   67392             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   67393             : #endif
   67394             : 
   67395             : SgForAllStatement* SgForAllStatement::next_node = nullptr;
   67396             : std::vector<unsigned char*> SgForAllStatement::pools;
   67397             : 
   67398             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   67399             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   67400             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   67401             : // around this macro definition rather than each use).
   67402             : #ifndef ALLOC_MUTEX
   67403             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   67404             :         do {                                                                     \
   67405             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   67406             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   67407             :                 abort();                                                         \
   67408             :             }                                                                    \
   67409             :         } while (0);
   67410             : #endif
   67411             : 
   67412             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   67413             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   67414             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   67415             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   67416             : 
   67417             : /*! \brief New operator for SgForAllStatement.
   67418             : 
   67419             :    This new operator implements memory pools to provide most efficent 
   67420             :    use of the heap within construction of large ASTs.
   67421             : 
   67422             : \internal The new and delete operators use the lower level C malloc/free
   67423             :    function calls for performance and to make sure that mixing of malloc/free
   67424             :    and new/delete by the used can be caught more readily.  This may change
   67425             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   67426             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   67427             :    deallocate memory allocated using ROSE_MALLOC.
   67428             : */
   67429           0 : void *SgForAllStatement::operator new ( size_t Size )
   67430             : {
   67431             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   67432             :      * returning or throwing an exception. */
   67433           0 :     ALLOC_MUTEX(SgForAllStatement, lock);
   67434             : 
   67435             : #if ROSE_ALLOC_TRACE == 2
   67436             : //    printf("SgForAllStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgForAllStatement::next_node);
   67437             : #endif
   67438             : 
   67439             : #if USE_CPP_NEW_DELETE_OPERATORS
   67440             :     void *mem = ROSE_MALLOC(Size);
   67441             :     ALLOC_MUTEX(SgForAllStatement, unlock);
   67442             :     return mem;
   67443             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   67444             : #if ROSE_PEDANTIC_ALLOC
   67445             :     ROSE_ASSERT(Size == sizeof(SgForAllStatement));
   67446             : #else
   67447           0 :     if (Size != sizeof(SgForAllStatement)) {
   67448           0 :       void * object = ROSE_MALLOC(Size);
   67449           0 :       ALLOC_MUTEX(SgForAllStatement, unlock);
   67450             :       return object;
   67451             :     }
   67452             : #endif
   67453             : 
   67454           0 :     if (SgForAllStatement::next_node == nullptr) {
   67455           0 :         SgForAllStatement * alloc = (SgForAllStatement*) ROSE_MALLOC ( SgForAllStatement::pool_size * sizeof(SgForAllStatement) );
   67456           0 :         ROSE_ASSERT(alloc != nullptr);
   67457             : 
   67458             : #if ROSE_ALLOC_TRACE == 2
   67459             : //        printf("SgForAllStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgForAllStatement::pools.size(), alloc, alloc + SgForAllStatement::pool_size);
   67460             : #endif
   67461             : 
   67462             : #if ROSE_ALLOC_MEMSET == 1
   67463             : #elif ROSE_ALLOC_MEMSET == 2
   67464             :         memset(alloc, 0x00, SgForAllStatement::pool_size * sizeof(SgForAllStatement));
   67465             : #elif ROSE_ALLOC_MEMSET == 3
   67466             :         memset(alloc, 0xAA, SgForAllStatement::pool_size * sizeof(SgForAllStatement));
   67467             : #endif
   67468           0 :         for (unsigned i=0; i < SgForAllStatement::pool_size-1; i++) {
   67469           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
   67470             :         }
   67471           0 :         alloc[SgForAllStatement::pool_size-1].p_freepointer = nullptr;
   67472             : 
   67473           0 :         SgForAllStatement::pools.push_back ( (unsigned char *) alloc );
   67474           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgForAllStatement::pool_size * sizeof(SgForAllStatement), V_SgForAllStatement ) );
   67475           0 :         SgForAllStatement::next_node = alloc;
   67476             :     }
   67477           0 :     ROSE_ASSERT(SgForAllStatement::next_node != nullptr);
   67478             : 
   67479           0 :     SgForAllStatement * object = SgForAllStatement::next_node;
   67480           0 :     SgForAllStatement::next_node = (SgForAllStatement*)(object->p_freepointer);
   67481             : 
   67482             : #if ROSE_ALLOC_TRACE == 2
   67483             :     printf("SgForAllStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgForAllStatement::next_node);
   67484             : #endif
   67485             : 
   67486           0 :     SgNode * fp = object->p_freepointer;
   67487             : #if ROSE_ALLOC_MEMSET == 1
   67488             : #elif ROSE_ALLOC_MEMSET == 2
   67489             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgForAllStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   67490             : #elif ROSE_ALLOC_MEMSET == 3
   67491             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgForAllStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   67492             : #endif
   67493           0 :     object->p_freepointer = fp;
   67494             : 
   67495             : #if ROSE_ALLOC_TRACE == 2
   67496             : //    printf("SgForAllStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgForAllStatement::next_node);
   67497             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   67498             :     Rose::MemPool::snapshot(oss.str());
   67499             :     alloc_trace_cnt++;
   67500             : #endif
   67501             : 
   67502           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   67503             : 
   67504           0 :     ALLOC_MUTEX(SgForAllStatement, unlock);
   67505             : 
   67506             :     return object;
   67507             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   67508             : }
   67509             : 
   67510             : 
   67511             : 
   67512             : /*! \brief Delete operator for SgForAllStatement.
   67513             : 
   67514             :    This delete operator implements deallocation using memory pools to 
   67515             :    provide most efficent use of the heap within construction of large ASTs.
   67516             : 
   67517             : \internal The new and delete operators use the lower level C malloc/free
   67518             :    function calls for performance and to make sure that mixing of malloc/free
   67519             :    and new/delete by the used can be caught more readily.  This may change
   67520             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   67521             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   67522             :    deallocate memory allocated using ROSE_MALLOC.
   67523             : */
   67524           0 : void SgForAllStatement::operator delete(void *Pointer, size_t Size)
   67525             : {
   67526             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   67527             :      * or throwing an exception. */
   67528           0 :     ALLOC_MUTEX(SgForAllStatement, lock);
   67529             : 
   67530             : #if USE_CPP_NEW_DELETE_OPERATORS
   67531             :     ROSE_FREE(Pointer);
   67532             : #else
   67533             : #if ROSE_PEDANTIC_ALLOC
   67534             :     ROSE_ASSERT(Size == sizeof(SgForAllStatement));
   67535             : #else
   67536           0 :     if (Size != sizeof(SgForAllStatement)) {
   67537           0 :       ROSE_FREE(Pointer);
   67538           0 :       ALLOC_MUTEX(SgForAllStatement, unlock);
   67539             :       return;
   67540             :     }
   67541             : #endif
   67542             : 
   67543           0 :     SgForAllStatement * object = (SgForAllStatement*) Pointer;
   67544           0 :     ROSE_ASSERT(object != nullptr);
   67545             : 
   67546             : #if ROSE_ALLOC_TRACE == 2
   67547             : //  printf("SgForAllStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgForAllStatement::next_node);
   67548             :     printf("SgForAllStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgForAllStatement::next_node);
   67549             : #endif
   67550             : 
   67551             : #if ROSE_PEDANTIC_ALLOC
   67552             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   67553             : #endif
   67554             : 
   67555             : #if ROSE_ALLOC_MEMSET == 1
   67556             : #elif ROSE_ALLOC_MEMSET == 2
   67557             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgForAllStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   67558             : #elif ROSE_ALLOC_MEMSET == 3
   67559             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgForAllStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   67560             : #endif
   67561             : 
   67562             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   67563             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   67564             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   67565             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   67566             : #else
   67567           0 :     object->p_freepointer = SgForAllStatement::next_node;
   67568           0 :     SgForAllStatement::next_node = object;
   67569             : #endif
   67570             : 
   67571             : #if ROSE_ALLOC_TRACE == 2
   67572             : //  printf("SgForAllStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgForAllStatement::next_node);
   67573             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   67574             :     Rose::MemPool::snapshot(oss.str());
   67575             :     alloc_trace_cnt++;
   67576             : #endif
   67577             : 
   67578             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   67579             : 
   67580           0 :     ALLOC_MUTEX(SgForAllStatement, unlock);
   67581             : }
   67582             : 
   67583             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   67584             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   67585             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   67586             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   67587             : // Also, note comment below from Robb (copied from the Common.code file).
   67588             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   67589             : //
   67590             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   67591             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   67592             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   67593             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   67594             : #if 0
   67595             : void SgForAllStatement::operator delete(void* pointer) { SgForAllStatement::operator delete (pointer, sizeof(SgForAllStatement)); };
   67596             : #endif
   67597             : /* #line 67598 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   67598             : 
   67599             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   67600             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   67601             : // obviously imply C++.
   67602             : 
   67603             : // This implements the support within ROSE for memory pools.  Memory pools
   67604             : // support the most condensed usage of memory within the construction of
   67605             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   67606             : // by a new operator written for each class.
   67607             : 
   67608             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   67609             :     // User wants multi-thread support and POSIX threads are available.
   67610             : #   include <pthread.h>
   67611             :     static pthread_mutex_t SgUpcForAllStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   67612             : #else
   67613             :      // Cause synchronization to be skipped.
   67614             : #    ifndef ALLOC_MUTEX
   67615             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   67616             : #    endif
   67617             : #    ifdef _REENTRANT
   67618             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   67619             : #       ifdef _MSC_VER
   67620             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   67621             : #       else
   67622             : #           warning "POSIX threads are not available; synchronization being skipped"
   67623             : #       endif
   67624             : #    endif
   67625             : #endif
   67626             : 
   67627             : #ifndef ROSE_ALLOC_TRACE
   67628             : #  define ROSE_ALLOC_TRACE 0
   67629             : #endif
   67630             : 
   67631             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   67632             : #define ROSE_ALLOC_TRACE_CNT
   67633             : #include "memory-pool-snapshot.h"
   67634             : unsigned long alloc_trace_cnt = 0;
   67635             : #endif
   67636             : 
   67637             : #if ROSE_ALLOC_TRACE
   67638             : const unsigned SgUpcForAllStatement::pool_size = 5;
   67639             : #else
   67640             : const unsigned SgUpcForAllStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   67641             : #endif
   67642             : 
   67643             : #ifndef ROSE_ALLOC_MEMSET
   67644             : #  define ROSE_ALLOC_MEMSET 0
   67645             : #endif
   67646             : 
   67647             : #ifndef ROSE_PEDANTIC_ALLOC
   67648             : #  define ROSE_PEDANTIC_ALLOC 0
   67649             : #endif
   67650             : 
   67651             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   67652             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   67653             : #endif
   67654             : 
   67655             : #if !defined(SGNODE__ALL_POOLS)
   67656             : #define SGNODE__ALL_POOLS
   67657             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   67658             : #endif
   67659             : 
   67660             : SgUpcForAllStatement* SgUpcForAllStatement::next_node = nullptr;
   67661             : std::vector<unsigned char*> SgUpcForAllStatement::pools;
   67662             : 
   67663             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   67664             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   67665             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   67666             : // around this macro definition rather than each use).
   67667             : #ifndef ALLOC_MUTEX
   67668             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   67669             :         do {                                                                     \
   67670             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   67671             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   67672             :                 abort();                                                         \
   67673             :             }                                                                    \
   67674             :         } while (0);
   67675             : #endif
   67676             : 
   67677             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   67678             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   67679             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   67680             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   67681             : 
   67682             : /*! \brief New operator for SgUpcForAllStatement.
   67683             : 
   67684             :    This new operator implements memory pools to provide most efficent 
   67685             :    use of the heap within construction of large ASTs.
   67686             : 
   67687             : \internal The new and delete operators use the lower level C malloc/free
   67688             :    function calls for performance and to make sure that mixing of malloc/free
   67689             :    and new/delete by the used can be caught more readily.  This may change
   67690             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   67691             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   67692             :    deallocate memory allocated using ROSE_MALLOC.
   67693             : */
   67694           0 : void *SgUpcForAllStatement::operator new ( size_t Size )
   67695             : {
   67696             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   67697             :      * returning or throwing an exception. */
   67698           0 :     ALLOC_MUTEX(SgUpcForAllStatement, lock);
   67699             : 
   67700             : #if ROSE_ALLOC_TRACE == 2
   67701             : //    printf("SgUpcForAllStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgUpcForAllStatement::next_node);
   67702             : #endif
   67703             : 
   67704             : #if USE_CPP_NEW_DELETE_OPERATORS
   67705             :     void *mem = ROSE_MALLOC(Size);
   67706             :     ALLOC_MUTEX(SgUpcForAllStatement, unlock);
   67707             :     return mem;
   67708             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   67709             : #if ROSE_PEDANTIC_ALLOC
   67710             :     ROSE_ASSERT(Size == sizeof(SgUpcForAllStatement));
   67711             : #else
   67712           0 :     if (Size != sizeof(SgUpcForAllStatement)) {
   67713           0 :       void * object = ROSE_MALLOC(Size);
   67714           0 :       ALLOC_MUTEX(SgUpcForAllStatement, unlock);
   67715             :       return object;
   67716             :     }
   67717             : #endif
   67718             : 
   67719           0 :     if (SgUpcForAllStatement::next_node == nullptr) {
   67720           0 :         SgUpcForAllStatement * alloc = (SgUpcForAllStatement*) ROSE_MALLOC ( SgUpcForAllStatement::pool_size * sizeof(SgUpcForAllStatement) );
   67721           0 :         ROSE_ASSERT(alloc != nullptr);
   67722             : 
   67723             : #if ROSE_ALLOC_TRACE == 2
   67724             : //        printf("SgUpcForAllStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgUpcForAllStatement::pools.size(), alloc, alloc + SgUpcForAllStatement::pool_size);
   67725             : #endif
   67726             : 
   67727             : #if ROSE_ALLOC_MEMSET == 1
   67728             : #elif ROSE_ALLOC_MEMSET == 2
   67729             :         memset(alloc, 0x00, SgUpcForAllStatement::pool_size * sizeof(SgUpcForAllStatement));
   67730             : #elif ROSE_ALLOC_MEMSET == 3
   67731             :         memset(alloc, 0xAA, SgUpcForAllStatement::pool_size * sizeof(SgUpcForAllStatement));
   67732             : #endif
   67733           0 :         for (unsigned i=0; i < SgUpcForAllStatement::pool_size-1; i++) {
   67734           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
   67735             :         }
   67736           0 :         alloc[SgUpcForAllStatement::pool_size-1].p_freepointer = nullptr;
   67737             : 
   67738           0 :         SgUpcForAllStatement::pools.push_back ( (unsigned char *) alloc );
   67739           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgUpcForAllStatement::pool_size * sizeof(SgUpcForAllStatement), V_SgUpcForAllStatement ) );
   67740           0 :         SgUpcForAllStatement::next_node = alloc;
   67741             :     }
   67742           0 :     ROSE_ASSERT(SgUpcForAllStatement::next_node != nullptr);
   67743             : 
   67744           0 :     SgUpcForAllStatement * object = SgUpcForAllStatement::next_node;
   67745           0 :     SgUpcForAllStatement::next_node = (SgUpcForAllStatement*)(object->p_freepointer);
   67746             : 
   67747             : #if ROSE_ALLOC_TRACE == 2
   67748             :     printf("SgUpcForAllStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUpcForAllStatement::next_node);
   67749             : #endif
   67750             : 
   67751           0 :     SgNode * fp = object->p_freepointer;
   67752             : #if ROSE_ALLOC_MEMSET == 1
   67753             : #elif ROSE_ALLOC_MEMSET == 2
   67754             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgUpcForAllStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   67755             : #elif ROSE_ALLOC_MEMSET == 3
   67756             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgUpcForAllStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   67757             : #endif
   67758           0 :     object->p_freepointer = fp;
   67759             : 
   67760             : #if ROSE_ALLOC_TRACE == 2
   67761             : //    printf("SgUpcForAllStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUpcForAllStatement::next_node);
   67762             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   67763             :     Rose::MemPool::snapshot(oss.str());
   67764             :     alloc_trace_cnt++;
   67765             : #endif
   67766             : 
   67767           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   67768             : 
   67769           0 :     ALLOC_MUTEX(SgUpcForAllStatement, unlock);
   67770             : 
   67771             :     return object;
   67772             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   67773             : }
   67774             : 
   67775             : 
   67776             : 
   67777             : /*! \brief Delete operator for SgUpcForAllStatement.
   67778             : 
   67779             :    This delete operator implements deallocation using memory pools to 
   67780             :    provide most efficent use of the heap within construction of large ASTs.
   67781             : 
   67782             : \internal The new and delete operators use the lower level C malloc/free
   67783             :    function calls for performance and to make sure that mixing of malloc/free
   67784             :    and new/delete by the used can be caught more readily.  This may change
   67785             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   67786             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   67787             :    deallocate memory allocated using ROSE_MALLOC.
   67788             : */
   67789           0 : void SgUpcForAllStatement::operator delete(void *Pointer, size_t Size)
   67790             : {
   67791             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   67792             :      * or throwing an exception. */
   67793           0 :     ALLOC_MUTEX(SgUpcForAllStatement, lock);
   67794             : 
   67795             : #if USE_CPP_NEW_DELETE_OPERATORS
   67796             :     ROSE_FREE(Pointer);
   67797             : #else
   67798             : #if ROSE_PEDANTIC_ALLOC
   67799             :     ROSE_ASSERT(Size == sizeof(SgUpcForAllStatement));
   67800             : #else
   67801           0 :     if (Size != sizeof(SgUpcForAllStatement)) {
   67802           0 :       ROSE_FREE(Pointer);
   67803           0 :       ALLOC_MUTEX(SgUpcForAllStatement, unlock);
   67804             :       return;
   67805             :     }
   67806             : #endif
   67807             : 
   67808           0 :     SgUpcForAllStatement * object = (SgUpcForAllStatement*) Pointer;
   67809           0 :     ROSE_ASSERT(object != nullptr);
   67810             : 
   67811             : #if ROSE_ALLOC_TRACE == 2
   67812             : //  printf("SgUpcForAllStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUpcForAllStatement::next_node);
   67813             :     printf("SgUpcForAllStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUpcForAllStatement::next_node);
   67814             : #endif
   67815             : 
   67816             : #if ROSE_PEDANTIC_ALLOC
   67817             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   67818             : #endif
   67819             : 
   67820             : #if ROSE_ALLOC_MEMSET == 1
   67821             : #elif ROSE_ALLOC_MEMSET == 2
   67822             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgUpcForAllStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   67823             : #elif ROSE_ALLOC_MEMSET == 3
   67824             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgUpcForAllStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   67825             : #endif
   67826             : 
   67827             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   67828             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   67829             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   67830             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   67831             : #else
   67832           0 :     object->p_freepointer = SgUpcForAllStatement::next_node;
   67833           0 :     SgUpcForAllStatement::next_node = object;
   67834             : #endif
   67835             : 
   67836             : #if ROSE_ALLOC_TRACE == 2
   67837             : //  printf("SgUpcForAllStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUpcForAllStatement::next_node);
   67838             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   67839             :     Rose::MemPool::snapshot(oss.str());
   67840             :     alloc_trace_cnt++;
   67841             : #endif
   67842             : 
   67843             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   67844             : 
   67845           0 :     ALLOC_MUTEX(SgUpcForAllStatement, unlock);
   67846             : }
   67847             : 
   67848             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   67849             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   67850             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   67851             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   67852             : // Also, note comment below from Robb (copied from the Common.code file).
   67853             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   67854             : //
   67855             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   67856             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   67857             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   67858             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   67859             : #if 0
   67860             : void SgUpcForAllStatement::operator delete(void* pointer) { SgUpcForAllStatement::operator delete (pointer, sizeof(SgUpcForAllStatement)); };
   67861             : #endif
   67862             : /* #line 67863 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   67863             : 
   67864             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   67865             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   67866             : // obviously imply C++.
   67867             : 
   67868             : // This implements the support within ROSE for memory pools.  Memory pools
   67869             : // support the most condensed usage of memory within the construction of
   67870             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   67871             : // by a new operator written for each class.
   67872             : 
   67873             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   67874             :     // User wants multi-thread support and POSIX threads are available.
   67875             : #   include <pthread.h>
   67876             :     static pthread_mutex_t SgCAFWithTeamStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   67877             : #else
   67878             :      // Cause synchronization to be skipped.
   67879             : #    ifndef ALLOC_MUTEX
   67880             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   67881             : #    endif
   67882             : #    ifdef _REENTRANT
   67883             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   67884             : #       ifdef _MSC_VER
   67885             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   67886             : #       else
   67887             : #           warning "POSIX threads are not available; synchronization being skipped"
   67888             : #       endif
   67889             : #    endif
   67890             : #endif
   67891             : 
   67892             : #ifndef ROSE_ALLOC_TRACE
   67893             : #  define ROSE_ALLOC_TRACE 0
   67894             : #endif
   67895             : 
   67896             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   67897             : #define ROSE_ALLOC_TRACE_CNT
   67898             : #include "memory-pool-snapshot.h"
   67899             : unsigned long alloc_trace_cnt = 0;
   67900             : #endif
   67901             : 
   67902             : #if ROSE_ALLOC_TRACE
   67903             : const unsigned SgCAFWithTeamStatement::pool_size = 5;
   67904             : #else
   67905             : const unsigned SgCAFWithTeamStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   67906             : #endif
   67907             : 
   67908             : #ifndef ROSE_ALLOC_MEMSET
   67909             : #  define ROSE_ALLOC_MEMSET 0
   67910             : #endif
   67911             : 
   67912             : #ifndef ROSE_PEDANTIC_ALLOC
   67913             : #  define ROSE_PEDANTIC_ALLOC 0
   67914             : #endif
   67915             : 
   67916             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   67917             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   67918             : #endif
   67919             : 
   67920             : #if !defined(SGNODE__ALL_POOLS)
   67921             : #define SGNODE__ALL_POOLS
   67922             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   67923             : #endif
   67924             : 
   67925             : SgCAFWithTeamStatement* SgCAFWithTeamStatement::next_node = nullptr;
   67926             : std::vector<unsigned char*> SgCAFWithTeamStatement::pools;
   67927             : 
   67928             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   67929             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   67930             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   67931             : // around this macro definition rather than each use).
   67932             : #ifndef ALLOC_MUTEX
   67933             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   67934             :         do {                                                                     \
   67935             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   67936             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   67937             :                 abort();                                                         \
   67938             :             }                                                                    \
   67939             :         } while (0);
   67940             : #endif
   67941             : 
   67942             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   67943             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   67944             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   67945             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   67946             : 
   67947             : /*! \brief New operator for SgCAFWithTeamStatement.
   67948             : 
   67949             :    This new operator implements memory pools to provide most efficent 
   67950             :    use of the heap within construction of large ASTs.
   67951             : 
   67952             : \internal The new and delete operators use the lower level C malloc/free
   67953             :    function calls for performance and to make sure that mixing of malloc/free
   67954             :    and new/delete by the used can be caught more readily.  This may change
   67955             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   67956             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   67957             :    deallocate memory allocated using ROSE_MALLOC.
   67958             : */
   67959           0 : void *SgCAFWithTeamStatement::operator new ( size_t Size )
   67960             : {
   67961             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   67962             :      * returning or throwing an exception. */
   67963           0 :     ALLOC_MUTEX(SgCAFWithTeamStatement, lock);
   67964             : 
   67965             : #if ROSE_ALLOC_TRACE == 2
   67966             : //    printf("SgCAFWithTeamStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgCAFWithTeamStatement::next_node);
   67967             : #endif
   67968             : 
   67969             : #if USE_CPP_NEW_DELETE_OPERATORS
   67970             :     void *mem = ROSE_MALLOC(Size);
   67971             :     ALLOC_MUTEX(SgCAFWithTeamStatement, unlock);
   67972             :     return mem;
   67973             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   67974             : #if ROSE_PEDANTIC_ALLOC
   67975             :     ROSE_ASSERT(Size == sizeof(SgCAFWithTeamStatement));
   67976             : #else
   67977           0 :     if (Size != sizeof(SgCAFWithTeamStatement)) {
   67978           0 :       void * object = ROSE_MALLOC(Size);
   67979           0 :       ALLOC_MUTEX(SgCAFWithTeamStatement, unlock);
   67980             :       return object;
   67981             :     }
   67982             : #endif
   67983             : 
   67984           0 :     if (SgCAFWithTeamStatement::next_node == nullptr) {
   67985           0 :         SgCAFWithTeamStatement * alloc = (SgCAFWithTeamStatement*) ROSE_MALLOC ( SgCAFWithTeamStatement::pool_size * sizeof(SgCAFWithTeamStatement) );
   67986           0 :         ROSE_ASSERT(alloc != nullptr);
   67987             : 
   67988             : #if ROSE_ALLOC_TRACE == 2
   67989             : //        printf("SgCAFWithTeamStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgCAFWithTeamStatement::pools.size(), alloc, alloc + SgCAFWithTeamStatement::pool_size);
   67990             : #endif
   67991             : 
   67992             : #if ROSE_ALLOC_MEMSET == 1
   67993             : #elif ROSE_ALLOC_MEMSET == 2
   67994             :         memset(alloc, 0x00, SgCAFWithTeamStatement::pool_size * sizeof(SgCAFWithTeamStatement));
   67995             : #elif ROSE_ALLOC_MEMSET == 3
   67996             :         memset(alloc, 0xAA, SgCAFWithTeamStatement::pool_size * sizeof(SgCAFWithTeamStatement));
   67997             : #endif
   67998           0 :         for (unsigned i=0; i < SgCAFWithTeamStatement::pool_size-1; i++) {
   67999           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
   68000             :         }
   68001           0 :         alloc[SgCAFWithTeamStatement::pool_size-1].p_freepointer = nullptr;
   68002             : 
   68003           0 :         SgCAFWithTeamStatement::pools.push_back ( (unsigned char *) alloc );
   68004           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgCAFWithTeamStatement::pool_size * sizeof(SgCAFWithTeamStatement), V_SgCAFWithTeamStatement ) );
   68005           0 :         SgCAFWithTeamStatement::next_node = alloc;
   68006             :     }
   68007           0 :     ROSE_ASSERT(SgCAFWithTeamStatement::next_node != nullptr);
   68008             : 
   68009           0 :     SgCAFWithTeamStatement * object = SgCAFWithTeamStatement::next_node;
   68010           0 :     SgCAFWithTeamStatement::next_node = (SgCAFWithTeamStatement*)(object->p_freepointer);
   68011             : 
   68012             : #if ROSE_ALLOC_TRACE == 2
   68013             :     printf("SgCAFWithTeamStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgCAFWithTeamStatement::next_node);
   68014             : #endif
   68015             : 
   68016           0 :     SgNode * fp = object->p_freepointer;
   68017             : #if ROSE_ALLOC_MEMSET == 1
   68018             : #elif ROSE_ALLOC_MEMSET == 2
   68019             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgCAFWithTeamStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   68020             : #elif ROSE_ALLOC_MEMSET == 3
   68021             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgCAFWithTeamStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   68022             : #endif
   68023           0 :     object->p_freepointer = fp;
   68024             : 
   68025             : #if ROSE_ALLOC_TRACE == 2
   68026             : //    printf("SgCAFWithTeamStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgCAFWithTeamStatement::next_node);
   68027             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   68028             :     Rose::MemPool::snapshot(oss.str());
   68029             :     alloc_trace_cnt++;
   68030             : #endif
   68031             : 
   68032           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   68033             : 
   68034           0 :     ALLOC_MUTEX(SgCAFWithTeamStatement, unlock);
   68035             : 
   68036             :     return object;
   68037             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   68038             : }
   68039             : 
   68040             : 
   68041             : 
   68042             : /*! \brief Delete operator for SgCAFWithTeamStatement.
   68043             : 
   68044             :    This delete operator implements deallocation using memory pools to 
   68045             :    provide most efficent use of the heap within construction of large ASTs.
   68046             : 
   68047             : \internal The new and delete operators use the lower level C malloc/free
   68048             :    function calls for performance and to make sure that mixing of malloc/free
   68049             :    and new/delete by the used can be caught more readily.  This may change
   68050             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   68051             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   68052             :    deallocate memory allocated using ROSE_MALLOC.
   68053             : */
   68054           0 : void SgCAFWithTeamStatement::operator delete(void *Pointer, size_t Size)
   68055             : {
   68056             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   68057             :      * or throwing an exception. */
   68058           0 :     ALLOC_MUTEX(SgCAFWithTeamStatement, lock);
   68059             : 
   68060             : #if USE_CPP_NEW_DELETE_OPERATORS
   68061             :     ROSE_FREE(Pointer);
   68062             : #else
   68063             : #if ROSE_PEDANTIC_ALLOC
   68064             :     ROSE_ASSERT(Size == sizeof(SgCAFWithTeamStatement));
   68065             : #else
   68066           0 :     if (Size != sizeof(SgCAFWithTeamStatement)) {
   68067           0 :       ROSE_FREE(Pointer);
   68068           0 :       ALLOC_MUTEX(SgCAFWithTeamStatement, unlock);
   68069             :       return;
   68070             :     }
   68071             : #endif
   68072             : 
   68073           0 :     SgCAFWithTeamStatement * object = (SgCAFWithTeamStatement*) Pointer;
   68074           0 :     ROSE_ASSERT(object != nullptr);
   68075             : 
   68076             : #if ROSE_ALLOC_TRACE == 2
   68077             : //  printf("SgCAFWithTeamStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgCAFWithTeamStatement::next_node);
   68078             :     printf("SgCAFWithTeamStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgCAFWithTeamStatement::next_node);
   68079             : #endif
   68080             : 
   68081             : #if ROSE_PEDANTIC_ALLOC
   68082             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   68083             : #endif
   68084             : 
   68085             : #if ROSE_ALLOC_MEMSET == 1
   68086             : #elif ROSE_ALLOC_MEMSET == 2
   68087             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgCAFWithTeamStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   68088             : #elif ROSE_ALLOC_MEMSET == 3
   68089             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgCAFWithTeamStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   68090             : #endif
   68091             : 
   68092             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   68093             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   68094             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   68095             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   68096             : #else
   68097           0 :     object->p_freepointer = SgCAFWithTeamStatement::next_node;
   68098           0 :     SgCAFWithTeamStatement::next_node = object;
   68099             : #endif
   68100             : 
   68101             : #if ROSE_ALLOC_TRACE == 2
   68102             : //  printf("SgCAFWithTeamStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgCAFWithTeamStatement::next_node);
   68103             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   68104             :     Rose::MemPool::snapshot(oss.str());
   68105             :     alloc_trace_cnt++;
   68106             : #endif
   68107             : 
   68108             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   68109             : 
   68110           0 :     ALLOC_MUTEX(SgCAFWithTeamStatement, unlock);
   68111             : }
   68112             : 
   68113             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   68114             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   68115             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   68116             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   68117             : // Also, note comment below from Robb (copied from the Common.code file).
   68118             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   68119             : //
   68120             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   68121             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   68122             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   68123             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   68124             : #if 0
   68125             : void SgCAFWithTeamStatement::operator delete(void* pointer) { SgCAFWithTeamStatement::operator delete (pointer, sizeof(SgCAFWithTeamStatement)); };
   68126             : #endif
   68127             : /* #line 68128 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   68128             : 
   68129             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   68130             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   68131             : // obviously imply C++.
   68132             : 
   68133             : // This implements the support within ROSE for memory pools.  Memory pools
   68134             : // support the most condensed usage of memory within the construction of
   68135             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   68136             : // by a new operator written for each class.
   68137             : 
   68138             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   68139             :     // User wants multi-thread support and POSIX threads are available.
   68140             : #   include <pthread.h>
   68141             :     static pthread_mutex_t SgFunctionParameterScope_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   68142             : #else
   68143             :      // Cause synchronization to be skipped.
   68144             : #    ifndef ALLOC_MUTEX
   68145             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   68146             : #    endif
   68147             : #    ifdef _REENTRANT
   68148             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   68149             : #       ifdef _MSC_VER
   68150             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   68151             : #       else
   68152             : #           warning "POSIX threads are not available; synchronization being skipped"
   68153             : #       endif
   68154             : #    endif
   68155             : #endif
   68156             : 
   68157             : #ifndef ROSE_ALLOC_TRACE
   68158             : #  define ROSE_ALLOC_TRACE 0
   68159             : #endif
   68160             : 
   68161             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   68162             : #define ROSE_ALLOC_TRACE_CNT
   68163             : #include "memory-pool-snapshot.h"
   68164             : unsigned long alloc_trace_cnt = 0;
   68165             : #endif
   68166             : 
   68167             : #if ROSE_ALLOC_TRACE
   68168             : const unsigned SgFunctionParameterScope::pool_size = 5;
   68169             : #else
   68170             : const unsigned SgFunctionParameterScope::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   68171             : #endif
   68172             : 
   68173             : #ifndef ROSE_ALLOC_MEMSET
   68174             : #  define ROSE_ALLOC_MEMSET 0
   68175             : #endif
   68176             : 
   68177             : #ifndef ROSE_PEDANTIC_ALLOC
   68178             : #  define ROSE_PEDANTIC_ALLOC 0
   68179             : #endif
   68180             : 
   68181             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   68182             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   68183             : #endif
   68184             : 
   68185             : #if !defined(SGNODE__ALL_POOLS)
   68186             : #define SGNODE__ALL_POOLS
   68187             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   68188             : #endif
   68189             : 
   68190             : SgFunctionParameterScope* SgFunctionParameterScope::next_node = nullptr;
   68191             : std::vector<unsigned char*> SgFunctionParameterScope::pools;
   68192             : 
   68193             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   68194             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   68195             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   68196             : // around this macro definition rather than each use).
   68197             : #ifndef ALLOC_MUTEX
   68198             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   68199             :         do {                                                                     \
   68200             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   68201             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   68202             :                 abort();                                                         \
   68203             :             }                                                                    \
   68204             :         } while (0);
   68205             : #endif
   68206             : 
   68207             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   68208             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   68209             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   68210             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   68211             : 
   68212             : /*! \brief New operator for SgFunctionParameterScope.
   68213             : 
   68214             :    This new operator implements memory pools to provide most efficent 
   68215             :    use of the heap within construction of large ASTs.
   68216             : 
   68217             : \internal The new and delete operators use the lower level C malloc/free
   68218             :    function calls for performance and to make sure that mixing of malloc/free
   68219             :    and new/delete by the used can be caught more readily.  This may change
   68220             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   68221             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   68222             :    deallocate memory allocated using ROSE_MALLOC.
   68223             : */
   68224           0 : void *SgFunctionParameterScope::operator new ( size_t Size )
   68225             : {
   68226             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   68227             :      * returning or throwing an exception. */
   68228           0 :     ALLOC_MUTEX(SgFunctionParameterScope, lock);
   68229             : 
   68230             : #if ROSE_ALLOC_TRACE == 2
   68231             : //    printf("SgFunctionParameterScope::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgFunctionParameterScope::next_node);
   68232             : #endif
   68233             : 
   68234             : #if USE_CPP_NEW_DELETE_OPERATORS
   68235             :     void *mem = ROSE_MALLOC(Size);
   68236             :     ALLOC_MUTEX(SgFunctionParameterScope, unlock);
   68237             :     return mem;
   68238             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   68239             : #if ROSE_PEDANTIC_ALLOC
   68240             :     ROSE_ASSERT(Size == sizeof(SgFunctionParameterScope));
   68241             : #else
   68242           0 :     if (Size != sizeof(SgFunctionParameterScope)) {
   68243           0 :       void * object = ROSE_MALLOC(Size);
   68244           0 :       ALLOC_MUTEX(SgFunctionParameterScope, unlock);
   68245             :       return object;
   68246             :     }
   68247             : #endif
   68248             : 
   68249           0 :     if (SgFunctionParameterScope::next_node == nullptr) {
   68250           0 :         SgFunctionParameterScope * alloc = (SgFunctionParameterScope*) ROSE_MALLOC ( SgFunctionParameterScope::pool_size * sizeof(SgFunctionParameterScope) );
   68251           0 :         ROSE_ASSERT(alloc != nullptr);
   68252             : 
   68253             : #if ROSE_ALLOC_TRACE == 2
   68254             : //        printf("SgFunctionParameterScope::alloc\n  block[%zi] = [ %p , %p [\n", SgFunctionParameterScope::pools.size(), alloc, alloc + SgFunctionParameterScope::pool_size);
   68255             : #endif
   68256             : 
   68257             : #if ROSE_ALLOC_MEMSET == 1
   68258             : #elif ROSE_ALLOC_MEMSET == 2
   68259             :         memset(alloc, 0x00, SgFunctionParameterScope::pool_size * sizeof(SgFunctionParameterScope));
   68260             : #elif ROSE_ALLOC_MEMSET == 3
   68261             :         memset(alloc, 0xAA, SgFunctionParameterScope::pool_size * sizeof(SgFunctionParameterScope));
   68262             : #endif
   68263           0 :         for (unsigned i=0; i < SgFunctionParameterScope::pool_size-1; i++) {
   68264           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
   68265             :         }
   68266           0 :         alloc[SgFunctionParameterScope::pool_size-1].p_freepointer = nullptr;
   68267             : 
   68268           0 :         SgFunctionParameterScope::pools.push_back ( (unsigned char *) alloc );
   68269           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgFunctionParameterScope::pool_size * sizeof(SgFunctionParameterScope), V_SgFunctionParameterScope ) );
   68270           0 :         SgFunctionParameterScope::next_node = alloc;
   68271             :     }
   68272           0 :     ROSE_ASSERT(SgFunctionParameterScope::next_node != nullptr);
   68273             : 
   68274           0 :     SgFunctionParameterScope * object = SgFunctionParameterScope::next_node;
   68275           0 :     SgFunctionParameterScope::next_node = (SgFunctionParameterScope*)(object->p_freepointer);
   68276             : 
   68277             : #if ROSE_ALLOC_TRACE == 2
   68278             :     printf("SgFunctionParameterScope::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgFunctionParameterScope::next_node);
   68279             : #endif
   68280             : 
   68281           0 :     SgNode * fp = object->p_freepointer;
   68282             : #if ROSE_ALLOC_MEMSET == 1
   68283             : #elif ROSE_ALLOC_MEMSET == 2
   68284             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgFunctionParameterScope) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   68285             : #elif ROSE_ALLOC_MEMSET == 3
   68286             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgFunctionParameterScope) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   68287             : #endif
   68288           0 :     object->p_freepointer = fp;
   68289             : 
   68290             : #if ROSE_ALLOC_TRACE == 2
   68291             : //    printf("SgFunctionParameterScope::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgFunctionParameterScope::next_node);
   68292             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   68293             :     Rose::MemPool::snapshot(oss.str());
   68294             :     alloc_trace_cnt++;
   68295             : #endif
   68296             : 
   68297           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   68298             : 
   68299           0 :     ALLOC_MUTEX(SgFunctionParameterScope, unlock);
   68300             : 
   68301             :     return object;
   68302             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   68303             : }
   68304             : 
   68305             : 
   68306             : 
   68307             : /*! \brief Delete operator for SgFunctionParameterScope.
   68308             : 
   68309             :    This delete operator implements deallocation using memory pools to 
   68310             :    provide most efficent use of the heap within construction of large ASTs.
   68311             : 
   68312             : \internal The new and delete operators use the lower level C malloc/free
   68313             :    function calls for performance and to make sure that mixing of malloc/free
   68314             :    and new/delete by the used can be caught more readily.  This may change
   68315             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   68316             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   68317             :    deallocate memory allocated using ROSE_MALLOC.
   68318             : */
   68319           0 : void SgFunctionParameterScope::operator delete(void *Pointer, size_t Size)
   68320             : {
   68321             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   68322             :      * or throwing an exception. */
   68323           0 :     ALLOC_MUTEX(SgFunctionParameterScope, lock);
   68324             : 
   68325             : #if USE_CPP_NEW_DELETE_OPERATORS
   68326             :     ROSE_FREE(Pointer);
   68327             : #else
   68328             : #if ROSE_PEDANTIC_ALLOC
   68329             :     ROSE_ASSERT(Size == sizeof(SgFunctionParameterScope));
   68330             : #else
   68331           0 :     if (Size != sizeof(SgFunctionParameterScope)) {
   68332           0 :       ROSE_FREE(Pointer);
   68333           0 :       ALLOC_MUTEX(SgFunctionParameterScope, unlock);
   68334             :       return;
   68335             :     }
   68336             : #endif
   68337             : 
   68338           0 :     SgFunctionParameterScope * object = (SgFunctionParameterScope*) Pointer;
   68339           0 :     ROSE_ASSERT(object != nullptr);
   68340             : 
   68341             : #if ROSE_ALLOC_TRACE == 2
   68342             : //  printf("SgFunctionParameterScope::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgFunctionParameterScope::next_node);
   68343             :     printf("SgFunctionParameterScope::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgFunctionParameterScope::next_node);
   68344             : #endif
   68345             : 
   68346             : #if ROSE_PEDANTIC_ALLOC
   68347             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   68348             : #endif
   68349             : 
   68350             : #if ROSE_ALLOC_MEMSET == 1
   68351             : #elif ROSE_ALLOC_MEMSET == 2
   68352             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgFunctionParameterScope) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   68353             : #elif ROSE_ALLOC_MEMSET == 3
   68354             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgFunctionParameterScope) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   68355             : #endif
   68356             : 
   68357             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   68358             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   68359             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   68360             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   68361             : #else
   68362           0 :     object->p_freepointer = SgFunctionParameterScope::next_node;
   68363           0 :     SgFunctionParameterScope::next_node = object;
   68364             : #endif
   68365             : 
   68366             : #if ROSE_ALLOC_TRACE == 2
   68367             : //  printf("SgFunctionParameterScope::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgFunctionParameterScope::next_node);
   68368             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   68369             :     Rose::MemPool::snapshot(oss.str());
   68370             :     alloc_trace_cnt++;
   68371             : #endif
   68372             : 
   68373             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   68374             : 
   68375           0 :     ALLOC_MUTEX(SgFunctionParameterScope, unlock);
   68376             : }
   68377             : 
   68378             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   68379             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   68380             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   68381             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   68382             : // Also, note comment below from Robb (copied from the Common.code file).
   68383             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   68384             : //
   68385             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   68386             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   68387             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   68388             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   68389             : #if 0
   68390             : void SgFunctionParameterScope::operator delete(void* pointer) { SgFunctionParameterScope::operator delete (pointer, sizeof(SgFunctionParameterScope)); };
   68391             : #endif
   68392             : /* #line 68393 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   68393             : 
   68394             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   68395             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   68396             : // obviously imply C++.
   68397             : 
   68398             : // This implements the support within ROSE for memory pools.  Memory pools
   68399             : // support the most condensed usage of memory within the construction of
   68400             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   68401             : // by a new operator written for each class.
   68402             : 
   68403             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   68404             :     // User wants multi-thread support and POSIX threads are available.
   68405             : #   include <pthread.h>
   68406             :     static pthread_mutex_t SgDeclarationScope_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   68407             : #else
   68408             :      // Cause synchronization to be skipped.
   68409             : #    ifndef ALLOC_MUTEX
   68410             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   68411             : #    endif
   68412             : #    ifdef _REENTRANT
   68413             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   68414             : #       ifdef _MSC_VER
   68415             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   68416             : #       else
   68417             : #           warning "POSIX threads are not available; synchronization being skipped"
   68418             : #       endif
   68419             : #    endif
   68420             : #endif
   68421             : 
   68422             : #ifndef ROSE_ALLOC_TRACE
   68423             : #  define ROSE_ALLOC_TRACE 0
   68424             : #endif
   68425             : 
   68426             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   68427             : #define ROSE_ALLOC_TRACE_CNT
   68428             : #include "memory-pool-snapshot.h"
   68429             : unsigned long alloc_trace_cnt = 0;
   68430             : #endif
   68431             : 
   68432             : #if ROSE_ALLOC_TRACE
   68433             : const unsigned SgDeclarationScope::pool_size = 5;
   68434             : #else
   68435             : const unsigned SgDeclarationScope::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   68436             : #endif
   68437             : 
   68438             : #ifndef ROSE_ALLOC_MEMSET
   68439             : #  define ROSE_ALLOC_MEMSET 0
   68440             : #endif
   68441             : 
   68442             : #ifndef ROSE_PEDANTIC_ALLOC
   68443             : #  define ROSE_PEDANTIC_ALLOC 0
   68444             : #endif
   68445             : 
   68446             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   68447             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   68448             : #endif
   68449             : 
   68450             : #if !defined(SGNODE__ALL_POOLS)
   68451             : #define SGNODE__ALL_POOLS
   68452             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   68453             : #endif
   68454             : 
   68455             : SgDeclarationScope* SgDeclarationScope::next_node = nullptr;
   68456             : std::vector<unsigned char*> SgDeclarationScope::pools;
   68457             : 
   68458             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   68459             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   68460             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   68461             : // around this macro definition rather than each use).
   68462             : #ifndef ALLOC_MUTEX
   68463             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   68464             :         do {                                                                     \
   68465             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   68466             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   68467             :                 abort();                                                         \
   68468             :             }                                                                    \
   68469             :         } while (0);
   68470             : #endif
   68471             : 
   68472             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   68473             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   68474             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   68475             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   68476             : 
   68477             : /*! \brief New operator for SgDeclarationScope.
   68478             : 
   68479             :    This new operator implements memory pools to provide most efficent 
   68480             :    use of the heap within construction of large ASTs.
   68481             : 
   68482             : \internal The new and delete operators use the lower level C malloc/free
   68483             :    function calls for performance and to make sure that mixing of malloc/free
   68484             :    and new/delete by the used can be caught more readily.  This may change
   68485             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   68486             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   68487             :    deallocate memory allocated using ROSE_MALLOC.
   68488             : */
   68489       69851 : void *SgDeclarationScope::operator new ( size_t Size )
   68490             : {
   68491             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   68492             :      * returning or throwing an exception. */
   68493       69851 :     ALLOC_MUTEX(SgDeclarationScope, lock);
   68494             : 
   68495             : #if ROSE_ALLOC_TRACE == 2
   68496             : //    printf("SgDeclarationScope::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgDeclarationScope::next_node);
   68497             : #endif
   68498             : 
   68499             : #if USE_CPP_NEW_DELETE_OPERATORS
   68500             :     void *mem = ROSE_MALLOC(Size);
   68501             :     ALLOC_MUTEX(SgDeclarationScope, unlock);
   68502             :     return mem;
   68503             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   68504             : #if ROSE_PEDANTIC_ALLOC
   68505             :     ROSE_ASSERT(Size == sizeof(SgDeclarationScope));
   68506             : #else
   68507       69851 :     if (Size != sizeof(SgDeclarationScope)) {
   68508           0 :       void * object = ROSE_MALLOC(Size);
   68509           0 :       ALLOC_MUTEX(SgDeclarationScope, unlock);
   68510             :       return object;
   68511             :     }
   68512             : #endif
   68513             : 
   68514       69851 :     if (SgDeclarationScope::next_node == nullptr) {
   68515         343 :         SgDeclarationScope * alloc = (SgDeclarationScope*) ROSE_MALLOC ( SgDeclarationScope::pool_size * sizeof(SgDeclarationScope) );
   68516         343 :         ROSE_ASSERT(alloc != nullptr);
   68517             : 
   68518             : #if ROSE_ALLOC_TRACE == 2
   68519             : //        printf("SgDeclarationScope::alloc\n  block[%zi] = [ %p , %p [\n", SgDeclarationScope::pools.size(), alloc, alloc + SgDeclarationScope::pool_size);
   68520             : #endif
   68521             : 
   68522             : #if ROSE_ALLOC_MEMSET == 1
   68523             : #elif ROSE_ALLOC_MEMSET == 2
   68524             :         memset(alloc, 0x00, SgDeclarationScope::pool_size * sizeof(SgDeclarationScope));
   68525             : #elif ROSE_ALLOC_MEMSET == 3
   68526             :         memset(alloc, 0xAA, SgDeclarationScope::pool_size * sizeof(SgDeclarationScope));
   68527             : #endif
   68528      686000 :         for (unsigned i=0; i < SgDeclarationScope::pool_size-1; i++) {
   68529      685657 :           alloc[i].p_freepointer = &(alloc[i+1]);
   68530             :         }
   68531         343 :         alloc[SgDeclarationScope::pool_size-1].p_freepointer = nullptr;
   68532             : 
   68533         343 :         SgDeclarationScope::pools.push_back ( (unsigned char *) alloc );
   68534         343 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgDeclarationScope::pool_size * sizeof(SgDeclarationScope), V_SgDeclarationScope ) );
   68535         343 :         SgDeclarationScope::next_node = alloc;
   68536             :     }
   68537       69851 :     ROSE_ASSERT(SgDeclarationScope::next_node != nullptr);
   68538             : 
   68539       69851 :     SgDeclarationScope * object = SgDeclarationScope::next_node;
   68540       69851 :     SgDeclarationScope::next_node = (SgDeclarationScope*)(object->p_freepointer);
   68541             : 
   68542             : #if ROSE_ALLOC_TRACE == 2
   68543             :     printf("SgDeclarationScope::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgDeclarationScope::next_node);
   68544             : #endif
   68545             : 
   68546       69851 :     SgNode * fp = object->p_freepointer;
   68547             : #if ROSE_ALLOC_MEMSET == 1
   68548             : #elif ROSE_ALLOC_MEMSET == 2
   68549             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgDeclarationScope) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   68550             : #elif ROSE_ALLOC_MEMSET == 3
   68551             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgDeclarationScope) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   68552             : #endif
   68553       69851 :     object->p_freepointer = fp;
   68554             : 
   68555             : #if ROSE_ALLOC_TRACE == 2
   68556             : //    printf("SgDeclarationScope::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgDeclarationScope::next_node);
   68557             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   68558             :     Rose::MemPool::snapshot(oss.str());
   68559             :     alloc_trace_cnt++;
   68560             : #endif
   68561             : 
   68562       69851 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   68563             : 
   68564       69851 :     ALLOC_MUTEX(SgDeclarationScope, unlock);
   68565             : 
   68566             :     return object;
   68567             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   68568             : }
   68569             : 
   68570             : 
   68571             : 
   68572             : /*! \brief Delete operator for SgDeclarationScope.
   68573             : 
   68574             :    This delete operator implements deallocation using memory pools to 
   68575             :    provide most efficent use of the heap within construction of large ASTs.
   68576             : 
   68577             : \internal The new and delete operators use the lower level C malloc/free
   68578             :    function calls for performance and to make sure that mixing of malloc/free
   68579             :    and new/delete by the used can be caught more readily.  This may change
   68580             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   68581             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   68582             :    deallocate memory allocated using ROSE_MALLOC.
   68583             : */
   68584       13312 : void SgDeclarationScope::operator delete(void *Pointer, size_t Size)
   68585             : {
   68586             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   68587             :      * or throwing an exception. */
   68588       13312 :     ALLOC_MUTEX(SgDeclarationScope, lock);
   68589             : 
   68590             : #if USE_CPP_NEW_DELETE_OPERATORS
   68591             :     ROSE_FREE(Pointer);
   68592             : #else
   68593             : #if ROSE_PEDANTIC_ALLOC
   68594             :     ROSE_ASSERT(Size == sizeof(SgDeclarationScope));
   68595             : #else
   68596       13312 :     if (Size != sizeof(SgDeclarationScope)) {
   68597           0 :       ROSE_FREE(Pointer);
   68598           0 :       ALLOC_MUTEX(SgDeclarationScope, unlock);
   68599             :       return;
   68600             :     }
   68601             : #endif
   68602             : 
   68603       13312 :     SgDeclarationScope * object = (SgDeclarationScope*) Pointer;
   68604       13312 :     ROSE_ASSERT(object != nullptr);
   68605             : 
   68606             : #if ROSE_ALLOC_TRACE == 2
   68607             : //  printf("SgDeclarationScope::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgDeclarationScope::next_node);
   68608             :     printf("SgDeclarationScope::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgDeclarationScope::next_node);
   68609             : #endif
   68610             : 
   68611             : #if ROSE_PEDANTIC_ALLOC
   68612             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   68613             : #endif
   68614             : 
   68615             : #if ROSE_ALLOC_MEMSET == 1
   68616             : #elif ROSE_ALLOC_MEMSET == 2
   68617             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgDeclarationScope) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   68618             : #elif ROSE_ALLOC_MEMSET == 3
   68619             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgDeclarationScope) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   68620             : #endif
   68621             : 
   68622             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   68623             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   68624             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   68625             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   68626             : #else
   68627       13312 :     object->p_freepointer = SgDeclarationScope::next_node;
   68628       13312 :     SgDeclarationScope::next_node = object;
   68629             : #endif
   68630             : 
   68631             : #if ROSE_ALLOC_TRACE == 2
   68632             : //  printf("SgDeclarationScope::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgDeclarationScope::next_node);
   68633             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   68634             :     Rose::MemPool::snapshot(oss.str());
   68635             :     alloc_trace_cnt++;
   68636             : #endif
   68637             : 
   68638             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   68639             : 
   68640       13312 :     ALLOC_MUTEX(SgDeclarationScope, unlock);
   68641             : }
   68642             : 
   68643             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   68644             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   68645             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   68646             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   68647             : // Also, note comment below from Robb (copied from the Common.code file).
   68648             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   68649             : //
   68650             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   68651             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   68652             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   68653             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   68654             : #if 0
   68655             : void SgDeclarationScope::operator delete(void* pointer) { SgDeclarationScope::operator delete (pointer, sizeof(SgDeclarationScope)); };
   68656             : #endif
   68657             : /* #line 68658 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   68658             : 
   68659             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   68660             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   68661             : // obviously imply C++.
   68662             : 
   68663             : // This implements the support within ROSE for memory pools.  Memory pools
   68664             : // support the most condensed usage of memory within the construction of
   68665             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   68666             : // by a new operator written for each class.
   68667             : 
   68668             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   68669             :     // User wants multi-thread support and POSIX threads are available.
   68670             : #   include <pthread.h>
   68671             :     static pthread_mutex_t SgRangeBasedForStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   68672             : #else
   68673             :      // Cause synchronization to be skipped.
   68674             : #    ifndef ALLOC_MUTEX
   68675             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   68676             : #    endif
   68677             : #    ifdef _REENTRANT
   68678             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   68679             : #       ifdef _MSC_VER
   68680             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   68681             : #       else
   68682             : #           warning "POSIX threads are not available; synchronization being skipped"
   68683             : #       endif
   68684             : #    endif
   68685             : #endif
   68686             : 
   68687             : #ifndef ROSE_ALLOC_TRACE
   68688             : #  define ROSE_ALLOC_TRACE 0
   68689             : #endif
   68690             : 
   68691             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   68692             : #define ROSE_ALLOC_TRACE_CNT
   68693             : #include "memory-pool-snapshot.h"
   68694             : unsigned long alloc_trace_cnt = 0;
   68695             : #endif
   68696             : 
   68697             : #if ROSE_ALLOC_TRACE
   68698             : const unsigned SgRangeBasedForStatement::pool_size = 5;
   68699             : #else
   68700             : const unsigned SgRangeBasedForStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   68701             : #endif
   68702             : 
   68703             : #ifndef ROSE_ALLOC_MEMSET
   68704             : #  define ROSE_ALLOC_MEMSET 0
   68705             : #endif
   68706             : 
   68707             : #ifndef ROSE_PEDANTIC_ALLOC
   68708             : #  define ROSE_PEDANTIC_ALLOC 0
   68709             : #endif
   68710             : 
   68711             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   68712             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   68713             : #endif
   68714             : 
   68715             : #if !defined(SGNODE__ALL_POOLS)
   68716             : #define SGNODE__ALL_POOLS
   68717             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   68718             : #endif
   68719             : 
   68720             : SgRangeBasedForStatement* SgRangeBasedForStatement::next_node = nullptr;
   68721             : std::vector<unsigned char*> SgRangeBasedForStatement::pools;
   68722             : 
   68723             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   68724             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   68725             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   68726             : // around this macro definition rather than each use).
   68727             : #ifndef ALLOC_MUTEX
   68728             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   68729             :         do {                                                                     \
   68730             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   68731             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   68732             :                 abort();                                                         \
   68733             :             }                                                                    \
   68734             :         } while (0);
   68735             : #endif
   68736             : 
   68737             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   68738             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   68739             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   68740             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   68741             : 
   68742             : /*! \brief New operator for SgRangeBasedForStatement.
   68743             : 
   68744             :    This new operator implements memory pools to provide most efficent 
   68745             :    use of the heap within construction of large ASTs.
   68746             : 
   68747             : \internal The new and delete operators use the lower level C malloc/free
   68748             :    function calls for performance and to make sure that mixing of malloc/free
   68749             :    and new/delete by the used can be caught more readily.  This may change
   68750             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   68751             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   68752             :    deallocate memory allocated using ROSE_MALLOC.
   68753             : */
   68754           0 : void *SgRangeBasedForStatement::operator new ( size_t Size )
   68755             : {
   68756             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   68757             :      * returning or throwing an exception. */
   68758           0 :     ALLOC_MUTEX(SgRangeBasedForStatement, lock);
   68759             : 
   68760             : #if ROSE_ALLOC_TRACE == 2
   68761             : //    printf("SgRangeBasedForStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgRangeBasedForStatement::next_node);
   68762             : #endif
   68763             : 
   68764             : #if USE_CPP_NEW_DELETE_OPERATORS
   68765             :     void *mem = ROSE_MALLOC(Size);
   68766             :     ALLOC_MUTEX(SgRangeBasedForStatement, unlock);
   68767             :     return mem;
   68768             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   68769             : #if ROSE_PEDANTIC_ALLOC
   68770             :     ROSE_ASSERT(Size == sizeof(SgRangeBasedForStatement));
   68771             : #else
   68772           0 :     if (Size != sizeof(SgRangeBasedForStatement)) {
   68773           0 :       void * object = ROSE_MALLOC(Size);
   68774           0 :       ALLOC_MUTEX(SgRangeBasedForStatement, unlock);
   68775             :       return object;
   68776             :     }
   68777             : #endif
   68778             : 
   68779           0 :     if (SgRangeBasedForStatement::next_node == nullptr) {
   68780           0 :         SgRangeBasedForStatement * alloc = (SgRangeBasedForStatement*) ROSE_MALLOC ( SgRangeBasedForStatement::pool_size * sizeof(SgRangeBasedForStatement) );
   68781           0 :         ROSE_ASSERT(alloc != nullptr);
   68782             : 
   68783             : #if ROSE_ALLOC_TRACE == 2
   68784             : //        printf("SgRangeBasedForStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgRangeBasedForStatement::pools.size(), alloc, alloc + SgRangeBasedForStatement::pool_size);
   68785             : #endif
   68786             : 
   68787             : #if ROSE_ALLOC_MEMSET == 1
   68788             : #elif ROSE_ALLOC_MEMSET == 2
   68789             :         memset(alloc, 0x00, SgRangeBasedForStatement::pool_size * sizeof(SgRangeBasedForStatement));
   68790             : #elif ROSE_ALLOC_MEMSET == 3
   68791             :         memset(alloc, 0xAA, SgRangeBasedForStatement::pool_size * sizeof(SgRangeBasedForStatement));
   68792             : #endif
   68793           0 :         for (unsigned i=0; i < SgRangeBasedForStatement::pool_size-1; i++) {
   68794           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
   68795             :         }
   68796           0 :         alloc[SgRangeBasedForStatement::pool_size-1].p_freepointer = nullptr;
   68797             : 
   68798           0 :         SgRangeBasedForStatement::pools.push_back ( (unsigned char *) alloc );
   68799           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgRangeBasedForStatement::pool_size * sizeof(SgRangeBasedForStatement), V_SgRangeBasedForStatement ) );
   68800           0 :         SgRangeBasedForStatement::next_node = alloc;
   68801             :     }
   68802           0 :     ROSE_ASSERT(SgRangeBasedForStatement::next_node != nullptr);
   68803             : 
   68804           0 :     SgRangeBasedForStatement * object = SgRangeBasedForStatement::next_node;
   68805           0 :     SgRangeBasedForStatement::next_node = (SgRangeBasedForStatement*)(object->p_freepointer);
   68806             : 
   68807             : #if ROSE_ALLOC_TRACE == 2
   68808             :     printf("SgRangeBasedForStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgRangeBasedForStatement::next_node);
   68809             : #endif
   68810             : 
   68811           0 :     SgNode * fp = object->p_freepointer;
   68812             : #if ROSE_ALLOC_MEMSET == 1
   68813             : #elif ROSE_ALLOC_MEMSET == 2
   68814             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgRangeBasedForStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   68815             : #elif ROSE_ALLOC_MEMSET == 3
   68816             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgRangeBasedForStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   68817             : #endif
   68818           0 :     object->p_freepointer = fp;
   68819             : 
   68820             : #if ROSE_ALLOC_TRACE == 2
   68821             : //    printf("SgRangeBasedForStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgRangeBasedForStatement::next_node);
   68822             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   68823             :     Rose::MemPool::snapshot(oss.str());
   68824             :     alloc_trace_cnt++;
   68825             : #endif
   68826             : 
   68827           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   68828             : 
   68829           0 :     ALLOC_MUTEX(SgRangeBasedForStatement, unlock);
   68830             : 
   68831             :     return object;
   68832             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   68833             : }
   68834             : 
   68835             : 
   68836             : 
   68837             : /*! \brief Delete operator for SgRangeBasedForStatement.
   68838             : 
   68839             :    This delete operator implements deallocation using memory pools to 
   68840             :    provide most efficent use of the heap within construction of large ASTs.
   68841             : 
   68842             : \internal The new and delete operators use the lower level C malloc/free
   68843             :    function calls for performance and to make sure that mixing of malloc/free
   68844             :    and new/delete by the used can be caught more readily.  This may change
   68845             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   68846             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   68847             :    deallocate memory allocated using ROSE_MALLOC.
   68848             : */
   68849           0 : void SgRangeBasedForStatement::operator delete(void *Pointer, size_t Size)
   68850             : {
   68851             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   68852             :      * or throwing an exception. */
   68853           0 :     ALLOC_MUTEX(SgRangeBasedForStatement, lock);
   68854             : 
   68855             : #if USE_CPP_NEW_DELETE_OPERATORS
   68856             :     ROSE_FREE(Pointer);
   68857             : #else
   68858             : #if ROSE_PEDANTIC_ALLOC
   68859             :     ROSE_ASSERT(Size == sizeof(SgRangeBasedForStatement));
   68860             : #else
   68861           0 :     if (Size != sizeof(SgRangeBasedForStatement)) {
   68862           0 :       ROSE_FREE(Pointer);
   68863           0 :       ALLOC_MUTEX(SgRangeBasedForStatement, unlock);
   68864             :       return;
   68865             :     }
   68866             : #endif
   68867             : 
   68868           0 :     SgRangeBasedForStatement * object = (SgRangeBasedForStatement*) Pointer;
   68869           0 :     ROSE_ASSERT(object != nullptr);
   68870             : 
   68871             : #if ROSE_ALLOC_TRACE == 2
   68872             : //  printf("SgRangeBasedForStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgRangeBasedForStatement::next_node);
   68873             :     printf("SgRangeBasedForStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgRangeBasedForStatement::next_node);
   68874             : #endif
   68875             : 
   68876             : #if ROSE_PEDANTIC_ALLOC
   68877             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   68878             : #endif
   68879             : 
   68880             : #if ROSE_ALLOC_MEMSET == 1
   68881             : #elif ROSE_ALLOC_MEMSET == 2
   68882             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgRangeBasedForStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   68883             : #elif ROSE_ALLOC_MEMSET == 3
   68884             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgRangeBasedForStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   68885             : #endif
   68886             : 
   68887             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   68888             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   68889             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   68890             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   68891             : #else
   68892           0 :     object->p_freepointer = SgRangeBasedForStatement::next_node;
   68893           0 :     SgRangeBasedForStatement::next_node = object;
   68894             : #endif
   68895             : 
   68896             : #if ROSE_ALLOC_TRACE == 2
   68897             : //  printf("SgRangeBasedForStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgRangeBasedForStatement::next_node);
   68898             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   68899             :     Rose::MemPool::snapshot(oss.str());
   68900             :     alloc_trace_cnt++;
   68901             : #endif
   68902             : 
   68903             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   68904             : 
   68905           0 :     ALLOC_MUTEX(SgRangeBasedForStatement, unlock);
   68906             : }
   68907             : 
   68908             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   68909             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   68910             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   68911             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   68912             : // Also, note comment below from Robb (copied from the Common.code file).
   68913             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   68914             : //
   68915             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   68916             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   68917             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   68918             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   68919             : #if 0
   68920             : void SgRangeBasedForStatement::operator delete(void* pointer) { SgRangeBasedForStatement::operator delete (pointer, sizeof(SgRangeBasedForStatement)); };
   68921             : #endif
   68922             : /* #line 68923 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   68923             : 
   68924             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   68925             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   68926             : // obviously imply C++.
   68927             : 
   68928             : // This implements the support within ROSE for memory pools.  Memory pools
   68929             : // support the most condensed usage of memory within the construction of
   68930             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   68931             : // by a new operator written for each class.
   68932             : 
   68933             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   68934             :     // User wants multi-thread support and POSIX threads are available.
   68935             : #   include <pthread.h>
   68936             :     static pthread_mutex_t SgFunctionTypeTable_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   68937             : #else
   68938             :      // Cause synchronization to be skipped.
   68939             : #    ifndef ALLOC_MUTEX
   68940             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   68941             : #    endif
   68942             : #    ifdef _REENTRANT
   68943             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   68944             : #       ifdef _MSC_VER
   68945             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   68946             : #       else
   68947             : #           warning "POSIX threads are not available; synchronization being skipped"
   68948             : #       endif
   68949             : #    endif
   68950             : #endif
   68951             : 
   68952             : #ifndef ROSE_ALLOC_TRACE
   68953             : #  define ROSE_ALLOC_TRACE 0
   68954             : #endif
   68955             : 
   68956             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   68957             : #define ROSE_ALLOC_TRACE_CNT
   68958             : #include "memory-pool-snapshot.h"
   68959             : unsigned long alloc_trace_cnt = 0;
   68960             : #endif
   68961             : 
   68962             : #if ROSE_ALLOC_TRACE
   68963             : const unsigned SgFunctionTypeTable::pool_size = 5;
   68964             : #else
   68965             : const unsigned SgFunctionTypeTable::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   68966             : #endif
   68967             : 
   68968             : #ifndef ROSE_ALLOC_MEMSET
   68969             : #  define ROSE_ALLOC_MEMSET 0
   68970             : #endif
   68971             : 
   68972             : #ifndef ROSE_PEDANTIC_ALLOC
   68973             : #  define ROSE_PEDANTIC_ALLOC 0
   68974             : #endif
   68975             : 
   68976             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   68977             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   68978             : #endif
   68979             : 
   68980             : #if !defined(SGNODE__ALL_POOLS)
   68981             : #define SGNODE__ALL_POOLS
   68982             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   68983             : #endif
   68984             : 
   68985             : SgFunctionTypeTable* SgFunctionTypeTable::next_node = nullptr;
   68986             : std::vector<unsigned char*> SgFunctionTypeTable::pools;
   68987             : 
   68988             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   68989             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   68990             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   68991             : // around this macro definition rather than each use).
   68992             : #ifndef ALLOC_MUTEX
   68993             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   68994             :         do {                                                                     \
   68995             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   68996             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   68997             :                 abort();                                                         \
   68998             :             }                                                                    \
   68999             :         } while (0);
   69000             : #endif
   69001             : 
   69002             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   69003             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   69004             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   69005             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   69006             : 
   69007             : /*! \brief New operator for SgFunctionTypeTable.
   69008             : 
   69009             :    This new operator implements memory pools to provide most efficent 
   69010             :    use of the heap within construction of large ASTs.
   69011             : 
   69012             : \internal The new and delete operators use the lower level C malloc/free
   69013             :    function calls for performance and to make sure that mixing of malloc/free
   69014             :    and new/delete by the used can be caught more readily.  This may change
   69015             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   69016             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   69017             :    deallocate memory allocated using ROSE_MALLOC.
   69018             : */
   69019         356 : void *SgFunctionTypeTable::operator new ( size_t Size )
   69020             : {
   69021             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   69022             :      * returning or throwing an exception. */
   69023         356 :     ALLOC_MUTEX(SgFunctionTypeTable, lock);
   69024             : 
   69025             : #if ROSE_ALLOC_TRACE == 2
   69026             : //    printf("SgFunctionTypeTable::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgFunctionTypeTable::next_node);
   69027             : #endif
   69028             : 
   69029             : #if USE_CPP_NEW_DELETE_OPERATORS
   69030             :     void *mem = ROSE_MALLOC(Size);
   69031             :     ALLOC_MUTEX(SgFunctionTypeTable, unlock);
   69032             :     return mem;
   69033             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   69034             : #if ROSE_PEDANTIC_ALLOC
   69035             :     ROSE_ASSERT(Size == sizeof(SgFunctionTypeTable));
   69036             : #else
   69037         356 :     if (Size != sizeof(SgFunctionTypeTable)) {
   69038           0 :       void * object = ROSE_MALLOC(Size);
   69039           0 :       ALLOC_MUTEX(SgFunctionTypeTable, unlock);
   69040             :       return object;
   69041             :     }
   69042             : #endif
   69043             : 
   69044         356 :     if (SgFunctionTypeTable::next_node == nullptr) {
   69045         354 :         SgFunctionTypeTable * alloc = (SgFunctionTypeTable*) ROSE_MALLOC ( SgFunctionTypeTable::pool_size * sizeof(SgFunctionTypeTable) );
   69046         354 :         ROSE_ASSERT(alloc != nullptr);
   69047             : 
   69048             : #if ROSE_ALLOC_TRACE == 2
   69049             : //        printf("SgFunctionTypeTable::alloc\n  block[%zi] = [ %p , %p [\n", SgFunctionTypeTable::pools.size(), alloc, alloc + SgFunctionTypeTable::pool_size);
   69050             : #endif
   69051             : 
   69052             : #if ROSE_ALLOC_MEMSET == 1
   69053             : #elif ROSE_ALLOC_MEMSET == 2
   69054             :         memset(alloc, 0x00, SgFunctionTypeTable::pool_size * sizeof(SgFunctionTypeTable));
   69055             : #elif ROSE_ALLOC_MEMSET == 3
   69056             :         memset(alloc, 0xAA, SgFunctionTypeTable::pool_size * sizeof(SgFunctionTypeTable));
   69057             : #endif
   69058      708000 :         for (unsigned i=0; i < SgFunctionTypeTable::pool_size-1; i++) {
   69059      707646 :           alloc[i].p_freepointer = &(alloc[i+1]);
   69060             :         }
   69061         354 :         alloc[SgFunctionTypeTable::pool_size-1].p_freepointer = nullptr;
   69062             : 
   69063         354 :         SgFunctionTypeTable::pools.push_back ( (unsigned char *) alloc );
   69064         354 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgFunctionTypeTable::pool_size * sizeof(SgFunctionTypeTable), V_SgFunctionTypeTable ) );
   69065         354 :         SgFunctionTypeTable::next_node = alloc;
   69066             :     }
   69067         356 :     ROSE_ASSERT(SgFunctionTypeTable::next_node != nullptr);
   69068             : 
   69069         356 :     SgFunctionTypeTable * object = SgFunctionTypeTable::next_node;
   69070         356 :     SgFunctionTypeTable::next_node = (SgFunctionTypeTable*)(object->p_freepointer);
   69071             : 
   69072             : #if ROSE_ALLOC_TRACE == 2
   69073             :     printf("SgFunctionTypeTable::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgFunctionTypeTable::next_node);
   69074             : #endif
   69075             : 
   69076         356 :     SgNode * fp = object->p_freepointer;
   69077             : #if ROSE_ALLOC_MEMSET == 1
   69078             : #elif ROSE_ALLOC_MEMSET == 2
   69079             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgFunctionTypeTable) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   69080             : #elif ROSE_ALLOC_MEMSET == 3
   69081             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgFunctionTypeTable) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   69082             : #endif
   69083         356 :     object->p_freepointer = fp;
   69084             : 
   69085             : #if ROSE_ALLOC_TRACE == 2
   69086             : //    printf("SgFunctionTypeTable::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgFunctionTypeTable::next_node);
   69087             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   69088             :     Rose::MemPool::snapshot(oss.str());
   69089             :     alloc_trace_cnt++;
   69090             : #endif
   69091             : 
   69092         356 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   69093             : 
   69094         356 :     ALLOC_MUTEX(SgFunctionTypeTable, unlock);
   69095             : 
   69096             :     return object;
   69097             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   69098             : }
   69099             : 
   69100             : 
   69101             : 
   69102             : /*! \brief Delete operator for SgFunctionTypeTable.
   69103             : 
   69104             :    This delete operator implements deallocation using memory pools to 
   69105             :    provide most efficent use of the heap within construction of large ASTs.
   69106             : 
   69107             : \internal The new and delete operators use the lower level C malloc/free
   69108             :    function calls for performance and to make sure that mixing of malloc/free
   69109             :    and new/delete by the used can be caught more readily.  This may change
   69110             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   69111             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   69112             :    deallocate memory allocated using ROSE_MALLOC.
   69113             : */
   69114           7 : void SgFunctionTypeTable::operator delete(void *Pointer, size_t Size)
   69115             : {
   69116             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   69117             :      * or throwing an exception. */
   69118           7 :     ALLOC_MUTEX(SgFunctionTypeTable, lock);
   69119             : 
   69120             : #if USE_CPP_NEW_DELETE_OPERATORS
   69121             :     ROSE_FREE(Pointer);
   69122             : #else
   69123             : #if ROSE_PEDANTIC_ALLOC
   69124             :     ROSE_ASSERT(Size == sizeof(SgFunctionTypeTable));
   69125             : #else
   69126           7 :     if (Size != sizeof(SgFunctionTypeTable)) {
   69127           0 :       ROSE_FREE(Pointer);
   69128           0 :       ALLOC_MUTEX(SgFunctionTypeTable, unlock);
   69129             :       return;
   69130             :     }
   69131             : #endif
   69132             : 
   69133           7 :     SgFunctionTypeTable * object = (SgFunctionTypeTable*) Pointer;
   69134           7 :     ROSE_ASSERT(object != nullptr);
   69135             : 
   69136             : #if ROSE_ALLOC_TRACE == 2
   69137             : //  printf("SgFunctionTypeTable::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgFunctionTypeTable::next_node);
   69138             :     printf("SgFunctionTypeTable::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgFunctionTypeTable::next_node);
   69139             : #endif
   69140             : 
   69141             : #if ROSE_PEDANTIC_ALLOC
   69142             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   69143             : #endif
   69144             : 
   69145             : #if ROSE_ALLOC_MEMSET == 1
   69146             : #elif ROSE_ALLOC_MEMSET == 2
   69147             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgFunctionTypeTable) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   69148             : #elif ROSE_ALLOC_MEMSET == 3
   69149             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgFunctionTypeTable) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   69150             : #endif
   69151             : 
   69152             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   69153             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   69154             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   69155             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   69156             : #else
   69157           7 :     object->p_freepointer = SgFunctionTypeTable::next_node;
   69158           7 :     SgFunctionTypeTable::next_node = object;
   69159             : #endif
   69160             : 
   69161             : #if ROSE_ALLOC_TRACE == 2
   69162             : //  printf("SgFunctionTypeTable::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgFunctionTypeTable::next_node);
   69163             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   69164             :     Rose::MemPool::snapshot(oss.str());
   69165             :     alloc_trace_cnt++;
   69166             : #endif
   69167             : 
   69168             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   69169             : 
   69170           7 :     ALLOC_MUTEX(SgFunctionTypeTable, unlock);
   69171             : }
   69172             : 
   69173             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   69174             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   69175             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   69176             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   69177             : // Also, note comment below from Robb (copied from the Common.code file).
   69178             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   69179             : //
   69180             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   69181             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   69182             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   69183             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   69184             : #if 0
   69185             : void SgFunctionTypeTable::operator delete(void* pointer) { SgFunctionTypeTable::operator delete (pointer, sizeof(SgFunctionTypeTable)); };
   69186             : #endif
   69187             : /* #line 69188 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   69188             : 
   69189             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   69190             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   69191             : // obviously imply C++.
   69192             : 
   69193             : // This implements the support within ROSE for memory pools.  Memory pools
   69194             : // support the most condensed usage of memory within the construction of
   69195             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   69196             : // by a new operator written for each class.
   69197             : 
   69198             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   69199             :     // User wants multi-thread support and POSIX threads are available.
   69200             : #   include <pthread.h>
   69201             :     static pthread_mutex_t SgDeclarationStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   69202             : #else
   69203             :      // Cause synchronization to be skipped.
   69204             : #    ifndef ALLOC_MUTEX
   69205             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   69206             : #    endif
   69207             : #    ifdef _REENTRANT
   69208             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   69209             : #       ifdef _MSC_VER
   69210             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   69211             : #       else
   69212             : #           warning "POSIX threads are not available; synchronization being skipped"
   69213             : #       endif
   69214             : #    endif
   69215             : #endif
   69216             : 
   69217             : #ifndef ROSE_ALLOC_TRACE
   69218             : #  define ROSE_ALLOC_TRACE 0
   69219             : #endif
   69220             : 
   69221             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   69222             : #define ROSE_ALLOC_TRACE_CNT
   69223             : #include "memory-pool-snapshot.h"
   69224             : unsigned long alloc_trace_cnt = 0;
   69225             : #endif
   69226             : 
   69227             : #if ROSE_ALLOC_TRACE
   69228             : const unsigned SgDeclarationStatement::pool_size = 5;
   69229             : #else
   69230             : const unsigned SgDeclarationStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   69231             : #endif
   69232             : 
   69233             : #ifndef ROSE_ALLOC_MEMSET
   69234             : #  define ROSE_ALLOC_MEMSET 0
   69235             : #endif
   69236             : 
   69237             : #ifndef ROSE_PEDANTIC_ALLOC
   69238             : #  define ROSE_PEDANTIC_ALLOC 0
   69239             : #endif
   69240             : 
   69241             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   69242             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   69243             : #endif
   69244             : 
   69245             : #if !defined(SGNODE__ALL_POOLS)
   69246             : #define SGNODE__ALL_POOLS
   69247             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   69248             : #endif
   69249             : 
   69250             : SgDeclarationStatement* SgDeclarationStatement::next_node = nullptr;
   69251             : std::vector<unsigned char*> SgDeclarationStatement::pools;
   69252             : 
   69253             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   69254             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   69255             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   69256             : // around this macro definition rather than each use).
   69257             : #ifndef ALLOC_MUTEX
   69258             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   69259             :         do {                                                                     \
   69260             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   69261             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   69262             :                 abort();                                                         \
   69263             :             }                                                                    \
   69264             :         } while (0);
   69265             : #endif
   69266             : 
   69267             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   69268             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   69269             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   69270             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   69271             : 
   69272             : /*! \brief New operator for SgDeclarationStatement.
   69273             : 
   69274             :    This new operator implements memory pools to provide most efficent 
   69275             :    use of the heap within construction of large ASTs.
   69276             : 
   69277             : \internal The new and delete operators use the lower level C malloc/free
   69278             :    function calls for performance and to make sure that mixing of malloc/free
   69279             :    and new/delete by the used can be caught more readily.  This may change
   69280             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   69281             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   69282             :    deallocate memory allocated using ROSE_MALLOC.
   69283             : */
   69284           0 : void *SgDeclarationStatement::operator new ( size_t Size )
   69285             : {
   69286             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   69287             :      * returning or throwing an exception. */
   69288           0 :     ALLOC_MUTEX(SgDeclarationStatement, lock);
   69289             : 
   69290             : #if ROSE_ALLOC_TRACE == 2
   69291             : //    printf("SgDeclarationStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgDeclarationStatement::next_node);
   69292             : #endif
   69293             : 
   69294             : #if USE_CPP_NEW_DELETE_OPERATORS
   69295             :     void *mem = ROSE_MALLOC(Size);
   69296             :     ALLOC_MUTEX(SgDeclarationStatement, unlock);
   69297             :     return mem;
   69298             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   69299             : #if ROSE_PEDANTIC_ALLOC
   69300             :     ROSE_ASSERT(Size == sizeof(SgDeclarationStatement));
   69301             : #else
   69302           0 :     if (Size != sizeof(SgDeclarationStatement)) {
   69303           0 :       void * object = ROSE_MALLOC(Size);
   69304           0 :       ALLOC_MUTEX(SgDeclarationStatement, unlock);
   69305             :       return object;
   69306             :     }
   69307             : #endif
   69308             : 
   69309           0 :     if (SgDeclarationStatement::next_node == nullptr) {
   69310           0 :         SgDeclarationStatement * alloc = (SgDeclarationStatement*) ROSE_MALLOC ( SgDeclarationStatement::pool_size * sizeof(SgDeclarationStatement) );
   69311           0 :         ROSE_ASSERT(alloc != nullptr);
   69312             : 
   69313             : #if ROSE_ALLOC_TRACE == 2
   69314             : //        printf("SgDeclarationStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgDeclarationStatement::pools.size(), alloc, alloc + SgDeclarationStatement::pool_size);
   69315             : #endif
   69316             : 
   69317             : #if ROSE_ALLOC_MEMSET == 1
   69318             : #elif ROSE_ALLOC_MEMSET == 2
   69319             :         memset(alloc, 0x00, SgDeclarationStatement::pool_size * sizeof(SgDeclarationStatement));
   69320             : #elif ROSE_ALLOC_MEMSET == 3
   69321             :         memset(alloc, 0xAA, SgDeclarationStatement::pool_size * sizeof(SgDeclarationStatement));
   69322             : #endif
   69323           0 :         for (unsigned i=0; i < SgDeclarationStatement::pool_size-1; i++) {
   69324           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
   69325             :         }
   69326           0 :         alloc[SgDeclarationStatement::pool_size-1].p_freepointer = nullptr;
   69327             : 
   69328           0 :         SgDeclarationStatement::pools.push_back ( (unsigned char *) alloc );
   69329           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgDeclarationStatement::pool_size * sizeof(SgDeclarationStatement), V_SgDeclarationStatement ) );
   69330           0 :         SgDeclarationStatement::next_node = alloc;
   69331             :     }
   69332           0 :     ROSE_ASSERT(SgDeclarationStatement::next_node != nullptr);
   69333             : 
   69334           0 :     SgDeclarationStatement * object = SgDeclarationStatement::next_node;
   69335           0 :     SgDeclarationStatement::next_node = (SgDeclarationStatement*)(object->p_freepointer);
   69336             : 
   69337             : #if ROSE_ALLOC_TRACE == 2
   69338             :     printf("SgDeclarationStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgDeclarationStatement::next_node);
   69339             : #endif
   69340             : 
   69341           0 :     SgNode * fp = object->p_freepointer;
   69342             : #if ROSE_ALLOC_MEMSET == 1
   69343             : #elif ROSE_ALLOC_MEMSET == 2
   69344             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgDeclarationStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   69345             : #elif ROSE_ALLOC_MEMSET == 3
   69346             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgDeclarationStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   69347             : #endif
   69348           0 :     object->p_freepointer = fp;
   69349             : 
   69350             : #if ROSE_ALLOC_TRACE == 2
   69351             : //    printf("SgDeclarationStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgDeclarationStatement::next_node);
   69352             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   69353             :     Rose::MemPool::snapshot(oss.str());
   69354             :     alloc_trace_cnt++;
   69355             : #endif
   69356             : 
   69357           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   69358             : 
   69359           0 :     ALLOC_MUTEX(SgDeclarationStatement, unlock);
   69360             : 
   69361             :     return object;
   69362             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   69363             : }
   69364             : 
   69365             : 
   69366             : 
   69367             : /*! \brief Delete operator for SgDeclarationStatement.
   69368             : 
   69369             :    This delete operator implements deallocation using memory pools to 
   69370             :    provide most efficent use of the heap within construction of large ASTs.
   69371             : 
   69372             : \internal The new and delete operators use the lower level C malloc/free
   69373             :    function calls for performance and to make sure that mixing of malloc/free
   69374             :    and new/delete by the used can be caught more readily.  This may change
   69375             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   69376             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   69377             :    deallocate memory allocated using ROSE_MALLOC.
   69378             : */
   69379           0 : void SgDeclarationStatement::operator delete(void *Pointer, size_t Size)
   69380             : {
   69381             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   69382             :      * or throwing an exception. */
   69383           0 :     ALLOC_MUTEX(SgDeclarationStatement, lock);
   69384             : 
   69385             : #if USE_CPP_NEW_DELETE_OPERATORS
   69386             :     ROSE_FREE(Pointer);
   69387             : #else
   69388             : #if ROSE_PEDANTIC_ALLOC
   69389             :     ROSE_ASSERT(Size == sizeof(SgDeclarationStatement));
   69390             : #else
   69391           0 :     if (Size != sizeof(SgDeclarationStatement)) {
   69392           0 :       ROSE_FREE(Pointer);
   69393           0 :       ALLOC_MUTEX(SgDeclarationStatement, unlock);
   69394             :       return;
   69395             :     }
   69396             : #endif
   69397             : 
   69398           0 :     SgDeclarationStatement * object = (SgDeclarationStatement*) Pointer;
   69399           0 :     ROSE_ASSERT(object != nullptr);
   69400             : 
   69401             : #if ROSE_ALLOC_TRACE == 2
   69402             : //  printf("SgDeclarationStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgDeclarationStatement::next_node);
   69403             :     printf("SgDeclarationStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgDeclarationStatement::next_node);
   69404             : #endif
   69405             : 
   69406             : #if ROSE_PEDANTIC_ALLOC
   69407             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   69408             : #endif
   69409             : 
   69410             : #if ROSE_ALLOC_MEMSET == 1
   69411             : #elif ROSE_ALLOC_MEMSET == 2
   69412             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgDeclarationStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   69413             : #elif ROSE_ALLOC_MEMSET == 3
   69414             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgDeclarationStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   69415             : #endif
   69416             : 
   69417             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   69418             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   69419             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   69420             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   69421             : #else
   69422           0 :     object->p_freepointer = SgDeclarationStatement::next_node;
   69423           0 :     SgDeclarationStatement::next_node = object;
   69424             : #endif
   69425             : 
   69426             : #if ROSE_ALLOC_TRACE == 2
   69427             : //  printf("SgDeclarationStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgDeclarationStatement::next_node);
   69428             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   69429             :     Rose::MemPool::snapshot(oss.str());
   69430             :     alloc_trace_cnt++;
   69431             : #endif
   69432             : 
   69433             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   69434             : 
   69435           0 :     ALLOC_MUTEX(SgDeclarationStatement, unlock);
   69436             : }
   69437             : 
   69438             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   69439             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   69440             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   69441             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   69442             : // Also, note comment below from Robb (copied from the Common.code file).
   69443             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   69444             : //
   69445             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   69446             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   69447             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   69448             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   69449             : #if 0
   69450             : void SgDeclarationStatement::operator delete(void* pointer) { SgDeclarationStatement::operator delete (pointer, sizeof(SgDeclarationStatement)); };
   69451             : #endif
   69452             : /* #line 69453 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   69453             : 
   69454             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   69455             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   69456             : // obviously imply C++.
   69457             : 
   69458             : // This implements the support within ROSE for memory pools.  Memory pools
   69459             : // support the most condensed usage of memory within the construction of
   69460             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   69461             : // by a new operator written for each class.
   69462             : 
   69463             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   69464             :     // User wants multi-thread support and POSIX threads are available.
   69465             : #   include <pthread.h>
   69466             :     static pthread_mutex_t SgFunctionParameterList_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   69467             : #else
   69468             :      // Cause synchronization to be skipped.
   69469             : #    ifndef ALLOC_MUTEX
   69470             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   69471             : #    endif
   69472             : #    ifdef _REENTRANT
   69473             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   69474             : #       ifdef _MSC_VER
   69475             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   69476             : #       else
   69477             : #           warning "POSIX threads are not available; synchronization being skipped"
   69478             : #       endif
   69479             : #    endif
   69480             : #endif
   69481             : 
   69482             : #ifndef ROSE_ALLOC_TRACE
   69483             : #  define ROSE_ALLOC_TRACE 0
   69484             : #endif
   69485             : 
   69486             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   69487             : #define ROSE_ALLOC_TRACE_CNT
   69488             : #include "memory-pool-snapshot.h"
   69489             : unsigned long alloc_trace_cnt = 0;
   69490             : #endif
   69491             : 
   69492             : #if ROSE_ALLOC_TRACE
   69493             : const unsigned SgFunctionParameterList::pool_size = 5;
   69494             : #else
   69495             : const unsigned SgFunctionParameterList::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   69496             : #endif
   69497             : 
   69498             : #ifndef ROSE_ALLOC_MEMSET
   69499             : #  define ROSE_ALLOC_MEMSET 0
   69500             : #endif
   69501             : 
   69502             : #ifndef ROSE_PEDANTIC_ALLOC
   69503             : #  define ROSE_PEDANTIC_ALLOC 0
   69504             : #endif
   69505             : 
   69506             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   69507             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   69508             : #endif
   69509             : 
   69510             : #if !defined(SGNODE__ALL_POOLS)
   69511             : #define SGNODE__ALL_POOLS
   69512             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   69513             : #endif
   69514             : 
   69515             : SgFunctionParameterList* SgFunctionParameterList::next_node = nullptr;
   69516             : std::vector<unsigned char*> SgFunctionParameterList::pools;
   69517             : 
   69518             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   69519             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   69520             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   69521             : // around this macro definition rather than each use).
   69522             : #ifndef ALLOC_MUTEX
   69523             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   69524             :         do {                                                                     \
   69525             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   69526             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   69527             :                 abort();                                                         \
   69528             :             }                                                                    \
   69529             :         } while (0);
   69530             : #endif
   69531             : 
   69532             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   69533             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   69534             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   69535             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   69536             : 
   69537             : /*! \brief New operator for SgFunctionParameterList.
   69538             : 
   69539             :    This new operator implements memory pools to provide most efficent 
   69540             :    use of the heap within construction of large ASTs.
   69541             : 
   69542             : \internal The new and delete operators use the lower level C malloc/free
   69543             :    function calls for performance and to make sure that mixing of malloc/free
   69544             :    and new/delete by the used can be caught more readily.  This may change
   69545             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   69546             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   69547             :    deallocate memory allocated using ROSE_MALLOC.
   69548             : */
   69549     3525380 : void *SgFunctionParameterList::operator new ( size_t Size )
   69550             : {
   69551             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   69552             :      * returning or throwing an exception. */
   69553     3525380 :     ALLOC_MUTEX(SgFunctionParameterList, lock);
   69554             : 
   69555             : #if ROSE_ALLOC_TRACE == 2
   69556             : //    printf("SgFunctionParameterList::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgFunctionParameterList::next_node);
   69557             : #endif
   69558             : 
   69559             : #if USE_CPP_NEW_DELETE_OPERATORS
   69560             :     void *mem = ROSE_MALLOC(Size);
   69561             :     ALLOC_MUTEX(SgFunctionParameterList, unlock);
   69562             :     return mem;
   69563             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   69564             : #if ROSE_PEDANTIC_ALLOC
   69565             :     ROSE_ASSERT(Size == sizeof(SgFunctionParameterList));
   69566             : #else
   69567     3525380 :     if (Size != sizeof(SgFunctionParameterList)) {
   69568           0 :       void * object = ROSE_MALLOC(Size);
   69569           0 :       ALLOC_MUTEX(SgFunctionParameterList, unlock);
   69570             :       return object;
   69571             :     }
   69572             : #endif
   69573             : 
   69574     3525380 :     if (SgFunctionParameterList::next_node == nullptr) {
   69575        1368 :         SgFunctionParameterList * alloc = (SgFunctionParameterList*) ROSE_MALLOC ( SgFunctionParameterList::pool_size * sizeof(SgFunctionParameterList) );
   69576        1368 :         ROSE_ASSERT(alloc != nullptr);
   69577             : 
   69578             : #if ROSE_ALLOC_TRACE == 2
   69579             : //        printf("SgFunctionParameterList::alloc\n  block[%zi] = [ %p , %p [\n", SgFunctionParameterList::pools.size(), alloc, alloc + SgFunctionParameterList::pool_size);
   69580             : #endif
   69581             : 
   69582             : #if ROSE_ALLOC_MEMSET == 1
   69583             : #elif ROSE_ALLOC_MEMSET == 2
   69584             :         memset(alloc, 0x00, SgFunctionParameterList::pool_size * sizeof(SgFunctionParameterList));
   69585             : #elif ROSE_ALLOC_MEMSET == 3
   69586             :         memset(alloc, 0xAA, SgFunctionParameterList::pool_size * sizeof(SgFunctionParameterList));
   69587             : #endif
   69588     2736000 :         for (unsigned i=0; i < SgFunctionParameterList::pool_size-1; i++) {
   69589     2734630 :           alloc[i].p_freepointer = &(alloc[i+1]);
   69590             :         }
   69591        1368 :         alloc[SgFunctionParameterList::pool_size-1].p_freepointer = nullptr;
   69592             : 
   69593        1368 :         SgFunctionParameterList::pools.push_back ( (unsigned char *) alloc );
   69594        1368 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgFunctionParameterList::pool_size * sizeof(SgFunctionParameterList), V_SgFunctionParameterList ) );
   69595        1368 :         SgFunctionParameterList::next_node = alloc;
   69596             :     }
   69597     3525380 :     ROSE_ASSERT(SgFunctionParameterList::next_node != nullptr);
   69598             : 
   69599     3525380 :     SgFunctionParameterList * object = SgFunctionParameterList::next_node;
   69600     3525380 :     SgFunctionParameterList::next_node = (SgFunctionParameterList*)(object->p_freepointer);
   69601             : 
   69602             : #if ROSE_ALLOC_TRACE == 2
   69603             :     printf("SgFunctionParameterList::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgFunctionParameterList::next_node);
   69604             : #endif
   69605             : 
   69606     3525380 :     SgNode * fp = object->p_freepointer;
   69607             : #if ROSE_ALLOC_MEMSET == 1
   69608             : #elif ROSE_ALLOC_MEMSET == 2
   69609             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgFunctionParameterList) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   69610             : #elif ROSE_ALLOC_MEMSET == 3
   69611             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgFunctionParameterList) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   69612             : #endif
   69613     3525380 :     object->p_freepointer = fp;
   69614             : 
   69615             : #if ROSE_ALLOC_TRACE == 2
   69616             : //    printf("SgFunctionParameterList::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgFunctionParameterList::next_node);
   69617             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   69618             :     Rose::MemPool::snapshot(oss.str());
   69619             :     alloc_trace_cnt++;
   69620             : #endif
   69621             : 
   69622     3525380 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   69623             : 
   69624     3525380 :     ALLOC_MUTEX(SgFunctionParameterList, unlock);
   69625             : 
   69626             :     return object;
   69627             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   69628             : }
   69629             : 
   69630             : 
   69631             : 
   69632             : /*! \brief Delete operator for SgFunctionParameterList.
   69633             : 
   69634             :    This delete operator implements deallocation using memory pools to 
   69635             :    provide most efficent use of the heap within construction of large ASTs.
   69636             : 
   69637             : \internal The new and delete operators use the lower level C malloc/free
   69638             :    function calls for performance and to make sure that mixing of malloc/free
   69639             :    and new/delete by the used can be caught more readily.  This may change
   69640             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   69641             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   69642             :    deallocate memory allocated using ROSE_MALLOC.
   69643             : */
   69644     1225990 : void SgFunctionParameterList::operator delete(void *Pointer, size_t Size)
   69645             : {
   69646             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   69647             :      * or throwing an exception. */
   69648     1225990 :     ALLOC_MUTEX(SgFunctionParameterList, lock);
   69649             : 
   69650             : #if USE_CPP_NEW_DELETE_OPERATORS
   69651             :     ROSE_FREE(Pointer);
   69652             : #else
   69653             : #if ROSE_PEDANTIC_ALLOC
   69654             :     ROSE_ASSERT(Size == sizeof(SgFunctionParameterList));
   69655             : #else
   69656     1225990 :     if (Size != sizeof(SgFunctionParameterList)) {
   69657           0 :       ROSE_FREE(Pointer);
   69658           0 :       ALLOC_MUTEX(SgFunctionParameterList, unlock);
   69659             :       return;
   69660             :     }
   69661             : #endif
   69662             : 
   69663     1225990 :     SgFunctionParameterList * object = (SgFunctionParameterList*) Pointer;
   69664     1225990 :     ROSE_ASSERT(object != nullptr);
   69665             : 
   69666             : #if ROSE_ALLOC_TRACE == 2
   69667             : //  printf("SgFunctionParameterList::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgFunctionParameterList::next_node);
   69668             :     printf("SgFunctionParameterList::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgFunctionParameterList::next_node);
   69669             : #endif
   69670             : 
   69671             : #if ROSE_PEDANTIC_ALLOC
   69672             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   69673             : #endif
   69674             : 
   69675             : #if ROSE_ALLOC_MEMSET == 1
   69676             : #elif ROSE_ALLOC_MEMSET == 2
   69677             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgFunctionParameterList) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   69678             : #elif ROSE_ALLOC_MEMSET == 3
   69679             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgFunctionParameterList) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   69680             : #endif
   69681             : 
   69682             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   69683             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   69684             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   69685             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   69686             : #else
   69687     1225990 :     object->p_freepointer = SgFunctionParameterList::next_node;
   69688     1225990 :     SgFunctionParameterList::next_node = object;
   69689             : #endif
   69690             : 
   69691             : #if ROSE_ALLOC_TRACE == 2
   69692             : //  printf("SgFunctionParameterList::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgFunctionParameterList::next_node);
   69693             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   69694             :     Rose::MemPool::snapshot(oss.str());
   69695             :     alloc_trace_cnt++;
   69696             : #endif
   69697             : 
   69698             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   69699             : 
   69700     1225990 :     ALLOC_MUTEX(SgFunctionParameterList, unlock);
   69701             : }
   69702             : 
   69703             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   69704             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   69705             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   69706             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   69707             : // Also, note comment below from Robb (copied from the Common.code file).
   69708             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   69709             : //
   69710             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   69711             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   69712             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   69713             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   69714             : #if 0
   69715             : void SgFunctionParameterList::operator delete(void* pointer) { SgFunctionParameterList::operator delete (pointer, sizeof(SgFunctionParameterList)); };
   69716             : #endif
   69717             : /* #line 69718 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   69718             : 
   69719             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   69720             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   69721             : // obviously imply C++.
   69722             : 
   69723             : // This implements the support within ROSE for memory pools.  Memory pools
   69724             : // support the most condensed usage of memory within the construction of
   69725             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   69726             : // by a new operator written for each class.
   69727             : 
   69728             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   69729             :     // User wants multi-thread support and POSIX threads are available.
   69730             : #   include <pthread.h>
   69731             :     static pthread_mutex_t SgVariableDeclaration_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   69732             : #else
   69733             :      // Cause synchronization to be skipped.
   69734             : #    ifndef ALLOC_MUTEX
   69735             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   69736             : #    endif
   69737             : #    ifdef _REENTRANT
   69738             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   69739             : #       ifdef _MSC_VER
   69740             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   69741             : #       else
   69742             : #           warning "POSIX threads are not available; synchronization being skipped"
   69743             : #       endif
   69744             : #    endif
   69745             : #endif
   69746             : 
   69747             : #ifndef ROSE_ALLOC_TRACE
   69748             : #  define ROSE_ALLOC_TRACE 0
   69749             : #endif
   69750             : 
   69751             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   69752             : #define ROSE_ALLOC_TRACE_CNT
   69753             : #include "memory-pool-snapshot.h"
   69754             : unsigned long alloc_trace_cnt = 0;
   69755             : #endif
   69756             : 
   69757             : #if ROSE_ALLOC_TRACE
   69758             : const unsigned SgVariableDeclaration::pool_size = 5;
   69759             : #else
   69760             : const unsigned SgVariableDeclaration::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   69761             : #endif
   69762             : 
   69763             : #ifndef ROSE_ALLOC_MEMSET
   69764             : #  define ROSE_ALLOC_MEMSET 0
   69765             : #endif
   69766             : 
   69767             : #ifndef ROSE_PEDANTIC_ALLOC
   69768             : #  define ROSE_PEDANTIC_ALLOC 0
   69769             : #endif
   69770             : 
   69771             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   69772             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   69773             : #endif
   69774             : 
   69775             : #if !defined(SGNODE__ALL_POOLS)
   69776             : #define SGNODE__ALL_POOLS
   69777             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   69778             : #endif
   69779             : 
   69780             : SgVariableDeclaration* SgVariableDeclaration::next_node = nullptr;
   69781             : std::vector<unsigned char*> SgVariableDeclaration::pools;
   69782             : 
   69783             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   69784             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   69785             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   69786             : // around this macro definition rather than each use).
   69787             : #ifndef ALLOC_MUTEX
   69788             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   69789             :         do {                                                                     \
   69790             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   69791             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   69792             :                 abort();                                                         \
   69793             :             }                                                                    \
   69794             :         } while (0);
   69795             : #endif
   69796             : 
   69797             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   69798             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   69799             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   69800             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   69801             : 
   69802             : /*! \brief New operator for SgVariableDeclaration.
   69803             : 
   69804             :    This new operator implements memory pools to provide most efficent 
   69805             :    use of the heap within construction of large ASTs.
   69806             : 
   69807             : \internal The new and delete operators use the lower level C malloc/free
   69808             :    function calls for performance and to make sure that mixing of malloc/free
   69809             :    and new/delete by the used can be caught more readily.  This may change
   69810             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   69811             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   69812             :    deallocate memory allocated using ROSE_MALLOC.
   69813             : */
   69814       34741 : void *SgVariableDeclaration::operator new ( size_t Size )
   69815             : {
   69816             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   69817             :      * returning or throwing an exception. */
   69818       34741 :     ALLOC_MUTEX(SgVariableDeclaration, lock);
   69819             : 
   69820             : #if ROSE_ALLOC_TRACE == 2
   69821             : //    printf("SgVariableDeclaration::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgVariableDeclaration::next_node);
   69822             : #endif
   69823             : 
   69824             : #if USE_CPP_NEW_DELETE_OPERATORS
   69825             :     void *mem = ROSE_MALLOC(Size);
   69826             :     ALLOC_MUTEX(SgVariableDeclaration, unlock);
   69827             :     return mem;
   69828             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   69829             : #if ROSE_PEDANTIC_ALLOC
   69830             :     ROSE_ASSERT(Size == sizeof(SgVariableDeclaration));
   69831             : #else
   69832       34741 :     if (Size != sizeof(SgVariableDeclaration)) {
   69833           0 :       void * object = ROSE_MALLOC(Size);
   69834           0 :       ALLOC_MUTEX(SgVariableDeclaration, unlock);
   69835             :       return object;
   69836             :     }
   69837             : #endif
   69838             : 
   69839       34741 :     if (SgVariableDeclaration::next_node == nullptr) {
   69840         317 :         SgVariableDeclaration * alloc = (SgVariableDeclaration*) ROSE_MALLOC ( SgVariableDeclaration::pool_size * sizeof(SgVariableDeclaration) );
   69841         317 :         ROSE_ASSERT(alloc != nullptr);
   69842             : 
   69843             : #if ROSE_ALLOC_TRACE == 2
   69844             : //        printf("SgVariableDeclaration::alloc\n  block[%zi] = [ %p , %p [\n", SgVariableDeclaration::pools.size(), alloc, alloc + SgVariableDeclaration::pool_size);
   69845             : #endif
   69846             : 
   69847             : #if ROSE_ALLOC_MEMSET == 1
   69848             : #elif ROSE_ALLOC_MEMSET == 2
   69849             :         memset(alloc, 0x00, SgVariableDeclaration::pool_size * sizeof(SgVariableDeclaration));
   69850             : #elif ROSE_ALLOC_MEMSET == 3
   69851             :         memset(alloc, 0xAA, SgVariableDeclaration::pool_size * sizeof(SgVariableDeclaration));
   69852             : #endif
   69853      634000 :         for (unsigned i=0; i < SgVariableDeclaration::pool_size-1; i++) {
   69854      633683 :           alloc[i].p_freepointer = &(alloc[i+1]);
   69855             :         }
   69856         317 :         alloc[SgVariableDeclaration::pool_size-1].p_freepointer = nullptr;
   69857             : 
   69858         317 :         SgVariableDeclaration::pools.push_back ( (unsigned char *) alloc );
   69859         317 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgVariableDeclaration::pool_size * sizeof(SgVariableDeclaration), V_SgVariableDeclaration ) );
   69860         317 :         SgVariableDeclaration::next_node = alloc;
   69861             :     }
   69862       34741 :     ROSE_ASSERT(SgVariableDeclaration::next_node != nullptr);
   69863             : 
   69864       34741 :     SgVariableDeclaration * object = SgVariableDeclaration::next_node;
   69865       34741 :     SgVariableDeclaration::next_node = (SgVariableDeclaration*)(object->p_freepointer);
   69866             : 
   69867             : #if ROSE_ALLOC_TRACE == 2
   69868             :     printf("SgVariableDeclaration::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgVariableDeclaration::next_node);
   69869             : #endif
   69870             : 
   69871       34741 :     SgNode * fp = object->p_freepointer;
   69872             : #if ROSE_ALLOC_MEMSET == 1
   69873             : #elif ROSE_ALLOC_MEMSET == 2
   69874             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgVariableDeclaration) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   69875             : #elif ROSE_ALLOC_MEMSET == 3
   69876             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgVariableDeclaration) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   69877             : #endif
   69878       34741 :     object->p_freepointer = fp;
   69879             : 
   69880             : #if ROSE_ALLOC_TRACE == 2
   69881             : //    printf("SgVariableDeclaration::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgVariableDeclaration::next_node);
   69882             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   69883             :     Rose::MemPool::snapshot(oss.str());
   69884             :     alloc_trace_cnt++;
   69885             : #endif
   69886             : 
   69887       34741 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   69888             : 
   69889       34741 :     ALLOC_MUTEX(SgVariableDeclaration, unlock);
   69890             : 
   69891             :     return object;
   69892             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   69893             : }
   69894             : 
   69895             : 
   69896             : 
   69897             : /*! \brief Delete operator for SgVariableDeclaration.
   69898             : 
   69899             :    This delete operator implements deallocation using memory pools to 
   69900             :    provide most efficent use of the heap within construction of large ASTs.
   69901             : 
   69902             : \internal The new and delete operators use the lower level C malloc/free
   69903             :    function calls for performance and to make sure that mixing of malloc/free
   69904             :    and new/delete by the used can be caught more readily.  This may change
   69905             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   69906             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   69907             :    deallocate memory allocated using ROSE_MALLOC.
   69908             : */
   69909        2589 : void SgVariableDeclaration::operator delete(void *Pointer, size_t Size)
   69910             : {
   69911             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   69912             :      * or throwing an exception. */
   69913        2589 :     ALLOC_MUTEX(SgVariableDeclaration, lock);
   69914             : 
   69915             : #if USE_CPP_NEW_DELETE_OPERATORS
   69916             :     ROSE_FREE(Pointer);
   69917             : #else
   69918             : #if ROSE_PEDANTIC_ALLOC
   69919             :     ROSE_ASSERT(Size == sizeof(SgVariableDeclaration));
   69920             : #else
   69921        2589 :     if (Size != sizeof(SgVariableDeclaration)) {
   69922           0 :       ROSE_FREE(Pointer);
   69923           0 :       ALLOC_MUTEX(SgVariableDeclaration, unlock);
   69924             :       return;
   69925             :     }
   69926             : #endif
   69927             : 
   69928        2589 :     SgVariableDeclaration * object = (SgVariableDeclaration*) Pointer;
   69929        2589 :     ROSE_ASSERT(object != nullptr);
   69930             : 
   69931             : #if ROSE_ALLOC_TRACE == 2
   69932             : //  printf("SgVariableDeclaration::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgVariableDeclaration::next_node);
   69933             :     printf("SgVariableDeclaration::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgVariableDeclaration::next_node);
   69934             : #endif
   69935             : 
   69936             : #if ROSE_PEDANTIC_ALLOC
   69937             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   69938             : #endif
   69939             : 
   69940             : #if ROSE_ALLOC_MEMSET == 1
   69941             : #elif ROSE_ALLOC_MEMSET == 2
   69942             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgVariableDeclaration) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   69943             : #elif ROSE_ALLOC_MEMSET == 3
   69944             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgVariableDeclaration) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   69945             : #endif
   69946             : 
   69947             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   69948             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   69949             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   69950             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   69951             : #else
   69952        2589 :     object->p_freepointer = SgVariableDeclaration::next_node;
   69953        2589 :     SgVariableDeclaration::next_node = object;
   69954             : #endif
   69955             : 
   69956             : #if ROSE_ALLOC_TRACE == 2
   69957             : //  printf("SgVariableDeclaration::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgVariableDeclaration::next_node);
   69958             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   69959             :     Rose::MemPool::snapshot(oss.str());
   69960             :     alloc_trace_cnt++;
   69961             : #endif
   69962             : 
   69963             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   69964             : 
   69965        2589 :     ALLOC_MUTEX(SgVariableDeclaration, unlock);
   69966             : }
   69967             : 
   69968             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   69969             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   69970             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   69971             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   69972             : // Also, note comment below from Robb (copied from the Common.code file).
   69973             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   69974             : //
   69975             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   69976             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   69977             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   69978             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   69979             : #if 0
   69980             : void SgVariableDeclaration::operator delete(void* pointer) { SgVariableDeclaration::operator delete (pointer, sizeof(SgVariableDeclaration)); };
   69981             : #endif
   69982             : /* #line 69983 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   69983             : 
   69984             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   69985             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   69986             : // obviously imply C++.
   69987             : 
   69988             : // This implements the support within ROSE for memory pools.  Memory pools
   69989             : // support the most condensed usage of memory within the construction of
   69990             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   69991             : // by a new operator written for each class.
   69992             : 
   69993             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   69994             :     // User wants multi-thread support and POSIX threads are available.
   69995             : #   include <pthread.h>
   69996             :     static pthread_mutex_t SgTemplateVariableDeclaration_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   69997             : #else
   69998             :      // Cause synchronization to be skipped.
   69999             : #    ifndef ALLOC_MUTEX
   70000             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   70001             : #    endif
   70002             : #    ifdef _REENTRANT
   70003             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   70004             : #       ifdef _MSC_VER
   70005             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   70006             : #       else
   70007             : #           warning "POSIX threads are not available; synchronization being skipped"
   70008             : #       endif
   70009             : #    endif
   70010             : #endif
   70011             : 
   70012             : #ifndef ROSE_ALLOC_TRACE
   70013             : #  define ROSE_ALLOC_TRACE 0
   70014             : #endif
   70015             : 
   70016             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   70017             : #define ROSE_ALLOC_TRACE_CNT
   70018             : #include "memory-pool-snapshot.h"
   70019             : unsigned long alloc_trace_cnt = 0;
   70020             : #endif
   70021             : 
   70022             : #if ROSE_ALLOC_TRACE
   70023             : const unsigned SgTemplateVariableDeclaration::pool_size = 5;
   70024             : #else
   70025             : const unsigned SgTemplateVariableDeclaration::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   70026             : #endif
   70027             : 
   70028             : #ifndef ROSE_ALLOC_MEMSET
   70029             : #  define ROSE_ALLOC_MEMSET 0
   70030             : #endif
   70031             : 
   70032             : #ifndef ROSE_PEDANTIC_ALLOC
   70033             : #  define ROSE_PEDANTIC_ALLOC 0
   70034             : #endif
   70035             : 
   70036             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   70037             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   70038             : #endif
   70039             : 
   70040             : #if !defined(SGNODE__ALL_POOLS)
   70041             : #define SGNODE__ALL_POOLS
   70042             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   70043             : #endif
   70044             : 
   70045             : SgTemplateVariableDeclaration* SgTemplateVariableDeclaration::next_node = nullptr;
   70046             : std::vector<unsigned char*> SgTemplateVariableDeclaration::pools;
   70047             : 
   70048             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   70049             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   70050             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   70051             : // around this macro definition rather than each use).
   70052             : #ifndef ALLOC_MUTEX
   70053             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   70054             :         do {                                                                     \
   70055             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   70056             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   70057             :                 abort();                                                         \
   70058             :             }                                                                    \
   70059             :         } while (0);
   70060             : #endif
   70061             : 
   70062             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   70063             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   70064             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   70065             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   70066             : 
   70067             : /*! \brief New operator for SgTemplateVariableDeclaration.
   70068             : 
   70069             :    This new operator implements memory pools to provide most efficent 
   70070             :    use of the heap within construction of large ASTs.
   70071             : 
   70072             : \internal The new and delete operators use the lower level C malloc/free
   70073             :    function calls for performance and to make sure that mixing of malloc/free
   70074             :    and new/delete by the used can be caught more readily.  This may change
   70075             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   70076             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   70077             :    deallocate memory allocated using ROSE_MALLOC.
   70078             : */
   70079        1011 : void *SgTemplateVariableDeclaration::operator new ( size_t Size )
   70080             : {
   70081             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   70082             :      * returning or throwing an exception. */
   70083        1011 :     ALLOC_MUTEX(SgTemplateVariableDeclaration, lock);
   70084             : 
   70085             : #if ROSE_ALLOC_TRACE == 2
   70086             : //    printf("SgTemplateVariableDeclaration::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgTemplateVariableDeclaration::next_node);
   70087             : #endif
   70088             : 
   70089             : #if USE_CPP_NEW_DELETE_OPERATORS
   70090             :     void *mem = ROSE_MALLOC(Size);
   70091             :     ALLOC_MUTEX(SgTemplateVariableDeclaration, unlock);
   70092             :     return mem;
   70093             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   70094             : #if ROSE_PEDANTIC_ALLOC
   70095             :     ROSE_ASSERT(Size == sizeof(SgTemplateVariableDeclaration));
   70096             : #else
   70097        1011 :     if (Size != sizeof(SgTemplateVariableDeclaration)) {
   70098           0 :       void * object = ROSE_MALLOC(Size);
   70099           0 :       ALLOC_MUTEX(SgTemplateVariableDeclaration, unlock);
   70100             :       return object;
   70101             :     }
   70102             : #endif
   70103             : 
   70104        1011 :     if (SgTemplateVariableDeclaration::next_node == nullptr) {
   70105          11 :         SgTemplateVariableDeclaration * alloc = (SgTemplateVariableDeclaration*) ROSE_MALLOC ( SgTemplateVariableDeclaration::pool_size * sizeof(SgTemplateVariableDeclaration) );
   70106          11 :         ROSE_ASSERT(alloc != nullptr);
   70107             : 
   70108             : #if ROSE_ALLOC_TRACE == 2
   70109             : //        printf("SgTemplateVariableDeclaration::alloc\n  block[%zi] = [ %p , %p [\n", SgTemplateVariableDeclaration::pools.size(), alloc, alloc + SgTemplateVariableDeclaration::pool_size);
   70110             : #endif
   70111             : 
   70112             : #if ROSE_ALLOC_MEMSET == 1
   70113             : #elif ROSE_ALLOC_MEMSET == 2
   70114             :         memset(alloc, 0x00, SgTemplateVariableDeclaration::pool_size * sizeof(SgTemplateVariableDeclaration));
   70115             : #elif ROSE_ALLOC_MEMSET == 3
   70116             :         memset(alloc, 0xAA, SgTemplateVariableDeclaration::pool_size * sizeof(SgTemplateVariableDeclaration));
   70117             : #endif
   70118       22000 :         for (unsigned i=0; i < SgTemplateVariableDeclaration::pool_size-1; i++) {
   70119       21989 :           alloc[i].p_freepointer = &(alloc[i+1]);
   70120             :         }
   70121          11 :         alloc[SgTemplateVariableDeclaration::pool_size-1].p_freepointer = nullptr;
   70122             : 
   70123          11 :         SgTemplateVariableDeclaration::pools.push_back ( (unsigned char *) alloc );
   70124          11 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgTemplateVariableDeclaration::pool_size * sizeof(SgTemplateVariableDeclaration), V_SgTemplateVariableDeclaration ) );
   70125          11 :         SgTemplateVariableDeclaration::next_node = alloc;
   70126             :     }
   70127        1011 :     ROSE_ASSERT(SgTemplateVariableDeclaration::next_node != nullptr);
   70128             : 
   70129        1011 :     SgTemplateVariableDeclaration * object = SgTemplateVariableDeclaration::next_node;
   70130        1011 :     SgTemplateVariableDeclaration::next_node = (SgTemplateVariableDeclaration*)(object->p_freepointer);
   70131             : 
   70132             : #if ROSE_ALLOC_TRACE == 2
   70133             :     printf("SgTemplateVariableDeclaration::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTemplateVariableDeclaration::next_node);
   70134             : #endif
   70135             : 
   70136        1011 :     SgNode * fp = object->p_freepointer;
   70137             : #if ROSE_ALLOC_MEMSET == 1
   70138             : #elif ROSE_ALLOC_MEMSET == 2
   70139             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgTemplateVariableDeclaration) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   70140             : #elif ROSE_ALLOC_MEMSET == 3
   70141             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgTemplateVariableDeclaration) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   70142             : #endif
   70143        1011 :     object->p_freepointer = fp;
   70144             : 
   70145             : #if ROSE_ALLOC_TRACE == 2
   70146             : //    printf("SgTemplateVariableDeclaration::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTemplateVariableDeclaration::next_node);
   70147             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   70148             :     Rose::MemPool::snapshot(oss.str());
   70149             :     alloc_trace_cnt++;
   70150             : #endif
   70151             : 
   70152        1011 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   70153             : 
   70154        1011 :     ALLOC_MUTEX(SgTemplateVariableDeclaration, unlock);
   70155             : 
   70156             :     return object;
   70157             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   70158             : }
   70159             : 
   70160             : 
   70161             : 
   70162             : /*! \brief Delete operator for SgTemplateVariableDeclaration.
   70163             : 
   70164             :    This delete operator implements deallocation using memory pools to 
   70165             :    provide most efficent use of the heap within construction of large ASTs.
   70166             : 
   70167             : \internal The new and delete operators use the lower level C malloc/free
   70168             :    function calls for performance and to make sure that mixing of malloc/free
   70169             :    and new/delete by the used can be caught more readily.  This may change
   70170             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   70171             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   70172             :    deallocate memory allocated using ROSE_MALLOC.
   70173             : */
   70174         204 : void SgTemplateVariableDeclaration::operator delete(void *Pointer, size_t Size)
   70175             : {
   70176             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   70177             :      * or throwing an exception. */
   70178         204 :     ALLOC_MUTEX(SgTemplateVariableDeclaration, lock);
   70179             : 
   70180             : #if USE_CPP_NEW_DELETE_OPERATORS
   70181             :     ROSE_FREE(Pointer);
   70182             : #else
   70183             : #if ROSE_PEDANTIC_ALLOC
   70184             :     ROSE_ASSERT(Size == sizeof(SgTemplateVariableDeclaration));
   70185             : #else
   70186         204 :     if (Size != sizeof(SgTemplateVariableDeclaration)) {
   70187           0 :       ROSE_FREE(Pointer);
   70188           0 :       ALLOC_MUTEX(SgTemplateVariableDeclaration, unlock);
   70189             :       return;
   70190             :     }
   70191             : #endif
   70192             : 
   70193         204 :     SgTemplateVariableDeclaration * object = (SgTemplateVariableDeclaration*) Pointer;
   70194         204 :     ROSE_ASSERT(object != nullptr);
   70195             : 
   70196             : #if ROSE_ALLOC_TRACE == 2
   70197             : //  printf("SgTemplateVariableDeclaration::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTemplateVariableDeclaration::next_node);
   70198             :     printf("SgTemplateVariableDeclaration::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTemplateVariableDeclaration::next_node);
   70199             : #endif
   70200             : 
   70201             : #if ROSE_PEDANTIC_ALLOC
   70202             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   70203             : #endif
   70204             : 
   70205             : #if ROSE_ALLOC_MEMSET == 1
   70206             : #elif ROSE_ALLOC_MEMSET == 2
   70207             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgTemplateVariableDeclaration) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   70208             : #elif ROSE_ALLOC_MEMSET == 3
   70209             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgTemplateVariableDeclaration) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   70210             : #endif
   70211             : 
   70212             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   70213             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   70214             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   70215             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   70216             : #else
   70217         204 :     object->p_freepointer = SgTemplateVariableDeclaration::next_node;
   70218         204 :     SgTemplateVariableDeclaration::next_node = object;
   70219             : #endif
   70220             : 
   70221             : #if ROSE_ALLOC_TRACE == 2
   70222             : //  printf("SgTemplateVariableDeclaration::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTemplateVariableDeclaration::next_node);
   70223             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   70224             :     Rose::MemPool::snapshot(oss.str());
   70225             :     alloc_trace_cnt++;
   70226             : #endif
   70227             : 
   70228             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   70229             : 
   70230         204 :     ALLOC_MUTEX(SgTemplateVariableDeclaration, unlock);
   70231             : }
   70232             : 
   70233             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   70234             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   70235             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   70236             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   70237             : // Also, note comment below from Robb (copied from the Common.code file).
   70238             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   70239             : //
   70240             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   70241             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   70242             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   70243             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   70244             : #if 0
   70245             : void SgTemplateVariableDeclaration::operator delete(void* pointer) { SgTemplateVariableDeclaration::operator delete (pointer, sizeof(SgTemplateVariableDeclaration)); };
   70246             : #endif
   70247             : /* #line 70248 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   70248             : 
   70249             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   70250             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   70251             : // obviously imply C++.
   70252             : 
   70253             : // This implements the support within ROSE for memory pools.  Memory pools
   70254             : // support the most condensed usage of memory within the construction of
   70255             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   70256             : // by a new operator written for each class.
   70257             : 
   70258             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   70259             :     // User wants multi-thread support and POSIX threads are available.
   70260             : #   include <pthread.h>
   70261             :     static pthread_mutex_t SgVariableDefinition_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   70262             : #else
   70263             :      // Cause synchronization to be skipped.
   70264             : #    ifndef ALLOC_MUTEX
   70265             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   70266             : #    endif
   70267             : #    ifdef _REENTRANT
   70268             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   70269             : #       ifdef _MSC_VER
   70270             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   70271             : #       else
   70272             : #           warning "POSIX threads are not available; synchronization being skipped"
   70273             : #       endif
   70274             : #    endif
   70275             : #endif
   70276             : 
   70277             : #ifndef ROSE_ALLOC_TRACE
   70278             : #  define ROSE_ALLOC_TRACE 0
   70279             : #endif
   70280             : 
   70281             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   70282             : #define ROSE_ALLOC_TRACE_CNT
   70283             : #include "memory-pool-snapshot.h"
   70284             : unsigned long alloc_trace_cnt = 0;
   70285             : #endif
   70286             : 
   70287             : #if ROSE_ALLOC_TRACE
   70288             : const unsigned SgVariableDefinition::pool_size = 5;
   70289             : #else
   70290             : const unsigned SgVariableDefinition::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   70291             : #endif
   70292             : 
   70293             : #ifndef ROSE_ALLOC_MEMSET
   70294             : #  define ROSE_ALLOC_MEMSET 0
   70295             : #endif
   70296             : 
   70297             : #ifndef ROSE_PEDANTIC_ALLOC
   70298             : #  define ROSE_PEDANTIC_ALLOC 0
   70299             : #endif
   70300             : 
   70301             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   70302             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   70303             : #endif
   70304             : 
   70305             : #if !defined(SGNODE__ALL_POOLS)
   70306             : #define SGNODE__ALL_POOLS
   70307             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   70308             : #endif
   70309             : 
   70310             : SgVariableDefinition* SgVariableDefinition::next_node = nullptr;
   70311             : std::vector<unsigned char*> SgVariableDefinition::pools;
   70312             : 
   70313             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   70314             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   70315             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   70316             : // around this macro definition rather than each use).
   70317             : #ifndef ALLOC_MUTEX
   70318             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   70319             :         do {                                                                     \
   70320             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   70321             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   70322             :                 abort();                                                         \
   70323             :             }                                                                    \
   70324             :         } while (0);
   70325             : #endif
   70326             : 
   70327             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   70328             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   70329             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   70330             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   70331             : 
   70332             : /*! \brief New operator for SgVariableDefinition.
   70333             : 
   70334             :    This new operator implements memory pools to provide most efficent 
   70335             :    use of the heap within construction of large ASTs.
   70336             : 
   70337             : \internal The new and delete operators use the lower level C malloc/free
   70338             :    function calls for performance and to make sure that mixing of malloc/free
   70339             :    and new/delete by the used can be caught more readily.  This may change
   70340             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   70341             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   70342             :    deallocate memory allocated using ROSE_MALLOC.
   70343             : */
   70344       35782 : void *SgVariableDefinition::operator new ( size_t Size )
   70345             : {
   70346             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   70347             :      * returning or throwing an exception. */
   70348       35782 :     ALLOC_MUTEX(SgVariableDefinition, lock);
   70349             : 
   70350             : #if ROSE_ALLOC_TRACE == 2
   70351             : //    printf("SgVariableDefinition::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgVariableDefinition::next_node);
   70352             : #endif
   70353             : 
   70354             : #if USE_CPP_NEW_DELETE_OPERATORS
   70355             :     void *mem = ROSE_MALLOC(Size);
   70356             :     ALLOC_MUTEX(SgVariableDefinition, unlock);
   70357             :     return mem;
   70358             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   70359             : #if ROSE_PEDANTIC_ALLOC
   70360             :     ROSE_ASSERT(Size == sizeof(SgVariableDefinition));
   70361             : #else
   70362       35782 :     if (Size != sizeof(SgVariableDefinition)) {
   70363           0 :       void * object = ROSE_MALLOC(Size);
   70364           0 :       ALLOC_MUTEX(SgVariableDefinition, unlock);
   70365             :       return object;
   70366             :     }
   70367             : #endif
   70368             : 
   70369       35782 :     if (SgVariableDefinition::next_node == nullptr) {
   70370         318 :         SgVariableDefinition * alloc = (SgVariableDefinition*) ROSE_MALLOC ( SgVariableDefinition::pool_size * sizeof(SgVariableDefinition) );
   70371         318 :         ROSE_ASSERT(alloc != nullptr);
   70372             : 
   70373             : #if ROSE_ALLOC_TRACE == 2
   70374             : //        printf("SgVariableDefinition::alloc\n  block[%zi] = [ %p , %p [\n", SgVariableDefinition::pools.size(), alloc, alloc + SgVariableDefinition::pool_size);
   70375             : #endif
   70376             : 
   70377             : #if ROSE_ALLOC_MEMSET == 1
   70378             : #elif ROSE_ALLOC_MEMSET == 2
   70379             :         memset(alloc, 0x00, SgVariableDefinition::pool_size * sizeof(SgVariableDefinition));
   70380             : #elif ROSE_ALLOC_MEMSET == 3
   70381             :         memset(alloc, 0xAA, SgVariableDefinition::pool_size * sizeof(SgVariableDefinition));
   70382             : #endif
   70383      636000 :         for (unsigned i=0; i < SgVariableDefinition::pool_size-1; i++) {
   70384      635682 :           alloc[i].p_freepointer = &(alloc[i+1]);
   70385             :         }
   70386         318 :         alloc[SgVariableDefinition::pool_size-1].p_freepointer = nullptr;
   70387             : 
   70388         318 :         SgVariableDefinition::pools.push_back ( (unsigned char *) alloc );
   70389         318 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgVariableDefinition::pool_size * sizeof(SgVariableDefinition), V_SgVariableDefinition ) );
   70390         318 :         SgVariableDefinition::next_node = alloc;
   70391             :     }
   70392       35782 :     ROSE_ASSERT(SgVariableDefinition::next_node != nullptr);
   70393             : 
   70394       35782 :     SgVariableDefinition * object = SgVariableDefinition::next_node;
   70395       35782 :     SgVariableDefinition::next_node = (SgVariableDefinition*)(object->p_freepointer);
   70396             : 
   70397             : #if ROSE_ALLOC_TRACE == 2
   70398             :     printf("SgVariableDefinition::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgVariableDefinition::next_node);
   70399             : #endif
   70400             : 
   70401       35782 :     SgNode * fp = object->p_freepointer;
   70402             : #if ROSE_ALLOC_MEMSET == 1
   70403             : #elif ROSE_ALLOC_MEMSET == 2
   70404             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgVariableDefinition) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   70405             : #elif ROSE_ALLOC_MEMSET == 3
   70406             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgVariableDefinition) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   70407             : #endif
   70408       35782 :     object->p_freepointer = fp;
   70409             : 
   70410             : #if ROSE_ALLOC_TRACE == 2
   70411             : //    printf("SgVariableDefinition::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgVariableDefinition::next_node);
   70412             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   70413             :     Rose::MemPool::snapshot(oss.str());
   70414             :     alloc_trace_cnt++;
   70415             : #endif
   70416             : 
   70417       35782 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   70418             : 
   70419       35782 :     ALLOC_MUTEX(SgVariableDefinition, unlock);
   70420             : 
   70421             :     return object;
   70422             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   70423             : }
   70424             : 
   70425             : 
   70426             : 
   70427             : /*! \brief Delete operator for SgVariableDefinition.
   70428             : 
   70429             :    This delete operator implements deallocation using memory pools to 
   70430             :    provide most efficent use of the heap within construction of large ASTs.
   70431             : 
   70432             : \internal The new and delete operators use the lower level C malloc/free
   70433             :    function calls for performance and to make sure that mixing of malloc/free
   70434             :    and new/delete by the used can be caught more readily.  This may change
   70435             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   70436             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   70437             :    deallocate memory allocated using ROSE_MALLOC.
   70438             : */
   70439        2793 : void SgVariableDefinition::operator delete(void *Pointer, size_t Size)
   70440             : {
   70441             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   70442             :      * or throwing an exception. */
   70443        2793 :     ALLOC_MUTEX(SgVariableDefinition, lock);
   70444             : 
   70445             : #if USE_CPP_NEW_DELETE_OPERATORS
   70446             :     ROSE_FREE(Pointer);
   70447             : #else
   70448             : #if ROSE_PEDANTIC_ALLOC
   70449             :     ROSE_ASSERT(Size == sizeof(SgVariableDefinition));
   70450             : #else
   70451        2793 :     if (Size != sizeof(SgVariableDefinition)) {
   70452           0 :       ROSE_FREE(Pointer);
   70453           0 :       ALLOC_MUTEX(SgVariableDefinition, unlock);
   70454             :       return;
   70455             :     }
   70456             : #endif
   70457             : 
   70458        2793 :     SgVariableDefinition * object = (SgVariableDefinition*) Pointer;
   70459        2793 :     ROSE_ASSERT(object != nullptr);
   70460             : 
   70461             : #if ROSE_ALLOC_TRACE == 2
   70462             : //  printf("SgVariableDefinition::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgVariableDefinition::next_node);
   70463             :     printf("SgVariableDefinition::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgVariableDefinition::next_node);
   70464             : #endif
   70465             : 
   70466             : #if ROSE_PEDANTIC_ALLOC
   70467             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   70468             : #endif
   70469             : 
   70470             : #if ROSE_ALLOC_MEMSET == 1
   70471             : #elif ROSE_ALLOC_MEMSET == 2
   70472             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgVariableDefinition) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   70473             : #elif ROSE_ALLOC_MEMSET == 3
   70474             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgVariableDefinition) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   70475             : #endif
   70476             : 
   70477             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   70478             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   70479             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   70480             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   70481             : #else
   70482        2793 :     object->p_freepointer = SgVariableDefinition::next_node;
   70483        2793 :     SgVariableDefinition::next_node = object;
   70484             : #endif
   70485             : 
   70486             : #if ROSE_ALLOC_TRACE == 2
   70487             : //  printf("SgVariableDefinition::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgVariableDefinition::next_node);
   70488             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   70489             :     Rose::MemPool::snapshot(oss.str());
   70490             :     alloc_trace_cnt++;
   70491             : #endif
   70492             : 
   70493             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   70494             : 
   70495        2793 :     ALLOC_MUTEX(SgVariableDefinition, unlock);
   70496             : }
   70497             : 
   70498             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   70499             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   70500             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   70501             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   70502             : // Also, note comment below from Robb (copied from the Common.code file).
   70503             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   70504             : //
   70505             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   70506             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   70507             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   70508             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   70509             : #if 0
   70510             : void SgVariableDefinition::operator delete(void* pointer) { SgVariableDefinition::operator delete (pointer, sizeof(SgVariableDefinition)); };
   70511             : #endif
   70512             : /* #line 70513 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   70513             : 
   70514             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   70515             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   70516             : // obviously imply C++.
   70517             : 
   70518             : // This implements the support within ROSE for memory pools.  Memory pools
   70519             : // support the most condensed usage of memory within the construction of
   70520             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   70521             : // by a new operator written for each class.
   70522             : 
   70523             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   70524             :     // User wants multi-thread support and POSIX threads are available.
   70525             : #   include <pthread.h>
   70526             :     static pthread_mutex_t SgClinkageDeclarationStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   70527             : #else
   70528             :      // Cause synchronization to be skipped.
   70529             : #    ifndef ALLOC_MUTEX
   70530             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   70531             : #    endif
   70532             : #    ifdef _REENTRANT
   70533             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   70534             : #       ifdef _MSC_VER
   70535             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   70536             : #       else
   70537             : #           warning "POSIX threads are not available; synchronization being skipped"
   70538             : #       endif
   70539             : #    endif
   70540             : #endif
   70541             : 
   70542             : #ifndef ROSE_ALLOC_TRACE
   70543             : #  define ROSE_ALLOC_TRACE 0
   70544             : #endif
   70545             : 
   70546             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   70547             : #define ROSE_ALLOC_TRACE_CNT
   70548             : #include "memory-pool-snapshot.h"
   70549             : unsigned long alloc_trace_cnt = 0;
   70550             : #endif
   70551             : 
   70552             : #if ROSE_ALLOC_TRACE
   70553             : const unsigned SgClinkageDeclarationStatement::pool_size = 5;
   70554             : #else
   70555             : const unsigned SgClinkageDeclarationStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   70556             : #endif
   70557             : 
   70558             : #ifndef ROSE_ALLOC_MEMSET
   70559             : #  define ROSE_ALLOC_MEMSET 0
   70560             : #endif
   70561             : 
   70562             : #ifndef ROSE_PEDANTIC_ALLOC
   70563             : #  define ROSE_PEDANTIC_ALLOC 0
   70564             : #endif
   70565             : 
   70566             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   70567             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   70568             : #endif
   70569             : 
   70570             : #if !defined(SGNODE__ALL_POOLS)
   70571             : #define SGNODE__ALL_POOLS
   70572             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   70573             : #endif
   70574             : 
   70575             : SgClinkageDeclarationStatement* SgClinkageDeclarationStatement::next_node = nullptr;
   70576             : std::vector<unsigned char*> SgClinkageDeclarationStatement::pools;
   70577             : 
   70578             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   70579             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   70580             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   70581             : // around this macro definition rather than each use).
   70582             : #ifndef ALLOC_MUTEX
   70583             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   70584             :         do {                                                                     \
   70585             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   70586             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   70587             :                 abort();                                                         \
   70588             :             }                                                                    \
   70589             :         } while (0);
   70590             : #endif
   70591             : 
   70592             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   70593             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   70594             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   70595             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   70596             : 
   70597             : /*! \brief New operator for SgClinkageDeclarationStatement.
   70598             : 
   70599             :    This new operator implements memory pools to provide most efficent 
   70600             :    use of the heap within construction of large ASTs.
   70601             : 
   70602             : \internal The new and delete operators use the lower level C malloc/free
   70603             :    function calls for performance and to make sure that mixing of malloc/free
   70604             :    and new/delete by the used can be caught more readily.  This may change
   70605             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   70606             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   70607             :    deallocate memory allocated using ROSE_MALLOC.
   70608             : */
   70609           0 : void *SgClinkageDeclarationStatement::operator new ( size_t Size )
   70610             : {
   70611             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   70612             :      * returning or throwing an exception. */
   70613           0 :     ALLOC_MUTEX(SgClinkageDeclarationStatement, lock);
   70614             : 
   70615             : #if ROSE_ALLOC_TRACE == 2
   70616             : //    printf("SgClinkageDeclarationStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgClinkageDeclarationStatement::next_node);
   70617             : #endif
   70618             : 
   70619             : #if USE_CPP_NEW_DELETE_OPERATORS
   70620             :     void *mem = ROSE_MALLOC(Size);
   70621             :     ALLOC_MUTEX(SgClinkageDeclarationStatement, unlock);
   70622             :     return mem;
   70623             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   70624             : #if ROSE_PEDANTIC_ALLOC
   70625             :     ROSE_ASSERT(Size == sizeof(SgClinkageDeclarationStatement));
   70626             : #else
   70627           0 :     if (Size != sizeof(SgClinkageDeclarationStatement)) {
   70628           0 :       void * object = ROSE_MALLOC(Size);
   70629           0 :       ALLOC_MUTEX(SgClinkageDeclarationStatement, unlock);
   70630             :       return object;
   70631             :     }
   70632             : #endif
   70633             : 
   70634           0 :     if (SgClinkageDeclarationStatement::next_node == nullptr) {
   70635           0 :         SgClinkageDeclarationStatement * alloc = (SgClinkageDeclarationStatement*) ROSE_MALLOC ( SgClinkageDeclarationStatement::pool_size * sizeof(SgClinkageDeclarationStatement) );
   70636           0 :         ROSE_ASSERT(alloc != nullptr);
   70637             : 
   70638             : #if ROSE_ALLOC_TRACE == 2
   70639             : //        printf("SgClinkageDeclarationStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgClinkageDeclarationStatement::pools.size(), alloc, alloc + SgClinkageDeclarationStatement::pool_size);
   70640             : #endif
   70641             : 
   70642             : #if ROSE_ALLOC_MEMSET == 1
   70643             : #elif ROSE_ALLOC_MEMSET == 2
   70644             :         memset(alloc, 0x00, SgClinkageDeclarationStatement::pool_size * sizeof(SgClinkageDeclarationStatement));
   70645             : #elif ROSE_ALLOC_MEMSET == 3
   70646             :         memset(alloc, 0xAA, SgClinkageDeclarationStatement::pool_size * sizeof(SgClinkageDeclarationStatement));
   70647             : #endif
   70648           0 :         for (unsigned i=0; i < SgClinkageDeclarationStatement::pool_size-1; i++) {
   70649           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
   70650             :         }
   70651           0 :         alloc[SgClinkageDeclarationStatement::pool_size-1].p_freepointer = nullptr;
   70652             : 
   70653           0 :         SgClinkageDeclarationStatement::pools.push_back ( (unsigned char *) alloc );
   70654           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgClinkageDeclarationStatement::pool_size * sizeof(SgClinkageDeclarationStatement), V_SgClinkageDeclarationStatement ) );
   70655           0 :         SgClinkageDeclarationStatement::next_node = alloc;
   70656             :     }
   70657           0 :     ROSE_ASSERT(SgClinkageDeclarationStatement::next_node != nullptr);
   70658             : 
   70659           0 :     SgClinkageDeclarationStatement * object = SgClinkageDeclarationStatement::next_node;
   70660           0 :     SgClinkageDeclarationStatement::next_node = (SgClinkageDeclarationStatement*)(object->p_freepointer);
   70661             : 
   70662             : #if ROSE_ALLOC_TRACE == 2
   70663             :     printf("SgClinkageDeclarationStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgClinkageDeclarationStatement::next_node);
   70664             : #endif
   70665             : 
   70666           0 :     SgNode * fp = object->p_freepointer;
   70667             : #if ROSE_ALLOC_MEMSET == 1
   70668             : #elif ROSE_ALLOC_MEMSET == 2
   70669             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgClinkageDeclarationStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   70670             : #elif ROSE_ALLOC_MEMSET == 3
   70671             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgClinkageDeclarationStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   70672             : #endif
   70673           0 :     object->p_freepointer = fp;
   70674             : 
   70675             : #if ROSE_ALLOC_TRACE == 2
   70676             : //    printf("SgClinkageDeclarationStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgClinkageDeclarationStatement::next_node);
   70677             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   70678             :     Rose::MemPool::snapshot(oss.str());
   70679             :     alloc_trace_cnt++;
   70680             : #endif
   70681             : 
   70682           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   70683             : 
   70684           0 :     ALLOC_MUTEX(SgClinkageDeclarationStatement, unlock);
   70685             : 
   70686             :     return object;
   70687             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   70688             : }
   70689             : 
   70690             : 
   70691             : 
   70692             : /*! \brief Delete operator for SgClinkageDeclarationStatement.
   70693             : 
   70694             :    This delete operator implements deallocation using memory pools to 
   70695             :    provide most efficent use of the heap within construction of large ASTs.
   70696             : 
   70697             : \internal The new and delete operators use the lower level C malloc/free
   70698             :    function calls for performance and to make sure that mixing of malloc/free
   70699             :    and new/delete by the used can be caught more readily.  This may change
   70700             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   70701             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   70702             :    deallocate memory allocated using ROSE_MALLOC.
   70703             : */
   70704           0 : void SgClinkageDeclarationStatement::operator delete(void *Pointer, size_t Size)
   70705             : {
   70706             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   70707             :      * or throwing an exception. */
   70708           0 :     ALLOC_MUTEX(SgClinkageDeclarationStatement, lock);
   70709             : 
   70710             : #if USE_CPP_NEW_DELETE_OPERATORS
   70711             :     ROSE_FREE(Pointer);
   70712             : #else
   70713             : #if ROSE_PEDANTIC_ALLOC
   70714             :     ROSE_ASSERT(Size == sizeof(SgClinkageDeclarationStatement));
   70715             : #else
   70716           0 :     if (Size != sizeof(SgClinkageDeclarationStatement)) {
   70717           0 :       ROSE_FREE(Pointer);
   70718           0 :       ALLOC_MUTEX(SgClinkageDeclarationStatement, unlock);
   70719             :       return;
   70720             :     }
   70721             : #endif
   70722             : 
   70723           0 :     SgClinkageDeclarationStatement * object = (SgClinkageDeclarationStatement*) Pointer;
   70724           0 :     ROSE_ASSERT(object != nullptr);
   70725             : 
   70726             : #if ROSE_ALLOC_TRACE == 2
   70727             : //  printf("SgClinkageDeclarationStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgClinkageDeclarationStatement::next_node);
   70728             :     printf("SgClinkageDeclarationStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgClinkageDeclarationStatement::next_node);
   70729             : #endif
   70730             : 
   70731             : #if ROSE_PEDANTIC_ALLOC
   70732             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   70733             : #endif
   70734             : 
   70735             : #if ROSE_ALLOC_MEMSET == 1
   70736             : #elif ROSE_ALLOC_MEMSET == 2
   70737             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgClinkageDeclarationStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   70738             : #elif ROSE_ALLOC_MEMSET == 3
   70739             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgClinkageDeclarationStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   70740             : #endif
   70741             : 
   70742             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   70743             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   70744             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   70745             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   70746             : #else
   70747           0 :     object->p_freepointer = SgClinkageDeclarationStatement::next_node;
   70748           0 :     SgClinkageDeclarationStatement::next_node = object;
   70749             : #endif
   70750             : 
   70751             : #if ROSE_ALLOC_TRACE == 2
   70752             : //  printf("SgClinkageDeclarationStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgClinkageDeclarationStatement::next_node);
   70753             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   70754             :     Rose::MemPool::snapshot(oss.str());
   70755             :     alloc_trace_cnt++;
   70756             : #endif
   70757             : 
   70758             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   70759             : 
   70760           0 :     ALLOC_MUTEX(SgClinkageDeclarationStatement, unlock);
   70761             : }
   70762             : 
   70763             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   70764             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   70765             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   70766             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   70767             : // Also, note comment below from Robb (copied from the Common.code file).
   70768             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   70769             : //
   70770             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   70771             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   70772             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   70773             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   70774             : #if 0
   70775             : void SgClinkageDeclarationStatement::operator delete(void* pointer) { SgClinkageDeclarationStatement::operator delete (pointer, sizeof(SgClinkageDeclarationStatement)); };
   70776             : #endif
   70777             : /* #line 70778 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   70778             : 
   70779             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   70780             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   70781             : // obviously imply C++.
   70782             : 
   70783             : // This implements the support within ROSE for memory pools.  Memory pools
   70784             : // support the most condensed usage of memory within the construction of
   70785             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   70786             : // by a new operator written for each class.
   70787             : 
   70788             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   70789             :     // User wants multi-thread support and POSIX threads are available.
   70790             : #   include <pthread.h>
   70791             :     static pthread_mutex_t SgClinkageStartStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   70792             : #else
   70793             :      // Cause synchronization to be skipped.
   70794             : #    ifndef ALLOC_MUTEX
   70795             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   70796             : #    endif
   70797             : #    ifdef _REENTRANT
   70798             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   70799             : #       ifdef _MSC_VER
   70800             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   70801             : #       else
   70802             : #           warning "POSIX threads are not available; synchronization being skipped"
   70803             : #       endif
   70804             : #    endif
   70805             : #endif
   70806             : 
   70807             : #ifndef ROSE_ALLOC_TRACE
   70808             : #  define ROSE_ALLOC_TRACE 0
   70809             : #endif
   70810             : 
   70811             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   70812             : #define ROSE_ALLOC_TRACE_CNT
   70813             : #include "memory-pool-snapshot.h"
   70814             : unsigned long alloc_trace_cnt = 0;
   70815             : #endif
   70816             : 
   70817             : #if ROSE_ALLOC_TRACE
   70818             : const unsigned SgClinkageStartStatement::pool_size = 5;
   70819             : #else
   70820             : const unsigned SgClinkageStartStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   70821             : #endif
   70822             : 
   70823             : #ifndef ROSE_ALLOC_MEMSET
   70824             : #  define ROSE_ALLOC_MEMSET 0
   70825             : #endif
   70826             : 
   70827             : #ifndef ROSE_PEDANTIC_ALLOC
   70828             : #  define ROSE_PEDANTIC_ALLOC 0
   70829             : #endif
   70830             : 
   70831             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   70832             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   70833             : #endif
   70834             : 
   70835             : #if !defined(SGNODE__ALL_POOLS)
   70836             : #define SGNODE__ALL_POOLS
   70837             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   70838             : #endif
   70839             : 
   70840             : SgClinkageStartStatement* SgClinkageStartStatement::next_node = nullptr;
   70841             : std::vector<unsigned char*> SgClinkageStartStatement::pools;
   70842             : 
   70843             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   70844             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   70845             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   70846             : // around this macro definition rather than each use).
   70847             : #ifndef ALLOC_MUTEX
   70848             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   70849             :         do {                                                                     \
   70850             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   70851             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   70852             :                 abort();                                                         \
   70853             :             }                                                                    \
   70854             :         } while (0);
   70855             : #endif
   70856             : 
   70857             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   70858             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   70859             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   70860             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   70861             : 
   70862             : /*! \brief New operator for SgClinkageStartStatement.
   70863             : 
   70864             :    This new operator implements memory pools to provide most efficent 
   70865             :    use of the heap within construction of large ASTs.
   70866             : 
   70867             : \internal The new and delete operators use the lower level C malloc/free
   70868             :    function calls for performance and to make sure that mixing of malloc/free
   70869             :    and new/delete by the used can be caught more readily.  This may change
   70870             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   70871             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   70872             :    deallocate memory allocated using ROSE_MALLOC.
   70873             : */
   70874           0 : void *SgClinkageStartStatement::operator new ( size_t Size )
   70875             : {
   70876             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   70877             :      * returning or throwing an exception. */
   70878           0 :     ALLOC_MUTEX(SgClinkageStartStatement, lock);
   70879             : 
   70880             : #if ROSE_ALLOC_TRACE == 2
   70881             : //    printf("SgClinkageStartStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgClinkageStartStatement::next_node);
   70882             : #endif
   70883             : 
   70884             : #if USE_CPP_NEW_DELETE_OPERATORS
   70885             :     void *mem = ROSE_MALLOC(Size);
   70886             :     ALLOC_MUTEX(SgClinkageStartStatement, unlock);
   70887             :     return mem;
   70888             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   70889             : #if ROSE_PEDANTIC_ALLOC
   70890             :     ROSE_ASSERT(Size == sizeof(SgClinkageStartStatement));
   70891             : #else
   70892           0 :     if (Size != sizeof(SgClinkageStartStatement)) {
   70893           0 :       void * object = ROSE_MALLOC(Size);
   70894           0 :       ALLOC_MUTEX(SgClinkageStartStatement, unlock);
   70895             :       return object;
   70896             :     }
   70897             : #endif
   70898             : 
   70899           0 :     if (SgClinkageStartStatement::next_node == nullptr) {
   70900           0 :         SgClinkageStartStatement * alloc = (SgClinkageStartStatement*) ROSE_MALLOC ( SgClinkageStartStatement::pool_size * sizeof(SgClinkageStartStatement) );
   70901           0 :         ROSE_ASSERT(alloc != nullptr);
   70902             : 
   70903             : #if ROSE_ALLOC_TRACE == 2
   70904             : //        printf("SgClinkageStartStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgClinkageStartStatement::pools.size(), alloc, alloc + SgClinkageStartStatement::pool_size);
   70905             : #endif
   70906             : 
   70907             : #if ROSE_ALLOC_MEMSET == 1
   70908             : #elif ROSE_ALLOC_MEMSET == 2
   70909             :         memset(alloc, 0x00, SgClinkageStartStatement::pool_size * sizeof(SgClinkageStartStatement));
   70910             : #elif ROSE_ALLOC_MEMSET == 3
   70911             :         memset(alloc, 0xAA, SgClinkageStartStatement::pool_size * sizeof(SgClinkageStartStatement));
   70912             : #endif
   70913           0 :         for (unsigned i=0; i < SgClinkageStartStatement::pool_size-1; i++) {
   70914           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
   70915             :         }
   70916           0 :         alloc[SgClinkageStartStatement::pool_size-1].p_freepointer = nullptr;
   70917             : 
   70918           0 :         SgClinkageStartStatement::pools.push_back ( (unsigned char *) alloc );
   70919           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgClinkageStartStatement::pool_size * sizeof(SgClinkageStartStatement), V_SgClinkageStartStatement ) );
   70920           0 :         SgClinkageStartStatement::next_node = alloc;
   70921             :     }
   70922           0 :     ROSE_ASSERT(SgClinkageStartStatement::next_node != nullptr);
   70923             : 
   70924           0 :     SgClinkageStartStatement * object = SgClinkageStartStatement::next_node;
   70925           0 :     SgClinkageStartStatement::next_node = (SgClinkageStartStatement*)(object->p_freepointer);
   70926             : 
   70927             : #if ROSE_ALLOC_TRACE == 2
   70928             :     printf("SgClinkageStartStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgClinkageStartStatement::next_node);
   70929             : #endif
   70930             : 
   70931           0 :     SgNode * fp = object->p_freepointer;
   70932             : #if ROSE_ALLOC_MEMSET == 1
   70933             : #elif ROSE_ALLOC_MEMSET == 2
   70934             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgClinkageStartStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   70935             : #elif ROSE_ALLOC_MEMSET == 3
   70936             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgClinkageStartStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   70937             : #endif
   70938           0 :     object->p_freepointer = fp;
   70939             : 
   70940             : #if ROSE_ALLOC_TRACE == 2
   70941             : //    printf("SgClinkageStartStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgClinkageStartStatement::next_node);
   70942             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   70943             :     Rose::MemPool::snapshot(oss.str());
   70944             :     alloc_trace_cnt++;
   70945             : #endif
   70946             : 
   70947           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   70948             : 
   70949           0 :     ALLOC_MUTEX(SgClinkageStartStatement, unlock);
   70950             : 
   70951             :     return object;
   70952             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   70953             : }
   70954             : 
   70955             : 
   70956             : 
   70957             : /*! \brief Delete operator for SgClinkageStartStatement.
   70958             : 
   70959             :    This delete operator implements deallocation using memory pools to 
   70960             :    provide most efficent use of the heap within construction of large ASTs.
   70961             : 
   70962             : \internal The new and delete operators use the lower level C malloc/free
   70963             :    function calls for performance and to make sure that mixing of malloc/free
   70964             :    and new/delete by the used can be caught more readily.  This may change
   70965             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   70966             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   70967             :    deallocate memory allocated using ROSE_MALLOC.
   70968             : */
   70969           0 : void SgClinkageStartStatement::operator delete(void *Pointer, size_t Size)
   70970             : {
   70971             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   70972             :      * or throwing an exception. */
   70973           0 :     ALLOC_MUTEX(SgClinkageStartStatement, lock);
   70974             : 
   70975             : #if USE_CPP_NEW_DELETE_OPERATORS
   70976             :     ROSE_FREE(Pointer);
   70977             : #else
   70978             : #if ROSE_PEDANTIC_ALLOC
   70979             :     ROSE_ASSERT(Size == sizeof(SgClinkageStartStatement));
   70980             : #else
   70981           0 :     if (Size != sizeof(SgClinkageStartStatement)) {
   70982           0 :       ROSE_FREE(Pointer);
   70983           0 :       ALLOC_MUTEX(SgClinkageStartStatement, unlock);
   70984             :       return;
   70985             :     }
   70986             : #endif
   70987             : 
   70988           0 :     SgClinkageStartStatement * object = (SgClinkageStartStatement*) Pointer;
   70989           0 :     ROSE_ASSERT(object != nullptr);
   70990             : 
   70991             : #if ROSE_ALLOC_TRACE == 2
   70992             : //  printf("SgClinkageStartStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgClinkageStartStatement::next_node);
   70993             :     printf("SgClinkageStartStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgClinkageStartStatement::next_node);
   70994             : #endif
   70995             : 
   70996             : #if ROSE_PEDANTIC_ALLOC
   70997             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   70998             : #endif
   70999             : 
   71000             : #if ROSE_ALLOC_MEMSET == 1
   71001             : #elif ROSE_ALLOC_MEMSET == 2
   71002             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgClinkageStartStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   71003             : #elif ROSE_ALLOC_MEMSET == 3
   71004             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgClinkageStartStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   71005             : #endif
   71006             : 
   71007             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   71008             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   71009             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   71010             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   71011             : #else
   71012           0 :     object->p_freepointer = SgClinkageStartStatement::next_node;
   71013           0 :     SgClinkageStartStatement::next_node = object;
   71014             : #endif
   71015             : 
   71016             : #if ROSE_ALLOC_TRACE == 2
   71017             : //  printf("SgClinkageStartStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgClinkageStartStatement::next_node);
   71018             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   71019             :     Rose::MemPool::snapshot(oss.str());
   71020             :     alloc_trace_cnt++;
   71021             : #endif
   71022             : 
   71023             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   71024             : 
   71025           0 :     ALLOC_MUTEX(SgClinkageStartStatement, unlock);
   71026             : }
   71027             : 
   71028             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   71029             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   71030             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   71031             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   71032             : // Also, note comment below from Robb (copied from the Common.code file).
   71033             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   71034             : //
   71035             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   71036             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   71037             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   71038             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   71039             : #if 0
   71040             : void SgClinkageStartStatement::operator delete(void* pointer) { SgClinkageStartStatement::operator delete (pointer, sizeof(SgClinkageStartStatement)); };
   71041             : #endif
   71042             : /* #line 71043 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   71043             : 
   71044             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   71045             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   71046             : // obviously imply C++.
   71047             : 
   71048             : // This implements the support within ROSE for memory pools.  Memory pools
   71049             : // support the most condensed usage of memory within the construction of
   71050             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   71051             : // by a new operator written for each class.
   71052             : 
   71053             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   71054             :     // User wants multi-thread support and POSIX threads are available.
   71055             : #   include <pthread.h>
   71056             :     static pthread_mutex_t SgClinkageEndStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   71057             : #else
   71058             :      // Cause synchronization to be skipped.
   71059             : #    ifndef ALLOC_MUTEX
   71060             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   71061             : #    endif
   71062             : #    ifdef _REENTRANT
   71063             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   71064             : #       ifdef _MSC_VER
   71065             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   71066             : #       else
   71067             : #           warning "POSIX threads are not available; synchronization being skipped"
   71068             : #       endif
   71069             : #    endif
   71070             : #endif
   71071             : 
   71072             : #ifndef ROSE_ALLOC_TRACE
   71073             : #  define ROSE_ALLOC_TRACE 0
   71074             : #endif
   71075             : 
   71076             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   71077             : #define ROSE_ALLOC_TRACE_CNT
   71078             : #include "memory-pool-snapshot.h"
   71079             : unsigned long alloc_trace_cnt = 0;
   71080             : #endif
   71081             : 
   71082             : #if ROSE_ALLOC_TRACE
   71083             : const unsigned SgClinkageEndStatement::pool_size = 5;
   71084             : #else
   71085             : const unsigned SgClinkageEndStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   71086             : #endif
   71087             : 
   71088             : #ifndef ROSE_ALLOC_MEMSET
   71089             : #  define ROSE_ALLOC_MEMSET 0
   71090             : #endif
   71091             : 
   71092             : #ifndef ROSE_PEDANTIC_ALLOC
   71093             : #  define ROSE_PEDANTIC_ALLOC 0
   71094             : #endif
   71095             : 
   71096             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   71097             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   71098             : #endif
   71099             : 
   71100             : #if !defined(SGNODE__ALL_POOLS)
   71101             : #define SGNODE__ALL_POOLS
   71102             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   71103             : #endif
   71104             : 
   71105             : SgClinkageEndStatement* SgClinkageEndStatement::next_node = nullptr;
   71106             : std::vector<unsigned char*> SgClinkageEndStatement::pools;
   71107             : 
   71108             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   71109             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   71110             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   71111             : // around this macro definition rather than each use).
   71112             : #ifndef ALLOC_MUTEX
   71113             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   71114             :         do {                                                                     \
   71115             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   71116             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   71117             :                 abort();                                                         \
   71118             :             }                                                                    \
   71119             :         } while (0);
   71120             : #endif
   71121             : 
   71122             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   71123             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   71124             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   71125             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   71126             : 
   71127             : /*! \brief New operator for SgClinkageEndStatement.
   71128             : 
   71129             :    This new operator implements memory pools to provide most efficent 
   71130             :    use of the heap within construction of large ASTs.
   71131             : 
   71132             : \internal The new and delete operators use the lower level C malloc/free
   71133             :    function calls for performance and to make sure that mixing of malloc/free
   71134             :    and new/delete by the used can be caught more readily.  This may change
   71135             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   71136             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   71137             :    deallocate memory allocated using ROSE_MALLOC.
   71138             : */
   71139           0 : void *SgClinkageEndStatement::operator new ( size_t Size )
   71140             : {
   71141             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   71142             :      * returning or throwing an exception. */
   71143           0 :     ALLOC_MUTEX(SgClinkageEndStatement, lock);
   71144             : 
   71145             : #if ROSE_ALLOC_TRACE == 2
   71146             : //    printf("SgClinkageEndStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgClinkageEndStatement::next_node);
   71147             : #endif
   71148             : 
   71149             : #if USE_CPP_NEW_DELETE_OPERATORS
   71150             :     void *mem = ROSE_MALLOC(Size);
   71151             :     ALLOC_MUTEX(SgClinkageEndStatement, unlock);
   71152             :     return mem;
   71153             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   71154             : #if ROSE_PEDANTIC_ALLOC
   71155             :     ROSE_ASSERT(Size == sizeof(SgClinkageEndStatement));
   71156             : #else
   71157           0 :     if (Size != sizeof(SgClinkageEndStatement)) {
   71158           0 :       void * object = ROSE_MALLOC(Size);
   71159           0 :       ALLOC_MUTEX(SgClinkageEndStatement, unlock);
   71160             :       return object;
   71161             :     }
   71162             : #endif
   71163             : 
   71164           0 :     if (SgClinkageEndStatement::next_node == nullptr) {
   71165           0 :         SgClinkageEndStatement * alloc = (SgClinkageEndStatement*) ROSE_MALLOC ( SgClinkageEndStatement::pool_size * sizeof(SgClinkageEndStatement) );
   71166           0 :         ROSE_ASSERT(alloc != nullptr);
   71167             : 
   71168             : #if ROSE_ALLOC_TRACE == 2
   71169             : //        printf("SgClinkageEndStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgClinkageEndStatement::pools.size(), alloc, alloc + SgClinkageEndStatement::pool_size);
   71170             : #endif
   71171             : 
   71172             : #if ROSE_ALLOC_MEMSET == 1
   71173             : #elif ROSE_ALLOC_MEMSET == 2
   71174             :         memset(alloc, 0x00, SgClinkageEndStatement::pool_size * sizeof(SgClinkageEndStatement));
   71175             : #elif ROSE_ALLOC_MEMSET == 3
   71176             :         memset(alloc, 0xAA, SgClinkageEndStatement::pool_size * sizeof(SgClinkageEndStatement));
   71177             : #endif
   71178           0 :         for (unsigned i=0; i < SgClinkageEndStatement::pool_size-1; i++) {
   71179           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
   71180             :         }
   71181           0 :         alloc[SgClinkageEndStatement::pool_size-1].p_freepointer = nullptr;
   71182             : 
   71183           0 :         SgClinkageEndStatement::pools.push_back ( (unsigned char *) alloc );
   71184           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgClinkageEndStatement::pool_size * sizeof(SgClinkageEndStatement), V_SgClinkageEndStatement ) );
   71185           0 :         SgClinkageEndStatement::next_node = alloc;
   71186             :     }
   71187           0 :     ROSE_ASSERT(SgClinkageEndStatement::next_node != nullptr);
   71188             : 
   71189           0 :     SgClinkageEndStatement * object = SgClinkageEndStatement::next_node;
   71190           0 :     SgClinkageEndStatement::next_node = (SgClinkageEndStatement*)(object->p_freepointer);
   71191             : 
   71192             : #if ROSE_ALLOC_TRACE == 2
   71193             :     printf("SgClinkageEndStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgClinkageEndStatement::next_node);
   71194             : #endif
   71195             : 
   71196           0 :     SgNode * fp = object->p_freepointer;
   71197             : #if ROSE_ALLOC_MEMSET == 1
   71198             : #elif ROSE_ALLOC_MEMSET == 2
   71199             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgClinkageEndStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   71200             : #elif ROSE_ALLOC_MEMSET == 3
   71201             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgClinkageEndStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   71202             : #endif
   71203           0 :     object->p_freepointer = fp;
   71204             : 
   71205             : #if ROSE_ALLOC_TRACE == 2
   71206             : //    printf("SgClinkageEndStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgClinkageEndStatement::next_node);
   71207             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   71208             :     Rose::MemPool::snapshot(oss.str());
   71209             :     alloc_trace_cnt++;
   71210             : #endif
   71211             : 
   71212           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   71213             : 
   71214           0 :     ALLOC_MUTEX(SgClinkageEndStatement, unlock);
   71215             : 
   71216             :     return object;
   71217             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   71218             : }
   71219             : 
   71220             : 
   71221             : 
   71222             : /*! \brief Delete operator for SgClinkageEndStatement.
   71223             : 
   71224             :    This delete operator implements deallocation using memory pools to 
   71225             :    provide most efficent use of the heap within construction of large ASTs.
   71226             : 
   71227             : \internal The new and delete operators use the lower level C malloc/free
   71228             :    function calls for performance and to make sure that mixing of malloc/free
   71229             :    and new/delete by the used can be caught more readily.  This may change
   71230             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   71231             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   71232             :    deallocate memory allocated using ROSE_MALLOC.
   71233             : */
   71234           0 : void SgClinkageEndStatement::operator delete(void *Pointer, size_t Size)
   71235             : {
   71236             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   71237             :      * or throwing an exception. */
   71238           0 :     ALLOC_MUTEX(SgClinkageEndStatement, lock);
   71239             : 
   71240             : #if USE_CPP_NEW_DELETE_OPERATORS
   71241             :     ROSE_FREE(Pointer);
   71242             : #else
   71243             : #if ROSE_PEDANTIC_ALLOC
   71244             :     ROSE_ASSERT(Size == sizeof(SgClinkageEndStatement));
   71245             : #else
   71246           0 :     if (Size != sizeof(SgClinkageEndStatement)) {
   71247           0 :       ROSE_FREE(Pointer);
   71248           0 :       ALLOC_MUTEX(SgClinkageEndStatement, unlock);
   71249             :       return;
   71250             :     }
   71251             : #endif
   71252             : 
   71253           0 :     SgClinkageEndStatement * object = (SgClinkageEndStatement*) Pointer;
   71254           0 :     ROSE_ASSERT(object != nullptr);
   71255             : 
   71256             : #if ROSE_ALLOC_TRACE == 2
   71257             : //  printf("SgClinkageEndStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgClinkageEndStatement::next_node);
   71258             :     printf("SgClinkageEndStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgClinkageEndStatement::next_node);
   71259             : #endif
   71260             : 
   71261             : #if ROSE_PEDANTIC_ALLOC
   71262             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   71263             : #endif
   71264             : 
   71265             : #if ROSE_ALLOC_MEMSET == 1
   71266             : #elif ROSE_ALLOC_MEMSET == 2
   71267             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgClinkageEndStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   71268             : #elif ROSE_ALLOC_MEMSET == 3
   71269             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgClinkageEndStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   71270             : #endif
   71271             : 
   71272             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   71273             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   71274             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   71275             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   71276             : #else
   71277           0 :     object->p_freepointer = SgClinkageEndStatement::next_node;
   71278           0 :     SgClinkageEndStatement::next_node = object;
   71279             : #endif
   71280             : 
   71281             : #if ROSE_ALLOC_TRACE == 2
   71282             : //  printf("SgClinkageEndStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgClinkageEndStatement::next_node);
   71283             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   71284             :     Rose::MemPool::snapshot(oss.str());
   71285             :     alloc_trace_cnt++;
   71286             : #endif
   71287             : 
   71288             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   71289             : 
   71290           0 :     ALLOC_MUTEX(SgClinkageEndStatement, unlock);
   71291             : }
   71292             : 
   71293             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   71294             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   71295             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   71296             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   71297             : // Also, note comment below from Robb (copied from the Common.code file).
   71298             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   71299             : //
   71300             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   71301             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   71302             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   71303             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   71304             : #if 0
   71305             : void SgClinkageEndStatement::operator delete(void* pointer) { SgClinkageEndStatement::operator delete (pointer, sizeof(SgClinkageEndStatement)); };
   71306             : #endif
   71307             : /* #line 71308 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   71308             : 
   71309             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   71310             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   71311             : // obviously imply C++.
   71312             : 
   71313             : // This implements the support within ROSE for memory pools.  Memory pools
   71314             : // support the most condensed usage of memory within the construction of
   71315             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   71316             : // by a new operator written for each class.
   71317             : 
   71318             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   71319             :     // User wants multi-thread support and POSIX threads are available.
   71320             : #   include <pthread.h>
   71321             :     static pthread_mutex_t SgEnumDeclaration_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   71322             : #else
   71323             :      // Cause synchronization to be skipped.
   71324             : #    ifndef ALLOC_MUTEX
   71325             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   71326             : #    endif
   71327             : #    ifdef _REENTRANT
   71328             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   71329             : #       ifdef _MSC_VER
   71330             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   71331             : #       else
   71332             : #           warning "POSIX threads are not available; synchronization being skipped"
   71333             : #       endif
   71334             : #    endif
   71335             : #endif
   71336             : 
   71337             : #ifndef ROSE_ALLOC_TRACE
   71338             : #  define ROSE_ALLOC_TRACE 0
   71339             : #endif
   71340             : 
   71341             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   71342             : #define ROSE_ALLOC_TRACE_CNT
   71343             : #include "memory-pool-snapshot.h"
   71344             : unsigned long alloc_trace_cnt = 0;
   71345             : #endif
   71346             : 
   71347             : #if ROSE_ALLOC_TRACE
   71348             : const unsigned SgEnumDeclaration::pool_size = 5;
   71349             : #else
   71350             : const unsigned SgEnumDeclaration::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   71351             : #endif
   71352             : 
   71353             : #ifndef ROSE_ALLOC_MEMSET
   71354             : #  define ROSE_ALLOC_MEMSET 0
   71355             : #endif
   71356             : 
   71357             : #ifndef ROSE_PEDANTIC_ALLOC
   71358             : #  define ROSE_PEDANTIC_ALLOC 0
   71359             : #endif
   71360             : 
   71361             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   71362             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   71363             : #endif
   71364             : 
   71365             : #if !defined(SGNODE__ALL_POOLS)
   71366             : #define SGNODE__ALL_POOLS
   71367             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   71368             : #endif
   71369             : 
   71370             : SgEnumDeclaration* SgEnumDeclaration::next_node = nullptr;
   71371             : std::vector<unsigned char*> SgEnumDeclaration::pools;
   71372             : 
   71373             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   71374             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   71375             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   71376             : // around this macro definition rather than each use).
   71377             : #ifndef ALLOC_MUTEX
   71378             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   71379             :         do {                                                                     \
   71380             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   71381             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   71382             :                 abort();                                                         \
   71383             :             }                                                                    \
   71384             :         } while (0);
   71385             : #endif
   71386             : 
   71387             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   71388             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   71389             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   71390             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   71391             : 
   71392             : /*! \brief New operator for SgEnumDeclaration.
   71393             : 
   71394             :    This new operator implements memory pools to provide most efficent 
   71395             :    use of the heap within construction of large ASTs.
   71396             : 
   71397             : \internal The new and delete operators use the lower level C malloc/free
   71398             :    function calls for performance and to make sure that mixing of malloc/free
   71399             :    and new/delete by the used can be caught more readily.  This may change
   71400             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   71401             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   71402             :    deallocate memory allocated using ROSE_MALLOC.
   71403             : */
   71404        3156 : void *SgEnumDeclaration::operator new ( size_t Size )
   71405             : {
   71406             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   71407             :      * returning or throwing an exception. */
   71408        3156 :     ALLOC_MUTEX(SgEnumDeclaration, lock);
   71409             : 
   71410             : #if ROSE_ALLOC_TRACE == 2
   71411             : //    printf("SgEnumDeclaration::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgEnumDeclaration::next_node);
   71412             : #endif
   71413             : 
   71414             : #if USE_CPP_NEW_DELETE_OPERATORS
   71415             :     void *mem = ROSE_MALLOC(Size);
   71416             :     ALLOC_MUTEX(SgEnumDeclaration, unlock);
   71417             :     return mem;
   71418             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   71419             : #if ROSE_PEDANTIC_ALLOC
   71420             :     ROSE_ASSERT(Size == sizeof(SgEnumDeclaration));
   71421             : #else
   71422        3156 :     if (Size != sizeof(SgEnumDeclaration)) {
   71423           0 :       void * object = ROSE_MALLOC(Size);
   71424           0 :       ALLOC_MUTEX(SgEnumDeclaration, unlock);
   71425             :       return object;
   71426             :     }
   71427             : #endif
   71428             : 
   71429        3156 :     if (SgEnumDeclaration::next_node == nullptr) {
   71430         183 :         SgEnumDeclaration * alloc = (SgEnumDeclaration*) ROSE_MALLOC ( SgEnumDeclaration::pool_size * sizeof(SgEnumDeclaration) );
   71431         183 :         ROSE_ASSERT(alloc != nullptr);
   71432             : 
   71433             : #if ROSE_ALLOC_TRACE == 2
   71434             : //        printf("SgEnumDeclaration::alloc\n  block[%zi] = [ %p , %p [\n", SgEnumDeclaration::pools.size(), alloc, alloc + SgEnumDeclaration::pool_size);
   71435             : #endif
   71436             : 
   71437             : #if ROSE_ALLOC_MEMSET == 1
   71438             : #elif ROSE_ALLOC_MEMSET == 2
   71439             :         memset(alloc, 0x00, SgEnumDeclaration::pool_size * sizeof(SgEnumDeclaration));
   71440             : #elif ROSE_ALLOC_MEMSET == 3
   71441             :         memset(alloc, 0xAA, SgEnumDeclaration::pool_size * sizeof(SgEnumDeclaration));
   71442             : #endif
   71443      366000 :         for (unsigned i=0; i < SgEnumDeclaration::pool_size-1; i++) {
   71444      365817 :           alloc[i].p_freepointer = &(alloc[i+1]);
   71445             :         }
   71446         183 :         alloc[SgEnumDeclaration::pool_size-1].p_freepointer = nullptr;
   71447             : 
   71448         183 :         SgEnumDeclaration::pools.push_back ( (unsigned char *) alloc );
   71449         183 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgEnumDeclaration::pool_size * sizeof(SgEnumDeclaration), V_SgEnumDeclaration ) );
   71450         183 :         SgEnumDeclaration::next_node = alloc;
   71451             :     }
   71452        3156 :     ROSE_ASSERT(SgEnumDeclaration::next_node != nullptr);
   71453             : 
   71454        3156 :     SgEnumDeclaration * object = SgEnumDeclaration::next_node;
   71455        3156 :     SgEnumDeclaration::next_node = (SgEnumDeclaration*)(object->p_freepointer);
   71456             : 
   71457             : #if ROSE_ALLOC_TRACE == 2
   71458             :     printf("SgEnumDeclaration::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgEnumDeclaration::next_node);
   71459             : #endif
   71460             : 
   71461        3156 :     SgNode * fp = object->p_freepointer;
   71462             : #if ROSE_ALLOC_MEMSET == 1
   71463             : #elif ROSE_ALLOC_MEMSET == 2
   71464             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgEnumDeclaration) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   71465             : #elif ROSE_ALLOC_MEMSET == 3
   71466             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgEnumDeclaration) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   71467             : #endif
   71468        3156 :     object->p_freepointer = fp;
   71469             : 
   71470             : #if ROSE_ALLOC_TRACE == 2
   71471             : //    printf("SgEnumDeclaration::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgEnumDeclaration::next_node);
   71472             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   71473             :     Rose::MemPool::snapshot(oss.str());
   71474             :     alloc_trace_cnt++;
   71475             : #endif
   71476             : 
   71477        3156 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   71478             : 
   71479        3156 :     ALLOC_MUTEX(SgEnumDeclaration, unlock);
   71480             : 
   71481             :     return object;
   71482             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   71483             : }
   71484             : 
   71485             : 
   71486             : 
   71487             : /*! \brief Delete operator for SgEnumDeclaration.
   71488             : 
   71489             :    This delete operator implements deallocation using memory pools to 
   71490             :    provide most efficent use of the heap within construction of large ASTs.
   71491             : 
   71492             : \internal The new and delete operators use the lower level C malloc/free
   71493             :    function calls for performance and to make sure that mixing of malloc/free
   71494             :    and new/delete by the used can be caught more readily.  This may change
   71495             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   71496             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   71497             :    deallocate memory allocated using ROSE_MALLOC.
   71498             : */
   71499         352 : void SgEnumDeclaration::operator delete(void *Pointer, size_t Size)
   71500             : {
   71501             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   71502             :      * or throwing an exception. */
   71503         352 :     ALLOC_MUTEX(SgEnumDeclaration, lock);
   71504             : 
   71505             : #if USE_CPP_NEW_DELETE_OPERATORS
   71506             :     ROSE_FREE(Pointer);
   71507             : #else
   71508             : #if ROSE_PEDANTIC_ALLOC
   71509             :     ROSE_ASSERT(Size == sizeof(SgEnumDeclaration));
   71510             : #else
   71511         352 :     if (Size != sizeof(SgEnumDeclaration)) {
   71512           0 :       ROSE_FREE(Pointer);
   71513           0 :       ALLOC_MUTEX(SgEnumDeclaration, unlock);
   71514             :       return;
   71515             :     }
   71516             : #endif
   71517             : 
   71518         352 :     SgEnumDeclaration * object = (SgEnumDeclaration*) Pointer;
   71519         352 :     ROSE_ASSERT(object != nullptr);
   71520             : 
   71521             : #if ROSE_ALLOC_TRACE == 2
   71522             : //  printf("SgEnumDeclaration::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgEnumDeclaration::next_node);
   71523             :     printf("SgEnumDeclaration::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgEnumDeclaration::next_node);
   71524             : #endif
   71525             : 
   71526             : #if ROSE_PEDANTIC_ALLOC
   71527             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   71528             : #endif
   71529             : 
   71530             : #if ROSE_ALLOC_MEMSET == 1
   71531             : #elif ROSE_ALLOC_MEMSET == 2
   71532             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgEnumDeclaration) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   71533             : #elif ROSE_ALLOC_MEMSET == 3
   71534             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgEnumDeclaration) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   71535             : #endif
   71536             : 
   71537             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   71538             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   71539             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   71540             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   71541             : #else
   71542         352 :     object->p_freepointer = SgEnumDeclaration::next_node;
   71543         352 :     SgEnumDeclaration::next_node = object;
   71544             : #endif
   71545             : 
   71546             : #if ROSE_ALLOC_TRACE == 2
   71547             : //  printf("SgEnumDeclaration::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgEnumDeclaration::next_node);
   71548             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   71549             :     Rose::MemPool::snapshot(oss.str());
   71550             :     alloc_trace_cnt++;
   71551             : #endif
   71552             : 
   71553             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   71554             : 
   71555         352 :     ALLOC_MUTEX(SgEnumDeclaration, unlock);
   71556             : }
   71557             : 
   71558             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   71559             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   71560             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   71561             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   71562             : // Also, note comment below from Robb (copied from the Common.code file).
   71563             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   71564             : //
   71565             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   71566             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   71567             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   71568             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   71569             : #if 0
   71570             : void SgEnumDeclaration::operator delete(void* pointer) { SgEnumDeclaration::operator delete (pointer, sizeof(SgEnumDeclaration)); };
   71571             : #endif
   71572             : /* #line 71573 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   71573             : 
   71574             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   71575             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   71576             : // obviously imply C++.
   71577             : 
   71578             : // This implements the support within ROSE for memory pools.  Memory pools
   71579             : // support the most condensed usage of memory within the construction of
   71580             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   71581             : // by a new operator written for each class.
   71582             : 
   71583             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   71584             :     // User wants multi-thread support and POSIX threads are available.
   71585             : #   include <pthread.h>
   71586             :     static pthread_mutex_t SgAsmStmt_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   71587             : #else
   71588             :      // Cause synchronization to be skipped.
   71589             : #    ifndef ALLOC_MUTEX
   71590             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   71591             : #    endif
   71592             : #    ifdef _REENTRANT
   71593             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   71594             : #       ifdef _MSC_VER
   71595             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   71596             : #       else
   71597             : #           warning "POSIX threads are not available; synchronization being skipped"
   71598             : #       endif
   71599             : #    endif
   71600             : #endif
   71601             : 
   71602             : #ifndef ROSE_ALLOC_TRACE
   71603             : #  define ROSE_ALLOC_TRACE 0
   71604             : #endif
   71605             : 
   71606             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   71607             : #define ROSE_ALLOC_TRACE_CNT
   71608             : #include "memory-pool-snapshot.h"
   71609             : unsigned long alloc_trace_cnt = 0;
   71610             : #endif
   71611             : 
   71612             : #if ROSE_ALLOC_TRACE
   71613             : const unsigned SgAsmStmt::pool_size = 5;
   71614             : #else
   71615             : const unsigned SgAsmStmt::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   71616             : #endif
   71617             : 
   71618             : #ifndef ROSE_ALLOC_MEMSET
   71619             : #  define ROSE_ALLOC_MEMSET 0
   71620             : #endif
   71621             : 
   71622             : #ifndef ROSE_PEDANTIC_ALLOC
   71623             : #  define ROSE_PEDANTIC_ALLOC 0
   71624             : #endif
   71625             : 
   71626             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   71627             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   71628             : #endif
   71629             : 
   71630             : #if !defined(SGNODE__ALL_POOLS)
   71631             : #define SGNODE__ALL_POOLS
   71632             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   71633             : #endif
   71634             : 
   71635             : SgAsmStmt* SgAsmStmt::next_node = nullptr;
   71636             : std::vector<unsigned char*> SgAsmStmt::pools;
   71637             : 
   71638             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   71639             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   71640             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   71641             : // around this macro definition rather than each use).
   71642             : #ifndef ALLOC_MUTEX
   71643             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   71644             :         do {                                                                     \
   71645             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   71646             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   71647             :                 abort();                                                         \
   71648             :             }                                                                    \
   71649             :         } while (0);
   71650             : #endif
   71651             : 
   71652             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   71653             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   71654             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   71655             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   71656             : 
   71657             : /*! \brief New operator for SgAsmStmt.
   71658             : 
   71659             :    This new operator implements memory pools to provide most efficent 
   71660             :    use of the heap within construction of large ASTs.
   71661             : 
   71662             : \internal The new and delete operators use the lower level C malloc/free
   71663             :    function calls for performance and to make sure that mixing of malloc/free
   71664             :    and new/delete by the used can be caught more readily.  This may change
   71665             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   71666             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   71667             :    deallocate memory allocated using ROSE_MALLOC.
   71668             : */
   71669           0 : void *SgAsmStmt::operator new ( size_t Size )
   71670             : {
   71671             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   71672             :      * returning or throwing an exception. */
   71673           0 :     ALLOC_MUTEX(SgAsmStmt, lock);
   71674             : 
   71675             : #if ROSE_ALLOC_TRACE == 2
   71676             : //    printf("SgAsmStmt::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgAsmStmt::next_node);
   71677             : #endif
   71678             : 
   71679             : #if USE_CPP_NEW_DELETE_OPERATORS
   71680             :     void *mem = ROSE_MALLOC(Size);
   71681             :     ALLOC_MUTEX(SgAsmStmt, unlock);
   71682             :     return mem;
   71683             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   71684             : #if ROSE_PEDANTIC_ALLOC
   71685             :     ROSE_ASSERT(Size == sizeof(SgAsmStmt));
   71686             : #else
   71687           0 :     if (Size != sizeof(SgAsmStmt)) {
   71688           0 :       void * object = ROSE_MALLOC(Size);
   71689           0 :       ALLOC_MUTEX(SgAsmStmt, unlock);
   71690             :       return object;
   71691             :     }
   71692             : #endif
   71693             : 
   71694           0 :     if (SgAsmStmt::next_node == nullptr) {
   71695           0 :         SgAsmStmt * alloc = (SgAsmStmt*) ROSE_MALLOC ( SgAsmStmt::pool_size * sizeof(SgAsmStmt) );
   71696           0 :         ROSE_ASSERT(alloc != nullptr);
   71697             : 
   71698             : #if ROSE_ALLOC_TRACE == 2
   71699             : //        printf("SgAsmStmt::alloc\n  block[%zi] = [ %p , %p [\n", SgAsmStmt::pools.size(), alloc, alloc + SgAsmStmt::pool_size);
   71700             : #endif
   71701             : 
   71702             : #if ROSE_ALLOC_MEMSET == 1
   71703             : #elif ROSE_ALLOC_MEMSET == 2
   71704             :         memset(alloc, 0x00, SgAsmStmt::pool_size * sizeof(SgAsmStmt));
   71705             : #elif ROSE_ALLOC_MEMSET == 3
   71706             :         memset(alloc, 0xAA, SgAsmStmt::pool_size * sizeof(SgAsmStmt));
   71707             : #endif
   71708           0 :         for (unsigned i=0; i < SgAsmStmt::pool_size-1; i++) {
   71709           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
   71710             :         }
   71711           0 :         alloc[SgAsmStmt::pool_size-1].p_freepointer = nullptr;
   71712             : 
   71713           0 :         SgAsmStmt::pools.push_back ( (unsigned char *) alloc );
   71714           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgAsmStmt::pool_size * sizeof(SgAsmStmt), V_SgAsmStmt ) );
   71715           0 :         SgAsmStmt::next_node = alloc;
   71716             :     }
   71717           0 :     ROSE_ASSERT(SgAsmStmt::next_node != nullptr);
   71718             : 
   71719           0 :     SgAsmStmt * object = SgAsmStmt::next_node;
   71720           0 :     SgAsmStmt::next_node = (SgAsmStmt*)(object->p_freepointer);
   71721             : 
   71722             : #if ROSE_ALLOC_TRACE == 2
   71723             :     printf("SgAsmStmt::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgAsmStmt::next_node);
   71724             : #endif
   71725             : 
   71726           0 :     SgNode * fp = object->p_freepointer;
   71727             : #if ROSE_ALLOC_MEMSET == 1
   71728             : #elif ROSE_ALLOC_MEMSET == 2
   71729             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgAsmStmt) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   71730             : #elif ROSE_ALLOC_MEMSET == 3
   71731             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgAsmStmt) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   71732             : #endif
   71733           0 :     object->p_freepointer = fp;
   71734             : 
   71735             : #if ROSE_ALLOC_TRACE == 2
   71736             : //    printf("SgAsmStmt::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgAsmStmt::next_node);
   71737             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   71738             :     Rose::MemPool::snapshot(oss.str());
   71739             :     alloc_trace_cnt++;
   71740             : #endif
   71741             : 
   71742           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   71743             : 
   71744           0 :     ALLOC_MUTEX(SgAsmStmt, unlock);
   71745             : 
   71746             :     return object;
   71747             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   71748             : }
   71749             : 
   71750             : 
   71751             : 
   71752             : /*! \brief Delete operator for SgAsmStmt.
   71753             : 
   71754             :    This delete operator implements deallocation using memory pools to 
   71755             :    provide most efficent use of the heap within construction of large ASTs.
   71756             : 
   71757             : \internal The new and delete operators use the lower level C malloc/free
   71758             :    function calls for performance and to make sure that mixing of malloc/free
   71759             :    and new/delete by the used can be caught more readily.  This may change
   71760             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   71761             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   71762             :    deallocate memory allocated using ROSE_MALLOC.
   71763             : */
   71764           0 : void SgAsmStmt::operator delete(void *Pointer, size_t Size)
   71765             : {
   71766             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   71767             :      * or throwing an exception. */
   71768           0 :     ALLOC_MUTEX(SgAsmStmt, lock);
   71769             : 
   71770             : #if USE_CPP_NEW_DELETE_OPERATORS
   71771             :     ROSE_FREE(Pointer);
   71772             : #else
   71773             : #if ROSE_PEDANTIC_ALLOC
   71774             :     ROSE_ASSERT(Size == sizeof(SgAsmStmt));
   71775             : #else
   71776           0 :     if (Size != sizeof(SgAsmStmt)) {
   71777           0 :       ROSE_FREE(Pointer);
   71778           0 :       ALLOC_MUTEX(SgAsmStmt, unlock);
   71779             :       return;
   71780             :     }
   71781             : #endif
   71782             : 
   71783           0 :     SgAsmStmt * object = (SgAsmStmt*) Pointer;
   71784           0 :     ROSE_ASSERT(object != nullptr);
   71785             : 
   71786             : #if ROSE_ALLOC_TRACE == 2
   71787             : //  printf("SgAsmStmt::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgAsmStmt::next_node);
   71788             :     printf("SgAsmStmt::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgAsmStmt::next_node);
   71789             : #endif
   71790             : 
   71791             : #if ROSE_PEDANTIC_ALLOC
   71792             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   71793             : #endif
   71794             : 
   71795             : #if ROSE_ALLOC_MEMSET == 1
   71796             : #elif ROSE_ALLOC_MEMSET == 2
   71797             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgAsmStmt) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   71798             : #elif ROSE_ALLOC_MEMSET == 3
   71799             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgAsmStmt) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   71800             : #endif
   71801             : 
   71802             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   71803             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   71804             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   71805             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   71806             : #else
   71807           0 :     object->p_freepointer = SgAsmStmt::next_node;
   71808           0 :     SgAsmStmt::next_node = object;
   71809             : #endif
   71810             : 
   71811             : #if ROSE_ALLOC_TRACE == 2
   71812             : //  printf("SgAsmStmt::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgAsmStmt::next_node);
   71813             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   71814             :     Rose::MemPool::snapshot(oss.str());
   71815             :     alloc_trace_cnt++;
   71816             : #endif
   71817             : 
   71818             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   71819             : 
   71820           0 :     ALLOC_MUTEX(SgAsmStmt, unlock);
   71821             : }
   71822             : 
   71823             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   71824             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   71825             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   71826             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   71827             : // Also, note comment below from Robb (copied from the Common.code file).
   71828             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   71829             : //
   71830             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   71831             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   71832             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   71833             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   71834             : #if 0
   71835             : void SgAsmStmt::operator delete(void* pointer) { SgAsmStmt::operator delete (pointer, sizeof(SgAsmStmt)); };
   71836             : #endif
   71837             : /* #line 71838 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   71838             : 
   71839             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   71840             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   71841             : // obviously imply C++.
   71842             : 
   71843             : // This implements the support within ROSE for memory pools.  Memory pools
   71844             : // support the most condensed usage of memory within the construction of
   71845             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   71846             : // by a new operator written for each class.
   71847             : 
   71848             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   71849             :     // User wants multi-thread support and POSIX threads are available.
   71850             : #   include <pthread.h>
   71851             :     static pthread_mutex_t SgAttributeSpecificationStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   71852             : #else
   71853             :      // Cause synchronization to be skipped.
   71854             : #    ifndef ALLOC_MUTEX
   71855             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   71856             : #    endif
   71857             : #    ifdef _REENTRANT
   71858             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   71859             : #       ifdef _MSC_VER
   71860             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   71861             : #       else
   71862             : #           warning "POSIX threads are not available; synchronization being skipped"
   71863             : #       endif
   71864             : #    endif
   71865             : #endif
   71866             : 
   71867             : #ifndef ROSE_ALLOC_TRACE
   71868             : #  define ROSE_ALLOC_TRACE 0
   71869             : #endif
   71870             : 
   71871             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   71872             : #define ROSE_ALLOC_TRACE_CNT
   71873             : #include "memory-pool-snapshot.h"
   71874             : unsigned long alloc_trace_cnt = 0;
   71875             : #endif
   71876             : 
   71877             : #if ROSE_ALLOC_TRACE
   71878             : const unsigned SgAttributeSpecificationStatement::pool_size = 5;
   71879             : #else
   71880             : const unsigned SgAttributeSpecificationStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   71881             : #endif
   71882             : 
   71883             : #ifndef ROSE_ALLOC_MEMSET
   71884             : #  define ROSE_ALLOC_MEMSET 0
   71885             : #endif
   71886             : 
   71887             : #ifndef ROSE_PEDANTIC_ALLOC
   71888             : #  define ROSE_PEDANTIC_ALLOC 0
   71889             : #endif
   71890             : 
   71891             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   71892             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   71893             : #endif
   71894             : 
   71895             : #if !defined(SGNODE__ALL_POOLS)
   71896             : #define SGNODE__ALL_POOLS
   71897             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   71898             : #endif
   71899             : 
   71900             : SgAttributeSpecificationStatement* SgAttributeSpecificationStatement::next_node = nullptr;
   71901             : std::vector<unsigned char*> SgAttributeSpecificationStatement::pools;
   71902             : 
   71903             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   71904             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   71905             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   71906             : // around this macro definition rather than each use).
   71907             : #ifndef ALLOC_MUTEX
   71908             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   71909             :         do {                                                                     \
   71910             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   71911             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   71912             :                 abort();                                                         \
   71913             :             }                                                                    \
   71914             :         } while (0);
   71915             : #endif
   71916             : 
   71917             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   71918             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   71919             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   71920             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   71921             : 
   71922             : /*! \brief New operator for SgAttributeSpecificationStatement.
   71923             : 
   71924             :    This new operator implements memory pools to provide most efficent 
   71925             :    use of the heap within construction of large ASTs.
   71926             : 
   71927             : \internal The new and delete operators use the lower level C malloc/free
   71928             :    function calls for performance and to make sure that mixing of malloc/free
   71929             :    and new/delete by the used can be caught more readily.  This may change
   71930             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   71931             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   71932             :    deallocate memory allocated using ROSE_MALLOC.
   71933             : */
   71934         551 : void *SgAttributeSpecificationStatement::operator new ( size_t Size )
   71935             : {
   71936             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   71937             :      * returning or throwing an exception. */
   71938         551 :     ALLOC_MUTEX(SgAttributeSpecificationStatement, lock);
   71939             : 
   71940             : #if ROSE_ALLOC_TRACE == 2
   71941             : //    printf("SgAttributeSpecificationStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgAttributeSpecificationStatement::next_node);
   71942             : #endif
   71943             : 
   71944             : #if USE_CPP_NEW_DELETE_OPERATORS
   71945             :     void *mem = ROSE_MALLOC(Size);
   71946             :     ALLOC_MUTEX(SgAttributeSpecificationStatement, unlock);
   71947             :     return mem;
   71948             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   71949             : #if ROSE_PEDANTIC_ALLOC
   71950             :     ROSE_ASSERT(Size == sizeof(SgAttributeSpecificationStatement));
   71951             : #else
   71952         551 :     if (Size != sizeof(SgAttributeSpecificationStatement)) {
   71953           0 :       void * object = ROSE_MALLOC(Size);
   71954           0 :       ALLOC_MUTEX(SgAttributeSpecificationStatement, unlock);
   71955             :       return object;
   71956             :     }
   71957             : #endif
   71958             : 
   71959         551 :     if (SgAttributeSpecificationStatement::next_node == nullptr) {
   71960          13 :         SgAttributeSpecificationStatement * alloc = (SgAttributeSpecificationStatement*) ROSE_MALLOC ( SgAttributeSpecificationStatement::pool_size * sizeof(SgAttributeSpecificationStatement) );
   71961          13 :         ROSE_ASSERT(alloc != nullptr);
   71962             : 
   71963             : #if ROSE_ALLOC_TRACE == 2
   71964             : //        printf("SgAttributeSpecificationStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgAttributeSpecificationStatement::pools.size(), alloc, alloc + SgAttributeSpecificationStatement::pool_size);
   71965             : #endif
   71966             : 
   71967             : #if ROSE_ALLOC_MEMSET == 1
   71968             : #elif ROSE_ALLOC_MEMSET == 2
   71969             :         memset(alloc, 0x00, SgAttributeSpecificationStatement::pool_size * sizeof(SgAttributeSpecificationStatement));
   71970             : #elif ROSE_ALLOC_MEMSET == 3
   71971             :         memset(alloc, 0xAA, SgAttributeSpecificationStatement::pool_size * sizeof(SgAttributeSpecificationStatement));
   71972             : #endif
   71973       26000 :         for (unsigned i=0; i < SgAttributeSpecificationStatement::pool_size-1; i++) {
   71974       25987 :           alloc[i].p_freepointer = &(alloc[i+1]);
   71975             :         }
   71976          13 :         alloc[SgAttributeSpecificationStatement::pool_size-1].p_freepointer = nullptr;
   71977             : 
   71978          13 :         SgAttributeSpecificationStatement::pools.push_back ( (unsigned char *) alloc );
   71979          13 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgAttributeSpecificationStatement::pool_size * sizeof(SgAttributeSpecificationStatement), V_SgAttributeSpecificationStatement ) );
   71980          13 :         SgAttributeSpecificationStatement::next_node = alloc;
   71981             :     }
   71982         551 :     ROSE_ASSERT(SgAttributeSpecificationStatement::next_node != nullptr);
   71983             : 
   71984         551 :     SgAttributeSpecificationStatement * object = SgAttributeSpecificationStatement::next_node;
   71985         551 :     SgAttributeSpecificationStatement::next_node = (SgAttributeSpecificationStatement*)(object->p_freepointer);
   71986             : 
   71987             : #if ROSE_ALLOC_TRACE == 2
   71988             :     printf("SgAttributeSpecificationStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgAttributeSpecificationStatement::next_node);
   71989             : #endif
   71990             : 
   71991         551 :     SgNode * fp = object->p_freepointer;
   71992             : #if ROSE_ALLOC_MEMSET == 1
   71993             : #elif ROSE_ALLOC_MEMSET == 2
   71994             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgAttributeSpecificationStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   71995             : #elif ROSE_ALLOC_MEMSET == 3
   71996             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgAttributeSpecificationStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   71997             : #endif
   71998         551 :     object->p_freepointer = fp;
   71999             : 
   72000             : #if ROSE_ALLOC_TRACE == 2
   72001             : //    printf("SgAttributeSpecificationStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgAttributeSpecificationStatement::next_node);
   72002             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   72003             :     Rose::MemPool::snapshot(oss.str());
   72004             :     alloc_trace_cnt++;
   72005             : #endif
   72006             : 
   72007         551 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   72008             : 
   72009         551 :     ALLOC_MUTEX(SgAttributeSpecificationStatement, unlock);
   72010             : 
   72011             :     return object;
   72012             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   72013             : }
   72014             : 
   72015             : 
   72016             : 
   72017             : /*! \brief Delete operator for SgAttributeSpecificationStatement.
   72018             : 
   72019             :    This delete operator implements deallocation using memory pools to 
   72020             :    provide most efficent use of the heap within construction of large ASTs.
   72021             : 
   72022             : \internal The new and delete operators use the lower level C malloc/free
   72023             :    function calls for performance and to make sure that mixing of malloc/free
   72024             :    and new/delete by the used can be caught more readily.  This may change
   72025             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   72026             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   72027             :    deallocate memory allocated using ROSE_MALLOC.
   72028             : */
   72029           0 : void SgAttributeSpecificationStatement::operator delete(void *Pointer, size_t Size)
   72030             : {
   72031             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   72032             :      * or throwing an exception. */
   72033           0 :     ALLOC_MUTEX(SgAttributeSpecificationStatement, lock);
   72034             : 
   72035             : #if USE_CPP_NEW_DELETE_OPERATORS
   72036             :     ROSE_FREE(Pointer);
   72037             : #else
   72038             : #if ROSE_PEDANTIC_ALLOC
   72039             :     ROSE_ASSERT(Size == sizeof(SgAttributeSpecificationStatement));
   72040             : #else
   72041           0 :     if (Size != sizeof(SgAttributeSpecificationStatement)) {
   72042           0 :       ROSE_FREE(Pointer);
   72043           0 :       ALLOC_MUTEX(SgAttributeSpecificationStatement, unlock);
   72044             :       return;
   72045             :     }
   72046             : #endif
   72047             : 
   72048           0 :     SgAttributeSpecificationStatement * object = (SgAttributeSpecificationStatement*) Pointer;
   72049           0 :     ROSE_ASSERT(object != nullptr);
   72050             : 
   72051             : #if ROSE_ALLOC_TRACE == 2
   72052             : //  printf("SgAttributeSpecificationStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgAttributeSpecificationStatement::next_node);
   72053             :     printf("SgAttributeSpecificationStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgAttributeSpecificationStatement::next_node);
   72054             : #endif
   72055             : 
   72056             : #if ROSE_PEDANTIC_ALLOC
   72057             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   72058             : #endif
   72059             : 
   72060             : #if ROSE_ALLOC_MEMSET == 1
   72061             : #elif ROSE_ALLOC_MEMSET == 2
   72062             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgAttributeSpecificationStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   72063             : #elif ROSE_ALLOC_MEMSET == 3
   72064             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgAttributeSpecificationStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   72065             : #endif
   72066             : 
   72067             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   72068             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   72069             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   72070             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   72071             : #else
   72072           0 :     object->p_freepointer = SgAttributeSpecificationStatement::next_node;
   72073           0 :     SgAttributeSpecificationStatement::next_node = object;
   72074             : #endif
   72075             : 
   72076             : #if ROSE_ALLOC_TRACE == 2
   72077             : //  printf("SgAttributeSpecificationStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgAttributeSpecificationStatement::next_node);
   72078             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   72079             :     Rose::MemPool::snapshot(oss.str());
   72080             :     alloc_trace_cnt++;
   72081             : #endif
   72082             : 
   72083             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   72084             : 
   72085           0 :     ALLOC_MUTEX(SgAttributeSpecificationStatement, unlock);
   72086             : }
   72087             : 
   72088             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   72089             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   72090             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   72091             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   72092             : // Also, note comment below from Robb (copied from the Common.code file).
   72093             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   72094             : //
   72095             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   72096             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   72097             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   72098             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   72099             : #if 0
   72100             : void SgAttributeSpecificationStatement::operator delete(void* pointer) { SgAttributeSpecificationStatement::operator delete (pointer, sizeof(SgAttributeSpecificationStatement)); };
   72101             : #endif
   72102             : /* #line 72103 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   72103             : 
   72104             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   72105             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   72106             : // obviously imply C++.
   72107             : 
   72108             : // This implements the support within ROSE for memory pools.  Memory pools
   72109             : // support the most condensed usage of memory within the construction of
   72110             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   72111             : // by a new operator written for each class.
   72112             : 
   72113             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   72114             :     // User wants multi-thread support and POSIX threads are available.
   72115             : #   include <pthread.h>
   72116             :     static pthread_mutex_t SgFormatStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   72117             : #else
   72118             :      // Cause synchronization to be skipped.
   72119             : #    ifndef ALLOC_MUTEX
   72120             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   72121             : #    endif
   72122             : #    ifdef _REENTRANT
   72123             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   72124             : #       ifdef _MSC_VER
   72125             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   72126             : #       else
   72127             : #           warning "POSIX threads are not available; synchronization being skipped"
   72128             : #       endif
   72129             : #    endif
   72130             : #endif
   72131             : 
   72132             : #ifndef ROSE_ALLOC_TRACE
   72133             : #  define ROSE_ALLOC_TRACE 0
   72134             : #endif
   72135             : 
   72136             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   72137             : #define ROSE_ALLOC_TRACE_CNT
   72138             : #include "memory-pool-snapshot.h"
   72139             : unsigned long alloc_trace_cnt = 0;
   72140             : #endif
   72141             : 
   72142             : #if ROSE_ALLOC_TRACE
   72143             : const unsigned SgFormatStatement::pool_size = 5;
   72144             : #else
   72145             : const unsigned SgFormatStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   72146             : #endif
   72147             : 
   72148             : #ifndef ROSE_ALLOC_MEMSET
   72149             : #  define ROSE_ALLOC_MEMSET 0
   72150             : #endif
   72151             : 
   72152             : #ifndef ROSE_PEDANTIC_ALLOC
   72153             : #  define ROSE_PEDANTIC_ALLOC 0
   72154             : #endif
   72155             : 
   72156             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   72157             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   72158             : #endif
   72159             : 
   72160             : #if !defined(SGNODE__ALL_POOLS)
   72161             : #define SGNODE__ALL_POOLS
   72162             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   72163             : #endif
   72164             : 
   72165             : SgFormatStatement* SgFormatStatement::next_node = nullptr;
   72166             : std::vector<unsigned char*> SgFormatStatement::pools;
   72167             : 
   72168             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   72169             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   72170             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   72171             : // around this macro definition rather than each use).
   72172             : #ifndef ALLOC_MUTEX
   72173             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   72174             :         do {                                                                     \
   72175             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   72176             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   72177             :                 abort();                                                         \
   72178             :             }                                                                    \
   72179             :         } while (0);
   72180             : #endif
   72181             : 
   72182             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   72183             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   72184             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   72185             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   72186             : 
   72187             : /*! \brief New operator for SgFormatStatement.
   72188             : 
   72189             :    This new operator implements memory pools to provide most efficent 
   72190             :    use of the heap within construction of large ASTs.
   72191             : 
   72192             : \internal The new and delete operators use the lower level C malloc/free
   72193             :    function calls for performance and to make sure that mixing of malloc/free
   72194             :    and new/delete by the used can be caught more readily.  This may change
   72195             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   72196             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   72197             :    deallocate memory allocated using ROSE_MALLOC.
   72198             : */
   72199           0 : void *SgFormatStatement::operator new ( size_t Size )
   72200             : {
   72201             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   72202             :      * returning or throwing an exception. */
   72203           0 :     ALLOC_MUTEX(SgFormatStatement, lock);
   72204             : 
   72205             : #if ROSE_ALLOC_TRACE == 2
   72206             : //    printf("SgFormatStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgFormatStatement::next_node);
   72207             : #endif
   72208             : 
   72209             : #if USE_CPP_NEW_DELETE_OPERATORS
   72210             :     void *mem = ROSE_MALLOC(Size);
   72211             :     ALLOC_MUTEX(SgFormatStatement, unlock);
   72212             :     return mem;
   72213             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   72214             : #if ROSE_PEDANTIC_ALLOC
   72215             :     ROSE_ASSERT(Size == sizeof(SgFormatStatement));
   72216             : #else
   72217           0 :     if (Size != sizeof(SgFormatStatement)) {
   72218           0 :       void * object = ROSE_MALLOC(Size);
   72219           0 :       ALLOC_MUTEX(SgFormatStatement, unlock);
   72220             :       return object;
   72221             :     }
   72222             : #endif
   72223             : 
   72224           0 :     if (SgFormatStatement::next_node == nullptr) {
   72225           0 :         SgFormatStatement * alloc = (SgFormatStatement*) ROSE_MALLOC ( SgFormatStatement::pool_size * sizeof(SgFormatStatement) );
   72226           0 :         ROSE_ASSERT(alloc != nullptr);
   72227             : 
   72228             : #if ROSE_ALLOC_TRACE == 2
   72229             : //        printf("SgFormatStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgFormatStatement::pools.size(), alloc, alloc + SgFormatStatement::pool_size);
   72230             : #endif
   72231             : 
   72232             : #if ROSE_ALLOC_MEMSET == 1
   72233             : #elif ROSE_ALLOC_MEMSET == 2
   72234             :         memset(alloc, 0x00, SgFormatStatement::pool_size * sizeof(SgFormatStatement));
   72235             : #elif ROSE_ALLOC_MEMSET == 3
   72236             :         memset(alloc, 0xAA, SgFormatStatement::pool_size * sizeof(SgFormatStatement));
   72237             : #endif
   72238           0 :         for (unsigned i=0; i < SgFormatStatement::pool_size-1; i++) {
   72239           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
   72240             :         }
   72241           0 :         alloc[SgFormatStatement::pool_size-1].p_freepointer = nullptr;
   72242             : 
   72243           0 :         SgFormatStatement::pools.push_back ( (unsigned char *) alloc );
   72244           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgFormatStatement::pool_size * sizeof(SgFormatStatement), V_SgFormatStatement ) );
   72245           0 :         SgFormatStatement::next_node = alloc;
   72246             :     }
   72247           0 :     ROSE_ASSERT(SgFormatStatement::next_node != nullptr);
   72248             : 
   72249           0 :     SgFormatStatement * object = SgFormatStatement::next_node;
   72250           0 :     SgFormatStatement::next_node = (SgFormatStatement*)(object->p_freepointer);
   72251             : 
   72252             : #if ROSE_ALLOC_TRACE == 2
   72253             :     printf("SgFormatStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgFormatStatement::next_node);
   72254             : #endif
   72255             : 
   72256           0 :     SgNode * fp = object->p_freepointer;
   72257             : #if ROSE_ALLOC_MEMSET == 1
   72258             : #elif ROSE_ALLOC_MEMSET == 2
   72259             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgFormatStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   72260             : #elif ROSE_ALLOC_MEMSET == 3
   72261             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgFormatStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   72262             : #endif
   72263           0 :     object->p_freepointer = fp;
   72264             : 
   72265             : #if ROSE_ALLOC_TRACE == 2
   72266             : //    printf("SgFormatStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgFormatStatement::next_node);
   72267             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   72268             :     Rose::MemPool::snapshot(oss.str());
   72269             :     alloc_trace_cnt++;
   72270             : #endif
   72271             : 
   72272           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   72273             : 
   72274           0 :     ALLOC_MUTEX(SgFormatStatement, unlock);
   72275             : 
   72276             :     return object;
   72277             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   72278             : }
   72279             : 
   72280             : 
   72281             : 
   72282             : /*! \brief Delete operator for SgFormatStatement.
   72283             : 
   72284             :    This delete operator implements deallocation using memory pools to 
   72285             :    provide most efficent use of the heap within construction of large ASTs.
   72286             : 
   72287             : \internal The new and delete operators use the lower level C malloc/free
   72288             :    function calls for performance and to make sure that mixing of malloc/free
   72289             :    and new/delete by the used can be caught more readily.  This may change
   72290             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   72291             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   72292             :    deallocate memory allocated using ROSE_MALLOC.
   72293             : */
   72294           0 : void SgFormatStatement::operator delete(void *Pointer, size_t Size)
   72295             : {
   72296             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   72297             :      * or throwing an exception. */
   72298           0 :     ALLOC_MUTEX(SgFormatStatement, lock);
   72299             : 
   72300             : #if USE_CPP_NEW_DELETE_OPERATORS
   72301             :     ROSE_FREE(Pointer);
   72302             : #else
   72303             : #if ROSE_PEDANTIC_ALLOC
   72304             :     ROSE_ASSERT(Size == sizeof(SgFormatStatement));
   72305             : #else
   72306           0 :     if (Size != sizeof(SgFormatStatement)) {
   72307           0 :       ROSE_FREE(Pointer);
   72308           0 :       ALLOC_MUTEX(SgFormatStatement, unlock);
   72309             :       return;
   72310             :     }
   72311             : #endif
   72312             : 
   72313           0 :     SgFormatStatement * object = (SgFormatStatement*) Pointer;
   72314           0 :     ROSE_ASSERT(object != nullptr);
   72315             : 
   72316             : #if ROSE_ALLOC_TRACE == 2
   72317             : //  printf("SgFormatStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgFormatStatement::next_node);
   72318             :     printf("SgFormatStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgFormatStatement::next_node);
   72319             : #endif
   72320             : 
   72321             : #if ROSE_PEDANTIC_ALLOC
   72322             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   72323             : #endif
   72324             : 
   72325             : #if ROSE_ALLOC_MEMSET == 1
   72326             : #elif ROSE_ALLOC_MEMSET == 2
   72327             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgFormatStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   72328             : #elif ROSE_ALLOC_MEMSET == 3
   72329             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgFormatStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   72330             : #endif
   72331             : 
   72332             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   72333             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   72334             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   72335             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   72336             : #else
   72337           0 :     object->p_freepointer = SgFormatStatement::next_node;
   72338           0 :     SgFormatStatement::next_node = object;
   72339             : #endif
   72340             : 
   72341             : #if ROSE_ALLOC_TRACE == 2
   72342             : //  printf("SgFormatStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgFormatStatement::next_node);
   72343             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   72344             :     Rose::MemPool::snapshot(oss.str());
   72345             :     alloc_trace_cnt++;
   72346             : #endif
   72347             : 
   72348             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   72349             : 
   72350           0 :     ALLOC_MUTEX(SgFormatStatement, unlock);
   72351             : }
   72352             : 
   72353             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   72354             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   72355             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   72356             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   72357             : // Also, note comment below from Robb (copied from the Common.code file).
   72358             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   72359             : //
   72360             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   72361             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   72362             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   72363             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   72364             : #if 0
   72365             : void SgFormatStatement::operator delete(void* pointer) { SgFormatStatement::operator delete (pointer, sizeof(SgFormatStatement)); };
   72366             : #endif
   72367             : /* #line 72368 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   72368             : 
   72369             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   72370             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   72371             : // obviously imply C++.
   72372             : 
   72373             : // This implements the support within ROSE for memory pools.  Memory pools
   72374             : // support the most condensed usage of memory within the construction of
   72375             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   72376             : // by a new operator written for each class.
   72377             : 
   72378             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   72379             :     // User wants multi-thread support and POSIX threads are available.
   72380             : #   include <pthread.h>
   72381             :     static pthread_mutex_t SgTemplateDeclaration_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   72382             : #else
   72383             :      // Cause synchronization to be skipped.
   72384             : #    ifndef ALLOC_MUTEX
   72385             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   72386             : #    endif
   72387             : #    ifdef _REENTRANT
   72388             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   72389             : #       ifdef _MSC_VER
   72390             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   72391             : #       else
   72392             : #           warning "POSIX threads are not available; synchronization being skipped"
   72393             : #       endif
   72394             : #    endif
   72395             : #endif
   72396             : 
   72397             : #ifndef ROSE_ALLOC_TRACE
   72398             : #  define ROSE_ALLOC_TRACE 0
   72399             : #endif
   72400             : 
   72401             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   72402             : #define ROSE_ALLOC_TRACE_CNT
   72403             : #include "memory-pool-snapshot.h"
   72404             : unsigned long alloc_trace_cnt = 0;
   72405             : #endif
   72406             : 
   72407             : #if ROSE_ALLOC_TRACE
   72408             : const unsigned SgTemplateDeclaration::pool_size = 5;
   72409             : #else
   72410             : const unsigned SgTemplateDeclaration::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   72411             : #endif
   72412             : 
   72413             : #ifndef ROSE_ALLOC_MEMSET
   72414             : #  define ROSE_ALLOC_MEMSET 0
   72415             : #endif
   72416             : 
   72417             : #ifndef ROSE_PEDANTIC_ALLOC
   72418             : #  define ROSE_PEDANTIC_ALLOC 0
   72419             : #endif
   72420             : 
   72421             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   72422             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   72423             : #endif
   72424             : 
   72425             : #if !defined(SGNODE__ALL_POOLS)
   72426             : #define SGNODE__ALL_POOLS
   72427             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   72428             : #endif
   72429             : 
   72430             : SgTemplateDeclaration* SgTemplateDeclaration::next_node = nullptr;
   72431             : std::vector<unsigned char*> SgTemplateDeclaration::pools;
   72432             : 
   72433             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   72434             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   72435             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   72436             : // around this macro definition rather than each use).
   72437             : #ifndef ALLOC_MUTEX
   72438             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   72439             :         do {                                                                     \
   72440             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   72441             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   72442             :                 abort();                                                         \
   72443             :             }                                                                    \
   72444             :         } while (0);
   72445             : #endif
   72446             : 
   72447             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   72448             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   72449             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   72450             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   72451             : 
   72452             : /*! \brief New operator for SgTemplateDeclaration.
   72453             : 
   72454             :    This new operator implements memory pools to provide most efficent 
   72455             :    use of the heap within construction of large ASTs.
   72456             : 
   72457             : \internal The new and delete operators use the lower level C malloc/free
   72458             :    function calls for performance and to make sure that mixing of malloc/free
   72459             :    and new/delete by the used can be caught more readily.  This may change
   72460             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   72461             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   72462             :    deallocate memory allocated using ROSE_MALLOC.
   72463             : */
   72464           0 : void *SgTemplateDeclaration::operator new ( size_t Size )
   72465             : {
   72466             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   72467             :      * returning or throwing an exception. */
   72468           0 :     ALLOC_MUTEX(SgTemplateDeclaration, lock);
   72469             : 
   72470             : #if ROSE_ALLOC_TRACE == 2
   72471             : //    printf("SgTemplateDeclaration::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgTemplateDeclaration::next_node);
   72472             : #endif
   72473             : 
   72474             : #if USE_CPP_NEW_DELETE_OPERATORS
   72475             :     void *mem = ROSE_MALLOC(Size);
   72476             :     ALLOC_MUTEX(SgTemplateDeclaration, unlock);
   72477             :     return mem;
   72478             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   72479             : #if ROSE_PEDANTIC_ALLOC
   72480             :     ROSE_ASSERT(Size == sizeof(SgTemplateDeclaration));
   72481             : #else
   72482           0 :     if (Size != sizeof(SgTemplateDeclaration)) {
   72483           0 :       void * object = ROSE_MALLOC(Size);
   72484           0 :       ALLOC_MUTEX(SgTemplateDeclaration, unlock);
   72485             :       return object;
   72486             :     }
   72487             : #endif
   72488             : 
   72489           0 :     if (SgTemplateDeclaration::next_node == nullptr) {
   72490           0 :         SgTemplateDeclaration * alloc = (SgTemplateDeclaration*) ROSE_MALLOC ( SgTemplateDeclaration::pool_size * sizeof(SgTemplateDeclaration) );
   72491           0 :         ROSE_ASSERT(alloc != nullptr);
   72492             : 
   72493             : #if ROSE_ALLOC_TRACE == 2
   72494             : //        printf("SgTemplateDeclaration::alloc\n  block[%zi] = [ %p , %p [\n", SgTemplateDeclaration::pools.size(), alloc, alloc + SgTemplateDeclaration::pool_size);
   72495             : #endif
   72496             : 
   72497             : #if ROSE_ALLOC_MEMSET == 1
   72498             : #elif ROSE_ALLOC_MEMSET == 2
   72499             :         memset(alloc, 0x00, SgTemplateDeclaration::pool_size * sizeof(SgTemplateDeclaration));
   72500             : #elif ROSE_ALLOC_MEMSET == 3
   72501             :         memset(alloc, 0xAA, SgTemplateDeclaration::pool_size * sizeof(SgTemplateDeclaration));
   72502             : #endif
   72503           0 :         for (unsigned i=0; i < SgTemplateDeclaration::pool_size-1; i++) {
   72504           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
   72505             :         }
   72506           0 :         alloc[SgTemplateDeclaration::pool_size-1].p_freepointer = nullptr;
   72507             : 
   72508           0 :         SgTemplateDeclaration::pools.push_back ( (unsigned char *) alloc );
   72509           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgTemplateDeclaration::pool_size * sizeof(SgTemplateDeclaration), V_SgTemplateDeclaration ) );
   72510           0 :         SgTemplateDeclaration::next_node = alloc;
   72511             :     }
   72512           0 :     ROSE_ASSERT(SgTemplateDeclaration::next_node != nullptr);
   72513             : 
   72514           0 :     SgTemplateDeclaration * object = SgTemplateDeclaration::next_node;
   72515           0 :     SgTemplateDeclaration::next_node = (SgTemplateDeclaration*)(object->p_freepointer);
   72516             : 
   72517             : #if ROSE_ALLOC_TRACE == 2
   72518             :     printf("SgTemplateDeclaration::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTemplateDeclaration::next_node);
   72519             : #endif
   72520             : 
   72521           0 :     SgNode * fp = object->p_freepointer;
   72522             : #if ROSE_ALLOC_MEMSET == 1
   72523             : #elif ROSE_ALLOC_MEMSET == 2
   72524             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgTemplateDeclaration) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   72525             : #elif ROSE_ALLOC_MEMSET == 3
   72526             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgTemplateDeclaration) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   72527             : #endif
   72528           0 :     object->p_freepointer = fp;
   72529             : 
   72530             : #if ROSE_ALLOC_TRACE == 2
   72531             : //    printf("SgTemplateDeclaration::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTemplateDeclaration::next_node);
   72532             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   72533             :     Rose::MemPool::snapshot(oss.str());
   72534             :     alloc_trace_cnt++;
   72535             : #endif
   72536             : 
   72537           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   72538             : 
   72539           0 :     ALLOC_MUTEX(SgTemplateDeclaration, unlock);
   72540             : 
   72541             :     return object;
   72542             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   72543             : }
   72544             : 
   72545             : 
   72546             : 
   72547             : /*! \brief Delete operator for SgTemplateDeclaration.
   72548             : 
   72549             :    This delete operator implements deallocation using memory pools to 
   72550             :    provide most efficent use of the heap within construction of large ASTs.
   72551             : 
   72552             : \internal The new and delete operators use the lower level C malloc/free
   72553             :    function calls for performance and to make sure that mixing of malloc/free
   72554             :    and new/delete by the used can be caught more readily.  This may change
   72555             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   72556             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   72557             :    deallocate memory allocated using ROSE_MALLOC.
   72558             : */
   72559           0 : void SgTemplateDeclaration::operator delete(void *Pointer, size_t Size)
   72560             : {
   72561             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   72562             :      * or throwing an exception. */
   72563           0 :     ALLOC_MUTEX(SgTemplateDeclaration, lock);
   72564             : 
   72565             : #if USE_CPP_NEW_DELETE_OPERATORS
   72566             :     ROSE_FREE(Pointer);
   72567             : #else
   72568             : #if ROSE_PEDANTIC_ALLOC
   72569             :     ROSE_ASSERT(Size == sizeof(SgTemplateDeclaration));
   72570             : #else
   72571           0 :     if (Size != sizeof(SgTemplateDeclaration)) {
   72572           0 :       ROSE_FREE(Pointer);
   72573           0 :       ALLOC_MUTEX(SgTemplateDeclaration, unlock);
   72574             :       return;
   72575             :     }
   72576             : #endif
   72577             : 
   72578           0 :     SgTemplateDeclaration * object = (SgTemplateDeclaration*) Pointer;
   72579           0 :     ROSE_ASSERT(object != nullptr);
   72580             : 
   72581             : #if ROSE_ALLOC_TRACE == 2
   72582             : //  printf("SgTemplateDeclaration::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTemplateDeclaration::next_node);
   72583             :     printf("SgTemplateDeclaration::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTemplateDeclaration::next_node);
   72584             : #endif
   72585             : 
   72586             : #if ROSE_PEDANTIC_ALLOC
   72587             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   72588             : #endif
   72589             : 
   72590             : #if ROSE_ALLOC_MEMSET == 1
   72591             : #elif ROSE_ALLOC_MEMSET == 2
   72592             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgTemplateDeclaration) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   72593             : #elif ROSE_ALLOC_MEMSET == 3
   72594             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgTemplateDeclaration) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   72595             : #endif
   72596             : 
   72597             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   72598             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   72599             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   72600             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   72601             : #else
   72602           0 :     object->p_freepointer = SgTemplateDeclaration::next_node;
   72603           0 :     SgTemplateDeclaration::next_node = object;
   72604             : #endif
   72605             : 
   72606             : #if ROSE_ALLOC_TRACE == 2
   72607             : //  printf("SgTemplateDeclaration::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTemplateDeclaration::next_node);
   72608             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   72609             :     Rose::MemPool::snapshot(oss.str());
   72610             :     alloc_trace_cnt++;
   72611             : #endif
   72612             : 
   72613             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   72614             : 
   72615           0 :     ALLOC_MUTEX(SgTemplateDeclaration, unlock);
   72616             : }
   72617             : 
   72618             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   72619             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   72620             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   72621             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   72622             : // Also, note comment below from Robb (copied from the Common.code file).
   72623             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   72624             : //
   72625             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   72626             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   72627             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   72628             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   72629             : #if 0
   72630             : void SgTemplateDeclaration::operator delete(void* pointer) { SgTemplateDeclaration::operator delete (pointer, sizeof(SgTemplateDeclaration)); };
   72631             : #endif
   72632             : /* #line 72633 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   72633             : 
   72634             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   72635             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   72636             : // obviously imply C++.
   72637             : 
   72638             : // This implements the support within ROSE for memory pools.  Memory pools
   72639             : // support the most condensed usage of memory within the construction of
   72640             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   72641             : // by a new operator written for each class.
   72642             : 
   72643             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   72644             :     // User wants multi-thread support and POSIX threads are available.
   72645             : #   include <pthread.h>
   72646             :     static pthread_mutex_t SgTemplateInstantiationDirectiveStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   72647             : #else
   72648             :      // Cause synchronization to be skipped.
   72649             : #    ifndef ALLOC_MUTEX
   72650             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   72651             : #    endif
   72652             : #    ifdef _REENTRANT
   72653             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   72654             : #       ifdef _MSC_VER
   72655             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   72656             : #       else
   72657             : #           warning "POSIX threads are not available; synchronization being skipped"
   72658             : #       endif
   72659             : #    endif
   72660             : #endif
   72661             : 
   72662             : #ifndef ROSE_ALLOC_TRACE
   72663             : #  define ROSE_ALLOC_TRACE 0
   72664             : #endif
   72665             : 
   72666             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   72667             : #define ROSE_ALLOC_TRACE_CNT
   72668             : #include "memory-pool-snapshot.h"
   72669             : unsigned long alloc_trace_cnt = 0;
   72670             : #endif
   72671             : 
   72672             : #if ROSE_ALLOC_TRACE
   72673             : const unsigned SgTemplateInstantiationDirectiveStatement::pool_size = 5;
   72674             : #else
   72675             : const unsigned SgTemplateInstantiationDirectiveStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   72676             : #endif
   72677             : 
   72678             : #ifndef ROSE_ALLOC_MEMSET
   72679             : #  define ROSE_ALLOC_MEMSET 0
   72680             : #endif
   72681             : 
   72682             : #ifndef ROSE_PEDANTIC_ALLOC
   72683             : #  define ROSE_PEDANTIC_ALLOC 0
   72684             : #endif
   72685             : 
   72686             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   72687             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   72688             : #endif
   72689             : 
   72690             : #if !defined(SGNODE__ALL_POOLS)
   72691             : #define SGNODE__ALL_POOLS
   72692             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   72693             : #endif
   72694             : 
   72695             : SgTemplateInstantiationDirectiveStatement* SgTemplateInstantiationDirectiveStatement::next_node = nullptr;
   72696             : std::vector<unsigned char*> SgTemplateInstantiationDirectiveStatement::pools;
   72697             : 
   72698             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   72699             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   72700             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   72701             : // around this macro definition rather than each use).
   72702             : #ifndef ALLOC_MUTEX
   72703             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   72704             :         do {                                                                     \
   72705             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   72706             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   72707             :                 abort();                                                         \
   72708             :             }                                                                    \
   72709             :         } while (0);
   72710             : #endif
   72711             : 
   72712             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   72713             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   72714             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   72715             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   72716             : 
   72717             : /*! \brief New operator for SgTemplateInstantiationDirectiveStatement.
   72718             : 
   72719             :    This new operator implements memory pools to provide most efficent 
   72720             :    use of the heap within construction of large ASTs.
   72721             : 
   72722             : \internal The new and delete operators use the lower level C malloc/free
   72723             :    function calls for performance and to make sure that mixing of malloc/free
   72724             :    and new/delete by the used can be caught more readily.  This may change
   72725             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   72726             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   72727             :    deallocate memory allocated using ROSE_MALLOC.
   72728             : */
   72729        1120 : void *SgTemplateInstantiationDirectiveStatement::operator new ( size_t Size )
   72730             : {
   72731             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   72732             :      * returning or throwing an exception. */
   72733        1120 :     ALLOC_MUTEX(SgTemplateInstantiationDirectiveStatement, lock);
   72734             : 
   72735             : #if ROSE_ALLOC_TRACE == 2
   72736             : //    printf("SgTemplateInstantiationDirectiveStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgTemplateInstantiationDirectiveStatement::next_node);
   72737             : #endif
   72738             : 
   72739             : #if USE_CPP_NEW_DELETE_OPERATORS
   72740             :     void *mem = ROSE_MALLOC(Size);
   72741             :     ALLOC_MUTEX(SgTemplateInstantiationDirectiveStatement, unlock);
   72742             :     return mem;
   72743             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   72744             : #if ROSE_PEDANTIC_ALLOC
   72745             :     ROSE_ASSERT(Size == sizeof(SgTemplateInstantiationDirectiveStatement));
   72746             : #else
   72747        1120 :     if (Size != sizeof(SgTemplateInstantiationDirectiveStatement)) {
   72748           0 :       void * object = ROSE_MALLOC(Size);
   72749           0 :       ALLOC_MUTEX(SgTemplateInstantiationDirectiveStatement, unlock);
   72750             :       return object;
   72751             :     }
   72752             : #endif
   72753             : 
   72754        1120 :     if (SgTemplateInstantiationDirectiveStatement::next_node == nullptr) {
   72755          10 :         SgTemplateInstantiationDirectiveStatement * alloc = (SgTemplateInstantiationDirectiveStatement*) ROSE_MALLOC ( SgTemplateInstantiationDirectiveStatement::pool_size * sizeof(SgTemplateInstantiationDirectiveStatement) );
   72756          10 :         ROSE_ASSERT(alloc != nullptr);
   72757             : 
   72758             : #if ROSE_ALLOC_TRACE == 2
   72759             : //        printf("SgTemplateInstantiationDirectiveStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgTemplateInstantiationDirectiveStatement::pools.size(), alloc, alloc + SgTemplateInstantiationDirectiveStatement::pool_size);
   72760             : #endif
   72761             : 
   72762             : #if ROSE_ALLOC_MEMSET == 1
   72763             : #elif ROSE_ALLOC_MEMSET == 2
   72764             :         memset(alloc, 0x00, SgTemplateInstantiationDirectiveStatement::pool_size * sizeof(SgTemplateInstantiationDirectiveStatement));
   72765             : #elif ROSE_ALLOC_MEMSET == 3
   72766             :         memset(alloc, 0xAA, SgTemplateInstantiationDirectiveStatement::pool_size * sizeof(SgTemplateInstantiationDirectiveStatement));
   72767             : #endif
   72768       20000 :         for (unsigned i=0; i < SgTemplateInstantiationDirectiveStatement::pool_size-1; i++) {
   72769       19990 :           alloc[i].p_freepointer = &(alloc[i+1]);
   72770             :         }
   72771          10 :         alloc[SgTemplateInstantiationDirectiveStatement::pool_size-1].p_freepointer = nullptr;
   72772             : 
   72773          10 :         SgTemplateInstantiationDirectiveStatement::pools.push_back ( (unsigned char *) alloc );
   72774          10 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgTemplateInstantiationDirectiveStatement::pool_size * sizeof(SgTemplateInstantiationDirectiveStatement), V_SgTemplateInstantiationDirectiveStatement ) );
   72775          10 :         SgTemplateInstantiationDirectiveStatement::next_node = alloc;
   72776             :     }
   72777        1120 :     ROSE_ASSERT(SgTemplateInstantiationDirectiveStatement::next_node != nullptr);
   72778             : 
   72779        1120 :     SgTemplateInstantiationDirectiveStatement * object = SgTemplateInstantiationDirectiveStatement::next_node;
   72780        1120 :     SgTemplateInstantiationDirectiveStatement::next_node = (SgTemplateInstantiationDirectiveStatement*)(object->p_freepointer);
   72781             : 
   72782             : #if ROSE_ALLOC_TRACE == 2
   72783             :     printf("SgTemplateInstantiationDirectiveStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTemplateInstantiationDirectiveStatement::next_node);
   72784             : #endif
   72785             : 
   72786        1120 :     SgNode * fp = object->p_freepointer;
   72787             : #if ROSE_ALLOC_MEMSET == 1
   72788             : #elif ROSE_ALLOC_MEMSET == 2
   72789             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgTemplateInstantiationDirectiveStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   72790             : #elif ROSE_ALLOC_MEMSET == 3
   72791             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgTemplateInstantiationDirectiveStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   72792             : #endif
   72793        1120 :     object->p_freepointer = fp;
   72794             : 
   72795             : #if ROSE_ALLOC_TRACE == 2
   72796             : //    printf("SgTemplateInstantiationDirectiveStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTemplateInstantiationDirectiveStatement::next_node);
   72797             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   72798             :     Rose::MemPool::snapshot(oss.str());
   72799             :     alloc_trace_cnt++;
   72800             : #endif
   72801             : 
   72802        1120 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   72803             : 
   72804        1120 :     ALLOC_MUTEX(SgTemplateInstantiationDirectiveStatement, unlock);
   72805             : 
   72806             :     return object;
   72807             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   72808             : }
   72809             : 
   72810             : 
   72811             : 
   72812             : /*! \brief Delete operator for SgTemplateInstantiationDirectiveStatement.
   72813             : 
   72814             :    This delete operator implements deallocation using memory pools to 
   72815             :    provide most efficent use of the heap within construction of large ASTs.
   72816             : 
   72817             : \internal The new and delete operators use the lower level C malloc/free
   72818             :    function calls for performance and to make sure that mixing of malloc/free
   72819             :    and new/delete by the used can be caught more readily.  This may change
   72820             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   72821             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   72822             :    deallocate memory allocated using ROSE_MALLOC.
   72823             : */
   72824         248 : void SgTemplateInstantiationDirectiveStatement::operator delete(void *Pointer, size_t Size)
   72825             : {
   72826             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   72827             :      * or throwing an exception. */
   72828         248 :     ALLOC_MUTEX(SgTemplateInstantiationDirectiveStatement, lock);
   72829             : 
   72830             : #if USE_CPP_NEW_DELETE_OPERATORS
   72831             :     ROSE_FREE(Pointer);
   72832             : #else
   72833             : #if ROSE_PEDANTIC_ALLOC
   72834             :     ROSE_ASSERT(Size == sizeof(SgTemplateInstantiationDirectiveStatement));
   72835             : #else
   72836         248 :     if (Size != sizeof(SgTemplateInstantiationDirectiveStatement)) {
   72837           0 :       ROSE_FREE(Pointer);
   72838           0 :       ALLOC_MUTEX(SgTemplateInstantiationDirectiveStatement, unlock);
   72839             :       return;
   72840             :     }
   72841             : #endif
   72842             : 
   72843         248 :     SgTemplateInstantiationDirectiveStatement * object = (SgTemplateInstantiationDirectiveStatement*) Pointer;
   72844         248 :     ROSE_ASSERT(object != nullptr);
   72845             : 
   72846             : #if ROSE_ALLOC_TRACE == 2
   72847             : //  printf("SgTemplateInstantiationDirectiveStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTemplateInstantiationDirectiveStatement::next_node);
   72848             :     printf("SgTemplateInstantiationDirectiveStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTemplateInstantiationDirectiveStatement::next_node);
   72849             : #endif
   72850             : 
   72851             : #if ROSE_PEDANTIC_ALLOC
   72852             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   72853             : #endif
   72854             : 
   72855             : #if ROSE_ALLOC_MEMSET == 1
   72856             : #elif ROSE_ALLOC_MEMSET == 2
   72857             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgTemplateInstantiationDirectiveStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   72858             : #elif ROSE_ALLOC_MEMSET == 3
   72859             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgTemplateInstantiationDirectiveStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   72860             : #endif
   72861             : 
   72862             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   72863             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   72864             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   72865             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   72866             : #else
   72867         248 :     object->p_freepointer = SgTemplateInstantiationDirectiveStatement::next_node;
   72868         248 :     SgTemplateInstantiationDirectiveStatement::next_node = object;
   72869             : #endif
   72870             : 
   72871             : #if ROSE_ALLOC_TRACE == 2
   72872             : //  printf("SgTemplateInstantiationDirectiveStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTemplateInstantiationDirectiveStatement::next_node);
   72873             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   72874             :     Rose::MemPool::snapshot(oss.str());
   72875             :     alloc_trace_cnt++;
   72876             : #endif
   72877             : 
   72878             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   72879             : 
   72880         248 :     ALLOC_MUTEX(SgTemplateInstantiationDirectiveStatement, unlock);
   72881             : }
   72882             : 
   72883             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   72884             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   72885             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   72886             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   72887             : // Also, note comment below from Robb (copied from the Common.code file).
   72888             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   72889             : //
   72890             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   72891             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   72892             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   72893             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   72894             : #if 0
   72895             : void SgTemplateInstantiationDirectiveStatement::operator delete(void* pointer) { SgTemplateInstantiationDirectiveStatement::operator delete (pointer, sizeof(SgTemplateInstantiationDirectiveStatement)); };
   72896             : #endif
   72897             : /* #line 72898 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   72898             : 
   72899             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   72900             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   72901             : // obviously imply C++.
   72902             : 
   72903             : // This implements the support within ROSE for memory pools.  Memory pools
   72904             : // support the most condensed usage of memory within the construction of
   72905             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   72906             : // by a new operator written for each class.
   72907             : 
   72908             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   72909             :     // User wants multi-thread support and POSIX threads are available.
   72910             : #   include <pthread.h>
   72911             :     static pthread_mutex_t SgUseStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   72912             : #else
   72913             :      // Cause synchronization to be skipped.
   72914             : #    ifndef ALLOC_MUTEX
   72915             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   72916             : #    endif
   72917             : #    ifdef _REENTRANT
   72918             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   72919             : #       ifdef _MSC_VER
   72920             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   72921             : #       else
   72922             : #           warning "POSIX threads are not available; synchronization being skipped"
   72923             : #       endif
   72924             : #    endif
   72925             : #endif
   72926             : 
   72927             : #ifndef ROSE_ALLOC_TRACE
   72928             : #  define ROSE_ALLOC_TRACE 0
   72929             : #endif
   72930             : 
   72931             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   72932             : #define ROSE_ALLOC_TRACE_CNT
   72933             : #include "memory-pool-snapshot.h"
   72934             : unsigned long alloc_trace_cnt = 0;
   72935             : #endif
   72936             : 
   72937             : #if ROSE_ALLOC_TRACE
   72938             : const unsigned SgUseStatement::pool_size = 5;
   72939             : #else
   72940             : const unsigned SgUseStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   72941             : #endif
   72942             : 
   72943             : #ifndef ROSE_ALLOC_MEMSET
   72944             : #  define ROSE_ALLOC_MEMSET 0
   72945             : #endif
   72946             : 
   72947             : #ifndef ROSE_PEDANTIC_ALLOC
   72948             : #  define ROSE_PEDANTIC_ALLOC 0
   72949             : #endif
   72950             : 
   72951             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   72952             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   72953             : #endif
   72954             : 
   72955             : #if !defined(SGNODE__ALL_POOLS)
   72956             : #define SGNODE__ALL_POOLS
   72957             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   72958             : #endif
   72959             : 
   72960             : SgUseStatement* SgUseStatement::next_node = nullptr;
   72961             : std::vector<unsigned char*> SgUseStatement::pools;
   72962             : 
   72963             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   72964             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   72965             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   72966             : // around this macro definition rather than each use).
   72967             : #ifndef ALLOC_MUTEX
   72968             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   72969             :         do {                                                                     \
   72970             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   72971             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   72972             :                 abort();                                                         \
   72973             :             }                                                                    \
   72974             :         } while (0);
   72975             : #endif
   72976             : 
   72977             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   72978             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   72979             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   72980             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   72981             : 
   72982             : /*! \brief New operator for SgUseStatement.
   72983             : 
   72984             :    This new operator implements memory pools to provide most efficent 
   72985             :    use of the heap within construction of large ASTs.
   72986             : 
   72987             : \internal The new and delete operators use the lower level C malloc/free
   72988             :    function calls for performance and to make sure that mixing of malloc/free
   72989             :    and new/delete by the used can be caught more readily.  This may change
   72990             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   72991             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   72992             :    deallocate memory allocated using ROSE_MALLOC.
   72993             : */
   72994           0 : void *SgUseStatement::operator new ( size_t Size )
   72995             : {
   72996             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   72997             :      * returning or throwing an exception. */
   72998           0 :     ALLOC_MUTEX(SgUseStatement, lock);
   72999             : 
   73000             : #if ROSE_ALLOC_TRACE == 2
   73001             : //    printf("SgUseStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgUseStatement::next_node);
   73002             : #endif
   73003             : 
   73004             : #if USE_CPP_NEW_DELETE_OPERATORS
   73005             :     void *mem = ROSE_MALLOC(Size);
   73006             :     ALLOC_MUTEX(SgUseStatement, unlock);
   73007             :     return mem;
   73008             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   73009             : #if ROSE_PEDANTIC_ALLOC
   73010             :     ROSE_ASSERT(Size == sizeof(SgUseStatement));
   73011             : #else
   73012           0 :     if (Size != sizeof(SgUseStatement)) {
   73013           0 :       void * object = ROSE_MALLOC(Size);
   73014           0 :       ALLOC_MUTEX(SgUseStatement, unlock);
   73015             :       return object;
   73016             :     }
   73017             : #endif
   73018             : 
   73019           0 :     if (SgUseStatement::next_node == nullptr) {
   73020           0 :         SgUseStatement * alloc = (SgUseStatement*) ROSE_MALLOC ( SgUseStatement::pool_size * sizeof(SgUseStatement) );
   73021           0 :         ROSE_ASSERT(alloc != nullptr);
   73022             : 
   73023             : #if ROSE_ALLOC_TRACE == 2
   73024             : //        printf("SgUseStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgUseStatement::pools.size(), alloc, alloc + SgUseStatement::pool_size);
   73025             : #endif
   73026             : 
   73027             : #if ROSE_ALLOC_MEMSET == 1
   73028             : #elif ROSE_ALLOC_MEMSET == 2
   73029             :         memset(alloc, 0x00, SgUseStatement::pool_size * sizeof(SgUseStatement));
   73030             : #elif ROSE_ALLOC_MEMSET == 3
   73031             :         memset(alloc, 0xAA, SgUseStatement::pool_size * sizeof(SgUseStatement));
   73032             : #endif
   73033           0 :         for (unsigned i=0; i < SgUseStatement::pool_size-1; i++) {
   73034           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
   73035             :         }
   73036           0 :         alloc[SgUseStatement::pool_size-1].p_freepointer = nullptr;
   73037             : 
   73038           0 :         SgUseStatement::pools.push_back ( (unsigned char *) alloc );
   73039           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgUseStatement::pool_size * sizeof(SgUseStatement), V_SgUseStatement ) );
   73040           0 :         SgUseStatement::next_node = alloc;
   73041             :     }
   73042           0 :     ROSE_ASSERT(SgUseStatement::next_node != nullptr);
   73043             : 
   73044           0 :     SgUseStatement * object = SgUseStatement::next_node;
   73045           0 :     SgUseStatement::next_node = (SgUseStatement*)(object->p_freepointer);
   73046             : 
   73047             : #if ROSE_ALLOC_TRACE == 2
   73048             :     printf("SgUseStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUseStatement::next_node);
   73049             : #endif
   73050             : 
   73051           0 :     SgNode * fp = object->p_freepointer;
   73052             : #if ROSE_ALLOC_MEMSET == 1
   73053             : #elif ROSE_ALLOC_MEMSET == 2
   73054             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgUseStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   73055             : #elif ROSE_ALLOC_MEMSET == 3
   73056             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgUseStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   73057             : #endif
   73058           0 :     object->p_freepointer = fp;
   73059             : 
   73060             : #if ROSE_ALLOC_TRACE == 2
   73061             : //    printf("SgUseStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUseStatement::next_node);
   73062             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   73063             :     Rose::MemPool::snapshot(oss.str());
   73064             :     alloc_trace_cnt++;
   73065             : #endif
   73066             : 
   73067           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   73068             : 
   73069           0 :     ALLOC_MUTEX(SgUseStatement, unlock);
   73070             : 
   73071             :     return object;
   73072             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   73073             : }
   73074             : 
   73075             : 
   73076             : 
   73077             : /*! \brief Delete operator for SgUseStatement.
   73078             : 
   73079             :    This delete operator implements deallocation using memory pools to 
   73080             :    provide most efficent use of the heap within construction of large ASTs.
   73081             : 
   73082             : \internal The new and delete operators use the lower level C malloc/free
   73083             :    function calls for performance and to make sure that mixing of malloc/free
   73084             :    and new/delete by the used can be caught more readily.  This may change
   73085             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   73086             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   73087             :    deallocate memory allocated using ROSE_MALLOC.
   73088             : */
   73089           0 : void SgUseStatement::operator delete(void *Pointer, size_t Size)
   73090             : {
   73091             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   73092             :      * or throwing an exception. */
   73093           0 :     ALLOC_MUTEX(SgUseStatement, lock);
   73094             : 
   73095             : #if USE_CPP_NEW_DELETE_OPERATORS
   73096             :     ROSE_FREE(Pointer);
   73097             : #else
   73098             : #if ROSE_PEDANTIC_ALLOC
   73099             :     ROSE_ASSERT(Size == sizeof(SgUseStatement));
   73100             : #else
   73101           0 :     if (Size != sizeof(SgUseStatement)) {
   73102           0 :       ROSE_FREE(Pointer);
   73103           0 :       ALLOC_MUTEX(SgUseStatement, unlock);
   73104             :       return;
   73105             :     }
   73106             : #endif
   73107             : 
   73108           0 :     SgUseStatement * object = (SgUseStatement*) Pointer;
   73109           0 :     ROSE_ASSERT(object != nullptr);
   73110             : 
   73111             : #if ROSE_ALLOC_TRACE == 2
   73112             : //  printf("SgUseStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUseStatement::next_node);
   73113             :     printf("SgUseStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUseStatement::next_node);
   73114             : #endif
   73115             : 
   73116             : #if ROSE_PEDANTIC_ALLOC
   73117             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   73118             : #endif
   73119             : 
   73120             : #if ROSE_ALLOC_MEMSET == 1
   73121             : #elif ROSE_ALLOC_MEMSET == 2
   73122             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgUseStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   73123             : #elif ROSE_ALLOC_MEMSET == 3
   73124             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgUseStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   73125             : #endif
   73126             : 
   73127             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   73128             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   73129             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   73130             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   73131             : #else
   73132           0 :     object->p_freepointer = SgUseStatement::next_node;
   73133           0 :     SgUseStatement::next_node = object;
   73134             : #endif
   73135             : 
   73136             : #if ROSE_ALLOC_TRACE == 2
   73137             : //  printf("SgUseStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUseStatement::next_node);
   73138             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   73139             :     Rose::MemPool::snapshot(oss.str());
   73140             :     alloc_trace_cnt++;
   73141             : #endif
   73142             : 
   73143             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   73144             : 
   73145           0 :     ALLOC_MUTEX(SgUseStatement, unlock);
   73146             : }
   73147             : 
   73148             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   73149             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   73150             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   73151             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   73152             : // Also, note comment below from Robb (copied from the Common.code file).
   73153             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   73154             : //
   73155             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   73156             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   73157             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   73158             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   73159             : #if 0
   73160             : void SgUseStatement::operator delete(void* pointer) { SgUseStatement::operator delete (pointer, sizeof(SgUseStatement)); };
   73161             : #endif
   73162             : /* #line 73163 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   73163             : 
   73164             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   73165             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   73166             : // obviously imply C++.
   73167             : 
   73168             : // This implements the support within ROSE for memory pools.  Memory pools
   73169             : // support the most condensed usage of memory within the construction of
   73170             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   73171             : // by a new operator written for each class.
   73172             : 
   73173             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   73174             :     // User wants multi-thread support and POSIX threads are available.
   73175             : #   include <pthread.h>
   73176             :     static pthread_mutex_t SgParameterStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   73177             : #else
   73178             :      // Cause synchronization to be skipped.
   73179             : #    ifndef ALLOC_MUTEX
   73180             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   73181             : #    endif
   73182             : #    ifdef _REENTRANT
   73183             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   73184             : #       ifdef _MSC_VER
   73185             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   73186             : #       else
   73187             : #           warning "POSIX threads are not available; synchronization being skipped"
   73188             : #       endif
   73189             : #    endif
   73190             : #endif
   73191             : 
   73192             : #ifndef ROSE_ALLOC_TRACE
   73193             : #  define ROSE_ALLOC_TRACE 0
   73194             : #endif
   73195             : 
   73196             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   73197             : #define ROSE_ALLOC_TRACE_CNT
   73198             : #include "memory-pool-snapshot.h"
   73199             : unsigned long alloc_trace_cnt = 0;
   73200             : #endif
   73201             : 
   73202             : #if ROSE_ALLOC_TRACE
   73203             : const unsigned SgParameterStatement::pool_size = 5;
   73204             : #else
   73205             : const unsigned SgParameterStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   73206             : #endif
   73207             : 
   73208             : #ifndef ROSE_ALLOC_MEMSET
   73209             : #  define ROSE_ALLOC_MEMSET 0
   73210             : #endif
   73211             : 
   73212             : #ifndef ROSE_PEDANTIC_ALLOC
   73213             : #  define ROSE_PEDANTIC_ALLOC 0
   73214             : #endif
   73215             : 
   73216             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   73217             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   73218             : #endif
   73219             : 
   73220             : #if !defined(SGNODE__ALL_POOLS)
   73221             : #define SGNODE__ALL_POOLS
   73222             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   73223             : #endif
   73224             : 
   73225             : SgParameterStatement* SgParameterStatement::next_node = nullptr;
   73226             : std::vector<unsigned char*> SgParameterStatement::pools;
   73227             : 
   73228             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   73229             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   73230             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   73231             : // around this macro definition rather than each use).
   73232             : #ifndef ALLOC_MUTEX
   73233             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   73234             :         do {                                                                     \
   73235             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   73236             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   73237             :                 abort();                                                         \
   73238             :             }                                                                    \
   73239             :         } while (0);
   73240             : #endif
   73241             : 
   73242             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   73243             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   73244             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   73245             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   73246             : 
   73247             : /*! \brief New operator for SgParameterStatement.
   73248             : 
   73249             :    This new operator implements memory pools to provide most efficent 
   73250             :    use of the heap within construction of large ASTs.
   73251             : 
   73252             : \internal The new and delete operators use the lower level C malloc/free
   73253             :    function calls for performance and to make sure that mixing of malloc/free
   73254             :    and new/delete by the used can be caught more readily.  This may change
   73255             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   73256             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   73257             :    deallocate memory allocated using ROSE_MALLOC.
   73258             : */
   73259           0 : void *SgParameterStatement::operator new ( size_t Size )
   73260             : {
   73261             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   73262             :      * returning or throwing an exception. */
   73263           0 :     ALLOC_MUTEX(SgParameterStatement, lock);
   73264             : 
   73265             : #if ROSE_ALLOC_TRACE == 2
   73266             : //    printf("SgParameterStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgParameterStatement::next_node);
   73267             : #endif
   73268             : 
   73269             : #if USE_CPP_NEW_DELETE_OPERATORS
   73270             :     void *mem = ROSE_MALLOC(Size);
   73271             :     ALLOC_MUTEX(SgParameterStatement, unlock);
   73272             :     return mem;
   73273             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   73274             : #if ROSE_PEDANTIC_ALLOC
   73275             :     ROSE_ASSERT(Size == sizeof(SgParameterStatement));
   73276             : #else
   73277           0 :     if (Size != sizeof(SgParameterStatement)) {
   73278           0 :       void * object = ROSE_MALLOC(Size);
   73279           0 :       ALLOC_MUTEX(SgParameterStatement, unlock);
   73280             :       return object;
   73281             :     }
   73282             : #endif
   73283             : 
   73284           0 :     if (SgParameterStatement::next_node == nullptr) {
   73285           0 :         SgParameterStatement * alloc = (SgParameterStatement*) ROSE_MALLOC ( SgParameterStatement::pool_size * sizeof(SgParameterStatement) );
   73286           0 :         ROSE_ASSERT(alloc != nullptr);
   73287             : 
   73288             : #if ROSE_ALLOC_TRACE == 2
   73289             : //        printf("SgParameterStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgParameterStatement::pools.size(), alloc, alloc + SgParameterStatement::pool_size);
   73290             : #endif
   73291             : 
   73292             : #if ROSE_ALLOC_MEMSET == 1
   73293             : #elif ROSE_ALLOC_MEMSET == 2
   73294             :         memset(alloc, 0x00, SgParameterStatement::pool_size * sizeof(SgParameterStatement));
   73295             : #elif ROSE_ALLOC_MEMSET == 3
   73296             :         memset(alloc, 0xAA, SgParameterStatement::pool_size * sizeof(SgParameterStatement));
   73297             : #endif
   73298           0 :         for (unsigned i=0; i < SgParameterStatement::pool_size-1; i++) {
   73299           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
   73300             :         }
   73301           0 :         alloc[SgParameterStatement::pool_size-1].p_freepointer = nullptr;
   73302             : 
   73303           0 :         SgParameterStatement::pools.push_back ( (unsigned char *) alloc );
   73304           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgParameterStatement::pool_size * sizeof(SgParameterStatement), V_SgParameterStatement ) );
   73305           0 :         SgParameterStatement::next_node = alloc;
   73306             :     }
   73307           0 :     ROSE_ASSERT(SgParameterStatement::next_node != nullptr);
   73308             : 
   73309           0 :     SgParameterStatement * object = SgParameterStatement::next_node;
   73310           0 :     SgParameterStatement::next_node = (SgParameterStatement*)(object->p_freepointer);
   73311             : 
   73312             : #if ROSE_ALLOC_TRACE == 2
   73313             :     printf("SgParameterStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgParameterStatement::next_node);
   73314             : #endif
   73315             : 
   73316           0 :     SgNode * fp = object->p_freepointer;
   73317             : #if ROSE_ALLOC_MEMSET == 1
   73318             : #elif ROSE_ALLOC_MEMSET == 2
   73319             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgParameterStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   73320             : #elif ROSE_ALLOC_MEMSET == 3
   73321             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgParameterStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   73322             : #endif
   73323           0 :     object->p_freepointer = fp;
   73324             : 
   73325             : #if ROSE_ALLOC_TRACE == 2
   73326             : //    printf("SgParameterStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgParameterStatement::next_node);
   73327             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   73328             :     Rose::MemPool::snapshot(oss.str());
   73329             :     alloc_trace_cnt++;
   73330             : #endif
   73331             : 
   73332           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   73333             : 
   73334           0 :     ALLOC_MUTEX(SgParameterStatement, unlock);
   73335             : 
   73336             :     return object;
   73337             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   73338             : }
   73339             : 
   73340             : 
   73341             : 
   73342             : /*! \brief Delete operator for SgParameterStatement.
   73343             : 
   73344             :    This delete operator implements deallocation using memory pools to 
   73345             :    provide most efficent use of the heap within construction of large ASTs.
   73346             : 
   73347             : \internal The new and delete operators use the lower level C malloc/free
   73348             :    function calls for performance and to make sure that mixing of malloc/free
   73349             :    and new/delete by the used can be caught more readily.  This may change
   73350             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   73351             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   73352             :    deallocate memory allocated using ROSE_MALLOC.
   73353             : */
   73354           0 : void SgParameterStatement::operator delete(void *Pointer, size_t Size)
   73355             : {
   73356             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   73357             :      * or throwing an exception. */
   73358           0 :     ALLOC_MUTEX(SgParameterStatement, lock);
   73359             : 
   73360             : #if USE_CPP_NEW_DELETE_OPERATORS
   73361             :     ROSE_FREE(Pointer);
   73362             : #else
   73363             : #if ROSE_PEDANTIC_ALLOC
   73364             :     ROSE_ASSERT(Size == sizeof(SgParameterStatement));
   73365             : #else
   73366           0 :     if (Size != sizeof(SgParameterStatement)) {
   73367           0 :       ROSE_FREE(Pointer);
   73368           0 :       ALLOC_MUTEX(SgParameterStatement, unlock);
   73369             :       return;
   73370             :     }
   73371             : #endif
   73372             : 
   73373           0 :     SgParameterStatement * object = (SgParameterStatement*) Pointer;
   73374           0 :     ROSE_ASSERT(object != nullptr);
   73375             : 
   73376             : #if ROSE_ALLOC_TRACE == 2
   73377             : //  printf("SgParameterStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgParameterStatement::next_node);
   73378             :     printf("SgParameterStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgParameterStatement::next_node);
   73379             : #endif
   73380             : 
   73381             : #if ROSE_PEDANTIC_ALLOC
   73382             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   73383             : #endif
   73384             : 
   73385             : #if ROSE_ALLOC_MEMSET == 1
   73386             : #elif ROSE_ALLOC_MEMSET == 2
   73387             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgParameterStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   73388             : #elif ROSE_ALLOC_MEMSET == 3
   73389             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgParameterStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   73390             : #endif
   73391             : 
   73392             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   73393             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   73394             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   73395             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   73396             : #else
   73397           0 :     object->p_freepointer = SgParameterStatement::next_node;
   73398           0 :     SgParameterStatement::next_node = object;
   73399             : #endif
   73400             : 
   73401             : #if ROSE_ALLOC_TRACE == 2
   73402             : //  printf("SgParameterStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgParameterStatement::next_node);
   73403             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   73404             :     Rose::MemPool::snapshot(oss.str());
   73405             :     alloc_trace_cnt++;
   73406             : #endif
   73407             : 
   73408             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   73409             : 
   73410           0 :     ALLOC_MUTEX(SgParameterStatement, unlock);
   73411             : }
   73412             : 
   73413             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   73414             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   73415             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   73416             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   73417             : // Also, note comment below from Robb (copied from the Common.code file).
   73418             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   73419             : //
   73420             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   73421             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   73422             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   73423             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   73424             : #if 0
   73425             : void SgParameterStatement::operator delete(void* pointer) { SgParameterStatement::operator delete (pointer, sizeof(SgParameterStatement)); };
   73426             : #endif
   73427             : /* #line 73428 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   73428             : 
   73429             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   73430             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   73431             : // obviously imply C++.
   73432             : 
   73433             : // This implements the support within ROSE for memory pools.  Memory pools
   73434             : // support the most condensed usage of memory within the construction of
   73435             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   73436             : // by a new operator written for each class.
   73437             : 
   73438             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   73439             :     // User wants multi-thread support and POSIX threads are available.
   73440             : #   include <pthread.h>
   73441             :     static pthread_mutex_t SgNamespaceDeclarationStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   73442             : #else
   73443             :      // Cause synchronization to be skipped.
   73444             : #    ifndef ALLOC_MUTEX
   73445             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   73446             : #    endif
   73447             : #    ifdef _REENTRANT
   73448             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   73449             : #       ifdef _MSC_VER
   73450             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   73451             : #       else
   73452             : #           warning "POSIX threads are not available; synchronization being skipped"
   73453             : #       endif
   73454             : #    endif
   73455             : #endif
   73456             : 
   73457             : #ifndef ROSE_ALLOC_TRACE
   73458             : #  define ROSE_ALLOC_TRACE 0
   73459             : #endif
   73460             : 
   73461             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   73462             : #define ROSE_ALLOC_TRACE_CNT
   73463             : #include "memory-pool-snapshot.h"
   73464             : unsigned long alloc_trace_cnt = 0;
   73465             : #endif
   73466             : 
   73467             : #if ROSE_ALLOC_TRACE
   73468             : const unsigned SgNamespaceDeclarationStatement::pool_size = 5;
   73469             : #else
   73470             : const unsigned SgNamespaceDeclarationStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   73471             : #endif
   73472             : 
   73473             : #ifndef ROSE_ALLOC_MEMSET
   73474             : #  define ROSE_ALLOC_MEMSET 0
   73475             : #endif
   73476             : 
   73477             : #ifndef ROSE_PEDANTIC_ALLOC
   73478             : #  define ROSE_PEDANTIC_ALLOC 0
   73479             : #endif
   73480             : 
   73481             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   73482             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   73483             : #endif
   73484             : 
   73485             : #if !defined(SGNODE__ALL_POOLS)
   73486             : #define SGNODE__ALL_POOLS
   73487             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   73488             : #endif
   73489             : 
   73490             : SgNamespaceDeclarationStatement* SgNamespaceDeclarationStatement::next_node = nullptr;
   73491             : std::vector<unsigned char*> SgNamespaceDeclarationStatement::pools;
   73492             : 
   73493             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   73494             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   73495             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   73496             : // around this macro definition rather than each use).
   73497             : #ifndef ALLOC_MUTEX
   73498             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   73499             :         do {                                                                     \
   73500             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   73501             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   73502             :                 abort();                                                         \
   73503             :             }                                                                    \
   73504             :         } while (0);
   73505             : #endif
   73506             : 
   73507             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   73508             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   73509             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   73510             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   73511             : 
   73512             : /*! \brief New operator for SgNamespaceDeclarationStatement.
   73513             : 
   73514             :    This new operator implements memory pools to provide most efficent 
   73515             :    use of the heap within construction of large ASTs.
   73516             : 
   73517             : \internal The new and delete operators use the lower level C malloc/free
   73518             :    function calls for performance and to make sure that mixing of malloc/free
   73519             :    and new/delete by the used can be caught more readily.  This may change
   73520             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   73521             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   73522             :    deallocate memory allocated using ROSE_MALLOC.
   73523             : */
   73524        1248 : void *SgNamespaceDeclarationStatement::operator new ( size_t Size )
   73525             : {
   73526             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   73527             :      * returning or throwing an exception. */
   73528        1248 :     ALLOC_MUTEX(SgNamespaceDeclarationStatement, lock);
   73529             : 
   73530             : #if ROSE_ALLOC_TRACE == 2
   73531             : //    printf("SgNamespaceDeclarationStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgNamespaceDeclarationStatement::next_node);
   73532             : #endif
   73533             : 
   73534             : #if USE_CPP_NEW_DELETE_OPERATORS
   73535             :     void *mem = ROSE_MALLOC(Size);
   73536             :     ALLOC_MUTEX(SgNamespaceDeclarationStatement, unlock);
   73537             :     return mem;
   73538             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   73539             : #if ROSE_PEDANTIC_ALLOC
   73540             :     ROSE_ASSERT(Size == sizeof(SgNamespaceDeclarationStatement));
   73541             : #else
   73542        1248 :     if (Size != sizeof(SgNamespaceDeclarationStatement)) {
   73543           0 :       void * object = ROSE_MALLOC(Size);
   73544           0 :       ALLOC_MUTEX(SgNamespaceDeclarationStatement, unlock);
   73545             :       return object;
   73546             :     }
   73547             : #endif
   73548             : 
   73549        1248 :     if (SgNamespaceDeclarationStatement::next_node == nullptr) {
   73550          16 :         SgNamespaceDeclarationStatement * alloc = (SgNamespaceDeclarationStatement*) ROSE_MALLOC ( SgNamespaceDeclarationStatement::pool_size * sizeof(SgNamespaceDeclarationStatement) );
   73551          16 :         ROSE_ASSERT(alloc != nullptr);
   73552             : 
   73553             : #if ROSE_ALLOC_TRACE == 2
   73554             : //        printf("SgNamespaceDeclarationStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgNamespaceDeclarationStatement::pools.size(), alloc, alloc + SgNamespaceDeclarationStatement::pool_size);
   73555             : #endif
   73556             : 
   73557             : #if ROSE_ALLOC_MEMSET == 1
   73558             : #elif ROSE_ALLOC_MEMSET == 2
   73559             :         memset(alloc, 0x00, SgNamespaceDeclarationStatement::pool_size * sizeof(SgNamespaceDeclarationStatement));
   73560             : #elif ROSE_ALLOC_MEMSET == 3
   73561             :         memset(alloc, 0xAA, SgNamespaceDeclarationStatement::pool_size * sizeof(SgNamespaceDeclarationStatement));
   73562             : #endif
   73563       32000 :         for (unsigned i=0; i < SgNamespaceDeclarationStatement::pool_size-1; i++) {
   73564       31984 :           alloc[i].p_freepointer = &(alloc[i+1]);
   73565             :         }
   73566          16 :         alloc[SgNamespaceDeclarationStatement::pool_size-1].p_freepointer = nullptr;
   73567             : 
   73568          16 :         SgNamespaceDeclarationStatement::pools.push_back ( (unsigned char *) alloc );
   73569          16 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgNamespaceDeclarationStatement::pool_size * sizeof(SgNamespaceDeclarationStatement), V_SgNamespaceDeclarationStatement ) );
   73570          16 :         SgNamespaceDeclarationStatement::next_node = alloc;
   73571             :     }
   73572        1248 :     ROSE_ASSERT(SgNamespaceDeclarationStatement::next_node != nullptr);
   73573             : 
   73574        1248 :     SgNamespaceDeclarationStatement * object = SgNamespaceDeclarationStatement::next_node;
   73575        1248 :     SgNamespaceDeclarationStatement::next_node = (SgNamespaceDeclarationStatement*)(object->p_freepointer);
   73576             : 
   73577             : #if ROSE_ALLOC_TRACE == 2
   73578             :     printf("SgNamespaceDeclarationStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgNamespaceDeclarationStatement::next_node);
   73579             : #endif
   73580             : 
   73581        1248 :     SgNode * fp = object->p_freepointer;
   73582             : #if ROSE_ALLOC_MEMSET == 1
   73583             : #elif ROSE_ALLOC_MEMSET == 2
   73584             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgNamespaceDeclarationStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   73585             : #elif ROSE_ALLOC_MEMSET == 3
   73586             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgNamespaceDeclarationStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   73587             : #endif
   73588        1248 :     object->p_freepointer = fp;
   73589             : 
   73590             : #if ROSE_ALLOC_TRACE == 2
   73591             : //    printf("SgNamespaceDeclarationStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgNamespaceDeclarationStatement::next_node);
   73592             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   73593             :     Rose::MemPool::snapshot(oss.str());
   73594             :     alloc_trace_cnt++;
   73595             : #endif
   73596             : 
   73597        1248 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   73598             : 
   73599        1248 :     ALLOC_MUTEX(SgNamespaceDeclarationStatement, unlock);
   73600             : 
   73601             :     return object;
   73602             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   73603             : }
   73604             : 
   73605             : 
   73606             : 
   73607             : /*! \brief Delete operator for SgNamespaceDeclarationStatement.
   73608             : 
   73609             :    This delete operator implements deallocation using memory pools to 
   73610             :    provide most efficent use of the heap within construction of large ASTs.
   73611             : 
   73612             : \internal The new and delete operators use the lower level C malloc/free
   73613             :    function calls for performance and to make sure that mixing of malloc/free
   73614             :    and new/delete by the used can be caught more readily.  This may change
   73615             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   73616             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   73617             :    deallocate memory allocated using ROSE_MALLOC.
   73618             : */
   73619         242 : void SgNamespaceDeclarationStatement::operator delete(void *Pointer, size_t Size)
   73620             : {
   73621             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   73622             :      * or throwing an exception. */
   73623         242 :     ALLOC_MUTEX(SgNamespaceDeclarationStatement, lock);
   73624             : 
   73625             : #if USE_CPP_NEW_DELETE_OPERATORS
   73626             :     ROSE_FREE(Pointer);
   73627             : #else
   73628             : #if ROSE_PEDANTIC_ALLOC
   73629             :     ROSE_ASSERT(Size == sizeof(SgNamespaceDeclarationStatement));
   73630             : #else
   73631         242 :     if (Size != sizeof(SgNamespaceDeclarationStatement)) {
   73632           0 :       ROSE_FREE(Pointer);
   73633           0 :       ALLOC_MUTEX(SgNamespaceDeclarationStatement, unlock);
   73634             :       return;
   73635             :     }
   73636             : #endif
   73637             : 
   73638         242 :     SgNamespaceDeclarationStatement * object = (SgNamespaceDeclarationStatement*) Pointer;
   73639         242 :     ROSE_ASSERT(object != nullptr);
   73640             : 
   73641             : #if ROSE_ALLOC_TRACE == 2
   73642             : //  printf("SgNamespaceDeclarationStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgNamespaceDeclarationStatement::next_node);
   73643             :     printf("SgNamespaceDeclarationStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgNamespaceDeclarationStatement::next_node);
   73644             : #endif
   73645             : 
   73646             : #if ROSE_PEDANTIC_ALLOC
   73647             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   73648             : #endif
   73649             : 
   73650             : #if ROSE_ALLOC_MEMSET == 1
   73651             : #elif ROSE_ALLOC_MEMSET == 2
   73652             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgNamespaceDeclarationStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   73653             : #elif ROSE_ALLOC_MEMSET == 3
   73654             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgNamespaceDeclarationStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   73655             : #endif
   73656             : 
   73657             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   73658             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   73659             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   73660             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   73661             : #else
   73662         242 :     object->p_freepointer = SgNamespaceDeclarationStatement::next_node;
   73663         242 :     SgNamespaceDeclarationStatement::next_node = object;
   73664             : #endif
   73665             : 
   73666             : #if ROSE_ALLOC_TRACE == 2
   73667             : //  printf("SgNamespaceDeclarationStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgNamespaceDeclarationStatement::next_node);
   73668             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   73669             :     Rose::MemPool::snapshot(oss.str());
   73670             :     alloc_trace_cnt++;
   73671             : #endif
   73672             : 
   73673             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   73674             : 
   73675         242 :     ALLOC_MUTEX(SgNamespaceDeclarationStatement, unlock);
   73676             : }
   73677             : 
   73678             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   73679             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   73680             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   73681             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   73682             : // Also, note comment below from Robb (copied from the Common.code file).
   73683             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   73684             : //
   73685             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   73686             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   73687             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   73688             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   73689             : #if 0
   73690             : void SgNamespaceDeclarationStatement::operator delete(void* pointer) { SgNamespaceDeclarationStatement::operator delete (pointer, sizeof(SgNamespaceDeclarationStatement)); };
   73691             : #endif
   73692             : /* #line 73693 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   73693             : 
   73694             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   73695             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   73696             : // obviously imply C++.
   73697             : 
   73698             : // This implements the support within ROSE for memory pools.  Memory pools
   73699             : // support the most condensed usage of memory within the construction of
   73700             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   73701             : // by a new operator written for each class.
   73702             : 
   73703             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   73704             :     // User wants multi-thread support and POSIX threads are available.
   73705             : #   include <pthread.h>
   73706             :     static pthread_mutex_t SgEquivalenceStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   73707             : #else
   73708             :      // Cause synchronization to be skipped.
   73709             : #    ifndef ALLOC_MUTEX
   73710             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   73711             : #    endif
   73712             : #    ifdef _REENTRANT
   73713             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   73714             : #       ifdef _MSC_VER
   73715             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   73716             : #       else
   73717             : #           warning "POSIX threads are not available; synchronization being skipped"
   73718             : #       endif
   73719             : #    endif
   73720             : #endif
   73721             : 
   73722             : #ifndef ROSE_ALLOC_TRACE
   73723             : #  define ROSE_ALLOC_TRACE 0
   73724             : #endif
   73725             : 
   73726             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   73727             : #define ROSE_ALLOC_TRACE_CNT
   73728             : #include "memory-pool-snapshot.h"
   73729             : unsigned long alloc_trace_cnt = 0;
   73730             : #endif
   73731             : 
   73732             : #if ROSE_ALLOC_TRACE
   73733             : const unsigned SgEquivalenceStatement::pool_size = 5;
   73734             : #else
   73735             : const unsigned SgEquivalenceStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   73736             : #endif
   73737             : 
   73738             : #ifndef ROSE_ALLOC_MEMSET
   73739             : #  define ROSE_ALLOC_MEMSET 0
   73740             : #endif
   73741             : 
   73742             : #ifndef ROSE_PEDANTIC_ALLOC
   73743             : #  define ROSE_PEDANTIC_ALLOC 0
   73744             : #endif
   73745             : 
   73746             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   73747             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   73748             : #endif
   73749             : 
   73750             : #if !defined(SGNODE__ALL_POOLS)
   73751             : #define SGNODE__ALL_POOLS
   73752             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   73753             : #endif
   73754             : 
   73755             : SgEquivalenceStatement* SgEquivalenceStatement::next_node = nullptr;
   73756             : std::vector<unsigned char*> SgEquivalenceStatement::pools;
   73757             : 
   73758             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   73759             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   73760             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   73761             : // around this macro definition rather than each use).
   73762             : #ifndef ALLOC_MUTEX
   73763             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   73764             :         do {                                                                     \
   73765             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   73766             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   73767             :                 abort();                                                         \
   73768             :             }                                                                    \
   73769             :         } while (0);
   73770             : #endif
   73771             : 
   73772             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   73773             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   73774             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   73775             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   73776             : 
   73777             : /*! \brief New operator for SgEquivalenceStatement.
   73778             : 
   73779             :    This new operator implements memory pools to provide most efficent 
   73780             :    use of the heap within construction of large ASTs.
   73781             : 
   73782             : \internal The new and delete operators use the lower level C malloc/free
   73783             :    function calls for performance and to make sure that mixing of malloc/free
   73784             :    and new/delete by the used can be caught more readily.  This may change
   73785             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   73786             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   73787             :    deallocate memory allocated using ROSE_MALLOC.
   73788             : */
   73789           0 : void *SgEquivalenceStatement::operator new ( size_t Size )
   73790             : {
   73791             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   73792             :      * returning or throwing an exception. */
   73793           0 :     ALLOC_MUTEX(SgEquivalenceStatement, lock);
   73794             : 
   73795             : #if ROSE_ALLOC_TRACE == 2
   73796             : //    printf("SgEquivalenceStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgEquivalenceStatement::next_node);
   73797             : #endif
   73798             : 
   73799             : #if USE_CPP_NEW_DELETE_OPERATORS
   73800             :     void *mem = ROSE_MALLOC(Size);
   73801             :     ALLOC_MUTEX(SgEquivalenceStatement, unlock);
   73802             :     return mem;
   73803             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   73804             : #if ROSE_PEDANTIC_ALLOC
   73805             :     ROSE_ASSERT(Size == sizeof(SgEquivalenceStatement));
   73806             : #else
   73807           0 :     if (Size != sizeof(SgEquivalenceStatement)) {
   73808           0 :       void * object = ROSE_MALLOC(Size);
   73809           0 :       ALLOC_MUTEX(SgEquivalenceStatement, unlock);
   73810             :       return object;
   73811             :     }
   73812             : #endif
   73813             : 
   73814           0 :     if (SgEquivalenceStatement::next_node == nullptr) {
   73815           0 :         SgEquivalenceStatement * alloc = (SgEquivalenceStatement*) ROSE_MALLOC ( SgEquivalenceStatement::pool_size * sizeof(SgEquivalenceStatement) );
   73816           0 :         ROSE_ASSERT(alloc != nullptr);
   73817             : 
   73818             : #if ROSE_ALLOC_TRACE == 2
   73819             : //        printf("SgEquivalenceStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgEquivalenceStatement::pools.size(), alloc, alloc + SgEquivalenceStatement::pool_size);
   73820             : #endif
   73821             : 
   73822             : #if ROSE_ALLOC_MEMSET == 1
   73823             : #elif ROSE_ALLOC_MEMSET == 2
   73824             :         memset(alloc, 0x00, SgEquivalenceStatement::pool_size * sizeof(SgEquivalenceStatement));
   73825             : #elif ROSE_ALLOC_MEMSET == 3
   73826             :         memset(alloc, 0xAA, SgEquivalenceStatement::pool_size * sizeof(SgEquivalenceStatement));
   73827             : #endif
   73828           0 :         for (unsigned i=0; i < SgEquivalenceStatement::pool_size-1; i++) {
   73829           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
   73830             :         }
   73831           0 :         alloc[SgEquivalenceStatement::pool_size-1].p_freepointer = nullptr;
   73832             : 
   73833           0 :         SgEquivalenceStatement::pools.push_back ( (unsigned char *) alloc );
   73834           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgEquivalenceStatement::pool_size * sizeof(SgEquivalenceStatement), V_SgEquivalenceStatement ) );
   73835           0 :         SgEquivalenceStatement::next_node = alloc;
   73836             :     }
   73837           0 :     ROSE_ASSERT(SgEquivalenceStatement::next_node != nullptr);
   73838             : 
   73839           0 :     SgEquivalenceStatement * object = SgEquivalenceStatement::next_node;
   73840           0 :     SgEquivalenceStatement::next_node = (SgEquivalenceStatement*)(object->p_freepointer);
   73841             : 
   73842             : #if ROSE_ALLOC_TRACE == 2
   73843             :     printf("SgEquivalenceStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgEquivalenceStatement::next_node);
   73844             : #endif
   73845             : 
   73846           0 :     SgNode * fp = object->p_freepointer;
   73847             : #if ROSE_ALLOC_MEMSET == 1
   73848             : #elif ROSE_ALLOC_MEMSET == 2
   73849             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgEquivalenceStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   73850             : #elif ROSE_ALLOC_MEMSET == 3
   73851             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgEquivalenceStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   73852             : #endif
   73853           0 :     object->p_freepointer = fp;
   73854             : 
   73855             : #if ROSE_ALLOC_TRACE == 2
   73856             : //    printf("SgEquivalenceStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgEquivalenceStatement::next_node);
   73857             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   73858             :     Rose::MemPool::snapshot(oss.str());
   73859             :     alloc_trace_cnt++;
   73860             : #endif
   73861             : 
   73862           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   73863             : 
   73864           0 :     ALLOC_MUTEX(SgEquivalenceStatement, unlock);
   73865             : 
   73866             :     return object;
   73867             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   73868             : }
   73869             : 
   73870             : 
   73871             : 
   73872             : /*! \brief Delete operator for SgEquivalenceStatement.
   73873             : 
   73874             :    This delete operator implements deallocation using memory pools to 
   73875             :    provide most efficent use of the heap within construction of large ASTs.
   73876             : 
   73877             : \internal The new and delete operators use the lower level C malloc/free
   73878             :    function calls for performance and to make sure that mixing of malloc/free
   73879             :    and new/delete by the used can be caught more readily.  This may change
   73880             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   73881             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   73882             :    deallocate memory allocated using ROSE_MALLOC.
   73883             : */
   73884           0 : void SgEquivalenceStatement::operator delete(void *Pointer, size_t Size)
   73885             : {
   73886             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   73887             :      * or throwing an exception. */
   73888           0 :     ALLOC_MUTEX(SgEquivalenceStatement, lock);
   73889             : 
   73890             : #if USE_CPP_NEW_DELETE_OPERATORS
   73891             :     ROSE_FREE(Pointer);
   73892             : #else
   73893             : #if ROSE_PEDANTIC_ALLOC
   73894             :     ROSE_ASSERT(Size == sizeof(SgEquivalenceStatement));
   73895             : #else
   73896           0 :     if (Size != sizeof(SgEquivalenceStatement)) {
   73897           0 :       ROSE_FREE(Pointer);
   73898           0 :       ALLOC_MUTEX(SgEquivalenceStatement, unlock);
   73899             :       return;
   73900             :     }
   73901             : #endif
   73902             : 
   73903           0 :     SgEquivalenceStatement * object = (SgEquivalenceStatement*) Pointer;
   73904           0 :     ROSE_ASSERT(object != nullptr);
   73905             : 
   73906             : #if ROSE_ALLOC_TRACE == 2
   73907             : //  printf("SgEquivalenceStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgEquivalenceStatement::next_node);
   73908             :     printf("SgEquivalenceStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgEquivalenceStatement::next_node);
   73909             : #endif
   73910             : 
   73911             : #if ROSE_PEDANTIC_ALLOC
   73912             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   73913             : #endif
   73914             : 
   73915             : #if ROSE_ALLOC_MEMSET == 1
   73916             : #elif ROSE_ALLOC_MEMSET == 2
   73917             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgEquivalenceStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   73918             : #elif ROSE_ALLOC_MEMSET == 3
   73919             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgEquivalenceStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   73920             : #endif
   73921             : 
   73922             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   73923             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   73924             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   73925             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   73926             : #else
   73927           0 :     object->p_freepointer = SgEquivalenceStatement::next_node;
   73928           0 :     SgEquivalenceStatement::next_node = object;
   73929             : #endif
   73930             : 
   73931             : #if ROSE_ALLOC_TRACE == 2
   73932             : //  printf("SgEquivalenceStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgEquivalenceStatement::next_node);
   73933             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   73934             :     Rose::MemPool::snapshot(oss.str());
   73935             :     alloc_trace_cnt++;
   73936             : #endif
   73937             : 
   73938             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   73939             : 
   73940           0 :     ALLOC_MUTEX(SgEquivalenceStatement, unlock);
   73941             : }
   73942             : 
   73943             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   73944             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   73945             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   73946             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   73947             : // Also, note comment below from Robb (copied from the Common.code file).
   73948             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   73949             : //
   73950             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   73951             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   73952             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   73953             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   73954             : #if 0
   73955             : void SgEquivalenceStatement::operator delete(void* pointer) { SgEquivalenceStatement::operator delete (pointer, sizeof(SgEquivalenceStatement)); };
   73956             : #endif
   73957             : /* #line 73958 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   73958             : 
   73959             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   73960             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   73961             : // obviously imply C++.
   73962             : 
   73963             : // This implements the support within ROSE for memory pools.  Memory pools
   73964             : // support the most condensed usage of memory within the construction of
   73965             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   73966             : // by a new operator written for each class.
   73967             : 
   73968             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   73969             :     // User wants multi-thread support and POSIX threads are available.
   73970             : #   include <pthread.h>
   73971             :     static pthread_mutex_t SgInterfaceStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   73972             : #else
   73973             :      // Cause synchronization to be skipped.
   73974             : #    ifndef ALLOC_MUTEX
   73975             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   73976             : #    endif
   73977             : #    ifdef _REENTRANT
   73978             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   73979             : #       ifdef _MSC_VER
   73980             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   73981             : #       else
   73982             : #           warning "POSIX threads are not available; synchronization being skipped"
   73983             : #       endif
   73984             : #    endif
   73985             : #endif
   73986             : 
   73987             : #ifndef ROSE_ALLOC_TRACE
   73988             : #  define ROSE_ALLOC_TRACE 0
   73989             : #endif
   73990             : 
   73991             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   73992             : #define ROSE_ALLOC_TRACE_CNT
   73993             : #include "memory-pool-snapshot.h"
   73994             : unsigned long alloc_trace_cnt = 0;
   73995             : #endif
   73996             : 
   73997             : #if ROSE_ALLOC_TRACE
   73998             : const unsigned SgInterfaceStatement::pool_size = 5;
   73999             : #else
   74000             : const unsigned SgInterfaceStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   74001             : #endif
   74002             : 
   74003             : #ifndef ROSE_ALLOC_MEMSET
   74004             : #  define ROSE_ALLOC_MEMSET 0
   74005             : #endif
   74006             : 
   74007             : #ifndef ROSE_PEDANTIC_ALLOC
   74008             : #  define ROSE_PEDANTIC_ALLOC 0
   74009             : #endif
   74010             : 
   74011             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   74012             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   74013             : #endif
   74014             : 
   74015             : #if !defined(SGNODE__ALL_POOLS)
   74016             : #define SGNODE__ALL_POOLS
   74017             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   74018             : #endif
   74019             : 
   74020             : SgInterfaceStatement* SgInterfaceStatement::next_node = nullptr;
   74021             : std::vector<unsigned char*> SgInterfaceStatement::pools;
   74022             : 
   74023             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   74024             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   74025             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   74026             : // around this macro definition rather than each use).
   74027             : #ifndef ALLOC_MUTEX
   74028             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   74029             :         do {                                                                     \
   74030             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   74031             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   74032             :                 abort();                                                         \
   74033             :             }                                                                    \
   74034             :         } while (0);
   74035             : #endif
   74036             : 
   74037             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   74038             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   74039             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   74040             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   74041             : 
   74042             : /*! \brief New operator for SgInterfaceStatement.
   74043             : 
   74044             :    This new operator implements memory pools to provide most efficent 
   74045             :    use of the heap within construction of large ASTs.
   74046             : 
   74047             : \internal The new and delete operators use the lower level C malloc/free
   74048             :    function calls for performance and to make sure that mixing of malloc/free
   74049             :    and new/delete by the used can be caught more readily.  This may change
   74050             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   74051             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   74052             :    deallocate memory allocated using ROSE_MALLOC.
   74053             : */
   74054           0 : void *SgInterfaceStatement::operator new ( size_t Size )
   74055             : {
   74056             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   74057             :      * returning or throwing an exception. */
   74058           0 :     ALLOC_MUTEX(SgInterfaceStatement, lock);
   74059             : 
   74060             : #if ROSE_ALLOC_TRACE == 2
   74061             : //    printf("SgInterfaceStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgInterfaceStatement::next_node);
   74062             : #endif
   74063             : 
   74064             : #if USE_CPP_NEW_DELETE_OPERATORS
   74065             :     void *mem = ROSE_MALLOC(Size);
   74066             :     ALLOC_MUTEX(SgInterfaceStatement, unlock);
   74067             :     return mem;
   74068             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   74069             : #if ROSE_PEDANTIC_ALLOC
   74070             :     ROSE_ASSERT(Size == sizeof(SgInterfaceStatement));
   74071             : #else
   74072           0 :     if (Size != sizeof(SgInterfaceStatement)) {
   74073           0 :       void * object = ROSE_MALLOC(Size);
   74074           0 :       ALLOC_MUTEX(SgInterfaceStatement, unlock);
   74075             :       return object;
   74076             :     }
   74077             : #endif
   74078             : 
   74079           0 :     if (SgInterfaceStatement::next_node == nullptr) {
   74080           0 :         SgInterfaceStatement * alloc = (SgInterfaceStatement*) ROSE_MALLOC ( SgInterfaceStatement::pool_size * sizeof(SgInterfaceStatement) );
   74081           0 :         ROSE_ASSERT(alloc != nullptr);
   74082             : 
   74083             : #if ROSE_ALLOC_TRACE == 2
   74084             : //        printf("SgInterfaceStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgInterfaceStatement::pools.size(), alloc, alloc + SgInterfaceStatement::pool_size);
   74085             : #endif
   74086             : 
   74087             : #if ROSE_ALLOC_MEMSET == 1
   74088             : #elif ROSE_ALLOC_MEMSET == 2
   74089             :         memset(alloc, 0x00, SgInterfaceStatement::pool_size * sizeof(SgInterfaceStatement));
   74090             : #elif ROSE_ALLOC_MEMSET == 3
   74091             :         memset(alloc, 0xAA, SgInterfaceStatement::pool_size * sizeof(SgInterfaceStatement));
   74092             : #endif
   74093           0 :         for (unsigned i=0; i < SgInterfaceStatement::pool_size-1; i++) {
   74094           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
   74095             :         }
   74096           0 :         alloc[SgInterfaceStatement::pool_size-1].p_freepointer = nullptr;
   74097             : 
   74098           0 :         SgInterfaceStatement::pools.push_back ( (unsigned char *) alloc );
   74099           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgInterfaceStatement::pool_size * sizeof(SgInterfaceStatement), V_SgInterfaceStatement ) );
   74100           0 :         SgInterfaceStatement::next_node = alloc;
   74101             :     }
   74102           0 :     ROSE_ASSERT(SgInterfaceStatement::next_node != nullptr);
   74103             : 
   74104           0 :     SgInterfaceStatement * object = SgInterfaceStatement::next_node;
   74105           0 :     SgInterfaceStatement::next_node = (SgInterfaceStatement*)(object->p_freepointer);
   74106             : 
   74107             : #if ROSE_ALLOC_TRACE == 2
   74108             :     printf("SgInterfaceStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgInterfaceStatement::next_node);
   74109             : #endif
   74110             : 
   74111           0 :     SgNode * fp = object->p_freepointer;
   74112             : #if ROSE_ALLOC_MEMSET == 1
   74113             : #elif ROSE_ALLOC_MEMSET == 2
   74114             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgInterfaceStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   74115             : #elif ROSE_ALLOC_MEMSET == 3
   74116             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgInterfaceStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   74117             : #endif
   74118           0 :     object->p_freepointer = fp;
   74119             : 
   74120             : #if ROSE_ALLOC_TRACE == 2
   74121             : //    printf("SgInterfaceStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgInterfaceStatement::next_node);
   74122             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   74123             :     Rose::MemPool::snapshot(oss.str());
   74124             :     alloc_trace_cnt++;
   74125             : #endif
   74126             : 
   74127           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   74128             : 
   74129           0 :     ALLOC_MUTEX(SgInterfaceStatement, unlock);
   74130             : 
   74131             :     return object;
   74132             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   74133             : }
   74134             : 
   74135             : 
   74136             : 
   74137             : /*! \brief Delete operator for SgInterfaceStatement.
   74138             : 
   74139             :    This delete operator implements deallocation using memory pools to 
   74140             :    provide most efficent use of the heap within construction of large ASTs.
   74141             : 
   74142             : \internal The new and delete operators use the lower level C malloc/free
   74143             :    function calls for performance and to make sure that mixing of malloc/free
   74144             :    and new/delete by the used can be caught more readily.  This may change
   74145             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   74146             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   74147             :    deallocate memory allocated using ROSE_MALLOC.
   74148             : */
   74149           0 : void SgInterfaceStatement::operator delete(void *Pointer, size_t Size)
   74150             : {
   74151             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   74152             :      * or throwing an exception. */
   74153           0 :     ALLOC_MUTEX(SgInterfaceStatement, lock);
   74154             : 
   74155             : #if USE_CPP_NEW_DELETE_OPERATORS
   74156             :     ROSE_FREE(Pointer);
   74157             : #else
   74158             : #if ROSE_PEDANTIC_ALLOC
   74159             :     ROSE_ASSERT(Size == sizeof(SgInterfaceStatement));
   74160             : #else
   74161           0 :     if (Size != sizeof(SgInterfaceStatement)) {
   74162           0 :       ROSE_FREE(Pointer);
   74163           0 :       ALLOC_MUTEX(SgInterfaceStatement, unlock);
   74164             :       return;
   74165             :     }
   74166             : #endif
   74167             : 
   74168           0 :     SgInterfaceStatement * object = (SgInterfaceStatement*) Pointer;
   74169           0 :     ROSE_ASSERT(object != nullptr);
   74170             : 
   74171             : #if ROSE_ALLOC_TRACE == 2
   74172             : //  printf("SgInterfaceStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgInterfaceStatement::next_node);
   74173             :     printf("SgInterfaceStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgInterfaceStatement::next_node);
   74174             : #endif
   74175             : 
   74176             : #if ROSE_PEDANTIC_ALLOC
   74177             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   74178             : #endif
   74179             : 
   74180             : #if ROSE_ALLOC_MEMSET == 1
   74181             : #elif ROSE_ALLOC_MEMSET == 2
   74182             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgInterfaceStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   74183             : #elif ROSE_ALLOC_MEMSET == 3
   74184             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgInterfaceStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   74185             : #endif
   74186             : 
   74187             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   74188             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   74189             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   74190             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   74191             : #else
   74192           0 :     object->p_freepointer = SgInterfaceStatement::next_node;
   74193           0 :     SgInterfaceStatement::next_node = object;
   74194             : #endif
   74195             : 
   74196             : #if ROSE_ALLOC_TRACE == 2
   74197             : //  printf("SgInterfaceStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgInterfaceStatement::next_node);
   74198             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   74199             :     Rose::MemPool::snapshot(oss.str());
   74200             :     alloc_trace_cnt++;
   74201             : #endif
   74202             : 
   74203             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   74204             : 
   74205           0 :     ALLOC_MUTEX(SgInterfaceStatement, unlock);
   74206             : }
   74207             : 
   74208             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   74209             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   74210             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   74211             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   74212             : // Also, note comment below from Robb (copied from the Common.code file).
   74213             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   74214             : //
   74215             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   74216             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   74217             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   74218             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   74219             : #if 0
   74220             : void SgInterfaceStatement::operator delete(void* pointer) { SgInterfaceStatement::operator delete (pointer, sizeof(SgInterfaceStatement)); };
   74221             : #endif
   74222             : /* #line 74223 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   74223             : 
   74224             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   74225             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   74226             : // obviously imply C++.
   74227             : 
   74228             : // This implements the support within ROSE for memory pools.  Memory pools
   74229             : // support the most condensed usage of memory within the construction of
   74230             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   74231             : // by a new operator written for each class.
   74232             : 
   74233             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   74234             :     // User wants multi-thread support and POSIX threads are available.
   74235             : #   include <pthread.h>
   74236             :     static pthread_mutex_t SgNamespaceAliasDeclarationStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   74237             : #else
   74238             :      // Cause synchronization to be skipped.
   74239             : #    ifndef ALLOC_MUTEX
   74240             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   74241             : #    endif
   74242             : #    ifdef _REENTRANT
   74243             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   74244             : #       ifdef _MSC_VER
   74245             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   74246             : #       else
   74247             : #           warning "POSIX threads are not available; synchronization being skipped"
   74248             : #       endif
   74249             : #    endif
   74250             : #endif
   74251             : 
   74252             : #ifndef ROSE_ALLOC_TRACE
   74253             : #  define ROSE_ALLOC_TRACE 0
   74254             : #endif
   74255             : 
   74256             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   74257             : #define ROSE_ALLOC_TRACE_CNT
   74258             : #include "memory-pool-snapshot.h"
   74259             : unsigned long alloc_trace_cnt = 0;
   74260             : #endif
   74261             : 
   74262             : #if ROSE_ALLOC_TRACE
   74263             : const unsigned SgNamespaceAliasDeclarationStatement::pool_size = 5;
   74264             : #else
   74265             : const unsigned SgNamespaceAliasDeclarationStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   74266             : #endif
   74267             : 
   74268             : #ifndef ROSE_ALLOC_MEMSET
   74269             : #  define ROSE_ALLOC_MEMSET 0
   74270             : #endif
   74271             : 
   74272             : #ifndef ROSE_PEDANTIC_ALLOC
   74273             : #  define ROSE_PEDANTIC_ALLOC 0
   74274             : #endif
   74275             : 
   74276             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   74277             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   74278             : #endif
   74279             : 
   74280             : #if !defined(SGNODE__ALL_POOLS)
   74281             : #define SGNODE__ALL_POOLS
   74282             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   74283             : #endif
   74284             : 
   74285             : SgNamespaceAliasDeclarationStatement* SgNamespaceAliasDeclarationStatement::next_node = nullptr;
   74286             : std::vector<unsigned char*> SgNamespaceAliasDeclarationStatement::pools;
   74287             : 
   74288             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   74289             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   74290             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   74291             : // around this macro definition rather than each use).
   74292             : #ifndef ALLOC_MUTEX
   74293             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   74294             :         do {                                                                     \
   74295             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   74296             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   74297             :                 abort();                                                         \
   74298             :             }                                                                    \
   74299             :         } while (0);
   74300             : #endif
   74301             : 
   74302             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   74303             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   74304             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   74305             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   74306             : 
   74307             : /*! \brief New operator for SgNamespaceAliasDeclarationStatement.
   74308             : 
   74309             :    This new operator implements memory pools to provide most efficent 
   74310             :    use of the heap within construction of large ASTs.
   74311             : 
   74312             : \internal The new and delete operators use the lower level C malloc/free
   74313             :    function calls for performance and to make sure that mixing of malloc/free
   74314             :    and new/delete by the used can be caught more readily.  This may change
   74315             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   74316             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   74317             :    deallocate memory allocated using ROSE_MALLOC.
   74318             : */
   74319           0 : void *SgNamespaceAliasDeclarationStatement::operator new ( size_t Size )
   74320             : {
   74321             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   74322             :      * returning or throwing an exception. */
   74323           0 :     ALLOC_MUTEX(SgNamespaceAliasDeclarationStatement, lock);
   74324             : 
   74325             : #if ROSE_ALLOC_TRACE == 2
   74326             : //    printf("SgNamespaceAliasDeclarationStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgNamespaceAliasDeclarationStatement::next_node);
   74327             : #endif
   74328             : 
   74329             : #if USE_CPP_NEW_DELETE_OPERATORS
   74330             :     void *mem = ROSE_MALLOC(Size);
   74331             :     ALLOC_MUTEX(SgNamespaceAliasDeclarationStatement, unlock);
   74332             :     return mem;
   74333             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   74334             : #if ROSE_PEDANTIC_ALLOC
   74335             :     ROSE_ASSERT(Size == sizeof(SgNamespaceAliasDeclarationStatement));
   74336             : #else
   74337           0 :     if (Size != sizeof(SgNamespaceAliasDeclarationStatement)) {
   74338           0 :       void * object = ROSE_MALLOC(Size);
   74339           0 :       ALLOC_MUTEX(SgNamespaceAliasDeclarationStatement, unlock);
   74340             :       return object;
   74341             :     }
   74342             : #endif
   74343             : 
   74344           0 :     if (SgNamespaceAliasDeclarationStatement::next_node == nullptr) {
   74345           0 :         SgNamespaceAliasDeclarationStatement * alloc = (SgNamespaceAliasDeclarationStatement*) ROSE_MALLOC ( SgNamespaceAliasDeclarationStatement::pool_size * sizeof(SgNamespaceAliasDeclarationStatement) );
   74346           0 :         ROSE_ASSERT(alloc != nullptr);
   74347             : 
   74348             : #if ROSE_ALLOC_TRACE == 2
   74349             : //        printf("SgNamespaceAliasDeclarationStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgNamespaceAliasDeclarationStatement::pools.size(), alloc, alloc + SgNamespaceAliasDeclarationStatement::pool_size);
   74350             : #endif
   74351             : 
   74352             : #if ROSE_ALLOC_MEMSET == 1
   74353             : #elif ROSE_ALLOC_MEMSET == 2
   74354             :         memset(alloc, 0x00, SgNamespaceAliasDeclarationStatement::pool_size * sizeof(SgNamespaceAliasDeclarationStatement));
   74355             : #elif ROSE_ALLOC_MEMSET == 3
   74356             :         memset(alloc, 0xAA, SgNamespaceAliasDeclarationStatement::pool_size * sizeof(SgNamespaceAliasDeclarationStatement));
   74357             : #endif
   74358           0 :         for (unsigned i=0; i < SgNamespaceAliasDeclarationStatement::pool_size-1; i++) {
   74359           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
   74360             :         }
   74361           0 :         alloc[SgNamespaceAliasDeclarationStatement::pool_size-1].p_freepointer = nullptr;
   74362             : 
   74363           0 :         SgNamespaceAliasDeclarationStatement::pools.push_back ( (unsigned char *) alloc );
   74364           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgNamespaceAliasDeclarationStatement::pool_size * sizeof(SgNamespaceAliasDeclarationStatement), V_SgNamespaceAliasDeclarationStatement ) );
   74365           0 :         SgNamespaceAliasDeclarationStatement::next_node = alloc;
   74366             :     }
   74367           0 :     ROSE_ASSERT(SgNamespaceAliasDeclarationStatement::next_node != nullptr);
   74368             : 
   74369           0 :     SgNamespaceAliasDeclarationStatement * object = SgNamespaceAliasDeclarationStatement::next_node;
   74370           0 :     SgNamespaceAliasDeclarationStatement::next_node = (SgNamespaceAliasDeclarationStatement*)(object->p_freepointer);
   74371             : 
   74372             : #if ROSE_ALLOC_TRACE == 2
   74373             :     printf("SgNamespaceAliasDeclarationStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgNamespaceAliasDeclarationStatement::next_node);
   74374             : #endif
   74375             : 
   74376           0 :     SgNode * fp = object->p_freepointer;
   74377             : #if ROSE_ALLOC_MEMSET == 1
   74378             : #elif ROSE_ALLOC_MEMSET == 2
   74379             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgNamespaceAliasDeclarationStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   74380             : #elif ROSE_ALLOC_MEMSET == 3
   74381             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgNamespaceAliasDeclarationStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   74382             : #endif
   74383           0 :     object->p_freepointer = fp;
   74384             : 
   74385             : #if ROSE_ALLOC_TRACE == 2
   74386             : //    printf("SgNamespaceAliasDeclarationStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgNamespaceAliasDeclarationStatement::next_node);
   74387             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   74388             :     Rose::MemPool::snapshot(oss.str());
   74389             :     alloc_trace_cnt++;
   74390             : #endif
   74391             : 
   74392           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   74393             : 
   74394           0 :     ALLOC_MUTEX(SgNamespaceAliasDeclarationStatement, unlock);
   74395             : 
   74396             :     return object;
   74397             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   74398             : }
   74399             : 
   74400             : 
   74401             : 
   74402             : /*! \brief Delete operator for SgNamespaceAliasDeclarationStatement.
   74403             : 
   74404             :    This delete operator implements deallocation using memory pools to 
   74405             :    provide most efficent use of the heap within construction of large ASTs.
   74406             : 
   74407             : \internal The new and delete operators use the lower level C malloc/free
   74408             :    function calls for performance and to make sure that mixing of malloc/free
   74409             :    and new/delete by the used can be caught more readily.  This may change
   74410             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   74411             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   74412             :    deallocate memory allocated using ROSE_MALLOC.
   74413             : */
   74414           0 : void SgNamespaceAliasDeclarationStatement::operator delete(void *Pointer, size_t Size)
   74415             : {
   74416             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   74417             :      * or throwing an exception. */
   74418           0 :     ALLOC_MUTEX(SgNamespaceAliasDeclarationStatement, lock);
   74419             : 
   74420             : #if USE_CPP_NEW_DELETE_OPERATORS
   74421             :     ROSE_FREE(Pointer);
   74422             : #else
   74423             : #if ROSE_PEDANTIC_ALLOC
   74424             :     ROSE_ASSERT(Size == sizeof(SgNamespaceAliasDeclarationStatement));
   74425             : #else
   74426           0 :     if (Size != sizeof(SgNamespaceAliasDeclarationStatement)) {
   74427           0 :       ROSE_FREE(Pointer);
   74428           0 :       ALLOC_MUTEX(SgNamespaceAliasDeclarationStatement, unlock);
   74429             :       return;
   74430             :     }
   74431             : #endif
   74432             : 
   74433           0 :     SgNamespaceAliasDeclarationStatement * object = (SgNamespaceAliasDeclarationStatement*) Pointer;
   74434           0 :     ROSE_ASSERT(object != nullptr);
   74435             : 
   74436             : #if ROSE_ALLOC_TRACE == 2
   74437             : //  printf("SgNamespaceAliasDeclarationStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgNamespaceAliasDeclarationStatement::next_node);
   74438             :     printf("SgNamespaceAliasDeclarationStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgNamespaceAliasDeclarationStatement::next_node);
   74439             : #endif
   74440             : 
   74441             : #if ROSE_PEDANTIC_ALLOC
   74442             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   74443             : #endif
   74444             : 
   74445             : #if ROSE_ALLOC_MEMSET == 1
   74446             : #elif ROSE_ALLOC_MEMSET == 2
   74447             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgNamespaceAliasDeclarationStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   74448             : #elif ROSE_ALLOC_MEMSET == 3
   74449             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgNamespaceAliasDeclarationStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   74450             : #endif
   74451             : 
   74452             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   74453             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   74454             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   74455             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   74456             : #else
   74457           0 :     object->p_freepointer = SgNamespaceAliasDeclarationStatement::next_node;
   74458           0 :     SgNamespaceAliasDeclarationStatement::next_node = object;
   74459             : #endif
   74460             : 
   74461             : #if ROSE_ALLOC_TRACE == 2
   74462             : //  printf("SgNamespaceAliasDeclarationStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgNamespaceAliasDeclarationStatement::next_node);
   74463             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   74464             :     Rose::MemPool::snapshot(oss.str());
   74465             :     alloc_trace_cnt++;
   74466             : #endif
   74467             : 
   74468             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   74469             : 
   74470           0 :     ALLOC_MUTEX(SgNamespaceAliasDeclarationStatement, unlock);
   74471             : }
   74472             : 
   74473             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   74474             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   74475             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   74476             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   74477             : // Also, note comment below from Robb (copied from the Common.code file).
   74478             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   74479             : //
   74480             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   74481             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   74482             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   74483             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   74484             : #if 0
   74485             : void SgNamespaceAliasDeclarationStatement::operator delete(void* pointer) { SgNamespaceAliasDeclarationStatement::operator delete (pointer, sizeof(SgNamespaceAliasDeclarationStatement)); };
   74486             : #endif
   74487             : /* #line 74488 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   74488             : 
   74489             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   74490             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   74491             : // obviously imply C++.
   74492             : 
   74493             : // This implements the support within ROSE for memory pools.  Memory pools
   74494             : // support the most condensed usage of memory within the construction of
   74495             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   74496             : // by a new operator written for each class.
   74497             : 
   74498             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   74499             :     // User wants multi-thread support and POSIX threads are available.
   74500             : #   include <pthread.h>
   74501             :     static pthread_mutex_t SgCommonBlock_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   74502             : #else
   74503             :      // Cause synchronization to be skipped.
   74504             : #    ifndef ALLOC_MUTEX
   74505             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   74506             : #    endif
   74507             : #    ifdef _REENTRANT
   74508             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   74509             : #       ifdef _MSC_VER
   74510             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   74511             : #       else
   74512             : #           warning "POSIX threads are not available; synchronization being skipped"
   74513             : #       endif
   74514             : #    endif
   74515             : #endif
   74516             : 
   74517             : #ifndef ROSE_ALLOC_TRACE
   74518             : #  define ROSE_ALLOC_TRACE 0
   74519             : #endif
   74520             : 
   74521             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   74522             : #define ROSE_ALLOC_TRACE_CNT
   74523             : #include "memory-pool-snapshot.h"
   74524             : unsigned long alloc_trace_cnt = 0;
   74525             : #endif
   74526             : 
   74527             : #if ROSE_ALLOC_TRACE
   74528             : const unsigned SgCommonBlock::pool_size = 5;
   74529             : #else
   74530             : const unsigned SgCommonBlock::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   74531             : #endif
   74532             : 
   74533             : #ifndef ROSE_ALLOC_MEMSET
   74534             : #  define ROSE_ALLOC_MEMSET 0
   74535             : #endif
   74536             : 
   74537             : #ifndef ROSE_PEDANTIC_ALLOC
   74538             : #  define ROSE_PEDANTIC_ALLOC 0
   74539             : #endif
   74540             : 
   74541             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   74542             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   74543             : #endif
   74544             : 
   74545             : #if !defined(SGNODE__ALL_POOLS)
   74546             : #define SGNODE__ALL_POOLS
   74547             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   74548             : #endif
   74549             : 
   74550             : SgCommonBlock* SgCommonBlock::next_node = nullptr;
   74551             : std::vector<unsigned char*> SgCommonBlock::pools;
   74552             : 
   74553             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   74554             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   74555             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   74556             : // around this macro definition rather than each use).
   74557             : #ifndef ALLOC_MUTEX
   74558             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   74559             :         do {                                                                     \
   74560             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   74561             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   74562             :                 abort();                                                         \
   74563             :             }                                                                    \
   74564             :         } while (0);
   74565             : #endif
   74566             : 
   74567             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   74568             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   74569             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   74570             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   74571             : 
   74572             : /*! \brief New operator for SgCommonBlock.
   74573             : 
   74574             :    This new operator implements memory pools to provide most efficent 
   74575             :    use of the heap within construction of large ASTs.
   74576             : 
   74577             : \internal The new and delete operators use the lower level C malloc/free
   74578             :    function calls for performance and to make sure that mixing of malloc/free
   74579             :    and new/delete by the used can be caught more readily.  This may change
   74580             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   74581             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   74582             :    deallocate memory allocated using ROSE_MALLOC.
   74583             : */
   74584           6 : void *SgCommonBlock::operator new ( size_t Size )
   74585             : {
   74586             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   74587             :      * returning or throwing an exception. */
   74588           6 :     ALLOC_MUTEX(SgCommonBlock, lock);
   74589             : 
   74590             : #if ROSE_ALLOC_TRACE == 2
   74591             : //    printf("SgCommonBlock::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgCommonBlock::next_node);
   74592             : #endif
   74593             : 
   74594             : #if USE_CPP_NEW_DELETE_OPERATORS
   74595             :     void *mem = ROSE_MALLOC(Size);
   74596             :     ALLOC_MUTEX(SgCommonBlock, unlock);
   74597             :     return mem;
   74598             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   74599             : #if ROSE_PEDANTIC_ALLOC
   74600             :     ROSE_ASSERT(Size == sizeof(SgCommonBlock));
   74601             : #else
   74602           6 :     if (Size != sizeof(SgCommonBlock)) {
   74603           0 :       void * object = ROSE_MALLOC(Size);
   74604           0 :       ALLOC_MUTEX(SgCommonBlock, unlock);
   74605             :       return object;
   74606             :     }
   74607             : #endif
   74608             : 
   74609           6 :     if (SgCommonBlock::next_node == nullptr) {
   74610           3 :         SgCommonBlock * alloc = (SgCommonBlock*) ROSE_MALLOC ( SgCommonBlock::pool_size * sizeof(SgCommonBlock) );
   74611           3 :         ROSE_ASSERT(alloc != nullptr);
   74612             : 
   74613             : #if ROSE_ALLOC_TRACE == 2
   74614             : //        printf("SgCommonBlock::alloc\n  block[%zi] = [ %p , %p [\n", SgCommonBlock::pools.size(), alloc, alloc + SgCommonBlock::pool_size);
   74615             : #endif
   74616             : 
   74617             : #if ROSE_ALLOC_MEMSET == 1
   74618             : #elif ROSE_ALLOC_MEMSET == 2
   74619             :         memset(alloc, 0x00, SgCommonBlock::pool_size * sizeof(SgCommonBlock));
   74620             : #elif ROSE_ALLOC_MEMSET == 3
   74621             :         memset(alloc, 0xAA, SgCommonBlock::pool_size * sizeof(SgCommonBlock));
   74622             : #endif
   74623        6000 :         for (unsigned i=0; i < SgCommonBlock::pool_size-1; i++) {
   74624        5997 :           alloc[i].p_freepointer = &(alloc[i+1]);
   74625             :         }
   74626           3 :         alloc[SgCommonBlock::pool_size-1].p_freepointer = nullptr;
   74627             : 
   74628           3 :         SgCommonBlock::pools.push_back ( (unsigned char *) alloc );
   74629           3 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgCommonBlock::pool_size * sizeof(SgCommonBlock), V_SgCommonBlock ) );
   74630           3 :         SgCommonBlock::next_node = alloc;
   74631             :     }
   74632           6 :     ROSE_ASSERT(SgCommonBlock::next_node != nullptr);
   74633             : 
   74634           6 :     SgCommonBlock * object = SgCommonBlock::next_node;
   74635           6 :     SgCommonBlock::next_node = (SgCommonBlock*)(object->p_freepointer);
   74636             : 
   74637             : #if ROSE_ALLOC_TRACE == 2
   74638             :     printf("SgCommonBlock::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgCommonBlock::next_node);
   74639             : #endif
   74640             : 
   74641           6 :     SgNode * fp = object->p_freepointer;
   74642             : #if ROSE_ALLOC_MEMSET == 1
   74643             : #elif ROSE_ALLOC_MEMSET == 2
   74644             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgCommonBlock) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   74645             : #elif ROSE_ALLOC_MEMSET == 3
   74646             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgCommonBlock) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   74647             : #endif
   74648           6 :     object->p_freepointer = fp;
   74649             : 
   74650             : #if ROSE_ALLOC_TRACE == 2
   74651             : //    printf("SgCommonBlock::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgCommonBlock::next_node);
   74652             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   74653             :     Rose::MemPool::snapshot(oss.str());
   74654             :     alloc_trace_cnt++;
   74655             : #endif
   74656             : 
   74657           6 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   74658             : 
   74659           6 :     ALLOC_MUTEX(SgCommonBlock, unlock);
   74660             : 
   74661             :     return object;
   74662             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   74663             : }
   74664             : 
   74665             : 
   74666             : 
   74667             : /*! \brief Delete operator for SgCommonBlock.
   74668             : 
   74669             :    This delete operator implements deallocation using memory pools to 
   74670             :    provide most efficent use of the heap within construction of large ASTs.
   74671             : 
   74672             : \internal The new and delete operators use the lower level C malloc/free
   74673             :    function calls for performance and to make sure that mixing of malloc/free
   74674             :    and new/delete by the used can be caught more readily.  This may change
   74675             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   74676             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   74677             :    deallocate memory allocated using ROSE_MALLOC.
   74678             : */
   74679           0 : void SgCommonBlock::operator delete(void *Pointer, size_t Size)
   74680             : {
   74681             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   74682             :      * or throwing an exception. */
   74683           0 :     ALLOC_MUTEX(SgCommonBlock, lock);
   74684             : 
   74685             : #if USE_CPP_NEW_DELETE_OPERATORS
   74686             :     ROSE_FREE(Pointer);
   74687             : #else
   74688             : #if ROSE_PEDANTIC_ALLOC
   74689             :     ROSE_ASSERT(Size == sizeof(SgCommonBlock));
   74690             : #else
   74691           0 :     if (Size != sizeof(SgCommonBlock)) {
   74692           0 :       ROSE_FREE(Pointer);
   74693           0 :       ALLOC_MUTEX(SgCommonBlock, unlock);
   74694             :       return;
   74695             :     }
   74696             : #endif
   74697             : 
   74698           0 :     SgCommonBlock * object = (SgCommonBlock*) Pointer;
   74699           0 :     ROSE_ASSERT(object != nullptr);
   74700             : 
   74701             : #if ROSE_ALLOC_TRACE == 2
   74702             : //  printf("SgCommonBlock::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgCommonBlock::next_node);
   74703             :     printf("SgCommonBlock::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgCommonBlock::next_node);
   74704             : #endif
   74705             : 
   74706             : #if ROSE_PEDANTIC_ALLOC
   74707             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   74708             : #endif
   74709             : 
   74710             : #if ROSE_ALLOC_MEMSET == 1
   74711             : #elif ROSE_ALLOC_MEMSET == 2
   74712             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgCommonBlock) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   74713             : #elif ROSE_ALLOC_MEMSET == 3
   74714             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgCommonBlock) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   74715             : #endif
   74716             : 
   74717             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   74718             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   74719             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   74720             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   74721             : #else
   74722           0 :     object->p_freepointer = SgCommonBlock::next_node;
   74723           0 :     SgCommonBlock::next_node = object;
   74724             : #endif
   74725             : 
   74726             : #if ROSE_ALLOC_TRACE == 2
   74727             : //  printf("SgCommonBlock::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgCommonBlock::next_node);
   74728             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   74729             :     Rose::MemPool::snapshot(oss.str());
   74730             :     alloc_trace_cnt++;
   74731             : #endif
   74732             : 
   74733             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   74734             : 
   74735           0 :     ALLOC_MUTEX(SgCommonBlock, unlock);
   74736             : }
   74737             : 
   74738             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   74739             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   74740             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   74741             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   74742             : // Also, note comment below from Robb (copied from the Common.code file).
   74743             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   74744             : //
   74745             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   74746             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   74747             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   74748             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   74749             : #if 0
   74750             : void SgCommonBlock::operator delete(void* pointer) { SgCommonBlock::operator delete (pointer, sizeof(SgCommonBlock)); };
   74751             : #endif
   74752             : /* #line 74753 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   74753             : 
   74754             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   74755             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   74756             : // obviously imply C++.
   74757             : 
   74758             : // This implements the support within ROSE for memory pools.  Memory pools
   74759             : // support the most condensed usage of memory within the construction of
   74760             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   74761             : // by a new operator written for each class.
   74762             : 
   74763             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   74764             :     // User wants multi-thread support and POSIX threads are available.
   74765             : #   include <pthread.h>
   74766             :     static pthread_mutex_t SgTypedefDeclaration_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   74767             : #else
   74768             :      // Cause synchronization to be skipped.
   74769             : #    ifndef ALLOC_MUTEX
   74770             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   74771             : #    endif
   74772             : #    ifdef _REENTRANT
   74773             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   74774             : #       ifdef _MSC_VER
   74775             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   74776             : #       else
   74777             : #           warning "POSIX threads are not available; synchronization being skipped"
   74778             : #       endif
   74779             : #    endif
   74780             : #endif
   74781             : 
   74782             : #ifndef ROSE_ALLOC_TRACE
   74783             : #  define ROSE_ALLOC_TRACE 0
   74784             : #endif
   74785             : 
   74786             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   74787             : #define ROSE_ALLOC_TRACE_CNT
   74788             : #include "memory-pool-snapshot.h"
   74789             : unsigned long alloc_trace_cnt = 0;
   74790             : #endif
   74791             : 
   74792             : #if ROSE_ALLOC_TRACE
   74793             : const unsigned SgTypedefDeclaration::pool_size = 5;
   74794             : #else
   74795             : const unsigned SgTypedefDeclaration::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   74796             : #endif
   74797             : 
   74798             : #ifndef ROSE_ALLOC_MEMSET
   74799             : #  define ROSE_ALLOC_MEMSET 0
   74800             : #endif
   74801             : 
   74802             : #ifndef ROSE_PEDANTIC_ALLOC
   74803             : #  define ROSE_PEDANTIC_ALLOC 0
   74804             : #endif
   74805             : 
   74806             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   74807             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   74808             : #endif
   74809             : 
   74810             : #if !defined(SGNODE__ALL_POOLS)
   74811             : #define SGNODE__ALL_POOLS
   74812             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   74813             : #endif
   74814             : 
   74815             : SgTypedefDeclaration* SgTypedefDeclaration::next_node = nullptr;
   74816             : std::vector<unsigned char*> SgTypedefDeclaration::pools;
   74817             : 
   74818             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   74819             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   74820             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   74821             : // around this macro definition rather than each use).
   74822             : #ifndef ALLOC_MUTEX
   74823             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   74824             :         do {                                                                     \
   74825             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   74826             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   74827             :                 abort();                                                         \
   74828             :             }                                                                    \
   74829             :         } while (0);
   74830             : #endif
   74831             : 
   74832             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   74833             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   74834             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   74835             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   74836             : 
   74837             : /*! \brief New operator for SgTypedefDeclaration.
   74838             : 
   74839             :    This new operator implements memory pools to provide most efficent 
   74840             :    use of the heap within construction of large ASTs.
   74841             : 
   74842             : \internal The new and delete operators use the lower level C malloc/free
   74843             :    function calls for performance and to make sure that mixing of malloc/free
   74844             :    and new/delete by the used can be caught more readily.  This may change
   74845             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   74846             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   74847             :    deallocate memory allocated using ROSE_MALLOC.
   74848             : */
   74849       56799 : void *SgTypedefDeclaration::operator new ( size_t Size )
   74850             : {
   74851             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   74852             :      * returning or throwing an exception. */
   74853       56799 :     ALLOC_MUTEX(SgTypedefDeclaration, lock);
   74854             : 
   74855             : #if ROSE_ALLOC_TRACE == 2
   74856             : //    printf("SgTypedefDeclaration::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgTypedefDeclaration::next_node);
   74857             : #endif
   74858             : 
   74859             : #if USE_CPP_NEW_DELETE_OPERATORS
   74860             :     void *mem = ROSE_MALLOC(Size);
   74861             :     ALLOC_MUTEX(SgTypedefDeclaration, unlock);
   74862             :     return mem;
   74863             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   74864             : #if ROSE_PEDANTIC_ALLOC
   74865             :     ROSE_ASSERT(Size == sizeof(SgTypedefDeclaration));
   74866             : #else
   74867       56799 :     if (Size != sizeof(SgTypedefDeclaration)) {
   74868           0 :       void * object = ROSE_MALLOC(Size);
   74869           0 :       ALLOC_MUTEX(SgTypedefDeclaration, unlock);
   74870             :       return object;
   74871             :     }
   74872             : #endif
   74873             : 
   74874       56799 :     if (SgTypedefDeclaration::next_node == nullptr) {
   74875         315 :         SgTypedefDeclaration * alloc = (SgTypedefDeclaration*) ROSE_MALLOC ( SgTypedefDeclaration::pool_size * sizeof(SgTypedefDeclaration) );
   74876         315 :         ROSE_ASSERT(alloc != nullptr);
   74877             : 
   74878             : #if ROSE_ALLOC_TRACE == 2
   74879             : //        printf("SgTypedefDeclaration::alloc\n  block[%zi] = [ %p , %p [\n", SgTypedefDeclaration::pools.size(), alloc, alloc + SgTypedefDeclaration::pool_size);
   74880             : #endif
   74881             : 
   74882             : #if ROSE_ALLOC_MEMSET == 1
   74883             : #elif ROSE_ALLOC_MEMSET == 2
   74884             :         memset(alloc, 0x00, SgTypedefDeclaration::pool_size * sizeof(SgTypedefDeclaration));
   74885             : #elif ROSE_ALLOC_MEMSET == 3
   74886             :         memset(alloc, 0xAA, SgTypedefDeclaration::pool_size * sizeof(SgTypedefDeclaration));
   74887             : #endif
   74888      630000 :         for (unsigned i=0; i < SgTypedefDeclaration::pool_size-1; i++) {
   74889      629685 :           alloc[i].p_freepointer = &(alloc[i+1]);
   74890             :         }
   74891         315 :         alloc[SgTypedefDeclaration::pool_size-1].p_freepointer = nullptr;
   74892             : 
   74893         315 :         SgTypedefDeclaration::pools.push_back ( (unsigned char *) alloc );
   74894         315 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgTypedefDeclaration::pool_size * sizeof(SgTypedefDeclaration), V_SgTypedefDeclaration ) );
   74895         315 :         SgTypedefDeclaration::next_node = alloc;
   74896             :     }
   74897       56799 :     ROSE_ASSERT(SgTypedefDeclaration::next_node != nullptr);
   74898             : 
   74899       56799 :     SgTypedefDeclaration * object = SgTypedefDeclaration::next_node;
   74900       56799 :     SgTypedefDeclaration::next_node = (SgTypedefDeclaration*)(object->p_freepointer);
   74901             : 
   74902             : #if ROSE_ALLOC_TRACE == 2
   74903             :     printf("SgTypedefDeclaration::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypedefDeclaration::next_node);
   74904             : #endif
   74905             : 
   74906       56799 :     SgNode * fp = object->p_freepointer;
   74907             : #if ROSE_ALLOC_MEMSET == 1
   74908             : #elif ROSE_ALLOC_MEMSET == 2
   74909             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgTypedefDeclaration) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   74910             : #elif ROSE_ALLOC_MEMSET == 3
   74911             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgTypedefDeclaration) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   74912             : #endif
   74913       56799 :     object->p_freepointer = fp;
   74914             : 
   74915             : #if ROSE_ALLOC_TRACE == 2
   74916             : //    printf("SgTypedefDeclaration::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypedefDeclaration::next_node);
   74917             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   74918             :     Rose::MemPool::snapshot(oss.str());
   74919             :     alloc_trace_cnt++;
   74920             : #endif
   74921             : 
   74922       56799 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   74923             : 
   74924       56799 :     ALLOC_MUTEX(SgTypedefDeclaration, unlock);
   74925             : 
   74926             :     return object;
   74927             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   74928             : }
   74929             : 
   74930             : 
   74931             : 
   74932             : /*! \brief Delete operator for SgTypedefDeclaration.
   74933             : 
   74934             :    This delete operator implements deallocation using memory pools to 
   74935             :    provide most efficent use of the heap within construction of large ASTs.
   74936             : 
   74937             : \internal The new and delete operators use the lower level C malloc/free
   74938             :    function calls for performance and to make sure that mixing of malloc/free
   74939             :    and new/delete by the used can be caught more readily.  This may change
   74940             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   74941             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   74942             :    deallocate memory allocated using ROSE_MALLOC.
   74943             : */
   74944        3438 : void SgTypedefDeclaration::operator delete(void *Pointer, size_t Size)
   74945             : {
   74946             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   74947             :      * or throwing an exception. */
   74948        3438 :     ALLOC_MUTEX(SgTypedefDeclaration, lock);
   74949             : 
   74950             : #if USE_CPP_NEW_DELETE_OPERATORS
   74951             :     ROSE_FREE(Pointer);
   74952             : #else
   74953             : #if ROSE_PEDANTIC_ALLOC
   74954             :     ROSE_ASSERT(Size == sizeof(SgTypedefDeclaration));
   74955             : #else
   74956        3438 :     if (Size != sizeof(SgTypedefDeclaration)) {
   74957           0 :       ROSE_FREE(Pointer);
   74958           0 :       ALLOC_MUTEX(SgTypedefDeclaration, unlock);
   74959             :       return;
   74960             :     }
   74961             : #endif
   74962             : 
   74963        3438 :     SgTypedefDeclaration * object = (SgTypedefDeclaration*) Pointer;
   74964        3438 :     ROSE_ASSERT(object != nullptr);
   74965             : 
   74966             : #if ROSE_ALLOC_TRACE == 2
   74967             : //  printf("SgTypedefDeclaration::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypedefDeclaration::next_node);
   74968             :     printf("SgTypedefDeclaration::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypedefDeclaration::next_node);
   74969             : #endif
   74970             : 
   74971             : #if ROSE_PEDANTIC_ALLOC
   74972             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   74973             : #endif
   74974             : 
   74975             : #if ROSE_ALLOC_MEMSET == 1
   74976             : #elif ROSE_ALLOC_MEMSET == 2
   74977             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgTypedefDeclaration) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   74978             : #elif ROSE_ALLOC_MEMSET == 3
   74979             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgTypedefDeclaration) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   74980             : #endif
   74981             : 
   74982             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   74983             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   74984             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   74985             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   74986             : #else
   74987        3438 :     object->p_freepointer = SgTypedefDeclaration::next_node;
   74988        3438 :     SgTypedefDeclaration::next_node = object;
   74989             : #endif
   74990             : 
   74991             : #if ROSE_ALLOC_TRACE == 2
   74992             : //  printf("SgTypedefDeclaration::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypedefDeclaration::next_node);
   74993             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   74994             :     Rose::MemPool::snapshot(oss.str());
   74995             :     alloc_trace_cnt++;
   74996             : #endif
   74997             : 
   74998             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   74999             : 
   75000        3438 :     ALLOC_MUTEX(SgTypedefDeclaration, unlock);
   75001             : }
   75002             : 
   75003             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   75004             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   75005             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   75006             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   75007             : // Also, note comment below from Robb (copied from the Common.code file).
   75008             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   75009             : //
   75010             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   75011             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   75012             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   75013             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   75014             : #if 0
   75015             : void SgTypedefDeclaration::operator delete(void* pointer) { SgTypedefDeclaration::operator delete (pointer, sizeof(SgTypedefDeclaration)); };
   75016             : #endif
   75017             : /* #line 75018 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   75018             : 
   75019             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   75020             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   75021             : // obviously imply C++.
   75022             : 
   75023             : // This implements the support within ROSE for memory pools.  Memory pools
   75024             : // support the most condensed usage of memory within the construction of
   75025             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   75026             : // by a new operator written for each class.
   75027             : 
   75028             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   75029             :     // User wants multi-thread support and POSIX threads are available.
   75030             : #   include <pthread.h>
   75031             :     static pthread_mutex_t SgTemplateTypedefDeclaration_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   75032             : #else
   75033             :      // Cause synchronization to be skipped.
   75034             : #    ifndef ALLOC_MUTEX
   75035             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   75036             : #    endif
   75037             : #    ifdef _REENTRANT
   75038             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   75039             : #       ifdef _MSC_VER
   75040             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   75041             : #       else
   75042             : #           warning "POSIX threads are not available; synchronization being skipped"
   75043             : #       endif
   75044             : #    endif
   75045             : #endif
   75046             : 
   75047             : #ifndef ROSE_ALLOC_TRACE
   75048             : #  define ROSE_ALLOC_TRACE 0
   75049             : #endif
   75050             : 
   75051             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   75052             : #define ROSE_ALLOC_TRACE_CNT
   75053             : #include "memory-pool-snapshot.h"
   75054             : unsigned long alloc_trace_cnt = 0;
   75055             : #endif
   75056             : 
   75057             : #if ROSE_ALLOC_TRACE
   75058             : const unsigned SgTemplateTypedefDeclaration::pool_size = 5;
   75059             : #else
   75060             : const unsigned SgTemplateTypedefDeclaration::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   75061             : #endif
   75062             : 
   75063             : #ifndef ROSE_ALLOC_MEMSET
   75064             : #  define ROSE_ALLOC_MEMSET 0
   75065             : #endif
   75066             : 
   75067             : #ifndef ROSE_PEDANTIC_ALLOC
   75068             : #  define ROSE_PEDANTIC_ALLOC 0
   75069             : #endif
   75070             : 
   75071             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   75072             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   75073             : #endif
   75074             : 
   75075             : #if !defined(SGNODE__ALL_POOLS)
   75076             : #define SGNODE__ALL_POOLS
   75077             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   75078             : #endif
   75079             : 
   75080             : SgTemplateTypedefDeclaration* SgTemplateTypedefDeclaration::next_node = nullptr;
   75081             : std::vector<unsigned char*> SgTemplateTypedefDeclaration::pools;
   75082             : 
   75083             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   75084             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   75085             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   75086             : // around this macro definition rather than each use).
   75087             : #ifndef ALLOC_MUTEX
   75088             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   75089             :         do {                                                                     \
   75090             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   75091             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   75092             :                 abort();                                                         \
   75093             :             }                                                                    \
   75094             :         } while (0);
   75095             : #endif
   75096             : 
   75097             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   75098             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   75099             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   75100             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   75101             : 
   75102             : /*! \brief New operator for SgTemplateTypedefDeclaration.
   75103             : 
   75104             :    This new operator implements memory pools to provide most efficent 
   75105             :    use of the heap within construction of large ASTs.
   75106             : 
   75107             : \internal The new and delete operators use the lower level C malloc/free
   75108             :    function calls for performance and to make sure that mixing of malloc/free
   75109             :    and new/delete by the used can be caught more readily.  This may change
   75110             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   75111             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   75112             :    deallocate memory allocated using ROSE_MALLOC.
   75113             : */
   75114         987 : void *SgTemplateTypedefDeclaration::operator new ( size_t Size )
   75115             : {
   75116             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   75117             :      * returning or throwing an exception. */
   75118         987 :     ALLOC_MUTEX(SgTemplateTypedefDeclaration, lock);
   75119             : 
   75120             : #if ROSE_ALLOC_TRACE == 2
   75121             : //    printf("SgTemplateTypedefDeclaration::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgTemplateTypedefDeclaration::next_node);
   75122             : #endif
   75123             : 
   75124             : #if USE_CPP_NEW_DELETE_OPERATORS
   75125             :     void *mem = ROSE_MALLOC(Size);
   75126             :     ALLOC_MUTEX(SgTemplateTypedefDeclaration, unlock);
   75127             :     return mem;
   75128             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   75129             : #if ROSE_PEDANTIC_ALLOC
   75130             :     ROSE_ASSERT(Size == sizeof(SgTemplateTypedefDeclaration));
   75131             : #else
   75132         987 :     if (Size != sizeof(SgTemplateTypedefDeclaration)) {
   75133           0 :       void * object = ROSE_MALLOC(Size);
   75134           0 :       ALLOC_MUTEX(SgTemplateTypedefDeclaration, unlock);
   75135             :       return object;
   75136             :     }
   75137             : #endif
   75138             : 
   75139         987 :     if (SgTemplateTypedefDeclaration::next_node == nullptr) {
   75140          10 :         SgTemplateTypedefDeclaration * alloc = (SgTemplateTypedefDeclaration*) ROSE_MALLOC ( SgTemplateTypedefDeclaration::pool_size * sizeof(SgTemplateTypedefDeclaration) );
   75141          10 :         ROSE_ASSERT(alloc != nullptr);
   75142             : 
   75143             : #if ROSE_ALLOC_TRACE == 2
   75144             : //        printf("SgTemplateTypedefDeclaration::alloc\n  block[%zi] = [ %p , %p [\n", SgTemplateTypedefDeclaration::pools.size(), alloc, alloc + SgTemplateTypedefDeclaration::pool_size);
   75145             : #endif
   75146             : 
   75147             : #if ROSE_ALLOC_MEMSET == 1
   75148             : #elif ROSE_ALLOC_MEMSET == 2
   75149             :         memset(alloc, 0x00, SgTemplateTypedefDeclaration::pool_size * sizeof(SgTemplateTypedefDeclaration));
   75150             : #elif ROSE_ALLOC_MEMSET == 3
   75151             :         memset(alloc, 0xAA, SgTemplateTypedefDeclaration::pool_size * sizeof(SgTemplateTypedefDeclaration));
   75152             : #endif
   75153       20000 :         for (unsigned i=0; i < SgTemplateTypedefDeclaration::pool_size-1; i++) {
   75154       19990 :           alloc[i].p_freepointer = &(alloc[i+1]);
   75155             :         }
   75156          10 :         alloc[SgTemplateTypedefDeclaration::pool_size-1].p_freepointer = nullptr;
   75157             : 
   75158          10 :         SgTemplateTypedefDeclaration::pools.push_back ( (unsigned char *) alloc );
   75159          10 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgTemplateTypedefDeclaration::pool_size * sizeof(SgTemplateTypedefDeclaration), V_SgTemplateTypedefDeclaration ) );
   75160          10 :         SgTemplateTypedefDeclaration::next_node = alloc;
   75161             :     }
   75162         987 :     ROSE_ASSERT(SgTemplateTypedefDeclaration::next_node != nullptr);
   75163             : 
   75164         987 :     SgTemplateTypedefDeclaration * object = SgTemplateTypedefDeclaration::next_node;
   75165         987 :     SgTemplateTypedefDeclaration::next_node = (SgTemplateTypedefDeclaration*)(object->p_freepointer);
   75166             : 
   75167             : #if ROSE_ALLOC_TRACE == 2
   75168             :     printf("SgTemplateTypedefDeclaration::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTemplateTypedefDeclaration::next_node);
   75169             : #endif
   75170             : 
   75171         987 :     SgNode * fp = object->p_freepointer;
   75172             : #if ROSE_ALLOC_MEMSET == 1
   75173             : #elif ROSE_ALLOC_MEMSET == 2
   75174             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgTemplateTypedefDeclaration) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   75175             : #elif ROSE_ALLOC_MEMSET == 3
   75176             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgTemplateTypedefDeclaration) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   75177             : #endif
   75178         987 :     object->p_freepointer = fp;
   75179             : 
   75180             : #if ROSE_ALLOC_TRACE == 2
   75181             : //    printf("SgTemplateTypedefDeclaration::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTemplateTypedefDeclaration::next_node);
   75182             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   75183             :     Rose::MemPool::snapshot(oss.str());
   75184             :     alloc_trace_cnt++;
   75185             : #endif
   75186             : 
   75187         987 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   75188             : 
   75189         987 :     ALLOC_MUTEX(SgTemplateTypedefDeclaration, unlock);
   75190             : 
   75191             :     return object;
   75192             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   75193             : }
   75194             : 
   75195             : 
   75196             : 
   75197             : /*! \brief Delete operator for SgTemplateTypedefDeclaration.
   75198             : 
   75199             :    This delete operator implements deallocation using memory pools to 
   75200             :    provide most efficent use of the heap within construction of large ASTs.
   75201             : 
   75202             : \internal The new and delete operators use the lower level C malloc/free
   75203             :    function calls for performance and to make sure that mixing of malloc/free
   75204             :    and new/delete by the used can be caught more readily.  This may change
   75205             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   75206             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   75207             :    deallocate memory allocated using ROSE_MALLOC.
   75208             : */
   75209         190 : void SgTemplateTypedefDeclaration::operator delete(void *Pointer, size_t Size)
   75210             : {
   75211             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   75212             :      * or throwing an exception. */
   75213         190 :     ALLOC_MUTEX(SgTemplateTypedefDeclaration, lock);
   75214             : 
   75215             : #if USE_CPP_NEW_DELETE_OPERATORS
   75216             :     ROSE_FREE(Pointer);
   75217             : #else
   75218             : #if ROSE_PEDANTIC_ALLOC
   75219             :     ROSE_ASSERT(Size == sizeof(SgTemplateTypedefDeclaration));
   75220             : #else
   75221         190 :     if (Size != sizeof(SgTemplateTypedefDeclaration)) {
   75222           0 :       ROSE_FREE(Pointer);
   75223           0 :       ALLOC_MUTEX(SgTemplateTypedefDeclaration, unlock);
   75224             :       return;
   75225             :     }
   75226             : #endif
   75227             : 
   75228         190 :     SgTemplateTypedefDeclaration * object = (SgTemplateTypedefDeclaration*) Pointer;
   75229         190 :     ROSE_ASSERT(object != nullptr);
   75230             : 
   75231             : #if ROSE_ALLOC_TRACE == 2
   75232             : //  printf("SgTemplateTypedefDeclaration::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTemplateTypedefDeclaration::next_node);
   75233             :     printf("SgTemplateTypedefDeclaration::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTemplateTypedefDeclaration::next_node);
   75234             : #endif
   75235             : 
   75236             : #if ROSE_PEDANTIC_ALLOC
   75237             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   75238             : #endif
   75239             : 
   75240             : #if ROSE_ALLOC_MEMSET == 1
   75241             : #elif ROSE_ALLOC_MEMSET == 2
   75242             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgTemplateTypedefDeclaration) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   75243             : #elif ROSE_ALLOC_MEMSET == 3
   75244             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgTemplateTypedefDeclaration) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   75245             : #endif
   75246             : 
   75247             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   75248             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   75249             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   75250             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   75251             : #else
   75252         190 :     object->p_freepointer = SgTemplateTypedefDeclaration::next_node;
   75253         190 :     SgTemplateTypedefDeclaration::next_node = object;
   75254             : #endif
   75255             : 
   75256             : #if ROSE_ALLOC_TRACE == 2
   75257             : //  printf("SgTemplateTypedefDeclaration::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTemplateTypedefDeclaration::next_node);
   75258             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   75259             :     Rose::MemPool::snapshot(oss.str());
   75260             :     alloc_trace_cnt++;
   75261             : #endif
   75262             : 
   75263             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   75264             : 
   75265         190 :     ALLOC_MUTEX(SgTemplateTypedefDeclaration, unlock);
   75266             : }
   75267             : 
   75268             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   75269             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   75270             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   75271             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   75272             : // Also, note comment below from Robb (copied from the Common.code file).
   75273             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   75274             : //
   75275             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   75276             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   75277             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   75278             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   75279             : #if 0
   75280             : void SgTemplateTypedefDeclaration::operator delete(void* pointer) { SgTemplateTypedefDeclaration::operator delete (pointer, sizeof(SgTemplateTypedefDeclaration)); };
   75281             : #endif
   75282             : /* #line 75283 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   75283             : 
   75284             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   75285             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   75286             : // obviously imply C++.
   75287             : 
   75288             : // This implements the support within ROSE for memory pools.  Memory pools
   75289             : // support the most condensed usage of memory within the construction of
   75290             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   75291             : // by a new operator written for each class.
   75292             : 
   75293             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   75294             :     // User wants multi-thread support and POSIX threads are available.
   75295             : #   include <pthread.h>
   75296             :     static pthread_mutex_t SgTemplateInstantiationTypedefDeclaration_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   75297             : #else
   75298             :      // Cause synchronization to be skipped.
   75299             : #    ifndef ALLOC_MUTEX
   75300             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   75301             : #    endif
   75302             : #    ifdef _REENTRANT
   75303             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   75304             : #       ifdef _MSC_VER
   75305             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   75306             : #       else
   75307             : #           warning "POSIX threads are not available; synchronization being skipped"
   75308             : #       endif
   75309             : #    endif
   75310             : #endif
   75311             : 
   75312             : #ifndef ROSE_ALLOC_TRACE
   75313             : #  define ROSE_ALLOC_TRACE 0
   75314             : #endif
   75315             : 
   75316             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   75317             : #define ROSE_ALLOC_TRACE_CNT
   75318             : #include "memory-pool-snapshot.h"
   75319             : unsigned long alloc_trace_cnt = 0;
   75320             : #endif
   75321             : 
   75322             : #if ROSE_ALLOC_TRACE
   75323             : const unsigned SgTemplateInstantiationTypedefDeclaration::pool_size = 5;
   75324             : #else
   75325             : const unsigned SgTemplateInstantiationTypedefDeclaration::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   75326             : #endif
   75327             : 
   75328             : #ifndef ROSE_ALLOC_MEMSET
   75329             : #  define ROSE_ALLOC_MEMSET 0
   75330             : #endif
   75331             : 
   75332             : #ifndef ROSE_PEDANTIC_ALLOC
   75333             : #  define ROSE_PEDANTIC_ALLOC 0
   75334             : #endif
   75335             : 
   75336             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   75337             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   75338             : #endif
   75339             : 
   75340             : #if !defined(SGNODE__ALL_POOLS)
   75341             : #define SGNODE__ALL_POOLS
   75342             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   75343             : #endif
   75344             : 
   75345             : SgTemplateInstantiationTypedefDeclaration* SgTemplateInstantiationTypedefDeclaration::next_node = nullptr;
   75346             : std::vector<unsigned char*> SgTemplateInstantiationTypedefDeclaration::pools;
   75347             : 
   75348             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   75349             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   75350             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   75351             : // around this macro definition rather than each use).
   75352             : #ifndef ALLOC_MUTEX
   75353             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   75354             :         do {                                                                     \
   75355             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   75356             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   75357             :                 abort();                                                         \
   75358             :             }                                                                    \
   75359             :         } while (0);
   75360             : #endif
   75361             : 
   75362             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   75363             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   75364             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   75365             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   75366             : 
   75367             : /*! \brief New operator for SgTemplateInstantiationTypedefDeclaration.
   75368             : 
   75369             :    This new operator implements memory pools to provide most efficent 
   75370             :    use of the heap within construction of large ASTs.
   75371             : 
   75372             : \internal The new and delete operators use the lower level C malloc/free
   75373             :    function calls for performance and to make sure that mixing of malloc/free
   75374             :    and new/delete by the used can be caught more readily.  This may change
   75375             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   75376             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   75377             :    deallocate memory allocated using ROSE_MALLOC.
   75378             : */
   75379         667 : void *SgTemplateInstantiationTypedefDeclaration::operator new ( size_t Size )
   75380             : {
   75381             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   75382             :      * returning or throwing an exception. */
   75383         667 :     ALLOC_MUTEX(SgTemplateInstantiationTypedefDeclaration, lock);
   75384             : 
   75385             : #if ROSE_ALLOC_TRACE == 2
   75386             : //    printf("SgTemplateInstantiationTypedefDeclaration::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgTemplateInstantiationTypedefDeclaration::next_node);
   75387             : #endif
   75388             : 
   75389             : #if USE_CPP_NEW_DELETE_OPERATORS
   75390             :     void *mem = ROSE_MALLOC(Size);
   75391             :     ALLOC_MUTEX(SgTemplateInstantiationTypedefDeclaration, unlock);
   75392             :     return mem;
   75393             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   75394             : #if ROSE_PEDANTIC_ALLOC
   75395             :     ROSE_ASSERT(Size == sizeof(SgTemplateInstantiationTypedefDeclaration));
   75396             : #else
   75397         667 :     if (Size != sizeof(SgTemplateInstantiationTypedefDeclaration)) {
   75398           0 :       void * object = ROSE_MALLOC(Size);
   75399           0 :       ALLOC_MUTEX(SgTemplateInstantiationTypedefDeclaration, unlock);
   75400             :       return object;
   75401             :     }
   75402             : #endif
   75403             : 
   75404         667 :     if (SgTemplateInstantiationTypedefDeclaration::next_node == nullptr) {
   75405          10 :         SgTemplateInstantiationTypedefDeclaration * alloc = (SgTemplateInstantiationTypedefDeclaration*) ROSE_MALLOC ( SgTemplateInstantiationTypedefDeclaration::pool_size * sizeof(SgTemplateInstantiationTypedefDeclaration) );
   75406          10 :         ROSE_ASSERT(alloc != nullptr);
   75407             : 
   75408             : #if ROSE_ALLOC_TRACE == 2
   75409             : //        printf("SgTemplateInstantiationTypedefDeclaration::alloc\n  block[%zi] = [ %p , %p [\n", SgTemplateInstantiationTypedefDeclaration::pools.size(), alloc, alloc + SgTemplateInstantiationTypedefDeclaration::pool_size);
   75410             : #endif
   75411             : 
   75412             : #if ROSE_ALLOC_MEMSET == 1
   75413             : #elif ROSE_ALLOC_MEMSET == 2
   75414             :         memset(alloc, 0x00, SgTemplateInstantiationTypedefDeclaration::pool_size * sizeof(SgTemplateInstantiationTypedefDeclaration));
   75415             : #elif ROSE_ALLOC_MEMSET == 3
   75416             :         memset(alloc, 0xAA, SgTemplateInstantiationTypedefDeclaration::pool_size * sizeof(SgTemplateInstantiationTypedefDeclaration));
   75417             : #endif
   75418       20000 :         for (unsigned i=0; i < SgTemplateInstantiationTypedefDeclaration::pool_size-1; i++) {
   75419       19990 :           alloc[i].p_freepointer = &(alloc[i+1]);
   75420             :         }
   75421          10 :         alloc[SgTemplateInstantiationTypedefDeclaration::pool_size-1].p_freepointer = nullptr;
   75422             : 
   75423          10 :         SgTemplateInstantiationTypedefDeclaration::pools.push_back ( (unsigned char *) alloc );
   75424          10 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgTemplateInstantiationTypedefDeclaration::pool_size * sizeof(SgTemplateInstantiationTypedefDeclaration), V_SgTemplateInstantiationTypedefDeclaration ) );
   75425          10 :         SgTemplateInstantiationTypedefDeclaration::next_node = alloc;
   75426             :     }
   75427         667 :     ROSE_ASSERT(SgTemplateInstantiationTypedefDeclaration::next_node != nullptr);
   75428             : 
   75429         667 :     SgTemplateInstantiationTypedefDeclaration * object = SgTemplateInstantiationTypedefDeclaration::next_node;
   75430         667 :     SgTemplateInstantiationTypedefDeclaration::next_node = (SgTemplateInstantiationTypedefDeclaration*)(object->p_freepointer);
   75431             : 
   75432             : #if ROSE_ALLOC_TRACE == 2
   75433             :     printf("SgTemplateInstantiationTypedefDeclaration::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTemplateInstantiationTypedefDeclaration::next_node);
   75434             : #endif
   75435             : 
   75436         667 :     SgNode * fp = object->p_freepointer;
   75437             : #if ROSE_ALLOC_MEMSET == 1
   75438             : #elif ROSE_ALLOC_MEMSET == 2
   75439             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgTemplateInstantiationTypedefDeclaration) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   75440             : #elif ROSE_ALLOC_MEMSET == 3
   75441             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgTemplateInstantiationTypedefDeclaration) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   75442             : #endif
   75443         667 :     object->p_freepointer = fp;
   75444             : 
   75445             : #if ROSE_ALLOC_TRACE == 2
   75446             : //    printf("SgTemplateInstantiationTypedefDeclaration::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTemplateInstantiationTypedefDeclaration::next_node);
   75447             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   75448             :     Rose::MemPool::snapshot(oss.str());
   75449             :     alloc_trace_cnt++;
   75450             : #endif
   75451             : 
   75452         667 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   75453             : 
   75454         667 :     ALLOC_MUTEX(SgTemplateInstantiationTypedefDeclaration, unlock);
   75455             : 
   75456             :     return object;
   75457             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   75458             : }
   75459             : 
   75460             : 
   75461             : 
   75462             : /*! \brief Delete operator for SgTemplateInstantiationTypedefDeclaration.
   75463             : 
   75464             :    This delete operator implements deallocation using memory pools to 
   75465             :    provide most efficent use of the heap within construction of large ASTs.
   75466             : 
   75467             : \internal The new and delete operators use the lower level C malloc/free
   75468             :    function calls for performance and to make sure that mixing of malloc/free
   75469             :    and new/delete by the used can be caught more readily.  This may change
   75470             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   75471             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   75472             :    deallocate memory allocated using ROSE_MALLOC.
   75473             : */
   75474         130 : void SgTemplateInstantiationTypedefDeclaration::operator delete(void *Pointer, size_t Size)
   75475             : {
   75476             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   75477             :      * or throwing an exception. */
   75478         130 :     ALLOC_MUTEX(SgTemplateInstantiationTypedefDeclaration, lock);
   75479             : 
   75480             : #if USE_CPP_NEW_DELETE_OPERATORS
   75481             :     ROSE_FREE(Pointer);
   75482             : #else
   75483             : #if ROSE_PEDANTIC_ALLOC
   75484             :     ROSE_ASSERT(Size == sizeof(SgTemplateInstantiationTypedefDeclaration));
   75485             : #else
   75486         130 :     if (Size != sizeof(SgTemplateInstantiationTypedefDeclaration)) {
   75487           0 :       ROSE_FREE(Pointer);
   75488           0 :       ALLOC_MUTEX(SgTemplateInstantiationTypedefDeclaration, unlock);
   75489             :       return;
   75490             :     }
   75491             : #endif
   75492             : 
   75493         130 :     SgTemplateInstantiationTypedefDeclaration * object = (SgTemplateInstantiationTypedefDeclaration*) Pointer;
   75494         130 :     ROSE_ASSERT(object != nullptr);
   75495             : 
   75496             : #if ROSE_ALLOC_TRACE == 2
   75497             : //  printf("SgTemplateInstantiationTypedefDeclaration::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTemplateInstantiationTypedefDeclaration::next_node);
   75498             :     printf("SgTemplateInstantiationTypedefDeclaration::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTemplateInstantiationTypedefDeclaration::next_node);
   75499             : #endif
   75500             : 
   75501             : #if ROSE_PEDANTIC_ALLOC
   75502             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   75503             : #endif
   75504             : 
   75505             : #if ROSE_ALLOC_MEMSET == 1
   75506             : #elif ROSE_ALLOC_MEMSET == 2
   75507             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgTemplateInstantiationTypedefDeclaration) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   75508             : #elif ROSE_ALLOC_MEMSET == 3
   75509             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgTemplateInstantiationTypedefDeclaration) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   75510             : #endif
   75511             : 
   75512             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   75513             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   75514             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   75515             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   75516             : #else
   75517         130 :     object->p_freepointer = SgTemplateInstantiationTypedefDeclaration::next_node;
   75518         130 :     SgTemplateInstantiationTypedefDeclaration::next_node = object;
   75519             : #endif
   75520             : 
   75521             : #if ROSE_ALLOC_TRACE == 2
   75522             : //  printf("SgTemplateInstantiationTypedefDeclaration::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTemplateInstantiationTypedefDeclaration::next_node);
   75523             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   75524             :     Rose::MemPool::snapshot(oss.str());
   75525             :     alloc_trace_cnt++;
   75526             : #endif
   75527             : 
   75528             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   75529             : 
   75530         130 :     ALLOC_MUTEX(SgTemplateInstantiationTypedefDeclaration, unlock);
   75531             : }
   75532             : 
   75533             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   75534             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   75535             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   75536             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   75537             : // Also, note comment below from Robb (copied from the Common.code file).
   75538             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   75539             : //
   75540             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   75541             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   75542             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   75543             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   75544             : #if 0
   75545             : void SgTemplateInstantiationTypedefDeclaration::operator delete(void* pointer) { SgTemplateInstantiationTypedefDeclaration::operator delete (pointer, sizeof(SgTemplateInstantiationTypedefDeclaration)); };
   75546             : #endif
   75547             : /* #line 75548 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   75548             : 
   75549             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   75550             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   75551             : // obviously imply C++.
   75552             : 
   75553             : // This implements the support within ROSE for memory pools.  Memory pools
   75554             : // support the most condensed usage of memory within the construction of
   75555             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   75556             : // by a new operator written for each class.
   75557             : 
   75558             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   75559             :     // User wants multi-thread support and POSIX threads are available.
   75560             : #   include <pthread.h>
   75561             :     static pthread_mutex_t SgStatementFunctionStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   75562             : #else
   75563             :      // Cause synchronization to be skipped.
   75564             : #    ifndef ALLOC_MUTEX
   75565             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   75566             : #    endif
   75567             : #    ifdef _REENTRANT
   75568             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   75569             : #       ifdef _MSC_VER
   75570             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   75571             : #       else
   75572             : #           warning "POSIX threads are not available; synchronization being skipped"
   75573             : #       endif
   75574             : #    endif
   75575             : #endif
   75576             : 
   75577             : #ifndef ROSE_ALLOC_TRACE
   75578             : #  define ROSE_ALLOC_TRACE 0
   75579             : #endif
   75580             : 
   75581             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   75582             : #define ROSE_ALLOC_TRACE_CNT
   75583             : #include "memory-pool-snapshot.h"
   75584             : unsigned long alloc_trace_cnt = 0;
   75585             : #endif
   75586             : 
   75587             : #if ROSE_ALLOC_TRACE
   75588             : const unsigned SgStatementFunctionStatement::pool_size = 5;
   75589             : #else
   75590             : const unsigned SgStatementFunctionStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   75591             : #endif
   75592             : 
   75593             : #ifndef ROSE_ALLOC_MEMSET
   75594             : #  define ROSE_ALLOC_MEMSET 0
   75595             : #endif
   75596             : 
   75597             : #ifndef ROSE_PEDANTIC_ALLOC
   75598             : #  define ROSE_PEDANTIC_ALLOC 0
   75599             : #endif
   75600             : 
   75601             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   75602             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   75603             : #endif
   75604             : 
   75605             : #if !defined(SGNODE__ALL_POOLS)
   75606             : #define SGNODE__ALL_POOLS
   75607             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   75608             : #endif
   75609             : 
   75610             : SgStatementFunctionStatement* SgStatementFunctionStatement::next_node = nullptr;
   75611             : std::vector<unsigned char*> SgStatementFunctionStatement::pools;
   75612             : 
   75613             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   75614             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   75615             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   75616             : // around this macro definition rather than each use).
   75617             : #ifndef ALLOC_MUTEX
   75618             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   75619             :         do {                                                                     \
   75620             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   75621             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   75622             :                 abort();                                                         \
   75623             :             }                                                                    \
   75624             :         } while (0);
   75625             : #endif
   75626             : 
   75627             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   75628             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   75629             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   75630             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   75631             : 
   75632             : /*! \brief New operator for SgStatementFunctionStatement.
   75633             : 
   75634             :    This new operator implements memory pools to provide most efficent 
   75635             :    use of the heap within construction of large ASTs.
   75636             : 
   75637             : \internal The new and delete operators use the lower level C malloc/free
   75638             :    function calls for performance and to make sure that mixing of malloc/free
   75639             :    and new/delete by the used can be caught more readily.  This may change
   75640             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   75641             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   75642             :    deallocate memory allocated using ROSE_MALLOC.
   75643             : */
   75644           0 : void *SgStatementFunctionStatement::operator new ( size_t Size )
   75645             : {
   75646             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   75647             :      * returning or throwing an exception. */
   75648           0 :     ALLOC_MUTEX(SgStatementFunctionStatement, lock);
   75649             : 
   75650             : #if ROSE_ALLOC_TRACE == 2
   75651             : //    printf("SgStatementFunctionStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgStatementFunctionStatement::next_node);
   75652             : #endif
   75653             : 
   75654             : #if USE_CPP_NEW_DELETE_OPERATORS
   75655             :     void *mem = ROSE_MALLOC(Size);
   75656             :     ALLOC_MUTEX(SgStatementFunctionStatement, unlock);
   75657             :     return mem;
   75658             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   75659             : #if ROSE_PEDANTIC_ALLOC
   75660             :     ROSE_ASSERT(Size == sizeof(SgStatementFunctionStatement));
   75661             : #else
   75662           0 :     if (Size != sizeof(SgStatementFunctionStatement)) {
   75663           0 :       void * object = ROSE_MALLOC(Size);
   75664           0 :       ALLOC_MUTEX(SgStatementFunctionStatement, unlock);
   75665             :       return object;
   75666             :     }
   75667             : #endif
   75668             : 
   75669           0 :     if (SgStatementFunctionStatement::next_node == nullptr) {
   75670           0 :         SgStatementFunctionStatement * alloc = (SgStatementFunctionStatement*) ROSE_MALLOC ( SgStatementFunctionStatement::pool_size * sizeof(SgStatementFunctionStatement) );
   75671           0 :         ROSE_ASSERT(alloc != nullptr);
   75672             : 
   75673             : #if ROSE_ALLOC_TRACE == 2
   75674             : //        printf("SgStatementFunctionStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgStatementFunctionStatement::pools.size(), alloc, alloc + SgStatementFunctionStatement::pool_size);
   75675             : #endif
   75676             : 
   75677             : #if ROSE_ALLOC_MEMSET == 1
   75678             : #elif ROSE_ALLOC_MEMSET == 2
   75679             :         memset(alloc, 0x00, SgStatementFunctionStatement::pool_size * sizeof(SgStatementFunctionStatement));
   75680             : #elif ROSE_ALLOC_MEMSET == 3
   75681             :         memset(alloc, 0xAA, SgStatementFunctionStatement::pool_size * sizeof(SgStatementFunctionStatement));
   75682             : #endif
   75683           0 :         for (unsigned i=0; i < SgStatementFunctionStatement::pool_size-1; i++) {
   75684           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
   75685             :         }
   75686           0 :         alloc[SgStatementFunctionStatement::pool_size-1].p_freepointer = nullptr;
   75687             : 
   75688           0 :         SgStatementFunctionStatement::pools.push_back ( (unsigned char *) alloc );
   75689           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgStatementFunctionStatement::pool_size * sizeof(SgStatementFunctionStatement), V_SgStatementFunctionStatement ) );
   75690           0 :         SgStatementFunctionStatement::next_node = alloc;
   75691             :     }
   75692           0 :     ROSE_ASSERT(SgStatementFunctionStatement::next_node != nullptr);
   75693             : 
   75694           0 :     SgStatementFunctionStatement * object = SgStatementFunctionStatement::next_node;
   75695           0 :     SgStatementFunctionStatement::next_node = (SgStatementFunctionStatement*)(object->p_freepointer);
   75696             : 
   75697             : #if ROSE_ALLOC_TRACE == 2
   75698             :     printf("SgStatementFunctionStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgStatementFunctionStatement::next_node);
   75699             : #endif
   75700             : 
   75701           0 :     SgNode * fp = object->p_freepointer;
   75702             : #if ROSE_ALLOC_MEMSET == 1
   75703             : #elif ROSE_ALLOC_MEMSET == 2
   75704             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgStatementFunctionStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   75705             : #elif ROSE_ALLOC_MEMSET == 3
   75706             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgStatementFunctionStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   75707             : #endif
   75708           0 :     object->p_freepointer = fp;
   75709             : 
   75710             : #if ROSE_ALLOC_TRACE == 2
   75711             : //    printf("SgStatementFunctionStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgStatementFunctionStatement::next_node);
   75712             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   75713             :     Rose::MemPool::snapshot(oss.str());
   75714             :     alloc_trace_cnt++;
   75715             : #endif
   75716             : 
   75717           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   75718             : 
   75719           0 :     ALLOC_MUTEX(SgStatementFunctionStatement, unlock);
   75720             : 
   75721             :     return object;
   75722             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   75723             : }
   75724             : 
   75725             : 
   75726             : 
   75727             : /*! \brief Delete operator for SgStatementFunctionStatement.
   75728             : 
   75729             :    This delete operator implements deallocation using memory pools to 
   75730             :    provide most efficent use of the heap within construction of large ASTs.
   75731             : 
   75732             : \internal The new and delete operators use the lower level C malloc/free
   75733             :    function calls for performance and to make sure that mixing of malloc/free
   75734             :    and new/delete by the used can be caught more readily.  This may change
   75735             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   75736             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   75737             :    deallocate memory allocated using ROSE_MALLOC.
   75738             : */
   75739           0 : void SgStatementFunctionStatement::operator delete(void *Pointer, size_t Size)
   75740             : {
   75741             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   75742             :      * or throwing an exception. */
   75743           0 :     ALLOC_MUTEX(SgStatementFunctionStatement, lock);
   75744             : 
   75745             : #if USE_CPP_NEW_DELETE_OPERATORS
   75746             :     ROSE_FREE(Pointer);
   75747             : #else
   75748             : #if ROSE_PEDANTIC_ALLOC
   75749             :     ROSE_ASSERT(Size == sizeof(SgStatementFunctionStatement));
   75750             : #else
   75751           0 :     if (Size != sizeof(SgStatementFunctionStatement)) {
   75752           0 :       ROSE_FREE(Pointer);
   75753           0 :       ALLOC_MUTEX(SgStatementFunctionStatement, unlock);
   75754             :       return;
   75755             :     }
   75756             : #endif
   75757             : 
   75758           0 :     SgStatementFunctionStatement * object = (SgStatementFunctionStatement*) Pointer;
   75759           0 :     ROSE_ASSERT(object != nullptr);
   75760             : 
   75761             : #if ROSE_ALLOC_TRACE == 2
   75762             : //  printf("SgStatementFunctionStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgStatementFunctionStatement::next_node);
   75763             :     printf("SgStatementFunctionStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgStatementFunctionStatement::next_node);
   75764             : #endif
   75765             : 
   75766             : #if ROSE_PEDANTIC_ALLOC
   75767             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   75768             : #endif
   75769             : 
   75770             : #if ROSE_ALLOC_MEMSET == 1
   75771             : #elif ROSE_ALLOC_MEMSET == 2
   75772             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgStatementFunctionStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   75773             : #elif ROSE_ALLOC_MEMSET == 3
   75774             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgStatementFunctionStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   75775             : #endif
   75776             : 
   75777             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   75778             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   75779             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   75780             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   75781             : #else
   75782           0 :     object->p_freepointer = SgStatementFunctionStatement::next_node;
   75783           0 :     SgStatementFunctionStatement::next_node = object;
   75784             : #endif
   75785             : 
   75786             : #if ROSE_ALLOC_TRACE == 2
   75787             : //  printf("SgStatementFunctionStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgStatementFunctionStatement::next_node);
   75788             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   75789             :     Rose::MemPool::snapshot(oss.str());
   75790             :     alloc_trace_cnt++;
   75791             : #endif
   75792             : 
   75793             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   75794             : 
   75795           0 :     ALLOC_MUTEX(SgStatementFunctionStatement, unlock);
   75796             : }
   75797             : 
   75798             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   75799             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   75800             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   75801             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   75802             : // Also, note comment below from Robb (copied from the Common.code file).
   75803             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   75804             : //
   75805             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   75806             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   75807             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   75808             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   75809             : #if 0
   75810             : void SgStatementFunctionStatement::operator delete(void* pointer) { SgStatementFunctionStatement::operator delete (pointer, sizeof(SgStatementFunctionStatement)); };
   75811             : #endif
   75812             : /* #line 75813 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   75813             : 
   75814             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   75815             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   75816             : // obviously imply C++.
   75817             : 
   75818             : // This implements the support within ROSE for memory pools.  Memory pools
   75819             : // support the most condensed usage of memory within the construction of
   75820             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   75821             : // by a new operator written for each class.
   75822             : 
   75823             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   75824             :     // User wants multi-thread support and POSIX threads are available.
   75825             : #   include <pthread.h>
   75826             :     static pthread_mutex_t SgCtorInitializerList_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   75827             : #else
   75828             :      // Cause synchronization to be skipped.
   75829             : #    ifndef ALLOC_MUTEX
   75830             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   75831             : #    endif
   75832             : #    ifdef _REENTRANT
   75833             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   75834             : #       ifdef _MSC_VER
   75835             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   75836             : #       else
   75837             : #           warning "POSIX threads are not available; synchronization being skipped"
   75838             : #       endif
   75839             : #    endif
   75840             : #endif
   75841             : 
   75842             : #ifndef ROSE_ALLOC_TRACE
   75843             : #  define ROSE_ALLOC_TRACE 0
   75844             : #endif
   75845             : 
   75846             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   75847             : #define ROSE_ALLOC_TRACE_CNT
   75848             : #include "memory-pool-snapshot.h"
   75849             : unsigned long alloc_trace_cnt = 0;
   75850             : #endif
   75851             : 
   75852             : #if ROSE_ALLOC_TRACE
   75853             : const unsigned SgCtorInitializerList::pool_size = 5;
   75854             : #else
   75855             : const unsigned SgCtorInitializerList::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   75856             : #endif
   75857             : 
   75858             : #ifndef ROSE_ALLOC_MEMSET
   75859             : #  define ROSE_ALLOC_MEMSET 0
   75860             : #endif
   75861             : 
   75862             : #ifndef ROSE_PEDANTIC_ALLOC
   75863             : #  define ROSE_PEDANTIC_ALLOC 0
   75864             : #endif
   75865             : 
   75866             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   75867             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   75868             : #endif
   75869             : 
   75870             : #if !defined(SGNODE__ALL_POOLS)
   75871             : #define SGNODE__ALL_POOLS
   75872             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   75873             : #endif
   75874             : 
   75875             : SgCtorInitializerList* SgCtorInitializerList::next_node = nullptr;
   75876             : std::vector<unsigned char*> SgCtorInitializerList::pools;
   75877             : 
   75878             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   75879             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   75880             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   75881             : // around this macro definition rather than each use).
   75882             : #ifndef ALLOC_MUTEX
   75883             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   75884             :         do {                                                                     \
   75885             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   75886             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   75887             :                 abort();                                                         \
   75888             :             }                                                                    \
   75889             :         } while (0);
   75890             : #endif
   75891             : 
   75892             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   75893             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   75894             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   75895             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   75896             : 
   75897             : /*! \brief New operator for SgCtorInitializerList.
   75898             : 
   75899             :    This new operator implements memory pools to provide most efficent 
   75900             :    use of the heap within construction of large ASTs.
   75901             : 
   75902             : \internal The new and delete operators use the lower level C malloc/free
   75903             :    function calls for performance and to make sure that mixing of malloc/free
   75904             :    and new/delete by the used can be caught more readily.  This may change
   75905             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   75906             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   75907             :    deallocate memory allocated using ROSE_MALLOC.
   75908             : */
   75909       43702 : void *SgCtorInitializerList::operator new ( size_t Size )
   75910             : {
   75911             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   75912             :      * returning or throwing an exception. */
   75913       43702 :     ALLOC_MUTEX(SgCtorInitializerList, lock);
   75914             : 
   75915             : #if ROSE_ALLOC_TRACE == 2
   75916             : //    printf("SgCtorInitializerList::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgCtorInitializerList::next_node);
   75917             : #endif
   75918             : 
   75919             : #if USE_CPP_NEW_DELETE_OPERATORS
   75920             :     void *mem = ROSE_MALLOC(Size);
   75921             :     ALLOC_MUTEX(SgCtorInitializerList, unlock);
   75922             :     return mem;
   75923             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   75924             : #if ROSE_PEDANTIC_ALLOC
   75925             :     ROSE_ASSERT(Size == sizeof(SgCtorInitializerList));
   75926             : #else
   75927       43702 :     if (Size != sizeof(SgCtorInitializerList)) {
   75928           0 :       void * object = ROSE_MALLOC(Size);
   75929           0 :       ALLOC_MUTEX(SgCtorInitializerList, unlock);
   75930             :       return object;
   75931             :     }
   75932             : #endif
   75933             : 
   75934       43702 :     if (SgCtorInitializerList::next_node == nullptr) {
   75935          33 :         SgCtorInitializerList * alloc = (SgCtorInitializerList*) ROSE_MALLOC ( SgCtorInitializerList::pool_size * sizeof(SgCtorInitializerList) );
   75936          33 :         ROSE_ASSERT(alloc != nullptr);
   75937             : 
   75938             : #if ROSE_ALLOC_TRACE == 2
   75939             : //        printf("SgCtorInitializerList::alloc\n  block[%zi] = [ %p , %p [\n", SgCtorInitializerList::pools.size(), alloc, alloc + SgCtorInitializerList::pool_size);
   75940             : #endif
   75941             : 
   75942             : #if ROSE_ALLOC_MEMSET == 1
   75943             : #elif ROSE_ALLOC_MEMSET == 2
   75944             :         memset(alloc, 0x00, SgCtorInitializerList::pool_size * sizeof(SgCtorInitializerList));
   75945             : #elif ROSE_ALLOC_MEMSET == 3
   75946             :         memset(alloc, 0xAA, SgCtorInitializerList::pool_size * sizeof(SgCtorInitializerList));
   75947             : #endif
   75948       66000 :         for (unsigned i=0; i < SgCtorInitializerList::pool_size-1; i++) {
   75949       65967 :           alloc[i].p_freepointer = &(alloc[i+1]);
   75950             :         }
   75951          33 :         alloc[SgCtorInitializerList::pool_size-1].p_freepointer = nullptr;
   75952             : 
   75953          33 :         SgCtorInitializerList::pools.push_back ( (unsigned char *) alloc );
   75954          33 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgCtorInitializerList::pool_size * sizeof(SgCtorInitializerList), V_SgCtorInitializerList ) );
   75955          33 :         SgCtorInitializerList::next_node = alloc;
   75956             :     }
   75957       43702 :     ROSE_ASSERT(SgCtorInitializerList::next_node != nullptr);
   75958             : 
   75959       43702 :     SgCtorInitializerList * object = SgCtorInitializerList::next_node;
   75960       43702 :     SgCtorInitializerList::next_node = (SgCtorInitializerList*)(object->p_freepointer);
   75961             : 
   75962             : #if ROSE_ALLOC_TRACE == 2
   75963             :     printf("SgCtorInitializerList::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgCtorInitializerList::next_node);
   75964             : #endif
   75965             : 
   75966       43702 :     SgNode * fp = object->p_freepointer;
   75967             : #if ROSE_ALLOC_MEMSET == 1
   75968             : #elif ROSE_ALLOC_MEMSET == 2
   75969             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgCtorInitializerList) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   75970             : #elif ROSE_ALLOC_MEMSET == 3
   75971             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgCtorInitializerList) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   75972             : #endif
   75973       43702 :     object->p_freepointer = fp;
   75974             : 
   75975             : #if ROSE_ALLOC_TRACE == 2
   75976             : //    printf("SgCtorInitializerList::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgCtorInitializerList::next_node);
   75977             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   75978             :     Rose::MemPool::snapshot(oss.str());
   75979             :     alloc_trace_cnt++;
   75980             : #endif
   75981             : 
   75982       43702 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   75983             : 
   75984       43702 :     ALLOC_MUTEX(SgCtorInitializerList, unlock);
   75985             : 
   75986             :     return object;
   75987             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   75988             : }
   75989             : 
   75990             : 
   75991             : 
   75992             : /*! \brief Delete operator for SgCtorInitializerList.
   75993             : 
   75994             :    This delete operator implements deallocation using memory pools to 
   75995             :    provide most efficent use of the heap within construction of large ASTs.
   75996             : 
   75997             : \internal The new and delete operators use the lower level C malloc/free
   75998             :    function calls for performance and to make sure that mixing of malloc/free
   75999             :    and new/delete by the used can be caught more readily.  This may change
   76000             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   76001             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   76002             :    deallocate memory allocated using ROSE_MALLOC.
   76003             : */
   76004        8856 : void SgCtorInitializerList::operator delete(void *Pointer, size_t Size)
   76005             : {
   76006             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   76007             :      * or throwing an exception. */
   76008        8856 :     ALLOC_MUTEX(SgCtorInitializerList, lock);
   76009             : 
   76010             : #if USE_CPP_NEW_DELETE_OPERATORS
   76011             :     ROSE_FREE(Pointer);
   76012             : #else
   76013             : #if ROSE_PEDANTIC_ALLOC
   76014             :     ROSE_ASSERT(Size == sizeof(SgCtorInitializerList));
   76015             : #else
   76016        8856 :     if (Size != sizeof(SgCtorInitializerList)) {
   76017           0 :       ROSE_FREE(Pointer);
   76018           0 :       ALLOC_MUTEX(SgCtorInitializerList, unlock);
   76019             :       return;
   76020             :     }
   76021             : #endif
   76022             : 
   76023        8856 :     SgCtorInitializerList * object = (SgCtorInitializerList*) Pointer;
   76024        8856 :     ROSE_ASSERT(object != nullptr);
   76025             : 
   76026             : #if ROSE_ALLOC_TRACE == 2
   76027             : //  printf("SgCtorInitializerList::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgCtorInitializerList::next_node);
   76028             :     printf("SgCtorInitializerList::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgCtorInitializerList::next_node);
   76029             : #endif
   76030             : 
   76031             : #if ROSE_PEDANTIC_ALLOC
   76032             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   76033             : #endif
   76034             : 
   76035             : #if ROSE_ALLOC_MEMSET == 1
   76036             : #elif ROSE_ALLOC_MEMSET == 2
   76037             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgCtorInitializerList) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   76038             : #elif ROSE_ALLOC_MEMSET == 3
   76039             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgCtorInitializerList) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   76040             : #endif
   76041             : 
   76042             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   76043             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   76044             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   76045             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   76046             : #else
   76047        8856 :     object->p_freepointer = SgCtorInitializerList::next_node;
   76048        8856 :     SgCtorInitializerList::next_node = object;
   76049             : #endif
   76050             : 
   76051             : #if ROSE_ALLOC_TRACE == 2
   76052             : //  printf("SgCtorInitializerList::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgCtorInitializerList::next_node);
   76053             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   76054             :     Rose::MemPool::snapshot(oss.str());
   76055             :     alloc_trace_cnt++;
   76056             : #endif
   76057             : 
   76058             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   76059             : 
   76060        8856 :     ALLOC_MUTEX(SgCtorInitializerList, unlock);
   76061             : }
   76062             : 
   76063             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   76064             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   76065             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   76066             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   76067             : // Also, note comment below from Robb (copied from the Common.code file).
   76068             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   76069             : //
   76070             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   76071             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   76072             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   76073             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   76074             : #if 0
   76075             : void SgCtorInitializerList::operator delete(void* pointer) { SgCtorInitializerList::operator delete (pointer, sizeof(SgCtorInitializerList)); };
   76076             : #endif
   76077             : /* #line 76078 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   76078             : 
   76079             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   76080             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   76081             : // obviously imply C++.
   76082             : 
   76083             : // This implements the support within ROSE for memory pools.  Memory pools
   76084             : // support the most condensed usage of memory within the construction of
   76085             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   76086             : // by a new operator written for each class.
   76087             : 
   76088             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   76089             :     // User wants multi-thread support and POSIX threads are available.
   76090             : #   include <pthread.h>
   76091             :     static pthread_mutex_t SgPragmaDeclaration_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   76092             : #else
   76093             :      // Cause synchronization to be skipped.
   76094             : #    ifndef ALLOC_MUTEX
   76095             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   76096             : #    endif
   76097             : #    ifdef _REENTRANT
   76098             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   76099             : #       ifdef _MSC_VER
   76100             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   76101             : #       else
   76102             : #           warning "POSIX threads are not available; synchronization being skipped"
   76103             : #       endif
   76104             : #    endif
   76105             : #endif
   76106             : 
   76107             : #ifndef ROSE_ALLOC_TRACE
   76108             : #  define ROSE_ALLOC_TRACE 0
   76109             : #endif
   76110             : 
   76111             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   76112             : #define ROSE_ALLOC_TRACE_CNT
   76113             : #include "memory-pool-snapshot.h"
   76114             : unsigned long alloc_trace_cnt = 0;
   76115             : #endif
   76116             : 
   76117             : #if ROSE_ALLOC_TRACE
   76118             : const unsigned SgPragmaDeclaration::pool_size = 5;
   76119             : #else
   76120             : const unsigned SgPragmaDeclaration::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   76121             : #endif
   76122             : 
   76123             : #ifndef ROSE_ALLOC_MEMSET
   76124             : #  define ROSE_ALLOC_MEMSET 0
   76125             : #endif
   76126             : 
   76127             : #ifndef ROSE_PEDANTIC_ALLOC
   76128             : #  define ROSE_PEDANTIC_ALLOC 0
   76129             : #endif
   76130             : 
   76131             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   76132             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   76133             : #endif
   76134             : 
   76135             : #if !defined(SGNODE__ALL_POOLS)
   76136             : #define SGNODE__ALL_POOLS
   76137             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   76138             : #endif
   76139             : 
   76140             : SgPragmaDeclaration* SgPragmaDeclaration::next_node = nullptr;
   76141             : std::vector<unsigned char*> SgPragmaDeclaration::pools;
   76142             : 
   76143             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   76144             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   76145             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   76146             : // around this macro definition rather than each use).
   76147             : #ifndef ALLOC_MUTEX
   76148             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   76149             :         do {                                                                     \
   76150             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   76151             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   76152             :                 abort();                                                         \
   76153             :             }                                                                    \
   76154             :         } while (0);
   76155             : #endif
   76156             : 
   76157             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   76158             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   76159             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   76160             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   76161             : 
   76162             : /*! \brief New operator for SgPragmaDeclaration.
   76163             : 
   76164             :    This new operator implements memory pools to provide most efficent 
   76165             :    use of the heap within construction of large ASTs.
   76166             : 
   76167             : \internal The new and delete operators use the lower level C malloc/free
   76168             :    function calls for performance and to make sure that mixing of malloc/free
   76169             :    and new/delete by the used can be caught more readily.  This may change
   76170             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   76171             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   76172             :    deallocate memory allocated using ROSE_MALLOC.
   76173             : */
   76174        1926 : void *SgPragmaDeclaration::operator new ( size_t Size )
   76175             : {
   76176             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   76177             :      * returning or throwing an exception. */
   76178        1926 :     ALLOC_MUTEX(SgPragmaDeclaration, lock);
   76179             : 
   76180             : #if ROSE_ALLOC_TRACE == 2
   76181             : //    printf("SgPragmaDeclaration::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgPragmaDeclaration::next_node);
   76182             : #endif
   76183             : 
   76184             : #if USE_CPP_NEW_DELETE_OPERATORS
   76185             :     void *mem = ROSE_MALLOC(Size);
   76186             :     ALLOC_MUTEX(SgPragmaDeclaration, unlock);
   76187             :     return mem;
   76188             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   76189             : #if ROSE_PEDANTIC_ALLOC
   76190             :     ROSE_ASSERT(Size == sizeof(SgPragmaDeclaration));
   76191             : #else
   76192        1926 :     if (Size != sizeof(SgPragmaDeclaration)) {
   76193           0 :       void * object = ROSE_MALLOC(Size);
   76194           0 :       ALLOC_MUTEX(SgPragmaDeclaration, unlock);
   76195             :       return object;
   76196             :     }
   76197             : #endif
   76198             : 
   76199        1926 :     if (SgPragmaDeclaration::next_node == nullptr) {
   76200         276 :         SgPragmaDeclaration * alloc = (SgPragmaDeclaration*) ROSE_MALLOC ( SgPragmaDeclaration::pool_size * sizeof(SgPragmaDeclaration) );
   76201         276 :         ROSE_ASSERT(alloc != nullptr);
   76202             : 
   76203             : #if ROSE_ALLOC_TRACE == 2
   76204             : //        printf("SgPragmaDeclaration::alloc\n  block[%zi] = [ %p , %p [\n", SgPragmaDeclaration::pools.size(), alloc, alloc + SgPragmaDeclaration::pool_size);
   76205             : #endif
   76206             : 
   76207             : #if ROSE_ALLOC_MEMSET == 1
   76208             : #elif ROSE_ALLOC_MEMSET == 2
   76209             :         memset(alloc, 0x00, SgPragmaDeclaration::pool_size * sizeof(SgPragmaDeclaration));
   76210             : #elif ROSE_ALLOC_MEMSET == 3
   76211             :         memset(alloc, 0xAA, SgPragmaDeclaration::pool_size * sizeof(SgPragmaDeclaration));
   76212             : #endif
   76213      552000 :         for (unsigned i=0; i < SgPragmaDeclaration::pool_size-1; i++) {
   76214      551724 :           alloc[i].p_freepointer = &(alloc[i+1]);
   76215             :         }
   76216         276 :         alloc[SgPragmaDeclaration::pool_size-1].p_freepointer = nullptr;
   76217             : 
   76218         276 :         SgPragmaDeclaration::pools.push_back ( (unsigned char *) alloc );
   76219         276 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgPragmaDeclaration::pool_size * sizeof(SgPragmaDeclaration), V_SgPragmaDeclaration ) );
   76220         276 :         SgPragmaDeclaration::next_node = alloc;
   76221             :     }
   76222        1926 :     ROSE_ASSERT(SgPragmaDeclaration::next_node != nullptr);
   76223             : 
   76224        1926 :     SgPragmaDeclaration * object = SgPragmaDeclaration::next_node;
   76225        1926 :     SgPragmaDeclaration::next_node = (SgPragmaDeclaration*)(object->p_freepointer);
   76226             : 
   76227             : #if ROSE_ALLOC_TRACE == 2
   76228             :     printf("SgPragmaDeclaration::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgPragmaDeclaration::next_node);
   76229             : #endif
   76230             : 
   76231        1926 :     SgNode * fp = object->p_freepointer;
   76232             : #if ROSE_ALLOC_MEMSET == 1
   76233             : #elif ROSE_ALLOC_MEMSET == 2
   76234             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgPragmaDeclaration) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   76235             : #elif ROSE_ALLOC_MEMSET == 3
   76236             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgPragmaDeclaration) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   76237             : #endif
   76238        1926 :     object->p_freepointer = fp;
   76239             : 
   76240             : #if ROSE_ALLOC_TRACE == 2
   76241             : //    printf("SgPragmaDeclaration::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgPragmaDeclaration::next_node);
   76242             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   76243             :     Rose::MemPool::snapshot(oss.str());
   76244             :     alloc_trace_cnt++;
   76245             : #endif
   76246             : 
   76247        1926 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   76248             : 
   76249        1926 :     ALLOC_MUTEX(SgPragmaDeclaration, unlock);
   76250             : 
   76251             :     return object;
   76252             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   76253             : }
   76254             : 
   76255             : 
   76256             : 
   76257             : /*! \brief Delete operator for SgPragmaDeclaration.
   76258             : 
   76259             :    This delete operator implements deallocation using memory pools to 
   76260             :    provide most efficent use of the heap within construction of large ASTs.
   76261             : 
   76262             : \internal The new and delete operators use the lower level C malloc/free
   76263             :    function calls for performance and to make sure that mixing of malloc/free
   76264             :    and new/delete by the used can be caught more readily.  This may change
   76265             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   76266             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   76267             :    deallocate memory allocated using ROSE_MALLOC.
   76268             : */
   76269         194 : void SgPragmaDeclaration::operator delete(void *Pointer, size_t Size)
   76270             : {
   76271             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   76272             :      * or throwing an exception. */
   76273         194 :     ALLOC_MUTEX(SgPragmaDeclaration, lock);
   76274             : 
   76275             : #if USE_CPP_NEW_DELETE_OPERATORS
   76276             :     ROSE_FREE(Pointer);
   76277             : #else
   76278             : #if ROSE_PEDANTIC_ALLOC
   76279             :     ROSE_ASSERT(Size == sizeof(SgPragmaDeclaration));
   76280             : #else
   76281         194 :     if (Size != sizeof(SgPragmaDeclaration)) {
   76282           0 :       ROSE_FREE(Pointer);
   76283           0 :       ALLOC_MUTEX(SgPragmaDeclaration, unlock);
   76284             :       return;
   76285             :     }
   76286             : #endif
   76287             : 
   76288         194 :     SgPragmaDeclaration * object = (SgPragmaDeclaration*) Pointer;
   76289         194 :     ROSE_ASSERT(object != nullptr);
   76290             : 
   76291             : #if ROSE_ALLOC_TRACE == 2
   76292             : //  printf("SgPragmaDeclaration::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgPragmaDeclaration::next_node);
   76293             :     printf("SgPragmaDeclaration::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgPragmaDeclaration::next_node);
   76294             : #endif
   76295             : 
   76296             : #if ROSE_PEDANTIC_ALLOC
   76297             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   76298             : #endif
   76299             : 
   76300             : #if ROSE_ALLOC_MEMSET == 1
   76301             : #elif ROSE_ALLOC_MEMSET == 2
   76302             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgPragmaDeclaration) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   76303             : #elif ROSE_ALLOC_MEMSET == 3
   76304             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgPragmaDeclaration) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   76305             : #endif
   76306             : 
   76307             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   76308             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   76309             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   76310             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   76311             : #else
   76312         194 :     object->p_freepointer = SgPragmaDeclaration::next_node;
   76313         194 :     SgPragmaDeclaration::next_node = object;
   76314             : #endif
   76315             : 
   76316             : #if ROSE_ALLOC_TRACE == 2
   76317             : //  printf("SgPragmaDeclaration::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgPragmaDeclaration::next_node);
   76318             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   76319             :     Rose::MemPool::snapshot(oss.str());
   76320             :     alloc_trace_cnt++;
   76321             : #endif
   76322             : 
   76323             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   76324             : 
   76325         194 :     ALLOC_MUTEX(SgPragmaDeclaration, unlock);
   76326             : }
   76327             : 
   76328             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   76329             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   76330             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   76331             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   76332             : // Also, note comment below from Robb (copied from the Common.code file).
   76333             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   76334             : //
   76335             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   76336             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   76337             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   76338             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   76339             : #if 0
   76340             : void SgPragmaDeclaration::operator delete(void* pointer) { SgPragmaDeclaration::operator delete (pointer, sizeof(SgPragmaDeclaration)); };
   76341             : #endif
   76342             : /* #line 76343 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   76343             : 
   76344             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   76345             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   76346             : // obviously imply C++.
   76347             : 
   76348             : // This implements the support within ROSE for memory pools.  Memory pools
   76349             : // support the most condensed usage of memory within the construction of
   76350             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   76351             : // by a new operator written for each class.
   76352             : 
   76353             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   76354             :     // User wants multi-thread support and POSIX threads are available.
   76355             : #   include <pthread.h>
   76356             :     static pthread_mutex_t SgUsingDirectiveStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   76357             : #else
   76358             :      // Cause synchronization to be skipped.
   76359             : #    ifndef ALLOC_MUTEX
   76360             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   76361             : #    endif
   76362             : #    ifdef _REENTRANT
   76363             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   76364             : #       ifdef _MSC_VER
   76365             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   76366             : #       else
   76367             : #           warning "POSIX threads are not available; synchronization being skipped"
   76368             : #       endif
   76369             : #    endif
   76370             : #endif
   76371             : 
   76372             : #ifndef ROSE_ALLOC_TRACE
   76373             : #  define ROSE_ALLOC_TRACE 0
   76374             : #endif
   76375             : 
   76376             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   76377             : #define ROSE_ALLOC_TRACE_CNT
   76378             : #include "memory-pool-snapshot.h"
   76379             : unsigned long alloc_trace_cnt = 0;
   76380             : #endif
   76381             : 
   76382             : #if ROSE_ALLOC_TRACE
   76383             : const unsigned SgUsingDirectiveStatement::pool_size = 5;
   76384             : #else
   76385             : const unsigned SgUsingDirectiveStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   76386             : #endif
   76387             : 
   76388             : #ifndef ROSE_ALLOC_MEMSET
   76389             : #  define ROSE_ALLOC_MEMSET 0
   76390             : #endif
   76391             : 
   76392             : #ifndef ROSE_PEDANTIC_ALLOC
   76393             : #  define ROSE_PEDANTIC_ALLOC 0
   76394             : #endif
   76395             : 
   76396             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   76397             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   76398             : #endif
   76399             : 
   76400             : #if !defined(SGNODE__ALL_POOLS)
   76401             : #define SGNODE__ALL_POOLS
   76402             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   76403             : #endif
   76404             : 
   76405             : SgUsingDirectiveStatement* SgUsingDirectiveStatement::next_node = nullptr;
   76406             : std::vector<unsigned char*> SgUsingDirectiveStatement::pools;
   76407             : 
   76408             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   76409             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   76410             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   76411             : // around this macro definition rather than each use).
   76412             : #ifndef ALLOC_MUTEX
   76413             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   76414             :         do {                                                                     \
   76415             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   76416             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   76417             :                 abort();                                                         \
   76418             :             }                                                                    \
   76419             :         } while (0);
   76420             : #endif
   76421             : 
   76422             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   76423             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   76424             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   76425             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   76426             : 
   76427             : /*! \brief New operator for SgUsingDirectiveStatement.
   76428             : 
   76429             :    This new operator implements memory pools to provide most efficent 
   76430             :    use of the heap within construction of large ASTs.
   76431             : 
   76432             : \internal The new and delete operators use the lower level C malloc/free
   76433             :    function calls for performance and to make sure that mixing of malloc/free
   76434             :    and new/delete by the used can be caught more readily.  This may change
   76435             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   76436             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   76437             :    deallocate memory allocated using ROSE_MALLOC.
   76438             : */
   76439          17 : void *SgUsingDirectiveStatement::operator new ( size_t Size )
   76440             : {
   76441             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   76442             :      * returning or throwing an exception. */
   76443          17 :     ALLOC_MUTEX(SgUsingDirectiveStatement, lock);
   76444             : 
   76445             : #if ROSE_ALLOC_TRACE == 2
   76446             : //    printf("SgUsingDirectiveStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgUsingDirectiveStatement::next_node);
   76447             : #endif
   76448             : 
   76449             : #if USE_CPP_NEW_DELETE_OPERATORS
   76450             :     void *mem = ROSE_MALLOC(Size);
   76451             :     ALLOC_MUTEX(SgUsingDirectiveStatement, unlock);
   76452             :     return mem;
   76453             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   76454             : #if ROSE_PEDANTIC_ALLOC
   76455             :     ROSE_ASSERT(Size == sizeof(SgUsingDirectiveStatement));
   76456             : #else
   76457          17 :     if (Size != sizeof(SgUsingDirectiveStatement)) {
   76458           0 :       void * object = ROSE_MALLOC(Size);
   76459           0 :       ALLOC_MUTEX(SgUsingDirectiveStatement, unlock);
   76460             :       return object;
   76461             :     }
   76462             : #endif
   76463             : 
   76464          17 :     if (SgUsingDirectiveStatement::next_node == nullptr) {
   76465          10 :         SgUsingDirectiveStatement * alloc = (SgUsingDirectiveStatement*) ROSE_MALLOC ( SgUsingDirectiveStatement::pool_size * sizeof(SgUsingDirectiveStatement) );
   76466          10 :         ROSE_ASSERT(alloc != nullptr);
   76467             : 
   76468             : #if ROSE_ALLOC_TRACE == 2
   76469             : //        printf("SgUsingDirectiveStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgUsingDirectiveStatement::pools.size(), alloc, alloc + SgUsingDirectiveStatement::pool_size);
   76470             : #endif
   76471             : 
   76472             : #if ROSE_ALLOC_MEMSET == 1
   76473             : #elif ROSE_ALLOC_MEMSET == 2
   76474             :         memset(alloc, 0x00, SgUsingDirectiveStatement::pool_size * sizeof(SgUsingDirectiveStatement));
   76475             : #elif ROSE_ALLOC_MEMSET == 3
   76476             :         memset(alloc, 0xAA, SgUsingDirectiveStatement::pool_size * sizeof(SgUsingDirectiveStatement));
   76477             : #endif
   76478       20000 :         for (unsigned i=0; i < SgUsingDirectiveStatement::pool_size-1; i++) {
   76479       19990 :           alloc[i].p_freepointer = &(alloc[i+1]);
   76480             :         }
   76481          10 :         alloc[SgUsingDirectiveStatement::pool_size-1].p_freepointer = nullptr;
   76482             : 
   76483          10 :         SgUsingDirectiveStatement::pools.push_back ( (unsigned char *) alloc );
   76484          10 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgUsingDirectiveStatement::pool_size * sizeof(SgUsingDirectiveStatement), V_SgUsingDirectiveStatement ) );
   76485          10 :         SgUsingDirectiveStatement::next_node = alloc;
   76486             :     }
   76487          17 :     ROSE_ASSERT(SgUsingDirectiveStatement::next_node != nullptr);
   76488             : 
   76489          17 :     SgUsingDirectiveStatement * object = SgUsingDirectiveStatement::next_node;
   76490          17 :     SgUsingDirectiveStatement::next_node = (SgUsingDirectiveStatement*)(object->p_freepointer);
   76491             : 
   76492             : #if ROSE_ALLOC_TRACE == 2
   76493             :     printf("SgUsingDirectiveStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUsingDirectiveStatement::next_node);
   76494             : #endif
   76495             : 
   76496          17 :     SgNode * fp = object->p_freepointer;
   76497             : #if ROSE_ALLOC_MEMSET == 1
   76498             : #elif ROSE_ALLOC_MEMSET == 2
   76499             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgUsingDirectiveStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   76500             : #elif ROSE_ALLOC_MEMSET == 3
   76501             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgUsingDirectiveStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   76502             : #endif
   76503          17 :     object->p_freepointer = fp;
   76504             : 
   76505             : #if ROSE_ALLOC_TRACE == 2
   76506             : //    printf("SgUsingDirectiveStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUsingDirectiveStatement::next_node);
   76507             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   76508             :     Rose::MemPool::snapshot(oss.str());
   76509             :     alloc_trace_cnt++;
   76510             : #endif
   76511             : 
   76512          17 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   76513             : 
   76514          17 :     ALLOC_MUTEX(SgUsingDirectiveStatement, unlock);
   76515             : 
   76516             :     return object;
   76517             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   76518             : }
   76519             : 
   76520             : 
   76521             : 
   76522             : /*! \brief Delete operator for SgUsingDirectiveStatement.
   76523             : 
   76524             :    This delete operator implements deallocation using memory pools to 
   76525             :    provide most efficent use of the heap within construction of large ASTs.
   76526             : 
   76527             : \internal The new and delete operators use the lower level C malloc/free
   76528             :    function calls for performance and to make sure that mixing of malloc/free
   76529             :    and new/delete by the used can be caught more readily.  This may change
   76530             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   76531             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   76532             :    deallocate memory allocated using ROSE_MALLOC.
   76533             : */
   76534           2 : void SgUsingDirectiveStatement::operator delete(void *Pointer, size_t Size)
   76535             : {
   76536             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   76537             :      * or throwing an exception. */
   76538           2 :     ALLOC_MUTEX(SgUsingDirectiveStatement, lock);
   76539             : 
   76540             : #if USE_CPP_NEW_DELETE_OPERATORS
   76541             :     ROSE_FREE(Pointer);
   76542             : #else
   76543             : #if ROSE_PEDANTIC_ALLOC
   76544             :     ROSE_ASSERT(Size == sizeof(SgUsingDirectiveStatement));
   76545             : #else
   76546           2 :     if (Size != sizeof(SgUsingDirectiveStatement)) {
   76547           0 :       ROSE_FREE(Pointer);
   76548           0 :       ALLOC_MUTEX(SgUsingDirectiveStatement, unlock);
   76549             :       return;
   76550             :     }
   76551             : #endif
   76552             : 
   76553           2 :     SgUsingDirectiveStatement * object = (SgUsingDirectiveStatement*) Pointer;
   76554           2 :     ROSE_ASSERT(object != nullptr);
   76555             : 
   76556             : #if ROSE_ALLOC_TRACE == 2
   76557             : //  printf("SgUsingDirectiveStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUsingDirectiveStatement::next_node);
   76558             :     printf("SgUsingDirectiveStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUsingDirectiveStatement::next_node);
   76559             : #endif
   76560             : 
   76561             : #if ROSE_PEDANTIC_ALLOC
   76562             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   76563             : #endif
   76564             : 
   76565             : #if ROSE_ALLOC_MEMSET == 1
   76566             : #elif ROSE_ALLOC_MEMSET == 2
   76567             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgUsingDirectiveStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   76568             : #elif ROSE_ALLOC_MEMSET == 3
   76569             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgUsingDirectiveStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   76570             : #endif
   76571             : 
   76572             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   76573             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   76574             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   76575             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   76576             : #else
   76577           2 :     object->p_freepointer = SgUsingDirectiveStatement::next_node;
   76578           2 :     SgUsingDirectiveStatement::next_node = object;
   76579             : #endif
   76580             : 
   76581             : #if ROSE_ALLOC_TRACE == 2
   76582             : //  printf("SgUsingDirectiveStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUsingDirectiveStatement::next_node);
   76583             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   76584             :     Rose::MemPool::snapshot(oss.str());
   76585             :     alloc_trace_cnt++;
   76586             : #endif
   76587             : 
   76588             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   76589             : 
   76590           2 :     ALLOC_MUTEX(SgUsingDirectiveStatement, unlock);
   76591             : }
   76592             : 
   76593             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   76594             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   76595             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   76596             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   76597             : // Also, note comment below from Robb (copied from the Common.code file).
   76598             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   76599             : //
   76600             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   76601             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   76602             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   76603             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   76604             : #if 0
   76605             : void SgUsingDirectiveStatement::operator delete(void* pointer) { SgUsingDirectiveStatement::operator delete (pointer, sizeof(SgUsingDirectiveStatement)); };
   76606             : #endif
   76607             : /* #line 76608 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   76608             : 
   76609             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   76610             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   76611             : // obviously imply C++.
   76612             : 
   76613             : // This implements the support within ROSE for memory pools.  Memory pools
   76614             : // support the most condensed usage of memory within the construction of
   76615             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   76616             : // by a new operator written for each class.
   76617             : 
   76618             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   76619             :     // User wants multi-thread support and POSIX threads are available.
   76620             : #   include <pthread.h>
   76621             :     static pthread_mutex_t SgClassDeclaration_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   76622             : #else
   76623             :      // Cause synchronization to be skipped.
   76624             : #    ifndef ALLOC_MUTEX
   76625             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   76626             : #    endif
   76627             : #    ifdef _REENTRANT
   76628             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   76629             : #       ifdef _MSC_VER
   76630             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   76631             : #       else
   76632             : #           warning "POSIX threads are not available; synchronization being skipped"
   76633             : #       endif
   76634             : #    endif
   76635             : #endif
   76636             : 
   76637             : #ifndef ROSE_ALLOC_TRACE
   76638             : #  define ROSE_ALLOC_TRACE 0
   76639             : #endif
   76640             : 
   76641             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   76642             : #define ROSE_ALLOC_TRACE_CNT
   76643             : #include "memory-pool-snapshot.h"
   76644             : unsigned long alloc_trace_cnt = 0;
   76645             : #endif
   76646             : 
   76647             : #if ROSE_ALLOC_TRACE
   76648             : const unsigned SgClassDeclaration::pool_size = 5;
   76649             : #else
   76650             : const unsigned SgClassDeclaration::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   76651             : #endif
   76652             : 
   76653             : #ifndef ROSE_ALLOC_MEMSET
   76654             : #  define ROSE_ALLOC_MEMSET 0
   76655             : #endif
   76656             : 
   76657             : #ifndef ROSE_PEDANTIC_ALLOC
   76658             : #  define ROSE_PEDANTIC_ALLOC 0
   76659             : #endif
   76660             : 
   76661             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   76662             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   76663             : #endif
   76664             : 
   76665             : #if !defined(SGNODE__ALL_POOLS)
   76666             : #define SGNODE__ALL_POOLS
   76667             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   76668             : #endif
   76669             : 
   76670             : SgClassDeclaration* SgClassDeclaration::next_node = nullptr;
   76671             : std::vector<unsigned char*> SgClassDeclaration::pools;
   76672             : 
   76673             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   76674             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   76675             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   76676             : // around this macro definition rather than each use).
   76677             : #ifndef ALLOC_MUTEX
   76678             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   76679             :         do {                                                                     \
   76680             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   76681             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   76682             :                 abort();                                                         \
   76683             :             }                                                                    \
   76684             :         } while (0);
   76685             : #endif
   76686             : 
   76687             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   76688             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   76689             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   76690             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   76691             : 
   76692             : /*! \brief New operator for SgClassDeclaration.
   76693             : 
   76694             :    This new operator implements memory pools to provide most efficent 
   76695             :    use of the heap within construction of large ASTs.
   76696             : 
   76697             : \internal The new and delete operators use the lower level C malloc/free
   76698             :    function calls for performance and to make sure that mixing of malloc/free
   76699             :    and new/delete by the used can be caught more readily.  This may change
   76700             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   76701             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   76702             :    deallocate memory allocated using ROSE_MALLOC.
   76703             : */
   76704       15129 : void *SgClassDeclaration::operator new ( size_t Size )
   76705             : {
   76706             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   76707             :      * returning or throwing an exception. */
   76708       15129 :     ALLOC_MUTEX(SgClassDeclaration, lock);
   76709             : 
   76710             : #if ROSE_ALLOC_TRACE == 2
   76711             : //    printf("SgClassDeclaration::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgClassDeclaration::next_node);
   76712             : #endif
   76713             : 
   76714             : #if USE_CPP_NEW_DELETE_OPERATORS
   76715             :     void *mem = ROSE_MALLOC(Size);
   76716             :     ALLOC_MUTEX(SgClassDeclaration, unlock);
   76717             :     return mem;
   76718             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   76719             : #if ROSE_PEDANTIC_ALLOC
   76720             :     ROSE_ASSERT(Size == sizeof(SgClassDeclaration));
   76721             : #else
   76722       15129 :     if (Size != sizeof(SgClassDeclaration)) {
   76723           0 :       void * object = ROSE_MALLOC(Size);
   76724           0 :       ALLOC_MUTEX(SgClassDeclaration, unlock);
   76725             :       return object;
   76726             :     }
   76727             : #endif
   76728             : 
   76729       15129 :     if (SgClassDeclaration::next_node == nullptr) {
   76730         212 :         SgClassDeclaration * alloc = (SgClassDeclaration*) ROSE_MALLOC ( SgClassDeclaration::pool_size * sizeof(SgClassDeclaration) );
   76731         212 :         ROSE_ASSERT(alloc != nullptr);
   76732             : 
   76733             : #if ROSE_ALLOC_TRACE == 2
   76734             : //        printf("SgClassDeclaration::alloc\n  block[%zi] = [ %p , %p [\n", SgClassDeclaration::pools.size(), alloc, alloc + SgClassDeclaration::pool_size);
   76735             : #endif
   76736             : 
   76737             : #if ROSE_ALLOC_MEMSET == 1
   76738             : #elif ROSE_ALLOC_MEMSET == 2
   76739             :         memset(alloc, 0x00, SgClassDeclaration::pool_size * sizeof(SgClassDeclaration));
   76740             : #elif ROSE_ALLOC_MEMSET == 3
   76741             :         memset(alloc, 0xAA, SgClassDeclaration::pool_size * sizeof(SgClassDeclaration));
   76742             : #endif
   76743      424000 :         for (unsigned i=0; i < SgClassDeclaration::pool_size-1; i++) {
   76744      423788 :           alloc[i].p_freepointer = &(alloc[i+1]);
   76745             :         }
   76746         212 :         alloc[SgClassDeclaration::pool_size-1].p_freepointer = nullptr;
   76747             : 
   76748         212 :         SgClassDeclaration::pools.push_back ( (unsigned char *) alloc );
   76749         212 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgClassDeclaration::pool_size * sizeof(SgClassDeclaration), V_SgClassDeclaration ) );
   76750         212 :         SgClassDeclaration::next_node = alloc;
   76751             :     }
   76752       15129 :     ROSE_ASSERT(SgClassDeclaration::next_node != nullptr);
   76753             : 
   76754       15129 :     SgClassDeclaration * object = SgClassDeclaration::next_node;
   76755       15129 :     SgClassDeclaration::next_node = (SgClassDeclaration*)(object->p_freepointer);
   76756             : 
   76757             : #if ROSE_ALLOC_TRACE == 2
   76758             :     printf("SgClassDeclaration::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgClassDeclaration::next_node);
   76759             : #endif
   76760             : 
   76761       15129 :     SgNode * fp = object->p_freepointer;
   76762             : #if ROSE_ALLOC_MEMSET == 1
   76763             : #elif ROSE_ALLOC_MEMSET == 2
   76764             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgClassDeclaration) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   76765             : #elif ROSE_ALLOC_MEMSET == 3
   76766             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgClassDeclaration) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   76767             : #endif
   76768       15129 :     object->p_freepointer = fp;
   76769             : 
   76770             : #if ROSE_ALLOC_TRACE == 2
   76771             : //    printf("SgClassDeclaration::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgClassDeclaration::next_node);
   76772             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   76773             :     Rose::MemPool::snapshot(oss.str());
   76774             :     alloc_trace_cnt++;
   76775             : #endif
   76776             : 
   76777       15129 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   76778             : 
   76779       15129 :     ALLOC_MUTEX(SgClassDeclaration, unlock);
   76780             : 
   76781             :     return object;
   76782             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   76783             : }
   76784             : 
   76785             : 
   76786             : 
   76787             : /*! \brief Delete operator for SgClassDeclaration.
   76788             : 
   76789             :    This delete operator implements deallocation using memory pools to 
   76790             :    provide most efficent use of the heap within construction of large ASTs.
   76791             : 
   76792             : \internal The new and delete operators use the lower level C malloc/free
   76793             :    function calls for performance and to make sure that mixing of malloc/free
   76794             :    and new/delete by the used can be caught more readily.  This may change
   76795             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   76796             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   76797             :    deallocate memory allocated using ROSE_MALLOC.
   76798             : */
   76799         742 : void SgClassDeclaration::operator delete(void *Pointer, size_t Size)
   76800             : {
   76801             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   76802             :      * or throwing an exception. */
   76803         742 :     ALLOC_MUTEX(SgClassDeclaration, lock);
   76804             : 
   76805             : #if USE_CPP_NEW_DELETE_OPERATORS
   76806             :     ROSE_FREE(Pointer);
   76807             : #else
   76808             : #if ROSE_PEDANTIC_ALLOC
   76809             :     ROSE_ASSERT(Size == sizeof(SgClassDeclaration));
   76810             : #else
   76811         742 :     if (Size != sizeof(SgClassDeclaration)) {
   76812           0 :       ROSE_FREE(Pointer);
   76813           0 :       ALLOC_MUTEX(SgClassDeclaration, unlock);
   76814             :       return;
   76815             :     }
   76816             : #endif
   76817             : 
   76818         742 :     SgClassDeclaration * object = (SgClassDeclaration*) Pointer;
   76819         742 :     ROSE_ASSERT(object != nullptr);
   76820             : 
   76821             : #if ROSE_ALLOC_TRACE == 2
   76822             : //  printf("SgClassDeclaration::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgClassDeclaration::next_node);
   76823             :     printf("SgClassDeclaration::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgClassDeclaration::next_node);
   76824             : #endif
   76825             : 
   76826             : #if ROSE_PEDANTIC_ALLOC
   76827             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   76828             : #endif
   76829             : 
   76830             : #if ROSE_ALLOC_MEMSET == 1
   76831             : #elif ROSE_ALLOC_MEMSET == 2
   76832             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgClassDeclaration) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   76833             : #elif ROSE_ALLOC_MEMSET == 3
   76834             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgClassDeclaration) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   76835             : #endif
   76836             : 
   76837             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   76838             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   76839             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   76840             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   76841             : #else
   76842         742 :     object->p_freepointer = SgClassDeclaration::next_node;
   76843         742 :     SgClassDeclaration::next_node = object;
   76844             : #endif
   76845             : 
   76846             : #if ROSE_ALLOC_TRACE == 2
   76847             : //  printf("SgClassDeclaration::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgClassDeclaration::next_node);
   76848             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   76849             :     Rose::MemPool::snapshot(oss.str());
   76850             :     alloc_trace_cnt++;
   76851             : #endif
   76852             : 
   76853             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   76854             : 
   76855         742 :     ALLOC_MUTEX(SgClassDeclaration, unlock);
   76856             : }
   76857             : 
   76858             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   76859             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   76860             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   76861             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   76862             : // Also, note comment below from Robb (copied from the Common.code file).
   76863             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   76864             : //
   76865             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   76866             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   76867             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   76868             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   76869             : #if 0
   76870             : void SgClassDeclaration::operator delete(void* pointer) { SgClassDeclaration::operator delete (pointer, sizeof(SgClassDeclaration)); };
   76871             : #endif
   76872             : /* #line 76873 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   76873             : 
   76874             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   76875             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   76876             : // obviously imply C++.
   76877             : 
   76878             : // This implements the support within ROSE for memory pools.  Memory pools
   76879             : // support the most condensed usage of memory within the construction of
   76880             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   76881             : // by a new operator written for each class.
   76882             : 
   76883             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   76884             :     // User wants multi-thread support and POSIX threads are available.
   76885             : #   include <pthread.h>
   76886             :     static pthread_mutex_t SgTemplateClassDeclaration_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   76887             : #else
   76888             :      // Cause synchronization to be skipped.
   76889             : #    ifndef ALLOC_MUTEX
   76890             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   76891             : #    endif
   76892             : #    ifdef _REENTRANT
   76893             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   76894             : #       ifdef _MSC_VER
   76895             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   76896             : #       else
   76897             : #           warning "POSIX threads are not available; synchronization being skipped"
   76898             : #       endif
   76899             : #    endif
   76900             : #endif
   76901             : 
   76902             : #ifndef ROSE_ALLOC_TRACE
   76903             : #  define ROSE_ALLOC_TRACE 0
   76904             : #endif
   76905             : 
   76906             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   76907             : #define ROSE_ALLOC_TRACE_CNT
   76908             : #include "memory-pool-snapshot.h"
   76909             : unsigned long alloc_trace_cnt = 0;
   76910             : #endif
   76911             : 
   76912             : #if ROSE_ALLOC_TRACE
   76913             : const unsigned SgTemplateClassDeclaration::pool_size = 5;
   76914             : #else
   76915             : const unsigned SgTemplateClassDeclaration::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   76916             : #endif
   76917             : 
   76918             : #ifndef ROSE_ALLOC_MEMSET
   76919             : #  define ROSE_ALLOC_MEMSET 0
   76920             : #endif
   76921             : 
   76922             : #ifndef ROSE_PEDANTIC_ALLOC
   76923             : #  define ROSE_PEDANTIC_ALLOC 0
   76924             : #endif
   76925             : 
   76926             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   76927             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   76928             : #endif
   76929             : 
   76930             : #if !defined(SGNODE__ALL_POOLS)
   76931             : #define SGNODE__ALL_POOLS
   76932             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   76933             : #endif
   76934             : 
   76935             : SgTemplateClassDeclaration* SgTemplateClassDeclaration::next_node = nullptr;
   76936             : std::vector<unsigned char*> SgTemplateClassDeclaration::pools;
   76937             : 
   76938             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   76939             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   76940             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   76941             : // around this macro definition rather than each use).
   76942             : #ifndef ALLOC_MUTEX
   76943             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   76944             :         do {                                                                     \
   76945             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   76946             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   76947             :                 abort();                                                         \
   76948             :             }                                                                    \
   76949             :         } while (0);
   76950             : #endif
   76951             : 
   76952             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   76953             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   76954             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   76955             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   76956             : 
   76957             : /*! \brief New operator for SgTemplateClassDeclaration.
   76958             : 
   76959             :    This new operator implements memory pools to provide most efficent 
   76960             :    use of the heap within construction of large ASTs.
   76961             : 
   76962             : \internal The new and delete operators use the lower level C malloc/free
   76963             :    function calls for performance and to make sure that mixing of malloc/free
   76964             :    and new/delete by the used can be caught more readily.  This may change
   76965             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   76966             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   76967             :    deallocate memory allocated using ROSE_MALLOC.
   76968             : */
   76969       11648 : void *SgTemplateClassDeclaration::operator new ( size_t Size )
   76970             : {
   76971             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   76972             :      * returning or throwing an exception. */
   76973       11648 :     ALLOC_MUTEX(SgTemplateClassDeclaration, lock);
   76974             : 
   76975             : #if ROSE_ALLOC_TRACE == 2
   76976             : //    printf("SgTemplateClassDeclaration::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgTemplateClassDeclaration::next_node);
   76977             : #endif
   76978             : 
   76979             : #if USE_CPP_NEW_DELETE_OPERATORS
   76980             :     void *mem = ROSE_MALLOC(Size);
   76981             :     ALLOC_MUTEX(SgTemplateClassDeclaration, unlock);
   76982             :     return mem;
   76983             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   76984             : #if ROSE_PEDANTIC_ALLOC
   76985             :     ROSE_ASSERT(Size == sizeof(SgTemplateClassDeclaration));
   76986             : #else
   76987       11648 :     if (Size != sizeof(SgTemplateClassDeclaration)) {
   76988           0 :       void * object = ROSE_MALLOC(Size);
   76989           0 :       ALLOC_MUTEX(SgTemplateClassDeclaration, unlock);
   76990             :       return object;
   76991             :     }
   76992             : #endif
   76993             : 
   76994       11648 :     if (SgTemplateClassDeclaration::next_node == nullptr) {
   76995          11 :         SgTemplateClassDeclaration * alloc = (SgTemplateClassDeclaration*) ROSE_MALLOC ( SgTemplateClassDeclaration::pool_size * sizeof(SgTemplateClassDeclaration) );
   76996          11 :         ROSE_ASSERT(alloc != nullptr);
   76997             : 
   76998             : #if ROSE_ALLOC_TRACE == 2
   76999             : //        printf("SgTemplateClassDeclaration::alloc\n  block[%zi] = [ %p , %p [\n", SgTemplateClassDeclaration::pools.size(), alloc, alloc + SgTemplateClassDeclaration::pool_size);
   77000             : #endif
   77001             : 
   77002             : #if ROSE_ALLOC_MEMSET == 1
   77003             : #elif ROSE_ALLOC_MEMSET == 2
   77004             :         memset(alloc, 0x00, SgTemplateClassDeclaration::pool_size * sizeof(SgTemplateClassDeclaration));
   77005             : #elif ROSE_ALLOC_MEMSET == 3
   77006             :         memset(alloc, 0xAA, SgTemplateClassDeclaration::pool_size * sizeof(SgTemplateClassDeclaration));
   77007             : #endif
   77008       22000 :         for (unsigned i=0; i < SgTemplateClassDeclaration::pool_size-1; i++) {
   77009       21989 :           alloc[i].p_freepointer = &(alloc[i+1]);
   77010             :         }
   77011          11 :         alloc[SgTemplateClassDeclaration::pool_size-1].p_freepointer = nullptr;
   77012             : 
   77013          11 :         SgTemplateClassDeclaration::pools.push_back ( (unsigned char *) alloc );
   77014          11 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgTemplateClassDeclaration::pool_size * sizeof(SgTemplateClassDeclaration), V_SgTemplateClassDeclaration ) );
   77015          11 :         SgTemplateClassDeclaration::next_node = alloc;
   77016             :     }
   77017       11648 :     ROSE_ASSERT(SgTemplateClassDeclaration::next_node != nullptr);
   77018             : 
   77019       11648 :     SgTemplateClassDeclaration * object = SgTemplateClassDeclaration::next_node;
   77020       11648 :     SgTemplateClassDeclaration::next_node = (SgTemplateClassDeclaration*)(object->p_freepointer);
   77021             : 
   77022             : #if ROSE_ALLOC_TRACE == 2
   77023             :     printf("SgTemplateClassDeclaration::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTemplateClassDeclaration::next_node);
   77024             : #endif
   77025             : 
   77026       11648 :     SgNode * fp = object->p_freepointer;
   77027             : #if ROSE_ALLOC_MEMSET == 1
   77028             : #elif ROSE_ALLOC_MEMSET == 2
   77029             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgTemplateClassDeclaration) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   77030             : #elif ROSE_ALLOC_MEMSET == 3
   77031             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgTemplateClassDeclaration) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   77032             : #endif
   77033       11648 :     object->p_freepointer = fp;
   77034             : 
   77035             : #if ROSE_ALLOC_TRACE == 2
   77036             : //    printf("SgTemplateClassDeclaration::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTemplateClassDeclaration::next_node);
   77037             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   77038             :     Rose::MemPool::snapshot(oss.str());
   77039             :     alloc_trace_cnt++;
   77040             : #endif
   77041             : 
   77042       11648 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   77043             : 
   77044       11648 :     ALLOC_MUTEX(SgTemplateClassDeclaration, unlock);
   77045             : 
   77046             :     return object;
   77047             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   77048             : }
   77049             : 
   77050             : 
   77051             : 
   77052             : /*! \brief Delete operator for SgTemplateClassDeclaration.
   77053             : 
   77054             :    This delete operator implements deallocation using memory pools to 
   77055             :    provide most efficent use of the heap within construction of large ASTs.
   77056             : 
   77057             : \internal The new and delete operators use the lower level C malloc/free
   77058             :    function calls for performance and to make sure that mixing of malloc/free
   77059             :    and new/delete by the used can be caught more readily.  This may change
   77060             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   77061             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   77062             :    deallocate memory allocated using ROSE_MALLOC.
   77063             : */
   77064        2180 : void SgTemplateClassDeclaration::operator delete(void *Pointer, size_t Size)
   77065             : {
   77066             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   77067             :      * or throwing an exception. */
   77068        2180 :     ALLOC_MUTEX(SgTemplateClassDeclaration, lock);
   77069             : 
   77070             : #if USE_CPP_NEW_DELETE_OPERATORS
   77071             :     ROSE_FREE(Pointer);
   77072             : #else
   77073             : #if ROSE_PEDANTIC_ALLOC
   77074             :     ROSE_ASSERT(Size == sizeof(SgTemplateClassDeclaration));
   77075             : #else
   77076        2180 :     if (Size != sizeof(SgTemplateClassDeclaration)) {
   77077           0 :       ROSE_FREE(Pointer);
   77078           0 :       ALLOC_MUTEX(SgTemplateClassDeclaration, unlock);
   77079             :       return;
   77080             :     }
   77081             : #endif
   77082             : 
   77083        2180 :     SgTemplateClassDeclaration * object = (SgTemplateClassDeclaration*) Pointer;
   77084        2180 :     ROSE_ASSERT(object != nullptr);
   77085             : 
   77086             : #if ROSE_ALLOC_TRACE == 2
   77087             : //  printf("SgTemplateClassDeclaration::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTemplateClassDeclaration::next_node);
   77088             :     printf("SgTemplateClassDeclaration::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTemplateClassDeclaration::next_node);
   77089             : #endif
   77090             : 
   77091             : #if ROSE_PEDANTIC_ALLOC
   77092             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   77093             : #endif
   77094             : 
   77095             : #if ROSE_ALLOC_MEMSET == 1
   77096             : #elif ROSE_ALLOC_MEMSET == 2
   77097             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgTemplateClassDeclaration) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   77098             : #elif ROSE_ALLOC_MEMSET == 3
   77099             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgTemplateClassDeclaration) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   77100             : #endif
   77101             : 
   77102             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   77103             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   77104             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   77105             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   77106             : #else
   77107        2180 :     object->p_freepointer = SgTemplateClassDeclaration::next_node;
   77108        2180 :     SgTemplateClassDeclaration::next_node = object;
   77109             : #endif
   77110             : 
   77111             : #if ROSE_ALLOC_TRACE == 2
   77112             : //  printf("SgTemplateClassDeclaration::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTemplateClassDeclaration::next_node);
   77113             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   77114             :     Rose::MemPool::snapshot(oss.str());
   77115             :     alloc_trace_cnt++;
   77116             : #endif
   77117             : 
   77118             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   77119             : 
   77120        2180 :     ALLOC_MUTEX(SgTemplateClassDeclaration, unlock);
   77121             : }
   77122             : 
   77123             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   77124             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   77125             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   77126             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   77127             : // Also, note comment below from Robb (copied from the Common.code file).
   77128             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   77129             : //
   77130             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   77131             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   77132             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   77133             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   77134             : #if 0
   77135             : void SgTemplateClassDeclaration::operator delete(void* pointer) { SgTemplateClassDeclaration::operator delete (pointer, sizeof(SgTemplateClassDeclaration)); };
   77136             : #endif
   77137             : /* #line 77138 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   77138             : 
   77139             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   77140             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   77141             : // obviously imply C++.
   77142             : 
   77143             : // This implements the support within ROSE for memory pools.  Memory pools
   77144             : // support the most condensed usage of memory within the construction of
   77145             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   77146             : // by a new operator written for each class.
   77147             : 
   77148             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   77149             :     // User wants multi-thread support and POSIX threads are available.
   77150             : #   include <pthread.h>
   77151             :     static pthread_mutex_t SgTemplateInstantiationDecl_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   77152             : #else
   77153             :      // Cause synchronization to be skipped.
   77154             : #    ifndef ALLOC_MUTEX
   77155             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   77156             : #    endif
   77157             : #    ifdef _REENTRANT
   77158             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   77159             : #       ifdef _MSC_VER
   77160             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   77161             : #       else
   77162             : #           warning "POSIX threads are not available; synchronization being skipped"
   77163             : #       endif
   77164             : #    endif
   77165             : #endif
   77166             : 
   77167             : #ifndef ROSE_ALLOC_TRACE
   77168             : #  define ROSE_ALLOC_TRACE 0
   77169             : #endif
   77170             : 
   77171             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   77172             : #define ROSE_ALLOC_TRACE_CNT
   77173             : #include "memory-pool-snapshot.h"
   77174             : unsigned long alloc_trace_cnt = 0;
   77175             : #endif
   77176             : 
   77177             : #if ROSE_ALLOC_TRACE
   77178             : const unsigned SgTemplateInstantiationDecl::pool_size = 5;
   77179             : #else
   77180             : const unsigned SgTemplateInstantiationDecl::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   77181             : #endif
   77182             : 
   77183             : #ifndef ROSE_ALLOC_MEMSET
   77184             : #  define ROSE_ALLOC_MEMSET 0
   77185             : #endif
   77186             : 
   77187             : #ifndef ROSE_PEDANTIC_ALLOC
   77188             : #  define ROSE_PEDANTIC_ALLOC 0
   77189             : #endif
   77190             : 
   77191             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   77192             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   77193             : #endif
   77194             : 
   77195             : #if !defined(SGNODE__ALL_POOLS)
   77196             : #define SGNODE__ALL_POOLS
   77197             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   77198             : #endif
   77199             : 
   77200             : SgTemplateInstantiationDecl* SgTemplateInstantiationDecl::next_node = nullptr;
   77201             : std::vector<unsigned char*> SgTemplateInstantiationDecl::pools;
   77202             : 
   77203             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   77204             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   77205             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   77206             : // around this macro definition rather than each use).
   77207             : #ifndef ALLOC_MUTEX
   77208             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   77209             :         do {                                                                     \
   77210             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   77211             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   77212             :                 abort();                                                         \
   77213             :             }                                                                    \
   77214             :         } while (0);
   77215             : #endif
   77216             : 
   77217             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   77218             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   77219             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   77220             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   77221             : 
   77222             : /*! \brief New operator for SgTemplateInstantiationDecl.
   77223             : 
   77224             :    This new operator implements memory pools to provide most efficent 
   77225             :    use of the heap within construction of large ASTs.
   77226             : 
   77227             : \internal The new and delete operators use the lower level C malloc/free
   77228             :    function calls for performance and to make sure that mixing of malloc/free
   77229             :    and new/delete by the used can be caught more readily.  This may change
   77230             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   77231             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   77232             :    deallocate memory allocated using ROSE_MALLOC.
   77233             : */
   77234       13162 : void *SgTemplateInstantiationDecl::operator new ( size_t Size )
   77235             : {
   77236             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   77237             :      * returning or throwing an exception. */
   77238       13162 :     ALLOC_MUTEX(SgTemplateInstantiationDecl, lock);
   77239             : 
   77240             : #if ROSE_ALLOC_TRACE == 2
   77241             : //    printf("SgTemplateInstantiationDecl::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgTemplateInstantiationDecl::next_node);
   77242             : #endif
   77243             : 
   77244             : #if USE_CPP_NEW_DELETE_OPERATORS
   77245             :     void *mem = ROSE_MALLOC(Size);
   77246             :     ALLOC_MUTEX(SgTemplateInstantiationDecl, unlock);
   77247             :     return mem;
   77248             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   77249             : #if ROSE_PEDANTIC_ALLOC
   77250             :     ROSE_ASSERT(Size == sizeof(SgTemplateInstantiationDecl));
   77251             : #else
   77252       13162 :     if (Size != sizeof(SgTemplateInstantiationDecl)) {
   77253           0 :       void * object = ROSE_MALLOC(Size);
   77254           0 :       ALLOC_MUTEX(SgTemplateInstantiationDecl, unlock);
   77255             :       return object;
   77256             :     }
   77257             : #endif
   77258             : 
   77259       13162 :     if (SgTemplateInstantiationDecl::next_node == nullptr) {
   77260          10 :         SgTemplateInstantiationDecl * alloc = (SgTemplateInstantiationDecl*) ROSE_MALLOC ( SgTemplateInstantiationDecl::pool_size * sizeof(SgTemplateInstantiationDecl) );
   77261          10 :         ROSE_ASSERT(alloc != nullptr);
   77262             : 
   77263             : #if ROSE_ALLOC_TRACE == 2
   77264             : //        printf("SgTemplateInstantiationDecl::alloc\n  block[%zi] = [ %p , %p [\n", SgTemplateInstantiationDecl::pools.size(), alloc, alloc + SgTemplateInstantiationDecl::pool_size);
   77265             : #endif
   77266             : 
   77267             : #if ROSE_ALLOC_MEMSET == 1
   77268             : #elif ROSE_ALLOC_MEMSET == 2
   77269             :         memset(alloc, 0x00, SgTemplateInstantiationDecl::pool_size * sizeof(SgTemplateInstantiationDecl));
   77270             : #elif ROSE_ALLOC_MEMSET == 3
   77271             :         memset(alloc, 0xAA, SgTemplateInstantiationDecl::pool_size * sizeof(SgTemplateInstantiationDecl));
   77272             : #endif
   77273       20000 :         for (unsigned i=0; i < SgTemplateInstantiationDecl::pool_size-1; i++) {
   77274       19990 :           alloc[i].p_freepointer = &(alloc[i+1]);
   77275             :         }
   77276          10 :         alloc[SgTemplateInstantiationDecl::pool_size-1].p_freepointer = nullptr;
   77277             : 
   77278          10 :         SgTemplateInstantiationDecl::pools.push_back ( (unsigned char *) alloc );
   77279          10 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgTemplateInstantiationDecl::pool_size * sizeof(SgTemplateInstantiationDecl), V_SgTemplateInstantiationDecl ) );
   77280          10 :         SgTemplateInstantiationDecl::next_node = alloc;
   77281             :     }
   77282       13162 :     ROSE_ASSERT(SgTemplateInstantiationDecl::next_node != nullptr);
   77283             : 
   77284       13162 :     SgTemplateInstantiationDecl * object = SgTemplateInstantiationDecl::next_node;
   77285       13162 :     SgTemplateInstantiationDecl::next_node = (SgTemplateInstantiationDecl*)(object->p_freepointer);
   77286             : 
   77287             : #if ROSE_ALLOC_TRACE == 2
   77288             :     printf("SgTemplateInstantiationDecl::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTemplateInstantiationDecl::next_node);
   77289             : #endif
   77290             : 
   77291       13162 :     SgNode * fp = object->p_freepointer;
   77292             : #if ROSE_ALLOC_MEMSET == 1
   77293             : #elif ROSE_ALLOC_MEMSET == 2
   77294             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgTemplateInstantiationDecl) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   77295             : #elif ROSE_ALLOC_MEMSET == 3
   77296             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgTemplateInstantiationDecl) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   77297             : #endif
   77298       13162 :     object->p_freepointer = fp;
   77299             : 
   77300             : #if ROSE_ALLOC_TRACE == 2
   77301             : //    printf("SgTemplateInstantiationDecl::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTemplateInstantiationDecl::next_node);
   77302             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   77303             :     Rose::MemPool::snapshot(oss.str());
   77304             :     alloc_trace_cnt++;
   77305             : #endif
   77306             : 
   77307       13162 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   77308             : 
   77309       13162 :     ALLOC_MUTEX(SgTemplateInstantiationDecl, unlock);
   77310             : 
   77311             :     return object;
   77312             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   77313             : }
   77314             : 
   77315             : 
   77316             : 
   77317             : /*! \brief Delete operator for SgTemplateInstantiationDecl.
   77318             : 
   77319             :    This delete operator implements deallocation using memory pools to 
   77320             :    provide most efficent use of the heap within construction of large ASTs.
   77321             : 
   77322             : \internal The new and delete operators use the lower level C malloc/free
   77323             :    function calls for performance and to make sure that mixing of malloc/free
   77324             :    and new/delete by the used can be caught more readily.  This may change
   77325             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   77326             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   77327             :    deallocate memory allocated using ROSE_MALLOC.
   77328             : */
   77329        2638 : void SgTemplateInstantiationDecl::operator delete(void *Pointer, size_t Size)
   77330             : {
   77331             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   77332             :      * or throwing an exception. */
   77333        2638 :     ALLOC_MUTEX(SgTemplateInstantiationDecl, lock);
   77334             : 
   77335             : #if USE_CPP_NEW_DELETE_OPERATORS
   77336             :     ROSE_FREE(Pointer);
   77337             : #else
   77338             : #if ROSE_PEDANTIC_ALLOC
   77339             :     ROSE_ASSERT(Size == sizeof(SgTemplateInstantiationDecl));
   77340             : #else
   77341        2638 :     if (Size != sizeof(SgTemplateInstantiationDecl)) {
   77342           0 :       ROSE_FREE(Pointer);
   77343           0 :       ALLOC_MUTEX(SgTemplateInstantiationDecl, unlock);
   77344             :       return;
   77345             :     }
   77346             : #endif
   77347             : 
   77348        2638 :     SgTemplateInstantiationDecl * object = (SgTemplateInstantiationDecl*) Pointer;
   77349        2638 :     ROSE_ASSERT(object != nullptr);
   77350             : 
   77351             : #if ROSE_ALLOC_TRACE == 2
   77352             : //  printf("SgTemplateInstantiationDecl::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTemplateInstantiationDecl::next_node);
   77353             :     printf("SgTemplateInstantiationDecl::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTemplateInstantiationDecl::next_node);
   77354             : #endif
   77355             : 
   77356             : #if ROSE_PEDANTIC_ALLOC
   77357             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   77358             : #endif
   77359             : 
   77360             : #if ROSE_ALLOC_MEMSET == 1
   77361             : #elif ROSE_ALLOC_MEMSET == 2
   77362             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgTemplateInstantiationDecl) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   77363             : #elif ROSE_ALLOC_MEMSET == 3
   77364             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgTemplateInstantiationDecl) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   77365             : #endif
   77366             : 
   77367             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   77368             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   77369             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   77370             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   77371             : #else
   77372        2638 :     object->p_freepointer = SgTemplateInstantiationDecl::next_node;
   77373        2638 :     SgTemplateInstantiationDecl::next_node = object;
   77374             : #endif
   77375             : 
   77376             : #if ROSE_ALLOC_TRACE == 2
   77377             : //  printf("SgTemplateInstantiationDecl::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTemplateInstantiationDecl::next_node);
   77378             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   77379             :     Rose::MemPool::snapshot(oss.str());
   77380             :     alloc_trace_cnt++;
   77381             : #endif
   77382             : 
   77383             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   77384             : 
   77385        2638 :     ALLOC_MUTEX(SgTemplateInstantiationDecl, unlock);
   77386             : }
   77387             : 
   77388             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   77389             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   77390             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   77391             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   77392             : // Also, note comment below from Robb (copied from the Common.code file).
   77393             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   77394             : //
   77395             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   77396             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   77397             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   77398             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   77399             : #if 0
   77400             : void SgTemplateInstantiationDecl::operator delete(void* pointer) { SgTemplateInstantiationDecl::operator delete (pointer, sizeof(SgTemplateInstantiationDecl)); };
   77401             : #endif
   77402             : /* #line 77403 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   77403             : 
   77404             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   77405             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   77406             : // obviously imply C++.
   77407             : 
   77408             : // This implements the support within ROSE for memory pools.  Memory pools
   77409             : // support the most condensed usage of memory within the construction of
   77410             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   77411             : // by a new operator written for each class.
   77412             : 
   77413             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   77414             :     // User wants multi-thread support and POSIX threads are available.
   77415             : #   include <pthread.h>
   77416             :     static pthread_mutex_t SgDerivedTypeStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   77417             : #else
   77418             :      // Cause synchronization to be skipped.
   77419             : #    ifndef ALLOC_MUTEX
   77420             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   77421             : #    endif
   77422             : #    ifdef _REENTRANT
   77423             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   77424             : #       ifdef _MSC_VER
   77425             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   77426             : #       else
   77427             : #           warning "POSIX threads are not available; synchronization being skipped"
   77428             : #       endif
   77429             : #    endif
   77430             : #endif
   77431             : 
   77432             : #ifndef ROSE_ALLOC_TRACE
   77433             : #  define ROSE_ALLOC_TRACE 0
   77434             : #endif
   77435             : 
   77436             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   77437             : #define ROSE_ALLOC_TRACE_CNT
   77438             : #include "memory-pool-snapshot.h"
   77439             : unsigned long alloc_trace_cnt = 0;
   77440             : #endif
   77441             : 
   77442             : #if ROSE_ALLOC_TRACE
   77443             : const unsigned SgDerivedTypeStatement::pool_size = 5;
   77444             : #else
   77445             : const unsigned SgDerivedTypeStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   77446             : #endif
   77447             : 
   77448             : #ifndef ROSE_ALLOC_MEMSET
   77449             : #  define ROSE_ALLOC_MEMSET 0
   77450             : #endif
   77451             : 
   77452             : #ifndef ROSE_PEDANTIC_ALLOC
   77453             : #  define ROSE_PEDANTIC_ALLOC 0
   77454             : #endif
   77455             : 
   77456             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   77457             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   77458             : #endif
   77459             : 
   77460             : #if !defined(SGNODE__ALL_POOLS)
   77461             : #define SGNODE__ALL_POOLS
   77462             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   77463             : #endif
   77464             : 
   77465             : SgDerivedTypeStatement* SgDerivedTypeStatement::next_node = nullptr;
   77466             : std::vector<unsigned char*> SgDerivedTypeStatement::pools;
   77467             : 
   77468             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   77469             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   77470             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   77471             : // around this macro definition rather than each use).
   77472             : #ifndef ALLOC_MUTEX
   77473             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   77474             :         do {                                                                     \
   77475             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   77476             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   77477             :                 abort();                                                         \
   77478             :             }                                                                    \
   77479             :         } while (0);
   77480             : #endif
   77481             : 
   77482             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   77483             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   77484             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   77485             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   77486             : 
   77487             : /*! \brief New operator for SgDerivedTypeStatement.
   77488             : 
   77489             :    This new operator implements memory pools to provide most efficent 
   77490             :    use of the heap within construction of large ASTs.
   77491             : 
   77492             : \internal The new and delete operators use the lower level C malloc/free
   77493             :    function calls for performance and to make sure that mixing of malloc/free
   77494             :    and new/delete by the used can be caught more readily.  This may change
   77495             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   77496             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   77497             :    deallocate memory allocated using ROSE_MALLOC.
   77498             : */
   77499           0 : void *SgDerivedTypeStatement::operator new ( size_t Size )
   77500             : {
   77501             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   77502             :      * returning or throwing an exception. */
   77503           0 :     ALLOC_MUTEX(SgDerivedTypeStatement, lock);
   77504             : 
   77505             : #if ROSE_ALLOC_TRACE == 2
   77506             : //    printf("SgDerivedTypeStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgDerivedTypeStatement::next_node);
   77507             : #endif
   77508             : 
   77509             : #if USE_CPP_NEW_DELETE_OPERATORS
   77510             :     void *mem = ROSE_MALLOC(Size);
   77511             :     ALLOC_MUTEX(SgDerivedTypeStatement, unlock);
   77512             :     return mem;
   77513             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   77514             : #if ROSE_PEDANTIC_ALLOC
   77515             :     ROSE_ASSERT(Size == sizeof(SgDerivedTypeStatement));
   77516             : #else
   77517           0 :     if (Size != sizeof(SgDerivedTypeStatement)) {
   77518           0 :       void * object = ROSE_MALLOC(Size);
   77519           0 :       ALLOC_MUTEX(SgDerivedTypeStatement, unlock);
   77520             :       return object;
   77521             :     }
   77522             : #endif
   77523             : 
   77524           0 :     if (SgDerivedTypeStatement::next_node == nullptr) {
   77525           0 :         SgDerivedTypeStatement * alloc = (SgDerivedTypeStatement*) ROSE_MALLOC ( SgDerivedTypeStatement::pool_size * sizeof(SgDerivedTypeStatement) );
   77526           0 :         ROSE_ASSERT(alloc != nullptr);
   77527             : 
   77528             : #if ROSE_ALLOC_TRACE == 2
   77529             : //        printf("SgDerivedTypeStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgDerivedTypeStatement::pools.size(), alloc, alloc + SgDerivedTypeStatement::pool_size);
   77530             : #endif
   77531             : 
   77532             : #if ROSE_ALLOC_MEMSET == 1
   77533             : #elif ROSE_ALLOC_MEMSET == 2
   77534             :         memset(alloc, 0x00, SgDerivedTypeStatement::pool_size * sizeof(SgDerivedTypeStatement));
   77535             : #elif ROSE_ALLOC_MEMSET == 3
   77536             :         memset(alloc, 0xAA, SgDerivedTypeStatement::pool_size * sizeof(SgDerivedTypeStatement));
   77537             : #endif
   77538           0 :         for (unsigned i=0; i < SgDerivedTypeStatement::pool_size-1; i++) {
   77539           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
   77540             :         }
   77541           0 :         alloc[SgDerivedTypeStatement::pool_size-1].p_freepointer = nullptr;
   77542             : 
   77543           0 :         SgDerivedTypeStatement::pools.push_back ( (unsigned char *) alloc );
   77544           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgDerivedTypeStatement::pool_size * sizeof(SgDerivedTypeStatement), V_SgDerivedTypeStatement ) );
   77545           0 :         SgDerivedTypeStatement::next_node = alloc;
   77546             :     }
   77547           0 :     ROSE_ASSERT(SgDerivedTypeStatement::next_node != nullptr);
   77548             : 
   77549           0 :     SgDerivedTypeStatement * object = SgDerivedTypeStatement::next_node;
   77550           0 :     SgDerivedTypeStatement::next_node = (SgDerivedTypeStatement*)(object->p_freepointer);
   77551             : 
   77552             : #if ROSE_ALLOC_TRACE == 2
   77553             :     printf("SgDerivedTypeStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgDerivedTypeStatement::next_node);
   77554             : #endif
   77555             : 
   77556           0 :     SgNode * fp = object->p_freepointer;
   77557             : #if ROSE_ALLOC_MEMSET == 1
   77558             : #elif ROSE_ALLOC_MEMSET == 2
   77559             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgDerivedTypeStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   77560             : #elif ROSE_ALLOC_MEMSET == 3
   77561             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgDerivedTypeStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   77562             : #endif
   77563           0 :     object->p_freepointer = fp;
   77564             : 
   77565             : #if ROSE_ALLOC_TRACE == 2
   77566             : //    printf("SgDerivedTypeStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgDerivedTypeStatement::next_node);
   77567             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   77568             :     Rose::MemPool::snapshot(oss.str());
   77569             :     alloc_trace_cnt++;
   77570             : #endif
   77571             : 
   77572           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   77573             : 
   77574           0 :     ALLOC_MUTEX(SgDerivedTypeStatement, unlock);
   77575             : 
   77576             :     return object;
   77577             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   77578             : }
   77579             : 
   77580             : 
   77581             : 
   77582             : /*! \brief Delete operator for SgDerivedTypeStatement.
   77583             : 
   77584             :    This delete operator implements deallocation using memory pools to 
   77585             :    provide most efficent use of the heap within construction of large ASTs.
   77586             : 
   77587             : \internal The new and delete operators use the lower level C malloc/free
   77588             :    function calls for performance and to make sure that mixing of malloc/free
   77589             :    and new/delete by the used can be caught more readily.  This may change
   77590             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   77591             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   77592             :    deallocate memory allocated using ROSE_MALLOC.
   77593             : */
   77594           0 : void SgDerivedTypeStatement::operator delete(void *Pointer, size_t Size)
   77595             : {
   77596             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   77597             :      * or throwing an exception. */
   77598           0 :     ALLOC_MUTEX(SgDerivedTypeStatement, lock);
   77599             : 
   77600             : #if USE_CPP_NEW_DELETE_OPERATORS
   77601             :     ROSE_FREE(Pointer);
   77602             : #else
   77603             : #if ROSE_PEDANTIC_ALLOC
   77604             :     ROSE_ASSERT(Size == sizeof(SgDerivedTypeStatement));
   77605             : #else
   77606           0 :     if (Size != sizeof(SgDerivedTypeStatement)) {
   77607           0 :       ROSE_FREE(Pointer);
   77608           0 :       ALLOC_MUTEX(SgDerivedTypeStatement, unlock);
   77609             :       return;
   77610             :     }
   77611             : #endif
   77612             : 
   77613           0 :     SgDerivedTypeStatement * object = (SgDerivedTypeStatement*) Pointer;
   77614           0 :     ROSE_ASSERT(object != nullptr);
   77615             : 
   77616             : #if ROSE_ALLOC_TRACE == 2
   77617             : //  printf("SgDerivedTypeStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgDerivedTypeStatement::next_node);
   77618             :     printf("SgDerivedTypeStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgDerivedTypeStatement::next_node);
   77619             : #endif
   77620             : 
   77621             : #if ROSE_PEDANTIC_ALLOC
   77622             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   77623             : #endif
   77624             : 
   77625             : #if ROSE_ALLOC_MEMSET == 1
   77626             : #elif ROSE_ALLOC_MEMSET == 2
   77627             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgDerivedTypeStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   77628             : #elif ROSE_ALLOC_MEMSET == 3
   77629             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgDerivedTypeStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   77630             : #endif
   77631             : 
   77632             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   77633             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   77634             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   77635             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   77636             : #else
   77637           0 :     object->p_freepointer = SgDerivedTypeStatement::next_node;
   77638           0 :     SgDerivedTypeStatement::next_node = object;
   77639             : #endif
   77640             : 
   77641             : #if ROSE_ALLOC_TRACE == 2
   77642             : //  printf("SgDerivedTypeStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgDerivedTypeStatement::next_node);
   77643             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   77644             :     Rose::MemPool::snapshot(oss.str());
   77645             :     alloc_trace_cnt++;
   77646             : #endif
   77647             : 
   77648             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   77649             : 
   77650           0 :     ALLOC_MUTEX(SgDerivedTypeStatement, unlock);
   77651             : }
   77652             : 
   77653             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   77654             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   77655             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   77656             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   77657             : // Also, note comment below from Robb (copied from the Common.code file).
   77658             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   77659             : //
   77660             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   77661             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   77662             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   77663             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   77664             : #if 0
   77665             : void SgDerivedTypeStatement::operator delete(void* pointer) { SgDerivedTypeStatement::operator delete (pointer, sizeof(SgDerivedTypeStatement)); };
   77666             : #endif
   77667             : /* #line 77668 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   77668             : 
   77669             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   77670             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   77671             : // obviously imply C++.
   77672             : 
   77673             : // This implements the support within ROSE for memory pools.  Memory pools
   77674             : // support the most condensed usage of memory within the construction of
   77675             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   77676             : // by a new operator written for each class.
   77677             : 
   77678             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   77679             :     // User wants multi-thread support and POSIX threads are available.
   77680             : #   include <pthread.h>
   77681             :     static pthread_mutex_t SgModuleStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   77682             : #else
   77683             :      // Cause synchronization to be skipped.
   77684             : #    ifndef ALLOC_MUTEX
   77685             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   77686             : #    endif
   77687             : #    ifdef _REENTRANT
   77688             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   77689             : #       ifdef _MSC_VER
   77690             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   77691             : #       else
   77692             : #           warning "POSIX threads are not available; synchronization being skipped"
   77693             : #       endif
   77694             : #    endif
   77695             : #endif
   77696             : 
   77697             : #ifndef ROSE_ALLOC_TRACE
   77698             : #  define ROSE_ALLOC_TRACE 0
   77699             : #endif
   77700             : 
   77701             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   77702             : #define ROSE_ALLOC_TRACE_CNT
   77703             : #include "memory-pool-snapshot.h"
   77704             : unsigned long alloc_trace_cnt = 0;
   77705             : #endif
   77706             : 
   77707             : #if ROSE_ALLOC_TRACE
   77708             : const unsigned SgModuleStatement::pool_size = 5;
   77709             : #else
   77710             : const unsigned SgModuleStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   77711             : #endif
   77712             : 
   77713             : #ifndef ROSE_ALLOC_MEMSET
   77714             : #  define ROSE_ALLOC_MEMSET 0
   77715             : #endif
   77716             : 
   77717             : #ifndef ROSE_PEDANTIC_ALLOC
   77718             : #  define ROSE_PEDANTIC_ALLOC 0
   77719             : #endif
   77720             : 
   77721             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   77722             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   77723             : #endif
   77724             : 
   77725             : #if !defined(SGNODE__ALL_POOLS)
   77726             : #define SGNODE__ALL_POOLS
   77727             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   77728             : #endif
   77729             : 
   77730             : SgModuleStatement* SgModuleStatement::next_node = nullptr;
   77731             : std::vector<unsigned char*> SgModuleStatement::pools;
   77732             : 
   77733             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   77734             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   77735             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   77736             : // around this macro definition rather than each use).
   77737             : #ifndef ALLOC_MUTEX
   77738             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   77739             :         do {                                                                     \
   77740             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   77741             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   77742             :                 abort();                                                         \
   77743             :             }                                                                    \
   77744             :         } while (0);
   77745             : #endif
   77746             : 
   77747             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   77748             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   77749             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   77750             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   77751             : 
   77752             : /*! \brief New operator for SgModuleStatement.
   77753             : 
   77754             :    This new operator implements memory pools to provide most efficent 
   77755             :    use of the heap within construction of large ASTs.
   77756             : 
   77757             : \internal The new and delete operators use the lower level C malloc/free
   77758             :    function calls for performance and to make sure that mixing of malloc/free
   77759             :    and new/delete by the used can be caught more readily.  This may change
   77760             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   77761             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   77762             :    deallocate memory allocated using ROSE_MALLOC.
   77763             : */
   77764           0 : void *SgModuleStatement::operator new ( size_t Size )
   77765             : {
   77766             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   77767             :      * returning or throwing an exception. */
   77768           0 :     ALLOC_MUTEX(SgModuleStatement, lock);
   77769             : 
   77770             : #if ROSE_ALLOC_TRACE == 2
   77771             : //    printf("SgModuleStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgModuleStatement::next_node);
   77772             : #endif
   77773             : 
   77774             : #if USE_CPP_NEW_DELETE_OPERATORS
   77775             :     void *mem = ROSE_MALLOC(Size);
   77776             :     ALLOC_MUTEX(SgModuleStatement, unlock);
   77777             :     return mem;
   77778             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   77779             : #if ROSE_PEDANTIC_ALLOC
   77780             :     ROSE_ASSERT(Size == sizeof(SgModuleStatement));
   77781             : #else
   77782           0 :     if (Size != sizeof(SgModuleStatement)) {
   77783           0 :       void * object = ROSE_MALLOC(Size);
   77784           0 :       ALLOC_MUTEX(SgModuleStatement, unlock);
   77785             :       return object;
   77786             :     }
   77787             : #endif
   77788             : 
   77789           0 :     if (SgModuleStatement::next_node == nullptr) {
   77790           0 :         SgModuleStatement * alloc = (SgModuleStatement*) ROSE_MALLOC ( SgModuleStatement::pool_size * sizeof(SgModuleStatement) );
   77791           0 :         ROSE_ASSERT(alloc != nullptr);
   77792             : 
   77793             : #if ROSE_ALLOC_TRACE == 2
   77794             : //        printf("SgModuleStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgModuleStatement::pools.size(), alloc, alloc + SgModuleStatement::pool_size);
   77795             : #endif
   77796             : 
   77797             : #if ROSE_ALLOC_MEMSET == 1
   77798             : #elif ROSE_ALLOC_MEMSET == 2
   77799             :         memset(alloc, 0x00, SgModuleStatement::pool_size * sizeof(SgModuleStatement));
   77800             : #elif ROSE_ALLOC_MEMSET == 3
   77801             :         memset(alloc, 0xAA, SgModuleStatement::pool_size * sizeof(SgModuleStatement));
   77802             : #endif
   77803           0 :         for (unsigned i=0; i < SgModuleStatement::pool_size-1; i++) {
   77804           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
   77805             :         }
   77806           0 :         alloc[SgModuleStatement::pool_size-1].p_freepointer = nullptr;
   77807             : 
   77808           0 :         SgModuleStatement::pools.push_back ( (unsigned char *) alloc );
   77809           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgModuleStatement::pool_size * sizeof(SgModuleStatement), V_SgModuleStatement ) );
   77810           0 :         SgModuleStatement::next_node = alloc;
   77811             :     }
   77812           0 :     ROSE_ASSERT(SgModuleStatement::next_node != nullptr);
   77813             : 
   77814           0 :     SgModuleStatement * object = SgModuleStatement::next_node;
   77815           0 :     SgModuleStatement::next_node = (SgModuleStatement*)(object->p_freepointer);
   77816             : 
   77817             : #if ROSE_ALLOC_TRACE == 2
   77818             :     printf("SgModuleStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgModuleStatement::next_node);
   77819             : #endif
   77820             : 
   77821           0 :     SgNode * fp = object->p_freepointer;
   77822             : #if ROSE_ALLOC_MEMSET == 1
   77823             : #elif ROSE_ALLOC_MEMSET == 2
   77824             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgModuleStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   77825             : #elif ROSE_ALLOC_MEMSET == 3
   77826             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgModuleStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   77827             : #endif
   77828           0 :     object->p_freepointer = fp;
   77829             : 
   77830             : #if ROSE_ALLOC_TRACE == 2
   77831             : //    printf("SgModuleStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgModuleStatement::next_node);
   77832             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   77833             :     Rose::MemPool::snapshot(oss.str());
   77834             :     alloc_trace_cnt++;
   77835             : #endif
   77836             : 
   77837           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   77838             : 
   77839           0 :     ALLOC_MUTEX(SgModuleStatement, unlock);
   77840             : 
   77841             :     return object;
   77842             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   77843             : }
   77844             : 
   77845             : 
   77846             : 
   77847             : /*! \brief Delete operator for SgModuleStatement.
   77848             : 
   77849             :    This delete operator implements deallocation using memory pools to 
   77850             :    provide most efficent use of the heap within construction of large ASTs.
   77851             : 
   77852             : \internal The new and delete operators use the lower level C malloc/free
   77853             :    function calls for performance and to make sure that mixing of malloc/free
   77854             :    and new/delete by the used can be caught more readily.  This may change
   77855             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   77856             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   77857             :    deallocate memory allocated using ROSE_MALLOC.
   77858             : */
   77859           0 : void SgModuleStatement::operator delete(void *Pointer, size_t Size)
   77860             : {
   77861             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   77862             :      * or throwing an exception. */
   77863           0 :     ALLOC_MUTEX(SgModuleStatement, lock);
   77864             : 
   77865             : #if USE_CPP_NEW_DELETE_OPERATORS
   77866             :     ROSE_FREE(Pointer);
   77867             : #else
   77868             : #if ROSE_PEDANTIC_ALLOC
   77869             :     ROSE_ASSERT(Size == sizeof(SgModuleStatement));
   77870             : #else
   77871           0 :     if (Size != sizeof(SgModuleStatement)) {
   77872           0 :       ROSE_FREE(Pointer);
   77873           0 :       ALLOC_MUTEX(SgModuleStatement, unlock);
   77874             :       return;
   77875             :     }
   77876             : #endif
   77877             : 
   77878           0 :     SgModuleStatement * object = (SgModuleStatement*) Pointer;
   77879           0 :     ROSE_ASSERT(object != nullptr);
   77880             : 
   77881             : #if ROSE_ALLOC_TRACE == 2
   77882             : //  printf("SgModuleStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgModuleStatement::next_node);
   77883             :     printf("SgModuleStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgModuleStatement::next_node);
   77884             : #endif
   77885             : 
   77886             : #if ROSE_PEDANTIC_ALLOC
   77887             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   77888             : #endif
   77889             : 
   77890             : #if ROSE_ALLOC_MEMSET == 1
   77891             : #elif ROSE_ALLOC_MEMSET == 2
   77892             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgModuleStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   77893             : #elif ROSE_ALLOC_MEMSET == 3
   77894             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgModuleStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   77895             : #endif
   77896             : 
   77897             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   77898             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   77899             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   77900             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   77901             : #else
   77902           0 :     object->p_freepointer = SgModuleStatement::next_node;
   77903           0 :     SgModuleStatement::next_node = object;
   77904             : #endif
   77905             : 
   77906             : #if ROSE_ALLOC_TRACE == 2
   77907             : //  printf("SgModuleStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgModuleStatement::next_node);
   77908             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   77909             :     Rose::MemPool::snapshot(oss.str());
   77910             :     alloc_trace_cnt++;
   77911             : #endif
   77912             : 
   77913             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   77914             : 
   77915           0 :     ALLOC_MUTEX(SgModuleStatement, unlock);
   77916             : }
   77917             : 
   77918             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   77919             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   77920             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   77921             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   77922             : // Also, note comment below from Robb (copied from the Common.code file).
   77923             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   77924             : //
   77925             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   77926             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   77927             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   77928             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   77929             : #if 0
   77930             : void SgModuleStatement::operator delete(void* pointer) { SgModuleStatement::operator delete (pointer, sizeof(SgModuleStatement)); };
   77931             : #endif
   77932             : /* #line 77933 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   77933             : 
   77934             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   77935             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   77936             : // obviously imply C++.
   77937             : 
   77938             : // This implements the support within ROSE for memory pools.  Memory pools
   77939             : // support the most condensed usage of memory within the construction of
   77940             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   77941             : // by a new operator written for each class.
   77942             : 
   77943             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   77944             :     // User wants multi-thread support and POSIX threads are available.
   77945             : #   include <pthread.h>
   77946             :     static pthread_mutex_t SgImplicitStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   77947             : #else
   77948             :      // Cause synchronization to be skipped.
   77949             : #    ifndef ALLOC_MUTEX
   77950             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   77951             : #    endif
   77952             : #    ifdef _REENTRANT
   77953             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   77954             : #       ifdef _MSC_VER
   77955             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   77956             : #       else
   77957             : #           warning "POSIX threads are not available; synchronization being skipped"
   77958             : #       endif
   77959             : #    endif
   77960             : #endif
   77961             : 
   77962             : #ifndef ROSE_ALLOC_TRACE
   77963             : #  define ROSE_ALLOC_TRACE 0
   77964             : #endif
   77965             : 
   77966             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   77967             : #define ROSE_ALLOC_TRACE_CNT
   77968             : #include "memory-pool-snapshot.h"
   77969             : unsigned long alloc_trace_cnt = 0;
   77970             : #endif
   77971             : 
   77972             : #if ROSE_ALLOC_TRACE
   77973             : const unsigned SgImplicitStatement::pool_size = 5;
   77974             : #else
   77975             : const unsigned SgImplicitStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   77976             : #endif
   77977             : 
   77978             : #ifndef ROSE_ALLOC_MEMSET
   77979             : #  define ROSE_ALLOC_MEMSET 0
   77980             : #endif
   77981             : 
   77982             : #ifndef ROSE_PEDANTIC_ALLOC
   77983             : #  define ROSE_PEDANTIC_ALLOC 0
   77984             : #endif
   77985             : 
   77986             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   77987             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   77988             : #endif
   77989             : 
   77990             : #if !defined(SGNODE__ALL_POOLS)
   77991             : #define SGNODE__ALL_POOLS
   77992             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   77993             : #endif
   77994             : 
   77995             : SgImplicitStatement* SgImplicitStatement::next_node = nullptr;
   77996             : std::vector<unsigned char*> SgImplicitStatement::pools;
   77997             : 
   77998             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   77999             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   78000             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   78001             : // around this macro definition rather than each use).
   78002             : #ifndef ALLOC_MUTEX
   78003             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   78004             :         do {                                                                     \
   78005             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   78006             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   78007             :                 abort();                                                         \
   78008             :             }                                                                    \
   78009             :         } while (0);
   78010             : #endif
   78011             : 
   78012             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   78013             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   78014             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   78015             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   78016             : 
   78017             : /*! \brief New operator for SgImplicitStatement.
   78018             : 
   78019             :    This new operator implements memory pools to provide most efficent 
   78020             :    use of the heap within construction of large ASTs.
   78021             : 
   78022             : \internal The new and delete operators use the lower level C malloc/free
   78023             :    function calls for performance and to make sure that mixing of malloc/free
   78024             :    and new/delete by the used can be caught more readily.  This may change
   78025             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   78026             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   78027             :    deallocate memory allocated using ROSE_MALLOC.
   78028             : */
   78029           6 : void *SgImplicitStatement::operator new ( size_t Size )
   78030             : {
   78031             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   78032             :      * returning or throwing an exception. */
   78033           6 :     ALLOC_MUTEX(SgImplicitStatement, lock);
   78034             : 
   78035             : #if ROSE_ALLOC_TRACE == 2
   78036             : //    printf("SgImplicitStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgImplicitStatement::next_node);
   78037             : #endif
   78038             : 
   78039             : #if USE_CPP_NEW_DELETE_OPERATORS
   78040             :     void *mem = ROSE_MALLOC(Size);
   78041             :     ALLOC_MUTEX(SgImplicitStatement, unlock);
   78042             :     return mem;
   78043             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   78044             : #if ROSE_PEDANTIC_ALLOC
   78045             :     ROSE_ASSERT(Size == sizeof(SgImplicitStatement));
   78046             : #else
   78047           6 :     if (Size != sizeof(SgImplicitStatement)) {
   78048           0 :       void * object = ROSE_MALLOC(Size);
   78049           0 :       ALLOC_MUTEX(SgImplicitStatement, unlock);
   78050             :       return object;
   78051             :     }
   78052             : #endif
   78053             : 
   78054           6 :     if (SgImplicitStatement::next_node == nullptr) {
   78055           6 :         SgImplicitStatement * alloc = (SgImplicitStatement*) ROSE_MALLOC ( SgImplicitStatement::pool_size * sizeof(SgImplicitStatement) );
   78056           6 :         ROSE_ASSERT(alloc != nullptr);
   78057             : 
   78058             : #if ROSE_ALLOC_TRACE == 2
   78059             : //        printf("SgImplicitStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgImplicitStatement::pools.size(), alloc, alloc + SgImplicitStatement::pool_size);
   78060             : #endif
   78061             : 
   78062             : #if ROSE_ALLOC_MEMSET == 1
   78063             : #elif ROSE_ALLOC_MEMSET == 2
   78064             :         memset(alloc, 0x00, SgImplicitStatement::pool_size * sizeof(SgImplicitStatement));
   78065             : #elif ROSE_ALLOC_MEMSET == 3
   78066             :         memset(alloc, 0xAA, SgImplicitStatement::pool_size * sizeof(SgImplicitStatement));
   78067             : #endif
   78068       12000 :         for (unsigned i=0; i < SgImplicitStatement::pool_size-1; i++) {
   78069       11994 :           alloc[i].p_freepointer = &(alloc[i+1]);
   78070             :         }
   78071           6 :         alloc[SgImplicitStatement::pool_size-1].p_freepointer = nullptr;
   78072             : 
   78073           6 :         SgImplicitStatement::pools.push_back ( (unsigned char *) alloc );
   78074           6 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgImplicitStatement::pool_size * sizeof(SgImplicitStatement), V_SgImplicitStatement ) );
   78075           6 :         SgImplicitStatement::next_node = alloc;
   78076             :     }
   78077           6 :     ROSE_ASSERT(SgImplicitStatement::next_node != nullptr);
   78078             : 
   78079           6 :     SgImplicitStatement * object = SgImplicitStatement::next_node;
   78080           6 :     SgImplicitStatement::next_node = (SgImplicitStatement*)(object->p_freepointer);
   78081             : 
   78082             : #if ROSE_ALLOC_TRACE == 2
   78083             :     printf("SgImplicitStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgImplicitStatement::next_node);
   78084             : #endif
   78085             : 
   78086           6 :     SgNode * fp = object->p_freepointer;
   78087             : #if ROSE_ALLOC_MEMSET == 1
   78088             : #elif ROSE_ALLOC_MEMSET == 2
   78089             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgImplicitStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   78090             : #elif ROSE_ALLOC_MEMSET == 3
   78091             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgImplicitStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   78092             : #endif
   78093           6 :     object->p_freepointer = fp;
   78094             : 
   78095             : #if ROSE_ALLOC_TRACE == 2
   78096             : //    printf("SgImplicitStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgImplicitStatement::next_node);
   78097             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   78098             :     Rose::MemPool::snapshot(oss.str());
   78099             :     alloc_trace_cnt++;
   78100             : #endif
   78101             : 
   78102           6 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   78103             : 
   78104           6 :     ALLOC_MUTEX(SgImplicitStatement, unlock);
   78105             : 
   78106             :     return object;
   78107             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   78108             : }
   78109             : 
   78110             : 
   78111             : 
   78112             : /*! \brief Delete operator for SgImplicitStatement.
   78113             : 
   78114             :    This delete operator implements deallocation using memory pools to 
   78115             :    provide most efficent use of the heap within construction of large ASTs.
   78116             : 
   78117             : \internal The new and delete operators use the lower level C malloc/free
   78118             :    function calls for performance and to make sure that mixing of malloc/free
   78119             :    and new/delete by the used can be caught more readily.  This may change
   78120             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   78121             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   78122             :    deallocate memory allocated using ROSE_MALLOC.
   78123             : */
   78124           0 : void SgImplicitStatement::operator delete(void *Pointer, size_t Size)
   78125             : {
   78126             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   78127             :      * or throwing an exception. */
   78128           0 :     ALLOC_MUTEX(SgImplicitStatement, lock);
   78129             : 
   78130             : #if USE_CPP_NEW_DELETE_OPERATORS
   78131             :     ROSE_FREE(Pointer);
   78132             : #else
   78133             : #if ROSE_PEDANTIC_ALLOC
   78134             :     ROSE_ASSERT(Size == sizeof(SgImplicitStatement));
   78135             : #else
   78136           0 :     if (Size != sizeof(SgImplicitStatement)) {
   78137           0 :       ROSE_FREE(Pointer);
   78138           0 :       ALLOC_MUTEX(SgImplicitStatement, unlock);
   78139             :       return;
   78140             :     }
   78141             : #endif
   78142             : 
   78143           0 :     SgImplicitStatement * object = (SgImplicitStatement*) Pointer;
   78144           0 :     ROSE_ASSERT(object != nullptr);
   78145             : 
   78146             : #if ROSE_ALLOC_TRACE == 2
   78147             : //  printf("SgImplicitStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgImplicitStatement::next_node);
   78148             :     printf("SgImplicitStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgImplicitStatement::next_node);
   78149             : #endif
   78150             : 
   78151             : #if ROSE_PEDANTIC_ALLOC
   78152             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   78153             : #endif
   78154             : 
   78155             : #if ROSE_ALLOC_MEMSET == 1
   78156             : #elif ROSE_ALLOC_MEMSET == 2
   78157             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgImplicitStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   78158             : #elif ROSE_ALLOC_MEMSET == 3
   78159             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgImplicitStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   78160             : #endif
   78161             : 
   78162             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   78163             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   78164             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   78165             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   78166             : #else
   78167           0 :     object->p_freepointer = SgImplicitStatement::next_node;
   78168           0 :     SgImplicitStatement::next_node = object;
   78169             : #endif
   78170             : 
   78171             : #if ROSE_ALLOC_TRACE == 2
   78172             : //  printf("SgImplicitStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgImplicitStatement::next_node);
   78173             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   78174             :     Rose::MemPool::snapshot(oss.str());
   78175             :     alloc_trace_cnt++;
   78176             : #endif
   78177             : 
   78178             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   78179             : 
   78180           0 :     ALLOC_MUTEX(SgImplicitStatement, unlock);
   78181             : }
   78182             : 
   78183             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   78184             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   78185             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   78186             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   78187             : // Also, note comment below from Robb (copied from the Common.code file).
   78188             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   78189             : //
   78190             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   78191             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   78192             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   78193             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   78194             : #if 0
   78195             : void SgImplicitStatement::operator delete(void* pointer) { SgImplicitStatement::operator delete (pointer, sizeof(SgImplicitStatement)); };
   78196             : #endif
   78197             : /* #line 78198 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   78198             : 
   78199             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   78200             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   78201             : // obviously imply C++.
   78202             : 
   78203             : // This implements the support within ROSE for memory pools.  Memory pools
   78204             : // support the most condensed usage of memory within the construction of
   78205             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   78206             : // by a new operator written for each class.
   78207             : 
   78208             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   78209             :     // User wants multi-thread support and POSIX threads are available.
   78210             : #   include <pthread.h>
   78211             :     static pthread_mutex_t SgUsingDeclarationStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   78212             : #else
   78213             :      // Cause synchronization to be skipped.
   78214             : #    ifndef ALLOC_MUTEX
   78215             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   78216             : #    endif
   78217             : #    ifdef _REENTRANT
   78218             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   78219             : #       ifdef _MSC_VER
   78220             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   78221             : #       else
   78222             : #           warning "POSIX threads are not available; synchronization being skipped"
   78223             : #       endif
   78224             : #    endif
   78225             : #endif
   78226             : 
   78227             : #ifndef ROSE_ALLOC_TRACE
   78228             : #  define ROSE_ALLOC_TRACE 0
   78229             : #endif
   78230             : 
   78231             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   78232             : #define ROSE_ALLOC_TRACE_CNT
   78233             : #include "memory-pool-snapshot.h"
   78234             : unsigned long alloc_trace_cnt = 0;
   78235             : #endif
   78236             : 
   78237             : #if ROSE_ALLOC_TRACE
   78238             : const unsigned SgUsingDeclarationStatement::pool_size = 5;
   78239             : #else
   78240             : const unsigned SgUsingDeclarationStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   78241             : #endif
   78242             : 
   78243             : #ifndef ROSE_ALLOC_MEMSET
   78244             : #  define ROSE_ALLOC_MEMSET 0
   78245             : #endif
   78246             : 
   78247             : #ifndef ROSE_PEDANTIC_ALLOC
   78248             : #  define ROSE_PEDANTIC_ALLOC 0
   78249             : #endif
   78250             : 
   78251             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   78252             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   78253             : #endif
   78254             : 
   78255             : #if !defined(SGNODE__ALL_POOLS)
   78256             : #define SGNODE__ALL_POOLS
   78257             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   78258             : #endif
   78259             : 
   78260             : SgUsingDeclarationStatement* SgUsingDeclarationStatement::next_node = nullptr;
   78261             : std::vector<unsigned char*> SgUsingDeclarationStatement::pools;
   78262             : 
   78263             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   78264             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   78265             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   78266             : // around this macro definition rather than each use).
   78267             : #ifndef ALLOC_MUTEX
   78268             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   78269             :         do {                                                                     \
   78270             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   78271             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   78272             :                 abort();                                                         \
   78273             :             }                                                                    \
   78274             :         } while (0);
   78275             : #endif
   78276             : 
   78277             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   78278             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   78279             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   78280             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   78281             : 
   78282             : /*! \brief New operator for SgUsingDeclarationStatement.
   78283             : 
   78284             :    This new operator implements memory pools to provide most efficent 
   78285             :    use of the heap within construction of large ASTs.
   78286             : 
   78287             : \internal The new and delete operators use the lower level C malloc/free
   78288             :    function calls for performance and to make sure that mixing of malloc/free
   78289             :    and new/delete by the used can be caught more readily.  This may change
   78290             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   78291             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   78292             :    deallocate memory allocated using ROSE_MALLOC.
   78293             : */
   78294        3313 : void *SgUsingDeclarationStatement::operator new ( size_t Size )
   78295             : {
   78296             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   78297             :      * returning or throwing an exception. */
   78298        3313 :     ALLOC_MUTEX(SgUsingDeclarationStatement, lock);
   78299             : 
   78300             : #if ROSE_ALLOC_TRACE == 2
   78301             : //    printf("SgUsingDeclarationStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgUsingDeclarationStatement::next_node);
   78302             : #endif
   78303             : 
   78304             : #if USE_CPP_NEW_DELETE_OPERATORS
   78305             :     void *mem = ROSE_MALLOC(Size);
   78306             :     ALLOC_MUTEX(SgUsingDeclarationStatement, unlock);
   78307             :     return mem;
   78308             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   78309             : #if ROSE_PEDANTIC_ALLOC
   78310             :     ROSE_ASSERT(Size == sizeof(SgUsingDeclarationStatement));
   78311             : #else
   78312        3313 :     if (Size != sizeof(SgUsingDeclarationStatement)) {
   78313           0 :       void * object = ROSE_MALLOC(Size);
   78314           0 :       ALLOC_MUTEX(SgUsingDeclarationStatement, unlock);
   78315             :       return object;
   78316             :     }
   78317             : #endif
   78318             : 
   78319        3313 :     if (SgUsingDeclarationStatement::next_node == nullptr) {
   78320          13 :         SgUsingDeclarationStatement * alloc = (SgUsingDeclarationStatement*) ROSE_MALLOC ( SgUsingDeclarationStatement::pool_size * sizeof(SgUsingDeclarationStatement) );
   78321          13 :         ROSE_ASSERT(alloc != nullptr);
   78322             : 
   78323             : #if ROSE_ALLOC_TRACE == 2
   78324             : //        printf("SgUsingDeclarationStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgUsingDeclarationStatement::pools.size(), alloc, alloc + SgUsingDeclarationStatement::pool_size);
   78325             : #endif
   78326             : 
   78327             : #if ROSE_ALLOC_MEMSET == 1
   78328             : #elif ROSE_ALLOC_MEMSET == 2
   78329             :         memset(alloc, 0x00, SgUsingDeclarationStatement::pool_size * sizeof(SgUsingDeclarationStatement));
   78330             : #elif ROSE_ALLOC_MEMSET == 3
   78331             :         memset(alloc, 0xAA, SgUsingDeclarationStatement::pool_size * sizeof(SgUsingDeclarationStatement));
   78332             : #endif
   78333       26000 :         for (unsigned i=0; i < SgUsingDeclarationStatement::pool_size-1; i++) {
   78334       25987 :           alloc[i].p_freepointer = &(alloc[i+1]);
   78335             :         }
   78336          13 :         alloc[SgUsingDeclarationStatement::pool_size-1].p_freepointer = nullptr;
   78337             : 
   78338          13 :         SgUsingDeclarationStatement::pools.push_back ( (unsigned char *) alloc );
   78339          13 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgUsingDeclarationStatement::pool_size * sizeof(SgUsingDeclarationStatement), V_SgUsingDeclarationStatement ) );
   78340          13 :         SgUsingDeclarationStatement::next_node = alloc;
   78341             :     }
   78342        3313 :     ROSE_ASSERT(SgUsingDeclarationStatement::next_node != nullptr);
   78343             : 
   78344        3313 :     SgUsingDeclarationStatement * object = SgUsingDeclarationStatement::next_node;
   78345        3313 :     SgUsingDeclarationStatement::next_node = (SgUsingDeclarationStatement*)(object->p_freepointer);
   78346             : 
   78347             : #if ROSE_ALLOC_TRACE == 2
   78348             :     printf("SgUsingDeclarationStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUsingDeclarationStatement::next_node);
   78349             : #endif
   78350             : 
   78351        3313 :     SgNode * fp = object->p_freepointer;
   78352             : #if ROSE_ALLOC_MEMSET == 1
   78353             : #elif ROSE_ALLOC_MEMSET == 2
   78354             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgUsingDeclarationStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   78355             : #elif ROSE_ALLOC_MEMSET == 3
   78356             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgUsingDeclarationStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   78357             : #endif
   78358        3313 :     object->p_freepointer = fp;
   78359             : 
   78360             : #if ROSE_ALLOC_TRACE == 2
   78361             : //    printf("SgUsingDeclarationStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUsingDeclarationStatement::next_node);
   78362             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   78363             :     Rose::MemPool::snapshot(oss.str());
   78364             :     alloc_trace_cnt++;
   78365             : #endif
   78366             : 
   78367        3313 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   78368             : 
   78369        3313 :     ALLOC_MUTEX(SgUsingDeclarationStatement, unlock);
   78370             : 
   78371             :     return object;
   78372             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   78373             : }
   78374             : 
   78375             : 
   78376             : 
   78377             : /*! \brief Delete operator for SgUsingDeclarationStatement.
   78378             : 
   78379             :    This delete operator implements deallocation using memory pools to 
   78380             :    provide most efficent use of the heap within construction of large ASTs.
   78381             : 
   78382             : \internal The new and delete operators use the lower level C malloc/free
   78383             :    function calls for performance and to make sure that mixing of malloc/free
   78384             :    and new/delete by the used can be caught more readily.  This may change
   78385             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   78386             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   78387             :    deallocate memory allocated using ROSE_MALLOC.
   78388             : */
   78389         550 : void SgUsingDeclarationStatement::operator delete(void *Pointer, size_t Size)
   78390             : {
   78391             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   78392             :      * or throwing an exception. */
   78393         550 :     ALLOC_MUTEX(SgUsingDeclarationStatement, lock);
   78394             : 
   78395             : #if USE_CPP_NEW_DELETE_OPERATORS
   78396             :     ROSE_FREE(Pointer);
   78397             : #else
   78398             : #if ROSE_PEDANTIC_ALLOC
   78399             :     ROSE_ASSERT(Size == sizeof(SgUsingDeclarationStatement));
   78400             : #else
   78401         550 :     if (Size != sizeof(SgUsingDeclarationStatement)) {
   78402           0 :       ROSE_FREE(Pointer);
   78403           0 :       ALLOC_MUTEX(SgUsingDeclarationStatement, unlock);
   78404             :       return;
   78405             :     }
   78406             : #endif
   78407             : 
   78408         550 :     SgUsingDeclarationStatement * object = (SgUsingDeclarationStatement*) Pointer;
   78409         550 :     ROSE_ASSERT(object != nullptr);
   78410             : 
   78411             : #if ROSE_ALLOC_TRACE == 2
   78412             : //  printf("SgUsingDeclarationStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUsingDeclarationStatement::next_node);
   78413             :     printf("SgUsingDeclarationStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUsingDeclarationStatement::next_node);
   78414             : #endif
   78415             : 
   78416             : #if ROSE_PEDANTIC_ALLOC
   78417             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   78418             : #endif
   78419             : 
   78420             : #if ROSE_ALLOC_MEMSET == 1
   78421             : #elif ROSE_ALLOC_MEMSET == 2
   78422             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgUsingDeclarationStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   78423             : #elif ROSE_ALLOC_MEMSET == 3
   78424             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgUsingDeclarationStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   78425             : #endif
   78426             : 
   78427             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   78428             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   78429             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   78430             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   78431             : #else
   78432         550 :     object->p_freepointer = SgUsingDeclarationStatement::next_node;
   78433         550 :     SgUsingDeclarationStatement::next_node = object;
   78434             : #endif
   78435             : 
   78436             : #if ROSE_ALLOC_TRACE == 2
   78437             : //  printf("SgUsingDeclarationStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUsingDeclarationStatement::next_node);
   78438             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   78439             :     Rose::MemPool::snapshot(oss.str());
   78440             :     alloc_trace_cnt++;
   78441             : #endif
   78442             : 
   78443             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   78444             : 
   78445         550 :     ALLOC_MUTEX(SgUsingDeclarationStatement, unlock);
   78446             : }
   78447             : 
   78448             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   78449             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   78450             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   78451             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   78452             : // Also, note comment below from Robb (copied from the Common.code file).
   78453             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   78454             : //
   78455             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   78456             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   78457             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   78458             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   78459             : #if 0
   78460             : void SgUsingDeclarationStatement::operator delete(void* pointer) { SgUsingDeclarationStatement::operator delete (pointer, sizeof(SgUsingDeclarationStatement)); };
   78461             : #endif
   78462             : /* #line 78463 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   78463             : 
   78464             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   78465             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   78466             : // obviously imply C++.
   78467             : 
   78468             : // This implements the support within ROSE for memory pools.  Memory pools
   78469             : // support the most condensed usage of memory within the construction of
   78470             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   78471             : // by a new operator written for each class.
   78472             : 
   78473             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   78474             :     // User wants multi-thread support and POSIX threads are available.
   78475             : #   include <pthread.h>
   78476             :     static pthread_mutex_t SgNamelistStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   78477             : #else
   78478             :      // Cause synchronization to be skipped.
   78479             : #    ifndef ALLOC_MUTEX
   78480             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   78481             : #    endif
   78482             : #    ifdef _REENTRANT
   78483             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   78484             : #       ifdef _MSC_VER
   78485             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   78486             : #       else
   78487             : #           warning "POSIX threads are not available; synchronization being skipped"
   78488             : #       endif
   78489             : #    endif
   78490             : #endif
   78491             : 
   78492             : #ifndef ROSE_ALLOC_TRACE
   78493             : #  define ROSE_ALLOC_TRACE 0
   78494             : #endif
   78495             : 
   78496             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   78497             : #define ROSE_ALLOC_TRACE_CNT
   78498             : #include "memory-pool-snapshot.h"
   78499             : unsigned long alloc_trace_cnt = 0;
   78500             : #endif
   78501             : 
   78502             : #if ROSE_ALLOC_TRACE
   78503             : const unsigned SgNamelistStatement::pool_size = 5;
   78504             : #else
   78505             : const unsigned SgNamelistStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   78506             : #endif
   78507             : 
   78508             : #ifndef ROSE_ALLOC_MEMSET
   78509             : #  define ROSE_ALLOC_MEMSET 0
   78510             : #endif
   78511             : 
   78512             : #ifndef ROSE_PEDANTIC_ALLOC
   78513             : #  define ROSE_PEDANTIC_ALLOC 0
   78514             : #endif
   78515             : 
   78516             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   78517             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   78518             : #endif
   78519             : 
   78520             : #if !defined(SGNODE__ALL_POOLS)
   78521             : #define SGNODE__ALL_POOLS
   78522             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   78523             : #endif
   78524             : 
   78525             : SgNamelistStatement* SgNamelistStatement::next_node = nullptr;
   78526             : std::vector<unsigned char*> SgNamelistStatement::pools;
   78527             : 
   78528             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   78529             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   78530             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   78531             : // around this macro definition rather than each use).
   78532             : #ifndef ALLOC_MUTEX
   78533             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   78534             :         do {                                                                     \
   78535             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   78536             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   78537             :                 abort();                                                         \
   78538             :             }                                                                    \
   78539             :         } while (0);
   78540             : #endif
   78541             : 
   78542             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   78543             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   78544             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   78545             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   78546             : 
   78547             : /*! \brief New operator for SgNamelistStatement.
   78548             : 
   78549             :    This new operator implements memory pools to provide most efficent 
   78550             :    use of the heap within construction of large ASTs.
   78551             : 
   78552             : \internal The new and delete operators use the lower level C malloc/free
   78553             :    function calls for performance and to make sure that mixing of malloc/free
   78554             :    and new/delete by the used can be caught more readily.  This may change
   78555             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   78556             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   78557             :    deallocate memory allocated using ROSE_MALLOC.
   78558             : */
   78559           0 : void *SgNamelistStatement::operator new ( size_t Size )
   78560             : {
   78561             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   78562             :      * returning or throwing an exception. */
   78563           0 :     ALLOC_MUTEX(SgNamelistStatement, lock);
   78564             : 
   78565             : #if ROSE_ALLOC_TRACE == 2
   78566             : //    printf("SgNamelistStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgNamelistStatement::next_node);
   78567             : #endif
   78568             : 
   78569             : #if USE_CPP_NEW_DELETE_OPERATORS
   78570             :     void *mem = ROSE_MALLOC(Size);
   78571             :     ALLOC_MUTEX(SgNamelistStatement, unlock);
   78572             :     return mem;
   78573             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   78574             : #if ROSE_PEDANTIC_ALLOC
   78575             :     ROSE_ASSERT(Size == sizeof(SgNamelistStatement));
   78576             : #else
   78577           0 :     if (Size != sizeof(SgNamelistStatement)) {
   78578           0 :       void * object = ROSE_MALLOC(Size);
   78579           0 :       ALLOC_MUTEX(SgNamelistStatement, unlock);
   78580             :       return object;
   78581             :     }
   78582             : #endif
   78583             : 
   78584           0 :     if (SgNamelistStatement::next_node == nullptr) {
   78585           0 :         SgNamelistStatement * alloc = (SgNamelistStatement*) ROSE_MALLOC ( SgNamelistStatement::pool_size * sizeof(SgNamelistStatement) );
   78586           0 :         ROSE_ASSERT(alloc != nullptr);
   78587             : 
   78588             : #if ROSE_ALLOC_TRACE == 2
   78589             : //        printf("SgNamelistStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgNamelistStatement::pools.size(), alloc, alloc + SgNamelistStatement::pool_size);
   78590             : #endif
   78591             : 
   78592             : #if ROSE_ALLOC_MEMSET == 1
   78593             : #elif ROSE_ALLOC_MEMSET == 2
   78594             :         memset(alloc, 0x00, SgNamelistStatement::pool_size * sizeof(SgNamelistStatement));
   78595             : #elif ROSE_ALLOC_MEMSET == 3
   78596             :         memset(alloc, 0xAA, SgNamelistStatement::pool_size * sizeof(SgNamelistStatement));
   78597             : #endif
   78598           0 :         for (unsigned i=0; i < SgNamelistStatement::pool_size-1; i++) {
   78599           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
   78600             :         }
   78601           0 :         alloc[SgNamelistStatement::pool_size-1].p_freepointer = nullptr;
   78602             : 
   78603           0 :         SgNamelistStatement::pools.push_back ( (unsigned char *) alloc );
   78604           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgNamelistStatement::pool_size * sizeof(SgNamelistStatement), V_SgNamelistStatement ) );
   78605           0 :         SgNamelistStatement::next_node = alloc;
   78606             :     }
   78607           0 :     ROSE_ASSERT(SgNamelistStatement::next_node != nullptr);
   78608             : 
   78609           0 :     SgNamelistStatement * object = SgNamelistStatement::next_node;
   78610           0 :     SgNamelistStatement::next_node = (SgNamelistStatement*)(object->p_freepointer);
   78611             : 
   78612             : #if ROSE_ALLOC_TRACE == 2
   78613             :     printf("SgNamelistStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgNamelistStatement::next_node);
   78614             : #endif
   78615             : 
   78616           0 :     SgNode * fp = object->p_freepointer;
   78617             : #if ROSE_ALLOC_MEMSET == 1
   78618             : #elif ROSE_ALLOC_MEMSET == 2
   78619             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgNamelistStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   78620             : #elif ROSE_ALLOC_MEMSET == 3
   78621             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgNamelistStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   78622             : #endif
   78623           0 :     object->p_freepointer = fp;
   78624             : 
   78625             : #if ROSE_ALLOC_TRACE == 2
   78626             : //    printf("SgNamelistStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgNamelistStatement::next_node);
   78627             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   78628             :     Rose::MemPool::snapshot(oss.str());
   78629             :     alloc_trace_cnt++;
   78630             : #endif
   78631             : 
   78632           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   78633             : 
   78634           0 :     ALLOC_MUTEX(SgNamelistStatement, unlock);
   78635             : 
   78636             :     return object;
   78637             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   78638             : }
   78639             : 
   78640             : 
   78641             : 
   78642             : /*! \brief Delete operator for SgNamelistStatement.
   78643             : 
   78644             :    This delete operator implements deallocation using memory pools to 
   78645             :    provide most efficent use of the heap within construction of large ASTs.
   78646             : 
   78647             : \internal The new and delete operators use the lower level C malloc/free
   78648             :    function calls for performance and to make sure that mixing of malloc/free
   78649             :    and new/delete by the used can be caught more readily.  This may change
   78650             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   78651             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   78652             :    deallocate memory allocated using ROSE_MALLOC.
   78653             : */
   78654           0 : void SgNamelistStatement::operator delete(void *Pointer, size_t Size)
   78655             : {
   78656             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   78657             :      * or throwing an exception. */
   78658           0 :     ALLOC_MUTEX(SgNamelistStatement, lock);
   78659             : 
   78660             : #if USE_CPP_NEW_DELETE_OPERATORS
   78661             :     ROSE_FREE(Pointer);
   78662             : #else
   78663             : #if ROSE_PEDANTIC_ALLOC
   78664             :     ROSE_ASSERT(Size == sizeof(SgNamelistStatement));
   78665             : #else
   78666           0 :     if (Size != sizeof(SgNamelistStatement)) {
   78667           0 :       ROSE_FREE(Pointer);
   78668           0 :       ALLOC_MUTEX(SgNamelistStatement, unlock);
   78669             :       return;
   78670             :     }
   78671             : #endif
   78672             : 
   78673           0 :     SgNamelistStatement * object = (SgNamelistStatement*) Pointer;
   78674           0 :     ROSE_ASSERT(object != nullptr);
   78675             : 
   78676             : #if ROSE_ALLOC_TRACE == 2
   78677             : //  printf("SgNamelistStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgNamelistStatement::next_node);
   78678             :     printf("SgNamelistStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgNamelistStatement::next_node);
   78679             : #endif
   78680             : 
   78681             : #if ROSE_PEDANTIC_ALLOC
   78682             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   78683             : #endif
   78684             : 
   78685             : #if ROSE_ALLOC_MEMSET == 1
   78686             : #elif ROSE_ALLOC_MEMSET == 2
   78687             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgNamelistStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   78688             : #elif ROSE_ALLOC_MEMSET == 3
   78689             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgNamelistStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   78690             : #endif
   78691             : 
   78692             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   78693             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   78694             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   78695             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   78696             : #else
   78697           0 :     object->p_freepointer = SgNamelistStatement::next_node;
   78698           0 :     SgNamelistStatement::next_node = object;
   78699             : #endif
   78700             : 
   78701             : #if ROSE_ALLOC_TRACE == 2
   78702             : //  printf("SgNamelistStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgNamelistStatement::next_node);
   78703             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   78704             :     Rose::MemPool::snapshot(oss.str());
   78705             :     alloc_trace_cnt++;
   78706             : #endif
   78707             : 
   78708             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   78709             : 
   78710           0 :     ALLOC_MUTEX(SgNamelistStatement, unlock);
   78711             : }
   78712             : 
   78713             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   78714             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   78715             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   78716             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   78717             : // Also, note comment below from Robb (copied from the Common.code file).
   78718             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   78719             : //
   78720             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   78721             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   78722             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   78723             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   78724             : #if 0
   78725             : void SgNamelistStatement::operator delete(void* pointer) { SgNamelistStatement::operator delete (pointer, sizeof(SgNamelistStatement)); };
   78726             : #endif
   78727             : /* #line 78728 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   78728             : 
   78729             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   78730             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   78731             : // obviously imply C++.
   78732             : 
   78733             : // This implements the support within ROSE for memory pools.  Memory pools
   78734             : // support the most condensed usage of memory within the construction of
   78735             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   78736             : // by a new operator written for each class.
   78737             : 
   78738             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   78739             :     // User wants multi-thread support and POSIX threads are available.
   78740             : #   include <pthread.h>
   78741             :     static pthread_mutex_t SgImportStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   78742             : #else
   78743             :      // Cause synchronization to be skipped.
   78744             : #    ifndef ALLOC_MUTEX
   78745             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   78746             : #    endif
   78747             : #    ifdef _REENTRANT
   78748             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   78749             : #       ifdef _MSC_VER
   78750             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   78751             : #       else
   78752             : #           warning "POSIX threads are not available; synchronization being skipped"
   78753             : #       endif
   78754             : #    endif
   78755             : #endif
   78756             : 
   78757             : #ifndef ROSE_ALLOC_TRACE
   78758             : #  define ROSE_ALLOC_TRACE 0
   78759             : #endif
   78760             : 
   78761             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   78762             : #define ROSE_ALLOC_TRACE_CNT
   78763             : #include "memory-pool-snapshot.h"
   78764             : unsigned long alloc_trace_cnt = 0;
   78765             : #endif
   78766             : 
   78767             : #if ROSE_ALLOC_TRACE
   78768             : const unsigned SgImportStatement::pool_size = 5;
   78769             : #else
   78770             : const unsigned SgImportStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   78771             : #endif
   78772             : 
   78773             : #ifndef ROSE_ALLOC_MEMSET
   78774             : #  define ROSE_ALLOC_MEMSET 0
   78775             : #endif
   78776             : 
   78777             : #ifndef ROSE_PEDANTIC_ALLOC
   78778             : #  define ROSE_PEDANTIC_ALLOC 0
   78779             : #endif
   78780             : 
   78781             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   78782             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   78783             : #endif
   78784             : 
   78785             : #if !defined(SGNODE__ALL_POOLS)
   78786             : #define SGNODE__ALL_POOLS
   78787             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   78788             : #endif
   78789             : 
   78790             : SgImportStatement* SgImportStatement::next_node = nullptr;
   78791             : std::vector<unsigned char*> SgImportStatement::pools;
   78792             : 
   78793             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   78794             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   78795             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   78796             : // around this macro definition rather than each use).
   78797             : #ifndef ALLOC_MUTEX
   78798             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   78799             :         do {                                                                     \
   78800             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   78801             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   78802             :                 abort();                                                         \
   78803             :             }                                                                    \
   78804             :         } while (0);
   78805             : #endif
   78806             : 
   78807             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   78808             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   78809             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   78810             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   78811             : 
   78812             : /*! \brief New operator for SgImportStatement.
   78813             : 
   78814             :    This new operator implements memory pools to provide most efficent 
   78815             :    use of the heap within construction of large ASTs.
   78816             : 
   78817             : \internal The new and delete operators use the lower level C malloc/free
   78818             :    function calls for performance and to make sure that mixing of malloc/free
   78819             :    and new/delete by the used can be caught more readily.  This may change
   78820             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   78821             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   78822             :    deallocate memory allocated using ROSE_MALLOC.
   78823             : */
   78824           0 : void *SgImportStatement::operator new ( size_t Size )
   78825             : {
   78826             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   78827             :      * returning or throwing an exception. */
   78828           0 :     ALLOC_MUTEX(SgImportStatement, lock);
   78829             : 
   78830             : #if ROSE_ALLOC_TRACE == 2
   78831             : //    printf("SgImportStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgImportStatement::next_node);
   78832             : #endif
   78833             : 
   78834             : #if USE_CPP_NEW_DELETE_OPERATORS
   78835             :     void *mem = ROSE_MALLOC(Size);
   78836             :     ALLOC_MUTEX(SgImportStatement, unlock);
   78837             :     return mem;
   78838             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   78839             : #if ROSE_PEDANTIC_ALLOC
   78840             :     ROSE_ASSERT(Size == sizeof(SgImportStatement));
   78841             : #else
   78842           0 :     if (Size != sizeof(SgImportStatement)) {
   78843           0 :       void * object = ROSE_MALLOC(Size);
   78844           0 :       ALLOC_MUTEX(SgImportStatement, unlock);
   78845             :       return object;
   78846             :     }
   78847             : #endif
   78848             : 
   78849           0 :     if (SgImportStatement::next_node == nullptr) {
   78850           0 :         SgImportStatement * alloc = (SgImportStatement*) ROSE_MALLOC ( SgImportStatement::pool_size * sizeof(SgImportStatement) );
   78851           0 :         ROSE_ASSERT(alloc != nullptr);
   78852             : 
   78853             : #if ROSE_ALLOC_TRACE == 2
   78854             : //        printf("SgImportStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgImportStatement::pools.size(), alloc, alloc + SgImportStatement::pool_size);
   78855             : #endif
   78856             : 
   78857             : #if ROSE_ALLOC_MEMSET == 1
   78858             : #elif ROSE_ALLOC_MEMSET == 2
   78859             :         memset(alloc, 0x00, SgImportStatement::pool_size * sizeof(SgImportStatement));
   78860             : #elif ROSE_ALLOC_MEMSET == 3
   78861             :         memset(alloc, 0xAA, SgImportStatement::pool_size * sizeof(SgImportStatement));
   78862             : #endif
   78863           0 :         for (unsigned i=0; i < SgImportStatement::pool_size-1; i++) {
   78864           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
   78865             :         }
   78866           0 :         alloc[SgImportStatement::pool_size-1].p_freepointer = nullptr;
   78867             : 
   78868           0 :         SgImportStatement::pools.push_back ( (unsigned char *) alloc );
   78869           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgImportStatement::pool_size * sizeof(SgImportStatement), V_SgImportStatement ) );
   78870           0 :         SgImportStatement::next_node = alloc;
   78871             :     }
   78872           0 :     ROSE_ASSERT(SgImportStatement::next_node != nullptr);
   78873             : 
   78874           0 :     SgImportStatement * object = SgImportStatement::next_node;
   78875           0 :     SgImportStatement::next_node = (SgImportStatement*)(object->p_freepointer);
   78876             : 
   78877             : #if ROSE_ALLOC_TRACE == 2
   78878             :     printf("SgImportStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgImportStatement::next_node);
   78879             : #endif
   78880             : 
   78881           0 :     SgNode * fp = object->p_freepointer;
   78882             : #if ROSE_ALLOC_MEMSET == 1
   78883             : #elif ROSE_ALLOC_MEMSET == 2
   78884             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgImportStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   78885             : #elif ROSE_ALLOC_MEMSET == 3
   78886             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgImportStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   78887             : #endif
   78888           0 :     object->p_freepointer = fp;
   78889             : 
   78890             : #if ROSE_ALLOC_TRACE == 2
   78891             : //    printf("SgImportStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgImportStatement::next_node);
   78892             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   78893             :     Rose::MemPool::snapshot(oss.str());
   78894             :     alloc_trace_cnt++;
   78895             : #endif
   78896             : 
   78897           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   78898             : 
   78899           0 :     ALLOC_MUTEX(SgImportStatement, unlock);
   78900             : 
   78901             :     return object;
   78902             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   78903             : }
   78904             : 
   78905             : 
   78906             : 
   78907             : /*! \brief Delete operator for SgImportStatement.
   78908             : 
   78909             :    This delete operator implements deallocation using memory pools to 
   78910             :    provide most efficent use of the heap within construction of large ASTs.
   78911             : 
   78912             : \internal The new and delete operators use the lower level C malloc/free
   78913             :    function calls for performance and to make sure that mixing of malloc/free
   78914             :    and new/delete by the used can be caught more readily.  This may change
   78915             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   78916             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   78917             :    deallocate memory allocated using ROSE_MALLOC.
   78918             : */
   78919           0 : void SgImportStatement::operator delete(void *Pointer, size_t Size)
   78920             : {
   78921             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   78922             :      * or throwing an exception. */
   78923           0 :     ALLOC_MUTEX(SgImportStatement, lock);
   78924             : 
   78925             : #if USE_CPP_NEW_DELETE_OPERATORS
   78926             :     ROSE_FREE(Pointer);
   78927             : #else
   78928             : #if ROSE_PEDANTIC_ALLOC
   78929             :     ROSE_ASSERT(Size == sizeof(SgImportStatement));
   78930             : #else
   78931           0 :     if (Size != sizeof(SgImportStatement)) {
   78932           0 :       ROSE_FREE(Pointer);
   78933           0 :       ALLOC_MUTEX(SgImportStatement, unlock);
   78934             :       return;
   78935             :     }
   78936             : #endif
   78937             : 
   78938           0 :     SgImportStatement * object = (SgImportStatement*) Pointer;
   78939           0 :     ROSE_ASSERT(object != nullptr);
   78940             : 
   78941             : #if ROSE_ALLOC_TRACE == 2
   78942             : //  printf("SgImportStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgImportStatement::next_node);
   78943             :     printf("SgImportStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgImportStatement::next_node);
   78944             : #endif
   78945             : 
   78946             : #if ROSE_PEDANTIC_ALLOC
   78947             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   78948             : #endif
   78949             : 
   78950             : #if ROSE_ALLOC_MEMSET == 1
   78951             : #elif ROSE_ALLOC_MEMSET == 2
   78952             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgImportStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   78953             : #elif ROSE_ALLOC_MEMSET == 3
   78954             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgImportStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   78955             : #endif
   78956             : 
   78957             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   78958             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   78959             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   78960             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   78961             : #else
   78962           0 :     object->p_freepointer = SgImportStatement::next_node;
   78963           0 :     SgImportStatement::next_node = object;
   78964             : #endif
   78965             : 
   78966             : #if ROSE_ALLOC_TRACE == 2
   78967             : //  printf("SgImportStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgImportStatement::next_node);
   78968             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   78969             :     Rose::MemPool::snapshot(oss.str());
   78970             :     alloc_trace_cnt++;
   78971             : #endif
   78972             : 
   78973             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   78974             : 
   78975           0 :     ALLOC_MUTEX(SgImportStatement, unlock);
   78976             : }
   78977             : 
   78978             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   78979             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   78980             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   78981             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   78982             : // Also, note comment below from Robb (copied from the Common.code file).
   78983             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   78984             : //
   78985             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   78986             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   78987             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   78988             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   78989             : #if 0
   78990             : void SgImportStatement::operator delete(void* pointer) { SgImportStatement::operator delete (pointer, sizeof(SgImportStatement)); };
   78991             : #endif
   78992             : /* #line 78993 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   78993             : 
   78994             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   78995             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   78996             : // obviously imply C++.
   78997             : 
   78998             : // This implements the support within ROSE for memory pools.  Memory pools
   78999             : // support the most condensed usage of memory within the construction of
   79000             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   79001             : // by a new operator written for each class.
   79002             : 
   79003             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   79004             :     // User wants multi-thread support and POSIX threads are available.
   79005             : #   include <pthread.h>
   79006             :     static pthread_mutex_t SgFunctionDeclaration_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   79007             : #else
   79008             :      // Cause synchronization to be skipped.
   79009             : #    ifndef ALLOC_MUTEX
   79010             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   79011             : #    endif
   79012             : #    ifdef _REENTRANT
   79013             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   79014             : #       ifdef _MSC_VER
   79015             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   79016             : #       else
   79017             : #           warning "POSIX threads are not available; synchronization being skipped"
   79018             : #       endif
   79019             : #    endif
   79020             : #endif
   79021             : 
   79022             : #ifndef ROSE_ALLOC_TRACE
   79023             : #  define ROSE_ALLOC_TRACE 0
   79024             : #endif
   79025             : 
   79026             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   79027             : #define ROSE_ALLOC_TRACE_CNT
   79028             : #include "memory-pool-snapshot.h"
   79029             : unsigned long alloc_trace_cnt = 0;
   79030             : #endif
   79031             : 
   79032             : #if ROSE_ALLOC_TRACE
   79033             : const unsigned SgFunctionDeclaration::pool_size = 5;
   79034             : #else
   79035             : const unsigned SgFunctionDeclaration::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   79036             : #endif
   79037             : 
   79038             : #ifndef ROSE_ALLOC_MEMSET
   79039             : #  define ROSE_ALLOC_MEMSET 0
   79040             : #endif
   79041             : 
   79042             : #ifndef ROSE_PEDANTIC_ALLOC
   79043             : #  define ROSE_PEDANTIC_ALLOC 0
   79044             : #endif
   79045             : 
   79046             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   79047             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   79048             : #endif
   79049             : 
   79050             : #if !defined(SGNODE__ALL_POOLS)
   79051             : #define SGNODE__ALL_POOLS
   79052             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   79053             : #endif
   79054             : 
   79055             : SgFunctionDeclaration* SgFunctionDeclaration::next_node = nullptr;
   79056             : std::vector<unsigned char*> SgFunctionDeclaration::pools;
   79057             : 
   79058             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   79059             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   79060             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   79061             : // around this macro definition rather than each use).
   79062             : #ifndef ALLOC_MUTEX
   79063             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   79064             :         do {                                                                     \
   79065             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   79066             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   79067             :                 abort();                                                         \
   79068             :             }                                                                    \
   79069             :         } while (0);
   79070             : #endif
   79071             : 
   79072             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   79073             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   79074             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   79075             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   79076             : 
   79077             : /*! \brief New operator for SgFunctionDeclaration.
   79078             : 
   79079             :    This new operator implements memory pools to provide most efficent 
   79080             :    use of the heap within construction of large ASTs.
   79081             : 
   79082             : \internal The new and delete operators use the lower level C malloc/free
   79083             :    function calls for performance and to make sure that mixing of malloc/free
   79084             :    and new/delete by the used can be caught more readily.  This may change
   79085             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   79086             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   79087             :    deallocate memory allocated using ROSE_MALLOC.
   79088             : */
   79089     1139880 : void *SgFunctionDeclaration::operator new ( size_t Size )
   79090             : {
   79091             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   79092             :      * returning or throwing an exception. */
   79093     1139880 :     ALLOC_MUTEX(SgFunctionDeclaration, lock);
   79094             : 
   79095             : #if ROSE_ALLOC_TRACE == 2
   79096             : //    printf("SgFunctionDeclaration::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgFunctionDeclaration::next_node);
   79097             : #endif
   79098             : 
   79099             : #if USE_CPP_NEW_DELETE_OPERATORS
   79100             :     void *mem = ROSE_MALLOC(Size);
   79101             :     ALLOC_MUTEX(SgFunctionDeclaration, unlock);
   79102             :     return mem;
   79103             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   79104             : #if ROSE_PEDANTIC_ALLOC
   79105             :     ROSE_ASSERT(Size == sizeof(SgFunctionDeclaration));
   79106             : #else
   79107     1139880 :     if (Size != sizeof(SgFunctionDeclaration)) {
   79108           0 :       void * object = ROSE_MALLOC(Size);
   79109           0 :       ALLOC_MUTEX(SgFunctionDeclaration, unlock);
   79110             :       return object;
   79111             :     }
   79112             : #endif
   79113             : 
   79114     1139880 :     if (SgFunctionDeclaration::next_node == nullptr) {
   79115         659 :         SgFunctionDeclaration * alloc = (SgFunctionDeclaration*) ROSE_MALLOC ( SgFunctionDeclaration::pool_size * sizeof(SgFunctionDeclaration) );
   79116         659 :         ROSE_ASSERT(alloc != nullptr);
   79117             : 
   79118             : #if ROSE_ALLOC_TRACE == 2
   79119             : //        printf("SgFunctionDeclaration::alloc\n  block[%zi] = [ %p , %p [\n", SgFunctionDeclaration::pools.size(), alloc, alloc + SgFunctionDeclaration::pool_size);
   79120             : #endif
   79121             : 
   79122             : #if ROSE_ALLOC_MEMSET == 1
   79123             : #elif ROSE_ALLOC_MEMSET == 2
   79124             :         memset(alloc, 0x00, SgFunctionDeclaration::pool_size * sizeof(SgFunctionDeclaration));
   79125             : #elif ROSE_ALLOC_MEMSET == 3
   79126             :         memset(alloc, 0xAA, SgFunctionDeclaration::pool_size * sizeof(SgFunctionDeclaration));
   79127             : #endif
   79128     1318000 :         for (unsigned i=0; i < SgFunctionDeclaration::pool_size-1; i++) {
   79129     1317340 :           alloc[i].p_freepointer = &(alloc[i+1]);
   79130             :         }
   79131         659 :         alloc[SgFunctionDeclaration::pool_size-1].p_freepointer = nullptr;
   79132             : 
   79133         659 :         SgFunctionDeclaration::pools.push_back ( (unsigned char *) alloc );
   79134         659 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgFunctionDeclaration::pool_size * sizeof(SgFunctionDeclaration), V_SgFunctionDeclaration ) );
   79135         659 :         SgFunctionDeclaration::next_node = alloc;
   79136             :     }
   79137     1139880 :     ROSE_ASSERT(SgFunctionDeclaration::next_node != nullptr);
   79138             : 
   79139     1139880 :     SgFunctionDeclaration * object = SgFunctionDeclaration::next_node;
   79140     1139880 :     SgFunctionDeclaration::next_node = (SgFunctionDeclaration*)(object->p_freepointer);
   79141             : 
   79142             : #if ROSE_ALLOC_TRACE == 2
   79143             :     printf("SgFunctionDeclaration::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgFunctionDeclaration::next_node);
   79144             : #endif
   79145             : 
   79146     1139880 :     SgNode * fp = object->p_freepointer;
   79147             : #if ROSE_ALLOC_MEMSET == 1
   79148             : #elif ROSE_ALLOC_MEMSET == 2
   79149             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgFunctionDeclaration) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   79150             : #elif ROSE_ALLOC_MEMSET == 3
   79151             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgFunctionDeclaration) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   79152             : #endif
   79153     1139880 :     object->p_freepointer = fp;
   79154             : 
   79155             : #if ROSE_ALLOC_TRACE == 2
   79156             : //    printf("SgFunctionDeclaration::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgFunctionDeclaration::next_node);
   79157             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   79158             :     Rose::MemPool::snapshot(oss.str());
   79159             :     alloc_trace_cnt++;
   79160             : #endif
   79161             : 
   79162     1139880 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   79163             : 
   79164     1139880 :     ALLOC_MUTEX(SgFunctionDeclaration, unlock);
   79165             : 
   79166             :     return object;
   79167             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   79168             : }
   79169             : 
   79170             : 
   79171             : 
   79172             : /*! \brief Delete operator for SgFunctionDeclaration.
   79173             : 
   79174             :    This delete operator implements deallocation using memory pools to 
   79175             :    provide most efficent use of the heap within construction of large ASTs.
   79176             : 
   79177             : \internal The new and delete operators use the lower level C malloc/free
   79178             :    function calls for performance and to make sure that mixing of malloc/free
   79179             :    and new/delete by the used can be caught more readily.  This may change
   79180             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   79181             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   79182             :    deallocate memory allocated using ROSE_MALLOC.
   79183             : */
   79184       15832 : void SgFunctionDeclaration::operator delete(void *Pointer, size_t Size)
   79185             : {
   79186             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   79187             :      * or throwing an exception. */
   79188       15832 :     ALLOC_MUTEX(SgFunctionDeclaration, lock);
   79189             : 
   79190             : #if USE_CPP_NEW_DELETE_OPERATORS
   79191             :     ROSE_FREE(Pointer);
   79192             : #else
   79193             : #if ROSE_PEDANTIC_ALLOC
   79194             :     ROSE_ASSERT(Size == sizeof(SgFunctionDeclaration));
   79195             : #else
   79196       15832 :     if (Size != sizeof(SgFunctionDeclaration)) {
   79197           0 :       ROSE_FREE(Pointer);
   79198           0 :       ALLOC_MUTEX(SgFunctionDeclaration, unlock);
   79199             :       return;
   79200             :     }
   79201             : #endif
   79202             : 
   79203       15832 :     SgFunctionDeclaration * object = (SgFunctionDeclaration*) Pointer;
   79204       15832 :     ROSE_ASSERT(object != nullptr);
   79205             : 
   79206             : #if ROSE_ALLOC_TRACE == 2
   79207             : //  printf("SgFunctionDeclaration::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgFunctionDeclaration::next_node);
   79208             :     printf("SgFunctionDeclaration::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgFunctionDeclaration::next_node);
   79209             : #endif
   79210             : 
   79211             : #if ROSE_PEDANTIC_ALLOC
   79212             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   79213             : #endif
   79214             : 
   79215             : #if ROSE_ALLOC_MEMSET == 1
   79216             : #elif ROSE_ALLOC_MEMSET == 2
   79217             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgFunctionDeclaration) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   79218             : #elif ROSE_ALLOC_MEMSET == 3
   79219             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgFunctionDeclaration) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   79220             : #endif
   79221             : 
   79222             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   79223             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   79224             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   79225             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   79226             : #else
   79227       15832 :     object->p_freepointer = SgFunctionDeclaration::next_node;
   79228       15832 :     SgFunctionDeclaration::next_node = object;
   79229             : #endif
   79230             : 
   79231             : #if ROSE_ALLOC_TRACE == 2
   79232             : //  printf("SgFunctionDeclaration::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgFunctionDeclaration::next_node);
   79233             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   79234             :     Rose::MemPool::snapshot(oss.str());
   79235             :     alloc_trace_cnt++;
   79236             : #endif
   79237             : 
   79238             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   79239             : 
   79240       15832 :     ALLOC_MUTEX(SgFunctionDeclaration, unlock);
   79241             : }
   79242             : 
   79243             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   79244             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   79245             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   79246             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   79247             : // Also, note comment below from Robb (copied from the Common.code file).
   79248             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   79249             : //
   79250             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   79251             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   79252             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   79253             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   79254             : #if 0
   79255             : void SgFunctionDeclaration::operator delete(void* pointer) { SgFunctionDeclaration::operator delete (pointer, sizeof(SgFunctionDeclaration)); };
   79256             : #endif
   79257             : /* #line 79258 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   79258             : 
   79259             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   79260             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   79261             : // obviously imply C++.
   79262             : 
   79263             : // This implements the support within ROSE for memory pools.  Memory pools
   79264             : // support the most condensed usage of memory within the construction of
   79265             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   79266             : // by a new operator written for each class.
   79267             : 
   79268             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   79269             :     // User wants multi-thread support and POSIX threads are available.
   79270             : #   include <pthread.h>
   79271             :     static pthread_mutex_t SgTemplateFunctionDeclaration_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   79272             : #else
   79273             :      // Cause synchronization to be skipped.
   79274             : #    ifndef ALLOC_MUTEX
   79275             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   79276             : #    endif
   79277             : #    ifdef _REENTRANT
   79278             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   79279             : #       ifdef _MSC_VER
   79280             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   79281             : #       else
   79282             : #           warning "POSIX threads are not available; synchronization being skipped"
   79283             : #       endif
   79284             : #    endif
   79285             : #endif
   79286             : 
   79287             : #ifndef ROSE_ALLOC_TRACE
   79288             : #  define ROSE_ALLOC_TRACE 0
   79289             : #endif
   79290             : 
   79291             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   79292             : #define ROSE_ALLOC_TRACE_CNT
   79293             : #include "memory-pool-snapshot.h"
   79294             : unsigned long alloc_trace_cnt = 0;
   79295             : #endif
   79296             : 
   79297             : #if ROSE_ALLOC_TRACE
   79298             : const unsigned SgTemplateFunctionDeclaration::pool_size = 5;
   79299             : #else
   79300             : const unsigned SgTemplateFunctionDeclaration::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   79301             : #endif
   79302             : 
   79303             : #ifndef ROSE_ALLOC_MEMSET
   79304             : #  define ROSE_ALLOC_MEMSET 0
   79305             : #endif
   79306             : 
   79307             : #ifndef ROSE_PEDANTIC_ALLOC
   79308             : #  define ROSE_PEDANTIC_ALLOC 0
   79309             : #endif
   79310             : 
   79311             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   79312             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   79313             : #endif
   79314             : 
   79315             : #if !defined(SGNODE__ALL_POOLS)
   79316             : #define SGNODE__ALL_POOLS
   79317             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   79318             : #endif
   79319             : 
   79320             : SgTemplateFunctionDeclaration* SgTemplateFunctionDeclaration::next_node = nullptr;
   79321             : std::vector<unsigned char*> SgTemplateFunctionDeclaration::pools;
   79322             : 
   79323             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   79324             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   79325             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   79326             : // around this macro definition rather than each use).
   79327             : #ifndef ALLOC_MUTEX
   79328             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   79329             :         do {                                                                     \
   79330             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   79331             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   79332             :                 abort();                                                         \
   79333             :             }                                                                    \
   79334             :         } while (0);
   79335             : #endif
   79336             : 
   79337             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   79338             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   79339             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   79340             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   79341             : 
   79342             : /*! \brief New operator for SgTemplateFunctionDeclaration.
   79343             : 
   79344             :    This new operator implements memory pools to provide most efficent 
   79345             :    use of the heap within construction of large ASTs.
   79346             : 
   79347             : \internal The new and delete operators use the lower level C malloc/free
   79348             :    function calls for performance and to make sure that mixing of malloc/free
   79349             :    and new/delete by the used can be caught more readily.  This may change
   79350             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   79351             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   79352             :    deallocate memory allocated using ROSE_MALLOC.
   79353             : */
   79354        7610 : void *SgTemplateFunctionDeclaration::operator new ( size_t Size )
   79355             : {
   79356             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   79357             :      * returning or throwing an exception. */
   79358        7610 :     ALLOC_MUTEX(SgTemplateFunctionDeclaration, lock);
   79359             : 
   79360             : #if ROSE_ALLOC_TRACE == 2
   79361             : //    printf("SgTemplateFunctionDeclaration::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgTemplateFunctionDeclaration::next_node);
   79362             : #endif
   79363             : 
   79364             : #if USE_CPP_NEW_DELETE_OPERATORS
   79365             :     void *mem = ROSE_MALLOC(Size);
   79366             :     ALLOC_MUTEX(SgTemplateFunctionDeclaration, unlock);
   79367             :     return mem;
   79368             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   79369             : #if ROSE_PEDANTIC_ALLOC
   79370             :     ROSE_ASSERT(Size == sizeof(SgTemplateFunctionDeclaration));
   79371             : #else
   79372        7610 :     if (Size != sizeof(SgTemplateFunctionDeclaration)) {
   79373           0 :       void * object = ROSE_MALLOC(Size);
   79374           0 :       ALLOC_MUTEX(SgTemplateFunctionDeclaration, unlock);
   79375             :       return object;
   79376             :     }
   79377             : #endif
   79378             : 
   79379        7610 :     if (SgTemplateFunctionDeclaration::next_node == nullptr) {
   79380          10 :         SgTemplateFunctionDeclaration * alloc = (SgTemplateFunctionDeclaration*) ROSE_MALLOC ( SgTemplateFunctionDeclaration::pool_size * sizeof(SgTemplateFunctionDeclaration) );
   79381          10 :         ROSE_ASSERT(alloc != nullptr);
   79382             : 
   79383             : #if ROSE_ALLOC_TRACE == 2
   79384             : //        printf("SgTemplateFunctionDeclaration::alloc\n  block[%zi] = [ %p , %p [\n", SgTemplateFunctionDeclaration::pools.size(), alloc, alloc + SgTemplateFunctionDeclaration::pool_size);
   79385             : #endif
   79386             : 
   79387             : #if ROSE_ALLOC_MEMSET == 1
   79388             : #elif ROSE_ALLOC_MEMSET == 2
   79389             :         memset(alloc, 0x00, SgTemplateFunctionDeclaration::pool_size * sizeof(SgTemplateFunctionDeclaration));
   79390             : #elif ROSE_ALLOC_MEMSET == 3
   79391             :         memset(alloc, 0xAA, SgTemplateFunctionDeclaration::pool_size * sizeof(SgTemplateFunctionDeclaration));
   79392             : #endif
   79393       20000 :         for (unsigned i=0; i < SgTemplateFunctionDeclaration::pool_size-1; i++) {
   79394       19990 :           alloc[i].p_freepointer = &(alloc[i+1]);
   79395             :         }
   79396          10 :         alloc[SgTemplateFunctionDeclaration::pool_size-1].p_freepointer = nullptr;
   79397             : 
   79398          10 :         SgTemplateFunctionDeclaration::pools.push_back ( (unsigned char *) alloc );
   79399          10 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgTemplateFunctionDeclaration::pool_size * sizeof(SgTemplateFunctionDeclaration), V_SgTemplateFunctionDeclaration ) );
   79400          10 :         SgTemplateFunctionDeclaration::next_node = alloc;
   79401             :     }
   79402        7610 :     ROSE_ASSERT(SgTemplateFunctionDeclaration::next_node != nullptr);
   79403             : 
   79404        7610 :     SgTemplateFunctionDeclaration * object = SgTemplateFunctionDeclaration::next_node;
   79405        7610 :     SgTemplateFunctionDeclaration::next_node = (SgTemplateFunctionDeclaration*)(object->p_freepointer);
   79406             : 
   79407             : #if ROSE_ALLOC_TRACE == 2
   79408             :     printf("SgTemplateFunctionDeclaration::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTemplateFunctionDeclaration::next_node);
   79409             : #endif
   79410             : 
   79411        7610 :     SgNode * fp = object->p_freepointer;
   79412             : #if ROSE_ALLOC_MEMSET == 1
   79413             : #elif ROSE_ALLOC_MEMSET == 2
   79414             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgTemplateFunctionDeclaration) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   79415             : #elif ROSE_ALLOC_MEMSET == 3
   79416             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgTemplateFunctionDeclaration) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   79417             : #endif
   79418        7610 :     object->p_freepointer = fp;
   79419             : 
   79420             : #if ROSE_ALLOC_TRACE == 2
   79421             : //    printf("SgTemplateFunctionDeclaration::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTemplateFunctionDeclaration::next_node);
   79422             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   79423             :     Rose::MemPool::snapshot(oss.str());
   79424             :     alloc_trace_cnt++;
   79425             : #endif
   79426             : 
   79427        7610 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   79428             : 
   79429        7610 :     ALLOC_MUTEX(SgTemplateFunctionDeclaration, unlock);
   79430             : 
   79431             :     return object;
   79432             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   79433             : }
   79434             : 
   79435             : 
   79436             : 
   79437             : /*! \brief Delete operator for SgTemplateFunctionDeclaration.
   79438             : 
   79439             :    This delete operator implements deallocation using memory pools to 
   79440             :    provide most efficent use of the heap within construction of large ASTs.
   79441             : 
   79442             : \internal The new and delete operators use the lower level C malloc/free
   79443             :    function calls for performance and to make sure that mixing of malloc/free
   79444             :    and new/delete by the used can be caught more readily.  This may change
   79445             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   79446             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   79447             :    deallocate memory allocated using ROSE_MALLOC.
   79448             : */
   79449        1352 : void SgTemplateFunctionDeclaration::operator delete(void *Pointer, size_t Size)
   79450             : {
   79451             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   79452             :      * or throwing an exception. */
   79453        1352 :     ALLOC_MUTEX(SgTemplateFunctionDeclaration, lock);
   79454             : 
   79455             : #if USE_CPP_NEW_DELETE_OPERATORS
   79456             :     ROSE_FREE(Pointer);
   79457             : #else
   79458             : #if ROSE_PEDANTIC_ALLOC
   79459             :     ROSE_ASSERT(Size == sizeof(SgTemplateFunctionDeclaration));
   79460             : #else
   79461        1352 :     if (Size != sizeof(SgTemplateFunctionDeclaration)) {
   79462           0 :       ROSE_FREE(Pointer);
   79463           0 :       ALLOC_MUTEX(SgTemplateFunctionDeclaration, unlock);
   79464             :       return;
   79465             :     }
   79466             : #endif
   79467             : 
   79468        1352 :     SgTemplateFunctionDeclaration * object = (SgTemplateFunctionDeclaration*) Pointer;
   79469        1352 :     ROSE_ASSERT(object != nullptr);
   79470             : 
   79471             : #if ROSE_ALLOC_TRACE == 2
   79472             : //  printf("SgTemplateFunctionDeclaration::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTemplateFunctionDeclaration::next_node);
   79473             :     printf("SgTemplateFunctionDeclaration::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTemplateFunctionDeclaration::next_node);
   79474             : #endif
   79475             : 
   79476             : #if ROSE_PEDANTIC_ALLOC
   79477             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   79478             : #endif
   79479             : 
   79480             : #if ROSE_ALLOC_MEMSET == 1
   79481             : #elif ROSE_ALLOC_MEMSET == 2
   79482             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgTemplateFunctionDeclaration) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   79483             : #elif ROSE_ALLOC_MEMSET == 3
   79484             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgTemplateFunctionDeclaration) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   79485             : #endif
   79486             : 
   79487             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   79488             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   79489             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   79490             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   79491             : #else
   79492        1352 :     object->p_freepointer = SgTemplateFunctionDeclaration::next_node;
   79493        1352 :     SgTemplateFunctionDeclaration::next_node = object;
   79494             : #endif
   79495             : 
   79496             : #if ROSE_ALLOC_TRACE == 2
   79497             : //  printf("SgTemplateFunctionDeclaration::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTemplateFunctionDeclaration::next_node);
   79498             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   79499             :     Rose::MemPool::snapshot(oss.str());
   79500             :     alloc_trace_cnt++;
   79501             : #endif
   79502             : 
   79503             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   79504             : 
   79505        1352 :     ALLOC_MUTEX(SgTemplateFunctionDeclaration, unlock);
   79506             : }
   79507             : 
   79508             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   79509             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   79510             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   79511             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   79512             : // Also, note comment below from Robb (copied from the Common.code file).
   79513             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   79514             : //
   79515             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   79516             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   79517             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   79518             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   79519             : #if 0
   79520             : void SgTemplateFunctionDeclaration::operator delete(void* pointer) { SgTemplateFunctionDeclaration::operator delete (pointer, sizeof(SgTemplateFunctionDeclaration)); };
   79521             : #endif
   79522             : /* #line 79523 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   79523             : 
   79524             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   79525             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   79526             : // obviously imply C++.
   79527             : 
   79528             : // This implements the support within ROSE for memory pools.  Memory pools
   79529             : // support the most condensed usage of memory within the construction of
   79530             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   79531             : // by a new operator written for each class.
   79532             : 
   79533             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   79534             :     // User wants multi-thread support and POSIX threads are available.
   79535             : #   include <pthread.h>
   79536             :     static pthread_mutex_t SgMemberFunctionDeclaration_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   79537             : #else
   79538             :      // Cause synchronization to be skipped.
   79539             : #    ifndef ALLOC_MUTEX
   79540             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   79541             : #    endif
   79542             : #    ifdef _REENTRANT
   79543             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   79544             : #       ifdef _MSC_VER
   79545             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   79546             : #       else
   79547             : #           warning "POSIX threads are not available; synchronization being skipped"
   79548             : #       endif
   79549             : #    endif
   79550             : #endif
   79551             : 
   79552             : #ifndef ROSE_ALLOC_TRACE
   79553             : #  define ROSE_ALLOC_TRACE 0
   79554             : #endif
   79555             : 
   79556             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   79557             : #define ROSE_ALLOC_TRACE_CNT
   79558             : #include "memory-pool-snapshot.h"
   79559             : unsigned long alloc_trace_cnt = 0;
   79560             : #endif
   79561             : 
   79562             : #if ROSE_ALLOC_TRACE
   79563             : const unsigned SgMemberFunctionDeclaration::pool_size = 5;
   79564             : #else
   79565             : const unsigned SgMemberFunctionDeclaration::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   79566             : #endif
   79567             : 
   79568             : #ifndef ROSE_ALLOC_MEMSET
   79569             : #  define ROSE_ALLOC_MEMSET 0
   79570             : #endif
   79571             : 
   79572             : #ifndef ROSE_PEDANTIC_ALLOC
   79573             : #  define ROSE_PEDANTIC_ALLOC 0
   79574             : #endif
   79575             : 
   79576             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   79577             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   79578             : #endif
   79579             : 
   79580             : #if !defined(SGNODE__ALL_POOLS)
   79581             : #define SGNODE__ALL_POOLS
   79582             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   79583             : #endif
   79584             : 
   79585             : SgMemberFunctionDeclaration* SgMemberFunctionDeclaration::next_node = nullptr;
   79586             : std::vector<unsigned char*> SgMemberFunctionDeclaration::pools;
   79587             : 
   79588             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   79589             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   79590             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   79591             : // around this macro definition rather than each use).
   79592             : #ifndef ALLOC_MUTEX
   79593             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   79594             :         do {                                                                     \
   79595             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   79596             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   79597             :                 abort();                                                         \
   79598             :             }                                                                    \
   79599             :         } while (0);
   79600             : #endif
   79601             : 
   79602             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   79603             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   79604             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   79605             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   79606             : 
   79607             : /*! \brief New operator for SgMemberFunctionDeclaration.
   79608             : 
   79609             :    This new operator implements memory pools to provide most efficent 
   79610             :    use of the heap within construction of large ASTs.
   79611             : 
   79612             : \internal The new and delete operators use the lower level C malloc/free
   79613             :    function calls for performance and to make sure that mixing of malloc/free
   79614             :    and new/delete by the used can be caught more readily.  This may change
   79615             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   79616             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   79617             :    deallocate memory allocated using ROSE_MALLOC.
   79618             : */
   79619        7735 : void *SgMemberFunctionDeclaration::operator new ( size_t Size )
   79620             : {
   79621             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   79622             :      * returning or throwing an exception. */
   79623        7735 :     ALLOC_MUTEX(SgMemberFunctionDeclaration, lock);
   79624             : 
   79625             : #if ROSE_ALLOC_TRACE == 2
   79626             : //    printf("SgMemberFunctionDeclaration::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgMemberFunctionDeclaration::next_node);
   79627             : #endif
   79628             : 
   79629             : #if USE_CPP_NEW_DELETE_OPERATORS
   79630             :     void *mem = ROSE_MALLOC(Size);
   79631             :     ALLOC_MUTEX(SgMemberFunctionDeclaration, unlock);
   79632             :     return mem;
   79633             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   79634             : #if ROSE_PEDANTIC_ALLOC
   79635             :     ROSE_ASSERT(Size == sizeof(SgMemberFunctionDeclaration));
   79636             : #else
   79637        7735 :     if (Size != sizeof(SgMemberFunctionDeclaration)) {
   79638           0 :       void * object = ROSE_MALLOC(Size);
   79639           0 :       ALLOC_MUTEX(SgMemberFunctionDeclaration, unlock);
   79640             :       return object;
   79641             :     }
   79642             : #endif
   79643             : 
   79644        7735 :     if (SgMemberFunctionDeclaration::next_node == nullptr) {
   79645          16 :         SgMemberFunctionDeclaration * alloc = (SgMemberFunctionDeclaration*) ROSE_MALLOC ( SgMemberFunctionDeclaration::pool_size * sizeof(SgMemberFunctionDeclaration) );
   79646          16 :         ROSE_ASSERT(alloc != nullptr);
   79647             : 
   79648             : #if ROSE_ALLOC_TRACE == 2
   79649             : //        printf("SgMemberFunctionDeclaration::alloc\n  block[%zi] = [ %p , %p [\n", SgMemberFunctionDeclaration::pools.size(), alloc, alloc + SgMemberFunctionDeclaration::pool_size);
   79650             : #endif
   79651             : 
   79652             : #if ROSE_ALLOC_MEMSET == 1
   79653             : #elif ROSE_ALLOC_MEMSET == 2
   79654             :         memset(alloc, 0x00, SgMemberFunctionDeclaration::pool_size * sizeof(SgMemberFunctionDeclaration));
   79655             : #elif ROSE_ALLOC_MEMSET == 3
   79656             :         memset(alloc, 0xAA, SgMemberFunctionDeclaration::pool_size * sizeof(SgMemberFunctionDeclaration));
   79657             : #endif
   79658       32000 :         for (unsigned i=0; i < SgMemberFunctionDeclaration::pool_size-1; i++) {
   79659       31984 :           alloc[i].p_freepointer = &(alloc[i+1]);
   79660             :         }
   79661          16 :         alloc[SgMemberFunctionDeclaration::pool_size-1].p_freepointer = nullptr;
   79662             : 
   79663          16 :         SgMemberFunctionDeclaration::pools.push_back ( (unsigned char *) alloc );
   79664          16 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgMemberFunctionDeclaration::pool_size * sizeof(SgMemberFunctionDeclaration), V_SgMemberFunctionDeclaration ) );
   79665          16 :         SgMemberFunctionDeclaration::next_node = alloc;
   79666             :     }
   79667        7735 :     ROSE_ASSERT(SgMemberFunctionDeclaration::next_node != nullptr);
   79668             : 
   79669        7735 :     SgMemberFunctionDeclaration * object = SgMemberFunctionDeclaration::next_node;
   79670        7735 :     SgMemberFunctionDeclaration::next_node = (SgMemberFunctionDeclaration*)(object->p_freepointer);
   79671             : 
   79672             : #if ROSE_ALLOC_TRACE == 2
   79673             :     printf("SgMemberFunctionDeclaration::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgMemberFunctionDeclaration::next_node);
   79674             : #endif
   79675             : 
   79676        7735 :     SgNode * fp = object->p_freepointer;
   79677             : #if ROSE_ALLOC_MEMSET == 1
   79678             : #elif ROSE_ALLOC_MEMSET == 2
   79679             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgMemberFunctionDeclaration) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   79680             : #elif ROSE_ALLOC_MEMSET == 3
   79681             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgMemberFunctionDeclaration) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   79682             : #endif
   79683        7735 :     object->p_freepointer = fp;
   79684             : 
   79685             : #if ROSE_ALLOC_TRACE == 2
   79686             : //    printf("SgMemberFunctionDeclaration::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgMemberFunctionDeclaration::next_node);
   79687             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   79688             :     Rose::MemPool::snapshot(oss.str());
   79689             :     alloc_trace_cnt++;
   79690             : #endif
   79691             : 
   79692        7735 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   79693             : 
   79694        7735 :     ALLOC_MUTEX(SgMemberFunctionDeclaration, unlock);
   79695             : 
   79696             :     return object;
   79697             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   79698             : }
   79699             : 
   79700             : 
   79701             : 
   79702             : /*! \brief Delete operator for SgMemberFunctionDeclaration.
   79703             : 
   79704             :    This delete operator implements deallocation using memory pools to 
   79705             :    provide most efficent use of the heap within construction of large ASTs.
   79706             : 
   79707             : \internal The new and delete operators use the lower level C malloc/free
   79708             :    function calls for performance and to make sure that mixing of malloc/free
   79709             :    and new/delete by the used can be caught more readily.  This may change
   79710             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   79711             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   79712             :    deallocate memory allocated using ROSE_MALLOC.
   79713             : */
   79714        1568 : void SgMemberFunctionDeclaration::operator delete(void *Pointer, size_t Size)
   79715             : {
   79716             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   79717             :      * or throwing an exception. */
   79718        1568 :     ALLOC_MUTEX(SgMemberFunctionDeclaration, lock);
   79719             : 
   79720             : #if USE_CPP_NEW_DELETE_OPERATORS
   79721             :     ROSE_FREE(Pointer);
   79722             : #else
   79723             : #if ROSE_PEDANTIC_ALLOC
   79724             :     ROSE_ASSERT(Size == sizeof(SgMemberFunctionDeclaration));
   79725             : #else
   79726        1568 :     if (Size != sizeof(SgMemberFunctionDeclaration)) {
   79727           0 :       ROSE_FREE(Pointer);
   79728           0 :       ALLOC_MUTEX(SgMemberFunctionDeclaration, unlock);
   79729             :       return;
   79730             :     }
   79731             : #endif
   79732             : 
   79733        1568 :     SgMemberFunctionDeclaration * object = (SgMemberFunctionDeclaration*) Pointer;
   79734        1568 :     ROSE_ASSERT(object != nullptr);
   79735             : 
   79736             : #if ROSE_ALLOC_TRACE == 2
   79737             : //  printf("SgMemberFunctionDeclaration::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgMemberFunctionDeclaration::next_node);
   79738             :     printf("SgMemberFunctionDeclaration::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgMemberFunctionDeclaration::next_node);
   79739             : #endif
   79740             : 
   79741             : #if ROSE_PEDANTIC_ALLOC
   79742             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   79743             : #endif
   79744             : 
   79745             : #if ROSE_ALLOC_MEMSET == 1
   79746             : #elif ROSE_ALLOC_MEMSET == 2
   79747             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgMemberFunctionDeclaration) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   79748             : #elif ROSE_ALLOC_MEMSET == 3
   79749             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgMemberFunctionDeclaration) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   79750             : #endif
   79751             : 
   79752             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   79753             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   79754             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   79755             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   79756             : #else
   79757        1568 :     object->p_freepointer = SgMemberFunctionDeclaration::next_node;
   79758        1568 :     SgMemberFunctionDeclaration::next_node = object;
   79759             : #endif
   79760             : 
   79761             : #if ROSE_ALLOC_TRACE == 2
   79762             : //  printf("SgMemberFunctionDeclaration::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgMemberFunctionDeclaration::next_node);
   79763             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   79764             :     Rose::MemPool::snapshot(oss.str());
   79765             :     alloc_trace_cnt++;
   79766             : #endif
   79767             : 
   79768             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   79769             : 
   79770        1568 :     ALLOC_MUTEX(SgMemberFunctionDeclaration, unlock);
   79771             : }
   79772             : 
   79773             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   79774             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   79775             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   79776             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   79777             : // Also, note comment below from Robb (copied from the Common.code file).
   79778             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   79779             : //
   79780             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   79781             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   79782             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   79783             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   79784             : #if 0
   79785             : void SgMemberFunctionDeclaration::operator delete(void* pointer) { SgMemberFunctionDeclaration::operator delete (pointer, sizeof(SgMemberFunctionDeclaration)); };
   79786             : #endif
   79787             : /* #line 79788 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   79788             : 
   79789             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   79790             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   79791             : // obviously imply C++.
   79792             : 
   79793             : // This implements the support within ROSE for memory pools.  Memory pools
   79794             : // support the most condensed usage of memory within the construction of
   79795             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   79796             : // by a new operator written for each class.
   79797             : 
   79798             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   79799             :     // User wants multi-thread support and POSIX threads are available.
   79800             : #   include <pthread.h>
   79801             :     static pthread_mutex_t SgTemplateMemberFunctionDeclaration_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   79802             : #else
   79803             :      // Cause synchronization to be skipped.
   79804             : #    ifndef ALLOC_MUTEX
   79805             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   79806             : #    endif
   79807             : #    ifdef _REENTRANT
   79808             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   79809             : #       ifdef _MSC_VER
   79810             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   79811             : #       else
   79812             : #           warning "POSIX threads are not available; synchronization being skipped"
   79813             : #       endif
   79814             : #    endif
   79815             : #endif
   79816             : 
   79817             : #ifndef ROSE_ALLOC_TRACE
   79818             : #  define ROSE_ALLOC_TRACE 0
   79819             : #endif
   79820             : 
   79821             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   79822             : #define ROSE_ALLOC_TRACE_CNT
   79823             : #include "memory-pool-snapshot.h"
   79824             : unsigned long alloc_trace_cnt = 0;
   79825             : #endif
   79826             : 
   79827             : #if ROSE_ALLOC_TRACE
   79828             : const unsigned SgTemplateMemberFunctionDeclaration::pool_size = 5;
   79829             : #else
   79830             : const unsigned SgTemplateMemberFunctionDeclaration::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   79831             : #endif
   79832             : 
   79833             : #ifndef ROSE_ALLOC_MEMSET
   79834             : #  define ROSE_ALLOC_MEMSET 0
   79835             : #endif
   79836             : 
   79837             : #ifndef ROSE_PEDANTIC_ALLOC
   79838             : #  define ROSE_PEDANTIC_ALLOC 0
   79839             : #endif
   79840             : 
   79841             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   79842             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   79843             : #endif
   79844             : 
   79845             : #if !defined(SGNODE__ALL_POOLS)
   79846             : #define SGNODE__ALL_POOLS
   79847             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   79848             : #endif
   79849             : 
   79850             : SgTemplateMemberFunctionDeclaration* SgTemplateMemberFunctionDeclaration::next_node = nullptr;
   79851             : std::vector<unsigned char*> SgTemplateMemberFunctionDeclaration::pools;
   79852             : 
   79853             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   79854             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   79855             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   79856             : // around this macro definition rather than each use).
   79857             : #ifndef ALLOC_MUTEX
   79858             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   79859             :         do {                                                                     \
   79860             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   79861             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   79862             :                 abort();                                                         \
   79863             :             }                                                                    \
   79864             :         } while (0);
   79865             : #endif
   79866             : 
   79867             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   79868             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   79869             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   79870             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   79871             : 
   79872             : /*! \brief New operator for SgTemplateMemberFunctionDeclaration.
   79873             : 
   79874             :    This new operator implements memory pools to provide most efficent 
   79875             :    use of the heap within construction of large ASTs.
   79876             : 
   79877             : \internal The new and delete operators use the lower level C malloc/free
   79878             :    function calls for performance and to make sure that mixing of malloc/free
   79879             :    and new/delete by the used can be caught more readily.  This may change
   79880             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   79881             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   79882             :    deallocate memory allocated using ROSE_MALLOC.
   79883             : */
   79884       19841 : void *SgTemplateMemberFunctionDeclaration::operator new ( size_t Size )
   79885             : {
   79886             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   79887             :      * returning or throwing an exception. */
   79888       19841 :     ALLOC_MUTEX(SgTemplateMemberFunctionDeclaration, lock);
   79889             : 
   79890             : #if ROSE_ALLOC_TRACE == 2
   79891             : //    printf("SgTemplateMemberFunctionDeclaration::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgTemplateMemberFunctionDeclaration::next_node);
   79892             : #endif
   79893             : 
   79894             : #if USE_CPP_NEW_DELETE_OPERATORS
   79895             :     void *mem = ROSE_MALLOC(Size);
   79896             :     ALLOC_MUTEX(SgTemplateMemberFunctionDeclaration, unlock);
   79897             :     return mem;
   79898             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   79899             : #if ROSE_PEDANTIC_ALLOC
   79900             :     ROSE_ASSERT(Size == sizeof(SgTemplateMemberFunctionDeclaration));
   79901             : #else
   79902       19841 :     if (Size != sizeof(SgTemplateMemberFunctionDeclaration)) {
   79903           0 :       void * object = ROSE_MALLOC(Size);
   79904           0 :       ALLOC_MUTEX(SgTemplateMemberFunctionDeclaration, unlock);
   79905             :       return object;
   79906             :     }
   79907             : #endif
   79908             : 
   79909       19841 :     if (SgTemplateMemberFunctionDeclaration::next_node == nullptr) {
   79910          12 :         SgTemplateMemberFunctionDeclaration * alloc = (SgTemplateMemberFunctionDeclaration*) ROSE_MALLOC ( SgTemplateMemberFunctionDeclaration::pool_size * sizeof(SgTemplateMemberFunctionDeclaration) );
   79911          12 :         ROSE_ASSERT(alloc != nullptr);
   79912             : 
   79913             : #if ROSE_ALLOC_TRACE == 2
   79914             : //        printf("SgTemplateMemberFunctionDeclaration::alloc\n  block[%zi] = [ %p , %p [\n", SgTemplateMemberFunctionDeclaration::pools.size(), alloc, alloc + SgTemplateMemberFunctionDeclaration::pool_size);
   79915             : #endif
   79916             : 
   79917             : #if ROSE_ALLOC_MEMSET == 1
   79918             : #elif ROSE_ALLOC_MEMSET == 2
   79919             :         memset(alloc, 0x00, SgTemplateMemberFunctionDeclaration::pool_size * sizeof(SgTemplateMemberFunctionDeclaration));
   79920             : #elif ROSE_ALLOC_MEMSET == 3
   79921             :         memset(alloc, 0xAA, SgTemplateMemberFunctionDeclaration::pool_size * sizeof(SgTemplateMemberFunctionDeclaration));
   79922             : #endif
   79923       24000 :         for (unsigned i=0; i < SgTemplateMemberFunctionDeclaration::pool_size-1; i++) {
   79924       23988 :           alloc[i].p_freepointer = &(alloc[i+1]);
   79925             :         }
   79926          12 :         alloc[SgTemplateMemberFunctionDeclaration::pool_size-1].p_freepointer = nullptr;
   79927             : 
   79928          12 :         SgTemplateMemberFunctionDeclaration::pools.push_back ( (unsigned char *) alloc );
   79929          12 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgTemplateMemberFunctionDeclaration::pool_size * sizeof(SgTemplateMemberFunctionDeclaration), V_SgTemplateMemberFunctionDeclaration ) );
   79930          12 :         SgTemplateMemberFunctionDeclaration::next_node = alloc;
   79931             :     }
   79932       19841 :     ROSE_ASSERT(SgTemplateMemberFunctionDeclaration::next_node != nullptr);
   79933             : 
   79934       19841 :     SgTemplateMemberFunctionDeclaration * object = SgTemplateMemberFunctionDeclaration::next_node;
   79935       19841 :     SgTemplateMemberFunctionDeclaration::next_node = (SgTemplateMemberFunctionDeclaration*)(object->p_freepointer);
   79936             : 
   79937             : #if ROSE_ALLOC_TRACE == 2
   79938             :     printf("SgTemplateMemberFunctionDeclaration::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTemplateMemberFunctionDeclaration::next_node);
   79939             : #endif
   79940             : 
   79941       19841 :     SgNode * fp = object->p_freepointer;
   79942             : #if ROSE_ALLOC_MEMSET == 1
   79943             : #elif ROSE_ALLOC_MEMSET == 2
   79944             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgTemplateMemberFunctionDeclaration) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   79945             : #elif ROSE_ALLOC_MEMSET == 3
   79946             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgTemplateMemberFunctionDeclaration) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   79947             : #endif
   79948       19841 :     object->p_freepointer = fp;
   79949             : 
   79950             : #if ROSE_ALLOC_TRACE == 2
   79951             : //    printf("SgTemplateMemberFunctionDeclaration::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTemplateMemberFunctionDeclaration::next_node);
   79952             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   79953             :     Rose::MemPool::snapshot(oss.str());
   79954             :     alloc_trace_cnt++;
   79955             : #endif
   79956             : 
   79957       19841 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   79958             : 
   79959       19841 :     ALLOC_MUTEX(SgTemplateMemberFunctionDeclaration, unlock);
   79960             : 
   79961             :     return object;
   79962             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   79963             : }
   79964             : 
   79965             : 
   79966             : 
   79967             : /*! \brief Delete operator for SgTemplateMemberFunctionDeclaration.
   79968             : 
   79969             :    This delete operator implements deallocation using memory pools to 
   79970             :    provide most efficent use of the heap within construction of large ASTs.
   79971             : 
   79972             : \internal The new and delete operators use the lower level C malloc/free
   79973             :    function calls for performance and to make sure that mixing of malloc/free
   79974             :    and new/delete by the used can be caught more readily.  This may change
   79975             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   79976             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   79977             :    deallocate memory allocated using ROSE_MALLOC.
   79978             : */
   79979        3810 : void SgTemplateMemberFunctionDeclaration::operator delete(void *Pointer, size_t Size)
   79980             : {
   79981             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   79982             :      * or throwing an exception. */
   79983        3810 :     ALLOC_MUTEX(SgTemplateMemberFunctionDeclaration, lock);
   79984             : 
   79985             : #if USE_CPP_NEW_DELETE_OPERATORS
   79986             :     ROSE_FREE(Pointer);
   79987             : #else
   79988             : #if ROSE_PEDANTIC_ALLOC
   79989             :     ROSE_ASSERT(Size == sizeof(SgTemplateMemberFunctionDeclaration));
   79990             : #else
   79991        3810 :     if (Size != sizeof(SgTemplateMemberFunctionDeclaration)) {
   79992           0 :       ROSE_FREE(Pointer);
   79993           0 :       ALLOC_MUTEX(SgTemplateMemberFunctionDeclaration, unlock);
   79994             :       return;
   79995             :     }
   79996             : #endif
   79997             : 
   79998        3810 :     SgTemplateMemberFunctionDeclaration * object = (SgTemplateMemberFunctionDeclaration*) Pointer;
   79999        3810 :     ROSE_ASSERT(object != nullptr);
   80000             : 
   80001             : #if ROSE_ALLOC_TRACE == 2
   80002             : //  printf("SgTemplateMemberFunctionDeclaration::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTemplateMemberFunctionDeclaration::next_node);
   80003             :     printf("SgTemplateMemberFunctionDeclaration::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTemplateMemberFunctionDeclaration::next_node);
   80004             : #endif
   80005             : 
   80006             : #if ROSE_PEDANTIC_ALLOC
   80007             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   80008             : #endif
   80009             : 
   80010             : #if ROSE_ALLOC_MEMSET == 1
   80011             : #elif ROSE_ALLOC_MEMSET == 2
   80012             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgTemplateMemberFunctionDeclaration) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   80013             : #elif ROSE_ALLOC_MEMSET == 3
   80014             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgTemplateMemberFunctionDeclaration) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   80015             : #endif
   80016             : 
   80017             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   80018             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   80019             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   80020             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   80021             : #else
   80022        3810 :     object->p_freepointer = SgTemplateMemberFunctionDeclaration::next_node;
   80023        3810 :     SgTemplateMemberFunctionDeclaration::next_node = object;
   80024             : #endif
   80025             : 
   80026             : #if ROSE_ALLOC_TRACE == 2
   80027             : //  printf("SgTemplateMemberFunctionDeclaration::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTemplateMemberFunctionDeclaration::next_node);
   80028             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   80029             :     Rose::MemPool::snapshot(oss.str());
   80030             :     alloc_trace_cnt++;
   80031             : #endif
   80032             : 
   80033             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   80034             : 
   80035        3810 :     ALLOC_MUTEX(SgTemplateMemberFunctionDeclaration, unlock);
   80036             : }
   80037             : 
   80038             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   80039             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   80040             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   80041             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   80042             : // Also, note comment below from Robb (copied from the Common.code file).
   80043             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   80044             : //
   80045             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   80046             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   80047             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   80048             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   80049             : #if 0
   80050             : void SgTemplateMemberFunctionDeclaration::operator delete(void* pointer) { SgTemplateMemberFunctionDeclaration::operator delete (pointer, sizeof(SgTemplateMemberFunctionDeclaration)); };
   80051             : #endif
   80052             : /* #line 80053 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   80053             : 
   80054             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   80055             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   80056             : // obviously imply C++.
   80057             : 
   80058             : // This implements the support within ROSE for memory pools.  Memory pools
   80059             : // support the most condensed usage of memory within the construction of
   80060             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   80061             : // by a new operator written for each class.
   80062             : 
   80063             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   80064             :     // User wants multi-thread support and POSIX threads are available.
   80065             : #   include <pthread.h>
   80066             :     static pthread_mutex_t SgTemplateInstantiationMemberFunctionDecl_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   80067             : #else
   80068             :      // Cause synchronization to be skipped.
   80069             : #    ifndef ALLOC_MUTEX
   80070             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   80071             : #    endif
   80072             : #    ifdef _REENTRANT
   80073             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   80074             : #       ifdef _MSC_VER
   80075             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   80076             : #       else
   80077             : #           warning "POSIX threads are not available; synchronization being skipped"
   80078             : #       endif
   80079             : #    endif
   80080             : #endif
   80081             : 
   80082             : #ifndef ROSE_ALLOC_TRACE
   80083             : #  define ROSE_ALLOC_TRACE 0
   80084             : #endif
   80085             : 
   80086             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   80087             : #define ROSE_ALLOC_TRACE_CNT
   80088             : #include "memory-pool-snapshot.h"
   80089             : unsigned long alloc_trace_cnt = 0;
   80090             : #endif
   80091             : 
   80092             : #if ROSE_ALLOC_TRACE
   80093             : const unsigned SgTemplateInstantiationMemberFunctionDecl::pool_size = 5;
   80094             : #else
   80095             : const unsigned SgTemplateInstantiationMemberFunctionDecl::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   80096             : #endif
   80097             : 
   80098             : #ifndef ROSE_ALLOC_MEMSET
   80099             : #  define ROSE_ALLOC_MEMSET 0
   80100             : #endif
   80101             : 
   80102             : #ifndef ROSE_PEDANTIC_ALLOC
   80103             : #  define ROSE_PEDANTIC_ALLOC 0
   80104             : #endif
   80105             : 
   80106             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   80107             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   80108             : #endif
   80109             : 
   80110             : #if !defined(SGNODE__ALL_POOLS)
   80111             : #define SGNODE__ALL_POOLS
   80112             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   80113             : #endif
   80114             : 
   80115             : SgTemplateInstantiationMemberFunctionDecl* SgTemplateInstantiationMemberFunctionDecl::next_node = nullptr;
   80116             : std::vector<unsigned char*> SgTemplateInstantiationMemberFunctionDecl::pools;
   80117             : 
   80118             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   80119             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   80120             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   80121             : // around this macro definition rather than each use).
   80122             : #ifndef ALLOC_MUTEX
   80123             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   80124             :         do {                                                                     \
   80125             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   80126             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   80127             :                 abort();                                                         \
   80128             :             }                                                                    \
   80129             :         } while (0);
   80130             : #endif
   80131             : 
   80132             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   80133             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   80134             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   80135             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   80136             : 
   80137             : /*! \brief New operator for SgTemplateInstantiationMemberFunctionDecl.
   80138             : 
   80139             :    This new operator implements memory pools to provide most efficent 
   80140             :    use of the heap within construction of large ASTs.
   80141             : 
   80142             : \internal The new and delete operators use the lower level C malloc/free
   80143             :    function calls for performance and to make sure that mixing of malloc/free
   80144             :    and new/delete by the used can be caught more readily.  This may change
   80145             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   80146             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   80147             :    deallocate memory allocated using ROSE_MALLOC.
   80148             : */
   80149       16126 : void *SgTemplateInstantiationMemberFunctionDecl::operator new ( size_t Size )
   80150             : {
   80151             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   80152             :      * returning or throwing an exception. */
   80153       16126 :     ALLOC_MUTEX(SgTemplateInstantiationMemberFunctionDecl, lock);
   80154             : 
   80155             : #if ROSE_ALLOC_TRACE == 2
   80156             : //    printf("SgTemplateInstantiationMemberFunctionDecl::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgTemplateInstantiationMemberFunctionDecl::next_node);
   80157             : #endif
   80158             : 
   80159             : #if USE_CPP_NEW_DELETE_OPERATORS
   80160             :     void *mem = ROSE_MALLOC(Size);
   80161             :     ALLOC_MUTEX(SgTemplateInstantiationMemberFunctionDecl, unlock);
   80162             :     return mem;
   80163             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   80164             : #if ROSE_PEDANTIC_ALLOC
   80165             :     ROSE_ASSERT(Size == sizeof(SgTemplateInstantiationMemberFunctionDecl));
   80166             : #else
   80167       16126 :     if (Size != sizeof(SgTemplateInstantiationMemberFunctionDecl)) {
   80168           0 :       void * object = ROSE_MALLOC(Size);
   80169           0 :       ALLOC_MUTEX(SgTemplateInstantiationMemberFunctionDecl, unlock);
   80170             :       return object;
   80171             :     }
   80172             : #endif
   80173             : 
   80174       16126 :     if (SgTemplateInstantiationMemberFunctionDecl::next_node == nullptr) {
   80175          10 :         SgTemplateInstantiationMemberFunctionDecl * alloc = (SgTemplateInstantiationMemberFunctionDecl*) ROSE_MALLOC ( SgTemplateInstantiationMemberFunctionDecl::pool_size * sizeof(SgTemplateInstantiationMemberFunctionDecl) );
   80176          10 :         ROSE_ASSERT(alloc != nullptr);
   80177             : 
   80178             : #if ROSE_ALLOC_TRACE == 2
   80179             : //        printf("SgTemplateInstantiationMemberFunctionDecl::alloc\n  block[%zi] = [ %p , %p [\n", SgTemplateInstantiationMemberFunctionDecl::pools.size(), alloc, alloc + SgTemplateInstantiationMemberFunctionDecl::pool_size);
   80180             : #endif
   80181             : 
   80182             : #if ROSE_ALLOC_MEMSET == 1
   80183             : #elif ROSE_ALLOC_MEMSET == 2
   80184             :         memset(alloc, 0x00, SgTemplateInstantiationMemberFunctionDecl::pool_size * sizeof(SgTemplateInstantiationMemberFunctionDecl));
   80185             : #elif ROSE_ALLOC_MEMSET == 3
   80186             :         memset(alloc, 0xAA, SgTemplateInstantiationMemberFunctionDecl::pool_size * sizeof(SgTemplateInstantiationMemberFunctionDecl));
   80187             : #endif
   80188       20000 :         for (unsigned i=0; i < SgTemplateInstantiationMemberFunctionDecl::pool_size-1; i++) {
   80189       19990 :           alloc[i].p_freepointer = &(alloc[i+1]);
   80190             :         }
   80191          10 :         alloc[SgTemplateInstantiationMemberFunctionDecl::pool_size-1].p_freepointer = nullptr;
   80192             : 
   80193          10 :         SgTemplateInstantiationMemberFunctionDecl::pools.push_back ( (unsigned char *) alloc );
   80194          10 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgTemplateInstantiationMemberFunctionDecl::pool_size * sizeof(SgTemplateInstantiationMemberFunctionDecl), V_SgTemplateInstantiationMemberFunctionDecl ) );
   80195          10 :         SgTemplateInstantiationMemberFunctionDecl::next_node = alloc;
   80196             :     }
   80197       16126 :     ROSE_ASSERT(SgTemplateInstantiationMemberFunctionDecl::next_node != nullptr);
   80198             : 
   80199       16126 :     SgTemplateInstantiationMemberFunctionDecl * object = SgTemplateInstantiationMemberFunctionDecl::next_node;
   80200       16126 :     SgTemplateInstantiationMemberFunctionDecl::next_node = (SgTemplateInstantiationMemberFunctionDecl*)(object->p_freepointer);
   80201             : 
   80202             : #if ROSE_ALLOC_TRACE == 2
   80203             :     printf("SgTemplateInstantiationMemberFunctionDecl::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTemplateInstantiationMemberFunctionDecl::next_node);
   80204             : #endif
   80205             : 
   80206       16126 :     SgNode * fp = object->p_freepointer;
   80207             : #if ROSE_ALLOC_MEMSET == 1
   80208             : #elif ROSE_ALLOC_MEMSET == 2
   80209             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgTemplateInstantiationMemberFunctionDecl) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   80210             : #elif ROSE_ALLOC_MEMSET == 3
   80211             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgTemplateInstantiationMemberFunctionDecl) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   80212             : #endif
   80213       16126 :     object->p_freepointer = fp;
   80214             : 
   80215             : #if ROSE_ALLOC_TRACE == 2
   80216             : //    printf("SgTemplateInstantiationMemberFunctionDecl::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTemplateInstantiationMemberFunctionDecl::next_node);
   80217             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   80218             :     Rose::MemPool::snapshot(oss.str());
   80219             :     alloc_trace_cnt++;
   80220             : #endif
   80221             : 
   80222       16126 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   80223             : 
   80224       16126 :     ALLOC_MUTEX(SgTemplateInstantiationMemberFunctionDecl, unlock);
   80225             : 
   80226             :     return object;
   80227             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   80228             : }
   80229             : 
   80230             : 
   80231             : 
   80232             : /*! \brief Delete operator for SgTemplateInstantiationMemberFunctionDecl.
   80233             : 
   80234             :    This delete operator implements deallocation using memory pools to 
   80235             :    provide most efficent use of the heap within construction of large ASTs.
   80236             : 
   80237             : \internal The new and delete operators use the lower level C malloc/free
   80238             :    function calls for performance and to make sure that mixing of malloc/free
   80239             :    and new/delete by the used can be caught more readily.  This may change
   80240             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   80241             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   80242             :    deallocate memory allocated using ROSE_MALLOC.
   80243             : */
   80244        3478 : void SgTemplateInstantiationMemberFunctionDecl::operator delete(void *Pointer, size_t Size)
   80245             : {
   80246             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   80247             :      * or throwing an exception. */
   80248        3478 :     ALLOC_MUTEX(SgTemplateInstantiationMemberFunctionDecl, lock);
   80249             : 
   80250             : #if USE_CPP_NEW_DELETE_OPERATORS
   80251             :     ROSE_FREE(Pointer);
   80252             : #else
   80253             : #if ROSE_PEDANTIC_ALLOC
   80254             :     ROSE_ASSERT(Size == sizeof(SgTemplateInstantiationMemberFunctionDecl));
   80255             : #else
   80256        3478 :     if (Size != sizeof(SgTemplateInstantiationMemberFunctionDecl)) {
   80257           0 :       ROSE_FREE(Pointer);
   80258           0 :       ALLOC_MUTEX(SgTemplateInstantiationMemberFunctionDecl, unlock);
   80259             :       return;
   80260             :     }
   80261             : #endif
   80262             : 
   80263        3478 :     SgTemplateInstantiationMemberFunctionDecl * object = (SgTemplateInstantiationMemberFunctionDecl*) Pointer;
   80264        3478 :     ROSE_ASSERT(object != nullptr);
   80265             : 
   80266             : #if ROSE_ALLOC_TRACE == 2
   80267             : //  printf("SgTemplateInstantiationMemberFunctionDecl::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTemplateInstantiationMemberFunctionDecl::next_node);
   80268             :     printf("SgTemplateInstantiationMemberFunctionDecl::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTemplateInstantiationMemberFunctionDecl::next_node);
   80269             : #endif
   80270             : 
   80271             : #if ROSE_PEDANTIC_ALLOC
   80272             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   80273             : #endif
   80274             : 
   80275             : #if ROSE_ALLOC_MEMSET == 1
   80276             : #elif ROSE_ALLOC_MEMSET == 2
   80277             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgTemplateInstantiationMemberFunctionDecl) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   80278             : #elif ROSE_ALLOC_MEMSET == 3
   80279             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgTemplateInstantiationMemberFunctionDecl) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   80280             : #endif
   80281             : 
   80282             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   80283             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   80284             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   80285             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   80286             : #else
   80287        3478 :     object->p_freepointer = SgTemplateInstantiationMemberFunctionDecl::next_node;
   80288        3478 :     SgTemplateInstantiationMemberFunctionDecl::next_node = object;
   80289             : #endif
   80290             : 
   80291             : #if ROSE_ALLOC_TRACE == 2
   80292             : //  printf("SgTemplateInstantiationMemberFunctionDecl::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTemplateInstantiationMemberFunctionDecl::next_node);
   80293             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   80294             :     Rose::MemPool::snapshot(oss.str());
   80295             :     alloc_trace_cnt++;
   80296             : #endif
   80297             : 
   80298             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   80299             : 
   80300        3478 :     ALLOC_MUTEX(SgTemplateInstantiationMemberFunctionDecl, unlock);
   80301             : }
   80302             : 
   80303             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   80304             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   80305             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   80306             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   80307             : // Also, note comment below from Robb (copied from the Common.code file).
   80308             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   80309             : //
   80310             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   80311             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   80312             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   80313             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   80314             : #if 0
   80315             : void SgTemplateInstantiationMemberFunctionDecl::operator delete(void* pointer) { SgTemplateInstantiationMemberFunctionDecl::operator delete (pointer, sizeof(SgTemplateInstantiationMemberFunctionDecl)); };
   80316             : #endif
   80317             : /* #line 80318 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   80318             : 
   80319             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   80320             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   80321             : // obviously imply C++.
   80322             : 
   80323             : // This implements the support within ROSE for memory pools.  Memory pools
   80324             : // support the most condensed usage of memory within the construction of
   80325             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   80326             : // by a new operator written for each class.
   80327             : 
   80328             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   80329             :     // User wants multi-thread support and POSIX threads are available.
   80330             : #   include <pthread.h>
   80331             :     static pthread_mutex_t SgTemplateInstantiationFunctionDecl_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   80332             : #else
   80333             :      // Cause synchronization to be skipped.
   80334             : #    ifndef ALLOC_MUTEX
   80335             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   80336             : #    endif
   80337             : #    ifdef _REENTRANT
   80338             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   80339             : #       ifdef _MSC_VER
   80340             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   80341             : #       else
   80342             : #           warning "POSIX threads are not available; synchronization being skipped"
   80343             : #       endif
   80344             : #    endif
   80345             : #endif
   80346             : 
   80347             : #ifndef ROSE_ALLOC_TRACE
   80348             : #  define ROSE_ALLOC_TRACE 0
   80349             : #endif
   80350             : 
   80351             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   80352             : #define ROSE_ALLOC_TRACE_CNT
   80353             : #include "memory-pool-snapshot.h"
   80354             : unsigned long alloc_trace_cnt = 0;
   80355             : #endif
   80356             : 
   80357             : #if ROSE_ALLOC_TRACE
   80358             : const unsigned SgTemplateInstantiationFunctionDecl::pool_size = 5;
   80359             : #else
   80360             : const unsigned SgTemplateInstantiationFunctionDecl::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   80361             : #endif
   80362             : 
   80363             : #ifndef ROSE_ALLOC_MEMSET
   80364             : #  define ROSE_ALLOC_MEMSET 0
   80365             : #endif
   80366             : 
   80367             : #ifndef ROSE_PEDANTIC_ALLOC
   80368             : #  define ROSE_PEDANTIC_ALLOC 0
   80369             : #endif
   80370             : 
   80371             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   80372             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   80373             : #endif
   80374             : 
   80375             : #if !defined(SGNODE__ALL_POOLS)
   80376             : #define SGNODE__ALL_POOLS
   80377             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   80378             : #endif
   80379             : 
   80380             : SgTemplateInstantiationFunctionDecl* SgTemplateInstantiationFunctionDecl::next_node = nullptr;
   80381             : std::vector<unsigned char*> SgTemplateInstantiationFunctionDecl::pools;
   80382             : 
   80383             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   80384             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   80385             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   80386             : // around this macro definition rather than each use).
   80387             : #ifndef ALLOC_MUTEX
   80388             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   80389             :         do {                                                                     \
   80390             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   80391             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   80392             :                 abort();                                                         \
   80393             :             }                                                                    \
   80394             :         } while (0);
   80395             : #endif
   80396             : 
   80397             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   80398             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   80399             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   80400             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   80401             : 
   80402             : /*! \brief New operator for SgTemplateInstantiationFunctionDecl.
   80403             : 
   80404             :    This new operator implements memory pools to provide most efficent 
   80405             :    use of the heap within construction of large ASTs.
   80406             : 
   80407             : \internal The new and delete operators use the lower level C malloc/free
   80408             :    function calls for performance and to make sure that mixing of malloc/free
   80409             :    and new/delete by the used can be caught more readily.  This may change
   80410             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   80411             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   80412             :    deallocate memory allocated using ROSE_MALLOC.
   80413             : */
   80414        2555 : void *SgTemplateInstantiationFunctionDecl::operator new ( size_t Size )
   80415             : {
   80416             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   80417             :      * returning or throwing an exception. */
   80418        2555 :     ALLOC_MUTEX(SgTemplateInstantiationFunctionDecl, lock);
   80419             : 
   80420             : #if ROSE_ALLOC_TRACE == 2
   80421             : //    printf("SgTemplateInstantiationFunctionDecl::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgTemplateInstantiationFunctionDecl::next_node);
   80422             : #endif
   80423             : 
   80424             : #if USE_CPP_NEW_DELETE_OPERATORS
   80425             :     void *mem = ROSE_MALLOC(Size);
   80426             :     ALLOC_MUTEX(SgTemplateInstantiationFunctionDecl, unlock);
   80427             :     return mem;
   80428             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   80429             : #if ROSE_PEDANTIC_ALLOC
   80430             :     ROSE_ASSERT(Size == sizeof(SgTemplateInstantiationFunctionDecl));
   80431             : #else
   80432        2555 :     if (Size != sizeof(SgTemplateInstantiationFunctionDecl)) {
   80433           0 :       void * object = ROSE_MALLOC(Size);
   80434           0 :       ALLOC_MUTEX(SgTemplateInstantiationFunctionDecl, unlock);
   80435             :       return object;
   80436             :     }
   80437             : #endif
   80438             : 
   80439        2555 :     if (SgTemplateInstantiationFunctionDecl::next_node == nullptr) {
   80440          10 :         SgTemplateInstantiationFunctionDecl * alloc = (SgTemplateInstantiationFunctionDecl*) ROSE_MALLOC ( SgTemplateInstantiationFunctionDecl::pool_size * sizeof(SgTemplateInstantiationFunctionDecl) );
   80441          10 :         ROSE_ASSERT(alloc != nullptr);
   80442             : 
   80443             : #if ROSE_ALLOC_TRACE == 2
   80444             : //        printf("SgTemplateInstantiationFunctionDecl::alloc\n  block[%zi] = [ %p , %p [\n", SgTemplateInstantiationFunctionDecl::pools.size(), alloc, alloc + SgTemplateInstantiationFunctionDecl::pool_size);
   80445             : #endif
   80446             : 
   80447             : #if ROSE_ALLOC_MEMSET == 1
   80448             : #elif ROSE_ALLOC_MEMSET == 2
   80449             :         memset(alloc, 0x00, SgTemplateInstantiationFunctionDecl::pool_size * sizeof(SgTemplateInstantiationFunctionDecl));
   80450             : #elif ROSE_ALLOC_MEMSET == 3
   80451             :         memset(alloc, 0xAA, SgTemplateInstantiationFunctionDecl::pool_size * sizeof(SgTemplateInstantiationFunctionDecl));
   80452             : #endif
   80453       20000 :         for (unsigned i=0; i < SgTemplateInstantiationFunctionDecl::pool_size-1; i++) {
   80454       19990 :           alloc[i].p_freepointer = &(alloc[i+1]);
   80455             :         }
   80456          10 :         alloc[SgTemplateInstantiationFunctionDecl::pool_size-1].p_freepointer = nullptr;
   80457             : 
   80458          10 :         SgTemplateInstantiationFunctionDecl::pools.push_back ( (unsigned char *) alloc );
   80459          10 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgTemplateInstantiationFunctionDecl::pool_size * sizeof(SgTemplateInstantiationFunctionDecl), V_SgTemplateInstantiationFunctionDecl ) );
   80460          10 :         SgTemplateInstantiationFunctionDecl::next_node = alloc;
   80461             :     }
   80462        2555 :     ROSE_ASSERT(SgTemplateInstantiationFunctionDecl::next_node != nullptr);
   80463             : 
   80464        2555 :     SgTemplateInstantiationFunctionDecl * object = SgTemplateInstantiationFunctionDecl::next_node;
   80465        2555 :     SgTemplateInstantiationFunctionDecl::next_node = (SgTemplateInstantiationFunctionDecl*)(object->p_freepointer);
   80466             : 
   80467             : #if ROSE_ALLOC_TRACE == 2
   80468             :     printf("SgTemplateInstantiationFunctionDecl::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTemplateInstantiationFunctionDecl::next_node);
   80469             : #endif
   80470             : 
   80471        2555 :     SgNode * fp = object->p_freepointer;
   80472             : #if ROSE_ALLOC_MEMSET == 1
   80473             : #elif ROSE_ALLOC_MEMSET == 2
   80474             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgTemplateInstantiationFunctionDecl) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   80475             : #elif ROSE_ALLOC_MEMSET == 3
   80476             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgTemplateInstantiationFunctionDecl) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   80477             : #endif
   80478        2555 :     object->p_freepointer = fp;
   80479             : 
   80480             : #if ROSE_ALLOC_TRACE == 2
   80481             : //    printf("SgTemplateInstantiationFunctionDecl::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTemplateInstantiationFunctionDecl::next_node);
   80482             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   80483             :     Rose::MemPool::snapshot(oss.str());
   80484             :     alloc_trace_cnt++;
   80485             : #endif
   80486             : 
   80487        2555 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   80488             : 
   80489        2555 :     ALLOC_MUTEX(SgTemplateInstantiationFunctionDecl, unlock);
   80490             : 
   80491             :     return object;
   80492             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   80493             : }
   80494             : 
   80495             : 
   80496             : 
   80497             : /*! \brief Delete operator for SgTemplateInstantiationFunctionDecl.
   80498             : 
   80499             :    This delete operator implements deallocation using memory pools to 
   80500             :    provide most efficent use of the heap within construction of large ASTs.
   80501             : 
   80502             : \internal The new and delete operators use the lower level C malloc/free
   80503             :    function calls for performance and to make sure that mixing of malloc/free
   80504             :    and new/delete by the used can be caught more readily.  This may change
   80505             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   80506             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   80507             :    deallocate memory allocated using ROSE_MALLOC.
   80508             : */
   80509         566 : void SgTemplateInstantiationFunctionDecl::operator delete(void *Pointer, size_t Size)
   80510             : {
   80511             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   80512             :      * or throwing an exception. */
   80513         566 :     ALLOC_MUTEX(SgTemplateInstantiationFunctionDecl, lock);
   80514             : 
   80515             : #if USE_CPP_NEW_DELETE_OPERATORS
   80516             :     ROSE_FREE(Pointer);
   80517             : #else
   80518             : #if ROSE_PEDANTIC_ALLOC
   80519             :     ROSE_ASSERT(Size == sizeof(SgTemplateInstantiationFunctionDecl));
   80520             : #else
   80521         566 :     if (Size != sizeof(SgTemplateInstantiationFunctionDecl)) {
   80522           0 :       ROSE_FREE(Pointer);
   80523           0 :       ALLOC_MUTEX(SgTemplateInstantiationFunctionDecl, unlock);
   80524             :       return;
   80525             :     }
   80526             : #endif
   80527             : 
   80528         566 :     SgTemplateInstantiationFunctionDecl * object = (SgTemplateInstantiationFunctionDecl*) Pointer;
   80529         566 :     ROSE_ASSERT(object != nullptr);
   80530             : 
   80531             : #if ROSE_ALLOC_TRACE == 2
   80532             : //  printf("SgTemplateInstantiationFunctionDecl::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTemplateInstantiationFunctionDecl::next_node);
   80533             :     printf("SgTemplateInstantiationFunctionDecl::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTemplateInstantiationFunctionDecl::next_node);
   80534             : #endif
   80535             : 
   80536             : #if ROSE_PEDANTIC_ALLOC
   80537             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   80538             : #endif
   80539             : 
   80540             : #if ROSE_ALLOC_MEMSET == 1
   80541             : #elif ROSE_ALLOC_MEMSET == 2
   80542             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgTemplateInstantiationFunctionDecl) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   80543             : #elif ROSE_ALLOC_MEMSET == 3
   80544             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgTemplateInstantiationFunctionDecl) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   80545             : #endif
   80546             : 
   80547             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   80548             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   80549             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   80550             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   80551             : #else
   80552         566 :     object->p_freepointer = SgTemplateInstantiationFunctionDecl::next_node;
   80553         566 :     SgTemplateInstantiationFunctionDecl::next_node = object;
   80554             : #endif
   80555             : 
   80556             : #if ROSE_ALLOC_TRACE == 2
   80557             : //  printf("SgTemplateInstantiationFunctionDecl::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTemplateInstantiationFunctionDecl::next_node);
   80558             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   80559             :     Rose::MemPool::snapshot(oss.str());
   80560             :     alloc_trace_cnt++;
   80561             : #endif
   80562             : 
   80563             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   80564             : 
   80565         566 :     ALLOC_MUTEX(SgTemplateInstantiationFunctionDecl, unlock);
   80566             : }
   80567             : 
   80568             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   80569             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   80570             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   80571             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   80572             : // Also, note comment below from Robb (copied from the Common.code file).
   80573             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   80574             : //
   80575             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   80576             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   80577             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   80578             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   80579             : #if 0
   80580             : void SgTemplateInstantiationFunctionDecl::operator delete(void* pointer) { SgTemplateInstantiationFunctionDecl::operator delete (pointer, sizeof(SgTemplateInstantiationFunctionDecl)); };
   80581             : #endif
   80582             : /* #line 80583 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   80583             : 
   80584             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   80585             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   80586             : // obviously imply C++.
   80587             : 
   80588             : // This implements the support within ROSE for memory pools.  Memory pools
   80589             : // support the most condensed usage of memory within the construction of
   80590             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   80591             : // by a new operator written for each class.
   80592             : 
   80593             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   80594             :     // User wants multi-thread support and POSIX threads are available.
   80595             : #   include <pthread.h>
   80596             :     static pthread_mutex_t SgProgramHeaderStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   80597             : #else
   80598             :      // Cause synchronization to be skipped.
   80599             : #    ifndef ALLOC_MUTEX
   80600             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   80601             : #    endif
   80602             : #    ifdef _REENTRANT
   80603             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   80604             : #       ifdef _MSC_VER
   80605             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   80606             : #       else
   80607             : #           warning "POSIX threads are not available; synchronization being skipped"
   80608             : #       endif
   80609             : #    endif
   80610             : #endif
   80611             : 
   80612             : #ifndef ROSE_ALLOC_TRACE
   80613             : #  define ROSE_ALLOC_TRACE 0
   80614             : #endif
   80615             : 
   80616             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   80617             : #define ROSE_ALLOC_TRACE_CNT
   80618             : #include "memory-pool-snapshot.h"
   80619             : unsigned long alloc_trace_cnt = 0;
   80620             : #endif
   80621             : 
   80622             : #if ROSE_ALLOC_TRACE
   80623             : const unsigned SgProgramHeaderStatement::pool_size = 5;
   80624             : #else
   80625             : const unsigned SgProgramHeaderStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   80626             : #endif
   80627             : 
   80628             : #ifndef ROSE_ALLOC_MEMSET
   80629             : #  define ROSE_ALLOC_MEMSET 0
   80630             : #endif
   80631             : 
   80632             : #ifndef ROSE_PEDANTIC_ALLOC
   80633             : #  define ROSE_PEDANTIC_ALLOC 0
   80634             : #endif
   80635             : 
   80636             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   80637             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   80638             : #endif
   80639             : 
   80640             : #if !defined(SGNODE__ALL_POOLS)
   80641             : #define SGNODE__ALL_POOLS
   80642             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   80643             : #endif
   80644             : 
   80645             : SgProgramHeaderStatement* SgProgramHeaderStatement::next_node = nullptr;
   80646             : std::vector<unsigned char*> SgProgramHeaderStatement::pools;
   80647             : 
   80648             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   80649             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   80650             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   80651             : // around this macro definition rather than each use).
   80652             : #ifndef ALLOC_MUTEX
   80653             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   80654             :         do {                                                                     \
   80655             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   80656             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   80657             :                 abort();                                                         \
   80658             :             }                                                                    \
   80659             :         } while (0);
   80660             : #endif
   80661             : 
   80662             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   80663             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   80664             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   80665             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   80666             : 
   80667             : /*! \brief New operator for SgProgramHeaderStatement.
   80668             : 
   80669             :    This new operator implements memory pools to provide most efficent 
   80670             :    use of the heap within construction of large ASTs.
   80671             : 
   80672             : \internal The new and delete operators use the lower level C malloc/free
   80673             :    function calls for performance and to make sure that mixing of malloc/free
   80674             :    and new/delete by the used can be caught more readily.  This may change
   80675             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   80676             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   80677             :    deallocate memory allocated using ROSE_MALLOC.
   80678             : */
   80679          27 : void *SgProgramHeaderStatement::operator new ( size_t Size )
   80680             : {
   80681             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   80682             :      * returning or throwing an exception. */
   80683          27 :     ALLOC_MUTEX(SgProgramHeaderStatement, lock);
   80684             : 
   80685             : #if ROSE_ALLOC_TRACE == 2
   80686             : //    printf("SgProgramHeaderStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgProgramHeaderStatement::next_node);
   80687             : #endif
   80688             : 
   80689             : #if USE_CPP_NEW_DELETE_OPERATORS
   80690             :     void *mem = ROSE_MALLOC(Size);
   80691             :     ALLOC_MUTEX(SgProgramHeaderStatement, unlock);
   80692             :     return mem;
   80693             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   80694             : #if ROSE_PEDANTIC_ALLOC
   80695             :     ROSE_ASSERT(Size == sizeof(SgProgramHeaderStatement));
   80696             : #else
   80697          27 :     if (Size != sizeof(SgProgramHeaderStatement)) {
   80698           0 :       void * object = ROSE_MALLOC(Size);
   80699           0 :       ALLOC_MUTEX(SgProgramHeaderStatement, unlock);
   80700             :       return object;
   80701             :     }
   80702             : #endif
   80703             : 
   80704          27 :     if (SgProgramHeaderStatement::next_node == nullptr) {
   80705          27 :         SgProgramHeaderStatement * alloc = (SgProgramHeaderStatement*) ROSE_MALLOC ( SgProgramHeaderStatement::pool_size * sizeof(SgProgramHeaderStatement) );
   80706          27 :         ROSE_ASSERT(alloc != nullptr);
   80707             : 
   80708             : #if ROSE_ALLOC_TRACE == 2
   80709             : //        printf("SgProgramHeaderStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgProgramHeaderStatement::pools.size(), alloc, alloc + SgProgramHeaderStatement::pool_size);
   80710             : #endif
   80711             : 
   80712             : #if ROSE_ALLOC_MEMSET == 1
   80713             : #elif ROSE_ALLOC_MEMSET == 2
   80714             :         memset(alloc, 0x00, SgProgramHeaderStatement::pool_size * sizeof(SgProgramHeaderStatement));
   80715             : #elif ROSE_ALLOC_MEMSET == 3
   80716             :         memset(alloc, 0xAA, SgProgramHeaderStatement::pool_size * sizeof(SgProgramHeaderStatement));
   80717             : #endif
   80718       54000 :         for (unsigned i=0; i < SgProgramHeaderStatement::pool_size-1; i++) {
   80719       53973 :           alloc[i].p_freepointer = &(alloc[i+1]);
   80720             :         }
   80721          27 :         alloc[SgProgramHeaderStatement::pool_size-1].p_freepointer = nullptr;
   80722             : 
   80723          27 :         SgProgramHeaderStatement::pools.push_back ( (unsigned char *) alloc );
   80724          27 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgProgramHeaderStatement::pool_size * sizeof(SgProgramHeaderStatement), V_SgProgramHeaderStatement ) );
   80725          27 :         SgProgramHeaderStatement::next_node = alloc;
   80726             :     }
   80727          27 :     ROSE_ASSERT(SgProgramHeaderStatement::next_node != nullptr);
   80728             : 
   80729          27 :     SgProgramHeaderStatement * object = SgProgramHeaderStatement::next_node;
   80730          27 :     SgProgramHeaderStatement::next_node = (SgProgramHeaderStatement*)(object->p_freepointer);
   80731             : 
   80732             : #if ROSE_ALLOC_TRACE == 2
   80733             :     printf("SgProgramHeaderStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgProgramHeaderStatement::next_node);
   80734             : #endif
   80735             : 
   80736          27 :     SgNode * fp = object->p_freepointer;
   80737             : #if ROSE_ALLOC_MEMSET == 1
   80738             : #elif ROSE_ALLOC_MEMSET == 2
   80739             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgProgramHeaderStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   80740             : #elif ROSE_ALLOC_MEMSET == 3
   80741             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgProgramHeaderStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   80742             : #endif
   80743          27 :     object->p_freepointer = fp;
   80744             : 
   80745             : #if ROSE_ALLOC_TRACE == 2
   80746             : //    printf("SgProgramHeaderStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgProgramHeaderStatement::next_node);
   80747             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   80748             :     Rose::MemPool::snapshot(oss.str());
   80749             :     alloc_trace_cnt++;
   80750             : #endif
   80751             : 
   80752          27 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   80753             : 
   80754          27 :     ALLOC_MUTEX(SgProgramHeaderStatement, unlock);
   80755             : 
   80756             :     return object;
   80757             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   80758             : }
   80759             : 
   80760             : 
   80761             : 
   80762             : /*! \brief Delete operator for SgProgramHeaderStatement.
   80763             : 
   80764             :    This delete operator implements deallocation using memory pools to 
   80765             :    provide most efficent use of the heap within construction of large ASTs.
   80766             : 
   80767             : \internal The new and delete operators use the lower level C malloc/free
   80768             :    function calls for performance and to make sure that mixing of malloc/free
   80769             :    and new/delete by the used can be caught more readily.  This may change
   80770             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   80771             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   80772             :    deallocate memory allocated using ROSE_MALLOC.
   80773             : */
   80774           1 : void SgProgramHeaderStatement::operator delete(void *Pointer, size_t Size)
   80775             : {
   80776             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   80777             :      * or throwing an exception. */
   80778           1 :     ALLOC_MUTEX(SgProgramHeaderStatement, lock);
   80779             : 
   80780             : #if USE_CPP_NEW_DELETE_OPERATORS
   80781             :     ROSE_FREE(Pointer);
   80782             : #else
   80783             : #if ROSE_PEDANTIC_ALLOC
   80784             :     ROSE_ASSERT(Size == sizeof(SgProgramHeaderStatement));
   80785             : #else
   80786           1 :     if (Size != sizeof(SgProgramHeaderStatement)) {
   80787           0 :       ROSE_FREE(Pointer);
   80788           0 :       ALLOC_MUTEX(SgProgramHeaderStatement, unlock);
   80789             :       return;
   80790             :     }
   80791             : #endif
   80792             : 
   80793           1 :     SgProgramHeaderStatement * object = (SgProgramHeaderStatement*) Pointer;
   80794           1 :     ROSE_ASSERT(object != nullptr);
   80795             : 
   80796             : #if ROSE_ALLOC_TRACE == 2
   80797             : //  printf("SgProgramHeaderStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgProgramHeaderStatement::next_node);
   80798             :     printf("SgProgramHeaderStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgProgramHeaderStatement::next_node);
   80799             : #endif
   80800             : 
   80801             : #if ROSE_PEDANTIC_ALLOC
   80802             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   80803             : #endif
   80804             : 
   80805             : #if ROSE_ALLOC_MEMSET == 1
   80806             : #elif ROSE_ALLOC_MEMSET == 2
   80807             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgProgramHeaderStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   80808             : #elif ROSE_ALLOC_MEMSET == 3
   80809             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgProgramHeaderStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   80810             : #endif
   80811             : 
   80812             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   80813             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   80814             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   80815             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   80816             : #else
   80817           1 :     object->p_freepointer = SgProgramHeaderStatement::next_node;
   80818           1 :     SgProgramHeaderStatement::next_node = object;
   80819             : #endif
   80820             : 
   80821             : #if ROSE_ALLOC_TRACE == 2
   80822             : //  printf("SgProgramHeaderStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgProgramHeaderStatement::next_node);
   80823             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   80824             :     Rose::MemPool::snapshot(oss.str());
   80825             :     alloc_trace_cnt++;
   80826             : #endif
   80827             : 
   80828             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   80829             : 
   80830           1 :     ALLOC_MUTEX(SgProgramHeaderStatement, unlock);
   80831             : }
   80832             : 
   80833             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   80834             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   80835             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   80836             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   80837             : // Also, note comment below from Robb (copied from the Common.code file).
   80838             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   80839             : //
   80840             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   80841             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   80842             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   80843             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   80844             : #if 0
   80845             : void SgProgramHeaderStatement::operator delete(void* pointer) { SgProgramHeaderStatement::operator delete (pointer, sizeof(SgProgramHeaderStatement)); };
   80846             : #endif
   80847             : /* #line 80848 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   80848             : 
   80849             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   80850             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   80851             : // obviously imply C++.
   80852             : 
   80853             : // This implements the support within ROSE for memory pools.  Memory pools
   80854             : // support the most condensed usage of memory within the construction of
   80855             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   80856             : // by a new operator written for each class.
   80857             : 
   80858             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   80859             :     // User wants multi-thread support and POSIX threads are available.
   80860             : #   include <pthread.h>
   80861             :     static pthread_mutex_t SgProcedureHeaderStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   80862             : #else
   80863             :      // Cause synchronization to be skipped.
   80864             : #    ifndef ALLOC_MUTEX
   80865             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   80866             : #    endif
   80867             : #    ifdef _REENTRANT
   80868             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   80869             : #       ifdef _MSC_VER
   80870             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   80871             : #       else
   80872             : #           warning "POSIX threads are not available; synchronization being skipped"
   80873             : #       endif
   80874             : #    endif
   80875             : #endif
   80876             : 
   80877             : #ifndef ROSE_ALLOC_TRACE
   80878             : #  define ROSE_ALLOC_TRACE 0
   80879             : #endif
   80880             : 
   80881             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   80882             : #define ROSE_ALLOC_TRACE_CNT
   80883             : #include "memory-pool-snapshot.h"
   80884             : unsigned long alloc_trace_cnt = 0;
   80885             : #endif
   80886             : 
   80887             : #if ROSE_ALLOC_TRACE
   80888             : const unsigned SgProcedureHeaderStatement::pool_size = 5;
   80889             : #else
   80890             : const unsigned SgProcedureHeaderStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   80891             : #endif
   80892             : 
   80893             : #ifndef ROSE_ALLOC_MEMSET
   80894             : #  define ROSE_ALLOC_MEMSET 0
   80895             : #endif
   80896             : 
   80897             : #ifndef ROSE_PEDANTIC_ALLOC
   80898             : #  define ROSE_PEDANTIC_ALLOC 0
   80899             : #endif
   80900             : 
   80901             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   80902             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   80903             : #endif
   80904             : 
   80905             : #if !defined(SGNODE__ALL_POOLS)
   80906             : #define SGNODE__ALL_POOLS
   80907             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   80908             : #endif
   80909             : 
   80910             : SgProcedureHeaderStatement* SgProcedureHeaderStatement::next_node = nullptr;
   80911             : std::vector<unsigned char*> SgProcedureHeaderStatement::pools;
   80912             : 
   80913             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   80914             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   80915             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   80916             : // around this macro definition rather than each use).
   80917             : #ifndef ALLOC_MUTEX
   80918             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   80919             :         do {                                                                     \
   80920             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   80921             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   80922             :                 abort();                                                         \
   80923             :             }                                                                    \
   80924             :         } while (0);
   80925             : #endif
   80926             : 
   80927             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   80928             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   80929             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   80930             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   80931             : 
   80932             : /*! \brief New operator for SgProcedureHeaderStatement.
   80933             : 
   80934             :    This new operator implements memory pools to provide most efficent 
   80935             :    use of the heap within construction of large ASTs.
   80936             : 
   80937             : \internal The new and delete operators use the lower level C malloc/free
   80938             :    function calls for performance and to make sure that mixing of malloc/free
   80939             :    and new/delete by the used can be caught more readily.  This may change
   80940             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   80941             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   80942             :    deallocate memory allocated using ROSE_MALLOC.
   80943             : */
   80944         402 : void *SgProcedureHeaderStatement::operator new ( size_t Size )
   80945             : {
   80946             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   80947             :      * returning or throwing an exception. */
   80948         402 :     ALLOC_MUTEX(SgProcedureHeaderStatement, lock);
   80949             : 
   80950             : #if ROSE_ALLOC_TRACE == 2
   80951             : //    printf("SgProcedureHeaderStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgProcedureHeaderStatement::next_node);
   80952             : #endif
   80953             : 
   80954             : #if USE_CPP_NEW_DELETE_OPERATORS
   80955             :     void *mem = ROSE_MALLOC(Size);
   80956             :     ALLOC_MUTEX(SgProcedureHeaderStatement, unlock);
   80957             :     return mem;
   80958             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   80959             : #if ROSE_PEDANTIC_ALLOC
   80960             :     ROSE_ASSERT(Size == sizeof(SgProcedureHeaderStatement));
   80961             : #else
   80962         402 :     if (Size != sizeof(SgProcedureHeaderStatement)) {
   80963           0 :       void * object = ROSE_MALLOC(Size);
   80964           0 :       ALLOC_MUTEX(SgProcedureHeaderStatement, unlock);
   80965             :       return object;
   80966             :     }
   80967             : #endif
   80968             : 
   80969         402 :     if (SgProcedureHeaderStatement::next_node == nullptr) {
   80970          23 :         SgProcedureHeaderStatement * alloc = (SgProcedureHeaderStatement*) ROSE_MALLOC ( SgProcedureHeaderStatement::pool_size * sizeof(SgProcedureHeaderStatement) );
   80971          23 :         ROSE_ASSERT(alloc != nullptr);
   80972             : 
   80973             : #if ROSE_ALLOC_TRACE == 2
   80974             : //        printf("SgProcedureHeaderStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgProcedureHeaderStatement::pools.size(), alloc, alloc + SgProcedureHeaderStatement::pool_size);
   80975             : #endif
   80976             : 
   80977             : #if ROSE_ALLOC_MEMSET == 1
   80978             : #elif ROSE_ALLOC_MEMSET == 2
   80979             :         memset(alloc, 0x00, SgProcedureHeaderStatement::pool_size * sizeof(SgProcedureHeaderStatement));
   80980             : #elif ROSE_ALLOC_MEMSET == 3
   80981             :         memset(alloc, 0xAA, SgProcedureHeaderStatement::pool_size * sizeof(SgProcedureHeaderStatement));
   80982             : #endif
   80983       46000 :         for (unsigned i=0; i < SgProcedureHeaderStatement::pool_size-1; i++) {
   80984       45977 :           alloc[i].p_freepointer = &(alloc[i+1]);
   80985             :         }
   80986          23 :         alloc[SgProcedureHeaderStatement::pool_size-1].p_freepointer = nullptr;
   80987             : 
   80988          23 :         SgProcedureHeaderStatement::pools.push_back ( (unsigned char *) alloc );
   80989          23 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgProcedureHeaderStatement::pool_size * sizeof(SgProcedureHeaderStatement), V_SgProcedureHeaderStatement ) );
   80990          23 :         SgProcedureHeaderStatement::next_node = alloc;
   80991             :     }
   80992         402 :     ROSE_ASSERT(SgProcedureHeaderStatement::next_node != nullptr);
   80993             : 
   80994         402 :     SgProcedureHeaderStatement * object = SgProcedureHeaderStatement::next_node;
   80995         402 :     SgProcedureHeaderStatement::next_node = (SgProcedureHeaderStatement*)(object->p_freepointer);
   80996             : 
   80997             : #if ROSE_ALLOC_TRACE == 2
   80998             :     printf("SgProcedureHeaderStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgProcedureHeaderStatement::next_node);
   80999             : #endif
   81000             : 
   81001         402 :     SgNode * fp = object->p_freepointer;
   81002             : #if ROSE_ALLOC_MEMSET == 1
   81003             : #elif ROSE_ALLOC_MEMSET == 2
   81004             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgProcedureHeaderStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   81005             : #elif ROSE_ALLOC_MEMSET == 3
   81006             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgProcedureHeaderStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   81007             : #endif
   81008         402 :     object->p_freepointer = fp;
   81009             : 
   81010             : #if ROSE_ALLOC_TRACE == 2
   81011             : //    printf("SgProcedureHeaderStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgProcedureHeaderStatement::next_node);
   81012             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   81013             :     Rose::MemPool::snapshot(oss.str());
   81014             :     alloc_trace_cnt++;
   81015             : #endif
   81016             : 
   81017         402 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   81018             : 
   81019         402 :     ALLOC_MUTEX(SgProcedureHeaderStatement, unlock);
   81020             : 
   81021             :     return object;
   81022             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   81023             : }
   81024             : 
   81025             : 
   81026             : 
   81027             : /*! \brief Delete operator for SgProcedureHeaderStatement.
   81028             : 
   81029             :    This delete operator implements deallocation using memory pools to 
   81030             :    provide most efficent use of the heap within construction of large ASTs.
   81031             : 
   81032             : \internal The new and delete operators use the lower level C malloc/free
   81033             :    function calls for performance and to make sure that mixing of malloc/free
   81034             :    and new/delete by the used can be caught more readily.  This may change
   81035             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   81036             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   81037             :    deallocate memory allocated using ROSE_MALLOC.
   81038             : */
   81039           0 : void SgProcedureHeaderStatement::operator delete(void *Pointer, size_t Size)
   81040             : {
   81041             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   81042             :      * or throwing an exception. */
   81043           0 :     ALLOC_MUTEX(SgProcedureHeaderStatement, lock);
   81044             : 
   81045             : #if USE_CPP_NEW_DELETE_OPERATORS
   81046             :     ROSE_FREE(Pointer);
   81047             : #else
   81048             : #if ROSE_PEDANTIC_ALLOC
   81049             :     ROSE_ASSERT(Size == sizeof(SgProcedureHeaderStatement));
   81050             : #else
   81051           0 :     if (Size != sizeof(SgProcedureHeaderStatement)) {
   81052           0 :       ROSE_FREE(Pointer);
   81053           0 :       ALLOC_MUTEX(SgProcedureHeaderStatement, unlock);
   81054             :       return;
   81055             :     }
   81056             : #endif
   81057             : 
   81058           0 :     SgProcedureHeaderStatement * object = (SgProcedureHeaderStatement*) Pointer;
   81059           0 :     ROSE_ASSERT(object != nullptr);
   81060             : 
   81061             : #if ROSE_ALLOC_TRACE == 2
   81062             : //  printf("SgProcedureHeaderStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgProcedureHeaderStatement::next_node);
   81063             :     printf("SgProcedureHeaderStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgProcedureHeaderStatement::next_node);
   81064             : #endif
   81065             : 
   81066             : #if ROSE_PEDANTIC_ALLOC
   81067             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   81068             : #endif
   81069             : 
   81070             : #if ROSE_ALLOC_MEMSET == 1
   81071             : #elif ROSE_ALLOC_MEMSET == 2
   81072             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgProcedureHeaderStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   81073             : #elif ROSE_ALLOC_MEMSET == 3
   81074             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgProcedureHeaderStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   81075             : #endif
   81076             : 
   81077             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   81078             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   81079             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   81080             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   81081             : #else
   81082           0 :     object->p_freepointer = SgProcedureHeaderStatement::next_node;
   81083           0 :     SgProcedureHeaderStatement::next_node = object;
   81084             : #endif
   81085             : 
   81086             : #if ROSE_ALLOC_TRACE == 2
   81087             : //  printf("SgProcedureHeaderStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgProcedureHeaderStatement::next_node);
   81088             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   81089             :     Rose::MemPool::snapshot(oss.str());
   81090             :     alloc_trace_cnt++;
   81091             : #endif
   81092             : 
   81093             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   81094             : 
   81095           0 :     ALLOC_MUTEX(SgProcedureHeaderStatement, unlock);
   81096             : }
   81097             : 
   81098             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   81099             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   81100             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   81101             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   81102             : // Also, note comment below from Robb (copied from the Common.code file).
   81103             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   81104             : //
   81105             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   81106             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   81107             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   81108             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   81109             : #if 0
   81110             : void SgProcedureHeaderStatement::operator delete(void* pointer) { SgProcedureHeaderStatement::operator delete (pointer, sizeof(SgProcedureHeaderStatement)); };
   81111             : #endif
   81112             : /* #line 81113 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   81113             : 
   81114             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   81115             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   81116             : // obviously imply C++.
   81117             : 
   81118             : // This implements the support within ROSE for memory pools.  Memory pools
   81119             : // support the most condensed usage of memory within the construction of
   81120             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   81121             : // by a new operator written for each class.
   81122             : 
   81123             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   81124             :     // User wants multi-thread support and POSIX threads are available.
   81125             : #   include <pthread.h>
   81126             :     static pthread_mutex_t SgEntryStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   81127             : #else
   81128             :      // Cause synchronization to be skipped.
   81129             : #    ifndef ALLOC_MUTEX
   81130             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   81131             : #    endif
   81132             : #    ifdef _REENTRANT
   81133             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   81134             : #       ifdef _MSC_VER
   81135             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   81136             : #       else
   81137             : #           warning "POSIX threads are not available; synchronization being skipped"
   81138             : #       endif
   81139             : #    endif
   81140             : #endif
   81141             : 
   81142             : #ifndef ROSE_ALLOC_TRACE
   81143             : #  define ROSE_ALLOC_TRACE 0
   81144             : #endif
   81145             : 
   81146             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   81147             : #define ROSE_ALLOC_TRACE_CNT
   81148             : #include "memory-pool-snapshot.h"
   81149             : unsigned long alloc_trace_cnt = 0;
   81150             : #endif
   81151             : 
   81152             : #if ROSE_ALLOC_TRACE
   81153             : const unsigned SgEntryStatement::pool_size = 5;
   81154             : #else
   81155             : const unsigned SgEntryStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   81156             : #endif
   81157             : 
   81158             : #ifndef ROSE_ALLOC_MEMSET
   81159             : #  define ROSE_ALLOC_MEMSET 0
   81160             : #endif
   81161             : 
   81162             : #ifndef ROSE_PEDANTIC_ALLOC
   81163             : #  define ROSE_PEDANTIC_ALLOC 0
   81164             : #endif
   81165             : 
   81166             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   81167             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   81168             : #endif
   81169             : 
   81170             : #if !defined(SGNODE__ALL_POOLS)
   81171             : #define SGNODE__ALL_POOLS
   81172             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   81173             : #endif
   81174             : 
   81175             : SgEntryStatement* SgEntryStatement::next_node = nullptr;
   81176             : std::vector<unsigned char*> SgEntryStatement::pools;
   81177             : 
   81178             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   81179             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   81180             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   81181             : // around this macro definition rather than each use).
   81182             : #ifndef ALLOC_MUTEX
   81183             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   81184             :         do {                                                                     \
   81185             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   81186             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   81187             :                 abort();                                                         \
   81188             :             }                                                                    \
   81189             :         } while (0);
   81190             : #endif
   81191             : 
   81192             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   81193             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   81194             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   81195             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   81196             : 
   81197             : /*! \brief New operator for SgEntryStatement.
   81198             : 
   81199             :    This new operator implements memory pools to provide most efficent 
   81200             :    use of the heap within construction of large ASTs.
   81201             : 
   81202             : \internal The new and delete operators use the lower level C malloc/free
   81203             :    function calls for performance and to make sure that mixing of malloc/free
   81204             :    and new/delete by the used can be caught more readily.  This may change
   81205             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   81206             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   81207             :    deallocate memory allocated using ROSE_MALLOC.
   81208             : */
   81209           0 : void *SgEntryStatement::operator new ( size_t Size )
   81210             : {
   81211             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   81212             :      * returning or throwing an exception. */
   81213           0 :     ALLOC_MUTEX(SgEntryStatement, lock);
   81214             : 
   81215             : #if ROSE_ALLOC_TRACE == 2
   81216             : //    printf("SgEntryStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgEntryStatement::next_node);
   81217             : #endif
   81218             : 
   81219             : #if USE_CPP_NEW_DELETE_OPERATORS
   81220             :     void *mem = ROSE_MALLOC(Size);
   81221             :     ALLOC_MUTEX(SgEntryStatement, unlock);
   81222             :     return mem;
   81223             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   81224             : #if ROSE_PEDANTIC_ALLOC
   81225             :     ROSE_ASSERT(Size == sizeof(SgEntryStatement));
   81226             : #else
   81227           0 :     if (Size != sizeof(SgEntryStatement)) {
   81228           0 :       void * object = ROSE_MALLOC(Size);
   81229           0 :       ALLOC_MUTEX(SgEntryStatement, unlock);
   81230             :       return object;
   81231             :     }
   81232             : #endif
   81233             : 
   81234           0 :     if (SgEntryStatement::next_node == nullptr) {
   81235           0 :         SgEntryStatement * alloc = (SgEntryStatement*) ROSE_MALLOC ( SgEntryStatement::pool_size * sizeof(SgEntryStatement) );
   81236           0 :         ROSE_ASSERT(alloc != nullptr);
   81237             : 
   81238             : #if ROSE_ALLOC_TRACE == 2
   81239             : //        printf("SgEntryStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgEntryStatement::pools.size(), alloc, alloc + SgEntryStatement::pool_size);
   81240             : #endif
   81241             : 
   81242             : #if ROSE_ALLOC_MEMSET == 1
   81243             : #elif ROSE_ALLOC_MEMSET == 2
   81244             :         memset(alloc, 0x00, SgEntryStatement::pool_size * sizeof(SgEntryStatement));
   81245             : #elif ROSE_ALLOC_MEMSET == 3
   81246             :         memset(alloc, 0xAA, SgEntryStatement::pool_size * sizeof(SgEntryStatement));
   81247             : #endif
   81248           0 :         for (unsigned i=0; i < SgEntryStatement::pool_size-1; i++) {
   81249           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
   81250             :         }
   81251           0 :         alloc[SgEntryStatement::pool_size-1].p_freepointer = nullptr;
   81252             : 
   81253           0 :         SgEntryStatement::pools.push_back ( (unsigned char *) alloc );
   81254           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgEntryStatement::pool_size * sizeof(SgEntryStatement), V_SgEntryStatement ) );
   81255           0 :         SgEntryStatement::next_node = alloc;
   81256             :     }
   81257           0 :     ROSE_ASSERT(SgEntryStatement::next_node != nullptr);
   81258             : 
   81259           0 :     SgEntryStatement * object = SgEntryStatement::next_node;
   81260           0 :     SgEntryStatement::next_node = (SgEntryStatement*)(object->p_freepointer);
   81261             : 
   81262             : #if ROSE_ALLOC_TRACE == 2
   81263             :     printf("SgEntryStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgEntryStatement::next_node);
   81264             : #endif
   81265             : 
   81266           0 :     SgNode * fp = object->p_freepointer;
   81267             : #if ROSE_ALLOC_MEMSET == 1
   81268             : #elif ROSE_ALLOC_MEMSET == 2
   81269             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgEntryStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   81270             : #elif ROSE_ALLOC_MEMSET == 3
   81271             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgEntryStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   81272             : #endif
   81273           0 :     object->p_freepointer = fp;
   81274             : 
   81275             : #if ROSE_ALLOC_TRACE == 2
   81276             : //    printf("SgEntryStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgEntryStatement::next_node);
   81277             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   81278             :     Rose::MemPool::snapshot(oss.str());
   81279             :     alloc_trace_cnt++;
   81280             : #endif
   81281             : 
   81282           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   81283             : 
   81284           0 :     ALLOC_MUTEX(SgEntryStatement, unlock);
   81285             : 
   81286             :     return object;
   81287             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   81288             : }
   81289             : 
   81290             : 
   81291             : 
   81292             : /*! \brief Delete operator for SgEntryStatement.
   81293             : 
   81294             :    This delete operator implements deallocation using memory pools to 
   81295             :    provide most efficent use of the heap within construction of large ASTs.
   81296             : 
   81297             : \internal The new and delete operators use the lower level C malloc/free
   81298             :    function calls for performance and to make sure that mixing of malloc/free
   81299             :    and new/delete by the used can be caught more readily.  This may change
   81300             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   81301             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   81302             :    deallocate memory allocated using ROSE_MALLOC.
   81303             : */
   81304           0 : void SgEntryStatement::operator delete(void *Pointer, size_t Size)
   81305             : {
   81306             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   81307             :      * or throwing an exception. */
   81308           0 :     ALLOC_MUTEX(SgEntryStatement, lock);
   81309             : 
   81310             : #if USE_CPP_NEW_DELETE_OPERATORS
   81311             :     ROSE_FREE(Pointer);
   81312             : #else
   81313             : #if ROSE_PEDANTIC_ALLOC
   81314             :     ROSE_ASSERT(Size == sizeof(SgEntryStatement));
   81315             : #else
   81316           0 :     if (Size != sizeof(SgEntryStatement)) {
   81317           0 :       ROSE_FREE(Pointer);
   81318           0 :       ALLOC_MUTEX(SgEntryStatement, unlock);
   81319             :       return;
   81320             :     }
   81321             : #endif
   81322             : 
   81323           0 :     SgEntryStatement * object = (SgEntryStatement*) Pointer;
   81324           0 :     ROSE_ASSERT(object != nullptr);
   81325             : 
   81326             : #if ROSE_ALLOC_TRACE == 2
   81327             : //  printf("SgEntryStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgEntryStatement::next_node);
   81328             :     printf("SgEntryStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgEntryStatement::next_node);
   81329             : #endif
   81330             : 
   81331             : #if ROSE_PEDANTIC_ALLOC
   81332             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   81333             : #endif
   81334             : 
   81335             : #if ROSE_ALLOC_MEMSET == 1
   81336             : #elif ROSE_ALLOC_MEMSET == 2
   81337             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgEntryStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   81338             : #elif ROSE_ALLOC_MEMSET == 3
   81339             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgEntryStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   81340             : #endif
   81341             : 
   81342             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   81343             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   81344             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   81345             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   81346             : #else
   81347           0 :     object->p_freepointer = SgEntryStatement::next_node;
   81348           0 :     SgEntryStatement::next_node = object;
   81349             : #endif
   81350             : 
   81351             : #if ROSE_ALLOC_TRACE == 2
   81352             : //  printf("SgEntryStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgEntryStatement::next_node);
   81353             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   81354             :     Rose::MemPool::snapshot(oss.str());
   81355             :     alloc_trace_cnt++;
   81356             : #endif
   81357             : 
   81358             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   81359             : 
   81360           0 :     ALLOC_MUTEX(SgEntryStatement, unlock);
   81361             : }
   81362             : 
   81363             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   81364             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   81365             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   81366             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   81367             : // Also, note comment below from Robb (copied from the Common.code file).
   81368             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   81369             : //
   81370             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   81371             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   81372             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   81373             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   81374             : #if 0
   81375             : void SgEntryStatement::operator delete(void* pointer) { SgEntryStatement::operator delete (pointer, sizeof(SgEntryStatement)); };
   81376             : #endif
   81377             : /* #line 81378 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   81378             : 
   81379             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   81380             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   81381             : // obviously imply C++.
   81382             : 
   81383             : // This implements the support within ROSE for memory pools.  Memory pools
   81384             : // support the most condensed usage of memory within the construction of
   81385             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   81386             : // by a new operator written for each class.
   81387             : 
   81388             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   81389             :     // User wants multi-thread support and POSIX threads are available.
   81390             : #   include <pthread.h>
   81391             :     static pthread_mutex_t SgContainsStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   81392             : #else
   81393             :      // Cause synchronization to be skipped.
   81394             : #    ifndef ALLOC_MUTEX
   81395             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   81396             : #    endif
   81397             : #    ifdef _REENTRANT
   81398             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   81399             : #       ifdef _MSC_VER
   81400             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   81401             : #       else
   81402             : #           warning "POSIX threads are not available; synchronization being skipped"
   81403             : #       endif
   81404             : #    endif
   81405             : #endif
   81406             : 
   81407             : #ifndef ROSE_ALLOC_TRACE
   81408             : #  define ROSE_ALLOC_TRACE 0
   81409             : #endif
   81410             : 
   81411             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   81412             : #define ROSE_ALLOC_TRACE_CNT
   81413             : #include "memory-pool-snapshot.h"
   81414             : unsigned long alloc_trace_cnt = 0;
   81415             : #endif
   81416             : 
   81417             : #if ROSE_ALLOC_TRACE
   81418             : const unsigned SgContainsStatement::pool_size = 5;
   81419             : #else
   81420             : const unsigned SgContainsStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   81421             : #endif
   81422             : 
   81423             : #ifndef ROSE_ALLOC_MEMSET
   81424             : #  define ROSE_ALLOC_MEMSET 0
   81425             : #endif
   81426             : 
   81427             : #ifndef ROSE_PEDANTIC_ALLOC
   81428             : #  define ROSE_PEDANTIC_ALLOC 0
   81429             : #endif
   81430             : 
   81431             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   81432             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   81433             : #endif
   81434             : 
   81435             : #if !defined(SGNODE__ALL_POOLS)
   81436             : #define SGNODE__ALL_POOLS
   81437             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   81438             : #endif
   81439             : 
   81440             : SgContainsStatement* SgContainsStatement::next_node = nullptr;
   81441             : std::vector<unsigned char*> SgContainsStatement::pools;
   81442             : 
   81443             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   81444             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   81445             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   81446             : // around this macro definition rather than each use).
   81447             : #ifndef ALLOC_MUTEX
   81448             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   81449             :         do {                                                                     \
   81450             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   81451             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   81452             :                 abort();                                                         \
   81453             :             }                                                                    \
   81454             :         } while (0);
   81455             : #endif
   81456             : 
   81457             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   81458             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   81459             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   81460             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   81461             : 
   81462             : /*! \brief New operator for SgContainsStatement.
   81463             : 
   81464             :    This new operator implements memory pools to provide most efficent 
   81465             :    use of the heap within construction of large ASTs.
   81466             : 
   81467             : \internal The new and delete operators use the lower level C malloc/free
   81468             :    function calls for performance and to make sure that mixing of malloc/free
   81469             :    and new/delete by the used can be caught more readily.  This may change
   81470             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   81471             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   81472             :    deallocate memory allocated using ROSE_MALLOC.
   81473             : */
   81474           0 : void *SgContainsStatement::operator new ( size_t Size )
   81475             : {
   81476             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   81477             :      * returning or throwing an exception. */
   81478           0 :     ALLOC_MUTEX(SgContainsStatement, lock);
   81479             : 
   81480             : #if ROSE_ALLOC_TRACE == 2
   81481             : //    printf("SgContainsStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgContainsStatement::next_node);
   81482             : #endif
   81483             : 
   81484             : #if USE_CPP_NEW_DELETE_OPERATORS
   81485             :     void *mem = ROSE_MALLOC(Size);
   81486             :     ALLOC_MUTEX(SgContainsStatement, unlock);
   81487             :     return mem;
   81488             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   81489             : #if ROSE_PEDANTIC_ALLOC
   81490             :     ROSE_ASSERT(Size == sizeof(SgContainsStatement));
   81491             : #else
   81492           0 :     if (Size != sizeof(SgContainsStatement)) {
   81493           0 :       void * object = ROSE_MALLOC(Size);
   81494           0 :       ALLOC_MUTEX(SgContainsStatement, unlock);
   81495             :       return object;
   81496             :     }
   81497             : #endif
   81498             : 
   81499           0 :     if (SgContainsStatement::next_node == nullptr) {
   81500           0 :         SgContainsStatement * alloc = (SgContainsStatement*) ROSE_MALLOC ( SgContainsStatement::pool_size * sizeof(SgContainsStatement) );
   81501           0 :         ROSE_ASSERT(alloc != nullptr);
   81502             : 
   81503             : #if ROSE_ALLOC_TRACE == 2
   81504             : //        printf("SgContainsStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgContainsStatement::pools.size(), alloc, alloc + SgContainsStatement::pool_size);
   81505             : #endif
   81506             : 
   81507             : #if ROSE_ALLOC_MEMSET == 1
   81508             : #elif ROSE_ALLOC_MEMSET == 2
   81509             :         memset(alloc, 0x00, SgContainsStatement::pool_size * sizeof(SgContainsStatement));
   81510             : #elif ROSE_ALLOC_MEMSET == 3
   81511             :         memset(alloc, 0xAA, SgContainsStatement::pool_size * sizeof(SgContainsStatement));
   81512             : #endif
   81513           0 :         for (unsigned i=0; i < SgContainsStatement::pool_size-1; i++) {
   81514           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
   81515             :         }
   81516           0 :         alloc[SgContainsStatement::pool_size-1].p_freepointer = nullptr;
   81517             : 
   81518           0 :         SgContainsStatement::pools.push_back ( (unsigned char *) alloc );
   81519           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgContainsStatement::pool_size * sizeof(SgContainsStatement), V_SgContainsStatement ) );
   81520           0 :         SgContainsStatement::next_node = alloc;
   81521             :     }
   81522           0 :     ROSE_ASSERT(SgContainsStatement::next_node != nullptr);
   81523             : 
   81524           0 :     SgContainsStatement * object = SgContainsStatement::next_node;
   81525           0 :     SgContainsStatement::next_node = (SgContainsStatement*)(object->p_freepointer);
   81526             : 
   81527             : #if ROSE_ALLOC_TRACE == 2
   81528             :     printf("SgContainsStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgContainsStatement::next_node);
   81529             : #endif
   81530             : 
   81531           0 :     SgNode * fp = object->p_freepointer;
   81532             : #if ROSE_ALLOC_MEMSET == 1
   81533             : #elif ROSE_ALLOC_MEMSET == 2
   81534             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgContainsStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   81535             : #elif ROSE_ALLOC_MEMSET == 3
   81536             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgContainsStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   81537             : #endif
   81538           0 :     object->p_freepointer = fp;
   81539             : 
   81540             : #if ROSE_ALLOC_TRACE == 2
   81541             : //    printf("SgContainsStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgContainsStatement::next_node);
   81542             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   81543             :     Rose::MemPool::snapshot(oss.str());
   81544             :     alloc_trace_cnt++;
   81545             : #endif
   81546             : 
   81547           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   81548             : 
   81549           0 :     ALLOC_MUTEX(SgContainsStatement, unlock);
   81550             : 
   81551             :     return object;
   81552             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   81553             : }
   81554             : 
   81555             : 
   81556             : 
   81557             : /*! \brief Delete operator for SgContainsStatement.
   81558             : 
   81559             :    This delete operator implements deallocation using memory pools to 
   81560             :    provide most efficent use of the heap within construction of large ASTs.
   81561             : 
   81562             : \internal The new and delete operators use the lower level C malloc/free
   81563             :    function calls for performance and to make sure that mixing of malloc/free
   81564             :    and new/delete by the used can be caught more readily.  This may change
   81565             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   81566             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   81567             :    deallocate memory allocated using ROSE_MALLOC.
   81568             : */
   81569           0 : void SgContainsStatement::operator delete(void *Pointer, size_t Size)
   81570             : {
   81571             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   81572             :      * or throwing an exception. */
   81573           0 :     ALLOC_MUTEX(SgContainsStatement, lock);
   81574             : 
   81575             : #if USE_CPP_NEW_DELETE_OPERATORS
   81576             :     ROSE_FREE(Pointer);
   81577             : #else
   81578             : #if ROSE_PEDANTIC_ALLOC
   81579             :     ROSE_ASSERT(Size == sizeof(SgContainsStatement));
   81580             : #else
   81581           0 :     if (Size != sizeof(SgContainsStatement)) {
   81582           0 :       ROSE_FREE(Pointer);
   81583           0 :       ALLOC_MUTEX(SgContainsStatement, unlock);
   81584             :       return;
   81585             :     }
   81586             : #endif
   81587             : 
   81588           0 :     SgContainsStatement * object = (SgContainsStatement*) Pointer;
   81589           0 :     ROSE_ASSERT(object != nullptr);
   81590             : 
   81591             : #if ROSE_ALLOC_TRACE == 2
   81592             : //  printf("SgContainsStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgContainsStatement::next_node);
   81593             :     printf("SgContainsStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgContainsStatement::next_node);
   81594             : #endif
   81595             : 
   81596             : #if ROSE_PEDANTIC_ALLOC
   81597             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   81598             : #endif
   81599             : 
   81600             : #if ROSE_ALLOC_MEMSET == 1
   81601             : #elif ROSE_ALLOC_MEMSET == 2
   81602             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgContainsStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   81603             : #elif ROSE_ALLOC_MEMSET == 3
   81604             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgContainsStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   81605             : #endif
   81606             : 
   81607             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   81608             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   81609             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   81610             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   81611             : #else
   81612           0 :     object->p_freepointer = SgContainsStatement::next_node;
   81613           0 :     SgContainsStatement::next_node = object;
   81614             : #endif
   81615             : 
   81616             : #if ROSE_ALLOC_TRACE == 2
   81617             : //  printf("SgContainsStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgContainsStatement::next_node);
   81618             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   81619             :     Rose::MemPool::snapshot(oss.str());
   81620             :     alloc_trace_cnt++;
   81621             : #endif
   81622             : 
   81623             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   81624             : 
   81625           0 :     ALLOC_MUTEX(SgContainsStatement, unlock);
   81626             : }
   81627             : 
   81628             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   81629             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   81630             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   81631             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   81632             : // Also, note comment below from Robb (copied from the Common.code file).
   81633             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   81634             : //
   81635             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   81636             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   81637             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   81638             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   81639             : #if 0
   81640             : void SgContainsStatement::operator delete(void* pointer) { SgContainsStatement::operator delete (pointer, sizeof(SgContainsStatement)); };
   81641             : #endif
   81642             : /* #line 81643 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   81643             : 
   81644             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   81645             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   81646             : // obviously imply C++.
   81647             : 
   81648             : // This implements the support within ROSE for memory pools.  Memory pools
   81649             : // support the most condensed usage of memory within the construction of
   81650             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   81651             : // by a new operator written for each class.
   81652             : 
   81653             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   81654             :     // User wants multi-thread support and POSIX threads are available.
   81655             : #   include <pthread.h>
   81656             :     static pthread_mutex_t SgC_PreprocessorDirectiveStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   81657             : #else
   81658             :      // Cause synchronization to be skipped.
   81659             : #    ifndef ALLOC_MUTEX
   81660             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   81661             : #    endif
   81662             : #    ifdef _REENTRANT
   81663             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   81664             : #       ifdef _MSC_VER
   81665             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   81666             : #       else
   81667             : #           warning "POSIX threads are not available; synchronization being skipped"
   81668             : #       endif
   81669             : #    endif
   81670             : #endif
   81671             : 
   81672             : #ifndef ROSE_ALLOC_TRACE
   81673             : #  define ROSE_ALLOC_TRACE 0
   81674             : #endif
   81675             : 
   81676             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   81677             : #define ROSE_ALLOC_TRACE_CNT
   81678             : #include "memory-pool-snapshot.h"
   81679             : unsigned long alloc_trace_cnt = 0;
   81680             : #endif
   81681             : 
   81682             : #if ROSE_ALLOC_TRACE
   81683             : const unsigned SgC_PreprocessorDirectiveStatement::pool_size = 5;
   81684             : #else
   81685             : const unsigned SgC_PreprocessorDirectiveStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   81686             : #endif
   81687             : 
   81688             : #ifndef ROSE_ALLOC_MEMSET
   81689             : #  define ROSE_ALLOC_MEMSET 0
   81690             : #endif
   81691             : 
   81692             : #ifndef ROSE_PEDANTIC_ALLOC
   81693             : #  define ROSE_PEDANTIC_ALLOC 0
   81694             : #endif
   81695             : 
   81696             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   81697             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   81698             : #endif
   81699             : 
   81700             : #if !defined(SGNODE__ALL_POOLS)
   81701             : #define SGNODE__ALL_POOLS
   81702             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   81703             : #endif
   81704             : 
   81705             : SgC_PreprocessorDirectiveStatement* SgC_PreprocessorDirectiveStatement::next_node = nullptr;
   81706             : std::vector<unsigned char*> SgC_PreprocessorDirectiveStatement::pools;
   81707             : 
   81708             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   81709             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   81710             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   81711             : // around this macro definition rather than each use).
   81712             : #ifndef ALLOC_MUTEX
   81713             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   81714             :         do {                                                                     \
   81715             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   81716             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   81717             :                 abort();                                                         \
   81718             :             }                                                                    \
   81719             :         } while (0);
   81720             : #endif
   81721             : 
   81722             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   81723             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   81724             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   81725             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   81726             : 
   81727             : /*! \brief New operator for SgC_PreprocessorDirectiveStatement.
   81728             : 
   81729             :    This new operator implements memory pools to provide most efficent 
   81730             :    use of the heap within construction of large ASTs.
   81731             : 
   81732             : \internal The new and delete operators use the lower level C malloc/free
   81733             :    function calls for performance and to make sure that mixing of malloc/free
   81734             :    and new/delete by the used can be caught more readily.  This may change
   81735             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   81736             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   81737             :    deallocate memory allocated using ROSE_MALLOC.
   81738             : */
   81739           0 : void *SgC_PreprocessorDirectiveStatement::operator new ( size_t Size )
   81740             : {
   81741             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   81742             :      * returning or throwing an exception. */
   81743           0 :     ALLOC_MUTEX(SgC_PreprocessorDirectiveStatement, lock);
   81744             : 
   81745             : #if ROSE_ALLOC_TRACE == 2
   81746             : //    printf("SgC_PreprocessorDirectiveStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgC_PreprocessorDirectiveStatement::next_node);
   81747             : #endif
   81748             : 
   81749             : #if USE_CPP_NEW_DELETE_OPERATORS
   81750             :     void *mem = ROSE_MALLOC(Size);
   81751             :     ALLOC_MUTEX(SgC_PreprocessorDirectiveStatement, unlock);
   81752             :     return mem;
   81753             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   81754             : #if ROSE_PEDANTIC_ALLOC
   81755             :     ROSE_ASSERT(Size == sizeof(SgC_PreprocessorDirectiveStatement));
   81756             : #else
   81757           0 :     if (Size != sizeof(SgC_PreprocessorDirectiveStatement)) {
   81758           0 :       void * object = ROSE_MALLOC(Size);
   81759           0 :       ALLOC_MUTEX(SgC_PreprocessorDirectiveStatement, unlock);
   81760             :       return object;
   81761             :     }
   81762             : #endif
   81763             : 
   81764           0 :     if (SgC_PreprocessorDirectiveStatement::next_node == nullptr) {
   81765           0 :         SgC_PreprocessorDirectiveStatement * alloc = (SgC_PreprocessorDirectiveStatement*) ROSE_MALLOC ( SgC_PreprocessorDirectiveStatement::pool_size * sizeof(SgC_PreprocessorDirectiveStatement) );
   81766           0 :         ROSE_ASSERT(alloc != nullptr);
   81767             : 
   81768             : #if ROSE_ALLOC_TRACE == 2
   81769             : //        printf("SgC_PreprocessorDirectiveStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgC_PreprocessorDirectiveStatement::pools.size(), alloc, alloc + SgC_PreprocessorDirectiveStatement::pool_size);
   81770             : #endif
   81771             : 
   81772             : #if ROSE_ALLOC_MEMSET == 1
   81773             : #elif ROSE_ALLOC_MEMSET == 2
   81774             :         memset(alloc, 0x00, SgC_PreprocessorDirectiveStatement::pool_size * sizeof(SgC_PreprocessorDirectiveStatement));
   81775             : #elif ROSE_ALLOC_MEMSET == 3
   81776             :         memset(alloc, 0xAA, SgC_PreprocessorDirectiveStatement::pool_size * sizeof(SgC_PreprocessorDirectiveStatement));
   81777             : #endif
   81778           0 :         for (unsigned i=0; i < SgC_PreprocessorDirectiveStatement::pool_size-1; i++) {
   81779           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
   81780             :         }
   81781           0 :         alloc[SgC_PreprocessorDirectiveStatement::pool_size-1].p_freepointer = nullptr;
   81782             : 
   81783           0 :         SgC_PreprocessorDirectiveStatement::pools.push_back ( (unsigned char *) alloc );
   81784           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgC_PreprocessorDirectiveStatement::pool_size * sizeof(SgC_PreprocessorDirectiveStatement), V_SgC_PreprocessorDirectiveStatement ) );
   81785           0 :         SgC_PreprocessorDirectiveStatement::next_node = alloc;
   81786             :     }
   81787           0 :     ROSE_ASSERT(SgC_PreprocessorDirectiveStatement::next_node != nullptr);
   81788             : 
   81789           0 :     SgC_PreprocessorDirectiveStatement * object = SgC_PreprocessorDirectiveStatement::next_node;
   81790           0 :     SgC_PreprocessorDirectiveStatement::next_node = (SgC_PreprocessorDirectiveStatement*)(object->p_freepointer);
   81791             : 
   81792             : #if ROSE_ALLOC_TRACE == 2
   81793             :     printf("SgC_PreprocessorDirectiveStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgC_PreprocessorDirectiveStatement::next_node);
   81794             : #endif
   81795             : 
   81796           0 :     SgNode * fp = object->p_freepointer;
   81797             : #if ROSE_ALLOC_MEMSET == 1
   81798             : #elif ROSE_ALLOC_MEMSET == 2
   81799             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgC_PreprocessorDirectiveStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   81800             : #elif ROSE_ALLOC_MEMSET == 3
   81801             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgC_PreprocessorDirectiveStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   81802             : #endif
   81803           0 :     object->p_freepointer = fp;
   81804             : 
   81805             : #if ROSE_ALLOC_TRACE == 2
   81806             : //    printf("SgC_PreprocessorDirectiveStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgC_PreprocessorDirectiveStatement::next_node);
   81807             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   81808             :     Rose::MemPool::snapshot(oss.str());
   81809             :     alloc_trace_cnt++;
   81810             : #endif
   81811             : 
   81812           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   81813             : 
   81814           0 :     ALLOC_MUTEX(SgC_PreprocessorDirectiveStatement, unlock);
   81815             : 
   81816             :     return object;
   81817             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   81818             : }
   81819             : 
   81820             : 
   81821             : 
   81822             : /*! \brief Delete operator for SgC_PreprocessorDirectiveStatement.
   81823             : 
   81824             :    This delete operator implements deallocation using memory pools to 
   81825             :    provide most efficent use of the heap within construction of large ASTs.
   81826             : 
   81827             : \internal The new and delete operators use the lower level C malloc/free
   81828             :    function calls for performance and to make sure that mixing of malloc/free
   81829             :    and new/delete by the used can be caught more readily.  This may change
   81830             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   81831             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   81832             :    deallocate memory allocated using ROSE_MALLOC.
   81833             : */
   81834           0 : void SgC_PreprocessorDirectiveStatement::operator delete(void *Pointer, size_t Size)
   81835             : {
   81836             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   81837             :      * or throwing an exception. */
   81838           0 :     ALLOC_MUTEX(SgC_PreprocessorDirectiveStatement, lock);
   81839             : 
   81840             : #if USE_CPP_NEW_DELETE_OPERATORS
   81841             :     ROSE_FREE(Pointer);
   81842             : #else
   81843             : #if ROSE_PEDANTIC_ALLOC
   81844             :     ROSE_ASSERT(Size == sizeof(SgC_PreprocessorDirectiveStatement));
   81845             : #else
   81846           0 :     if (Size != sizeof(SgC_PreprocessorDirectiveStatement)) {
   81847           0 :       ROSE_FREE(Pointer);
   81848           0 :       ALLOC_MUTEX(SgC_PreprocessorDirectiveStatement, unlock);
   81849             :       return;
   81850             :     }
   81851             : #endif
   81852             : 
   81853           0 :     SgC_PreprocessorDirectiveStatement * object = (SgC_PreprocessorDirectiveStatement*) Pointer;
   81854           0 :     ROSE_ASSERT(object != nullptr);
   81855             : 
   81856             : #if ROSE_ALLOC_TRACE == 2
   81857             : //  printf("SgC_PreprocessorDirectiveStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgC_PreprocessorDirectiveStatement::next_node);
   81858             :     printf("SgC_PreprocessorDirectiveStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgC_PreprocessorDirectiveStatement::next_node);
   81859             : #endif
   81860             : 
   81861             : #if ROSE_PEDANTIC_ALLOC
   81862             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   81863             : #endif
   81864             : 
   81865             : #if ROSE_ALLOC_MEMSET == 1
   81866             : #elif ROSE_ALLOC_MEMSET == 2
   81867             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgC_PreprocessorDirectiveStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   81868             : #elif ROSE_ALLOC_MEMSET == 3
   81869             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgC_PreprocessorDirectiveStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   81870             : #endif
   81871             : 
   81872             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   81873             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   81874             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   81875             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   81876             : #else
   81877           0 :     object->p_freepointer = SgC_PreprocessorDirectiveStatement::next_node;
   81878           0 :     SgC_PreprocessorDirectiveStatement::next_node = object;
   81879             : #endif
   81880             : 
   81881             : #if ROSE_ALLOC_TRACE == 2
   81882             : //  printf("SgC_PreprocessorDirectiveStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgC_PreprocessorDirectiveStatement::next_node);
   81883             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   81884             :     Rose::MemPool::snapshot(oss.str());
   81885             :     alloc_trace_cnt++;
   81886             : #endif
   81887             : 
   81888             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   81889             : 
   81890           0 :     ALLOC_MUTEX(SgC_PreprocessorDirectiveStatement, unlock);
   81891             : }
   81892             : 
   81893             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   81894             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   81895             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   81896             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   81897             : // Also, note comment below from Robb (copied from the Common.code file).
   81898             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   81899             : //
   81900             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   81901             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   81902             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   81903             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   81904             : #if 0
   81905             : void SgC_PreprocessorDirectiveStatement::operator delete(void* pointer) { SgC_PreprocessorDirectiveStatement::operator delete (pointer, sizeof(SgC_PreprocessorDirectiveStatement)); };
   81906             : #endif
   81907             : /* #line 81908 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   81908             : 
   81909             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   81910             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   81911             : // obviously imply C++.
   81912             : 
   81913             : // This implements the support within ROSE for memory pools.  Memory pools
   81914             : // support the most condensed usage of memory within the construction of
   81915             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   81916             : // by a new operator written for each class.
   81917             : 
   81918             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   81919             :     // User wants multi-thread support and POSIX threads are available.
   81920             : #   include <pthread.h>
   81921             :     static pthread_mutex_t SgIncludeDirectiveStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   81922             : #else
   81923             :      // Cause synchronization to be skipped.
   81924             : #    ifndef ALLOC_MUTEX
   81925             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   81926             : #    endif
   81927             : #    ifdef _REENTRANT
   81928             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   81929             : #       ifdef _MSC_VER
   81930             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   81931             : #       else
   81932             : #           warning "POSIX threads are not available; synchronization being skipped"
   81933             : #       endif
   81934             : #    endif
   81935             : #endif
   81936             : 
   81937             : #ifndef ROSE_ALLOC_TRACE
   81938             : #  define ROSE_ALLOC_TRACE 0
   81939             : #endif
   81940             : 
   81941             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   81942             : #define ROSE_ALLOC_TRACE_CNT
   81943             : #include "memory-pool-snapshot.h"
   81944             : unsigned long alloc_trace_cnt = 0;
   81945             : #endif
   81946             : 
   81947             : #if ROSE_ALLOC_TRACE
   81948             : const unsigned SgIncludeDirectiveStatement::pool_size = 5;
   81949             : #else
   81950             : const unsigned SgIncludeDirectiveStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   81951             : #endif
   81952             : 
   81953             : #ifndef ROSE_ALLOC_MEMSET
   81954             : #  define ROSE_ALLOC_MEMSET 0
   81955             : #endif
   81956             : 
   81957             : #ifndef ROSE_PEDANTIC_ALLOC
   81958             : #  define ROSE_PEDANTIC_ALLOC 0
   81959             : #endif
   81960             : 
   81961             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   81962             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   81963             : #endif
   81964             : 
   81965             : #if !defined(SGNODE__ALL_POOLS)
   81966             : #define SGNODE__ALL_POOLS
   81967             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   81968             : #endif
   81969             : 
   81970             : SgIncludeDirectiveStatement* SgIncludeDirectiveStatement::next_node = nullptr;
   81971             : std::vector<unsigned char*> SgIncludeDirectiveStatement::pools;
   81972             : 
   81973             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   81974             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   81975             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   81976             : // around this macro definition rather than each use).
   81977             : #ifndef ALLOC_MUTEX
   81978             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   81979             :         do {                                                                     \
   81980             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   81981             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   81982             :                 abort();                                                         \
   81983             :             }                                                                    \
   81984             :         } while (0);
   81985             : #endif
   81986             : 
   81987             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   81988             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   81989             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   81990             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   81991             : 
   81992             : /*! \brief New operator for SgIncludeDirectiveStatement.
   81993             : 
   81994             :    This new operator implements memory pools to provide most efficent 
   81995             :    use of the heap within construction of large ASTs.
   81996             : 
   81997             : \internal The new and delete operators use the lower level C malloc/free
   81998             :    function calls for performance and to make sure that mixing of malloc/free
   81999             :    and new/delete by the used can be caught more readily.  This may change
   82000             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   82001             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   82002             :    deallocate memory allocated using ROSE_MALLOC.
   82003             : */
   82004           0 : void *SgIncludeDirectiveStatement::operator new ( size_t Size )
   82005             : {
   82006             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   82007             :      * returning or throwing an exception. */
   82008           0 :     ALLOC_MUTEX(SgIncludeDirectiveStatement, lock);
   82009             : 
   82010             : #if ROSE_ALLOC_TRACE == 2
   82011             : //    printf("SgIncludeDirectiveStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgIncludeDirectiveStatement::next_node);
   82012             : #endif
   82013             : 
   82014             : #if USE_CPP_NEW_DELETE_OPERATORS
   82015             :     void *mem = ROSE_MALLOC(Size);
   82016             :     ALLOC_MUTEX(SgIncludeDirectiveStatement, unlock);
   82017             :     return mem;
   82018             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   82019             : #if ROSE_PEDANTIC_ALLOC
   82020             :     ROSE_ASSERT(Size == sizeof(SgIncludeDirectiveStatement));
   82021             : #else
   82022           0 :     if (Size != sizeof(SgIncludeDirectiveStatement)) {
   82023           0 :       void * object = ROSE_MALLOC(Size);
   82024           0 :       ALLOC_MUTEX(SgIncludeDirectiveStatement, unlock);
   82025             :       return object;
   82026             :     }
   82027             : #endif
   82028             : 
   82029           0 :     if (SgIncludeDirectiveStatement::next_node == nullptr) {
   82030           0 :         SgIncludeDirectiveStatement * alloc = (SgIncludeDirectiveStatement*) ROSE_MALLOC ( SgIncludeDirectiveStatement::pool_size * sizeof(SgIncludeDirectiveStatement) );
   82031           0 :         ROSE_ASSERT(alloc != nullptr);
   82032             : 
   82033             : #if ROSE_ALLOC_TRACE == 2
   82034             : //        printf("SgIncludeDirectiveStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgIncludeDirectiveStatement::pools.size(), alloc, alloc + SgIncludeDirectiveStatement::pool_size);
   82035             : #endif
   82036             : 
   82037             : #if ROSE_ALLOC_MEMSET == 1
   82038             : #elif ROSE_ALLOC_MEMSET == 2
   82039             :         memset(alloc, 0x00, SgIncludeDirectiveStatement::pool_size * sizeof(SgIncludeDirectiveStatement));
   82040             : #elif ROSE_ALLOC_MEMSET == 3
   82041             :         memset(alloc, 0xAA, SgIncludeDirectiveStatement::pool_size * sizeof(SgIncludeDirectiveStatement));
   82042             : #endif
   82043           0 :         for (unsigned i=0; i < SgIncludeDirectiveStatement::pool_size-1; i++) {
   82044           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
   82045             :         }
   82046           0 :         alloc[SgIncludeDirectiveStatement::pool_size-1].p_freepointer = nullptr;
   82047             : 
   82048           0 :         SgIncludeDirectiveStatement::pools.push_back ( (unsigned char *) alloc );
   82049           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgIncludeDirectiveStatement::pool_size * sizeof(SgIncludeDirectiveStatement), V_SgIncludeDirectiveStatement ) );
   82050           0 :         SgIncludeDirectiveStatement::next_node = alloc;
   82051             :     }
   82052           0 :     ROSE_ASSERT(SgIncludeDirectiveStatement::next_node != nullptr);
   82053             : 
   82054           0 :     SgIncludeDirectiveStatement * object = SgIncludeDirectiveStatement::next_node;
   82055           0 :     SgIncludeDirectiveStatement::next_node = (SgIncludeDirectiveStatement*)(object->p_freepointer);
   82056             : 
   82057             : #if ROSE_ALLOC_TRACE == 2
   82058             :     printf("SgIncludeDirectiveStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgIncludeDirectiveStatement::next_node);
   82059             : #endif
   82060             : 
   82061           0 :     SgNode * fp = object->p_freepointer;
   82062             : #if ROSE_ALLOC_MEMSET == 1
   82063             : #elif ROSE_ALLOC_MEMSET == 2
   82064             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgIncludeDirectiveStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   82065             : #elif ROSE_ALLOC_MEMSET == 3
   82066             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgIncludeDirectiveStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   82067             : #endif
   82068           0 :     object->p_freepointer = fp;
   82069             : 
   82070             : #if ROSE_ALLOC_TRACE == 2
   82071             : //    printf("SgIncludeDirectiveStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgIncludeDirectiveStatement::next_node);
   82072             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   82073             :     Rose::MemPool::snapshot(oss.str());
   82074             :     alloc_trace_cnt++;
   82075             : #endif
   82076             : 
   82077           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   82078             : 
   82079           0 :     ALLOC_MUTEX(SgIncludeDirectiveStatement, unlock);
   82080             : 
   82081             :     return object;
   82082             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   82083             : }
   82084             : 
   82085             : 
   82086             : 
   82087             : /*! \brief Delete operator for SgIncludeDirectiveStatement.
   82088             : 
   82089             :    This delete operator implements deallocation using memory pools to 
   82090             :    provide most efficent use of the heap within construction of large ASTs.
   82091             : 
   82092             : \internal The new and delete operators use the lower level C malloc/free
   82093             :    function calls for performance and to make sure that mixing of malloc/free
   82094             :    and new/delete by the used can be caught more readily.  This may change
   82095             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   82096             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   82097             :    deallocate memory allocated using ROSE_MALLOC.
   82098             : */
   82099           0 : void SgIncludeDirectiveStatement::operator delete(void *Pointer, size_t Size)
   82100             : {
   82101             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   82102             :      * or throwing an exception. */
   82103           0 :     ALLOC_MUTEX(SgIncludeDirectiveStatement, lock);
   82104             : 
   82105             : #if USE_CPP_NEW_DELETE_OPERATORS
   82106             :     ROSE_FREE(Pointer);
   82107             : #else
   82108             : #if ROSE_PEDANTIC_ALLOC
   82109             :     ROSE_ASSERT(Size == sizeof(SgIncludeDirectiveStatement));
   82110             : #else
   82111           0 :     if (Size != sizeof(SgIncludeDirectiveStatement)) {
   82112           0 :       ROSE_FREE(Pointer);
   82113           0 :       ALLOC_MUTEX(SgIncludeDirectiveStatement, unlock);
   82114             :       return;
   82115             :     }
   82116             : #endif
   82117             : 
   82118           0 :     SgIncludeDirectiveStatement * object = (SgIncludeDirectiveStatement*) Pointer;
   82119           0 :     ROSE_ASSERT(object != nullptr);
   82120             : 
   82121             : #if ROSE_ALLOC_TRACE == 2
   82122             : //  printf("SgIncludeDirectiveStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgIncludeDirectiveStatement::next_node);
   82123             :     printf("SgIncludeDirectiveStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgIncludeDirectiveStatement::next_node);
   82124             : #endif
   82125             : 
   82126             : #if ROSE_PEDANTIC_ALLOC
   82127             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   82128             : #endif
   82129             : 
   82130             : #if ROSE_ALLOC_MEMSET == 1
   82131             : #elif ROSE_ALLOC_MEMSET == 2
   82132             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgIncludeDirectiveStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   82133             : #elif ROSE_ALLOC_MEMSET == 3
   82134             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgIncludeDirectiveStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   82135             : #endif
   82136             : 
   82137             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   82138             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   82139             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   82140             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   82141             : #else
   82142           0 :     object->p_freepointer = SgIncludeDirectiveStatement::next_node;
   82143           0 :     SgIncludeDirectiveStatement::next_node = object;
   82144             : #endif
   82145             : 
   82146             : #if ROSE_ALLOC_TRACE == 2
   82147             : //  printf("SgIncludeDirectiveStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgIncludeDirectiveStatement::next_node);
   82148             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   82149             :     Rose::MemPool::snapshot(oss.str());
   82150             :     alloc_trace_cnt++;
   82151             : #endif
   82152             : 
   82153             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   82154             : 
   82155           0 :     ALLOC_MUTEX(SgIncludeDirectiveStatement, unlock);
   82156             : }
   82157             : 
   82158             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   82159             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   82160             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   82161             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   82162             : // Also, note comment below from Robb (copied from the Common.code file).
   82163             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   82164             : //
   82165             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   82166             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   82167             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   82168             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   82169             : #if 0
   82170             : void SgIncludeDirectiveStatement::operator delete(void* pointer) { SgIncludeDirectiveStatement::operator delete (pointer, sizeof(SgIncludeDirectiveStatement)); };
   82171             : #endif
   82172             : /* #line 82173 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   82173             : 
   82174             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   82175             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   82176             : // obviously imply C++.
   82177             : 
   82178             : // This implements the support within ROSE for memory pools.  Memory pools
   82179             : // support the most condensed usage of memory within the construction of
   82180             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   82181             : // by a new operator written for each class.
   82182             : 
   82183             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   82184             :     // User wants multi-thread support and POSIX threads are available.
   82185             : #   include <pthread.h>
   82186             :     static pthread_mutex_t SgDefineDirectiveStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   82187             : #else
   82188             :      // Cause synchronization to be skipped.
   82189             : #    ifndef ALLOC_MUTEX
   82190             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   82191             : #    endif
   82192             : #    ifdef _REENTRANT
   82193             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   82194             : #       ifdef _MSC_VER
   82195             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   82196             : #       else
   82197             : #           warning "POSIX threads are not available; synchronization being skipped"
   82198             : #       endif
   82199             : #    endif
   82200             : #endif
   82201             : 
   82202             : #ifndef ROSE_ALLOC_TRACE
   82203             : #  define ROSE_ALLOC_TRACE 0
   82204             : #endif
   82205             : 
   82206             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   82207             : #define ROSE_ALLOC_TRACE_CNT
   82208             : #include "memory-pool-snapshot.h"
   82209             : unsigned long alloc_trace_cnt = 0;
   82210             : #endif
   82211             : 
   82212             : #if ROSE_ALLOC_TRACE
   82213             : const unsigned SgDefineDirectiveStatement::pool_size = 5;
   82214             : #else
   82215             : const unsigned SgDefineDirectiveStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   82216             : #endif
   82217             : 
   82218             : #ifndef ROSE_ALLOC_MEMSET
   82219             : #  define ROSE_ALLOC_MEMSET 0
   82220             : #endif
   82221             : 
   82222             : #ifndef ROSE_PEDANTIC_ALLOC
   82223             : #  define ROSE_PEDANTIC_ALLOC 0
   82224             : #endif
   82225             : 
   82226             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   82227             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   82228             : #endif
   82229             : 
   82230             : #if !defined(SGNODE__ALL_POOLS)
   82231             : #define SGNODE__ALL_POOLS
   82232             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   82233             : #endif
   82234             : 
   82235             : SgDefineDirectiveStatement* SgDefineDirectiveStatement::next_node = nullptr;
   82236             : std::vector<unsigned char*> SgDefineDirectiveStatement::pools;
   82237             : 
   82238             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   82239             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   82240             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   82241             : // around this macro definition rather than each use).
   82242             : #ifndef ALLOC_MUTEX
   82243             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   82244             :         do {                                                                     \
   82245             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   82246             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   82247             :                 abort();                                                         \
   82248             :             }                                                                    \
   82249             :         } while (0);
   82250             : #endif
   82251             : 
   82252             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   82253             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   82254             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   82255             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   82256             : 
   82257             : /*! \brief New operator for SgDefineDirectiveStatement.
   82258             : 
   82259             :    This new operator implements memory pools to provide most efficent 
   82260             :    use of the heap within construction of large ASTs.
   82261             : 
   82262             : \internal The new and delete operators use the lower level C malloc/free
   82263             :    function calls for performance and to make sure that mixing of malloc/free
   82264             :    and new/delete by the used can be caught more readily.  This may change
   82265             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   82266             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   82267             :    deallocate memory allocated using ROSE_MALLOC.
   82268             : */
   82269           0 : void *SgDefineDirectiveStatement::operator new ( size_t Size )
   82270             : {
   82271             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   82272             :      * returning or throwing an exception. */
   82273           0 :     ALLOC_MUTEX(SgDefineDirectiveStatement, lock);
   82274             : 
   82275             : #if ROSE_ALLOC_TRACE == 2
   82276             : //    printf("SgDefineDirectiveStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgDefineDirectiveStatement::next_node);
   82277             : #endif
   82278             : 
   82279             : #if USE_CPP_NEW_DELETE_OPERATORS
   82280             :     void *mem = ROSE_MALLOC(Size);
   82281             :     ALLOC_MUTEX(SgDefineDirectiveStatement, unlock);
   82282             :     return mem;
   82283             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   82284             : #if ROSE_PEDANTIC_ALLOC
   82285             :     ROSE_ASSERT(Size == sizeof(SgDefineDirectiveStatement));
   82286             : #else
   82287           0 :     if (Size != sizeof(SgDefineDirectiveStatement)) {
   82288           0 :       void * object = ROSE_MALLOC(Size);
   82289           0 :       ALLOC_MUTEX(SgDefineDirectiveStatement, unlock);
   82290             :       return object;
   82291             :     }
   82292             : #endif
   82293             : 
   82294           0 :     if (SgDefineDirectiveStatement::next_node == nullptr) {
   82295           0 :         SgDefineDirectiveStatement * alloc = (SgDefineDirectiveStatement*) ROSE_MALLOC ( SgDefineDirectiveStatement::pool_size * sizeof(SgDefineDirectiveStatement) );
   82296           0 :         ROSE_ASSERT(alloc != nullptr);
   82297             : 
   82298             : #if ROSE_ALLOC_TRACE == 2
   82299             : //        printf("SgDefineDirectiveStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgDefineDirectiveStatement::pools.size(), alloc, alloc + SgDefineDirectiveStatement::pool_size);
   82300             : #endif
   82301             : 
   82302             : #if ROSE_ALLOC_MEMSET == 1
   82303             : #elif ROSE_ALLOC_MEMSET == 2
   82304             :         memset(alloc, 0x00, SgDefineDirectiveStatement::pool_size * sizeof(SgDefineDirectiveStatement));
   82305             : #elif ROSE_ALLOC_MEMSET == 3
   82306             :         memset(alloc, 0xAA, SgDefineDirectiveStatement::pool_size * sizeof(SgDefineDirectiveStatement));
   82307             : #endif
   82308           0 :         for (unsigned i=0; i < SgDefineDirectiveStatement::pool_size-1; i++) {
   82309           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
   82310             :         }
   82311           0 :         alloc[SgDefineDirectiveStatement::pool_size-1].p_freepointer = nullptr;
   82312             : 
   82313           0 :         SgDefineDirectiveStatement::pools.push_back ( (unsigned char *) alloc );
   82314           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgDefineDirectiveStatement::pool_size * sizeof(SgDefineDirectiveStatement), V_SgDefineDirectiveStatement ) );
   82315           0 :         SgDefineDirectiveStatement::next_node = alloc;
   82316             :     }
   82317           0 :     ROSE_ASSERT(SgDefineDirectiveStatement::next_node != nullptr);
   82318             : 
   82319           0 :     SgDefineDirectiveStatement * object = SgDefineDirectiveStatement::next_node;
   82320           0 :     SgDefineDirectiveStatement::next_node = (SgDefineDirectiveStatement*)(object->p_freepointer);
   82321             : 
   82322             : #if ROSE_ALLOC_TRACE == 2
   82323             :     printf("SgDefineDirectiveStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgDefineDirectiveStatement::next_node);
   82324             : #endif
   82325             : 
   82326           0 :     SgNode * fp = object->p_freepointer;
   82327             : #if ROSE_ALLOC_MEMSET == 1
   82328             : #elif ROSE_ALLOC_MEMSET == 2
   82329             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgDefineDirectiveStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   82330             : #elif ROSE_ALLOC_MEMSET == 3
   82331             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgDefineDirectiveStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   82332             : #endif
   82333           0 :     object->p_freepointer = fp;
   82334             : 
   82335             : #if ROSE_ALLOC_TRACE == 2
   82336             : //    printf("SgDefineDirectiveStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgDefineDirectiveStatement::next_node);
   82337             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   82338             :     Rose::MemPool::snapshot(oss.str());
   82339             :     alloc_trace_cnt++;
   82340             : #endif
   82341             : 
   82342           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   82343             : 
   82344           0 :     ALLOC_MUTEX(SgDefineDirectiveStatement, unlock);
   82345             : 
   82346             :     return object;
   82347             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   82348             : }
   82349             : 
   82350             : 
   82351             : 
   82352             : /*! \brief Delete operator for SgDefineDirectiveStatement.
   82353             : 
   82354             :    This delete operator implements deallocation using memory pools to 
   82355             :    provide most efficent use of the heap within construction of large ASTs.
   82356             : 
   82357             : \internal The new and delete operators use the lower level C malloc/free
   82358             :    function calls for performance and to make sure that mixing of malloc/free
   82359             :    and new/delete by the used can be caught more readily.  This may change
   82360             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   82361             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   82362             :    deallocate memory allocated using ROSE_MALLOC.
   82363             : */
   82364           0 : void SgDefineDirectiveStatement::operator delete(void *Pointer, size_t Size)
   82365             : {
   82366             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   82367             :      * or throwing an exception. */
   82368           0 :     ALLOC_MUTEX(SgDefineDirectiveStatement, lock);
   82369             : 
   82370             : #if USE_CPP_NEW_DELETE_OPERATORS
   82371             :     ROSE_FREE(Pointer);
   82372             : #else
   82373             : #if ROSE_PEDANTIC_ALLOC
   82374             :     ROSE_ASSERT(Size == sizeof(SgDefineDirectiveStatement));
   82375             : #else
   82376           0 :     if (Size != sizeof(SgDefineDirectiveStatement)) {
   82377           0 :       ROSE_FREE(Pointer);
   82378           0 :       ALLOC_MUTEX(SgDefineDirectiveStatement, unlock);
   82379             :       return;
   82380             :     }
   82381             : #endif
   82382             : 
   82383           0 :     SgDefineDirectiveStatement * object = (SgDefineDirectiveStatement*) Pointer;
   82384           0 :     ROSE_ASSERT(object != nullptr);
   82385             : 
   82386             : #if ROSE_ALLOC_TRACE == 2
   82387             : //  printf("SgDefineDirectiveStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgDefineDirectiveStatement::next_node);
   82388             :     printf("SgDefineDirectiveStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgDefineDirectiveStatement::next_node);
   82389             : #endif
   82390             : 
   82391             : #if ROSE_PEDANTIC_ALLOC
   82392             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   82393             : #endif
   82394             : 
   82395             : #if ROSE_ALLOC_MEMSET == 1
   82396             : #elif ROSE_ALLOC_MEMSET == 2
   82397             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgDefineDirectiveStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   82398             : #elif ROSE_ALLOC_MEMSET == 3
   82399             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgDefineDirectiveStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   82400             : #endif
   82401             : 
   82402             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   82403             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   82404             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   82405             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   82406             : #else
   82407           0 :     object->p_freepointer = SgDefineDirectiveStatement::next_node;
   82408           0 :     SgDefineDirectiveStatement::next_node = object;
   82409             : #endif
   82410             : 
   82411             : #if ROSE_ALLOC_TRACE == 2
   82412             : //  printf("SgDefineDirectiveStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgDefineDirectiveStatement::next_node);
   82413             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   82414             :     Rose::MemPool::snapshot(oss.str());
   82415             :     alloc_trace_cnt++;
   82416             : #endif
   82417             : 
   82418             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   82419             : 
   82420           0 :     ALLOC_MUTEX(SgDefineDirectiveStatement, unlock);
   82421             : }
   82422             : 
   82423             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   82424             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   82425             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   82426             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   82427             : // Also, note comment below from Robb (copied from the Common.code file).
   82428             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   82429             : //
   82430             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   82431             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   82432             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   82433             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   82434             : #if 0
   82435             : void SgDefineDirectiveStatement::operator delete(void* pointer) { SgDefineDirectiveStatement::operator delete (pointer, sizeof(SgDefineDirectiveStatement)); };
   82436             : #endif
   82437             : /* #line 82438 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   82438             : 
   82439             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   82440             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   82441             : // obviously imply C++.
   82442             : 
   82443             : // This implements the support within ROSE for memory pools.  Memory pools
   82444             : // support the most condensed usage of memory within the construction of
   82445             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   82446             : // by a new operator written for each class.
   82447             : 
   82448             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   82449             :     // User wants multi-thread support and POSIX threads are available.
   82450             : #   include <pthread.h>
   82451             :     static pthread_mutex_t SgUndefDirectiveStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   82452             : #else
   82453             :      // Cause synchronization to be skipped.
   82454             : #    ifndef ALLOC_MUTEX
   82455             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   82456             : #    endif
   82457             : #    ifdef _REENTRANT
   82458             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   82459             : #       ifdef _MSC_VER
   82460             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   82461             : #       else
   82462             : #           warning "POSIX threads are not available; synchronization being skipped"
   82463             : #       endif
   82464             : #    endif
   82465             : #endif
   82466             : 
   82467             : #ifndef ROSE_ALLOC_TRACE
   82468             : #  define ROSE_ALLOC_TRACE 0
   82469             : #endif
   82470             : 
   82471             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   82472             : #define ROSE_ALLOC_TRACE_CNT
   82473             : #include "memory-pool-snapshot.h"
   82474             : unsigned long alloc_trace_cnt = 0;
   82475             : #endif
   82476             : 
   82477             : #if ROSE_ALLOC_TRACE
   82478             : const unsigned SgUndefDirectiveStatement::pool_size = 5;
   82479             : #else
   82480             : const unsigned SgUndefDirectiveStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   82481             : #endif
   82482             : 
   82483             : #ifndef ROSE_ALLOC_MEMSET
   82484             : #  define ROSE_ALLOC_MEMSET 0
   82485             : #endif
   82486             : 
   82487             : #ifndef ROSE_PEDANTIC_ALLOC
   82488             : #  define ROSE_PEDANTIC_ALLOC 0
   82489             : #endif
   82490             : 
   82491             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   82492             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   82493             : #endif
   82494             : 
   82495             : #if !defined(SGNODE__ALL_POOLS)
   82496             : #define SGNODE__ALL_POOLS
   82497             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   82498             : #endif
   82499             : 
   82500             : SgUndefDirectiveStatement* SgUndefDirectiveStatement::next_node = nullptr;
   82501             : std::vector<unsigned char*> SgUndefDirectiveStatement::pools;
   82502             : 
   82503             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   82504             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   82505             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   82506             : // around this macro definition rather than each use).
   82507             : #ifndef ALLOC_MUTEX
   82508             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   82509             :         do {                                                                     \
   82510             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   82511             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   82512             :                 abort();                                                         \
   82513             :             }                                                                    \
   82514             :         } while (0);
   82515             : #endif
   82516             : 
   82517             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   82518             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   82519             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   82520             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   82521             : 
   82522             : /*! \brief New operator for SgUndefDirectiveStatement.
   82523             : 
   82524             :    This new operator implements memory pools to provide most efficent 
   82525             :    use of the heap within construction of large ASTs.
   82526             : 
   82527             : \internal The new and delete operators use the lower level C malloc/free
   82528             :    function calls for performance and to make sure that mixing of malloc/free
   82529             :    and new/delete by the used can be caught more readily.  This may change
   82530             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   82531             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   82532             :    deallocate memory allocated using ROSE_MALLOC.
   82533             : */
   82534           0 : void *SgUndefDirectiveStatement::operator new ( size_t Size )
   82535             : {
   82536             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   82537             :      * returning or throwing an exception. */
   82538           0 :     ALLOC_MUTEX(SgUndefDirectiveStatement, lock);
   82539             : 
   82540             : #if ROSE_ALLOC_TRACE == 2
   82541             : //    printf("SgUndefDirectiveStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgUndefDirectiveStatement::next_node);
   82542             : #endif
   82543             : 
   82544             : #if USE_CPP_NEW_DELETE_OPERATORS
   82545             :     void *mem = ROSE_MALLOC(Size);
   82546             :     ALLOC_MUTEX(SgUndefDirectiveStatement, unlock);
   82547             :     return mem;
   82548             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   82549             : #if ROSE_PEDANTIC_ALLOC
   82550             :     ROSE_ASSERT(Size == sizeof(SgUndefDirectiveStatement));
   82551             : #else
   82552           0 :     if (Size != sizeof(SgUndefDirectiveStatement)) {
   82553           0 :       void * object = ROSE_MALLOC(Size);
   82554           0 :       ALLOC_MUTEX(SgUndefDirectiveStatement, unlock);
   82555             :       return object;
   82556             :     }
   82557             : #endif
   82558             : 
   82559           0 :     if (SgUndefDirectiveStatement::next_node == nullptr) {
   82560           0 :         SgUndefDirectiveStatement * alloc = (SgUndefDirectiveStatement*) ROSE_MALLOC ( SgUndefDirectiveStatement::pool_size * sizeof(SgUndefDirectiveStatement) );
   82561           0 :         ROSE_ASSERT(alloc != nullptr);
   82562             : 
   82563             : #if ROSE_ALLOC_TRACE == 2
   82564             : //        printf("SgUndefDirectiveStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgUndefDirectiveStatement::pools.size(), alloc, alloc + SgUndefDirectiveStatement::pool_size);
   82565             : #endif
   82566             : 
   82567             : #if ROSE_ALLOC_MEMSET == 1
   82568             : #elif ROSE_ALLOC_MEMSET == 2
   82569             :         memset(alloc, 0x00, SgUndefDirectiveStatement::pool_size * sizeof(SgUndefDirectiveStatement));
   82570             : #elif ROSE_ALLOC_MEMSET == 3
   82571             :         memset(alloc, 0xAA, SgUndefDirectiveStatement::pool_size * sizeof(SgUndefDirectiveStatement));
   82572             : #endif
   82573           0 :         for (unsigned i=0; i < SgUndefDirectiveStatement::pool_size-1; i++) {
   82574           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
   82575             :         }
   82576           0 :         alloc[SgUndefDirectiveStatement::pool_size-1].p_freepointer = nullptr;
   82577             : 
   82578           0 :         SgUndefDirectiveStatement::pools.push_back ( (unsigned char *) alloc );
   82579           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgUndefDirectiveStatement::pool_size * sizeof(SgUndefDirectiveStatement), V_SgUndefDirectiveStatement ) );
   82580           0 :         SgUndefDirectiveStatement::next_node = alloc;
   82581             :     }
   82582           0 :     ROSE_ASSERT(SgUndefDirectiveStatement::next_node != nullptr);
   82583             : 
   82584           0 :     SgUndefDirectiveStatement * object = SgUndefDirectiveStatement::next_node;
   82585           0 :     SgUndefDirectiveStatement::next_node = (SgUndefDirectiveStatement*)(object->p_freepointer);
   82586             : 
   82587             : #if ROSE_ALLOC_TRACE == 2
   82588             :     printf("SgUndefDirectiveStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUndefDirectiveStatement::next_node);
   82589             : #endif
   82590             : 
   82591           0 :     SgNode * fp = object->p_freepointer;
   82592             : #if ROSE_ALLOC_MEMSET == 1
   82593             : #elif ROSE_ALLOC_MEMSET == 2
   82594             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgUndefDirectiveStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   82595             : #elif ROSE_ALLOC_MEMSET == 3
   82596             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgUndefDirectiveStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   82597             : #endif
   82598           0 :     object->p_freepointer = fp;
   82599             : 
   82600             : #if ROSE_ALLOC_TRACE == 2
   82601             : //    printf("SgUndefDirectiveStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUndefDirectiveStatement::next_node);
   82602             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   82603             :     Rose::MemPool::snapshot(oss.str());
   82604             :     alloc_trace_cnt++;
   82605             : #endif
   82606             : 
   82607           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   82608             : 
   82609           0 :     ALLOC_MUTEX(SgUndefDirectiveStatement, unlock);
   82610             : 
   82611             :     return object;
   82612             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   82613             : }
   82614             : 
   82615             : 
   82616             : 
   82617             : /*! \brief Delete operator for SgUndefDirectiveStatement.
   82618             : 
   82619             :    This delete operator implements deallocation using memory pools to 
   82620             :    provide most efficent use of the heap within construction of large ASTs.
   82621             : 
   82622             : \internal The new and delete operators use the lower level C malloc/free
   82623             :    function calls for performance and to make sure that mixing of malloc/free
   82624             :    and new/delete by the used can be caught more readily.  This may change
   82625             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   82626             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   82627             :    deallocate memory allocated using ROSE_MALLOC.
   82628             : */
   82629           0 : void SgUndefDirectiveStatement::operator delete(void *Pointer, size_t Size)
   82630             : {
   82631             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   82632             :      * or throwing an exception. */
   82633           0 :     ALLOC_MUTEX(SgUndefDirectiveStatement, lock);
   82634             : 
   82635             : #if USE_CPP_NEW_DELETE_OPERATORS
   82636             :     ROSE_FREE(Pointer);
   82637             : #else
   82638             : #if ROSE_PEDANTIC_ALLOC
   82639             :     ROSE_ASSERT(Size == sizeof(SgUndefDirectiveStatement));
   82640             : #else
   82641           0 :     if (Size != sizeof(SgUndefDirectiveStatement)) {
   82642           0 :       ROSE_FREE(Pointer);
   82643           0 :       ALLOC_MUTEX(SgUndefDirectiveStatement, unlock);
   82644             :       return;
   82645             :     }
   82646             : #endif
   82647             : 
   82648           0 :     SgUndefDirectiveStatement * object = (SgUndefDirectiveStatement*) Pointer;
   82649           0 :     ROSE_ASSERT(object != nullptr);
   82650             : 
   82651             : #if ROSE_ALLOC_TRACE == 2
   82652             : //  printf("SgUndefDirectiveStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUndefDirectiveStatement::next_node);
   82653             :     printf("SgUndefDirectiveStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUndefDirectiveStatement::next_node);
   82654             : #endif
   82655             : 
   82656             : #if ROSE_PEDANTIC_ALLOC
   82657             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   82658             : #endif
   82659             : 
   82660             : #if ROSE_ALLOC_MEMSET == 1
   82661             : #elif ROSE_ALLOC_MEMSET == 2
   82662             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgUndefDirectiveStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   82663             : #elif ROSE_ALLOC_MEMSET == 3
   82664             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgUndefDirectiveStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   82665             : #endif
   82666             : 
   82667             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   82668             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   82669             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   82670             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   82671             : #else
   82672           0 :     object->p_freepointer = SgUndefDirectiveStatement::next_node;
   82673           0 :     SgUndefDirectiveStatement::next_node = object;
   82674             : #endif
   82675             : 
   82676             : #if ROSE_ALLOC_TRACE == 2
   82677             : //  printf("SgUndefDirectiveStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUndefDirectiveStatement::next_node);
   82678             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   82679             :     Rose::MemPool::snapshot(oss.str());
   82680             :     alloc_trace_cnt++;
   82681             : #endif
   82682             : 
   82683             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   82684             : 
   82685           0 :     ALLOC_MUTEX(SgUndefDirectiveStatement, unlock);
   82686             : }
   82687             : 
   82688             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   82689             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   82690             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   82691             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   82692             : // Also, note comment below from Robb (copied from the Common.code file).
   82693             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   82694             : //
   82695             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   82696             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   82697             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   82698             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   82699             : #if 0
   82700             : void SgUndefDirectiveStatement::operator delete(void* pointer) { SgUndefDirectiveStatement::operator delete (pointer, sizeof(SgUndefDirectiveStatement)); };
   82701             : #endif
   82702             : /* #line 82703 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   82703             : 
   82704             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   82705             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   82706             : // obviously imply C++.
   82707             : 
   82708             : // This implements the support within ROSE for memory pools.  Memory pools
   82709             : // support the most condensed usage of memory within the construction of
   82710             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   82711             : // by a new operator written for each class.
   82712             : 
   82713             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   82714             :     // User wants multi-thread support and POSIX threads are available.
   82715             : #   include <pthread.h>
   82716             :     static pthread_mutex_t SgIfdefDirectiveStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   82717             : #else
   82718             :      // Cause synchronization to be skipped.
   82719             : #    ifndef ALLOC_MUTEX
   82720             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   82721             : #    endif
   82722             : #    ifdef _REENTRANT
   82723             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   82724             : #       ifdef _MSC_VER
   82725             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   82726             : #       else
   82727             : #           warning "POSIX threads are not available; synchronization being skipped"
   82728             : #       endif
   82729             : #    endif
   82730             : #endif
   82731             : 
   82732             : #ifndef ROSE_ALLOC_TRACE
   82733             : #  define ROSE_ALLOC_TRACE 0
   82734             : #endif
   82735             : 
   82736             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   82737             : #define ROSE_ALLOC_TRACE_CNT
   82738             : #include "memory-pool-snapshot.h"
   82739             : unsigned long alloc_trace_cnt = 0;
   82740             : #endif
   82741             : 
   82742             : #if ROSE_ALLOC_TRACE
   82743             : const unsigned SgIfdefDirectiveStatement::pool_size = 5;
   82744             : #else
   82745             : const unsigned SgIfdefDirectiveStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   82746             : #endif
   82747             : 
   82748             : #ifndef ROSE_ALLOC_MEMSET
   82749             : #  define ROSE_ALLOC_MEMSET 0
   82750             : #endif
   82751             : 
   82752             : #ifndef ROSE_PEDANTIC_ALLOC
   82753             : #  define ROSE_PEDANTIC_ALLOC 0
   82754             : #endif
   82755             : 
   82756             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   82757             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   82758             : #endif
   82759             : 
   82760             : #if !defined(SGNODE__ALL_POOLS)
   82761             : #define SGNODE__ALL_POOLS
   82762             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   82763             : #endif
   82764             : 
   82765             : SgIfdefDirectiveStatement* SgIfdefDirectiveStatement::next_node = nullptr;
   82766             : std::vector<unsigned char*> SgIfdefDirectiveStatement::pools;
   82767             : 
   82768             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   82769             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   82770             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   82771             : // around this macro definition rather than each use).
   82772             : #ifndef ALLOC_MUTEX
   82773             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   82774             :         do {                                                                     \
   82775             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   82776             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   82777             :                 abort();                                                         \
   82778             :             }                                                                    \
   82779             :         } while (0);
   82780             : #endif
   82781             : 
   82782             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   82783             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   82784             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   82785             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   82786             : 
   82787             : /*! \brief New operator for SgIfdefDirectiveStatement.
   82788             : 
   82789             :    This new operator implements memory pools to provide most efficent 
   82790             :    use of the heap within construction of large ASTs.
   82791             : 
   82792             : \internal The new and delete operators use the lower level C malloc/free
   82793             :    function calls for performance and to make sure that mixing of malloc/free
   82794             :    and new/delete by the used can be caught more readily.  This may change
   82795             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   82796             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   82797             :    deallocate memory allocated using ROSE_MALLOC.
   82798             : */
   82799           0 : void *SgIfdefDirectiveStatement::operator new ( size_t Size )
   82800             : {
   82801             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   82802             :      * returning or throwing an exception. */
   82803           0 :     ALLOC_MUTEX(SgIfdefDirectiveStatement, lock);
   82804             : 
   82805             : #if ROSE_ALLOC_TRACE == 2
   82806             : //    printf("SgIfdefDirectiveStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgIfdefDirectiveStatement::next_node);
   82807             : #endif
   82808             : 
   82809             : #if USE_CPP_NEW_DELETE_OPERATORS
   82810             :     void *mem = ROSE_MALLOC(Size);
   82811             :     ALLOC_MUTEX(SgIfdefDirectiveStatement, unlock);
   82812             :     return mem;
   82813             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   82814             : #if ROSE_PEDANTIC_ALLOC
   82815             :     ROSE_ASSERT(Size == sizeof(SgIfdefDirectiveStatement));
   82816             : #else
   82817           0 :     if (Size != sizeof(SgIfdefDirectiveStatement)) {
   82818           0 :       void * object = ROSE_MALLOC(Size);
   82819           0 :       ALLOC_MUTEX(SgIfdefDirectiveStatement, unlock);
   82820             :       return object;
   82821             :     }
   82822             : #endif
   82823             : 
   82824           0 :     if (SgIfdefDirectiveStatement::next_node == nullptr) {
   82825           0 :         SgIfdefDirectiveStatement * alloc = (SgIfdefDirectiveStatement*) ROSE_MALLOC ( SgIfdefDirectiveStatement::pool_size * sizeof(SgIfdefDirectiveStatement) );
   82826           0 :         ROSE_ASSERT(alloc != nullptr);
   82827             : 
   82828             : #if ROSE_ALLOC_TRACE == 2
   82829             : //        printf("SgIfdefDirectiveStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgIfdefDirectiveStatement::pools.size(), alloc, alloc + SgIfdefDirectiveStatement::pool_size);
   82830             : #endif
   82831             : 
   82832             : #if ROSE_ALLOC_MEMSET == 1
   82833             : #elif ROSE_ALLOC_MEMSET == 2
   82834             :         memset(alloc, 0x00, SgIfdefDirectiveStatement::pool_size * sizeof(SgIfdefDirectiveStatement));
   82835             : #elif ROSE_ALLOC_MEMSET == 3
   82836             :         memset(alloc, 0xAA, SgIfdefDirectiveStatement::pool_size * sizeof(SgIfdefDirectiveStatement));
   82837             : #endif
   82838           0 :         for (unsigned i=0; i < SgIfdefDirectiveStatement::pool_size-1; i++) {
   82839           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
   82840             :         }
   82841           0 :         alloc[SgIfdefDirectiveStatement::pool_size-1].p_freepointer = nullptr;
   82842             : 
   82843           0 :         SgIfdefDirectiveStatement::pools.push_back ( (unsigned char *) alloc );
   82844           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgIfdefDirectiveStatement::pool_size * sizeof(SgIfdefDirectiveStatement), V_SgIfdefDirectiveStatement ) );
   82845           0 :         SgIfdefDirectiveStatement::next_node = alloc;
   82846             :     }
   82847           0 :     ROSE_ASSERT(SgIfdefDirectiveStatement::next_node != nullptr);
   82848             : 
   82849           0 :     SgIfdefDirectiveStatement * object = SgIfdefDirectiveStatement::next_node;
   82850           0 :     SgIfdefDirectiveStatement::next_node = (SgIfdefDirectiveStatement*)(object->p_freepointer);
   82851             : 
   82852             : #if ROSE_ALLOC_TRACE == 2
   82853             :     printf("SgIfdefDirectiveStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgIfdefDirectiveStatement::next_node);
   82854             : #endif
   82855             : 
   82856           0 :     SgNode * fp = object->p_freepointer;
   82857             : #if ROSE_ALLOC_MEMSET == 1
   82858             : #elif ROSE_ALLOC_MEMSET == 2
   82859             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgIfdefDirectiveStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   82860             : #elif ROSE_ALLOC_MEMSET == 3
   82861             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgIfdefDirectiveStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   82862             : #endif
   82863           0 :     object->p_freepointer = fp;
   82864             : 
   82865             : #if ROSE_ALLOC_TRACE == 2
   82866             : //    printf("SgIfdefDirectiveStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgIfdefDirectiveStatement::next_node);
   82867             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   82868             :     Rose::MemPool::snapshot(oss.str());
   82869             :     alloc_trace_cnt++;
   82870             : #endif
   82871             : 
   82872           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   82873             : 
   82874           0 :     ALLOC_MUTEX(SgIfdefDirectiveStatement, unlock);
   82875             : 
   82876             :     return object;
   82877             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   82878             : }
   82879             : 
   82880             : 
   82881             : 
   82882             : /*! \brief Delete operator for SgIfdefDirectiveStatement.
   82883             : 
   82884             :    This delete operator implements deallocation using memory pools to 
   82885             :    provide most efficent use of the heap within construction of large ASTs.
   82886             : 
   82887             : \internal The new and delete operators use the lower level C malloc/free
   82888             :    function calls for performance and to make sure that mixing of malloc/free
   82889             :    and new/delete by the used can be caught more readily.  This may change
   82890             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   82891             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   82892             :    deallocate memory allocated using ROSE_MALLOC.
   82893             : */
   82894           0 : void SgIfdefDirectiveStatement::operator delete(void *Pointer, size_t Size)
   82895             : {
   82896             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   82897             :      * or throwing an exception. */
   82898           0 :     ALLOC_MUTEX(SgIfdefDirectiveStatement, lock);
   82899             : 
   82900             : #if USE_CPP_NEW_DELETE_OPERATORS
   82901             :     ROSE_FREE(Pointer);
   82902             : #else
   82903             : #if ROSE_PEDANTIC_ALLOC
   82904             :     ROSE_ASSERT(Size == sizeof(SgIfdefDirectiveStatement));
   82905             : #else
   82906           0 :     if (Size != sizeof(SgIfdefDirectiveStatement)) {
   82907           0 :       ROSE_FREE(Pointer);
   82908           0 :       ALLOC_MUTEX(SgIfdefDirectiveStatement, unlock);
   82909             :       return;
   82910             :     }
   82911             : #endif
   82912             : 
   82913           0 :     SgIfdefDirectiveStatement * object = (SgIfdefDirectiveStatement*) Pointer;
   82914           0 :     ROSE_ASSERT(object != nullptr);
   82915             : 
   82916             : #if ROSE_ALLOC_TRACE == 2
   82917             : //  printf("SgIfdefDirectiveStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgIfdefDirectiveStatement::next_node);
   82918             :     printf("SgIfdefDirectiveStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgIfdefDirectiveStatement::next_node);
   82919             : #endif
   82920             : 
   82921             : #if ROSE_PEDANTIC_ALLOC
   82922             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   82923             : #endif
   82924             : 
   82925             : #if ROSE_ALLOC_MEMSET == 1
   82926             : #elif ROSE_ALLOC_MEMSET == 2
   82927             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgIfdefDirectiveStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   82928             : #elif ROSE_ALLOC_MEMSET == 3
   82929             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgIfdefDirectiveStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   82930             : #endif
   82931             : 
   82932             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   82933             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   82934             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   82935             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   82936             : #else
   82937           0 :     object->p_freepointer = SgIfdefDirectiveStatement::next_node;
   82938           0 :     SgIfdefDirectiveStatement::next_node = object;
   82939             : #endif
   82940             : 
   82941             : #if ROSE_ALLOC_TRACE == 2
   82942             : //  printf("SgIfdefDirectiveStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgIfdefDirectiveStatement::next_node);
   82943             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   82944             :     Rose::MemPool::snapshot(oss.str());
   82945             :     alloc_trace_cnt++;
   82946             : #endif
   82947             : 
   82948             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   82949             : 
   82950           0 :     ALLOC_MUTEX(SgIfdefDirectiveStatement, unlock);
   82951             : }
   82952             : 
   82953             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   82954             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   82955             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   82956             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   82957             : // Also, note comment below from Robb (copied from the Common.code file).
   82958             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   82959             : //
   82960             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   82961             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   82962             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   82963             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   82964             : #if 0
   82965             : void SgIfdefDirectiveStatement::operator delete(void* pointer) { SgIfdefDirectiveStatement::operator delete (pointer, sizeof(SgIfdefDirectiveStatement)); };
   82966             : #endif
   82967             : /* #line 82968 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   82968             : 
   82969             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   82970             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   82971             : // obviously imply C++.
   82972             : 
   82973             : // This implements the support within ROSE for memory pools.  Memory pools
   82974             : // support the most condensed usage of memory within the construction of
   82975             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   82976             : // by a new operator written for each class.
   82977             : 
   82978             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   82979             :     // User wants multi-thread support and POSIX threads are available.
   82980             : #   include <pthread.h>
   82981             :     static pthread_mutex_t SgIfndefDirectiveStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   82982             : #else
   82983             :      // Cause synchronization to be skipped.
   82984             : #    ifndef ALLOC_MUTEX
   82985             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   82986             : #    endif
   82987             : #    ifdef _REENTRANT
   82988             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   82989             : #       ifdef _MSC_VER
   82990             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   82991             : #       else
   82992             : #           warning "POSIX threads are not available; synchronization being skipped"
   82993             : #       endif
   82994             : #    endif
   82995             : #endif
   82996             : 
   82997             : #ifndef ROSE_ALLOC_TRACE
   82998             : #  define ROSE_ALLOC_TRACE 0
   82999             : #endif
   83000             : 
   83001             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   83002             : #define ROSE_ALLOC_TRACE_CNT
   83003             : #include "memory-pool-snapshot.h"
   83004             : unsigned long alloc_trace_cnt = 0;
   83005             : #endif
   83006             : 
   83007             : #if ROSE_ALLOC_TRACE
   83008             : const unsigned SgIfndefDirectiveStatement::pool_size = 5;
   83009             : #else
   83010             : const unsigned SgIfndefDirectiveStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   83011             : #endif
   83012             : 
   83013             : #ifndef ROSE_ALLOC_MEMSET
   83014             : #  define ROSE_ALLOC_MEMSET 0
   83015             : #endif
   83016             : 
   83017             : #ifndef ROSE_PEDANTIC_ALLOC
   83018             : #  define ROSE_PEDANTIC_ALLOC 0
   83019             : #endif
   83020             : 
   83021             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   83022             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   83023             : #endif
   83024             : 
   83025             : #if !defined(SGNODE__ALL_POOLS)
   83026             : #define SGNODE__ALL_POOLS
   83027             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   83028             : #endif
   83029             : 
   83030             : SgIfndefDirectiveStatement* SgIfndefDirectiveStatement::next_node = nullptr;
   83031             : std::vector<unsigned char*> SgIfndefDirectiveStatement::pools;
   83032             : 
   83033             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   83034             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   83035             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   83036             : // around this macro definition rather than each use).
   83037             : #ifndef ALLOC_MUTEX
   83038             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   83039             :         do {                                                                     \
   83040             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   83041             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   83042             :                 abort();                                                         \
   83043             :             }                                                                    \
   83044             :         } while (0);
   83045             : #endif
   83046             : 
   83047             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   83048             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   83049             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   83050             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   83051             : 
   83052             : /*! \brief New operator for SgIfndefDirectiveStatement.
   83053             : 
   83054             :    This new operator implements memory pools to provide most efficent 
   83055             :    use of the heap within construction of large ASTs.
   83056             : 
   83057             : \internal The new and delete operators use the lower level C malloc/free
   83058             :    function calls for performance and to make sure that mixing of malloc/free
   83059             :    and new/delete by the used can be caught more readily.  This may change
   83060             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   83061             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   83062             :    deallocate memory allocated using ROSE_MALLOC.
   83063             : */
   83064           0 : void *SgIfndefDirectiveStatement::operator new ( size_t Size )
   83065             : {
   83066             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   83067             :      * returning or throwing an exception. */
   83068           0 :     ALLOC_MUTEX(SgIfndefDirectiveStatement, lock);
   83069             : 
   83070             : #if ROSE_ALLOC_TRACE == 2
   83071             : //    printf("SgIfndefDirectiveStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgIfndefDirectiveStatement::next_node);
   83072             : #endif
   83073             : 
   83074             : #if USE_CPP_NEW_DELETE_OPERATORS
   83075             :     void *mem = ROSE_MALLOC(Size);
   83076             :     ALLOC_MUTEX(SgIfndefDirectiveStatement, unlock);
   83077             :     return mem;
   83078             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   83079             : #if ROSE_PEDANTIC_ALLOC
   83080             :     ROSE_ASSERT(Size == sizeof(SgIfndefDirectiveStatement));
   83081             : #else
   83082           0 :     if (Size != sizeof(SgIfndefDirectiveStatement)) {
   83083           0 :       void * object = ROSE_MALLOC(Size);
   83084           0 :       ALLOC_MUTEX(SgIfndefDirectiveStatement, unlock);
   83085             :       return object;
   83086             :     }
   83087             : #endif
   83088             : 
   83089           0 :     if (SgIfndefDirectiveStatement::next_node == nullptr) {
   83090           0 :         SgIfndefDirectiveStatement * alloc = (SgIfndefDirectiveStatement*) ROSE_MALLOC ( SgIfndefDirectiveStatement::pool_size * sizeof(SgIfndefDirectiveStatement) );
   83091           0 :         ROSE_ASSERT(alloc != nullptr);
   83092             : 
   83093             : #if ROSE_ALLOC_TRACE == 2
   83094             : //        printf("SgIfndefDirectiveStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgIfndefDirectiveStatement::pools.size(), alloc, alloc + SgIfndefDirectiveStatement::pool_size);
   83095             : #endif
   83096             : 
   83097             : #if ROSE_ALLOC_MEMSET == 1
   83098             : #elif ROSE_ALLOC_MEMSET == 2
   83099             :         memset(alloc, 0x00, SgIfndefDirectiveStatement::pool_size * sizeof(SgIfndefDirectiveStatement));
   83100             : #elif ROSE_ALLOC_MEMSET == 3
   83101             :         memset(alloc, 0xAA, SgIfndefDirectiveStatement::pool_size * sizeof(SgIfndefDirectiveStatement));
   83102             : #endif
   83103           0 :         for (unsigned i=0; i < SgIfndefDirectiveStatement::pool_size-1; i++) {
   83104           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
   83105             :         }
   83106           0 :         alloc[SgIfndefDirectiveStatement::pool_size-1].p_freepointer = nullptr;
   83107             : 
   83108           0 :         SgIfndefDirectiveStatement::pools.push_back ( (unsigned char *) alloc );
   83109           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgIfndefDirectiveStatement::pool_size * sizeof(SgIfndefDirectiveStatement), V_SgIfndefDirectiveStatement ) );
   83110           0 :         SgIfndefDirectiveStatement::next_node = alloc;
   83111             :     }
   83112           0 :     ROSE_ASSERT(SgIfndefDirectiveStatement::next_node != nullptr);
   83113             : 
   83114           0 :     SgIfndefDirectiveStatement * object = SgIfndefDirectiveStatement::next_node;
   83115           0 :     SgIfndefDirectiveStatement::next_node = (SgIfndefDirectiveStatement*)(object->p_freepointer);
   83116             : 
   83117             : #if ROSE_ALLOC_TRACE == 2
   83118             :     printf("SgIfndefDirectiveStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgIfndefDirectiveStatement::next_node);
   83119             : #endif
   83120             : 
   83121           0 :     SgNode * fp = object->p_freepointer;
   83122             : #if ROSE_ALLOC_MEMSET == 1
   83123             : #elif ROSE_ALLOC_MEMSET == 2
   83124             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgIfndefDirectiveStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   83125             : #elif ROSE_ALLOC_MEMSET == 3
   83126             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgIfndefDirectiveStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   83127             : #endif
   83128           0 :     object->p_freepointer = fp;
   83129             : 
   83130             : #if ROSE_ALLOC_TRACE == 2
   83131             : //    printf("SgIfndefDirectiveStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgIfndefDirectiveStatement::next_node);
   83132             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   83133             :     Rose::MemPool::snapshot(oss.str());
   83134             :     alloc_trace_cnt++;
   83135             : #endif
   83136             : 
   83137           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   83138             : 
   83139           0 :     ALLOC_MUTEX(SgIfndefDirectiveStatement, unlock);
   83140             : 
   83141             :     return object;
   83142             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   83143             : }
   83144             : 
   83145             : 
   83146             : 
   83147             : /*! \brief Delete operator for SgIfndefDirectiveStatement.
   83148             : 
   83149             :    This delete operator implements deallocation using memory pools to 
   83150             :    provide most efficent use of the heap within construction of large ASTs.
   83151             : 
   83152             : \internal The new and delete operators use the lower level C malloc/free
   83153             :    function calls for performance and to make sure that mixing of malloc/free
   83154             :    and new/delete by the used can be caught more readily.  This may change
   83155             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   83156             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   83157             :    deallocate memory allocated using ROSE_MALLOC.
   83158             : */
   83159           0 : void SgIfndefDirectiveStatement::operator delete(void *Pointer, size_t Size)
   83160             : {
   83161             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   83162             :      * or throwing an exception. */
   83163           0 :     ALLOC_MUTEX(SgIfndefDirectiveStatement, lock);
   83164             : 
   83165             : #if USE_CPP_NEW_DELETE_OPERATORS
   83166             :     ROSE_FREE(Pointer);
   83167             : #else
   83168             : #if ROSE_PEDANTIC_ALLOC
   83169             :     ROSE_ASSERT(Size == sizeof(SgIfndefDirectiveStatement));
   83170             : #else
   83171           0 :     if (Size != sizeof(SgIfndefDirectiveStatement)) {
   83172           0 :       ROSE_FREE(Pointer);
   83173           0 :       ALLOC_MUTEX(SgIfndefDirectiveStatement, unlock);
   83174             :       return;
   83175             :     }
   83176             : #endif
   83177             : 
   83178           0 :     SgIfndefDirectiveStatement * object = (SgIfndefDirectiveStatement*) Pointer;
   83179           0 :     ROSE_ASSERT(object != nullptr);
   83180             : 
   83181             : #if ROSE_ALLOC_TRACE == 2
   83182             : //  printf("SgIfndefDirectiveStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgIfndefDirectiveStatement::next_node);
   83183             :     printf("SgIfndefDirectiveStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgIfndefDirectiveStatement::next_node);
   83184             : #endif
   83185             : 
   83186             : #if ROSE_PEDANTIC_ALLOC
   83187             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   83188             : #endif
   83189             : 
   83190             : #if ROSE_ALLOC_MEMSET == 1
   83191             : #elif ROSE_ALLOC_MEMSET == 2
   83192             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgIfndefDirectiveStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   83193             : #elif ROSE_ALLOC_MEMSET == 3
   83194             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgIfndefDirectiveStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   83195             : #endif
   83196             : 
   83197             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   83198             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   83199             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   83200             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   83201             : #else
   83202           0 :     object->p_freepointer = SgIfndefDirectiveStatement::next_node;
   83203           0 :     SgIfndefDirectiveStatement::next_node = object;
   83204             : #endif
   83205             : 
   83206             : #if ROSE_ALLOC_TRACE == 2
   83207             : //  printf("SgIfndefDirectiveStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgIfndefDirectiveStatement::next_node);
   83208             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   83209             :     Rose::MemPool::snapshot(oss.str());
   83210             :     alloc_trace_cnt++;
   83211             : #endif
   83212             : 
   83213             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   83214             : 
   83215           0 :     ALLOC_MUTEX(SgIfndefDirectiveStatement, unlock);
   83216             : }
   83217             : 
   83218             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   83219             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   83220             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   83221             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   83222             : // Also, note comment below from Robb (copied from the Common.code file).
   83223             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   83224             : //
   83225             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   83226             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   83227             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   83228             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   83229             : #if 0
   83230             : void SgIfndefDirectiveStatement::operator delete(void* pointer) { SgIfndefDirectiveStatement::operator delete (pointer, sizeof(SgIfndefDirectiveStatement)); };
   83231             : #endif
   83232             : /* #line 83233 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   83233             : 
   83234             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   83235             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   83236             : // obviously imply C++.
   83237             : 
   83238             : // This implements the support within ROSE for memory pools.  Memory pools
   83239             : // support the most condensed usage of memory within the construction of
   83240             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   83241             : // by a new operator written for each class.
   83242             : 
   83243             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   83244             :     // User wants multi-thread support and POSIX threads are available.
   83245             : #   include <pthread.h>
   83246             :     static pthread_mutex_t SgIfDirectiveStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   83247             : #else
   83248             :      // Cause synchronization to be skipped.
   83249             : #    ifndef ALLOC_MUTEX
   83250             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   83251             : #    endif
   83252             : #    ifdef _REENTRANT
   83253             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   83254             : #       ifdef _MSC_VER
   83255             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   83256             : #       else
   83257             : #           warning "POSIX threads are not available; synchronization being skipped"
   83258             : #       endif
   83259             : #    endif
   83260             : #endif
   83261             : 
   83262             : #ifndef ROSE_ALLOC_TRACE
   83263             : #  define ROSE_ALLOC_TRACE 0
   83264             : #endif
   83265             : 
   83266             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   83267             : #define ROSE_ALLOC_TRACE_CNT
   83268             : #include "memory-pool-snapshot.h"
   83269             : unsigned long alloc_trace_cnt = 0;
   83270             : #endif
   83271             : 
   83272             : #if ROSE_ALLOC_TRACE
   83273             : const unsigned SgIfDirectiveStatement::pool_size = 5;
   83274             : #else
   83275             : const unsigned SgIfDirectiveStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   83276             : #endif
   83277             : 
   83278             : #ifndef ROSE_ALLOC_MEMSET
   83279             : #  define ROSE_ALLOC_MEMSET 0
   83280             : #endif
   83281             : 
   83282             : #ifndef ROSE_PEDANTIC_ALLOC
   83283             : #  define ROSE_PEDANTIC_ALLOC 0
   83284             : #endif
   83285             : 
   83286             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   83287             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   83288             : #endif
   83289             : 
   83290             : #if !defined(SGNODE__ALL_POOLS)
   83291             : #define SGNODE__ALL_POOLS
   83292             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   83293             : #endif
   83294             : 
   83295             : SgIfDirectiveStatement* SgIfDirectiveStatement::next_node = nullptr;
   83296             : std::vector<unsigned char*> SgIfDirectiveStatement::pools;
   83297             : 
   83298             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   83299             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   83300             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   83301             : // around this macro definition rather than each use).
   83302             : #ifndef ALLOC_MUTEX
   83303             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   83304             :         do {                                                                     \
   83305             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   83306             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   83307             :                 abort();                                                         \
   83308             :             }                                                                    \
   83309             :         } while (0);
   83310             : #endif
   83311             : 
   83312             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   83313             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   83314             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   83315             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   83316             : 
   83317             : /*! \brief New operator for SgIfDirectiveStatement.
   83318             : 
   83319             :    This new operator implements memory pools to provide most efficent 
   83320             :    use of the heap within construction of large ASTs.
   83321             : 
   83322             : \internal The new and delete operators use the lower level C malloc/free
   83323             :    function calls for performance and to make sure that mixing of malloc/free
   83324             :    and new/delete by the used can be caught more readily.  This may change
   83325             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   83326             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   83327             :    deallocate memory allocated using ROSE_MALLOC.
   83328             : */
   83329           0 : void *SgIfDirectiveStatement::operator new ( size_t Size )
   83330             : {
   83331             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   83332             :      * returning or throwing an exception. */
   83333           0 :     ALLOC_MUTEX(SgIfDirectiveStatement, lock);
   83334             : 
   83335             : #if ROSE_ALLOC_TRACE == 2
   83336             : //    printf("SgIfDirectiveStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgIfDirectiveStatement::next_node);
   83337             : #endif
   83338             : 
   83339             : #if USE_CPP_NEW_DELETE_OPERATORS
   83340             :     void *mem = ROSE_MALLOC(Size);
   83341             :     ALLOC_MUTEX(SgIfDirectiveStatement, unlock);
   83342             :     return mem;
   83343             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   83344             : #if ROSE_PEDANTIC_ALLOC
   83345             :     ROSE_ASSERT(Size == sizeof(SgIfDirectiveStatement));
   83346             : #else
   83347           0 :     if (Size != sizeof(SgIfDirectiveStatement)) {
   83348           0 :       void * object = ROSE_MALLOC(Size);
   83349           0 :       ALLOC_MUTEX(SgIfDirectiveStatement, unlock);
   83350             :       return object;
   83351             :     }
   83352             : #endif
   83353             : 
   83354           0 :     if (SgIfDirectiveStatement::next_node == nullptr) {
   83355           0 :         SgIfDirectiveStatement * alloc = (SgIfDirectiveStatement*) ROSE_MALLOC ( SgIfDirectiveStatement::pool_size * sizeof(SgIfDirectiveStatement) );
   83356           0 :         ROSE_ASSERT(alloc != nullptr);
   83357             : 
   83358             : #if ROSE_ALLOC_TRACE == 2
   83359             : //        printf("SgIfDirectiveStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgIfDirectiveStatement::pools.size(), alloc, alloc + SgIfDirectiveStatement::pool_size);
   83360             : #endif
   83361             : 
   83362             : #if ROSE_ALLOC_MEMSET == 1
   83363             : #elif ROSE_ALLOC_MEMSET == 2
   83364             :         memset(alloc, 0x00, SgIfDirectiveStatement::pool_size * sizeof(SgIfDirectiveStatement));
   83365             : #elif ROSE_ALLOC_MEMSET == 3
   83366             :         memset(alloc, 0xAA, SgIfDirectiveStatement::pool_size * sizeof(SgIfDirectiveStatement));
   83367             : #endif
   83368           0 :         for (unsigned i=0; i < SgIfDirectiveStatement::pool_size-1; i++) {
   83369           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
   83370             :         }
   83371           0 :         alloc[SgIfDirectiveStatement::pool_size-1].p_freepointer = nullptr;
   83372             : 
   83373           0 :         SgIfDirectiveStatement::pools.push_back ( (unsigned char *) alloc );
   83374           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgIfDirectiveStatement::pool_size * sizeof(SgIfDirectiveStatement), V_SgIfDirectiveStatement ) );
   83375           0 :         SgIfDirectiveStatement::next_node = alloc;
   83376             :     }
   83377           0 :     ROSE_ASSERT(SgIfDirectiveStatement::next_node != nullptr);
   83378             : 
   83379           0 :     SgIfDirectiveStatement * object = SgIfDirectiveStatement::next_node;
   83380           0 :     SgIfDirectiveStatement::next_node = (SgIfDirectiveStatement*)(object->p_freepointer);
   83381             : 
   83382             : #if ROSE_ALLOC_TRACE == 2
   83383             :     printf("SgIfDirectiveStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgIfDirectiveStatement::next_node);
   83384             : #endif
   83385             : 
   83386           0 :     SgNode * fp = object->p_freepointer;
   83387             : #if ROSE_ALLOC_MEMSET == 1
   83388             : #elif ROSE_ALLOC_MEMSET == 2
   83389             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgIfDirectiveStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   83390             : #elif ROSE_ALLOC_MEMSET == 3
   83391             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgIfDirectiveStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   83392             : #endif
   83393           0 :     object->p_freepointer = fp;
   83394             : 
   83395             : #if ROSE_ALLOC_TRACE == 2
   83396             : //    printf("SgIfDirectiveStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgIfDirectiveStatement::next_node);
   83397             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   83398             :     Rose::MemPool::snapshot(oss.str());
   83399             :     alloc_trace_cnt++;
   83400             : #endif
   83401             : 
   83402           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   83403             : 
   83404           0 :     ALLOC_MUTEX(SgIfDirectiveStatement, unlock);
   83405             : 
   83406             :     return object;
   83407             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   83408             : }
   83409             : 
   83410             : 
   83411             : 
   83412             : /*! \brief Delete operator for SgIfDirectiveStatement.
   83413             : 
   83414             :    This delete operator implements deallocation using memory pools to 
   83415             :    provide most efficent use of the heap within construction of large ASTs.
   83416             : 
   83417             : \internal The new and delete operators use the lower level C malloc/free
   83418             :    function calls for performance and to make sure that mixing of malloc/free
   83419             :    and new/delete by the used can be caught more readily.  This may change
   83420             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   83421             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   83422             :    deallocate memory allocated using ROSE_MALLOC.
   83423             : */
   83424           0 : void SgIfDirectiveStatement::operator delete(void *Pointer, size_t Size)
   83425             : {
   83426             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   83427             :      * or throwing an exception. */
   83428           0 :     ALLOC_MUTEX(SgIfDirectiveStatement, lock);
   83429             : 
   83430             : #if USE_CPP_NEW_DELETE_OPERATORS
   83431             :     ROSE_FREE(Pointer);
   83432             : #else
   83433             : #if ROSE_PEDANTIC_ALLOC
   83434             :     ROSE_ASSERT(Size == sizeof(SgIfDirectiveStatement));
   83435             : #else
   83436           0 :     if (Size != sizeof(SgIfDirectiveStatement)) {
   83437           0 :       ROSE_FREE(Pointer);
   83438           0 :       ALLOC_MUTEX(SgIfDirectiveStatement, unlock);
   83439             :       return;
   83440             :     }
   83441             : #endif
   83442             : 
   83443           0 :     SgIfDirectiveStatement * object = (SgIfDirectiveStatement*) Pointer;
   83444           0 :     ROSE_ASSERT(object != nullptr);
   83445             : 
   83446             : #if ROSE_ALLOC_TRACE == 2
   83447             : //  printf("SgIfDirectiveStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgIfDirectiveStatement::next_node);
   83448             :     printf("SgIfDirectiveStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgIfDirectiveStatement::next_node);
   83449             : #endif
   83450             : 
   83451             : #if ROSE_PEDANTIC_ALLOC
   83452             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   83453             : #endif
   83454             : 
   83455             : #if ROSE_ALLOC_MEMSET == 1
   83456             : #elif ROSE_ALLOC_MEMSET == 2
   83457             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgIfDirectiveStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   83458             : #elif ROSE_ALLOC_MEMSET == 3
   83459             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgIfDirectiveStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   83460             : #endif
   83461             : 
   83462             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   83463             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   83464             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   83465             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   83466             : #else
   83467           0 :     object->p_freepointer = SgIfDirectiveStatement::next_node;
   83468           0 :     SgIfDirectiveStatement::next_node = object;
   83469             : #endif
   83470             : 
   83471             : #if ROSE_ALLOC_TRACE == 2
   83472             : //  printf("SgIfDirectiveStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgIfDirectiveStatement::next_node);
   83473             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   83474             :     Rose::MemPool::snapshot(oss.str());
   83475             :     alloc_trace_cnt++;
   83476             : #endif
   83477             : 
   83478             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   83479             : 
   83480           0 :     ALLOC_MUTEX(SgIfDirectiveStatement, unlock);
   83481             : }
   83482             : 
   83483             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   83484             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   83485             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   83486             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   83487             : // Also, note comment below from Robb (copied from the Common.code file).
   83488             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   83489             : //
   83490             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   83491             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   83492             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   83493             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   83494             : #if 0
   83495             : void SgIfDirectiveStatement::operator delete(void* pointer) { SgIfDirectiveStatement::operator delete (pointer, sizeof(SgIfDirectiveStatement)); };
   83496             : #endif
   83497             : /* #line 83498 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   83498             : 
   83499             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   83500             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   83501             : // obviously imply C++.
   83502             : 
   83503             : // This implements the support within ROSE for memory pools.  Memory pools
   83504             : // support the most condensed usage of memory within the construction of
   83505             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   83506             : // by a new operator written for each class.
   83507             : 
   83508             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   83509             :     // User wants multi-thread support and POSIX threads are available.
   83510             : #   include <pthread.h>
   83511             :     static pthread_mutex_t SgDeadIfDirectiveStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   83512             : #else
   83513             :      // Cause synchronization to be skipped.
   83514             : #    ifndef ALLOC_MUTEX
   83515             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   83516             : #    endif
   83517             : #    ifdef _REENTRANT
   83518             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   83519             : #       ifdef _MSC_VER
   83520             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   83521             : #       else
   83522             : #           warning "POSIX threads are not available; synchronization being skipped"
   83523             : #       endif
   83524             : #    endif
   83525             : #endif
   83526             : 
   83527             : #ifndef ROSE_ALLOC_TRACE
   83528             : #  define ROSE_ALLOC_TRACE 0
   83529             : #endif
   83530             : 
   83531             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   83532             : #define ROSE_ALLOC_TRACE_CNT
   83533             : #include "memory-pool-snapshot.h"
   83534             : unsigned long alloc_trace_cnt = 0;
   83535             : #endif
   83536             : 
   83537             : #if ROSE_ALLOC_TRACE
   83538             : const unsigned SgDeadIfDirectiveStatement::pool_size = 5;
   83539             : #else
   83540             : const unsigned SgDeadIfDirectiveStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   83541             : #endif
   83542             : 
   83543             : #ifndef ROSE_ALLOC_MEMSET
   83544             : #  define ROSE_ALLOC_MEMSET 0
   83545             : #endif
   83546             : 
   83547             : #ifndef ROSE_PEDANTIC_ALLOC
   83548             : #  define ROSE_PEDANTIC_ALLOC 0
   83549             : #endif
   83550             : 
   83551             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   83552             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   83553             : #endif
   83554             : 
   83555             : #if !defined(SGNODE__ALL_POOLS)
   83556             : #define SGNODE__ALL_POOLS
   83557             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   83558             : #endif
   83559             : 
   83560             : SgDeadIfDirectiveStatement* SgDeadIfDirectiveStatement::next_node = nullptr;
   83561             : std::vector<unsigned char*> SgDeadIfDirectiveStatement::pools;
   83562             : 
   83563             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   83564             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   83565             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   83566             : // around this macro definition rather than each use).
   83567             : #ifndef ALLOC_MUTEX
   83568             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   83569             :         do {                                                                     \
   83570             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   83571             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   83572             :                 abort();                                                         \
   83573             :             }                                                                    \
   83574             :         } while (0);
   83575             : #endif
   83576             : 
   83577             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   83578             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   83579             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   83580             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   83581             : 
   83582             : /*! \brief New operator for SgDeadIfDirectiveStatement.
   83583             : 
   83584             :    This new operator implements memory pools to provide most efficent 
   83585             :    use of the heap within construction of large ASTs.
   83586             : 
   83587             : \internal The new and delete operators use the lower level C malloc/free
   83588             :    function calls for performance and to make sure that mixing of malloc/free
   83589             :    and new/delete by the used can be caught more readily.  This may change
   83590             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   83591             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   83592             :    deallocate memory allocated using ROSE_MALLOC.
   83593             : */
   83594           0 : void *SgDeadIfDirectiveStatement::operator new ( size_t Size )
   83595             : {
   83596             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   83597             :      * returning or throwing an exception. */
   83598           0 :     ALLOC_MUTEX(SgDeadIfDirectiveStatement, lock);
   83599             : 
   83600             : #if ROSE_ALLOC_TRACE == 2
   83601             : //    printf("SgDeadIfDirectiveStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgDeadIfDirectiveStatement::next_node);
   83602             : #endif
   83603             : 
   83604             : #if USE_CPP_NEW_DELETE_OPERATORS
   83605             :     void *mem = ROSE_MALLOC(Size);
   83606             :     ALLOC_MUTEX(SgDeadIfDirectiveStatement, unlock);
   83607             :     return mem;
   83608             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   83609             : #if ROSE_PEDANTIC_ALLOC
   83610             :     ROSE_ASSERT(Size == sizeof(SgDeadIfDirectiveStatement));
   83611             : #else
   83612           0 :     if (Size != sizeof(SgDeadIfDirectiveStatement)) {
   83613           0 :       void * object = ROSE_MALLOC(Size);
   83614           0 :       ALLOC_MUTEX(SgDeadIfDirectiveStatement, unlock);
   83615             :       return object;
   83616             :     }
   83617             : #endif
   83618             : 
   83619           0 :     if (SgDeadIfDirectiveStatement::next_node == nullptr) {
   83620           0 :         SgDeadIfDirectiveStatement * alloc = (SgDeadIfDirectiveStatement*) ROSE_MALLOC ( SgDeadIfDirectiveStatement::pool_size * sizeof(SgDeadIfDirectiveStatement) );
   83621           0 :         ROSE_ASSERT(alloc != nullptr);
   83622             : 
   83623             : #if ROSE_ALLOC_TRACE == 2
   83624             : //        printf("SgDeadIfDirectiveStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgDeadIfDirectiveStatement::pools.size(), alloc, alloc + SgDeadIfDirectiveStatement::pool_size);
   83625             : #endif
   83626             : 
   83627             : #if ROSE_ALLOC_MEMSET == 1
   83628             : #elif ROSE_ALLOC_MEMSET == 2
   83629             :         memset(alloc, 0x00, SgDeadIfDirectiveStatement::pool_size * sizeof(SgDeadIfDirectiveStatement));
   83630             : #elif ROSE_ALLOC_MEMSET == 3
   83631             :         memset(alloc, 0xAA, SgDeadIfDirectiveStatement::pool_size * sizeof(SgDeadIfDirectiveStatement));
   83632             : #endif
   83633           0 :         for (unsigned i=0; i < SgDeadIfDirectiveStatement::pool_size-1; i++) {
   83634           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
   83635             :         }
   83636           0 :         alloc[SgDeadIfDirectiveStatement::pool_size-1].p_freepointer = nullptr;
   83637             : 
   83638           0 :         SgDeadIfDirectiveStatement::pools.push_back ( (unsigned char *) alloc );
   83639           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgDeadIfDirectiveStatement::pool_size * sizeof(SgDeadIfDirectiveStatement), V_SgDeadIfDirectiveStatement ) );
   83640           0 :         SgDeadIfDirectiveStatement::next_node = alloc;
   83641             :     }
   83642           0 :     ROSE_ASSERT(SgDeadIfDirectiveStatement::next_node != nullptr);
   83643             : 
   83644           0 :     SgDeadIfDirectiveStatement * object = SgDeadIfDirectiveStatement::next_node;
   83645           0 :     SgDeadIfDirectiveStatement::next_node = (SgDeadIfDirectiveStatement*)(object->p_freepointer);
   83646             : 
   83647             : #if ROSE_ALLOC_TRACE == 2
   83648             :     printf("SgDeadIfDirectiveStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgDeadIfDirectiveStatement::next_node);
   83649             : #endif
   83650             : 
   83651           0 :     SgNode * fp = object->p_freepointer;
   83652             : #if ROSE_ALLOC_MEMSET == 1
   83653             : #elif ROSE_ALLOC_MEMSET == 2
   83654             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgDeadIfDirectiveStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   83655             : #elif ROSE_ALLOC_MEMSET == 3
   83656             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgDeadIfDirectiveStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   83657             : #endif
   83658           0 :     object->p_freepointer = fp;
   83659             : 
   83660             : #if ROSE_ALLOC_TRACE == 2
   83661             : //    printf("SgDeadIfDirectiveStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgDeadIfDirectiveStatement::next_node);
   83662             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   83663             :     Rose::MemPool::snapshot(oss.str());
   83664             :     alloc_trace_cnt++;
   83665             : #endif
   83666             : 
   83667           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   83668             : 
   83669           0 :     ALLOC_MUTEX(SgDeadIfDirectiveStatement, unlock);
   83670             : 
   83671             :     return object;
   83672             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   83673             : }
   83674             : 
   83675             : 
   83676             : 
   83677             : /*! \brief Delete operator for SgDeadIfDirectiveStatement.
   83678             : 
   83679             :    This delete operator implements deallocation using memory pools to 
   83680             :    provide most efficent use of the heap within construction of large ASTs.
   83681             : 
   83682             : \internal The new and delete operators use the lower level C malloc/free
   83683             :    function calls for performance and to make sure that mixing of malloc/free
   83684             :    and new/delete by the used can be caught more readily.  This may change
   83685             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   83686             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   83687             :    deallocate memory allocated using ROSE_MALLOC.
   83688             : */
   83689           0 : void SgDeadIfDirectiveStatement::operator delete(void *Pointer, size_t Size)
   83690             : {
   83691             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   83692             :      * or throwing an exception. */
   83693           0 :     ALLOC_MUTEX(SgDeadIfDirectiveStatement, lock);
   83694             : 
   83695             : #if USE_CPP_NEW_DELETE_OPERATORS
   83696             :     ROSE_FREE(Pointer);
   83697             : #else
   83698             : #if ROSE_PEDANTIC_ALLOC
   83699             :     ROSE_ASSERT(Size == sizeof(SgDeadIfDirectiveStatement));
   83700             : #else
   83701           0 :     if (Size != sizeof(SgDeadIfDirectiveStatement)) {
   83702           0 :       ROSE_FREE(Pointer);
   83703           0 :       ALLOC_MUTEX(SgDeadIfDirectiveStatement, unlock);
   83704             :       return;
   83705             :     }
   83706             : #endif
   83707             : 
   83708           0 :     SgDeadIfDirectiveStatement * object = (SgDeadIfDirectiveStatement*) Pointer;
   83709           0 :     ROSE_ASSERT(object != nullptr);
   83710             : 
   83711             : #if ROSE_ALLOC_TRACE == 2
   83712             : //  printf("SgDeadIfDirectiveStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgDeadIfDirectiveStatement::next_node);
   83713             :     printf("SgDeadIfDirectiveStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgDeadIfDirectiveStatement::next_node);
   83714             : #endif
   83715             : 
   83716             : #if ROSE_PEDANTIC_ALLOC
   83717             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   83718             : #endif
   83719             : 
   83720             : #if ROSE_ALLOC_MEMSET == 1
   83721             : #elif ROSE_ALLOC_MEMSET == 2
   83722             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgDeadIfDirectiveStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   83723             : #elif ROSE_ALLOC_MEMSET == 3
   83724             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgDeadIfDirectiveStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   83725             : #endif
   83726             : 
   83727             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   83728             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   83729             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   83730             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   83731             : #else
   83732           0 :     object->p_freepointer = SgDeadIfDirectiveStatement::next_node;
   83733           0 :     SgDeadIfDirectiveStatement::next_node = object;
   83734             : #endif
   83735             : 
   83736             : #if ROSE_ALLOC_TRACE == 2
   83737             : //  printf("SgDeadIfDirectiveStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgDeadIfDirectiveStatement::next_node);
   83738             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   83739             :     Rose::MemPool::snapshot(oss.str());
   83740             :     alloc_trace_cnt++;
   83741             : #endif
   83742             : 
   83743             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   83744             : 
   83745           0 :     ALLOC_MUTEX(SgDeadIfDirectiveStatement, unlock);
   83746             : }
   83747             : 
   83748             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   83749             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   83750             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   83751             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   83752             : // Also, note comment below from Robb (copied from the Common.code file).
   83753             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   83754             : //
   83755             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   83756             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   83757             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   83758             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   83759             : #if 0
   83760             : void SgDeadIfDirectiveStatement::operator delete(void* pointer) { SgDeadIfDirectiveStatement::operator delete (pointer, sizeof(SgDeadIfDirectiveStatement)); };
   83761             : #endif
   83762             : /* #line 83763 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   83763             : 
   83764             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   83765             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   83766             : // obviously imply C++.
   83767             : 
   83768             : // This implements the support within ROSE for memory pools.  Memory pools
   83769             : // support the most condensed usage of memory within the construction of
   83770             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   83771             : // by a new operator written for each class.
   83772             : 
   83773             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   83774             :     // User wants multi-thread support and POSIX threads are available.
   83775             : #   include <pthread.h>
   83776             :     static pthread_mutex_t SgElseDirectiveStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   83777             : #else
   83778             :      // Cause synchronization to be skipped.
   83779             : #    ifndef ALLOC_MUTEX
   83780             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   83781             : #    endif
   83782             : #    ifdef _REENTRANT
   83783             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   83784             : #       ifdef _MSC_VER
   83785             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   83786             : #       else
   83787             : #           warning "POSIX threads are not available; synchronization being skipped"
   83788             : #       endif
   83789             : #    endif
   83790             : #endif
   83791             : 
   83792             : #ifndef ROSE_ALLOC_TRACE
   83793             : #  define ROSE_ALLOC_TRACE 0
   83794             : #endif
   83795             : 
   83796             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   83797             : #define ROSE_ALLOC_TRACE_CNT
   83798             : #include "memory-pool-snapshot.h"
   83799             : unsigned long alloc_trace_cnt = 0;
   83800             : #endif
   83801             : 
   83802             : #if ROSE_ALLOC_TRACE
   83803             : const unsigned SgElseDirectiveStatement::pool_size = 5;
   83804             : #else
   83805             : const unsigned SgElseDirectiveStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   83806             : #endif
   83807             : 
   83808             : #ifndef ROSE_ALLOC_MEMSET
   83809             : #  define ROSE_ALLOC_MEMSET 0
   83810             : #endif
   83811             : 
   83812             : #ifndef ROSE_PEDANTIC_ALLOC
   83813             : #  define ROSE_PEDANTIC_ALLOC 0
   83814             : #endif
   83815             : 
   83816             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   83817             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   83818             : #endif
   83819             : 
   83820             : #if !defined(SGNODE__ALL_POOLS)
   83821             : #define SGNODE__ALL_POOLS
   83822             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   83823             : #endif
   83824             : 
   83825             : SgElseDirectiveStatement* SgElseDirectiveStatement::next_node = nullptr;
   83826             : std::vector<unsigned char*> SgElseDirectiveStatement::pools;
   83827             : 
   83828             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   83829             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   83830             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   83831             : // around this macro definition rather than each use).
   83832             : #ifndef ALLOC_MUTEX
   83833             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   83834             :         do {                                                                     \
   83835             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   83836             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   83837             :                 abort();                                                         \
   83838             :             }                                                                    \
   83839             :         } while (0);
   83840             : #endif
   83841             : 
   83842             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   83843             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   83844             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   83845             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   83846             : 
   83847             : /*! \brief New operator for SgElseDirectiveStatement.
   83848             : 
   83849             :    This new operator implements memory pools to provide most efficent 
   83850             :    use of the heap within construction of large ASTs.
   83851             : 
   83852             : \internal The new and delete operators use the lower level C malloc/free
   83853             :    function calls for performance and to make sure that mixing of malloc/free
   83854             :    and new/delete by the used can be caught more readily.  This may change
   83855             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   83856             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   83857             :    deallocate memory allocated using ROSE_MALLOC.
   83858             : */
   83859           0 : void *SgElseDirectiveStatement::operator new ( size_t Size )
   83860             : {
   83861             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   83862             :      * returning or throwing an exception. */
   83863           0 :     ALLOC_MUTEX(SgElseDirectiveStatement, lock);
   83864             : 
   83865             : #if ROSE_ALLOC_TRACE == 2
   83866             : //    printf("SgElseDirectiveStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgElseDirectiveStatement::next_node);
   83867             : #endif
   83868             : 
   83869             : #if USE_CPP_NEW_DELETE_OPERATORS
   83870             :     void *mem = ROSE_MALLOC(Size);
   83871             :     ALLOC_MUTEX(SgElseDirectiveStatement, unlock);
   83872             :     return mem;
   83873             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   83874             : #if ROSE_PEDANTIC_ALLOC
   83875             :     ROSE_ASSERT(Size == sizeof(SgElseDirectiveStatement));
   83876             : #else
   83877           0 :     if (Size != sizeof(SgElseDirectiveStatement)) {
   83878           0 :       void * object = ROSE_MALLOC(Size);
   83879           0 :       ALLOC_MUTEX(SgElseDirectiveStatement, unlock);
   83880             :       return object;
   83881             :     }
   83882             : #endif
   83883             : 
   83884           0 :     if (SgElseDirectiveStatement::next_node == nullptr) {
   83885           0 :         SgElseDirectiveStatement * alloc = (SgElseDirectiveStatement*) ROSE_MALLOC ( SgElseDirectiveStatement::pool_size * sizeof(SgElseDirectiveStatement) );
   83886           0 :         ROSE_ASSERT(alloc != nullptr);
   83887             : 
   83888             : #if ROSE_ALLOC_TRACE == 2
   83889             : //        printf("SgElseDirectiveStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgElseDirectiveStatement::pools.size(), alloc, alloc + SgElseDirectiveStatement::pool_size);
   83890             : #endif
   83891             : 
   83892             : #if ROSE_ALLOC_MEMSET == 1
   83893             : #elif ROSE_ALLOC_MEMSET == 2
   83894             :         memset(alloc, 0x00, SgElseDirectiveStatement::pool_size * sizeof(SgElseDirectiveStatement));
   83895             : #elif ROSE_ALLOC_MEMSET == 3
   83896             :         memset(alloc, 0xAA, SgElseDirectiveStatement::pool_size * sizeof(SgElseDirectiveStatement));
   83897             : #endif
   83898           0 :         for (unsigned i=0; i < SgElseDirectiveStatement::pool_size-1; i++) {
   83899           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
   83900             :         }
   83901           0 :         alloc[SgElseDirectiveStatement::pool_size-1].p_freepointer = nullptr;
   83902             : 
   83903           0 :         SgElseDirectiveStatement::pools.push_back ( (unsigned char *) alloc );
   83904           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgElseDirectiveStatement::pool_size * sizeof(SgElseDirectiveStatement), V_SgElseDirectiveStatement ) );
   83905           0 :         SgElseDirectiveStatement::next_node = alloc;
   83906             :     }
   83907           0 :     ROSE_ASSERT(SgElseDirectiveStatement::next_node != nullptr);
   83908             : 
   83909           0 :     SgElseDirectiveStatement * object = SgElseDirectiveStatement::next_node;
   83910           0 :     SgElseDirectiveStatement::next_node = (SgElseDirectiveStatement*)(object->p_freepointer);
   83911             : 
   83912             : #if ROSE_ALLOC_TRACE == 2
   83913             :     printf("SgElseDirectiveStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgElseDirectiveStatement::next_node);
   83914             : #endif
   83915             : 
   83916           0 :     SgNode * fp = object->p_freepointer;
   83917             : #if ROSE_ALLOC_MEMSET == 1
   83918             : #elif ROSE_ALLOC_MEMSET == 2
   83919             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgElseDirectiveStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   83920             : #elif ROSE_ALLOC_MEMSET == 3
   83921             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgElseDirectiveStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   83922             : #endif
   83923           0 :     object->p_freepointer = fp;
   83924             : 
   83925             : #if ROSE_ALLOC_TRACE == 2
   83926             : //    printf("SgElseDirectiveStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgElseDirectiveStatement::next_node);
   83927             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   83928             :     Rose::MemPool::snapshot(oss.str());
   83929             :     alloc_trace_cnt++;
   83930             : #endif
   83931             : 
   83932           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   83933             : 
   83934           0 :     ALLOC_MUTEX(SgElseDirectiveStatement, unlock);
   83935             : 
   83936             :     return object;
   83937             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   83938             : }
   83939             : 
   83940             : 
   83941             : 
   83942             : /*! \brief Delete operator for SgElseDirectiveStatement.
   83943             : 
   83944             :    This delete operator implements deallocation using memory pools to 
   83945             :    provide most efficent use of the heap within construction of large ASTs.
   83946             : 
   83947             : \internal The new and delete operators use the lower level C malloc/free
   83948             :    function calls for performance and to make sure that mixing of malloc/free
   83949             :    and new/delete by the used can be caught more readily.  This may change
   83950             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   83951             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   83952             :    deallocate memory allocated using ROSE_MALLOC.
   83953             : */
   83954           0 : void SgElseDirectiveStatement::operator delete(void *Pointer, size_t Size)
   83955             : {
   83956             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   83957             :      * or throwing an exception. */
   83958           0 :     ALLOC_MUTEX(SgElseDirectiveStatement, lock);
   83959             : 
   83960             : #if USE_CPP_NEW_DELETE_OPERATORS
   83961             :     ROSE_FREE(Pointer);
   83962             : #else
   83963             : #if ROSE_PEDANTIC_ALLOC
   83964             :     ROSE_ASSERT(Size == sizeof(SgElseDirectiveStatement));
   83965             : #else
   83966           0 :     if (Size != sizeof(SgElseDirectiveStatement)) {
   83967           0 :       ROSE_FREE(Pointer);
   83968           0 :       ALLOC_MUTEX(SgElseDirectiveStatement, unlock);
   83969             :       return;
   83970             :     }
   83971             : #endif
   83972             : 
   83973           0 :     SgElseDirectiveStatement * object = (SgElseDirectiveStatement*) Pointer;
   83974           0 :     ROSE_ASSERT(object != nullptr);
   83975             : 
   83976             : #if ROSE_ALLOC_TRACE == 2
   83977             : //  printf("SgElseDirectiveStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgElseDirectiveStatement::next_node);
   83978             :     printf("SgElseDirectiveStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgElseDirectiveStatement::next_node);
   83979             : #endif
   83980             : 
   83981             : #if ROSE_PEDANTIC_ALLOC
   83982             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   83983             : #endif
   83984             : 
   83985             : #if ROSE_ALLOC_MEMSET == 1
   83986             : #elif ROSE_ALLOC_MEMSET == 2
   83987             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgElseDirectiveStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   83988             : #elif ROSE_ALLOC_MEMSET == 3
   83989             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgElseDirectiveStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   83990             : #endif
   83991             : 
   83992             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   83993             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   83994             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   83995             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   83996             : #else
   83997           0 :     object->p_freepointer = SgElseDirectiveStatement::next_node;
   83998           0 :     SgElseDirectiveStatement::next_node = object;
   83999             : #endif
   84000             : 
   84001             : #if ROSE_ALLOC_TRACE == 2
   84002             : //  printf("SgElseDirectiveStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgElseDirectiveStatement::next_node);
   84003             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   84004             :     Rose::MemPool::snapshot(oss.str());
   84005             :     alloc_trace_cnt++;
   84006             : #endif
   84007             : 
   84008             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   84009             : 
   84010           0 :     ALLOC_MUTEX(SgElseDirectiveStatement, unlock);
   84011             : }
   84012             : 
   84013             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   84014             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   84015             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   84016             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   84017             : // Also, note comment below from Robb (copied from the Common.code file).
   84018             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   84019             : //
   84020             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   84021             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   84022             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   84023             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   84024             : #if 0
   84025             : void SgElseDirectiveStatement::operator delete(void* pointer) { SgElseDirectiveStatement::operator delete (pointer, sizeof(SgElseDirectiveStatement)); };
   84026             : #endif
   84027             : /* #line 84028 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   84028             : 
   84029             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   84030             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   84031             : // obviously imply C++.
   84032             : 
   84033             : // This implements the support within ROSE for memory pools.  Memory pools
   84034             : // support the most condensed usage of memory within the construction of
   84035             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   84036             : // by a new operator written for each class.
   84037             : 
   84038             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   84039             :     // User wants multi-thread support and POSIX threads are available.
   84040             : #   include <pthread.h>
   84041             :     static pthread_mutex_t SgElseifDirectiveStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   84042             : #else
   84043             :      // Cause synchronization to be skipped.
   84044             : #    ifndef ALLOC_MUTEX
   84045             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   84046             : #    endif
   84047             : #    ifdef _REENTRANT
   84048             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   84049             : #       ifdef _MSC_VER
   84050             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   84051             : #       else
   84052             : #           warning "POSIX threads are not available; synchronization being skipped"
   84053             : #       endif
   84054             : #    endif
   84055             : #endif
   84056             : 
   84057             : #ifndef ROSE_ALLOC_TRACE
   84058             : #  define ROSE_ALLOC_TRACE 0
   84059             : #endif
   84060             : 
   84061             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   84062             : #define ROSE_ALLOC_TRACE_CNT
   84063             : #include "memory-pool-snapshot.h"
   84064             : unsigned long alloc_trace_cnt = 0;
   84065             : #endif
   84066             : 
   84067             : #if ROSE_ALLOC_TRACE
   84068             : const unsigned SgElseifDirectiveStatement::pool_size = 5;
   84069             : #else
   84070             : const unsigned SgElseifDirectiveStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   84071             : #endif
   84072             : 
   84073             : #ifndef ROSE_ALLOC_MEMSET
   84074             : #  define ROSE_ALLOC_MEMSET 0
   84075             : #endif
   84076             : 
   84077             : #ifndef ROSE_PEDANTIC_ALLOC
   84078             : #  define ROSE_PEDANTIC_ALLOC 0
   84079             : #endif
   84080             : 
   84081             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   84082             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   84083             : #endif
   84084             : 
   84085             : #if !defined(SGNODE__ALL_POOLS)
   84086             : #define SGNODE__ALL_POOLS
   84087             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   84088             : #endif
   84089             : 
   84090             : SgElseifDirectiveStatement* SgElseifDirectiveStatement::next_node = nullptr;
   84091             : std::vector<unsigned char*> SgElseifDirectiveStatement::pools;
   84092             : 
   84093             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   84094             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   84095             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   84096             : // around this macro definition rather than each use).
   84097             : #ifndef ALLOC_MUTEX
   84098             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   84099             :         do {                                                                     \
   84100             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   84101             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   84102             :                 abort();                                                         \
   84103             :             }                                                                    \
   84104             :         } while (0);
   84105             : #endif
   84106             : 
   84107             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   84108             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   84109             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   84110             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   84111             : 
   84112             : /*! \brief New operator for SgElseifDirectiveStatement.
   84113             : 
   84114             :    This new operator implements memory pools to provide most efficent 
   84115             :    use of the heap within construction of large ASTs.
   84116             : 
   84117             : \internal The new and delete operators use the lower level C malloc/free
   84118             :    function calls for performance and to make sure that mixing of malloc/free
   84119             :    and new/delete by the used can be caught more readily.  This may change
   84120             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   84121             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   84122             :    deallocate memory allocated using ROSE_MALLOC.
   84123             : */
   84124           0 : void *SgElseifDirectiveStatement::operator new ( size_t Size )
   84125             : {
   84126             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   84127             :      * returning or throwing an exception. */
   84128           0 :     ALLOC_MUTEX(SgElseifDirectiveStatement, lock);
   84129             : 
   84130             : #if ROSE_ALLOC_TRACE == 2
   84131             : //    printf("SgElseifDirectiveStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgElseifDirectiveStatement::next_node);
   84132             : #endif
   84133             : 
   84134             : #if USE_CPP_NEW_DELETE_OPERATORS
   84135             :     void *mem = ROSE_MALLOC(Size);
   84136             :     ALLOC_MUTEX(SgElseifDirectiveStatement, unlock);
   84137             :     return mem;
   84138             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   84139             : #if ROSE_PEDANTIC_ALLOC
   84140             :     ROSE_ASSERT(Size == sizeof(SgElseifDirectiveStatement));
   84141             : #else
   84142           0 :     if (Size != sizeof(SgElseifDirectiveStatement)) {
   84143           0 :       void * object = ROSE_MALLOC(Size);
   84144           0 :       ALLOC_MUTEX(SgElseifDirectiveStatement, unlock);
   84145             :       return object;
   84146             :     }
   84147             : #endif
   84148             : 
   84149           0 :     if (SgElseifDirectiveStatement::next_node == nullptr) {
   84150           0 :         SgElseifDirectiveStatement * alloc = (SgElseifDirectiveStatement*) ROSE_MALLOC ( SgElseifDirectiveStatement::pool_size * sizeof(SgElseifDirectiveStatement) );
   84151           0 :         ROSE_ASSERT(alloc != nullptr);
   84152             : 
   84153             : #if ROSE_ALLOC_TRACE == 2
   84154             : //        printf("SgElseifDirectiveStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgElseifDirectiveStatement::pools.size(), alloc, alloc + SgElseifDirectiveStatement::pool_size);
   84155             : #endif
   84156             : 
   84157             : #if ROSE_ALLOC_MEMSET == 1
   84158             : #elif ROSE_ALLOC_MEMSET == 2
   84159             :         memset(alloc, 0x00, SgElseifDirectiveStatement::pool_size * sizeof(SgElseifDirectiveStatement));
   84160             : #elif ROSE_ALLOC_MEMSET == 3
   84161             :         memset(alloc, 0xAA, SgElseifDirectiveStatement::pool_size * sizeof(SgElseifDirectiveStatement));
   84162             : #endif
   84163           0 :         for (unsigned i=0; i < SgElseifDirectiveStatement::pool_size-1; i++) {
   84164           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
   84165             :         }
   84166           0 :         alloc[SgElseifDirectiveStatement::pool_size-1].p_freepointer = nullptr;
   84167             : 
   84168           0 :         SgElseifDirectiveStatement::pools.push_back ( (unsigned char *) alloc );
   84169           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgElseifDirectiveStatement::pool_size * sizeof(SgElseifDirectiveStatement), V_SgElseifDirectiveStatement ) );
   84170           0 :         SgElseifDirectiveStatement::next_node = alloc;
   84171             :     }
   84172           0 :     ROSE_ASSERT(SgElseifDirectiveStatement::next_node != nullptr);
   84173             : 
   84174           0 :     SgElseifDirectiveStatement * object = SgElseifDirectiveStatement::next_node;
   84175           0 :     SgElseifDirectiveStatement::next_node = (SgElseifDirectiveStatement*)(object->p_freepointer);
   84176             : 
   84177             : #if ROSE_ALLOC_TRACE == 2
   84178             :     printf("SgElseifDirectiveStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgElseifDirectiveStatement::next_node);
   84179             : #endif
   84180             : 
   84181           0 :     SgNode * fp = object->p_freepointer;
   84182             : #if ROSE_ALLOC_MEMSET == 1
   84183             : #elif ROSE_ALLOC_MEMSET == 2
   84184             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgElseifDirectiveStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   84185             : #elif ROSE_ALLOC_MEMSET == 3
   84186             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgElseifDirectiveStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   84187             : #endif
   84188           0 :     object->p_freepointer = fp;
   84189             : 
   84190             : #if ROSE_ALLOC_TRACE == 2
   84191             : //    printf("SgElseifDirectiveStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgElseifDirectiveStatement::next_node);
   84192             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   84193             :     Rose::MemPool::snapshot(oss.str());
   84194             :     alloc_trace_cnt++;
   84195             : #endif
   84196             : 
   84197           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   84198             : 
   84199           0 :     ALLOC_MUTEX(SgElseifDirectiveStatement, unlock);
   84200             : 
   84201             :     return object;
   84202             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   84203             : }
   84204             : 
   84205             : 
   84206             : 
   84207             : /*! \brief Delete operator for SgElseifDirectiveStatement.
   84208             : 
   84209             :    This delete operator implements deallocation using memory pools to 
   84210             :    provide most efficent use of the heap within construction of large ASTs.
   84211             : 
   84212             : \internal The new and delete operators use the lower level C malloc/free
   84213             :    function calls for performance and to make sure that mixing of malloc/free
   84214             :    and new/delete by the used can be caught more readily.  This may change
   84215             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   84216             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   84217             :    deallocate memory allocated using ROSE_MALLOC.
   84218             : */
   84219           0 : void SgElseifDirectiveStatement::operator delete(void *Pointer, size_t Size)
   84220             : {
   84221             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   84222             :      * or throwing an exception. */
   84223           0 :     ALLOC_MUTEX(SgElseifDirectiveStatement, lock);
   84224             : 
   84225             : #if USE_CPP_NEW_DELETE_OPERATORS
   84226             :     ROSE_FREE(Pointer);
   84227             : #else
   84228             : #if ROSE_PEDANTIC_ALLOC
   84229             :     ROSE_ASSERT(Size == sizeof(SgElseifDirectiveStatement));
   84230             : #else
   84231           0 :     if (Size != sizeof(SgElseifDirectiveStatement)) {
   84232           0 :       ROSE_FREE(Pointer);
   84233           0 :       ALLOC_MUTEX(SgElseifDirectiveStatement, unlock);
   84234             :       return;
   84235             :     }
   84236             : #endif
   84237             : 
   84238           0 :     SgElseifDirectiveStatement * object = (SgElseifDirectiveStatement*) Pointer;
   84239           0 :     ROSE_ASSERT(object != nullptr);
   84240             : 
   84241             : #if ROSE_ALLOC_TRACE == 2
   84242             : //  printf("SgElseifDirectiveStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgElseifDirectiveStatement::next_node);
   84243             :     printf("SgElseifDirectiveStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgElseifDirectiveStatement::next_node);
   84244             : #endif
   84245             : 
   84246             : #if ROSE_PEDANTIC_ALLOC
   84247             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   84248             : #endif
   84249             : 
   84250             : #if ROSE_ALLOC_MEMSET == 1
   84251             : #elif ROSE_ALLOC_MEMSET == 2
   84252             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgElseifDirectiveStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   84253             : #elif ROSE_ALLOC_MEMSET == 3
   84254             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgElseifDirectiveStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   84255             : #endif
   84256             : 
   84257             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   84258             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   84259             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   84260             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   84261             : #else
   84262           0 :     object->p_freepointer = SgElseifDirectiveStatement::next_node;
   84263           0 :     SgElseifDirectiveStatement::next_node = object;
   84264             : #endif
   84265             : 
   84266             : #if ROSE_ALLOC_TRACE == 2
   84267             : //  printf("SgElseifDirectiveStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgElseifDirectiveStatement::next_node);
   84268             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   84269             :     Rose::MemPool::snapshot(oss.str());
   84270             :     alloc_trace_cnt++;
   84271             : #endif
   84272             : 
   84273             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   84274             : 
   84275           0 :     ALLOC_MUTEX(SgElseifDirectiveStatement, unlock);
   84276             : }
   84277             : 
   84278             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   84279             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   84280             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   84281             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   84282             : // Also, note comment below from Robb (copied from the Common.code file).
   84283             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   84284             : //
   84285             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   84286             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   84287             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   84288             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   84289             : #if 0
   84290             : void SgElseifDirectiveStatement::operator delete(void* pointer) { SgElseifDirectiveStatement::operator delete (pointer, sizeof(SgElseifDirectiveStatement)); };
   84291             : #endif
   84292             : /* #line 84293 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   84293             : 
   84294             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   84295             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   84296             : // obviously imply C++.
   84297             : 
   84298             : // This implements the support within ROSE for memory pools.  Memory pools
   84299             : // support the most condensed usage of memory within the construction of
   84300             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   84301             : // by a new operator written for each class.
   84302             : 
   84303             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   84304             :     // User wants multi-thread support and POSIX threads are available.
   84305             : #   include <pthread.h>
   84306             :     static pthread_mutex_t SgEndifDirectiveStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   84307             : #else
   84308             :      // Cause synchronization to be skipped.
   84309             : #    ifndef ALLOC_MUTEX
   84310             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   84311             : #    endif
   84312             : #    ifdef _REENTRANT
   84313             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   84314             : #       ifdef _MSC_VER
   84315             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   84316             : #       else
   84317             : #           warning "POSIX threads are not available; synchronization being skipped"
   84318             : #       endif
   84319             : #    endif
   84320             : #endif
   84321             : 
   84322             : #ifndef ROSE_ALLOC_TRACE
   84323             : #  define ROSE_ALLOC_TRACE 0
   84324             : #endif
   84325             : 
   84326             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   84327             : #define ROSE_ALLOC_TRACE_CNT
   84328             : #include "memory-pool-snapshot.h"
   84329             : unsigned long alloc_trace_cnt = 0;
   84330             : #endif
   84331             : 
   84332             : #if ROSE_ALLOC_TRACE
   84333             : const unsigned SgEndifDirectiveStatement::pool_size = 5;
   84334             : #else
   84335             : const unsigned SgEndifDirectiveStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   84336             : #endif
   84337             : 
   84338             : #ifndef ROSE_ALLOC_MEMSET
   84339             : #  define ROSE_ALLOC_MEMSET 0
   84340             : #endif
   84341             : 
   84342             : #ifndef ROSE_PEDANTIC_ALLOC
   84343             : #  define ROSE_PEDANTIC_ALLOC 0
   84344             : #endif
   84345             : 
   84346             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   84347             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   84348             : #endif
   84349             : 
   84350             : #if !defined(SGNODE__ALL_POOLS)
   84351             : #define SGNODE__ALL_POOLS
   84352             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   84353             : #endif
   84354             : 
   84355             : SgEndifDirectiveStatement* SgEndifDirectiveStatement::next_node = nullptr;
   84356             : std::vector<unsigned char*> SgEndifDirectiveStatement::pools;
   84357             : 
   84358             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   84359             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   84360             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   84361             : // around this macro definition rather than each use).
   84362             : #ifndef ALLOC_MUTEX
   84363             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   84364             :         do {                                                                     \
   84365             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   84366             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   84367             :                 abort();                                                         \
   84368             :             }                                                                    \
   84369             :         } while (0);
   84370             : #endif
   84371             : 
   84372             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   84373             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   84374             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   84375             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   84376             : 
   84377             : /*! \brief New operator for SgEndifDirectiveStatement.
   84378             : 
   84379             :    This new operator implements memory pools to provide most efficent 
   84380             :    use of the heap within construction of large ASTs.
   84381             : 
   84382             : \internal The new and delete operators use the lower level C malloc/free
   84383             :    function calls for performance and to make sure that mixing of malloc/free
   84384             :    and new/delete by the used can be caught more readily.  This may change
   84385             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   84386             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   84387             :    deallocate memory allocated using ROSE_MALLOC.
   84388             : */
   84389           0 : void *SgEndifDirectiveStatement::operator new ( size_t Size )
   84390             : {
   84391             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   84392             :      * returning or throwing an exception. */
   84393           0 :     ALLOC_MUTEX(SgEndifDirectiveStatement, lock);
   84394             : 
   84395             : #if ROSE_ALLOC_TRACE == 2
   84396             : //    printf("SgEndifDirectiveStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgEndifDirectiveStatement::next_node);
   84397             : #endif
   84398             : 
   84399             : #if USE_CPP_NEW_DELETE_OPERATORS
   84400             :     void *mem = ROSE_MALLOC(Size);
   84401             :     ALLOC_MUTEX(SgEndifDirectiveStatement, unlock);
   84402             :     return mem;
   84403             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   84404             : #if ROSE_PEDANTIC_ALLOC
   84405             :     ROSE_ASSERT(Size == sizeof(SgEndifDirectiveStatement));
   84406             : #else
   84407           0 :     if (Size != sizeof(SgEndifDirectiveStatement)) {
   84408           0 :       void * object = ROSE_MALLOC(Size);
   84409           0 :       ALLOC_MUTEX(SgEndifDirectiveStatement, unlock);
   84410             :       return object;
   84411             :     }
   84412             : #endif
   84413             : 
   84414           0 :     if (SgEndifDirectiveStatement::next_node == nullptr) {
   84415           0 :         SgEndifDirectiveStatement * alloc = (SgEndifDirectiveStatement*) ROSE_MALLOC ( SgEndifDirectiveStatement::pool_size * sizeof(SgEndifDirectiveStatement) );
   84416           0 :         ROSE_ASSERT(alloc != nullptr);
   84417             : 
   84418             : #if ROSE_ALLOC_TRACE == 2
   84419             : //        printf("SgEndifDirectiveStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgEndifDirectiveStatement::pools.size(), alloc, alloc + SgEndifDirectiveStatement::pool_size);
   84420             : #endif
   84421             : 
   84422             : #if ROSE_ALLOC_MEMSET == 1
   84423             : #elif ROSE_ALLOC_MEMSET == 2
   84424             :         memset(alloc, 0x00, SgEndifDirectiveStatement::pool_size * sizeof(SgEndifDirectiveStatement));
   84425             : #elif ROSE_ALLOC_MEMSET == 3
   84426             :         memset(alloc, 0xAA, SgEndifDirectiveStatement::pool_size * sizeof(SgEndifDirectiveStatement));
   84427             : #endif
   84428           0 :         for (unsigned i=0; i < SgEndifDirectiveStatement::pool_size-1; i++) {
   84429           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
   84430             :         }
   84431           0 :         alloc[SgEndifDirectiveStatement::pool_size-1].p_freepointer = nullptr;
   84432             : 
   84433           0 :         SgEndifDirectiveStatement::pools.push_back ( (unsigned char *) alloc );
   84434           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgEndifDirectiveStatement::pool_size * sizeof(SgEndifDirectiveStatement), V_SgEndifDirectiveStatement ) );
   84435           0 :         SgEndifDirectiveStatement::next_node = alloc;
   84436             :     }
   84437           0 :     ROSE_ASSERT(SgEndifDirectiveStatement::next_node != nullptr);
   84438             : 
   84439           0 :     SgEndifDirectiveStatement * object = SgEndifDirectiveStatement::next_node;
   84440           0 :     SgEndifDirectiveStatement::next_node = (SgEndifDirectiveStatement*)(object->p_freepointer);
   84441             : 
   84442             : #if ROSE_ALLOC_TRACE == 2
   84443             :     printf("SgEndifDirectiveStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgEndifDirectiveStatement::next_node);
   84444             : #endif
   84445             : 
   84446           0 :     SgNode * fp = object->p_freepointer;
   84447             : #if ROSE_ALLOC_MEMSET == 1
   84448             : #elif ROSE_ALLOC_MEMSET == 2
   84449             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgEndifDirectiveStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   84450             : #elif ROSE_ALLOC_MEMSET == 3
   84451             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgEndifDirectiveStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   84452             : #endif
   84453           0 :     object->p_freepointer = fp;
   84454             : 
   84455             : #if ROSE_ALLOC_TRACE == 2
   84456             : //    printf("SgEndifDirectiveStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgEndifDirectiveStatement::next_node);
   84457             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   84458             :     Rose::MemPool::snapshot(oss.str());
   84459             :     alloc_trace_cnt++;
   84460             : #endif
   84461             : 
   84462           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   84463             : 
   84464           0 :     ALLOC_MUTEX(SgEndifDirectiveStatement, unlock);
   84465             : 
   84466             :     return object;
   84467             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   84468             : }
   84469             : 
   84470             : 
   84471             : 
   84472             : /*! \brief Delete operator for SgEndifDirectiveStatement.
   84473             : 
   84474             :    This delete operator implements deallocation using memory pools to 
   84475             :    provide most efficent use of the heap within construction of large ASTs.
   84476             : 
   84477             : \internal The new and delete operators use the lower level C malloc/free
   84478             :    function calls for performance and to make sure that mixing of malloc/free
   84479             :    and new/delete by the used can be caught more readily.  This may change
   84480             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   84481             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   84482             :    deallocate memory allocated using ROSE_MALLOC.
   84483             : */
   84484           0 : void SgEndifDirectiveStatement::operator delete(void *Pointer, size_t Size)
   84485             : {
   84486             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   84487             :      * or throwing an exception. */
   84488           0 :     ALLOC_MUTEX(SgEndifDirectiveStatement, lock);
   84489             : 
   84490             : #if USE_CPP_NEW_DELETE_OPERATORS
   84491             :     ROSE_FREE(Pointer);
   84492             : #else
   84493             : #if ROSE_PEDANTIC_ALLOC
   84494             :     ROSE_ASSERT(Size == sizeof(SgEndifDirectiveStatement));
   84495             : #else
   84496           0 :     if (Size != sizeof(SgEndifDirectiveStatement)) {
   84497           0 :       ROSE_FREE(Pointer);
   84498           0 :       ALLOC_MUTEX(SgEndifDirectiveStatement, unlock);
   84499             :       return;
   84500             :     }
   84501             : #endif
   84502             : 
   84503           0 :     SgEndifDirectiveStatement * object = (SgEndifDirectiveStatement*) Pointer;
   84504           0 :     ROSE_ASSERT(object != nullptr);
   84505             : 
   84506             : #if ROSE_ALLOC_TRACE == 2
   84507             : //  printf("SgEndifDirectiveStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgEndifDirectiveStatement::next_node);
   84508             :     printf("SgEndifDirectiveStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgEndifDirectiveStatement::next_node);
   84509             : #endif
   84510             : 
   84511             : #if ROSE_PEDANTIC_ALLOC
   84512             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   84513             : #endif
   84514             : 
   84515             : #if ROSE_ALLOC_MEMSET == 1
   84516             : #elif ROSE_ALLOC_MEMSET == 2
   84517             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgEndifDirectiveStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   84518             : #elif ROSE_ALLOC_MEMSET == 3
   84519             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgEndifDirectiveStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   84520             : #endif
   84521             : 
   84522             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   84523             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   84524             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   84525             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   84526             : #else
   84527           0 :     object->p_freepointer = SgEndifDirectiveStatement::next_node;
   84528           0 :     SgEndifDirectiveStatement::next_node = object;
   84529             : #endif
   84530             : 
   84531             : #if ROSE_ALLOC_TRACE == 2
   84532             : //  printf("SgEndifDirectiveStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgEndifDirectiveStatement::next_node);
   84533             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   84534             :     Rose::MemPool::snapshot(oss.str());
   84535             :     alloc_trace_cnt++;
   84536             : #endif
   84537             : 
   84538             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   84539             : 
   84540           0 :     ALLOC_MUTEX(SgEndifDirectiveStatement, unlock);
   84541             : }
   84542             : 
   84543             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   84544             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   84545             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   84546             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   84547             : // Also, note comment below from Robb (copied from the Common.code file).
   84548             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   84549             : //
   84550             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   84551             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   84552             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   84553             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   84554             : #if 0
   84555             : void SgEndifDirectiveStatement::operator delete(void* pointer) { SgEndifDirectiveStatement::operator delete (pointer, sizeof(SgEndifDirectiveStatement)); };
   84556             : #endif
   84557             : /* #line 84558 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   84558             : 
   84559             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   84560             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   84561             : // obviously imply C++.
   84562             : 
   84563             : // This implements the support within ROSE for memory pools.  Memory pools
   84564             : // support the most condensed usage of memory within the construction of
   84565             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   84566             : // by a new operator written for each class.
   84567             : 
   84568             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   84569             :     // User wants multi-thread support and POSIX threads are available.
   84570             : #   include <pthread.h>
   84571             :     static pthread_mutex_t SgLineDirectiveStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   84572             : #else
   84573             :      // Cause synchronization to be skipped.
   84574             : #    ifndef ALLOC_MUTEX
   84575             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   84576             : #    endif
   84577             : #    ifdef _REENTRANT
   84578             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   84579             : #       ifdef _MSC_VER
   84580             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   84581             : #       else
   84582             : #           warning "POSIX threads are not available; synchronization being skipped"
   84583             : #       endif
   84584             : #    endif
   84585             : #endif
   84586             : 
   84587             : #ifndef ROSE_ALLOC_TRACE
   84588             : #  define ROSE_ALLOC_TRACE 0
   84589             : #endif
   84590             : 
   84591             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   84592             : #define ROSE_ALLOC_TRACE_CNT
   84593             : #include "memory-pool-snapshot.h"
   84594             : unsigned long alloc_trace_cnt = 0;
   84595             : #endif
   84596             : 
   84597             : #if ROSE_ALLOC_TRACE
   84598             : const unsigned SgLineDirectiveStatement::pool_size = 5;
   84599             : #else
   84600             : const unsigned SgLineDirectiveStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   84601             : #endif
   84602             : 
   84603             : #ifndef ROSE_ALLOC_MEMSET
   84604             : #  define ROSE_ALLOC_MEMSET 0
   84605             : #endif
   84606             : 
   84607             : #ifndef ROSE_PEDANTIC_ALLOC
   84608             : #  define ROSE_PEDANTIC_ALLOC 0
   84609             : #endif
   84610             : 
   84611             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   84612             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   84613             : #endif
   84614             : 
   84615             : #if !defined(SGNODE__ALL_POOLS)
   84616             : #define SGNODE__ALL_POOLS
   84617             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   84618             : #endif
   84619             : 
   84620             : SgLineDirectiveStatement* SgLineDirectiveStatement::next_node = nullptr;
   84621             : std::vector<unsigned char*> SgLineDirectiveStatement::pools;
   84622             : 
   84623             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   84624             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   84625             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   84626             : // around this macro definition rather than each use).
   84627             : #ifndef ALLOC_MUTEX
   84628             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   84629             :         do {                                                                     \
   84630             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   84631             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   84632             :                 abort();                                                         \
   84633             :             }                                                                    \
   84634             :         } while (0);
   84635             : #endif
   84636             : 
   84637             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   84638             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   84639             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   84640             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   84641             : 
   84642             : /*! \brief New operator for SgLineDirectiveStatement.
   84643             : 
   84644             :    This new operator implements memory pools to provide most efficent 
   84645             :    use of the heap within construction of large ASTs.
   84646             : 
   84647             : \internal The new and delete operators use the lower level C malloc/free
   84648             :    function calls for performance and to make sure that mixing of malloc/free
   84649             :    and new/delete by the used can be caught more readily.  This may change
   84650             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   84651             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   84652             :    deallocate memory allocated using ROSE_MALLOC.
   84653             : */
   84654           0 : void *SgLineDirectiveStatement::operator new ( size_t Size )
   84655             : {
   84656             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   84657             :      * returning or throwing an exception. */
   84658           0 :     ALLOC_MUTEX(SgLineDirectiveStatement, lock);
   84659             : 
   84660             : #if ROSE_ALLOC_TRACE == 2
   84661             : //    printf("SgLineDirectiveStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgLineDirectiveStatement::next_node);
   84662             : #endif
   84663             : 
   84664             : #if USE_CPP_NEW_DELETE_OPERATORS
   84665             :     void *mem = ROSE_MALLOC(Size);
   84666             :     ALLOC_MUTEX(SgLineDirectiveStatement, unlock);
   84667             :     return mem;
   84668             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   84669             : #if ROSE_PEDANTIC_ALLOC
   84670             :     ROSE_ASSERT(Size == sizeof(SgLineDirectiveStatement));
   84671             : #else
   84672           0 :     if (Size != sizeof(SgLineDirectiveStatement)) {
   84673           0 :       void * object = ROSE_MALLOC(Size);
   84674           0 :       ALLOC_MUTEX(SgLineDirectiveStatement, unlock);
   84675             :       return object;
   84676             :     }
   84677             : #endif
   84678             : 
   84679           0 :     if (SgLineDirectiveStatement::next_node == nullptr) {
   84680           0 :         SgLineDirectiveStatement * alloc = (SgLineDirectiveStatement*) ROSE_MALLOC ( SgLineDirectiveStatement::pool_size * sizeof(SgLineDirectiveStatement) );
   84681           0 :         ROSE_ASSERT(alloc != nullptr);
   84682             : 
   84683             : #if ROSE_ALLOC_TRACE == 2
   84684             : //        printf("SgLineDirectiveStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgLineDirectiveStatement::pools.size(), alloc, alloc + SgLineDirectiveStatement::pool_size);
   84685             : #endif
   84686             : 
   84687             : #if ROSE_ALLOC_MEMSET == 1
   84688             : #elif ROSE_ALLOC_MEMSET == 2
   84689             :         memset(alloc, 0x00, SgLineDirectiveStatement::pool_size * sizeof(SgLineDirectiveStatement));
   84690             : #elif ROSE_ALLOC_MEMSET == 3
   84691             :         memset(alloc, 0xAA, SgLineDirectiveStatement::pool_size * sizeof(SgLineDirectiveStatement));
   84692             : #endif
   84693           0 :         for (unsigned i=0; i < SgLineDirectiveStatement::pool_size-1; i++) {
   84694           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
   84695             :         }
   84696           0 :         alloc[SgLineDirectiveStatement::pool_size-1].p_freepointer = nullptr;
   84697             : 
   84698           0 :         SgLineDirectiveStatement::pools.push_back ( (unsigned char *) alloc );
   84699           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgLineDirectiveStatement::pool_size * sizeof(SgLineDirectiveStatement), V_SgLineDirectiveStatement ) );
   84700           0 :         SgLineDirectiveStatement::next_node = alloc;
   84701             :     }
   84702           0 :     ROSE_ASSERT(SgLineDirectiveStatement::next_node != nullptr);
   84703             : 
   84704           0 :     SgLineDirectiveStatement * object = SgLineDirectiveStatement::next_node;
   84705           0 :     SgLineDirectiveStatement::next_node = (SgLineDirectiveStatement*)(object->p_freepointer);
   84706             : 
   84707             : #if ROSE_ALLOC_TRACE == 2
   84708             :     printf("SgLineDirectiveStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgLineDirectiveStatement::next_node);
   84709             : #endif
   84710             : 
   84711           0 :     SgNode * fp = object->p_freepointer;
   84712             : #if ROSE_ALLOC_MEMSET == 1
   84713             : #elif ROSE_ALLOC_MEMSET == 2
   84714             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgLineDirectiveStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   84715             : #elif ROSE_ALLOC_MEMSET == 3
   84716             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgLineDirectiveStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   84717             : #endif
   84718           0 :     object->p_freepointer = fp;
   84719             : 
   84720             : #if ROSE_ALLOC_TRACE == 2
   84721             : //    printf("SgLineDirectiveStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgLineDirectiveStatement::next_node);
   84722             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   84723             :     Rose::MemPool::snapshot(oss.str());
   84724             :     alloc_trace_cnt++;
   84725             : #endif
   84726             : 
   84727           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   84728             : 
   84729           0 :     ALLOC_MUTEX(SgLineDirectiveStatement, unlock);
   84730             : 
   84731             :     return object;
   84732             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   84733             : }
   84734             : 
   84735             : 
   84736             : 
   84737             : /*! \brief Delete operator for SgLineDirectiveStatement.
   84738             : 
   84739             :    This delete operator implements deallocation using memory pools to 
   84740             :    provide most efficent use of the heap within construction of large ASTs.
   84741             : 
   84742             : \internal The new and delete operators use the lower level C malloc/free
   84743             :    function calls for performance and to make sure that mixing of malloc/free
   84744             :    and new/delete by the used can be caught more readily.  This may change
   84745             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   84746             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   84747             :    deallocate memory allocated using ROSE_MALLOC.
   84748             : */
   84749           0 : void SgLineDirectiveStatement::operator delete(void *Pointer, size_t Size)
   84750             : {
   84751             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   84752             :      * or throwing an exception. */
   84753           0 :     ALLOC_MUTEX(SgLineDirectiveStatement, lock);
   84754             : 
   84755             : #if USE_CPP_NEW_DELETE_OPERATORS
   84756             :     ROSE_FREE(Pointer);
   84757             : #else
   84758             : #if ROSE_PEDANTIC_ALLOC
   84759             :     ROSE_ASSERT(Size == sizeof(SgLineDirectiveStatement));
   84760             : #else
   84761           0 :     if (Size != sizeof(SgLineDirectiveStatement)) {
   84762           0 :       ROSE_FREE(Pointer);
   84763           0 :       ALLOC_MUTEX(SgLineDirectiveStatement, unlock);
   84764             :       return;
   84765             :     }
   84766             : #endif
   84767             : 
   84768           0 :     SgLineDirectiveStatement * object = (SgLineDirectiveStatement*) Pointer;
   84769           0 :     ROSE_ASSERT(object != nullptr);
   84770             : 
   84771             : #if ROSE_ALLOC_TRACE == 2
   84772             : //  printf("SgLineDirectiveStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgLineDirectiveStatement::next_node);
   84773             :     printf("SgLineDirectiveStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgLineDirectiveStatement::next_node);
   84774             : #endif
   84775             : 
   84776             : #if ROSE_PEDANTIC_ALLOC
   84777             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   84778             : #endif
   84779             : 
   84780             : #if ROSE_ALLOC_MEMSET == 1
   84781             : #elif ROSE_ALLOC_MEMSET == 2
   84782             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgLineDirectiveStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   84783             : #elif ROSE_ALLOC_MEMSET == 3
   84784             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgLineDirectiveStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   84785             : #endif
   84786             : 
   84787             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   84788             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   84789             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   84790             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   84791             : #else
   84792           0 :     object->p_freepointer = SgLineDirectiveStatement::next_node;
   84793           0 :     SgLineDirectiveStatement::next_node = object;
   84794             : #endif
   84795             : 
   84796             : #if ROSE_ALLOC_TRACE == 2
   84797             : //  printf("SgLineDirectiveStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgLineDirectiveStatement::next_node);
   84798             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   84799             :     Rose::MemPool::snapshot(oss.str());
   84800             :     alloc_trace_cnt++;
   84801             : #endif
   84802             : 
   84803             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   84804             : 
   84805           0 :     ALLOC_MUTEX(SgLineDirectiveStatement, unlock);
   84806             : }
   84807             : 
   84808             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   84809             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   84810             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   84811             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   84812             : // Also, note comment below from Robb (copied from the Common.code file).
   84813             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   84814             : //
   84815             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   84816             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   84817             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   84818             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   84819             : #if 0
   84820             : void SgLineDirectiveStatement::operator delete(void* pointer) { SgLineDirectiveStatement::operator delete (pointer, sizeof(SgLineDirectiveStatement)); };
   84821             : #endif
   84822             : /* #line 84823 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   84823             : 
   84824             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   84825             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   84826             : // obviously imply C++.
   84827             : 
   84828             : // This implements the support within ROSE for memory pools.  Memory pools
   84829             : // support the most condensed usage of memory within the construction of
   84830             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   84831             : // by a new operator written for each class.
   84832             : 
   84833             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   84834             :     // User wants multi-thread support and POSIX threads are available.
   84835             : #   include <pthread.h>
   84836             :     static pthread_mutex_t SgWarningDirectiveStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   84837             : #else
   84838             :      // Cause synchronization to be skipped.
   84839             : #    ifndef ALLOC_MUTEX
   84840             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   84841             : #    endif
   84842             : #    ifdef _REENTRANT
   84843             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   84844             : #       ifdef _MSC_VER
   84845             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   84846             : #       else
   84847             : #           warning "POSIX threads are not available; synchronization being skipped"
   84848             : #       endif
   84849             : #    endif
   84850             : #endif
   84851             : 
   84852             : #ifndef ROSE_ALLOC_TRACE
   84853             : #  define ROSE_ALLOC_TRACE 0
   84854             : #endif
   84855             : 
   84856             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   84857             : #define ROSE_ALLOC_TRACE_CNT
   84858             : #include "memory-pool-snapshot.h"
   84859             : unsigned long alloc_trace_cnt = 0;
   84860             : #endif
   84861             : 
   84862             : #if ROSE_ALLOC_TRACE
   84863             : const unsigned SgWarningDirectiveStatement::pool_size = 5;
   84864             : #else
   84865             : const unsigned SgWarningDirectiveStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   84866             : #endif
   84867             : 
   84868             : #ifndef ROSE_ALLOC_MEMSET
   84869             : #  define ROSE_ALLOC_MEMSET 0
   84870             : #endif
   84871             : 
   84872             : #ifndef ROSE_PEDANTIC_ALLOC
   84873             : #  define ROSE_PEDANTIC_ALLOC 0
   84874             : #endif
   84875             : 
   84876             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   84877             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   84878             : #endif
   84879             : 
   84880             : #if !defined(SGNODE__ALL_POOLS)
   84881             : #define SGNODE__ALL_POOLS
   84882             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   84883             : #endif
   84884             : 
   84885             : SgWarningDirectiveStatement* SgWarningDirectiveStatement::next_node = nullptr;
   84886             : std::vector<unsigned char*> SgWarningDirectiveStatement::pools;
   84887             : 
   84888             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   84889             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   84890             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   84891             : // around this macro definition rather than each use).
   84892             : #ifndef ALLOC_MUTEX
   84893             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   84894             :         do {                                                                     \
   84895             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   84896             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   84897             :                 abort();                                                         \
   84898             :             }                                                                    \
   84899             :         } while (0);
   84900             : #endif
   84901             : 
   84902             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   84903             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   84904             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   84905             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   84906             : 
   84907             : /*! \brief New operator for SgWarningDirectiveStatement.
   84908             : 
   84909             :    This new operator implements memory pools to provide most efficent 
   84910             :    use of the heap within construction of large ASTs.
   84911             : 
   84912             : \internal The new and delete operators use the lower level C malloc/free
   84913             :    function calls for performance and to make sure that mixing of malloc/free
   84914             :    and new/delete by the used can be caught more readily.  This may change
   84915             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   84916             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   84917             :    deallocate memory allocated using ROSE_MALLOC.
   84918             : */
   84919           0 : void *SgWarningDirectiveStatement::operator new ( size_t Size )
   84920             : {
   84921             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   84922             :      * returning or throwing an exception. */
   84923           0 :     ALLOC_MUTEX(SgWarningDirectiveStatement, lock);
   84924             : 
   84925             : #if ROSE_ALLOC_TRACE == 2
   84926             : //    printf("SgWarningDirectiveStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgWarningDirectiveStatement::next_node);
   84927             : #endif
   84928             : 
   84929             : #if USE_CPP_NEW_DELETE_OPERATORS
   84930             :     void *mem = ROSE_MALLOC(Size);
   84931             :     ALLOC_MUTEX(SgWarningDirectiveStatement, unlock);
   84932             :     return mem;
   84933             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   84934             : #if ROSE_PEDANTIC_ALLOC
   84935             :     ROSE_ASSERT(Size == sizeof(SgWarningDirectiveStatement));
   84936             : #else
   84937           0 :     if (Size != sizeof(SgWarningDirectiveStatement)) {
   84938           0 :       void * object = ROSE_MALLOC(Size);
   84939           0 :       ALLOC_MUTEX(SgWarningDirectiveStatement, unlock);
   84940             :       return object;
   84941             :     }
   84942             : #endif
   84943             : 
   84944           0 :     if (SgWarningDirectiveStatement::next_node == nullptr) {
   84945           0 :         SgWarningDirectiveStatement * alloc = (SgWarningDirectiveStatement*) ROSE_MALLOC ( SgWarningDirectiveStatement::pool_size * sizeof(SgWarningDirectiveStatement) );
   84946           0 :         ROSE_ASSERT(alloc != nullptr);
   84947             : 
   84948             : #if ROSE_ALLOC_TRACE == 2
   84949             : //        printf("SgWarningDirectiveStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgWarningDirectiveStatement::pools.size(), alloc, alloc + SgWarningDirectiveStatement::pool_size);
   84950             : #endif
   84951             : 
   84952             : #if ROSE_ALLOC_MEMSET == 1
   84953             : #elif ROSE_ALLOC_MEMSET == 2
   84954             :         memset(alloc, 0x00, SgWarningDirectiveStatement::pool_size * sizeof(SgWarningDirectiveStatement));
   84955             : #elif ROSE_ALLOC_MEMSET == 3
   84956             :         memset(alloc, 0xAA, SgWarningDirectiveStatement::pool_size * sizeof(SgWarningDirectiveStatement));
   84957             : #endif
   84958           0 :         for (unsigned i=0; i < SgWarningDirectiveStatement::pool_size-1; i++) {
   84959           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
   84960             :         }
   84961           0 :         alloc[SgWarningDirectiveStatement::pool_size-1].p_freepointer = nullptr;
   84962             : 
   84963           0 :         SgWarningDirectiveStatement::pools.push_back ( (unsigned char *) alloc );
   84964           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgWarningDirectiveStatement::pool_size * sizeof(SgWarningDirectiveStatement), V_SgWarningDirectiveStatement ) );
   84965           0 :         SgWarningDirectiveStatement::next_node = alloc;
   84966             :     }
   84967           0 :     ROSE_ASSERT(SgWarningDirectiveStatement::next_node != nullptr);
   84968             : 
   84969           0 :     SgWarningDirectiveStatement * object = SgWarningDirectiveStatement::next_node;
   84970           0 :     SgWarningDirectiveStatement::next_node = (SgWarningDirectiveStatement*)(object->p_freepointer);
   84971             : 
   84972             : #if ROSE_ALLOC_TRACE == 2
   84973             :     printf("SgWarningDirectiveStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgWarningDirectiveStatement::next_node);
   84974             : #endif
   84975             : 
   84976           0 :     SgNode * fp = object->p_freepointer;
   84977             : #if ROSE_ALLOC_MEMSET == 1
   84978             : #elif ROSE_ALLOC_MEMSET == 2
   84979             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgWarningDirectiveStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   84980             : #elif ROSE_ALLOC_MEMSET == 3
   84981             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgWarningDirectiveStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   84982             : #endif
   84983           0 :     object->p_freepointer = fp;
   84984             : 
   84985             : #if ROSE_ALLOC_TRACE == 2
   84986             : //    printf("SgWarningDirectiveStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgWarningDirectiveStatement::next_node);
   84987             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   84988             :     Rose::MemPool::snapshot(oss.str());
   84989             :     alloc_trace_cnt++;
   84990             : #endif
   84991             : 
   84992           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   84993             : 
   84994           0 :     ALLOC_MUTEX(SgWarningDirectiveStatement, unlock);
   84995             : 
   84996             :     return object;
   84997             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   84998             : }
   84999             : 
   85000             : 
   85001             : 
   85002             : /*! \brief Delete operator for SgWarningDirectiveStatement.
   85003             : 
   85004             :    This delete operator implements deallocation using memory pools to 
   85005             :    provide most efficent use of the heap within construction of large ASTs.
   85006             : 
   85007             : \internal The new and delete operators use the lower level C malloc/free
   85008             :    function calls for performance and to make sure that mixing of malloc/free
   85009             :    and new/delete by the used can be caught more readily.  This may change
   85010             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   85011             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   85012             :    deallocate memory allocated using ROSE_MALLOC.
   85013             : */
   85014           0 : void SgWarningDirectiveStatement::operator delete(void *Pointer, size_t Size)
   85015             : {
   85016             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   85017             :      * or throwing an exception. */
   85018           0 :     ALLOC_MUTEX(SgWarningDirectiveStatement, lock);
   85019             : 
   85020             : #if USE_CPP_NEW_DELETE_OPERATORS
   85021             :     ROSE_FREE(Pointer);
   85022             : #else
   85023             : #if ROSE_PEDANTIC_ALLOC
   85024             :     ROSE_ASSERT(Size == sizeof(SgWarningDirectiveStatement));
   85025             : #else
   85026           0 :     if (Size != sizeof(SgWarningDirectiveStatement)) {
   85027           0 :       ROSE_FREE(Pointer);
   85028           0 :       ALLOC_MUTEX(SgWarningDirectiveStatement, unlock);
   85029             :       return;
   85030             :     }
   85031             : #endif
   85032             : 
   85033           0 :     SgWarningDirectiveStatement * object = (SgWarningDirectiveStatement*) Pointer;
   85034           0 :     ROSE_ASSERT(object != nullptr);
   85035             : 
   85036             : #if ROSE_ALLOC_TRACE == 2
   85037             : //  printf("SgWarningDirectiveStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgWarningDirectiveStatement::next_node);
   85038             :     printf("SgWarningDirectiveStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgWarningDirectiveStatement::next_node);
   85039             : #endif
   85040             : 
   85041             : #if ROSE_PEDANTIC_ALLOC
   85042             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   85043             : #endif
   85044             : 
   85045             : #if ROSE_ALLOC_MEMSET == 1
   85046             : #elif ROSE_ALLOC_MEMSET == 2
   85047             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgWarningDirectiveStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   85048             : #elif ROSE_ALLOC_MEMSET == 3
   85049             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgWarningDirectiveStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   85050             : #endif
   85051             : 
   85052             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   85053             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   85054             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   85055             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   85056             : #else
   85057           0 :     object->p_freepointer = SgWarningDirectiveStatement::next_node;
   85058           0 :     SgWarningDirectiveStatement::next_node = object;
   85059             : #endif
   85060             : 
   85061             : #if ROSE_ALLOC_TRACE == 2
   85062             : //  printf("SgWarningDirectiveStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgWarningDirectiveStatement::next_node);
   85063             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   85064             :     Rose::MemPool::snapshot(oss.str());
   85065             :     alloc_trace_cnt++;
   85066             : #endif
   85067             : 
   85068             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   85069             : 
   85070           0 :     ALLOC_MUTEX(SgWarningDirectiveStatement, unlock);
   85071             : }
   85072             : 
   85073             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   85074             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   85075             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   85076             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   85077             : // Also, note comment below from Robb (copied from the Common.code file).
   85078             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   85079             : //
   85080             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   85081             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   85082             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   85083             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   85084             : #if 0
   85085             : void SgWarningDirectiveStatement::operator delete(void* pointer) { SgWarningDirectiveStatement::operator delete (pointer, sizeof(SgWarningDirectiveStatement)); };
   85086             : #endif
   85087             : /* #line 85088 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   85088             : 
   85089             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   85090             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   85091             : // obviously imply C++.
   85092             : 
   85093             : // This implements the support within ROSE for memory pools.  Memory pools
   85094             : // support the most condensed usage of memory within the construction of
   85095             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   85096             : // by a new operator written for each class.
   85097             : 
   85098             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   85099             :     // User wants multi-thread support and POSIX threads are available.
   85100             : #   include <pthread.h>
   85101             :     static pthread_mutex_t SgErrorDirectiveStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   85102             : #else
   85103             :      // Cause synchronization to be skipped.
   85104             : #    ifndef ALLOC_MUTEX
   85105             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   85106             : #    endif
   85107             : #    ifdef _REENTRANT
   85108             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   85109             : #       ifdef _MSC_VER
   85110             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   85111             : #       else
   85112             : #           warning "POSIX threads are not available; synchronization being skipped"
   85113             : #       endif
   85114             : #    endif
   85115             : #endif
   85116             : 
   85117             : #ifndef ROSE_ALLOC_TRACE
   85118             : #  define ROSE_ALLOC_TRACE 0
   85119             : #endif
   85120             : 
   85121             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   85122             : #define ROSE_ALLOC_TRACE_CNT
   85123             : #include "memory-pool-snapshot.h"
   85124             : unsigned long alloc_trace_cnt = 0;
   85125             : #endif
   85126             : 
   85127             : #if ROSE_ALLOC_TRACE
   85128             : const unsigned SgErrorDirectiveStatement::pool_size = 5;
   85129             : #else
   85130             : const unsigned SgErrorDirectiveStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   85131             : #endif
   85132             : 
   85133             : #ifndef ROSE_ALLOC_MEMSET
   85134             : #  define ROSE_ALLOC_MEMSET 0
   85135             : #endif
   85136             : 
   85137             : #ifndef ROSE_PEDANTIC_ALLOC
   85138             : #  define ROSE_PEDANTIC_ALLOC 0
   85139             : #endif
   85140             : 
   85141             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   85142             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   85143             : #endif
   85144             : 
   85145             : #if !defined(SGNODE__ALL_POOLS)
   85146             : #define SGNODE__ALL_POOLS
   85147             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   85148             : #endif
   85149             : 
   85150             : SgErrorDirectiveStatement* SgErrorDirectiveStatement::next_node = nullptr;
   85151             : std::vector<unsigned char*> SgErrorDirectiveStatement::pools;
   85152             : 
   85153             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   85154             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   85155             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   85156             : // around this macro definition rather than each use).
   85157             : #ifndef ALLOC_MUTEX
   85158             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   85159             :         do {                                                                     \
   85160             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   85161             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   85162             :                 abort();                                                         \
   85163             :             }                                                                    \
   85164             :         } while (0);
   85165             : #endif
   85166             : 
   85167             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   85168             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   85169             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   85170             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   85171             : 
   85172             : /*! \brief New operator for SgErrorDirectiveStatement.
   85173             : 
   85174             :    This new operator implements memory pools to provide most efficent 
   85175             :    use of the heap within construction of large ASTs.
   85176             : 
   85177             : \internal The new and delete operators use the lower level C malloc/free
   85178             :    function calls for performance and to make sure that mixing of malloc/free
   85179             :    and new/delete by the used can be caught more readily.  This may change
   85180             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   85181             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   85182             :    deallocate memory allocated using ROSE_MALLOC.
   85183             : */
   85184           0 : void *SgErrorDirectiveStatement::operator new ( size_t Size )
   85185             : {
   85186             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   85187             :      * returning or throwing an exception. */
   85188           0 :     ALLOC_MUTEX(SgErrorDirectiveStatement, lock);
   85189             : 
   85190             : #if ROSE_ALLOC_TRACE == 2
   85191             : //    printf("SgErrorDirectiveStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgErrorDirectiveStatement::next_node);
   85192             : #endif
   85193             : 
   85194             : #if USE_CPP_NEW_DELETE_OPERATORS
   85195             :     void *mem = ROSE_MALLOC(Size);
   85196             :     ALLOC_MUTEX(SgErrorDirectiveStatement, unlock);
   85197             :     return mem;
   85198             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   85199             : #if ROSE_PEDANTIC_ALLOC
   85200             :     ROSE_ASSERT(Size == sizeof(SgErrorDirectiveStatement));
   85201             : #else
   85202           0 :     if (Size != sizeof(SgErrorDirectiveStatement)) {
   85203           0 :       void * object = ROSE_MALLOC(Size);
   85204           0 :       ALLOC_MUTEX(SgErrorDirectiveStatement, unlock);
   85205             :       return object;
   85206             :     }
   85207             : #endif
   85208             : 
   85209           0 :     if (SgErrorDirectiveStatement::next_node == nullptr) {
   85210           0 :         SgErrorDirectiveStatement * alloc = (SgErrorDirectiveStatement*) ROSE_MALLOC ( SgErrorDirectiveStatement::pool_size * sizeof(SgErrorDirectiveStatement) );
   85211           0 :         ROSE_ASSERT(alloc != nullptr);
   85212             : 
   85213             : #if ROSE_ALLOC_TRACE == 2
   85214             : //        printf("SgErrorDirectiveStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgErrorDirectiveStatement::pools.size(), alloc, alloc + SgErrorDirectiveStatement::pool_size);
   85215             : #endif
   85216             : 
   85217             : #if ROSE_ALLOC_MEMSET == 1
   85218             : #elif ROSE_ALLOC_MEMSET == 2
   85219             :         memset(alloc, 0x00, SgErrorDirectiveStatement::pool_size * sizeof(SgErrorDirectiveStatement));
   85220             : #elif ROSE_ALLOC_MEMSET == 3
   85221             :         memset(alloc, 0xAA, SgErrorDirectiveStatement::pool_size * sizeof(SgErrorDirectiveStatement));
   85222             : #endif
   85223           0 :         for (unsigned i=0; i < SgErrorDirectiveStatement::pool_size-1; i++) {
   85224           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
   85225             :         }
   85226           0 :         alloc[SgErrorDirectiveStatement::pool_size-1].p_freepointer = nullptr;
   85227             : 
   85228           0 :         SgErrorDirectiveStatement::pools.push_back ( (unsigned char *) alloc );
   85229           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgErrorDirectiveStatement::pool_size * sizeof(SgErrorDirectiveStatement), V_SgErrorDirectiveStatement ) );
   85230           0 :         SgErrorDirectiveStatement::next_node = alloc;
   85231             :     }
   85232           0 :     ROSE_ASSERT(SgErrorDirectiveStatement::next_node != nullptr);
   85233             : 
   85234           0 :     SgErrorDirectiveStatement * object = SgErrorDirectiveStatement::next_node;
   85235           0 :     SgErrorDirectiveStatement::next_node = (SgErrorDirectiveStatement*)(object->p_freepointer);
   85236             : 
   85237             : #if ROSE_ALLOC_TRACE == 2
   85238             :     printf("SgErrorDirectiveStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgErrorDirectiveStatement::next_node);
   85239             : #endif
   85240             : 
   85241           0 :     SgNode * fp = object->p_freepointer;
   85242             : #if ROSE_ALLOC_MEMSET == 1
   85243             : #elif ROSE_ALLOC_MEMSET == 2
   85244             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgErrorDirectiveStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   85245             : #elif ROSE_ALLOC_MEMSET == 3
   85246             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgErrorDirectiveStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   85247             : #endif
   85248           0 :     object->p_freepointer = fp;
   85249             : 
   85250             : #if ROSE_ALLOC_TRACE == 2
   85251             : //    printf("SgErrorDirectiveStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgErrorDirectiveStatement::next_node);
   85252             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   85253             :     Rose::MemPool::snapshot(oss.str());
   85254             :     alloc_trace_cnt++;
   85255             : #endif
   85256             : 
   85257           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   85258             : 
   85259           0 :     ALLOC_MUTEX(SgErrorDirectiveStatement, unlock);
   85260             : 
   85261             :     return object;
   85262             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   85263             : }
   85264             : 
   85265             : 
   85266             : 
   85267             : /*! \brief Delete operator for SgErrorDirectiveStatement.
   85268             : 
   85269             :    This delete operator implements deallocation using memory pools to 
   85270             :    provide most efficent use of the heap within construction of large ASTs.
   85271             : 
   85272             : \internal The new and delete operators use the lower level C malloc/free
   85273             :    function calls for performance and to make sure that mixing of malloc/free
   85274             :    and new/delete by the used can be caught more readily.  This may change
   85275             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   85276             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   85277             :    deallocate memory allocated using ROSE_MALLOC.
   85278             : */
   85279           0 : void SgErrorDirectiveStatement::operator delete(void *Pointer, size_t Size)
   85280             : {
   85281             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   85282             :      * or throwing an exception. */
   85283           0 :     ALLOC_MUTEX(SgErrorDirectiveStatement, lock);
   85284             : 
   85285             : #if USE_CPP_NEW_DELETE_OPERATORS
   85286             :     ROSE_FREE(Pointer);
   85287             : #else
   85288             : #if ROSE_PEDANTIC_ALLOC
   85289             :     ROSE_ASSERT(Size == sizeof(SgErrorDirectiveStatement));
   85290             : #else
   85291           0 :     if (Size != sizeof(SgErrorDirectiveStatement)) {
   85292           0 :       ROSE_FREE(Pointer);
   85293           0 :       ALLOC_MUTEX(SgErrorDirectiveStatement, unlock);
   85294             :       return;
   85295             :     }
   85296             : #endif
   85297             : 
   85298           0 :     SgErrorDirectiveStatement * object = (SgErrorDirectiveStatement*) Pointer;
   85299           0 :     ROSE_ASSERT(object != nullptr);
   85300             : 
   85301             : #if ROSE_ALLOC_TRACE == 2
   85302             : //  printf("SgErrorDirectiveStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgErrorDirectiveStatement::next_node);
   85303             :     printf("SgErrorDirectiveStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgErrorDirectiveStatement::next_node);
   85304             : #endif
   85305             : 
   85306             : #if ROSE_PEDANTIC_ALLOC
   85307             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   85308             : #endif
   85309             : 
   85310             : #if ROSE_ALLOC_MEMSET == 1
   85311             : #elif ROSE_ALLOC_MEMSET == 2
   85312             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgErrorDirectiveStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   85313             : #elif ROSE_ALLOC_MEMSET == 3
   85314             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgErrorDirectiveStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   85315             : #endif
   85316             : 
   85317             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   85318             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   85319             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   85320             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   85321             : #else
   85322           0 :     object->p_freepointer = SgErrorDirectiveStatement::next_node;
   85323           0 :     SgErrorDirectiveStatement::next_node = object;
   85324             : #endif
   85325             : 
   85326             : #if ROSE_ALLOC_TRACE == 2
   85327             : //  printf("SgErrorDirectiveStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgErrorDirectiveStatement::next_node);
   85328             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   85329             :     Rose::MemPool::snapshot(oss.str());
   85330             :     alloc_trace_cnt++;
   85331             : #endif
   85332             : 
   85333             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   85334             : 
   85335           0 :     ALLOC_MUTEX(SgErrorDirectiveStatement, unlock);
   85336             : }
   85337             : 
   85338             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   85339             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   85340             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   85341             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   85342             : // Also, note comment below from Robb (copied from the Common.code file).
   85343             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   85344             : //
   85345             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   85346             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   85347             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   85348             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   85349             : #if 0
   85350             : void SgErrorDirectiveStatement::operator delete(void* pointer) { SgErrorDirectiveStatement::operator delete (pointer, sizeof(SgErrorDirectiveStatement)); };
   85351             : #endif
   85352             : /* #line 85353 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   85353             : 
   85354             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   85355             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   85356             : // obviously imply C++.
   85357             : 
   85358             : // This implements the support within ROSE for memory pools.  Memory pools
   85359             : // support the most condensed usage of memory within the construction of
   85360             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   85361             : // by a new operator written for each class.
   85362             : 
   85363             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   85364             :     // User wants multi-thread support and POSIX threads are available.
   85365             : #   include <pthread.h>
   85366             :     static pthread_mutex_t SgEmptyDirectiveStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   85367             : #else
   85368             :      // Cause synchronization to be skipped.
   85369             : #    ifndef ALLOC_MUTEX
   85370             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   85371             : #    endif
   85372             : #    ifdef _REENTRANT
   85373             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   85374             : #       ifdef _MSC_VER
   85375             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   85376             : #       else
   85377             : #           warning "POSIX threads are not available; synchronization being skipped"
   85378             : #       endif
   85379             : #    endif
   85380             : #endif
   85381             : 
   85382             : #ifndef ROSE_ALLOC_TRACE
   85383             : #  define ROSE_ALLOC_TRACE 0
   85384             : #endif
   85385             : 
   85386             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   85387             : #define ROSE_ALLOC_TRACE_CNT
   85388             : #include "memory-pool-snapshot.h"
   85389             : unsigned long alloc_trace_cnt = 0;
   85390             : #endif
   85391             : 
   85392             : #if ROSE_ALLOC_TRACE
   85393             : const unsigned SgEmptyDirectiveStatement::pool_size = 5;
   85394             : #else
   85395             : const unsigned SgEmptyDirectiveStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   85396             : #endif
   85397             : 
   85398             : #ifndef ROSE_ALLOC_MEMSET
   85399             : #  define ROSE_ALLOC_MEMSET 0
   85400             : #endif
   85401             : 
   85402             : #ifndef ROSE_PEDANTIC_ALLOC
   85403             : #  define ROSE_PEDANTIC_ALLOC 0
   85404             : #endif
   85405             : 
   85406             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   85407             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   85408             : #endif
   85409             : 
   85410             : #if !defined(SGNODE__ALL_POOLS)
   85411             : #define SGNODE__ALL_POOLS
   85412             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   85413             : #endif
   85414             : 
   85415             : SgEmptyDirectiveStatement* SgEmptyDirectiveStatement::next_node = nullptr;
   85416             : std::vector<unsigned char*> SgEmptyDirectiveStatement::pools;
   85417             : 
   85418             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   85419             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   85420             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   85421             : // around this macro definition rather than each use).
   85422             : #ifndef ALLOC_MUTEX
   85423             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   85424             :         do {                                                                     \
   85425             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   85426             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   85427             :                 abort();                                                         \
   85428             :             }                                                                    \
   85429             :         } while (0);
   85430             : #endif
   85431             : 
   85432             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   85433             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   85434             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   85435             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   85436             : 
   85437             : /*! \brief New operator for SgEmptyDirectiveStatement.
   85438             : 
   85439             :    This new operator implements memory pools to provide most efficent 
   85440             :    use of the heap within construction of large ASTs.
   85441             : 
   85442             : \internal The new and delete operators use the lower level C malloc/free
   85443             :    function calls for performance and to make sure that mixing of malloc/free
   85444             :    and new/delete by the used can be caught more readily.  This may change
   85445             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   85446             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   85447             :    deallocate memory allocated using ROSE_MALLOC.
   85448             : */
   85449           0 : void *SgEmptyDirectiveStatement::operator new ( size_t Size )
   85450             : {
   85451             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   85452             :      * returning or throwing an exception. */
   85453           0 :     ALLOC_MUTEX(SgEmptyDirectiveStatement, lock);
   85454             : 
   85455             : #if ROSE_ALLOC_TRACE == 2
   85456             : //    printf("SgEmptyDirectiveStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgEmptyDirectiveStatement::next_node);
   85457             : #endif
   85458             : 
   85459             : #if USE_CPP_NEW_DELETE_OPERATORS
   85460             :     void *mem = ROSE_MALLOC(Size);
   85461             :     ALLOC_MUTEX(SgEmptyDirectiveStatement, unlock);
   85462             :     return mem;
   85463             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   85464             : #if ROSE_PEDANTIC_ALLOC
   85465             :     ROSE_ASSERT(Size == sizeof(SgEmptyDirectiveStatement));
   85466             : #else
   85467           0 :     if (Size != sizeof(SgEmptyDirectiveStatement)) {
   85468           0 :       void * object = ROSE_MALLOC(Size);
   85469           0 :       ALLOC_MUTEX(SgEmptyDirectiveStatement, unlock);
   85470             :       return object;
   85471             :     }
   85472             : #endif
   85473             : 
   85474           0 :     if (SgEmptyDirectiveStatement::next_node == nullptr) {
   85475           0 :         SgEmptyDirectiveStatement * alloc = (SgEmptyDirectiveStatement*) ROSE_MALLOC ( SgEmptyDirectiveStatement::pool_size * sizeof(SgEmptyDirectiveStatement) );
   85476           0 :         ROSE_ASSERT(alloc != nullptr);
   85477             : 
   85478             : #if ROSE_ALLOC_TRACE == 2
   85479             : //        printf("SgEmptyDirectiveStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgEmptyDirectiveStatement::pools.size(), alloc, alloc + SgEmptyDirectiveStatement::pool_size);
   85480             : #endif
   85481             : 
   85482             : #if ROSE_ALLOC_MEMSET == 1
   85483             : #elif ROSE_ALLOC_MEMSET == 2
   85484             :         memset(alloc, 0x00, SgEmptyDirectiveStatement::pool_size * sizeof(SgEmptyDirectiveStatement));
   85485             : #elif ROSE_ALLOC_MEMSET == 3
   85486             :         memset(alloc, 0xAA, SgEmptyDirectiveStatement::pool_size * sizeof(SgEmptyDirectiveStatement));
   85487             : #endif
   85488           0 :         for (unsigned i=0; i < SgEmptyDirectiveStatement::pool_size-1; i++) {
   85489           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
   85490             :         }
   85491           0 :         alloc[SgEmptyDirectiveStatement::pool_size-1].p_freepointer = nullptr;
   85492             : 
   85493           0 :         SgEmptyDirectiveStatement::pools.push_back ( (unsigned char *) alloc );
   85494           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgEmptyDirectiveStatement::pool_size * sizeof(SgEmptyDirectiveStatement), V_SgEmptyDirectiveStatement ) );
   85495           0 :         SgEmptyDirectiveStatement::next_node = alloc;
   85496             :     }
   85497           0 :     ROSE_ASSERT(SgEmptyDirectiveStatement::next_node != nullptr);
   85498             : 
   85499           0 :     SgEmptyDirectiveStatement * object = SgEmptyDirectiveStatement::next_node;
   85500           0 :     SgEmptyDirectiveStatement::next_node = (SgEmptyDirectiveStatement*)(object->p_freepointer);
   85501             : 
   85502             : #if ROSE_ALLOC_TRACE == 2
   85503             :     printf("SgEmptyDirectiveStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgEmptyDirectiveStatement::next_node);
   85504             : #endif
   85505             : 
   85506           0 :     SgNode * fp = object->p_freepointer;
   85507             : #if ROSE_ALLOC_MEMSET == 1
   85508             : #elif ROSE_ALLOC_MEMSET == 2
   85509             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgEmptyDirectiveStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   85510             : #elif ROSE_ALLOC_MEMSET == 3
   85511             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgEmptyDirectiveStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   85512             : #endif
   85513           0 :     object->p_freepointer = fp;
   85514             : 
   85515             : #if ROSE_ALLOC_TRACE == 2
   85516             : //    printf("SgEmptyDirectiveStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgEmptyDirectiveStatement::next_node);
   85517             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   85518             :     Rose::MemPool::snapshot(oss.str());
   85519             :     alloc_trace_cnt++;
   85520             : #endif
   85521             : 
   85522           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   85523             : 
   85524           0 :     ALLOC_MUTEX(SgEmptyDirectiveStatement, unlock);
   85525             : 
   85526             :     return object;
   85527             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   85528             : }
   85529             : 
   85530             : 
   85531             : 
   85532             : /*! \brief Delete operator for SgEmptyDirectiveStatement.
   85533             : 
   85534             :    This delete operator implements deallocation using memory pools to 
   85535             :    provide most efficent use of the heap within construction of large ASTs.
   85536             : 
   85537             : \internal The new and delete operators use the lower level C malloc/free
   85538             :    function calls for performance and to make sure that mixing of malloc/free
   85539             :    and new/delete by the used can be caught more readily.  This may change
   85540             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   85541             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   85542             :    deallocate memory allocated using ROSE_MALLOC.
   85543             : */
   85544           0 : void SgEmptyDirectiveStatement::operator delete(void *Pointer, size_t Size)
   85545             : {
   85546             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   85547             :      * or throwing an exception. */
   85548           0 :     ALLOC_MUTEX(SgEmptyDirectiveStatement, lock);
   85549             : 
   85550             : #if USE_CPP_NEW_DELETE_OPERATORS
   85551             :     ROSE_FREE(Pointer);
   85552             : #else
   85553             : #if ROSE_PEDANTIC_ALLOC
   85554             :     ROSE_ASSERT(Size == sizeof(SgEmptyDirectiveStatement));
   85555             : #else
   85556           0 :     if (Size != sizeof(SgEmptyDirectiveStatement)) {
   85557           0 :       ROSE_FREE(Pointer);
   85558           0 :       ALLOC_MUTEX(SgEmptyDirectiveStatement, unlock);
   85559             :       return;
   85560             :     }
   85561             : #endif
   85562             : 
   85563           0 :     SgEmptyDirectiveStatement * object = (SgEmptyDirectiveStatement*) Pointer;
   85564           0 :     ROSE_ASSERT(object != nullptr);
   85565             : 
   85566             : #if ROSE_ALLOC_TRACE == 2
   85567             : //  printf("SgEmptyDirectiveStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgEmptyDirectiveStatement::next_node);
   85568             :     printf("SgEmptyDirectiveStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgEmptyDirectiveStatement::next_node);
   85569             : #endif
   85570             : 
   85571             : #if ROSE_PEDANTIC_ALLOC
   85572             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   85573             : #endif
   85574             : 
   85575             : #if ROSE_ALLOC_MEMSET == 1
   85576             : #elif ROSE_ALLOC_MEMSET == 2
   85577             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgEmptyDirectiveStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   85578             : #elif ROSE_ALLOC_MEMSET == 3
   85579             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgEmptyDirectiveStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   85580             : #endif
   85581             : 
   85582             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   85583             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   85584             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   85585             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   85586             : #else
   85587           0 :     object->p_freepointer = SgEmptyDirectiveStatement::next_node;
   85588           0 :     SgEmptyDirectiveStatement::next_node = object;
   85589             : #endif
   85590             : 
   85591             : #if ROSE_ALLOC_TRACE == 2
   85592             : //  printf("SgEmptyDirectiveStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgEmptyDirectiveStatement::next_node);
   85593             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   85594             :     Rose::MemPool::snapshot(oss.str());
   85595             :     alloc_trace_cnt++;
   85596             : #endif
   85597             : 
   85598             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   85599             : 
   85600           0 :     ALLOC_MUTEX(SgEmptyDirectiveStatement, unlock);
   85601             : }
   85602             : 
   85603             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   85604             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   85605             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   85606             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   85607             : // Also, note comment below from Robb (copied from the Common.code file).
   85608             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   85609             : //
   85610             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   85611             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   85612             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   85613             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   85614             : #if 0
   85615             : void SgEmptyDirectiveStatement::operator delete(void* pointer) { SgEmptyDirectiveStatement::operator delete (pointer, sizeof(SgEmptyDirectiveStatement)); };
   85616             : #endif
   85617             : /* #line 85618 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   85618             : 
   85619             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   85620             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   85621             : // obviously imply C++.
   85622             : 
   85623             : // This implements the support within ROSE for memory pools.  Memory pools
   85624             : // support the most condensed usage of memory within the construction of
   85625             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   85626             : // by a new operator written for each class.
   85627             : 
   85628             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   85629             :     // User wants multi-thread support and POSIX threads are available.
   85630             : #   include <pthread.h>
   85631             :     static pthread_mutex_t SgIncludeNextDirectiveStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   85632             : #else
   85633             :      // Cause synchronization to be skipped.
   85634             : #    ifndef ALLOC_MUTEX
   85635             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   85636             : #    endif
   85637             : #    ifdef _REENTRANT
   85638             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   85639             : #       ifdef _MSC_VER
   85640             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   85641             : #       else
   85642             : #           warning "POSIX threads are not available; synchronization being skipped"
   85643             : #       endif
   85644             : #    endif
   85645             : #endif
   85646             : 
   85647             : #ifndef ROSE_ALLOC_TRACE
   85648             : #  define ROSE_ALLOC_TRACE 0
   85649             : #endif
   85650             : 
   85651             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   85652             : #define ROSE_ALLOC_TRACE_CNT
   85653             : #include "memory-pool-snapshot.h"
   85654             : unsigned long alloc_trace_cnt = 0;
   85655             : #endif
   85656             : 
   85657             : #if ROSE_ALLOC_TRACE
   85658             : const unsigned SgIncludeNextDirectiveStatement::pool_size = 5;
   85659             : #else
   85660             : const unsigned SgIncludeNextDirectiveStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   85661             : #endif
   85662             : 
   85663             : #ifndef ROSE_ALLOC_MEMSET
   85664             : #  define ROSE_ALLOC_MEMSET 0
   85665             : #endif
   85666             : 
   85667             : #ifndef ROSE_PEDANTIC_ALLOC
   85668             : #  define ROSE_PEDANTIC_ALLOC 0
   85669             : #endif
   85670             : 
   85671             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   85672             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   85673             : #endif
   85674             : 
   85675             : #if !defined(SGNODE__ALL_POOLS)
   85676             : #define SGNODE__ALL_POOLS
   85677             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   85678             : #endif
   85679             : 
   85680             : SgIncludeNextDirectiveStatement* SgIncludeNextDirectiveStatement::next_node = nullptr;
   85681             : std::vector<unsigned char*> SgIncludeNextDirectiveStatement::pools;
   85682             : 
   85683             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   85684             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   85685             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   85686             : // around this macro definition rather than each use).
   85687             : #ifndef ALLOC_MUTEX
   85688             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   85689             :         do {                                                                     \
   85690             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   85691             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   85692             :                 abort();                                                         \
   85693             :             }                                                                    \
   85694             :         } while (0);
   85695             : #endif
   85696             : 
   85697             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   85698             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   85699             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   85700             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   85701             : 
   85702             : /*! \brief New operator for SgIncludeNextDirectiveStatement.
   85703             : 
   85704             :    This new operator implements memory pools to provide most efficent 
   85705             :    use of the heap within construction of large ASTs.
   85706             : 
   85707             : \internal The new and delete operators use the lower level C malloc/free
   85708             :    function calls for performance and to make sure that mixing of malloc/free
   85709             :    and new/delete by the used can be caught more readily.  This may change
   85710             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   85711             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   85712             :    deallocate memory allocated using ROSE_MALLOC.
   85713             : */
   85714           0 : void *SgIncludeNextDirectiveStatement::operator new ( size_t Size )
   85715             : {
   85716             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   85717             :      * returning or throwing an exception. */
   85718           0 :     ALLOC_MUTEX(SgIncludeNextDirectiveStatement, lock);
   85719             : 
   85720             : #if ROSE_ALLOC_TRACE == 2
   85721             : //    printf("SgIncludeNextDirectiveStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgIncludeNextDirectiveStatement::next_node);
   85722             : #endif
   85723             : 
   85724             : #if USE_CPP_NEW_DELETE_OPERATORS
   85725             :     void *mem = ROSE_MALLOC(Size);
   85726             :     ALLOC_MUTEX(SgIncludeNextDirectiveStatement, unlock);
   85727             :     return mem;
   85728             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   85729             : #if ROSE_PEDANTIC_ALLOC
   85730             :     ROSE_ASSERT(Size == sizeof(SgIncludeNextDirectiveStatement));
   85731             : #else
   85732           0 :     if (Size != sizeof(SgIncludeNextDirectiveStatement)) {
   85733           0 :       void * object = ROSE_MALLOC(Size);
   85734           0 :       ALLOC_MUTEX(SgIncludeNextDirectiveStatement, unlock);
   85735             :       return object;
   85736             :     }
   85737             : #endif
   85738             : 
   85739           0 :     if (SgIncludeNextDirectiveStatement::next_node == nullptr) {
   85740           0 :         SgIncludeNextDirectiveStatement * alloc = (SgIncludeNextDirectiveStatement*) ROSE_MALLOC ( SgIncludeNextDirectiveStatement::pool_size * sizeof(SgIncludeNextDirectiveStatement) );
   85741           0 :         ROSE_ASSERT(alloc != nullptr);
   85742             : 
   85743             : #if ROSE_ALLOC_TRACE == 2
   85744             : //        printf("SgIncludeNextDirectiveStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgIncludeNextDirectiveStatement::pools.size(), alloc, alloc + SgIncludeNextDirectiveStatement::pool_size);
   85745             : #endif
   85746             : 
   85747             : #if ROSE_ALLOC_MEMSET == 1
   85748             : #elif ROSE_ALLOC_MEMSET == 2
   85749             :         memset(alloc, 0x00, SgIncludeNextDirectiveStatement::pool_size * sizeof(SgIncludeNextDirectiveStatement));
   85750             : #elif ROSE_ALLOC_MEMSET == 3
   85751             :         memset(alloc, 0xAA, SgIncludeNextDirectiveStatement::pool_size * sizeof(SgIncludeNextDirectiveStatement));
   85752             : #endif
   85753           0 :         for (unsigned i=0; i < SgIncludeNextDirectiveStatement::pool_size-1; i++) {
   85754           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
   85755             :         }
   85756           0 :         alloc[SgIncludeNextDirectiveStatement::pool_size-1].p_freepointer = nullptr;
   85757             : 
   85758           0 :         SgIncludeNextDirectiveStatement::pools.push_back ( (unsigned char *) alloc );
   85759           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgIncludeNextDirectiveStatement::pool_size * sizeof(SgIncludeNextDirectiveStatement), V_SgIncludeNextDirectiveStatement ) );
   85760           0 :         SgIncludeNextDirectiveStatement::next_node = alloc;
   85761             :     }
   85762           0 :     ROSE_ASSERT(SgIncludeNextDirectiveStatement::next_node != nullptr);
   85763             : 
   85764           0 :     SgIncludeNextDirectiveStatement * object = SgIncludeNextDirectiveStatement::next_node;
   85765           0 :     SgIncludeNextDirectiveStatement::next_node = (SgIncludeNextDirectiveStatement*)(object->p_freepointer);
   85766             : 
   85767             : #if ROSE_ALLOC_TRACE == 2
   85768             :     printf("SgIncludeNextDirectiveStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgIncludeNextDirectiveStatement::next_node);
   85769             : #endif
   85770             : 
   85771           0 :     SgNode * fp = object->p_freepointer;
   85772             : #if ROSE_ALLOC_MEMSET == 1
   85773             : #elif ROSE_ALLOC_MEMSET == 2
   85774             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgIncludeNextDirectiveStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   85775             : #elif ROSE_ALLOC_MEMSET == 3
   85776             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgIncludeNextDirectiveStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   85777             : #endif
   85778           0 :     object->p_freepointer = fp;
   85779             : 
   85780             : #if ROSE_ALLOC_TRACE == 2
   85781             : //    printf("SgIncludeNextDirectiveStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgIncludeNextDirectiveStatement::next_node);
   85782             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   85783             :     Rose::MemPool::snapshot(oss.str());
   85784             :     alloc_trace_cnt++;
   85785             : #endif
   85786             : 
   85787           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   85788             : 
   85789           0 :     ALLOC_MUTEX(SgIncludeNextDirectiveStatement, unlock);
   85790             : 
   85791             :     return object;
   85792             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   85793             : }
   85794             : 
   85795             : 
   85796             : 
   85797             : /*! \brief Delete operator for SgIncludeNextDirectiveStatement.
   85798             : 
   85799             :    This delete operator implements deallocation using memory pools to 
   85800             :    provide most efficent use of the heap within construction of large ASTs.
   85801             : 
   85802             : \internal The new and delete operators use the lower level C malloc/free
   85803             :    function calls for performance and to make sure that mixing of malloc/free
   85804             :    and new/delete by the used can be caught more readily.  This may change
   85805             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   85806             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   85807             :    deallocate memory allocated using ROSE_MALLOC.
   85808             : */
   85809           0 : void SgIncludeNextDirectiveStatement::operator delete(void *Pointer, size_t Size)
   85810             : {
   85811             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   85812             :      * or throwing an exception. */
   85813           0 :     ALLOC_MUTEX(SgIncludeNextDirectiveStatement, lock);
   85814             : 
   85815             : #if USE_CPP_NEW_DELETE_OPERATORS
   85816             :     ROSE_FREE(Pointer);
   85817             : #else
   85818             : #if ROSE_PEDANTIC_ALLOC
   85819             :     ROSE_ASSERT(Size == sizeof(SgIncludeNextDirectiveStatement));
   85820             : #else
   85821           0 :     if (Size != sizeof(SgIncludeNextDirectiveStatement)) {
   85822           0 :       ROSE_FREE(Pointer);
   85823           0 :       ALLOC_MUTEX(SgIncludeNextDirectiveStatement, unlock);
   85824             :       return;
   85825             :     }
   85826             : #endif
   85827             : 
   85828           0 :     SgIncludeNextDirectiveStatement * object = (SgIncludeNextDirectiveStatement*) Pointer;
   85829           0 :     ROSE_ASSERT(object != nullptr);
   85830             : 
   85831             : #if ROSE_ALLOC_TRACE == 2
   85832             : //  printf("SgIncludeNextDirectiveStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgIncludeNextDirectiveStatement::next_node);
   85833             :     printf("SgIncludeNextDirectiveStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgIncludeNextDirectiveStatement::next_node);
   85834             : #endif
   85835             : 
   85836             : #if ROSE_PEDANTIC_ALLOC
   85837             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   85838             : #endif
   85839             : 
   85840             : #if ROSE_ALLOC_MEMSET == 1
   85841             : #elif ROSE_ALLOC_MEMSET == 2
   85842             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgIncludeNextDirectiveStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   85843             : #elif ROSE_ALLOC_MEMSET == 3
   85844             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgIncludeNextDirectiveStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   85845             : #endif
   85846             : 
   85847             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   85848             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   85849             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   85850             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   85851             : #else
   85852           0 :     object->p_freepointer = SgIncludeNextDirectiveStatement::next_node;
   85853           0 :     SgIncludeNextDirectiveStatement::next_node = object;
   85854             : #endif
   85855             : 
   85856             : #if ROSE_ALLOC_TRACE == 2
   85857             : //  printf("SgIncludeNextDirectiveStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgIncludeNextDirectiveStatement::next_node);
   85858             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   85859             :     Rose::MemPool::snapshot(oss.str());
   85860             :     alloc_trace_cnt++;
   85861             : #endif
   85862             : 
   85863             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   85864             : 
   85865           0 :     ALLOC_MUTEX(SgIncludeNextDirectiveStatement, unlock);
   85866             : }
   85867             : 
   85868             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   85869             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   85870             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   85871             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   85872             : // Also, note comment below from Robb (copied from the Common.code file).
   85873             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   85874             : //
   85875             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   85876             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   85877             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   85878             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   85879             : #if 0
   85880             : void SgIncludeNextDirectiveStatement::operator delete(void* pointer) { SgIncludeNextDirectiveStatement::operator delete (pointer, sizeof(SgIncludeNextDirectiveStatement)); };
   85881             : #endif
   85882             : /* #line 85883 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   85883             : 
   85884             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   85885             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   85886             : // obviously imply C++.
   85887             : 
   85888             : // This implements the support within ROSE for memory pools.  Memory pools
   85889             : // support the most condensed usage of memory within the construction of
   85890             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   85891             : // by a new operator written for each class.
   85892             : 
   85893             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   85894             :     // User wants multi-thread support and POSIX threads are available.
   85895             : #   include <pthread.h>
   85896             :     static pthread_mutex_t SgIdentDirectiveStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   85897             : #else
   85898             :      // Cause synchronization to be skipped.
   85899             : #    ifndef ALLOC_MUTEX
   85900             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   85901             : #    endif
   85902             : #    ifdef _REENTRANT
   85903             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   85904             : #       ifdef _MSC_VER
   85905             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   85906             : #       else
   85907             : #           warning "POSIX threads are not available; synchronization being skipped"
   85908             : #       endif
   85909             : #    endif
   85910             : #endif
   85911             : 
   85912             : #ifndef ROSE_ALLOC_TRACE
   85913             : #  define ROSE_ALLOC_TRACE 0
   85914             : #endif
   85915             : 
   85916             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   85917             : #define ROSE_ALLOC_TRACE_CNT
   85918             : #include "memory-pool-snapshot.h"
   85919             : unsigned long alloc_trace_cnt = 0;
   85920             : #endif
   85921             : 
   85922             : #if ROSE_ALLOC_TRACE
   85923             : const unsigned SgIdentDirectiveStatement::pool_size = 5;
   85924             : #else
   85925             : const unsigned SgIdentDirectiveStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   85926             : #endif
   85927             : 
   85928             : #ifndef ROSE_ALLOC_MEMSET
   85929             : #  define ROSE_ALLOC_MEMSET 0
   85930             : #endif
   85931             : 
   85932             : #ifndef ROSE_PEDANTIC_ALLOC
   85933             : #  define ROSE_PEDANTIC_ALLOC 0
   85934             : #endif
   85935             : 
   85936             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   85937             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   85938             : #endif
   85939             : 
   85940             : #if !defined(SGNODE__ALL_POOLS)
   85941             : #define SGNODE__ALL_POOLS
   85942             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   85943             : #endif
   85944             : 
   85945             : SgIdentDirectiveStatement* SgIdentDirectiveStatement::next_node = nullptr;
   85946             : std::vector<unsigned char*> SgIdentDirectiveStatement::pools;
   85947             : 
   85948             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   85949             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   85950             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   85951             : // around this macro definition rather than each use).
   85952             : #ifndef ALLOC_MUTEX
   85953             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   85954             :         do {                                                                     \
   85955             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   85956             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   85957             :                 abort();                                                         \
   85958             :             }                                                                    \
   85959             :         } while (0);
   85960             : #endif
   85961             : 
   85962             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   85963             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   85964             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   85965             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   85966             : 
   85967             : /*! \brief New operator for SgIdentDirectiveStatement.
   85968             : 
   85969             :    This new operator implements memory pools to provide most efficent 
   85970             :    use of the heap within construction of large ASTs.
   85971             : 
   85972             : \internal The new and delete operators use the lower level C malloc/free
   85973             :    function calls for performance and to make sure that mixing of malloc/free
   85974             :    and new/delete by the used can be caught more readily.  This may change
   85975             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   85976             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   85977             :    deallocate memory allocated using ROSE_MALLOC.
   85978             : */
   85979           0 : void *SgIdentDirectiveStatement::operator new ( size_t Size )
   85980             : {
   85981             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   85982             :      * returning or throwing an exception. */
   85983           0 :     ALLOC_MUTEX(SgIdentDirectiveStatement, lock);
   85984             : 
   85985             : #if ROSE_ALLOC_TRACE == 2
   85986             : //    printf("SgIdentDirectiveStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgIdentDirectiveStatement::next_node);
   85987             : #endif
   85988             : 
   85989             : #if USE_CPP_NEW_DELETE_OPERATORS
   85990             :     void *mem = ROSE_MALLOC(Size);
   85991             :     ALLOC_MUTEX(SgIdentDirectiveStatement, unlock);
   85992             :     return mem;
   85993             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   85994             : #if ROSE_PEDANTIC_ALLOC
   85995             :     ROSE_ASSERT(Size == sizeof(SgIdentDirectiveStatement));
   85996             : #else
   85997           0 :     if (Size != sizeof(SgIdentDirectiveStatement)) {
   85998           0 :       void * object = ROSE_MALLOC(Size);
   85999           0 :       ALLOC_MUTEX(SgIdentDirectiveStatement, unlock);
   86000             :       return object;
   86001             :     }
   86002             : #endif
   86003             : 
   86004           0 :     if (SgIdentDirectiveStatement::next_node == nullptr) {
   86005           0 :         SgIdentDirectiveStatement * alloc = (SgIdentDirectiveStatement*) ROSE_MALLOC ( SgIdentDirectiveStatement::pool_size * sizeof(SgIdentDirectiveStatement) );
   86006           0 :         ROSE_ASSERT(alloc != nullptr);
   86007             : 
   86008             : #if ROSE_ALLOC_TRACE == 2
   86009             : //        printf("SgIdentDirectiveStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgIdentDirectiveStatement::pools.size(), alloc, alloc + SgIdentDirectiveStatement::pool_size);
   86010             : #endif
   86011             : 
   86012             : #if ROSE_ALLOC_MEMSET == 1
   86013             : #elif ROSE_ALLOC_MEMSET == 2
   86014             :         memset(alloc, 0x00, SgIdentDirectiveStatement::pool_size * sizeof(SgIdentDirectiveStatement));
   86015             : #elif ROSE_ALLOC_MEMSET == 3
   86016             :         memset(alloc, 0xAA, SgIdentDirectiveStatement::pool_size * sizeof(SgIdentDirectiveStatement));
   86017             : #endif
   86018           0 :         for (unsigned i=0; i < SgIdentDirectiveStatement::pool_size-1; i++) {
   86019           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
   86020             :         }
   86021           0 :         alloc[SgIdentDirectiveStatement::pool_size-1].p_freepointer = nullptr;
   86022             : 
   86023           0 :         SgIdentDirectiveStatement::pools.push_back ( (unsigned char *) alloc );
   86024           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgIdentDirectiveStatement::pool_size * sizeof(SgIdentDirectiveStatement), V_SgIdentDirectiveStatement ) );
   86025           0 :         SgIdentDirectiveStatement::next_node = alloc;
   86026             :     }
   86027           0 :     ROSE_ASSERT(SgIdentDirectiveStatement::next_node != nullptr);
   86028             : 
   86029           0 :     SgIdentDirectiveStatement * object = SgIdentDirectiveStatement::next_node;
   86030           0 :     SgIdentDirectiveStatement::next_node = (SgIdentDirectiveStatement*)(object->p_freepointer);
   86031             : 
   86032             : #if ROSE_ALLOC_TRACE == 2
   86033             :     printf("SgIdentDirectiveStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgIdentDirectiveStatement::next_node);
   86034             : #endif
   86035             : 
   86036           0 :     SgNode * fp = object->p_freepointer;
   86037             : #if ROSE_ALLOC_MEMSET == 1
   86038             : #elif ROSE_ALLOC_MEMSET == 2
   86039             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgIdentDirectiveStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   86040             : #elif ROSE_ALLOC_MEMSET == 3
   86041             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgIdentDirectiveStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   86042             : #endif
   86043           0 :     object->p_freepointer = fp;
   86044             : 
   86045             : #if ROSE_ALLOC_TRACE == 2
   86046             : //    printf("SgIdentDirectiveStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgIdentDirectiveStatement::next_node);
   86047             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   86048             :     Rose::MemPool::snapshot(oss.str());
   86049             :     alloc_trace_cnt++;
   86050             : #endif
   86051             : 
   86052           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   86053             : 
   86054           0 :     ALLOC_MUTEX(SgIdentDirectiveStatement, unlock);
   86055             : 
   86056             :     return object;
   86057             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   86058             : }
   86059             : 
   86060             : 
   86061             : 
   86062             : /*! \brief Delete operator for SgIdentDirectiveStatement.
   86063             : 
   86064             :    This delete operator implements deallocation using memory pools to 
   86065             :    provide most efficent use of the heap within construction of large ASTs.
   86066             : 
   86067             : \internal The new and delete operators use the lower level C malloc/free
   86068             :    function calls for performance and to make sure that mixing of malloc/free
   86069             :    and new/delete by the used can be caught more readily.  This may change
   86070             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   86071             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   86072             :    deallocate memory allocated using ROSE_MALLOC.
   86073             : */
   86074           0 : void SgIdentDirectiveStatement::operator delete(void *Pointer, size_t Size)
   86075             : {
   86076             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   86077             :      * or throwing an exception. */
   86078           0 :     ALLOC_MUTEX(SgIdentDirectiveStatement, lock);
   86079             : 
   86080             : #if USE_CPP_NEW_DELETE_OPERATORS
   86081             :     ROSE_FREE(Pointer);
   86082             : #else
   86083             : #if ROSE_PEDANTIC_ALLOC
   86084             :     ROSE_ASSERT(Size == sizeof(SgIdentDirectiveStatement));
   86085             : #else
   86086           0 :     if (Size != sizeof(SgIdentDirectiveStatement)) {
   86087           0 :       ROSE_FREE(Pointer);
   86088           0 :       ALLOC_MUTEX(SgIdentDirectiveStatement, unlock);
   86089             :       return;
   86090             :     }
   86091             : #endif
   86092             : 
   86093           0 :     SgIdentDirectiveStatement * object = (SgIdentDirectiveStatement*) Pointer;
   86094           0 :     ROSE_ASSERT(object != nullptr);
   86095             : 
   86096             : #if ROSE_ALLOC_TRACE == 2
   86097             : //  printf("SgIdentDirectiveStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgIdentDirectiveStatement::next_node);
   86098             :     printf("SgIdentDirectiveStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgIdentDirectiveStatement::next_node);
   86099             : #endif
   86100             : 
   86101             : #if ROSE_PEDANTIC_ALLOC
   86102             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   86103             : #endif
   86104             : 
   86105             : #if ROSE_ALLOC_MEMSET == 1
   86106             : #elif ROSE_ALLOC_MEMSET == 2
   86107             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgIdentDirectiveStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   86108             : #elif ROSE_ALLOC_MEMSET == 3
   86109             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgIdentDirectiveStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   86110             : #endif
   86111             : 
   86112             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   86113             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   86114             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   86115             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   86116             : #else
   86117           0 :     object->p_freepointer = SgIdentDirectiveStatement::next_node;
   86118           0 :     SgIdentDirectiveStatement::next_node = object;
   86119             : #endif
   86120             : 
   86121             : #if ROSE_ALLOC_TRACE == 2
   86122             : //  printf("SgIdentDirectiveStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgIdentDirectiveStatement::next_node);
   86123             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   86124             :     Rose::MemPool::snapshot(oss.str());
   86125             :     alloc_trace_cnt++;
   86126             : #endif
   86127             : 
   86128             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   86129             : 
   86130           0 :     ALLOC_MUTEX(SgIdentDirectiveStatement, unlock);
   86131             : }
   86132             : 
   86133             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   86134             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   86135             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   86136             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   86137             : // Also, note comment below from Robb (copied from the Common.code file).
   86138             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   86139             : //
   86140             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   86141             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   86142             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   86143             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   86144             : #if 0
   86145             : void SgIdentDirectiveStatement::operator delete(void* pointer) { SgIdentDirectiveStatement::operator delete (pointer, sizeof(SgIdentDirectiveStatement)); };
   86146             : #endif
   86147             : /* #line 86148 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   86148             : 
   86149             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   86150             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   86151             : // obviously imply C++.
   86152             : 
   86153             : // This implements the support within ROSE for memory pools.  Memory pools
   86154             : // support the most condensed usage of memory within the construction of
   86155             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   86156             : // by a new operator written for each class.
   86157             : 
   86158             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   86159             :     // User wants multi-thread support and POSIX threads are available.
   86160             : #   include <pthread.h>
   86161             :     static pthread_mutex_t SgLinemarkerDirectiveStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   86162             : #else
   86163             :      // Cause synchronization to be skipped.
   86164             : #    ifndef ALLOC_MUTEX
   86165             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   86166             : #    endif
   86167             : #    ifdef _REENTRANT
   86168             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   86169             : #       ifdef _MSC_VER
   86170             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   86171             : #       else
   86172             : #           warning "POSIX threads are not available; synchronization being skipped"
   86173             : #       endif
   86174             : #    endif
   86175             : #endif
   86176             : 
   86177             : #ifndef ROSE_ALLOC_TRACE
   86178             : #  define ROSE_ALLOC_TRACE 0
   86179             : #endif
   86180             : 
   86181             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   86182             : #define ROSE_ALLOC_TRACE_CNT
   86183             : #include "memory-pool-snapshot.h"
   86184             : unsigned long alloc_trace_cnt = 0;
   86185             : #endif
   86186             : 
   86187             : #if ROSE_ALLOC_TRACE
   86188             : const unsigned SgLinemarkerDirectiveStatement::pool_size = 5;
   86189             : #else
   86190             : const unsigned SgLinemarkerDirectiveStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   86191             : #endif
   86192             : 
   86193             : #ifndef ROSE_ALLOC_MEMSET
   86194             : #  define ROSE_ALLOC_MEMSET 0
   86195             : #endif
   86196             : 
   86197             : #ifndef ROSE_PEDANTIC_ALLOC
   86198             : #  define ROSE_PEDANTIC_ALLOC 0
   86199             : #endif
   86200             : 
   86201             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   86202             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   86203             : #endif
   86204             : 
   86205             : #if !defined(SGNODE__ALL_POOLS)
   86206             : #define SGNODE__ALL_POOLS
   86207             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   86208             : #endif
   86209             : 
   86210             : SgLinemarkerDirectiveStatement* SgLinemarkerDirectiveStatement::next_node = nullptr;
   86211             : std::vector<unsigned char*> SgLinemarkerDirectiveStatement::pools;
   86212             : 
   86213             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   86214             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   86215             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   86216             : // around this macro definition rather than each use).
   86217             : #ifndef ALLOC_MUTEX
   86218             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   86219             :         do {                                                                     \
   86220             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   86221             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   86222             :                 abort();                                                         \
   86223             :             }                                                                    \
   86224             :         } while (0);
   86225             : #endif
   86226             : 
   86227             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   86228             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   86229             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   86230             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   86231             : 
   86232             : /*! \brief New operator for SgLinemarkerDirectiveStatement.
   86233             : 
   86234             :    This new operator implements memory pools to provide most efficent 
   86235             :    use of the heap within construction of large ASTs.
   86236             : 
   86237             : \internal The new and delete operators use the lower level C malloc/free
   86238             :    function calls for performance and to make sure that mixing of malloc/free
   86239             :    and new/delete by the used can be caught more readily.  This may change
   86240             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   86241             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   86242             :    deallocate memory allocated using ROSE_MALLOC.
   86243             : */
   86244           0 : void *SgLinemarkerDirectiveStatement::operator new ( size_t Size )
   86245             : {
   86246             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   86247             :      * returning or throwing an exception. */
   86248           0 :     ALLOC_MUTEX(SgLinemarkerDirectiveStatement, lock);
   86249             : 
   86250             : #if ROSE_ALLOC_TRACE == 2
   86251             : //    printf("SgLinemarkerDirectiveStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgLinemarkerDirectiveStatement::next_node);
   86252             : #endif
   86253             : 
   86254             : #if USE_CPP_NEW_DELETE_OPERATORS
   86255             :     void *mem = ROSE_MALLOC(Size);
   86256             :     ALLOC_MUTEX(SgLinemarkerDirectiveStatement, unlock);
   86257             :     return mem;
   86258             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   86259             : #if ROSE_PEDANTIC_ALLOC
   86260             :     ROSE_ASSERT(Size == sizeof(SgLinemarkerDirectiveStatement));
   86261             : #else
   86262           0 :     if (Size != sizeof(SgLinemarkerDirectiveStatement)) {
   86263           0 :       void * object = ROSE_MALLOC(Size);
   86264           0 :       ALLOC_MUTEX(SgLinemarkerDirectiveStatement, unlock);
   86265             :       return object;
   86266             :     }
   86267             : #endif
   86268             : 
   86269           0 :     if (SgLinemarkerDirectiveStatement::next_node == nullptr) {
   86270           0 :         SgLinemarkerDirectiveStatement * alloc = (SgLinemarkerDirectiveStatement*) ROSE_MALLOC ( SgLinemarkerDirectiveStatement::pool_size * sizeof(SgLinemarkerDirectiveStatement) );
   86271           0 :         ROSE_ASSERT(alloc != nullptr);
   86272             : 
   86273             : #if ROSE_ALLOC_TRACE == 2
   86274             : //        printf("SgLinemarkerDirectiveStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgLinemarkerDirectiveStatement::pools.size(), alloc, alloc + SgLinemarkerDirectiveStatement::pool_size);
   86275             : #endif
   86276             : 
   86277             : #if ROSE_ALLOC_MEMSET == 1
   86278             : #elif ROSE_ALLOC_MEMSET == 2
   86279             :         memset(alloc, 0x00, SgLinemarkerDirectiveStatement::pool_size * sizeof(SgLinemarkerDirectiveStatement));
   86280             : #elif ROSE_ALLOC_MEMSET == 3
   86281             :         memset(alloc, 0xAA, SgLinemarkerDirectiveStatement::pool_size * sizeof(SgLinemarkerDirectiveStatement));
   86282             : #endif
   86283           0 :         for (unsigned i=0; i < SgLinemarkerDirectiveStatement::pool_size-1; i++) {
   86284           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
   86285             :         }
   86286           0 :         alloc[SgLinemarkerDirectiveStatement::pool_size-1].p_freepointer = nullptr;
   86287             : 
   86288           0 :         SgLinemarkerDirectiveStatement::pools.push_back ( (unsigned char *) alloc );
   86289           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgLinemarkerDirectiveStatement::pool_size * sizeof(SgLinemarkerDirectiveStatement), V_SgLinemarkerDirectiveStatement ) );
   86290           0 :         SgLinemarkerDirectiveStatement::next_node = alloc;
   86291             :     }
   86292           0 :     ROSE_ASSERT(SgLinemarkerDirectiveStatement::next_node != nullptr);
   86293             : 
   86294           0 :     SgLinemarkerDirectiveStatement * object = SgLinemarkerDirectiveStatement::next_node;
   86295           0 :     SgLinemarkerDirectiveStatement::next_node = (SgLinemarkerDirectiveStatement*)(object->p_freepointer);
   86296             : 
   86297             : #if ROSE_ALLOC_TRACE == 2
   86298             :     printf("SgLinemarkerDirectiveStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgLinemarkerDirectiveStatement::next_node);
   86299             : #endif
   86300             : 
   86301           0 :     SgNode * fp = object->p_freepointer;
   86302             : #if ROSE_ALLOC_MEMSET == 1
   86303             : #elif ROSE_ALLOC_MEMSET == 2
   86304             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgLinemarkerDirectiveStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   86305             : #elif ROSE_ALLOC_MEMSET == 3
   86306             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgLinemarkerDirectiveStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   86307             : #endif
   86308           0 :     object->p_freepointer = fp;
   86309             : 
   86310             : #if ROSE_ALLOC_TRACE == 2
   86311             : //    printf("SgLinemarkerDirectiveStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgLinemarkerDirectiveStatement::next_node);
   86312             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   86313             :     Rose::MemPool::snapshot(oss.str());
   86314             :     alloc_trace_cnt++;
   86315             : #endif
   86316             : 
   86317           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   86318             : 
   86319           0 :     ALLOC_MUTEX(SgLinemarkerDirectiveStatement, unlock);
   86320             : 
   86321             :     return object;
   86322             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   86323             : }
   86324             : 
   86325             : 
   86326             : 
   86327             : /*! \brief Delete operator for SgLinemarkerDirectiveStatement.
   86328             : 
   86329             :    This delete operator implements deallocation using memory pools to 
   86330             :    provide most efficent use of the heap within construction of large ASTs.
   86331             : 
   86332             : \internal The new and delete operators use the lower level C malloc/free
   86333             :    function calls for performance and to make sure that mixing of malloc/free
   86334             :    and new/delete by the used can be caught more readily.  This may change
   86335             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   86336             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   86337             :    deallocate memory allocated using ROSE_MALLOC.
   86338             : */
   86339           0 : void SgLinemarkerDirectiveStatement::operator delete(void *Pointer, size_t Size)
   86340             : {
   86341             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   86342             :      * or throwing an exception. */
   86343           0 :     ALLOC_MUTEX(SgLinemarkerDirectiveStatement, lock);
   86344             : 
   86345             : #if USE_CPP_NEW_DELETE_OPERATORS
   86346             :     ROSE_FREE(Pointer);
   86347             : #else
   86348             : #if ROSE_PEDANTIC_ALLOC
   86349             :     ROSE_ASSERT(Size == sizeof(SgLinemarkerDirectiveStatement));
   86350             : #else
   86351           0 :     if (Size != sizeof(SgLinemarkerDirectiveStatement)) {
   86352           0 :       ROSE_FREE(Pointer);
   86353           0 :       ALLOC_MUTEX(SgLinemarkerDirectiveStatement, unlock);
   86354             :       return;
   86355             :     }
   86356             : #endif
   86357             : 
   86358           0 :     SgLinemarkerDirectiveStatement * object = (SgLinemarkerDirectiveStatement*) Pointer;
   86359           0 :     ROSE_ASSERT(object != nullptr);
   86360             : 
   86361             : #if ROSE_ALLOC_TRACE == 2
   86362             : //  printf("SgLinemarkerDirectiveStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgLinemarkerDirectiveStatement::next_node);
   86363             :     printf("SgLinemarkerDirectiveStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgLinemarkerDirectiveStatement::next_node);
   86364             : #endif
   86365             : 
   86366             : #if ROSE_PEDANTIC_ALLOC
   86367             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   86368             : #endif
   86369             : 
   86370             : #if ROSE_ALLOC_MEMSET == 1
   86371             : #elif ROSE_ALLOC_MEMSET == 2
   86372             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgLinemarkerDirectiveStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   86373             : #elif ROSE_ALLOC_MEMSET == 3
   86374             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgLinemarkerDirectiveStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   86375             : #endif
   86376             : 
   86377             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   86378             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   86379             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   86380             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   86381             : #else
   86382           0 :     object->p_freepointer = SgLinemarkerDirectiveStatement::next_node;
   86383           0 :     SgLinemarkerDirectiveStatement::next_node = object;
   86384             : #endif
   86385             : 
   86386             : #if ROSE_ALLOC_TRACE == 2
   86387             : //  printf("SgLinemarkerDirectiveStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgLinemarkerDirectiveStatement::next_node);
   86388             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   86389             :     Rose::MemPool::snapshot(oss.str());
   86390             :     alloc_trace_cnt++;
   86391             : #endif
   86392             : 
   86393             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   86394             : 
   86395           0 :     ALLOC_MUTEX(SgLinemarkerDirectiveStatement, unlock);
   86396             : }
   86397             : 
   86398             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   86399             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   86400             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   86401             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   86402             : // Also, note comment below from Robb (copied from the Common.code file).
   86403             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   86404             : //
   86405             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   86406             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   86407             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   86408             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   86409             : #if 0
   86410             : void SgLinemarkerDirectiveStatement::operator delete(void* pointer) { SgLinemarkerDirectiveStatement::operator delete (pointer, sizeof(SgLinemarkerDirectiveStatement)); };
   86411             : #endif
   86412             : /* #line 86413 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   86413             : 
   86414             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   86415             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   86416             : // obviously imply C++.
   86417             : 
   86418             : // This implements the support within ROSE for memory pools.  Memory pools
   86419             : // support the most condensed usage of memory within the construction of
   86420             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   86421             : // by a new operator written for each class.
   86422             : 
   86423             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   86424             :     // User wants multi-thread support and POSIX threads are available.
   86425             : #   include <pthread.h>
   86426             :     static pthread_mutex_t SgOmpThreadprivateStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   86427             : #else
   86428             :      // Cause synchronization to be skipped.
   86429             : #    ifndef ALLOC_MUTEX
   86430             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   86431             : #    endif
   86432             : #    ifdef _REENTRANT
   86433             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   86434             : #       ifdef _MSC_VER
   86435             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   86436             : #       else
   86437             : #           warning "POSIX threads are not available; synchronization being skipped"
   86438             : #       endif
   86439             : #    endif
   86440             : #endif
   86441             : 
   86442             : #ifndef ROSE_ALLOC_TRACE
   86443             : #  define ROSE_ALLOC_TRACE 0
   86444             : #endif
   86445             : 
   86446             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   86447             : #define ROSE_ALLOC_TRACE_CNT
   86448             : #include "memory-pool-snapshot.h"
   86449             : unsigned long alloc_trace_cnt = 0;
   86450             : #endif
   86451             : 
   86452             : #if ROSE_ALLOC_TRACE
   86453             : const unsigned SgOmpThreadprivateStatement::pool_size = 5;
   86454             : #else
   86455             : const unsigned SgOmpThreadprivateStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   86456             : #endif
   86457             : 
   86458             : #ifndef ROSE_ALLOC_MEMSET
   86459             : #  define ROSE_ALLOC_MEMSET 0
   86460             : #endif
   86461             : 
   86462             : #ifndef ROSE_PEDANTIC_ALLOC
   86463             : #  define ROSE_PEDANTIC_ALLOC 0
   86464             : #endif
   86465             : 
   86466             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   86467             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   86468             : #endif
   86469             : 
   86470             : #if !defined(SGNODE__ALL_POOLS)
   86471             : #define SGNODE__ALL_POOLS
   86472             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   86473             : #endif
   86474             : 
   86475             : SgOmpThreadprivateStatement* SgOmpThreadprivateStatement::next_node = nullptr;
   86476             : std::vector<unsigned char*> SgOmpThreadprivateStatement::pools;
   86477             : 
   86478             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   86479             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   86480             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   86481             : // around this macro definition rather than each use).
   86482             : #ifndef ALLOC_MUTEX
   86483             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   86484             :         do {                                                                     \
   86485             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   86486             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   86487             :                 abort();                                                         \
   86488             :             }                                                                    \
   86489             :         } while (0);
   86490             : #endif
   86491             : 
   86492             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   86493             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   86494             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   86495             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   86496             : 
   86497             : /*! \brief New operator for SgOmpThreadprivateStatement.
   86498             : 
   86499             :    This new operator implements memory pools to provide most efficent 
   86500             :    use of the heap within construction of large ASTs.
   86501             : 
   86502             : \internal The new and delete operators use the lower level C malloc/free
   86503             :    function calls for performance and to make sure that mixing of malloc/free
   86504             :    and new/delete by the used can be caught more readily.  This may change
   86505             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   86506             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   86507             :    deallocate memory allocated using ROSE_MALLOC.
   86508             : */
   86509           7 : void *SgOmpThreadprivateStatement::operator new ( size_t Size )
   86510             : {
   86511             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   86512             :      * returning or throwing an exception. */
   86513           7 :     ALLOC_MUTEX(SgOmpThreadprivateStatement, lock);
   86514             : 
   86515             : #if ROSE_ALLOC_TRACE == 2
   86516             : //    printf("SgOmpThreadprivateStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgOmpThreadprivateStatement::next_node);
   86517             : #endif
   86518             : 
   86519             : #if USE_CPP_NEW_DELETE_OPERATORS
   86520             :     void *mem = ROSE_MALLOC(Size);
   86521             :     ALLOC_MUTEX(SgOmpThreadprivateStatement, unlock);
   86522             :     return mem;
   86523             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   86524             : #if ROSE_PEDANTIC_ALLOC
   86525             :     ROSE_ASSERT(Size == sizeof(SgOmpThreadprivateStatement));
   86526             : #else
   86527           7 :     if (Size != sizeof(SgOmpThreadprivateStatement)) {
   86528           0 :       void * object = ROSE_MALLOC(Size);
   86529           0 :       ALLOC_MUTEX(SgOmpThreadprivateStatement, unlock);
   86530             :       return object;
   86531             :     }
   86532             : #endif
   86533             : 
   86534           7 :     if (SgOmpThreadprivateStatement::next_node == nullptr) {
   86535           7 :         SgOmpThreadprivateStatement * alloc = (SgOmpThreadprivateStatement*) ROSE_MALLOC ( SgOmpThreadprivateStatement::pool_size * sizeof(SgOmpThreadprivateStatement) );
   86536           7 :         ROSE_ASSERT(alloc != nullptr);
   86537             : 
   86538             : #if ROSE_ALLOC_TRACE == 2
   86539             : //        printf("SgOmpThreadprivateStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgOmpThreadprivateStatement::pools.size(), alloc, alloc + SgOmpThreadprivateStatement::pool_size);
   86540             : #endif
   86541             : 
   86542             : #if ROSE_ALLOC_MEMSET == 1
   86543             : #elif ROSE_ALLOC_MEMSET == 2
   86544             :         memset(alloc, 0x00, SgOmpThreadprivateStatement::pool_size * sizeof(SgOmpThreadprivateStatement));
   86545             : #elif ROSE_ALLOC_MEMSET == 3
   86546             :         memset(alloc, 0xAA, SgOmpThreadprivateStatement::pool_size * sizeof(SgOmpThreadprivateStatement));
   86547             : #endif
   86548       14000 :         for (unsigned i=0; i < SgOmpThreadprivateStatement::pool_size-1; i++) {
   86549       13993 :           alloc[i].p_freepointer = &(alloc[i+1]);
   86550             :         }
   86551           7 :         alloc[SgOmpThreadprivateStatement::pool_size-1].p_freepointer = nullptr;
   86552             : 
   86553           7 :         SgOmpThreadprivateStatement::pools.push_back ( (unsigned char *) alloc );
   86554           7 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgOmpThreadprivateStatement::pool_size * sizeof(SgOmpThreadprivateStatement), V_SgOmpThreadprivateStatement ) );
   86555           7 :         SgOmpThreadprivateStatement::next_node = alloc;
   86556             :     }
   86557           7 :     ROSE_ASSERT(SgOmpThreadprivateStatement::next_node != nullptr);
   86558             : 
   86559           7 :     SgOmpThreadprivateStatement * object = SgOmpThreadprivateStatement::next_node;
   86560           7 :     SgOmpThreadprivateStatement::next_node = (SgOmpThreadprivateStatement*)(object->p_freepointer);
   86561             : 
   86562             : #if ROSE_ALLOC_TRACE == 2
   86563             :     printf("SgOmpThreadprivateStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpThreadprivateStatement::next_node);
   86564             : #endif
   86565             : 
   86566           7 :     SgNode * fp = object->p_freepointer;
   86567             : #if ROSE_ALLOC_MEMSET == 1
   86568             : #elif ROSE_ALLOC_MEMSET == 2
   86569             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpThreadprivateStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   86570             : #elif ROSE_ALLOC_MEMSET == 3
   86571             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgOmpThreadprivateStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   86572             : #endif
   86573           7 :     object->p_freepointer = fp;
   86574             : 
   86575             : #if ROSE_ALLOC_TRACE == 2
   86576             : //    printf("SgOmpThreadprivateStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpThreadprivateStatement::next_node);
   86577             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   86578             :     Rose::MemPool::snapshot(oss.str());
   86579             :     alloc_trace_cnt++;
   86580             : #endif
   86581             : 
   86582           7 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   86583             : 
   86584           7 :     ALLOC_MUTEX(SgOmpThreadprivateStatement, unlock);
   86585             : 
   86586             :     return object;
   86587             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   86588             : }
   86589             : 
   86590             : 
   86591             : 
   86592             : /*! \brief Delete operator for SgOmpThreadprivateStatement.
   86593             : 
   86594             :    This delete operator implements deallocation using memory pools to 
   86595             :    provide most efficent use of the heap within construction of large ASTs.
   86596             : 
   86597             : \internal The new and delete operators use the lower level C malloc/free
   86598             :    function calls for performance and to make sure that mixing of malloc/free
   86599             :    and new/delete by the used can be caught more readily.  This may change
   86600             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   86601             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   86602             :    deallocate memory allocated using ROSE_MALLOC.
   86603             : */
   86604           0 : void SgOmpThreadprivateStatement::operator delete(void *Pointer, size_t Size)
   86605             : {
   86606             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   86607             :      * or throwing an exception. */
   86608           0 :     ALLOC_MUTEX(SgOmpThreadprivateStatement, lock);
   86609             : 
   86610             : #if USE_CPP_NEW_DELETE_OPERATORS
   86611             :     ROSE_FREE(Pointer);
   86612             : #else
   86613             : #if ROSE_PEDANTIC_ALLOC
   86614             :     ROSE_ASSERT(Size == sizeof(SgOmpThreadprivateStatement));
   86615             : #else
   86616           0 :     if (Size != sizeof(SgOmpThreadprivateStatement)) {
   86617           0 :       ROSE_FREE(Pointer);
   86618           0 :       ALLOC_MUTEX(SgOmpThreadprivateStatement, unlock);
   86619             :       return;
   86620             :     }
   86621             : #endif
   86622             : 
   86623           0 :     SgOmpThreadprivateStatement * object = (SgOmpThreadprivateStatement*) Pointer;
   86624           0 :     ROSE_ASSERT(object != nullptr);
   86625             : 
   86626             : #if ROSE_ALLOC_TRACE == 2
   86627             : //  printf("SgOmpThreadprivateStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpThreadprivateStatement::next_node);
   86628             :     printf("SgOmpThreadprivateStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpThreadprivateStatement::next_node);
   86629             : #endif
   86630             : 
   86631             : #if ROSE_PEDANTIC_ALLOC
   86632             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   86633             : #endif
   86634             : 
   86635             : #if ROSE_ALLOC_MEMSET == 1
   86636             : #elif ROSE_ALLOC_MEMSET == 2
   86637             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpThreadprivateStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   86638             : #elif ROSE_ALLOC_MEMSET == 3
   86639             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgOmpThreadprivateStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   86640             : #endif
   86641             : 
   86642             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   86643             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   86644             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   86645             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   86646             : #else
   86647           0 :     object->p_freepointer = SgOmpThreadprivateStatement::next_node;
   86648           0 :     SgOmpThreadprivateStatement::next_node = object;
   86649             : #endif
   86650             : 
   86651             : #if ROSE_ALLOC_TRACE == 2
   86652             : //  printf("SgOmpThreadprivateStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpThreadprivateStatement::next_node);
   86653             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   86654             :     Rose::MemPool::snapshot(oss.str());
   86655             :     alloc_trace_cnt++;
   86656             : #endif
   86657             : 
   86658             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   86659             : 
   86660           0 :     ALLOC_MUTEX(SgOmpThreadprivateStatement, unlock);
   86661             : }
   86662             : 
   86663             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   86664             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   86665             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   86666             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   86667             : // Also, note comment below from Robb (copied from the Common.code file).
   86668             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   86669             : //
   86670             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   86671             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   86672             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   86673             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   86674             : #if 0
   86675             : void SgOmpThreadprivateStatement::operator delete(void* pointer) { SgOmpThreadprivateStatement::operator delete (pointer, sizeof(SgOmpThreadprivateStatement)); };
   86676             : #endif
   86677             : /* #line 86678 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   86678             : 
   86679             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   86680             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   86681             : // obviously imply C++.
   86682             : 
   86683             : // This implements the support within ROSE for memory pools.  Memory pools
   86684             : // support the most condensed usage of memory within the construction of
   86685             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   86686             : // by a new operator written for each class.
   86687             : 
   86688             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   86689             :     // User wants multi-thread support and POSIX threads are available.
   86690             : #   include <pthread.h>
   86691             :     static pthread_mutex_t SgOmpRequiresStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   86692             : #else
   86693             :      // Cause synchronization to be skipped.
   86694             : #    ifndef ALLOC_MUTEX
   86695             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   86696             : #    endif
   86697             : #    ifdef _REENTRANT
   86698             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   86699             : #       ifdef _MSC_VER
   86700             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   86701             : #       else
   86702             : #           warning "POSIX threads are not available; synchronization being skipped"
   86703             : #       endif
   86704             : #    endif
   86705             : #endif
   86706             : 
   86707             : #ifndef ROSE_ALLOC_TRACE
   86708             : #  define ROSE_ALLOC_TRACE 0
   86709             : #endif
   86710             : 
   86711             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   86712             : #define ROSE_ALLOC_TRACE_CNT
   86713             : #include "memory-pool-snapshot.h"
   86714             : unsigned long alloc_trace_cnt = 0;
   86715             : #endif
   86716             : 
   86717             : #if ROSE_ALLOC_TRACE
   86718             : const unsigned SgOmpRequiresStatement::pool_size = 5;
   86719             : #else
   86720             : const unsigned SgOmpRequiresStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   86721             : #endif
   86722             : 
   86723             : #ifndef ROSE_ALLOC_MEMSET
   86724             : #  define ROSE_ALLOC_MEMSET 0
   86725             : #endif
   86726             : 
   86727             : #ifndef ROSE_PEDANTIC_ALLOC
   86728             : #  define ROSE_PEDANTIC_ALLOC 0
   86729             : #endif
   86730             : 
   86731             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   86732             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   86733             : #endif
   86734             : 
   86735             : #if !defined(SGNODE__ALL_POOLS)
   86736             : #define SGNODE__ALL_POOLS
   86737             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   86738             : #endif
   86739             : 
   86740             : SgOmpRequiresStatement* SgOmpRequiresStatement::next_node = nullptr;
   86741             : std::vector<unsigned char*> SgOmpRequiresStatement::pools;
   86742             : 
   86743             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   86744             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   86745             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   86746             : // around this macro definition rather than each use).
   86747             : #ifndef ALLOC_MUTEX
   86748             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   86749             :         do {                                                                     \
   86750             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   86751             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   86752             :                 abort();                                                         \
   86753             :             }                                                                    \
   86754             :         } while (0);
   86755             : #endif
   86756             : 
   86757             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   86758             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   86759             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   86760             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   86761             : 
   86762             : /*! \brief New operator for SgOmpRequiresStatement.
   86763             : 
   86764             :    This new operator implements memory pools to provide most efficent 
   86765             :    use of the heap within construction of large ASTs.
   86766             : 
   86767             : \internal The new and delete operators use the lower level C malloc/free
   86768             :    function calls for performance and to make sure that mixing of malloc/free
   86769             :    and new/delete by the used can be caught more readily.  This may change
   86770             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   86771             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   86772             :    deallocate memory allocated using ROSE_MALLOC.
   86773             : */
   86774           7 : void *SgOmpRequiresStatement::operator new ( size_t Size )
   86775             : {
   86776             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   86777             :      * returning or throwing an exception. */
   86778           7 :     ALLOC_MUTEX(SgOmpRequiresStatement, lock);
   86779             : 
   86780             : #if ROSE_ALLOC_TRACE == 2
   86781             : //    printf("SgOmpRequiresStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgOmpRequiresStatement::next_node);
   86782             : #endif
   86783             : 
   86784             : #if USE_CPP_NEW_DELETE_OPERATORS
   86785             :     void *mem = ROSE_MALLOC(Size);
   86786             :     ALLOC_MUTEX(SgOmpRequiresStatement, unlock);
   86787             :     return mem;
   86788             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   86789             : #if ROSE_PEDANTIC_ALLOC
   86790             :     ROSE_ASSERT(Size == sizeof(SgOmpRequiresStatement));
   86791             : #else
   86792           7 :     if (Size != sizeof(SgOmpRequiresStatement)) {
   86793           0 :       void * object = ROSE_MALLOC(Size);
   86794           0 :       ALLOC_MUTEX(SgOmpRequiresStatement, unlock);
   86795             :       return object;
   86796             :     }
   86797             : #endif
   86798             : 
   86799           7 :     if (SgOmpRequiresStatement::next_node == nullptr) {
   86800           7 :         SgOmpRequiresStatement * alloc = (SgOmpRequiresStatement*) ROSE_MALLOC ( SgOmpRequiresStatement::pool_size * sizeof(SgOmpRequiresStatement) );
   86801           7 :         ROSE_ASSERT(alloc != nullptr);
   86802             : 
   86803             : #if ROSE_ALLOC_TRACE == 2
   86804             : //        printf("SgOmpRequiresStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgOmpRequiresStatement::pools.size(), alloc, alloc + SgOmpRequiresStatement::pool_size);
   86805             : #endif
   86806             : 
   86807             : #if ROSE_ALLOC_MEMSET == 1
   86808             : #elif ROSE_ALLOC_MEMSET == 2
   86809             :         memset(alloc, 0x00, SgOmpRequiresStatement::pool_size * sizeof(SgOmpRequiresStatement));
   86810             : #elif ROSE_ALLOC_MEMSET == 3
   86811             :         memset(alloc, 0xAA, SgOmpRequiresStatement::pool_size * sizeof(SgOmpRequiresStatement));
   86812             : #endif
   86813       14000 :         for (unsigned i=0; i < SgOmpRequiresStatement::pool_size-1; i++) {
   86814       13993 :           alloc[i].p_freepointer = &(alloc[i+1]);
   86815             :         }
   86816           7 :         alloc[SgOmpRequiresStatement::pool_size-1].p_freepointer = nullptr;
   86817             : 
   86818           7 :         SgOmpRequiresStatement::pools.push_back ( (unsigned char *) alloc );
   86819           7 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgOmpRequiresStatement::pool_size * sizeof(SgOmpRequiresStatement), V_SgOmpRequiresStatement ) );
   86820           7 :         SgOmpRequiresStatement::next_node = alloc;
   86821             :     }
   86822           7 :     ROSE_ASSERT(SgOmpRequiresStatement::next_node != nullptr);
   86823             : 
   86824           7 :     SgOmpRequiresStatement * object = SgOmpRequiresStatement::next_node;
   86825           7 :     SgOmpRequiresStatement::next_node = (SgOmpRequiresStatement*)(object->p_freepointer);
   86826             : 
   86827             : #if ROSE_ALLOC_TRACE == 2
   86828             :     printf("SgOmpRequiresStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpRequiresStatement::next_node);
   86829             : #endif
   86830             : 
   86831           7 :     SgNode * fp = object->p_freepointer;
   86832             : #if ROSE_ALLOC_MEMSET == 1
   86833             : #elif ROSE_ALLOC_MEMSET == 2
   86834             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpRequiresStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   86835             : #elif ROSE_ALLOC_MEMSET == 3
   86836             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgOmpRequiresStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   86837             : #endif
   86838           7 :     object->p_freepointer = fp;
   86839             : 
   86840             : #if ROSE_ALLOC_TRACE == 2
   86841             : //    printf("SgOmpRequiresStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpRequiresStatement::next_node);
   86842             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   86843             :     Rose::MemPool::snapshot(oss.str());
   86844             :     alloc_trace_cnt++;
   86845             : #endif
   86846             : 
   86847           7 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   86848             : 
   86849           7 :     ALLOC_MUTEX(SgOmpRequiresStatement, unlock);
   86850             : 
   86851             :     return object;
   86852             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   86853             : }
   86854             : 
   86855             : 
   86856             : 
   86857             : /*! \brief Delete operator for SgOmpRequiresStatement.
   86858             : 
   86859             :    This delete operator implements deallocation using memory pools to 
   86860             :    provide most efficent use of the heap within construction of large ASTs.
   86861             : 
   86862             : \internal The new and delete operators use the lower level C malloc/free
   86863             :    function calls for performance and to make sure that mixing of malloc/free
   86864             :    and new/delete by the used can be caught more readily.  This may change
   86865             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   86866             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   86867             :    deallocate memory allocated using ROSE_MALLOC.
   86868             : */
   86869           0 : void SgOmpRequiresStatement::operator delete(void *Pointer, size_t Size)
   86870             : {
   86871             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   86872             :      * or throwing an exception. */
   86873           0 :     ALLOC_MUTEX(SgOmpRequiresStatement, lock);
   86874             : 
   86875             : #if USE_CPP_NEW_DELETE_OPERATORS
   86876             :     ROSE_FREE(Pointer);
   86877             : #else
   86878             : #if ROSE_PEDANTIC_ALLOC
   86879             :     ROSE_ASSERT(Size == sizeof(SgOmpRequiresStatement));
   86880             : #else
   86881           0 :     if (Size != sizeof(SgOmpRequiresStatement)) {
   86882           0 :       ROSE_FREE(Pointer);
   86883           0 :       ALLOC_MUTEX(SgOmpRequiresStatement, unlock);
   86884             :       return;
   86885             :     }
   86886             : #endif
   86887             : 
   86888           0 :     SgOmpRequiresStatement * object = (SgOmpRequiresStatement*) Pointer;
   86889           0 :     ROSE_ASSERT(object != nullptr);
   86890             : 
   86891             : #if ROSE_ALLOC_TRACE == 2
   86892             : //  printf("SgOmpRequiresStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpRequiresStatement::next_node);
   86893             :     printf("SgOmpRequiresStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpRequiresStatement::next_node);
   86894             : #endif
   86895             : 
   86896             : #if ROSE_PEDANTIC_ALLOC
   86897             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   86898             : #endif
   86899             : 
   86900             : #if ROSE_ALLOC_MEMSET == 1
   86901             : #elif ROSE_ALLOC_MEMSET == 2
   86902             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpRequiresStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   86903             : #elif ROSE_ALLOC_MEMSET == 3
   86904             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgOmpRequiresStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   86905             : #endif
   86906             : 
   86907             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   86908             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   86909             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   86910             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   86911             : #else
   86912           0 :     object->p_freepointer = SgOmpRequiresStatement::next_node;
   86913           0 :     SgOmpRequiresStatement::next_node = object;
   86914             : #endif
   86915             : 
   86916             : #if ROSE_ALLOC_TRACE == 2
   86917             : //  printf("SgOmpRequiresStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpRequiresStatement::next_node);
   86918             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   86919             :     Rose::MemPool::snapshot(oss.str());
   86920             :     alloc_trace_cnt++;
   86921             : #endif
   86922             : 
   86923             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   86924             : 
   86925           0 :     ALLOC_MUTEX(SgOmpRequiresStatement, unlock);
   86926             : }
   86927             : 
   86928             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   86929             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   86930             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   86931             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   86932             : // Also, note comment below from Robb (copied from the Common.code file).
   86933             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   86934             : //
   86935             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   86936             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   86937             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   86938             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   86939             : #if 0
   86940             : void SgOmpRequiresStatement::operator delete(void* pointer) { SgOmpRequiresStatement::operator delete (pointer, sizeof(SgOmpRequiresStatement)); };
   86941             : #endif
   86942             : /* #line 86943 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   86943             : 
   86944             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   86945             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   86946             : // obviously imply C++.
   86947             : 
   86948             : // This implements the support within ROSE for memory pools.  Memory pools
   86949             : // support the most condensed usage of memory within the construction of
   86950             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   86951             : // by a new operator written for each class.
   86952             : 
   86953             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   86954             :     // User wants multi-thread support and POSIX threads are available.
   86955             : #   include <pthread.h>
   86956             :     static pthread_mutex_t SgFortranIncludeLine_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   86957             : #else
   86958             :      // Cause synchronization to be skipped.
   86959             : #    ifndef ALLOC_MUTEX
   86960             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   86961             : #    endif
   86962             : #    ifdef _REENTRANT
   86963             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   86964             : #       ifdef _MSC_VER
   86965             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   86966             : #       else
   86967             : #           warning "POSIX threads are not available; synchronization being skipped"
   86968             : #       endif
   86969             : #    endif
   86970             : #endif
   86971             : 
   86972             : #ifndef ROSE_ALLOC_TRACE
   86973             : #  define ROSE_ALLOC_TRACE 0
   86974             : #endif
   86975             : 
   86976             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   86977             : #define ROSE_ALLOC_TRACE_CNT
   86978             : #include "memory-pool-snapshot.h"
   86979             : unsigned long alloc_trace_cnt = 0;
   86980             : #endif
   86981             : 
   86982             : #if ROSE_ALLOC_TRACE
   86983             : const unsigned SgFortranIncludeLine::pool_size = 5;
   86984             : #else
   86985             : const unsigned SgFortranIncludeLine::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   86986             : #endif
   86987             : 
   86988             : #ifndef ROSE_ALLOC_MEMSET
   86989             : #  define ROSE_ALLOC_MEMSET 0
   86990             : #endif
   86991             : 
   86992             : #ifndef ROSE_PEDANTIC_ALLOC
   86993             : #  define ROSE_PEDANTIC_ALLOC 0
   86994             : #endif
   86995             : 
   86996             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   86997             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   86998             : #endif
   86999             : 
   87000             : #if !defined(SGNODE__ALL_POOLS)
   87001             : #define SGNODE__ALL_POOLS
   87002             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   87003             : #endif
   87004             : 
   87005             : SgFortranIncludeLine* SgFortranIncludeLine::next_node = nullptr;
   87006             : std::vector<unsigned char*> SgFortranIncludeLine::pools;
   87007             : 
   87008             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   87009             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   87010             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   87011             : // around this macro definition rather than each use).
   87012             : #ifndef ALLOC_MUTEX
   87013             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   87014             :         do {                                                                     \
   87015             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   87016             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   87017             :                 abort();                                                         \
   87018             :             }                                                                    \
   87019             :         } while (0);
   87020             : #endif
   87021             : 
   87022             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   87023             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   87024             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   87025             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   87026             : 
   87027             : /*! \brief New operator for SgFortranIncludeLine.
   87028             : 
   87029             :    This new operator implements memory pools to provide most efficent 
   87030             :    use of the heap within construction of large ASTs.
   87031             : 
   87032             : \internal The new and delete operators use the lower level C malloc/free
   87033             :    function calls for performance and to make sure that mixing of malloc/free
   87034             :    and new/delete by the used can be caught more readily.  This may change
   87035             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   87036             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   87037             :    deallocate memory allocated using ROSE_MALLOC.
   87038             : */
   87039          28 : void *SgFortranIncludeLine::operator new ( size_t Size )
   87040             : {
   87041             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   87042             :      * returning or throwing an exception. */
   87043          28 :     ALLOC_MUTEX(SgFortranIncludeLine, lock);
   87044             : 
   87045             : #if ROSE_ALLOC_TRACE == 2
   87046             : //    printf("SgFortranIncludeLine::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgFortranIncludeLine::next_node);
   87047             : #endif
   87048             : 
   87049             : #if USE_CPP_NEW_DELETE_OPERATORS
   87050             :     void *mem = ROSE_MALLOC(Size);
   87051             :     ALLOC_MUTEX(SgFortranIncludeLine, unlock);
   87052             :     return mem;
   87053             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   87054             : #if ROSE_PEDANTIC_ALLOC
   87055             :     ROSE_ASSERT(Size == sizeof(SgFortranIncludeLine));
   87056             : #else
   87057          28 :     if (Size != sizeof(SgFortranIncludeLine)) {
   87058           0 :       void * object = ROSE_MALLOC(Size);
   87059           0 :       ALLOC_MUTEX(SgFortranIncludeLine, unlock);
   87060             :       return object;
   87061             :     }
   87062             : #endif
   87063             : 
   87064          28 :     if (SgFortranIncludeLine::next_node == nullptr) {
   87065          12 :         SgFortranIncludeLine * alloc = (SgFortranIncludeLine*) ROSE_MALLOC ( SgFortranIncludeLine::pool_size * sizeof(SgFortranIncludeLine) );
   87066          12 :         ROSE_ASSERT(alloc != nullptr);
   87067             : 
   87068             : #if ROSE_ALLOC_TRACE == 2
   87069             : //        printf("SgFortranIncludeLine::alloc\n  block[%zi] = [ %p , %p [\n", SgFortranIncludeLine::pools.size(), alloc, alloc + SgFortranIncludeLine::pool_size);
   87070             : #endif
   87071             : 
   87072             : #if ROSE_ALLOC_MEMSET == 1
   87073             : #elif ROSE_ALLOC_MEMSET == 2
   87074             :         memset(alloc, 0x00, SgFortranIncludeLine::pool_size * sizeof(SgFortranIncludeLine));
   87075             : #elif ROSE_ALLOC_MEMSET == 3
   87076             :         memset(alloc, 0xAA, SgFortranIncludeLine::pool_size * sizeof(SgFortranIncludeLine));
   87077             : #endif
   87078       24000 :         for (unsigned i=0; i < SgFortranIncludeLine::pool_size-1; i++) {
   87079       23988 :           alloc[i].p_freepointer = &(alloc[i+1]);
   87080             :         }
   87081          12 :         alloc[SgFortranIncludeLine::pool_size-1].p_freepointer = nullptr;
   87082             : 
   87083          12 :         SgFortranIncludeLine::pools.push_back ( (unsigned char *) alloc );
   87084          12 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgFortranIncludeLine::pool_size * sizeof(SgFortranIncludeLine), V_SgFortranIncludeLine ) );
   87085          12 :         SgFortranIncludeLine::next_node = alloc;
   87086             :     }
   87087          28 :     ROSE_ASSERT(SgFortranIncludeLine::next_node != nullptr);
   87088             : 
   87089          28 :     SgFortranIncludeLine * object = SgFortranIncludeLine::next_node;
   87090          28 :     SgFortranIncludeLine::next_node = (SgFortranIncludeLine*)(object->p_freepointer);
   87091             : 
   87092             : #if ROSE_ALLOC_TRACE == 2
   87093             :     printf("SgFortranIncludeLine::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgFortranIncludeLine::next_node);
   87094             : #endif
   87095             : 
   87096          28 :     SgNode * fp = object->p_freepointer;
   87097             : #if ROSE_ALLOC_MEMSET == 1
   87098             : #elif ROSE_ALLOC_MEMSET == 2
   87099             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgFortranIncludeLine) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   87100             : #elif ROSE_ALLOC_MEMSET == 3
   87101             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgFortranIncludeLine) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   87102             : #endif
   87103          28 :     object->p_freepointer = fp;
   87104             : 
   87105             : #if ROSE_ALLOC_TRACE == 2
   87106             : //    printf("SgFortranIncludeLine::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgFortranIncludeLine::next_node);
   87107             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   87108             :     Rose::MemPool::snapshot(oss.str());
   87109             :     alloc_trace_cnt++;
   87110             : #endif
   87111             : 
   87112          28 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   87113             : 
   87114          28 :     ALLOC_MUTEX(SgFortranIncludeLine, unlock);
   87115             : 
   87116             :     return object;
   87117             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   87118             : }
   87119             : 
   87120             : 
   87121             : 
   87122             : /*! \brief Delete operator for SgFortranIncludeLine.
   87123             : 
   87124             :    This delete operator implements deallocation using memory pools to 
   87125             :    provide most efficent use of the heap within construction of large ASTs.
   87126             : 
   87127             : \internal The new and delete operators use the lower level C malloc/free
   87128             :    function calls for performance and to make sure that mixing of malloc/free
   87129             :    and new/delete by the used can be caught more readily.  This may change
   87130             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   87131             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   87132             :    deallocate memory allocated using ROSE_MALLOC.
   87133             : */
   87134           0 : void SgFortranIncludeLine::operator delete(void *Pointer, size_t Size)
   87135             : {
   87136             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   87137             :      * or throwing an exception. */
   87138           0 :     ALLOC_MUTEX(SgFortranIncludeLine, lock);
   87139             : 
   87140             : #if USE_CPP_NEW_DELETE_OPERATORS
   87141             :     ROSE_FREE(Pointer);
   87142             : #else
   87143             : #if ROSE_PEDANTIC_ALLOC
   87144             :     ROSE_ASSERT(Size == sizeof(SgFortranIncludeLine));
   87145             : #else
   87146           0 :     if (Size != sizeof(SgFortranIncludeLine)) {
   87147           0 :       ROSE_FREE(Pointer);
   87148           0 :       ALLOC_MUTEX(SgFortranIncludeLine, unlock);
   87149             :       return;
   87150             :     }
   87151             : #endif
   87152             : 
   87153           0 :     SgFortranIncludeLine * object = (SgFortranIncludeLine*) Pointer;
   87154           0 :     ROSE_ASSERT(object != nullptr);
   87155             : 
   87156             : #if ROSE_ALLOC_TRACE == 2
   87157             : //  printf("SgFortranIncludeLine::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgFortranIncludeLine::next_node);
   87158             :     printf("SgFortranIncludeLine::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgFortranIncludeLine::next_node);
   87159             : #endif
   87160             : 
   87161             : #if ROSE_PEDANTIC_ALLOC
   87162             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   87163             : #endif
   87164             : 
   87165             : #if ROSE_ALLOC_MEMSET == 1
   87166             : #elif ROSE_ALLOC_MEMSET == 2
   87167             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgFortranIncludeLine) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   87168             : #elif ROSE_ALLOC_MEMSET == 3
   87169             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgFortranIncludeLine) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   87170             : #endif
   87171             : 
   87172             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   87173             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   87174             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   87175             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   87176             : #else
   87177           0 :     object->p_freepointer = SgFortranIncludeLine::next_node;
   87178           0 :     SgFortranIncludeLine::next_node = object;
   87179             : #endif
   87180             : 
   87181             : #if ROSE_ALLOC_TRACE == 2
   87182             : //  printf("SgFortranIncludeLine::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgFortranIncludeLine::next_node);
   87183             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   87184             :     Rose::MemPool::snapshot(oss.str());
   87185             :     alloc_trace_cnt++;
   87186             : #endif
   87187             : 
   87188             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   87189             : 
   87190           0 :     ALLOC_MUTEX(SgFortranIncludeLine, unlock);
   87191             : }
   87192             : 
   87193             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   87194             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   87195             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   87196             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   87197             : // Also, note comment below from Robb (copied from the Common.code file).
   87198             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   87199             : //
   87200             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   87201             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   87202             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   87203             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   87204             : #if 0
   87205             : void SgFortranIncludeLine::operator delete(void* pointer) { SgFortranIncludeLine::operator delete (pointer, sizeof(SgFortranIncludeLine)); };
   87206             : #endif
   87207             : /* #line 87208 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   87208             : 
   87209             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   87210             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   87211             : // obviously imply C++.
   87212             : 
   87213             : // This implements the support within ROSE for memory pools.  Memory pools
   87214             : // support the most condensed usage of memory within the construction of
   87215             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   87216             : // by a new operator written for each class.
   87217             : 
   87218             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   87219             :     // User wants multi-thread support and POSIX threads are available.
   87220             : #   include <pthread.h>
   87221             :     static pthread_mutex_t SgOmpTaskwaitStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   87222             : #else
   87223             :      // Cause synchronization to be skipped.
   87224             : #    ifndef ALLOC_MUTEX
   87225             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   87226             : #    endif
   87227             : #    ifdef _REENTRANT
   87228             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   87229             : #       ifdef _MSC_VER
   87230             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   87231             : #       else
   87232             : #           warning "POSIX threads are not available; synchronization being skipped"
   87233             : #       endif
   87234             : #    endif
   87235             : #endif
   87236             : 
   87237             : #ifndef ROSE_ALLOC_TRACE
   87238             : #  define ROSE_ALLOC_TRACE 0
   87239             : #endif
   87240             : 
   87241             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   87242             : #define ROSE_ALLOC_TRACE_CNT
   87243             : #include "memory-pool-snapshot.h"
   87244             : unsigned long alloc_trace_cnt = 0;
   87245             : #endif
   87246             : 
   87247             : #if ROSE_ALLOC_TRACE
   87248             : const unsigned SgOmpTaskwaitStatement::pool_size = 5;
   87249             : #else
   87250             : const unsigned SgOmpTaskwaitStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   87251             : #endif
   87252             : 
   87253             : #ifndef ROSE_ALLOC_MEMSET
   87254             : #  define ROSE_ALLOC_MEMSET 0
   87255             : #endif
   87256             : 
   87257             : #ifndef ROSE_PEDANTIC_ALLOC
   87258             : #  define ROSE_PEDANTIC_ALLOC 0
   87259             : #endif
   87260             : 
   87261             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   87262             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   87263             : #endif
   87264             : 
   87265             : #if !defined(SGNODE__ALL_POOLS)
   87266             : #define SGNODE__ALL_POOLS
   87267             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   87268             : #endif
   87269             : 
   87270             : SgOmpTaskwaitStatement* SgOmpTaskwaitStatement::next_node = nullptr;
   87271             : std::vector<unsigned char*> SgOmpTaskwaitStatement::pools;
   87272             : 
   87273             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   87274             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   87275             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   87276             : // around this macro definition rather than each use).
   87277             : #ifndef ALLOC_MUTEX
   87278             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   87279             :         do {                                                                     \
   87280             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   87281             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   87282             :                 abort();                                                         \
   87283             :             }                                                                    \
   87284             :         } while (0);
   87285             : #endif
   87286             : 
   87287             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   87288             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   87289             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   87290             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   87291             : 
   87292             : /*! \brief New operator for SgOmpTaskwaitStatement.
   87293             : 
   87294             :    This new operator implements memory pools to provide most efficent 
   87295             :    use of the heap within construction of large ASTs.
   87296             : 
   87297             : \internal The new and delete operators use the lower level C malloc/free
   87298             :    function calls for performance and to make sure that mixing of malloc/free
   87299             :    and new/delete by the used can be caught more readily.  This may change
   87300             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   87301             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   87302             :    deallocate memory allocated using ROSE_MALLOC.
   87303             : */
   87304          28 : void *SgOmpTaskwaitStatement::operator new ( size_t Size )
   87305             : {
   87306             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   87307             :      * returning or throwing an exception. */
   87308          28 :     ALLOC_MUTEX(SgOmpTaskwaitStatement, lock);
   87309             : 
   87310             : #if ROSE_ALLOC_TRACE == 2
   87311             : //    printf("SgOmpTaskwaitStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgOmpTaskwaitStatement::next_node);
   87312             : #endif
   87313             : 
   87314             : #if USE_CPP_NEW_DELETE_OPERATORS
   87315             :     void *mem = ROSE_MALLOC(Size);
   87316             :     ALLOC_MUTEX(SgOmpTaskwaitStatement, unlock);
   87317             :     return mem;
   87318             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   87319             : #if ROSE_PEDANTIC_ALLOC
   87320             :     ROSE_ASSERT(Size == sizeof(SgOmpTaskwaitStatement));
   87321             : #else
   87322          28 :     if (Size != sizeof(SgOmpTaskwaitStatement)) {
   87323           0 :       void * object = ROSE_MALLOC(Size);
   87324           0 :       ALLOC_MUTEX(SgOmpTaskwaitStatement, unlock);
   87325             :       return object;
   87326             :     }
   87327             : #endif
   87328             : 
   87329          28 :     if (SgOmpTaskwaitStatement::next_node == nullptr) {
   87330           6 :         SgOmpTaskwaitStatement * alloc = (SgOmpTaskwaitStatement*) ROSE_MALLOC ( SgOmpTaskwaitStatement::pool_size * sizeof(SgOmpTaskwaitStatement) );
   87331           6 :         ROSE_ASSERT(alloc != nullptr);
   87332             : 
   87333             : #if ROSE_ALLOC_TRACE == 2
   87334             : //        printf("SgOmpTaskwaitStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgOmpTaskwaitStatement::pools.size(), alloc, alloc + SgOmpTaskwaitStatement::pool_size);
   87335             : #endif
   87336             : 
   87337             : #if ROSE_ALLOC_MEMSET == 1
   87338             : #elif ROSE_ALLOC_MEMSET == 2
   87339             :         memset(alloc, 0x00, SgOmpTaskwaitStatement::pool_size * sizeof(SgOmpTaskwaitStatement));
   87340             : #elif ROSE_ALLOC_MEMSET == 3
   87341             :         memset(alloc, 0xAA, SgOmpTaskwaitStatement::pool_size * sizeof(SgOmpTaskwaitStatement));
   87342             : #endif
   87343       12000 :         for (unsigned i=0; i < SgOmpTaskwaitStatement::pool_size-1; i++) {
   87344       11994 :           alloc[i].p_freepointer = &(alloc[i+1]);
   87345             :         }
   87346           6 :         alloc[SgOmpTaskwaitStatement::pool_size-1].p_freepointer = nullptr;
   87347             : 
   87348           6 :         SgOmpTaskwaitStatement::pools.push_back ( (unsigned char *) alloc );
   87349           6 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgOmpTaskwaitStatement::pool_size * sizeof(SgOmpTaskwaitStatement), V_SgOmpTaskwaitStatement ) );
   87350           6 :         SgOmpTaskwaitStatement::next_node = alloc;
   87351             :     }
   87352          28 :     ROSE_ASSERT(SgOmpTaskwaitStatement::next_node != nullptr);
   87353             : 
   87354          28 :     SgOmpTaskwaitStatement * object = SgOmpTaskwaitStatement::next_node;
   87355          28 :     SgOmpTaskwaitStatement::next_node = (SgOmpTaskwaitStatement*)(object->p_freepointer);
   87356             : 
   87357             : #if ROSE_ALLOC_TRACE == 2
   87358             :     printf("SgOmpTaskwaitStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpTaskwaitStatement::next_node);
   87359             : #endif
   87360             : 
   87361          28 :     SgNode * fp = object->p_freepointer;
   87362             : #if ROSE_ALLOC_MEMSET == 1
   87363             : #elif ROSE_ALLOC_MEMSET == 2
   87364             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpTaskwaitStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   87365             : #elif ROSE_ALLOC_MEMSET == 3
   87366             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgOmpTaskwaitStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   87367             : #endif
   87368          28 :     object->p_freepointer = fp;
   87369             : 
   87370             : #if ROSE_ALLOC_TRACE == 2
   87371             : //    printf("SgOmpTaskwaitStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpTaskwaitStatement::next_node);
   87372             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   87373             :     Rose::MemPool::snapshot(oss.str());
   87374             :     alloc_trace_cnt++;
   87375             : #endif
   87376             : 
   87377          28 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   87378             : 
   87379          28 :     ALLOC_MUTEX(SgOmpTaskwaitStatement, unlock);
   87380             : 
   87381             :     return object;
   87382             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   87383             : }
   87384             : 
   87385             : 
   87386             : 
   87387             : /*! \brief Delete operator for SgOmpTaskwaitStatement.
   87388             : 
   87389             :    This delete operator implements deallocation using memory pools to 
   87390             :    provide most efficent use of the heap within construction of large ASTs.
   87391             : 
   87392             : \internal The new and delete operators use the lower level C malloc/free
   87393             :    function calls for performance and to make sure that mixing of malloc/free
   87394             :    and new/delete by the used can be caught more readily.  This may change
   87395             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   87396             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   87397             :    deallocate memory allocated using ROSE_MALLOC.
   87398             : */
   87399           0 : void SgOmpTaskwaitStatement::operator delete(void *Pointer, size_t Size)
   87400             : {
   87401             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   87402             :      * or throwing an exception. */
   87403           0 :     ALLOC_MUTEX(SgOmpTaskwaitStatement, lock);
   87404             : 
   87405             : #if USE_CPP_NEW_DELETE_OPERATORS
   87406             :     ROSE_FREE(Pointer);
   87407             : #else
   87408             : #if ROSE_PEDANTIC_ALLOC
   87409             :     ROSE_ASSERT(Size == sizeof(SgOmpTaskwaitStatement));
   87410             : #else
   87411           0 :     if (Size != sizeof(SgOmpTaskwaitStatement)) {
   87412           0 :       ROSE_FREE(Pointer);
   87413           0 :       ALLOC_MUTEX(SgOmpTaskwaitStatement, unlock);
   87414             :       return;
   87415             :     }
   87416             : #endif
   87417             : 
   87418           0 :     SgOmpTaskwaitStatement * object = (SgOmpTaskwaitStatement*) Pointer;
   87419           0 :     ROSE_ASSERT(object != nullptr);
   87420             : 
   87421             : #if ROSE_ALLOC_TRACE == 2
   87422             : //  printf("SgOmpTaskwaitStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpTaskwaitStatement::next_node);
   87423             :     printf("SgOmpTaskwaitStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpTaskwaitStatement::next_node);
   87424             : #endif
   87425             : 
   87426             : #if ROSE_PEDANTIC_ALLOC
   87427             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   87428             : #endif
   87429             : 
   87430             : #if ROSE_ALLOC_MEMSET == 1
   87431             : #elif ROSE_ALLOC_MEMSET == 2
   87432             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpTaskwaitStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   87433             : #elif ROSE_ALLOC_MEMSET == 3
   87434             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgOmpTaskwaitStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   87435             : #endif
   87436             : 
   87437             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   87438             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   87439             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   87440             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   87441             : #else
   87442           0 :     object->p_freepointer = SgOmpTaskwaitStatement::next_node;
   87443           0 :     SgOmpTaskwaitStatement::next_node = object;
   87444             : #endif
   87445             : 
   87446             : #if ROSE_ALLOC_TRACE == 2
   87447             : //  printf("SgOmpTaskwaitStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpTaskwaitStatement::next_node);
   87448             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   87449             :     Rose::MemPool::snapshot(oss.str());
   87450             :     alloc_trace_cnt++;
   87451             : #endif
   87452             : 
   87453             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   87454             : 
   87455           0 :     ALLOC_MUTEX(SgOmpTaskwaitStatement, unlock);
   87456             : }
   87457             : 
   87458             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   87459             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   87460             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   87461             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   87462             : // Also, note comment below from Robb (copied from the Common.code file).
   87463             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   87464             : //
   87465             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   87466             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   87467             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   87468             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   87469             : #if 0
   87470             : void SgOmpTaskwaitStatement::operator delete(void* pointer) { SgOmpTaskwaitStatement::operator delete (pointer, sizeof(SgOmpTaskwaitStatement)); };
   87471             : #endif
   87472             : /* #line 87473 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   87473             : 
   87474             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   87475             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   87476             : // obviously imply C++.
   87477             : 
   87478             : // This implements the support within ROSE for memory pools.  Memory pools
   87479             : // support the most condensed usage of memory within the construction of
   87480             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   87481             : // by a new operator written for each class.
   87482             : 
   87483             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   87484             :     // User wants multi-thread support and POSIX threads are available.
   87485             : #   include <pthread.h>
   87486             :     static pthread_mutex_t SgStmtDeclarationStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   87487             : #else
   87488             :      // Cause synchronization to be skipped.
   87489             : #    ifndef ALLOC_MUTEX
   87490             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   87491             : #    endif
   87492             : #    ifdef _REENTRANT
   87493             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   87494             : #       ifdef _MSC_VER
   87495             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   87496             : #       else
   87497             : #           warning "POSIX threads are not available; synchronization being skipped"
   87498             : #       endif
   87499             : #    endif
   87500             : #endif
   87501             : 
   87502             : #ifndef ROSE_ALLOC_TRACE
   87503             : #  define ROSE_ALLOC_TRACE 0
   87504             : #endif
   87505             : 
   87506             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   87507             : #define ROSE_ALLOC_TRACE_CNT
   87508             : #include "memory-pool-snapshot.h"
   87509             : unsigned long alloc_trace_cnt = 0;
   87510             : #endif
   87511             : 
   87512             : #if ROSE_ALLOC_TRACE
   87513             : const unsigned SgStmtDeclarationStatement::pool_size = 5;
   87514             : #else
   87515             : const unsigned SgStmtDeclarationStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   87516             : #endif
   87517             : 
   87518             : #ifndef ROSE_ALLOC_MEMSET
   87519             : #  define ROSE_ALLOC_MEMSET 0
   87520             : #endif
   87521             : 
   87522             : #ifndef ROSE_PEDANTIC_ALLOC
   87523             : #  define ROSE_PEDANTIC_ALLOC 0
   87524             : #endif
   87525             : 
   87526             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   87527             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   87528             : #endif
   87529             : 
   87530             : #if !defined(SGNODE__ALL_POOLS)
   87531             : #define SGNODE__ALL_POOLS
   87532             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   87533             : #endif
   87534             : 
   87535             : SgStmtDeclarationStatement* SgStmtDeclarationStatement::next_node = nullptr;
   87536             : std::vector<unsigned char*> SgStmtDeclarationStatement::pools;
   87537             : 
   87538             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   87539             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   87540             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   87541             : // around this macro definition rather than each use).
   87542             : #ifndef ALLOC_MUTEX
   87543             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   87544             :         do {                                                                     \
   87545             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   87546             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   87547             :                 abort();                                                         \
   87548             :             }                                                                    \
   87549             :         } while (0);
   87550             : #endif
   87551             : 
   87552             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   87553             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   87554             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   87555             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   87556             : 
   87557             : /*! \brief New operator for SgStmtDeclarationStatement.
   87558             : 
   87559             :    This new operator implements memory pools to provide most efficent 
   87560             :    use of the heap within construction of large ASTs.
   87561             : 
   87562             : \internal The new and delete operators use the lower level C malloc/free
   87563             :    function calls for performance and to make sure that mixing of malloc/free
   87564             :    and new/delete by the used can be caught more readily.  This may change
   87565             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   87566             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   87567             :    deallocate memory allocated using ROSE_MALLOC.
   87568             : */
   87569           0 : void *SgStmtDeclarationStatement::operator new ( size_t Size )
   87570             : {
   87571             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   87572             :      * returning or throwing an exception. */
   87573           0 :     ALLOC_MUTEX(SgStmtDeclarationStatement, lock);
   87574             : 
   87575             : #if ROSE_ALLOC_TRACE == 2
   87576             : //    printf("SgStmtDeclarationStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgStmtDeclarationStatement::next_node);
   87577             : #endif
   87578             : 
   87579             : #if USE_CPP_NEW_DELETE_OPERATORS
   87580             :     void *mem = ROSE_MALLOC(Size);
   87581             :     ALLOC_MUTEX(SgStmtDeclarationStatement, unlock);
   87582             :     return mem;
   87583             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   87584             : #if ROSE_PEDANTIC_ALLOC
   87585             :     ROSE_ASSERT(Size == sizeof(SgStmtDeclarationStatement));
   87586             : #else
   87587           0 :     if (Size != sizeof(SgStmtDeclarationStatement)) {
   87588           0 :       void * object = ROSE_MALLOC(Size);
   87589           0 :       ALLOC_MUTEX(SgStmtDeclarationStatement, unlock);
   87590             :       return object;
   87591             :     }
   87592             : #endif
   87593             : 
   87594           0 :     if (SgStmtDeclarationStatement::next_node == nullptr) {
   87595           0 :         SgStmtDeclarationStatement * alloc = (SgStmtDeclarationStatement*) ROSE_MALLOC ( SgStmtDeclarationStatement::pool_size * sizeof(SgStmtDeclarationStatement) );
   87596           0 :         ROSE_ASSERT(alloc != nullptr);
   87597             : 
   87598             : #if ROSE_ALLOC_TRACE == 2
   87599             : //        printf("SgStmtDeclarationStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgStmtDeclarationStatement::pools.size(), alloc, alloc + SgStmtDeclarationStatement::pool_size);
   87600             : #endif
   87601             : 
   87602             : #if ROSE_ALLOC_MEMSET == 1
   87603             : #elif ROSE_ALLOC_MEMSET == 2
   87604             :         memset(alloc, 0x00, SgStmtDeclarationStatement::pool_size * sizeof(SgStmtDeclarationStatement));
   87605             : #elif ROSE_ALLOC_MEMSET == 3
   87606             :         memset(alloc, 0xAA, SgStmtDeclarationStatement::pool_size * sizeof(SgStmtDeclarationStatement));
   87607             : #endif
   87608           0 :         for (unsigned i=0; i < SgStmtDeclarationStatement::pool_size-1; i++) {
   87609           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
   87610             :         }
   87611           0 :         alloc[SgStmtDeclarationStatement::pool_size-1].p_freepointer = nullptr;
   87612             : 
   87613           0 :         SgStmtDeclarationStatement::pools.push_back ( (unsigned char *) alloc );
   87614           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgStmtDeclarationStatement::pool_size * sizeof(SgStmtDeclarationStatement), V_SgStmtDeclarationStatement ) );
   87615           0 :         SgStmtDeclarationStatement::next_node = alloc;
   87616             :     }
   87617           0 :     ROSE_ASSERT(SgStmtDeclarationStatement::next_node != nullptr);
   87618             : 
   87619           0 :     SgStmtDeclarationStatement * object = SgStmtDeclarationStatement::next_node;
   87620           0 :     SgStmtDeclarationStatement::next_node = (SgStmtDeclarationStatement*)(object->p_freepointer);
   87621             : 
   87622             : #if ROSE_ALLOC_TRACE == 2
   87623             :     printf("SgStmtDeclarationStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgStmtDeclarationStatement::next_node);
   87624             : #endif
   87625             : 
   87626           0 :     SgNode * fp = object->p_freepointer;
   87627             : #if ROSE_ALLOC_MEMSET == 1
   87628             : #elif ROSE_ALLOC_MEMSET == 2
   87629             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgStmtDeclarationStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   87630             : #elif ROSE_ALLOC_MEMSET == 3
   87631             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgStmtDeclarationStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   87632             : #endif
   87633           0 :     object->p_freepointer = fp;
   87634             : 
   87635             : #if ROSE_ALLOC_TRACE == 2
   87636             : //    printf("SgStmtDeclarationStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgStmtDeclarationStatement::next_node);
   87637             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   87638             :     Rose::MemPool::snapshot(oss.str());
   87639             :     alloc_trace_cnt++;
   87640             : #endif
   87641             : 
   87642           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   87643             : 
   87644           0 :     ALLOC_MUTEX(SgStmtDeclarationStatement, unlock);
   87645             : 
   87646             :     return object;
   87647             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   87648             : }
   87649             : 
   87650             : 
   87651             : 
   87652             : /*! \brief Delete operator for SgStmtDeclarationStatement.
   87653             : 
   87654             :    This delete operator implements deallocation using memory pools to 
   87655             :    provide most efficent use of the heap within construction of large ASTs.
   87656             : 
   87657             : \internal The new and delete operators use the lower level C malloc/free
   87658             :    function calls for performance and to make sure that mixing of malloc/free
   87659             :    and new/delete by the used can be caught more readily.  This may change
   87660             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   87661             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   87662             :    deallocate memory allocated using ROSE_MALLOC.
   87663             : */
   87664           0 : void SgStmtDeclarationStatement::operator delete(void *Pointer, size_t Size)
   87665             : {
   87666             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   87667             :      * or throwing an exception. */
   87668           0 :     ALLOC_MUTEX(SgStmtDeclarationStatement, lock);
   87669             : 
   87670             : #if USE_CPP_NEW_DELETE_OPERATORS
   87671             :     ROSE_FREE(Pointer);
   87672             : #else
   87673             : #if ROSE_PEDANTIC_ALLOC
   87674             :     ROSE_ASSERT(Size == sizeof(SgStmtDeclarationStatement));
   87675             : #else
   87676           0 :     if (Size != sizeof(SgStmtDeclarationStatement)) {
   87677           0 :       ROSE_FREE(Pointer);
   87678           0 :       ALLOC_MUTEX(SgStmtDeclarationStatement, unlock);
   87679             :       return;
   87680             :     }
   87681             : #endif
   87682             : 
   87683           0 :     SgStmtDeclarationStatement * object = (SgStmtDeclarationStatement*) Pointer;
   87684           0 :     ROSE_ASSERT(object != nullptr);
   87685             : 
   87686             : #if ROSE_ALLOC_TRACE == 2
   87687             : //  printf("SgStmtDeclarationStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgStmtDeclarationStatement::next_node);
   87688             :     printf("SgStmtDeclarationStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgStmtDeclarationStatement::next_node);
   87689             : #endif
   87690             : 
   87691             : #if ROSE_PEDANTIC_ALLOC
   87692             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   87693             : #endif
   87694             : 
   87695             : #if ROSE_ALLOC_MEMSET == 1
   87696             : #elif ROSE_ALLOC_MEMSET == 2
   87697             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgStmtDeclarationStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   87698             : #elif ROSE_ALLOC_MEMSET == 3
   87699             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgStmtDeclarationStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   87700             : #endif
   87701             : 
   87702             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   87703             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   87704             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   87705             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   87706             : #else
   87707           0 :     object->p_freepointer = SgStmtDeclarationStatement::next_node;
   87708           0 :     SgStmtDeclarationStatement::next_node = object;
   87709             : #endif
   87710             : 
   87711             : #if ROSE_ALLOC_TRACE == 2
   87712             : //  printf("SgStmtDeclarationStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgStmtDeclarationStatement::next_node);
   87713             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   87714             :     Rose::MemPool::snapshot(oss.str());
   87715             :     alloc_trace_cnt++;
   87716             : #endif
   87717             : 
   87718             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   87719             : 
   87720           0 :     ALLOC_MUTEX(SgStmtDeclarationStatement, unlock);
   87721             : }
   87722             : 
   87723             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   87724             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   87725             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   87726             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   87727             : // Also, note comment below from Robb (copied from the Common.code file).
   87728             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   87729             : //
   87730             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   87731             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   87732             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   87733             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   87734             : #if 0
   87735             : void SgStmtDeclarationStatement::operator delete(void* pointer) { SgStmtDeclarationStatement::operator delete (pointer, sizeof(SgStmtDeclarationStatement)); };
   87736             : #endif
   87737             : /* #line 87738 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   87738             : 
   87739             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   87740             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   87741             : // obviously imply C++.
   87742             : 
   87743             : // This implements the support within ROSE for memory pools.  Memory pools
   87744             : // support the most condensed usage of memory within the construction of
   87745             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   87746             : // by a new operator written for each class.
   87747             : 
   87748             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   87749             :     // User wants multi-thread support and POSIX threads are available.
   87750             : #   include <pthread.h>
   87751             :     static pthread_mutex_t SgStaticAssertionDeclaration_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   87752             : #else
   87753             :      // Cause synchronization to be skipped.
   87754             : #    ifndef ALLOC_MUTEX
   87755             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   87756             : #    endif
   87757             : #    ifdef _REENTRANT
   87758             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   87759             : #       ifdef _MSC_VER
   87760             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   87761             : #       else
   87762             : #           warning "POSIX threads are not available; synchronization being skipped"
   87763             : #       endif
   87764             : #    endif
   87765             : #endif
   87766             : 
   87767             : #ifndef ROSE_ALLOC_TRACE
   87768             : #  define ROSE_ALLOC_TRACE 0
   87769             : #endif
   87770             : 
   87771             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   87772             : #define ROSE_ALLOC_TRACE_CNT
   87773             : #include "memory-pool-snapshot.h"
   87774             : unsigned long alloc_trace_cnt = 0;
   87775             : #endif
   87776             : 
   87777             : #if ROSE_ALLOC_TRACE
   87778             : const unsigned SgStaticAssertionDeclaration::pool_size = 5;
   87779             : #else
   87780             : const unsigned SgStaticAssertionDeclaration::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   87781             : #endif
   87782             : 
   87783             : #ifndef ROSE_ALLOC_MEMSET
   87784             : #  define ROSE_ALLOC_MEMSET 0
   87785             : #endif
   87786             : 
   87787             : #ifndef ROSE_PEDANTIC_ALLOC
   87788             : #  define ROSE_PEDANTIC_ALLOC 0
   87789             : #endif
   87790             : 
   87791             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   87792             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   87793             : #endif
   87794             : 
   87795             : #if !defined(SGNODE__ALL_POOLS)
   87796             : #define SGNODE__ALL_POOLS
   87797             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   87798             : #endif
   87799             : 
   87800             : SgStaticAssertionDeclaration* SgStaticAssertionDeclaration::next_node = nullptr;
   87801             : std::vector<unsigned char*> SgStaticAssertionDeclaration::pools;
   87802             : 
   87803             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   87804             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   87805             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   87806             : // around this macro definition rather than each use).
   87807             : #ifndef ALLOC_MUTEX
   87808             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   87809             :         do {                                                                     \
   87810             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   87811             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   87812             :                 abort();                                                         \
   87813             :             }                                                                    \
   87814             :         } while (0);
   87815             : #endif
   87816             : 
   87817             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   87818             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   87819             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   87820             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   87821             : 
   87822             : /*! \brief New operator for SgStaticAssertionDeclaration.
   87823             : 
   87824             :    This new operator implements memory pools to provide most efficent 
   87825             :    use of the heap within construction of large ASTs.
   87826             : 
   87827             : \internal The new and delete operators use the lower level C malloc/free
   87828             :    function calls for performance and to make sure that mixing of malloc/free
   87829             :    and new/delete by the used can be caught more readily.  This may change
   87830             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   87831             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   87832             :    deallocate memory allocated using ROSE_MALLOC.
   87833             : */
   87834         170 : void *SgStaticAssertionDeclaration::operator new ( size_t Size )
   87835             : {
   87836             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   87837             :      * returning or throwing an exception. */
   87838         170 :     ALLOC_MUTEX(SgStaticAssertionDeclaration, lock);
   87839             : 
   87840             : #if ROSE_ALLOC_TRACE == 2
   87841             : //    printf("SgStaticAssertionDeclaration::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgStaticAssertionDeclaration::next_node);
   87842             : #endif
   87843             : 
   87844             : #if USE_CPP_NEW_DELETE_OPERATORS
   87845             :     void *mem = ROSE_MALLOC(Size);
   87846             :     ALLOC_MUTEX(SgStaticAssertionDeclaration, unlock);
   87847             :     return mem;
   87848             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   87849             : #if ROSE_PEDANTIC_ALLOC
   87850             :     ROSE_ASSERT(Size == sizeof(SgStaticAssertionDeclaration));
   87851             : #else
   87852         170 :     if (Size != sizeof(SgStaticAssertionDeclaration)) {
   87853           0 :       void * object = ROSE_MALLOC(Size);
   87854           0 :       ALLOC_MUTEX(SgStaticAssertionDeclaration, unlock);
   87855             :       return object;
   87856             :     }
   87857             : #endif
   87858             : 
   87859         170 :     if (SgStaticAssertionDeclaration::next_node == nullptr) {
   87860          10 :         SgStaticAssertionDeclaration * alloc = (SgStaticAssertionDeclaration*) ROSE_MALLOC ( SgStaticAssertionDeclaration::pool_size * sizeof(SgStaticAssertionDeclaration) );
   87861          10 :         ROSE_ASSERT(alloc != nullptr);
   87862             : 
   87863             : #if ROSE_ALLOC_TRACE == 2
   87864             : //        printf("SgStaticAssertionDeclaration::alloc\n  block[%zi] = [ %p , %p [\n", SgStaticAssertionDeclaration::pools.size(), alloc, alloc + SgStaticAssertionDeclaration::pool_size);
   87865             : #endif
   87866             : 
   87867             : #if ROSE_ALLOC_MEMSET == 1
   87868             : #elif ROSE_ALLOC_MEMSET == 2
   87869             :         memset(alloc, 0x00, SgStaticAssertionDeclaration::pool_size * sizeof(SgStaticAssertionDeclaration));
   87870             : #elif ROSE_ALLOC_MEMSET == 3
   87871             :         memset(alloc, 0xAA, SgStaticAssertionDeclaration::pool_size * sizeof(SgStaticAssertionDeclaration));
   87872             : #endif
   87873       20000 :         for (unsigned i=0; i < SgStaticAssertionDeclaration::pool_size-1; i++) {
   87874       19990 :           alloc[i].p_freepointer = &(alloc[i+1]);
   87875             :         }
   87876          10 :         alloc[SgStaticAssertionDeclaration::pool_size-1].p_freepointer = nullptr;
   87877             : 
   87878          10 :         SgStaticAssertionDeclaration::pools.push_back ( (unsigned char *) alloc );
   87879          10 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgStaticAssertionDeclaration::pool_size * sizeof(SgStaticAssertionDeclaration), V_SgStaticAssertionDeclaration ) );
   87880          10 :         SgStaticAssertionDeclaration::next_node = alloc;
   87881             :     }
   87882         170 :     ROSE_ASSERT(SgStaticAssertionDeclaration::next_node != nullptr);
   87883             : 
   87884         170 :     SgStaticAssertionDeclaration * object = SgStaticAssertionDeclaration::next_node;
   87885         170 :     SgStaticAssertionDeclaration::next_node = (SgStaticAssertionDeclaration*)(object->p_freepointer);
   87886             : 
   87887             : #if ROSE_ALLOC_TRACE == 2
   87888             :     printf("SgStaticAssertionDeclaration::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgStaticAssertionDeclaration::next_node);
   87889             : #endif
   87890             : 
   87891         170 :     SgNode * fp = object->p_freepointer;
   87892             : #if ROSE_ALLOC_MEMSET == 1
   87893             : #elif ROSE_ALLOC_MEMSET == 2
   87894             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgStaticAssertionDeclaration) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   87895             : #elif ROSE_ALLOC_MEMSET == 3
   87896             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgStaticAssertionDeclaration) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   87897             : #endif
   87898         170 :     object->p_freepointer = fp;
   87899             : 
   87900             : #if ROSE_ALLOC_TRACE == 2
   87901             : //    printf("SgStaticAssertionDeclaration::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgStaticAssertionDeclaration::next_node);
   87902             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   87903             :     Rose::MemPool::snapshot(oss.str());
   87904             :     alloc_trace_cnt++;
   87905             : #endif
   87906             : 
   87907         170 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   87908             : 
   87909         170 :     ALLOC_MUTEX(SgStaticAssertionDeclaration, unlock);
   87910             : 
   87911             :     return object;
   87912             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   87913             : }
   87914             : 
   87915             : 
   87916             : 
   87917             : /*! \brief Delete operator for SgStaticAssertionDeclaration.
   87918             : 
   87919             :    This delete operator implements deallocation using memory pools to 
   87920             :    provide most efficent use of the heap within construction of large ASTs.
   87921             : 
   87922             : \internal The new and delete operators use the lower level C malloc/free
   87923             :    function calls for performance and to make sure that mixing of malloc/free
   87924             :    and new/delete by the used can be caught more readily.  This may change
   87925             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   87926             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   87927             :    deallocate memory allocated using ROSE_MALLOC.
   87928             : */
   87929          28 : void SgStaticAssertionDeclaration::operator delete(void *Pointer, size_t Size)
   87930             : {
   87931             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   87932             :      * or throwing an exception. */
   87933          28 :     ALLOC_MUTEX(SgStaticAssertionDeclaration, lock);
   87934             : 
   87935             : #if USE_CPP_NEW_DELETE_OPERATORS
   87936             :     ROSE_FREE(Pointer);
   87937             : #else
   87938             : #if ROSE_PEDANTIC_ALLOC
   87939             :     ROSE_ASSERT(Size == sizeof(SgStaticAssertionDeclaration));
   87940             : #else
   87941          28 :     if (Size != sizeof(SgStaticAssertionDeclaration)) {
   87942           0 :       ROSE_FREE(Pointer);
   87943           0 :       ALLOC_MUTEX(SgStaticAssertionDeclaration, unlock);
   87944             :       return;
   87945             :     }
   87946             : #endif
   87947             : 
   87948          28 :     SgStaticAssertionDeclaration * object = (SgStaticAssertionDeclaration*) Pointer;
   87949          28 :     ROSE_ASSERT(object != nullptr);
   87950             : 
   87951             : #if ROSE_ALLOC_TRACE == 2
   87952             : //  printf("SgStaticAssertionDeclaration::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgStaticAssertionDeclaration::next_node);
   87953             :     printf("SgStaticAssertionDeclaration::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgStaticAssertionDeclaration::next_node);
   87954             : #endif
   87955             : 
   87956             : #if ROSE_PEDANTIC_ALLOC
   87957             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   87958             : #endif
   87959             : 
   87960             : #if ROSE_ALLOC_MEMSET == 1
   87961             : #elif ROSE_ALLOC_MEMSET == 2
   87962             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgStaticAssertionDeclaration) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   87963             : #elif ROSE_ALLOC_MEMSET == 3
   87964             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgStaticAssertionDeclaration) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   87965             : #endif
   87966             : 
   87967             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   87968             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   87969             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   87970             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   87971             : #else
   87972          28 :     object->p_freepointer = SgStaticAssertionDeclaration::next_node;
   87973          28 :     SgStaticAssertionDeclaration::next_node = object;
   87974             : #endif
   87975             : 
   87976             : #if ROSE_ALLOC_TRACE == 2
   87977             : //  printf("SgStaticAssertionDeclaration::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgStaticAssertionDeclaration::next_node);
   87978             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   87979             :     Rose::MemPool::snapshot(oss.str());
   87980             :     alloc_trace_cnt++;
   87981             : #endif
   87982             : 
   87983             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   87984             : 
   87985          28 :     ALLOC_MUTEX(SgStaticAssertionDeclaration, unlock);
   87986             : }
   87987             : 
   87988             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   87989             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   87990             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   87991             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   87992             : // Also, note comment below from Robb (copied from the Common.code file).
   87993             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   87994             : //
   87995             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   87996             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   87997             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   87998             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   87999             : #if 0
   88000             : void SgStaticAssertionDeclaration::operator delete(void* pointer) { SgStaticAssertionDeclaration::operator delete (pointer, sizeof(SgStaticAssertionDeclaration)); };
   88001             : #endif
   88002             : /* #line 88003 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   88003             : 
   88004             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   88005             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   88006             : // obviously imply C++.
   88007             : 
   88008             : // This implements the support within ROSE for memory pools.  Memory pools
   88009             : // support the most condensed usage of memory within the construction of
   88010             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   88011             : // by a new operator written for each class.
   88012             : 
   88013             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   88014             :     // User wants multi-thread support and POSIX threads are available.
   88015             : #   include <pthread.h>
   88016             :     static pthread_mutex_t SgOmpDeclareSimdStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   88017             : #else
   88018             :      // Cause synchronization to be skipped.
   88019             : #    ifndef ALLOC_MUTEX
   88020             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   88021             : #    endif
   88022             : #    ifdef _REENTRANT
   88023             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   88024             : #       ifdef _MSC_VER
   88025             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   88026             : #       else
   88027             : #           warning "POSIX threads are not available; synchronization being skipped"
   88028             : #       endif
   88029             : #    endif
   88030             : #endif
   88031             : 
   88032             : #ifndef ROSE_ALLOC_TRACE
   88033             : #  define ROSE_ALLOC_TRACE 0
   88034             : #endif
   88035             : 
   88036             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   88037             : #define ROSE_ALLOC_TRACE_CNT
   88038             : #include "memory-pool-snapshot.h"
   88039             : unsigned long alloc_trace_cnt = 0;
   88040             : #endif
   88041             : 
   88042             : #if ROSE_ALLOC_TRACE
   88043             : const unsigned SgOmpDeclareSimdStatement::pool_size = 5;
   88044             : #else
   88045             : const unsigned SgOmpDeclareSimdStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   88046             : #endif
   88047             : 
   88048             : #ifndef ROSE_ALLOC_MEMSET
   88049             : #  define ROSE_ALLOC_MEMSET 0
   88050             : #endif
   88051             : 
   88052             : #ifndef ROSE_PEDANTIC_ALLOC
   88053             : #  define ROSE_PEDANTIC_ALLOC 0
   88054             : #endif
   88055             : 
   88056             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   88057             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   88058             : #endif
   88059             : 
   88060             : #if !defined(SGNODE__ALL_POOLS)
   88061             : #define SGNODE__ALL_POOLS
   88062             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   88063             : #endif
   88064             : 
   88065             : SgOmpDeclareSimdStatement* SgOmpDeclareSimdStatement::next_node = nullptr;
   88066             : std::vector<unsigned char*> SgOmpDeclareSimdStatement::pools;
   88067             : 
   88068             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   88069             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   88070             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   88071             : // around this macro definition rather than each use).
   88072             : #ifndef ALLOC_MUTEX
   88073             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   88074             :         do {                                                                     \
   88075             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   88076             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   88077             :                 abort();                                                         \
   88078             :             }                                                                    \
   88079             :         } while (0);
   88080             : #endif
   88081             : 
   88082             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   88083             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   88084             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   88085             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   88086             : 
   88087             : /*! \brief New operator for SgOmpDeclareSimdStatement.
   88088             : 
   88089             :    This new operator implements memory pools to provide most efficent 
   88090             :    use of the heap within construction of large ASTs.
   88091             : 
   88092             : \internal The new and delete operators use the lower level C malloc/free
   88093             :    function calls for performance and to make sure that mixing of malloc/free
   88094             :    and new/delete by the used can be caught more readily.  This may change
   88095             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   88096             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   88097             :    deallocate memory allocated using ROSE_MALLOC.
   88098             : */
   88099           3 : void *SgOmpDeclareSimdStatement::operator new ( size_t Size )
   88100             : {
   88101             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   88102             :      * returning or throwing an exception. */
   88103           3 :     ALLOC_MUTEX(SgOmpDeclareSimdStatement, lock);
   88104             : 
   88105             : #if ROSE_ALLOC_TRACE == 2
   88106             : //    printf("SgOmpDeclareSimdStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgOmpDeclareSimdStatement::next_node);
   88107             : #endif
   88108             : 
   88109             : #if USE_CPP_NEW_DELETE_OPERATORS
   88110             :     void *mem = ROSE_MALLOC(Size);
   88111             :     ALLOC_MUTEX(SgOmpDeclareSimdStatement, unlock);
   88112             :     return mem;
   88113             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   88114             : #if ROSE_PEDANTIC_ALLOC
   88115             :     ROSE_ASSERT(Size == sizeof(SgOmpDeclareSimdStatement));
   88116             : #else
   88117           3 :     if (Size != sizeof(SgOmpDeclareSimdStatement)) {
   88118           0 :       void * object = ROSE_MALLOC(Size);
   88119           0 :       ALLOC_MUTEX(SgOmpDeclareSimdStatement, unlock);
   88120             :       return object;
   88121             :     }
   88122             : #endif
   88123             : 
   88124           3 :     if (SgOmpDeclareSimdStatement::next_node == nullptr) {
   88125           1 :         SgOmpDeclareSimdStatement * alloc = (SgOmpDeclareSimdStatement*) ROSE_MALLOC ( SgOmpDeclareSimdStatement::pool_size * sizeof(SgOmpDeclareSimdStatement) );
   88126           1 :         ROSE_ASSERT(alloc != nullptr);
   88127             : 
   88128             : #if ROSE_ALLOC_TRACE == 2
   88129             : //        printf("SgOmpDeclareSimdStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgOmpDeclareSimdStatement::pools.size(), alloc, alloc + SgOmpDeclareSimdStatement::pool_size);
   88130             : #endif
   88131             : 
   88132             : #if ROSE_ALLOC_MEMSET == 1
   88133             : #elif ROSE_ALLOC_MEMSET == 2
   88134             :         memset(alloc, 0x00, SgOmpDeclareSimdStatement::pool_size * sizeof(SgOmpDeclareSimdStatement));
   88135             : #elif ROSE_ALLOC_MEMSET == 3
   88136             :         memset(alloc, 0xAA, SgOmpDeclareSimdStatement::pool_size * sizeof(SgOmpDeclareSimdStatement));
   88137             : #endif
   88138        2000 :         for (unsigned i=0; i < SgOmpDeclareSimdStatement::pool_size-1; i++) {
   88139        1999 :           alloc[i].p_freepointer = &(alloc[i+1]);
   88140             :         }
   88141           1 :         alloc[SgOmpDeclareSimdStatement::pool_size-1].p_freepointer = nullptr;
   88142             : 
   88143           1 :         SgOmpDeclareSimdStatement::pools.push_back ( (unsigned char *) alloc );
   88144           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgOmpDeclareSimdStatement::pool_size * sizeof(SgOmpDeclareSimdStatement), V_SgOmpDeclareSimdStatement ) );
   88145           1 :         SgOmpDeclareSimdStatement::next_node = alloc;
   88146             :     }
   88147           3 :     ROSE_ASSERT(SgOmpDeclareSimdStatement::next_node != nullptr);
   88148             : 
   88149           3 :     SgOmpDeclareSimdStatement * object = SgOmpDeclareSimdStatement::next_node;
   88150           3 :     SgOmpDeclareSimdStatement::next_node = (SgOmpDeclareSimdStatement*)(object->p_freepointer);
   88151             : 
   88152             : #if ROSE_ALLOC_TRACE == 2
   88153             :     printf("SgOmpDeclareSimdStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpDeclareSimdStatement::next_node);
   88154             : #endif
   88155             : 
   88156           3 :     SgNode * fp = object->p_freepointer;
   88157             : #if ROSE_ALLOC_MEMSET == 1
   88158             : #elif ROSE_ALLOC_MEMSET == 2
   88159             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpDeclareSimdStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   88160             : #elif ROSE_ALLOC_MEMSET == 3
   88161             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgOmpDeclareSimdStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   88162             : #endif
   88163           3 :     object->p_freepointer = fp;
   88164             : 
   88165             : #if ROSE_ALLOC_TRACE == 2
   88166             : //    printf("SgOmpDeclareSimdStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpDeclareSimdStatement::next_node);
   88167             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   88168             :     Rose::MemPool::snapshot(oss.str());
   88169             :     alloc_trace_cnt++;
   88170             : #endif
   88171             : 
   88172           3 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   88173             : 
   88174           3 :     ALLOC_MUTEX(SgOmpDeclareSimdStatement, unlock);
   88175             : 
   88176             :     return object;
   88177             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   88178             : }
   88179             : 
   88180             : 
   88181             : 
   88182             : /*! \brief Delete operator for SgOmpDeclareSimdStatement.
   88183             : 
   88184             :    This delete operator implements deallocation using memory pools to 
   88185             :    provide most efficent use of the heap within construction of large ASTs.
   88186             : 
   88187             : \internal The new and delete operators use the lower level C malloc/free
   88188             :    function calls for performance and to make sure that mixing of malloc/free
   88189             :    and new/delete by the used can be caught more readily.  This may change
   88190             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   88191             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   88192             :    deallocate memory allocated using ROSE_MALLOC.
   88193             : */
   88194           0 : void SgOmpDeclareSimdStatement::operator delete(void *Pointer, size_t Size)
   88195             : {
   88196             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   88197             :      * or throwing an exception. */
   88198           0 :     ALLOC_MUTEX(SgOmpDeclareSimdStatement, lock);
   88199             : 
   88200             : #if USE_CPP_NEW_DELETE_OPERATORS
   88201             :     ROSE_FREE(Pointer);
   88202             : #else
   88203             : #if ROSE_PEDANTIC_ALLOC
   88204             :     ROSE_ASSERT(Size == sizeof(SgOmpDeclareSimdStatement));
   88205             : #else
   88206           0 :     if (Size != sizeof(SgOmpDeclareSimdStatement)) {
   88207           0 :       ROSE_FREE(Pointer);
   88208           0 :       ALLOC_MUTEX(SgOmpDeclareSimdStatement, unlock);
   88209             :       return;
   88210             :     }
   88211             : #endif
   88212             : 
   88213           0 :     SgOmpDeclareSimdStatement * object = (SgOmpDeclareSimdStatement*) Pointer;
   88214           0 :     ROSE_ASSERT(object != nullptr);
   88215             : 
   88216             : #if ROSE_ALLOC_TRACE == 2
   88217             : //  printf("SgOmpDeclareSimdStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpDeclareSimdStatement::next_node);
   88218             :     printf("SgOmpDeclareSimdStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpDeclareSimdStatement::next_node);
   88219             : #endif
   88220             : 
   88221             : #if ROSE_PEDANTIC_ALLOC
   88222             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   88223             : #endif
   88224             : 
   88225             : #if ROSE_ALLOC_MEMSET == 1
   88226             : #elif ROSE_ALLOC_MEMSET == 2
   88227             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpDeclareSimdStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   88228             : #elif ROSE_ALLOC_MEMSET == 3
   88229             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgOmpDeclareSimdStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   88230             : #endif
   88231             : 
   88232             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   88233             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   88234             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   88235             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   88236             : #else
   88237           0 :     object->p_freepointer = SgOmpDeclareSimdStatement::next_node;
   88238           0 :     SgOmpDeclareSimdStatement::next_node = object;
   88239             : #endif
   88240             : 
   88241             : #if ROSE_ALLOC_TRACE == 2
   88242             : //  printf("SgOmpDeclareSimdStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpDeclareSimdStatement::next_node);
   88243             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   88244             :     Rose::MemPool::snapshot(oss.str());
   88245             :     alloc_trace_cnt++;
   88246             : #endif
   88247             : 
   88248             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   88249             : 
   88250           0 :     ALLOC_MUTEX(SgOmpDeclareSimdStatement, unlock);
   88251             : }
   88252             : 
   88253             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   88254             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   88255             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   88256             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   88257             : // Also, note comment below from Robb (copied from the Common.code file).
   88258             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   88259             : //
   88260             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   88261             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   88262             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   88263             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   88264             : #if 0
   88265             : void SgOmpDeclareSimdStatement::operator delete(void* pointer) { SgOmpDeclareSimdStatement::operator delete (pointer, sizeof(SgOmpDeclareSimdStatement)); };
   88266             : #endif
   88267             : /* #line 88268 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   88268             : 
   88269             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   88270             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   88271             : // obviously imply C++.
   88272             : 
   88273             : // This implements the support within ROSE for memory pools.  Memory pools
   88274             : // support the most condensed usage of memory within the construction of
   88275             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   88276             : // by a new operator written for each class.
   88277             : 
   88278             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   88279             :     // User wants multi-thread support and POSIX threads are available.
   88280             : #   include <pthread.h>
   88281             :     static pthread_mutex_t SgMicrosoftAttributeDeclaration_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   88282             : #else
   88283             :      // Cause synchronization to be skipped.
   88284             : #    ifndef ALLOC_MUTEX
   88285             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   88286             : #    endif
   88287             : #    ifdef _REENTRANT
   88288             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   88289             : #       ifdef _MSC_VER
   88290             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   88291             : #       else
   88292             : #           warning "POSIX threads are not available; synchronization being skipped"
   88293             : #       endif
   88294             : #    endif
   88295             : #endif
   88296             : 
   88297             : #ifndef ROSE_ALLOC_TRACE
   88298             : #  define ROSE_ALLOC_TRACE 0
   88299             : #endif
   88300             : 
   88301             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   88302             : #define ROSE_ALLOC_TRACE_CNT
   88303             : #include "memory-pool-snapshot.h"
   88304             : unsigned long alloc_trace_cnt = 0;
   88305             : #endif
   88306             : 
   88307             : #if ROSE_ALLOC_TRACE
   88308             : const unsigned SgMicrosoftAttributeDeclaration::pool_size = 5;
   88309             : #else
   88310             : const unsigned SgMicrosoftAttributeDeclaration::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   88311             : #endif
   88312             : 
   88313             : #ifndef ROSE_ALLOC_MEMSET
   88314             : #  define ROSE_ALLOC_MEMSET 0
   88315             : #endif
   88316             : 
   88317             : #ifndef ROSE_PEDANTIC_ALLOC
   88318             : #  define ROSE_PEDANTIC_ALLOC 0
   88319             : #endif
   88320             : 
   88321             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   88322             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   88323             : #endif
   88324             : 
   88325             : #if !defined(SGNODE__ALL_POOLS)
   88326             : #define SGNODE__ALL_POOLS
   88327             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   88328             : #endif
   88329             : 
   88330             : SgMicrosoftAttributeDeclaration* SgMicrosoftAttributeDeclaration::next_node = nullptr;
   88331             : std::vector<unsigned char*> SgMicrosoftAttributeDeclaration::pools;
   88332             : 
   88333             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   88334             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   88335             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   88336             : // around this macro definition rather than each use).
   88337             : #ifndef ALLOC_MUTEX
   88338             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   88339             :         do {                                                                     \
   88340             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   88341             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   88342             :                 abort();                                                         \
   88343             :             }                                                                    \
   88344             :         } while (0);
   88345             : #endif
   88346             : 
   88347             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   88348             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   88349             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   88350             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   88351             : 
   88352             : /*! \brief New operator for SgMicrosoftAttributeDeclaration.
   88353             : 
   88354             :    This new operator implements memory pools to provide most efficent 
   88355             :    use of the heap within construction of large ASTs.
   88356             : 
   88357             : \internal The new and delete operators use the lower level C malloc/free
   88358             :    function calls for performance and to make sure that mixing of malloc/free
   88359             :    and new/delete by the used can be caught more readily.  This may change
   88360             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   88361             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   88362             :    deallocate memory allocated using ROSE_MALLOC.
   88363             : */
   88364           0 : void *SgMicrosoftAttributeDeclaration::operator new ( size_t Size )
   88365             : {
   88366             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   88367             :      * returning or throwing an exception. */
   88368           0 :     ALLOC_MUTEX(SgMicrosoftAttributeDeclaration, lock);
   88369             : 
   88370             : #if ROSE_ALLOC_TRACE == 2
   88371             : //    printf("SgMicrosoftAttributeDeclaration::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgMicrosoftAttributeDeclaration::next_node);
   88372             : #endif
   88373             : 
   88374             : #if USE_CPP_NEW_DELETE_OPERATORS
   88375             :     void *mem = ROSE_MALLOC(Size);
   88376             :     ALLOC_MUTEX(SgMicrosoftAttributeDeclaration, unlock);
   88377             :     return mem;
   88378             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   88379             : #if ROSE_PEDANTIC_ALLOC
   88380             :     ROSE_ASSERT(Size == sizeof(SgMicrosoftAttributeDeclaration));
   88381             : #else
   88382           0 :     if (Size != sizeof(SgMicrosoftAttributeDeclaration)) {
   88383           0 :       void * object = ROSE_MALLOC(Size);
   88384           0 :       ALLOC_MUTEX(SgMicrosoftAttributeDeclaration, unlock);
   88385             :       return object;
   88386             :     }
   88387             : #endif
   88388             : 
   88389           0 :     if (SgMicrosoftAttributeDeclaration::next_node == nullptr) {
   88390           0 :         SgMicrosoftAttributeDeclaration * alloc = (SgMicrosoftAttributeDeclaration*) ROSE_MALLOC ( SgMicrosoftAttributeDeclaration::pool_size * sizeof(SgMicrosoftAttributeDeclaration) );
   88391           0 :         ROSE_ASSERT(alloc != nullptr);
   88392             : 
   88393             : #if ROSE_ALLOC_TRACE == 2
   88394             : //        printf("SgMicrosoftAttributeDeclaration::alloc\n  block[%zi] = [ %p , %p [\n", SgMicrosoftAttributeDeclaration::pools.size(), alloc, alloc + SgMicrosoftAttributeDeclaration::pool_size);
   88395             : #endif
   88396             : 
   88397             : #if ROSE_ALLOC_MEMSET == 1
   88398             : #elif ROSE_ALLOC_MEMSET == 2
   88399             :         memset(alloc, 0x00, SgMicrosoftAttributeDeclaration::pool_size * sizeof(SgMicrosoftAttributeDeclaration));
   88400             : #elif ROSE_ALLOC_MEMSET == 3
   88401             :         memset(alloc, 0xAA, SgMicrosoftAttributeDeclaration::pool_size * sizeof(SgMicrosoftAttributeDeclaration));
   88402             : #endif
   88403           0 :         for (unsigned i=0; i < SgMicrosoftAttributeDeclaration::pool_size-1; i++) {
   88404           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
   88405             :         }
   88406           0 :         alloc[SgMicrosoftAttributeDeclaration::pool_size-1].p_freepointer = nullptr;
   88407             : 
   88408           0 :         SgMicrosoftAttributeDeclaration::pools.push_back ( (unsigned char *) alloc );
   88409           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgMicrosoftAttributeDeclaration::pool_size * sizeof(SgMicrosoftAttributeDeclaration), V_SgMicrosoftAttributeDeclaration ) );
   88410           0 :         SgMicrosoftAttributeDeclaration::next_node = alloc;
   88411             :     }
   88412           0 :     ROSE_ASSERT(SgMicrosoftAttributeDeclaration::next_node != nullptr);
   88413             : 
   88414           0 :     SgMicrosoftAttributeDeclaration * object = SgMicrosoftAttributeDeclaration::next_node;
   88415           0 :     SgMicrosoftAttributeDeclaration::next_node = (SgMicrosoftAttributeDeclaration*)(object->p_freepointer);
   88416             : 
   88417             : #if ROSE_ALLOC_TRACE == 2
   88418             :     printf("SgMicrosoftAttributeDeclaration::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgMicrosoftAttributeDeclaration::next_node);
   88419             : #endif
   88420             : 
   88421           0 :     SgNode * fp = object->p_freepointer;
   88422             : #if ROSE_ALLOC_MEMSET == 1
   88423             : #elif ROSE_ALLOC_MEMSET == 2
   88424             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgMicrosoftAttributeDeclaration) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   88425             : #elif ROSE_ALLOC_MEMSET == 3
   88426             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgMicrosoftAttributeDeclaration) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   88427             : #endif
   88428           0 :     object->p_freepointer = fp;
   88429             : 
   88430             : #if ROSE_ALLOC_TRACE == 2
   88431             : //    printf("SgMicrosoftAttributeDeclaration::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgMicrosoftAttributeDeclaration::next_node);
   88432             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   88433             :     Rose::MemPool::snapshot(oss.str());
   88434             :     alloc_trace_cnt++;
   88435             : #endif
   88436             : 
   88437           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   88438             : 
   88439           0 :     ALLOC_MUTEX(SgMicrosoftAttributeDeclaration, unlock);
   88440             : 
   88441             :     return object;
   88442             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   88443             : }
   88444             : 
   88445             : 
   88446             : 
   88447             : /*! \brief Delete operator for SgMicrosoftAttributeDeclaration.
   88448             : 
   88449             :    This delete operator implements deallocation using memory pools to 
   88450             :    provide most efficent use of the heap within construction of large ASTs.
   88451             : 
   88452             : \internal The new and delete operators use the lower level C malloc/free
   88453             :    function calls for performance and to make sure that mixing of malloc/free
   88454             :    and new/delete by the used can be caught more readily.  This may change
   88455             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   88456             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   88457             :    deallocate memory allocated using ROSE_MALLOC.
   88458             : */
   88459           0 : void SgMicrosoftAttributeDeclaration::operator delete(void *Pointer, size_t Size)
   88460             : {
   88461             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   88462             :      * or throwing an exception. */
   88463           0 :     ALLOC_MUTEX(SgMicrosoftAttributeDeclaration, lock);
   88464             : 
   88465             : #if USE_CPP_NEW_DELETE_OPERATORS
   88466             :     ROSE_FREE(Pointer);
   88467             : #else
   88468             : #if ROSE_PEDANTIC_ALLOC
   88469             :     ROSE_ASSERT(Size == sizeof(SgMicrosoftAttributeDeclaration));
   88470             : #else
   88471           0 :     if (Size != sizeof(SgMicrosoftAttributeDeclaration)) {
   88472           0 :       ROSE_FREE(Pointer);
   88473           0 :       ALLOC_MUTEX(SgMicrosoftAttributeDeclaration, unlock);
   88474             :       return;
   88475             :     }
   88476             : #endif
   88477             : 
   88478           0 :     SgMicrosoftAttributeDeclaration * object = (SgMicrosoftAttributeDeclaration*) Pointer;
   88479           0 :     ROSE_ASSERT(object != nullptr);
   88480             : 
   88481             : #if ROSE_ALLOC_TRACE == 2
   88482             : //  printf("SgMicrosoftAttributeDeclaration::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgMicrosoftAttributeDeclaration::next_node);
   88483             :     printf("SgMicrosoftAttributeDeclaration::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgMicrosoftAttributeDeclaration::next_node);
   88484             : #endif
   88485             : 
   88486             : #if ROSE_PEDANTIC_ALLOC
   88487             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   88488             : #endif
   88489             : 
   88490             : #if ROSE_ALLOC_MEMSET == 1
   88491             : #elif ROSE_ALLOC_MEMSET == 2
   88492             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgMicrosoftAttributeDeclaration) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   88493             : #elif ROSE_ALLOC_MEMSET == 3
   88494             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgMicrosoftAttributeDeclaration) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   88495             : #endif
   88496             : 
   88497             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   88498             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   88499             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   88500             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   88501             : #else
   88502           0 :     object->p_freepointer = SgMicrosoftAttributeDeclaration::next_node;
   88503           0 :     SgMicrosoftAttributeDeclaration::next_node = object;
   88504             : #endif
   88505             : 
   88506             : #if ROSE_ALLOC_TRACE == 2
   88507             : //  printf("SgMicrosoftAttributeDeclaration::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgMicrosoftAttributeDeclaration::next_node);
   88508             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   88509             :     Rose::MemPool::snapshot(oss.str());
   88510             :     alloc_trace_cnt++;
   88511             : #endif
   88512             : 
   88513             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   88514             : 
   88515           0 :     ALLOC_MUTEX(SgMicrosoftAttributeDeclaration, unlock);
   88516             : }
   88517             : 
   88518             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   88519             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   88520             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   88521             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   88522             : // Also, note comment below from Robb (copied from the Common.code file).
   88523             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   88524             : //
   88525             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   88526             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   88527             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   88528             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   88529             : #if 0
   88530             : void SgMicrosoftAttributeDeclaration::operator delete(void* pointer) { SgMicrosoftAttributeDeclaration::operator delete (pointer, sizeof(SgMicrosoftAttributeDeclaration)); };
   88531             : #endif
   88532             : /* #line 88533 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   88533             : 
   88534             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   88535             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   88536             : // obviously imply C++.
   88537             : 
   88538             : // This implements the support within ROSE for memory pools.  Memory pools
   88539             : // support the most condensed usage of memory within the construction of
   88540             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   88541             : // by a new operator written for each class.
   88542             : 
   88543             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   88544             :     // User wants multi-thread support and POSIX threads are available.
   88545             : #   include <pthread.h>
   88546             :     static pthread_mutex_t SgNonrealDecl_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   88547             : #else
   88548             :      // Cause synchronization to be skipped.
   88549             : #    ifndef ALLOC_MUTEX
   88550             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   88551             : #    endif
   88552             : #    ifdef _REENTRANT
   88553             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   88554             : #       ifdef _MSC_VER
   88555             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   88556             : #       else
   88557             : #           warning "POSIX threads are not available; synchronization being skipped"
   88558             : #       endif
   88559             : #    endif
   88560             : #endif
   88561             : 
   88562             : #ifndef ROSE_ALLOC_TRACE
   88563             : #  define ROSE_ALLOC_TRACE 0
   88564             : #endif
   88565             : 
   88566             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   88567             : #define ROSE_ALLOC_TRACE_CNT
   88568             : #include "memory-pool-snapshot.h"
   88569             : unsigned long alloc_trace_cnt = 0;
   88570             : #endif
   88571             : 
   88572             : #if ROSE_ALLOC_TRACE
   88573             : const unsigned SgNonrealDecl::pool_size = 5;
   88574             : #else
   88575             : const unsigned SgNonrealDecl::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   88576             : #endif
   88577             : 
   88578             : #ifndef ROSE_ALLOC_MEMSET
   88579             : #  define ROSE_ALLOC_MEMSET 0
   88580             : #endif
   88581             : 
   88582             : #ifndef ROSE_PEDANTIC_ALLOC
   88583             : #  define ROSE_PEDANTIC_ALLOC 0
   88584             : #endif
   88585             : 
   88586             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   88587             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   88588             : #endif
   88589             : 
   88590             : #if !defined(SGNODE__ALL_POOLS)
   88591             : #define SGNODE__ALL_POOLS
   88592             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   88593             : #endif
   88594             : 
   88595             : SgNonrealDecl* SgNonrealDecl::next_node = nullptr;
   88596             : std::vector<unsigned char*> SgNonrealDecl::pools;
   88597             : 
   88598             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   88599             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   88600             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   88601             : // around this macro definition rather than each use).
   88602             : #ifndef ALLOC_MUTEX
   88603             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   88604             :         do {                                                                     \
   88605             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   88606             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   88607             :                 abort();                                                         \
   88608             :             }                                                                    \
   88609             :         } while (0);
   88610             : #endif
   88611             : 
   88612             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   88613             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   88614             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   88615             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   88616             : 
   88617             : /*! \brief New operator for SgNonrealDecl.
   88618             : 
   88619             :    This new operator implements memory pools to provide most efficent 
   88620             :    use of the heap within construction of large ASTs.
   88621             : 
   88622             : \internal The new and delete operators use the lower level C malloc/free
   88623             :    function calls for performance and to make sure that mixing of malloc/free
   88624             :    and new/delete by the used can be caught more readily.  This may change
   88625             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   88626             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   88627             :    deallocate memory allocated using ROSE_MALLOC.
   88628             : */
   88629       54405 : void *SgNonrealDecl::operator new ( size_t Size )
   88630             : {
   88631             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   88632             :      * returning or throwing an exception. */
   88633       54405 :     ALLOC_MUTEX(SgNonrealDecl, lock);
   88634             : 
   88635             : #if ROSE_ALLOC_TRACE == 2
   88636             : //    printf("SgNonrealDecl::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgNonrealDecl::next_node);
   88637             : #endif
   88638             : 
   88639             : #if USE_CPP_NEW_DELETE_OPERATORS
   88640             :     void *mem = ROSE_MALLOC(Size);
   88641             :     ALLOC_MUTEX(SgNonrealDecl, unlock);
   88642             :     return mem;
   88643             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   88644             : #if ROSE_PEDANTIC_ALLOC
   88645             :     ROSE_ASSERT(Size == sizeof(SgNonrealDecl));
   88646             : #else
   88647       54405 :     if (Size != sizeof(SgNonrealDecl)) {
   88648           0 :       void * object = ROSE_MALLOC(Size);
   88649           0 :       ALLOC_MUTEX(SgNonrealDecl, unlock);
   88650             :       return object;
   88651             :     }
   88652             : #endif
   88653             : 
   88654       54405 :     if (SgNonrealDecl::next_node == nullptr) {
   88655          31 :         SgNonrealDecl * alloc = (SgNonrealDecl*) ROSE_MALLOC ( SgNonrealDecl::pool_size * sizeof(SgNonrealDecl) );
   88656          31 :         ROSE_ASSERT(alloc != nullptr);
   88657             : 
   88658             : #if ROSE_ALLOC_TRACE == 2
   88659             : //        printf("SgNonrealDecl::alloc\n  block[%zi] = [ %p , %p [\n", SgNonrealDecl::pools.size(), alloc, alloc + SgNonrealDecl::pool_size);
   88660             : #endif
   88661             : 
   88662             : #if ROSE_ALLOC_MEMSET == 1
   88663             : #elif ROSE_ALLOC_MEMSET == 2
   88664             :         memset(alloc, 0x00, SgNonrealDecl::pool_size * sizeof(SgNonrealDecl));
   88665             : #elif ROSE_ALLOC_MEMSET == 3
   88666             :         memset(alloc, 0xAA, SgNonrealDecl::pool_size * sizeof(SgNonrealDecl));
   88667             : #endif
   88668       62000 :         for (unsigned i=0; i < SgNonrealDecl::pool_size-1; i++) {
   88669       61969 :           alloc[i].p_freepointer = &(alloc[i+1]);
   88670             :         }
   88671          31 :         alloc[SgNonrealDecl::pool_size-1].p_freepointer = nullptr;
   88672             : 
   88673          31 :         SgNonrealDecl::pools.push_back ( (unsigned char *) alloc );
   88674          31 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgNonrealDecl::pool_size * sizeof(SgNonrealDecl), V_SgNonrealDecl ) );
   88675          31 :         SgNonrealDecl::next_node = alloc;
   88676             :     }
   88677       54405 :     ROSE_ASSERT(SgNonrealDecl::next_node != nullptr);
   88678             : 
   88679       54405 :     SgNonrealDecl * object = SgNonrealDecl::next_node;
   88680       54405 :     SgNonrealDecl::next_node = (SgNonrealDecl*)(object->p_freepointer);
   88681             : 
   88682             : #if ROSE_ALLOC_TRACE == 2
   88683             :     printf("SgNonrealDecl::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgNonrealDecl::next_node);
   88684             : #endif
   88685             : 
   88686       54405 :     SgNode * fp = object->p_freepointer;
   88687             : #if ROSE_ALLOC_MEMSET == 1
   88688             : #elif ROSE_ALLOC_MEMSET == 2
   88689             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgNonrealDecl) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   88690             : #elif ROSE_ALLOC_MEMSET == 3
   88691             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgNonrealDecl) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   88692             : #endif
   88693       54405 :     object->p_freepointer = fp;
   88694             : 
   88695             : #if ROSE_ALLOC_TRACE == 2
   88696             : //    printf("SgNonrealDecl::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgNonrealDecl::next_node);
   88697             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   88698             :     Rose::MemPool::snapshot(oss.str());
   88699             :     alloc_trace_cnt++;
   88700             : #endif
   88701             : 
   88702       54405 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   88703             : 
   88704       54405 :     ALLOC_MUTEX(SgNonrealDecl, unlock);
   88705             : 
   88706             :     return object;
   88707             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   88708             : }
   88709             : 
   88710             : 
   88711             : 
   88712             : /*! \brief Delete operator for SgNonrealDecl.
   88713             : 
   88714             :    This delete operator implements deallocation using memory pools to 
   88715             :    provide most efficent use of the heap within construction of large ASTs.
   88716             : 
   88717             : \internal The new and delete operators use the lower level C malloc/free
   88718             :    function calls for performance and to make sure that mixing of malloc/free
   88719             :    and new/delete by the used can be caught more readily.  This may change
   88720             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   88721             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   88722             :    deallocate memory allocated using ROSE_MALLOC.
   88723             : */
   88724       10160 : void SgNonrealDecl::operator delete(void *Pointer, size_t Size)
   88725             : {
   88726             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   88727             :      * or throwing an exception. */
   88728       10160 :     ALLOC_MUTEX(SgNonrealDecl, lock);
   88729             : 
   88730             : #if USE_CPP_NEW_DELETE_OPERATORS
   88731             :     ROSE_FREE(Pointer);
   88732             : #else
   88733             : #if ROSE_PEDANTIC_ALLOC
   88734             :     ROSE_ASSERT(Size == sizeof(SgNonrealDecl));
   88735             : #else
   88736       10160 :     if (Size != sizeof(SgNonrealDecl)) {
   88737           0 :       ROSE_FREE(Pointer);
   88738           0 :       ALLOC_MUTEX(SgNonrealDecl, unlock);
   88739             :       return;
   88740             :     }
   88741             : #endif
   88742             : 
   88743       10160 :     SgNonrealDecl * object = (SgNonrealDecl*) Pointer;
   88744       10160 :     ROSE_ASSERT(object != nullptr);
   88745             : 
   88746             : #if ROSE_ALLOC_TRACE == 2
   88747             : //  printf("SgNonrealDecl::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgNonrealDecl::next_node);
   88748             :     printf("SgNonrealDecl::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgNonrealDecl::next_node);
   88749             : #endif
   88750             : 
   88751             : #if ROSE_PEDANTIC_ALLOC
   88752             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   88753             : #endif
   88754             : 
   88755             : #if ROSE_ALLOC_MEMSET == 1
   88756             : #elif ROSE_ALLOC_MEMSET == 2
   88757             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgNonrealDecl) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   88758             : #elif ROSE_ALLOC_MEMSET == 3
   88759             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgNonrealDecl) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   88760             : #endif
   88761             : 
   88762             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   88763             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   88764             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   88765             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   88766             : #else
   88767       10160 :     object->p_freepointer = SgNonrealDecl::next_node;
   88768       10160 :     SgNonrealDecl::next_node = object;
   88769             : #endif
   88770             : 
   88771             : #if ROSE_ALLOC_TRACE == 2
   88772             : //  printf("SgNonrealDecl::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgNonrealDecl::next_node);
   88773             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   88774             :     Rose::MemPool::snapshot(oss.str());
   88775             :     alloc_trace_cnt++;
   88776             : #endif
   88777             : 
   88778             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   88779             : 
   88780       10160 :     ALLOC_MUTEX(SgNonrealDecl, unlock);
   88781             : }
   88782             : 
   88783             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   88784             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   88785             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   88786             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   88787             : // Also, note comment below from Robb (copied from the Common.code file).
   88788             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   88789             : //
   88790             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   88791             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   88792             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   88793             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   88794             : #if 0
   88795             : void SgNonrealDecl::operator delete(void* pointer) { SgNonrealDecl::operator delete (pointer, sizeof(SgNonrealDecl)); };
   88796             : #endif
   88797             : /* #line 88798 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   88798             : 
   88799             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   88800             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   88801             : // obviously imply C++.
   88802             : 
   88803             : // This implements the support within ROSE for memory pools.  Memory pools
   88804             : // support the most condensed usage of memory within the construction of
   88805             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   88806             : // by a new operator written for each class.
   88807             : 
   88808             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   88809             :     // User wants multi-thread support and POSIX threads are available.
   88810             : #   include <pthread.h>
   88811             :     static pthread_mutex_t SgEmptyDeclaration_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   88812             : #else
   88813             :      // Cause synchronization to be skipped.
   88814             : #    ifndef ALLOC_MUTEX
   88815             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   88816             : #    endif
   88817             : #    ifdef _REENTRANT
   88818             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   88819             : #       ifdef _MSC_VER
   88820             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   88821             : #       else
   88822             : #           warning "POSIX threads are not available; synchronization being skipped"
   88823             : #       endif
   88824             : #    endif
   88825             : #endif
   88826             : 
   88827             : #ifndef ROSE_ALLOC_TRACE
   88828             : #  define ROSE_ALLOC_TRACE 0
   88829             : #endif
   88830             : 
   88831             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   88832             : #define ROSE_ALLOC_TRACE_CNT
   88833             : #include "memory-pool-snapshot.h"
   88834             : unsigned long alloc_trace_cnt = 0;
   88835             : #endif
   88836             : 
   88837             : #if ROSE_ALLOC_TRACE
   88838             : const unsigned SgEmptyDeclaration::pool_size = 5;
   88839             : #else
   88840             : const unsigned SgEmptyDeclaration::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   88841             : #endif
   88842             : 
   88843             : #ifndef ROSE_ALLOC_MEMSET
   88844             : #  define ROSE_ALLOC_MEMSET 0
   88845             : #endif
   88846             : 
   88847             : #ifndef ROSE_PEDANTIC_ALLOC
   88848             : #  define ROSE_PEDANTIC_ALLOC 0
   88849             : #endif
   88850             : 
   88851             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   88852             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   88853             : #endif
   88854             : 
   88855             : #if !defined(SGNODE__ALL_POOLS)
   88856             : #define SGNODE__ALL_POOLS
   88857             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   88858             : #endif
   88859             : 
   88860             : SgEmptyDeclaration* SgEmptyDeclaration::next_node = nullptr;
   88861             : std::vector<unsigned char*> SgEmptyDeclaration::pools;
   88862             : 
   88863             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   88864             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   88865             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   88866             : // around this macro definition rather than each use).
   88867             : #ifndef ALLOC_MUTEX
   88868             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   88869             :         do {                                                                     \
   88870             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   88871             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   88872             :                 abort();                                                         \
   88873             :             }                                                                    \
   88874             :         } while (0);
   88875             : #endif
   88876             : 
   88877             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   88878             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   88879             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   88880             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   88881             : 
   88882             : /*! \brief New operator for SgEmptyDeclaration.
   88883             : 
   88884             :    This new operator implements memory pools to provide most efficent 
   88885             :    use of the heap within construction of large ASTs.
   88886             : 
   88887             : \internal The new and delete operators use the lower level C malloc/free
   88888             :    function calls for performance and to make sure that mixing of malloc/free
   88889             :    and new/delete by the used can be caught more readily.  This may change
   88890             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   88891             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   88892             :    deallocate memory allocated using ROSE_MALLOC.
   88893             : */
   88894           0 : void *SgEmptyDeclaration::operator new ( size_t Size )
   88895             : {
   88896             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   88897             :      * returning or throwing an exception. */
   88898           0 :     ALLOC_MUTEX(SgEmptyDeclaration, lock);
   88899             : 
   88900             : #if ROSE_ALLOC_TRACE == 2
   88901             : //    printf("SgEmptyDeclaration::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgEmptyDeclaration::next_node);
   88902             : #endif
   88903             : 
   88904             : #if USE_CPP_NEW_DELETE_OPERATORS
   88905             :     void *mem = ROSE_MALLOC(Size);
   88906             :     ALLOC_MUTEX(SgEmptyDeclaration, unlock);
   88907             :     return mem;
   88908             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   88909             : #if ROSE_PEDANTIC_ALLOC
   88910             :     ROSE_ASSERT(Size == sizeof(SgEmptyDeclaration));
   88911             : #else
   88912           0 :     if (Size != sizeof(SgEmptyDeclaration)) {
   88913           0 :       void * object = ROSE_MALLOC(Size);
   88914           0 :       ALLOC_MUTEX(SgEmptyDeclaration, unlock);
   88915             :       return object;
   88916             :     }
   88917             : #endif
   88918             : 
   88919           0 :     if (SgEmptyDeclaration::next_node == nullptr) {
   88920           0 :         SgEmptyDeclaration * alloc = (SgEmptyDeclaration*) ROSE_MALLOC ( SgEmptyDeclaration::pool_size * sizeof(SgEmptyDeclaration) );
   88921           0 :         ROSE_ASSERT(alloc != nullptr);
   88922             : 
   88923             : #if ROSE_ALLOC_TRACE == 2
   88924             : //        printf("SgEmptyDeclaration::alloc\n  block[%zi] = [ %p , %p [\n", SgEmptyDeclaration::pools.size(), alloc, alloc + SgEmptyDeclaration::pool_size);
   88925             : #endif
   88926             : 
   88927             : #if ROSE_ALLOC_MEMSET == 1
   88928             : #elif ROSE_ALLOC_MEMSET == 2
   88929             :         memset(alloc, 0x00, SgEmptyDeclaration::pool_size * sizeof(SgEmptyDeclaration));
   88930             : #elif ROSE_ALLOC_MEMSET == 3
   88931             :         memset(alloc, 0xAA, SgEmptyDeclaration::pool_size * sizeof(SgEmptyDeclaration));
   88932             : #endif
   88933           0 :         for (unsigned i=0; i < SgEmptyDeclaration::pool_size-1; i++) {
   88934           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
   88935             :         }
   88936           0 :         alloc[SgEmptyDeclaration::pool_size-1].p_freepointer = nullptr;
   88937             : 
   88938           0 :         SgEmptyDeclaration::pools.push_back ( (unsigned char *) alloc );
   88939           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgEmptyDeclaration::pool_size * sizeof(SgEmptyDeclaration), V_SgEmptyDeclaration ) );
   88940           0 :         SgEmptyDeclaration::next_node = alloc;
   88941             :     }
   88942           0 :     ROSE_ASSERT(SgEmptyDeclaration::next_node != nullptr);
   88943             : 
   88944           0 :     SgEmptyDeclaration * object = SgEmptyDeclaration::next_node;
   88945           0 :     SgEmptyDeclaration::next_node = (SgEmptyDeclaration*)(object->p_freepointer);
   88946             : 
   88947             : #if ROSE_ALLOC_TRACE == 2
   88948             :     printf("SgEmptyDeclaration::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgEmptyDeclaration::next_node);
   88949             : #endif
   88950             : 
   88951           0 :     SgNode * fp = object->p_freepointer;
   88952             : #if ROSE_ALLOC_MEMSET == 1
   88953             : #elif ROSE_ALLOC_MEMSET == 2
   88954             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgEmptyDeclaration) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   88955             : #elif ROSE_ALLOC_MEMSET == 3
   88956             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgEmptyDeclaration) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   88957             : #endif
   88958           0 :     object->p_freepointer = fp;
   88959             : 
   88960             : #if ROSE_ALLOC_TRACE == 2
   88961             : //    printf("SgEmptyDeclaration::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgEmptyDeclaration::next_node);
   88962             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   88963             :     Rose::MemPool::snapshot(oss.str());
   88964             :     alloc_trace_cnt++;
   88965             : #endif
   88966             : 
   88967           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   88968             : 
   88969           0 :     ALLOC_MUTEX(SgEmptyDeclaration, unlock);
   88970             : 
   88971             :     return object;
   88972             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   88973             : }
   88974             : 
   88975             : 
   88976             : 
   88977             : /*! \brief Delete operator for SgEmptyDeclaration.
   88978             : 
   88979             :    This delete operator implements deallocation using memory pools to 
   88980             :    provide most efficent use of the heap within construction of large ASTs.
   88981             : 
   88982             : \internal The new and delete operators use the lower level C malloc/free
   88983             :    function calls for performance and to make sure that mixing of malloc/free
   88984             :    and new/delete by the used can be caught more readily.  This may change
   88985             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   88986             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   88987             :    deallocate memory allocated using ROSE_MALLOC.
   88988             : */
   88989           0 : void SgEmptyDeclaration::operator delete(void *Pointer, size_t Size)
   88990             : {
   88991             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   88992             :      * or throwing an exception. */
   88993           0 :     ALLOC_MUTEX(SgEmptyDeclaration, lock);
   88994             : 
   88995             : #if USE_CPP_NEW_DELETE_OPERATORS
   88996             :     ROSE_FREE(Pointer);
   88997             : #else
   88998             : #if ROSE_PEDANTIC_ALLOC
   88999             :     ROSE_ASSERT(Size == sizeof(SgEmptyDeclaration));
   89000             : #else
   89001           0 :     if (Size != sizeof(SgEmptyDeclaration)) {
   89002           0 :       ROSE_FREE(Pointer);
   89003           0 :       ALLOC_MUTEX(SgEmptyDeclaration, unlock);
   89004             :       return;
   89005             :     }
   89006             : #endif
   89007             : 
   89008           0 :     SgEmptyDeclaration * object = (SgEmptyDeclaration*) Pointer;
   89009           0 :     ROSE_ASSERT(object != nullptr);
   89010             : 
   89011             : #if ROSE_ALLOC_TRACE == 2
   89012             : //  printf("SgEmptyDeclaration::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgEmptyDeclaration::next_node);
   89013             :     printf("SgEmptyDeclaration::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgEmptyDeclaration::next_node);
   89014             : #endif
   89015             : 
   89016             : #if ROSE_PEDANTIC_ALLOC
   89017             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   89018             : #endif
   89019             : 
   89020             : #if ROSE_ALLOC_MEMSET == 1
   89021             : #elif ROSE_ALLOC_MEMSET == 2
   89022             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgEmptyDeclaration) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   89023             : #elif ROSE_ALLOC_MEMSET == 3
   89024             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgEmptyDeclaration) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   89025             : #endif
   89026             : 
   89027             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   89028             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   89029             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   89030             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   89031             : #else
   89032           0 :     object->p_freepointer = SgEmptyDeclaration::next_node;
   89033           0 :     SgEmptyDeclaration::next_node = object;
   89034             : #endif
   89035             : 
   89036             : #if ROSE_ALLOC_TRACE == 2
   89037             : //  printf("SgEmptyDeclaration::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgEmptyDeclaration::next_node);
   89038             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   89039             :     Rose::MemPool::snapshot(oss.str());
   89040             :     alloc_trace_cnt++;
   89041             : #endif
   89042             : 
   89043             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   89044             : 
   89045           0 :     ALLOC_MUTEX(SgEmptyDeclaration, unlock);
   89046             : }
   89047             : 
   89048             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   89049             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   89050             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   89051             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   89052             : // Also, note comment below from Robb (copied from the Common.code file).
   89053             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   89054             : //
   89055             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   89056             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   89057             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   89058             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   89059             : #if 0
   89060             : void SgEmptyDeclaration::operator delete(void* pointer) { SgEmptyDeclaration::operator delete (pointer, sizeof(SgEmptyDeclaration)); };
   89061             : #endif
   89062             : /* #line 89063 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   89063             : 
   89064             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   89065             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   89066             : // obviously imply C++.
   89067             : 
   89068             : // This implements the support within ROSE for memory pools.  Memory pools
   89069             : // support the most condensed usage of memory within the construction of
   89070             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   89071             : // by a new operator written for each class.
   89072             : 
   89073             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   89074             :     // User wants multi-thread support and POSIX threads are available.
   89075             : #   include <pthread.h>
   89076             :     static pthread_mutex_t SgExprStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   89077             : #else
   89078             :      // Cause synchronization to be skipped.
   89079             : #    ifndef ALLOC_MUTEX
   89080             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   89081             : #    endif
   89082             : #    ifdef _REENTRANT
   89083             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   89084             : #       ifdef _MSC_VER
   89085             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   89086             : #       else
   89087             : #           warning "POSIX threads are not available; synchronization being skipped"
   89088             : #       endif
   89089             : #    endif
   89090             : #endif
   89091             : 
   89092             : #ifndef ROSE_ALLOC_TRACE
   89093             : #  define ROSE_ALLOC_TRACE 0
   89094             : #endif
   89095             : 
   89096             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   89097             : #define ROSE_ALLOC_TRACE_CNT
   89098             : #include "memory-pool-snapshot.h"
   89099             : unsigned long alloc_trace_cnt = 0;
   89100             : #endif
   89101             : 
   89102             : #if ROSE_ALLOC_TRACE
   89103             : const unsigned SgExprStatement::pool_size = 5;
   89104             : #else
   89105             : const unsigned SgExprStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   89106             : #endif
   89107             : 
   89108             : #ifndef ROSE_ALLOC_MEMSET
   89109             : #  define ROSE_ALLOC_MEMSET 0
   89110             : #endif
   89111             : 
   89112             : #ifndef ROSE_PEDANTIC_ALLOC
   89113             : #  define ROSE_PEDANTIC_ALLOC 0
   89114             : #endif
   89115             : 
   89116             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   89117             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   89118             : #endif
   89119             : 
   89120             : #if !defined(SGNODE__ALL_POOLS)
   89121             : #define SGNODE__ALL_POOLS
   89122             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   89123             : #endif
   89124             : 
   89125             : SgExprStatement* SgExprStatement::next_node = nullptr;
   89126             : std::vector<unsigned char*> SgExprStatement::pools;
   89127             : 
   89128             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   89129             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   89130             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   89131             : // around this macro definition rather than each use).
   89132             : #ifndef ALLOC_MUTEX
   89133             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   89134             :         do {                                                                     \
   89135             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   89136             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   89137             :                 abort();                                                         \
   89138             :             }                                                                    \
   89139             :         } while (0);
   89140             : #endif
   89141             : 
   89142             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   89143             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   89144             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   89145             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   89146             : 
   89147             : /*! \brief New operator for SgExprStatement.
   89148             : 
   89149             :    This new operator implements memory pools to provide most efficent 
   89150             :    use of the heap within construction of large ASTs.
   89151             : 
   89152             : \internal The new and delete operators use the lower level C malloc/free
   89153             :    function calls for performance and to make sure that mixing of malloc/free
   89154             :    and new/delete by the used can be caught more readily.  This may change
   89155             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   89156             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   89157             :    deallocate memory allocated using ROSE_MALLOC.
   89158             : */
   89159       26437 : void *SgExprStatement::operator new ( size_t Size )
   89160             : {
   89161             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   89162             :      * returning or throwing an exception. */
   89163       26437 :     ALLOC_MUTEX(SgExprStatement, lock);
   89164             : 
   89165             : #if ROSE_ALLOC_TRACE == 2
   89166             : //    printf("SgExprStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgExprStatement::next_node);
   89167             : #endif
   89168             : 
   89169             : #if USE_CPP_NEW_DELETE_OPERATORS
   89170             :     void *mem = ROSE_MALLOC(Size);
   89171             :     ALLOC_MUTEX(SgExprStatement, unlock);
   89172             :     return mem;
   89173             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   89174             : #if ROSE_PEDANTIC_ALLOC
   89175             :     ROSE_ASSERT(Size == sizeof(SgExprStatement));
   89176             : #else
   89177       26437 :     if (Size != sizeof(SgExprStatement)) {
   89178           0 :       void * object = ROSE_MALLOC(Size);
   89179           0 :       ALLOC_MUTEX(SgExprStatement, unlock);
   89180             :       return object;
   89181             :     }
   89182             : #endif
   89183             : 
   89184       26437 :     if (SgExprStatement::next_node == nullptr) {
   89185         309 :         SgExprStatement * alloc = (SgExprStatement*) ROSE_MALLOC ( SgExprStatement::pool_size * sizeof(SgExprStatement) );
   89186         309 :         ROSE_ASSERT(alloc != nullptr);
   89187             : 
   89188             : #if ROSE_ALLOC_TRACE == 2
   89189             : //        printf("SgExprStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgExprStatement::pools.size(), alloc, alloc + SgExprStatement::pool_size);
   89190             : #endif
   89191             : 
   89192             : #if ROSE_ALLOC_MEMSET == 1
   89193             : #elif ROSE_ALLOC_MEMSET == 2
   89194             :         memset(alloc, 0x00, SgExprStatement::pool_size * sizeof(SgExprStatement));
   89195             : #elif ROSE_ALLOC_MEMSET == 3
   89196             :         memset(alloc, 0xAA, SgExprStatement::pool_size * sizeof(SgExprStatement));
   89197             : #endif
   89198      618000 :         for (unsigned i=0; i < SgExprStatement::pool_size-1; i++) {
   89199      617691 :           alloc[i].p_freepointer = &(alloc[i+1]);
   89200             :         }
   89201         309 :         alloc[SgExprStatement::pool_size-1].p_freepointer = nullptr;
   89202             : 
   89203         309 :         SgExprStatement::pools.push_back ( (unsigned char *) alloc );
   89204         309 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgExprStatement::pool_size * sizeof(SgExprStatement), V_SgExprStatement ) );
   89205         309 :         SgExprStatement::next_node = alloc;
   89206             :     }
   89207       26437 :     ROSE_ASSERT(SgExprStatement::next_node != nullptr);
   89208             : 
   89209       26437 :     SgExprStatement * object = SgExprStatement::next_node;
   89210       26437 :     SgExprStatement::next_node = (SgExprStatement*)(object->p_freepointer);
   89211             : 
   89212             : #if ROSE_ALLOC_TRACE == 2
   89213             :     printf("SgExprStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgExprStatement::next_node);
   89214             : #endif
   89215             : 
   89216       26437 :     SgNode * fp = object->p_freepointer;
   89217             : #if ROSE_ALLOC_MEMSET == 1
   89218             : #elif ROSE_ALLOC_MEMSET == 2
   89219             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgExprStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   89220             : #elif ROSE_ALLOC_MEMSET == 3
   89221             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgExprStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   89222             : #endif
   89223       26437 :     object->p_freepointer = fp;
   89224             : 
   89225             : #if ROSE_ALLOC_TRACE == 2
   89226             : //    printf("SgExprStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgExprStatement::next_node);
   89227             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   89228             :     Rose::MemPool::snapshot(oss.str());
   89229             :     alloc_trace_cnt++;
   89230             : #endif
   89231             : 
   89232       26437 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   89233             : 
   89234       26437 :     ALLOC_MUTEX(SgExprStatement, unlock);
   89235             : 
   89236             :     return object;
   89237             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   89238             : }
   89239             : 
   89240             : 
   89241             : 
   89242             : /*! \brief Delete operator for SgExprStatement.
   89243             : 
   89244             :    This delete operator implements deallocation using memory pools to 
   89245             :    provide most efficent use of the heap within construction of large ASTs.
   89246             : 
   89247             : \internal The new and delete operators use the lower level C malloc/free
   89248             :    function calls for performance and to make sure that mixing of malloc/free
   89249             :    and new/delete by the used can be caught more readily.  This may change
   89250             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   89251             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   89252             :    deallocate memory allocated using ROSE_MALLOC.
   89253             : */
   89254        4417 : void SgExprStatement::operator delete(void *Pointer, size_t Size)
   89255             : {
   89256             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   89257             :      * or throwing an exception. */
   89258        4417 :     ALLOC_MUTEX(SgExprStatement, lock);
   89259             : 
   89260             : #if USE_CPP_NEW_DELETE_OPERATORS
   89261             :     ROSE_FREE(Pointer);
   89262             : #else
   89263             : #if ROSE_PEDANTIC_ALLOC
   89264             :     ROSE_ASSERT(Size == sizeof(SgExprStatement));
   89265             : #else
   89266        4417 :     if (Size != sizeof(SgExprStatement)) {
   89267           0 :       ROSE_FREE(Pointer);
   89268           0 :       ALLOC_MUTEX(SgExprStatement, unlock);
   89269             :       return;
   89270             :     }
   89271             : #endif
   89272             : 
   89273        4417 :     SgExprStatement * object = (SgExprStatement*) Pointer;
   89274        4417 :     ROSE_ASSERT(object != nullptr);
   89275             : 
   89276             : #if ROSE_ALLOC_TRACE == 2
   89277             : //  printf("SgExprStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgExprStatement::next_node);
   89278             :     printf("SgExprStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgExprStatement::next_node);
   89279             : #endif
   89280             : 
   89281             : #if ROSE_PEDANTIC_ALLOC
   89282             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   89283             : #endif
   89284             : 
   89285             : #if ROSE_ALLOC_MEMSET == 1
   89286             : #elif ROSE_ALLOC_MEMSET == 2
   89287             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgExprStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   89288             : #elif ROSE_ALLOC_MEMSET == 3
   89289             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgExprStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   89290             : #endif
   89291             : 
   89292             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   89293             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   89294             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   89295             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   89296             : #else
   89297        4417 :     object->p_freepointer = SgExprStatement::next_node;
   89298        4417 :     SgExprStatement::next_node = object;
   89299             : #endif
   89300             : 
   89301             : #if ROSE_ALLOC_TRACE == 2
   89302             : //  printf("SgExprStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgExprStatement::next_node);
   89303             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   89304             :     Rose::MemPool::snapshot(oss.str());
   89305             :     alloc_trace_cnt++;
   89306             : #endif
   89307             : 
   89308             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   89309             : 
   89310        4417 :     ALLOC_MUTEX(SgExprStatement, unlock);
   89311             : }
   89312             : 
   89313             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   89314             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   89315             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   89316             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   89317             : // Also, note comment below from Robb (copied from the Common.code file).
   89318             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   89319             : //
   89320             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   89321             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   89322             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   89323             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   89324             : #if 0
   89325             : void SgExprStatement::operator delete(void* pointer) { SgExprStatement::operator delete (pointer, sizeof(SgExprStatement)); };
   89326             : #endif
   89327             : /* #line 89328 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   89328             : 
   89329             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   89330             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   89331             : // obviously imply C++.
   89332             : 
   89333             : // This implements the support within ROSE for memory pools.  Memory pools
   89334             : // support the most condensed usage of memory within the construction of
   89335             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   89336             : // by a new operator written for each class.
   89337             : 
   89338             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   89339             :     // User wants multi-thread support and POSIX threads are available.
   89340             : #   include <pthread.h>
   89341             :     static pthread_mutex_t SgLabelStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   89342             : #else
   89343             :      // Cause synchronization to be skipped.
   89344             : #    ifndef ALLOC_MUTEX
   89345             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   89346             : #    endif
   89347             : #    ifdef _REENTRANT
   89348             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   89349             : #       ifdef _MSC_VER
   89350             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   89351             : #       else
   89352             : #           warning "POSIX threads are not available; synchronization being skipped"
   89353             : #       endif
   89354             : #    endif
   89355             : #endif
   89356             : 
   89357             : #ifndef ROSE_ALLOC_TRACE
   89358             : #  define ROSE_ALLOC_TRACE 0
   89359             : #endif
   89360             : 
   89361             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   89362             : #define ROSE_ALLOC_TRACE_CNT
   89363             : #include "memory-pool-snapshot.h"
   89364             : unsigned long alloc_trace_cnt = 0;
   89365             : #endif
   89366             : 
   89367             : #if ROSE_ALLOC_TRACE
   89368             : const unsigned SgLabelStatement::pool_size = 5;
   89369             : #else
   89370             : const unsigned SgLabelStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   89371             : #endif
   89372             : 
   89373             : #ifndef ROSE_ALLOC_MEMSET
   89374             : #  define ROSE_ALLOC_MEMSET 0
   89375             : #endif
   89376             : 
   89377             : #ifndef ROSE_PEDANTIC_ALLOC
   89378             : #  define ROSE_PEDANTIC_ALLOC 0
   89379             : #endif
   89380             : 
   89381             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   89382             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   89383             : #endif
   89384             : 
   89385             : #if !defined(SGNODE__ALL_POOLS)
   89386             : #define SGNODE__ALL_POOLS
   89387             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   89388             : #endif
   89389             : 
   89390             : SgLabelStatement* SgLabelStatement::next_node = nullptr;
   89391             : std::vector<unsigned char*> SgLabelStatement::pools;
   89392             : 
   89393             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   89394             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   89395             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   89396             : // around this macro definition rather than each use).
   89397             : #ifndef ALLOC_MUTEX
   89398             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   89399             :         do {                                                                     \
   89400             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   89401             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   89402             :                 abort();                                                         \
   89403             :             }                                                                    \
   89404             :         } while (0);
   89405             : #endif
   89406             : 
   89407             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   89408             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   89409             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   89410             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   89411             : 
   89412             : /*! \brief New operator for SgLabelStatement.
   89413             : 
   89414             :    This new operator implements memory pools to provide most efficent 
   89415             :    use of the heap within construction of large ASTs.
   89416             : 
   89417             : \internal The new and delete operators use the lower level C malloc/free
   89418             :    function calls for performance and to make sure that mixing of malloc/free
   89419             :    and new/delete by the used can be caught more readily.  This may change
   89420             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   89421             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   89422             :    deallocate memory allocated using ROSE_MALLOC.
   89423             : */
   89424          11 : void *SgLabelStatement::operator new ( size_t Size )
   89425             : {
   89426             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   89427             :      * returning or throwing an exception. */
   89428          11 :     ALLOC_MUTEX(SgLabelStatement, lock);
   89429             : 
   89430             : #if ROSE_ALLOC_TRACE == 2
   89431             : //    printf("SgLabelStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgLabelStatement::next_node);
   89432             : #endif
   89433             : 
   89434             : #if USE_CPP_NEW_DELETE_OPERATORS
   89435             :     void *mem = ROSE_MALLOC(Size);
   89436             :     ALLOC_MUTEX(SgLabelStatement, unlock);
   89437             :     return mem;
   89438             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   89439             : #if ROSE_PEDANTIC_ALLOC
   89440             :     ROSE_ASSERT(Size == sizeof(SgLabelStatement));
   89441             : #else
   89442          11 :     if (Size != sizeof(SgLabelStatement)) {
   89443           0 :       void * object = ROSE_MALLOC(Size);
   89444           0 :       ALLOC_MUTEX(SgLabelStatement, unlock);
   89445             :       return object;
   89446             :     }
   89447             : #endif
   89448             : 
   89449          11 :     if (SgLabelStatement::next_node == nullptr) {
   89450           6 :         SgLabelStatement * alloc = (SgLabelStatement*) ROSE_MALLOC ( SgLabelStatement::pool_size * sizeof(SgLabelStatement) );
   89451           6 :         ROSE_ASSERT(alloc != nullptr);
   89452             : 
   89453             : #if ROSE_ALLOC_TRACE == 2
   89454             : //        printf("SgLabelStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgLabelStatement::pools.size(), alloc, alloc + SgLabelStatement::pool_size);
   89455             : #endif
   89456             : 
   89457             : #if ROSE_ALLOC_MEMSET == 1
   89458             : #elif ROSE_ALLOC_MEMSET == 2
   89459             :         memset(alloc, 0x00, SgLabelStatement::pool_size * sizeof(SgLabelStatement));
   89460             : #elif ROSE_ALLOC_MEMSET == 3
   89461             :         memset(alloc, 0xAA, SgLabelStatement::pool_size * sizeof(SgLabelStatement));
   89462             : #endif
   89463       12000 :         for (unsigned i=0; i < SgLabelStatement::pool_size-1; i++) {
   89464       11994 :           alloc[i].p_freepointer = &(alloc[i+1]);
   89465             :         }
   89466           6 :         alloc[SgLabelStatement::pool_size-1].p_freepointer = nullptr;
   89467             : 
   89468           6 :         SgLabelStatement::pools.push_back ( (unsigned char *) alloc );
   89469           6 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgLabelStatement::pool_size * sizeof(SgLabelStatement), V_SgLabelStatement ) );
   89470           6 :         SgLabelStatement::next_node = alloc;
   89471             :     }
   89472          11 :     ROSE_ASSERT(SgLabelStatement::next_node != nullptr);
   89473             : 
   89474          11 :     SgLabelStatement * object = SgLabelStatement::next_node;
   89475          11 :     SgLabelStatement::next_node = (SgLabelStatement*)(object->p_freepointer);
   89476             : 
   89477             : #if ROSE_ALLOC_TRACE == 2
   89478             :     printf("SgLabelStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgLabelStatement::next_node);
   89479             : #endif
   89480             : 
   89481          11 :     SgNode * fp = object->p_freepointer;
   89482             : #if ROSE_ALLOC_MEMSET == 1
   89483             : #elif ROSE_ALLOC_MEMSET == 2
   89484             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgLabelStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   89485             : #elif ROSE_ALLOC_MEMSET == 3
   89486             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgLabelStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   89487             : #endif
   89488          11 :     object->p_freepointer = fp;
   89489             : 
   89490             : #if ROSE_ALLOC_TRACE == 2
   89491             : //    printf("SgLabelStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgLabelStatement::next_node);
   89492             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   89493             :     Rose::MemPool::snapshot(oss.str());
   89494             :     alloc_trace_cnt++;
   89495             : #endif
   89496             : 
   89497          11 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   89498             : 
   89499          11 :     ALLOC_MUTEX(SgLabelStatement, unlock);
   89500             : 
   89501             :     return object;
   89502             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   89503             : }
   89504             : 
   89505             : 
   89506             : 
   89507             : /*! \brief Delete operator for SgLabelStatement.
   89508             : 
   89509             :    This delete operator implements deallocation using memory pools to 
   89510             :    provide most efficent use of the heap within construction of large ASTs.
   89511             : 
   89512             : \internal The new and delete operators use the lower level C malloc/free
   89513             :    function calls for performance and to make sure that mixing of malloc/free
   89514             :    and new/delete by the used can be caught more readily.  This may change
   89515             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   89516             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   89517             :    deallocate memory allocated using ROSE_MALLOC.
   89518             : */
   89519           0 : void SgLabelStatement::operator delete(void *Pointer, size_t Size)
   89520             : {
   89521             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   89522             :      * or throwing an exception. */
   89523           0 :     ALLOC_MUTEX(SgLabelStatement, lock);
   89524             : 
   89525             : #if USE_CPP_NEW_DELETE_OPERATORS
   89526             :     ROSE_FREE(Pointer);
   89527             : #else
   89528             : #if ROSE_PEDANTIC_ALLOC
   89529             :     ROSE_ASSERT(Size == sizeof(SgLabelStatement));
   89530             : #else
   89531           0 :     if (Size != sizeof(SgLabelStatement)) {
   89532           0 :       ROSE_FREE(Pointer);
   89533           0 :       ALLOC_MUTEX(SgLabelStatement, unlock);
   89534             :       return;
   89535             :     }
   89536             : #endif
   89537             : 
   89538           0 :     SgLabelStatement * object = (SgLabelStatement*) Pointer;
   89539           0 :     ROSE_ASSERT(object != nullptr);
   89540             : 
   89541             : #if ROSE_ALLOC_TRACE == 2
   89542             : //  printf("SgLabelStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgLabelStatement::next_node);
   89543             :     printf("SgLabelStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgLabelStatement::next_node);
   89544             : #endif
   89545             : 
   89546             : #if ROSE_PEDANTIC_ALLOC
   89547             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   89548             : #endif
   89549             : 
   89550             : #if ROSE_ALLOC_MEMSET == 1
   89551             : #elif ROSE_ALLOC_MEMSET == 2
   89552             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgLabelStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   89553             : #elif ROSE_ALLOC_MEMSET == 3
   89554             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgLabelStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   89555             : #endif
   89556             : 
   89557             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   89558             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   89559             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   89560             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   89561             : #else
   89562           0 :     object->p_freepointer = SgLabelStatement::next_node;
   89563           0 :     SgLabelStatement::next_node = object;
   89564             : #endif
   89565             : 
   89566             : #if ROSE_ALLOC_TRACE == 2
   89567             : //  printf("SgLabelStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgLabelStatement::next_node);
   89568             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   89569             :     Rose::MemPool::snapshot(oss.str());
   89570             :     alloc_trace_cnt++;
   89571             : #endif
   89572             : 
   89573             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   89574             : 
   89575           0 :     ALLOC_MUTEX(SgLabelStatement, unlock);
   89576             : }
   89577             : 
   89578             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   89579             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   89580             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   89581             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   89582             : // Also, note comment below from Robb (copied from the Common.code file).
   89583             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   89584             : //
   89585             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   89586             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   89587             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   89588             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   89589             : #if 0
   89590             : void SgLabelStatement::operator delete(void* pointer) { SgLabelStatement::operator delete (pointer, sizeof(SgLabelStatement)); };
   89591             : #endif
   89592             : /* #line 89593 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   89593             : 
   89594             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   89595             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   89596             : // obviously imply C++.
   89597             : 
   89598             : // This implements the support within ROSE for memory pools.  Memory pools
   89599             : // support the most condensed usage of memory within the construction of
   89600             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   89601             : // by a new operator written for each class.
   89602             : 
   89603             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   89604             :     // User wants multi-thread support and POSIX threads are available.
   89605             : #   include <pthread.h>
   89606             :     static pthread_mutex_t SgCaseOptionStmt_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   89607             : #else
   89608             :      // Cause synchronization to be skipped.
   89609             : #    ifndef ALLOC_MUTEX
   89610             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   89611             : #    endif
   89612             : #    ifdef _REENTRANT
   89613             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   89614             : #       ifdef _MSC_VER
   89615             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   89616             : #       else
   89617             : #           warning "POSIX threads are not available; synchronization being skipped"
   89618             : #       endif
   89619             : #    endif
   89620             : #endif
   89621             : 
   89622             : #ifndef ROSE_ALLOC_TRACE
   89623             : #  define ROSE_ALLOC_TRACE 0
   89624             : #endif
   89625             : 
   89626             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   89627             : #define ROSE_ALLOC_TRACE_CNT
   89628             : #include "memory-pool-snapshot.h"
   89629             : unsigned long alloc_trace_cnt = 0;
   89630             : #endif
   89631             : 
   89632             : #if ROSE_ALLOC_TRACE
   89633             : const unsigned SgCaseOptionStmt::pool_size = 5;
   89634             : #else
   89635             : const unsigned SgCaseOptionStmt::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   89636             : #endif
   89637             : 
   89638             : #ifndef ROSE_ALLOC_MEMSET
   89639             : #  define ROSE_ALLOC_MEMSET 0
   89640             : #endif
   89641             : 
   89642             : #ifndef ROSE_PEDANTIC_ALLOC
   89643             : #  define ROSE_PEDANTIC_ALLOC 0
   89644             : #endif
   89645             : 
   89646             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   89647             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   89648             : #endif
   89649             : 
   89650             : #if !defined(SGNODE__ALL_POOLS)
   89651             : #define SGNODE__ALL_POOLS
   89652             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   89653             : #endif
   89654             : 
   89655             : SgCaseOptionStmt* SgCaseOptionStmt::next_node = nullptr;
   89656             : std::vector<unsigned char*> SgCaseOptionStmt::pools;
   89657             : 
   89658             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   89659             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   89660             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   89661             : // around this macro definition rather than each use).
   89662             : #ifndef ALLOC_MUTEX
   89663             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   89664             :         do {                                                                     \
   89665             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   89666             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   89667             :                 abort();                                                         \
   89668             :             }                                                                    \
   89669             :         } while (0);
   89670             : #endif
   89671             : 
   89672             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   89673             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   89674             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   89675             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   89676             : 
   89677             : /*! \brief New operator for SgCaseOptionStmt.
   89678             : 
   89679             :    This new operator implements memory pools to provide most efficent 
   89680             :    use of the heap within construction of large ASTs.
   89681             : 
   89682             : \internal The new and delete operators use the lower level C malloc/free
   89683             :    function calls for performance and to make sure that mixing of malloc/free
   89684             :    and new/delete by the used can be caught more readily.  This may change
   89685             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   89686             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   89687             :    deallocate memory allocated using ROSE_MALLOC.
   89688             : */
   89689           1 : void *SgCaseOptionStmt::operator new ( size_t Size )
   89690             : {
   89691             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   89692             :      * returning or throwing an exception. */
   89693           1 :     ALLOC_MUTEX(SgCaseOptionStmt, lock);
   89694             : 
   89695             : #if ROSE_ALLOC_TRACE == 2
   89696             : //    printf("SgCaseOptionStmt::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgCaseOptionStmt::next_node);
   89697             : #endif
   89698             : 
   89699             : #if USE_CPP_NEW_DELETE_OPERATORS
   89700             :     void *mem = ROSE_MALLOC(Size);
   89701             :     ALLOC_MUTEX(SgCaseOptionStmt, unlock);
   89702             :     return mem;
   89703             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   89704             : #if ROSE_PEDANTIC_ALLOC
   89705             :     ROSE_ASSERT(Size == sizeof(SgCaseOptionStmt));
   89706             : #else
   89707           1 :     if (Size != sizeof(SgCaseOptionStmt)) {
   89708           0 :       void * object = ROSE_MALLOC(Size);
   89709           0 :       ALLOC_MUTEX(SgCaseOptionStmt, unlock);
   89710             :       return object;
   89711             :     }
   89712             : #endif
   89713             : 
   89714           1 :     if (SgCaseOptionStmt::next_node == nullptr) {
   89715           1 :         SgCaseOptionStmt * alloc = (SgCaseOptionStmt*) ROSE_MALLOC ( SgCaseOptionStmt::pool_size * sizeof(SgCaseOptionStmt) );
   89716           1 :         ROSE_ASSERT(alloc != nullptr);
   89717             : 
   89718             : #if ROSE_ALLOC_TRACE == 2
   89719             : //        printf("SgCaseOptionStmt::alloc\n  block[%zi] = [ %p , %p [\n", SgCaseOptionStmt::pools.size(), alloc, alloc + SgCaseOptionStmt::pool_size);
   89720             : #endif
   89721             : 
   89722             : #if ROSE_ALLOC_MEMSET == 1
   89723             : #elif ROSE_ALLOC_MEMSET == 2
   89724             :         memset(alloc, 0x00, SgCaseOptionStmt::pool_size * sizeof(SgCaseOptionStmt));
   89725             : #elif ROSE_ALLOC_MEMSET == 3
   89726             :         memset(alloc, 0xAA, SgCaseOptionStmt::pool_size * sizeof(SgCaseOptionStmt));
   89727             : #endif
   89728        2000 :         for (unsigned i=0; i < SgCaseOptionStmt::pool_size-1; i++) {
   89729        1999 :           alloc[i].p_freepointer = &(alloc[i+1]);
   89730             :         }
   89731           1 :         alloc[SgCaseOptionStmt::pool_size-1].p_freepointer = nullptr;
   89732             : 
   89733           1 :         SgCaseOptionStmt::pools.push_back ( (unsigned char *) alloc );
   89734           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgCaseOptionStmt::pool_size * sizeof(SgCaseOptionStmt), V_SgCaseOptionStmt ) );
   89735           1 :         SgCaseOptionStmt::next_node = alloc;
   89736             :     }
   89737           1 :     ROSE_ASSERT(SgCaseOptionStmt::next_node != nullptr);
   89738             : 
   89739           1 :     SgCaseOptionStmt * object = SgCaseOptionStmt::next_node;
   89740           1 :     SgCaseOptionStmt::next_node = (SgCaseOptionStmt*)(object->p_freepointer);
   89741             : 
   89742             : #if ROSE_ALLOC_TRACE == 2
   89743             :     printf("SgCaseOptionStmt::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgCaseOptionStmt::next_node);
   89744             : #endif
   89745             : 
   89746           1 :     SgNode * fp = object->p_freepointer;
   89747             : #if ROSE_ALLOC_MEMSET == 1
   89748             : #elif ROSE_ALLOC_MEMSET == 2
   89749             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgCaseOptionStmt) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   89750             : #elif ROSE_ALLOC_MEMSET == 3
   89751             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgCaseOptionStmt) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   89752             : #endif
   89753           1 :     object->p_freepointer = fp;
   89754             : 
   89755             : #if ROSE_ALLOC_TRACE == 2
   89756             : //    printf("SgCaseOptionStmt::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgCaseOptionStmt::next_node);
   89757             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   89758             :     Rose::MemPool::snapshot(oss.str());
   89759             :     alloc_trace_cnt++;
   89760             : #endif
   89761             : 
   89762           1 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   89763             : 
   89764           1 :     ALLOC_MUTEX(SgCaseOptionStmt, unlock);
   89765             : 
   89766             :     return object;
   89767             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   89768             : }
   89769             : 
   89770             : 
   89771             : 
   89772             : /*! \brief Delete operator for SgCaseOptionStmt.
   89773             : 
   89774             :    This delete operator implements deallocation using memory pools to 
   89775             :    provide most efficent use of the heap within construction of large ASTs.
   89776             : 
   89777             : \internal The new and delete operators use the lower level C malloc/free
   89778             :    function calls for performance and to make sure that mixing of malloc/free
   89779             :    and new/delete by the used can be caught more readily.  This may change
   89780             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   89781             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   89782             :    deallocate memory allocated using ROSE_MALLOC.
   89783             : */
   89784           0 : void SgCaseOptionStmt::operator delete(void *Pointer, size_t Size)
   89785             : {
   89786             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   89787             :      * or throwing an exception. */
   89788           0 :     ALLOC_MUTEX(SgCaseOptionStmt, lock);
   89789             : 
   89790             : #if USE_CPP_NEW_DELETE_OPERATORS
   89791             :     ROSE_FREE(Pointer);
   89792             : #else
   89793             : #if ROSE_PEDANTIC_ALLOC
   89794             :     ROSE_ASSERT(Size == sizeof(SgCaseOptionStmt));
   89795             : #else
   89796           0 :     if (Size != sizeof(SgCaseOptionStmt)) {
   89797           0 :       ROSE_FREE(Pointer);
   89798           0 :       ALLOC_MUTEX(SgCaseOptionStmt, unlock);
   89799             :       return;
   89800             :     }
   89801             : #endif
   89802             : 
   89803           0 :     SgCaseOptionStmt * object = (SgCaseOptionStmt*) Pointer;
   89804           0 :     ROSE_ASSERT(object != nullptr);
   89805             : 
   89806             : #if ROSE_ALLOC_TRACE == 2
   89807             : //  printf("SgCaseOptionStmt::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgCaseOptionStmt::next_node);
   89808             :     printf("SgCaseOptionStmt::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgCaseOptionStmt::next_node);
   89809             : #endif
   89810             : 
   89811             : #if ROSE_PEDANTIC_ALLOC
   89812             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   89813             : #endif
   89814             : 
   89815             : #if ROSE_ALLOC_MEMSET == 1
   89816             : #elif ROSE_ALLOC_MEMSET == 2
   89817             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgCaseOptionStmt) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   89818             : #elif ROSE_ALLOC_MEMSET == 3
   89819             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgCaseOptionStmt) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   89820             : #endif
   89821             : 
   89822             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   89823             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   89824             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   89825             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   89826             : #else
   89827           0 :     object->p_freepointer = SgCaseOptionStmt::next_node;
   89828           0 :     SgCaseOptionStmt::next_node = object;
   89829             : #endif
   89830             : 
   89831             : #if ROSE_ALLOC_TRACE == 2
   89832             : //  printf("SgCaseOptionStmt::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgCaseOptionStmt::next_node);
   89833             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   89834             :     Rose::MemPool::snapshot(oss.str());
   89835             :     alloc_trace_cnt++;
   89836             : #endif
   89837             : 
   89838             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   89839             : 
   89840           0 :     ALLOC_MUTEX(SgCaseOptionStmt, unlock);
   89841             : }
   89842             : 
   89843             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   89844             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   89845             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   89846             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   89847             : // Also, note comment below from Robb (copied from the Common.code file).
   89848             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   89849             : //
   89850             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   89851             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   89852             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   89853             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   89854             : #if 0
   89855             : void SgCaseOptionStmt::operator delete(void* pointer) { SgCaseOptionStmt::operator delete (pointer, sizeof(SgCaseOptionStmt)); };
   89856             : #endif
   89857             : /* #line 89858 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   89858             : 
   89859             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   89860             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   89861             : // obviously imply C++.
   89862             : 
   89863             : // This implements the support within ROSE for memory pools.  Memory pools
   89864             : // support the most condensed usage of memory within the construction of
   89865             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   89866             : // by a new operator written for each class.
   89867             : 
   89868             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   89869             :     // User wants multi-thread support and POSIX threads are available.
   89870             : #   include <pthread.h>
   89871             :     static pthread_mutex_t SgTryStmt_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   89872             : #else
   89873             :      // Cause synchronization to be skipped.
   89874             : #    ifndef ALLOC_MUTEX
   89875             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   89876             : #    endif
   89877             : #    ifdef _REENTRANT
   89878             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   89879             : #       ifdef _MSC_VER
   89880             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   89881             : #       else
   89882             : #           warning "POSIX threads are not available; synchronization being skipped"
   89883             : #       endif
   89884             : #    endif
   89885             : #endif
   89886             : 
   89887             : #ifndef ROSE_ALLOC_TRACE
   89888             : #  define ROSE_ALLOC_TRACE 0
   89889             : #endif
   89890             : 
   89891             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   89892             : #define ROSE_ALLOC_TRACE_CNT
   89893             : #include "memory-pool-snapshot.h"
   89894             : unsigned long alloc_trace_cnt = 0;
   89895             : #endif
   89896             : 
   89897             : #if ROSE_ALLOC_TRACE
   89898             : const unsigned SgTryStmt::pool_size = 5;
   89899             : #else
   89900             : const unsigned SgTryStmt::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   89901             : #endif
   89902             : 
   89903             : #ifndef ROSE_ALLOC_MEMSET
   89904             : #  define ROSE_ALLOC_MEMSET 0
   89905             : #endif
   89906             : 
   89907             : #ifndef ROSE_PEDANTIC_ALLOC
   89908             : #  define ROSE_PEDANTIC_ALLOC 0
   89909             : #endif
   89910             : 
   89911             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   89912             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   89913             : #endif
   89914             : 
   89915             : #if !defined(SGNODE__ALL_POOLS)
   89916             : #define SGNODE__ALL_POOLS
   89917             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   89918             : #endif
   89919             : 
   89920             : SgTryStmt* SgTryStmt::next_node = nullptr;
   89921             : std::vector<unsigned char*> SgTryStmt::pools;
   89922             : 
   89923             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   89924             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   89925             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   89926             : // around this macro definition rather than each use).
   89927             : #ifndef ALLOC_MUTEX
   89928             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   89929             :         do {                                                                     \
   89930             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   89931             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   89932             :                 abort();                                                         \
   89933             :             }                                                                    \
   89934             :         } while (0);
   89935             : #endif
   89936             : 
   89937             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   89938             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   89939             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   89940             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   89941             : 
   89942             : /*! \brief New operator for SgTryStmt.
   89943             : 
   89944             :    This new operator implements memory pools to provide most efficent 
   89945             :    use of the heap within construction of large ASTs.
   89946             : 
   89947             : \internal The new and delete operators use the lower level C malloc/free
   89948             :    function calls for performance and to make sure that mixing of malloc/free
   89949             :    and new/delete by the used can be caught more readily.  This may change
   89950             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   89951             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   89952             :    deallocate memory allocated using ROSE_MALLOC.
   89953             : */
   89954         568 : void *SgTryStmt::operator new ( size_t Size )
   89955             : {
   89956             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   89957             :      * returning or throwing an exception. */
   89958         568 :     ALLOC_MUTEX(SgTryStmt, lock);
   89959             : 
   89960             : #if ROSE_ALLOC_TRACE == 2
   89961             : //    printf("SgTryStmt::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgTryStmt::next_node);
   89962             : #endif
   89963             : 
   89964             : #if USE_CPP_NEW_DELETE_OPERATORS
   89965             :     void *mem = ROSE_MALLOC(Size);
   89966             :     ALLOC_MUTEX(SgTryStmt, unlock);
   89967             :     return mem;
   89968             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   89969             : #if ROSE_PEDANTIC_ALLOC
   89970             :     ROSE_ASSERT(Size == sizeof(SgTryStmt));
   89971             : #else
   89972         568 :     if (Size != sizeof(SgTryStmt)) {
   89973           0 :       void * object = ROSE_MALLOC(Size);
   89974           0 :       ALLOC_MUTEX(SgTryStmt, unlock);
   89975             :       return object;
   89976             :     }
   89977             : #endif
   89978             : 
   89979         568 :     if (SgTryStmt::next_node == nullptr) {
   89980          10 :         SgTryStmt * alloc = (SgTryStmt*) ROSE_MALLOC ( SgTryStmt::pool_size * sizeof(SgTryStmt) );
   89981          10 :         ROSE_ASSERT(alloc != nullptr);
   89982             : 
   89983             : #if ROSE_ALLOC_TRACE == 2
   89984             : //        printf("SgTryStmt::alloc\n  block[%zi] = [ %p , %p [\n", SgTryStmt::pools.size(), alloc, alloc + SgTryStmt::pool_size);
   89985             : #endif
   89986             : 
   89987             : #if ROSE_ALLOC_MEMSET == 1
   89988             : #elif ROSE_ALLOC_MEMSET == 2
   89989             :         memset(alloc, 0x00, SgTryStmt::pool_size * sizeof(SgTryStmt));
   89990             : #elif ROSE_ALLOC_MEMSET == 3
   89991             :         memset(alloc, 0xAA, SgTryStmt::pool_size * sizeof(SgTryStmt));
   89992             : #endif
   89993       20000 :         for (unsigned i=0; i < SgTryStmt::pool_size-1; i++) {
   89994       19990 :           alloc[i].p_freepointer = &(alloc[i+1]);
   89995             :         }
   89996          10 :         alloc[SgTryStmt::pool_size-1].p_freepointer = nullptr;
   89997             : 
   89998          10 :         SgTryStmt::pools.push_back ( (unsigned char *) alloc );
   89999          10 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgTryStmt::pool_size * sizeof(SgTryStmt), V_SgTryStmt ) );
   90000          10 :         SgTryStmt::next_node = alloc;
   90001             :     }
   90002         568 :     ROSE_ASSERT(SgTryStmt::next_node != nullptr);
   90003             : 
   90004         568 :     SgTryStmt * object = SgTryStmt::next_node;
   90005         568 :     SgTryStmt::next_node = (SgTryStmt*)(object->p_freepointer);
   90006             : 
   90007             : #if ROSE_ALLOC_TRACE == 2
   90008             :     printf("SgTryStmt::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTryStmt::next_node);
   90009             : #endif
   90010             : 
   90011         568 :     SgNode * fp = object->p_freepointer;
   90012             : #if ROSE_ALLOC_MEMSET == 1
   90013             : #elif ROSE_ALLOC_MEMSET == 2
   90014             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgTryStmt) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   90015             : #elif ROSE_ALLOC_MEMSET == 3
   90016             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgTryStmt) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   90017             : #endif
   90018         568 :     object->p_freepointer = fp;
   90019             : 
   90020             : #if ROSE_ALLOC_TRACE == 2
   90021             : //    printf("SgTryStmt::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTryStmt::next_node);
   90022             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   90023             :     Rose::MemPool::snapshot(oss.str());
   90024             :     alloc_trace_cnt++;
   90025             : #endif
   90026             : 
   90027         568 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   90028             : 
   90029         568 :     ALLOC_MUTEX(SgTryStmt, unlock);
   90030             : 
   90031             :     return object;
   90032             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   90033             : }
   90034             : 
   90035             : 
   90036             : 
   90037             : /*! \brief Delete operator for SgTryStmt.
   90038             : 
   90039             :    This delete operator implements deallocation using memory pools to 
   90040             :    provide most efficent use of the heap within construction of large ASTs.
   90041             : 
   90042             : \internal The new and delete operators use the lower level C malloc/free
   90043             :    function calls for performance and to make sure that mixing of malloc/free
   90044             :    and new/delete by the used can be caught more readily.  This may change
   90045             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   90046             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   90047             :    deallocate memory allocated using ROSE_MALLOC.
   90048             : */
   90049         108 : void SgTryStmt::operator delete(void *Pointer, size_t Size)
   90050             : {
   90051             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   90052             :      * or throwing an exception. */
   90053         108 :     ALLOC_MUTEX(SgTryStmt, lock);
   90054             : 
   90055             : #if USE_CPP_NEW_DELETE_OPERATORS
   90056             :     ROSE_FREE(Pointer);
   90057             : #else
   90058             : #if ROSE_PEDANTIC_ALLOC
   90059             :     ROSE_ASSERT(Size == sizeof(SgTryStmt));
   90060             : #else
   90061         108 :     if (Size != sizeof(SgTryStmt)) {
   90062           0 :       ROSE_FREE(Pointer);
   90063           0 :       ALLOC_MUTEX(SgTryStmt, unlock);
   90064             :       return;
   90065             :     }
   90066             : #endif
   90067             : 
   90068         108 :     SgTryStmt * object = (SgTryStmt*) Pointer;
   90069         108 :     ROSE_ASSERT(object != nullptr);
   90070             : 
   90071             : #if ROSE_ALLOC_TRACE == 2
   90072             : //  printf("SgTryStmt::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTryStmt::next_node);
   90073             :     printf("SgTryStmt::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTryStmt::next_node);
   90074             : #endif
   90075             : 
   90076             : #if ROSE_PEDANTIC_ALLOC
   90077             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   90078             : #endif
   90079             : 
   90080             : #if ROSE_ALLOC_MEMSET == 1
   90081             : #elif ROSE_ALLOC_MEMSET == 2
   90082             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgTryStmt) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   90083             : #elif ROSE_ALLOC_MEMSET == 3
   90084             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgTryStmt) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   90085             : #endif
   90086             : 
   90087             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   90088             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   90089             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   90090             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   90091             : #else
   90092         108 :     object->p_freepointer = SgTryStmt::next_node;
   90093         108 :     SgTryStmt::next_node = object;
   90094             : #endif
   90095             : 
   90096             : #if ROSE_ALLOC_TRACE == 2
   90097             : //  printf("SgTryStmt::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTryStmt::next_node);
   90098             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   90099             :     Rose::MemPool::snapshot(oss.str());
   90100             :     alloc_trace_cnt++;
   90101             : #endif
   90102             : 
   90103             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   90104             : 
   90105         108 :     ALLOC_MUTEX(SgTryStmt, unlock);
   90106             : }
   90107             : 
   90108             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   90109             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   90110             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   90111             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   90112             : // Also, note comment below from Robb (copied from the Common.code file).
   90113             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   90114             : //
   90115             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   90116             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   90117             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   90118             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   90119             : #if 0
   90120             : void SgTryStmt::operator delete(void* pointer) { SgTryStmt::operator delete (pointer, sizeof(SgTryStmt)); };
   90121             : #endif
   90122             : /* #line 90123 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   90123             : 
   90124             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   90125             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   90126             : // obviously imply C++.
   90127             : 
   90128             : // This implements the support within ROSE for memory pools.  Memory pools
   90129             : // support the most condensed usage of memory within the construction of
   90130             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   90131             : // by a new operator written for each class.
   90132             : 
   90133             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   90134             :     // User wants multi-thread support and POSIX threads are available.
   90135             : #   include <pthread.h>
   90136             :     static pthread_mutex_t SgDefaultOptionStmt_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   90137             : #else
   90138             :      // Cause synchronization to be skipped.
   90139             : #    ifndef ALLOC_MUTEX
   90140             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   90141             : #    endif
   90142             : #    ifdef _REENTRANT
   90143             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   90144             : #       ifdef _MSC_VER
   90145             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   90146             : #       else
   90147             : #           warning "POSIX threads are not available; synchronization being skipped"
   90148             : #       endif
   90149             : #    endif
   90150             : #endif
   90151             : 
   90152             : #ifndef ROSE_ALLOC_TRACE
   90153             : #  define ROSE_ALLOC_TRACE 0
   90154             : #endif
   90155             : 
   90156             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   90157             : #define ROSE_ALLOC_TRACE_CNT
   90158             : #include "memory-pool-snapshot.h"
   90159             : unsigned long alloc_trace_cnt = 0;
   90160             : #endif
   90161             : 
   90162             : #if ROSE_ALLOC_TRACE
   90163             : const unsigned SgDefaultOptionStmt::pool_size = 5;
   90164             : #else
   90165             : const unsigned SgDefaultOptionStmt::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   90166             : #endif
   90167             : 
   90168             : #ifndef ROSE_ALLOC_MEMSET
   90169             : #  define ROSE_ALLOC_MEMSET 0
   90170             : #endif
   90171             : 
   90172             : #ifndef ROSE_PEDANTIC_ALLOC
   90173             : #  define ROSE_PEDANTIC_ALLOC 0
   90174             : #endif
   90175             : 
   90176             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   90177             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   90178             : #endif
   90179             : 
   90180             : #if !defined(SGNODE__ALL_POOLS)
   90181             : #define SGNODE__ALL_POOLS
   90182             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   90183             : #endif
   90184             : 
   90185             : SgDefaultOptionStmt* SgDefaultOptionStmt::next_node = nullptr;
   90186             : std::vector<unsigned char*> SgDefaultOptionStmt::pools;
   90187             : 
   90188             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   90189             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   90190             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   90191             : // around this macro definition rather than each use).
   90192             : #ifndef ALLOC_MUTEX
   90193             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   90194             :         do {                                                                     \
   90195             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   90196             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   90197             :                 abort();                                                         \
   90198             :             }                                                                    \
   90199             :         } while (0);
   90200             : #endif
   90201             : 
   90202             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   90203             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   90204             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   90205             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   90206             : 
   90207             : /*! \brief New operator for SgDefaultOptionStmt.
   90208             : 
   90209             :    This new operator implements memory pools to provide most efficent 
   90210             :    use of the heap within construction of large ASTs.
   90211             : 
   90212             : \internal The new and delete operators use the lower level C malloc/free
   90213             :    function calls for performance and to make sure that mixing of malloc/free
   90214             :    and new/delete by the used can be caught more readily.  This may change
   90215             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   90216             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   90217             :    deallocate memory allocated using ROSE_MALLOC.
   90218             : */
   90219           1 : void *SgDefaultOptionStmt::operator new ( size_t Size )
   90220             : {
   90221             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   90222             :      * returning or throwing an exception. */
   90223           1 :     ALLOC_MUTEX(SgDefaultOptionStmt, lock);
   90224             : 
   90225             : #if ROSE_ALLOC_TRACE == 2
   90226             : //    printf("SgDefaultOptionStmt::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgDefaultOptionStmt::next_node);
   90227             : #endif
   90228             : 
   90229             : #if USE_CPP_NEW_DELETE_OPERATORS
   90230             :     void *mem = ROSE_MALLOC(Size);
   90231             :     ALLOC_MUTEX(SgDefaultOptionStmt, unlock);
   90232             :     return mem;
   90233             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   90234             : #if ROSE_PEDANTIC_ALLOC
   90235             :     ROSE_ASSERT(Size == sizeof(SgDefaultOptionStmt));
   90236             : #else
   90237           1 :     if (Size != sizeof(SgDefaultOptionStmt)) {
   90238           0 :       void * object = ROSE_MALLOC(Size);
   90239           0 :       ALLOC_MUTEX(SgDefaultOptionStmt, unlock);
   90240             :       return object;
   90241             :     }
   90242             : #endif
   90243             : 
   90244           1 :     if (SgDefaultOptionStmt::next_node == nullptr) {
   90245           1 :         SgDefaultOptionStmt * alloc = (SgDefaultOptionStmt*) ROSE_MALLOC ( SgDefaultOptionStmt::pool_size * sizeof(SgDefaultOptionStmt) );
   90246           1 :         ROSE_ASSERT(alloc != nullptr);
   90247             : 
   90248             : #if ROSE_ALLOC_TRACE == 2
   90249             : //        printf("SgDefaultOptionStmt::alloc\n  block[%zi] = [ %p , %p [\n", SgDefaultOptionStmt::pools.size(), alloc, alloc + SgDefaultOptionStmt::pool_size);
   90250             : #endif
   90251             : 
   90252             : #if ROSE_ALLOC_MEMSET == 1
   90253             : #elif ROSE_ALLOC_MEMSET == 2
   90254             :         memset(alloc, 0x00, SgDefaultOptionStmt::pool_size * sizeof(SgDefaultOptionStmt));
   90255             : #elif ROSE_ALLOC_MEMSET == 3
   90256             :         memset(alloc, 0xAA, SgDefaultOptionStmt::pool_size * sizeof(SgDefaultOptionStmt));
   90257             : #endif
   90258        2000 :         for (unsigned i=0; i < SgDefaultOptionStmt::pool_size-1; i++) {
   90259        1999 :           alloc[i].p_freepointer = &(alloc[i+1]);
   90260             :         }
   90261           1 :         alloc[SgDefaultOptionStmt::pool_size-1].p_freepointer = nullptr;
   90262             : 
   90263           1 :         SgDefaultOptionStmt::pools.push_back ( (unsigned char *) alloc );
   90264           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgDefaultOptionStmt::pool_size * sizeof(SgDefaultOptionStmt), V_SgDefaultOptionStmt ) );
   90265           1 :         SgDefaultOptionStmt::next_node = alloc;
   90266             :     }
   90267           1 :     ROSE_ASSERT(SgDefaultOptionStmt::next_node != nullptr);
   90268             : 
   90269           1 :     SgDefaultOptionStmt * object = SgDefaultOptionStmt::next_node;
   90270           1 :     SgDefaultOptionStmt::next_node = (SgDefaultOptionStmt*)(object->p_freepointer);
   90271             : 
   90272             : #if ROSE_ALLOC_TRACE == 2
   90273             :     printf("SgDefaultOptionStmt::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgDefaultOptionStmt::next_node);
   90274             : #endif
   90275             : 
   90276           1 :     SgNode * fp = object->p_freepointer;
   90277             : #if ROSE_ALLOC_MEMSET == 1
   90278             : #elif ROSE_ALLOC_MEMSET == 2
   90279             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgDefaultOptionStmt) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   90280             : #elif ROSE_ALLOC_MEMSET == 3
   90281             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgDefaultOptionStmt) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   90282             : #endif
   90283           1 :     object->p_freepointer = fp;
   90284             : 
   90285             : #if ROSE_ALLOC_TRACE == 2
   90286             : //    printf("SgDefaultOptionStmt::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgDefaultOptionStmt::next_node);
   90287             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   90288             :     Rose::MemPool::snapshot(oss.str());
   90289             :     alloc_trace_cnt++;
   90290             : #endif
   90291             : 
   90292           1 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   90293             : 
   90294           1 :     ALLOC_MUTEX(SgDefaultOptionStmt, unlock);
   90295             : 
   90296             :     return object;
   90297             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   90298             : }
   90299             : 
   90300             : 
   90301             : 
   90302             : /*! \brief Delete operator for SgDefaultOptionStmt.
   90303             : 
   90304             :    This delete operator implements deallocation using memory pools to 
   90305             :    provide most efficent use of the heap within construction of large ASTs.
   90306             : 
   90307             : \internal The new and delete operators use the lower level C malloc/free
   90308             :    function calls for performance and to make sure that mixing of malloc/free
   90309             :    and new/delete by the used can be caught more readily.  This may change
   90310             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   90311             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   90312             :    deallocate memory allocated using ROSE_MALLOC.
   90313             : */
   90314           0 : void SgDefaultOptionStmt::operator delete(void *Pointer, size_t Size)
   90315             : {
   90316             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   90317             :      * or throwing an exception. */
   90318           0 :     ALLOC_MUTEX(SgDefaultOptionStmt, lock);
   90319             : 
   90320             : #if USE_CPP_NEW_DELETE_OPERATORS
   90321             :     ROSE_FREE(Pointer);
   90322             : #else
   90323             : #if ROSE_PEDANTIC_ALLOC
   90324             :     ROSE_ASSERT(Size == sizeof(SgDefaultOptionStmt));
   90325             : #else
   90326           0 :     if (Size != sizeof(SgDefaultOptionStmt)) {
   90327           0 :       ROSE_FREE(Pointer);
   90328           0 :       ALLOC_MUTEX(SgDefaultOptionStmt, unlock);
   90329             :       return;
   90330             :     }
   90331             : #endif
   90332             : 
   90333           0 :     SgDefaultOptionStmt * object = (SgDefaultOptionStmt*) Pointer;
   90334           0 :     ROSE_ASSERT(object != nullptr);
   90335             : 
   90336             : #if ROSE_ALLOC_TRACE == 2
   90337             : //  printf("SgDefaultOptionStmt::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgDefaultOptionStmt::next_node);
   90338             :     printf("SgDefaultOptionStmt::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgDefaultOptionStmt::next_node);
   90339             : #endif
   90340             : 
   90341             : #if ROSE_PEDANTIC_ALLOC
   90342             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   90343             : #endif
   90344             : 
   90345             : #if ROSE_ALLOC_MEMSET == 1
   90346             : #elif ROSE_ALLOC_MEMSET == 2
   90347             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgDefaultOptionStmt) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   90348             : #elif ROSE_ALLOC_MEMSET == 3
   90349             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgDefaultOptionStmt) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   90350             : #endif
   90351             : 
   90352             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   90353             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   90354             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   90355             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   90356             : #else
   90357           0 :     object->p_freepointer = SgDefaultOptionStmt::next_node;
   90358           0 :     SgDefaultOptionStmt::next_node = object;
   90359             : #endif
   90360             : 
   90361             : #if ROSE_ALLOC_TRACE == 2
   90362             : //  printf("SgDefaultOptionStmt::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgDefaultOptionStmt::next_node);
   90363             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   90364             :     Rose::MemPool::snapshot(oss.str());
   90365             :     alloc_trace_cnt++;
   90366             : #endif
   90367             : 
   90368             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   90369             : 
   90370           0 :     ALLOC_MUTEX(SgDefaultOptionStmt, unlock);
   90371             : }
   90372             : 
   90373             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   90374             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   90375             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   90376             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   90377             : // Also, note comment below from Robb (copied from the Common.code file).
   90378             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   90379             : //
   90380             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   90381             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   90382             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   90383             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   90384             : #if 0
   90385             : void SgDefaultOptionStmt::operator delete(void* pointer) { SgDefaultOptionStmt::operator delete (pointer, sizeof(SgDefaultOptionStmt)); };
   90386             : #endif
   90387             : /* #line 90388 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   90388             : 
   90389             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   90390             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   90391             : // obviously imply C++.
   90392             : 
   90393             : // This implements the support within ROSE for memory pools.  Memory pools
   90394             : // support the most condensed usage of memory within the construction of
   90395             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   90396             : // by a new operator written for each class.
   90397             : 
   90398             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   90399             :     // User wants multi-thread support and POSIX threads are available.
   90400             : #   include <pthread.h>
   90401             :     static pthread_mutex_t SgBreakStmt_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   90402             : #else
   90403             :      // Cause synchronization to be skipped.
   90404             : #    ifndef ALLOC_MUTEX
   90405             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   90406             : #    endif
   90407             : #    ifdef _REENTRANT
   90408             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   90409             : #       ifdef _MSC_VER
   90410             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   90411             : #       else
   90412             : #           warning "POSIX threads are not available; synchronization being skipped"
   90413             : #       endif
   90414             : #    endif
   90415             : #endif
   90416             : 
   90417             : #ifndef ROSE_ALLOC_TRACE
   90418             : #  define ROSE_ALLOC_TRACE 0
   90419             : #endif
   90420             : 
   90421             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   90422             : #define ROSE_ALLOC_TRACE_CNT
   90423             : #include "memory-pool-snapshot.h"
   90424             : unsigned long alloc_trace_cnt = 0;
   90425             : #endif
   90426             : 
   90427             : #if ROSE_ALLOC_TRACE
   90428             : const unsigned SgBreakStmt::pool_size = 5;
   90429             : #else
   90430             : const unsigned SgBreakStmt::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   90431             : #endif
   90432             : 
   90433             : #ifndef ROSE_ALLOC_MEMSET
   90434             : #  define ROSE_ALLOC_MEMSET 0
   90435             : #endif
   90436             : 
   90437             : #ifndef ROSE_PEDANTIC_ALLOC
   90438             : #  define ROSE_PEDANTIC_ALLOC 0
   90439             : #endif
   90440             : 
   90441             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   90442             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   90443             : #endif
   90444             : 
   90445             : #if !defined(SGNODE__ALL_POOLS)
   90446             : #define SGNODE__ALL_POOLS
   90447             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   90448             : #endif
   90449             : 
   90450             : SgBreakStmt* SgBreakStmt::next_node = nullptr;
   90451             : std::vector<unsigned char*> SgBreakStmt::pools;
   90452             : 
   90453             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   90454             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   90455             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   90456             : // around this macro definition rather than each use).
   90457             : #ifndef ALLOC_MUTEX
   90458             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   90459             :         do {                                                                     \
   90460             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   90461             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   90462             :                 abort();                                                         \
   90463             :             }                                                                    \
   90464             :         } while (0);
   90465             : #endif
   90466             : 
   90467             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   90468             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   90469             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   90470             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   90471             : 
   90472             : /*! \brief New operator for SgBreakStmt.
   90473             : 
   90474             :    This new operator implements memory pools to provide most efficent 
   90475             :    use of the heap within construction of large ASTs.
   90476             : 
   90477             : \internal The new and delete operators use the lower level C malloc/free
   90478             :    function calls for performance and to make sure that mixing of malloc/free
   90479             :    and new/delete by the used can be caught more readily.  This may change
   90480             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   90481             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   90482             :    deallocate memory allocated using ROSE_MALLOC.
   90483             : */
   90484         272 : void *SgBreakStmt::operator new ( size_t Size )
   90485             : {
   90486             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   90487             :      * returning or throwing an exception. */
   90488         272 :     ALLOC_MUTEX(SgBreakStmt, lock);
   90489             : 
   90490             : #if ROSE_ALLOC_TRACE == 2
   90491             : //    printf("SgBreakStmt::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgBreakStmt::next_node);
   90492             : #endif
   90493             : 
   90494             : #if USE_CPP_NEW_DELETE_OPERATORS
   90495             :     void *mem = ROSE_MALLOC(Size);
   90496             :     ALLOC_MUTEX(SgBreakStmt, unlock);
   90497             :     return mem;
   90498             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   90499             : #if ROSE_PEDANTIC_ALLOC
   90500             :     ROSE_ASSERT(Size == sizeof(SgBreakStmt));
   90501             : #else
   90502         272 :     if (Size != sizeof(SgBreakStmt)) {
   90503           0 :       void * object = ROSE_MALLOC(Size);
   90504           0 :       ALLOC_MUTEX(SgBreakStmt, unlock);
   90505             :       return object;
   90506             :     }
   90507             : #endif
   90508             : 
   90509         272 :     if (SgBreakStmt::next_node == nullptr) {
   90510           8 :         SgBreakStmt * alloc = (SgBreakStmt*) ROSE_MALLOC ( SgBreakStmt::pool_size * sizeof(SgBreakStmt) );
   90511           8 :         ROSE_ASSERT(alloc != nullptr);
   90512             : 
   90513             : #if ROSE_ALLOC_TRACE == 2
   90514             : //        printf("SgBreakStmt::alloc\n  block[%zi] = [ %p , %p [\n", SgBreakStmt::pools.size(), alloc, alloc + SgBreakStmt::pool_size);
   90515             : #endif
   90516             : 
   90517             : #if ROSE_ALLOC_MEMSET == 1
   90518             : #elif ROSE_ALLOC_MEMSET == 2
   90519             :         memset(alloc, 0x00, SgBreakStmt::pool_size * sizeof(SgBreakStmt));
   90520             : #elif ROSE_ALLOC_MEMSET == 3
   90521             :         memset(alloc, 0xAA, SgBreakStmt::pool_size * sizeof(SgBreakStmt));
   90522             : #endif
   90523       16000 :         for (unsigned i=0; i < SgBreakStmt::pool_size-1; i++) {
   90524       15992 :           alloc[i].p_freepointer = &(alloc[i+1]);
   90525             :         }
   90526           8 :         alloc[SgBreakStmt::pool_size-1].p_freepointer = nullptr;
   90527             : 
   90528           8 :         SgBreakStmt::pools.push_back ( (unsigned char *) alloc );
   90529           8 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgBreakStmt::pool_size * sizeof(SgBreakStmt), V_SgBreakStmt ) );
   90530           8 :         SgBreakStmt::next_node = alloc;
   90531             :     }
   90532         272 :     ROSE_ASSERT(SgBreakStmt::next_node != nullptr);
   90533             : 
   90534         272 :     SgBreakStmt * object = SgBreakStmt::next_node;
   90535         272 :     SgBreakStmt::next_node = (SgBreakStmt*)(object->p_freepointer);
   90536             : 
   90537             : #if ROSE_ALLOC_TRACE == 2
   90538             :     printf("SgBreakStmt::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgBreakStmt::next_node);
   90539             : #endif
   90540             : 
   90541         272 :     SgNode * fp = object->p_freepointer;
   90542             : #if ROSE_ALLOC_MEMSET == 1
   90543             : #elif ROSE_ALLOC_MEMSET == 2
   90544             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgBreakStmt) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   90545             : #elif ROSE_ALLOC_MEMSET == 3
   90546             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgBreakStmt) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   90547             : #endif
   90548         272 :     object->p_freepointer = fp;
   90549             : 
   90550             : #if ROSE_ALLOC_TRACE == 2
   90551             : //    printf("SgBreakStmt::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgBreakStmt::next_node);
   90552             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   90553             :     Rose::MemPool::snapshot(oss.str());
   90554             :     alloc_trace_cnt++;
   90555             : #endif
   90556             : 
   90557         272 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   90558             : 
   90559         272 :     ALLOC_MUTEX(SgBreakStmt, unlock);
   90560             : 
   90561             :     return object;
   90562             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   90563             : }
   90564             : 
   90565             : 
   90566             : 
   90567             : /*! \brief Delete operator for SgBreakStmt.
   90568             : 
   90569             :    This delete operator implements deallocation using memory pools to 
   90570             :    provide most efficent use of the heap within construction of large ASTs.
   90571             : 
   90572             : \internal The new and delete operators use the lower level C malloc/free
   90573             :    function calls for performance and to make sure that mixing of malloc/free
   90574             :    and new/delete by the used can be caught more readily.  This may change
   90575             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   90576             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   90577             :    deallocate memory allocated using ROSE_MALLOC.
   90578             : */
   90579          60 : void SgBreakStmt::operator delete(void *Pointer, size_t Size)
   90580             : {
   90581             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   90582             :      * or throwing an exception. */
   90583          60 :     ALLOC_MUTEX(SgBreakStmt, lock);
   90584             : 
   90585             : #if USE_CPP_NEW_DELETE_OPERATORS
   90586             :     ROSE_FREE(Pointer);
   90587             : #else
   90588             : #if ROSE_PEDANTIC_ALLOC
   90589             :     ROSE_ASSERT(Size == sizeof(SgBreakStmt));
   90590             : #else
   90591          60 :     if (Size != sizeof(SgBreakStmt)) {
   90592           0 :       ROSE_FREE(Pointer);
   90593           0 :       ALLOC_MUTEX(SgBreakStmt, unlock);
   90594             :       return;
   90595             :     }
   90596             : #endif
   90597             : 
   90598          60 :     SgBreakStmt * object = (SgBreakStmt*) Pointer;
   90599          60 :     ROSE_ASSERT(object != nullptr);
   90600             : 
   90601             : #if ROSE_ALLOC_TRACE == 2
   90602             : //  printf("SgBreakStmt::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgBreakStmt::next_node);
   90603             :     printf("SgBreakStmt::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgBreakStmt::next_node);
   90604             : #endif
   90605             : 
   90606             : #if ROSE_PEDANTIC_ALLOC
   90607             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   90608             : #endif
   90609             : 
   90610             : #if ROSE_ALLOC_MEMSET == 1
   90611             : #elif ROSE_ALLOC_MEMSET == 2
   90612             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgBreakStmt) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   90613             : #elif ROSE_ALLOC_MEMSET == 3
   90614             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgBreakStmt) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   90615             : #endif
   90616             : 
   90617             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   90618             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   90619             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   90620             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   90621             : #else
   90622          60 :     object->p_freepointer = SgBreakStmt::next_node;
   90623          60 :     SgBreakStmt::next_node = object;
   90624             : #endif
   90625             : 
   90626             : #if ROSE_ALLOC_TRACE == 2
   90627             : //  printf("SgBreakStmt::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgBreakStmt::next_node);
   90628             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   90629             :     Rose::MemPool::snapshot(oss.str());
   90630             :     alloc_trace_cnt++;
   90631             : #endif
   90632             : 
   90633             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   90634             : 
   90635          60 :     ALLOC_MUTEX(SgBreakStmt, unlock);
   90636             : }
   90637             : 
   90638             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   90639             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   90640             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   90641             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   90642             : // Also, note comment below from Robb (copied from the Common.code file).
   90643             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   90644             : //
   90645             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   90646             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   90647             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   90648             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   90649             : #if 0
   90650             : void SgBreakStmt::operator delete(void* pointer) { SgBreakStmt::operator delete (pointer, sizeof(SgBreakStmt)); };
   90651             : #endif
   90652             : /* #line 90653 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   90653             : 
   90654             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   90655             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   90656             : // obviously imply C++.
   90657             : 
   90658             : // This implements the support within ROSE for memory pools.  Memory pools
   90659             : // support the most condensed usage of memory within the construction of
   90660             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   90661             : // by a new operator written for each class.
   90662             : 
   90663             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   90664             :     // User wants multi-thread support and POSIX threads are available.
   90665             : #   include <pthread.h>
   90666             :     static pthread_mutex_t SgContinueStmt_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   90667             : #else
   90668             :      // Cause synchronization to be skipped.
   90669             : #    ifndef ALLOC_MUTEX
   90670             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   90671             : #    endif
   90672             : #    ifdef _REENTRANT
   90673             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   90674             : #       ifdef _MSC_VER
   90675             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   90676             : #       else
   90677             : #           warning "POSIX threads are not available; synchronization being skipped"
   90678             : #       endif
   90679             : #    endif
   90680             : #endif
   90681             : 
   90682             : #ifndef ROSE_ALLOC_TRACE
   90683             : #  define ROSE_ALLOC_TRACE 0
   90684             : #endif
   90685             : 
   90686             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   90687             : #define ROSE_ALLOC_TRACE_CNT
   90688             : #include "memory-pool-snapshot.h"
   90689             : unsigned long alloc_trace_cnt = 0;
   90690             : #endif
   90691             : 
   90692             : #if ROSE_ALLOC_TRACE
   90693             : const unsigned SgContinueStmt::pool_size = 5;
   90694             : #else
   90695             : const unsigned SgContinueStmt::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   90696             : #endif
   90697             : 
   90698             : #ifndef ROSE_ALLOC_MEMSET
   90699             : #  define ROSE_ALLOC_MEMSET 0
   90700             : #endif
   90701             : 
   90702             : #ifndef ROSE_PEDANTIC_ALLOC
   90703             : #  define ROSE_PEDANTIC_ALLOC 0
   90704             : #endif
   90705             : 
   90706             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   90707             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   90708             : #endif
   90709             : 
   90710             : #if !defined(SGNODE__ALL_POOLS)
   90711             : #define SGNODE__ALL_POOLS
   90712             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   90713             : #endif
   90714             : 
   90715             : SgContinueStmt* SgContinueStmt::next_node = nullptr;
   90716             : std::vector<unsigned char*> SgContinueStmt::pools;
   90717             : 
   90718             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   90719             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   90720             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   90721             : // around this macro definition rather than each use).
   90722             : #ifndef ALLOC_MUTEX
   90723             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   90724             :         do {                                                                     \
   90725             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   90726             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   90727             :                 abort();                                                         \
   90728             :             }                                                                    \
   90729             :         } while (0);
   90730             : #endif
   90731             : 
   90732             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   90733             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   90734             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   90735             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   90736             : 
   90737             : /*! \brief New operator for SgContinueStmt.
   90738             : 
   90739             :    This new operator implements memory pools to provide most efficent 
   90740             :    use of the heap within construction of large ASTs.
   90741             : 
   90742             : \internal The new and delete operators use the lower level C malloc/free
   90743             :    function calls for performance and to make sure that mixing of malloc/free
   90744             :    and new/delete by the used can be caught more readily.  This may change
   90745             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   90746             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   90747             :    deallocate memory allocated using ROSE_MALLOC.
   90748             : */
   90749          18 : void *SgContinueStmt::operator new ( size_t Size )
   90750             : {
   90751             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   90752             :      * returning or throwing an exception. */
   90753          18 :     ALLOC_MUTEX(SgContinueStmt, lock);
   90754             : 
   90755             : #if ROSE_ALLOC_TRACE == 2
   90756             : //    printf("SgContinueStmt::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgContinueStmt::next_node);
   90757             : #endif
   90758             : 
   90759             : #if USE_CPP_NEW_DELETE_OPERATORS
   90760             :     void *mem = ROSE_MALLOC(Size);
   90761             :     ALLOC_MUTEX(SgContinueStmt, unlock);
   90762             :     return mem;
   90763             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   90764             : #if ROSE_PEDANTIC_ALLOC
   90765             :     ROSE_ASSERT(Size == sizeof(SgContinueStmt));
   90766             : #else
   90767          18 :     if (Size != sizeof(SgContinueStmt)) {
   90768           0 :       void * object = ROSE_MALLOC(Size);
   90769           0 :       ALLOC_MUTEX(SgContinueStmt, unlock);
   90770             :       return object;
   90771             :     }
   90772             : #endif
   90773             : 
   90774          18 :     if (SgContinueStmt::next_node == nullptr) {
   90775           8 :         SgContinueStmt * alloc = (SgContinueStmt*) ROSE_MALLOC ( SgContinueStmt::pool_size * sizeof(SgContinueStmt) );
   90776           8 :         ROSE_ASSERT(alloc != nullptr);
   90777             : 
   90778             : #if ROSE_ALLOC_TRACE == 2
   90779             : //        printf("SgContinueStmt::alloc\n  block[%zi] = [ %p , %p [\n", SgContinueStmt::pools.size(), alloc, alloc + SgContinueStmt::pool_size);
   90780             : #endif
   90781             : 
   90782             : #if ROSE_ALLOC_MEMSET == 1
   90783             : #elif ROSE_ALLOC_MEMSET == 2
   90784             :         memset(alloc, 0x00, SgContinueStmt::pool_size * sizeof(SgContinueStmt));
   90785             : #elif ROSE_ALLOC_MEMSET == 3
   90786             :         memset(alloc, 0xAA, SgContinueStmt::pool_size * sizeof(SgContinueStmt));
   90787             : #endif
   90788       16000 :         for (unsigned i=0; i < SgContinueStmt::pool_size-1; i++) {
   90789       15992 :           alloc[i].p_freepointer = &(alloc[i+1]);
   90790             :         }
   90791           8 :         alloc[SgContinueStmt::pool_size-1].p_freepointer = nullptr;
   90792             : 
   90793           8 :         SgContinueStmt::pools.push_back ( (unsigned char *) alloc );
   90794           8 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgContinueStmt::pool_size * sizeof(SgContinueStmt), V_SgContinueStmt ) );
   90795           8 :         SgContinueStmt::next_node = alloc;
   90796             :     }
   90797          18 :     ROSE_ASSERT(SgContinueStmt::next_node != nullptr);
   90798             : 
   90799          18 :     SgContinueStmt * object = SgContinueStmt::next_node;
   90800          18 :     SgContinueStmt::next_node = (SgContinueStmt*)(object->p_freepointer);
   90801             : 
   90802             : #if ROSE_ALLOC_TRACE == 2
   90803             :     printf("SgContinueStmt::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgContinueStmt::next_node);
   90804             : #endif
   90805             : 
   90806          18 :     SgNode * fp = object->p_freepointer;
   90807             : #if ROSE_ALLOC_MEMSET == 1
   90808             : #elif ROSE_ALLOC_MEMSET == 2
   90809             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgContinueStmt) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   90810             : #elif ROSE_ALLOC_MEMSET == 3
   90811             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgContinueStmt) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   90812             : #endif
   90813          18 :     object->p_freepointer = fp;
   90814             : 
   90815             : #if ROSE_ALLOC_TRACE == 2
   90816             : //    printf("SgContinueStmt::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgContinueStmt::next_node);
   90817             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   90818             :     Rose::MemPool::snapshot(oss.str());
   90819             :     alloc_trace_cnt++;
   90820             : #endif
   90821             : 
   90822          18 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   90823             : 
   90824          18 :     ALLOC_MUTEX(SgContinueStmt, unlock);
   90825             : 
   90826             :     return object;
   90827             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   90828             : }
   90829             : 
   90830             : 
   90831             : 
   90832             : /*! \brief Delete operator for SgContinueStmt.
   90833             : 
   90834             :    This delete operator implements deallocation using memory pools to 
   90835             :    provide most efficent use of the heap within construction of large ASTs.
   90836             : 
   90837             : \internal The new and delete operators use the lower level C malloc/free
   90838             :    function calls for performance and to make sure that mixing of malloc/free
   90839             :    and new/delete by the used can be caught more readily.  This may change
   90840             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   90841             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   90842             :    deallocate memory allocated using ROSE_MALLOC.
   90843             : */
   90844           4 : void SgContinueStmt::operator delete(void *Pointer, size_t Size)
   90845             : {
   90846             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   90847             :      * or throwing an exception. */
   90848           4 :     ALLOC_MUTEX(SgContinueStmt, lock);
   90849             : 
   90850             : #if USE_CPP_NEW_DELETE_OPERATORS
   90851             :     ROSE_FREE(Pointer);
   90852             : #else
   90853             : #if ROSE_PEDANTIC_ALLOC
   90854             :     ROSE_ASSERT(Size == sizeof(SgContinueStmt));
   90855             : #else
   90856           4 :     if (Size != sizeof(SgContinueStmt)) {
   90857           0 :       ROSE_FREE(Pointer);
   90858           0 :       ALLOC_MUTEX(SgContinueStmt, unlock);
   90859             :       return;
   90860             :     }
   90861             : #endif
   90862             : 
   90863           4 :     SgContinueStmt * object = (SgContinueStmt*) Pointer;
   90864           4 :     ROSE_ASSERT(object != nullptr);
   90865             : 
   90866             : #if ROSE_ALLOC_TRACE == 2
   90867             : //  printf("SgContinueStmt::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgContinueStmt::next_node);
   90868             :     printf("SgContinueStmt::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgContinueStmt::next_node);
   90869             : #endif
   90870             : 
   90871             : #if ROSE_PEDANTIC_ALLOC
   90872             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   90873             : #endif
   90874             : 
   90875             : #if ROSE_ALLOC_MEMSET == 1
   90876             : #elif ROSE_ALLOC_MEMSET == 2
   90877             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgContinueStmt) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   90878             : #elif ROSE_ALLOC_MEMSET == 3
   90879             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgContinueStmt) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   90880             : #endif
   90881             : 
   90882             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   90883             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   90884             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   90885             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   90886             : #else
   90887           4 :     object->p_freepointer = SgContinueStmt::next_node;
   90888           4 :     SgContinueStmt::next_node = object;
   90889             : #endif
   90890             : 
   90891             : #if ROSE_ALLOC_TRACE == 2
   90892             : //  printf("SgContinueStmt::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgContinueStmt::next_node);
   90893             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   90894             :     Rose::MemPool::snapshot(oss.str());
   90895             :     alloc_trace_cnt++;
   90896             : #endif
   90897             : 
   90898             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   90899             : 
   90900           4 :     ALLOC_MUTEX(SgContinueStmt, unlock);
   90901             : }
   90902             : 
   90903             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   90904             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   90905             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   90906             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   90907             : // Also, note comment below from Robb (copied from the Common.code file).
   90908             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   90909             : //
   90910             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   90911             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   90912             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   90913             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   90914             : #if 0
   90915             : void SgContinueStmt::operator delete(void* pointer) { SgContinueStmt::operator delete (pointer, sizeof(SgContinueStmt)); };
   90916             : #endif
   90917             : /* #line 90918 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   90918             : 
   90919             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   90920             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   90921             : // obviously imply C++.
   90922             : 
   90923             : // This implements the support within ROSE for memory pools.  Memory pools
   90924             : // support the most condensed usage of memory within the construction of
   90925             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   90926             : // by a new operator written for each class.
   90927             : 
   90928             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   90929             :     // User wants multi-thread support and POSIX threads are available.
   90930             : #   include <pthread.h>
   90931             :     static pthread_mutex_t SgReturnStmt_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   90932             : #else
   90933             :      // Cause synchronization to be skipped.
   90934             : #    ifndef ALLOC_MUTEX
   90935             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   90936             : #    endif
   90937             : #    ifdef _REENTRANT
   90938             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   90939             : #       ifdef _MSC_VER
   90940             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   90941             : #       else
   90942             : #           warning "POSIX threads are not available; synchronization being skipped"
   90943             : #       endif
   90944             : #    endif
   90945             : #endif
   90946             : 
   90947             : #ifndef ROSE_ALLOC_TRACE
   90948             : #  define ROSE_ALLOC_TRACE 0
   90949             : #endif
   90950             : 
   90951             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   90952             : #define ROSE_ALLOC_TRACE_CNT
   90953             : #include "memory-pool-snapshot.h"
   90954             : unsigned long alloc_trace_cnt = 0;
   90955             : #endif
   90956             : 
   90957             : #if ROSE_ALLOC_TRACE
   90958             : const unsigned SgReturnStmt::pool_size = 5;
   90959             : #else
   90960             : const unsigned SgReturnStmt::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   90961             : #endif
   90962             : 
   90963             : #ifndef ROSE_ALLOC_MEMSET
   90964             : #  define ROSE_ALLOC_MEMSET 0
   90965             : #endif
   90966             : 
   90967             : #ifndef ROSE_PEDANTIC_ALLOC
   90968             : #  define ROSE_PEDANTIC_ALLOC 0
   90969             : #endif
   90970             : 
   90971             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   90972             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   90973             : #endif
   90974             : 
   90975             : #if !defined(SGNODE__ALL_POOLS)
   90976             : #define SGNODE__ALL_POOLS
   90977             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   90978             : #endif
   90979             : 
   90980             : SgReturnStmt* SgReturnStmt::next_node = nullptr;
   90981             : std::vector<unsigned char*> SgReturnStmt::pools;
   90982             : 
   90983             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   90984             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   90985             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   90986             : // around this macro definition rather than each use).
   90987             : #ifndef ALLOC_MUTEX
   90988             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   90989             :         do {                                                                     \
   90990             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   90991             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   90992             :                 abort();                                                         \
   90993             :             }                                                                    \
   90994             :         } while (0);
   90995             : #endif
   90996             : 
   90997             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   90998             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   90999             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   91000             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   91001             : 
   91002             : /*! \brief New operator for SgReturnStmt.
   91003             : 
   91004             :    This new operator implements memory pools to provide most efficent 
   91005             :    use of the heap within construction of large ASTs.
   91006             : 
   91007             : \internal The new and delete operators use the lower level C malloc/free
   91008             :    function calls for performance and to make sure that mixing of malloc/free
   91009             :    and new/delete by the used can be caught more readily.  This may change
   91010             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   91011             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   91012             :    deallocate memory allocated using ROSE_MALLOC.
   91013             : */
   91014       15714 : void *SgReturnStmt::operator new ( size_t Size )
   91015             : {
   91016             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   91017             :      * returning or throwing an exception. */
   91018       15714 :     ALLOC_MUTEX(SgReturnStmt, lock);
   91019             : 
   91020             : #if ROSE_ALLOC_TRACE == 2
   91021             : //    printf("SgReturnStmt::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgReturnStmt::next_node);
   91022             : #endif
   91023             : 
   91024             : #if USE_CPP_NEW_DELETE_OPERATORS
   91025             :     void *mem = ROSE_MALLOC(Size);
   91026             :     ALLOC_MUTEX(SgReturnStmt, unlock);
   91027             :     return mem;
   91028             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   91029             : #if ROSE_PEDANTIC_ALLOC
   91030             :     ROSE_ASSERT(Size == sizeof(SgReturnStmt));
   91031             : #else
   91032       15714 :     if (Size != sizeof(SgReturnStmt)) {
   91033           0 :       void * object = ROSE_MALLOC(Size);
   91034           0 :       ALLOC_MUTEX(SgReturnStmt, unlock);
   91035             :       return object;
   91036             :     }
   91037             : #endif
   91038             : 
   91039       15714 :     if (SgReturnStmt::next_node == nullptr) {
   91040         247 :         SgReturnStmt * alloc = (SgReturnStmt*) ROSE_MALLOC ( SgReturnStmt::pool_size * sizeof(SgReturnStmt) );
   91041         247 :         ROSE_ASSERT(alloc != nullptr);
   91042             : 
   91043             : #if ROSE_ALLOC_TRACE == 2
   91044             : //        printf("SgReturnStmt::alloc\n  block[%zi] = [ %p , %p [\n", SgReturnStmt::pools.size(), alloc, alloc + SgReturnStmt::pool_size);
   91045             : #endif
   91046             : 
   91047             : #if ROSE_ALLOC_MEMSET == 1
   91048             : #elif ROSE_ALLOC_MEMSET == 2
   91049             :         memset(alloc, 0x00, SgReturnStmt::pool_size * sizeof(SgReturnStmt));
   91050             : #elif ROSE_ALLOC_MEMSET == 3
   91051             :         memset(alloc, 0xAA, SgReturnStmt::pool_size * sizeof(SgReturnStmt));
   91052             : #endif
   91053      494000 :         for (unsigned i=0; i < SgReturnStmt::pool_size-1; i++) {
   91054      493753 :           alloc[i].p_freepointer = &(alloc[i+1]);
   91055             :         }
   91056         247 :         alloc[SgReturnStmt::pool_size-1].p_freepointer = nullptr;
   91057             : 
   91058         247 :         SgReturnStmt::pools.push_back ( (unsigned char *) alloc );
   91059         247 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgReturnStmt::pool_size * sizeof(SgReturnStmt), V_SgReturnStmt ) );
   91060         247 :         SgReturnStmt::next_node = alloc;
   91061             :     }
   91062       15714 :     ROSE_ASSERT(SgReturnStmt::next_node != nullptr);
   91063             : 
   91064       15714 :     SgReturnStmt * object = SgReturnStmt::next_node;
   91065       15714 :     SgReturnStmt::next_node = (SgReturnStmt*)(object->p_freepointer);
   91066             : 
   91067             : #if ROSE_ALLOC_TRACE == 2
   91068             :     printf("SgReturnStmt::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgReturnStmt::next_node);
   91069             : #endif
   91070             : 
   91071       15714 :     SgNode * fp = object->p_freepointer;
   91072             : #if ROSE_ALLOC_MEMSET == 1
   91073             : #elif ROSE_ALLOC_MEMSET == 2
   91074             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgReturnStmt) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   91075             : #elif ROSE_ALLOC_MEMSET == 3
   91076             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgReturnStmt) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   91077             : #endif
   91078       15714 :     object->p_freepointer = fp;
   91079             : 
   91080             : #if ROSE_ALLOC_TRACE == 2
   91081             : //    printf("SgReturnStmt::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgReturnStmt::next_node);
   91082             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   91083             :     Rose::MemPool::snapshot(oss.str());
   91084             :     alloc_trace_cnt++;
   91085             : #endif
   91086             : 
   91087       15714 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   91088             : 
   91089       15714 :     ALLOC_MUTEX(SgReturnStmt, unlock);
   91090             : 
   91091             :     return object;
   91092             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   91093             : }
   91094             : 
   91095             : 
   91096             : 
   91097             : /*! \brief Delete operator for SgReturnStmt.
   91098             : 
   91099             :    This delete operator implements deallocation using memory pools to 
   91100             :    provide most efficent use of the heap within construction of large ASTs.
   91101             : 
   91102             : \internal The new and delete operators use the lower level C malloc/free
   91103             :    function calls for performance and to make sure that mixing of malloc/free
   91104             :    and new/delete by the used can be caught more readily.  This may change
   91105             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   91106             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   91107             :    deallocate memory allocated using ROSE_MALLOC.
   91108             : */
   91109        2810 : void SgReturnStmt::operator delete(void *Pointer, size_t Size)
   91110             : {
   91111             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   91112             :      * or throwing an exception. */
   91113        2810 :     ALLOC_MUTEX(SgReturnStmt, lock);
   91114             : 
   91115             : #if USE_CPP_NEW_DELETE_OPERATORS
   91116             :     ROSE_FREE(Pointer);
   91117             : #else
   91118             : #if ROSE_PEDANTIC_ALLOC
   91119             :     ROSE_ASSERT(Size == sizeof(SgReturnStmt));
   91120             : #else
   91121        2810 :     if (Size != sizeof(SgReturnStmt)) {
   91122           0 :       ROSE_FREE(Pointer);
   91123           0 :       ALLOC_MUTEX(SgReturnStmt, unlock);
   91124             :       return;
   91125             :     }
   91126             : #endif
   91127             : 
   91128        2810 :     SgReturnStmt * object = (SgReturnStmt*) Pointer;
   91129        2810 :     ROSE_ASSERT(object != nullptr);
   91130             : 
   91131             : #if ROSE_ALLOC_TRACE == 2
   91132             : //  printf("SgReturnStmt::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgReturnStmt::next_node);
   91133             :     printf("SgReturnStmt::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgReturnStmt::next_node);
   91134             : #endif
   91135             : 
   91136             : #if ROSE_PEDANTIC_ALLOC
   91137             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   91138             : #endif
   91139             : 
   91140             : #if ROSE_ALLOC_MEMSET == 1
   91141             : #elif ROSE_ALLOC_MEMSET == 2
   91142             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgReturnStmt) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   91143             : #elif ROSE_ALLOC_MEMSET == 3
   91144             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgReturnStmt) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   91145             : #endif
   91146             : 
   91147             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   91148             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   91149             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   91150             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   91151             : #else
   91152        2810 :     object->p_freepointer = SgReturnStmt::next_node;
   91153        2810 :     SgReturnStmt::next_node = object;
   91154             : #endif
   91155             : 
   91156             : #if ROSE_ALLOC_TRACE == 2
   91157             : //  printf("SgReturnStmt::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgReturnStmt::next_node);
   91158             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   91159             :     Rose::MemPool::snapshot(oss.str());
   91160             :     alloc_trace_cnt++;
   91161             : #endif
   91162             : 
   91163             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   91164             : 
   91165        2810 :     ALLOC_MUTEX(SgReturnStmt, unlock);
   91166             : }
   91167             : 
   91168             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   91169             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   91170             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   91171             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   91172             : // Also, note comment below from Robb (copied from the Common.code file).
   91173             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   91174             : //
   91175             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   91176             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   91177             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   91178             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   91179             : #if 0
   91180             : void SgReturnStmt::operator delete(void* pointer) { SgReturnStmt::operator delete (pointer, sizeof(SgReturnStmt)); };
   91181             : #endif
   91182             : /* #line 91183 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   91183             : 
   91184             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   91185             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   91186             : // obviously imply C++.
   91187             : 
   91188             : // This implements the support within ROSE for memory pools.  Memory pools
   91189             : // support the most condensed usage of memory within the construction of
   91190             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   91191             : // by a new operator written for each class.
   91192             : 
   91193             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   91194             :     // User wants multi-thread support and POSIX threads are available.
   91195             : #   include <pthread.h>
   91196             :     static pthread_mutex_t SgGotoStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   91197             : #else
   91198             :      // Cause synchronization to be skipped.
   91199             : #    ifndef ALLOC_MUTEX
   91200             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   91201             : #    endif
   91202             : #    ifdef _REENTRANT
   91203             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   91204             : #       ifdef _MSC_VER
   91205             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   91206             : #       else
   91207             : #           warning "POSIX threads are not available; synchronization being skipped"
   91208             : #       endif
   91209             : #    endif
   91210             : #endif
   91211             : 
   91212             : #ifndef ROSE_ALLOC_TRACE
   91213             : #  define ROSE_ALLOC_TRACE 0
   91214             : #endif
   91215             : 
   91216             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   91217             : #define ROSE_ALLOC_TRACE_CNT
   91218             : #include "memory-pool-snapshot.h"
   91219             : unsigned long alloc_trace_cnt = 0;
   91220             : #endif
   91221             : 
   91222             : #if ROSE_ALLOC_TRACE
   91223             : const unsigned SgGotoStatement::pool_size = 5;
   91224             : #else
   91225             : const unsigned SgGotoStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   91226             : #endif
   91227             : 
   91228             : #ifndef ROSE_ALLOC_MEMSET
   91229             : #  define ROSE_ALLOC_MEMSET 0
   91230             : #endif
   91231             : 
   91232             : #ifndef ROSE_PEDANTIC_ALLOC
   91233             : #  define ROSE_PEDANTIC_ALLOC 0
   91234             : #endif
   91235             : 
   91236             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   91237             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   91238             : #endif
   91239             : 
   91240             : #if !defined(SGNODE__ALL_POOLS)
   91241             : #define SGNODE__ALL_POOLS
   91242             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   91243             : #endif
   91244             : 
   91245             : SgGotoStatement* SgGotoStatement::next_node = nullptr;
   91246             : std::vector<unsigned char*> SgGotoStatement::pools;
   91247             : 
   91248             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   91249             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   91250             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   91251             : // around this macro definition rather than each use).
   91252             : #ifndef ALLOC_MUTEX
   91253             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   91254             :         do {                                                                     \
   91255             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   91256             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   91257             :                 abort();                                                         \
   91258             :             }                                                                    \
   91259             :         } while (0);
   91260             : #endif
   91261             : 
   91262             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   91263             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   91264             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   91265             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   91266             : 
   91267             : /*! \brief New operator for SgGotoStatement.
   91268             : 
   91269             :    This new operator implements memory pools to provide most efficent 
   91270             :    use of the heap within construction of large ASTs.
   91271             : 
   91272             : \internal The new and delete operators use the lower level C malloc/free
   91273             :    function calls for performance and to make sure that mixing of malloc/free
   91274             :    and new/delete by the used can be caught more readily.  This may change
   91275             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   91276             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   91277             :    deallocate memory allocated using ROSE_MALLOC.
   91278             : */
   91279           4 : void *SgGotoStatement::operator new ( size_t Size )
   91280             : {
   91281             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   91282             :      * returning or throwing an exception. */
   91283           4 :     ALLOC_MUTEX(SgGotoStatement, lock);
   91284             : 
   91285             : #if ROSE_ALLOC_TRACE == 2
   91286             : //    printf("SgGotoStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgGotoStatement::next_node);
   91287             : #endif
   91288             : 
   91289             : #if USE_CPP_NEW_DELETE_OPERATORS
   91290             :     void *mem = ROSE_MALLOC(Size);
   91291             :     ALLOC_MUTEX(SgGotoStatement, unlock);
   91292             :     return mem;
   91293             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   91294             : #if ROSE_PEDANTIC_ALLOC
   91295             :     ROSE_ASSERT(Size == sizeof(SgGotoStatement));
   91296             : #else
   91297           4 :     if (Size != sizeof(SgGotoStatement)) {
   91298           0 :       void * object = ROSE_MALLOC(Size);
   91299           0 :       ALLOC_MUTEX(SgGotoStatement, unlock);
   91300             :       return object;
   91301             :     }
   91302             : #endif
   91303             : 
   91304           4 :     if (SgGotoStatement::next_node == nullptr) {
   91305           3 :         SgGotoStatement * alloc = (SgGotoStatement*) ROSE_MALLOC ( SgGotoStatement::pool_size * sizeof(SgGotoStatement) );
   91306           3 :         ROSE_ASSERT(alloc != nullptr);
   91307             : 
   91308             : #if ROSE_ALLOC_TRACE == 2
   91309             : //        printf("SgGotoStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgGotoStatement::pools.size(), alloc, alloc + SgGotoStatement::pool_size);
   91310             : #endif
   91311             : 
   91312             : #if ROSE_ALLOC_MEMSET == 1
   91313             : #elif ROSE_ALLOC_MEMSET == 2
   91314             :         memset(alloc, 0x00, SgGotoStatement::pool_size * sizeof(SgGotoStatement));
   91315             : #elif ROSE_ALLOC_MEMSET == 3
   91316             :         memset(alloc, 0xAA, SgGotoStatement::pool_size * sizeof(SgGotoStatement));
   91317             : #endif
   91318        6000 :         for (unsigned i=0; i < SgGotoStatement::pool_size-1; i++) {
   91319        5997 :           alloc[i].p_freepointer = &(alloc[i+1]);
   91320             :         }
   91321           3 :         alloc[SgGotoStatement::pool_size-1].p_freepointer = nullptr;
   91322             : 
   91323           3 :         SgGotoStatement::pools.push_back ( (unsigned char *) alloc );
   91324           3 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgGotoStatement::pool_size * sizeof(SgGotoStatement), V_SgGotoStatement ) );
   91325           3 :         SgGotoStatement::next_node = alloc;
   91326             :     }
   91327           4 :     ROSE_ASSERT(SgGotoStatement::next_node != nullptr);
   91328             : 
   91329           4 :     SgGotoStatement * object = SgGotoStatement::next_node;
   91330           4 :     SgGotoStatement::next_node = (SgGotoStatement*)(object->p_freepointer);
   91331             : 
   91332             : #if ROSE_ALLOC_TRACE == 2
   91333             :     printf("SgGotoStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgGotoStatement::next_node);
   91334             : #endif
   91335             : 
   91336           4 :     SgNode * fp = object->p_freepointer;
   91337             : #if ROSE_ALLOC_MEMSET == 1
   91338             : #elif ROSE_ALLOC_MEMSET == 2
   91339             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgGotoStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   91340             : #elif ROSE_ALLOC_MEMSET == 3
   91341             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgGotoStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   91342             : #endif
   91343           4 :     object->p_freepointer = fp;
   91344             : 
   91345             : #if ROSE_ALLOC_TRACE == 2
   91346             : //    printf("SgGotoStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgGotoStatement::next_node);
   91347             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   91348             :     Rose::MemPool::snapshot(oss.str());
   91349             :     alloc_trace_cnt++;
   91350             : #endif
   91351             : 
   91352           4 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   91353             : 
   91354           4 :     ALLOC_MUTEX(SgGotoStatement, unlock);
   91355             : 
   91356             :     return object;
   91357             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   91358             : }
   91359             : 
   91360             : 
   91361             : 
   91362             : /*! \brief Delete operator for SgGotoStatement.
   91363             : 
   91364             :    This delete operator implements deallocation using memory pools to 
   91365             :    provide most efficent use of the heap within construction of large ASTs.
   91366             : 
   91367             : \internal The new and delete operators use the lower level C malloc/free
   91368             :    function calls for performance and to make sure that mixing of malloc/free
   91369             :    and new/delete by the used can be caught more readily.  This may change
   91370             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   91371             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   91372             :    deallocate memory allocated using ROSE_MALLOC.
   91373             : */
   91374           0 : void SgGotoStatement::operator delete(void *Pointer, size_t Size)
   91375             : {
   91376             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   91377             :      * or throwing an exception. */
   91378           0 :     ALLOC_MUTEX(SgGotoStatement, lock);
   91379             : 
   91380             : #if USE_CPP_NEW_DELETE_OPERATORS
   91381             :     ROSE_FREE(Pointer);
   91382             : #else
   91383             : #if ROSE_PEDANTIC_ALLOC
   91384             :     ROSE_ASSERT(Size == sizeof(SgGotoStatement));
   91385             : #else
   91386           0 :     if (Size != sizeof(SgGotoStatement)) {
   91387           0 :       ROSE_FREE(Pointer);
   91388           0 :       ALLOC_MUTEX(SgGotoStatement, unlock);
   91389             :       return;
   91390             :     }
   91391             : #endif
   91392             : 
   91393           0 :     SgGotoStatement * object = (SgGotoStatement*) Pointer;
   91394           0 :     ROSE_ASSERT(object != nullptr);
   91395             : 
   91396             : #if ROSE_ALLOC_TRACE == 2
   91397             : //  printf("SgGotoStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgGotoStatement::next_node);
   91398             :     printf("SgGotoStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgGotoStatement::next_node);
   91399             : #endif
   91400             : 
   91401             : #if ROSE_PEDANTIC_ALLOC
   91402             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   91403             : #endif
   91404             : 
   91405             : #if ROSE_ALLOC_MEMSET == 1
   91406             : #elif ROSE_ALLOC_MEMSET == 2
   91407             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgGotoStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   91408             : #elif ROSE_ALLOC_MEMSET == 3
   91409             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgGotoStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   91410             : #endif
   91411             : 
   91412             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   91413             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   91414             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   91415             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   91416             : #else
   91417           0 :     object->p_freepointer = SgGotoStatement::next_node;
   91418           0 :     SgGotoStatement::next_node = object;
   91419             : #endif
   91420             : 
   91421             : #if ROSE_ALLOC_TRACE == 2
   91422             : //  printf("SgGotoStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgGotoStatement::next_node);
   91423             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   91424             :     Rose::MemPool::snapshot(oss.str());
   91425             :     alloc_trace_cnt++;
   91426             : #endif
   91427             : 
   91428             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   91429             : 
   91430           0 :     ALLOC_MUTEX(SgGotoStatement, unlock);
   91431             : }
   91432             : 
   91433             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   91434             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   91435             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   91436             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   91437             : // Also, note comment below from Robb (copied from the Common.code file).
   91438             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   91439             : //
   91440             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   91441             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   91442             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   91443             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   91444             : #if 0
   91445             : void SgGotoStatement::operator delete(void* pointer) { SgGotoStatement::operator delete (pointer, sizeof(SgGotoStatement)); };
   91446             : #endif
   91447             : /* #line 91448 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   91448             : 
   91449             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   91450             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   91451             : // obviously imply C++.
   91452             : 
   91453             : // This implements the support within ROSE for memory pools.  Memory pools
   91454             : // support the most condensed usage of memory within the construction of
   91455             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   91456             : // by a new operator written for each class.
   91457             : 
   91458             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   91459             :     // User wants multi-thread support and POSIX threads are available.
   91460             : #   include <pthread.h>
   91461             :     static pthread_mutex_t SgSpawnStmt_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   91462             : #else
   91463             :      // Cause synchronization to be skipped.
   91464             : #    ifndef ALLOC_MUTEX
   91465             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   91466             : #    endif
   91467             : #    ifdef _REENTRANT
   91468             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   91469             : #       ifdef _MSC_VER
   91470             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   91471             : #       else
   91472             : #           warning "POSIX threads are not available; synchronization being skipped"
   91473             : #       endif
   91474             : #    endif
   91475             : #endif
   91476             : 
   91477             : #ifndef ROSE_ALLOC_TRACE
   91478             : #  define ROSE_ALLOC_TRACE 0
   91479             : #endif
   91480             : 
   91481             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   91482             : #define ROSE_ALLOC_TRACE_CNT
   91483             : #include "memory-pool-snapshot.h"
   91484             : unsigned long alloc_trace_cnt = 0;
   91485             : #endif
   91486             : 
   91487             : #if ROSE_ALLOC_TRACE
   91488             : const unsigned SgSpawnStmt::pool_size = 5;
   91489             : #else
   91490             : const unsigned SgSpawnStmt::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   91491             : #endif
   91492             : 
   91493             : #ifndef ROSE_ALLOC_MEMSET
   91494             : #  define ROSE_ALLOC_MEMSET 0
   91495             : #endif
   91496             : 
   91497             : #ifndef ROSE_PEDANTIC_ALLOC
   91498             : #  define ROSE_PEDANTIC_ALLOC 0
   91499             : #endif
   91500             : 
   91501             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   91502             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   91503             : #endif
   91504             : 
   91505             : #if !defined(SGNODE__ALL_POOLS)
   91506             : #define SGNODE__ALL_POOLS
   91507             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   91508             : #endif
   91509             : 
   91510             : SgSpawnStmt* SgSpawnStmt::next_node = nullptr;
   91511             : std::vector<unsigned char*> SgSpawnStmt::pools;
   91512             : 
   91513             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   91514             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   91515             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   91516             : // around this macro definition rather than each use).
   91517             : #ifndef ALLOC_MUTEX
   91518             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   91519             :         do {                                                                     \
   91520             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   91521             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   91522             :                 abort();                                                         \
   91523             :             }                                                                    \
   91524             :         } while (0);
   91525             : #endif
   91526             : 
   91527             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   91528             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   91529             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   91530             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   91531             : 
   91532             : /*! \brief New operator for SgSpawnStmt.
   91533             : 
   91534             :    This new operator implements memory pools to provide most efficent 
   91535             :    use of the heap within construction of large ASTs.
   91536             : 
   91537             : \internal The new and delete operators use the lower level C malloc/free
   91538             :    function calls for performance and to make sure that mixing of malloc/free
   91539             :    and new/delete by the used can be caught more readily.  This may change
   91540             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   91541             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   91542             :    deallocate memory allocated using ROSE_MALLOC.
   91543             : */
   91544           0 : void *SgSpawnStmt::operator new ( size_t Size )
   91545             : {
   91546             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   91547             :      * returning or throwing an exception. */
   91548           0 :     ALLOC_MUTEX(SgSpawnStmt, lock);
   91549             : 
   91550             : #if ROSE_ALLOC_TRACE == 2
   91551             : //    printf("SgSpawnStmt::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgSpawnStmt::next_node);
   91552             : #endif
   91553             : 
   91554             : #if USE_CPP_NEW_DELETE_OPERATORS
   91555             :     void *mem = ROSE_MALLOC(Size);
   91556             :     ALLOC_MUTEX(SgSpawnStmt, unlock);
   91557             :     return mem;
   91558             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   91559             : #if ROSE_PEDANTIC_ALLOC
   91560             :     ROSE_ASSERT(Size == sizeof(SgSpawnStmt));
   91561             : #else
   91562           0 :     if (Size != sizeof(SgSpawnStmt)) {
   91563           0 :       void * object = ROSE_MALLOC(Size);
   91564           0 :       ALLOC_MUTEX(SgSpawnStmt, unlock);
   91565             :       return object;
   91566             :     }
   91567             : #endif
   91568             : 
   91569           0 :     if (SgSpawnStmt::next_node == nullptr) {
   91570           0 :         SgSpawnStmt * alloc = (SgSpawnStmt*) ROSE_MALLOC ( SgSpawnStmt::pool_size * sizeof(SgSpawnStmt) );
   91571           0 :         ROSE_ASSERT(alloc != nullptr);
   91572             : 
   91573             : #if ROSE_ALLOC_TRACE == 2
   91574             : //        printf("SgSpawnStmt::alloc\n  block[%zi] = [ %p , %p [\n", SgSpawnStmt::pools.size(), alloc, alloc + SgSpawnStmt::pool_size);
   91575             : #endif
   91576             : 
   91577             : #if ROSE_ALLOC_MEMSET == 1
   91578             : #elif ROSE_ALLOC_MEMSET == 2
   91579             :         memset(alloc, 0x00, SgSpawnStmt::pool_size * sizeof(SgSpawnStmt));
   91580             : #elif ROSE_ALLOC_MEMSET == 3
   91581             :         memset(alloc, 0xAA, SgSpawnStmt::pool_size * sizeof(SgSpawnStmt));
   91582             : #endif
   91583           0 :         for (unsigned i=0; i < SgSpawnStmt::pool_size-1; i++) {
   91584           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
   91585             :         }
   91586           0 :         alloc[SgSpawnStmt::pool_size-1].p_freepointer = nullptr;
   91587             : 
   91588           0 :         SgSpawnStmt::pools.push_back ( (unsigned char *) alloc );
   91589           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgSpawnStmt::pool_size * sizeof(SgSpawnStmt), V_SgSpawnStmt ) );
   91590           0 :         SgSpawnStmt::next_node = alloc;
   91591             :     }
   91592           0 :     ROSE_ASSERT(SgSpawnStmt::next_node != nullptr);
   91593             : 
   91594           0 :     SgSpawnStmt * object = SgSpawnStmt::next_node;
   91595           0 :     SgSpawnStmt::next_node = (SgSpawnStmt*)(object->p_freepointer);
   91596             : 
   91597             : #if ROSE_ALLOC_TRACE == 2
   91598             :     printf("SgSpawnStmt::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgSpawnStmt::next_node);
   91599             : #endif
   91600             : 
   91601           0 :     SgNode * fp = object->p_freepointer;
   91602             : #if ROSE_ALLOC_MEMSET == 1
   91603             : #elif ROSE_ALLOC_MEMSET == 2
   91604             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgSpawnStmt) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   91605             : #elif ROSE_ALLOC_MEMSET == 3
   91606             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgSpawnStmt) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   91607             : #endif
   91608           0 :     object->p_freepointer = fp;
   91609             : 
   91610             : #if ROSE_ALLOC_TRACE == 2
   91611             : //    printf("SgSpawnStmt::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgSpawnStmt::next_node);
   91612             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   91613             :     Rose::MemPool::snapshot(oss.str());
   91614             :     alloc_trace_cnt++;
   91615             : #endif
   91616             : 
   91617           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   91618             : 
   91619           0 :     ALLOC_MUTEX(SgSpawnStmt, unlock);
   91620             : 
   91621             :     return object;
   91622             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   91623             : }
   91624             : 
   91625             : 
   91626             : 
   91627             : /*! \brief Delete operator for SgSpawnStmt.
   91628             : 
   91629             :    This delete operator implements deallocation using memory pools to 
   91630             :    provide most efficent use of the heap within construction of large ASTs.
   91631             : 
   91632             : \internal The new and delete operators use the lower level C malloc/free
   91633             :    function calls for performance and to make sure that mixing of malloc/free
   91634             :    and new/delete by the used can be caught more readily.  This may change
   91635             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   91636             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   91637             :    deallocate memory allocated using ROSE_MALLOC.
   91638             : */
   91639           0 : void SgSpawnStmt::operator delete(void *Pointer, size_t Size)
   91640             : {
   91641             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   91642             :      * or throwing an exception. */
   91643           0 :     ALLOC_MUTEX(SgSpawnStmt, lock);
   91644             : 
   91645             : #if USE_CPP_NEW_DELETE_OPERATORS
   91646             :     ROSE_FREE(Pointer);
   91647             : #else
   91648             : #if ROSE_PEDANTIC_ALLOC
   91649             :     ROSE_ASSERT(Size == sizeof(SgSpawnStmt));
   91650             : #else
   91651           0 :     if (Size != sizeof(SgSpawnStmt)) {
   91652           0 :       ROSE_FREE(Pointer);
   91653           0 :       ALLOC_MUTEX(SgSpawnStmt, unlock);
   91654             :       return;
   91655             :     }
   91656             : #endif
   91657             : 
   91658           0 :     SgSpawnStmt * object = (SgSpawnStmt*) Pointer;
   91659           0 :     ROSE_ASSERT(object != nullptr);
   91660             : 
   91661             : #if ROSE_ALLOC_TRACE == 2
   91662             : //  printf("SgSpawnStmt::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgSpawnStmt::next_node);
   91663             :     printf("SgSpawnStmt::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgSpawnStmt::next_node);
   91664             : #endif
   91665             : 
   91666             : #if ROSE_PEDANTIC_ALLOC
   91667             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   91668             : #endif
   91669             : 
   91670             : #if ROSE_ALLOC_MEMSET == 1
   91671             : #elif ROSE_ALLOC_MEMSET == 2
   91672             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgSpawnStmt) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   91673             : #elif ROSE_ALLOC_MEMSET == 3
   91674             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgSpawnStmt) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   91675             : #endif
   91676             : 
   91677             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   91678             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   91679             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   91680             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   91681             : #else
   91682           0 :     object->p_freepointer = SgSpawnStmt::next_node;
   91683           0 :     SgSpawnStmt::next_node = object;
   91684             : #endif
   91685             : 
   91686             : #if ROSE_ALLOC_TRACE == 2
   91687             : //  printf("SgSpawnStmt::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgSpawnStmt::next_node);
   91688             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   91689             :     Rose::MemPool::snapshot(oss.str());
   91690             :     alloc_trace_cnt++;
   91691             : #endif
   91692             : 
   91693             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   91694             : 
   91695           0 :     ALLOC_MUTEX(SgSpawnStmt, unlock);
   91696             : }
   91697             : 
   91698             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   91699             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   91700             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   91701             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   91702             : // Also, note comment below from Robb (copied from the Common.code file).
   91703             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   91704             : //
   91705             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   91706             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   91707             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   91708             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   91709             : #if 0
   91710             : void SgSpawnStmt::operator delete(void* pointer) { SgSpawnStmt::operator delete (pointer, sizeof(SgSpawnStmt)); };
   91711             : #endif
   91712             : /* #line 91713 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   91713             : 
   91714             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   91715             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   91716             : // obviously imply C++.
   91717             : 
   91718             : // This implements the support within ROSE for memory pools.  Memory pools
   91719             : // support the most condensed usage of memory within the construction of
   91720             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   91721             : // by a new operator written for each class.
   91722             : 
   91723             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   91724             :     // User wants multi-thread support and POSIX threads are available.
   91725             : #   include <pthread.h>
   91726             :     static pthread_mutex_t SgNullStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   91727             : #else
   91728             :      // Cause synchronization to be skipped.
   91729             : #    ifndef ALLOC_MUTEX
   91730             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   91731             : #    endif
   91732             : #    ifdef _REENTRANT
   91733             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   91734             : #       ifdef _MSC_VER
   91735             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   91736             : #       else
   91737             : #           warning "POSIX threads are not available; synchronization being skipped"
   91738             : #       endif
   91739             : #    endif
   91740             : #endif
   91741             : 
   91742             : #ifndef ROSE_ALLOC_TRACE
   91743             : #  define ROSE_ALLOC_TRACE 0
   91744             : #endif
   91745             : 
   91746             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   91747             : #define ROSE_ALLOC_TRACE_CNT
   91748             : #include "memory-pool-snapshot.h"
   91749             : unsigned long alloc_trace_cnt = 0;
   91750             : #endif
   91751             : 
   91752             : #if ROSE_ALLOC_TRACE
   91753             : const unsigned SgNullStatement::pool_size = 5;
   91754             : #else
   91755             : const unsigned SgNullStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   91756             : #endif
   91757             : 
   91758             : #ifndef ROSE_ALLOC_MEMSET
   91759             : #  define ROSE_ALLOC_MEMSET 0
   91760             : #endif
   91761             : 
   91762             : #ifndef ROSE_PEDANTIC_ALLOC
   91763             : #  define ROSE_PEDANTIC_ALLOC 0
   91764             : #endif
   91765             : 
   91766             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   91767             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   91768             : #endif
   91769             : 
   91770             : #if !defined(SGNODE__ALL_POOLS)
   91771             : #define SGNODE__ALL_POOLS
   91772             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   91773             : #endif
   91774             : 
   91775             : SgNullStatement* SgNullStatement::next_node = nullptr;
   91776             : std::vector<unsigned char*> SgNullStatement::pools;
   91777             : 
   91778             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   91779             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   91780             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   91781             : // around this macro definition rather than each use).
   91782             : #ifndef ALLOC_MUTEX
   91783             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   91784             :         do {                                                                     \
   91785             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   91786             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   91787             :                 abort();                                                         \
   91788             :             }                                                                    \
   91789             :         } while (0);
   91790             : #endif
   91791             : 
   91792             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   91793             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   91794             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   91795             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   91796             : 
   91797             : /*! \brief New operator for SgNullStatement.
   91798             : 
   91799             :    This new operator implements memory pools to provide most efficent 
   91800             :    use of the heap within construction of large ASTs.
   91801             : 
   91802             : \internal The new and delete operators use the lower level C malloc/free
   91803             :    function calls for performance and to make sure that mixing of malloc/free
   91804             :    and new/delete by the used can be caught more readily.  This may change
   91805             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   91806             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   91807             :    deallocate memory allocated using ROSE_MALLOC.
   91808             : */
   91809         278 : void *SgNullStatement::operator new ( size_t Size )
   91810             : {
   91811             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   91812             :      * returning or throwing an exception. */
   91813         278 :     ALLOC_MUTEX(SgNullStatement, lock);
   91814             : 
   91815             : #if ROSE_ALLOC_TRACE == 2
   91816             : //    printf("SgNullStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgNullStatement::next_node);
   91817             : #endif
   91818             : 
   91819             : #if USE_CPP_NEW_DELETE_OPERATORS
   91820             :     void *mem = ROSE_MALLOC(Size);
   91821             :     ALLOC_MUTEX(SgNullStatement, unlock);
   91822             :     return mem;
   91823             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   91824             : #if ROSE_PEDANTIC_ALLOC
   91825             :     ROSE_ASSERT(Size == sizeof(SgNullStatement));
   91826             : #else
   91827         278 :     if (Size != sizeof(SgNullStatement)) {
   91828           0 :       void * object = ROSE_MALLOC(Size);
   91829           0 :       ALLOC_MUTEX(SgNullStatement, unlock);
   91830             :       return object;
   91831             :     }
   91832             : #endif
   91833             : 
   91834         278 :     if (SgNullStatement::next_node == nullptr) {
   91835          12 :         SgNullStatement * alloc = (SgNullStatement*) ROSE_MALLOC ( SgNullStatement::pool_size * sizeof(SgNullStatement) );
   91836          12 :         ROSE_ASSERT(alloc != nullptr);
   91837             : 
   91838             : #if ROSE_ALLOC_TRACE == 2
   91839             : //        printf("SgNullStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgNullStatement::pools.size(), alloc, alloc + SgNullStatement::pool_size);
   91840             : #endif
   91841             : 
   91842             : #if ROSE_ALLOC_MEMSET == 1
   91843             : #elif ROSE_ALLOC_MEMSET == 2
   91844             :         memset(alloc, 0x00, SgNullStatement::pool_size * sizeof(SgNullStatement));
   91845             : #elif ROSE_ALLOC_MEMSET == 3
   91846             :         memset(alloc, 0xAA, SgNullStatement::pool_size * sizeof(SgNullStatement));
   91847             : #endif
   91848       24000 :         for (unsigned i=0; i < SgNullStatement::pool_size-1; i++) {
   91849       23988 :           alloc[i].p_freepointer = &(alloc[i+1]);
   91850             :         }
   91851          12 :         alloc[SgNullStatement::pool_size-1].p_freepointer = nullptr;
   91852             : 
   91853          12 :         SgNullStatement::pools.push_back ( (unsigned char *) alloc );
   91854          12 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgNullStatement::pool_size * sizeof(SgNullStatement), V_SgNullStatement ) );
   91855          12 :         SgNullStatement::next_node = alloc;
   91856             :     }
   91857         278 :     ROSE_ASSERT(SgNullStatement::next_node != nullptr);
   91858             : 
   91859         278 :     SgNullStatement * object = SgNullStatement::next_node;
   91860         278 :     SgNullStatement::next_node = (SgNullStatement*)(object->p_freepointer);
   91861             : 
   91862             : #if ROSE_ALLOC_TRACE == 2
   91863             :     printf("SgNullStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgNullStatement::next_node);
   91864             : #endif
   91865             : 
   91866         278 :     SgNode * fp = object->p_freepointer;
   91867             : #if ROSE_ALLOC_MEMSET == 1
   91868             : #elif ROSE_ALLOC_MEMSET == 2
   91869             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgNullStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   91870             : #elif ROSE_ALLOC_MEMSET == 3
   91871             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgNullStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   91872             : #endif
   91873         278 :     object->p_freepointer = fp;
   91874             : 
   91875             : #if ROSE_ALLOC_TRACE == 2
   91876             : //    printf("SgNullStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgNullStatement::next_node);
   91877             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   91878             :     Rose::MemPool::snapshot(oss.str());
   91879             :     alloc_trace_cnt++;
   91880             : #endif
   91881             : 
   91882         278 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   91883             : 
   91884         278 :     ALLOC_MUTEX(SgNullStatement, unlock);
   91885             : 
   91886             :     return object;
   91887             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   91888             : }
   91889             : 
   91890             : 
   91891             : 
   91892             : /*! \brief Delete operator for SgNullStatement.
   91893             : 
   91894             :    This delete operator implements deallocation using memory pools to 
   91895             :    provide most efficent use of the heap within construction of large ASTs.
   91896             : 
   91897             : \internal The new and delete operators use the lower level C malloc/free
   91898             :    function calls for performance and to make sure that mixing of malloc/free
   91899             :    and new/delete by the used can be caught more readily.  This may change
   91900             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   91901             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   91902             :    deallocate memory allocated using ROSE_MALLOC.
   91903             : */
   91904          42 : void SgNullStatement::operator delete(void *Pointer, size_t Size)
   91905             : {
   91906             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   91907             :      * or throwing an exception. */
   91908          42 :     ALLOC_MUTEX(SgNullStatement, lock);
   91909             : 
   91910             : #if USE_CPP_NEW_DELETE_OPERATORS
   91911             :     ROSE_FREE(Pointer);
   91912             : #else
   91913             : #if ROSE_PEDANTIC_ALLOC
   91914             :     ROSE_ASSERT(Size == sizeof(SgNullStatement));
   91915             : #else
   91916          42 :     if (Size != sizeof(SgNullStatement)) {
   91917           0 :       ROSE_FREE(Pointer);
   91918           0 :       ALLOC_MUTEX(SgNullStatement, unlock);
   91919             :       return;
   91920             :     }
   91921             : #endif
   91922             : 
   91923          42 :     SgNullStatement * object = (SgNullStatement*) Pointer;
   91924          42 :     ROSE_ASSERT(object != nullptr);
   91925             : 
   91926             : #if ROSE_ALLOC_TRACE == 2
   91927             : //  printf("SgNullStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgNullStatement::next_node);
   91928             :     printf("SgNullStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgNullStatement::next_node);
   91929             : #endif
   91930             : 
   91931             : #if ROSE_PEDANTIC_ALLOC
   91932             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   91933             : #endif
   91934             : 
   91935             : #if ROSE_ALLOC_MEMSET == 1
   91936             : #elif ROSE_ALLOC_MEMSET == 2
   91937             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgNullStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   91938             : #elif ROSE_ALLOC_MEMSET == 3
   91939             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgNullStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   91940             : #endif
   91941             : 
   91942             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   91943             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   91944             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   91945             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   91946             : #else
   91947          42 :     object->p_freepointer = SgNullStatement::next_node;
   91948          42 :     SgNullStatement::next_node = object;
   91949             : #endif
   91950             : 
   91951             : #if ROSE_ALLOC_TRACE == 2
   91952             : //  printf("SgNullStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgNullStatement::next_node);
   91953             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   91954             :     Rose::MemPool::snapshot(oss.str());
   91955             :     alloc_trace_cnt++;
   91956             : #endif
   91957             : 
   91958             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   91959             : 
   91960          42 :     ALLOC_MUTEX(SgNullStatement, unlock);
   91961             : }
   91962             : 
   91963             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   91964             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   91965             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   91966             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   91967             : // Also, note comment below from Robb (copied from the Common.code file).
   91968             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   91969             : //
   91970             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   91971             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   91972             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   91973             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   91974             : #if 0
   91975             : void SgNullStatement::operator delete(void* pointer) { SgNullStatement::operator delete (pointer, sizeof(SgNullStatement)); };
   91976             : #endif
   91977             : /* #line 91978 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   91978             : 
   91979             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   91980             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   91981             : // obviously imply C++.
   91982             : 
   91983             : // This implements the support within ROSE for memory pools.  Memory pools
   91984             : // support the most condensed usage of memory within the construction of
   91985             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   91986             : // by a new operator written for each class.
   91987             : 
   91988             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   91989             :     // User wants multi-thread support and POSIX threads are available.
   91990             : #   include <pthread.h>
   91991             :     static pthread_mutex_t SgVariantStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   91992             : #else
   91993             :      // Cause synchronization to be skipped.
   91994             : #    ifndef ALLOC_MUTEX
   91995             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   91996             : #    endif
   91997             : #    ifdef _REENTRANT
   91998             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   91999             : #       ifdef _MSC_VER
   92000             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   92001             : #       else
   92002             : #           warning "POSIX threads are not available; synchronization being skipped"
   92003             : #       endif
   92004             : #    endif
   92005             : #endif
   92006             : 
   92007             : #ifndef ROSE_ALLOC_TRACE
   92008             : #  define ROSE_ALLOC_TRACE 0
   92009             : #endif
   92010             : 
   92011             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   92012             : #define ROSE_ALLOC_TRACE_CNT
   92013             : #include "memory-pool-snapshot.h"
   92014             : unsigned long alloc_trace_cnt = 0;
   92015             : #endif
   92016             : 
   92017             : #if ROSE_ALLOC_TRACE
   92018             : const unsigned SgVariantStatement::pool_size = 5;
   92019             : #else
   92020             : const unsigned SgVariantStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   92021             : #endif
   92022             : 
   92023             : #ifndef ROSE_ALLOC_MEMSET
   92024             : #  define ROSE_ALLOC_MEMSET 0
   92025             : #endif
   92026             : 
   92027             : #ifndef ROSE_PEDANTIC_ALLOC
   92028             : #  define ROSE_PEDANTIC_ALLOC 0
   92029             : #endif
   92030             : 
   92031             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   92032             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   92033             : #endif
   92034             : 
   92035             : #if !defined(SGNODE__ALL_POOLS)
   92036             : #define SGNODE__ALL_POOLS
   92037             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   92038             : #endif
   92039             : 
   92040             : SgVariantStatement* SgVariantStatement::next_node = nullptr;
   92041             : std::vector<unsigned char*> SgVariantStatement::pools;
   92042             : 
   92043             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   92044             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   92045             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   92046             : // around this macro definition rather than each use).
   92047             : #ifndef ALLOC_MUTEX
   92048             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   92049             :         do {                                                                     \
   92050             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   92051             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   92052             :                 abort();                                                         \
   92053             :             }                                                                    \
   92054             :         } while (0);
   92055             : #endif
   92056             : 
   92057             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   92058             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   92059             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   92060             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   92061             : 
   92062             : /*! \brief New operator for SgVariantStatement.
   92063             : 
   92064             :    This new operator implements memory pools to provide most efficent 
   92065             :    use of the heap within construction of large ASTs.
   92066             : 
   92067             : \internal The new and delete operators use the lower level C malloc/free
   92068             :    function calls for performance and to make sure that mixing of malloc/free
   92069             :    and new/delete by the used can be caught more readily.  This may change
   92070             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   92071             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   92072             :    deallocate memory allocated using ROSE_MALLOC.
   92073             : */
   92074           0 : void *SgVariantStatement::operator new ( size_t Size )
   92075             : {
   92076             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   92077             :      * returning or throwing an exception. */
   92078           0 :     ALLOC_MUTEX(SgVariantStatement, lock);
   92079             : 
   92080             : #if ROSE_ALLOC_TRACE == 2
   92081             : //    printf("SgVariantStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgVariantStatement::next_node);
   92082             : #endif
   92083             : 
   92084             : #if USE_CPP_NEW_DELETE_OPERATORS
   92085             :     void *mem = ROSE_MALLOC(Size);
   92086             :     ALLOC_MUTEX(SgVariantStatement, unlock);
   92087             :     return mem;
   92088             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   92089             : #if ROSE_PEDANTIC_ALLOC
   92090             :     ROSE_ASSERT(Size == sizeof(SgVariantStatement));
   92091             : #else
   92092           0 :     if (Size != sizeof(SgVariantStatement)) {
   92093           0 :       void * object = ROSE_MALLOC(Size);
   92094           0 :       ALLOC_MUTEX(SgVariantStatement, unlock);
   92095             :       return object;
   92096             :     }
   92097             : #endif
   92098             : 
   92099           0 :     if (SgVariantStatement::next_node == nullptr) {
   92100           0 :         SgVariantStatement * alloc = (SgVariantStatement*) ROSE_MALLOC ( SgVariantStatement::pool_size * sizeof(SgVariantStatement) );
   92101           0 :         ROSE_ASSERT(alloc != nullptr);
   92102             : 
   92103             : #if ROSE_ALLOC_TRACE == 2
   92104             : //        printf("SgVariantStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgVariantStatement::pools.size(), alloc, alloc + SgVariantStatement::pool_size);
   92105             : #endif
   92106             : 
   92107             : #if ROSE_ALLOC_MEMSET == 1
   92108             : #elif ROSE_ALLOC_MEMSET == 2
   92109             :         memset(alloc, 0x00, SgVariantStatement::pool_size * sizeof(SgVariantStatement));
   92110             : #elif ROSE_ALLOC_MEMSET == 3
   92111             :         memset(alloc, 0xAA, SgVariantStatement::pool_size * sizeof(SgVariantStatement));
   92112             : #endif
   92113           0 :         for (unsigned i=0; i < SgVariantStatement::pool_size-1; i++) {
   92114           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
   92115             :         }
   92116           0 :         alloc[SgVariantStatement::pool_size-1].p_freepointer = nullptr;
   92117             : 
   92118           0 :         SgVariantStatement::pools.push_back ( (unsigned char *) alloc );
   92119           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgVariantStatement::pool_size * sizeof(SgVariantStatement), V_SgVariantStatement ) );
   92120           0 :         SgVariantStatement::next_node = alloc;
   92121             :     }
   92122           0 :     ROSE_ASSERT(SgVariantStatement::next_node != nullptr);
   92123             : 
   92124           0 :     SgVariantStatement * object = SgVariantStatement::next_node;
   92125           0 :     SgVariantStatement::next_node = (SgVariantStatement*)(object->p_freepointer);
   92126             : 
   92127             : #if ROSE_ALLOC_TRACE == 2
   92128             :     printf("SgVariantStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgVariantStatement::next_node);
   92129             : #endif
   92130             : 
   92131           0 :     SgNode * fp = object->p_freepointer;
   92132             : #if ROSE_ALLOC_MEMSET == 1
   92133             : #elif ROSE_ALLOC_MEMSET == 2
   92134             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgVariantStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   92135             : #elif ROSE_ALLOC_MEMSET == 3
   92136             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgVariantStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   92137             : #endif
   92138           0 :     object->p_freepointer = fp;
   92139             : 
   92140             : #if ROSE_ALLOC_TRACE == 2
   92141             : //    printf("SgVariantStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgVariantStatement::next_node);
   92142             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   92143             :     Rose::MemPool::snapshot(oss.str());
   92144             :     alloc_trace_cnt++;
   92145             : #endif
   92146             : 
   92147           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   92148             : 
   92149           0 :     ALLOC_MUTEX(SgVariantStatement, unlock);
   92150             : 
   92151             :     return object;
   92152             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   92153             : }
   92154             : 
   92155             : 
   92156             : 
   92157             : /*! \brief Delete operator for SgVariantStatement.
   92158             : 
   92159             :    This delete operator implements deallocation using memory pools to 
   92160             :    provide most efficent use of the heap within construction of large ASTs.
   92161             : 
   92162             : \internal The new and delete operators use the lower level C malloc/free
   92163             :    function calls for performance and to make sure that mixing of malloc/free
   92164             :    and new/delete by the used can be caught more readily.  This may change
   92165             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   92166             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   92167             :    deallocate memory allocated using ROSE_MALLOC.
   92168             : */
   92169           0 : void SgVariantStatement::operator delete(void *Pointer, size_t Size)
   92170             : {
   92171             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   92172             :      * or throwing an exception. */
   92173           0 :     ALLOC_MUTEX(SgVariantStatement, lock);
   92174             : 
   92175             : #if USE_CPP_NEW_DELETE_OPERATORS
   92176             :     ROSE_FREE(Pointer);
   92177             : #else
   92178             : #if ROSE_PEDANTIC_ALLOC
   92179             :     ROSE_ASSERT(Size == sizeof(SgVariantStatement));
   92180             : #else
   92181           0 :     if (Size != sizeof(SgVariantStatement)) {
   92182           0 :       ROSE_FREE(Pointer);
   92183           0 :       ALLOC_MUTEX(SgVariantStatement, unlock);
   92184             :       return;
   92185             :     }
   92186             : #endif
   92187             : 
   92188           0 :     SgVariantStatement * object = (SgVariantStatement*) Pointer;
   92189           0 :     ROSE_ASSERT(object != nullptr);
   92190             : 
   92191             : #if ROSE_ALLOC_TRACE == 2
   92192             : //  printf("SgVariantStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgVariantStatement::next_node);
   92193             :     printf("SgVariantStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgVariantStatement::next_node);
   92194             : #endif
   92195             : 
   92196             : #if ROSE_PEDANTIC_ALLOC
   92197             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   92198             : #endif
   92199             : 
   92200             : #if ROSE_ALLOC_MEMSET == 1
   92201             : #elif ROSE_ALLOC_MEMSET == 2
   92202             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgVariantStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   92203             : #elif ROSE_ALLOC_MEMSET == 3
   92204             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgVariantStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   92205             : #endif
   92206             : 
   92207             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   92208             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   92209             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   92210             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   92211             : #else
   92212           0 :     object->p_freepointer = SgVariantStatement::next_node;
   92213           0 :     SgVariantStatement::next_node = object;
   92214             : #endif
   92215             : 
   92216             : #if ROSE_ALLOC_TRACE == 2
   92217             : //  printf("SgVariantStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgVariantStatement::next_node);
   92218             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   92219             :     Rose::MemPool::snapshot(oss.str());
   92220             :     alloc_trace_cnt++;
   92221             : #endif
   92222             : 
   92223             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   92224             : 
   92225           0 :     ALLOC_MUTEX(SgVariantStatement, unlock);
   92226             : }
   92227             : 
   92228             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   92229             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   92230             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   92231             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   92232             : // Also, note comment below from Robb (copied from the Common.code file).
   92233             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   92234             : //
   92235             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   92236             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   92237             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   92238             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   92239             : #if 0
   92240             : void SgVariantStatement::operator delete(void* pointer) { SgVariantStatement::operator delete (pointer, sizeof(SgVariantStatement)); };
   92241             : #endif
   92242             : /* #line 92243 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   92243             : 
   92244             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   92245             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   92246             : // obviously imply C++.
   92247             : 
   92248             : // This implements the support within ROSE for memory pools.  Memory pools
   92249             : // support the most condensed usage of memory within the construction of
   92250             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   92251             : // by a new operator written for each class.
   92252             : 
   92253             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   92254             :     // User wants multi-thread support and POSIX threads are available.
   92255             : #   include <pthread.h>
   92256             :     static pthread_mutex_t SgForInitStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   92257             : #else
   92258             :      // Cause synchronization to be skipped.
   92259             : #    ifndef ALLOC_MUTEX
   92260             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   92261             : #    endif
   92262             : #    ifdef _REENTRANT
   92263             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   92264             : #       ifdef _MSC_VER
   92265             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   92266             : #       else
   92267             : #           warning "POSIX threads are not available; synchronization being skipped"
   92268             : #       endif
   92269             : #    endif
   92270             : #endif
   92271             : 
   92272             : #ifndef ROSE_ALLOC_TRACE
   92273             : #  define ROSE_ALLOC_TRACE 0
   92274             : #endif
   92275             : 
   92276             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   92277             : #define ROSE_ALLOC_TRACE_CNT
   92278             : #include "memory-pool-snapshot.h"
   92279             : unsigned long alloc_trace_cnt = 0;
   92280             : #endif
   92281             : 
   92282             : #if ROSE_ALLOC_TRACE
   92283             : const unsigned SgForInitStatement::pool_size = 5;
   92284             : #else
   92285             : const unsigned SgForInitStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   92286             : #endif
   92287             : 
   92288             : #ifndef ROSE_ALLOC_MEMSET
   92289             : #  define ROSE_ALLOC_MEMSET 0
   92290             : #endif
   92291             : 
   92292             : #ifndef ROSE_PEDANTIC_ALLOC
   92293             : #  define ROSE_PEDANTIC_ALLOC 0
   92294             : #endif
   92295             : 
   92296             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   92297             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   92298             : #endif
   92299             : 
   92300             : #if !defined(SGNODE__ALL_POOLS)
   92301             : #define SGNODE__ALL_POOLS
   92302             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   92303             : #endif
   92304             : 
   92305             : SgForInitStatement* SgForInitStatement::next_node = nullptr;
   92306             : std::vector<unsigned char*> SgForInitStatement::pools;
   92307             : 
   92308             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   92309             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   92310             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   92311             : // around this macro definition rather than each use).
   92312             : #ifndef ALLOC_MUTEX
   92313             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   92314             :         do {                                                                     \
   92315             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   92316             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   92317             :                 abort();                                                         \
   92318             :             }                                                                    \
   92319             :         } while (0);
   92320             : #endif
   92321             : 
   92322             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   92323             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   92324             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   92325             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   92326             : 
   92327             : /*! \brief New operator for SgForInitStatement.
   92328             : 
   92329             :    This new operator implements memory pools to provide most efficent 
   92330             :    use of the heap within construction of large ASTs.
   92331             : 
   92332             : \internal The new and delete operators use the lower level C malloc/free
   92333             :    function calls for performance and to make sure that mixing of malloc/free
   92334             :    and new/delete by the used can be caught more readily.  This may change
   92335             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   92336             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   92337             :    deallocate memory allocated using ROSE_MALLOC.
   92338             : */
   92339        1978 : void *SgForInitStatement::operator new ( size_t Size )
   92340             : {
   92341             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   92342             :      * returning or throwing an exception. */
   92343        1978 :     ALLOC_MUTEX(SgForInitStatement, lock);
   92344             : 
   92345             : #if ROSE_ALLOC_TRACE == 2
   92346             : //    printf("SgForInitStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgForInitStatement::next_node);
   92347             : #endif
   92348             : 
   92349             : #if USE_CPP_NEW_DELETE_OPERATORS
   92350             :     void *mem = ROSE_MALLOC(Size);
   92351             :     ALLOC_MUTEX(SgForInitStatement, unlock);
   92352             :     return mem;
   92353             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   92354             : #if ROSE_PEDANTIC_ALLOC
   92355             :     ROSE_ASSERT(Size == sizeof(SgForInitStatement));
   92356             : #else
   92357        1978 :     if (Size != sizeof(SgForInitStatement)) {
   92358           0 :       void * object = ROSE_MALLOC(Size);
   92359           0 :       ALLOC_MUTEX(SgForInitStatement, unlock);
   92360             :       return object;
   92361             :     }
   92362             : #endif
   92363             : 
   92364        1978 :     if (SgForInitStatement::next_node == nullptr) {
   92365         172 :         SgForInitStatement * alloc = (SgForInitStatement*) ROSE_MALLOC ( SgForInitStatement::pool_size * sizeof(SgForInitStatement) );
   92366         172 :         ROSE_ASSERT(alloc != nullptr);
   92367             : 
   92368             : #if ROSE_ALLOC_TRACE == 2
   92369             : //        printf("SgForInitStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgForInitStatement::pools.size(), alloc, alloc + SgForInitStatement::pool_size);
   92370             : #endif
   92371             : 
   92372             : #if ROSE_ALLOC_MEMSET == 1
   92373             : #elif ROSE_ALLOC_MEMSET == 2
   92374             :         memset(alloc, 0x00, SgForInitStatement::pool_size * sizeof(SgForInitStatement));
   92375             : #elif ROSE_ALLOC_MEMSET == 3
   92376             :         memset(alloc, 0xAA, SgForInitStatement::pool_size * sizeof(SgForInitStatement));
   92377             : #endif
   92378      344000 :         for (unsigned i=0; i < SgForInitStatement::pool_size-1; i++) {
   92379      343828 :           alloc[i].p_freepointer = &(alloc[i+1]);
   92380             :         }
   92381         172 :         alloc[SgForInitStatement::pool_size-1].p_freepointer = nullptr;
   92382             : 
   92383         172 :         SgForInitStatement::pools.push_back ( (unsigned char *) alloc );
   92384         172 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgForInitStatement::pool_size * sizeof(SgForInitStatement), V_SgForInitStatement ) );
   92385         172 :         SgForInitStatement::next_node = alloc;
   92386             :     }
   92387        1978 :     ROSE_ASSERT(SgForInitStatement::next_node != nullptr);
   92388             : 
   92389        1978 :     SgForInitStatement * object = SgForInitStatement::next_node;
   92390        1978 :     SgForInitStatement::next_node = (SgForInitStatement*)(object->p_freepointer);
   92391             : 
   92392             : #if ROSE_ALLOC_TRACE == 2
   92393             :     printf("SgForInitStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgForInitStatement::next_node);
   92394             : #endif
   92395             : 
   92396        1978 :     SgNode * fp = object->p_freepointer;
   92397             : #if ROSE_ALLOC_MEMSET == 1
   92398             : #elif ROSE_ALLOC_MEMSET == 2
   92399             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgForInitStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   92400             : #elif ROSE_ALLOC_MEMSET == 3
   92401             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgForInitStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   92402             : #endif
   92403        1978 :     object->p_freepointer = fp;
   92404             : 
   92405             : #if ROSE_ALLOC_TRACE == 2
   92406             : //    printf("SgForInitStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgForInitStatement::next_node);
   92407             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   92408             :     Rose::MemPool::snapshot(oss.str());
   92409             :     alloc_trace_cnt++;
   92410             : #endif
   92411             : 
   92412        1978 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   92413             : 
   92414        1978 :     ALLOC_MUTEX(SgForInitStatement, unlock);
   92415             : 
   92416             :     return object;
   92417             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   92418             : }
   92419             : 
   92420             : 
   92421             : 
   92422             : /*! \brief Delete operator for SgForInitStatement.
   92423             : 
   92424             :    This delete operator implements deallocation using memory pools to 
   92425             :    provide most efficent use of the heap within construction of large ASTs.
   92426             : 
   92427             : \internal The new and delete operators use the lower level C malloc/free
   92428             :    function calls for performance and to make sure that mixing of malloc/free
   92429             :    and new/delete by the used can be caught more readily.  This may change
   92430             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   92431             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   92432             :    deallocate memory allocated using ROSE_MALLOC.
   92433             : */
   92434        1049 : void SgForInitStatement::operator delete(void *Pointer, size_t Size)
   92435             : {
   92436             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   92437             :      * or throwing an exception. */
   92438        1049 :     ALLOC_MUTEX(SgForInitStatement, lock);
   92439             : 
   92440             : #if USE_CPP_NEW_DELETE_OPERATORS
   92441             :     ROSE_FREE(Pointer);
   92442             : #else
   92443             : #if ROSE_PEDANTIC_ALLOC
   92444             :     ROSE_ASSERT(Size == sizeof(SgForInitStatement));
   92445             : #else
   92446        1049 :     if (Size != sizeof(SgForInitStatement)) {
   92447           0 :       ROSE_FREE(Pointer);
   92448           0 :       ALLOC_MUTEX(SgForInitStatement, unlock);
   92449             :       return;
   92450             :     }
   92451             : #endif
   92452             : 
   92453        1049 :     SgForInitStatement * object = (SgForInitStatement*) Pointer;
   92454        1049 :     ROSE_ASSERT(object != nullptr);
   92455             : 
   92456             : #if ROSE_ALLOC_TRACE == 2
   92457             : //  printf("SgForInitStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgForInitStatement::next_node);
   92458             :     printf("SgForInitStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgForInitStatement::next_node);
   92459             : #endif
   92460             : 
   92461             : #if ROSE_PEDANTIC_ALLOC
   92462             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   92463             : #endif
   92464             : 
   92465             : #if ROSE_ALLOC_MEMSET == 1
   92466             : #elif ROSE_ALLOC_MEMSET == 2
   92467             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgForInitStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   92468             : #elif ROSE_ALLOC_MEMSET == 3
   92469             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgForInitStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   92470             : #endif
   92471             : 
   92472             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   92473             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   92474             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   92475             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   92476             : #else
   92477        1049 :     object->p_freepointer = SgForInitStatement::next_node;
   92478        1049 :     SgForInitStatement::next_node = object;
   92479             : #endif
   92480             : 
   92481             : #if ROSE_ALLOC_TRACE == 2
   92482             : //  printf("SgForInitStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgForInitStatement::next_node);
   92483             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   92484             :     Rose::MemPool::snapshot(oss.str());
   92485             :     alloc_trace_cnt++;
   92486             : #endif
   92487             : 
   92488             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   92489             : 
   92490        1049 :     ALLOC_MUTEX(SgForInitStatement, unlock);
   92491             : }
   92492             : 
   92493             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   92494             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   92495             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   92496             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   92497             : // Also, note comment below from Robb (copied from the Common.code file).
   92498             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   92499             : //
   92500             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   92501             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   92502             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   92503             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   92504             : #if 0
   92505             : void SgForInitStatement::operator delete(void* pointer) { SgForInitStatement::operator delete (pointer, sizeof(SgForInitStatement)); };
   92506             : #endif
   92507             : /* #line 92508 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   92508             : 
   92509             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   92510             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   92511             : // obviously imply C++.
   92512             : 
   92513             : // This implements the support within ROSE for memory pools.  Memory pools
   92514             : // support the most condensed usage of memory within the construction of
   92515             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   92516             : // by a new operator written for each class.
   92517             : 
   92518             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   92519             :     // User wants multi-thread support and POSIX threads are available.
   92520             : #   include <pthread.h>
   92521             :     static pthread_mutex_t SgCatchStatementSeq_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   92522             : #else
   92523             :      // Cause synchronization to be skipped.
   92524             : #    ifndef ALLOC_MUTEX
   92525             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   92526             : #    endif
   92527             : #    ifdef _REENTRANT
   92528             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   92529             : #       ifdef _MSC_VER
   92530             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   92531             : #       else
   92532             : #           warning "POSIX threads are not available; synchronization being skipped"
   92533             : #       endif
   92534             : #    endif
   92535             : #endif
   92536             : 
   92537             : #ifndef ROSE_ALLOC_TRACE
   92538             : #  define ROSE_ALLOC_TRACE 0
   92539             : #endif
   92540             : 
   92541             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   92542             : #define ROSE_ALLOC_TRACE_CNT
   92543             : #include "memory-pool-snapshot.h"
   92544             : unsigned long alloc_trace_cnt = 0;
   92545             : #endif
   92546             : 
   92547             : #if ROSE_ALLOC_TRACE
   92548             : const unsigned SgCatchStatementSeq::pool_size = 5;
   92549             : #else
   92550             : const unsigned SgCatchStatementSeq::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   92551             : #endif
   92552             : 
   92553             : #ifndef ROSE_ALLOC_MEMSET
   92554             : #  define ROSE_ALLOC_MEMSET 0
   92555             : #endif
   92556             : 
   92557             : #ifndef ROSE_PEDANTIC_ALLOC
   92558             : #  define ROSE_PEDANTIC_ALLOC 0
   92559             : #endif
   92560             : 
   92561             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   92562             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   92563             : #endif
   92564             : 
   92565             : #if !defined(SGNODE__ALL_POOLS)
   92566             : #define SGNODE__ALL_POOLS
   92567             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   92568             : #endif
   92569             : 
   92570             : SgCatchStatementSeq* SgCatchStatementSeq::next_node = nullptr;
   92571             : std::vector<unsigned char*> SgCatchStatementSeq::pools;
   92572             : 
   92573             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   92574             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   92575             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   92576             : // around this macro definition rather than each use).
   92577             : #ifndef ALLOC_MUTEX
   92578             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   92579             :         do {                                                                     \
   92580             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   92581             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   92582             :                 abort();                                                         \
   92583             :             }                                                                    \
   92584             :         } while (0);
   92585             : #endif
   92586             : 
   92587             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   92588             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   92589             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   92590             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   92591             : 
   92592             : /*! \brief New operator for SgCatchStatementSeq.
   92593             : 
   92594             :    This new operator implements memory pools to provide most efficent 
   92595             :    use of the heap within construction of large ASTs.
   92596             : 
   92597             : \internal The new and delete operators use the lower level C malloc/free
   92598             :    function calls for performance and to make sure that mixing of malloc/free
   92599             :    and new/delete by the used can be caught more readily.  This may change
   92600             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   92601             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   92602             :    deallocate memory allocated using ROSE_MALLOC.
   92603             : */
   92604         568 : void *SgCatchStatementSeq::operator new ( size_t Size )
   92605             : {
   92606             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   92607             :      * returning or throwing an exception. */
   92608         568 :     ALLOC_MUTEX(SgCatchStatementSeq, lock);
   92609             : 
   92610             : #if ROSE_ALLOC_TRACE == 2
   92611             : //    printf("SgCatchStatementSeq::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgCatchStatementSeq::next_node);
   92612             : #endif
   92613             : 
   92614             : #if USE_CPP_NEW_DELETE_OPERATORS
   92615             :     void *mem = ROSE_MALLOC(Size);
   92616             :     ALLOC_MUTEX(SgCatchStatementSeq, unlock);
   92617             :     return mem;
   92618             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   92619             : #if ROSE_PEDANTIC_ALLOC
   92620             :     ROSE_ASSERT(Size == sizeof(SgCatchStatementSeq));
   92621             : #else
   92622         568 :     if (Size != sizeof(SgCatchStatementSeq)) {
   92623           0 :       void * object = ROSE_MALLOC(Size);
   92624           0 :       ALLOC_MUTEX(SgCatchStatementSeq, unlock);
   92625             :       return object;
   92626             :     }
   92627             : #endif
   92628             : 
   92629         568 :     if (SgCatchStatementSeq::next_node == nullptr) {
   92630          10 :         SgCatchStatementSeq * alloc = (SgCatchStatementSeq*) ROSE_MALLOC ( SgCatchStatementSeq::pool_size * sizeof(SgCatchStatementSeq) );
   92631          10 :         ROSE_ASSERT(alloc != nullptr);
   92632             : 
   92633             : #if ROSE_ALLOC_TRACE == 2
   92634             : //        printf("SgCatchStatementSeq::alloc\n  block[%zi] = [ %p , %p [\n", SgCatchStatementSeq::pools.size(), alloc, alloc + SgCatchStatementSeq::pool_size);
   92635             : #endif
   92636             : 
   92637             : #if ROSE_ALLOC_MEMSET == 1
   92638             : #elif ROSE_ALLOC_MEMSET == 2
   92639             :         memset(alloc, 0x00, SgCatchStatementSeq::pool_size * sizeof(SgCatchStatementSeq));
   92640             : #elif ROSE_ALLOC_MEMSET == 3
   92641             :         memset(alloc, 0xAA, SgCatchStatementSeq::pool_size * sizeof(SgCatchStatementSeq));
   92642             : #endif
   92643       20000 :         for (unsigned i=0; i < SgCatchStatementSeq::pool_size-1; i++) {
   92644       19990 :           alloc[i].p_freepointer = &(alloc[i+1]);
   92645             :         }
   92646          10 :         alloc[SgCatchStatementSeq::pool_size-1].p_freepointer = nullptr;
   92647             : 
   92648          10 :         SgCatchStatementSeq::pools.push_back ( (unsigned char *) alloc );
   92649          10 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgCatchStatementSeq::pool_size * sizeof(SgCatchStatementSeq), V_SgCatchStatementSeq ) );
   92650          10 :         SgCatchStatementSeq::next_node = alloc;
   92651             :     }
   92652         568 :     ROSE_ASSERT(SgCatchStatementSeq::next_node != nullptr);
   92653             : 
   92654         568 :     SgCatchStatementSeq * object = SgCatchStatementSeq::next_node;
   92655         568 :     SgCatchStatementSeq::next_node = (SgCatchStatementSeq*)(object->p_freepointer);
   92656             : 
   92657             : #if ROSE_ALLOC_TRACE == 2
   92658             :     printf("SgCatchStatementSeq::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgCatchStatementSeq::next_node);
   92659             : #endif
   92660             : 
   92661         568 :     SgNode * fp = object->p_freepointer;
   92662             : #if ROSE_ALLOC_MEMSET == 1
   92663             : #elif ROSE_ALLOC_MEMSET == 2
   92664             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgCatchStatementSeq) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   92665             : #elif ROSE_ALLOC_MEMSET == 3
   92666             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgCatchStatementSeq) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   92667             : #endif
   92668         568 :     object->p_freepointer = fp;
   92669             : 
   92670             : #if ROSE_ALLOC_TRACE == 2
   92671             : //    printf("SgCatchStatementSeq::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgCatchStatementSeq::next_node);
   92672             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   92673             :     Rose::MemPool::snapshot(oss.str());
   92674             :     alloc_trace_cnt++;
   92675             : #endif
   92676             : 
   92677         568 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   92678             : 
   92679         568 :     ALLOC_MUTEX(SgCatchStatementSeq, unlock);
   92680             : 
   92681             :     return object;
   92682             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   92683             : }
   92684             : 
   92685             : 
   92686             : 
   92687             : /*! \brief Delete operator for SgCatchStatementSeq.
   92688             : 
   92689             :    This delete operator implements deallocation using memory pools to 
   92690             :    provide most efficent use of the heap within construction of large ASTs.
   92691             : 
   92692             : \internal The new and delete operators use the lower level C malloc/free
   92693             :    function calls for performance and to make sure that mixing of malloc/free
   92694             :    and new/delete by the used can be caught more readily.  This may change
   92695             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   92696             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   92697             :    deallocate memory allocated using ROSE_MALLOC.
   92698             : */
   92699         108 : void SgCatchStatementSeq::operator delete(void *Pointer, size_t Size)
   92700             : {
   92701             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   92702             :      * or throwing an exception. */
   92703         108 :     ALLOC_MUTEX(SgCatchStatementSeq, lock);
   92704             : 
   92705             : #if USE_CPP_NEW_DELETE_OPERATORS
   92706             :     ROSE_FREE(Pointer);
   92707             : #else
   92708             : #if ROSE_PEDANTIC_ALLOC
   92709             :     ROSE_ASSERT(Size == sizeof(SgCatchStatementSeq));
   92710             : #else
   92711         108 :     if (Size != sizeof(SgCatchStatementSeq)) {
   92712           0 :       ROSE_FREE(Pointer);
   92713           0 :       ALLOC_MUTEX(SgCatchStatementSeq, unlock);
   92714             :       return;
   92715             :     }
   92716             : #endif
   92717             : 
   92718         108 :     SgCatchStatementSeq * object = (SgCatchStatementSeq*) Pointer;
   92719         108 :     ROSE_ASSERT(object != nullptr);
   92720             : 
   92721             : #if ROSE_ALLOC_TRACE == 2
   92722             : //  printf("SgCatchStatementSeq::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgCatchStatementSeq::next_node);
   92723             :     printf("SgCatchStatementSeq::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgCatchStatementSeq::next_node);
   92724             : #endif
   92725             : 
   92726             : #if ROSE_PEDANTIC_ALLOC
   92727             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   92728             : #endif
   92729             : 
   92730             : #if ROSE_ALLOC_MEMSET == 1
   92731             : #elif ROSE_ALLOC_MEMSET == 2
   92732             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgCatchStatementSeq) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   92733             : #elif ROSE_ALLOC_MEMSET == 3
   92734             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgCatchStatementSeq) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   92735             : #endif
   92736             : 
   92737             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   92738             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   92739             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   92740             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   92741             : #else
   92742         108 :     object->p_freepointer = SgCatchStatementSeq::next_node;
   92743         108 :     SgCatchStatementSeq::next_node = object;
   92744             : #endif
   92745             : 
   92746             : #if ROSE_ALLOC_TRACE == 2
   92747             : //  printf("SgCatchStatementSeq::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgCatchStatementSeq::next_node);
   92748             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   92749             :     Rose::MemPool::snapshot(oss.str());
   92750             :     alloc_trace_cnt++;
   92751             : #endif
   92752             : 
   92753             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   92754             : 
   92755         108 :     ALLOC_MUTEX(SgCatchStatementSeq, unlock);
   92756             : }
   92757             : 
   92758             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   92759             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   92760             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   92761             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   92762             : // Also, note comment below from Robb (copied from the Common.code file).
   92763             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   92764             : //
   92765             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   92766             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   92767             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   92768             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   92769             : #if 0
   92770             : void SgCatchStatementSeq::operator delete(void* pointer) { SgCatchStatementSeq::operator delete (pointer, sizeof(SgCatchStatementSeq)); };
   92771             : #endif
   92772             : /* #line 92773 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   92773             : 
   92774             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   92775             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   92776             : // obviously imply C++.
   92777             : 
   92778             : // This implements the support within ROSE for memory pools.  Memory pools
   92779             : // support the most condensed usage of memory within the construction of
   92780             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   92781             : // by a new operator written for each class.
   92782             : 
   92783             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   92784             :     // User wants multi-thread support and POSIX threads are available.
   92785             : #   include <pthread.h>
   92786             :     static pthread_mutex_t SgProcessControlStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   92787             : #else
   92788             :      // Cause synchronization to be skipped.
   92789             : #    ifndef ALLOC_MUTEX
   92790             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   92791             : #    endif
   92792             : #    ifdef _REENTRANT
   92793             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   92794             : #       ifdef _MSC_VER
   92795             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   92796             : #       else
   92797             : #           warning "POSIX threads are not available; synchronization being skipped"
   92798             : #       endif
   92799             : #    endif
   92800             : #endif
   92801             : 
   92802             : #ifndef ROSE_ALLOC_TRACE
   92803             : #  define ROSE_ALLOC_TRACE 0
   92804             : #endif
   92805             : 
   92806             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   92807             : #define ROSE_ALLOC_TRACE_CNT
   92808             : #include "memory-pool-snapshot.h"
   92809             : unsigned long alloc_trace_cnt = 0;
   92810             : #endif
   92811             : 
   92812             : #if ROSE_ALLOC_TRACE
   92813             : const unsigned SgProcessControlStatement::pool_size = 5;
   92814             : #else
   92815             : const unsigned SgProcessControlStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   92816             : #endif
   92817             : 
   92818             : #ifndef ROSE_ALLOC_MEMSET
   92819             : #  define ROSE_ALLOC_MEMSET 0
   92820             : #endif
   92821             : 
   92822             : #ifndef ROSE_PEDANTIC_ALLOC
   92823             : #  define ROSE_PEDANTIC_ALLOC 0
   92824             : #endif
   92825             : 
   92826             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   92827             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   92828             : #endif
   92829             : 
   92830             : #if !defined(SGNODE__ALL_POOLS)
   92831             : #define SGNODE__ALL_POOLS
   92832             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   92833             : #endif
   92834             : 
   92835             : SgProcessControlStatement* SgProcessControlStatement::next_node = nullptr;
   92836             : std::vector<unsigned char*> SgProcessControlStatement::pools;
   92837             : 
   92838             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   92839             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   92840             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   92841             : // around this macro definition rather than each use).
   92842             : #ifndef ALLOC_MUTEX
   92843             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   92844             :         do {                                                                     \
   92845             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   92846             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   92847             :                 abort();                                                         \
   92848             :             }                                                                    \
   92849             :         } while (0);
   92850             : #endif
   92851             : 
   92852             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   92853             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   92854             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   92855             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   92856             : 
   92857             : /*! \brief New operator for SgProcessControlStatement.
   92858             : 
   92859             :    This new operator implements memory pools to provide most efficent 
   92860             :    use of the heap within construction of large ASTs.
   92861             : 
   92862             : \internal The new and delete operators use the lower level C malloc/free
   92863             :    function calls for performance and to make sure that mixing of malloc/free
   92864             :    and new/delete by the used can be caught more readily.  This may change
   92865             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   92866             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   92867             :    deallocate memory allocated using ROSE_MALLOC.
   92868             : */
   92869           1 : void *SgProcessControlStatement::operator new ( size_t Size )
   92870             : {
   92871             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   92872             :      * returning or throwing an exception. */
   92873           1 :     ALLOC_MUTEX(SgProcessControlStatement, lock);
   92874             : 
   92875             : #if ROSE_ALLOC_TRACE == 2
   92876             : //    printf("SgProcessControlStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgProcessControlStatement::next_node);
   92877             : #endif
   92878             : 
   92879             : #if USE_CPP_NEW_DELETE_OPERATORS
   92880             :     void *mem = ROSE_MALLOC(Size);
   92881             :     ALLOC_MUTEX(SgProcessControlStatement, unlock);
   92882             :     return mem;
   92883             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   92884             : #if ROSE_PEDANTIC_ALLOC
   92885             :     ROSE_ASSERT(Size == sizeof(SgProcessControlStatement));
   92886             : #else
   92887           1 :     if (Size != sizeof(SgProcessControlStatement)) {
   92888           0 :       void * object = ROSE_MALLOC(Size);
   92889           0 :       ALLOC_MUTEX(SgProcessControlStatement, unlock);
   92890             :       return object;
   92891             :     }
   92892             : #endif
   92893             : 
   92894           1 :     if (SgProcessControlStatement::next_node == nullptr) {
   92895           1 :         SgProcessControlStatement * alloc = (SgProcessControlStatement*) ROSE_MALLOC ( SgProcessControlStatement::pool_size * sizeof(SgProcessControlStatement) );
   92896           1 :         ROSE_ASSERT(alloc != nullptr);
   92897             : 
   92898             : #if ROSE_ALLOC_TRACE == 2
   92899             : //        printf("SgProcessControlStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgProcessControlStatement::pools.size(), alloc, alloc + SgProcessControlStatement::pool_size);
   92900             : #endif
   92901             : 
   92902             : #if ROSE_ALLOC_MEMSET == 1
   92903             : #elif ROSE_ALLOC_MEMSET == 2
   92904             :         memset(alloc, 0x00, SgProcessControlStatement::pool_size * sizeof(SgProcessControlStatement));
   92905             : #elif ROSE_ALLOC_MEMSET == 3
   92906             :         memset(alloc, 0xAA, SgProcessControlStatement::pool_size * sizeof(SgProcessControlStatement));
   92907             : #endif
   92908        2000 :         for (unsigned i=0; i < SgProcessControlStatement::pool_size-1; i++) {
   92909        1999 :           alloc[i].p_freepointer = &(alloc[i+1]);
   92910             :         }
   92911           1 :         alloc[SgProcessControlStatement::pool_size-1].p_freepointer = nullptr;
   92912             : 
   92913           1 :         SgProcessControlStatement::pools.push_back ( (unsigned char *) alloc );
   92914           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgProcessControlStatement::pool_size * sizeof(SgProcessControlStatement), V_SgProcessControlStatement ) );
   92915           1 :         SgProcessControlStatement::next_node = alloc;
   92916             :     }
   92917           1 :     ROSE_ASSERT(SgProcessControlStatement::next_node != nullptr);
   92918             : 
   92919           1 :     SgProcessControlStatement * object = SgProcessControlStatement::next_node;
   92920           1 :     SgProcessControlStatement::next_node = (SgProcessControlStatement*)(object->p_freepointer);
   92921             : 
   92922             : #if ROSE_ALLOC_TRACE == 2
   92923             :     printf("SgProcessControlStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgProcessControlStatement::next_node);
   92924             : #endif
   92925             : 
   92926           1 :     SgNode * fp = object->p_freepointer;
   92927             : #if ROSE_ALLOC_MEMSET == 1
   92928             : #elif ROSE_ALLOC_MEMSET == 2
   92929             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgProcessControlStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   92930             : #elif ROSE_ALLOC_MEMSET == 3
   92931             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgProcessControlStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   92932             : #endif
   92933           1 :     object->p_freepointer = fp;
   92934             : 
   92935             : #if ROSE_ALLOC_TRACE == 2
   92936             : //    printf("SgProcessControlStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgProcessControlStatement::next_node);
   92937             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   92938             :     Rose::MemPool::snapshot(oss.str());
   92939             :     alloc_trace_cnt++;
   92940             : #endif
   92941             : 
   92942           1 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   92943             : 
   92944           1 :     ALLOC_MUTEX(SgProcessControlStatement, unlock);
   92945             : 
   92946             :     return object;
   92947             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   92948             : }
   92949             : 
   92950             : 
   92951             : 
   92952             : /*! \brief Delete operator for SgProcessControlStatement.
   92953             : 
   92954             :    This delete operator implements deallocation using memory pools to 
   92955             :    provide most efficent use of the heap within construction of large ASTs.
   92956             : 
   92957             : \internal The new and delete operators use the lower level C malloc/free
   92958             :    function calls for performance and to make sure that mixing of malloc/free
   92959             :    and new/delete by the used can be caught more readily.  This may change
   92960             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   92961             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   92962             :    deallocate memory allocated using ROSE_MALLOC.
   92963             : */
   92964           0 : void SgProcessControlStatement::operator delete(void *Pointer, size_t Size)
   92965             : {
   92966             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   92967             :      * or throwing an exception. */
   92968           0 :     ALLOC_MUTEX(SgProcessControlStatement, lock);
   92969             : 
   92970             : #if USE_CPP_NEW_DELETE_OPERATORS
   92971             :     ROSE_FREE(Pointer);
   92972             : #else
   92973             : #if ROSE_PEDANTIC_ALLOC
   92974             :     ROSE_ASSERT(Size == sizeof(SgProcessControlStatement));
   92975             : #else
   92976           0 :     if (Size != sizeof(SgProcessControlStatement)) {
   92977           0 :       ROSE_FREE(Pointer);
   92978           0 :       ALLOC_MUTEX(SgProcessControlStatement, unlock);
   92979             :       return;
   92980             :     }
   92981             : #endif
   92982             : 
   92983           0 :     SgProcessControlStatement * object = (SgProcessControlStatement*) Pointer;
   92984           0 :     ROSE_ASSERT(object != nullptr);
   92985             : 
   92986             : #if ROSE_ALLOC_TRACE == 2
   92987             : //  printf("SgProcessControlStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgProcessControlStatement::next_node);
   92988             :     printf("SgProcessControlStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgProcessControlStatement::next_node);
   92989             : #endif
   92990             : 
   92991             : #if ROSE_PEDANTIC_ALLOC
   92992             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   92993             : #endif
   92994             : 
   92995             : #if ROSE_ALLOC_MEMSET == 1
   92996             : #elif ROSE_ALLOC_MEMSET == 2
   92997             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgProcessControlStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   92998             : #elif ROSE_ALLOC_MEMSET == 3
   92999             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgProcessControlStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   93000             : #endif
   93001             : 
   93002             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   93003             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   93004             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   93005             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   93006             : #else
   93007           0 :     object->p_freepointer = SgProcessControlStatement::next_node;
   93008           0 :     SgProcessControlStatement::next_node = object;
   93009             : #endif
   93010             : 
   93011             : #if ROSE_ALLOC_TRACE == 2
   93012             : //  printf("SgProcessControlStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgProcessControlStatement::next_node);
   93013             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   93014             :     Rose::MemPool::snapshot(oss.str());
   93015             :     alloc_trace_cnt++;
   93016             : #endif
   93017             : 
   93018             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   93019             : 
   93020           0 :     ALLOC_MUTEX(SgProcessControlStatement, unlock);
   93021             : }
   93022             : 
   93023             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   93024             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   93025             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   93026             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   93027             : // Also, note comment below from Robb (copied from the Common.code file).
   93028             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   93029             : //
   93030             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   93031             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   93032             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   93033             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   93034             : #if 0
   93035             : void SgProcessControlStatement::operator delete(void* pointer) { SgProcessControlStatement::operator delete (pointer, sizeof(SgProcessControlStatement)); };
   93036             : #endif
   93037             : /* #line 93038 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   93038             : 
   93039             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   93040             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   93041             : // obviously imply C++.
   93042             : 
   93043             : // This implements the support within ROSE for memory pools.  Memory pools
   93044             : // support the most condensed usage of memory within the construction of
   93045             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   93046             : // by a new operator written for each class.
   93047             : 
   93048             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   93049             :     // User wants multi-thread support and POSIX threads are available.
   93050             : #   include <pthread.h>
   93051             :     static pthread_mutex_t SgIOStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   93052             : #else
   93053             :      // Cause synchronization to be skipped.
   93054             : #    ifndef ALLOC_MUTEX
   93055             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   93056             : #    endif
   93057             : #    ifdef _REENTRANT
   93058             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   93059             : #       ifdef _MSC_VER
   93060             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   93061             : #       else
   93062             : #           warning "POSIX threads are not available; synchronization being skipped"
   93063             : #       endif
   93064             : #    endif
   93065             : #endif
   93066             : 
   93067             : #ifndef ROSE_ALLOC_TRACE
   93068             : #  define ROSE_ALLOC_TRACE 0
   93069             : #endif
   93070             : 
   93071             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   93072             : #define ROSE_ALLOC_TRACE_CNT
   93073             : #include "memory-pool-snapshot.h"
   93074             : unsigned long alloc_trace_cnt = 0;
   93075             : #endif
   93076             : 
   93077             : #if ROSE_ALLOC_TRACE
   93078             : const unsigned SgIOStatement::pool_size = 5;
   93079             : #else
   93080             : const unsigned SgIOStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   93081             : #endif
   93082             : 
   93083             : #ifndef ROSE_ALLOC_MEMSET
   93084             : #  define ROSE_ALLOC_MEMSET 0
   93085             : #endif
   93086             : 
   93087             : #ifndef ROSE_PEDANTIC_ALLOC
   93088             : #  define ROSE_PEDANTIC_ALLOC 0
   93089             : #endif
   93090             : 
   93091             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   93092             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   93093             : #endif
   93094             : 
   93095             : #if !defined(SGNODE__ALL_POOLS)
   93096             : #define SGNODE__ALL_POOLS
   93097             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   93098             : #endif
   93099             : 
   93100             : SgIOStatement* SgIOStatement::next_node = nullptr;
   93101             : std::vector<unsigned char*> SgIOStatement::pools;
   93102             : 
   93103             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   93104             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   93105             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   93106             : // around this macro definition rather than each use).
   93107             : #ifndef ALLOC_MUTEX
   93108             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   93109             :         do {                                                                     \
   93110             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   93111             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   93112             :                 abort();                                                         \
   93113             :             }                                                                    \
   93114             :         } while (0);
   93115             : #endif
   93116             : 
   93117             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   93118             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   93119             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   93120             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   93121             : 
   93122             : /*! \brief New operator for SgIOStatement.
   93123             : 
   93124             :    This new operator implements memory pools to provide most efficent 
   93125             :    use of the heap within construction of large ASTs.
   93126             : 
   93127             : \internal The new and delete operators use the lower level C malloc/free
   93128             :    function calls for performance and to make sure that mixing of malloc/free
   93129             :    and new/delete by the used can be caught more readily.  This may change
   93130             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   93131             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   93132             :    deallocate memory allocated using ROSE_MALLOC.
   93133             : */
   93134           0 : void *SgIOStatement::operator new ( size_t Size )
   93135             : {
   93136             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   93137             :      * returning or throwing an exception. */
   93138           0 :     ALLOC_MUTEX(SgIOStatement, lock);
   93139             : 
   93140             : #if ROSE_ALLOC_TRACE == 2
   93141             : //    printf("SgIOStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgIOStatement::next_node);
   93142             : #endif
   93143             : 
   93144             : #if USE_CPP_NEW_DELETE_OPERATORS
   93145             :     void *mem = ROSE_MALLOC(Size);
   93146             :     ALLOC_MUTEX(SgIOStatement, unlock);
   93147             :     return mem;
   93148             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   93149             : #if ROSE_PEDANTIC_ALLOC
   93150             :     ROSE_ASSERT(Size == sizeof(SgIOStatement));
   93151             : #else
   93152           0 :     if (Size != sizeof(SgIOStatement)) {
   93153           0 :       void * object = ROSE_MALLOC(Size);
   93154           0 :       ALLOC_MUTEX(SgIOStatement, unlock);
   93155             :       return object;
   93156             :     }
   93157             : #endif
   93158             : 
   93159           0 :     if (SgIOStatement::next_node == nullptr) {
   93160           0 :         SgIOStatement * alloc = (SgIOStatement*) ROSE_MALLOC ( SgIOStatement::pool_size * sizeof(SgIOStatement) );
   93161           0 :         ROSE_ASSERT(alloc != nullptr);
   93162             : 
   93163             : #if ROSE_ALLOC_TRACE == 2
   93164             : //        printf("SgIOStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgIOStatement::pools.size(), alloc, alloc + SgIOStatement::pool_size);
   93165             : #endif
   93166             : 
   93167             : #if ROSE_ALLOC_MEMSET == 1
   93168             : #elif ROSE_ALLOC_MEMSET == 2
   93169             :         memset(alloc, 0x00, SgIOStatement::pool_size * sizeof(SgIOStatement));
   93170             : #elif ROSE_ALLOC_MEMSET == 3
   93171             :         memset(alloc, 0xAA, SgIOStatement::pool_size * sizeof(SgIOStatement));
   93172             : #endif
   93173           0 :         for (unsigned i=0; i < SgIOStatement::pool_size-1; i++) {
   93174           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
   93175             :         }
   93176           0 :         alloc[SgIOStatement::pool_size-1].p_freepointer = nullptr;
   93177             : 
   93178           0 :         SgIOStatement::pools.push_back ( (unsigned char *) alloc );
   93179           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgIOStatement::pool_size * sizeof(SgIOStatement), V_SgIOStatement ) );
   93180           0 :         SgIOStatement::next_node = alloc;
   93181             :     }
   93182           0 :     ROSE_ASSERT(SgIOStatement::next_node != nullptr);
   93183             : 
   93184           0 :     SgIOStatement * object = SgIOStatement::next_node;
   93185           0 :     SgIOStatement::next_node = (SgIOStatement*)(object->p_freepointer);
   93186             : 
   93187             : #if ROSE_ALLOC_TRACE == 2
   93188             :     printf("SgIOStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgIOStatement::next_node);
   93189             : #endif
   93190             : 
   93191           0 :     SgNode * fp = object->p_freepointer;
   93192             : #if ROSE_ALLOC_MEMSET == 1
   93193             : #elif ROSE_ALLOC_MEMSET == 2
   93194             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgIOStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   93195             : #elif ROSE_ALLOC_MEMSET == 3
   93196             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgIOStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   93197             : #endif
   93198           0 :     object->p_freepointer = fp;
   93199             : 
   93200             : #if ROSE_ALLOC_TRACE == 2
   93201             : //    printf("SgIOStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgIOStatement::next_node);
   93202             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   93203             :     Rose::MemPool::snapshot(oss.str());
   93204             :     alloc_trace_cnt++;
   93205             : #endif
   93206             : 
   93207           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   93208             : 
   93209           0 :     ALLOC_MUTEX(SgIOStatement, unlock);
   93210             : 
   93211             :     return object;
   93212             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   93213             : }
   93214             : 
   93215             : 
   93216             : 
   93217             : /*! \brief Delete operator for SgIOStatement.
   93218             : 
   93219             :    This delete operator implements deallocation using memory pools to 
   93220             :    provide most efficent use of the heap within construction of large ASTs.
   93221             : 
   93222             : \internal The new and delete operators use the lower level C malloc/free
   93223             :    function calls for performance and to make sure that mixing of malloc/free
   93224             :    and new/delete by the used can be caught more readily.  This may change
   93225             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   93226             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   93227             :    deallocate memory allocated using ROSE_MALLOC.
   93228             : */
   93229           0 : void SgIOStatement::operator delete(void *Pointer, size_t Size)
   93230             : {
   93231             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   93232             :      * or throwing an exception. */
   93233           0 :     ALLOC_MUTEX(SgIOStatement, lock);
   93234             : 
   93235             : #if USE_CPP_NEW_DELETE_OPERATORS
   93236             :     ROSE_FREE(Pointer);
   93237             : #else
   93238             : #if ROSE_PEDANTIC_ALLOC
   93239             :     ROSE_ASSERT(Size == sizeof(SgIOStatement));
   93240             : #else
   93241           0 :     if (Size != sizeof(SgIOStatement)) {
   93242           0 :       ROSE_FREE(Pointer);
   93243           0 :       ALLOC_MUTEX(SgIOStatement, unlock);
   93244             :       return;
   93245             :     }
   93246             : #endif
   93247             : 
   93248           0 :     SgIOStatement * object = (SgIOStatement*) Pointer;
   93249           0 :     ROSE_ASSERT(object != nullptr);
   93250             : 
   93251             : #if ROSE_ALLOC_TRACE == 2
   93252             : //  printf("SgIOStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgIOStatement::next_node);
   93253             :     printf("SgIOStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgIOStatement::next_node);
   93254             : #endif
   93255             : 
   93256             : #if ROSE_PEDANTIC_ALLOC
   93257             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   93258             : #endif
   93259             : 
   93260             : #if ROSE_ALLOC_MEMSET == 1
   93261             : #elif ROSE_ALLOC_MEMSET == 2
   93262             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgIOStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   93263             : #elif ROSE_ALLOC_MEMSET == 3
   93264             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgIOStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   93265             : #endif
   93266             : 
   93267             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   93268             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   93269             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   93270             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   93271             : #else
   93272           0 :     object->p_freepointer = SgIOStatement::next_node;
   93273           0 :     SgIOStatement::next_node = object;
   93274             : #endif
   93275             : 
   93276             : #if ROSE_ALLOC_TRACE == 2
   93277             : //  printf("SgIOStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgIOStatement::next_node);
   93278             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   93279             :     Rose::MemPool::snapshot(oss.str());
   93280             :     alloc_trace_cnt++;
   93281             : #endif
   93282             : 
   93283             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   93284             : 
   93285           0 :     ALLOC_MUTEX(SgIOStatement, unlock);
   93286             : }
   93287             : 
   93288             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   93289             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   93290             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   93291             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   93292             : // Also, note comment below from Robb (copied from the Common.code file).
   93293             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   93294             : //
   93295             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   93296             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   93297             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   93298             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   93299             : #if 0
   93300             : void SgIOStatement::operator delete(void* pointer) { SgIOStatement::operator delete (pointer, sizeof(SgIOStatement)); };
   93301             : #endif
   93302             : /* #line 93303 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   93303             : 
   93304             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   93305             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   93306             : // obviously imply C++.
   93307             : 
   93308             : // This implements the support within ROSE for memory pools.  Memory pools
   93309             : // support the most condensed usage of memory within the construction of
   93310             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   93311             : // by a new operator written for each class.
   93312             : 
   93313             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   93314             :     // User wants multi-thread support and POSIX threads are available.
   93315             : #   include <pthread.h>
   93316             :     static pthread_mutex_t SgPrintStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   93317             : #else
   93318             :      // Cause synchronization to be skipped.
   93319             : #    ifndef ALLOC_MUTEX
   93320             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   93321             : #    endif
   93322             : #    ifdef _REENTRANT
   93323             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   93324             : #       ifdef _MSC_VER
   93325             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   93326             : #       else
   93327             : #           warning "POSIX threads are not available; synchronization being skipped"
   93328             : #       endif
   93329             : #    endif
   93330             : #endif
   93331             : 
   93332             : #ifndef ROSE_ALLOC_TRACE
   93333             : #  define ROSE_ALLOC_TRACE 0
   93334             : #endif
   93335             : 
   93336             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   93337             : #define ROSE_ALLOC_TRACE_CNT
   93338             : #include "memory-pool-snapshot.h"
   93339             : unsigned long alloc_trace_cnt = 0;
   93340             : #endif
   93341             : 
   93342             : #if ROSE_ALLOC_TRACE
   93343             : const unsigned SgPrintStatement::pool_size = 5;
   93344             : #else
   93345             : const unsigned SgPrintStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   93346             : #endif
   93347             : 
   93348             : #ifndef ROSE_ALLOC_MEMSET
   93349             : #  define ROSE_ALLOC_MEMSET 0
   93350             : #endif
   93351             : 
   93352             : #ifndef ROSE_PEDANTIC_ALLOC
   93353             : #  define ROSE_PEDANTIC_ALLOC 0
   93354             : #endif
   93355             : 
   93356             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   93357             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   93358             : #endif
   93359             : 
   93360             : #if !defined(SGNODE__ALL_POOLS)
   93361             : #define SGNODE__ALL_POOLS
   93362             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   93363             : #endif
   93364             : 
   93365             : SgPrintStatement* SgPrintStatement::next_node = nullptr;
   93366             : std::vector<unsigned char*> SgPrintStatement::pools;
   93367             : 
   93368             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   93369             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   93370             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   93371             : // around this macro definition rather than each use).
   93372             : #ifndef ALLOC_MUTEX
   93373             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   93374             :         do {                                                                     \
   93375             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   93376             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   93377             :                 abort();                                                         \
   93378             :             }                                                                    \
   93379             :         } while (0);
   93380             : #endif
   93381             : 
   93382             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   93383             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   93384             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   93385             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   93386             : 
   93387             : /*! \brief New operator for SgPrintStatement.
   93388             : 
   93389             :    This new operator implements memory pools to provide most efficent 
   93390             :    use of the heap within construction of large ASTs.
   93391             : 
   93392             : \internal The new and delete operators use the lower level C malloc/free
   93393             :    function calls for performance and to make sure that mixing of malloc/free
   93394             :    and new/delete by the used can be caught more readily.  This may change
   93395             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   93396             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   93397             :    deallocate memory allocated using ROSE_MALLOC.
   93398             : */
   93399          55 : void *SgPrintStatement::operator new ( size_t Size )
   93400             : {
   93401             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   93402             :      * returning or throwing an exception. */
   93403          55 :     ALLOC_MUTEX(SgPrintStatement, lock);
   93404             : 
   93405             : #if ROSE_ALLOC_TRACE == 2
   93406             : //    printf("SgPrintStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgPrintStatement::next_node);
   93407             : #endif
   93408             : 
   93409             : #if USE_CPP_NEW_DELETE_OPERATORS
   93410             :     void *mem = ROSE_MALLOC(Size);
   93411             :     ALLOC_MUTEX(SgPrintStatement, unlock);
   93412             :     return mem;
   93413             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   93414             : #if ROSE_PEDANTIC_ALLOC
   93415             :     ROSE_ASSERT(Size == sizeof(SgPrintStatement));
   93416             : #else
   93417          55 :     if (Size != sizeof(SgPrintStatement)) {
   93418           0 :       void * object = ROSE_MALLOC(Size);
   93419           0 :       ALLOC_MUTEX(SgPrintStatement, unlock);
   93420             :       return object;
   93421             :     }
   93422             : #endif
   93423             : 
   93424          55 :     if (SgPrintStatement::next_node == nullptr) {
   93425          28 :         SgPrintStatement * alloc = (SgPrintStatement*) ROSE_MALLOC ( SgPrintStatement::pool_size * sizeof(SgPrintStatement) );
   93426          28 :         ROSE_ASSERT(alloc != nullptr);
   93427             : 
   93428             : #if ROSE_ALLOC_TRACE == 2
   93429             : //        printf("SgPrintStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgPrintStatement::pools.size(), alloc, alloc + SgPrintStatement::pool_size);
   93430             : #endif
   93431             : 
   93432             : #if ROSE_ALLOC_MEMSET == 1
   93433             : #elif ROSE_ALLOC_MEMSET == 2
   93434             :         memset(alloc, 0x00, SgPrintStatement::pool_size * sizeof(SgPrintStatement));
   93435             : #elif ROSE_ALLOC_MEMSET == 3
   93436             :         memset(alloc, 0xAA, SgPrintStatement::pool_size * sizeof(SgPrintStatement));
   93437             : #endif
   93438       56000 :         for (unsigned i=0; i < SgPrintStatement::pool_size-1; i++) {
   93439       55972 :           alloc[i].p_freepointer = &(alloc[i+1]);
   93440             :         }
   93441          28 :         alloc[SgPrintStatement::pool_size-1].p_freepointer = nullptr;
   93442             : 
   93443          28 :         SgPrintStatement::pools.push_back ( (unsigned char *) alloc );
   93444          28 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgPrintStatement::pool_size * sizeof(SgPrintStatement), V_SgPrintStatement ) );
   93445          28 :         SgPrintStatement::next_node = alloc;
   93446             :     }
   93447          55 :     ROSE_ASSERT(SgPrintStatement::next_node != nullptr);
   93448             : 
   93449          55 :     SgPrintStatement * object = SgPrintStatement::next_node;
   93450          55 :     SgPrintStatement::next_node = (SgPrintStatement*)(object->p_freepointer);
   93451             : 
   93452             : #if ROSE_ALLOC_TRACE == 2
   93453             :     printf("SgPrintStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgPrintStatement::next_node);
   93454             : #endif
   93455             : 
   93456          55 :     SgNode * fp = object->p_freepointer;
   93457             : #if ROSE_ALLOC_MEMSET == 1
   93458             : #elif ROSE_ALLOC_MEMSET == 2
   93459             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgPrintStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   93460             : #elif ROSE_ALLOC_MEMSET == 3
   93461             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgPrintStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   93462             : #endif
   93463          55 :     object->p_freepointer = fp;
   93464             : 
   93465             : #if ROSE_ALLOC_TRACE == 2
   93466             : //    printf("SgPrintStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgPrintStatement::next_node);
   93467             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   93468             :     Rose::MemPool::snapshot(oss.str());
   93469             :     alloc_trace_cnt++;
   93470             : #endif
   93471             : 
   93472          55 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   93473             : 
   93474          55 :     ALLOC_MUTEX(SgPrintStatement, unlock);
   93475             : 
   93476             :     return object;
   93477             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   93478             : }
   93479             : 
   93480             : 
   93481             : 
   93482             : /*! \brief Delete operator for SgPrintStatement.
   93483             : 
   93484             :    This delete operator implements deallocation using memory pools to 
   93485             :    provide most efficent use of the heap within construction of large ASTs.
   93486             : 
   93487             : \internal The new and delete operators use the lower level C malloc/free
   93488             :    function calls for performance and to make sure that mixing of malloc/free
   93489             :    and new/delete by the used can be caught more readily.  This may change
   93490             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   93491             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   93492             :    deallocate memory allocated using ROSE_MALLOC.
   93493             : */
   93494           1 : void SgPrintStatement::operator delete(void *Pointer, size_t Size)
   93495             : {
   93496             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   93497             :      * or throwing an exception. */
   93498           1 :     ALLOC_MUTEX(SgPrintStatement, lock);
   93499             : 
   93500             : #if USE_CPP_NEW_DELETE_OPERATORS
   93501             :     ROSE_FREE(Pointer);
   93502             : #else
   93503             : #if ROSE_PEDANTIC_ALLOC
   93504             :     ROSE_ASSERT(Size == sizeof(SgPrintStatement));
   93505             : #else
   93506           1 :     if (Size != sizeof(SgPrintStatement)) {
   93507           0 :       ROSE_FREE(Pointer);
   93508           0 :       ALLOC_MUTEX(SgPrintStatement, unlock);
   93509             :       return;
   93510             :     }
   93511             : #endif
   93512             : 
   93513           1 :     SgPrintStatement * object = (SgPrintStatement*) Pointer;
   93514           1 :     ROSE_ASSERT(object != nullptr);
   93515             : 
   93516             : #if ROSE_ALLOC_TRACE == 2
   93517             : //  printf("SgPrintStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgPrintStatement::next_node);
   93518             :     printf("SgPrintStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgPrintStatement::next_node);
   93519             : #endif
   93520             : 
   93521             : #if ROSE_PEDANTIC_ALLOC
   93522             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   93523             : #endif
   93524             : 
   93525             : #if ROSE_ALLOC_MEMSET == 1
   93526             : #elif ROSE_ALLOC_MEMSET == 2
   93527             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgPrintStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   93528             : #elif ROSE_ALLOC_MEMSET == 3
   93529             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgPrintStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   93530             : #endif
   93531             : 
   93532             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   93533             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   93534             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   93535             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   93536             : #else
   93537           1 :     object->p_freepointer = SgPrintStatement::next_node;
   93538           1 :     SgPrintStatement::next_node = object;
   93539             : #endif
   93540             : 
   93541             : #if ROSE_ALLOC_TRACE == 2
   93542             : //  printf("SgPrintStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgPrintStatement::next_node);
   93543             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   93544             :     Rose::MemPool::snapshot(oss.str());
   93545             :     alloc_trace_cnt++;
   93546             : #endif
   93547             : 
   93548             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   93549             : 
   93550           1 :     ALLOC_MUTEX(SgPrintStatement, unlock);
   93551             : }
   93552             : 
   93553             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   93554             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   93555             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   93556             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   93557             : // Also, note comment below from Robb (copied from the Common.code file).
   93558             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   93559             : //
   93560             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   93561             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   93562             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   93563             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   93564             : #if 0
   93565             : void SgPrintStatement::operator delete(void* pointer) { SgPrintStatement::operator delete (pointer, sizeof(SgPrintStatement)); };
   93566             : #endif
   93567             : /* #line 93568 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   93568             : 
   93569             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   93570             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   93571             : // obviously imply C++.
   93572             : 
   93573             : // This implements the support within ROSE for memory pools.  Memory pools
   93574             : // support the most condensed usage of memory within the construction of
   93575             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   93576             : // by a new operator written for each class.
   93577             : 
   93578             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   93579             :     // User wants multi-thread support and POSIX threads are available.
   93580             : #   include <pthread.h>
   93581             :     static pthread_mutex_t SgReadStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   93582             : #else
   93583             :      // Cause synchronization to be skipped.
   93584             : #    ifndef ALLOC_MUTEX
   93585             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   93586             : #    endif
   93587             : #    ifdef _REENTRANT
   93588             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   93589             : #       ifdef _MSC_VER
   93590             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   93591             : #       else
   93592             : #           warning "POSIX threads are not available; synchronization being skipped"
   93593             : #       endif
   93594             : #    endif
   93595             : #endif
   93596             : 
   93597             : #ifndef ROSE_ALLOC_TRACE
   93598             : #  define ROSE_ALLOC_TRACE 0
   93599             : #endif
   93600             : 
   93601             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   93602             : #define ROSE_ALLOC_TRACE_CNT
   93603             : #include "memory-pool-snapshot.h"
   93604             : unsigned long alloc_trace_cnt = 0;
   93605             : #endif
   93606             : 
   93607             : #if ROSE_ALLOC_TRACE
   93608             : const unsigned SgReadStatement::pool_size = 5;
   93609             : #else
   93610             : const unsigned SgReadStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   93611             : #endif
   93612             : 
   93613             : #ifndef ROSE_ALLOC_MEMSET
   93614             : #  define ROSE_ALLOC_MEMSET 0
   93615             : #endif
   93616             : 
   93617             : #ifndef ROSE_PEDANTIC_ALLOC
   93618             : #  define ROSE_PEDANTIC_ALLOC 0
   93619             : #endif
   93620             : 
   93621             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   93622             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   93623             : #endif
   93624             : 
   93625             : #if !defined(SGNODE__ALL_POOLS)
   93626             : #define SGNODE__ALL_POOLS
   93627             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   93628             : #endif
   93629             : 
   93630             : SgReadStatement* SgReadStatement::next_node = nullptr;
   93631             : std::vector<unsigned char*> SgReadStatement::pools;
   93632             : 
   93633             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   93634             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   93635             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   93636             : // around this macro definition rather than each use).
   93637             : #ifndef ALLOC_MUTEX
   93638             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   93639             :         do {                                                                     \
   93640             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   93641             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   93642             :                 abort();                                                         \
   93643             :             }                                                                    \
   93644             :         } while (0);
   93645             : #endif
   93646             : 
   93647             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   93648             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   93649             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   93650             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   93651             : 
   93652             : /*! \brief New operator for SgReadStatement.
   93653             : 
   93654             :    This new operator implements memory pools to provide most efficent 
   93655             :    use of the heap within construction of large ASTs.
   93656             : 
   93657             : \internal The new and delete operators use the lower level C malloc/free
   93658             :    function calls for performance and to make sure that mixing of malloc/free
   93659             :    and new/delete by the used can be caught more readily.  This may change
   93660             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   93661             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   93662             :    deallocate memory allocated using ROSE_MALLOC.
   93663             : */
   93664           0 : void *SgReadStatement::operator new ( size_t Size )
   93665             : {
   93666             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   93667             :      * returning or throwing an exception. */
   93668           0 :     ALLOC_MUTEX(SgReadStatement, lock);
   93669             : 
   93670             : #if ROSE_ALLOC_TRACE == 2
   93671             : //    printf("SgReadStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgReadStatement::next_node);
   93672             : #endif
   93673             : 
   93674             : #if USE_CPP_NEW_DELETE_OPERATORS
   93675             :     void *mem = ROSE_MALLOC(Size);
   93676             :     ALLOC_MUTEX(SgReadStatement, unlock);
   93677             :     return mem;
   93678             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   93679             : #if ROSE_PEDANTIC_ALLOC
   93680             :     ROSE_ASSERT(Size == sizeof(SgReadStatement));
   93681             : #else
   93682           0 :     if (Size != sizeof(SgReadStatement)) {
   93683           0 :       void * object = ROSE_MALLOC(Size);
   93684           0 :       ALLOC_MUTEX(SgReadStatement, unlock);
   93685             :       return object;
   93686             :     }
   93687             : #endif
   93688             : 
   93689           0 :     if (SgReadStatement::next_node == nullptr) {
   93690           0 :         SgReadStatement * alloc = (SgReadStatement*) ROSE_MALLOC ( SgReadStatement::pool_size * sizeof(SgReadStatement) );
   93691           0 :         ROSE_ASSERT(alloc != nullptr);
   93692             : 
   93693             : #if ROSE_ALLOC_TRACE == 2
   93694             : //        printf("SgReadStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgReadStatement::pools.size(), alloc, alloc + SgReadStatement::pool_size);
   93695             : #endif
   93696             : 
   93697             : #if ROSE_ALLOC_MEMSET == 1
   93698             : #elif ROSE_ALLOC_MEMSET == 2
   93699             :         memset(alloc, 0x00, SgReadStatement::pool_size * sizeof(SgReadStatement));
   93700             : #elif ROSE_ALLOC_MEMSET == 3
   93701             :         memset(alloc, 0xAA, SgReadStatement::pool_size * sizeof(SgReadStatement));
   93702             : #endif
   93703           0 :         for (unsigned i=0; i < SgReadStatement::pool_size-1; i++) {
   93704           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
   93705             :         }
   93706           0 :         alloc[SgReadStatement::pool_size-1].p_freepointer = nullptr;
   93707             : 
   93708           0 :         SgReadStatement::pools.push_back ( (unsigned char *) alloc );
   93709           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgReadStatement::pool_size * sizeof(SgReadStatement), V_SgReadStatement ) );
   93710           0 :         SgReadStatement::next_node = alloc;
   93711             :     }
   93712           0 :     ROSE_ASSERT(SgReadStatement::next_node != nullptr);
   93713             : 
   93714           0 :     SgReadStatement * object = SgReadStatement::next_node;
   93715           0 :     SgReadStatement::next_node = (SgReadStatement*)(object->p_freepointer);
   93716             : 
   93717             : #if ROSE_ALLOC_TRACE == 2
   93718             :     printf("SgReadStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgReadStatement::next_node);
   93719             : #endif
   93720             : 
   93721           0 :     SgNode * fp = object->p_freepointer;
   93722             : #if ROSE_ALLOC_MEMSET == 1
   93723             : #elif ROSE_ALLOC_MEMSET == 2
   93724             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgReadStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   93725             : #elif ROSE_ALLOC_MEMSET == 3
   93726             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgReadStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   93727             : #endif
   93728           0 :     object->p_freepointer = fp;
   93729             : 
   93730             : #if ROSE_ALLOC_TRACE == 2
   93731             : //    printf("SgReadStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgReadStatement::next_node);
   93732             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   93733             :     Rose::MemPool::snapshot(oss.str());
   93734             :     alloc_trace_cnt++;
   93735             : #endif
   93736             : 
   93737           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   93738             : 
   93739           0 :     ALLOC_MUTEX(SgReadStatement, unlock);
   93740             : 
   93741             :     return object;
   93742             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   93743             : }
   93744             : 
   93745             : 
   93746             : 
   93747             : /*! \brief Delete operator for SgReadStatement.
   93748             : 
   93749             :    This delete operator implements deallocation using memory pools to 
   93750             :    provide most efficent use of the heap within construction of large ASTs.
   93751             : 
   93752             : \internal The new and delete operators use the lower level C malloc/free
   93753             :    function calls for performance and to make sure that mixing of malloc/free
   93754             :    and new/delete by the used can be caught more readily.  This may change
   93755             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   93756             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   93757             :    deallocate memory allocated using ROSE_MALLOC.
   93758             : */
   93759           0 : void SgReadStatement::operator delete(void *Pointer, size_t Size)
   93760             : {
   93761             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   93762             :      * or throwing an exception. */
   93763           0 :     ALLOC_MUTEX(SgReadStatement, lock);
   93764             : 
   93765             : #if USE_CPP_NEW_DELETE_OPERATORS
   93766             :     ROSE_FREE(Pointer);
   93767             : #else
   93768             : #if ROSE_PEDANTIC_ALLOC
   93769             :     ROSE_ASSERT(Size == sizeof(SgReadStatement));
   93770             : #else
   93771           0 :     if (Size != sizeof(SgReadStatement)) {
   93772           0 :       ROSE_FREE(Pointer);
   93773           0 :       ALLOC_MUTEX(SgReadStatement, unlock);
   93774             :       return;
   93775             :     }
   93776             : #endif
   93777             : 
   93778           0 :     SgReadStatement * object = (SgReadStatement*) Pointer;
   93779           0 :     ROSE_ASSERT(object != nullptr);
   93780             : 
   93781             : #if ROSE_ALLOC_TRACE == 2
   93782             : //  printf("SgReadStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgReadStatement::next_node);
   93783             :     printf("SgReadStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgReadStatement::next_node);
   93784             : #endif
   93785             : 
   93786             : #if ROSE_PEDANTIC_ALLOC
   93787             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   93788             : #endif
   93789             : 
   93790             : #if ROSE_ALLOC_MEMSET == 1
   93791             : #elif ROSE_ALLOC_MEMSET == 2
   93792             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgReadStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   93793             : #elif ROSE_ALLOC_MEMSET == 3
   93794             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgReadStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   93795             : #endif
   93796             : 
   93797             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   93798             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   93799             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   93800             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   93801             : #else
   93802           0 :     object->p_freepointer = SgReadStatement::next_node;
   93803           0 :     SgReadStatement::next_node = object;
   93804             : #endif
   93805             : 
   93806             : #if ROSE_ALLOC_TRACE == 2
   93807             : //  printf("SgReadStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgReadStatement::next_node);
   93808             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   93809             :     Rose::MemPool::snapshot(oss.str());
   93810             :     alloc_trace_cnt++;
   93811             : #endif
   93812             : 
   93813             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   93814             : 
   93815           0 :     ALLOC_MUTEX(SgReadStatement, unlock);
   93816             : }
   93817             : 
   93818             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   93819             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   93820             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   93821             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   93822             : // Also, note comment below from Robb (copied from the Common.code file).
   93823             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   93824             : //
   93825             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   93826             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   93827             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   93828             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   93829             : #if 0
   93830             : void SgReadStatement::operator delete(void* pointer) { SgReadStatement::operator delete (pointer, sizeof(SgReadStatement)); };
   93831             : #endif
   93832             : /* #line 93833 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   93833             : 
   93834             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   93835             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   93836             : // obviously imply C++.
   93837             : 
   93838             : // This implements the support within ROSE for memory pools.  Memory pools
   93839             : // support the most condensed usage of memory within the construction of
   93840             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   93841             : // by a new operator written for each class.
   93842             : 
   93843             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   93844             :     // User wants multi-thread support and POSIX threads are available.
   93845             : #   include <pthread.h>
   93846             :     static pthread_mutex_t SgWriteStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   93847             : #else
   93848             :      // Cause synchronization to be skipped.
   93849             : #    ifndef ALLOC_MUTEX
   93850             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   93851             : #    endif
   93852             : #    ifdef _REENTRANT
   93853             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   93854             : #       ifdef _MSC_VER
   93855             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   93856             : #       else
   93857             : #           warning "POSIX threads are not available; synchronization being skipped"
   93858             : #       endif
   93859             : #    endif
   93860             : #endif
   93861             : 
   93862             : #ifndef ROSE_ALLOC_TRACE
   93863             : #  define ROSE_ALLOC_TRACE 0
   93864             : #endif
   93865             : 
   93866             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   93867             : #define ROSE_ALLOC_TRACE_CNT
   93868             : #include "memory-pool-snapshot.h"
   93869             : unsigned long alloc_trace_cnt = 0;
   93870             : #endif
   93871             : 
   93872             : #if ROSE_ALLOC_TRACE
   93873             : const unsigned SgWriteStatement::pool_size = 5;
   93874             : #else
   93875             : const unsigned SgWriteStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   93876             : #endif
   93877             : 
   93878             : #ifndef ROSE_ALLOC_MEMSET
   93879             : #  define ROSE_ALLOC_MEMSET 0
   93880             : #endif
   93881             : 
   93882             : #ifndef ROSE_PEDANTIC_ALLOC
   93883             : #  define ROSE_PEDANTIC_ALLOC 0
   93884             : #endif
   93885             : 
   93886             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   93887             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   93888             : #endif
   93889             : 
   93890             : #if !defined(SGNODE__ALL_POOLS)
   93891             : #define SGNODE__ALL_POOLS
   93892             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   93893             : #endif
   93894             : 
   93895             : SgWriteStatement* SgWriteStatement::next_node = nullptr;
   93896             : std::vector<unsigned char*> SgWriteStatement::pools;
   93897             : 
   93898             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   93899             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   93900             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   93901             : // around this macro definition rather than each use).
   93902             : #ifndef ALLOC_MUTEX
   93903             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   93904             :         do {                                                                     \
   93905             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   93906             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   93907             :                 abort();                                                         \
   93908             :             }                                                                    \
   93909             :         } while (0);
   93910             : #endif
   93911             : 
   93912             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   93913             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   93914             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   93915             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   93916             : 
   93917             : /*! \brief New operator for SgWriteStatement.
   93918             : 
   93919             :    This new operator implements memory pools to provide most efficent 
   93920             :    use of the heap within construction of large ASTs.
   93921             : 
   93922             : \internal The new and delete operators use the lower level C malloc/free
   93923             :    function calls for performance and to make sure that mixing of malloc/free
   93924             :    and new/delete by the used can be caught more readily.  This may change
   93925             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   93926             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   93927             :    deallocate memory allocated using ROSE_MALLOC.
   93928             : */
   93929           7 : void *SgWriteStatement::operator new ( size_t Size )
   93930             : {
   93931             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   93932             :      * returning or throwing an exception. */
   93933           7 :     ALLOC_MUTEX(SgWriteStatement, lock);
   93934             : 
   93935             : #if ROSE_ALLOC_TRACE == 2
   93936             : //    printf("SgWriteStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgWriteStatement::next_node);
   93937             : #endif
   93938             : 
   93939             : #if USE_CPP_NEW_DELETE_OPERATORS
   93940             :     void *mem = ROSE_MALLOC(Size);
   93941             :     ALLOC_MUTEX(SgWriteStatement, unlock);
   93942             :     return mem;
   93943             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   93944             : #if ROSE_PEDANTIC_ALLOC
   93945             :     ROSE_ASSERT(Size == sizeof(SgWriteStatement));
   93946             : #else
   93947           7 :     if (Size != sizeof(SgWriteStatement)) {
   93948           0 :       void * object = ROSE_MALLOC(Size);
   93949           0 :       ALLOC_MUTEX(SgWriteStatement, unlock);
   93950             :       return object;
   93951             :     }
   93952             : #endif
   93953             : 
   93954           7 :     if (SgWriteStatement::next_node == nullptr) {
   93955           1 :         SgWriteStatement * alloc = (SgWriteStatement*) ROSE_MALLOC ( SgWriteStatement::pool_size * sizeof(SgWriteStatement) );
   93956           1 :         ROSE_ASSERT(alloc != nullptr);
   93957             : 
   93958             : #if ROSE_ALLOC_TRACE == 2
   93959             : //        printf("SgWriteStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgWriteStatement::pools.size(), alloc, alloc + SgWriteStatement::pool_size);
   93960             : #endif
   93961             : 
   93962             : #if ROSE_ALLOC_MEMSET == 1
   93963             : #elif ROSE_ALLOC_MEMSET == 2
   93964             :         memset(alloc, 0x00, SgWriteStatement::pool_size * sizeof(SgWriteStatement));
   93965             : #elif ROSE_ALLOC_MEMSET == 3
   93966             :         memset(alloc, 0xAA, SgWriteStatement::pool_size * sizeof(SgWriteStatement));
   93967             : #endif
   93968        2000 :         for (unsigned i=0; i < SgWriteStatement::pool_size-1; i++) {
   93969        1999 :           alloc[i].p_freepointer = &(alloc[i+1]);
   93970             :         }
   93971           1 :         alloc[SgWriteStatement::pool_size-1].p_freepointer = nullptr;
   93972             : 
   93973           1 :         SgWriteStatement::pools.push_back ( (unsigned char *) alloc );
   93974           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgWriteStatement::pool_size * sizeof(SgWriteStatement), V_SgWriteStatement ) );
   93975           1 :         SgWriteStatement::next_node = alloc;
   93976             :     }
   93977           7 :     ROSE_ASSERT(SgWriteStatement::next_node != nullptr);
   93978             : 
   93979           7 :     SgWriteStatement * object = SgWriteStatement::next_node;
   93980           7 :     SgWriteStatement::next_node = (SgWriteStatement*)(object->p_freepointer);
   93981             : 
   93982             : #if ROSE_ALLOC_TRACE == 2
   93983             :     printf("SgWriteStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgWriteStatement::next_node);
   93984             : #endif
   93985             : 
   93986           7 :     SgNode * fp = object->p_freepointer;
   93987             : #if ROSE_ALLOC_MEMSET == 1
   93988             : #elif ROSE_ALLOC_MEMSET == 2
   93989             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgWriteStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   93990             : #elif ROSE_ALLOC_MEMSET == 3
   93991             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgWriteStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   93992             : #endif
   93993           7 :     object->p_freepointer = fp;
   93994             : 
   93995             : #if ROSE_ALLOC_TRACE == 2
   93996             : //    printf("SgWriteStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgWriteStatement::next_node);
   93997             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   93998             :     Rose::MemPool::snapshot(oss.str());
   93999             :     alloc_trace_cnt++;
   94000             : #endif
   94001             : 
   94002           7 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   94003             : 
   94004           7 :     ALLOC_MUTEX(SgWriteStatement, unlock);
   94005             : 
   94006             :     return object;
   94007             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   94008             : }
   94009             : 
   94010             : 
   94011             : 
   94012             : /*! \brief Delete operator for SgWriteStatement.
   94013             : 
   94014             :    This delete operator implements deallocation using memory pools to 
   94015             :    provide most efficent use of the heap within construction of large ASTs.
   94016             : 
   94017             : \internal The new and delete operators use the lower level C malloc/free
   94018             :    function calls for performance and to make sure that mixing of malloc/free
   94019             :    and new/delete by the used can be caught more readily.  This may change
   94020             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   94021             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   94022             :    deallocate memory allocated using ROSE_MALLOC.
   94023             : */
   94024           0 : void SgWriteStatement::operator delete(void *Pointer, size_t Size)
   94025             : {
   94026             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   94027             :      * or throwing an exception. */
   94028           0 :     ALLOC_MUTEX(SgWriteStatement, lock);
   94029             : 
   94030             : #if USE_CPP_NEW_DELETE_OPERATORS
   94031             :     ROSE_FREE(Pointer);
   94032             : #else
   94033             : #if ROSE_PEDANTIC_ALLOC
   94034             :     ROSE_ASSERT(Size == sizeof(SgWriteStatement));
   94035             : #else
   94036           0 :     if (Size != sizeof(SgWriteStatement)) {
   94037           0 :       ROSE_FREE(Pointer);
   94038           0 :       ALLOC_MUTEX(SgWriteStatement, unlock);
   94039             :       return;
   94040             :     }
   94041             : #endif
   94042             : 
   94043           0 :     SgWriteStatement * object = (SgWriteStatement*) Pointer;
   94044           0 :     ROSE_ASSERT(object != nullptr);
   94045             : 
   94046             : #if ROSE_ALLOC_TRACE == 2
   94047             : //  printf("SgWriteStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgWriteStatement::next_node);
   94048             :     printf("SgWriteStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgWriteStatement::next_node);
   94049             : #endif
   94050             : 
   94051             : #if ROSE_PEDANTIC_ALLOC
   94052             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   94053             : #endif
   94054             : 
   94055             : #if ROSE_ALLOC_MEMSET == 1
   94056             : #elif ROSE_ALLOC_MEMSET == 2
   94057             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgWriteStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   94058             : #elif ROSE_ALLOC_MEMSET == 3
   94059             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgWriteStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   94060             : #endif
   94061             : 
   94062             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   94063             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   94064             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   94065             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   94066             : #else
   94067           0 :     object->p_freepointer = SgWriteStatement::next_node;
   94068           0 :     SgWriteStatement::next_node = object;
   94069             : #endif
   94070             : 
   94071             : #if ROSE_ALLOC_TRACE == 2
   94072             : //  printf("SgWriteStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgWriteStatement::next_node);
   94073             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   94074             :     Rose::MemPool::snapshot(oss.str());
   94075             :     alloc_trace_cnt++;
   94076             : #endif
   94077             : 
   94078             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   94079             : 
   94080           0 :     ALLOC_MUTEX(SgWriteStatement, unlock);
   94081             : }
   94082             : 
   94083             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   94084             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   94085             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   94086             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   94087             : // Also, note comment below from Robb (copied from the Common.code file).
   94088             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   94089             : //
   94090             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   94091             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   94092             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   94093             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   94094             : #if 0
   94095             : void SgWriteStatement::operator delete(void* pointer) { SgWriteStatement::operator delete (pointer, sizeof(SgWriteStatement)); };
   94096             : #endif
   94097             : /* #line 94098 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   94098             : 
   94099             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   94100             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   94101             : // obviously imply C++.
   94102             : 
   94103             : // This implements the support within ROSE for memory pools.  Memory pools
   94104             : // support the most condensed usage of memory within the construction of
   94105             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   94106             : // by a new operator written for each class.
   94107             : 
   94108             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   94109             :     // User wants multi-thread support and POSIX threads are available.
   94110             : #   include <pthread.h>
   94111             :     static pthread_mutex_t SgOpenStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   94112             : #else
   94113             :      // Cause synchronization to be skipped.
   94114             : #    ifndef ALLOC_MUTEX
   94115             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   94116             : #    endif
   94117             : #    ifdef _REENTRANT
   94118             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   94119             : #       ifdef _MSC_VER
   94120             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   94121             : #       else
   94122             : #           warning "POSIX threads are not available; synchronization being skipped"
   94123             : #       endif
   94124             : #    endif
   94125             : #endif
   94126             : 
   94127             : #ifndef ROSE_ALLOC_TRACE
   94128             : #  define ROSE_ALLOC_TRACE 0
   94129             : #endif
   94130             : 
   94131             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   94132             : #define ROSE_ALLOC_TRACE_CNT
   94133             : #include "memory-pool-snapshot.h"
   94134             : unsigned long alloc_trace_cnt = 0;
   94135             : #endif
   94136             : 
   94137             : #if ROSE_ALLOC_TRACE
   94138             : const unsigned SgOpenStatement::pool_size = 5;
   94139             : #else
   94140             : const unsigned SgOpenStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   94141             : #endif
   94142             : 
   94143             : #ifndef ROSE_ALLOC_MEMSET
   94144             : #  define ROSE_ALLOC_MEMSET 0
   94145             : #endif
   94146             : 
   94147             : #ifndef ROSE_PEDANTIC_ALLOC
   94148             : #  define ROSE_PEDANTIC_ALLOC 0
   94149             : #endif
   94150             : 
   94151             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   94152             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   94153             : #endif
   94154             : 
   94155             : #if !defined(SGNODE__ALL_POOLS)
   94156             : #define SGNODE__ALL_POOLS
   94157             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   94158             : #endif
   94159             : 
   94160             : SgOpenStatement* SgOpenStatement::next_node = nullptr;
   94161             : std::vector<unsigned char*> SgOpenStatement::pools;
   94162             : 
   94163             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   94164             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   94165             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   94166             : // around this macro definition rather than each use).
   94167             : #ifndef ALLOC_MUTEX
   94168             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   94169             :         do {                                                                     \
   94170             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   94171             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   94172             :                 abort();                                                         \
   94173             :             }                                                                    \
   94174             :         } while (0);
   94175             : #endif
   94176             : 
   94177             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   94178             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   94179             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   94180             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   94181             : 
   94182             : /*! \brief New operator for SgOpenStatement.
   94183             : 
   94184             :    This new operator implements memory pools to provide most efficent 
   94185             :    use of the heap within construction of large ASTs.
   94186             : 
   94187             : \internal The new and delete operators use the lower level C malloc/free
   94188             :    function calls for performance and to make sure that mixing of malloc/free
   94189             :    and new/delete by the used can be caught more readily.  This may change
   94190             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   94191             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   94192             :    deallocate memory allocated using ROSE_MALLOC.
   94193             : */
   94194           0 : void *SgOpenStatement::operator new ( size_t Size )
   94195             : {
   94196             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   94197             :      * returning or throwing an exception. */
   94198           0 :     ALLOC_MUTEX(SgOpenStatement, lock);
   94199             : 
   94200             : #if ROSE_ALLOC_TRACE == 2
   94201             : //    printf("SgOpenStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgOpenStatement::next_node);
   94202             : #endif
   94203             : 
   94204             : #if USE_CPP_NEW_DELETE_OPERATORS
   94205             :     void *mem = ROSE_MALLOC(Size);
   94206             :     ALLOC_MUTEX(SgOpenStatement, unlock);
   94207             :     return mem;
   94208             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   94209             : #if ROSE_PEDANTIC_ALLOC
   94210             :     ROSE_ASSERT(Size == sizeof(SgOpenStatement));
   94211             : #else
   94212           0 :     if (Size != sizeof(SgOpenStatement)) {
   94213           0 :       void * object = ROSE_MALLOC(Size);
   94214           0 :       ALLOC_MUTEX(SgOpenStatement, unlock);
   94215             :       return object;
   94216             :     }
   94217             : #endif
   94218             : 
   94219           0 :     if (SgOpenStatement::next_node == nullptr) {
   94220           0 :         SgOpenStatement * alloc = (SgOpenStatement*) ROSE_MALLOC ( SgOpenStatement::pool_size * sizeof(SgOpenStatement) );
   94221           0 :         ROSE_ASSERT(alloc != nullptr);
   94222             : 
   94223             : #if ROSE_ALLOC_TRACE == 2
   94224             : //        printf("SgOpenStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgOpenStatement::pools.size(), alloc, alloc + SgOpenStatement::pool_size);
   94225             : #endif
   94226             : 
   94227             : #if ROSE_ALLOC_MEMSET == 1
   94228             : #elif ROSE_ALLOC_MEMSET == 2
   94229             :         memset(alloc, 0x00, SgOpenStatement::pool_size * sizeof(SgOpenStatement));
   94230             : #elif ROSE_ALLOC_MEMSET == 3
   94231             :         memset(alloc, 0xAA, SgOpenStatement::pool_size * sizeof(SgOpenStatement));
   94232             : #endif
   94233           0 :         for (unsigned i=0; i < SgOpenStatement::pool_size-1; i++) {
   94234           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
   94235             :         }
   94236           0 :         alloc[SgOpenStatement::pool_size-1].p_freepointer = nullptr;
   94237             : 
   94238           0 :         SgOpenStatement::pools.push_back ( (unsigned char *) alloc );
   94239           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgOpenStatement::pool_size * sizeof(SgOpenStatement), V_SgOpenStatement ) );
   94240           0 :         SgOpenStatement::next_node = alloc;
   94241             :     }
   94242           0 :     ROSE_ASSERT(SgOpenStatement::next_node != nullptr);
   94243             : 
   94244           0 :     SgOpenStatement * object = SgOpenStatement::next_node;
   94245           0 :     SgOpenStatement::next_node = (SgOpenStatement*)(object->p_freepointer);
   94246             : 
   94247             : #if ROSE_ALLOC_TRACE == 2
   94248             :     printf("SgOpenStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOpenStatement::next_node);
   94249             : #endif
   94250             : 
   94251           0 :     SgNode * fp = object->p_freepointer;
   94252             : #if ROSE_ALLOC_MEMSET == 1
   94253             : #elif ROSE_ALLOC_MEMSET == 2
   94254             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOpenStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   94255             : #elif ROSE_ALLOC_MEMSET == 3
   94256             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgOpenStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   94257             : #endif
   94258           0 :     object->p_freepointer = fp;
   94259             : 
   94260             : #if ROSE_ALLOC_TRACE == 2
   94261             : //    printf("SgOpenStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOpenStatement::next_node);
   94262             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   94263             :     Rose::MemPool::snapshot(oss.str());
   94264             :     alloc_trace_cnt++;
   94265             : #endif
   94266             : 
   94267           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   94268             : 
   94269           0 :     ALLOC_MUTEX(SgOpenStatement, unlock);
   94270             : 
   94271             :     return object;
   94272             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   94273             : }
   94274             : 
   94275             : 
   94276             : 
   94277             : /*! \brief Delete operator for SgOpenStatement.
   94278             : 
   94279             :    This delete operator implements deallocation using memory pools to 
   94280             :    provide most efficent use of the heap within construction of large ASTs.
   94281             : 
   94282             : \internal The new and delete operators use the lower level C malloc/free
   94283             :    function calls for performance and to make sure that mixing of malloc/free
   94284             :    and new/delete by the used can be caught more readily.  This may change
   94285             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   94286             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   94287             :    deallocate memory allocated using ROSE_MALLOC.
   94288             : */
   94289           0 : void SgOpenStatement::operator delete(void *Pointer, size_t Size)
   94290             : {
   94291             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   94292             :      * or throwing an exception. */
   94293           0 :     ALLOC_MUTEX(SgOpenStatement, lock);
   94294             : 
   94295             : #if USE_CPP_NEW_DELETE_OPERATORS
   94296             :     ROSE_FREE(Pointer);
   94297             : #else
   94298             : #if ROSE_PEDANTIC_ALLOC
   94299             :     ROSE_ASSERT(Size == sizeof(SgOpenStatement));
   94300             : #else
   94301           0 :     if (Size != sizeof(SgOpenStatement)) {
   94302           0 :       ROSE_FREE(Pointer);
   94303           0 :       ALLOC_MUTEX(SgOpenStatement, unlock);
   94304             :       return;
   94305             :     }
   94306             : #endif
   94307             : 
   94308           0 :     SgOpenStatement * object = (SgOpenStatement*) Pointer;
   94309           0 :     ROSE_ASSERT(object != nullptr);
   94310             : 
   94311             : #if ROSE_ALLOC_TRACE == 2
   94312             : //  printf("SgOpenStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOpenStatement::next_node);
   94313             :     printf("SgOpenStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOpenStatement::next_node);
   94314             : #endif
   94315             : 
   94316             : #if ROSE_PEDANTIC_ALLOC
   94317             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   94318             : #endif
   94319             : 
   94320             : #if ROSE_ALLOC_MEMSET == 1
   94321             : #elif ROSE_ALLOC_MEMSET == 2
   94322             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOpenStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   94323             : #elif ROSE_ALLOC_MEMSET == 3
   94324             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgOpenStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   94325             : #endif
   94326             : 
   94327             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   94328             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   94329             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   94330             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   94331             : #else
   94332           0 :     object->p_freepointer = SgOpenStatement::next_node;
   94333           0 :     SgOpenStatement::next_node = object;
   94334             : #endif
   94335             : 
   94336             : #if ROSE_ALLOC_TRACE == 2
   94337             : //  printf("SgOpenStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOpenStatement::next_node);
   94338             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   94339             :     Rose::MemPool::snapshot(oss.str());
   94340             :     alloc_trace_cnt++;
   94341             : #endif
   94342             : 
   94343             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   94344             : 
   94345           0 :     ALLOC_MUTEX(SgOpenStatement, unlock);
   94346             : }
   94347             : 
   94348             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   94349             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   94350             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   94351             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   94352             : // Also, note comment below from Robb (copied from the Common.code file).
   94353             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   94354             : //
   94355             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   94356             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   94357             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   94358             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   94359             : #if 0
   94360             : void SgOpenStatement::operator delete(void* pointer) { SgOpenStatement::operator delete (pointer, sizeof(SgOpenStatement)); };
   94361             : #endif
   94362             : /* #line 94363 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   94363             : 
   94364             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   94365             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   94366             : // obviously imply C++.
   94367             : 
   94368             : // This implements the support within ROSE for memory pools.  Memory pools
   94369             : // support the most condensed usage of memory within the construction of
   94370             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   94371             : // by a new operator written for each class.
   94372             : 
   94373             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   94374             :     // User wants multi-thread support and POSIX threads are available.
   94375             : #   include <pthread.h>
   94376             :     static pthread_mutex_t SgCloseStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   94377             : #else
   94378             :      // Cause synchronization to be skipped.
   94379             : #    ifndef ALLOC_MUTEX
   94380             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   94381             : #    endif
   94382             : #    ifdef _REENTRANT
   94383             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   94384             : #       ifdef _MSC_VER
   94385             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   94386             : #       else
   94387             : #           warning "POSIX threads are not available; synchronization being skipped"
   94388             : #       endif
   94389             : #    endif
   94390             : #endif
   94391             : 
   94392             : #ifndef ROSE_ALLOC_TRACE
   94393             : #  define ROSE_ALLOC_TRACE 0
   94394             : #endif
   94395             : 
   94396             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   94397             : #define ROSE_ALLOC_TRACE_CNT
   94398             : #include "memory-pool-snapshot.h"
   94399             : unsigned long alloc_trace_cnt = 0;
   94400             : #endif
   94401             : 
   94402             : #if ROSE_ALLOC_TRACE
   94403             : const unsigned SgCloseStatement::pool_size = 5;
   94404             : #else
   94405             : const unsigned SgCloseStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   94406             : #endif
   94407             : 
   94408             : #ifndef ROSE_ALLOC_MEMSET
   94409             : #  define ROSE_ALLOC_MEMSET 0
   94410             : #endif
   94411             : 
   94412             : #ifndef ROSE_PEDANTIC_ALLOC
   94413             : #  define ROSE_PEDANTIC_ALLOC 0
   94414             : #endif
   94415             : 
   94416             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   94417             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   94418             : #endif
   94419             : 
   94420             : #if !defined(SGNODE__ALL_POOLS)
   94421             : #define SGNODE__ALL_POOLS
   94422             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   94423             : #endif
   94424             : 
   94425             : SgCloseStatement* SgCloseStatement::next_node = nullptr;
   94426             : std::vector<unsigned char*> SgCloseStatement::pools;
   94427             : 
   94428             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   94429             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   94430             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   94431             : // around this macro definition rather than each use).
   94432             : #ifndef ALLOC_MUTEX
   94433             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   94434             :         do {                                                                     \
   94435             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   94436             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   94437             :                 abort();                                                         \
   94438             :             }                                                                    \
   94439             :         } while (0);
   94440             : #endif
   94441             : 
   94442             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   94443             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   94444             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   94445             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   94446             : 
   94447             : /*! \brief New operator for SgCloseStatement.
   94448             : 
   94449             :    This new operator implements memory pools to provide most efficent 
   94450             :    use of the heap within construction of large ASTs.
   94451             : 
   94452             : \internal The new and delete operators use the lower level C malloc/free
   94453             :    function calls for performance and to make sure that mixing of malloc/free
   94454             :    and new/delete by the used can be caught more readily.  This may change
   94455             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   94456             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   94457             :    deallocate memory allocated using ROSE_MALLOC.
   94458             : */
   94459           0 : void *SgCloseStatement::operator new ( size_t Size )
   94460             : {
   94461             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   94462             :      * returning or throwing an exception. */
   94463           0 :     ALLOC_MUTEX(SgCloseStatement, lock);
   94464             : 
   94465             : #if ROSE_ALLOC_TRACE == 2
   94466             : //    printf("SgCloseStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgCloseStatement::next_node);
   94467             : #endif
   94468             : 
   94469             : #if USE_CPP_NEW_DELETE_OPERATORS
   94470             :     void *mem = ROSE_MALLOC(Size);
   94471             :     ALLOC_MUTEX(SgCloseStatement, unlock);
   94472             :     return mem;
   94473             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   94474             : #if ROSE_PEDANTIC_ALLOC
   94475             :     ROSE_ASSERT(Size == sizeof(SgCloseStatement));
   94476             : #else
   94477           0 :     if (Size != sizeof(SgCloseStatement)) {
   94478           0 :       void * object = ROSE_MALLOC(Size);
   94479           0 :       ALLOC_MUTEX(SgCloseStatement, unlock);
   94480             :       return object;
   94481             :     }
   94482             : #endif
   94483             : 
   94484           0 :     if (SgCloseStatement::next_node == nullptr) {
   94485           0 :         SgCloseStatement * alloc = (SgCloseStatement*) ROSE_MALLOC ( SgCloseStatement::pool_size * sizeof(SgCloseStatement) );
   94486           0 :         ROSE_ASSERT(alloc != nullptr);
   94487             : 
   94488             : #if ROSE_ALLOC_TRACE == 2
   94489             : //        printf("SgCloseStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgCloseStatement::pools.size(), alloc, alloc + SgCloseStatement::pool_size);
   94490             : #endif
   94491             : 
   94492             : #if ROSE_ALLOC_MEMSET == 1
   94493             : #elif ROSE_ALLOC_MEMSET == 2
   94494             :         memset(alloc, 0x00, SgCloseStatement::pool_size * sizeof(SgCloseStatement));
   94495             : #elif ROSE_ALLOC_MEMSET == 3
   94496             :         memset(alloc, 0xAA, SgCloseStatement::pool_size * sizeof(SgCloseStatement));
   94497             : #endif
   94498           0 :         for (unsigned i=0; i < SgCloseStatement::pool_size-1; i++) {
   94499           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
   94500             :         }
   94501           0 :         alloc[SgCloseStatement::pool_size-1].p_freepointer = nullptr;
   94502             : 
   94503           0 :         SgCloseStatement::pools.push_back ( (unsigned char *) alloc );
   94504           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgCloseStatement::pool_size * sizeof(SgCloseStatement), V_SgCloseStatement ) );
   94505           0 :         SgCloseStatement::next_node = alloc;
   94506             :     }
   94507           0 :     ROSE_ASSERT(SgCloseStatement::next_node != nullptr);
   94508             : 
   94509           0 :     SgCloseStatement * object = SgCloseStatement::next_node;
   94510           0 :     SgCloseStatement::next_node = (SgCloseStatement*)(object->p_freepointer);
   94511             : 
   94512             : #if ROSE_ALLOC_TRACE == 2
   94513             :     printf("SgCloseStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgCloseStatement::next_node);
   94514             : #endif
   94515             : 
   94516           0 :     SgNode * fp = object->p_freepointer;
   94517             : #if ROSE_ALLOC_MEMSET == 1
   94518             : #elif ROSE_ALLOC_MEMSET == 2
   94519             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgCloseStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   94520             : #elif ROSE_ALLOC_MEMSET == 3
   94521             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgCloseStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   94522             : #endif
   94523           0 :     object->p_freepointer = fp;
   94524             : 
   94525             : #if ROSE_ALLOC_TRACE == 2
   94526             : //    printf("SgCloseStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgCloseStatement::next_node);
   94527             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   94528             :     Rose::MemPool::snapshot(oss.str());
   94529             :     alloc_trace_cnt++;
   94530             : #endif
   94531             : 
   94532           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   94533             : 
   94534           0 :     ALLOC_MUTEX(SgCloseStatement, unlock);
   94535             : 
   94536             :     return object;
   94537             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   94538             : }
   94539             : 
   94540             : 
   94541             : 
   94542             : /*! \brief Delete operator for SgCloseStatement.
   94543             : 
   94544             :    This delete operator implements deallocation using memory pools to 
   94545             :    provide most efficent use of the heap within construction of large ASTs.
   94546             : 
   94547             : \internal The new and delete operators use the lower level C malloc/free
   94548             :    function calls for performance and to make sure that mixing of malloc/free
   94549             :    and new/delete by the used can be caught more readily.  This may change
   94550             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   94551             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   94552             :    deallocate memory allocated using ROSE_MALLOC.
   94553             : */
   94554           0 : void SgCloseStatement::operator delete(void *Pointer, size_t Size)
   94555             : {
   94556             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   94557             :      * or throwing an exception. */
   94558           0 :     ALLOC_MUTEX(SgCloseStatement, lock);
   94559             : 
   94560             : #if USE_CPP_NEW_DELETE_OPERATORS
   94561             :     ROSE_FREE(Pointer);
   94562             : #else
   94563             : #if ROSE_PEDANTIC_ALLOC
   94564             :     ROSE_ASSERT(Size == sizeof(SgCloseStatement));
   94565             : #else
   94566           0 :     if (Size != sizeof(SgCloseStatement)) {
   94567           0 :       ROSE_FREE(Pointer);
   94568           0 :       ALLOC_MUTEX(SgCloseStatement, unlock);
   94569             :       return;
   94570             :     }
   94571             : #endif
   94572             : 
   94573           0 :     SgCloseStatement * object = (SgCloseStatement*) Pointer;
   94574           0 :     ROSE_ASSERT(object != nullptr);
   94575             : 
   94576             : #if ROSE_ALLOC_TRACE == 2
   94577             : //  printf("SgCloseStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgCloseStatement::next_node);
   94578             :     printf("SgCloseStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgCloseStatement::next_node);
   94579             : #endif
   94580             : 
   94581             : #if ROSE_PEDANTIC_ALLOC
   94582             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   94583             : #endif
   94584             : 
   94585             : #if ROSE_ALLOC_MEMSET == 1
   94586             : #elif ROSE_ALLOC_MEMSET == 2
   94587             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgCloseStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   94588             : #elif ROSE_ALLOC_MEMSET == 3
   94589             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgCloseStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   94590             : #endif
   94591             : 
   94592             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   94593             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   94594             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   94595             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   94596             : #else
   94597           0 :     object->p_freepointer = SgCloseStatement::next_node;
   94598           0 :     SgCloseStatement::next_node = object;
   94599             : #endif
   94600             : 
   94601             : #if ROSE_ALLOC_TRACE == 2
   94602             : //  printf("SgCloseStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgCloseStatement::next_node);
   94603             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   94604             :     Rose::MemPool::snapshot(oss.str());
   94605             :     alloc_trace_cnt++;
   94606             : #endif
   94607             : 
   94608             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   94609             : 
   94610           0 :     ALLOC_MUTEX(SgCloseStatement, unlock);
   94611             : }
   94612             : 
   94613             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   94614             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   94615             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   94616             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   94617             : // Also, note comment below from Robb (copied from the Common.code file).
   94618             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   94619             : //
   94620             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   94621             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   94622             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   94623             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   94624             : #if 0
   94625             : void SgCloseStatement::operator delete(void* pointer) { SgCloseStatement::operator delete (pointer, sizeof(SgCloseStatement)); };
   94626             : #endif
   94627             : /* #line 94628 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   94628             : 
   94629             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   94630             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   94631             : // obviously imply C++.
   94632             : 
   94633             : // This implements the support within ROSE for memory pools.  Memory pools
   94634             : // support the most condensed usage of memory within the construction of
   94635             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   94636             : // by a new operator written for each class.
   94637             : 
   94638             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   94639             :     // User wants multi-thread support and POSIX threads are available.
   94640             : #   include <pthread.h>
   94641             :     static pthread_mutex_t SgInquireStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   94642             : #else
   94643             :      // Cause synchronization to be skipped.
   94644             : #    ifndef ALLOC_MUTEX
   94645             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   94646             : #    endif
   94647             : #    ifdef _REENTRANT
   94648             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   94649             : #       ifdef _MSC_VER
   94650             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   94651             : #       else
   94652             : #           warning "POSIX threads are not available; synchronization being skipped"
   94653             : #       endif
   94654             : #    endif
   94655             : #endif
   94656             : 
   94657             : #ifndef ROSE_ALLOC_TRACE
   94658             : #  define ROSE_ALLOC_TRACE 0
   94659             : #endif
   94660             : 
   94661             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   94662             : #define ROSE_ALLOC_TRACE_CNT
   94663             : #include "memory-pool-snapshot.h"
   94664             : unsigned long alloc_trace_cnt = 0;
   94665             : #endif
   94666             : 
   94667             : #if ROSE_ALLOC_TRACE
   94668             : const unsigned SgInquireStatement::pool_size = 5;
   94669             : #else
   94670             : const unsigned SgInquireStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   94671             : #endif
   94672             : 
   94673             : #ifndef ROSE_ALLOC_MEMSET
   94674             : #  define ROSE_ALLOC_MEMSET 0
   94675             : #endif
   94676             : 
   94677             : #ifndef ROSE_PEDANTIC_ALLOC
   94678             : #  define ROSE_PEDANTIC_ALLOC 0
   94679             : #endif
   94680             : 
   94681             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   94682             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   94683             : #endif
   94684             : 
   94685             : #if !defined(SGNODE__ALL_POOLS)
   94686             : #define SGNODE__ALL_POOLS
   94687             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   94688             : #endif
   94689             : 
   94690             : SgInquireStatement* SgInquireStatement::next_node = nullptr;
   94691             : std::vector<unsigned char*> SgInquireStatement::pools;
   94692             : 
   94693             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   94694             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   94695             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   94696             : // around this macro definition rather than each use).
   94697             : #ifndef ALLOC_MUTEX
   94698             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   94699             :         do {                                                                     \
   94700             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   94701             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   94702             :                 abort();                                                         \
   94703             :             }                                                                    \
   94704             :         } while (0);
   94705             : #endif
   94706             : 
   94707             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   94708             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   94709             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   94710             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   94711             : 
   94712             : /*! \brief New operator for SgInquireStatement.
   94713             : 
   94714             :    This new operator implements memory pools to provide most efficent 
   94715             :    use of the heap within construction of large ASTs.
   94716             : 
   94717             : \internal The new and delete operators use the lower level C malloc/free
   94718             :    function calls for performance and to make sure that mixing of malloc/free
   94719             :    and new/delete by the used can be caught more readily.  This may change
   94720             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   94721             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   94722             :    deallocate memory allocated using ROSE_MALLOC.
   94723             : */
   94724           0 : void *SgInquireStatement::operator new ( size_t Size )
   94725             : {
   94726             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   94727             :      * returning or throwing an exception. */
   94728           0 :     ALLOC_MUTEX(SgInquireStatement, lock);
   94729             : 
   94730             : #if ROSE_ALLOC_TRACE == 2
   94731             : //    printf("SgInquireStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgInquireStatement::next_node);
   94732             : #endif
   94733             : 
   94734             : #if USE_CPP_NEW_DELETE_OPERATORS
   94735             :     void *mem = ROSE_MALLOC(Size);
   94736             :     ALLOC_MUTEX(SgInquireStatement, unlock);
   94737             :     return mem;
   94738             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   94739             : #if ROSE_PEDANTIC_ALLOC
   94740             :     ROSE_ASSERT(Size == sizeof(SgInquireStatement));
   94741             : #else
   94742           0 :     if (Size != sizeof(SgInquireStatement)) {
   94743           0 :       void * object = ROSE_MALLOC(Size);
   94744           0 :       ALLOC_MUTEX(SgInquireStatement, unlock);
   94745             :       return object;
   94746             :     }
   94747             : #endif
   94748             : 
   94749           0 :     if (SgInquireStatement::next_node == nullptr) {
   94750           0 :         SgInquireStatement * alloc = (SgInquireStatement*) ROSE_MALLOC ( SgInquireStatement::pool_size * sizeof(SgInquireStatement) );
   94751           0 :         ROSE_ASSERT(alloc != nullptr);
   94752             : 
   94753             : #if ROSE_ALLOC_TRACE == 2
   94754             : //        printf("SgInquireStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgInquireStatement::pools.size(), alloc, alloc + SgInquireStatement::pool_size);
   94755             : #endif
   94756             : 
   94757             : #if ROSE_ALLOC_MEMSET == 1
   94758             : #elif ROSE_ALLOC_MEMSET == 2
   94759             :         memset(alloc, 0x00, SgInquireStatement::pool_size * sizeof(SgInquireStatement));
   94760             : #elif ROSE_ALLOC_MEMSET == 3
   94761             :         memset(alloc, 0xAA, SgInquireStatement::pool_size * sizeof(SgInquireStatement));
   94762             : #endif
   94763           0 :         for (unsigned i=0; i < SgInquireStatement::pool_size-1; i++) {
   94764           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
   94765             :         }
   94766           0 :         alloc[SgInquireStatement::pool_size-1].p_freepointer = nullptr;
   94767             : 
   94768           0 :         SgInquireStatement::pools.push_back ( (unsigned char *) alloc );
   94769           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgInquireStatement::pool_size * sizeof(SgInquireStatement), V_SgInquireStatement ) );
   94770           0 :         SgInquireStatement::next_node = alloc;
   94771             :     }
   94772           0 :     ROSE_ASSERT(SgInquireStatement::next_node != nullptr);
   94773             : 
   94774           0 :     SgInquireStatement * object = SgInquireStatement::next_node;
   94775           0 :     SgInquireStatement::next_node = (SgInquireStatement*)(object->p_freepointer);
   94776             : 
   94777             : #if ROSE_ALLOC_TRACE == 2
   94778             :     printf("SgInquireStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgInquireStatement::next_node);
   94779             : #endif
   94780             : 
   94781           0 :     SgNode * fp = object->p_freepointer;
   94782             : #if ROSE_ALLOC_MEMSET == 1
   94783             : #elif ROSE_ALLOC_MEMSET == 2
   94784             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgInquireStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   94785             : #elif ROSE_ALLOC_MEMSET == 3
   94786             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgInquireStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   94787             : #endif
   94788           0 :     object->p_freepointer = fp;
   94789             : 
   94790             : #if ROSE_ALLOC_TRACE == 2
   94791             : //    printf("SgInquireStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgInquireStatement::next_node);
   94792             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   94793             :     Rose::MemPool::snapshot(oss.str());
   94794             :     alloc_trace_cnt++;
   94795             : #endif
   94796             : 
   94797           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   94798             : 
   94799           0 :     ALLOC_MUTEX(SgInquireStatement, unlock);
   94800             : 
   94801             :     return object;
   94802             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   94803             : }
   94804             : 
   94805             : 
   94806             : 
   94807             : /*! \brief Delete operator for SgInquireStatement.
   94808             : 
   94809             :    This delete operator implements deallocation using memory pools to 
   94810             :    provide most efficent use of the heap within construction of large ASTs.
   94811             : 
   94812             : \internal The new and delete operators use the lower level C malloc/free
   94813             :    function calls for performance and to make sure that mixing of malloc/free
   94814             :    and new/delete by the used can be caught more readily.  This may change
   94815             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   94816             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   94817             :    deallocate memory allocated using ROSE_MALLOC.
   94818             : */
   94819           0 : void SgInquireStatement::operator delete(void *Pointer, size_t Size)
   94820             : {
   94821             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   94822             :      * or throwing an exception. */
   94823           0 :     ALLOC_MUTEX(SgInquireStatement, lock);
   94824             : 
   94825             : #if USE_CPP_NEW_DELETE_OPERATORS
   94826             :     ROSE_FREE(Pointer);
   94827             : #else
   94828             : #if ROSE_PEDANTIC_ALLOC
   94829             :     ROSE_ASSERT(Size == sizeof(SgInquireStatement));
   94830             : #else
   94831           0 :     if (Size != sizeof(SgInquireStatement)) {
   94832           0 :       ROSE_FREE(Pointer);
   94833           0 :       ALLOC_MUTEX(SgInquireStatement, unlock);
   94834             :       return;
   94835             :     }
   94836             : #endif
   94837             : 
   94838           0 :     SgInquireStatement * object = (SgInquireStatement*) Pointer;
   94839           0 :     ROSE_ASSERT(object != nullptr);
   94840             : 
   94841             : #if ROSE_ALLOC_TRACE == 2
   94842             : //  printf("SgInquireStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgInquireStatement::next_node);
   94843             :     printf("SgInquireStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgInquireStatement::next_node);
   94844             : #endif
   94845             : 
   94846             : #if ROSE_PEDANTIC_ALLOC
   94847             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   94848             : #endif
   94849             : 
   94850             : #if ROSE_ALLOC_MEMSET == 1
   94851             : #elif ROSE_ALLOC_MEMSET == 2
   94852             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgInquireStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   94853             : #elif ROSE_ALLOC_MEMSET == 3
   94854             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgInquireStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   94855             : #endif
   94856             : 
   94857             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   94858             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   94859             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   94860             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   94861             : #else
   94862           0 :     object->p_freepointer = SgInquireStatement::next_node;
   94863           0 :     SgInquireStatement::next_node = object;
   94864             : #endif
   94865             : 
   94866             : #if ROSE_ALLOC_TRACE == 2
   94867             : //  printf("SgInquireStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgInquireStatement::next_node);
   94868             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   94869             :     Rose::MemPool::snapshot(oss.str());
   94870             :     alloc_trace_cnt++;
   94871             : #endif
   94872             : 
   94873             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   94874             : 
   94875           0 :     ALLOC_MUTEX(SgInquireStatement, unlock);
   94876             : }
   94877             : 
   94878             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   94879             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   94880             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   94881             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   94882             : // Also, note comment below from Robb (copied from the Common.code file).
   94883             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   94884             : //
   94885             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   94886             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   94887             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   94888             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   94889             : #if 0
   94890             : void SgInquireStatement::operator delete(void* pointer) { SgInquireStatement::operator delete (pointer, sizeof(SgInquireStatement)); };
   94891             : #endif
   94892             : /* #line 94893 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   94893             : 
   94894             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   94895             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   94896             : // obviously imply C++.
   94897             : 
   94898             : // This implements the support within ROSE for memory pools.  Memory pools
   94899             : // support the most condensed usage of memory within the construction of
   94900             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   94901             : // by a new operator written for each class.
   94902             : 
   94903             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   94904             :     // User wants multi-thread support and POSIX threads are available.
   94905             : #   include <pthread.h>
   94906             :     static pthread_mutex_t SgFlushStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   94907             : #else
   94908             :      // Cause synchronization to be skipped.
   94909             : #    ifndef ALLOC_MUTEX
   94910             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   94911             : #    endif
   94912             : #    ifdef _REENTRANT
   94913             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   94914             : #       ifdef _MSC_VER
   94915             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   94916             : #       else
   94917             : #           warning "POSIX threads are not available; synchronization being skipped"
   94918             : #       endif
   94919             : #    endif
   94920             : #endif
   94921             : 
   94922             : #ifndef ROSE_ALLOC_TRACE
   94923             : #  define ROSE_ALLOC_TRACE 0
   94924             : #endif
   94925             : 
   94926             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   94927             : #define ROSE_ALLOC_TRACE_CNT
   94928             : #include "memory-pool-snapshot.h"
   94929             : unsigned long alloc_trace_cnt = 0;
   94930             : #endif
   94931             : 
   94932             : #if ROSE_ALLOC_TRACE
   94933             : const unsigned SgFlushStatement::pool_size = 5;
   94934             : #else
   94935             : const unsigned SgFlushStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   94936             : #endif
   94937             : 
   94938             : #ifndef ROSE_ALLOC_MEMSET
   94939             : #  define ROSE_ALLOC_MEMSET 0
   94940             : #endif
   94941             : 
   94942             : #ifndef ROSE_PEDANTIC_ALLOC
   94943             : #  define ROSE_PEDANTIC_ALLOC 0
   94944             : #endif
   94945             : 
   94946             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   94947             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   94948             : #endif
   94949             : 
   94950             : #if !defined(SGNODE__ALL_POOLS)
   94951             : #define SGNODE__ALL_POOLS
   94952             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   94953             : #endif
   94954             : 
   94955             : SgFlushStatement* SgFlushStatement::next_node = nullptr;
   94956             : std::vector<unsigned char*> SgFlushStatement::pools;
   94957             : 
   94958             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   94959             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   94960             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   94961             : // around this macro definition rather than each use).
   94962             : #ifndef ALLOC_MUTEX
   94963             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   94964             :         do {                                                                     \
   94965             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   94966             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   94967             :                 abort();                                                         \
   94968             :             }                                                                    \
   94969             :         } while (0);
   94970             : #endif
   94971             : 
   94972             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   94973             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   94974             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   94975             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   94976             : 
   94977             : /*! \brief New operator for SgFlushStatement.
   94978             : 
   94979             :    This new operator implements memory pools to provide most efficent 
   94980             :    use of the heap within construction of large ASTs.
   94981             : 
   94982             : \internal The new and delete operators use the lower level C malloc/free
   94983             :    function calls for performance and to make sure that mixing of malloc/free
   94984             :    and new/delete by the used can be caught more readily.  This may change
   94985             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   94986             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   94987             :    deallocate memory allocated using ROSE_MALLOC.
   94988             : */
   94989           0 : void *SgFlushStatement::operator new ( size_t Size )
   94990             : {
   94991             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   94992             :      * returning or throwing an exception. */
   94993           0 :     ALLOC_MUTEX(SgFlushStatement, lock);
   94994             : 
   94995             : #if ROSE_ALLOC_TRACE == 2
   94996             : //    printf("SgFlushStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgFlushStatement::next_node);
   94997             : #endif
   94998             : 
   94999             : #if USE_CPP_NEW_DELETE_OPERATORS
   95000             :     void *mem = ROSE_MALLOC(Size);
   95001             :     ALLOC_MUTEX(SgFlushStatement, unlock);
   95002             :     return mem;
   95003             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   95004             : #if ROSE_PEDANTIC_ALLOC
   95005             :     ROSE_ASSERT(Size == sizeof(SgFlushStatement));
   95006             : #else
   95007           0 :     if (Size != sizeof(SgFlushStatement)) {
   95008           0 :       void * object = ROSE_MALLOC(Size);
   95009           0 :       ALLOC_MUTEX(SgFlushStatement, unlock);
   95010             :       return object;
   95011             :     }
   95012             : #endif
   95013             : 
   95014           0 :     if (SgFlushStatement::next_node == nullptr) {
   95015           0 :         SgFlushStatement * alloc = (SgFlushStatement*) ROSE_MALLOC ( SgFlushStatement::pool_size * sizeof(SgFlushStatement) );
   95016           0 :         ROSE_ASSERT(alloc != nullptr);
   95017             : 
   95018             : #if ROSE_ALLOC_TRACE == 2
   95019             : //        printf("SgFlushStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgFlushStatement::pools.size(), alloc, alloc + SgFlushStatement::pool_size);
   95020             : #endif
   95021             : 
   95022             : #if ROSE_ALLOC_MEMSET == 1
   95023             : #elif ROSE_ALLOC_MEMSET == 2
   95024             :         memset(alloc, 0x00, SgFlushStatement::pool_size * sizeof(SgFlushStatement));
   95025             : #elif ROSE_ALLOC_MEMSET == 3
   95026             :         memset(alloc, 0xAA, SgFlushStatement::pool_size * sizeof(SgFlushStatement));
   95027             : #endif
   95028           0 :         for (unsigned i=0; i < SgFlushStatement::pool_size-1; i++) {
   95029           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
   95030             :         }
   95031           0 :         alloc[SgFlushStatement::pool_size-1].p_freepointer = nullptr;
   95032             : 
   95033           0 :         SgFlushStatement::pools.push_back ( (unsigned char *) alloc );
   95034           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgFlushStatement::pool_size * sizeof(SgFlushStatement), V_SgFlushStatement ) );
   95035           0 :         SgFlushStatement::next_node = alloc;
   95036             :     }
   95037           0 :     ROSE_ASSERT(SgFlushStatement::next_node != nullptr);
   95038             : 
   95039           0 :     SgFlushStatement * object = SgFlushStatement::next_node;
   95040           0 :     SgFlushStatement::next_node = (SgFlushStatement*)(object->p_freepointer);
   95041             : 
   95042             : #if ROSE_ALLOC_TRACE == 2
   95043             :     printf("SgFlushStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgFlushStatement::next_node);
   95044             : #endif
   95045             : 
   95046           0 :     SgNode * fp = object->p_freepointer;
   95047             : #if ROSE_ALLOC_MEMSET == 1
   95048             : #elif ROSE_ALLOC_MEMSET == 2
   95049             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgFlushStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   95050             : #elif ROSE_ALLOC_MEMSET == 3
   95051             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgFlushStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   95052             : #endif
   95053           0 :     object->p_freepointer = fp;
   95054             : 
   95055             : #if ROSE_ALLOC_TRACE == 2
   95056             : //    printf("SgFlushStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgFlushStatement::next_node);
   95057             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   95058             :     Rose::MemPool::snapshot(oss.str());
   95059             :     alloc_trace_cnt++;
   95060             : #endif
   95061             : 
   95062           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   95063             : 
   95064           0 :     ALLOC_MUTEX(SgFlushStatement, unlock);
   95065             : 
   95066             :     return object;
   95067             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   95068             : }
   95069             : 
   95070             : 
   95071             : 
   95072             : /*! \brief Delete operator for SgFlushStatement.
   95073             : 
   95074             :    This delete operator implements deallocation using memory pools to 
   95075             :    provide most efficent use of the heap within construction of large ASTs.
   95076             : 
   95077             : \internal The new and delete operators use the lower level C malloc/free
   95078             :    function calls for performance and to make sure that mixing of malloc/free
   95079             :    and new/delete by the used can be caught more readily.  This may change
   95080             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   95081             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   95082             :    deallocate memory allocated using ROSE_MALLOC.
   95083             : */
   95084           0 : void SgFlushStatement::operator delete(void *Pointer, size_t Size)
   95085             : {
   95086             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   95087             :      * or throwing an exception. */
   95088           0 :     ALLOC_MUTEX(SgFlushStatement, lock);
   95089             : 
   95090             : #if USE_CPP_NEW_DELETE_OPERATORS
   95091             :     ROSE_FREE(Pointer);
   95092             : #else
   95093             : #if ROSE_PEDANTIC_ALLOC
   95094             :     ROSE_ASSERT(Size == sizeof(SgFlushStatement));
   95095             : #else
   95096           0 :     if (Size != sizeof(SgFlushStatement)) {
   95097           0 :       ROSE_FREE(Pointer);
   95098           0 :       ALLOC_MUTEX(SgFlushStatement, unlock);
   95099             :       return;
   95100             :     }
   95101             : #endif
   95102             : 
   95103           0 :     SgFlushStatement * object = (SgFlushStatement*) Pointer;
   95104           0 :     ROSE_ASSERT(object != nullptr);
   95105             : 
   95106             : #if ROSE_ALLOC_TRACE == 2
   95107             : //  printf("SgFlushStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgFlushStatement::next_node);
   95108             :     printf("SgFlushStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgFlushStatement::next_node);
   95109             : #endif
   95110             : 
   95111             : #if ROSE_PEDANTIC_ALLOC
   95112             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   95113             : #endif
   95114             : 
   95115             : #if ROSE_ALLOC_MEMSET == 1
   95116             : #elif ROSE_ALLOC_MEMSET == 2
   95117             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgFlushStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   95118             : #elif ROSE_ALLOC_MEMSET == 3
   95119             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgFlushStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   95120             : #endif
   95121             : 
   95122             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   95123             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   95124             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   95125             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   95126             : #else
   95127           0 :     object->p_freepointer = SgFlushStatement::next_node;
   95128           0 :     SgFlushStatement::next_node = object;
   95129             : #endif
   95130             : 
   95131             : #if ROSE_ALLOC_TRACE == 2
   95132             : //  printf("SgFlushStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgFlushStatement::next_node);
   95133             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   95134             :     Rose::MemPool::snapshot(oss.str());
   95135             :     alloc_trace_cnt++;
   95136             : #endif
   95137             : 
   95138             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   95139             : 
   95140           0 :     ALLOC_MUTEX(SgFlushStatement, unlock);
   95141             : }
   95142             : 
   95143             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   95144             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   95145             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   95146             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   95147             : // Also, note comment below from Robb (copied from the Common.code file).
   95148             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   95149             : //
   95150             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   95151             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   95152             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   95153             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   95154             : #if 0
   95155             : void SgFlushStatement::operator delete(void* pointer) { SgFlushStatement::operator delete (pointer, sizeof(SgFlushStatement)); };
   95156             : #endif
   95157             : /* #line 95158 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   95158             : 
   95159             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   95160             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   95161             : // obviously imply C++.
   95162             : 
   95163             : // This implements the support within ROSE for memory pools.  Memory pools
   95164             : // support the most condensed usage of memory within the construction of
   95165             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   95166             : // by a new operator written for each class.
   95167             : 
   95168             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   95169             :     // User wants multi-thread support and POSIX threads are available.
   95170             : #   include <pthread.h>
   95171             :     static pthread_mutex_t SgBackspaceStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   95172             : #else
   95173             :      // Cause synchronization to be skipped.
   95174             : #    ifndef ALLOC_MUTEX
   95175             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   95176             : #    endif
   95177             : #    ifdef _REENTRANT
   95178             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   95179             : #       ifdef _MSC_VER
   95180             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   95181             : #       else
   95182             : #           warning "POSIX threads are not available; synchronization being skipped"
   95183             : #       endif
   95184             : #    endif
   95185             : #endif
   95186             : 
   95187             : #ifndef ROSE_ALLOC_TRACE
   95188             : #  define ROSE_ALLOC_TRACE 0
   95189             : #endif
   95190             : 
   95191             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   95192             : #define ROSE_ALLOC_TRACE_CNT
   95193             : #include "memory-pool-snapshot.h"
   95194             : unsigned long alloc_trace_cnt = 0;
   95195             : #endif
   95196             : 
   95197             : #if ROSE_ALLOC_TRACE
   95198             : const unsigned SgBackspaceStatement::pool_size = 5;
   95199             : #else
   95200             : const unsigned SgBackspaceStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   95201             : #endif
   95202             : 
   95203             : #ifndef ROSE_ALLOC_MEMSET
   95204             : #  define ROSE_ALLOC_MEMSET 0
   95205             : #endif
   95206             : 
   95207             : #ifndef ROSE_PEDANTIC_ALLOC
   95208             : #  define ROSE_PEDANTIC_ALLOC 0
   95209             : #endif
   95210             : 
   95211             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   95212             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   95213             : #endif
   95214             : 
   95215             : #if !defined(SGNODE__ALL_POOLS)
   95216             : #define SGNODE__ALL_POOLS
   95217             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   95218             : #endif
   95219             : 
   95220             : SgBackspaceStatement* SgBackspaceStatement::next_node = nullptr;
   95221             : std::vector<unsigned char*> SgBackspaceStatement::pools;
   95222             : 
   95223             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   95224             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   95225             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   95226             : // around this macro definition rather than each use).
   95227             : #ifndef ALLOC_MUTEX
   95228             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   95229             :         do {                                                                     \
   95230             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   95231             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   95232             :                 abort();                                                         \
   95233             :             }                                                                    \
   95234             :         } while (0);
   95235             : #endif
   95236             : 
   95237             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   95238             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   95239             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   95240             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   95241             : 
   95242             : /*! \brief New operator for SgBackspaceStatement.
   95243             : 
   95244             :    This new operator implements memory pools to provide most efficent 
   95245             :    use of the heap within construction of large ASTs.
   95246             : 
   95247             : \internal The new and delete operators use the lower level C malloc/free
   95248             :    function calls for performance and to make sure that mixing of malloc/free
   95249             :    and new/delete by the used can be caught more readily.  This may change
   95250             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   95251             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   95252             :    deallocate memory allocated using ROSE_MALLOC.
   95253             : */
   95254           0 : void *SgBackspaceStatement::operator new ( size_t Size )
   95255             : {
   95256             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   95257             :      * returning or throwing an exception. */
   95258           0 :     ALLOC_MUTEX(SgBackspaceStatement, lock);
   95259             : 
   95260             : #if ROSE_ALLOC_TRACE == 2
   95261             : //    printf("SgBackspaceStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgBackspaceStatement::next_node);
   95262             : #endif
   95263             : 
   95264             : #if USE_CPP_NEW_DELETE_OPERATORS
   95265             :     void *mem = ROSE_MALLOC(Size);
   95266             :     ALLOC_MUTEX(SgBackspaceStatement, unlock);
   95267             :     return mem;
   95268             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   95269             : #if ROSE_PEDANTIC_ALLOC
   95270             :     ROSE_ASSERT(Size == sizeof(SgBackspaceStatement));
   95271             : #else
   95272           0 :     if (Size != sizeof(SgBackspaceStatement)) {
   95273           0 :       void * object = ROSE_MALLOC(Size);
   95274           0 :       ALLOC_MUTEX(SgBackspaceStatement, unlock);
   95275             :       return object;
   95276             :     }
   95277             : #endif
   95278             : 
   95279           0 :     if (SgBackspaceStatement::next_node == nullptr) {
   95280           0 :         SgBackspaceStatement * alloc = (SgBackspaceStatement*) ROSE_MALLOC ( SgBackspaceStatement::pool_size * sizeof(SgBackspaceStatement) );
   95281           0 :         ROSE_ASSERT(alloc != nullptr);
   95282             : 
   95283             : #if ROSE_ALLOC_TRACE == 2
   95284             : //        printf("SgBackspaceStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgBackspaceStatement::pools.size(), alloc, alloc + SgBackspaceStatement::pool_size);
   95285             : #endif
   95286             : 
   95287             : #if ROSE_ALLOC_MEMSET == 1
   95288             : #elif ROSE_ALLOC_MEMSET == 2
   95289             :         memset(alloc, 0x00, SgBackspaceStatement::pool_size * sizeof(SgBackspaceStatement));
   95290             : #elif ROSE_ALLOC_MEMSET == 3
   95291             :         memset(alloc, 0xAA, SgBackspaceStatement::pool_size * sizeof(SgBackspaceStatement));
   95292             : #endif
   95293           0 :         for (unsigned i=0; i < SgBackspaceStatement::pool_size-1; i++) {
   95294           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
   95295             :         }
   95296           0 :         alloc[SgBackspaceStatement::pool_size-1].p_freepointer = nullptr;
   95297             : 
   95298           0 :         SgBackspaceStatement::pools.push_back ( (unsigned char *) alloc );
   95299           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgBackspaceStatement::pool_size * sizeof(SgBackspaceStatement), V_SgBackspaceStatement ) );
   95300           0 :         SgBackspaceStatement::next_node = alloc;
   95301             :     }
   95302           0 :     ROSE_ASSERT(SgBackspaceStatement::next_node != nullptr);
   95303             : 
   95304           0 :     SgBackspaceStatement * object = SgBackspaceStatement::next_node;
   95305           0 :     SgBackspaceStatement::next_node = (SgBackspaceStatement*)(object->p_freepointer);
   95306             : 
   95307             : #if ROSE_ALLOC_TRACE == 2
   95308             :     printf("SgBackspaceStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgBackspaceStatement::next_node);
   95309             : #endif
   95310             : 
   95311           0 :     SgNode * fp = object->p_freepointer;
   95312             : #if ROSE_ALLOC_MEMSET == 1
   95313             : #elif ROSE_ALLOC_MEMSET == 2
   95314             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgBackspaceStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   95315             : #elif ROSE_ALLOC_MEMSET == 3
   95316             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgBackspaceStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   95317             : #endif
   95318           0 :     object->p_freepointer = fp;
   95319             : 
   95320             : #if ROSE_ALLOC_TRACE == 2
   95321             : //    printf("SgBackspaceStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgBackspaceStatement::next_node);
   95322             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   95323             :     Rose::MemPool::snapshot(oss.str());
   95324             :     alloc_trace_cnt++;
   95325             : #endif
   95326             : 
   95327           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   95328             : 
   95329           0 :     ALLOC_MUTEX(SgBackspaceStatement, unlock);
   95330             : 
   95331             :     return object;
   95332             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   95333             : }
   95334             : 
   95335             : 
   95336             : 
   95337             : /*! \brief Delete operator for SgBackspaceStatement.
   95338             : 
   95339             :    This delete operator implements deallocation using memory pools to 
   95340             :    provide most efficent use of the heap within construction of large ASTs.
   95341             : 
   95342             : \internal The new and delete operators use the lower level C malloc/free
   95343             :    function calls for performance and to make sure that mixing of malloc/free
   95344             :    and new/delete by the used can be caught more readily.  This may change
   95345             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   95346             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   95347             :    deallocate memory allocated using ROSE_MALLOC.
   95348             : */
   95349           0 : void SgBackspaceStatement::operator delete(void *Pointer, size_t Size)
   95350             : {
   95351             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   95352             :      * or throwing an exception. */
   95353           0 :     ALLOC_MUTEX(SgBackspaceStatement, lock);
   95354             : 
   95355             : #if USE_CPP_NEW_DELETE_OPERATORS
   95356             :     ROSE_FREE(Pointer);
   95357             : #else
   95358             : #if ROSE_PEDANTIC_ALLOC
   95359             :     ROSE_ASSERT(Size == sizeof(SgBackspaceStatement));
   95360             : #else
   95361           0 :     if (Size != sizeof(SgBackspaceStatement)) {
   95362           0 :       ROSE_FREE(Pointer);
   95363           0 :       ALLOC_MUTEX(SgBackspaceStatement, unlock);
   95364             :       return;
   95365             :     }
   95366             : #endif
   95367             : 
   95368           0 :     SgBackspaceStatement * object = (SgBackspaceStatement*) Pointer;
   95369           0 :     ROSE_ASSERT(object != nullptr);
   95370             : 
   95371             : #if ROSE_ALLOC_TRACE == 2
   95372             : //  printf("SgBackspaceStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgBackspaceStatement::next_node);
   95373             :     printf("SgBackspaceStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgBackspaceStatement::next_node);
   95374             : #endif
   95375             : 
   95376             : #if ROSE_PEDANTIC_ALLOC
   95377             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   95378             : #endif
   95379             : 
   95380             : #if ROSE_ALLOC_MEMSET == 1
   95381             : #elif ROSE_ALLOC_MEMSET == 2
   95382             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgBackspaceStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   95383             : #elif ROSE_ALLOC_MEMSET == 3
   95384             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgBackspaceStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   95385             : #endif
   95386             : 
   95387             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   95388             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   95389             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   95390             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   95391             : #else
   95392           0 :     object->p_freepointer = SgBackspaceStatement::next_node;
   95393           0 :     SgBackspaceStatement::next_node = object;
   95394             : #endif
   95395             : 
   95396             : #if ROSE_ALLOC_TRACE == 2
   95397             : //  printf("SgBackspaceStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgBackspaceStatement::next_node);
   95398             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   95399             :     Rose::MemPool::snapshot(oss.str());
   95400             :     alloc_trace_cnt++;
   95401             : #endif
   95402             : 
   95403             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   95404             : 
   95405           0 :     ALLOC_MUTEX(SgBackspaceStatement, unlock);
   95406             : }
   95407             : 
   95408             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   95409             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   95410             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   95411             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   95412             : // Also, note comment below from Robb (copied from the Common.code file).
   95413             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   95414             : //
   95415             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   95416             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   95417             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   95418             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   95419             : #if 0
   95420             : void SgBackspaceStatement::operator delete(void* pointer) { SgBackspaceStatement::operator delete (pointer, sizeof(SgBackspaceStatement)); };
   95421             : #endif
   95422             : /* #line 95423 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   95423             : 
   95424             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   95425             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   95426             : // obviously imply C++.
   95427             : 
   95428             : // This implements the support within ROSE for memory pools.  Memory pools
   95429             : // support the most condensed usage of memory within the construction of
   95430             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   95431             : // by a new operator written for each class.
   95432             : 
   95433             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   95434             :     // User wants multi-thread support and POSIX threads are available.
   95435             : #   include <pthread.h>
   95436             :     static pthread_mutex_t SgRewindStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   95437             : #else
   95438             :      // Cause synchronization to be skipped.
   95439             : #    ifndef ALLOC_MUTEX
   95440             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   95441             : #    endif
   95442             : #    ifdef _REENTRANT
   95443             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   95444             : #       ifdef _MSC_VER
   95445             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   95446             : #       else
   95447             : #           warning "POSIX threads are not available; synchronization being skipped"
   95448             : #       endif
   95449             : #    endif
   95450             : #endif
   95451             : 
   95452             : #ifndef ROSE_ALLOC_TRACE
   95453             : #  define ROSE_ALLOC_TRACE 0
   95454             : #endif
   95455             : 
   95456             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   95457             : #define ROSE_ALLOC_TRACE_CNT
   95458             : #include "memory-pool-snapshot.h"
   95459             : unsigned long alloc_trace_cnt = 0;
   95460             : #endif
   95461             : 
   95462             : #if ROSE_ALLOC_TRACE
   95463             : const unsigned SgRewindStatement::pool_size = 5;
   95464             : #else
   95465             : const unsigned SgRewindStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   95466             : #endif
   95467             : 
   95468             : #ifndef ROSE_ALLOC_MEMSET
   95469             : #  define ROSE_ALLOC_MEMSET 0
   95470             : #endif
   95471             : 
   95472             : #ifndef ROSE_PEDANTIC_ALLOC
   95473             : #  define ROSE_PEDANTIC_ALLOC 0
   95474             : #endif
   95475             : 
   95476             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   95477             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   95478             : #endif
   95479             : 
   95480             : #if !defined(SGNODE__ALL_POOLS)
   95481             : #define SGNODE__ALL_POOLS
   95482             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   95483             : #endif
   95484             : 
   95485             : SgRewindStatement* SgRewindStatement::next_node = nullptr;
   95486             : std::vector<unsigned char*> SgRewindStatement::pools;
   95487             : 
   95488             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   95489             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   95490             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   95491             : // around this macro definition rather than each use).
   95492             : #ifndef ALLOC_MUTEX
   95493             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   95494             :         do {                                                                     \
   95495             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   95496             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   95497             :                 abort();                                                         \
   95498             :             }                                                                    \
   95499             :         } while (0);
   95500             : #endif
   95501             : 
   95502             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   95503             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   95504             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   95505             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   95506             : 
   95507             : /*! \brief New operator for SgRewindStatement.
   95508             : 
   95509             :    This new operator implements memory pools to provide most efficent 
   95510             :    use of the heap within construction of large ASTs.
   95511             : 
   95512             : \internal The new and delete operators use the lower level C malloc/free
   95513             :    function calls for performance and to make sure that mixing of malloc/free
   95514             :    and new/delete by the used can be caught more readily.  This may change
   95515             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   95516             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   95517             :    deallocate memory allocated using ROSE_MALLOC.
   95518             : */
   95519           0 : void *SgRewindStatement::operator new ( size_t Size )
   95520             : {
   95521             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   95522             :      * returning or throwing an exception. */
   95523           0 :     ALLOC_MUTEX(SgRewindStatement, lock);
   95524             : 
   95525             : #if ROSE_ALLOC_TRACE == 2
   95526             : //    printf("SgRewindStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgRewindStatement::next_node);
   95527             : #endif
   95528             : 
   95529             : #if USE_CPP_NEW_DELETE_OPERATORS
   95530             :     void *mem = ROSE_MALLOC(Size);
   95531             :     ALLOC_MUTEX(SgRewindStatement, unlock);
   95532             :     return mem;
   95533             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   95534             : #if ROSE_PEDANTIC_ALLOC
   95535             :     ROSE_ASSERT(Size == sizeof(SgRewindStatement));
   95536             : #else
   95537           0 :     if (Size != sizeof(SgRewindStatement)) {
   95538           0 :       void * object = ROSE_MALLOC(Size);
   95539           0 :       ALLOC_MUTEX(SgRewindStatement, unlock);
   95540             :       return object;
   95541             :     }
   95542             : #endif
   95543             : 
   95544           0 :     if (SgRewindStatement::next_node == nullptr) {
   95545           0 :         SgRewindStatement * alloc = (SgRewindStatement*) ROSE_MALLOC ( SgRewindStatement::pool_size * sizeof(SgRewindStatement) );
   95546           0 :         ROSE_ASSERT(alloc != nullptr);
   95547             : 
   95548             : #if ROSE_ALLOC_TRACE == 2
   95549             : //        printf("SgRewindStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgRewindStatement::pools.size(), alloc, alloc + SgRewindStatement::pool_size);
   95550             : #endif
   95551             : 
   95552             : #if ROSE_ALLOC_MEMSET == 1
   95553             : #elif ROSE_ALLOC_MEMSET == 2
   95554             :         memset(alloc, 0x00, SgRewindStatement::pool_size * sizeof(SgRewindStatement));
   95555             : #elif ROSE_ALLOC_MEMSET == 3
   95556             :         memset(alloc, 0xAA, SgRewindStatement::pool_size * sizeof(SgRewindStatement));
   95557             : #endif
   95558           0 :         for (unsigned i=0; i < SgRewindStatement::pool_size-1; i++) {
   95559           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
   95560             :         }
   95561           0 :         alloc[SgRewindStatement::pool_size-1].p_freepointer = nullptr;
   95562             : 
   95563           0 :         SgRewindStatement::pools.push_back ( (unsigned char *) alloc );
   95564           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgRewindStatement::pool_size * sizeof(SgRewindStatement), V_SgRewindStatement ) );
   95565           0 :         SgRewindStatement::next_node = alloc;
   95566             :     }
   95567           0 :     ROSE_ASSERT(SgRewindStatement::next_node != nullptr);
   95568             : 
   95569           0 :     SgRewindStatement * object = SgRewindStatement::next_node;
   95570           0 :     SgRewindStatement::next_node = (SgRewindStatement*)(object->p_freepointer);
   95571             : 
   95572             : #if ROSE_ALLOC_TRACE == 2
   95573             :     printf("SgRewindStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgRewindStatement::next_node);
   95574             : #endif
   95575             : 
   95576           0 :     SgNode * fp = object->p_freepointer;
   95577             : #if ROSE_ALLOC_MEMSET == 1
   95578             : #elif ROSE_ALLOC_MEMSET == 2
   95579             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgRewindStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   95580             : #elif ROSE_ALLOC_MEMSET == 3
   95581             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgRewindStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   95582             : #endif
   95583           0 :     object->p_freepointer = fp;
   95584             : 
   95585             : #if ROSE_ALLOC_TRACE == 2
   95586             : //    printf("SgRewindStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgRewindStatement::next_node);
   95587             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   95588             :     Rose::MemPool::snapshot(oss.str());
   95589             :     alloc_trace_cnt++;
   95590             : #endif
   95591             : 
   95592           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   95593             : 
   95594           0 :     ALLOC_MUTEX(SgRewindStatement, unlock);
   95595             : 
   95596             :     return object;
   95597             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   95598             : }
   95599             : 
   95600             : 
   95601             : 
   95602             : /*! \brief Delete operator for SgRewindStatement.
   95603             : 
   95604             :    This delete operator implements deallocation using memory pools to 
   95605             :    provide most efficent use of the heap within construction of large ASTs.
   95606             : 
   95607             : \internal The new and delete operators use the lower level C malloc/free
   95608             :    function calls for performance and to make sure that mixing of malloc/free
   95609             :    and new/delete by the used can be caught more readily.  This may change
   95610             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   95611             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   95612             :    deallocate memory allocated using ROSE_MALLOC.
   95613             : */
   95614           0 : void SgRewindStatement::operator delete(void *Pointer, size_t Size)
   95615             : {
   95616             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   95617             :      * or throwing an exception. */
   95618           0 :     ALLOC_MUTEX(SgRewindStatement, lock);
   95619             : 
   95620             : #if USE_CPP_NEW_DELETE_OPERATORS
   95621             :     ROSE_FREE(Pointer);
   95622             : #else
   95623             : #if ROSE_PEDANTIC_ALLOC
   95624             :     ROSE_ASSERT(Size == sizeof(SgRewindStatement));
   95625             : #else
   95626           0 :     if (Size != sizeof(SgRewindStatement)) {
   95627           0 :       ROSE_FREE(Pointer);
   95628           0 :       ALLOC_MUTEX(SgRewindStatement, unlock);
   95629             :       return;
   95630             :     }
   95631             : #endif
   95632             : 
   95633           0 :     SgRewindStatement * object = (SgRewindStatement*) Pointer;
   95634           0 :     ROSE_ASSERT(object != nullptr);
   95635             : 
   95636             : #if ROSE_ALLOC_TRACE == 2
   95637             : //  printf("SgRewindStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgRewindStatement::next_node);
   95638             :     printf("SgRewindStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgRewindStatement::next_node);
   95639             : #endif
   95640             : 
   95641             : #if ROSE_PEDANTIC_ALLOC
   95642             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   95643             : #endif
   95644             : 
   95645             : #if ROSE_ALLOC_MEMSET == 1
   95646             : #elif ROSE_ALLOC_MEMSET == 2
   95647             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgRewindStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   95648             : #elif ROSE_ALLOC_MEMSET == 3
   95649             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgRewindStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   95650             : #endif
   95651             : 
   95652             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   95653             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   95654             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   95655             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   95656             : #else
   95657           0 :     object->p_freepointer = SgRewindStatement::next_node;
   95658           0 :     SgRewindStatement::next_node = object;
   95659             : #endif
   95660             : 
   95661             : #if ROSE_ALLOC_TRACE == 2
   95662             : //  printf("SgRewindStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgRewindStatement::next_node);
   95663             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   95664             :     Rose::MemPool::snapshot(oss.str());
   95665             :     alloc_trace_cnt++;
   95666             : #endif
   95667             : 
   95668             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   95669             : 
   95670           0 :     ALLOC_MUTEX(SgRewindStatement, unlock);
   95671             : }
   95672             : 
   95673             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   95674             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   95675             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   95676             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   95677             : // Also, note comment below from Robb (copied from the Common.code file).
   95678             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   95679             : //
   95680             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   95681             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   95682             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   95683             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   95684             : #if 0
   95685             : void SgRewindStatement::operator delete(void* pointer) { SgRewindStatement::operator delete (pointer, sizeof(SgRewindStatement)); };
   95686             : #endif
   95687             : /* #line 95688 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   95688             : 
   95689             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   95690             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   95691             : // obviously imply C++.
   95692             : 
   95693             : // This implements the support within ROSE for memory pools.  Memory pools
   95694             : // support the most condensed usage of memory within the construction of
   95695             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   95696             : // by a new operator written for each class.
   95697             : 
   95698             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   95699             :     // User wants multi-thread support and POSIX threads are available.
   95700             : #   include <pthread.h>
   95701             :     static pthread_mutex_t SgEndfileStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   95702             : #else
   95703             :      // Cause synchronization to be skipped.
   95704             : #    ifndef ALLOC_MUTEX
   95705             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   95706             : #    endif
   95707             : #    ifdef _REENTRANT
   95708             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   95709             : #       ifdef _MSC_VER
   95710             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   95711             : #       else
   95712             : #           warning "POSIX threads are not available; synchronization being skipped"
   95713             : #       endif
   95714             : #    endif
   95715             : #endif
   95716             : 
   95717             : #ifndef ROSE_ALLOC_TRACE
   95718             : #  define ROSE_ALLOC_TRACE 0
   95719             : #endif
   95720             : 
   95721             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   95722             : #define ROSE_ALLOC_TRACE_CNT
   95723             : #include "memory-pool-snapshot.h"
   95724             : unsigned long alloc_trace_cnt = 0;
   95725             : #endif
   95726             : 
   95727             : #if ROSE_ALLOC_TRACE
   95728             : const unsigned SgEndfileStatement::pool_size = 5;
   95729             : #else
   95730             : const unsigned SgEndfileStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   95731             : #endif
   95732             : 
   95733             : #ifndef ROSE_ALLOC_MEMSET
   95734             : #  define ROSE_ALLOC_MEMSET 0
   95735             : #endif
   95736             : 
   95737             : #ifndef ROSE_PEDANTIC_ALLOC
   95738             : #  define ROSE_PEDANTIC_ALLOC 0
   95739             : #endif
   95740             : 
   95741             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   95742             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   95743             : #endif
   95744             : 
   95745             : #if !defined(SGNODE__ALL_POOLS)
   95746             : #define SGNODE__ALL_POOLS
   95747             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   95748             : #endif
   95749             : 
   95750             : SgEndfileStatement* SgEndfileStatement::next_node = nullptr;
   95751             : std::vector<unsigned char*> SgEndfileStatement::pools;
   95752             : 
   95753             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   95754             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   95755             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   95756             : // around this macro definition rather than each use).
   95757             : #ifndef ALLOC_MUTEX
   95758             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   95759             :         do {                                                                     \
   95760             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   95761             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   95762             :                 abort();                                                         \
   95763             :             }                                                                    \
   95764             :         } while (0);
   95765             : #endif
   95766             : 
   95767             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   95768             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   95769             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   95770             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   95771             : 
   95772             : /*! \brief New operator for SgEndfileStatement.
   95773             : 
   95774             :    This new operator implements memory pools to provide most efficent 
   95775             :    use of the heap within construction of large ASTs.
   95776             : 
   95777             : \internal The new and delete operators use the lower level C malloc/free
   95778             :    function calls for performance and to make sure that mixing of malloc/free
   95779             :    and new/delete by the used can be caught more readily.  This may change
   95780             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   95781             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   95782             :    deallocate memory allocated using ROSE_MALLOC.
   95783             : */
   95784           0 : void *SgEndfileStatement::operator new ( size_t Size )
   95785             : {
   95786             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   95787             :      * returning or throwing an exception. */
   95788           0 :     ALLOC_MUTEX(SgEndfileStatement, lock);
   95789             : 
   95790             : #if ROSE_ALLOC_TRACE == 2
   95791             : //    printf("SgEndfileStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgEndfileStatement::next_node);
   95792             : #endif
   95793             : 
   95794             : #if USE_CPP_NEW_DELETE_OPERATORS
   95795             :     void *mem = ROSE_MALLOC(Size);
   95796             :     ALLOC_MUTEX(SgEndfileStatement, unlock);
   95797             :     return mem;
   95798             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   95799             : #if ROSE_PEDANTIC_ALLOC
   95800             :     ROSE_ASSERT(Size == sizeof(SgEndfileStatement));
   95801             : #else
   95802           0 :     if (Size != sizeof(SgEndfileStatement)) {
   95803           0 :       void * object = ROSE_MALLOC(Size);
   95804           0 :       ALLOC_MUTEX(SgEndfileStatement, unlock);
   95805             :       return object;
   95806             :     }
   95807             : #endif
   95808             : 
   95809           0 :     if (SgEndfileStatement::next_node == nullptr) {
   95810           0 :         SgEndfileStatement * alloc = (SgEndfileStatement*) ROSE_MALLOC ( SgEndfileStatement::pool_size * sizeof(SgEndfileStatement) );
   95811           0 :         ROSE_ASSERT(alloc != nullptr);
   95812             : 
   95813             : #if ROSE_ALLOC_TRACE == 2
   95814             : //        printf("SgEndfileStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgEndfileStatement::pools.size(), alloc, alloc + SgEndfileStatement::pool_size);
   95815             : #endif
   95816             : 
   95817             : #if ROSE_ALLOC_MEMSET == 1
   95818             : #elif ROSE_ALLOC_MEMSET == 2
   95819             :         memset(alloc, 0x00, SgEndfileStatement::pool_size * sizeof(SgEndfileStatement));
   95820             : #elif ROSE_ALLOC_MEMSET == 3
   95821             :         memset(alloc, 0xAA, SgEndfileStatement::pool_size * sizeof(SgEndfileStatement));
   95822             : #endif
   95823           0 :         for (unsigned i=0; i < SgEndfileStatement::pool_size-1; i++) {
   95824           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
   95825             :         }
   95826           0 :         alloc[SgEndfileStatement::pool_size-1].p_freepointer = nullptr;
   95827             : 
   95828           0 :         SgEndfileStatement::pools.push_back ( (unsigned char *) alloc );
   95829           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgEndfileStatement::pool_size * sizeof(SgEndfileStatement), V_SgEndfileStatement ) );
   95830           0 :         SgEndfileStatement::next_node = alloc;
   95831             :     }
   95832           0 :     ROSE_ASSERT(SgEndfileStatement::next_node != nullptr);
   95833             : 
   95834           0 :     SgEndfileStatement * object = SgEndfileStatement::next_node;
   95835           0 :     SgEndfileStatement::next_node = (SgEndfileStatement*)(object->p_freepointer);
   95836             : 
   95837             : #if ROSE_ALLOC_TRACE == 2
   95838             :     printf("SgEndfileStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgEndfileStatement::next_node);
   95839             : #endif
   95840             : 
   95841           0 :     SgNode * fp = object->p_freepointer;
   95842             : #if ROSE_ALLOC_MEMSET == 1
   95843             : #elif ROSE_ALLOC_MEMSET == 2
   95844             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgEndfileStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   95845             : #elif ROSE_ALLOC_MEMSET == 3
   95846             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgEndfileStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   95847             : #endif
   95848           0 :     object->p_freepointer = fp;
   95849             : 
   95850             : #if ROSE_ALLOC_TRACE == 2
   95851             : //    printf("SgEndfileStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgEndfileStatement::next_node);
   95852             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   95853             :     Rose::MemPool::snapshot(oss.str());
   95854             :     alloc_trace_cnt++;
   95855             : #endif
   95856             : 
   95857           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   95858             : 
   95859           0 :     ALLOC_MUTEX(SgEndfileStatement, unlock);
   95860             : 
   95861             :     return object;
   95862             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   95863             : }
   95864             : 
   95865             : 
   95866             : 
   95867             : /*! \brief Delete operator for SgEndfileStatement.
   95868             : 
   95869             :    This delete operator implements deallocation using memory pools to 
   95870             :    provide most efficent use of the heap within construction of large ASTs.
   95871             : 
   95872             : \internal The new and delete operators use the lower level C malloc/free
   95873             :    function calls for performance and to make sure that mixing of malloc/free
   95874             :    and new/delete by the used can be caught more readily.  This may change
   95875             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   95876             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   95877             :    deallocate memory allocated using ROSE_MALLOC.
   95878             : */
   95879           0 : void SgEndfileStatement::operator delete(void *Pointer, size_t Size)
   95880             : {
   95881             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   95882             :      * or throwing an exception. */
   95883           0 :     ALLOC_MUTEX(SgEndfileStatement, lock);
   95884             : 
   95885             : #if USE_CPP_NEW_DELETE_OPERATORS
   95886             :     ROSE_FREE(Pointer);
   95887             : #else
   95888             : #if ROSE_PEDANTIC_ALLOC
   95889             :     ROSE_ASSERT(Size == sizeof(SgEndfileStatement));
   95890             : #else
   95891           0 :     if (Size != sizeof(SgEndfileStatement)) {
   95892           0 :       ROSE_FREE(Pointer);
   95893           0 :       ALLOC_MUTEX(SgEndfileStatement, unlock);
   95894             :       return;
   95895             :     }
   95896             : #endif
   95897             : 
   95898           0 :     SgEndfileStatement * object = (SgEndfileStatement*) Pointer;
   95899           0 :     ROSE_ASSERT(object != nullptr);
   95900             : 
   95901             : #if ROSE_ALLOC_TRACE == 2
   95902             : //  printf("SgEndfileStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgEndfileStatement::next_node);
   95903             :     printf("SgEndfileStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgEndfileStatement::next_node);
   95904             : #endif
   95905             : 
   95906             : #if ROSE_PEDANTIC_ALLOC
   95907             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   95908             : #endif
   95909             : 
   95910             : #if ROSE_ALLOC_MEMSET == 1
   95911             : #elif ROSE_ALLOC_MEMSET == 2
   95912             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgEndfileStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   95913             : #elif ROSE_ALLOC_MEMSET == 3
   95914             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgEndfileStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   95915             : #endif
   95916             : 
   95917             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   95918             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   95919             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   95920             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   95921             : #else
   95922           0 :     object->p_freepointer = SgEndfileStatement::next_node;
   95923           0 :     SgEndfileStatement::next_node = object;
   95924             : #endif
   95925             : 
   95926             : #if ROSE_ALLOC_TRACE == 2
   95927             : //  printf("SgEndfileStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgEndfileStatement::next_node);
   95928             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   95929             :     Rose::MemPool::snapshot(oss.str());
   95930             :     alloc_trace_cnt++;
   95931             : #endif
   95932             : 
   95933             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   95934             : 
   95935           0 :     ALLOC_MUTEX(SgEndfileStatement, unlock);
   95936             : }
   95937             : 
   95938             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   95939             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   95940             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   95941             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   95942             : // Also, note comment below from Robb (copied from the Common.code file).
   95943             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   95944             : //
   95945             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   95946             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   95947             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   95948             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   95949             : #if 0
   95950             : void SgEndfileStatement::operator delete(void* pointer) { SgEndfileStatement::operator delete (pointer, sizeof(SgEndfileStatement)); };
   95951             : #endif
   95952             : /* #line 95953 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   95953             : 
   95954             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   95955             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   95956             : // obviously imply C++.
   95957             : 
   95958             : // This implements the support within ROSE for memory pools.  Memory pools
   95959             : // support the most condensed usage of memory within the construction of
   95960             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   95961             : // by a new operator written for each class.
   95962             : 
   95963             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   95964             :     // User wants multi-thread support and POSIX threads are available.
   95965             : #   include <pthread.h>
   95966             :     static pthread_mutex_t SgWaitStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   95967             : #else
   95968             :      // Cause synchronization to be skipped.
   95969             : #    ifndef ALLOC_MUTEX
   95970             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   95971             : #    endif
   95972             : #    ifdef _REENTRANT
   95973             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   95974             : #       ifdef _MSC_VER
   95975             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   95976             : #       else
   95977             : #           warning "POSIX threads are not available; synchronization being skipped"
   95978             : #       endif
   95979             : #    endif
   95980             : #endif
   95981             : 
   95982             : #ifndef ROSE_ALLOC_TRACE
   95983             : #  define ROSE_ALLOC_TRACE 0
   95984             : #endif
   95985             : 
   95986             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   95987             : #define ROSE_ALLOC_TRACE_CNT
   95988             : #include "memory-pool-snapshot.h"
   95989             : unsigned long alloc_trace_cnt = 0;
   95990             : #endif
   95991             : 
   95992             : #if ROSE_ALLOC_TRACE
   95993             : const unsigned SgWaitStatement::pool_size = 5;
   95994             : #else
   95995             : const unsigned SgWaitStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   95996             : #endif
   95997             : 
   95998             : #ifndef ROSE_ALLOC_MEMSET
   95999             : #  define ROSE_ALLOC_MEMSET 0
   96000             : #endif
   96001             : 
   96002             : #ifndef ROSE_PEDANTIC_ALLOC
   96003             : #  define ROSE_PEDANTIC_ALLOC 0
   96004             : #endif
   96005             : 
   96006             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   96007             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   96008             : #endif
   96009             : 
   96010             : #if !defined(SGNODE__ALL_POOLS)
   96011             : #define SGNODE__ALL_POOLS
   96012             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   96013             : #endif
   96014             : 
   96015             : SgWaitStatement* SgWaitStatement::next_node = nullptr;
   96016             : std::vector<unsigned char*> SgWaitStatement::pools;
   96017             : 
   96018             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   96019             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   96020             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   96021             : // around this macro definition rather than each use).
   96022             : #ifndef ALLOC_MUTEX
   96023             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   96024             :         do {                                                                     \
   96025             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   96026             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   96027             :                 abort();                                                         \
   96028             :             }                                                                    \
   96029             :         } while (0);
   96030             : #endif
   96031             : 
   96032             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   96033             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   96034             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   96035             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   96036             : 
   96037             : /*! \brief New operator for SgWaitStatement.
   96038             : 
   96039             :    This new operator implements memory pools to provide most efficent 
   96040             :    use of the heap within construction of large ASTs.
   96041             : 
   96042             : \internal The new and delete operators use the lower level C malloc/free
   96043             :    function calls for performance and to make sure that mixing of malloc/free
   96044             :    and new/delete by the used can be caught more readily.  This may change
   96045             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   96046             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   96047             :    deallocate memory allocated using ROSE_MALLOC.
   96048             : */
   96049           0 : void *SgWaitStatement::operator new ( size_t Size )
   96050             : {
   96051             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   96052             :      * returning or throwing an exception. */
   96053           0 :     ALLOC_MUTEX(SgWaitStatement, lock);
   96054             : 
   96055             : #if ROSE_ALLOC_TRACE == 2
   96056             : //    printf("SgWaitStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgWaitStatement::next_node);
   96057             : #endif
   96058             : 
   96059             : #if USE_CPP_NEW_DELETE_OPERATORS
   96060             :     void *mem = ROSE_MALLOC(Size);
   96061             :     ALLOC_MUTEX(SgWaitStatement, unlock);
   96062             :     return mem;
   96063             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   96064             : #if ROSE_PEDANTIC_ALLOC
   96065             :     ROSE_ASSERT(Size == sizeof(SgWaitStatement));
   96066             : #else
   96067           0 :     if (Size != sizeof(SgWaitStatement)) {
   96068           0 :       void * object = ROSE_MALLOC(Size);
   96069           0 :       ALLOC_MUTEX(SgWaitStatement, unlock);
   96070             :       return object;
   96071             :     }
   96072             : #endif
   96073             : 
   96074           0 :     if (SgWaitStatement::next_node == nullptr) {
   96075           0 :         SgWaitStatement * alloc = (SgWaitStatement*) ROSE_MALLOC ( SgWaitStatement::pool_size * sizeof(SgWaitStatement) );
   96076           0 :         ROSE_ASSERT(alloc != nullptr);
   96077             : 
   96078             : #if ROSE_ALLOC_TRACE == 2
   96079             : //        printf("SgWaitStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgWaitStatement::pools.size(), alloc, alloc + SgWaitStatement::pool_size);
   96080             : #endif
   96081             : 
   96082             : #if ROSE_ALLOC_MEMSET == 1
   96083             : #elif ROSE_ALLOC_MEMSET == 2
   96084             :         memset(alloc, 0x00, SgWaitStatement::pool_size * sizeof(SgWaitStatement));
   96085             : #elif ROSE_ALLOC_MEMSET == 3
   96086             :         memset(alloc, 0xAA, SgWaitStatement::pool_size * sizeof(SgWaitStatement));
   96087             : #endif
   96088           0 :         for (unsigned i=0; i < SgWaitStatement::pool_size-1; i++) {
   96089           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
   96090             :         }
   96091           0 :         alloc[SgWaitStatement::pool_size-1].p_freepointer = nullptr;
   96092             : 
   96093           0 :         SgWaitStatement::pools.push_back ( (unsigned char *) alloc );
   96094           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgWaitStatement::pool_size * sizeof(SgWaitStatement), V_SgWaitStatement ) );
   96095           0 :         SgWaitStatement::next_node = alloc;
   96096             :     }
   96097           0 :     ROSE_ASSERT(SgWaitStatement::next_node != nullptr);
   96098             : 
   96099           0 :     SgWaitStatement * object = SgWaitStatement::next_node;
   96100           0 :     SgWaitStatement::next_node = (SgWaitStatement*)(object->p_freepointer);
   96101             : 
   96102             : #if ROSE_ALLOC_TRACE == 2
   96103             :     printf("SgWaitStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgWaitStatement::next_node);
   96104             : #endif
   96105             : 
   96106           0 :     SgNode * fp = object->p_freepointer;
   96107             : #if ROSE_ALLOC_MEMSET == 1
   96108             : #elif ROSE_ALLOC_MEMSET == 2
   96109             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgWaitStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   96110             : #elif ROSE_ALLOC_MEMSET == 3
   96111             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgWaitStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   96112             : #endif
   96113           0 :     object->p_freepointer = fp;
   96114             : 
   96115             : #if ROSE_ALLOC_TRACE == 2
   96116             : //    printf("SgWaitStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgWaitStatement::next_node);
   96117             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   96118             :     Rose::MemPool::snapshot(oss.str());
   96119             :     alloc_trace_cnt++;
   96120             : #endif
   96121             : 
   96122           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   96123             : 
   96124           0 :     ALLOC_MUTEX(SgWaitStatement, unlock);
   96125             : 
   96126             :     return object;
   96127             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   96128             : }
   96129             : 
   96130             : 
   96131             : 
   96132             : /*! \brief Delete operator for SgWaitStatement.
   96133             : 
   96134             :    This delete operator implements deallocation using memory pools to 
   96135             :    provide most efficent use of the heap within construction of large ASTs.
   96136             : 
   96137             : \internal The new and delete operators use the lower level C malloc/free
   96138             :    function calls for performance and to make sure that mixing of malloc/free
   96139             :    and new/delete by the used can be caught more readily.  This may change
   96140             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   96141             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   96142             :    deallocate memory allocated using ROSE_MALLOC.
   96143             : */
   96144           0 : void SgWaitStatement::operator delete(void *Pointer, size_t Size)
   96145             : {
   96146             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   96147             :      * or throwing an exception. */
   96148           0 :     ALLOC_MUTEX(SgWaitStatement, lock);
   96149             : 
   96150             : #if USE_CPP_NEW_DELETE_OPERATORS
   96151             :     ROSE_FREE(Pointer);
   96152             : #else
   96153             : #if ROSE_PEDANTIC_ALLOC
   96154             :     ROSE_ASSERT(Size == sizeof(SgWaitStatement));
   96155             : #else
   96156           0 :     if (Size != sizeof(SgWaitStatement)) {
   96157           0 :       ROSE_FREE(Pointer);
   96158           0 :       ALLOC_MUTEX(SgWaitStatement, unlock);
   96159             :       return;
   96160             :     }
   96161             : #endif
   96162             : 
   96163           0 :     SgWaitStatement * object = (SgWaitStatement*) Pointer;
   96164           0 :     ROSE_ASSERT(object != nullptr);
   96165             : 
   96166             : #if ROSE_ALLOC_TRACE == 2
   96167             : //  printf("SgWaitStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgWaitStatement::next_node);
   96168             :     printf("SgWaitStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgWaitStatement::next_node);
   96169             : #endif
   96170             : 
   96171             : #if ROSE_PEDANTIC_ALLOC
   96172             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   96173             : #endif
   96174             : 
   96175             : #if ROSE_ALLOC_MEMSET == 1
   96176             : #elif ROSE_ALLOC_MEMSET == 2
   96177             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgWaitStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   96178             : #elif ROSE_ALLOC_MEMSET == 3
   96179             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgWaitStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   96180             : #endif
   96181             : 
   96182             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   96183             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   96184             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   96185             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   96186             : #else
   96187           0 :     object->p_freepointer = SgWaitStatement::next_node;
   96188           0 :     SgWaitStatement::next_node = object;
   96189             : #endif
   96190             : 
   96191             : #if ROSE_ALLOC_TRACE == 2
   96192             : //  printf("SgWaitStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgWaitStatement::next_node);
   96193             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   96194             :     Rose::MemPool::snapshot(oss.str());
   96195             :     alloc_trace_cnt++;
   96196             : #endif
   96197             : 
   96198             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   96199             : 
   96200           0 :     ALLOC_MUTEX(SgWaitStatement, unlock);
   96201             : }
   96202             : 
   96203             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   96204             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   96205             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   96206             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   96207             : // Also, note comment below from Robb (copied from the Common.code file).
   96208             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   96209             : //
   96210             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   96211             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   96212             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   96213             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   96214             : #if 0
   96215             : void SgWaitStatement::operator delete(void* pointer) { SgWaitStatement::operator delete (pointer, sizeof(SgWaitStatement)); };
   96216             : #endif
   96217             : /* #line 96218 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   96218             : 
   96219             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   96220             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   96221             : // obviously imply C++.
   96222             : 
   96223             : // This implements the support within ROSE for memory pools.  Memory pools
   96224             : // support the most condensed usage of memory within the construction of
   96225             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   96226             : // by a new operator written for each class.
   96227             : 
   96228             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   96229             :     // User wants multi-thread support and POSIX threads are available.
   96230             : #   include <pthread.h>
   96231             :     static pthread_mutex_t SgWhereStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   96232             : #else
   96233             :      // Cause synchronization to be skipped.
   96234             : #    ifndef ALLOC_MUTEX
   96235             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   96236             : #    endif
   96237             : #    ifdef _REENTRANT
   96238             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   96239             : #       ifdef _MSC_VER
   96240             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   96241             : #       else
   96242             : #           warning "POSIX threads are not available; synchronization being skipped"
   96243             : #       endif
   96244             : #    endif
   96245             : #endif
   96246             : 
   96247             : #ifndef ROSE_ALLOC_TRACE
   96248             : #  define ROSE_ALLOC_TRACE 0
   96249             : #endif
   96250             : 
   96251             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   96252             : #define ROSE_ALLOC_TRACE_CNT
   96253             : #include "memory-pool-snapshot.h"
   96254             : unsigned long alloc_trace_cnt = 0;
   96255             : #endif
   96256             : 
   96257             : #if ROSE_ALLOC_TRACE
   96258             : const unsigned SgWhereStatement::pool_size = 5;
   96259             : #else
   96260             : const unsigned SgWhereStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   96261             : #endif
   96262             : 
   96263             : #ifndef ROSE_ALLOC_MEMSET
   96264             : #  define ROSE_ALLOC_MEMSET 0
   96265             : #endif
   96266             : 
   96267             : #ifndef ROSE_PEDANTIC_ALLOC
   96268             : #  define ROSE_PEDANTIC_ALLOC 0
   96269             : #endif
   96270             : 
   96271             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   96272             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   96273             : #endif
   96274             : 
   96275             : #if !defined(SGNODE__ALL_POOLS)
   96276             : #define SGNODE__ALL_POOLS
   96277             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   96278             : #endif
   96279             : 
   96280             : SgWhereStatement* SgWhereStatement::next_node = nullptr;
   96281             : std::vector<unsigned char*> SgWhereStatement::pools;
   96282             : 
   96283             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   96284             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   96285             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   96286             : // around this macro definition rather than each use).
   96287             : #ifndef ALLOC_MUTEX
   96288             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   96289             :         do {                                                                     \
   96290             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   96291             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   96292             :                 abort();                                                         \
   96293             :             }                                                                    \
   96294             :         } while (0);
   96295             : #endif
   96296             : 
   96297             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   96298             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   96299             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   96300             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   96301             : 
   96302             : /*! \brief New operator for SgWhereStatement.
   96303             : 
   96304             :    This new operator implements memory pools to provide most efficent 
   96305             :    use of the heap within construction of large ASTs.
   96306             : 
   96307             : \internal The new and delete operators use the lower level C malloc/free
   96308             :    function calls for performance and to make sure that mixing of malloc/free
   96309             :    and new/delete by the used can be caught more readily.  This may change
   96310             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   96311             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   96312             :    deallocate memory allocated using ROSE_MALLOC.
   96313             : */
   96314           0 : void *SgWhereStatement::operator new ( size_t Size )
   96315             : {
   96316             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   96317             :      * returning or throwing an exception. */
   96318           0 :     ALLOC_MUTEX(SgWhereStatement, lock);
   96319             : 
   96320             : #if ROSE_ALLOC_TRACE == 2
   96321             : //    printf("SgWhereStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgWhereStatement::next_node);
   96322             : #endif
   96323             : 
   96324             : #if USE_CPP_NEW_DELETE_OPERATORS
   96325             :     void *mem = ROSE_MALLOC(Size);
   96326             :     ALLOC_MUTEX(SgWhereStatement, unlock);
   96327             :     return mem;
   96328             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   96329             : #if ROSE_PEDANTIC_ALLOC
   96330             :     ROSE_ASSERT(Size == sizeof(SgWhereStatement));
   96331             : #else
   96332           0 :     if (Size != sizeof(SgWhereStatement)) {
   96333           0 :       void * object = ROSE_MALLOC(Size);
   96334           0 :       ALLOC_MUTEX(SgWhereStatement, unlock);
   96335             :       return object;
   96336             :     }
   96337             : #endif
   96338             : 
   96339           0 :     if (SgWhereStatement::next_node == nullptr) {
   96340           0 :         SgWhereStatement * alloc = (SgWhereStatement*) ROSE_MALLOC ( SgWhereStatement::pool_size * sizeof(SgWhereStatement) );
   96341           0 :         ROSE_ASSERT(alloc != nullptr);
   96342             : 
   96343             : #if ROSE_ALLOC_TRACE == 2
   96344             : //        printf("SgWhereStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgWhereStatement::pools.size(), alloc, alloc + SgWhereStatement::pool_size);
   96345             : #endif
   96346             : 
   96347             : #if ROSE_ALLOC_MEMSET == 1
   96348             : #elif ROSE_ALLOC_MEMSET == 2
   96349             :         memset(alloc, 0x00, SgWhereStatement::pool_size * sizeof(SgWhereStatement));
   96350             : #elif ROSE_ALLOC_MEMSET == 3
   96351             :         memset(alloc, 0xAA, SgWhereStatement::pool_size * sizeof(SgWhereStatement));
   96352             : #endif
   96353           0 :         for (unsigned i=0; i < SgWhereStatement::pool_size-1; i++) {
   96354           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
   96355             :         }
   96356           0 :         alloc[SgWhereStatement::pool_size-1].p_freepointer = nullptr;
   96357             : 
   96358           0 :         SgWhereStatement::pools.push_back ( (unsigned char *) alloc );
   96359           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgWhereStatement::pool_size * sizeof(SgWhereStatement), V_SgWhereStatement ) );
   96360           0 :         SgWhereStatement::next_node = alloc;
   96361             :     }
   96362           0 :     ROSE_ASSERT(SgWhereStatement::next_node != nullptr);
   96363             : 
   96364           0 :     SgWhereStatement * object = SgWhereStatement::next_node;
   96365           0 :     SgWhereStatement::next_node = (SgWhereStatement*)(object->p_freepointer);
   96366             : 
   96367             : #if ROSE_ALLOC_TRACE == 2
   96368             :     printf("SgWhereStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgWhereStatement::next_node);
   96369             : #endif
   96370             : 
   96371           0 :     SgNode * fp = object->p_freepointer;
   96372             : #if ROSE_ALLOC_MEMSET == 1
   96373             : #elif ROSE_ALLOC_MEMSET == 2
   96374             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgWhereStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   96375             : #elif ROSE_ALLOC_MEMSET == 3
   96376             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgWhereStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   96377             : #endif
   96378           0 :     object->p_freepointer = fp;
   96379             : 
   96380             : #if ROSE_ALLOC_TRACE == 2
   96381             : //    printf("SgWhereStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgWhereStatement::next_node);
   96382             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   96383             :     Rose::MemPool::snapshot(oss.str());
   96384             :     alloc_trace_cnt++;
   96385             : #endif
   96386             : 
   96387           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   96388             : 
   96389           0 :     ALLOC_MUTEX(SgWhereStatement, unlock);
   96390             : 
   96391             :     return object;
   96392             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   96393             : }
   96394             : 
   96395             : 
   96396             : 
   96397             : /*! \brief Delete operator for SgWhereStatement.
   96398             : 
   96399             :    This delete operator implements deallocation using memory pools to 
   96400             :    provide most efficent use of the heap within construction of large ASTs.
   96401             : 
   96402             : \internal The new and delete operators use the lower level C malloc/free
   96403             :    function calls for performance and to make sure that mixing of malloc/free
   96404             :    and new/delete by the used can be caught more readily.  This may change
   96405             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   96406             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   96407             :    deallocate memory allocated using ROSE_MALLOC.
   96408             : */
   96409           0 : void SgWhereStatement::operator delete(void *Pointer, size_t Size)
   96410             : {
   96411             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   96412             :      * or throwing an exception. */
   96413           0 :     ALLOC_MUTEX(SgWhereStatement, lock);
   96414             : 
   96415             : #if USE_CPP_NEW_DELETE_OPERATORS
   96416             :     ROSE_FREE(Pointer);
   96417             : #else
   96418             : #if ROSE_PEDANTIC_ALLOC
   96419             :     ROSE_ASSERT(Size == sizeof(SgWhereStatement));
   96420             : #else
   96421           0 :     if (Size != sizeof(SgWhereStatement)) {
   96422           0 :       ROSE_FREE(Pointer);
   96423           0 :       ALLOC_MUTEX(SgWhereStatement, unlock);
   96424             :       return;
   96425             :     }
   96426             : #endif
   96427             : 
   96428           0 :     SgWhereStatement * object = (SgWhereStatement*) Pointer;
   96429           0 :     ROSE_ASSERT(object != nullptr);
   96430             : 
   96431             : #if ROSE_ALLOC_TRACE == 2
   96432             : //  printf("SgWhereStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgWhereStatement::next_node);
   96433             :     printf("SgWhereStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgWhereStatement::next_node);
   96434             : #endif
   96435             : 
   96436             : #if ROSE_PEDANTIC_ALLOC
   96437             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   96438             : #endif
   96439             : 
   96440             : #if ROSE_ALLOC_MEMSET == 1
   96441             : #elif ROSE_ALLOC_MEMSET == 2
   96442             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgWhereStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   96443             : #elif ROSE_ALLOC_MEMSET == 3
   96444             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgWhereStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   96445             : #endif
   96446             : 
   96447             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   96448             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   96449             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   96450             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   96451             : #else
   96452           0 :     object->p_freepointer = SgWhereStatement::next_node;
   96453           0 :     SgWhereStatement::next_node = object;
   96454             : #endif
   96455             : 
   96456             : #if ROSE_ALLOC_TRACE == 2
   96457             : //  printf("SgWhereStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgWhereStatement::next_node);
   96458             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   96459             :     Rose::MemPool::snapshot(oss.str());
   96460             :     alloc_trace_cnt++;
   96461             : #endif
   96462             : 
   96463             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   96464             : 
   96465           0 :     ALLOC_MUTEX(SgWhereStatement, unlock);
   96466             : }
   96467             : 
   96468             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   96469             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   96470             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   96471             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   96472             : // Also, note comment below from Robb (copied from the Common.code file).
   96473             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   96474             : //
   96475             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   96476             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   96477             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   96478             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   96479             : #if 0
   96480             : void SgWhereStatement::operator delete(void* pointer) { SgWhereStatement::operator delete (pointer, sizeof(SgWhereStatement)); };
   96481             : #endif
   96482             : /* #line 96483 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   96483             : 
   96484             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   96485             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   96486             : // obviously imply C++.
   96487             : 
   96488             : // This implements the support within ROSE for memory pools.  Memory pools
   96489             : // support the most condensed usage of memory within the construction of
   96490             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   96491             : // by a new operator written for each class.
   96492             : 
   96493             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   96494             :     // User wants multi-thread support and POSIX threads are available.
   96495             : #   include <pthread.h>
   96496             :     static pthread_mutex_t SgElseWhereStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   96497             : #else
   96498             :      // Cause synchronization to be skipped.
   96499             : #    ifndef ALLOC_MUTEX
   96500             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   96501             : #    endif
   96502             : #    ifdef _REENTRANT
   96503             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   96504             : #       ifdef _MSC_VER
   96505             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   96506             : #       else
   96507             : #           warning "POSIX threads are not available; synchronization being skipped"
   96508             : #       endif
   96509             : #    endif
   96510             : #endif
   96511             : 
   96512             : #ifndef ROSE_ALLOC_TRACE
   96513             : #  define ROSE_ALLOC_TRACE 0
   96514             : #endif
   96515             : 
   96516             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   96517             : #define ROSE_ALLOC_TRACE_CNT
   96518             : #include "memory-pool-snapshot.h"
   96519             : unsigned long alloc_trace_cnt = 0;
   96520             : #endif
   96521             : 
   96522             : #if ROSE_ALLOC_TRACE
   96523             : const unsigned SgElseWhereStatement::pool_size = 5;
   96524             : #else
   96525             : const unsigned SgElseWhereStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   96526             : #endif
   96527             : 
   96528             : #ifndef ROSE_ALLOC_MEMSET
   96529             : #  define ROSE_ALLOC_MEMSET 0
   96530             : #endif
   96531             : 
   96532             : #ifndef ROSE_PEDANTIC_ALLOC
   96533             : #  define ROSE_PEDANTIC_ALLOC 0
   96534             : #endif
   96535             : 
   96536             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   96537             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   96538             : #endif
   96539             : 
   96540             : #if !defined(SGNODE__ALL_POOLS)
   96541             : #define SGNODE__ALL_POOLS
   96542             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   96543             : #endif
   96544             : 
   96545             : SgElseWhereStatement* SgElseWhereStatement::next_node = nullptr;
   96546             : std::vector<unsigned char*> SgElseWhereStatement::pools;
   96547             : 
   96548             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   96549             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   96550             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   96551             : // around this macro definition rather than each use).
   96552             : #ifndef ALLOC_MUTEX
   96553             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   96554             :         do {                                                                     \
   96555             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   96556             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   96557             :                 abort();                                                         \
   96558             :             }                                                                    \
   96559             :         } while (0);
   96560             : #endif
   96561             : 
   96562             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   96563             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   96564             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   96565             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   96566             : 
   96567             : /*! \brief New operator for SgElseWhereStatement.
   96568             : 
   96569             :    This new operator implements memory pools to provide most efficent 
   96570             :    use of the heap within construction of large ASTs.
   96571             : 
   96572             : \internal The new and delete operators use the lower level C malloc/free
   96573             :    function calls for performance and to make sure that mixing of malloc/free
   96574             :    and new/delete by the used can be caught more readily.  This may change
   96575             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   96576             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   96577             :    deallocate memory allocated using ROSE_MALLOC.
   96578             : */
   96579           0 : void *SgElseWhereStatement::operator new ( size_t Size )
   96580             : {
   96581             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   96582             :      * returning or throwing an exception. */
   96583           0 :     ALLOC_MUTEX(SgElseWhereStatement, lock);
   96584             : 
   96585             : #if ROSE_ALLOC_TRACE == 2
   96586             : //    printf("SgElseWhereStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgElseWhereStatement::next_node);
   96587             : #endif
   96588             : 
   96589             : #if USE_CPP_NEW_DELETE_OPERATORS
   96590             :     void *mem = ROSE_MALLOC(Size);
   96591             :     ALLOC_MUTEX(SgElseWhereStatement, unlock);
   96592             :     return mem;
   96593             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   96594             : #if ROSE_PEDANTIC_ALLOC
   96595             :     ROSE_ASSERT(Size == sizeof(SgElseWhereStatement));
   96596             : #else
   96597           0 :     if (Size != sizeof(SgElseWhereStatement)) {
   96598           0 :       void * object = ROSE_MALLOC(Size);
   96599           0 :       ALLOC_MUTEX(SgElseWhereStatement, unlock);
   96600             :       return object;
   96601             :     }
   96602             : #endif
   96603             : 
   96604           0 :     if (SgElseWhereStatement::next_node == nullptr) {
   96605           0 :         SgElseWhereStatement * alloc = (SgElseWhereStatement*) ROSE_MALLOC ( SgElseWhereStatement::pool_size * sizeof(SgElseWhereStatement) );
   96606           0 :         ROSE_ASSERT(alloc != nullptr);
   96607             : 
   96608             : #if ROSE_ALLOC_TRACE == 2
   96609             : //        printf("SgElseWhereStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgElseWhereStatement::pools.size(), alloc, alloc + SgElseWhereStatement::pool_size);
   96610             : #endif
   96611             : 
   96612             : #if ROSE_ALLOC_MEMSET == 1
   96613             : #elif ROSE_ALLOC_MEMSET == 2
   96614             :         memset(alloc, 0x00, SgElseWhereStatement::pool_size * sizeof(SgElseWhereStatement));
   96615             : #elif ROSE_ALLOC_MEMSET == 3
   96616             :         memset(alloc, 0xAA, SgElseWhereStatement::pool_size * sizeof(SgElseWhereStatement));
   96617             : #endif
   96618           0 :         for (unsigned i=0; i < SgElseWhereStatement::pool_size-1; i++) {
   96619           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
   96620             :         }
   96621           0 :         alloc[SgElseWhereStatement::pool_size-1].p_freepointer = nullptr;
   96622             : 
   96623           0 :         SgElseWhereStatement::pools.push_back ( (unsigned char *) alloc );
   96624           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgElseWhereStatement::pool_size * sizeof(SgElseWhereStatement), V_SgElseWhereStatement ) );
   96625           0 :         SgElseWhereStatement::next_node = alloc;
   96626             :     }
   96627           0 :     ROSE_ASSERT(SgElseWhereStatement::next_node != nullptr);
   96628             : 
   96629           0 :     SgElseWhereStatement * object = SgElseWhereStatement::next_node;
   96630           0 :     SgElseWhereStatement::next_node = (SgElseWhereStatement*)(object->p_freepointer);
   96631             : 
   96632             : #if ROSE_ALLOC_TRACE == 2
   96633             :     printf("SgElseWhereStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgElseWhereStatement::next_node);
   96634             : #endif
   96635             : 
   96636           0 :     SgNode * fp = object->p_freepointer;
   96637             : #if ROSE_ALLOC_MEMSET == 1
   96638             : #elif ROSE_ALLOC_MEMSET == 2
   96639             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgElseWhereStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   96640             : #elif ROSE_ALLOC_MEMSET == 3
   96641             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgElseWhereStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   96642             : #endif
   96643           0 :     object->p_freepointer = fp;
   96644             : 
   96645             : #if ROSE_ALLOC_TRACE == 2
   96646             : //    printf("SgElseWhereStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgElseWhereStatement::next_node);
   96647             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   96648             :     Rose::MemPool::snapshot(oss.str());
   96649             :     alloc_trace_cnt++;
   96650             : #endif
   96651             : 
   96652           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   96653             : 
   96654           0 :     ALLOC_MUTEX(SgElseWhereStatement, unlock);
   96655             : 
   96656             :     return object;
   96657             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   96658             : }
   96659             : 
   96660             : 
   96661             : 
   96662             : /*! \brief Delete operator for SgElseWhereStatement.
   96663             : 
   96664             :    This delete operator implements deallocation using memory pools to 
   96665             :    provide most efficent use of the heap within construction of large ASTs.
   96666             : 
   96667             : \internal The new and delete operators use the lower level C malloc/free
   96668             :    function calls for performance and to make sure that mixing of malloc/free
   96669             :    and new/delete by the used can be caught more readily.  This may change
   96670             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   96671             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   96672             :    deallocate memory allocated using ROSE_MALLOC.
   96673             : */
   96674           0 : void SgElseWhereStatement::operator delete(void *Pointer, size_t Size)
   96675             : {
   96676             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   96677             :      * or throwing an exception. */
   96678           0 :     ALLOC_MUTEX(SgElseWhereStatement, lock);
   96679             : 
   96680             : #if USE_CPP_NEW_DELETE_OPERATORS
   96681             :     ROSE_FREE(Pointer);
   96682             : #else
   96683             : #if ROSE_PEDANTIC_ALLOC
   96684             :     ROSE_ASSERT(Size == sizeof(SgElseWhereStatement));
   96685             : #else
   96686           0 :     if (Size != sizeof(SgElseWhereStatement)) {
   96687           0 :       ROSE_FREE(Pointer);
   96688           0 :       ALLOC_MUTEX(SgElseWhereStatement, unlock);
   96689             :       return;
   96690             :     }
   96691             : #endif
   96692             : 
   96693           0 :     SgElseWhereStatement * object = (SgElseWhereStatement*) Pointer;
   96694           0 :     ROSE_ASSERT(object != nullptr);
   96695             : 
   96696             : #if ROSE_ALLOC_TRACE == 2
   96697             : //  printf("SgElseWhereStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgElseWhereStatement::next_node);
   96698             :     printf("SgElseWhereStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgElseWhereStatement::next_node);
   96699             : #endif
   96700             : 
   96701             : #if ROSE_PEDANTIC_ALLOC
   96702             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   96703             : #endif
   96704             : 
   96705             : #if ROSE_ALLOC_MEMSET == 1
   96706             : #elif ROSE_ALLOC_MEMSET == 2
   96707             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgElseWhereStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   96708             : #elif ROSE_ALLOC_MEMSET == 3
   96709             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgElseWhereStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   96710             : #endif
   96711             : 
   96712             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   96713             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   96714             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   96715             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   96716             : #else
   96717           0 :     object->p_freepointer = SgElseWhereStatement::next_node;
   96718           0 :     SgElseWhereStatement::next_node = object;
   96719             : #endif
   96720             : 
   96721             : #if ROSE_ALLOC_TRACE == 2
   96722             : //  printf("SgElseWhereStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgElseWhereStatement::next_node);
   96723             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   96724             :     Rose::MemPool::snapshot(oss.str());
   96725             :     alloc_trace_cnt++;
   96726             : #endif
   96727             : 
   96728             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   96729             : 
   96730           0 :     ALLOC_MUTEX(SgElseWhereStatement, unlock);
   96731             : }
   96732             : 
   96733             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   96734             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   96735             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   96736             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   96737             : // Also, note comment below from Robb (copied from the Common.code file).
   96738             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   96739             : //
   96740             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   96741             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   96742             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   96743             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   96744             : #if 0
   96745             : void SgElseWhereStatement::operator delete(void* pointer) { SgElseWhereStatement::operator delete (pointer, sizeof(SgElseWhereStatement)); };
   96746             : #endif
   96747             : /* #line 96748 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   96748             : 
   96749             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   96750             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   96751             : // obviously imply C++.
   96752             : 
   96753             : // This implements the support within ROSE for memory pools.  Memory pools
   96754             : // support the most condensed usage of memory within the construction of
   96755             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   96756             : // by a new operator written for each class.
   96757             : 
   96758             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   96759             :     // User wants multi-thread support and POSIX threads are available.
   96760             : #   include <pthread.h>
   96761             :     static pthread_mutex_t SgNullifyStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   96762             : #else
   96763             :      // Cause synchronization to be skipped.
   96764             : #    ifndef ALLOC_MUTEX
   96765             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   96766             : #    endif
   96767             : #    ifdef _REENTRANT
   96768             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   96769             : #       ifdef _MSC_VER
   96770             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   96771             : #       else
   96772             : #           warning "POSIX threads are not available; synchronization being skipped"
   96773             : #       endif
   96774             : #    endif
   96775             : #endif
   96776             : 
   96777             : #ifndef ROSE_ALLOC_TRACE
   96778             : #  define ROSE_ALLOC_TRACE 0
   96779             : #endif
   96780             : 
   96781             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   96782             : #define ROSE_ALLOC_TRACE_CNT
   96783             : #include "memory-pool-snapshot.h"
   96784             : unsigned long alloc_trace_cnt = 0;
   96785             : #endif
   96786             : 
   96787             : #if ROSE_ALLOC_TRACE
   96788             : const unsigned SgNullifyStatement::pool_size = 5;
   96789             : #else
   96790             : const unsigned SgNullifyStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   96791             : #endif
   96792             : 
   96793             : #ifndef ROSE_ALLOC_MEMSET
   96794             : #  define ROSE_ALLOC_MEMSET 0
   96795             : #endif
   96796             : 
   96797             : #ifndef ROSE_PEDANTIC_ALLOC
   96798             : #  define ROSE_PEDANTIC_ALLOC 0
   96799             : #endif
   96800             : 
   96801             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   96802             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   96803             : #endif
   96804             : 
   96805             : #if !defined(SGNODE__ALL_POOLS)
   96806             : #define SGNODE__ALL_POOLS
   96807             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   96808             : #endif
   96809             : 
   96810             : SgNullifyStatement* SgNullifyStatement::next_node = nullptr;
   96811             : std::vector<unsigned char*> SgNullifyStatement::pools;
   96812             : 
   96813             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   96814             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   96815             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   96816             : // around this macro definition rather than each use).
   96817             : #ifndef ALLOC_MUTEX
   96818             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   96819             :         do {                                                                     \
   96820             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   96821             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   96822             :                 abort();                                                         \
   96823             :             }                                                                    \
   96824             :         } while (0);
   96825             : #endif
   96826             : 
   96827             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   96828             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   96829             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   96830             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   96831             : 
   96832             : /*! \brief New operator for SgNullifyStatement.
   96833             : 
   96834             :    This new operator implements memory pools to provide most efficent 
   96835             :    use of the heap within construction of large ASTs.
   96836             : 
   96837             : \internal The new and delete operators use the lower level C malloc/free
   96838             :    function calls for performance and to make sure that mixing of malloc/free
   96839             :    and new/delete by the used can be caught more readily.  This may change
   96840             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   96841             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   96842             :    deallocate memory allocated using ROSE_MALLOC.
   96843             : */
   96844           0 : void *SgNullifyStatement::operator new ( size_t Size )
   96845             : {
   96846             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   96847             :      * returning or throwing an exception. */
   96848           0 :     ALLOC_MUTEX(SgNullifyStatement, lock);
   96849             : 
   96850             : #if ROSE_ALLOC_TRACE == 2
   96851             : //    printf("SgNullifyStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgNullifyStatement::next_node);
   96852             : #endif
   96853             : 
   96854             : #if USE_CPP_NEW_DELETE_OPERATORS
   96855             :     void *mem = ROSE_MALLOC(Size);
   96856             :     ALLOC_MUTEX(SgNullifyStatement, unlock);
   96857             :     return mem;
   96858             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   96859             : #if ROSE_PEDANTIC_ALLOC
   96860             :     ROSE_ASSERT(Size == sizeof(SgNullifyStatement));
   96861             : #else
   96862           0 :     if (Size != sizeof(SgNullifyStatement)) {
   96863           0 :       void * object = ROSE_MALLOC(Size);
   96864           0 :       ALLOC_MUTEX(SgNullifyStatement, unlock);
   96865             :       return object;
   96866             :     }
   96867             : #endif
   96868             : 
   96869           0 :     if (SgNullifyStatement::next_node == nullptr) {
   96870           0 :         SgNullifyStatement * alloc = (SgNullifyStatement*) ROSE_MALLOC ( SgNullifyStatement::pool_size * sizeof(SgNullifyStatement) );
   96871           0 :         ROSE_ASSERT(alloc != nullptr);
   96872             : 
   96873             : #if ROSE_ALLOC_TRACE == 2
   96874             : //        printf("SgNullifyStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgNullifyStatement::pools.size(), alloc, alloc + SgNullifyStatement::pool_size);
   96875             : #endif
   96876             : 
   96877             : #if ROSE_ALLOC_MEMSET == 1
   96878             : #elif ROSE_ALLOC_MEMSET == 2
   96879             :         memset(alloc, 0x00, SgNullifyStatement::pool_size * sizeof(SgNullifyStatement));
   96880             : #elif ROSE_ALLOC_MEMSET == 3
   96881             :         memset(alloc, 0xAA, SgNullifyStatement::pool_size * sizeof(SgNullifyStatement));
   96882             : #endif
   96883           0 :         for (unsigned i=0; i < SgNullifyStatement::pool_size-1; i++) {
   96884           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
   96885             :         }
   96886           0 :         alloc[SgNullifyStatement::pool_size-1].p_freepointer = nullptr;
   96887             : 
   96888           0 :         SgNullifyStatement::pools.push_back ( (unsigned char *) alloc );
   96889           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgNullifyStatement::pool_size * sizeof(SgNullifyStatement), V_SgNullifyStatement ) );
   96890           0 :         SgNullifyStatement::next_node = alloc;
   96891             :     }
   96892           0 :     ROSE_ASSERT(SgNullifyStatement::next_node != nullptr);
   96893             : 
   96894           0 :     SgNullifyStatement * object = SgNullifyStatement::next_node;
   96895           0 :     SgNullifyStatement::next_node = (SgNullifyStatement*)(object->p_freepointer);
   96896             : 
   96897             : #if ROSE_ALLOC_TRACE == 2
   96898             :     printf("SgNullifyStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgNullifyStatement::next_node);
   96899             : #endif
   96900             : 
   96901           0 :     SgNode * fp = object->p_freepointer;
   96902             : #if ROSE_ALLOC_MEMSET == 1
   96903             : #elif ROSE_ALLOC_MEMSET == 2
   96904             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgNullifyStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   96905             : #elif ROSE_ALLOC_MEMSET == 3
   96906             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgNullifyStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   96907             : #endif
   96908           0 :     object->p_freepointer = fp;
   96909             : 
   96910             : #if ROSE_ALLOC_TRACE == 2
   96911             : //    printf("SgNullifyStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgNullifyStatement::next_node);
   96912             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   96913             :     Rose::MemPool::snapshot(oss.str());
   96914             :     alloc_trace_cnt++;
   96915             : #endif
   96916             : 
   96917           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   96918             : 
   96919           0 :     ALLOC_MUTEX(SgNullifyStatement, unlock);
   96920             : 
   96921             :     return object;
   96922             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   96923             : }
   96924             : 
   96925             : 
   96926             : 
   96927             : /*! \brief Delete operator for SgNullifyStatement.
   96928             : 
   96929             :    This delete operator implements deallocation using memory pools to 
   96930             :    provide most efficent use of the heap within construction of large ASTs.
   96931             : 
   96932             : \internal The new and delete operators use the lower level C malloc/free
   96933             :    function calls for performance and to make sure that mixing of malloc/free
   96934             :    and new/delete by the used can be caught more readily.  This may change
   96935             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   96936             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   96937             :    deallocate memory allocated using ROSE_MALLOC.
   96938             : */
   96939           0 : void SgNullifyStatement::operator delete(void *Pointer, size_t Size)
   96940             : {
   96941             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   96942             :      * or throwing an exception. */
   96943           0 :     ALLOC_MUTEX(SgNullifyStatement, lock);
   96944             : 
   96945             : #if USE_CPP_NEW_DELETE_OPERATORS
   96946             :     ROSE_FREE(Pointer);
   96947             : #else
   96948             : #if ROSE_PEDANTIC_ALLOC
   96949             :     ROSE_ASSERT(Size == sizeof(SgNullifyStatement));
   96950             : #else
   96951           0 :     if (Size != sizeof(SgNullifyStatement)) {
   96952           0 :       ROSE_FREE(Pointer);
   96953           0 :       ALLOC_MUTEX(SgNullifyStatement, unlock);
   96954             :       return;
   96955             :     }
   96956             : #endif
   96957             : 
   96958           0 :     SgNullifyStatement * object = (SgNullifyStatement*) Pointer;
   96959           0 :     ROSE_ASSERT(object != nullptr);
   96960             : 
   96961             : #if ROSE_ALLOC_TRACE == 2
   96962             : //  printf("SgNullifyStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgNullifyStatement::next_node);
   96963             :     printf("SgNullifyStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgNullifyStatement::next_node);
   96964             : #endif
   96965             : 
   96966             : #if ROSE_PEDANTIC_ALLOC
   96967             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   96968             : #endif
   96969             : 
   96970             : #if ROSE_ALLOC_MEMSET == 1
   96971             : #elif ROSE_ALLOC_MEMSET == 2
   96972             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgNullifyStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   96973             : #elif ROSE_ALLOC_MEMSET == 3
   96974             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgNullifyStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   96975             : #endif
   96976             : 
   96977             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   96978             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   96979             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   96980             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   96981             : #else
   96982           0 :     object->p_freepointer = SgNullifyStatement::next_node;
   96983           0 :     SgNullifyStatement::next_node = object;
   96984             : #endif
   96985             : 
   96986             : #if ROSE_ALLOC_TRACE == 2
   96987             : //  printf("SgNullifyStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgNullifyStatement::next_node);
   96988             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   96989             :     Rose::MemPool::snapshot(oss.str());
   96990             :     alloc_trace_cnt++;
   96991             : #endif
   96992             : 
   96993             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   96994             : 
   96995           0 :     ALLOC_MUTEX(SgNullifyStatement, unlock);
   96996             : }
   96997             : 
   96998             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   96999             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   97000             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   97001             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   97002             : // Also, note comment below from Robb (copied from the Common.code file).
   97003             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   97004             : //
   97005             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   97006             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   97007             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   97008             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   97009             : #if 0
   97010             : void SgNullifyStatement::operator delete(void* pointer) { SgNullifyStatement::operator delete (pointer, sizeof(SgNullifyStatement)); };
   97011             : #endif
   97012             : /* #line 97013 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   97013             : 
   97014             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   97015             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   97016             : // obviously imply C++.
   97017             : 
   97018             : // This implements the support within ROSE for memory pools.  Memory pools
   97019             : // support the most condensed usage of memory within the construction of
   97020             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   97021             : // by a new operator written for each class.
   97022             : 
   97023             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   97024             :     // User wants multi-thread support and POSIX threads are available.
   97025             : #   include <pthread.h>
   97026             :     static pthread_mutex_t SgArithmeticIfStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   97027             : #else
   97028             :      // Cause synchronization to be skipped.
   97029             : #    ifndef ALLOC_MUTEX
   97030             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   97031             : #    endif
   97032             : #    ifdef _REENTRANT
   97033             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   97034             : #       ifdef _MSC_VER
   97035             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   97036             : #       else
   97037             : #           warning "POSIX threads are not available; synchronization being skipped"
   97038             : #       endif
   97039             : #    endif
   97040             : #endif
   97041             : 
   97042             : #ifndef ROSE_ALLOC_TRACE
   97043             : #  define ROSE_ALLOC_TRACE 0
   97044             : #endif
   97045             : 
   97046             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   97047             : #define ROSE_ALLOC_TRACE_CNT
   97048             : #include "memory-pool-snapshot.h"
   97049             : unsigned long alloc_trace_cnt = 0;
   97050             : #endif
   97051             : 
   97052             : #if ROSE_ALLOC_TRACE
   97053             : const unsigned SgArithmeticIfStatement::pool_size = 5;
   97054             : #else
   97055             : const unsigned SgArithmeticIfStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   97056             : #endif
   97057             : 
   97058             : #ifndef ROSE_ALLOC_MEMSET
   97059             : #  define ROSE_ALLOC_MEMSET 0
   97060             : #endif
   97061             : 
   97062             : #ifndef ROSE_PEDANTIC_ALLOC
   97063             : #  define ROSE_PEDANTIC_ALLOC 0
   97064             : #endif
   97065             : 
   97066             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   97067             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   97068             : #endif
   97069             : 
   97070             : #if !defined(SGNODE__ALL_POOLS)
   97071             : #define SGNODE__ALL_POOLS
   97072             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   97073             : #endif
   97074             : 
   97075             : SgArithmeticIfStatement* SgArithmeticIfStatement::next_node = nullptr;
   97076             : std::vector<unsigned char*> SgArithmeticIfStatement::pools;
   97077             : 
   97078             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   97079             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   97080             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   97081             : // around this macro definition rather than each use).
   97082             : #ifndef ALLOC_MUTEX
   97083             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   97084             :         do {                                                                     \
   97085             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   97086             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   97087             :                 abort();                                                         \
   97088             :             }                                                                    \
   97089             :         } while (0);
   97090             : #endif
   97091             : 
   97092             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   97093             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   97094             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   97095             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   97096             : 
   97097             : /*! \brief New operator for SgArithmeticIfStatement.
   97098             : 
   97099             :    This new operator implements memory pools to provide most efficent 
   97100             :    use of the heap within construction of large ASTs.
   97101             : 
   97102             : \internal The new and delete operators use the lower level C malloc/free
   97103             :    function calls for performance and to make sure that mixing of malloc/free
   97104             :    and new/delete by the used can be caught more readily.  This may change
   97105             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   97106             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   97107             :    deallocate memory allocated using ROSE_MALLOC.
   97108             : */
   97109           0 : void *SgArithmeticIfStatement::operator new ( size_t Size )
   97110             : {
   97111             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   97112             :      * returning or throwing an exception. */
   97113           0 :     ALLOC_MUTEX(SgArithmeticIfStatement, lock);
   97114             : 
   97115             : #if ROSE_ALLOC_TRACE == 2
   97116             : //    printf("SgArithmeticIfStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgArithmeticIfStatement::next_node);
   97117             : #endif
   97118             : 
   97119             : #if USE_CPP_NEW_DELETE_OPERATORS
   97120             :     void *mem = ROSE_MALLOC(Size);
   97121             :     ALLOC_MUTEX(SgArithmeticIfStatement, unlock);
   97122             :     return mem;
   97123             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   97124             : #if ROSE_PEDANTIC_ALLOC
   97125             :     ROSE_ASSERT(Size == sizeof(SgArithmeticIfStatement));
   97126             : #else
   97127           0 :     if (Size != sizeof(SgArithmeticIfStatement)) {
   97128           0 :       void * object = ROSE_MALLOC(Size);
   97129           0 :       ALLOC_MUTEX(SgArithmeticIfStatement, unlock);
   97130             :       return object;
   97131             :     }
   97132             : #endif
   97133             : 
   97134           0 :     if (SgArithmeticIfStatement::next_node == nullptr) {
   97135           0 :         SgArithmeticIfStatement * alloc = (SgArithmeticIfStatement*) ROSE_MALLOC ( SgArithmeticIfStatement::pool_size * sizeof(SgArithmeticIfStatement) );
   97136           0 :         ROSE_ASSERT(alloc != nullptr);
   97137             : 
   97138             : #if ROSE_ALLOC_TRACE == 2
   97139             : //        printf("SgArithmeticIfStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgArithmeticIfStatement::pools.size(), alloc, alloc + SgArithmeticIfStatement::pool_size);
   97140             : #endif
   97141             : 
   97142             : #if ROSE_ALLOC_MEMSET == 1
   97143             : #elif ROSE_ALLOC_MEMSET == 2
   97144             :         memset(alloc, 0x00, SgArithmeticIfStatement::pool_size * sizeof(SgArithmeticIfStatement));
   97145             : #elif ROSE_ALLOC_MEMSET == 3
   97146             :         memset(alloc, 0xAA, SgArithmeticIfStatement::pool_size * sizeof(SgArithmeticIfStatement));
   97147             : #endif
   97148           0 :         for (unsigned i=0; i < SgArithmeticIfStatement::pool_size-1; i++) {
   97149           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
   97150             :         }
   97151           0 :         alloc[SgArithmeticIfStatement::pool_size-1].p_freepointer = nullptr;
   97152             : 
   97153           0 :         SgArithmeticIfStatement::pools.push_back ( (unsigned char *) alloc );
   97154           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgArithmeticIfStatement::pool_size * sizeof(SgArithmeticIfStatement), V_SgArithmeticIfStatement ) );
   97155           0 :         SgArithmeticIfStatement::next_node = alloc;
   97156             :     }
   97157           0 :     ROSE_ASSERT(SgArithmeticIfStatement::next_node != nullptr);
   97158             : 
   97159           0 :     SgArithmeticIfStatement * object = SgArithmeticIfStatement::next_node;
   97160           0 :     SgArithmeticIfStatement::next_node = (SgArithmeticIfStatement*)(object->p_freepointer);
   97161             : 
   97162             : #if ROSE_ALLOC_TRACE == 2
   97163             :     printf("SgArithmeticIfStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgArithmeticIfStatement::next_node);
   97164             : #endif
   97165             : 
   97166           0 :     SgNode * fp = object->p_freepointer;
   97167             : #if ROSE_ALLOC_MEMSET == 1
   97168             : #elif ROSE_ALLOC_MEMSET == 2
   97169             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgArithmeticIfStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   97170             : #elif ROSE_ALLOC_MEMSET == 3
   97171             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgArithmeticIfStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   97172             : #endif
   97173           0 :     object->p_freepointer = fp;
   97174             : 
   97175             : #if ROSE_ALLOC_TRACE == 2
   97176             : //    printf("SgArithmeticIfStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgArithmeticIfStatement::next_node);
   97177             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   97178             :     Rose::MemPool::snapshot(oss.str());
   97179             :     alloc_trace_cnt++;
   97180             : #endif
   97181             : 
   97182           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   97183             : 
   97184           0 :     ALLOC_MUTEX(SgArithmeticIfStatement, unlock);
   97185             : 
   97186             :     return object;
   97187             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   97188             : }
   97189             : 
   97190             : 
   97191             : 
   97192             : /*! \brief Delete operator for SgArithmeticIfStatement.
   97193             : 
   97194             :    This delete operator implements deallocation using memory pools to 
   97195             :    provide most efficent use of the heap within construction of large ASTs.
   97196             : 
   97197             : \internal The new and delete operators use the lower level C malloc/free
   97198             :    function calls for performance and to make sure that mixing of malloc/free
   97199             :    and new/delete by the used can be caught more readily.  This may change
   97200             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   97201             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   97202             :    deallocate memory allocated using ROSE_MALLOC.
   97203             : */
   97204           0 : void SgArithmeticIfStatement::operator delete(void *Pointer, size_t Size)
   97205             : {
   97206             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   97207             :      * or throwing an exception. */
   97208           0 :     ALLOC_MUTEX(SgArithmeticIfStatement, lock);
   97209             : 
   97210             : #if USE_CPP_NEW_DELETE_OPERATORS
   97211             :     ROSE_FREE(Pointer);
   97212             : #else
   97213             : #if ROSE_PEDANTIC_ALLOC
   97214             :     ROSE_ASSERT(Size == sizeof(SgArithmeticIfStatement));
   97215             : #else
   97216           0 :     if (Size != sizeof(SgArithmeticIfStatement)) {
   97217           0 :       ROSE_FREE(Pointer);
   97218           0 :       ALLOC_MUTEX(SgArithmeticIfStatement, unlock);
   97219             :       return;
   97220             :     }
   97221             : #endif
   97222             : 
   97223           0 :     SgArithmeticIfStatement * object = (SgArithmeticIfStatement*) Pointer;
   97224           0 :     ROSE_ASSERT(object != nullptr);
   97225             : 
   97226             : #if ROSE_ALLOC_TRACE == 2
   97227             : //  printf("SgArithmeticIfStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgArithmeticIfStatement::next_node);
   97228             :     printf("SgArithmeticIfStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgArithmeticIfStatement::next_node);
   97229             : #endif
   97230             : 
   97231             : #if ROSE_PEDANTIC_ALLOC
   97232             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   97233             : #endif
   97234             : 
   97235             : #if ROSE_ALLOC_MEMSET == 1
   97236             : #elif ROSE_ALLOC_MEMSET == 2
   97237             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgArithmeticIfStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   97238             : #elif ROSE_ALLOC_MEMSET == 3
   97239             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgArithmeticIfStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   97240             : #endif
   97241             : 
   97242             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   97243             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   97244             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   97245             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   97246             : #else
   97247           0 :     object->p_freepointer = SgArithmeticIfStatement::next_node;
   97248           0 :     SgArithmeticIfStatement::next_node = object;
   97249             : #endif
   97250             : 
   97251             : #if ROSE_ALLOC_TRACE == 2
   97252             : //  printf("SgArithmeticIfStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgArithmeticIfStatement::next_node);
   97253             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   97254             :     Rose::MemPool::snapshot(oss.str());
   97255             :     alloc_trace_cnt++;
   97256             : #endif
   97257             : 
   97258             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   97259             : 
   97260           0 :     ALLOC_MUTEX(SgArithmeticIfStatement, unlock);
   97261             : }
   97262             : 
   97263             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   97264             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   97265             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   97266             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   97267             : // Also, note comment below from Robb (copied from the Common.code file).
   97268             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   97269             : //
   97270             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   97271             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   97272             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   97273             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   97274             : #if 0
   97275             : void SgArithmeticIfStatement::operator delete(void* pointer) { SgArithmeticIfStatement::operator delete (pointer, sizeof(SgArithmeticIfStatement)); };
   97276             : #endif
   97277             : /* #line 97278 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   97278             : 
   97279             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   97280             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   97281             : // obviously imply C++.
   97282             : 
   97283             : // This implements the support within ROSE for memory pools.  Memory pools
   97284             : // support the most condensed usage of memory within the construction of
   97285             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   97286             : // by a new operator written for each class.
   97287             : 
   97288             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   97289             :     // User wants multi-thread support and POSIX threads are available.
   97290             : #   include <pthread.h>
   97291             :     static pthread_mutex_t SgAssignStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   97292             : #else
   97293             :      // Cause synchronization to be skipped.
   97294             : #    ifndef ALLOC_MUTEX
   97295             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   97296             : #    endif
   97297             : #    ifdef _REENTRANT
   97298             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   97299             : #       ifdef _MSC_VER
   97300             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   97301             : #       else
   97302             : #           warning "POSIX threads are not available; synchronization being skipped"
   97303             : #       endif
   97304             : #    endif
   97305             : #endif
   97306             : 
   97307             : #ifndef ROSE_ALLOC_TRACE
   97308             : #  define ROSE_ALLOC_TRACE 0
   97309             : #endif
   97310             : 
   97311             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   97312             : #define ROSE_ALLOC_TRACE_CNT
   97313             : #include "memory-pool-snapshot.h"
   97314             : unsigned long alloc_trace_cnt = 0;
   97315             : #endif
   97316             : 
   97317             : #if ROSE_ALLOC_TRACE
   97318             : const unsigned SgAssignStatement::pool_size = 5;
   97319             : #else
   97320             : const unsigned SgAssignStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   97321             : #endif
   97322             : 
   97323             : #ifndef ROSE_ALLOC_MEMSET
   97324             : #  define ROSE_ALLOC_MEMSET 0
   97325             : #endif
   97326             : 
   97327             : #ifndef ROSE_PEDANTIC_ALLOC
   97328             : #  define ROSE_PEDANTIC_ALLOC 0
   97329             : #endif
   97330             : 
   97331             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   97332             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   97333             : #endif
   97334             : 
   97335             : #if !defined(SGNODE__ALL_POOLS)
   97336             : #define SGNODE__ALL_POOLS
   97337             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   97338             : #endif
   97339             : 
   97340             : SgAssignStatement* SgAssignStatement::next_node = nullptr;
   97341             : std::vector<unsigned char*> SgAssignStatement::pools;
   97342             : 
   97343             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   97344             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   97345             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   97346             : // around this macro definition rather than each use).
   97347             : #ifndef ALLOC_MUTEX
   97348             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   97349             :         do {                                                                     \
   97350             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   97351             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   97352             :                 abort();                                                         \
   97353             :             }                                                                    \
   97354             :         } while (0);
   97355             : #endif
   97356             : 
   97357             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   97358             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   97359             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   97360             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   97361             : 
   97362             : /*! \brief New operator for SgAssignStatement.
   97363             : 
   97364             :    This new operator implements memory pools to provide most efficent 
   97365             :    use of the heap within construction of large ASTs.
   97366             : 
   97367             : \internal The new and delete operators use the lower level C malloc/free
   97368             :    function calls for performance and to make sure that mixing of malloc/free
   97369             :    and new/delete by the used can be caught more readily.  This may change
   97370             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   97371             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   97372             :    deallocate memory allocated using ROSE_MALLOC.
   97373             : */
   97374           0 : void *SgAssignStatement::operator new ( size_t Size )
   97375             : {
   97376             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   97377             :      * returning or throwing an exception. */
   97378           0 :     ALLOC_MUTEX(SgAssignStatement, lock);
   97379             : 
   97380             : #if ROSE_ALLOC_TRACE == 2
   97381             : //    printf("SgAssignStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgAssignStatement::next_node);
   97382             : #endif
   97383             : 
   97384             : #if USE_CPP_NEW_DELETE_OPERATORS
   97385             :     void *mem = ROSE_MALLOC(Size);
   97386             :     ALLOC_MUTEX(SgAssignStatement, unlock);
   97387             :     return mem;
   97388             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   97389             : #if ROSE_PEDANTIC_ALLOC
   97390             :     ROSE_ASSERT(Size == sizeof(SgAssignStatement));
   97391             : #else
   97392           0 :     if (Size != sizeof(SgAssignStatement)) {
   97393           0 :       void * object = ROSE_MALLOC(Size);
   97394           0 :       ALLOC_MUTEX(SgAssignStatement, unlock);
   97395             :       return object;
   97396             :     }
   97397             : #endif
   97398             : 
   97399           0 :     if (SgAssignStatement::next_node == nullptr) {
   97400           0 :         SgAssignStatement * alloc = (SgAssignStatement*) ROSE_MALLOC ( SgAssignStatement::pool_size * sizeof(SgAssignStatement) );
   97401           0 :         ROSE_ASSERT(alloc != nullptr);
   97402             : 
   97403             : #if ROSE_ALLOC_TRACE == 2
   97404             : //        printf("SgAssignStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgAssignStatement::pools.size(), alloc, alloc + SgAssignStatement::pool_size);
   97405             : #endif
   97406             : 
   97407             : #if ROSE_ALLOC_MEMSET == 1
   97408             : #elif ROSE_ALLOC_MEMSET == 2
   97409             :         memset(alloc, 0x00, SgAssignStatement::pool_size * sizeof(SgAssignStatement));
   97410             : #elif ROSE_ALLOC_MEMSET == 3
   97411             :         memset(alloc, 0xAA, SgAssignStatement::pool_size * sizeof(SgAssignStatement));
   97412             : #endif
   97413           0 :         for (unsigned i=0; i < SgAssignStatement::pool_size-1; i++) {
   97414           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
   97415             :         }
   97416           0 :         alloc[SgAssignStatement::pool_size-1].p_freepointer = nullptr;
   97417             : 
   97418           0 :         SgAssignStatement::pools.push_back ( (unsigned char *) alloc );
   97419           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgAssignStatement::pool_size * sizeof(SgAssignStatement), V_SgAssignStatement ) );
   97420           0 :         SgAssignStatement::next_node = alloc;
   97421             :     }
   97422           0 :     ROSE_ASSERT(SgAssignStatement::next_node != nullptr);
   97423             : 
   97424           0 :     SgAssignStatement * object = SgAssignStatement::next_node;
   97425           0 :     SgAssignStatement::next_node = (SgAssignStatement*)(object->p_freepointer);
   97426             : 
   97427             : #if ROSE_ALLOC_TRACE == 2
   97428             :     printf("SgAssignStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgAssignStatement::next_node);
   97429             : #endif
   97430             : 
   97431           0 :     SgNode * fp = object->p_freepointer;
   97432             : #if ROSE_ALLOC_MEMSET == 1
   97433             : #elif ROSE_ALLOC_MEMSET == 2
   97434             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgAssignStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   97435             : #elif ROSE_ALLOC_MEMSET == 3
   97436             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgAssignStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   97437             : #endif
   97438           0 :     object->p_freepointer = fp;
   97439             : 
   97440             : #if ROSE_ALLOC_TRACE == 2
   97441             : //    printf("SgAssignStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgAssignStatement::next_node);
   97442             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   97443             :     Rose::MemPool::snapshot(oss.str());
   97444             :     alloc_trace_cnt++;
   97445             : #endif
   97446             : 
   97447           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   97448             : 
   97449           0 :     ALLOC_MUTEX(SgAssignStatement, unlock);
   97450             : 
   97451             :     return object;
   97452             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   97453             : }
   97454             : 
   97455             : 
   97456             : 
   97457             : /*! \brief Delete operator for SgAssignStatement.
   97458             : 
   97459             :    This delete operator implements deallocation using memory pools to 
   97460             :    provide most efficent use of the heap within construction of large ASTs.
   97461             : 
   97462             : \internal The new and delete operators use the lower level C malloc/free
   97463             :    function calls for performance and to make sure that mixing of malloc/free
   97464             :    and new/delete by the used can be caught more readily.  This may change
   97465             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   97466             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   97467             :    deallocate memory allocated using ROSE_MALLOC.
   97468             : */
   97469           0 : void SgAssignStatement::operator delete(void *Pointer, size_t Size)
   97470             : {
   97471             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   97472             :      * or throwing an exception. */
   97473           0 :     ALLOC_MUTEX(SgAssignStatement, lock);
   97474             : 
   97475             : #if USE_CPP_NEW_DELETE_OPERATORS
   97476             :     ROSE_FREE(Pointer);
   97477             : #else
   97478             : #if ROSE_PEDANTIC_ALLOC
   97479             :     ROSE_ASSERT(Size == sizeof(SgAssignStatement));
   97480             : #else
   97481           0 :     if (Size != sizeof(SgAssignStatement)) {
   97482           0 :       ROSE_FREE(Pointer);
   97483           0 :       ALLOC_MUTEX(SgAssignStatement, unlock);
   97484             :       return;
   97485             :     }
   97486             : #endif
   97487             : 
   97488           0 :     SgAssignStatement * object = (SgAssignStatement*) Pointer;
   97489           0 :     ROSE_ASSERT(object != nullptr);
   97490             : 
   97491             : #if ROSE_ALLOC_TRACE == 2
   97492             : //  printf("SgAssignStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgAssignStatement::next_node);
   97493             :     printf("SgAssignStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgAssignStatement::next_node);
   97494             : #endif
   97495             : 
   97496             : #if ROSE_PEDANTIC_ALLOC
   97497             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   97498             : #endif
   97499             : 
   97500             : #if ROSE_ALLOC_MEMSET == 1
   97501             : #elif ROSE_ALLOC_MEMSET == 2
   97502             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgAssignStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   97503             : #elif ROSE_ALLOC_MEMSET == 3
   97504             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgAssignStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   97505             : #endif
   97506             : 
   97507             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   97508             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   97509             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   97510             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   97511             : #else
   97512           0 :     object->p_freepointer = SgAssignStatement::next_node;
   97513           0 :     SgAssignStatement::next_node = object;
   97514             : #endif
   97515             : 
   97516             : #if ROSE_ALLOC_TRACE == 2
   97517             : //  printf("SgAssignStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgAssignStatement::next_node);
   97518             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   97519             :     Rose::MemPool::snapshot(oss.str());
   97520             :     alloc_trace_cnt++;
   97521             : #endif
   97522             : 
   97523             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   97524             : 
   97525           0 :     ALLOC_MUTEX(SgAssignStatement, unlock);
   97526             : }
   97527             : 
   97528             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   97529             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   97530             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   97531             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   97532             : // Also, note comment below from Robb (copied from the Common.code file).
   97533             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   97534             : //
   97535             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   97536             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   97537             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   97538             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   97539             : #if 0
   97540             : void SgAssignStatement::operator delete(void* pointer) { SgAssignStatement::operator delete (pointer, sizeof(SgAssignStatement)); };
   97541             : #endif
   97542             : /* #line 97543 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   97543             : 
   97544             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   97545             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   97546             : // obviously imply C++.
   97547             : 
   97548             : // This implements the support within ROSE for memory pools.  Memory pools
   97549             : // support the most condensed usage of memory within the construction of
   97550             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   97551             : // by a new operator written for each class.
   97552             : 
   97553             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   97554             :     // User wants multi-thread support and POSIX threads are available.
   97555             : #   include <pthread.h>
   97556             :     static pthread_mutex_t SgComputedGotoStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   97557             : #else
   97558             :      // Cause synchronization to be skipped.
   97559             : #    ifndef ALLOC_MUTEX
   97560             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   97561             : #    endif
   97562             : #    ifdef _REENTRANT
   97563             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   97564             : #       ifdef _MSC_VER
   97565             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   97566             : #       else
   97567             : #           warning "POSIX threads are not available; synchronization being skipped"
   97568             : #       endif
   97569             : #    endif
   97570             : #endif
   97571             : 
   97572             : #ifndef ROSE_ALLOC_TRACE
   97573             : #  define ROSE_ALLOC_TRACE 0
   97574             : #endif
   97575             : 
   97576             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   97577             : #define ROSE_ALLOC_TRACE_CNT
   97578             : #include "memory-pool-snapshot.h"
   97579             : unsigned long alloc_trace_cnt = 0;
   97580             : #endif
   97581             : 
   97582             : #if ROSE_ALLOC_TRACE
   97583             : const unsigned SgComputedGotoStatement::pool_size = 5;
   97584             : #else
   97585             : const unsigned SgComputedGotoStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   97586             : #endif
   97587             : 
   97588             : #ifndef ROSE_ALLOC_MEMSET
   97589             : #  define ROSE_ALLOC_MEMSET 0
   97590             : #endif
   97591             : 
   97592             : #ifndef ROSE_PEDANTIC_ALLOC
   97593             : #  define ROSE_PEDANTIC_ALLOC 0
   97594             : #endif
   97595             : 
   97596             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   97597             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   97598             : #endif
   97599             : 
   97600             : #if !defined(SGNODE__ALL_POOLS)
   97601             : #define SGNODE__ALL_POOLS
   97602             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   97603             : #endif
   97604             : 
   97605             : SgComputedGotoStatement* SgComputedGotoStatement::next_node = nullptr;
   97606             : std::vector<unsigned char*> SgComputedGotoStatement::pools;
   97607             : 
   97608             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   97609             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   97610             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   97611             : // around this macro definition rather than each use).
   97612             : #ifndef ALLOC_MUTEX
   97613             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   97614             :         do {                                                                     \
   97615             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   97616             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   97617             :                 abort();                                                         \
   97618             :             }                                                                    \
   97619             :         } while (0);
   97620             : #endif
   97621             : 
   97622             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   97623             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   97624             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   97625             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   97626             : 
   97627             : /*! \brief New operator for SgComputedGotoStatement.
   97628             : 
   97629             :    This new operator implements memory pools to provide most efficent 
   97630             :    use of the heap within construction of large ASTs.
   97631             : 
   97632             : \internal The new and delete operators use the lower level C malloc/free
   97633             :    function calls for performance and to make sure that mixing of malloc/free
   97634             :    and new/delete by the used can be caught more readily.  This may change
   97635             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   97636             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   97637             :    deallocate memory allocated using ROSE_MALLOC.
   97638             : */
   97639           0 : void *SgComputedGotoStatement::operator new ( size_t Size )
   97640             : {
   97641             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   97642             :      * returning or throwing an exception. */
   97643           0 :     ALLOC_MUTEX(SgComputedGotoStatement, lock);
   97644             : 
   97645             : #if ROSE_ALLOC_TRACE == 2
   97646             : //    printf("SgComputedGotoStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgComputedGotoStatement::next_node);
   97647             : #endif
   97648             : 
   97649             : #if USE_CPP_NEW_DELETE_OPERATORS
   97650             :     void *mem = ROSE_MALLOC(Size);
   97651             :     ALLOC_MUTEX(SgComputedGotoStatement, unlock);
   97652             :     return mem;
   97653             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   97654             : #if ROSE_PEDANTIC_ALLOC
   97655             :     ROSE_ASSERT(Size == sizeof(SgComputedGotoStatement));
   97656             : #else
   97657           0 :     if (Size != sizeof(SgComputedGotoStatement)) {
   97658           0 :       void * object = ROSE_MALLOC(Size);
   97659           0 :       ALLOC_MUTEX(SgComputedGotoStatement, unlock);
   97660             :       return object;
   97661             :     }
   97662             : #endif
   97663             : 
   97664           0 :     if (SgComputedGotoStatement::next_node == nullptr) {
   97665           0 :         SgComputedGotoStatement * alloc = (SgComputedGotoStatement*) ROSE_MALLOC ( SgComputedGotoStatement::pool_size * sizeof(SgComputedGotoStatement) );
   97666           0 :         ROSE_ASSERT(alloc != nullptr);
   97667             : 
   97668             : #if ROSE_ALLOC_TRACE == 2
   97669             : //        printf("SgComputedGotoStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgComputedGotoStatement::pools.size(), alloc, alloc + SgComputedGotoStatement::pool_size);
   97670             : #endif
   97671             : 
   97672             : #if ROSE_ALLOC_MEMSET == 1
   97673             : #elif ROSE_ALLOC_MEMSET == 2
   97674             :         memset(alloc, 0x00, SgComputedGotoStatement::pool_size * sizeof(SgComputedGotoStatement));
   97675             : #elif ROSE_ALLOC_MEMSET == 3
   97676             :         memset(alloc, 0xAA, SgComputedGotoStatement::pool_size * sizeof(SgComputedGotoStatement));
   97677             : #endif
   97678           0 :         for (unsigned i=0; i < SgComputedGotoStatement::pool_size-1; i++) {
   97679           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
   97680             :         }
   97681           0 :         alloc[SgComputedGotoStatement::pool_size-1].p_freepointer = nullptr;
   97682             : 
   97683           0 :         SgComputedGotoStatement::pools.push_back ( (unsigned char *) alloc );
   97684           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgComputedGotoStatement::pool_size * sizeof(SgComputedGotoStatement), V_SgComputedGotoStatement ) );
   97685           0 :         SgComputedGotoStatement::next_node = alloc;
   97686             :     }
   97687           0 :     ROSE_ASSERT(SgComputedGotoStatement::next_node != nullptr);
   97688             : 
   97689           0 :     SgComputedGotoStatement * object = SgComputedGotoStatement::next_node;
   97690           0 :     SgComputedGotoStatement::next_node = (SgComputedGotoStatement*)(object->p_freepointer);
   97691             : 
   97692             : #if ROSE_ALLOC_TRACE == 2
   97693             :     printf("SgComputedGotoStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgComputedGotoStatement::next_node);
   97694             : #endif
   97695             : 
   97696           0 :     SgNode * fp = object->p_freepointer;
   97697             : #if ROSE_ALLOC_MEMSET == 1
   97698             : #elif ROSE_ALLOC_MEMSET == 2
   97699             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgComputedGotoStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   97700             : #elif ROSE_ALLOC_MEMSET == 3
   97701             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgComputedGotoStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   97702             : #endif
   97703           0 :     object->p_freepointer = fp;
   97704             : 
   97705             : #if ROSE_ALLOC_TRACE == 2
   97706             : //    printf("SgComputedGotoStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgComputedGotoStatement::next_node);
   97707             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   97708             :     Rose::MemPool::snapshot(oss.str());
   97709             :     alloc_trace_cnt++;
   97710             : #endif
   97711             : 
   97712           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   97713             : 
   97714           0 :     ALLOC_MUTEX(SgComputedGotoStatement, unlock);
   97715             : 
   97716             :     return object;
   97717             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   97718             : }
   97719             : 
   97720             : 
   97721             : 
   97722             : /*! \brief Delete operator for SgComputedGotoStatement.
   97723             : 
   97724             :    This delete operator implements deallocation using memory pools to 
   97725             :    provide most efficent use of the heap within construction of large ASTs.
   97726             : 
   97727             : \internal The new and delete operators use the lower level C malloc/free
   97728             :    function calls for performance and to make sure that mixing of malloc/free
   97729             :    and new/delete by the used can be caught more readily.  This may change
   97730             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   97731             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   97732             :    deallocate memory allocated using ROSE_MALLOC.
   97733             : */
   97734           0 : void SgComputedGotoStatement::operator delete(void *Pointer, size_t Size)
   97735             : {
   97736             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   97737             :      * or throwing an exception. */
   97738           0 :     ALLOC_MUTEX(SgComputedGotoStatement, lock);
   97739             : 
   97740             : #if USE_CPP_NEW_DELETE_OPERATORS
   97741             :     ROSE_FREE(Pointer);
   97742             : #else
   97743             : #if ROSE_PEDANTIC_ALLOC
   97744             :     ROSE_ASSERT(Size == sizeof(SgComputedGotoStatement));
   97745             : #else
   97746           0 :     if (Size != sizeof(SgComputedGotoStatement)) {
   97747           0 :       ROSE_FREE(Pointer);
   97748           0 :       ALLOC_MUTEX(SgComputedGotoStatement, unlock);
   97749             :       return;
   97750             :     }
   97751             : #endif
   97752             : 
   97753           0 :     SgComputedGotoStatement * object = (SgComputedGotoStatement*) Pointer;
   97754           0 :     ROSE_ASSERT(object != nullptr);
   97755             : 
   97756             : #if ROSE_ALLOC_TRACE == 2
   97757             : //  printf("SgComputedGotoStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgComputedGotoStatement::next_node);
   97758             :     printf("SgComputedGotoStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgComputedGotoStatement::next_node);
   97759             : #endif
   97760             : 
   97761             : #if ROSE_PEDANTIC_ALLOC
   97762             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   97763             : #endif
   97764             : 
   97765             : #if ROSE_ALLOC_MEMSET == 1
   97766             : #elif ROSE_ALLOC_MEMSET == 2
   97767             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgComputedGotoStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   97768             : #elif ROSE_ALLOC_MEMSET == 3
   97769             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgComputedGotoStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   97770             : #endif
   97771             : 
   97772             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   97773             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   97774             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   97775             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   97776             : #else
   97777           0 :     object->p_freepointer = SgComputedGotoStatement::next_node;
   97778           0 :     SgComputedGotoStatement::next_node = object;
   97779             : #endif
   97780             : 
   97781             : #if ROSE_ALLOC_TRACE == 2
   97782             : //  printf("SgComputedGotoStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgComputedGotoStatement::next_node);
   97783             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   97784             :     Rose::MemPool::snapshot(oss.str());
   97785             :     alloc_trace_cnt++;
   97786             : #endif
   97787             : 
   97788             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   97789             : 
   97790           0 :     ALLOC_MUTEX(SgComputedGotoStatement, unlock);
   97791             : }
   97792             : 
   97793             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   97794             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   97795             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   97796             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   97797             : // Also, note comment below from Robb (copied from the Common.code file).
   97798             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   97799             : //
   97800             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   97801             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   97802             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   97803             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   97804             : #if 0
   97805             : void SgComputedGotoStatement::operator delete(void* pointer) { SgComputedGotoStatement::operator delete (pointer, sizeof(SgComputedGotoStatement)); };
   97806             : #endif
   97807             : /* #line 97808 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   97808             : 
   97809             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   97810             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   97811             : // obviously imply C++.
   97812             : 
   97813             : // This implements the support within ROSE for memory pools.  Memory pools
   97814             : // support the most condensed usage of memory within the construction of
   97815             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   97816             : // by a new operator written for each class.
   97817             : 
   97818             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   97819             :     // User wants multi-thread support and POSIX threads are available.
   97820             : #   include <pthread.h>
   97821             :     static pthread_mutex_t SgAssignedGotoStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   97822             : #else
   97823             :      // Cause synchronization to be skipped.
   97824             : #    ifndef ALLOC_MUTEX
   97825             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   97826             : #    endif
   97827             : #    ifdef _REENTRANT
   97828             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   97829             : #       ifdef _MSC_VER
   97830             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   97831             : #       else
   97832             : #           warning "POSIX threads are not available; synchronization being skipped"
   97833             : #       endif
   97834             : #    endif
   97835             : #endif
   97836             : 
   97837             : #ifndef ROSE_ALLOC_TRACE
   97838             : #  define ROSE_ALLOC_TRACE 0
   97839             : #endif
   97840             : 
   97841             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   97842             : #define ROSE_ALLOC_TRACE_CNT
   97843             : #include "memory-pool-snapshot.h"
   97844             : unsigned long alloc_trace_cnt = 0;
   97845             : #endif
   97846             : 
   97847             : #if ROSE_ALLOC_TRACE
   97848             : const unsigned SgAssignedGotoStatement::pool_size = 5;
   97849             : #else
   97850             : const unsigned SgAssignedGotoStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   97851             : #endif
   97852             : 
   97853             : #ifndef ROSE_ALLOC_MEMSET
   97854             : #  define ROSE_ALLOC_MEMSET 0
   97855             : #endif
   97856             : 
   97857             : #ifndef ROSE_PEDANTIC_ALLOC
   97858             : #  define ROSE_PEDANTIC_ALLOC 0
   97859             : #endif
   97860             : 
   97861             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   97862             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   97863             : #endif
   97864             : 
   97865             : #if !defined(SGNODE__ALL_POOLS)
   97866             : #define SGNODE__ALL_POOLS
   97867             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   97868             : #endif
   97869             : 
   97870             : SgAssignedGotoStatement* SgAssignedGotoStatement::next_node = nullptr;
   97871             : std::vector<unsigned char*> SgAssignedGotoStatement::pools;
   97872             : 
   97873             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   97874             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   97875             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   97876             : // around this macro definition rather than each use).
   97877             : #ifndef ALLOC_MUTEX
   97878             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   97879             :         do {                                                                     \
   97880             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   97881             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   97882             :                 abort();                                                         \
   97883             :             }                                                                    \
   97884             :         } while (0);
   97885             : #endif
   97886             : 
   97887             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   97888             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   97889             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   97890             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   97891             : 
   97892             : /*! \brief New operator for SgAssignedGotoStatement.
   97893             : 
   97894             :    This new operator implements memory pools to provide most efficent 
   97895             :    use of the heap within construction of large ASTs.
   97896             : 
   97897             : \internal The new and delete operators use the lower level C malloc/free
   97898             :    function calls for performance and to make sure that mixing of malloc/free
   97899             :    and new/delete by the used can be caught more readily.  This may change
   97900             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   97901             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   97902             :    deallocate memory allocated using ROSE_MALLOC.
   97903             : */
   97904           0 : void *SgAssignedGotoStatement::operator new ( size_t Size )
   97905             : {
   97906             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   97907             :      * returning or throwing an exception. */
   97908           0 :     ALLOC_MUTEX(SgAssignedGotoStatement, lock);
   97909             : 
   97910             : #if ROSE_ALLOC_TRACE == 2
   97911             : //    printf("SgAssignedGotoStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgAssignedGotoStatement::next_node);
   97912             : #endif
   97913             : 
   97914             : #if USE_CPP_NEW_DELETE_OPERATORS
   97915             :     void *mem = ROSE_MALLOC(Size);
   97916             :     ALLOC_MUTEX(SgAssignedGotoStatement, unlock);
   97917             :     return mem;
   97918             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   97919             : #if ROSE_PEDANTIC_ALLOC
   97920             :     ROSE_ASSERT(Size == sizeof(SgAssignedGotoStatement));
   97921             : #else
   97922           0 :     if (Size != sizeof(SgAssignedGotoStatement)) {
   97923           0 :       void * object = ROSE_MALLOC(Size);
   97924           0 :       ALLOC_MUTEX(SgAssignedGotoStatement, unlock);
   97925             :       return object;
   97926             :     }
   97927             : #endif
   97928             : 
   97929           0 :     if (SgAssignedGotoStatement::next_node == nullptr) {
   97930           0 :         SgAssignedGotoStatement * alloc = (SgAssignedGotoStatement*) ROSE_MALLOC ( SgAssignedGotoStatement::pool_size * sizeof(SgAssignedGotoStatement) );
   97931           0 :         ROSE_ASSERT(alloc != nullptr);
   97932             : 
   97933             : #if ROSE_ALLOC_TRACE == 2
   97934             : //        printf("SgAssignedGotoStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgAssignedGotoStatement::pools.size(), alloc, alloc + SgAssignedGotoStatement::pool_size);
   97935             : #endif
   97936             : 
   97937             : #if ROSE_ALLOC_MEMSET == 1
   97938             : #elif ROSE_ALLOC_MEMSET == 2
   97939             :         memset(alloc, 0x00, SgAssignedGotoStatement::pool_size * sizeof(SgAssignedGotoStatement));
   97940             : #elif ROSE_ALLOC_MEMSET == 3
   97941             :         memset(alloc, 0xAA, SgAssignedGotoStatement::pool_size * sizeof(SgAssignedGotoStatement));
   97942             : #endif
   97943           0 :         for (unsigned i=0; i < SgAssignedGotoStatement::pool_size-1; i++) {
   97944           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
   97945             :         }
   97946           0 :         alloc[SgAssignedGotoStatement::pool_size-1].p_freepointer = nullptr;
   97947             : 
   97948           0 :         SgAssignedGotoStatement::pools.push_back ( (unsigned char *) alloc );
   97949           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgAssignedGotoStatement::pool_size * sizeof(SgAssignedGotoStatement), V_SgAssignedGotoStatement ) );
   97950           0 :         SgAssignedGotoStatement::next_node = alloc;
   97951             :     }
   97952           0 :     ROSE_ASSERT(SgAssignedGotoStatement::next_node != nullptr);
   97953             : 
   97954           0 :     SgAssignedGotoStatement * object = SgAssignedGotoStatement::next_node;
   97955           0 :     SgAssignedGotoStatement::next_node = (SgAssignedGotoStatement*)(object->p_freepointer);
   97956             : 
   97957             : #if ROSE_ALLOC_TRACE == 2
   97958             :     printf("SgAssignedGotoStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgAssignedGotoStatement::next_node);
   97959             : #endif
   97960             : 
   97961           0 :     SgNode * fp = object->p_freepointer;
   97962             : #if ROSE_ALLOC_MEMSET == 1
   97963             : #elif ROSE_ALLOC_MEMSET == 2
   97964             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgAssignedGotoStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   97965             : #elif ROSE_ALLOC_MEMSET == 3
   97966             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgAssignedGotoStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   97967             : #endif
   97968           0 :     object->p_freepointer = fp;
   97969             : 
   97970             : #if ROSE_ALLOC_TRACE == 2
   97971             : //    printf("SgAssignedGotoStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgAssignedGotoStatement::next_node);
   97972             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   97973             :     Rose::MemPool::snapshot(oss.str());
   97974             :     alloc_trace_cnt++;
   97975             : #endif
   97976             : 
   97977           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   97978             : 
   97979           0 :     ALLOC_MUTEX(SgAssignedGotoStatement, unlock);
   97980             : 
   97981             :     return object;
   97982             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   97983             : }
   97984             : 
   97985             : 
   97986             : 
   97987             : /*! \brief Delete operator for SgAssignedGotoStatement.
   97988             : 
   97989             :    This delete operator implements deallocation using memory pools to 
   97990             :    provide most efficent use of the heap within construction of large ASTs.
   97991             : 
   97992             : \internal The new and delete operators use the lower level C malloc/free
   97993             :    function calls for performance and to make sure that mixing of malloc/free
   97994             :    and new/delete by the used can be caught more readily.  This may change
   97995             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   97996             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   97997             :    deallocate memory allocated using ROSE_MALLOC.
   97998             : */
   97999           0 : void SgAssignedGotoStatement::operator delete(void *Pointer, size_t Size)
   98000             : {
   98001             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   98002             :      * or throwing an exception. */
   98003           0 :     ALLOC_MUTEX(SgAssignedGotoStatement, lock);
   98004             : 
   98005             : #if USE_CPP_NEW_DELETE_OPERATORS
   98006             :     ROSE_FREE(Pointer);
   98007             : #else
   98008             : #if ROSE_PEDANTIC_ALLOC
   98009             :     ROSE_ASSERT(Size == sizeof(SgAssignedGotoStatement));
   98010             : #else
   98011           0 :     if (Size != sizeof(SgAssignedGotoStatement)) {
   98012           0 :       ROSE_FREE(Pointer);
   98013           0 :       ALLOC_MUTEX(SgAssignedGotoStatement, unlock);
   98014             :       return;
   98015             :     }
   98016             : #endif
   98017             : 
   98018           0 :     SgAssignedGotoStatement * object = (SgAssignedGotoStatement*) Pointer;
   98019           0 :     ROSE_ASSERT(object != nullptr);
   98020             : 
   98021             : #if ROSE_ALLOC_TRACE == 2
   98022             : //  printf("SgAssignedGotoStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgAssignedGotoStatement::next_node);
   98023             :     printf("SgAssignedGotoStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgAssignedGotoStatement::next_node);
   98024             : #endif
   98025             : 
   98026             : #if ROSE_PEDANTIC_ALLOC
   98027             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   98028             : #endif
   98029             : 
   98030             : #if ROSE_ALLOC_MEMSET == 1
   98031             : #elif ROSE_ALLOC_MEMSET == 2
   98032             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgAssignedGotoStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   98033             : #elif ROSE_ALLOC_MEMSET == 3
   98034             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgAssignedGotoStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   98035             : #endif
   98036             : 
   98037             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   98038             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   98039             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   98040             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   98041             : #else
   98042           0 :     object->p_freepointer = SgAssignedGotoStatement::next_node;
   98043           0 :     SgAssignedGotoStatement::next_node = object;
   98044             : #endif
   98045             : 
   98046             : #if ROSE_ALLOC_TRACE == 2
   98047             : //  printf("SgAssignedGotoStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgAssignedGotoStatement::next_node);
   98048             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   98049             :     Rose::MemPool::snapshot(oss.str());
   98050             :     alloc_trace_cnt++;
   98051             : #endif
   98052             : 
   98053             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   98054             : 
   98055           0 :     ALLOC_MUTEX(SgAssignedGotoStatement, unlock);
   98056             : }
   98057             : 
   98058             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   98059             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   98060             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   98061             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   98062             : // Also, note comment below from Robb (copied from the Common.code file).
   98063             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   98064             : //
   98065             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   98066             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   98067             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   98068             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   98069             : #if 0
   98070             : void SgAssignedGotoStatement::operator delete(void* pointer) { SgAssignedGotoStatement::operator delete (pointer, sizeof(SgAssignedGotoStatement)); };
   98071             : #endif
   98072             : /* #line 98073 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   98073             : 
   98074             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   98075             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   98076             : // obviously imply C++.
   98077             : 
   98078             : // This implements the support within ROSE for memory pools.  Memory pools
   98079             : // support the most condensed usage of memory within the construction of
   98080             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   98081             : // by a new operator written for each class.
   98082             : 
   98083             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   98084             :     // User wants multi-thread support and POSIX threads are available.
   98085             : #   include <pthread.h>
   98086             :     static pthread_mutex_t SgAllocateStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   98087             : #else
   98088             :      // Cause synchronization to be skipped.
   98089             : #    ifndef ALLOC_MUTEX
   98090             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   98091             : #    endif
   98092             : #    ifdef _REENTRANT
   98093             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   98094             : #       ifdef _MSC_VER
   98095             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   98096             : #       else
   98097             : #           warning "POSIX threads are not available; synchronization being skipped"
   98098             : #       endif
   98099             : #    endif
   98100             : #endif
   98101             : 
   98102             : #ifndef ROSE_ALLOC_TRACE
   98103             : #  define ROSE_ALLOC_TRACE 0
   98104             : #endif
   98105             : 
   98106             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   98107             : #define ROSE_ALLOC_TRACE_CNT
   98108             : #include "memory-pool-snapshot.h"
   98109             : unsigned long alloc_trace_cnt = 0;
   98110             : #endif
   98111             : 
   98112             : #if ROSE_ALLOC_TRACE
   98113             : const unsigned SgAllocateStatement::pool_size = 5;
   98114             : #else
   98115             : const unsigned SgAllocateStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   98116             : #endif
   98117             : 
   98118             : #ifndef ROSE_ALLOC_MEMSET
   98119             : #  define ROSE_ALLOC_MEMSET 0
   98120             : #endif
   98121             : 
   98122             : #ifndef ROSE_PEDANTIC_ALLOC
   98123             : #  define ROSE_PEDANTIC_ALLOC 0
   98124             : #endif
   98125             : 
   98126             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   98127             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   98128             : #endif
   98129             : 
   98130             : #if !defined(SGNODE__ALL_POOLS)
   98131             : #define SGNODE__ALL_POOLS
   98132             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   98133             : #endif
   98134             : 
   98135             : SgAllocateStatement* SgAllocateStatement::next_node = nullptr;
   98136             : std::vector<unsigned char*> SgAllocateStatement::pools;
   98137             : 
   98138             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   98139             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   98140             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   98141             : // around this macro definition rather than each use).
   98142             : #ifndef ALLOC_MUTEX
   98143             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   98144             :         do {                                                                     \
   98145             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   98146             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   98147             :                 abort();                                                         \
   98148             :             }                                                                    \
   98149             :         } while (0);
   98150             : #endif
   98151             : 
   98152             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   98153             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   98154             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   98155             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   98156             : 
   98157             : /*! \brief New operator for SgAllocateStatement.
   98158             : 
   98159             :    This new operator implements memory pools to provide most efficent 
   98160             :    use of the heap within construction of large ASTs.
   98161             : 
   98162             : \internal The new and delete operators use the lower level C malloc/free
   98163             :    function calls for performance and to make sure that mixing of malloc/free
   98164             :    and new/delete by the used can be caught more readily.  This may change
   98165             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   98166             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   98167             :    deallocate memory allocated using ROSE_MALLOC.
   98168             : */
   98169           0 : void *SgAllocateStatement::operator new ( size_t Size )
   98170             : {
   98171             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   98172             :      * returning or throwing an exception. */
   98173           0 :     ALLOC_MUTEX(SgAllocateStatement, lock);
   98174             : 
   98175             : #if ROSE_ALLOC_TRACE == 2
   98176             : //    printf("SgAllocateStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgAllocateStatement::next_node);
   98177             : #endif
   98178             : 
   98179             : #if USE_CPP_NEW_DELETE_OPERATORS
   98180             :     void *mem = ROSE_MALLOC(Size);
   98181             :     ALLOC_MUTEX(SgAllocateStatement, unlock);
   98182             :     return mem;
   98183             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   98184             : #if ROSE_PEDANTIC_ALLOC
   98185             :     ROSE_ASSERT(Size == sizeof(SgAllocateStatement));
   98186             : #else
   98187           0 :     if (Size != sizeof(SgAllocateStatement)) {
   98188           0 :       void * object = ROSE_MALLOC(Size);
   98189           0 :       ALLOC_MUTEX(SgAllocateStatement, unlock);
   98190             :       return object;
   98191             :     }
   98192             : #endif
   98193             : 
   98194           0 :     if (SgAllocateStatement::next_node == nullptr) {
   98195           0 :         SgAllocateStatement * alloc = (SgAllocateStatement*) ROSE_MALLOC ( SgAllocateStatement::pool_size * sizeof(SgAllocateStatement) );
   98196           0 :         ROSE_ASSERT(alloc != nullptr);
   98197             : 
   98198             : #if ROSE_ALLOC_TRACE == 2
   98199             : //        printf("SgAllocateStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgAllocateStatement::pools.size(), alloc, alloc + SgAllocateStatement::pool_size);
   98200             : #endif
   98201             : 
   98202             : #if ROSE_ALLOC_MEMSET == 1
   98203             : #elif ROSE_ALLOC_MEMSET == 2
   98204             :         memset(alloc, 0x00, SgAllocateStatement::pool_size * sizeof(SgAllocateStatement));
   98205             : #elif ROSE_ALLOC_MEMSET == 3
   98206             :         memset(alloc, 0xAA, SgAllocateStatement::pool_size * sizeof(SgAllocateStatement));
   98207             : #endif
   98208           0 :         for (unsigned i=0; i < SgAllocateStatement::pool_size-1; i++) {
   98209           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
   98210             :         }
   98211           0 :         alloc[SgAllocateStatement::pool_size-1].p_freepointer = nullptr;
   98212             : 
   98213           0 :         SgAllocateStatement::pools.push_back ( (unsigned char *) alloc );
   98214           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgAllocateStatement::pool_size * sizeof(SgAllocateStatement), V_SgAllocateStatement ) );
   98215           0 :         SgAllocateStatement::next_node = alloc;
   98216             :     }
   98217           0 :     ROSE_ASSERT(SgAllocateStatement::next_node != nullptr);
   98218             : 
   98219           0 :     SgAllocateStatement * object = SgAllocateStatement::next_node;
   98220           0 :     SgAllocateStatement::next_node = (SgAllocateStatement*)(object->p_freepointer);
   98221             : 
   98222             : #if ROSE_ALLOC_TRACE == 2
   98223             :     printf("SgAllocateStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgAllocateStatement::next_node);
   98224             : #endif
   98225             : 
   98226           0 :     SgNode * fp = object->p_freepointer;
   98227             : #if ROSE_ALLOC_MEMSET == 1
   98228             : #elif ROSE_ALLOC_MEMSET == 2
   98229             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgAllocateStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   98230             : #elif ROSE_ALLOC_MEMSET == 3
   98231             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgAllocateStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   98232             : #endif
   98233           0 :     object->p_freepointer = fp;
   98234             : 
   98235             : #if ROSE_ALLOC_TRACE == 2
   98236             : //    printf("SgAllocateStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgAllocateStatement::next_node);
   98237             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   98238             :     Rose::MemPool::snapshot(oss.str());
   98239             :     alloc_trace_cnt++;
   98240             : #endif
   98241             : 
   98242           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   98243             : 
   98244           0 :     ALLOC_MUTEX(SgAllocateStatement, unlock);
   98245             : 
   98246             :     return object;
   98247             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   98248             : }
   98249             : 
   98250             : 
   98251             : 
   98252             : /*! \brief Delete operator for SgAllocateStatement.
   98253             : 
   98254             :    This delete operator implements deallocation using memory pools to 
   98255             :    provide most efficent use of the heap within construction of large ASTs.
   98256             : 
   98257             : \internal The new and delete operators use the lower level C malloc/free
   98258             :    function calls for performance and to make sure that mixing of malloc/free
   98259             :    and new/delete by the used can be caught more readily.  This may change
   98260             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   98261             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   98262             :    deallocate memory allocated using ROSE_MALLOC.
   98263             : */
   98264           0 : void SgAllocateStatement::operator delete(void *Pointer, size_t Size)
   98265             : {
   98266             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   98267             :      * or throwing an exception. */
   98268           0 :     ALLOC_MUTEX(SgAllocateStatement, lock);
   98269             : 
   98270             : #if USE_CPP_NEW_DELETE_OPERATORS
   98271             :     ROSE_FREE(Pointer);
   98272             : #else
   98273             : #if ROSE_PEDANTIC_ALLOC
   98274             :     ROSE_ASSERT(Size == sizeof(SgAllocateStatement));
   98275             : #else
   98276           0 :     if (Size != sizeof(SgAllocateStatement)) {
   98277           0 :       ROSE_FREE(Pointer);
   98278           0 :       ALLOC_MUTEX(SgAllocateStatement, unlock);
   98279             :       return;
   98280             :     }
   98281             : #endif
   98282             : 
   98283           0 :     SgAllocateStatement * object = (SgAllocateStatement*) Pointer;
   98284           0 :     ROSE_ASSERT(object != nullptr);
   98285             : 
   98286             : #if ROSE_ALLOC_TRACE == 2
   98287             : //  printf("SgAllocateStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgAllocateStatement::next_node);
   98288             :     printf("SgAllocateStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgAllocateStatement::next_node);
   98289             : #endif
   98290             : 
   98291             : #if ROSE_PEDANTIC_ALLOC
   98292             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   98293             : #endif
   98294             : 
   98295             : #if ROSE_ALLOC_MEMSET == 1
   98296             : #elif ROSE_ALLOC_MEMSET == 2
   98297             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgAllocateStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   98298             : #elif ROSE_ALLOC_MEMSET == 3
   98299             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgAllocateStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   98300             : #endif
   98301             : 
   98302             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   98303             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   98304             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   98305             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   98306             : #else
   98307           0 :     object->p_freepointer = SgAllocateStatement::next_node;
   98308           0 :     SgAllocateStatement::next_node = object;
   98309             : #endif
   98310             : 
   98311             : #if ROSE_ALLOC_TRACE == 2
   98312             : //  printf("SgAllocateStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgAllocateStatement::next_node);
   98313             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   98314             :     Rose::MemPool::snapshot(oss.str());
   98315             :     alloc_trace_cnt++;
   98316             : #endif
   98317             : 
   98318             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   98319             : 
   98320           0 :     ALLOC_MUTEX(SgAllocateStatement, unlock);
   98321             : }
   98322             : 
   98323             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   98324             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   98325             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   98326             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   98327             : // Also, note comment below from Robb (copied from the Common.code file).
   98328             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   98329             : //
   98330             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   98331             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   98332             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   98333             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   98334             : #if 0
   98335             : void SgAllocateStatement::operator delete(void* pointer) { SgAllocateStatement::operator delete (pointer, sizeof(SgAllocateStatement)); };
   98336             : #endif
   98337             : /* #line 98338 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   98338             : 
   98339             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   98340             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   98341             : // obviously imply C++.
   98342             : 
   98343             : // This implements the support within ROSE for memory pools.  Memory pools
   98344             : // support the most condensed usage of memory within the construction of
   98345             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   98346             : // by a new operator written for each class.
   98347             : 
   98348             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   98349             :     // User wants multi-thread support and POSIX threads are available.
   98350             : #   include <pthread.h>
   98351             :     static pthread_mutex_t SgDeallocateStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   98352             : #else
   98353             :      // Cause synchronization to be skipped.
   98354             : #    ifndef ALLOC_MUTEX
   98355             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   98356             : #    endif
   98357             : #    ifdef _REENTRANT
   98358             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   98359             : #       ifdef _MSC_VER
   98360             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   98361             : #       else
   98362             : #           warning "POSIX threads are not available; synchronization being skipped"
   98363             : #       endif
   98364             : #    endif
   98365             : #endif
   98366             : 
   98367             : #ifndef ROSE_ALLOC_TRACE
   98368             : #  define ROSE_ALLOC_TRACE 0
   98369             : #endif
   98370             : 
   98371             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   98372             : #define ROSE_ALLOC_TRACE_CNT
   98373             : #include "memory-pool-snapshot.h"
   98374             : unsigned long alloc_trace_cnt = 0;
   98375             : #endif
   98376             : 
   98377             : #if ROSE_ALLOC_TRACE
   98378             : const unsigned SgDeallocateStatement::pool_size = 5;
   98379             : #else
   98380             : const unsigned SgDeallocateStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   98381             : #endif
   98382             : 
   98383             : #ifndef ROSE_ALLOC_MEMSET
   98384             : #  define ROSE_ALLOC_MEMSET 0
   98385             : #endif
   98386             : 
   98387             : #ifndef ROSE_PEDANTIC_ALLOC
   98388             : #  define ROSE_PEDANTIC_ALLOC 0
   98389             : #endif
   98390             : 
   98391             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   98392             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   98393             : #endif
   98394             : 
   98395             : #if !defined(SGNODE__ALL_POOLS)
   98396             : #define SGNODE__ALL_POOLS
   98397             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   98398             : #endif
   98399             : 
   98400             : SgDeallocateStatement* SgDeallocateStatement::next_node = nullptr;
   98401             : std::vector<unsigned char*> SgDeallocateStatement::pools;
   98402             : 
   98403             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   98404             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   98405             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   98406             : // around this macro definition rather than each use).
   98407             : #ifndef ALLOC_MUTEX
   98408             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   98409             :         do {                                                                     \
   98410             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   98411             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   98412             :                 abort();                                                         \
   98413             :             }                                                                    \
   98414             :         } while (0);
   98415             : #endif
   98416             : 
   98417             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   98418             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   98419             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   98420             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   98421             : 
   98422             : /*! \brief New operator for SgDeallocateStatement.
   98423             : 
   98424             :    This new operator implements memory pools to provide most efficent 
   98425             :    use of the heap within construction of large ASTs.
   98426             : 
   98427             : \internal The new and delete operators use the lower level C malloc/free
   98428             :    function calls for performance and to make sure that mixing of malloc/free
   98429             :    and new/delete by the used can be caught more readily.  This may change
   98430             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   98431             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   98432             :    deallocate memory allocated using ROSE_MALLOC.
   98433             : */
   98434           0 : void *SgDeallocateStatement::operator new ( size_t Size )
   98435             : {
   98436             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   98437             :      * returning or throwing an exception. */
   98438           0 :     ALLOC_MUTEX(SgDeallocateStatement, lock);
   98439             : 
   98440             : #if ROSE_ALLOC_TRACE == 2
   98441             : //    printf("SgDeallocateStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgDeallocateStatement::next_node);
   98442             : #endif
   98443             : 
   98444             : #if USE_CPP_NEW_DELETE_OPERATORS
   98445             :     void *mem = ROSE_MALLOC(Size);
   98446             :     ALLOC_MUTEX(SgDeallocateStatement, unlock);
   98447             :     return mem;
   98448             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   98449             : #if ROSE_PEDANTIC_ALLOC
   98450             :     ROSE_ASSERT(Size == sizeof(SgDeallocateStatement));
   98451             : #else
   98452           0 :     if (Size != sizeof(SgDeallocateStatement)) {
   98453           0 :       void * object = ROSE_MALLOC(Size);
   98454           0 :       ALLOC_MUTEX(SgDeallocateStatement, unlock);
   98455             :       return object;
   98456             :     }
   98457             : #endif
   98458             : 
   98459           0 :     if (SgDeallocateStatement::next_node == nullptr) {
   98460           0 :         SgDeallocateStatement * alloc = (SgDeallocateStatement*) ROSE_MALLOC ( SgDeallocateStatement::pool_size * sizeof(SgDeallocateStatement) );
   98461           0 :         ROSE_ASSERT(alloc != nullptr);
   98462             : 
   98463             : #if ROSE_ALLOC_TRACE == 2
   98464             : //        printf("SgDeallocateStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgDeallocateStatement::pools.size(), alloc, alloc + SgDeallocateStatement::pool_size);
   98465             : #endif
   98466             : 
   98467             : #if ROSE_ALLOC_MEMSET == 1
   98468             : #elif ROSE_ALLOC_MEMSET == 2
   98469             :         memset(alloc, 0x00, SgDeallocateStatement::pool_size * sizeof(SgDeallocateStatement));
   98470             : #elif ROSE_ALLOC_MEMSET == 3
   98471             :         memset(alloc, 0xAA, SgDeallocateStatement::pool_size * sizeof(SgDeallocateStatement));
   98472             : #endif
   98473           0 :         for (unsigned i=0; i < SgDeallocateStatement::pool_size-1; i++) {
   98474           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
   98475             :         }
   98476           0 :         alloc[SgDeallocateStatement::pool_size-1].p_freepointer = nullptr;
   98477             : 
   98478           0 :         SgDeallocateStatement::pools.push_back ( (unsigned char *) alloc );
   98479           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgDeallocateStatement::pool_size * sizeof(SgDeallocateStatement), V_SgDeallocateStatement ) );
   98480           0 :         SgDeallocateStatement::next_node = alloc;
   98481             :     }
   98482           0 :     ROSE_ASSERT(SgDeallocateStatement::next_node != nullptr);
   98483             : 
   98484           0 :     SgDeallocateStatement * object = SgDeallocateStatement::next_node;
   98485           0 :     SgDeallocateStatement::next_node = (SgDeallocateStatement*)(object->p_freepointer);
   98486             : 
   98487             : #if ROSE_ALLOC_TRACE == 2
   98488             :     printf("SgDeallocateStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgDeallocateStatement::next_node);
   98489             : #endif
   98490             : 
   98491           0 :     SgNode * fp = object->p_freepointer;
   98492             : #if ROSE_ALLOC_MEMSET == 1
   98493             : #elif ROSE_ALLOC_MEMSET == 2
   98494             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgDeallocateStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   98495             : #elif ROSE_ALLOC_MEMSET == 3
   98496             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgDeallocateStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   98497             : #endif
   98498           0 :     object->p_freepointer = fp;
   98499             : 
   98500             : #if ROSE_ALLOC_TRACE == 2
   98501             : //    printf("SgDeallocateStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgDeallocateStatement::next_node);
   98502             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   98503             :     Rose::MemPool::snapshot(oss.str());
   98504             :     alloc_trace_cnt++;
   98505             : #endif
   98506             : 
   98507           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   98508             : 
   98509           0 :     ALLOC_MUTEX(SgDeallocateStatement, unlock);
   98510             : 
   98511             :     return object;
   98512             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   98513             : }
   98514             : 
   98515             : 
   98516             : 
   98517             : /*! \brief Delete operator for SgDeallocateStatement.
   98518             : 
   98519             :    This delete operator implements deallocation using memory pools to 
   98520             :    provide most efficent use of the heap within construction of large ASTs.
   98521             : 
   98522             : \internal The new and delete operators use the lower level C malloc/free
   98523             :    function calls for performance and to make sure that mixing of malloc/free
   98524             :    and new/delete by the used can be caught more readily.  This may change
   98525             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   98526             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   98527             :    deallocate memory allocated using ROSE_MALLOC.
   98528             : */
   98529           0 : void SgDeallocateStatement::operator delete(void *Pointer, size_t Size)
   98530             : {
   98531             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   98532             :      * or throwing an exception. */
   98533           0 :     ALLOC_MUTEX(SgDeallocateStatement, lock);
   98534             : 
   98535             : #if USE_CPP_NEW_DELETE_OPERATORS
   98536             :     ROSE_FREE(Pointer);
   98537             : #else
   98538             : #if ROSE_PEDANTIC_ALLOC
   98539             :     ROSE_ASSERT(Size == sizeof(SgDeallocateStatement));
   98540             : #else
   98541           0 :     if (Size != sizeof(SgDeallocateStatement)) {
   98542           0 :       ROSE_FREE(Pointer);
   98543           0 :       ALLOC_MUTEX(SgDeallocateStatement, unlock);
   98544             :       return;
   98545             :     }
   98546             : #endif
   98547             : 
   98548           0 :     SgDeallocateStatement * object = (SgDeallocateStatement*) Pointer;
   98549           0 :     ROSE_ASSERT(object != nullptr);
   98550             : 
   98551             : #if ROSE_ALLOC_TRACE == 2
   98552             : //  printf("SgDeallocateStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgDeallocateStatement::next_node);
   98553             :     printf("SgDeallocateStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgDeallocateStatement::next_node);
   98554             : #endif
   98555             : 
   98556             : #if ROSE_PEDANTIC_ALLOC
   98557             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   98558             : #endif
   98559             : 
   98560             : #if ROSE_ALLOC_MEMSET == 1
   98561             : #elif ROSE_ALLOC_MEMSET == 2
   98562             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgDeallocateStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   98563             : #elif ROSE_ALLOC_MEMSET == 3
   98564             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgDeallocateStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   98565             : #endif
   98566             : 
   98567             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   98568             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   98569             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   98570             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   98571             : #else
   98572           0 :     object->p_freepointer = SgDeallocateStatement::next_node;
   98573           0 :     SgDeallocateStatement::next_node = object;
   98574             : #endif
   98575             : 
   98576             : #if ROSE_ALLOC_TRACE == 2
   98577             : //  printf("SgDeallocateStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgDeallocateStatement::next_node);
   98578             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   98579             :     Rose::MemPool::snapshot(oss.str());
   98580             :     alloc_trace_cnt++;
   98581             : #endif
   98582             : 
   98583             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   98584             : 
   98585           0 :     ALLOC_MUTEX(SgDeallocateStatement, unlock);
   98586             : }
   98587             : 
   98588             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   98589             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   98590             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   98591             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   98592             : // Also, note comment below from Robb (copied from the Common.code file).
   98593             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   98594             : //
   98595             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   98596             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   98597             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   98598             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   98599             : #if 0
   98600             : void SgDeallocateStatement::operator delete(void* pointer) { SgDeallocateStatement::operator delete (pointer, sizeof(SgDeallocateStatement)); };
   98601             : #endif
   98602             : /* #line 98603 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   98603             : 
   98604             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   98605             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   98606             : // obviously imply C++.
   98607             : 
   98608             : // This implements the support within ROSE for memory pools.  Memory pools
   98609             : // support the most condensed usage of memory within the construction of
   98610             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   98611             : // by a new operator written for each class.
   98612             : 
   98613             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   98614             :     // User wants multi-thread support and POSIX threads are available.
   98615             : #   include <pthread.h>
   98616             :     static pthread_mutex_t SgUpcNotifyStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   98617             : #else
   98618             :      // Cause synchronization to be skipped.
   98619             : #    ifndef ALLOC_MUTEX
   98620             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   98621             : #    endif
   98622             : #    ifdef _REENTRANT
   98623             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   98624             : #       ifdef _MSC_VER
   98625             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   98626             : #       else
   98627             : #           warning "POSIX threads are not available; synchronization being skipped"
   98628             : #       endif
   98629             : #    endif
   98630             : #endif
   98631             : 
   98632             : #ifndef ROSE_ALLOC_TRACE
   98633             : #  define ROSE_ALLOC_TRACE 0
   98634             : #endif
   98635             : 
   98636             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   98637             : #define ROSE_ALLOC_TRACE_CNT
   98638             : #include "memory-pool-snapshot.h"
   98639             : unsigned long alloc_trace_cnt = 0;
   98640             : #endif
   98641             : 
   98642             : #if ROSE_ALLOC_TRACE
   98643             : const unsigned SgUpcNotifyStatement::pool_size = 5;
   98644             : #else
   98645             : const unsigned SgUpcNotifyStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   98646             : #endif
   98647             : 
   98648             : #ifndef ROSE_ALLOC_MEMSET
   98649             : #  define ROSE_ALLOC_MEMSET 0
   98650             : #endif
   98651             : 
   98652             : #ifndef ROSE_PEDANTIC_ALLOC
   98653             : #  define ROSE_PEDANTIC_ALLOC 0
   98654             : #endif
   98655             : 
   98656             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   98657             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   98658             : #endif
   98659             : 
   98660             : #if !defined(SGNODE__ALL_POOLS)
   98661             : #define SGNODE__ALL_POOLS
   98662             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   98663             : #endif
   98664             : 
   98665             : SgUpcNotifyStatement* SgUpcNotifyStatement::next_node = nullptr;
   98666             : std::vector<unsigned char*> SgUpcNotifyStatement::pools;
   98667             : 
   98668             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   98669             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   98670             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   98671             : // around this macro definition rather than each use).
   98672             : #ifndef ALLOC_MUTEX
   98673             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   98674             :         do {                                                                     \
   98675             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   98676             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   98677             :                 abort();                                                         \
   98678             :             }                                                                    \
   98679             :         } while (0);
   98680             : #endif
   98681             : 
   98682             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   98683             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   98684             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   98685             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   98686             : 
   98687             : /*! \brief New operator for SgUpcNotifyStatement.
   98688             : 
   98689             :    This new operator implements memory pools to provide most efficent 
   98690             :    use of the heap within construction of large ASTs.
   98691             : 
   98692             : \internal The new and delete operators use the lower level C malloc/free
   98693             :    function calls for performance and to make sure that mixing of malloc/free
   98694             :    and new/delete by the used can be caught more readily.  This may change
   98695             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   98696             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   98697             :    deallocate memory allocated using ROSE_MALLOC.
   98698             : */
   98699           0 : void *SgUpcNotifyStatement::operator new ( size_t Size )
   98700             : {
   98701             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   98702             :      * returning or throwing an exception. */
   98703           0 :     ALLOC_MUTEX(SgUpcNotifyStatement, lock);
   98704             : 
   98705             : #if ROSE_ALLOC_TRACE == 2
   98706             : //    printf("SgUpcNotifyStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgUpcNotifyStatement::next_node);
   98707             : #endif
   98708             : 
   98709             : #if USE_CPP_NEW_DELETE_OPERATORS
   98710             :     void *mem = ROSE_MALLOC(Size);
   98711             :     ALLOC_MUTEX(SgUpcNotifyStatement, unlock);
   98712             :     return mem;
   98713             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   98714             : #if ROSE_PEDANTIC_ALLOC
   98715             :     ROSE_ASSERT(Size == sizeof(SgUpcNotifyStatement));
   98716             : #else
   98717           0 :     if (Size != sizeof(SgUpcNotifyStatement)) {
   98718           0 :       void * object = ROSE_MALLOC(Size);
   98719           0 :       ALLOC_MUTEX(SgUpcNotifyStatement, unlock);
   98720             :       return object;
   98721             :     }
   98722             : #endif
   98723             : 
   98724           0 :     if (SgUpcNotifyStatement::next_node == nullptr) {
   98725           0 :         SgUpcNotifyStatement * alloc = (SgUpcNotifyStatement*) ROSE_MALLOC ( SgUpcNotifyStatement::pool_size * sizeof(SgUpcNotifyStatement) );
   98726           0 :         ROSE_ASSERT(alloc != nullptr);
   98727             : 
   98728             : #if ROSE_ALLOC_TRACE == 2
   98729             : //        printf("SgUpcNotifyStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgUpcNotifyStatement::pools.size(), alloc, alloc + SgUpcNotifyStatement::pool_size);
   98730             : #endif
   98731             : 
   98732             : #if ROSE_ALLOC_MEMSET == 1
   98733             : #elif ROSE_ALLOC_MEMSET == 2
   98734             :         memset(alloc, 0x00, SgUpcNotifyStatement::pool_size * sizeof(SgUpcNotifyStatement));
   98735             : #elif ROSE_ALLOC_MEMSET == 3
   98736             :         memset(alloc, 0xAA, SgUpcNotifyStatement::pool_size * sizeof(SgUpcNotifyStatement));
   98737             : #endif
   98738           0 :         for (unsigned i=0; i < SgUpcNotifyStatement::pool_size-1; i++) {
   98739           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
   98740             :         }
   98741           0 :         alloc[SgUpcNotifyStatement::pool_size-1].p_freepointer = nullptr;
   98742             : 
   98743           0 :         SgUpcNotifyStatement::pools.push_back ( (unsigned char *) alloc );
   98744           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgUpcNotifyStatement::pool_size * sizeof(SgUpcNotifyStatement), V_SgUpcNotifyStatement ) );
   98745           0 :         SgUpcNotifyStatement::next_node = alloc;
   98746             :     }
   98747           0 :     ROSE_ASSERT(SgUpcNotifyStatement::next_node != nullptr);
   98748             : 
   98749           0 :     SgUpcNotifyStatement * object = SgUpcNotifyStatement::next_node;
   98750           0 :     SgUpcNotifyStatement::next_node = (SgUpcNotifyStatement*)(object->p_freepointer);
   98751             : 
   98752             : #if ROSE_ALLOC_TRACE == 2
   98753             :     printf("SgUpcNotifyStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUpcNotifyStatement::next_node);
   98754             : #endif
   98755             : 
   98756           0 :     SgNode * fp = object->p_freepointer;
   98757             : #if ROSE_ALLOC_MEMSET == 1
   98758             : #elif ROSE_ALLOC_MEMSET == 2
   98759             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgUpcNotifyStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   98760             : #elif ROSE_ALLOC_MEMSET == 3
   98761             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgUpcNotifyStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   98762             : #endif
   98763           0 :     object->p_freepointer = fp;
   98764             : 
   98765             : #if ROSE_ALLOC_TRACE == 2
   98766             : //    printf("SgUpcNotifyStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUpcNotifyStatement::next_node);
   98767             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   98768             :     Rose::MemPool::snapshot(oss.str());
   98769             :     alloc_trace_cnt++;
   98770             : #endif
   98771             : 
   98772           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   98773             : 
   98774           0 :     ALLOC_MUTEX(SgUpcNotifyStatement, unlock);
   98775             : 
   98776             :     return object;
   98777             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   98778             : }
   98779             : 
   98780             : 
   98781             : 
   98782             : /*! \brief Delete operator for SgUpcNotifyStatement.
   98783             : 
   98784             :    This delete operator implements deallocation using memory pools to 
   98785             :    provide most efficent use of the heap within construction of large ASTs.
   98786             : 
   98787             : \internal The new and delete operators use the lower level C malloc/free
   98788             :    function calls for performance and to make sure that mixing of malloc/free
   98789             :    and new/delete by the used can be caught more readily.  This may change
   98790             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   98791             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   98792             :    deallocate memory allocated using ROSE_MALLOC.
   98793             : */
   98794           0 : void SgUpcNotifyStatement::operator delete(void *Pointer, size_t Size)
   98795             : {
   98796             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   98797             :      * or throwing an exception. */
   98798           0 :     ALLOC_MUTEX(SgUpcNotifyStatement, lock);
   98799             : 
   98800             : #if USE_CPP_NEW_DELETE_OPERATORS
   98801             :     ROSE_FREE(Pointer);
   98802             : #else
   98803             : #if ROSE_PEDANTIC_ALLOC
   98804             :     ROSE_ASSERT(Size == sizeof(SgUpcNotifyStatement));
   98805             : #else
   98806           0 :     if (Size != sizeof(SgUpcNotifyStatement)) {
   98807           0 :       ROSE_FREE(Pointer);
   98808           0 :       ALLOC_MUTEX(SgUpcNotifyStatement, unlock);
   98809             :       return;
   98810             :     }
   98811             : #endif
   98812             : 
   98813           0 :     SgUpcNotifyStatement * object = (SgUpcNotifyStatement*) Pointer;
   98814           0 :     ROSE_ASSERT(object != nullptr);
   98815             : 
   98816             : #if ROSE_ALLOC_TRACE == 2
   98817             : //  printf("SgUpcNotifyStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUpcNotifyStatement::next_node);
   98818             :     printf("SgUpcNotifyStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUpcNotifyStatement::next_node);
   98819             : #endif
   98820             : 
   98821             : #if ROSE_PEDANTIC_ALLOC
   98822             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   98823             : #endif
   98824             : 
   98825             : #if ROSE_ALLOC_MEMSET == 1
   98826             : #elif ROSE_ALLOC_MEMSET == 2
   98827             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgUpcNotifyStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   98828             : #elif ROSE_ALLOC_MEMSET == 3
   98829             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgUpcNotifyStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   98830             : #endif
   98831             : 
   98832             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   98833             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   98834             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   98835             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   98836             : #else
   98837           0 :     object->p_freepointer = SgUpcNotifyStatement::next_node;
   98838           0 :     SgUpcNotifyStatement::next_node = object;
   98839             : #endif
   98840             : 
   98841             : #if ROSE_ALLOC_TRACE == 2
   98842             : //  printf("SgUpcNotifyStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUpcNotifyStatement::next_node);
   98843             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   98844             :     Rose::MemPool::snapshot(oss.str());
   98845             :     alloc_trace_cnt++;
   98846             : #endif
   98847             : 
   98848             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   98849             : 
   98850           0 :     ALLOC_MUTEX(SgUpcNotifyStatement, unlock);
   98851             : }
   98852             : 
   98853             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   98854             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   98855             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   98856             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   98857             : // Also, note comment below from Robb (copied from the Common.code file).
   98858             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   98859             : //
   98860             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   98861             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   98862             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   98863             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   98864             : #if 0
   98865             : void SgUpcNotifyStatement::operator delete(void* pointer) { SgUpcNotifyStatement::operator delete (pointer, sizeof(SgUpcNotifyStatement)); };
   98866             : #endif
   98867             : /* #line 98868 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   98868             : 
   98869             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   98870             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   98871             : // obviously imply C++.
   98872             : 
   98873             : // This implements the support within ROSE for memory pools.  Memory pools
   98874             : // support the most condensed usage of memory within the construction of
   98875             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   98876             : // by a new operator written for each class.
   98877             : 
   98878             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   98879             :     // User wants multi-thread support and POSIX threads are available.
   98880             : #   include <pthread.h>
   98881             :     static pthread_mutex_t SgUpcWaitStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   98882             : #else
   98883             :      // Cause synchronization to be skipped.
   98884             : #    ifndef ALLOC_MUTEX
   98885             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   98886             : #    endif
   98887             : #    ifdef _REENTRANT
   98888             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   98889             : #       ifdef _MSC_VER
   98890             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   98891             : #       else
   98892             : #           warning "POSIX threads are not available; synchronization being skipped"
   98893             : #       endif
   98894             : #    endif
   98895             : #endif
   98896             : 
   98897             : #ifndef ROSE_ALLOC_TRACE
   98898             : #  define ROSE_ALLOC_TRACE 0
   98899             : #endif
   98900             : 
   98901             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   98902             : #define ROSE_ALLOC_TRACE_CNT
   98903             : #include "memory-pool-snapshot.h"
   98904             : unsigned long alloc_trace_cnt = 0;
   98905             : #endif
   98906             : 
   98907             : #if ROSE_ALLOC_TRACE
   98908             : const unsigned SgUpcWaitStatement::pool_size = 5;
   98909             : #else
   98910             : const unsigned SgUpcWaitStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   98911             : #endif
   98912             : 
   98913             : #ifndef ROSE_ALLOC_MEMSET
   98914             : #  define ROSE_ALLOC_MEMSET 0
   98915             : #endif
   98916             : 
   98917             : #ifndef ROSE_PEDANTIC_ALLOC
   98918             : #  define ROSE_PEDANTIC_ALLOC 0
   98919             : #endif
   98920             : 
   98921             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   98922             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   98923             : #endif
   98924             : 
   98925             : #if !defined(SGNODE__ALL_POOLS)
   98926             : #define SGNODE__ALL_POOLS
   98927             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   98928             : #endif
   98929             : 
   98930             : SgUpcWaitStatement* SgUpcWaitStatement::next_node = nullptr;
   98931             : std::vector<unsigned char*> SgUpcWaitStatement::pools;
   98932             : 
   98933             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   98934             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   98935             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   98936             : // around this macro definition rather than each use).
   98937             : #ifndef ALLOC_MUTEX
   98938             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   98939             :         do {                                                                     \
   98940             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   98941             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   98942             :                 abort();                                                         \
   98943             :             }                                                                    \
   98944             :         } while (0);
   98945             : #endif
   98946             : 
   98947             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   98948             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   98949             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   98950             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   98951             : 
   98952             : /*! \brief New operator for SgUpcWaitStatement.
   98953             : 
   98954             :    This new operator implements memory pools to provide most efficent 
   98955             :    use of the heap within construction of large ASTs.
   98956             : 
   98957             : \internal The new and delete operators use the lower level C malloc/free
   98958             :    function calls for performance and to make sure that mixing of malloc/free
   98959             :    and new/delete by the used can be caught more readily.  This may change
   98960             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   98961             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   98962             :    deallocate memory allocated using ROSE_MALLOC.
   98963             : */
   98964           0 : void *SgUpcWaitStatement::operator new ( size_t Size )
   98965             : {
   98966             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   98967             :      * returning or throwing an exception. */
   98968           0 :     ALLOC_MUTEX(SgUpcWaitStatement, lock);
   98969             : 
   98970             : #if ROSE_ALLOC_TRACE == 2
   98971             : //    printf("SgUpcWaitStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgUpcWaitStatement::next_node);
   98972             : #endif
   98973             : 
   98974             : #if USE_CPP_NEW_DELETE_OPERATORS
   98975             :     void *mem = ROSE_MALLOC(Size);
   98976             :     ALLOC_MUTEX(SgUpcWaitStatement, unlock);
   98977             :     return mem;
   98978             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   98979             : #if ROSE_PEDANTIC_ALLOC
   98980             :     ROSE_ASSERT(Size == sizeof(SgUpcWaitStatement));
   98981             : #else
   98982           0 :     if (Size != sizeof(SgUpcWaitStatement)) {
   98983           0 :       void * object = ROSE_MALLOC(Size);
   98984           0 :       ALLOC_MUTEX(SgUpcWaitStatement, unlock);
   98985             :       return object;
   98986             :     }
   98987             : #endif
   98988             : 
   98989           0 :     if (SgUpcWaitStatement::next_node == nullptr) {
   98990           0 :         SgUpcWaitStatement * alloc = (SgUpcWaitStatement*) ROSE_MALLOC ( SgUpcWaitStatement::pool_size * sizeof(SgUpcWaitStatement) );
   98991           0 :         ROSE_ASSERT(alloc != nullptr);
   98992             : 
   98993             : #if ROSE_ALLOC_TRACE == 2
   98994             : //        printf("SgUpcWaitStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgUpcWaitStatement::pools.size(), alloc, alloc + SgUpcWaitStatement::pool_size);
   98995             : #endif
   98996             : 
   98997             : #if ROSE_ALLOC_MEMSET == 1
   98998             : #elif ROSE_ALLOC_MEMSET == 2
   98999             :         memset(alloc, 0x00, SgUpcWaitStatement::pool_size * sizeof(SgUpcWaitStatement));
   99000             : #elif ROSE_ALLOC_MEMSET == 3
   99001             :         memset(alloc, 0xAA, SgUpcWaitStatement::pool_size * sizeof(SgUpcWaitStatement));
   99002             : #endif
   99003           0 :         for (unsigned i=0; i < SgUpcWaitStatement::pool_size-1; i++) {
   99004           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
   99005             :         }
   99006           0 :         alloc[SgUpcWaitStatement::pool_size-1].p_freepointer = nullptr;
   99007             : 
   99008           0 :         SgUpcWaitStatement::pools.push_back ( (unsigned char *) alloc );
   99009           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgUpcWaitStatement::pool_size * sizeof(SgUpcWaitStatement), V_SgUpcWaitStatement ) );
   99010           0 :         SgUpcWaitStatement::next_node = alloc;
   99011             :     }
   99012           0 :     ROSE_ASSERT(SgUpcWaitStatement::next_node != nullptr);
   99013             : 
   99014           0 :     SgUpcWaitStatement * object = SgUpcWaitStatement::next_node;
   99015           0 :     SgUpcWaitStatement::next_node = (SgUpcWaitStatement*)(object->p_freepointer);
   99016             : 
   99017             : #if ROSE_ALLOC_TRACE == 2
   99018             :     printf("SgUpcWaitStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUpcWaitStatement::next_node);
   99019             : #endif
   99020             : 
   99021           0 :     SgNode * fp = object->p_freepointer;
   99022             : #if ROSE_ALLOC_MEMSET == 1
   99023             : #elif ROSE_ALLOC_MEMSET == 2
   99024             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgUpcWaitStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   99025             : #elif ROSE_ALLOC_MEMSET == 3
   99026             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgUpcWaitStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   99027             : #endif
   99028           0 :     object->p_freepointer = fp;
   99029             : 
   99030             : #if ROSE_ALLOC_TRACE == 2
   99031             : //    printf("SgUpcWaitStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUpcWaitStatement::next_node);
   99032             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   99033             :     Rose::MemPool::snapshot(oss.str());
   99034             :     alloc_trace_cnt++;
   99035             : #endif
   99036             : 
   99037           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   99038             : 
   99039           0 :     ALLOC_MUTEX(SgUpcWaitStatement, unlock);
   99040             : 
   99041             :     return object;
   99042             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   99043             : }
   99044             : 
   99045             : 
   99046             : 
   99047             : /*! \brief Delete operator for SgUpcWaitStatement.
   99048             : 
   99049             :    This delete operator implements deallocation using memory pools to 
   99050             :    provide most efficent use of the heap within construction of large ASTs.
   99051             : 
   99052             : \internal The new and delete operators use the lower level C malloc/free
   99053             :    function calls for performance and to make sure that mixing of malloc/free
   99054             :    and new/delete by the used can be caught more readily.  This may change
   99055             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   99056             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   99057             :    deallocate memory allocated using ROSE_MALLOC.
   99058             : */
   99059           0 : void SgUpcWaitStatement::operator delete(void *Pointer, size_t Size)
   99060             : {
   99061             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   99062             :      * or throwing an exception. */
   99063           0 :     ALLOC_MUTEX(SgUpcWaitStatement, lock);
   99064             : 
   99065             : #if USE_CPP_NEW_DELETE_OPERATORS
   99066             :     ROSE_FREE(Pointer);
   99067             : #else
   99068             : #if ROSE_PEDANTIC_ALLOC
   99069             :     ROSE_ASSERT(Size == sizeof(SgUpcWaitStatement));
   99070             : #else
   99071           0 :     if (Size != sizeof(SgUpcWaitStatement)) {
   99072           0 :       ROSE_FREE(Pointer);
   99073           0 :       ALLOC_MUTEX(SgUpcWaitStatement, unlock);
   99074             :       return;
   99075             :     }
   99076             : #endif
   99077             : 
   99078           0 :     SgUpcWaitStatement * object = (SgUpcWaitStatement*) Pointer;
   99079           0 :     ROSE_ASSERT(object != nullptr);
   99080             : 
   99081             : #if ROSE_ALLOC_TRACE == 2
   99082             : //  printf("SgUpcWaitStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUpcWaitStatement::next_node);
   99083             :     printf("SgUpcWaitStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUpcWaitStatement::next_node);
   99084             : #endif
   99085             : 
   99086             : #if ROSE_PEDANTIC_ALLOC
   99087             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   99088             : #endif
   99089             : 
   99090             : #if ROSE_ALLOC_MEMSET == 1
   99091             : #elif ROSE_ALLOC_MEMSET == 2
   99092             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgUpcWaitStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   99093             : #elif ROSE_ALLOC_MEMSET == 3
   99094             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgUpcWaitStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   99095             : #endif
   99096             : 
   99097             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   99098             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   99099             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   99100             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   99101             : #else
   99102           0 :     object->p_freepointer = SgUpcWaitStatement::next_node;
   99103           0 :     SgUpcWaitStatement::next_node = object;
   99104             : #endif
   99105             : 
   99106             : #if ROSE_ALLOC_TRACE == 2
   99107             : //  printf("SgUpcWaitStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUpcWaitStatement::next_node);
   99108             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   99109             :     Rose::MemPool::snapshot(oss.str());
   99110             :     alloc_trace_cnt++;
   99111             : #endif
   99112             : 
   99113             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   99114             : 
   99115           0 :     ALLOC_MUTEX(SgUpcWaitStatement, unlock);
   99116             : }
   99117             : 
   99118             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   99119             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   99120             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   99121             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   99122             : // Also, note comment below from Robb (copied from the Common.code file).
   99123             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   99124             : //
   99125             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   99126             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   99127             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   99128             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   99129             : #if 0
   99130             : void SgUpcWaitStatement::operator delete(void* pointer) { SgUpcWaitStatement::operator delete (pointer, sizeof(SgUpcWaitStatement)); };
   99131             : #endif
   99132             : /* #line 99133 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   99133             : 
   99134             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   99135             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   99136             : // obviously imply C++.
   99137             : 
   99138             : // This implements the support within ROSE for memory pools.  Memory pools
   99139             : // support the most condensed usage of memory within the construction of
   99140             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   99141             : // by a new operator written for each class.
   99142             : 
   99143             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   99144             :     // User wants multi-thread support and POSIX threads are available.
   99145             : #   include <pthread.h>
   99146             :     static pthread_mutex_t SgUpcBarrierStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   99147             : #else
   99148             :      // Cause synchronization to be skipped.
   99149             : #    ifndef ALLOC_MUTEX
   99150             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   99151             : #    endif
   99152             : #    ifdef _REENTRANT
   99153             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   99154             : #       ifdef _MSC_VER
   99155             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   99156             : #       else
   99157             : #           warning "POSIX threads are not available; synchronization being skipped"
   99158             : #       endif
   99159             : #    endif
   99160             : #endif
   99161             : 
   99162             : #ifndef ROSE_ALLOC_TRACE
   99163             : #  define ROSE_ALLOC_TRACE 0
   99164             : #endif
   99165             : 
   99166             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   99167             : #define ROSE_ALLOC_TRACE_CNT
   99168             : #include "memory-pool-snapshot.h"
   99169             : unsigned long alloc_trace_cnt = 0;
   99170             : #endif
   99171             : 
   99172             : #if ROSE_ALLOC_TRACE
   99173             : const unsigned SgUpcBarrierStatement::pool_size = 5;
   99174             : #else
   99175             : const unsigned SgUpcBarrierStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   99176             : #endif
   99177             : 
   99178             : #ifndef ROSE_ALLOC_MEMSET
   99179             : #  define ROSE_ALLOC_MEMSET 0
   99180             : #endif
   99181             : 
   99182             : #ifndef ROSE_PEDANTIC_ALLOC
   99183             : #  define ROSE_PEDANTIC_ALLOC 0
   99184             : #endif
   99185             : 
   99186             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   99187             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   99188             : #endif
   99189             : 
   99190             : #if !defined(SGNODE__ALL_POOLS)
   99191             : #define SGNODE__ALL_POOLS
   99192             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   99193             : #endif
   99194             : 
   99195             : SgUpcBarrierStatement* SgUpcBarrierStatement::next_node = nullptr;
   99196             : std::vector<unsigned char*> SgUpcBarrierStatement::pools;
   99197             : 
   99198             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   99199             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   99200             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   99201             : // around this macro definition rather than each use).
   99202             : #ifndef ALLOC_MUTEX
   99203             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   99204             :         do {                                                                     \
   99205             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   99206             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   99207             :                 abort();                                                         \
   99208             :             }                                                                    \
   99209             :         } while (0);
   99210             : #endif
   99211             : 
   99212             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   99213             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   99214             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   99215             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   99216             : 
   99217             : /*! \brief New operator for SgUpcBarrierStatement.
   99218             : 
   99219             :    This new operator implements memory pools to provide most efficent 
   99220             :    use of the heap within construction of large ASTs.
   99221             : 
   99222             : \internal The new and delete operators use the lower level C malloc/free
   99223             :    function calls for performance and to make sure that mixing of malloc/free
   99224             :    and new/delete by the used can be caught more readily.  This may change
   99225             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   99226             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   99227             :    deallocate memory allocated using ROSE_MALLOC.
   99228             : */
   99229           0 : void *SgUpcBarrierStatement::operator new ( size_t Size )
   99230             : {
   99231             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   99232             :      * returning or throwing an exception. */
   99233           0 :     ALLOC_MUTEX(SgUpcBarrierStatement, lock);
   99234             : 
   99235             : #if ROSE_ALLOC_TRACE == 2
   99236             : //    printf("SgUpcBarrierStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgUpcBarrierStatement::next_node);
   99237             : #endif
   99238             : 
   99239             : #if USE_CPP_NEW_DELETE_OPERATORS
   99240             :     void *mem = ROSE_MALLOC(Size);
   99241             :     ALLOC_MUTEX(SgUpcBarrierStatement, unlock);
   99242             :     return mem;
   99243             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   99244             : #if ROSE_PEDANTIC_ALLOC
   99245             :     ROSE_ASSERT(Size == sizeof(SgUpcBarrierStatement));
   99246             : #else
   99247           0 :     if (Size != sizeof(SgUpcBarrierStatement)) {
   99248           0 :       void * object = ROSE_MALLOC(Size);
   99249           0 :       ALLOC_MUTEX(SgUpcBarrierStatement, unlock);
   99250             :       return object;
   99251             :     }
   99252             : #endif
   99253             : 
   99254           0 :     if (SgUpcBarrierStatement::next_node == nullptr) {
   99255           0 :         SgUpcBarrierStatement * alloc = (SgUpcBarrierStatement*) ROSE_MALLOC ( SgUpcBarrierStatement::pool_size * sizeof(SgUpcBarrierStatement) );
   99256           0 :         ROSE_ASSERT(alloc != nullptr);
   99257             : 
   99258             : #if ROSE_ALLOC_TRACE == 2
   99259             : //        printf("SgUpcBarrierStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgUpcBarrierStatement::pools.size(), alloc, alloc + SgUpcBarrierStatement::pool_size);
   99260             : #endif
   99261             : 
   99262             : #if ROSE_ALLOC_MEMSET == 1
   99263             : #elif ROSE_ALLOC_MEMSET == 2
   99264             :         memset(alloc, 0x00, SgUpcBarrierStatement::pool_size * sizeof(SgUpcBarrierStatement));
   99265             : #elif ROSE_ALLOC_MEMSET == 3
   99266             :         memset(alloc, 0xAA, SgUpcBarrierStatement::pool_size * sizeof(SgUpcBarrierStatement));
   99267             : #endif
   99268           0 :         for (unsigned i=0; i < SgUpcBarrierStatement::pool_size-1; i++) {
   99269           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
   99270             :         }
   99271           0 :         alloc[SgUpcBarrierStatement::pool_size-1].p_freepointer = nullptr;
   99272             : 
   99273           0 :         SgUpcBarrierStatement::pools.push_back ( (unsigned char *) alloc );
   99274           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgUpcBarrierStatement::pool_size * sizeof(SgUpcBarrierStatement), V_SgUpcBarrierStatement ) );
   99275           0 :         SgUpcBarrierStatement::next_node = alloc;
   99276             :     }
   99277           0 :     ROSE_ASSERT(SgUpcBarrierStatement::next_node != nullptr);
   99278             : 
   99279           0 :     SgUpcBarrierStatement * object = SgUpcBarrierStatement::next_node;
   99280           0 :     SgUpcBarrierStatement::next_node = (SgUpcBarrierStatement*)(object->p_freepointer);
   99281             : 
   99282             : #if ROSE_ALLOC_TRACE == 2
   99283             :     printf("SgUpcBarrierStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUpcBarrierStatement::next_node);
   99284             : #endif
   99285             : 
   99286           0 :     SgNode * fp = object->p_freepointer;
   99287             : #if ROSE_ALLOC_MEMSET == 1
   99288             : #elif ROSE_ALLOC_MEMSET == 2
   99289             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgUpcBarrierStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   99290             : #elif ROSE_ALLOC_MEMSET == 3
   99291             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgUpcBarrierStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   99292             : #endif
   99293           0 :     object->p_freepointer = fp;
   99294             : 
   99295             : #if ROSE_ALLOC_TRACE == 2
   99296             : //    printf("SgUpcBarrierStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUpcBarrierStatement::next_node);
   99297             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   99298             :     Rose::MemPool::snapshot(oss.str());
   99299             :     alloc_trace_cnt++;
   99300             : #endif
   99301             : 
   99302           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   99303             : 
   99304           0 :     ALLOC_MUTEX(SgUpcBarrierStatement, unlock);
   99305             : 
   99306             :     return object;
   99307             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   99308             : }
   99309             : 
   99310             : 
   99311             : 
   99312             : /*! \brief Delete operator for SgUpcBarrierStatement.
   99313             : 
   99314             :    This delete operator implements deallocation using memory pools to 
   99315             :    provide most efficent use of the heap within construction of large ASTs.
   99316             : 
   99317             : \internal The new and delete operators use the lower level C malloc/free
   99318             :    function calls for performance and to make sure that mixing of malloc/free
   99319             :    and new/delete by the used can be caught more readily.  This may change
   99320             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   99321             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   99322             :    deallocate memory allocated using ROSE_MALLOC.
   99323             : */
   99324           0 : void SgUpcBarrierStatement::operator delete(void *Pointer, size_t Size)
   99325             : {
   99326             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   99327             :      * or throwing an exception. */
   99328           0 :     ALLOC_MUTEX(SgUpcBarrierStatement, lock);
   99329             : 
   99330             : #if USE_CPP_NEW_DELETE_OPERATORS
   99331             :     ROSE_FREE(Pointer);
   99332             : #else
   99333             : #if ROSE_PEDANTIC_ALLOC
   99334             :     ROSE_ASSERT(Size == sizeof(SgUpcBarrierStatement));
   99335             : #else
   99336           0 :     if (Size != sizeof(SgUpcBarrierStatement)) {
   99337           0 :       ROSE_FREE(Pointer);
   99338           0 :       ALLOC_MUTEX(SgUpcBarrierStatement, unlock);
   99339             :       return;
   99340             :     }
   99341             : #endif
   99342             : 
   99343           0 :     SgUpcBarrierStatement * object = (SgUpcBarrierStatement*) Pointer;
   99344           0 :     ROSE_ASSERT(object != nullptr);
   99345             : 
   99346             : #if ROSE_ALLOC_TRACE == 2
   99347             : //  printf("SgUpcBarrierStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUpcBarrierStatement::next_node);
   99348             :     printf("SgUpcBarrierStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUpcBarrierStatement::next_node);
   99349             : #endif
   99350             : 
   99351             : #if ROSE_PEDANTIC_ALLOC
   99352             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   99353             : #endif
   99354             : 
   99355             : #if ROSE_ALLOC_MEMSET == 1
   99356             : #elif ROSE_ALLOC_MEMSET == 2
   99357             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgUpcBarrierStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   99358             : #elif ROSE_ALLOC_MEMSET == 3
   99359             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgUpcBarrierStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   99360             : #endif
   99361             : 
   99362             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   99363             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   99364             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   99365             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   99366             : #else
   99367           0 :     object->p_freepointer = SgUpcBarrierStatement::next_node;
   99368           0 :     SgUpcBarrierStatement::next_node = object;
   99369             : #endif
   99370             : 
   99371             : #if ROSE_ALLOC_TRACE == 2
   99372             : //  printf("SgUpcBarrierStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUpcBarrierStatement::next_node);
   99373             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   99374             :     Rose::MemPool::snapshot(oss.str());
   99375             :     alloc_trace_cnt++;
   99376             : #endif
   99377             : 
   99378             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   99379             : 
   99380           0 :     ALLOC_MUTEX(SgUpcBarrierStatement, unlock);
   99381             : }
   99382             : 
   99383             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   99384             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   99385             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   99386             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   99387             : // Also, note comment below from Robb (copied from the Common.code file).
   99388             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   99389             : //
   99390             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   99391             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   99392             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   99393             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   99394             : #if 0
   99395             : void SgUpcBarrierStatement::operator delete(void* pointer) { SgUpcBarrierStatement::operator delete (pointer, sizeof(SgUpcBarrierStatement)); };
   99396             : #endif
   99397             : /* #line 99398 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   99398             : 
   99399             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   99400             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   99401             : // obviously imply C++.
   99402             : 
   99403             : // This implements the support within ROSE for memory pools.  Memory pools
   99404             : // support the most condensed usage of memory within the construction of
   99405             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   99406             : // by a new operator written for each class.
   99407             : 
   99408             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   99409             :     // User wants multi-thread support and POSIX threads are available.
   99410             : #   include <pthread.h>
   99411             :     static pthread_mutex_t SgUpcFenceStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   99412             : #else
   99413             :      // Cause synchronization to be skipped.
   99414             : #    ifndef ALLOC_MUTEX
   99415             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   99416             : #    endif
   99417             : #    ifdef _REENTRANT
   99418             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   99419             : #       ifdef _MSC_VER
   99420             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   99421             : #       else
   99422             : #           warning "POSIX threads are not available; synchronization being skipped"
   99423             : #       endif
   99424             : #    endif
   99425             : #endif
   99426             : 
   99427             : #ifndef ROSE_ALLOC_TRACE
   99428             : #  define ROSE_ALLOC_TRACE 0
   99429             : #endif
   99430             : 
   99431             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   99432             : #define ROSE_ALLOC_TRACE_CNT
   99433             : #include "memory-pool-snapshot.h"
   99434             : unsigned long alloc_trace_cnt = 0;
   99435             : #endif
   99436             : 
   99437             : #if ROSE_ALLOC_TRACE
   99438             : const unsigned SgUpcFenceStatement::pool_size = 5;
   99439             : #else
   99440             : const unsigned SgUpcFenceStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   99441             : #endif
   99442             : 
   99443             : #ifndef ROSE_ALLOC_MEMSET
   99444             : #  define ROSE_ALLOC_MEMSET 0
   99445             : #endif
   99446             : 
   99447             : #ifndef ROSE_PEDANTIC_ALLOC
   99448             : #  define ROSE_PEDANTIC_ALLOC 0
   99449             : #endif
   99450             : 
   99451             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   99452             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   99453             : #endif
   99454             : 
   99455             : #if !defined(SGNODE__ALL_POOLS)
   99456             : #define SGNODE__ALL_POOLS
   99457             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   99458             : #endif
   99459             : 
   99460             : SgUpcFenceStatement* SgUpcFenceStatement::next_node = nullptr;
   99461             : std::vector<unsigned char*> SgUpcFenceStatement::pools;
   99462             : 
   99463             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   99464             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   99465             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   99466             : // around this macro definition rather than each use).
   99467             : #ifndef ALLOC_MUTEX
   99468             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   99469             :         do {                                                                     \
   99470             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   99471             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   99472             :                 abort();                                                         \
   99473             :             }                                                                    \
   99474             :         } while (0);
   99475             : #endif
   99476             : 
   99477             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   99478             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   99479             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   99480             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   99481             : 
   99482             : /*! \brief New operator for SgUpcFenceStatement.
   99483             : 
   99484             :    This new operator implements memory pools to provide most efficent 
   99485             :    use of the heap within construction of large ASTs.
   99486             : 
   99487             : \internal The new and delete operators use the lower level C malloc/free
   99488             :    function calls for performance and to make sure that mixing of malloc/free
   99489             :    and new/delete by the used can be caught more readily.  This may change
   99490             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   99491             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   99492             :    deallocate memory allocated using ROSE_MALLOC.
   99493             : */
   99494           0 : void *SgUpcFenceStatement::operator new ( size_t Size )
   99495             : {
   99496             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   99497             :      * returning or throwing an exception. */
   99498           0 :     ALLOC_MUTEX(SgUpcFenceStatement, lock);
   99499             : 
   99500             : #if ROSE_ALLOC_TRACE == 2
   99501             : //    printf("SgUpcFenceStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgUpcFenceStatement::next_node);
   99502             : #endif
   99503             : 
   99504             : #if USE_CPP_NEW_DELETE_OPERATORS
   99505             :     void *mem = ROSE_MALLOC(Size);
   99506             :     ALLOC_MUTEX(SgUpcFenceStatement, unlock);
   99507             :     return mem;
   99508             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   99509             : #if ROSE_PEDANTIC_ALLOC
   99510             :     ROSE_ASSERT(Size == sizeof(SgUpcFenceStatement));
   99511             : #else
   99512           0 :     if (Size != sizeof(SgUpcFenceStatement)) {
   99513           0 :       void * object = ROSE_MALLOC(Size);
   99514           0 :       ALLOC_MUTEX(SgUpcFenceStatement, unlock);
   99515             :       return object;
   99516             :     }
   99517             : #endif
   99518             : 
   99519           0 :     if (SgUpcFenceStatement::next_node == nullptr) {
   99520           0 :         SgUpcFenceStatement * alloc = (SgUpcFenceStatement*) ROSE_MALLOC ( SgUpcFenceStatement::pool_size * sizeof(SgUpcFenceStatement) );
   99521           0 :         ROSE_ASSERT(alloc != nullptr);
   99522             : 
   99523             : #if ROSE_ALLOC_TRACE == 2
   99524             : //        printf("SgUpcFenceStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgUpcFenceStatement::pools.size(), alloc, alloc + SgUpcFenceStatement::pool_size);
   99525             : #endif
   99526             : 
   99527             : #if ROSE_ALLOC_MEMSET == 1
   99528             : #elif ROSE_ALLOC_MEMSET == 2
   99529             :         memset(alloc, 0x00, SgUpcFenceStatement::pool_size * sizeof(SgUpcFenceStatement));
   99530             : #elif ROSE_ALLOC_MEMSET == 3
   99531             :         memset(alloc, 0xAA, SgUpcFenceStatement::pool_size * sizeof(SgUpcFenceStatement));
   99532             : #endif
   99533           0 :         for (unsigned i=0; i < SgUpcFenceStatement::pool_size-1; i++) {
   99534           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
   99535             :         }
   99536           0 :         alloc[SgUpcFenceStatement::pool_size-1].p_freepointer = nullptr;
   99537             : 
   99538           0 :         SgUpcFenceStatement::pools.push_back ( (unsigned char *) alloc );
   99539           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgUpcFenceStatement::pool_size * sizeof(SgUpcFenceStatement), V_SgUpcFenceStatement ) );
   99540           0 :         SgUpcFenceStatement::next_node = alloc;
   99541             :     }
   99542           0 :     ROSE_ASSERT(SgUpcFenceStatement::next_node != nullptr);
   99543             : 
   99544           0 :     SgUpcFenceStatement * object = SgUpcFenceStatement::next_node;
   99545           0 :     SgUpcFenceStatement::next_node = (SgUpcFenceStatement*)(object->p_freepointer);
   99546             : 
   99547             : #if ROSE_ALLOC_TRACE == 2
   99548             :     printf("SgUpcFenceStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUpcFenceStatement::next_node);
   99549             : #endif
   99550             : 
   99551           0 :     SgNode * fp = object->p_freepointer;
   99552             : #if ROSE_ALLOC_MEMSET == 1
   99553             : #elif ROSE_ALLOC_MEMSET == 2
   99554             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgUpcFenceStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   99555             : #elif ROSE_ALLOC_MEMSET == 3
   99556             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgUpcFenceStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   99557             : #endif
   99558           0 :     object->p_freepointer = fp;
   99559             : 
   99560             : #if ROSE_ALLOC_TRACE == 2
   99561             : //    printf("SgUpcFenceStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUpcFenceStatement::next_node);
   99562             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   99563             :     Rose::MemPool::snapshot(oss.str());
   99564             :     alloc_trace_cnt++;
   99565             : #endif
   99566             : 
   99567           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   99568             : 
   99569           0 :     ALLOC_MUTEX(SgUpcFenceStatement, unlock);
   99570             : 
   99571             :     return object;
   99572             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   99573             : }
   99574             : 
   99575             : 
   99576             : 
   99577             : /*! \brief Delete operator for SgUpcFenceStatement.
   99578             : 
   99579             :    This delete operator implements deallocation using memory pools to 
   99580             :    provide most efficent use of the heap within construction of large ASTs.
   99581             : 
   99582             : \internal The new and delete operators use the lower level C malloc/free
   99583             :    function calls for performance and to make sure that mixing of malloc/free
   99584             :    and new/delete by the used can be caught more readily.  This may change
   99585             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   99586             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   99587             :    deallocate memory allocated using ROSE_MALLOC.
   99588             : */
   99589           0 : void SgUpcFenceStatement::operator delete(void *Pointer, size_t Size)
   99590             : {
   99591             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   99592             :      * or throwing an exception. */
   99593           0 :     ALLOC_MUTEX(SgUpcFenceStatement, lock);
   99594             : 
   99595             : #if USE_CPP_NEW_DELETE_OPERATORS
   99596             :     ROSE_FREE(Pointer);
   99597             : #else
   99598             : #if ROSE_PEDANTIC_ALLOC
   99599             :     ROSE_ASSERT(Size == sizeof(SgUpcFenceStatement));
   99600             : #else
   99601           0 :     if (Size != sizeof(SgUpcFenceStatement)) {
   99602           0 :       ROSE_FREE(Pointer);
   99603           0 :       ALLOC_MUTEX(SgUpcFenceStatement, unlock);
   99604             :       return;
   99605             :     }
   99606             : #endif
   99607             : 
   99608           0 :     SgUpcFenceStatement * object = (SgUpcFenceStatement*) Pointer;
   99609           0 :     ROSE_ASSERT(object != nullptr);
   99610             : 
   99611             : #if ROSE_ALLOC_TRACE == 2
   99612             : //  printf("SgUpcFenceStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUpcFenceStatement::next_node);
   99613             :     printf("SgUpcFenceStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUpcFenceStatement::next_node);
   99614             : #endif
   99615             : 
   99616             : #if ROSE_PEDANTIC_ALLOC
   99617             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   99618             : #endif
   99619             : 
   99620             : #if ROSE_ALLOC_MEMSET == 1
   99621             : #elif ROSE_ALLOC_MEMSET == 2
   99622             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgUpcFenceStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   99623             : #elif ROSE_ALLOC_MEMSET == 3
   99624             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgUpcFenceStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   99625             : #endif
   99626             : 
   99627             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   99628             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   99629             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   99630             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   99631             : #else
   99632           0 :     object->p_freepointer = SgUpcFenceStatement::next_node;
   99633           0 :     SgUpcFenceStatement::next_node = object;
   99634             : #endif
   99635             : 
   99636             : #if ROSE_ALLOC_TRACE == 2
   99637             : //  printf("SgUpcFenceStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUpcFenceStatement::next_node);
   99638             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   99639             :     Rose::MemPool::snapshot(oss.str());
   99640             :     alloc_trace_cnt++;
   99641             : #endif
   99642             : 
   99643             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   99644             : 
   99645           0 :     ALLOC_MUTEX(SgUpcFenceStatement, unlock);
   99646             : }
   99647             : 
   99648             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   99649             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   99650             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   99651             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   99652             : // Also, note comment below from Robb (copied from the Common.code file).
   99653             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   99654             : //
   99655             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   99656             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   99657             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   99658             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   99659             : #if 0
   99660             : void SgUpcFenceStatement::operator delete(void* pointer) { SgUpcFenceStatement::operator delete (pointer, sizeof(SgUpcFenceStatement)); };
   99661             : #endif
   99662             : /* #line 99663 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   99663             : 
   99664             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   99665             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   99666             : // obviously imply C++.
   99667             : 
   99668             : // This implements the support within ROSE for memory pools.  Memory pools
   99669             : // support the most condensed usage of memory within the construction of
   99670             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   99671             : // by a new operator written for each class.
   99672             : 
   99673             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   99674             :     // User wants multi-thread support and POSIX threads are available.
   99675             : #   include <pthread.h>
   99676             :     static pthread_mutex_t SgUpirBaseStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   99677             : #else
   99678             :      // Cause synchronization to be skipped.
   99679             : #    ifndef ALLOC_MUTEX
   99680             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   99681             : #    endif
   99682             : #    ifdef _REENTRANT
   99683             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   99684             : #       ifdef _MSC_VER
   99685             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   99686             : #       else
   99687             : #           warning "POSIX threads are not available; synchronization being skipped"
   99688             : #       endif
   99689             : #    endif
   99690             : #endif
   99691             : 
   99692             : #ifndef ROSE_ALLOC_TRACE
   99693             : #  define ROSE_ALLOC_TRACE 0
   99694             : #endif
   99695             : 
   99696             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   99697             : #define ROSE_ALLOC_TRACE_CNT
   99698             : #include "memory-pool-snapshot.h"
   99699             : unsigned long alloc_trace_cnt = 0;
   99700             : #endif
   99701             : 
   99702             : #if ROSE_ALLOC_TRACE
   99703             : const unsigned SgUpirBaseStatement::pool_size = 5;
   99704             : #else
   99705             : const unsigned SgUpirBaseStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   99706             : #endif
   99707             : 
   99708             : #ifndef ROSE_ALLOC_MEMSET
   99709             : #  define ROSE_ALLOC_MEMSET 0
   99710             : #endif
   99711             : 
   99712             : #ifndef ROSE_PEDANTIC_ALLOC
   99713             : #  define ROSE_PEDANTIC_ALLOC 0
   99714             : #endif
   99715             : 
   99716             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   99717             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   99718             : #endif
   99719             : 
   99720             : #if !defined(SGNODE__ALL_POOLS)
   99721             : #define SGNODE__ALL_POOLS
   99722             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   99723             : #endif
   99724             : 
   99725             : SgUpirBaseStatement* SgUpirBaseStatement::next_node = nullptr;
   99726             : std::vector<unsigned char*> SgUpirBaseStatement::pools;
   99727             : 
   99728             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   99729             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   99730             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   99731             : // around this macro definition rather than each use).
   99732             : #ifndef ALLOC_MUTEX
   99733             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   99734             :         do {                                                                     \
   99735             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
   99736             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
   99737             :                 abort();                                                         \
   99738             :             }                                                                    \
   99739             :         } while (0);
   99740             : #endif
   99741             : 
   99742             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
   99743             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
   99744             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
   99745             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
   99746             : 
   99747             : /*! \brief New operator for SgUpirBaseStatement.
   99748             : 
   99749             :    This new operator implements memory pools to provide most efficent 
   99750             :    use of the heap within construction of large ASTs.
   99751             : 
   99752             : \internal The new and delete operators use the lower level C malloc/free
   99753             :    function calls for performance and to make sure that mixing of malloc/free
   99754             :    and new/delete by the used can be caught more readily.  This may change
   99755             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   99756             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   99757             :    deallocate memory allocated using ROSE_MALLOC.
   99758             : */
   99759           0 : void *SgUpirBaseStatement::operator new ( size_t Size )
   99760             : {
   99761             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
   99762             :      * returning or throwing an exception. */
   99763           0 :     ALLOC_MUTEX(SgUpirBaseStatement, lock);
   99764             : 
   99765             : #if ROSE_ALLOC_TRACE == 2
   99766             : //    printf("SgUpirBaseStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgUpirBaseStatement::next_node);
   99767             : #endif
   99768             : 
   99769             : #if USE_CPP_NEW_DELETE_OPERATORS
   99770             :     void *mem = ROSE_MALLOC(Size);
   99771             :     ALLOC_MUTEX(SgUpirBaseStatement, unlock);
   99772             :     return mem;
   99773             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
   99774             : #if ROSE_PEDANTIC_ALLOC
   99775             :     ROSE_ASSERT(Size == sizeof(SgUpirBaseStatement));
   99776             : #else
   99777           0 :     if (Size != sizeof(SgUpirBaseStatement)) {
   99778           0 :       void * object = ROSE_MALLOC(Size);
   99779           0 :       ALLOC_MUTEX(SgUpirBaseStatement, unlock);
   99780             :       return object;
   99781             :     }
   99782             : #endif
   99783             : 
   99784           0 :     if (SgUpirBaseStatement::next_node == nullptr) {
   99785           0 :         SgUpirBaseStatement * alloc = (SgUpirBaseStatement*) ROSE_MALLOC ( SgUpirBaseStatement::pool_size * sizeof(SgUpirBaseStatement) );
   99786           0 :         ROSE_ASSERT(alloc != nullptr);
   99787             : 
   99788             : #if ROSE_ALLOC_TRACE == 2
   99789             : //        printf("SgUpirBaseStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgUpirBaseStatement::pools.size(), alloc, alloc + SgUpirBaseStatement::pool_size);
   99790             : #endif
   99791             : 
   99792             : #if ROSE_ALLOC_MEMSET == 1
   99793             : #elif ROSE_ALLOC_MEMSET == 2
   99794             :         memset(alloc, 0x00, SgUpirBaseStatement::pool_size * sizeof(SgUpirBaseStatement));
   99795             : #elif ROSE_ALLOC_MEMSET == 3
   99796             :         memset(alloc, 0xAA, SgUpirBaseStatement::pool_size * sizeof(SgUpirBaseStatement));
   99797             : #endif
   99798           0 :         for (unsigned i=0; i < SgUpirBaseStatement::pool_size-1; i++) {
   99799           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
   99800             :         }
   99801           0 :         alloc[SgUpirBaseStatement::pool_size-1].p_freepointer = nullptr;
   99802             : 
   99803           0 :         SgUpirBaseStatement::pools.push_back ( (unsigned char *) alloc );
   99804           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgUpirBaseStatement::pool_size * sizeof(SgUpirBaseStatement), V_SgUpirBaseStatement ) );
   99805           0 :         SgUpirBaseStatement::next_node = alloc;
   99806             :     }
   99807           0 :     ROSE_ASSERT(SgUpirBaseStatement::next_node != nullptr);
   99808             : 
   99809           0 :     SgUpirBaseStatement * object = SgUpirBaseStatement::next_node;
   99810           0 :     SgUpirBaseStatement::next_node = (SgUpirBaseStatement*)(object->p_freepointer);
   99811             : 
   99812             : #if ROSE_ALLOC_TRACE == 2
   99813             :     printf("SgUpirBaseStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUpirBaseStatement::next_node);
   99814             : #endif
   99815             : 
   99816           0 :     SgNode * fp = object->p_freepointer;
   99817             : #if ROSE_ALLOC_MEMSET == 1
   99818             : #elif ROSE_ALLOC_MEMSET == 2
   99819             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgUpirBaseStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   99820             : #elif ROSE_ALLOC_MEMSET == 3
   99821             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgUpirBaseStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   99822             : #endif
   99823           0 :     object->p_freepointer = fp;
   99824             : 
   99825             : #if ROSE_ALLOC_TRACE == 2
   99826             : //    printf("SgUpirBaseStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUpirBaseStatement::next_node);
   99827             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   99828             :     Rose::MemPool::snapshot(oss.str());
   99829             :     alloc_trace_cnt++;
   99830             : #endif
   99831             : 
   99832           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
   99833             : 
   99834           0 :     ALLOC_MUTEX(SgUpirBaseStatement, unlock);
   99835             : 
   99836             :     return object;
   99837             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   99838             : }
   99839             : 
   99840             : 
   99841             : 
   99842             : /*! \brief Delete operator for SgUpirBaseStatement.
   99843             : 
   99844             :    This delete operator implements deallocation using memory pools to 
   99845             :    provide most efficent use of the heap within construction of large ASTs.
   99846             : 
   99847             : \internal The new and delete operators use the lower level C malloc/free
   99848             :    function calls for performance and to make sure that mixing of malloc/free
   99849             :    and new/delete by the used can be caught more readily.  This may change
   99850             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
   99851             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
   99852             :    deallocate memory allocated using ROSE_MALLOC.
   99853             : */
   99854           0 : void SgUpirBaseStatement::operator delete(void *Pointer, size_t Size)
   99855             : {
   99856             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
   99857             :      * or throwing an exception. */
   99858           0 :     ALLOC_MUTEX(SgUpirBaseStatement, lock);
   99859             : 
   99860             : #if USE_CPP_NEW_DELETE_OPERATORS
   99861             :     ROSE_FREE(Pointer);
   99862             : #else
   99863             : #if ROSE_PEDANTIC_ALLOC
   99864             :     ROSE_ASSERT(Size == sizeof(SgUpirBaseStatement));
   99865             : #else
   99866           0 :     if (Size != sizeof(SgUpirBaseStatement)) {
   99867           0 :       ROSE_FREE(Pointer);
   99868           0 :       ALLOC_MUTEX(SgUpirBaseStatement, unlock);
   99869             :       return;
   99870             :     }
   99871             : #endif
   99872             : 
   99873           0 :     SgUpirBaseStatement * object = (SgUpirBaseStatement*) Pointer;
   99874           0 :     ROSE_ASSERT(object != nullptr);
   99875             : 
   99876             : #if ROSE_ALLOC_TRACE == 2
   99877             : //  printf("SgUpirBaseStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUpirBaseStatement::next_node);
   99878             :     printf("SgUpirBaseStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUpirBaseStatement::next_node);
   99879             : #endif
   99880             : 
   99881             : #if ROSE_PEDANTIC_ALLOC
   99882             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
   99883             : #endif
   99884             : 
   99885             : #if ROSE_ALLOC_MEMSET == 1
   99886             : #elif ROSE_ALLOC_MEMSET == 2
   99887             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgUpirBaseStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   99888             : #elif ROSE_ALLOC_MEMSET == 3
   99889             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgUpirBaseStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
   99890             : #endif
   99891             : 
   99892             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
   99893             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
   99894             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
   99895             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
   99896             : #else
   99897           0 :     object->p_freepointer = SgUpirBaseStatement::next_node;
   99898           0 :     SgUpirBaseStatement::next_node = object;
   99899             : #endif
   99900             : 
   99901             : #if ROSE_ALLOC_TRACE == 2
   99902             : //  printf("SgUpirBaseStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUpirBaseStatement::next_node);
   99903             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
   99904             :     Rose::MemPool::snapshot(oss.str());
   99905             :     alloc_trace_cnt++;
   99906             : #endif
   99907             : 
   99908             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
   99909             : 
   99910           0 :     ALLOC_MUTEX(SgUpirBaseStatement, unlock);
   99911             : }
   99912             : 
   99913             : // DQ (11/27/2009): I have moved this member function definition to outside of the
   99914             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
   99915             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
   99916             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
   99917             : // Also, note comment below from Robb (copied from the Common.code file).
   99918             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
   99919             : //
   99920             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
   99921             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
   99922             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
   99923             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
   99924             : #if 0
   99925             : void SgUpirBaseStatement::operator delete(void* pointer) { SgUpirBaseStatement::operator delete (pointer, sizeof(SgUpirBaseStatement)); };
   99926             : #endif
   99927             : /* #line 99928 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
   99928             : 
   99929             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
   99930             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
   99931             : // obviously imply C++.
   99932             : 
   99933             : // This implements the support within ROSE for memory pools.  Memory pools
   99934             : // support the most condensed usage of memory within the construction of
   99935             : // and AST. Large blocks of contiguous storage for each RI node is allocated
   99936             : // by a new operator written for each class.
   99937             : 
   99938             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
   99939             :     // User wants multi-thread support and POSIX threads are available.
   99940             : #   include <pthread.h>
   99941             :     static pthread_mutex_t SgOmpTaskyieldStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
   99942             : #else
   99943             :      // Cause synchronization to be skipped.
   99944             : #    ifndef ALLOC_MUTEX
   99945             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
   99946             : #    endif
   99947             : #    ifdef _REENTRANT
   99948             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
   99949             : #       ifdef _MSC_VER
   99950             : #           pragma message("POSIX threads are not available; synchronization being skipped")
   99951             : #       else
   99952             : #           warning "POSIX threads are not available; synchronization being skipped"
   99953             : #       endif
   99954             : #    endif
   99955             : #endif
   99956             : 
   99957             : #ifndef ROSE_ALLOC_TRACE
   99958             : #  define ROSE_ALLOC_TRACE 0
   99959             : #endif
   99960             : 
   99961             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
   99962             : #define ROSE_ALLOC_TRACE_CNT
   99963             : #include "memory-pool-snapshot.h"
   99964             : unsigned long alloc_trace_cnt = 0;
   99965             : #endif
   99966             : 
   99967             : #if ROSE_ALLOC_TRACE
   99968             : const unsigned SgOmpTaskyieldStatement::pool_size = 5;
   99969             : #else
   99970             : const unsigned SgOmpTaskyieldStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
   99971             : #endif
   99972             : 
   99973             : #ifndef ROSE_ALLOC_MEMSET
   99974             : #  define ROSE_ALLOC_MEMSET 0
   99975             : #endif
   99976             : 
   99977             : #ifndef ROSE_PEDANTIC_ALLOC
   99978             : #  define ROSE_PEDANTIC_ALLOC 0
   99979             : #endif
   99980             : 
   99981             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
   99982             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
   99983             : #endif
   99984             : 
   99985             : #if !defined(SGNODE__ALL_POOLS)
   99986             : #define SGNODE__ALL_POOLS
   99987             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
   99988             : #endif
   99989             : 
   99990             : SgOmpTaskyieldStatement* SgOmpTaskyieldStatement::next_node = nullptr;
   99991             : std::vector<unsigned char*> SgOmpTaskyieldStatement::pools;
   99992             : 
   99993             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
   99994             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
   99995             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
   99996             : // around this macro definition rather than each use).
   99997             : #ifndef ALLOC_MUTEX
   99998             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
   99999             :         do {                                                                     \
  100000             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  100001             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  100002             :                 abort();                                                         \
  100003             :             }                                                                    \
  100004             :         } while (0);
  100005             : #endif
  100006             : 
  100007             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  100008             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  100009             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  100010             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  100011             : 
  100012             : /*! \brief New operator for SgOmpTaskyieldStatement.
  100013             : 
  100014             :    This new operator implements memory pools to provide most efficent 
  100015             :    use of the heap within construction of large ASTs.
  100016             : 
  100017             : \internal The new and delete operators use the lower level C malloc/free
  100018             :    function calls for performance and to make sure that mixing of malloc/free
  100019             :    and new/delete by the used can be caught more readily.  This may change
  100020             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  100021             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  100022             :    deallocate memory allocated using ROSE_MALLOC.
  100023             : */
  100024           1 : void *SgOmpTaskyieldStatement::operator new ( size_t Size )
  100025             : {
  100026             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  100027             :      * returning or throwing an exception. */
  100028           1 :     ALLOC_MUTEX(SgOmpTaskyieldStatement, lock);
  100029             : 
  100030             : #if ROSE_ALLOC_TRACE == 2
  100031             : //    printf("SgOmpTaskyieldStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgOmpTaskyieldStatement::next_node);
  100032             : #endif
  100033             : 
  100034             : #if USE_CPP_NEW_DELETE_OPERATORS
  100035             :     void *mem = ROSE_MALLOC(Size);
  100036             :     ALLOC_MUTEX(SgOmpTaskyieldStatement, unlock);
  100037             :     return mem;
  100038             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  100039             : #if ROSE_PEDANTIC_ALLOC
  100040             :     ROSE_ASSERT(Size == sizeof(SgOmpTaskyieldStatement));
  100041             : #else
  100042           1 :     if (Size != sizeof(SgOmpTaskyieldStatement)) {
  100043           0 :       void * object = ROSE_MALLOC(Size);
  100044           0 :       ALLOC_MUTEX(SgOmpTaskyieldStatement, unlock);
  100045             :       return object;
  100046             :     }
  100047             : #endif
  100048             : 
  100049           1 :     if (SgOmpTaskyieldStatement::next_node == nullptr) {
  100050           1 :         SgOmpTaskyieldStatement * alloc = (SgOmpTaskyieldStatement*) ROSE_MALLOC ( SgOmpTaskyieldStatement::pool_size * sizeof(SgOmpTaskyieldStatement) );
  100051           1 :         ROSE_ASSERT(alloc != nullptr);
  100052             : 
  100053             : #if ROSE_ALLOC_TRACE == 2
  100054             : //        printf("SgOmpTaskyieldStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgOmpTaskyieldStatement::pools.size(), alloc, alloc + SgOmpTaskyieldStatement::pool_size);
  100055             : #endif
  100056             : 
  100057             : #if ROSE_ALLOC_MEMSET == 1
  100058             : #elif ROSE_ALLOC_MEMSET == 2
  100059             :         memset(alloc, 0x00, SgOmpTaskyieldStatement::pool_size * sizeof(SgOmpTaskyieldStatement));
  100060             : #elif ROSE_ALLOC_MEMSET == 3
  100061             :         memset(alloc, 0xAA, SgOmpTaskyieldStatement::pool_size * sizeof(SgOmpTaskyieldStatement));
  100062             : #endif
  100063        2000 :         for (unsigned i=0; i < SgOmpTaskyieldStatement::pool_size-1; i++) {
  100064        1999 :           alloc[i].p_freepointer = &(alloc[i+1]);
  100065             :         }
  100066           1 :         alloc[SgOmpTaskyieldStatement::pool_size-1].p_freepointer = nullptr;
  100067             : 
  100068           1 :         SgOmpTaskyieldStatement::pools.push_back ( (unsigned char *) alloc );
  100069           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgOmpTaskyieldStatement::pool_size * sizeof(SgOmpTaskyieldStatement), V_SgOmpTaskyieldStatement ) );
  100070           1 :         SgOmpTaskyieldStatement::next_node = alloc;
  100071             :     }
  100072           1 :     ROSE_ASSERT(SgOmpTaskyieldStatement::next_node != nullptr);
  100073             : 
  100074           1 :     SgOmpTaskyieldStatement * object = SgOmpTaskyieldStatement::next_node;
  100075           1 :     SgOmpTaskyieldStatement::next_node = (SgOmpTaskyieldStatement*)(object->p_freepointer);
  100076             : 
  100077             : #if ROSE_ALLOC_TRACE == 2
  100078             :     printf("SgOmpTaskyieldStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpTaskyieldStatement::next_node);
  100079             : #endif
  100080             : 
  100081           1 :     SgNode * fp = object->p_freepointer;
  100082             : #if ROSE_ALLOC_MEMSET == 1
  100083             : #elif ROSE_ALLOC_MEMSET == 2
  100084             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpTaskyieldStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  100085             : #elif ROSE_ALLOC_MEMSET == 3
  100086             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgOmpTaskyieldStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  100087             : #endif
  100088           1 :     object->p_freepointer = fp;
  100089             : 
  100090             : #if ROSE_ALLOC_TRACE == 2
  100091             : //    printf("SgOmpTaskyieldStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpTaskyieldStatement::next_node);
  100092             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  100093             :     Rose::MemPool::snapshot(oss.str());
  100094             :     alloc_trace_cnt++;
  100095             : #endif
  100096             : 
  100097           1 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  100098             : 
  100099           1 :     ALLOC_MUTEX(SgOmpTaskyieldStatement, unlock);
  100100             : 
  100101             :     return object;
  100102             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  100103             : }
  100104             : 
  100105             : 
  100106             : 
  100107             : /*! \brief Delete operator for SgOmpTaskyieldStatement.
  100108             : 
  100109             :    This delete operator implements deallocation using memory pools to 
  100110             :    provide most efficent use of the heap within construction of large ASTs.
  100111             : 
  100112             : \internal The new and delete operators use the lower level C malloc/free
  100113             :    function calls for performance and to make sure that mixing of malloc/free
  100114             :    and new/delete by the used can be caught more readily.  This may change
  100115             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  100116             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  100117             :    deallocate memory allocated using ROSE_MALLOC.
  100118             : */
  100119           0 : void SgOmpTaskyieldStatement::operator delete(void *Pointer, size_t Size)
  100120             : {
  100121             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  100122             :      * or throwing an exception. */
  100123           0 :     ALLOC_MUTEX(SgOmpTaskyieldStatement, lock);
  100124             : 
  100125             : #if USE_CPP_NEW_DELETE_OPERATORS
  100126             :     ROSE_FREE(Pointer);
  100127             : #else
  100128             : #if ROSE_PEDANTIC_ALLOC
  100129             :     ROSE_ASSERT(Size == sizeof(SgOmpTaskyieldStatement));
  100130             : #else
  100131           0 :     if (Size != sizeof(SgOmpTaskyieldStatement)) {
  100132           0 :       ROSE_FREE(Pointer);
  100133           0 :       ALLOC_MUTEX(SgOmpTaskyieldStatement, unlock);
  100134             :       return;
  100135             :     }
  100136             : #endif
  100137             : 
  100138           0 :     SgOmpTaskyieldStatement * object = (SgOmpTaskyieldStatement*) Pointer;
  100139           0 :     ROSE_ASSERT(object != nullptr);
  100140             : 
  100141             : #if ROSE_ALLOC_TRACE == 2
  100142             : //  printf("SgOmpTaskyieldStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpTaskyieldStatement::next_node);
  100143             :     printf("SgOmpTaskyieldStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpTaskyieldStatement::next_node);
  100144             : #endif
  100145             : 
  100146             : #if ROSE_PEDANTIC_ALLOC
  100147             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  100148             : #endif
  100149             : 
  100150             : #if ROSE_ALLOC_MEMSET == 1
  100151             : #elif ROSE_ALLOC_MEMSET == 2
  100152             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpTaskyieldStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  100153             : #elif ROSE_ALLOC_MEMSET == 3
  100154             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgOmpTaskyieldStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  100155             : #endif
  100156             : 
  100157             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  100158             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  100159             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  100160             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  100161             : #else
  100162           0 :     object->p_freepointer = SgOmpTaskyieldStatement::next_node;
  100163           0 :     SgOmpTaskyieldStatement::next_node = object;
  100164             : #endif
  100165             : 
  100166             : #if ROSE_ALLOC_TRACE == 2
  100167             : //  printf("SgOmpTaskyieldStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpTaskyieldStatement::next_node);
  100168             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  100169             :     Rose::MemPool::snapshot(oss.str());
  100170             :     alloc_trace_cnt++;
  100171             : #endif
  100172             : 
  100173             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  100174             : 
  100175           0 :     ALLOC_MUTEX(SgOmpTaskyieldStatement, unlock);
  100176             : }
  100177             : 
  100178             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  100179             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  100180             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  100181             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  100182             : // Also, note comment below from Robb (copied from the Common.code file).
  100183             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  100184             : //
  100185             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  100186             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  100187             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  100188             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  100189             : #if 0
  100190             : void SgOmpTaskyieldStatement::operator delete(void* pointer) { SgOmpTaskyieldStatement::operator delete (pointer, sizeof(SgOmpTaskyieldStatement)); };
  100191             : #endif
  100192             : /* #line 100193 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  100193             : 
  100194             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  100195             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  100196             : // obviously imply C++.
  100197             : 
  100198             : // This implements the support within ROSE for memory pools.  Memory pools
  100199             : // support the most condensed usage of memory within the construction of
  100200             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  100201             : // by a new operator written for each class.
  100202             : 
  100203             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  100204             :     // User wants multi-thread support and POSIX threads are available.
  100205             : #   include <pthread.h>
  100206             :     static pthread_mutex_t SgOmpBarrierStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  100207             : #else
  100208             :      // Cause synchronization to be skipped.
  100209             : #    ifndef ALLOC_MUTEX
  100210             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  100211             : #    endif
  100212             : #    ifdef _REENTRANT
  100213             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  100214             : #       ifdef _MSC_VER
  100215             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  100216             : #       else
  100217             : #           warning "POSIX threads are not available; synchronization being skipped"
  100218             : #       endif
  100219             : #    endif
  100220             : #endif
  100221             : 
  100222             : #ifndef ROSE_ALLOC_TRACE
  100223             : #  define ROSE_ALLOC_TRACE 0
  100224             : #endif
  100225             : 
  100226             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  100227             : #define ROSE_ALLOC_TRACE_CNT
  100228             : #include "memory-pool-snapshot.h"
  100229             : unsigned long alloc_trace_cnt = 0;
  100230             : #endif
  100231             : 
  100232             : #if ROSE_ALLOC_TRACE
  100233             : const unsigned SgOmpBarrierStatement::pool_size = 5;
  100234             : #else
  100235             : const unsigned SgOmpBarrierStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  100236             : #endif
  100237             : 
  100238             : #ifndef ROSE_ALLOC_MEMSET
  100239             : #  define ROSE_ALLOC_MEMSET 0
  100240             : #endif
  100241             : 
  100242             : #ifndef ROSE_PEDANTIC_ALLOC
  100243             : #  define ROSE_PEDANTIC_ALLOC 0
  100244             : #endif
  100245             : 
  100246             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  100247             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  100248             : #endif
  100249             : 
  100250             : #if !defined(SGNODE__ALL_POOLS)
  100251             : #define SGNODE__ALL_POOLS
  100252             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  100253             : #endif
  100254             : 
  100255             : SgOmpBarrierStatement* SgOmpBarrierStatement::next_node = nullptr;
  100256             : std::vector<unsigned char*> SgOmpBarrierStatement::pools;
  100257             : 
  100258             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  100259             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  100260             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  100261             : // around this macro definition rather than each use).
  100262             : #ifndef ALLOC_MUTEX
  100263             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  100264             :         do {                                                                     \
  100265             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  100266             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  100267             :                 abort();                                                         \
  100268             :             }                                                                    \
  100269             :         } while (0);
  100270             : #endif
  100271             : 
  100272             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  100273             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  100274             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  100275             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  100276             : 
  100277             : /*! \brief New operator for SgOmpBarrierStatement.
  100278             : 
  100279             :    This new operator implements memory pools to provide most efficent 
  100280             :    use of the heap within construction of large ASTs.
  100281             : 
  100282             : \internal The new and delete operators use the lower level C malloc/free
  100283             :    function calls for performance and to make sure that mixing of malloc/free
  100284             :    and new/delete by the used can be caught more readily.  This may change
  100285             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  100286             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  100287             :    deallocate memory allocated using ROSE_MALLOC.
  100288             : */
  100289          17 : void *SgOmpBarrierStatement::operator new ( size_t Size )
  100290             : {
  100291             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  100292             :      * returning or throwing an exception. */
  100293          17 :     ALLOC_MUTEX(SgOmpBarrierStatement, lock);
  100294             : 
  100295             : #if ROSE_ALLOC_TRACE == 2
  100296             : //    printf("SgOmpBarrierStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgOmpBarrierStatement::next_node);
  100297             : #endif
  100298             : 
  100299             : #if USE_CPP_NEW_DELETE_OPERATORS
  100300             :     void *mem = ROSE_MALLOC(Size);
  100301             :     ALLOC_MUTEX(SgOmpBarrierStatement, unlock);
  100302             :     return mem;
  100303             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  100304             : #if ROSE_PEDANTIC_ALLOC
  100305             :     ROSE_ASSERT(Size == sizeof(SgOmpBarrierStatement));
  100306             : #else
  100307          17 :     if (Size != sizeof(SgOmpBarrierStatement)) {
  100308           0 :       void * object = ROSE_MALLOC(Size);
  100309           0 :       ALLOC_MUTEX(SgOmpBarrierStatement, unlock);
  100310             :       return object;
  100311             :     }
  100312             : #endif
  100313             : 
  100314          17 :     if (SgOmpBarrierStatement::next_node == nullptr) {
  100315          12 :         SgOmpBarrierStatement * alloc = (SgOmpBarrierStatement*) ROSE_MALLOC ( SgOmpBarrierStatement::pool_size * sizeof(SgOmpBarrierStatement) );
  100316          12 :         ROSE_ASSERT(alloc != nullptr);
  100317             : 
  100318             : #if ROSE_ALLOC_TRACE == 2
  100319             : //        printf("SgOmpBarrierStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgOmpBarrierStatement::pools.size(), alloc, alloc + SgOmpBarrierStatement::pool_size);
  100320             : #endif
  100321             : 
  100322             : #if ROSE_ALLOC_MEMSET == 1
  100323             : #elif ROSE_ALLOC_MEMSET == 2
  100324             :         memset(alloc, 0x00, SgOmpBarrierStatement::pool_size * sizeof(SgOmpBarrierStatement));
  100325             : #elif ROSE_ALLOC_MEMSET == 3
  100326             :         memset(alloc, 0xAA, SgOmpBarrierStatement::pool_size * sizeof(SgOmpBarrierStatement));
  100327             : #endif
  100328       24000 :         for (unsigned i=0; i < SgOmpBarrierStatement::pool_size-1; i++) {
  100329       23988 :           alloc[i].p_freepointer = &(alloc[i+1]);
  100330             :         }
  100331          12 :         alloc[SgOmpBarrierStatement::pool_size-1].p_freepointer = nullptr;
  100332             : 
  100333          12 :         SgOmpBarrierStatement::pools.push_back ( (unsigned char *) alloc );
  100334          12 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgOmpBarrierStatement::pool_size * sizeof(SgOmpBarrierStatement), V_SgOmpBarrierStatement ) );
  100335          12 :         SgOmpBarrierStatement::next_node = alloc;
  100336             :     }
  100337          17 :     ROSE_ASSERT(SgOmpBarrierStatement::next_node != nullptr);
  100338             : 
  100339          17 :     SgOmpBarrierStatement * object = SgOmpBarrierStatement::next_node;
  100340          17 :     SgOmpBarrierStatement::next_node = (SgOmpBarrierStatement*)(object->p_freepointer);
  100341             : 
  100342             : #if ROSE_ALLOC_TRACE == 2
  100343             :     printf("SgOmpBarrierStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpBarrierStatement::next_node);
  100344             : #endif
  100345             : 
  100346          17 :     SgNode * fp = object->p_freepointer;
  100347             : #if ROSE_ALLOC_MEMSET == 1
  100348             : #elif ROSE_ALLOC_MEMSET == 2
  100349             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpBarrierStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  100350             : #elif ROSE_ALLOC_MEMSET == 3
  100351             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgOmpBarrierStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  100352             : #endif
  100353          17 :     object->p_freepointer = fp;
  100354             : 
  100355             : #if ROSE_ALLOC_TRACE == 2
  100356             : //    printf("SgOmpBarrierStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpBarrierStatement::next_node);
  100357             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  100358             :     Rose::MemPool::snapshot(oss.str());
  100359             :     alloc_trace_cnt++;
  100360             : #endif
  100361             : 
  100362          17 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  100363             : 
  100364          17 :     ALLOC_MUTEX(SgOmpBarrierStatement, unlock);
  100365             : 
  100366             :     return object;
  100367             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  100368             : }
  100369             : 
  100370             : 
  100371             : 
  100372             : /*! \brief Delete operator for SgOmpBarrierStatement.
  100373             : 
  100374             :    This delete operator implements deallocation using memory pools to 
  100375             :    provide most efficent use of the heap within construction of large ASTs.
  100376             : 
  100377             : \internal The new and delete operators use the lower level C malloc/free
  100378             :    function calls for performance and to make sure that mixing of malloc/free
  100379             :    and new/delete by the used can be caught more readily.  This may change
  100380             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  100381             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  100382             :    deallocate memory allocated using ROSE_MALLOC.
  100383             : */
  100384           0 : void SgOmpBarrierStatement::operator delete(void *Pointer, size_t Size)
  100385             : {
  100386             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  100387             :      * or throwing an exception. */
  100388           0 :     ALLOC_MUTEX(SgOmpBarrierStatement, lock);
  100389             : 
  100390             : #if USE_CPP_NEW_DELETE_OPERATORS
  100391             :     ROSE_FREE(Pointer);
  100392             : #else
  100393             : #if ROSE_PEDANTIC_ALLOC
  100394             :     ROSE_ASSERT(Size == sizeof(SgOmpBarrierStatement));
  100395             : #else
  100396           0 :     if (Size != sizeof(SgOmpBarrierStatement)) {
  100397           0 :       ROSE_FREE(Pointer);
  100398           0 :       ALLOC_MUTEX(SgOmpBarrierStatement, unlock);
  100399             :       return;
  100400             :     }
  100401             : #endif
  100402             : 
  100403           0 :     SgOmpBarrierStatement * object = (SgOmpBarrierStatement*) Pointer;
  100404           0 :     ROSE_ASSERT(object != nullptr);
  100405             : 
  100406             : #if ROSE_ALLOC_TRACE == 2
  100407             : //  printf("SgOmpBarrierStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpBarrierStatement::next_node);
  100408             :     printf("SgOmpBarrierStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpBarrierStatement::next_node);
  100409             : #endif
  100410             : 
  100411             : #if ROSE_PEDANTIC_ALLOC
  100412             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  100413             : #endif
  100414             : 
  100415             : #if ROSE_ALLOC_MEMSET == 1
  100416             : #elif ROSE_ALLOC_MEMSET == 2
  100417             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpBarrierStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  100418             : #elif ROSE_ALLOC_MEMSET == 3
  100419             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgOmpBarrierStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  100420             : #endif
  100421             : 
  100422             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  100423             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  100424             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  100425             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  100426             : #else
  100427           0 :     object->p_freepointer = SgOmpBarrierStatement::next_node;
  100428           0 :     SgOmpBarrierStatement::next_node = object;
  100429             : #endif
  100430             : 
  100431             : #if ROSE_ALLOC_TRACE == 2
  100432             : //  printf("SgOmpBarrierStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpBarrierStatement::next_node);
  100433             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  100434             :     Rose::MemPool::snapshot(oss.str());
  100435             :     alloc_trace_cnt++;
  100436             : #endif
  100437             : 
  100438             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  100439             : 
  100440           0 :     ALLOC_MUTEX(SgOmpBarrierStatement, unlock);
  100441             : }
  100442             : 
  100443             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  100444             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  100445             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  100446             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  100447             : // Also, note comment below from Robb (copied from the Common.code file).
  100448             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  100449             : //
  100450             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  100451             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  100452             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  100453             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  100454             : #if 0
  100455             : void SgOmpBarrierStatement::operator delete(void* pointer) { SgOmpBarrierStatement::operator delete (pointer, sizeof(SgOmpBarrierStatement)); };
  100456             : #endif
  100457             : /* #line 100458 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  100458             : 
  100459             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  100460             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  100461             : // obviously imply C++.
  100462             : 
  100463             : // This implements the support within ROSE for memory pools.  Memory pools
  100464             : // support the most condensed usage of memory within the construction of
  100465             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  100466             : // by a new operator written for each class.
  100467             : 
  100468             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  100469             :     // User wants multi-thread support and POSIX threads are available.
  100470             : #   include <pthread.h>
  100471             :     static pthread_mutex_t SgUpirBodyStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  100472             : #else
  100473             :      // Cause synchronization to be skipped.
  100474             : #    ifndef ALLOC_MUTEX
  100475             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  100476             : #    endif
  100477             : #    ifdef _REENTRANT
  100478             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  100479             : #       ifdef _MSC_VER
  100480             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  100481             : #       else
  100482             : #           warning "POSIX threads are not available; synchronization being skipped"
  100483             : #       endif
  100484             : #    endif
  100485             : #endif
  100486             : 
  100487             : #ifndef ROSE_ALLOC_TRACE
  100488             : #  define ROSE_ALLOC_TRACE 0
  100489             : #endif
  100490             : 
  100491             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  100492             : #define ROSE_ALLOC_TRACE_CNT
  100493             : #include "memory-pool-snapshot.h"
  100494             : unsigned long alloc_trace_cnt = 0;
  100495             : #endif
  100496             : 
  100497             : #if ROSE_ALLOC_TRACE
  100498             : const unsigned SgUpirBodyStatement::pool_size = 5;
  100499             : #else
  100500             : const unsigned SgUpirBodyStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  100501             : #endif
  100502             : 
  100503             : #ifndef ROSE_ALLOC_MEMSET
  100504             : #  define ROSE_ALLOC_MEMSET 0
  100505             : #endif
  100506             : 
  100507             : #ifndef ROSE_PEDANTIC_ALLOC
  100508             : #  define ROSE_PEDANTIC_ALLOC 0
  100509             : #endif
  100510             : 
  100511             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  100512             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  100513             : #endif
  100514             : 
  100515             : #if !defined(SGNODE__ALL_POOLS)
  100516             : #define SGNODE__ALL_POOLS
  100517             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  100518             : #endif
  100519             : 
  100520             : SgUpirBodyStatement* SgUpirBodyStatement::next_node = nullptr;
  100521             : std::vector<unsigned char*> SgUpirBodyStatement::pools;
  100522             : 
  100523             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  100524             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  100525             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  100526             : // around this macro definition rather than each use).
  100527             : #ifndef ALLOC_MUTEX
  100528             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  100529             :         do {                                                                     \
  100530             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  100531             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  100532             :                 abort();                                                         \
  100533             :             }                                                                    \
  100534             :         } while (0);
  100535             : #endif
  100536             : 
  100537             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  100538             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  100539             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  100540             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  100541             : 
  100542             : /*! \brief New operator for SgUpirBodyStatement.
  100543             : 
  100544             :    This new operator implements memory pools to provide most efficent 
  100545             :    use of the heap within construction of large ASTs.
  100546             : 
  100547             : \internal The new and delete operators use the lower level C malloc/free
  100548             :    function calls for performance and to make sure that mixing of malloc/free
  100549             :    and new/delete by the used can be caught more readily.  This may change
  100550             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  100551             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  100552             :    deallocate memory allocated using ROSE_MALLOC.
  100553             : */
  100554           0 : void *SgUpirBodyStatement::operator new ( size_t Size )
  100555             : {
  100556             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  100557             :      * returning or throwing an exception. */
  100558           0 :     ALLOC_MUTEX(SgUpirBodyStatement, lock);
  100559             : 
  100560             : #if ROSE_ALLOC_TRACE == 2
  100561             : //    printf("SgUpirBodyStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgUpirBodyStatement::next_node);
  100562             : #endif
  100563             : 
  100564             : #if USE_CPP_NEW_DELETE_OPERATORS
  100565             :     void *mem = ROSE_MALLOC(Size);
  100566             :     ALLOC_MUTEX(SgUpirBodyStatement, unlock);
  100567             :     return mem;
  100568             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  100569             : #if ROSE_PEDANTIC_ALLOC
  100570             :     ROSE_ASSERT(Size == sizeof(SgUpirBodyStatement));
  100571             : #else
  100572           0 :     if (Size != sizeof(SgUpirBodyStatement)) {
  100573           0 :       void * object = ROSE_MALLOC(Size);
  100574           0 :       ALLOC_MUTEX(SgUpirBodyStatement, unlock);
  100575             :       return object;
  100576             :     }
  100577             : #endif
  100578             : 
  100579           0 :     if (SgUpirBodyStatement::next_node == nullptr) {
  100580           0 :         SgUpirBodyStatement * alloc = (SgUpirBodyStatement*) ROSE_MALLOC ( SgUpirBodyStatement::pool_size * sizeof(SgUpirBodyStatement) );
  100581           0 :         ROSE_ASSERT(alloc != nullptr);
  100582             : 
  100583             : #if ROSE_ALLOC_TRACE == 2
  100584             : //        printf("SgUpirBodyStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgUpirBodyStatement::pools.size(), alloc, alloc + SgUpirBodyStatement::pool_size);
  100585             : #endif
  100586             : 
  100587             : #if ROSE_ALLOC_MEMSET == 1
  100588             : #elif ROSE_ALLOC_MEMSET == 2
  100589             :         memset(alloc, 0x00, SgUpirBodyStatement::pool_size * sizeof(SgUpirBodyStatement));
  100590             : #elif ROSE_ALLOC_MEMSET == 3
  100591             :         memset(alloc, 0xAA, SgUpirBodyStatement::pool_size * sizeof(SgUpirBodyStatement));
  100592             : #endif
  100593           0 :         for (unsigned i=0; i < SgUpirBodyStatement::pool_size-1; i++) {
  100594           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
  100595             :         }
  100596           0 :         alloc[SgUpirBodyStatement::pool_size-1].p_freepointer = nullptr;
  100597             : 
  100598           0 :         SgUpirBodyStatement::pools.push_back ( (unsigned char *) alloc );
  100599           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgUpirBodyStatement::pool_size * sizeof(SgUpirBodyStatement), V_SgUpirBodyStatement ) );
  100600           0 :         SgUpirBodyStatement::next_node = alloc;
  100601             :     }
  100602           0 :     ROSE_ASSERT(SgUpirBodyStatement::next_node != nullptr);
  100603             : 
  100604           0 :     SgUpirBodyStatement * object = SgUpirBodyStatement::next_node;
  100605           0 :     SgUpirBodyStatement::next_node = (SgUpirBodyStatement*)(object->p_freepointer);
  100606             : 
  100607             : #if ROSE_ALLOC_TRACE == 2
  100608             :     printf("SgUpirBodyStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUpirBodyStatement::next_node);
  100609             : #endif
  100610             : 
  100611           0 :     SgNode * fp = object->p_freepointer;
  100612             : #if ROSE_ALLOC_MEMSET == 1
  100613             : #elif ROSE_ALLOC_MEMSET == 2
  100614             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgUpirBodyStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  100615             : #elif ROSE_ALLOC_MEMSET == 3
  100616             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgUpirBodyStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  100617             : #endif
  100618           0 :     object->p_freepointer = fp;
  100619             : 
  100620             : #if ROSE_ALLOC_TRACE == 2
  100621             : //    printf("SgUpirBodyStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUpirBodyStatement::next_node);
  100622             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  100623             :     Rose::MemPool::snapshot(oss.str());
  100624             :     alloc_trace_cnt++;
  100625             : #endif
  100626             : 
  100627           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  100628             : 
  100629           0 :     ALLOC_MUTEX(SgUpirBodyStatement, unlock);
  100630             : 
  100631             :     return object;
  100632             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  100633             : }
  100634             : 
  100635             : 
  100636             : 
  100637             : /*! \brief Delete operator for SgUpirBodyStatement.
  100638             : 
  100639             :    This delete operator implements deallocation using memory pools to 
  100640             :    provide most efficent use of the heap within construction of large ASTs.
  100641             : 
  100642             : \internal The new and delete operators use the lower level C malloc/free
  100643             :    function calls for performance and to make sure that mixing of malloc/free
  100644             :    and new/delete by the used can be caught more readily.  This may change
  100645             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  100646             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  100647             :    deallocate memory allocated using ROSE_MALLOC.
  100648             : */
  100649           0 : void SgUpirBodyStatement::operator delete(void *Pointer, size_t Size)
  100650             : {
  100651             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  100652             :      * or throwing an exception. */
  100653           0 :     ALLOC_MUTEX(SgUpirBodyStatement, lock);
  100654             : 
  100655             : #if USE_CPP_NEW_DELETE_OPERATORS
  100656             :     ROSE_FREE(Pointer);
  100657             : #else
  100658             : #if ROSE_PEDANTIC_ALLOC
  100659             :     ROSE_ASSERT(Size == sizeof(SgUpirBodyStatement));
  100660             : #else
  100661           0 :     if (Size != sizeof(SgUpirBodyStatement)) {
  100662           0 :       ROSE_FREE(Pointer);
  100663           0 :       ALLOC_MUTEX(SgUpirBodyStatement, unlock);
  100664             :       return;
  100665             :     }
  100666             : #endif
  100667             : 
  100668           0 :     SgUpirBodyStatement * object = (SgUpirBodyStatement*) Pointer;
  100669           0 :     ROSE_ASSERT(object != nullptr);
  100670             : 
  100671             : #if ROSE_ALLOC_TRACE == 2
  100672             : //  printf("SgUpirBodyStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUpirBodyStatement::next_node);
  100673             :     printf("SgUpirBodyStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUpirBodyStatement::next_node);
  100674             : #endif
  100675             : 
  100676             : #if ROSE_PEDANTIC_ALLOC
  100677             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  100678             : #endif
  100679             : 
  100680             : #if ROSE_ALLOC_MEMSET == 1
  100681             : #elif ROSE_ALLOC_MEMSET == 2
  100682             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgUpirBodyStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  100683             : #elif ROSE_ALLOC_MEMSET == 3
  100684             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgUpirBodyStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  100685             : #endif
  100686             : 
  100687             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  100688             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  100689             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  100690             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  100691             : #else
  100692           0 :     object->p_freepointer = SgUpirBodyStatement::next_node;
  100693           0 :     SgUpirBodyStatement::next_node = object;
  100694             : #endif
  100695             : 
  100696             : #if ROSE_ALLOC_TRACE == 2
  100697             : //  printf("SgUpirBodyStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUpirBodyStatement::next_node);
  100698             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  100699             :     Rose::MemPool::snapshot(oss.str());
  100700             :     alloc_trace_cnt++;
  100701             : #endif
  100702             : 
  100703             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  100704             : 
  100705           0 :     ALLOC_MUTEX(SgUpirBodyStatement, unlock);
  100706             : }
  100707             : 
  100708             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  100709             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  100710             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  100711             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  100712             : // Also, note comment below from Robb (copied from the Common.code file).
  100713             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  100714             : //
  100715             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  100716             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  100717             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  100718             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  100719             : #if 0
  100720             : void SgUpirBodyStatement::operator delete(void* pointer) { SgUpirBodyStatement::operator delete (pointer, sizeof(SgUpirBodyStatement)); };
  100721             : #endif
  100722             : /* #line 100723 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  100723             : 
  100724             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  100725             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  100726             : // obviously imply C++.
  100727             : 
  100728             : // This implements the support within ROSE for memory pools.  Memory pools
  100729             : // support the most condensed usage of memory within the construction of
  100730             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  100731             : // by a new operator written for each class.
  100732             : 
  100733             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  100734             :     // User wants multi-thread support and POSIX threads are available.
  100735             : #   include <pthread.h>
  100736             :     static pthread_mutex_t SgOmpMasterStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  100737             : #else
  100738             :      // Cause synchronization to be skipped.
  100739             : #    ifndef ALLOC_MUTEX
  100740             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  100741             : #    endif
  100742             : #    ifdef _REENTRANT
  100743             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  100744             : #       ifdef _MSC_VER
  100745             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  100746             : #       else
  100747             : #           warning "POSIX threads are not available; synchronization being skipped"
  100748             : #       endif
  100749             : #    endif
  100750             : #endif
  100751             : 
  100752             : #ifndef ROSE_ALLOC_TRACE
  100753             : #  define ROSE_ALLOC_TRACE 0
  100754             : #endif
  100755             : 
  100756             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  100757             : #define ROSE_ALLOC_TRACE_CNT
  100758             : #include "memory-pool-snapshot.h"
  100759             : unsigned long alloc_trace_cnt = 0;
  100760             : #endif
  100761             : 
  100762             : #if ROSE_ALLOC_TRACE
  100763             : const unsigned SgOmpMasterStatement::pool_size = 5;
  100764             : #else
  100765             : const unsigned SgOmpMasterStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  100766             : #endif
  100767             : 
  100768             : #ifndef ROSE_ALLOC_MEMSET
  100769             : #  define ROSE_ALLOC_MEMSET 0
  100770             : #endif
  100771             : 
  100772             : #ifndef ROSE_PEDANTIC_ALLOC
  100773             : #  define ROSE_PEDANTIC_ALLOC 0
  100774             : #endif
  100775             : 
  100776             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  100777             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  100778             : #endif
  100779             : 
  100780             : #if !defined(SGNODE__ALL_POOLS)
  100781             : #define SGNODE__ALL_POOLS
  100782             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  100783             : #endif
  100784             : 
  100785             : SgOmpMasterStatement* SgOmpMasterStatement::next_node = nullptr;
  100786             : std::vector<unsigned char*> SgOmpMasterStatement::pools;
  100787             : 
  100788             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  100789             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  100790             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  100791             : // around this macro definition rather than each use).
  100792             : #ifndef ALLOC_MUTEX
  100793             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  100794             :         do {                                                                     \
  100795             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  100796             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  100797             :                 abort();                                                         \
  100798             :             }                                                                    \
  100799             :         } while (0);
  100800             : #endif
  100801             : 
  100802             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  100803             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  100804             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  100805             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  100806             : 
  100807             : /*! \brief New operator for SgOmpMasterStatement.
  100808             : 
  100809             :    This new operator implements memory pools to provide most efficent 
  100810             :    use of the heap within construction of large ASTs.
  100811             : 
  100812             : \internal The new and delete operators use the lower level C malloc/free
  100813             :    function calls for performance and to make sure that mixing of malloc/free
  100814             :    and new/delete by the used can be caught more readily.  This may change
  100815             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  100816             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  100817             :    deallocate memory allocated using ROSE_MALLOC.
  100818             : */
  100819          14 : void *SgOmpMasterStatement::operator new ( size_t Size )
  100820             : {
  100821             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  100822             :      * returning or throwing an exception. */
  100823          14 :     ALLOC_MUTEX(SgOmpMasterStatement, lock);
  100824             : 
  100825             : #if ROSE_ALLOC_TRACE == 2
  100826             : //    printf("SgOmpMasterStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgOmpMasterStatement::next_node);
  100827             : #endif
  100828             : 
  100829             : #if USE_CPP_NEW_DELETE_OPERATORS
  100830             :     void *mem = ROSE_MALLOC(Size);
  100831             :     ALLOC_MUTEX(SgOmpMasterStatement, unlock);
  100832             :     return mem;
  100833             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  100834             : #if ROSE_PEDANTIC_ALLOC
  100835             :     ROSE_ASSERT(Size == sizeof(SgOmpMasterStatement));
  100836             : #else
  100837          14 :     if (Size != sizeof(SgOmpMasterStatement)) {
  100838           0 :       void * object = ROSE_MALLOC(Size);
  100839           0 :       ALLOC_MUTEX(SgOmpMasterStatement, unlock);
  100840             :       return object;
  100841             :     }
  100842             : #endif
  100843             : 
  100844          14 :     if (SgOmpMasterStatement::next_node == nullptr) {
  100845           8 :         SgOmpMasterStatement * alloc = (SgOmpMasterStatement*) ROSE_MALLOC ( SgOmpMasterStatement::pool_size * sizeof(SgOmpMasterStatement) );
  100846           8 :         ROSE_ASSERT(alloc != nullptr);
  100847             : 
  100848             : #if ROSE_ALLOC_TRACE == 2
  100849             : //        printf("SgOmpMasterStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgOmpMasterStatement::pools.size(), alloc, alloc + SgOmpMasterStatement::pool_size);
  100850             : #endif
  100851             : 
  100852             : #if ROSE_ALLOC_MEMSET == 1
  100853             : #elif ROSE_ALLOC_MEMSET == 2
  100854             :         memset(alloc, 0x00, SgOmpMasterStatement::pool_size * sizeof(SgOmpMasterStatement));
  100855             : #elif ROSE_ALLOC_MEMSET == 3
  100856             :         memset(alloc, 0xAA, SgOmpMasterStatement::pool_size * sizeof(SgOmpMasterStatement));
  100857             : #endif
  100858       16000 :         for (unsigned i=0; i < SgOmpMasterStatement::pool_size-1; i++) {
  100859       15992 :           alloc[i].p_freepointer = &(alloc[i+1]);
  100860             :         }
  100861           8 :         alloc[SgOmpMasterStatement::pool_size-1].p_freepointer = nullptr;
  100862             : 
  100863           8 :         SgOmpMasterStatement::pools.push_back ( (unsigned char *) alloc );
  100864           8 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgOmpMasterStatement::pool_size * sizeof(SgOmpMasterStatement), V_SgOmpMasterStatement ) );
  100865           8 :         SgOmpMasterStatement::next_node = alloc;
  100866             :     }
  100867          14 :     ROSE_ASSERT(SgOmpMasterStatement::next_node != nullptr);
  100868             : 
  100869          14 :     SgOmpMasterStatement * object = SgOmpMasterStatement::next_node;
  100870          14 :     SgOmpMasterStatement::next_node = (SgOmpMasterStatement*)(object->p_freepointer);
  100871             : 
  100872             : #if ROSE_ALLOC_TRACE == 2
  100873             :     printf("SgOmpMasterStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpMasterStatement::next_node);
  100874             : #endif
  100875             : 
  100876          14 :     SgNode * fp = object->p_freepointer;
  100877             : #if ROSE_ALLOC_MEMSET == 1
  100878             : #elif ROSE_ALLOC_MEMSET == 2
  100879             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpMasterStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  100880             : #elif ROSE_ALLOC_MEMSET == 3
  100881             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgOmpMasterStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  100882             : #endif
  100883          14 :     object->p_freepointer = fp;
  100884             : 
  100885             : #if ROSE_ALLOC_TRACE == 2
  100886             : //    printf("SgOmpMasterStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpMasterStatement::next_node);
  100887             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  100888             :     Rose::MemPool::snapshot(oss.str());
  100889             :     alloc_trace_cnt++;
  100890             : #endif
  100891             : 
  100892          14 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  100893             : 
  100894          14 :     ALLOC_MUTEX(SgOmpMasterStatement, unlock);
  100895             : 
  100896             :     return object;
  100897             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  100898             : }
  100899             : 
  100900             : 
  100901             : 
  100902             : /*! \brief Delete operator for SgOmpMasterStatement.
  100903             : 
  100904             :    This delete operator implements deallocation using memory pools to 
  100905             :    provide most efficent use of the heap within construction of large ASTs.
  100906             : 
  100907             : \internal The new and delete operators use the lower level C malloc/free
  100908             :    function calls for performance and to make sure that mixing of malloc/free
  100909             :    and new/delete by the used can be caught more readily.  This may change
  100910             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  100911             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  100912             :    deallocate memory allocated using ROSE_MALLOC.
  100913             : */
  100914           0 : void SgOmpMasterStatement::operator delete(void *Pointer, size_t Size)
  100915             : {
  100916             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  100917             :      * or throwing an exception. */
  100918           0 :     ALLOC_MUTEX(SgOmpMasterStatement, lock);
  100919             : 
  100920             : #if USE_CPP_NEW_DELETE_OPERATORS
  100921             :     ROSE_FREE(Pointer);
  100922             : #else
  100923             : #if ROSE_PEDANTIC_ALLOC
  100924             :     ROSE_ASSERT(Size == sizeof(SgOmpMasterStatement));
  100925             : #else
  100926           0 :     if (Size != sizeof(SgOmpMasterStatement)) {
  100927           0 :       ROSE_FREE(Pointer);
  100928           0 :       ALLOC_MUTEX(SgOmpMasterStatement, unlock);
  100929             :       return;
  100930             :     }
  100931             : #endif
  100932             : 
  100933           0 :     SgOmpMasterStatement * object = (SgOmpMasterStatement*) Pointer;
  100934           0 :     ROSE_ASSERT(object != nullptr);
  100935             : 
  100936             : #if ROSE_ALLOC_TRACE == 2
  100937             : //  printf("SgOmpMasterStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpMasterStatement::next_node);
  100938             :     printf("SgOmpMasterStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpMasterStatement::next_node);
  100939             : #endif
  100940             : 
  100941             : #if ROSE_PEDANTIC_ALLOC
  100942             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  100943             : #endif
  100944             : 
  100945             : #if ROSE_ALLOC_MEMSET == 1
  100946             : #elif ROSE_ALLOC_MEMSET == 2
  100947             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpMasterStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  100948             : #elif ROSE_ALLOC_MEMSET == 3
  100949             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgOmpMasterStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  100950             : #endif
  100951             : 
  100952             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  100953             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  100954             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  100955             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  100956             : #else
  100957           0 :     object->p_freepointer = SgOmpMasterStatement::next_node;
  100958           0 :     SgOmpMasterStatement::next_node = object;
  100959             : #endif
  100960             : 
  100961             : #if ROSE_ALLOC_TRACE == 2
  100962             : //  printf("SgOmpMasterStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpMasterStatement::next_node);
  100963             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  100964             :     Rose::MemPool::snapshot(oss.str());
  100965             :     alloc_trace_cnt++;
  100966             : #endif
  100967             : 
  100968             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  100969             : 
  100970           0 :     ALLOC_MUTEX(SgOmpMasterStatement, unlock);
  100971             : }
  100972             : 
  100973             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  100974             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  100975             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  100976             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  100977             : // Also, note comment below from Robb (copied from the Common.code file).
  100978             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  100979             : //
  100980             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  100981             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  100982             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  100983             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  100984             : #if 0
  100985             : void SgOmpMasterStatement::operator delete(void* pointer) { SgOmpMasterStatement::operator delete (pointer, sizeof(SgOmpMasterStatement)); };
  100986             : #endif
  100987             : /* #line 100988 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  100988             : 
  100989             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  100990             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  100991             : // obviously imply C++.
  100992             : 
  100993             : // This implements the support within ROSE for memory pools.  Memory pools
  100994             : // support the most condensed usage of memory within the construction of
  100995             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  100996             : // by a new operator written for each class.
  100997             : 
  100998             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  100999             :     // User wants multi-thread support and POSIX threads are available.
  101000             : #   include <pthread.h>
  101001             :     static pthread_mutex_t SgOmpSectionStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  101002             : #else
  101003             :      // Cause synchronization to be skipped.
  101004             : #    ifndef ALLOC_MUTEX
  101005             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  101006             : #    endif
  101007             : #    ifdef _REENTRANT
  101008             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  101009             : #       ifdef _MSC_VER
  101010             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  101011             : #       else
  101012             : #           warning "POSIX threads are not available; synchronization being skipped"
  101013             : #       endif
  101014             : #    endif
  101015             : #endif
  101016             : 
  101017             : #ifndef ROSE_ALLOC_TRACE
  101018             : #  define ROSE_ALLOC_TRACE 0
  101019             : #endif
  101020             : 
  101021             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  101022             : #define ROSE_ALLOC_TRACE_CNT
  101023             : #include "memory-pool-snapshot.h"
  101024             : unsigned long alloc_trace_cnt = 0;
  101025             : #endif
  101026             : 
  101027             : #if ROSE_ALLOC_TRACE
  101028             : const unsigned SgOmpSectionStatement::pool_size = 5;
  101029             : #else
  101030             : const unsigned SgOmpSectionStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  101031             : #endif
  101032             : 
  101033             : #ifndef ROSE_ALLOC_MEMSET
  101034             : #  define ROSE_ALLOC_MEMSET 0
  101035             : #endif
  101036             : 
  101037             : #ifndef ROSE_PEDANTIC_ALLOC
  101038             : #  define ROSE_PEDANTIC_ALLOC 0
  101039             : #endif
  101040             : 
  101041             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  101042             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  101043             : #endif
  101044             : 
  101045             : #if !defined(SGNODE__ALL_POOLS)
  101046             : #define SGNODE__ALL_POOLS
  101047             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  101048             : #endif
  101049             : 
  101050             : SgOmpSectionStatement* SgOmpSectionStatement::next_node = nullptr;
  101051             : std::vector<unsigned char*> SgOmpSectionStatement::pools;
  101052             : 
  101053             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  101054             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  101055             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  101056             : // around this macro definition rather than each use).
  101057             : #ifndef ALLOC_MUTEX
  101058             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  101059             :         do {                                                                     \
  101060             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  101061             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  101062             :                 abort();                                                         \
  101063             :             }                                                                    \
  101064             :         } while (0);
  101065             : #endif
  101066             : 
  101067             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  101068             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  101069             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  101070             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  101071             : 
  101072             : /*! \brief New operator for SgOmpSectionStatement.
  101073             : 
  101074             :    This new operator implements memory pools to provide most efficent 
  101075             :    use of the heap within construction of large ASTs.
  101076             : 
  101077             : \internal The new and delete operators use the lower level C malloc/free
  101078             :    function calls for performance and to make sure that mixing of malloc/free
  101079             :    and new/delete by the used can be caught more readily.  This may change
  101080             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  101081             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  101082             :    deallocate memory allocated using ROSE_MALLOC.
  101083             : */
  101084          29 : void *SgOmpSectionStatement::operator new ( size_t Size )
  101085             : {
  101086             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  101087             :      * returning or throwing an exception. */
  101088          29 :     ALLOC_MUTEX(SgOmpSectionStatement, lock);
  101089             : 
  101090             : #if ROSE_ALLOC_TRACE == 2
  101091             : //    printf("SgOmpSectionStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgOmpSectionStatement::next_node);
  101092             : #endif
  101093             : 
  101094             : #if USE_CPP_NEW_DELETE_OPERATORS
  101095             :     void *mem = ROSE_MALLOC(Size);
  101096             :     ALLOC_MUTEX(SgOmpSectionStatement, unlock);
  101097             :     return mem;
  101098             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  101099             : #if ROSE_PEDANTIC_ALLOC
  101100             :     ROSE_ASSERT(Size == sizeof(SgOmpSectionStatement));
  101101             : #else
  101102          29 :     if (Size != sizeof(SgOmpSectionStatement)) {
  101103           0 :       void * object = ROSE_MALLOC(Size);
  101104           0 :       ALLOC_MUTEX(SgOmpSectionStatement, unlock);
  101105             :       return object;
  101106             :     }
  101107             : #endif
  101108             : 
  101109          29 :     if (SgOmpSectionStatement::next_node == nullptr) {
  101110           9 :         SgOmpSectionStatement * alloc = (SgOmpSectionStatement*) ROSE_MALLOC ( SgOmpSectionStatement::pool_size * sizeof(SgOmpSectionStatement) );
  101111           9 :         ROSE_ASSERT(alloc != nullptr);
  101112             : 
  101113             : #if ROSE_ALLOC_TRACE == 2
  101114             : //        printf("SgOmpSectionStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgOmpSectionStatement::pools.size(), alloc, alloc + SgOmpSectionStatement::pool_size);
  101115             : #endif
  101116             : 
  101117             : #if ROSE_ALLOC_MEMSET == 1
  101118             : #elif ROSE_ALLOC_MEMSET == 2
  101119             :         memset(alloc, 0x00, SgOmpSectionStatement::pool_size * sizeof(SgOmpSectionStatement));
  101120             : #elif ROSE_ALLOC_MEMSET == 3
  101121             :         memset(alloc, 0xAA, SgOmpSectionStatement::pool_size * sizeof(SgOmpSectionStatement));
  101122             : #endif
  101123       18000 :         for (unsigned i=0; i < SgOmpSectionStatement::pool_size-1; i++) {
  101124       17991 :           alloc[i].p_freepointer = &(alloc[i+1]);
  101125             :         }
  101126           9 :         alloc[SgOmpSectionStatement::pool_size-1].p_freepointer = nullptr;
  101127             : 
  101128           9 :         SgOmpSectionStatement::pools.push_back ( (unsigned char *) alloc );
  101129           9 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgOmpSectionStatement::pool_size * sizeof(SgOmpSectionStatement), V_SgOmpSectionStatement ) );
  101130           9 :         SgOmpSectionStatement::next_node = alloc;
  101131             :     }
  101132          29 :     ROSE_ASSERT(SgOmpSectionStatement::next_node != nullptr);
  101133             : 
  101134          29 :     SgOmpSectionStatement * object = SgOmpSectionStatement::next_node;
  101135          29 :     SgOmpSectionStatement::next_node = (SgOmpSectionStatement*)(object->p_freepointer);
  101136             : 
  101137             : #if ROSE_ALLOC_TRACE == 2
  101138             :     printf("SgOmpSectionStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpSectionStatement::next_node);
  101139             : #endif
  101140             : 
  101141          29 :     SgNode * fp = object->p_freepointer;
  101142             : #if ROSE_ALLOC_MEMSET == 1
  101143             : #elif ROSE_ALLOC_MEMSET == 2
  101144             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpSectionStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  101145             : #elif ROSE_ALLOC_MEMSET == 3
  101146             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgOmpSectionStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  101147             : #endif
  101148          29 :     object->p_freepointer = fp;
  101149             : 
  101150             : #if ROSE_ALLOC_TRACE == 2
  101151             : //    printf("SgOmpSectionStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpSectionStatement::next_node);
  101152             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  101153             :     Rose::MemPool::snapshot(oss.str());
  101154             :     alloc_trace_cnt++;
  101155             : #endif
  101156             : 
  101157          29 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  101158             : 
  101159          29 :     ALLOC_MUTEX(SgOmpSectionStatement, unlock);
  101160             : 
  101161             :     return object;
  101162             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  101163             : }
  101164             : 
  101165             : 
  101166             : 
  101167             : /*! \brief Delete operator for SgOmpSectionStatement.
  101168             : 
  101169             :    This delete operator implements deallocation using memory pools to 
  101170             :    provide most efficent use of the heap within construction of large ASTs.
  101171             : 
  101172             : \internal The new and delete operators use the lower level C malloc/free
  101173             :    function calls for performance and to make sure that mixing of malloc/free
  101174             :    and new/delete by the used can be caught more readily.  This may change
  101175             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  101176             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  101177             :    deallocate memory allocated using ROSE_MALLOC.
  101178             : */
  101179           0 : void SgOmpSectionStatement::operator delete(void *Pointer, size_t Size)
  101180             : {
  101181             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  101182             :      * or throwing an exception. */
  101183           0 :     ALLOC_MUTEX(SgOmpSectionStatement, lock);
  101184             : 
  101185             : #if USE_CPP_NEW_DELETE_OPERATORS
  101186             :     ROSE_FREE(Pointer);
  101187             : #else
  101188             : #if ROSE_PEDANTIC_ALLOC
  101189             :     ROSE_ASSERT(Size == sizeof(SgOmpSectionStatement));
  101190             : #else
  101191           0 :     if (Size != sizeof(SgOmpSectionStatement)) {
  101192           0 :       ROSE_FREE(Pointer);
  101193           0 :       ALLOC_MUTEX(SgOmpSectionStatement, unlock);
  101194             :       return;
  101195             :     }
  101196             : #endif
  101197             : 
  101198           0 :     SgOmpSectionStatement * object = (SgOmpSectionStatement*) Pointer;
  101199           0 :     ROSE_ASSERT(object != nullptr);
  101200             : 
  101201             : #if ROSE_ALLOC_TRACE == 2
  101202             : //  printf("SgOmpSectionStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpSectionStatement::next_node);
  101203             :     printf("SgOmpSectionStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpSectionStatement::next_node);
  101204             : #endif
  101205             : 
  101206             : #if ROSE_PEDANTIC_ALLOC
  101207             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  101208             : #endif
  101209             : 
  101210             : #if ROSE_ALLOC_MEMSET == 1
  101211             : #elif ROSE_ALLOC_MEMSET == 2
  101212             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpSectionStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  101213             : #elif ROSE_ALLOC_MEMSET == 3
  101214             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgOmpSectionStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  101215             : #endif
  101216             : 
  101217             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  101218             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  101219             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  101220             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  101221             : #else
  101222           0 :     object->p_freepointer = SgOmpSectionStatement::next_node;
  101223           0 :     SgOmpSectionStatement::next_node = object;
  101224             : #endif
  101225             : 
  101226             : #if ROSE_ALLOC_TRACE == 2
  101227             : //  printf("SgOmpSectionStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpSectionStatement::next_node);
  101228             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  101229             :     Rose::MemPool::snapshot(oss.str());
  101230             :     alloc_trace_cnt++;
  101231             : #endif
  101232             : 
  101233             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  101234             : 
  101235           0 :     ALLOC_MUTEX(SgOmpSectionStatement, unlock);
  101236             : }
  101237             : 
  101238             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  101239             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  101240             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  101241             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  101242             : // Also, note comment below from Robb (copied from the Common.code file).
  101243             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  101244             : //
  101245             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  101246             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  101247             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  101248             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  101249             : #if 0
  101250             : void SgOmpSectionStatement::operator delete(void* pointer) { SgOmpSectionStatement::operator delete (pointer, sizeof(SgOmpSectionStatement)); };
  101251             : #endif
  101252             : /* #line 101253 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  101253             : 
  101254             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  101255             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  101256             : // obviously imply C++.
  101257             : 
  101258             : // This implements the support within ROSE for memory pools.  Memory pools
  101259             : // support the most condensed usage of memory within the construction of
  101260             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  101261             : // by a new operator written for each class.
  101262             : 
  101263             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  101264             :     // User wants multi-thread support and POSIX threads are available.
  101265             : #   include <pthread.h>
  101266             :     static pthread_mutex_t SgOmpWorkshareStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  101267             : #else
  101268             :      // Cause synchronization to be skipped.
  101269             : #    ifndef ALLOC_MUTEX
  101270             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  101271             : #    endif
  101272             : #    ifdef _REENTRANT
  101273             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  101274             : #       ifdef _MSC_VER
  101275             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  101276             : #       else
  101277             : #           warning "POSIX threads are not available; synchronization being skipped"
  101278             : #       endif
  101279             : #    endif
  101280             : #endif
  101281             : 
  101282             : #ifndef ROSE_ALLOC_TRACE
  101283             : #  define ROSE_ALLOC_TRACE 0
  101284             : #endif
  101285             : 
  101286             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  101287             : #define ROSE_ALLOC_TRACE_CNT
  101288             : #include "memory-pool-snapshot.h"
  101289             : unsigned long alloc_trace_cnt = 0;
  101290             : #endif
  101291             : 
  101292             : #if ROSE_ALLOC_TRACE
  101293             : const unsigned SgOmpWorkshareStatement::pool_size = 5;
  101294             : #else
  101295             : const unsigned SgOmpWorkshareStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  101296             : #endif
  101297             : 
  101298             : #ifndef ROSE_ALLOC_MEMSET
  101299             : #  define ROSE_ALLOC_MEMSET 0
  101300             : #endif
  101301             : 
  101302             : #ifndef ROSE_PEDANTIC_ALLOC
  101303             : #  define ROSE_PEDANTIC_ALLOC 0
  101304             : #endif
  101305             : 
  101306             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  101307             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  101308             : #endif
  101309             : 
  101310             : #if !defined(SGNODE__ALL_POOLS)
  101311             : #define SGNODE__ALL_POOLS
  101312             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  101313             : #endif
  101314             : 
  101315             : SgOmpWorkshareStatement* SgOmpWorkshareStatement::next_node = nullptr;
  101316             : std::vector<unsigned char*> SgOmpWorkshareStatement::pools;
  101317             : 
  101318             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  101319             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  101320             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  101321             : // around this macro definition rather than each use).
  101322             : #ifndef ALLOC_MUTEX
  101323             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  101324             :         do {                                                                     \
  101325             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  101326             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  101327             :                 abort();                                                         \
  101328             :             }                                                                    \
  101329             :         } while (0);
  101330             : #endif
  101331             : 
  101332             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  101333             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  101334             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  101335             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  101336             : 
  101337             : /*! \brief New operator for SgOmpWorkshareStatement.
  101338             : 
  101339             :    This new operator implements memory pools to provide most efficent 
  101340             :    use of the heap within construction of large ASTs.
  101341             : 
  101342             : \internal The new and delete operators use the lower level C malloc/free
  101343             :    function calls for performance and to make sure that mixing of malloc/free
  101344             :    and new/delete by the used can be caught more readily.  This may change
  101345             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  101346             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  101347             :    deallocate memory allocated using ROSE_MALLOC.
  101348             : */
  101349           0 : void *SgOmpWorkshareStatement::operator new ( size_t Size )
  101350             : {
  101351             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  101352             :      * returning or throwing an exception. */
  101353           0 :     ALLOC_MUTEX(SgOmpWorkshareStatement, lock);
  101354             : 
  101355             : #if ROSE_ALLOC_TRACE == 2
  101356             : //    printf("SgOmpWorkshareStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgOmpWorkshareStatement::next_node);
  101357             : #endif
  101358             : 
  101359             : #if USE_CPP_NEW_DELETE_OPERATORS
  101360             :     void *mem = ROSE_MALLOC(Size);
  101361             :     ALLOC_MUTEX(SgOmpWorkshareStatement, unlock);
  101362             :     return mem;
  101363             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  101364             : #if ROSE_PEDANTIC_ALLOC
  101365             :     ROSE_ASSERT(Size == sizeof(SgOmpWorkshareStatement));
  101366             : #else
  101367           0 :     if (Size != sizeof(SgOmpWorkshareStatement)) {
  101368           0 :       void * object = ROSE_MALLOC(Size);
  101369           0 :       ALLOC_MUTEX(SgOmpWorkshareStatement, unlock);
  101370             :       return object;
  101371             :     }
  101372             : #endif
  101373             : 
  101374           0 :     if (SgOmpWorkshareStatement::next_node == nullptr) {
  101375           0 :         SgOmpWorkshareStatement * alloc = (SgOmpWorkshareStatement*) ROSE_MALLOC ( SgOmpWorkshareStatement::pool_size * sizeof(SgOmpWorkshareStatement) );
  101376           0 :         ROSE_ASSERT(alloc != nullptr);
  101377             : 
  101378             : #if ROSE_ALLOC_TRACE == 2
  101379             : //        printf("SgOmpWorkshareStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgOmpWorkshareStatement::pools.size(), alloc, alloc + SgOmpWorkshareStatement::pool_size);
  101380             : #endif
  101381             : 
  101382             : #if ROSE_ALLOC_MEMSET == 1
  101383             : #elif ROSE_ALLOC_MEMSET == 2
  101384             :         memset(alloc, 0x00, SgOmpWorkshareStatement::pool_size * sizeof(SgOmpWorkshareStatement));
  101385             : #elif ROSE_ALLOC_MEMSET == 3
  101386             :         memset(alloc, 0xAA, SgOmpWorkshareStatement::pool_size * sizeof(SgOmpWorkshareStatement));
  101387             : #endif
  101388           0 :         for (unsigned i=0; i < SgOmpWorkshareStatement::pool_size-1; i++) {
  101389           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
  101390             :         }
  101391           0 :         alloc[SgOmpWorkshareStatement::pool_size-1].p_freepointer = nullptr;
  101392             : 
  101393           0 :         SgOmpWorkshareStatement::pools.push_back ( (unsigned char *) alloc );
  101394           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgOmpWorkshareStatement::pool_size * sizeof(SgOmpWorkshareStatement), V_SgOmpWorkshareStatement ) );
  101395           0 :         SgOmpWorkshareStatement::next_node = alloc;
  101396             :     }
  101397           0 :     ROSE_ASSERT(SgOmpWorkshareStatement::next_node != nullptr);
  101398             : 
  101399           0 :     SgOmpWorkshareStatement * object = SgOmpWorkshareStatement::next_node;
  101400           0 :     SgOmpWorkshareStatement::next_node = (SgOmpWorkshareStatement*)(object->p_freepointer);
  101401             : 
  101402             : #if ROSE_ALLOC_TRACE == 2
  101403             :     printf("SgOmpWorkshareStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpWorkshareStatement::next_node);
  101404             : #endif
  101405             : 
  101406           0 :     SgNode * fp = object->p_freepointer;
  101407             : #if ROSE_ALLOC_MEMSET == 1
  101408             : #elif ROSE_ALLOC_MEMSET == 2
  101409             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpWorkshareStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  101410             : #elif ROSE_ALLOC_MEMSET == 3
  101411             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgOmpWorkshareStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  101412             : #endif
  101413           0 :     object->p_freepointer = fp;
  101414             : 
  101415             : #if ROSE_ALLOC_TRACE == 2
  101416             : //    printf("SgOmpWorkshareStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpWorkshareStatement::next_node);
  101417             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  101418             :     Rose::MemPool::snapshot(oss.str());
  101419             :     alloc_trace_cnt++;
  101420             : #endif
  101421             : 
  101422           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  101423             : 
  101424           0 :     ALLOC_MUTEX(SgOmpWorkshareStatement, unlock);
  101425             : 
  101426             :     return object;
  101427             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  101428             : }
  101429             : 
  101430             : 
  101431             : 
  101432             : /*! \brief Delete operator for SgOmpWorkshareStatement.
  101433             : 
  101434             :    This delete operator implements deallocation using memory pools to 
  101435             :    provide most efficent use of the heap within construction of large ASTs.
  101436             : 
  101437             : \internal The new and delete operators use the lower level C malloc/free
  101438             :    function calls for performance and to make sure that mixing of malloc/free
  101439             :    and new/delete by the used can be caught more readily.  This may change
  101440             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  101441             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  101442             :    deallocate memory allocated using ROSE_MALLOC.
  101443             : */
  101444           0 : void SgOmpWorkshareStatement::operator delete(void *Pointer, size_t Size)
  101445             : {
  101446             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  101447             :      * or throwing an exception. */
  101448           0 :     ALLOC_MUTEX(SgOmpWorkshareStatement, lock);
  101449             : 
  101450             : #if USE_CPP_NEW_DELETE_OPERATORS
  101451             :     ROSE_FREE(Pointer);
  101452             : #else
  101453             : #if ROSE_PEDANTIC_ALLOC
  101454             :     ROSE_ASSERT(Size == sizeof(SgOmpWorkshareStatement));
  101455             : #else
  101456           0 :     if (Size != sizeof(SgOmpWorkshareStatement)) {
  101457           0 :       ROSE_FREE(Pointer);
  101458           0 :       ALLOC_MUTEX(SgOmpWorkshareStatement, unlock);
  101459             :       return;
  101460             :     }
  101461             : #endif
  101462             : 
  101463           0 :     SgOmpWorkshareStatement * object = (SgOmpWorkshareStatement*) Pointer;
  101464           0 :     ROSE_ASSERT(object != nullptr);
  101465             : 
  101466             : #if ROSE_ALLOC_TRACE == 2
  101467             : //  printf("SgOmpWorkshareStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpWorkshareStatement::next_node);
  101468             :     printf("SgOmpWorkshareStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpWorkshareStatement::next_node);
  101469             : #endif
  101470             : 
  101471             : #if ROSE_PEDANTIC_ALLOC
  101472             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  101473             : #endif
  101474             : 
  101475             : #if ROSE_ALLOC_MEMSET == 1
  101476             : #elif ROSE_ALLOC_MEMSET == 2
  101477             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpWorkshareStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  101478             : #elif ROSE_ALLOC_MEMSET == 3
  101479             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgOmpWorkshareStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  101480             : #endif
  101481             : 
  101482             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  101483             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  101484             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  101485             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  101486             : #else
  101487           0 :     object->p_freepointer = SgOmpWorkshareStatement::next_node;
  101488           0 :     SgOmpWorkshareStatement::next_node = object;
  101489             : #endif
  101490             : 
  101491             : #if ROSE_ALLOC_TRACE == 2
  101492             : //  printf("SgOmpWorkshareStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpWorkshareStatement::next_node);
  101493             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  101494             :     Rose::MemPool::snapshot(oss.str());
  101495             :     alloc_trace_cnt++;
  101496             : #endif
  101497             : 
  101498             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  101499             : 
  101500           0 :     ALLOC_MUTEX(SgOmpWorkshareStatement, unlock);
  101501             : }
  101502             : 
  101503             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  101504             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  101505             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  101506             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  101507             : // Also, note comment below from Robb (copied from the Common.code file).
  101508             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  101509             : //
  101510             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  101511             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  101512             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  101513             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  101514             : #if 0
  101515             : void SgOmpWorkshareStatement::operator delete(void* pointer) { SgOmpWorkshareStatement::operator delete (pointer, sizeof(SgOmpWorkshareStatement)); };
  101516             : #endif
  101517             : /* #line 101518 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  101518             : 
  101519             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  101520             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  101521             : // obviously imply C++.
  101522             : 
  101523             : // This implements the support within ROSE for memory pools.  Memory pools
  101524             : // support the most condensed usage of memory within the construction of
  101525             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  101526             : // by a new operator written for each class.
  101527             : 
  101528             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  101529             :     // User wants multi-thread support and POSIX threads are available.
  101530             : #   include <pthread.h>
  101531             :     static pthread_mutex_t SgUpirFieldBodyStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  101532             : #else
  101533             :      // Cause synchronization to be skipped.
  101534             : #    ifndef ALLOC_MUTEX
  101535             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  101536             : #    endif
  101537             : #    ifdef _REENTRANT
  101538             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  101539             : #       ifdef _MSC_VER
  101540             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  101541             : #       else
  101542             : #           warning "POSIX threads are not available; synchronization being skipped"
  101543             : #       endif
  101544             : #    endif
  101545             : #endif
  101546             : 
  101547             : #ifndef ROSE_ALLOC_TRACE
  101548             : #  define ROSE_ALLOC_TRACE 0
  101549             : #endif
  101550             : 
  101551             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  101552             : #define ROSE_ALLOC_TRACE_CNT
  101553             : #include "memory-pool-snapshot.h"
  101554             : unsigned long alloc_trace_cnt = 0;
  101555             : #endif
  101556             : 
  101557             : #if ROSE_ALLOC_TRACE
  101558             : const unsigned SgUpirFieldBodyStatement::pool_size = 5;
  101559             : #else
  101560             : const unsigned SgUpirFieldBodyStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  101561             : #endif
  101562             : 
  101563             : #ifndef ROSE_ALLOC_MEMSET
  101564             : #  define ROSE_ALLOC_MEMSET 0
  101565             : #endif
  101566             : 
  101567             : #ifndef ROSE_PEDANTIC_ALLOC
  101568             : #  define ROSE_PEDANTIC_ALLOC 0
  101569             : #endif
  101570             : 
  101571             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  101572             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  101573             : #endif
  101574             : 
  101575             : #if !defined(SGNODE__ALL_POOLS)
  101576             : #define SGNODE__ALL_POOLS
  101577             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  101578             : #endif
  101579             : 
  101580             : SgUpirFieldBodyStatement* SgUpirFieldBodyStatement::next_node = nullptr;
  101581             : std::vector<unsigned char*> SgUpirFieldBodyStatement::pools;
  101582             : 
  101583             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  101584             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  101585             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  101586             : // around this macro definition rather than each use).
  101587             : #ifndef ALLOC_MUTEX
  101588             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  101589             :         do {                                                                     \
  101590             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  101591             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  101592             :                 abort();                                                         \
  101593             :             }                                                                    \
  101594             :         } while (0);
  101595             : #endif
  101596             : 
  101597             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  101598             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  101599             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  101600             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  101601             : 
  101602             : /*! \brief New operator for SgUpirFieldBodyStatement.
  101603             : 
  101604             :    This new operator implements memory pools to provide most efficent 
  101605             :    use of the heap within construction of large ASTs.
  101606             : 
  101607             : \internal The new and delete operators use the lower level C malloc/free
  101608             :    function calls for performance and to make sure that mixing of malloc/free
  101609             :    and new/delete by the used can be caught more readily.  This may change
  101610             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  101611             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  101612             :    deallocate memory allocated using ROSE_MALLOC.
  101613             : */
  101614           0 : void *SgUpirFieldBodyStatement::operator new ( size_t Size )
  101615             : {
  101616             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  101617             :      * returning or throwing an exception. */
  101618           0 :     ALLOC_MUTEX(SgUpirFieldBodyStatement, lock);
  101619             : 
  101620             : #if ROSE_ALLOC_TRACE == 2
  101621             : //    printf("SgUpirFieldBodyStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgUpirFieldBodyStatement::next_node);
  101622             : #endif
  101623             : 
  101624             : #if USE_CPP_NEW_DELETE_OPERATORS
  101625             :     void *mem = ROSE_MALLOC(Size);
  101626             :     ALLOC_MUTEX(SgUpirFieldBodyStatement, unlock);
  101627             :     return mem;
  101628             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  101629             : #if ROSE_PEDANTIC_ALLOC
  101630             :     ROSE_ASSERT(Size == sizeof(SgUpirFieldBodyStatement));
  101631             : #else
  101632           0 :     if (Size != sizeof(SgUpirFieldBodyStatement)) {
  101633           0 :       void * object = ROSE_MALLOC(Size);
  101634           0 :       ALLOC_MUTEX(SgUpirFieldBodyStatement, unlock);
  101635             :       return object;
  101636             :     }
  101637             : #endif
  101638             : 
  101639           0 :     if (SgUpirFieldBodyStatement::next_node == nullptr) {
  101640           0 :         SgUpirFieldBodyStatement * alloc = (SgUpirFieldBodyStatement*) ROSE_MALLOC ( SgUpirFieldBodyStatement::pool_size * sizeof(SgUpirFieldBodyStatement) );
  101641           0 :         ROSE_ASSERT(alloc != nullptr);
  101642             : 
  101643             : #if ROSE_ALLOC_TRACE == 2
  101644             : //        printf("SgUpirFieldBodyStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgUpirFieldBodyStatement::pools.size(), alloc, alloc + SgUpirFieldBodyStatement::pool_size);
  101645             : #endif
  101646             : 
  101647             : #if ROSE_ALLOC_MEMSET == 1
  101648             : #elif ROSE_ALLOC_MEMSET == 2
  101649             :         memset(alloc, 0x00, SgUpirFieldBodyStatement::pool_size * sizeof(SgUpirFieldBodyStatement));
  101650             : #elif ROSE_ALLOC_MEMSET == 3
  101651             :         memset(alloc, 0xAA, SgUpirFieldBodyStatement::pool_size * sizeof(SgUpirFieldBodyStatement));
  101652             : #endif
  101653           0 :         for (unsigned i=0; i < SgUpirFieldBodyStatement::pool_size-1; i++) {
  101654           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
  101655             :         }
  101656           0 :         alloc[SgUpirFieldBodyStatement::pool_size-1].p_freepointer = nullptr;
  101657             : 
  101658           0 :         SgUpirFieldBodyStatement::pools.push_back ( (unsigned char *) alloc );
  101659           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgUpirFieldBodyStatement::pool_size * sizeof(SgUpirFieldBodyStatement), V_SgUpirFieldBodyStatement ) );
  101660           0 :         SgUpirFieldBodyStatement::next_node = alloc;
  101661             :     }
  101662           0 :     ROSE_ASSERT(SgUpirFieldBodyStatement::next_node != nullptr);
  101663             : 
  101664           0 :     SgUpirFieldBodyStatement * object = SgUpirFieldBodyStatement::next_node;
  101665           0 :     SgUpirFieldBodyStatement::next_node = (SgUpirFieldBodyStatement*)(object->p_freepointer);
  101666             : 
  101667             : #if ROSE_ALLOC_TRACE == 2
  101668             :     printf("SgUpirFieldBodyStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUpirFieldBodyStatement::next_node);
  101669             : #endif
  101670             : 
  101671           0 :     SgNode * fp = object->p_freepointer;
  101672             : #if ROSE_ALLOC_MEMSET == 1
  101673             : #elif ROSE_ALLOC_MEMSET == 2
  101674             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgUpirFieldBodyStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  101675             : #elif ROSE_ALLOC_MEMSET == 3
  101676             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgUpirFieldBodyStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  101677             : #endif
  101678           0 :     object->p_freepointer = fp;
  101679             : 
  101680             : #if ROSE_ALLOC_TRACE == 2
  101681             : //    printf("SgUpirFieldBodyStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUpirFieldBodyStatement::next_node);
  101682             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  101683             :     Rose::MemPool::snapshot(oss.str());
  101684             :     alloc_trace_cnt++;
  101685             : #endif
  101686             : 
  101687           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  101688             : 
  101689           0 :     ALLOC_MUTEX(SgUpirFieldBodyStatement, unlock);
  101690             : 
  101691             :     return object;
  101692             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  101693             : }
  101694             : 
  101695             : 
  101696             : 
  101697             : /*! \brief Delete operator for SgUpirFieldBodyStatement.
  101698             : 
  101699             :    This delete operator implements deallocation using memory pools to 
  101700             :    provide most efficent use of the heap within construction of large ASTs.
  101701             : 
  101702             : \internal The new and delete operators use the lower level C malloc/free
  101703             :    function calls for performance and to make sure that mixing of malloc/free
  101704             :    and new/delete by the used can be caught more readily.  This may change
  101705             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  101706             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  101707             :    deallocate memory allocated using ROSE_MALLOC.
  101708             : */
  101709           0 : void SgUpirFieldBodyStatement::operator delete(void *Pointer, size_t Size)
  101710             : {
  101711             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  101712             :      * or throwing an exception. */
  101713           0 :     ALLOC_MUTEX(SgUpirFieldBodyStatement, lock);
  101714             : 
  101715             : #if USE_CPP_NEW_DELETE_OPERATORS
  101716             :     ROSE_FREE(Pointer);
  101717             : #else
  101718             : #if ROSE_PEDANTIC_ALLOC
  101719             :     ROSE_ASSERT(Size == sizeof(SgUpirFieldBodyStatement));
  101720             : #else
  101721           0 :     if (Size != sizeof(SgUpirFieldBodyStatement)) {
  101722           0 :       ROSE_FREE(Pointer);
  101723           0 :       ALLOC_MUTEX(SgUpirFieldBodyStatement, unlock);
  101724             :       return;
  101725             :     }
  101726             : #endif
  101727             : 
  101728           0 :     SgUpirFieldBodyStatement * object = (SgUpirFieldBodyStatement*) Pointer;
  101729           0 :     ROSE_ASSERT(object != nullptr);
  101730             : 
  101731             : #if ROSE_ALLOC_TRACE == 2
  101732             : //  printf("SgUpirFieldBodyStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUpirFieldBodyStatement::next_node);
  101733             :     printf("SgUpirFieldBodyStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUpirFieldBodyStatement::next_node);
  101734             : #endif
  101735             : 
  101736             : #if ROSE_PEDANTIC_ALLOC
  101737             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  101738             : #endif
  101739             : 
  101740             : #if ROSE_ALLOC_MEMSET == 1
  101741             : #elif ROSE_ALLOC_MEMSET == 2
  101742             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgUpirFieldBodyStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  101743             : #elif ROSE_ALLOC_MEMSET == 3
  101744             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgUpirFieldBodyStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  101745             : #endif
  101746             : 
  101747             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  101748             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  101749             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  101750             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  101751             : #else
  101752           0 :     object->p_freepointer = SgUpirFieldBodyStatement::next_node;
  101753           0 :     SgUpirFieldBodyStatement::next_node = object;
  101754             : #endif
  101755             : 
  101756             : #if ROSE_ALLOC_TRACE == 2
  101757             : //  printf("SgUpirFieldBodyStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUpirFieldBodyStatement::next_node);
  101758             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  101759             :     Rose::MemPool::snapshot(oss.str());
  101760             :     alloc_trace_cnt++;
  101761             : #endif
  101762             : 
  101763             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  101764             : 
  101765           0 :     ALLOC_MUTEX(SgUpirFieldBodyStatement, unlock);
  101766             : }
  101767             : 
  101768             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  101769             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  101770             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  101771             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  101772             : // Also, note comment below from Robb (copied from the Common.code file).
  101773             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  101774             : //
  101775             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  101776             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  101777             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  101778             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  101779             : #if 0
  101780             : void SgUpirFieldBodyStatement::operator delete(void* pointer) { SgUpirFieldBodyStatement::operator delete (pointer, sizeof(SgUpirFieldBodyStatement)); };
  101781             : #endif
  101782             : /* #line 101783 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  101783             : 
  101784             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  101785             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  101786             : // obviously imply C++.
  101787             : 
  101788             : // This implements the support within ROSE for memory pools.  Memory pools
  101789             : // support the most condensed usage of memory within the construction of
  101790             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  101791             : // by a new operator written for each class.
  101792             : 
  101793             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  101794             :     // User wants multi-thread support and POSIX threads are available.
  101795             : #   include <pthread.h>
  101796             :     static pthread_mutex_t SgUpirSpmdStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  101797             : #else
  101798             :      // Cause synchronization to be skipped.
  101799             : #    ifndef ALLOC_MUTEX
  101800             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  101801             : #    endif
  101802             : #    ifdef _REENTRANT
  101803             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  101804             : #       ifdef _MSC_VER
  101805             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  101806             : #       else
  101807             : #           warning "POSIX threads are not available; synchronization being skipped"
  101808             : #       endif
  101809             : #    endif
  101810             : #endif
  101811             : 
  101812             : #ifndef ROSE_ALLOC_TRACE
  101813             : #  define ROSE_ALLOC_TRACE 0
  101814             : #endif
  101815             : 
  101816             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  101817             : #define ROSE_ALLOC_TRACE_CNT
  101818             : #include "memory-pool-snapshot.h"
  101819             : unsigned long alloc_trace_cnt = 0;
  101820             : #endif
  101821             : 
  101822             : #if ROSE_ALLOC_TRACE
  101823             : const unsigned SgUpirSpmdStatement::pool_size = 5;
  101824             : #else
  101825             : const unsigned SgUpirSpmdStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  101826             : #endif
  101827             : 
  101828             : #ifndef ROSE_ALLOC_MEMSET
  101829             : #  define ROSE_ALLOC_MEMSET 0
  101830             : #endif
  101831             : 
  101832             : #ifndef ROSE_PEDANTIC_ALLOC
  101833             : #  define ROSE_PEDANTIC_ALLOC 0
  101834             : #endif
  101835             : 
  101836             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  101837             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  101838             : #endif
  101839             : 
  101840             : #if !defined(SGNODE__ALL_POOLS)
  101841             : #define SGNODE__ALL_POOLS
  101842             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  101843             : #endif
  101844             : 
  101845             : SgUpirSpmdStatement* SgUpirSpmdStatement::next_node = nullptr;
  101846             : std::vector<unsigned char*> SgUpirSpmdStatement::pools;
  101847             : 
  101848             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  101849             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  101850             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  101851             : // around this macro definition rather than each use).
  101852             : #ifndef ALLOC_MUTEX
  101853             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  101854             :         do {                                                                     \
  101855             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  101856             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  101857             :                 abort();                                                         \
  101858             :             }                                                                    \
  101859             :         } while (0);
  101860             : #endif
  101861             : 
  101862             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  101863             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  101864             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  101865             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  101866             : 
  101867             : /*! \brief New operator for SgUpirSpmdStatement.
  101868             : 
  101869             :    This new operator implements memory pools to provide most efficent 
  101870             :    use of the heap within construction of large ASTs.
  101871             : 
  101872             : \internal The new and delete operators use the lower level C malloc/free
  101873             :    function calls for performance and to make sure that mixing of malloc/free
  101874             :    and new/delete by the used can be caught more readily.  This may change
  101875             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  101876             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  101877             :    deallocate memory allocated using ROSE_MALLOC.
  101878             : */
  101879         354 : void *SgUpirSpmdStatement::operator new ( size_t Size )
  101880             : {
  101881             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  101882             :      * returning or throwing an exception. */
  101883         354 :     ALLOC_MUTEX(SgUpirSpmdStatement, lock);
  101884             : 
  101885             : #if ROSE_ALLOC_TRACE == 2
  101886             : //    printf("SgUpirSpmdStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgUpirSpmdStatement::next_node);
  101887             : #endif
  101888             : 
  101889             : #if USE_CPP_NEW_DELETE_OPERATORS
  101890             :     void *mem = ROSE_MALLOC(Size);
  101891             :     ALLOC_MUTEX(SgUpirSpmdStatement, unlock);
  101892             :     return mem;
  101893             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  101894             : #if ROSE_PEDANTIC_ALLOC
  101895             :     ROSE_ASSERT(Size == sizeof(SgUpirSpmdStatement));
  101896             : #else
  101897         354 :     if (Size != sizeof(SgUpirSpmdStatement)) {
  101898           0 :       void * object = ROSE_MALLOC(Size);
  101899           0 :       ALLOC_MUTEX(SgUpirSpmdStatement, unlock);
  101900             :       return object;
  101901             :     }
  101902             : #endif
  101903             : 
  101904         354 :     if (SgUpirSpmdStatement::next_node == nullptr) {
  101905         205 :         SgUpirSpmdStatement * alloc = (SgUpirSpmdStatement*) ROSE_MALLOC ( SgUpirSpmdStatement::pool_size * sizeof(SgUpirSpmdStatement) );
  101906         205 :         ROSE_ASSERT(alloc != nullptr);
  101907             : 
  101908             : #if ROSE_ALLOC_TRACE == 2
  101909             : //        printf("SgUpirSpmdStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgUpirSpmdStatement::pools.size(), alloc, alloc + SgUpirSpmdStatement::pool_size);
  101910             : #endif
  101911             : 
  101912             : #if ROSE_ALLOC_MEMSET == 1
  101913             : #elif ROSE_ALLOC_MEMSET == 2
  101914             :         memset(alloc, 0x00, SgUpirSpmdStatement::pool_size * sizeof(SgUpirSpmdStatement));
  101915             : #elif ROSE_ALLOC_MEMSET == 3
  101916             :         memset(alloc, 0xAA, SgUpirSpmdStatement::pool_size * sizeof(SgUpirSpmdStatement));
  101917             : #endif
  101918      410000 :         for (unsigned i=0; i < SgUpirSpmdStatement::pool_size-1; i++) {
  101919      409795 :           alloc[i].p_freepointer = &(alloc[i+1]);
  101920             :         }
  101921         205 :         alloc[SgUpirSpmdStatement::pool_size-1].p_freepointer = nullptr;
  101922             : 
  101923         205 :         SgUpirSpmdStatement::pools.push_back ( (unsigned char *) alloc );
  101924         205 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgUpirSpmdStatement::pool_size * sizeof(SgUpirSpmdStatement), V_SgUpirSpmdStatement ) );
  101925         205 :         SgUpirSpmdStatement::next_node = alloc;
  101926             :     }
  101927         354 :     ROSE_ASSERT(SgUpirSpmdStatement::next_node != nullptr);
  101928             : 
  101929         354 :     SgUpirSpmdStatement * object = SgUpirSpmdStatement::next_node;
  101930         354 :     SgUpirSpmdStatement::next_node = (SgUpirSpmdStatement*)(object->p_freepointer);
  101931             : 
  101932             : #if ROSE_ALLOC_TRACE == 2
  101933             :     printf("SgUpirSpmdStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUpirSpmdStatement::next_node);
  101934             : #endif
  101935             : 
  101936         354 :     SgNode * fp = object->p_freepointer;
  101937             : #if ROSE_ALLOC_MEMSET == 1
  101938             : #elif ROSE_ALLOC_MEMSET == 2
  101939             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgUpirSpmdStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  101940             : #elif ROSE_ALLOC_MEMSET == 3
  101941             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgUpirSpmdStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  101942             : #endif
  101943         354 :     object->p_freepointer = fp;
  101944             : 
  101945             : #if ROSE_ALLOC_TRACE == 2
  101946             : //    printf("SgUpirSpmdStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUpirSpmdStatement::next_node);
  101947             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  101948             :     Rose::MemPool::snapshot(oss.str());
  101949             :     alloc_trace_cnt++;
  101950             : #endif
  101951             : 
  101952         354 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  101953             : 
  101954         354 :     ALLOC_MUTEX(SgUpirSpmdStatement, unlock);
  101955             : 
  101956             :     return object;
  101957             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  101958             : }
  101959             : 
  101960             : 
  101961             : 
  101962             : /*! \brief Delete operator for SgUpirSpmdStatement.
  101963             : 
  101964             :    This delete operator implements deallocation using memory pools to 
  101965             :    provide most efficent use of the heap within construction of large ASTs.
  101966             : 
  101967             : \internal The new and delete operators use the lower level C malloc/free
  101968             :    function calls for performance and to make sure that mixing of malloc/free
  101969             :    and new/delete by the used can be caught more readily.  This may change
  101970             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  101971             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  101972             :    deallocate memory allocated using ROSE_MALLOC.
  101973             : */
  101974           0 : void SgUpirSpmdStatement::operator delete(void *Pointer, size_t Size)
  101975             : {
  101976             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  101977             :      * or throwing an exception. */
  101978           0 :     ALLOC_MUTEX(SgUpirSpmdStatement, lock);
  101979             : 
  101980             : #if USE_CPP_NEW_DELETE_OPERATORS
  101981             :     ROSE_FREE(Pointer);
  101982             : #else
  101983             : #if ROSE_PEDANTIC_ALLOC
  101984             :     ROSE_ASSERT(Size == sizeof(SgUpirSpmdStatement));
  101985             : #else
  101986           0 :     if (Size != sizeof(SgUpirSpmdStatement)) {
  101987           0 :       ROSE_FREE(Pointer);
  101988           0 :       ALLOC_MUTEX(SgUpirSpmdStatement, unlock);
  101989             :       return;
  101990             :     }
  101991             : #endif
  101992             : 
  101993           0 :     SgUpirSpmdStatement * object = (SgUpirSpmdStatement*) Pointer;
  101994           0 :     ROSE_ASSERT(object != nullptr);
  101995             : 
  101996             : #if ROSE_ALLOC_TRACE == 2
  101997             : //  printf("SgUpirSpmdStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUpirSpmdStatement::next_node);
  101998             :     printf("SgUpirSpmdStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUpirSpmdStatement::next_node);
  101999             : #endif
  102000             : 
  102001             : #if ROSE_PEDANTIC_ALLOC
  102002             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  102003             : #endif
  102004             : 
  102005             : #if ROSE_ALLOC_MEMSET == 1
  102006             : #elif ROSE_ALLOC_MEMSET == 2
  102007             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgUpirSpmdStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  102008             : #elif ROSE_ALLOC_MEMSET == 3
  102009             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgUpirSpmdStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  102010             : #endif
  102011             : 
  102012             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  102013             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  102014             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  102015             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  102016             : #else
  102017           0 :     object->p_freepointer = SgUpirSpmdStatement::next_node;
  102018           0 :     SgUpirSpmdStatement::next_node = object;
  102019             : #endif
  102020             : 
  102021             : #if ROSE_ALLOC_TRACE == 2
  102022             : //  printf("SgUpirSpmdStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUpirSpmdStatement::next_node);
  102023             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  102024             :     Rose::MemPool::snapshot(oss.str());
  102025             :     alloc_trace_cnt++;
  102026             : #endif
  102027             : 
  102028             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  102029             : 
  102030           0 :     ALLOC_MUTEX(SgUpirSpmdStatement, unlock);
  102031             : }
  102032             : 
  102033             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  102034             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  102035             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  102036             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  102037             : // Also, note comment below from Robb (copied from the Common.code file).
  102038             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  102039             : //
  102040             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  102041             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  102042             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  102043             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  102044             : #if 0
  102045             : void SgUpirSpmdStatement::operator delete(void* pointer) { SgUpirSpmdStatement::operator delete (pointer, sizeof(SgUpirSpmdStatement)); };
  102046             : #endif
  102047             : /* #line 102048 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  102048             : 
  102049             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  102050             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  102051             : // obviously imply C++.
  102052             : 
  102053             : // This implements the support within ROSE for memory pools.  Memory pools
  102054             : // support the most condensed usage of memory within the construction of
  102055             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  102056             : // by a new operator written for each class.
  102057             : 
  102058             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  102059             :     // User wants multi-thread support and POSIX threads are available.
  102060             : #   include <pthread.h>
  102061             :     static pthread_mutex_t SgOmpTeamsStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  102062             : #else
  102063             :      // Cause synchronization to be skipped.
  102064             : #    ifndef ALLOC_MUTEX
  102065             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  102066             : #    endif
  102067             : #    ifdef _REENTRANT
  102068             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  102069             : #       ifdef _MSC_VER
  102070             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  102071             : #       else
  102072             : #           warning "POSIX threads are not available; synchronization being skipped"
  102073             : #       endif
  102074             : #    endif
  102075             : #endif
  102076             : 
  102077             : #ifndef ROSE_ALLOC_TRACE
  102078             : #  define ROSE_ALLOC_TRACE 0
  102079             : #endif
  102080             : 
  102081             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  102082             : #define ROSE_ALLOC_TRACE_CNT
  102083             : #include "memory-pool-snapshot.h"
  102084             : unsigned long alloc_trace_cnt = 0;
  102085             : #endif
  102086             : 
  102087             : #if ROSE_ALLOC_TRACE
  102088             : const unsigned SgOmpTeamsStatement::pool_size = 5;
  102089             : #else
  102090             : const unsigned SgOmpTeamsStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  102091             : #endif
  102092             : 
  102093             : #ifndef ROSE_ALLOC_MEMSET
  102094             : #  define ROSE_ALLOC_MEMSET 0
  102095             : #endif
  102096             : 
  102097             : #ifndef ROSE_PEDANTIC_ALLOC
  102098             : #  define ROSE_PEDANTIC_ALLOC 0
  102099             : #endif
  102100             : 
  102101             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  102102             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  102103             : #endif
  102104             : 
  102105             : #if !defined(SGNODE__ALL_POOLS)
  102106             : #define SGNODE__ALL_POOLS
  102107             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  102108             : #endif
  102109             : 
  102110             : SgOmpTeamsStatement* SgOmpTeamsStatement::next_node = nullptr;
  102111             : std::vector<unsigned char*> SgOmpTeamsStatement::pools;
  102112             : 
  102113             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  102114             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  102115             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  102116             : // around this macro definition rather than each use).
  102117             : #ifndef ALLOC_MUTEX
  102118             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  102119             :         do {                                                                     \
  102120             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  102121             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  102122             :                 abort();                                                         \
  102123             :             }                                                                    \
  102124             :         } while (0);
  102125             : #endif
  102126             : 
  102127             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  102128             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  102129             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  102130             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  102131             : 
  102132             : /*! \brief New operator for SgOmpTeamsStatement.
  102133             : 
  102134             :    This new operator implements memory pools to provide most efficent 
  102135             :    use of the heap within construction of large ASTs.
  102136             : 
  102137             : \internal The new and delete operators use the lower level C malloc/free
  102138             :    function calls for performance and to make sure that mixing of malloc/free
  102139             :    and new/delete by the used can be caught more readily.  This may change
  102140             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  102141             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  102142             :    deallocate memory allocated using ROSE_MALLOC.
  102143             : */
  102144           3 : void *SgOmpTeamsStatement::operator new ( size_t Size )
  102145             : {
  102146             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  102147             :      * returning or throwing an exception. */
  102148           3 :     ALLOC_MUTEX(SgOmpTeamsStatement, lock);
  102149             : 
  102150             : #if ROSE_ALLOC_TRACE == 2
  102151             : //    printf("SgOmpTeamsStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgOmpTeamsStatement::next_node);
  102152             : #endif
  102153             : 
  102154             : #if USE_CPP_NEW_DELETE_OPERATORS
  102155             :     void *mem = ROSE_MALLOC(Size);
  102156             :     ALLOC_MUTEX(SgOmpTeamsStatement, unlock);
  102157             :     return mem;
  102158             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  102159             : #if ROSE_PEDANTIC_ALLOC
  102160             :     ROSE_ASSERT(Size == sizeof(SgOmpTeamsStatement));
  102161             : #else
  102162           3 :     if (Size != sizeof(SgOmpTeamsStatement)) {
  102163           0 :       void * object = ROSE_MALLOC(Size);
  102164           0 :       ALLOC_MUTEX(SgOmpTeamsStatement, unlock);
  102165             :       return object;
  102166             :     }
  102167             : #endif
  102168             : 
  102169           3 :     if (SgOmpTeamsStatement::next_node == nullptr) {
  102170           3 :         SgOmpTeamsStatement * alloc = (SgOmpTeamsStatement*) ROSE_MALLOC ( SgOmpTeamsStatement::pool_size * sizeof(SgOmpTeamsStatement) );
  102171           3 :         ROSE_ASSERT(alloc != nullptr);
  102172             : 
  102173             : #if ROSE_ALLOC_TRACE == 2
  102174             : //        printf("SgOmpTeamsStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgOmpTeamsStatement::pools.size(), alloc, alloc + SgOmpTeamsStatement::pool_size);
  102175             : #endif
  102176             : 
  102177             : #if ROSE_ALLOC_MEMSET == 1
  102178             : #elif ROSE_ALLOC_MEMSET == 2
  102179             :         memset(alloc, 0x00, SgOmpTeamsStatement::pool_size * sizeof(SgOmpTeamsStatement));
  102180             : #elif ROSE_ALLOC_MEMSET == 3
  102181             :         memset(alloc, 0xAA, SgOmpTeamsStatement::pool_size * sizeof(SgOmpTeamsStatement));
  102182             : #endif
  102183        6000 :         for (unsigned i=0; i < SgOmpTeamsStatement::pool_size-1; i++) {
  102184        5997 :           alloc[i].p_freepointer = &(alloc[i+1]);
  102185             :         }
  102186           3 :         alloc[SgOmpTeamsStatement::pool_size-1].p_freepointer = nullptr;
  102187             : 
  102188           3 :         SgOmpTeamsStatement::pools.push_back ( (unsigned char *) alloc );
  102189           3 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgOmpTeamsStatement::pool_size * sizeof(SgOmpTeamsStatement), V_SgOmpTeamsStatement ) );
  102190           3 :         SgOmpTeamsStatement::next_node = alloc;
  102191             :     }
  102192           3 :     ROSE_ASSERT(SgOmpTeamsStatement::next_node != nullptr);
  102193             : 
  102194           3 :     SgOmpTeamsStatement * object = SgOmpTeamsStatement::next_node;
  102195           3 :     SgOmpTeamsStatement::next_node = (SgOmpTeamsStatement*)(object->p_freepointer);
  102196             : 
  102197             : #if ROSE_ALLOC_TRACE == 2
  102198             :     printf("SgOmpTeamsStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpTeamsStatement::next_node);
  102199             : #endif
  102200             : 
  102201           3 :     SgNode * fp = object->p_freepointer;
  102202             : #if ROSE_ALLOC_MEMSET == 1
  102203             : #elif ROSE_ALLOC_MEMSET == 2
  102204             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpTeamsStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  102205             : #elif ROSE_ALLOC_MEMSET == 3
  102206             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgOmpTeamsStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  102207             : #endif
  102208           3 :     object->p_freepointer = fp;
  102209             : 
  102210             : #if ROSE_ALLOC_TRACE == 2
  102211             : //    printf("SgOmpTeamsStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpTeamsStatement::next_node);
  102212             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  102213             :     Rose::MemPool::snapshot(oss.str());
  102214             :     alloc_trace_cnt++;
  102215             : #endif
  102216             : 
  102217           3 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  102218             : 
  102219           3 :     ALLOC_MUTEX(SgOmpTeamsStatement, unlock);
  102220             : 
  102221             :     return object;
  102222             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  102223             : }
  102224             : 
  102225             : 
  102226             : 
  102227             : /*! \brief Delete operator for SgOmpTeamsStatement.
  102228             : 
  102229             :    This delete operator implements deallocation using memory pools to 
  102230             :    provide most efficent use of the heap within construction of large ASTs.
  102231             : 
  102232             : \internal The new and delete operators use the lower level C malloc/free
  102233             :    function calls for performance and to make sure that mixing of malloc/free
  102234             :    and new/delete by the used can be caught more readily.  This may change
  102235             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  102236             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  102237             :    deallocate memory allocated using ROSE_MALLOC.
  102238             : */
  102239           0 : void SgOmpTeamsStatement::operator delete(void *Pointer, size_t Size)
  102240             : {
  102241             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  102242             :      * or throwing an exception. */
  102243           0 :     ALLOC_MUTEX(SgOmpTeamsStatement, lock);
  102244             : 
  102245             : #if USE_CPP_NEW_DELETE_OPERATORS
  102246             :     ROSE_FREE(Pointer);
  102247             : #else
  102248             : #if ROSE_PEDANTIC_ALLOC
  102249             :     ROSE_ASSERT(Size == sizeof(SgOmpTeamsStatement));
  102250             : #else
  102251           0 :     if (Size != sizeof(SgOmpTeamsStatement)) {
  102252           0 :       ROSE_FREE(Pointer);
  102253           0 :       ALLOC_MUTEX(SgOmpTeamsStatement, unlock);
  102254             :       return;
  102255             :     }
  102256             : #endif
  102257             : 
  102258           0 :     SgOmpTeamsStatement * object = (SgOmpTeamsStatement*) Pointer;
  102259           0 :     ROSE_ASSERT(object != nullptr);
  102260             : 
  102261             : #if ROSE_ALLOC_TRACE == 2
  102262             : //  printf("SgOmpTeamsStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpTeamsStatement::next_node);
  102263             :     printf("SgOmpTeamsStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpTeamsStatement::next_node);
  102264             : #endif
  102265             : 
  102266             : #if ROSE_PEDANTIC_ALLOC
  102267             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  102268             : #endif
  102269             : 
  102270             : #if ROSE_ALLOC_MEMSET == 1
  102271             : #elif ROSE_ALLOC_MEMSET == 2
  102272             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpTeamsStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  102273             : #elif ROSE_ALLOC_MEMSET == 3
  102274             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgOmpTeamsStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  102275             : #endif
  102276             : 
  102277             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  102278             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  102279             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  102280             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  102281             : #else
  102282           0 :     object->p_freepointer = SgOmpTeamsStatement::next_node;
  102283           0 :     SgOmpTeamsStatement::next_node = object;
  102284             : #endif
  102285             : 
  102286             : #if ROSE_ALLOC_TRACE == 2
  102287             : //  printf("SgOmpTeamsStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpTeamsStatement::next_node);
  102288             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  102289             :     Rose::MemPool::snapshot(oss.str());
  102290             :     alloc_trace_cnt++;
  102291             : #endif
  102292             : 
  102293             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  102294             : 
  102295           0 :     ALLOC_MUTEX(SgOmpTeamsStatement, unlock);
  102296             : }
  102297             : 
  102298             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  102299             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  102300             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  102301             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  102302             : // Also, note comment below from Robb (copied from the Common.code file).
  102303             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  102304             : //
  102305             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  102306             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  102307             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  102308             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  102309             : #if 0
  102310             : void SgOmpTeamsStatement::operator delete(void* pointer) { SgOmpTeamsStatement::operator delete (pointer, sizeof(SgOmpTeamsStatement)); };
  102311             : #endif
  102312             : /* #line 102313 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  102313             : 
  102314             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  102315             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  102316             : // obviously imply C++.
  102317             : 
  102318             : // This implements the support within ROSE for memory pools.  Memory pools
  102319             : // support the most condensed usage of memory within the construction of
  102320             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  102321             : // by a new operator written for each class.
  102322             : 
  102323             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  102324             :     // User wants multi-thread support and POSIX threads are available.
  102325             : #   include <pthread.h>
  102326             :     static pthread_mutex_t SgOmpSingleStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  102327             : #else
  102328             :      // Cause synchronization to be skipped.
  102329             : #    ifndef ALLOC_MUTEX
  102330             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  102331             : #    endif
  102332             : #    ifdef _REENTRANT
  102333             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  102334             : #       ifdef _MSC_VER
  102335             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  102336             : #       else
  102337             : #           warning "POSIX threads are not available; synchronization being skipped"
  102338             : #       endif
  102339             : #    endif
  102340             : #endif
  102341             : 
  102342             : #ifndef ROSE_ALLOC_TRACE
  102343             : #  define ROSE_ALLOC_TRACE 0
  102344             : #endif
  102345             : 
  102346             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  102347             : #define ROSE_ALLOC_TRACE_CNT
  102348             : #include "memory-pool-snapshot.h"
  102349             : unsigned long alloc_trace_cnt = 0;
  102350             : #endif
  102351             : 
  102352             : #if ROSE_ALLOC_TRACE
  102353             : const unsigned SgOmpSingleStatement::pool_size = 5;
  102354             : #else
  102355             : const unsigned SgOmpSingleStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  102356             : #endif
  102357             : 
  102358             : #ifndef ROSE_ALLOC_MEMSET
  102359             : #  define ROSE_ALLOC_MEMSET 0
  102360             : #endif
  102361             : 
  102362             : #ifndef ROSE_PEDANTIC_ALLOC
  102363             : #  define ROSE_PEDANTIC_ALLOC 0
  102364             : #endif
  102365             : 
  102366             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  102367             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  102368             : #endif
  102369             : 
  102370             : #if !defined(SGNODE__ALL_POOLS)
  102371             : #define SGNODE__ALL_POOLS
  102372             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  102373             : #endif
  102374             : 
  102375             : SgOmpSingleStatement* SgOmpSingleStatement::next_node = nullptr;
  102376             : std::vector<unsigned char*> SgOmpSingleStatement::pools;
  102377             : 
  102378             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  102379             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  102380             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  102381             : // around this macro definition rather than each use).
  102382             : #ifndef ALLOC_MUTEX
  102383             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  102384             :         do {                                                                     \
  102385             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  102386             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  102387             :                 abort();                                                         \
  102388             :             }                                                                    \
  102389             :         } while (0);
  102390             : #endif
  102391             : 
  102392             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  102393             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  102394             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  102395             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  102396             : 
  102397             : /*! \brief New operator for SgOmpSingleStatement.
  102398             : 
  102399             :    This new operator implements memory pools to provide most efficent 
  102400             :    use of the heap within construction of large ASTs.
  102401             : 
  102402             : \internal The new and delete operators use the lower level C malloc/free
  102403             :    function calls for performance and to make sure that mixing of malloc/free
  102404             :    and new/delete by the used can be caught more readily.  This may change
  102405             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  102406             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  102407             :    deallocate memory allocated using ROSE_MALLOC.
  102408             : */
  102409          84 : void *SgOmpSingleStatement::operator new ( size_t Size )
  102410             : {
  102411             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  102412             :      * returning or throwing an exception. */
  102413          84 :     ALLOC_MUTEX(SgOmpSingleStatement, lock);
  102414             : 
  102415             : #if ROSE_ALLOC_TRACE == 2
  102416             : //    printf("SgOmpSingleStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgOmpSingleStatement::next_node);
  102417             : #endif
  102418             : 
  102419             : #if USE_CPP_NEW_DELETE_OPERATORS
  102420             :     void *mem = ROSE_MALLOC(Size);
  102421             :     ALLOC_MUTEX(SgOmpSingleStatement, unlock);
  102422             :     return mem;
  102423             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  102424             : #if ROSE_PEDANTIC_ALLOC
  102425             :     ROSE_ASSERT(Size == sizeof(SgOmpSingleStatement));
  102426             : #else
  102427          84 :     if (Size != sizeof(SgOmpSingleStatement)) {
  102428           0 :       void * object = ROSE_MALLOC(Size);
  102429           0 :       ALLOC_MUTEX(SgOmpSingleStatement, unlock);
  102430             :       return object;
  102431             :     }
  102432             : #endif
  102433             : 
  102434          84 :     if (SgOmpSingleStatement::next_node == nullptr) {
  102435          64 :         SgOmpSingleStatement * alloc = (SgOmpSingleStatement*) ROSE_MALLOC ( SgOmpSingleStatement::pool_size * sizeof(SgOmpSingleStatement) );
  102436          64 :         ROSE_ASSERT(alloc != nullptr);
  102437             : 
  102438             : #if ROSE_ALLOC_TRACE == 2
  102439             : //        printf("SgOmpSingleStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgOmpSingleStatement::pools.size(), alloc, alloc + SgOmpSingleStatement::pool_size);
  102440             : #endif
  102441             : 
  102442             : #if ROSE_ALLOC_MEMSET == 1
  102443             : #elif ROSE_ALLOC_MEMSET == 2
  102444             :         memset(alloc, 0x00, SgOmpSingleStatement::pool_size * sizeof(SgOmpSingleStatement));
  102445             : #elif ROSE_ALLOC_MEMSET == 3
  102446             :         memset(alloc, 0xAA, SgOmpSingleStatement::pool_size * sizeof(SgOmpSingleStatement));
  102447             : #endif
  102448      128000 :         for (unsigned i=0; i < SgOmpSingleStatement::pool_size-1; i++) {
  102449      127936 :           alloc[i].p_freepointer = &(alloc[i+1]);
  102450             :         }
  102451          64 :         alloc[SgOmpSingleStatement::pool_size-1].p_freepointer = nullptr;
  102452             : 
  102453          64 :         SgOmpSingleStatement::pools.push_back ( (unsigned char *) alloc );
  102454          64 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgOmpSingleStatement::pool_size * sizeof(SgOmpSingleStatement), V_SgOmpSingleStatement ) );
  102455          64 :         SgOmpSingleStatement::next_node = alloc;
  102456             :     }
  102457          84 :     ROSE_ASSERT(SgOmpSingleStatement::next_node != nullptr);
  102458             : 
  102459          84 :     SgOmpSingleStatement * object = SgOmpSingleStatement::next_node;
  102460          84 :     SgOmpSingleStatement::next_node = (SgOmpSingleStatement*)(object->p_freepointer);
  102461             : 
  102462             : #if ROSE_ALLOC_TRACE == 2
  102463             :     printf("SgOmpSingleStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpSingleStatement::next_node);
  102464             : #endif
  102465             : 
  102466          84 :     SgNode * fp = object->p_freepointer;
  102467             : #if ROSE_ALLOC_MEMSET == 1
  102468             : #elif ROSE_ALLOC_MEMSET == 2
  102469             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpSingleStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  102470             : #elif ROSE_ALLOC_MEMSET == 3
  102471             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgOmpSingleStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  102472             : #endif
  102473          84 :     object->p_freepointer = fp;
  102474             : 
  102475             : #if ROSE_ALLOC_TRACE == 2
  102476             : //    printf("SgOmpSingleStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpSingleStatement::next_node);
  102477             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  102478             :     Rose::MemPool::snapshot(oss.str());
  102479             :     alloc_trace_cnt++;
  102480             : #endif
  102481             : 
  102482          84 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  102483             : 
  102484          84 :     ALLOC_MUTEX(SgOmpSingleStatement, unlock);
  102485             : 
  102486             :     return object;
  102487             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  102488             : }
  102489             : 
  102490             : 
  102491             : 
  102492             : /*! \brief Delete operator for SgOmpSingleStatement.
  102493             : 
  102494             :    This delete operator implements deallocation using memory pools to 
  102495             :    provide most efficent use of the heap within construction of large ASTs.
  102496             : 
  102497             : \internal The new and delete operators use the lower level C malloc/free
  102498             :    function calls for performance and to make sure that mixing of malloc/free
  102499             :    and new/delete by the used can be caught more readily.  This may change
  102500             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  102501             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  102502             :    deallocate memory allocated using ROSE_MALLOC.
  102503             : */
  102504           0 : void SgOmpSingleStatement::operator delete(void *Pointer, size_t Size)
  102505             : {
  102506             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  102507             :      * or throwing an exception. */
  102508           0 :     ALLOC_MUTEX(SgOmpSingleStatement, lock);
  102509             : 
  102510             : #if USE_CPP_NEW_DELETE_OPERATORS
  102511             :     ROSE_FREE(Pointer);
  102512             : #else
  102513             : #if ROSE_PEDANTIC_ALLOC
  102514             :     ROSE_ASSERT(Size == sizeof(SgOmpSingleStatement));
  102515             : #else
  102516           0 :     if (Size != sizeof(SgOmpSingleStatement)) {
  102517           0 :       ROSE_FREE(Pointer);
  102518           0 :       ALLOC_MUTEX(SgOmpSingleStatement, unlock);
  102519             :       return;
  102520             :     }
  102521             : #endif
  102522             : 
  102523           0 :     SgOmpSingleStatement * object = (SgOmpSingleStatement*) Pointer;
  102524           0 :     ROSE_ASSERT(object != nullptr);
  102525             : 
  102526             : #if ROSE_ALLOC_TRACE == 2
  102527             : //  printf("SgOmpSingleStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpSingleStatement::next_node);
  102528             :     printf("SgOmpSingleStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpSingleStatement::next_node);
  102529             : #endif
  102530             : 
  102531             : #if ROSE_PEDANTIC_ALLOC
  102532             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  102533             : #endif
  102534             : 
  102535             : #if ROSE_ALLOC_MEMSET == 1
  102536             : #elif ROSE_ALLOC_MEMSET == 2
  102537             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpSingleStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  102538             : #elif ROSE_ALLOC_MEMSET == 3
  102539             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgOmpSingleStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  102540             : #endif
  102541             : 
  102542             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  102543             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  102544             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  102545             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  102546             : #else
  102547           0 :     object->p_freepointer = SgOmpSingleStatement::next_node;
  102548           0 :     SgOmpSingleStatement::next_node = object;
  102549             : #endif
  102550             : 
  102551             : #if ROSE_ALLOC_TRACE == 2
  102552             : //  printf("SgOmpSingleStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpSingleStatement::next_node);
  102553             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  102554             :     Rose::MemPool::snapshot(oss.str());
  102555             :     alloc_trace_cnt++;
  102556             : #endif
  102557             : 
  102558             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  102559             : 
  102560           0 :     ALLOC_MUTEX(SgOmpSingleStatement, unlock);
  102561             : }
  102562             : 
  102563             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  102564             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  102565             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  102566             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  102567             : // Also, note comment below from Robb (copied from the Common.code file).
  102568             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  102569             : //
  102570             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  102571             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  102572             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  102573             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  102574             : #if 0
  102575             : void SgOmpSingleStatement::operator delete(void* pointer) { SgOmpSingleStatement::operator delete (pointer, sizeof(SgOmpSingleStatement)); };
  102576             : #endif
  102577             : /* #line 102578 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  102578             : 
  102579             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  102580             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  102581             : // obviously imply C++.
  102582             : 
  102583             : // This implements the support within ROSE for memory pools.  Memory pools
  102584             : // support the most condensed usage of memory within the construction of
  102585             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  102586             : // by a new operator written for each class.
  102587             : 
  102588             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  102589             :     // User wants multi-thread support and POSIX threads are available.
  102590             : #   include <pthread.h>
  102591             :     static pthread_mutex_t SgOmpAtomicStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  102592             : #else
  102593             :      // Cause synchronization to be skipped.
  102594             : #    ifndef ALLOC_MUTEX
  102595             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  102596             : #    endif
  102597             : #    ifdef _REENTRANT
  102598             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  102599             : #       ifdef _MSC_VER
  102600             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  102601             : #       else
  102602             : #           warning "POSIX threads are not available; synchronization being skipped"
  102603             : #       endif
  102604             : #    endif
  102605             : #endif
  102606             : 
  102607             : #ifndef ROSE_ALLOC_TRACE
  102608             : #  define ROSE_ALLOC_TRACE 0
  102609             : #endif
  102610             : 
  102611             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  102612             : #define ROSE_ALLOC_TRACE_CNT
  102613             : #include "memory-pool-snapshot.h"
  102614             : unsigned long alloc_trace_cnt = 0;
  102615             : #endif
  102616             : 
  102617             : #if ROSE_ALLOC_TRACE
  102618             : const unsigned SgOmpAtomicStatement::pool_size = 5;
  102619             : #else
  102620             : const unsigned SgOmpAtomicStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  102621             : #endif
  102622             : 
  102623             : #ifndef ROSE_ALLOC_MEMSET
  102624             : #  define ROSE_ALLOC_MEMSET 0
  102625             : #endif
  102626             : 
  102627             : #ifndef ROSE_PEDANTIC_ALLOC
  102628             : #  define ROSE_PEDANTIC_ALLOC 0
  102629             : #endif
  102630             : 
  102631             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  102632             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  102633             : #endif
  102634             : 
  102635             : #if !defined(SGNODE__ALL_POOLS)
  102636             : #define SGNODE__ALL_POOLS
  102637             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  102638             : #endif
  102639             : 
  102640             : SgOmpAtomicStatement* SgOmpAtomicStatement::next_node = nullptr;
  102641             : std::vector<unsigned char*> SgOmpAtomicStatement::pools;
  102642             : 
  102643             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  102644             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  102645             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  102646             : // around this macro definition rather than each use).
  102647             : #ifndef ALLOC_MUTEX
  102648             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  102649             :         do {                                                                     \
  102650             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  102651             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  102652             :                 abort();                                                         \
  102653             :             }                                                                    \
  102654             :         } while (0);
  102655             : #endif
  102656             : 
  102657             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  102658             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  102659             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  102660             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  102661             : 
  102662             : /*! \brief New operator for SgOmpAtomicStatement.
  102663             : 
  102664             :    This new operator implements memory pools to provide most efficent 
  102665             :    use of the heap within construction of large ASTs.
  102666             : 
  102667             : \internal The new and delete operators use the lower level C malloc/free
  102668             :    function calls for performance and to make sure that mixing of malloc/free
  102669             :    and new/delete by the used can be caught more readily.  This may change
  102670             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  102671             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  102672             :    deallocate memory allocated using ROSE_MALLOC.
  102673             : */
  102674           8 : void *SgOmpAtomicStatement::operator new ( size_t Size )
  102675             : {
  102676             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  102677             :      * returning or throwing an exception. */
  102678           8 :     ALLOC_MUTEX(SgOmpAtomicStatement, lock);
  102679             : 
  102680             : #if ROSE_ALLOC_TRACE == 2
  102681             : //    printf("SgOmpAtomicStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgOmpAtomicStatement::next_node);
  102682             : #endif
  102683             : 
  102684             : #if USE_CPP_NEW_DELETE_OPERATORS
  102685             :     void *mem = ROSE_MALLOC(Size);
  102686             :     ALLOC_MUTEX(SgOmpAtomicStatement, unlock);
  102687             :     return mem;
  102688             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  102689             : #if ROSE_PEDANTIC_ALLOC
  102690             :     ROSE_ASSERT(Size == sizeof(SgOmpAtomicStatement));
  102691             : #else
  102692           8 :     if (Size != sizeof(SgOmpAtomicStatement)) {
  102693           0 :       void * object = ROSE_MALLOC(Size);
  102694           0 :       ALLOC_MUTEX(SgOmpAtomicStatement, unlock);
  102695             :       return object;
  102696             :     }
  102697             : #endif
  102698             : 
  102699           8 :     if (SgOmpAtomicStatement::next_node == nullptr) {
  102700           5 :         SgOmpAtomicStatement * alloc = (SgOmpAtomicStatement*) ROSE_MALLOC ( SgOmpAtomicStatement::pool_size * sizeof(SgOmpAtomicStatement) );
  102701           5 :         ROSE_ASSERT(alloc != nullptr);
  102702             : 
  102703             : #if ROSE_ALLOC_TRACE == 2
  102704             : //        printf("SgOmpAtomicStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgOmpAtomicStatement::pools.size(), alloc, alloc + SgOmpAtomicStatement::pool_size);
  102705             : #endif
  102706             : 
  102707             : #if ROSE_ALLOC_MEMSET == 1
  102708             : #elif ROSE_ALLOC_MEMSET == 2
  102709             :         memset(alloc, 0x00, SgOmpAtomicStatement::pool_size * sizeof(SgOmpAtomicStatement));
  102710             : #elif ROSE_ALLOC_MEMSET == 3
  102711             :         memset(alloc, 0xAA, SgOmpAtomicStatement::pool_size * sizeof(SgOmpAtomicStatement));
  102712             : #endif
  102713       10000 :         for (unsigned i=0; i < SgOmpAtomicStatement::pool_size-1; i++) {
  102714        9995 :           alloc[i].p_freepointer = &(alloc[i+1]);
  102715             :         }
  102716           5 :         alloc[SgOmpAtomicStatement::pool_size-1].p_freepointer = nullptr;
  102717             : 
  102718           5 :         SgOmpAtomicStatement::pools.push_back ( (unsigned char *) alloc );
  102719           5 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgOmpAtomicStatement::pool_size * sizeof(SgOmpAtomicStatement), V_SgOmpAtomicStatement ) );
  102720           5 :         SgOmpAtomicStatement::next_node = alloc;
  102721             :     }
  102722           8 :     ROSE_ASSERT(SgOmpAtomicStatement::next_node != nullptr);
  102723             : 
  102724           8 :     SgOmpAtomicStatement * object = SgOmpAtomicStatement::next_node;
  102725           8 :     SgOmpAtomicStatement::next_node = (SgOmpAtomicStatement*)(object->p_freepointer);
  102726             : 
  102727             : #if ROSE_ALLOC_TRACE == 2
  102728             :     printf("SgOmpAtomicStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpAtomicStatement::next_node);
  102729             : #endif
  102730             : 
  102731           8 :     SgNode * fp = object->p_freepointer;
  102732             : #if ROSE_ALLOC_MEMSET == 1
  102733             : #elif ROSE_ALLOC_MEMSET == 2
  102734             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpAtomicStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  102735             : #elif ROSE_ALLOC_MEMSET == 3
  102736             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgOmpAtomicStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  102737             : #endif
  102738           8 :     object->p_freepointer = fp;
  102739             : 
  102740             : #if ROSE_ALLOC_TRACE == 2
  102741             : //    printf("SgOmpAtomicStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpAtomicStatement::next_node);
  102742             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  102743             :     Rose::MemPool::snapshot(oss.str());
  102744             :     alloc_trace_cnt++;
  102745             : #endif
  102746             : 
  102747           8 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  102748             : 
  102749           8 :     ALLOC_MUTEX(SgOmpAtomicStatement, unlock);
  102750             : 
  102751             :     return object;
  102752             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  102753             : }
  102754             : 
  102755             : 
  102756             : 
  102757             : /*! \brief Delete operator for SgOmpAtomicStatement.
  102758             : 
  102759             :    This delete operator implements deallocation using memory pools to 
  102760             :    provide most efficent use of the heap within construction of large ASTs.
  102761             : 
  102762             : \internal The new and delete operators use the lower level C malloc/free
  102763             :    function calls for performance and to make sure that mixing of malloc/free
  102764             :    and new/delete by the used can be caught more readily.  This may change
  102765             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  102766             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  102767             :    deallocate memory allocated using ROSE_MALLOC.
  102768             : */
  102769           0 : void SgOmpAtomicStatement::operator delete(void *Pointer, size_t Size)
  102770             : {
  102771             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  102772             :      * or throwing an exception. */
  102773           0 :     ALLOC_MUTEX(SgOmpAtomicStatement, lock);
  102774             : 
  102775             : #if USE_CPP_NEW_DELETE_OPERATORS
  102776             :     ROSE_FREE(Pointer);
  102777             : #else
  102778             : #if ROSE_PEDANTIC_ALLOC
  102779             :     ROSE_ASSERT(Size == sizeof(SgOmpAtomicStatement));
  102780             : #else
  102781           0 :     if (Size != sizeof(SgOmpAtomicStatement)) {
  102782           0 :       ROSE_FREE(Pointer);
  102783           0 :       ALLOC_MUTEX(SgOmpAtomicStatement, unlock);
  102784             :       return;
  102785             :     }
  102786             : #endif
  102787             : 
  102788           0 :     SgOmpAtomicStatement * object = (SgOmpAtomicStatement*) Pointer;
  102789           0 :     ROSE_ASSERT(object != nullptr);
  102790             : 
  102791             : #if ROSE_ALLOC_TRACE == 2
  102792             : //  printf("SgOmpAtomicStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpAtomicStatement::next_node);
  102793             :     printf("SgOmpAtomicStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpAtomicStatement::next_node);
  102794             : #endif
  102795             : 
  102796             : #if ROSE_PEDANTIC_ALLOC
  102797             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  102798             : #endif
  102799             : 
  102800             : #if ROSE_ALLOC_MEMSET == 1
  102801             : #elif ROSE_ALLOC_MEMSET == 2
  102802             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpAtomicStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  102803             : #elif ROSE_ALLOC_MEMSET == 3
  102804             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgOmpAtomicStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  102805             : #endif
  102806             : 
  102807             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  102808             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  102809             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  102810             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  102811             : #else
  102812           0 :     object->p_freepointer = SgOmpAtomicStatement::next_node;
  102813           0 :     SgOmpAtomicStatement::next_node = object;
  102814             : #endif
  102815             : 
  102816             : #if ROSE_ALLOC_TRACE == 2
  102817             : //  printf("SgOmpAtomicStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpAtomicStatement::next_node);
  102818             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  102819             :     Rose::MemPool::snapshot(oss.str());
  102820             :     alloc_trace_cnt++;
  102821             : #endif
  102822             : 
  102823             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  102824             : 
  102825           0 :     ALLOC_MUTEX(SgOmpAtomicStatement, unlock);
  102826             : }
  102827             : 
  102828             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  102829             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  102830             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  102831             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  102832             : // Also, note comment below from Robb (copied from the Common.code file).
  102833             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  102834             : //
  102835             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  102836             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  102837             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  102838             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  102839             : #if 0
  102840             : void SgOmpAtomicStatement::operator delete(void* pointer) { SgOmpAtomicStatement::operator delete (pointer, sizeof(SgOmpAtomicStatement)); };
  102841             : #endif
  102842             : /* #line 102843 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  102843             : 
  102844             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  102845             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  102846             : // obviously imply C++.
  102847             : 
  102848             : // This implements the support within ROSE for memory pools.  Memory pools
  102849             : // support the most condensed usage of memory within the construction of
  102850             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  102851             : // by a new operator written for each class.
  102852             : 
  102853             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  102854             :     // User wants multi-thread support and POSIX threads are available.
  102855             : #   include <pthread.h>
  102856             :     static pthread_mutex_t SgOmpScanStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  102857             : #else
  102858             :      // Cause synchronization to be skipped.
  102859             : #    ifndef ALLOC_MUTEX
  102860             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  102861             : #    endif
  102862             : #    ifdef _REENTRANT
  102863             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  102864             : #       ifdef _MSC_VER
  102865             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  102866             : #       else
  102867             : #           warning "POSIX threads are not available; synchronization being skipped"
  102868             : #       endif
  102869             : #    endif
  102870             : #endif
  102871             : 
  102872             : #ifndef ROSE_ALLOC_TRACE
  102873             : #  define ROSE_ALLOC_TRACE 0
  102874             : #endif
  102875             : 
  102876             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  102877             : #define ROSE_ALLOC_TRACE_CNT
  102878             : #include "memory-pool-snapshot.h"
  102879             : unsigned long alloc_trace_cnt = 0;
  102880             : #endif
  102881             : 
  102882             : #if ROSE_ALLOC_TRACE
  102883             : const unsigned SgOmpScanStatement::pool_size = 5;
  102884             : #else
  102885             : const unsigned SgOmpScanStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  102886             : #endif
  102887             : 
  102888             : #ifndef ROSE_ALLOC_MEMSET
  102889             : #  define ROSE_ALLOC_MEMSET 0
  102890             : #endif
  102891             : 
  102892             : #ifndef ROSE_PEDANTIC_ALLOC
  102893             : #  define ROSE_PEDANTIC_ALLOC 0
  102894             : #endif
  102895             : 
  102896             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  102897             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  102898             : #endif
  102899             : 
  102900             : #if !defined(SGNODE__ALL_POOLS)
  102901             : #define SGNODE__ALL_POOLS
  102902             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  102903             : #endif
  102904             : 
  102905             : SgOmpScanStatement* SgOmpScanStatement::next_node = nullptr;
  102906             : std::vector<unsigned char*> SgOmpScanStatement::pools;
  102907             : 
  102908             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  102909             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  102910             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  102911             : // around this macro definition rather than each use).
  102912             : #ifndef ALLOC_MUTEX
  102913             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  102914             :         do {                                                                     \
  102915             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  102916             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  102917             :                 abort();                                                         \
  102918             :             }                                                                    \
  102919             :         } while (0);
  102920             : #endif
  102921             : 
  102922             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  102923             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  102924             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  102925             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  102926             : 
  102927             : /*! \brief New operator for SgOmpScanStatement.
  102928             : 
  102929             :    This new operator implements memory pools to provide most efficent 
  102930             :    use of the heap within construction of large ASTs.
  102931             : 
  102932             : \internal The new and delete operators use the lower level C malloc/free
  102933             :    function calls for performance and to make sure that mixing of malloc/free
  102934             :    and new/delete by the used can be caught more readily.  This may change
  102935             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  102936             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  102937             :    deallocate memory allocated using ROSE_MALLOC.
  102938             : */
  102939           1 : void *SgOmpScanStatement::operator new ( size_t Size )
  102940             : {
  102941             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  102942             :      * returning or throwing an exception. */
  102943           1 :     ALLOC_MUTEX(SgOmpScanStatement, lock);
  102944             : 
  102945             : #if ROSE_ALLOC_TRACE == 2
  102946             : //    printf("SgOmpScanStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgOmpScanStatement::next_node);
  102947             : #endif
  102948             : 
  102949             : #if USE_CPP_NEW_DELETE_OPERATORS
  102950             :     void *mem = ROSE_MALLOC(Size);
  102951             :     ALLOC_MUTEX(SgOmpScanStatement, unlock);
  102952             :     return mem;
  102953             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  102954             : #if ROSE_PEDANTIC_ALLOC
  102955             :     ROSE_ASSERT(Size == sizeof(SgOmpScanStatement));
  102956             : #else
  102957           1 :     if (Size != sizeof(SgOmpScanStatement)) {
  102958           0 :       void * object = ROSE_MALLOC(Size);
  102959           0 :       ALLOC_MUTEX(SgOmpScanStatement, unlock);
  102960             :       return object;
  102961             :     }
  102962             : #endif
  102963             : 
  102964           1 :     if (SgOmpScanStatement::next_node == nullptr) {
  102965           1 :         SgOmpScanStatement * alloc = (SgOmpScanStatement*) ROSE_MALLOC ( SgOmpScanStatement::pool_size * sizeof(SgOmpScanStatement) );
  102966           1 :         ROSE_ASSERT(alloc != nullptr);
  102967             : 
  102968             : #if ROSE_ALLOC_TRACE == 2
  102969             : //        printf("SgOmpScanStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgOmpScanStatement::pools.size(), alloc, alloc + SgOmpScanStatement::pool_size);
  102970             : #endif
  102971             : 
  102972             : #if ROSE_ALLOC_MEMSET == 1
  102973             : #elif ROSE_ALLOC_MEMSET == 2
  102974             :         memset(alloc, 0x00, SgOmpScanStatement::pool_size * sizeof(SgOmpScanStatement));
  102975             : #elif ROSE_ALLOC_MEMSET == 3
  102976             :         memset(alloc, 0xAA, SgOmpScanStatement::pool_size * sizeof(SgOmpScanStatement));
  102977             : #endif
  102978        2000 :         for (unsigned i=0; i < SgOmpScanStatement::pool_size-1; i++) {
  102979        1999 :           alloc[i].p_freepointer = &(alloc[i+1]);
  102980             :         }
  102981           1 :         alloc[SgOmpScanStatement::pool_size-1].p_freepointer = nullptr;
  102982             : 
  102983           1 :         SgOmpScanStatement::pools.push_back ( (unsigned char *) alloc );
  102984           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgOmpScanStatement::pool_size * sizeof(SgOmpScanStatement), V_SgOmpScanStatement ) );
  102985           1 :         SgOmpScanStatement::next_node = alloc;
  102986             :     }
  102987           1 :     ROSE_ASSERT(SgOmpScanStatement::next_node != nullptr);
  102988             : 
  102989           1 :     SgOmpScanStatement * object = SgOmpScanStatement::next_node;
  102990           1 :     SgOmpScanStatement::next_node = (SgOmpScanStatement*)(object->p_freepointer);
  102991             : 
  102992             : #if ROSE_ALLOC_TRACE == 2
  102993             :     printf("SgOmpScanStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpScanStatement::next_node);
  102994             : #endif
  102995             : 
  102996           1 :     SgNode * fp = object->p_freepointer;
  102997             : #if ROSE_ALLOC_MEMSET == 1
  102998             : #elif ROSE_ALLOC_MEMSET == 2
  102999             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpScanStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  103000             : #elif ROSE_ALLOC_MEMSET == 3
  103001             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgOmpScanStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  103002             : #endif
  103003           1 :     object->p_freepointer = fp;
  103004             : 
  103005             : #if ROSE_ALLOC_TRACE == 2
  103006             : //    printf("SgOmpScanStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpScanStatement::next_node);
  103007             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  103008             :     Rose::MemPool::snapshot(oss.str());
  103009             :     alloc_trace_cnt++;
  103010             : #endif
  103011             : 
  103012           1 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  103013             : 
  103014           1 :     ALLOC_MUTEX(SgOmpScanStatement, unlock);
  103015             : 
  103016             :     return object;
  103017             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  103018             : }
  103019             : 
  103020             : 
  103021             : 
  103022             : /*! \brief Delete operator for SgOmpScanStatement.
  103023             : 
  103024             :    This delete operator implements deallocation using memory pools to 
  103025             :    provide most efficent use of the heap within construction of large ASTs.
  103026             : 
  103027             : \internal The new and delete operators use the lower level C malloc/free
  103028             :    function calls for performance and to make sure that mixing of malloc/free
  103029             :    and new/delete by the used can be caught more readily.  This may change
  103030             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  103031             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  103032             :    deallocate memory allocated using ROSE_MALLOC.
  103033             : */
  103034           0 : void SgOmpScanStatement::operator delete(void *Pointer, size_t Size)
  103035             : {
  103036             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  103037             :      * or throwing an exception. */
  103038           0 :     ALLOC_MUTEX(SgOmpScanStatement, lock);
  103039             : 
  103040             : #if USE_CPP_NEW_DELETE_OPERATORS
  103041             :     ROSE_FREE(Pointer);
  103042             : #else
  103043             : #if ROSE_PEDANTIC_ALLOC
  103044             :     ROSE_ASSERT(Size == sizeof(SgOmpScanStatement));
  103045             : #else
  103046           0 :     if (Size != sizeof(SgOmpScanStatement)) {
  103047           0 :       ROSE_FREE(Pointer);
  103048           0 :       ALLOC_MUTEX(SgOmpScanStatement, unlock);
  103049             :       return;
  103050             :     }
  103051             : #endif
  103052             : 
  103053           0 :     SgOmpScanStatement * object = (SgOmpScanStatement*) Pointer;
  103054           0 :     ROSE_ASSERT(object != nullptr);
  103055             : 
  103056             : #if ROSE_ALLOC_TRACE == 2
  103057             : //  printf("SgOmpScanStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpScanStatement::next_node);
  103058             :     printf("SgOmpScanStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpScanStatement::next_node);
  103059             : #endif
  103060             : 
  103061             : #if ROSE_PEDANTIC_ALLOC
  103062             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  103063             : #endif
  103064             : 
  103065             : #if ROSE_ALLOC_MEMSET == 1
  103066             : #elif ROSE_ALLOC_MEMSET == 2
  103067             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpScanStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  103068             : #elif ROSE_ALLOC_MEMSET == 3
  103069             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgOmpScanStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  103070             : #endif
  103071             : 
  103072             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  103073             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  103074             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  103075             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  103076             : #else
  103077           0 :     object->p_freepointer = SgOmpScanStatement::next_node;
  103078           0 :     SgOmpScanStatement::next_node = object;
  103079             : #endif
  103080             : 
  103081             : #if ROSE_ALLOC_TRACE == 2
  103082             : //  printf("SgOmpScanStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpScanStatement::next_node);
  103083             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  103084             :     Rose::MemPool::snapshot(oss.str());
  103085             :     alloc_trace_cnt++;
  103086             : #endif
  103087             : 
  103088             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  103089             : 
  103090           0 :     ALLOC_MUTEX(SgOmpScanStatement, unlock);
  103091             : }
  103092             : 
  103093             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  103094             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  103095             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  103096             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  103097             : // Also, note comment below from Robb (copied from the Common.code file).
  103098             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  103099             : //
  103100             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  103101             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  103102             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  103103             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  103104             : #if 0
  103105             : void SgOmpScanStatement::operator delete(void* pointer) { SgOmpScanStatement::operator delete (pointer, sizeof(SgOmpScanStatement)); };
  103106             : #endif
  103107             : /* #line 103108 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  103108             : 
  103109             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  103110             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  103111             : // obviously imply C++.
  103112             : 
  103113             : // This implements the support within ROSE for memory pools.  Memory pools
  103114             : // support the most condensed usage of memory within the construction of
  103115             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  103116             : // by a new operator written for each class.
  103117             : 
  103118             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  103119             :     // User wants multi-thread support and POSIX threads are available.
  103120             : #   include <pthread.h>
  103121             :     static pthread_mutex_t SgOmpMetadirectiveStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  103122             : #else
  103123             :      // Cause synchronization to be skipped.
  103124             : #    ifndef ALLOC_MUTEX
  103125             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  103126             : #    endif
  103127             : #    ifdef _REENTRANT
  103128             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  103129             : #       ifdef _MSC_VER
  103130             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  103131             : #       else
  103132             : #           warning "POSIX threads are not available; synchronization being skipped"
  103133             : #       endif
  103134             : #    endif
  103135             : #endif
  103136             : 
  103137             : #ifndef ROSE_ALLOC_TRACE
  103138             : #  define ROSE_ALLOC_TRACE 0
  103139             : #endif
  103140             : 
  103141             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  103142             : #define ROSE_ALLOC_TRACE_CNT
  103143             : #include "memory-pool-snapshot.h"
  103144             : unsigned long alloc_trace_cnt = 0;
  103145             : #endif
  103146             : 
  103147             : #if ROSE_ALLOC_TRACE
  103148             : const unsigned SgOmpMetadirectiveStatement::pool_size = 5;
  103149             : #else
  103150             : const unsigned SgOmpMetadirectiveStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  103151             : #endif
  103152             : 
  103153             : #ifndef ROSE_ALLOC_MEMSET
  103154             : #  define ROSE_ALLOC_MEMSET 0
  103155             : #endif
  103156             : 
  103157             : #ifndef ROSE_PEDANTIC_ALLOC
  103158             : #  define ROSE_PEDANTIC_ALLOC 0
  103159             : #endif
  103160             : 
  103161             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  103162             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  103163             : #endif
  103164             : 
  103165             : #if !defined(SGNODE__ALL_POOLS)
  103166             : #define SGNODE__ALL_POOLS
  103167             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  103168             : #endif
  103169             : 
  103170             : SgOmpMetadirectiveStatement* SgOmpMetadirectiveStatement::next_node = nullptr;
  103171             : std::vector<unsigned char*> SgOmpMetadirectiveStatement::pools;
  103172             : 
  103173             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  103174             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  103175             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  103176             : // around this macro definition rather than each use).
  103177             : #ifndef ALLOC_MUTEX
  103178             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  103179             :         do {                                                                     \
  103180             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  103181             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  103182             :                 abort();                                                         \
  103183             :             }                                                                    \
  103184             :         } while (0);
  103185             : #endif
  103186             : 
  103187             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  103188             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  103189             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  103190             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  103191             : 
  103192             : /*! \brief New operator for SgOmpMetadirectiveStatement.
  103193             : 
  103194             :    This new operator implements memory pools to provide most efficent 
  103195             :    use of the heap within construction of large ASTs.
  103196             : 
  103197             : \internal The new and delete operators use the lower level C malloc/free
  103198             :    function calls for performance and to make sure that mixing of malloc/free
  103199             :    and new/delete by the used can be caught more readily.  This may change
  103200             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  103201             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  103202             :    deallocate memory allocated using ROSE_MALLOC.
  103203             : */
  103204           0 : void *SgOmpMetadirectiveStatement::operator new ( size_t Size )
  103205             : {
  103206             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  103207             :      * returning or throwing an exception. */
  103208           0 :     ALLOC_MUTEX(SgOmpMetadirectiveStatement, lock);
  103209             : 
  103210             : #if ROSE_ALLOC_TRACE == 2
  103211             : //    printf("SgOmpMetadirectiveStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgOmpMetadirectiveStatement::next_node);
  103212             : #endif
  103213             : 
  103214             : #if USE_CPP_NEW_DELETE_OPERATORS
  103215             :     void *mem = ROSE_MALLOC(Size);
  103216             :     ALLOC_MUTEX(SgOmpMetadirectiveStatement, unlock);
  103217             :     return mem;
  103218             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  103219             : #if ROSE_PEDANTIC_ALLOC
  103220             :     ROSE_ASSERT(Size == sizeof(SgOmpMetadirectiveStatement));
  103221             : #else
  103222           0 :     if (Size != sizeof(SgOmpMetadirectiveStatement)) {
  103223           0 :       void * object = ROSE_MALLOC(Size);
  103224           0 :       ALLOC_MUTEX(SgOmpMetadirectiveStatement, unlock);
  103225             :       return object;
  103226             :     }
  103227             : #endif
  103228             : 
  103229           0 :     if (SgOmpMetadirectiveStatement::next_node == nullptr) {
  103230           0 :         SgOmpMetadirectiveStatement * alloc = (SgOmpMetadirectiveStatement*) ROSE_MALLOC ( SgOmpMetadirectiveStatement::pool_size * sizeof(SgOmpMetadirectiveStatement) );
  103231           0 :         ROSE_ASSERT(alloc != nullptr);
  103232             : 
  103233             : #if ROSE_ALLOC_TRACE == 2
  103234             : //        printf("SgOmpMetadirectiveStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgOmpMetadirectiveStatement::pools.size(), alloc, alloc + SgOmpMetadirectiveStatement::pool_size);
  103235             : #endif
  103236             : 
  103237             : #if ROSE_ALLOC_MEMSET == 1
  103238             : #elif ROSE_ALLOC_MEMSET == 2
  103239             :         memset(alloc, 0x00, SgOmpMetadirectiveStatement::pool_size * sizeof(SgOmpMetadirectiveStatement));
  103240             : #elif ROSE_ALLOC_MEMSET == 3
  103241             :         memset(alloc, 0xAA, SgOmpMetadirectiveStatement::pool_size * sizeof(SgOmpMetadirectiveStatement));
  103242             : #endif
  103243           0 :         for (unsigned i=0; i < SgOmpMetadirectiveStatement::pool_size-1; i++) {
  103244           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
  103245             :         }
  103246           0 :         alloc[SgOmpMetadirectiveStatement::pool_size-1].p_freepointer = nullptr;
  103247             : 
  103248           0 :         SgOmpMetadirectiveStatement::pools.push_back ( (unsigned char *) alloc );
  103249           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgOmpMetadirectiveStatement::pool_size * sizeof(SgOmpMetadirectiveStatement), V_SgOmpMetadirectiveStatement ) );
  103250           0 :         SgOmpMetadirectiveStatement::next_node = alloc;
  103251             :     }
  103252           0 :     ROSE_ASSERT(SgOmpMetadirectiveStatement::next_node != nullptr);
  103253             : 
  103254           0 :     SgOmpMetadirectiveStatement * object = SgOmpMetadirectiveStatement::next_node;
  103255           0 :     SgOmpMetadirectiveStatement::next_node = (SgOmpMetadirectiveStatement*)(object->p_freepointer);
  103256             : 
  103257             : #if ROSE_ALLOC_TRACE == 2
  103258             :     printf("SgOmpMetadirectiveStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpMetadirectiveStatement::next_node);
  103259             : #endif
  103260             : 
  103261           0 :     SgNode * fp = object->p_freepointer;
  103262             : #if ROSE_ALLOC_MEMSET == 1
  103263             : #elif ROSE_ALLOC_MEMSET == 2
  103264             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpMetadirectiveStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  103265             : #elif ROSE_ALLOC_MEMSET == 3
  103266             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgOmpMetadirectiveStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  103267             : #endif
  103268           0 :     object->p_freepointer = fp;
  103269             : 
  103270             : #if ROSE_ALLOC_TRACE == 2
  103271             : //    printf("SgOmpMetadirectiveStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpMetadirectiveStatement::next_node);
  103272             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  103273             :     Rose::MemPool::snapshot(oss.str());
  103274             :     alloc_trace_cnt++;
  103275             : #endif
  103276             : 
  103277           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  103278             : 
  103279           0 :     ALLOC_MUTEX(SgOmpMetadirectiveStatement, unlock);
  103280             : 
  103281             :     return object;
  103282             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  103283             : }
  103284             : 
  103285             : 
  103286             : 
  103287             : /*! \brief Delete operator for SgOmpMetadirectiveStatement.
  103288             : 
  103289             :    This delete operator implements deallocation using memory pools to 
  103290             :    provide most efficent use of the heap within construction of large ASTs.
  103291             : 
  103292             : \internal The new and delete operators use the lower level C malloc/free
  103293             :    function calls for performance and to make sure that mixing of malloc/free
  103294             :    and new/delete by the used can be caught more readily.  This may change
  103295             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  103296             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  103297             :    deallocate memory allocated using ROSE_MALLOC.
  103298             : */
  103299           0 : void SgOmpMetadirectiveStatement::operator delete(void *Pointer, size_t Size)
  103300             : {
  103301             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  103302             :      * or throwing an exception. */
  103303           0 :     ALLOC_MUTEX(SgOmpMetadirectiveStatement, lock);
  103304             : 
  103305             : #if USE_CPP_NEW_DELETE_OPERATORS
  103306             :     ROSE_FREE(Pointer);
  103307             : #else
  103308             : #if ROSE_PEDANTIC_ALLOC
  103309             :     ROSE_ASSERT(Size == sizeof(SgOmpMetadirectiveStatement));
  103310             : #else
  103311           0 :     if (Size != sizeof(SgOmpMetadirectiveStatement)) {
  103312           0 :       ROSE_FREE(Pointer);
  103313           0 :       ALLOC_MUTEX(SgOmpMetadirectiveStatement, unlock);
  103314             :       return;
  103315             :     }
  103316             : #endif
  103317             : 
  103318           0 :     SgOmpMetadirectiveStatement * object = (SgOmpMetadirectiveStatement*) Pointer;
  103319           0 :     ROSE_ASSERT(object != nullptr);
  103320             : 
  103321             : #if ROSE_ALLOC_TRACE == 2
  103322             : //  printf("SgOmpMetadirectiveStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpMetadirectiveStatement::next_node);
  103323             :     printf("SgOmpMetadirectiveStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpMetadirectiveStatement::next_node);
  103324             : #endif
  103325             : 
  103326             : #if ROSE_PEDANTIC_ALLOC
  103327             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  103328             : #endif
  103329             : 
  103330             : #if ROSE_ALLOC_MEMSET == 1
  103331             : #elif ROSE_ALLOC_MEMSET == 2
  103332             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpMetadirectiveStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  103333             : #elif ROSE_ALLOC_MEMSET == 3
  103334             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgOmpMetadirectiveStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  103335             : #endif
  103336             : 
  103337             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  103338             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  103339             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  103340             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  103341             : #else
  103342           0 :     object->p_freepointer = SgOmpMetadirectiveStatement::next_node;
  103343           0 :     SgOmpMetadirectiveStatement::next_node = object;
  103344             : #endif
  103345             : 
  103346             : #if ROSE_ALLOC_TRACE == 2
  103347             : //  printf("SgOmpMetadirectiveStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpMetadirectiveStatement::next_node);
  103348             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  103349             :     Rose::MemPool::snapshot(oss.str());
  103350             :     alloc_trace_cnt++;
  103351             : #endif
  103352             : 
  103353             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  103354             : 
  103355           0 :     ALLOC_MUTEX(SgOmpMetadirectiveStatement, unlock);
  103356             : }
  103357             : 
  103358             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  103359             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  103360             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  103361             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  103362             : // Also, note comment below from Robb (copied from the Common.code file).
  103363             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  103364             : //
  103365             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  103366             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  103367             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  103368             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  103369             : #if 0
  103370             : void SgOmpMetadirectiveStatement::operator delete(void* pointer) { SgOmpMetadirectiveStatement::operator delete (pointer, sizeof(SgOmpMetadirectiveStatement)); };
  103371             : #endif
  103372             : /* #line 103373 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  103373             : 
  103374             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  103375             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  103376             : // obviously imply C++.
  103377             : 
  103378             : // This implements the support within ROSE for memory pools.  Memory pools
  103379             : // support the most condensed usage of memory within the construction of
  103380             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  103381             : // by a new operator written for each class.
  103382             : 
  103383             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  103384             :     // User wants multi-thread support and POSIX threads are available.
  103385             : #   include <pthread.h>
  103386             :     static pthread_mutex_t SgOmpLoopStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  103387             : #else
  103388             :      // Cause synchronization to be skipped.
  103389             : #    ifndef ALLOC_MUTEX
  103390             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  103391             : #    endif
  103392             : #    ifdef _REENTRANT
  103393             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  103394             : #       ifdef _MSC_VER
  103395             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  103396             : #       else
  103397             : #           warning "POSIX threads are not available; synchronization being skipped"
  103398             : #       endif
  103399             : #    endif
  103400             : #endif
  103401             : 
  103402             : #ifndef ROSE_ALLOC_TRACE
  103403             : #  define ROSE_ALLOC_TRACE 0
  103404             : #endif
  103405             : 
  103406             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  103407             : #define ROSE_ALLOC_TRACE_CNT
  103408             : #include "memory-pool-snapshot.h"
  103409             : unsigned long alloc_trace_cnt = 0;
  103410             : #endif
  103411             : 
  103412             : #if ROSE_ALLOC_TRACE
  103413             : const unsigned SgOmpLoopStatement::pool_size = 5;
  103414             : #else
  103415             : const unsigned SgOmpLoopStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  103416             : #endif
  103417             : 
  103418             : #ifndef ROSE_ALLOC_MEMSET
  103419             : #  define ROSE_ALLOC_MEMSET 0
  103420             : #endif
  103421             : 
  103422             : #ifndef ROSE_PEDANTIC_ALLOC
  103423             : #  define ROSE_PEDANTIC_ALLOC 0
  103424             : #endif
  103425             : 
  103426             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  103427             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  103428             : #endif
  103429             : 
  103430             : #if !defined(SGNODE__ALL_POOLS)
  103431             : #define SGNODE__ALL_POOLS
  103432             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  103433             : #endif
  103434             : 
  103435             : SgOmpLoopStatement* SgOmpLoopStatement::next_node = nullptr;
  103436             : std::vector<unsigned char*> SgOmpLoopStatement::pools;
  103437             : 
  103438             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  103439             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  103440             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  103441             : // around this macro definition rather than each use).
  103442             : #ifndef ALLOC_MUTEX
  103443             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  103444             :         do {                                                                     \
  103445             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  103446             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  103447             :                 abort();                                                         \
  103448             :             }                                                                    \
  103449             :         } while (0);
  103450             : #endif
  103451             : 
  103452             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  103453             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  103454             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  103455             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  103456             : 
  103457             : /*! \brief New operator for SgOmpLoopStatement.
  103458             : 
  103459             :    This new operator implements memory pools to provide most efficent 
  103460             :    use of the heap within construction of large ASTs.
  103461             : 
  103462             : \internal The new and delete operators use the lower level C malloc/free
  103463             :    function calls for performance and to make sure that mixing of malloc/free
  103464             :    and new/delete by the used can be caught more readily.  This may change
  103465             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  103466             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  103467             :    deallocate memory allocated using ROSE_MALLOC.
  103468             : */
  103469           1 : void *SgOmpLoopStatement::operator new ( size_t Size )
  103470             : {
  103471             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  103472             :      * returning or throwing an exception. */
  103473           1 :     ALLOC_MUTEX(SgOmpLoopStatement, lock);
  103474             : 
  103475             : #if ROSE_ALLOC_TRACE == 2
  103476             : //    printf("SgOmpLoopStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgOmpLoopStatement::next_node);
  103477             : #endif
  103478             : 
  103479             : #if USE_CPP_NEW_DELETE_OPERATORS
  103480             :     void *mem = ROSE_MALLOC(Size);
  103481             :     ALLOC_MUTEX(SgOmpLoopStatement, unlock);
  103482             :     return mem;
  103483             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  103484             : #if ROSE_PEDANTIC_ALLOC
  103485             :     ROSE_ASSERT(Size == sizeof(SgOmpLoopStatement));
  103486             : #else
  103487           1 :     if (Size != sizeof(SgOmpLoopStatement)) {
  103488           0 :       void * object = ROSE_MALLOC(Size);
  103489           0 :       ALLOC_MUTEX(SgOmpLoopStatement, unlock);
  103490             :       return object;
  103491             :     }
  103492             : #endif
  103493             : 
  103494           1 :     if (SgOmpLoopStatement::next_node == nullptr) {
  103495           1 :         SgOmpLoopStatement * alloc = (SgOmpLoopStatement*) ROSE_MALLOC ( SgOmpLoopStatement::pool_size * sizeof(SgOmpLoopStatement) );
  103496           1 :         ROSE_ASSERT(alloc != nullptr);
  103497             : 
  103498             : #if ROSE_ALLOC_TRACE == 2
  103499             : //        printf("SgOmpLoopStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgOmpLoopStatement::pools.size(), alloc, alloc + SgOmpLoopStatement::pool_size);
  103500             : #endif
  103501             : 
  103502             : #if ROSE_ALLOC_MEMSET == 1
  103503             : #elif ROSE_ALLOC_MEMSET == 2
  103504             :         memset(alloc, 0x00, SgOmpLoopStatement::pool_size * sizeof(SgOmpLoopStatement));
  103505             : #elif ROSE_ALLOC_MEMSET == 3
  103506             :         memset(alloc, 0xAA, SgOmpLoopStatement::pool_size * sizeof(SgOmpLoopStatement));
  103507             : #endif
  103508        2000 :         for (unsigned i=0; i < SgOmpLoopStatement::pool_size-1; i++) {
  103509        1999 :           alloc[i].p_freepointer = &(alloc[i+1]);
  103510             :         }
  103511           1 :         alloc[SgOmpLoopStatement::pool_size-1].p_freepointer = nullptr;
  103512             : 
  103513           1 :         SgOmpLoopStatement::pools.push_back ( (unsigned char *) alloc );
  103514           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgOmpLoopStatement::pool_size * sizeof(SgOmpLoopStatement), V_SgOmpLoopStatement ) );
  103515           1 :         SgOmpLoopStatement::next_node = alloc;
  103516             :     }
  103517           1 :     ROSE_ASSERT(SgOmpLoopStatement::next_node != nullptr);
  103518             : 
  103519           1 :     SgOmpLoopStatement * object = SgOmpLoopStatement::next_node;
  103520           1 :     SgOmpLoopStatement::next_node = (SgOmpLoopStatement*)(object->p_freepointer);
  103521             : 
  103522             : #if ROSE_ALLOC_TRACE == 2
  103523             :     printf("SgOmpLoopStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpLoopStatement::next_node);
  103524             : #endif
  103525             : 
  103526           1 :     SgNode * fp = object->p_freepointer;
  103527             : #if ROSE_ALLOC_MEMSET == 1
  103528             : #elif ROSE_ALLOC_MEMSET == 2
  103529             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpLoopStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  103530             : #elif ROSE_ALLOC_MEMSET == 3
  103531             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgOmpLoopStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  103532             : #endif
  103533           1 :     object->p_freepointer = fp;
  103534             : 
  103535             : #if ROSE_ALLOC_TRACE == 2
  103536             : //    printf("SgOmpLoopStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpLoopStatement::next_node);
  103537             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  103538             :     Rose::MemPool::snapshot(oss.str());
  103539             :     alloc_trace_cnt++;
  103540             : #endif
  103541             : 
  103542           1 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  103543             : 
  103544           1 :     ALLOC_MUTEX(SgOmpLoopStatement, unlock);
  103545             : 
  103546             :     return object;
  103547             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  103548             : }
  103549             : 
  103550             : 
  103551             : 
  103552             : /*! \brief Delete operator for SgOmpLoopStatement.
  103553             : 
  103554             :    This delete operator implements deallocation using memory pools to 
  103555             :    provide most efficent use of the heap within construction of large ASTs.
  103556             : 
  103557             : \internal The new and delete operators use the lower level C malloc/free
  103558             :    function calls for performance and to make sure that mixing of malloc/free
  103559             :    and new/delete by the used can be caught more readily.  This may change
  103560             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  103561             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  103562             :    deallocate memory allocated using ROSE_MALLOC.
  103563             : */
  103564           0 : void SgOmpLoopStatement::operator delete(void *Pointer, size_t Size)
  103565             : {
  103566             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  103567             :      * or throwing an exception. */
  103568           0 :     ALLOC_MUTEX(SgOmpLoopStatement, lock);
  103569             : 
  103570             : #if USE_CPP_NEW_DELETE_OPERATORS
  103571             :     ROSE_FREE(Pointer);
  103572             : #else
  103573             : #if ROSE_PEDANTIC_ALLOC
  103574             :     ROSE_ASSERT(Size == sizeof(SgOmpLoopStatement));
  103575             : #else
  103576           0 :     if (Size != sizeof(SgOmpLoopStatement)) {
  103577           0 :       ROSE_FREE(Pointer);
  103578           0 :       ALLOC_MUTEX(SgOmpLoopStatement, unlock);
  103579             :       return;
  103580             :     }
  103581             : #endif
  103582             : 
  103583           0 :     SgOmpLoopStatement * object = (SgOmpLoopStatement*) Pointer;
  103584           0 :     ROSE_ASSERT(object != nullptr);
  103585             : 
  103586             : #if ROSE_ALLOC_TRACE == 2
  103587             : //  printf("SgOmpLoopStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpLoopStatement::next_node);
  103588             :     printf("SgOmpLoopStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpLoopStatement::next_node);
  103589             : #endif
  103590             : 
  103591             : #if ROSE_PEDANTIC_ALLOC
  103592             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  103593             : #endif
  103594             : 
  103595             : #if ROSE_ALLOC_MEMSET == 1
  103596             : #elif ROSE_ALLOC_MEMSET == 2
  103597             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpLoopStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  103598             : #elif ROSE_ALLOC_MEMSET == 3
  103599             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgOmpLoopStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  103600             : #endif
  103601             : 
  103602             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  103603             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  103604             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  103605             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  103606             : #else
  103607           0 :     object->p_freepointer = SgOmpLoopStatement::next_node;
  103608           0 :     SgOmpLoopStatement::next_node = object;
  103609             : #endif
  103610             : 
  103611             : #if ROSE_ALLOC_TRACE == 2
  103612             : //  printf("SgOmpLoopStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpLoopStatement::next_node);
  103613             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  103614             :     Rose::MemPool::snapshot(oss.str());
  103615             :     alloc_trace_cnt++;
  103616             : #endif
  103617             : 
  103618             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  103619             : 
  103620           0 :     ALLOC_MUTEX(SgOmpLoopStatement, unlock);
  103621             : }
  103622             : 
  103623             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  103624             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  103625             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  103626             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  103627             : // Also, note comment below from Robb (copied from the Common.code file).
  103628             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  103629             : //
  103630             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  103631             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  103632             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  103633             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  103634             : #if 0
  103635             : void SgOmpLoopStatement::operator delete(void* pointer) { SgOmpLoopStatement::operator delete (pointer, sizeof(SgOmpLoopStatement)); };
  103636             : #endif
  103637             : /* #line 103638 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  103638             : 
  103639             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  103640             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  103641             : // obviously imply C++.
  103642             : 
  103643             : // This implements the support within ROSE for memory pools.  Memory pools
  103644             : // support the most condensed usage of memory within the construction of
  103645             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  103646             : // by a new operator written for each class.
  103647             : 
  103648             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  103649             :     // User wants multi-thread support and POSIX threads are available.
  103650             : #   include <pthread.h>
  103651             :     static pthread_mutex_t SgOmpOrderedStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  103652             : #else
  103653             :      // Cause synchronization to be skipped.
  103654             : #    ifndef ALLOC_MUTEX
  103655             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  103656             : #    endif
  103657             : #    ifdef _REENTRANT
  103658             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  103659             : #       ifdef _MSC_VER
  103660             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  103661             : #       else
  103662             : #           warning "POSIX threads are not available; synchronization being skipped"
  103663             : #       endif
  103664             : #    endif
  103665             : #endif
  103666             : 
  103667             : #ifndef ROSE_ALLOC_TRACE
  103668             : #  define ROSE_ALLOC_TRACE 0
  103669             : #endif
  103670             : 
  103671             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  103672             : #define ROSE_ALLOC_TRACE_CNT
  103673             : #include "memory-pool-snapshot.h"
  103674             : unsigned long alloc_trace_cnt = 0;
  103675             : #endif
  103676             : 
  103677             : #if ROSE_ALLOC_TRACE
  103678             : const unsigned SgOmpOrderedStatement::pool_size = 5;
  103679             : #else
  103680             : const unsigned SgOmpOrderedStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  103681             : #endif
  103682             : 
  103683             : #ifndef ROSE_ALLOC_MEMSET
  103684             : #  define ROSE_ALLOC_MEMSET 0
  103685             : #endif
  103686             : 
  103687             : #ifndef ROSE_PEDANTIC_ALLOC
  103688             : #  define ROSE_PEDANTIC_ALLOC 0
  103689             : #endif
  103690             : 
  103691             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  103692             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  103693             : #endif
  103694             : 
  103695             : #if !defined(SGNODE__ALL_POOLS)
  103696             : #define SGNODE__ALL_POOLS
  103697             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  103698             : #endif
  103699             : 
  103700             : SgOmpOrderedStatement* SgOmpOrderedStatement::next_node = nullptr;
  103701             : std::vector<unsigned char*> SgOmpOrderedStatement::pools;
  103702             : 
  103703             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  103704             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  103705             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  103706             : // around this macro definition rather than each use).
  103707             : #ifndef ALLOC_MUTEX
  103708             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  103709             :         do {                                                                     \
  103710             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  103711             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  103712             :                 abort();                                                         \
  103713             :             }                                                                    \
  103714             :         } while (0);
  103715             : #endif
  103716             : 
  103717             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  103718             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  103719             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  103720             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  103721             : 
  103722             : /*! \brief New operator for SgOmpOrderedStatement.
  103723             : 
  103724             :    This new operator implements memory pools to provide most efficent 
  103725             :    use of the heap within construction of large ASTs.
  103726             : 
  103727             : \internal The new and delete operators use the lower level C malloc/free
  103728             :    function calls for performance and to make sure that mixing of malloc/free
  103729             :    and new/delete by the used can be caught more readily.  This may change
  103730             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  103731             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  103732             :    deallocate memory allocated using ROSE_MALLOC.
  103733             : */
  103734           4 : void *SgOmpOrderedStatement::operator new ( size_t Size )
  103735             : {
  103736             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  103737             :      * returning or throwing an exception. */
  103738           4 :     ALLOC_MUTEX(SgOmpOrderedStatement, lock);
  103739             : 
  103740             : #if ROSE_ALLOC_TRACE == 2
  103741             : //    printf("SgOmpOrderedStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgOmpOrderedStatement::next_node);
  103742             : #endif
  103743             : 
  103744             : #if USE_CPP_NEW_DELETE_OPERATORS
  103745             :     void *mem = ROSE_MALLOC(Size);
  103746             :     ALLOC_MUTEX(SgOmpOrderedStatement, unlock);
  103747             :     return mem;
  103748             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  103749             : #if ROSE_PEDANTIC_ALLOC
  103750             :     ROSE_ASSERT(Size == sizeof(SgOmpOrderedStatement));
  103751             : #else
  103752           4 :     if (Size != sizeof(SgOmpOrderedStatement)) {
  103753           0 :       void * object = ROSE_MALLOC(Size);
  103754           0 :       ALLOC_MUTEX(SgOmpOrderedStatement, unlock);
  103755             :       return object;
  103756             :     }
  103757             : #endif
  103758             : 
  103759           4 :     if (SgOmpOrderedStatement::next_node == nullptr) {
  103760           4 :         SgOmpOrderedStatement * alloc = (SgOmpOrderedStatement*) ROSE_MALLOC ( SgOmpOrderedStatement::pool_size * sizeof(SgOmpOrderedStatement) );
  103761           4 :         ROSE_ASSERT(alloc != nullptr);
  103762             : 
  103763             : #if ROSE_ALLOC_TRACE == 2
  103764             : //        printf("SgOmpOrderedStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgOmpOrderedStatement::pools.size(), alloc, alloc + SgOmpOrderedStatement::pool_size);
  103765             : #endif
  103766             : 
  103767             : #if ROSE_ALLOC_MEMSET == 1
  103768             : #elif ROSE_ALLOC_MEMSET == 2
  103769             :         memset(alloc, 0x00, SgOmpOrderedStatement::pool_size * sizeof(SgOmpOrderedStatement));
  103770             : #elif ROSE_ALLOC_MEMSET == 3
  103771             :         memset(alloc, 0xAA, SgOmpOrderedStatement::pool_size * sizeof(SgOmpOrderedStatement));
  103772             : #endif
  103773        8000 :         for (unsigned i=0; i < SgOmpOrderedStatement::pool_size-1; i++) {
  103774        7996 :           alloc[i].p_freepointer = &(alloc[i+1]);
  103775             :         }
  103776           4 :         alloc[SgOmpOrderedStatement::pool_size-1].p_freepointer = nullptr;
  103777             : 
  103778           4 :         SgOmpOrderedStatement::pools.push_back ( (unsigned char *) alloc );
  103779           4 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgOmpOrderedStatement::pool_size * sizeof(SgOmpOrderedStatement), V_SgOmpOrderedStatement ) );
  103780           4 :         SgOmpOrderedStatement::next_node = alloc;
  103781             :     }
  103782           4 :     ROSE_ASSERT(SgOmpOrderedStatement::next_node != nullptr);
  103783             : 
  103784           4 :     SgOmpOrderedStatement * object = SgOmpOrderedStatement::next_node;
  103785           4 :     SgOmpOrderedStatement::next_node = (SgOmpOrderedStatement*)(object->p_freepointer);
  103786             : 
  103787             : #if ROSE_ALLOC_TRACE == 2
  103788             :     printf("SgOmpOrderedStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpOrderedStatement::next_node);
  103789             : #endif
  103790             : 
  103791           4 :     SgNode * fp = object->p_freepointer;
  103792             : #if ROSE_ALLOC_MEMSET == 1
  103793             : #elif ROSE_ALLOC_MEMSET == 2
  103794             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpOrderedStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  103795             : #elif ROSE_ALLOC_MEMSET == 3
  103796             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgOmpOrderedStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  103797             : #endif
  103798           4 :     object->p_freepointer = fp;
  103799             : 
  103800             : #if ROSE_ALLOC_TRACE == 2
  103801             : //    printf("SgOmpOrderedStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpOrderedStatement::next_node);
  103802             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  103803             :     Rose::MemPool::snapshot(oss.str());
  103804             :     alloc_trace_cnt++;
  103805             : #endif
  103806             : 
  103807           4 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  103808             : 
  103809           4 :     ALLOC_MUTEX(SgOmpOrderedStatement, unlock);
  103810             : 
  103811             :     return object;
  103812             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  103813             : }
  103814             : 
  103815             : 
  103816             : 
  103817             : /*! \brief Delete operator for SgOmpOrderedStatement.
  103818             : 
  103819             :    This delete operator implements deallocation using memory pools to 
  103820             :    provide most efficent use of the heap within construction of large ASTs.
  103821             : 
  103822             : \internal The new and delete operators use the lower level C malloc/free
  103823             :    function calls for performance and to make sure that mixing of malloc/free
  103824             :    and new/delete by the used can be caught more readily.  This may change
  103825             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  103826             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  103827             :    deallocate memory allocated using ROSE_MALLOC.
  103828             : */
  103829           0 : void SgOmpOrderedStatement::operator delete(void *Pointer, size_t Size)
  103830             : {
  103831             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  103832             :      * or throwing an exception. */
  103833           0 :     ALLOC_MUTEX(SgOmpOrderedStatement, lock);
  103834             : 
  103835             : #if USE_CPP_NEW_DELETE_OPERATORS
  103836             :     ROSE_FREE(Pointer);
  103837             : #else
  103838             : #if ROSE_PEDANTIC_ALLOC
  103839             :     ROSE_ASSERT(Size == sizeof(SgOmpOrderedStatement));
  103840             : #else
  103841           0 :     if (Size != sizeof(SgOmpOrderedStatement)) {
  103842           0 :       ROSE_FREE(Pointer);
  103843           0 :       ALLOC_MUTEX(SgOmpOrderedStatement, unlock);
  103844             :       return;
  103845             :     }
  103846             : #endif
  103847             : 
  103848           0 :     SgOmpOrderedStatement * object = (SgOmpOrderedStatement*) Pointer;
  103849           0 :     ROSE_ASSERT(object != nullptr);
  103850             : 
  103851             : #if ROSE_ALLOC_TRACE == 2
  103852             : //  printf("SgOmpOrderedStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpOrderedStatement::next_node);
  103853             :     printf("SgOmpOrderedStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpOrderedStatement::next_node);
  103854             : #endif
  103855             : 
  103856             : #if ROSE_PEDANTIC_ALLOC
  103857             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  103858             : #endif
  103859             : 
  103860             : #if ROSE_ALLOC_MEMSET == 1
  103861             : #elif ROSE_ALLOC_MEMSET == 2
  103862             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpOrderedStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  103863             : #elif ROSE_ALLOC_MEMSET == 3
  103864             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgOmpOrderedStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  103865             : #endif
  103866             : 
  103867             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  103868             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  103869             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  103870             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  103871             : #else
  103872           0 :     object->p_freepointer = SgOmpOrderedStatement::next_node;
  103873           0 :     SgOmpOrderedStatement::next_node = object;
  103874             : #endif
  103875             : 
  103876             : #if ROSE_ALLOC_TRACE == 2
  103877             : //  printf("SgOmpOrderedStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpOrderedStatement::next_node);
  103878             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  103879             :     Rose::MemPool::snapshot(oss.str());
  103880             :     alloc_trace_cnt++;
  103881             : #endif
  103882             : 
  103883             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  103884             : 
  103885           0 :     ALLOC_MUTEX(SgOmpOrderedStatement, unlock);
  103886             : }
  103887             : 
  103888             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  103889             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  103890             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  103891             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  103892             : // Also, note comment below from Robb (copied from the Common.code file).
  103893             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  103894             : //
  103895             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  103896             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  103897             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  103898             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  103899             : #if 0
  103900             : void SgOmpOrderedStatement::operator delete(void* pointer) { SgOmpOrderedStatement::operator delete (pointer, sizeof(SgOmpOrderedStatement)); };
  103901             : #endif
  103902             : /* #line 103903 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  103903             : 
  103904             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  103905             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  103906             : // obviously imply C++.
  103907             : 
  103908             : // This implements the support within ROSE for memory pools.  Memory pools
  103909             : // support the most condensed usage of memory within the construction of
  103910             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  103911             : // by a new operator written for each class.
  103912             : 
  103913             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  103914             :     // User wants multi-thread support and POSIX threads are available.
  103915             : #   include <pthread.h>
  103916             :     static pthread_mutex_t SgOmpTaskgroupStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  103917             : #else
  103918             :      // Cause synchronization to be skipped.
  103919             : #    ifndef ALLOC_MUTEX
  103920             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  103921             : #    endif
  103922             : #    ifdef _REENTRANT
  103923             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  103924             : #       ifdef _MSC_VER
  103925             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  103926             : #       else
  103927             : #           warning "POSIX threads are not available; synchronization being skipped"
  103928             : #       endif
  103929             : #    endif
  103930             : #endif
  103931             : 
  103932             : #ifndef ROSE_ALLOC_TRACE
  103933             : #  define ROSE_ALLOC_TRACE 0
  103934             : #endif
  103935             : 
  103936             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  103937             : #define ROSE_ALLOC_TRACE_CNT
  103938             : #include "memory-pool-snapshot.h"
  103939             : unsigned long alloc_trace_cnt = 0;
  103940             : #endif
  103941             : 
  103942             : #if ROSE_ALLOC_TRACE
  103943             : const unsigned SgOmpTaskgroupStatement::pool_size = 5;
  103944             : #else
  103945             : const unsigned SgOmpTaskgroupStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  103946             : #endif
  103947             : 
  103948             : #ifndef ROSE_ALLOC_MEMSET
  103949             : #  define ROSE_ALLOC_MEMSET 0
  103950             : #endif
  103951             : 
  103952             : #ifndef ROSE_PEDANTIC_ALLOC
  103953             : #  define ROSE_PEDANTIC_ALLOC 0
  103954             : #endif
  103955             : 
  103956             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  103957             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  103958             : #endif
  103959             : 
  103960             : #if !defined(SGNODE__ALL_POOLS)
  103961             : #define SGNODE__ALL_POOLS
  103962             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  103963             : #endif
  103964             : 
  103965             : SgOmpTaskgroupStatement* SgOmpTaskgroupStatement::next_node = nullptr;
  103966             : std::vector<unsigned char*> SgOmpTaskgroupStatement::pools;
  103967             : 
  103968             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  103969             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  103970             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  103971             : // around this macro definition rather than each use).
  103972             : #ifndef ALLOC_MUTEX
  103973             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  103974             :         do {                                                                     \
  103975             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  103976             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  103977             :                 abort();                                                         \
  103978             :             }                                                                    \
  103979             :         } while (0);
  103980             : #endif
  103981             : 
  103982             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  103983             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  103984             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  103985             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  103986             : 
  103987             : /*! \brief New operator for SgOmpTaskgroupStatement.
  103988             : 
  103989             :    This new operator implements memory pools to provide most efficent 
  103990             :    use of the heap within construction of large ASTs.
  103991             : 
  103992             : \internal The new and delete operators use the lower level C malloc/free
  103993             :    function calls for performance and to make sure that mixing of malloc/free
  103994             :    and new/delete by the used can be caught more readily.  This may change
  103995             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  103996             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  103997             :    deallocate memory allocated using ROSE_MALLOC.
  103998             : */
  103999           2 : void *SgOmpTaskgroupStatement::operator new ( size_t Size )
  104000             : {
  104001             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  104002             :      * returning or throwing an exception. */
  104003           2 :     ALLOC_MUTEX(SgOmpTaskgroupStatement, lock);
  104004             : 
  104005             : #if ROSE_ALLOC_TRACE == 2
  104006             : //    printf("SgOmpTaskgroupStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgOmpTaskgroupStatement::next_node);
  104007             : #endif
  104008             : 
  104009             : #if USE_CPP_NEW_DELETE_OPERATORS
  104010             :     void *mem = ROSE_MALLOC(Size);
  104011             :     ALLOC_MUTEX(SgOmpTaskgroupStatement, unlock);
  104012             :     return mem;
  104013             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  104014             : #if ROSE_PEDANTIC_ALLOC
  104015             :     ROSE_ASSERT(Size == sizeof(SgOmpTaskgroupStatement));
  104016             : #else
  104017           2 :     if (Size != sizeof(SgOmpTaskgroupStatement)) {
  104018           0 :       void * object = ROSE_MALLOC(Size);
  104019           0 :       ALLOC_MUTEX(SgOmpTaskgroupStatement, unlock);
  104020             :       return object;
  104021             :     }
  104022             : #endif
  104023             : 
  104024           2 :     if (SgOmpTaskgroupStatement::next_node == nullptr) {
  104025           2 :         SgOmpTaskgroupStatement * alloc = (SgOmpTaskgroupStatement*) ROSE_MALLOC ( SgOmpTaskgroupStatement::pool_size * sizeof(SgOmpTaskgroupStatement) );
  104026           2 :         ROSE_ASSERT(alloc != nullptr);
  104027             : 
  104028             : #if ROSE_ALLOC_TRACE == 2
  104029             : //        printf("SgOmpTaskgroupStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgOmpTaskgroupStatement::pools.size(), alloc, alloc + SgOmpTaskgroupStatement::pool_size);
  104030             : #endif
  104031             : 
  104032             : #if ROSE_ALLOC_MEMSET == 1
  104033             : #elif ROSE_ALLOC_MEMSET == 2
  104034             :         memset(alloc, 0x00, SgOmpTaskgroupStatement::pool_size * sizeof(SgOmpTaskgroupStatement));
  104035             : #elif ROSE_ALLOC_MEMSET == 3
  104036             :         memset(alloc, 0xAA, SgOmpTaskgroupStatement::pool_size * sizeof(SgOmpTaskgroupStatement));
  104037             : #endif
  104038        4000 :         for (unsigned i=0; i < SgOmpTaskgroupStatement::pool_size-1; i++) {
  104039        3998 :           alloc[i].p_freepointer = &(alloc[i+1]);
  104040             :         }
  104041           2 :         alloc[SgOmpTaskgroupStatement::pool_size-1].p_freepointer = nullptr;
  104042             : 
  104043           2 :         SgOmpTaskgroupStatement::pools.push_back ( (unsigned char *) alloc );
  104044           2 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgOmpTaskgroupStatement::pool_size * sizeof(SgOmpTaskgroupStatement), V_SgOmpTaskgroupStatement ) );
  104045           2 :         SgOmpTaskgroupStatement::next_node = alloc;
  104046             :     }
  104047           2 :     ROSE_ASSERT(SgOmpTaskgroupStatement::next_node != nullptr);
  104048             : 
  104049           2 :     SgOmpTaskgroupStatement * object = SgOmpTaskgroupStatement::next_node;
  104050           2 :     SgOmpTaskgroupStatement::next_node = (SgOmpTaskgroupStatement*)(object->p_freepointer);
  104051             : 
  104052             : #if ROSE_ALLOC_TRACE == 2
  104053             :     printf("SgOmpTaskgroupStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpTaskgroupStatement::next_node);
  104054             : #endif
  104055             : 
  104056           2 :     SgNode * fp = object->p_freepointer;
  104057             : #if ROSE_ALLOC_MEMSET == 1
  104058             : #elif ROSE_ALLOC_MEMSET == 2
  104059             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpTaskgroupStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  104060             : #elif ROSE_ALLOC_MEMSET == 3
  104061             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgOmpTaskgroupStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  104062             : #endif
  104063           2 :     object->p_freepointer = fp;
  104064             : 
  104065             : #if ROSE_ALLOC_TRACE == 2
  104066             : //    printf("SgOmpTaskgroupStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpTaskgroupStatement::next_node);
  104067             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  104068             :     Rose::MemPool::snapshot(oss.str());
  104069             :     alloc_trace_cnt++;
  104070             : #endif
  104071             : 
  104072           2 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  104073             : 
  104074           2 :     ALLOC_MUTEX(SgOmpTaskgroupStatement, unlock);
  104075             : 
  104076             :     return object;
  104077             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  104078             : }
  104079             : 
  104080             : 
  104081             : 
  104082             : /*! \brief Delete operator for SgOmpTaskgroupStatement.
  104083             : 
  104084             :    This delete operator implements deallocation using memory pools to 
  104085             :    provide most efficent use of the heap within construction of large ASTs.
  104086             : 
  104087             : \internal The new and delete operators use the lower level C malloc/free
  104088             :    function calls for performance and to make sure that mixing of malloc/free
  104089             :    and new/delete by the used can be caught more readily.  This may change
  104090             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  104091             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  104092             :    deallocate memory allocated using ROSE_MALLOC.
  104093             : */
  104094           0 : void SgOmpTaskgroupStatement::operator delete(void *Pointer, size_t Size)
  104095             : {
  104096             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  104097             :      * or throwing an exception. */
  104098           0 :     ALLOC_MUTEX(SgOmpTaskgroupStatement, lock);
  104099             : 
  104100             : #if USE_CPP_NEW_DELETE_OPERATORS
  104101             :     ROSE_FREE(Pointer);
  104102             : #else
  104103             : #if ROSE_PEDANTIC_ALLOC
  104104             :     ROSE_ASSERT(Size == sizeof(SgOmpTaskgroupStatement));
  104105             : #else
  104106           0 :     if (Size != sizeof(SgOmpTaskgroupStatement)) {
  104107           0 :       ROSE_FREE(Pointer);
  104108           0 :       ALLOC_MUTEX(SgOmpTaskgroupStatement, unlock);
  104109             :       return;
  104110             :     }
  104111             : #endif
  104112             : 
  104113           0 :     SgOmpTaskgroupStatement * object = (SgOmpTaskgroupStatement*) Pointer;
  104114           0 :     ROSE_ASSERT(object != nullptr);
  104115             : 
  104116             : #if ROSE_ALLOC_TRACE == 2
  104117             : //  printf("SgOmpTaskgroupStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpTaskgroupStatement::next_node);
  104118             :     printf("SgOmpTaskgroupStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpTaskgroupStatement::next_node);
  104119             : #endif
  104120             : 
  104121             : #if ROSE_PEDANTIC_ALLOC
  104122             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  104123             : #endif
  104124             : 
  104125             : #if ROSE_ALLOC_MEMSET == 1
  104126             : #elif ROSE_ALLOC_MEMSET == 2
  104127             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpTaskgroupStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  104128             : #elif ROSE_ALLOC_MEMSET == 3
  104129             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgOmpTaskgroupStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  104130             : #endif
  104131             : 
  104132             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  104133             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  104134             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  104135             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  104136             : #else
  104137           0 :     object->p_freepointer = SgOmpTaskgroupStatement::next_node;
  104138           0 :     SgOmpTaskgroupStatement::next_node = object;
  104139             : #endif
  104140             : 
  104141             : #if ROSE_ALLOC_TRACE == 2
  104142             : //  printf("SgOmpTaskgroupStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpTaskgroupStatement::next_node);
  104143             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  104144             :     Rose::MemPool::snapshot(oss.str());
  104145             :     alloc_trace_cnt++;
  104146             : #endif
  104147             : 
  104148             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  104149             : 
  104150           0 :     ALLOC_MUTEX(SgOmpTaskgroupStatement, unlock);
  104151             : }
  104152             : 
  104153             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  104154             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  104155             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  104156             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  104157             : // Also, note comment below from Robb (copied from the Common.code file).
  104158             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  104159             : //
  104160             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  104161             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  104162             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  104163             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  104164             : #if 0
  104165             : void SgOmpTaskgroupStatement::operator delete(void* pointer) { SgOmpTaskgroupStatement::operator delete (pointer, sizeof(SgOmpTaskgroupStatement)); };
  104166             : #endif
  104167             : /* #line 104168 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  104168             : 
  104169             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  104170             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  104171             : // obviously imply C++.
  104172             : 
  104173             : // This implements the support within ROSE for memory pools.  Memory pools
  104174             : // support the most condensed usage of memory within the construction of
  104175             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  104176             : // by a new operator written for each class.
  104177             : 
  104178             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  104179             :     // User wants multi-thread support and POSIX threads are available.
  104180             : #   include <pthread.h>
  104181             :     static pthread_mutex_t SgOmpTaskloopStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  104182             : #else
  104183             :      // Cause synchronization to be skipped.
  104184             : #    ifndef ALLOC_MUTEX
  104185             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  104186             : #    endif
  104187             : #    ifdef _REENTRANT
  104188             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  104189             : #       ifdef _MSC_VER
  104190             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  104191             : #       else
  104192             : #           warning "POSIX threads are not available; synchronization being skipped"
  104193             : #       endif
  104194             : #    endif
  104195             : #endif
  104196             : 
  104197             : #ifndef ROSE_ALLOC_TRACE
  104198             : #  define ROSE_ALLOC_TRACE 0
  104199             : #endif
  104200             : 
  104201             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  104202             : #define ROSE_ALLOC_TRACE_CNT
  104203             : #include "memory-pool-snapshot.h"
  104204             : unsigned long alloc_trace_cnt = 0;
  104205             : #endif
  104206             : 
  104207             : #if ROSE_ALLOC_TRACE
  104208             : const unsigned SgOmpTaskloopStatement::pool_size = 5;
  104209             : #else
  104210             : const unsigned SgOmpTaskloopStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  104211             : #endif
  104212             : 
  104213             : #ifndef ROSE_ALLOC_MEMSET
  104214             : #  define ROSE_ALLOC_MEMSET 0
  104215             : #endif
  104216             : 
  104217             : #ifndef ROSE_PEDANTIC_ALLOC
  104218             : #  define ROSE_PEDANTIC_ALLOC 0
  104219             : #endif
  104220             : 
  104221             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  104222             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  104223             : #endif
  104224             : 
  104225             : #if !defined(SGNODE__ALL_POOLS)
  104226             : #define SGNODE__ALL_POOLS
  104227             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  104228             : #endif
  104229             : 
  104230             : SgOmpTaskloopStatement* SgOmpTaskloopStatement::next_node = nullptr;
  104231             : std::vector<unsigned char*> SgOmpTaskloopStatement::pools;
  104232             : 
  104233             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  104234             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  104235             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  104236             : // around this macro definition rather than each use).
  104237             : #ifndef ALLOC_MUTEX
  104238             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  104239             :         do {                                                                     \
  104240             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  104241             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  104242             :                 abort();                                                         \
  104243             :             }                                                                    \
  104244             :         } while (0);
  104245             : #endif
  104246             : 
  104247             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  104248             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  104249             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  104250             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  104251             : 
  104252             : /*! \brief New operator for SgOmpTaskloopStatement.
  104253             : 
  104254             :    This new operator implements memory pools to provide most efficent 
  104255             :    use of the heap within construction of large ASTs.
  104256             : 
  104257             : \internal The new and delete operators use the lower level C malloc/free
  104258             :    function calls for performance and to make sure that mixing of malloc/free
  104259             :    and new/delete by the used can be caught more readily.  This may change
  104260             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  104261             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  104262             :    deallocate memory allocated using ROSE_MALLOC.
  104263             : */
  104264           2 : void *SgOmpTaskloopStatement::operator new ( size_t Size )
  104265             : {
  104266             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  104267             :      * returning or throwing an exception. */
  104268           2 :     ALLOC_MUTEX(SgOmpTaskloopStatement, lock);
  104269             : 
  104270             : #if ROSE_ALLOC_TRACE == 2
  104271             : //    printf("SgOmpTaskloopStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgOmpTaskloopStatement::next_node);
  104272             : #endif
  104273             : 
  104274             : #if USE_CPP_NEW_DELETE_OPERATORS
  104275             :     void *mem = ROSE_MALLOC(Size);
  104276             :     ALLOC_MUTEX(SgOmpTaskloopStatement, unlock);
  104277             :     return mem;
  104278             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  104279             : #if ROSE_PEDANTIC_ALLOC
  104280             :     ROSE_ASSERT(Size == sizeof(SgOmpTaskloopStatement));
  104281             : #else
  104282           2 :     if (Size != sizeof(SgOmpTaskloopStatement)) {
  104283           0 :       void * object = ROSE_MALLOC(Size);
  104284           0 :       ALLOC_MUTEX(SgOmpTaskloopStatement, unlock);
  104285             :       return object;
  104286             :     }
  104287             : #endif
  104288             : 
  104289           2 :     if (SgOmpTaskloopStatement::next_node == nullptr) {
  104290           2 :         SgOmpTaskloopStatement * alloc = (SgOmpTaskloopStatement*) ROSE_MALLOC ( SgOmpTaskloopStatement::pool_size * sizeof(SgOmpTaskloopStatement) );
  104291           2 :         ROSE_ASSERT(alloc != nullptr);
  104292             : 
  104293             : #if ROSE_ALLOC_TRACE == 2
  104294             : //        printf("SgOmpTaskloopStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgOmpTaskloopStatement::pools.size(), alloc, alloc + SgOmpTaskloopStatement::pool_size);
  104295             : #endif
  104296             : 
  104297             : #if ROSE_ALLOC_MEMSET == 1
  104298             : #elif ROSE_ALLOC_MEMSET == 2
  104299             :         memset(alloc, 0x00, SgOmpTaskloopStatement::pool_size * sizeof(SgOmpTaskloopStatement));
  104300             : #elif ROSE_ALLOC_MEMSET == 3
  104301             :         memset(alloc, 0xAA, SgOmpTaskloopStatement::pool_size * sizeof(SgOmpTaskloopStatement));
  104302             : #endif
  104303        4000 :         for (unsigned i=0; i < SgOmpTaskloopStatement::pool_size-1; i++) {
  104304        3998 :           alloc[i].p_freepointer = &(alloc[i+1]);
  104305             :         }
  104306           2 :         alloc[SgOmpTaskloopStatement::pool_size-1].p_freepointer = nullptr;
  104307             : 
  104308           2 :         SgOmpTaskloopStatement::pools.push_back ( (unsigned char *) alloc );
  104309           2 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgOmpTaskloopStatement::pool_size * sizeof(SgOmpTaskloopStatement), V_SgOmpTaskloopStatement ) );
  104310           2 :         SgOmpTaskloopStatement::next_node = alloc;
  104311             :     }
  104312           2 :     ROSE_ASSERT(SgOmpTaskloopStatement::next_node != nullptr);
  104313             : 
  104314           2 :     SgOmpTaskloopStatement * object = SgOmpTaskloopStatement::next_node;
  104315           2 :     SgOmpTaskloopStatement::next_node = (SgOmpTaskloopStatement*)(object->p_freepointer);
  104316             : 
  104317             : #if ROSE_ALLOC_TRACE == 2
  104318             :     printf("SgOmpTaskloopStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpTaskloopStatement::next_node);
  104319             : #endif
  104320             : 
  104321           2 :     SgNode * fp = object->p_freepointer;
  104322             : #if ROSE_ALLOC_MEMSET == 1
  104323             : #elif ROSE_ALLOC_MEMSET == 2
  104324             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpTaskloopStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  104325             : #elif ROSE_ALLOC_MEMSET == 3
  104326             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgOmpTaskloopStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  104327             : #endif
  104328           2 :     object->p_freepointer = fp;
  104329             : 
  104330             : #if ROSE_ALLOC_TRACE == 2
  104331             : //    printf("SgOmpTaskloopStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpTaskloopStatement::next_node);
  104332             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  104333             :     Rose::MemPool::snapshot(oss.str());
  104334             :     alloc_trace_cnt++;
  104335             : #endif
  104336             : 
  104337           2 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  104338             : 
  104339           2 :     ALLOC_MUTEX(SgOmpTaskloopStatement, unlock);
  104340             : 
  104341             :     return object;
  104342             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  104343             : }
  104344             : 
  104345             : 
  104346             : 
  104347             : /*! \brief Delete operator for SgOmpTaskloopStatement.
  104348             : 
  104349             :    This delete operator implements deallocation using memory pools to 
  104350             :    provide most efficent use of the heap within construction of large ASTs.
  104351             : 
  104352             : \internal The new and delete operators use the lower level C malloc/free
  104353             :    function calls for performance and to make sure that mixing of malloc/free
  104354             :    and new/delete by the used can be caught more readily.  This may change
  104355             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  104356             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  104357             :    deallocate memory allocated using ROSE_MALLOC.
  104358             : */
  104359           0 : void SgOmpTaskloopStatement::operator delete(void *Pointer, size_t Size)
  104360             : {
  104361             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  104362             :      * or throwing an exception. */
  104363           0 :     ALLOC_MUTEX(SgOmpTaskloopStatement, lock);
  104364             : 
  104365             : #if USE_CPP_NEW_DELETE_OPERATORS
  104366             :     ROSE_FREE(Pointer);
  104367             : #else
  104368             : #if ROSE_PEDANTIC_ALLOC
  104369             :     ROSE_ASSERT(Size == sizeof(SgOmpTaskloopStatement));
  104370             : #else
  104371           0 :     if (Size != sizeof(SgOmpTaskloopStatement)) {
  104372           0 :       ROSE_FREE(Pointer);
  104373           0 :       ALLOC_MUTEX(SgOmpTaskloopStatement, unlock);
  104374             :       return;
  104375             :     }
  104376             : #endif
  104377             : 
  104378           0 :     SgOmpTaskloopStatement * object = (SgOmpTaskloopStatement*) Pointer;
  104379           0 :     ROSE_ASSERT(object != nullptr);
  104380             : 
  104381             : #if ROSE_ALLOC_TRACE == 2
  104382             : //  printf("SgOmpTaskloopStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpTaskloopStatement::next_node);
  104383             :     printf("SgOmpTaskloopStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpTaskloopStatement::next_node);
  104384             : #endif
  104385             : 
  104386             : #if ROSE_PEDANTIC_ALLOC
  104387             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  104388             : #endif
  104389             : 
  104390             : #if ROSE_ALLOC_MEMSET == 1
  104391             : #elif ROSE_ALLOC_MEMSET == 2
  104392             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpTaskloopStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  104393             : #elif ROSE_ALLOC_MEMSET == 3
  104394             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgOmpTaskloopStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  104395             : #endif
  104396             : 
  104397             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  104398             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  104399             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  104400             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  104401             : #else
  104402           0 :     object->p_freepointer = SgOmpTaskloopStatement::next_node;
  104403           0 :     SgOmpTaskloopStatement::next_node = object;
  104404             : #endif
  104405             : 
  104406             : #if ROSE_ALLOC_TRACE == 2
  104407             : //  printf("SgOmpTaskloopStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpTaskloopStatement::next_node);
  104408             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  104409             :     Rose::MemPool::snapshot(oss.str());
  104410             :     alloc_trace_cnt++;
  104411             : #endif
  104412             : 
  104413             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  104414             : 
  104415           0 :     ALLOC_MUTEX(SgOmpTaskloopStatement, unlock);
  104416             : }
  104417             : 
  104418             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  104419             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  104420             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  104421             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  104422             : // Also, note comment below from Robb (copied from the Common.code file).
  104423             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  104424             : //
  104425             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  104426             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  104427             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  104428             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  104429             : #if 0
  104430             : void SgOmpTaskloopStatement::operator delete(void* pointer) { SgOmpTaskloopStatement::operator delete (pointer, sizeof(SgOmpTaskloopStatement)); };
  104431             : #endif
  104432             : /* #line 104433 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  104433             : 
  104434             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  104435             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  104436             : // obviously imply C++.
  104437             : 
  104438             : // This implements the support within ROSE for memory pools.  Memory pools
  104439             : // support the most condensed usage of memory within the construction of
  104440             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  104441             : // by a new operator written for each class.
  104442             : 
  104443             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  104444             :     // User wants multi-thread support and POSIX threads are available.
  104445             : #   include <pthread.h>
  104446             :     static pthread_mutex_t SgOmpDepobjStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  104447             : #else
  104448             :      // Cause synchronization to be skipped.
  104449             : #    ifndef ALLOC_MUTEX
  104450             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  104451             : #    endif
  104452             : #    ifdef _REENTRANT
  104453             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  104454             : #       ifdef _MSC_VER
  104455             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  104456             : #       else
  104457             : #           warning "POSIX threads are not available; synchronization being skipped"
  104458             : #       endif
  104459             : #    endif
  104460             : #endif
  104461             : 
  104462             : #ifndef ROSE_ALLOC_TRACE
  104463             : #  define ROSE_ALLOC_TRACE 0
  104464             : #endif
  104465             : 
  104466             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  104467             : #define ROSE_ALLOC_TRACE_CNT
  104468             : #include "memory-pool-snapshot.h"
  104469             : unsigned long alloc_trace_cnt = 0;
  104470             : #endif
  104471             : 
  104472             : #if ROSE_ALLOC_TRACE
  104473             : const unsigned SgOmpDepobjStatement::pool_size = 5;
  104474             : #else
  104475             : const unsigned SgOmpDepobjStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  104476             : #endif
  104477             : 
  104478             : #ifndef ROSE_ALLOC_MEMSET
  104479             : #  define ROSE_ALLOC_MEMSET 0
  104480             : #endif
  104481             : 
  104482             : #ifndef ROSE_PEDANTIC_ALLOC
  104483             : #  define ROSE_PEDANTIC_ALLOC 0
  104484             : #endif
  104485             : 
  104486             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  104487             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  104488             : #endif
  104489             : 
  104490             : #if !defined(SGNODE__ALL_POOLS)
  104491             : #define SGNODE__ALL_POOLS
  104492             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  104493             : #endif
  104494             : 
  104495             : SgOmpDepobjStatement* SgOmpDepobjStatement::next_node = nullptr;
  104496             : std::vector<unsigned char*> SgOmpDepobjStatement::pools;
  104497             : 
  104498             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  104499             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  104500             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  104501             : // around this macro definition rather than each use).
  104502             : #ifndef ALLOC_MUTEX
  104503             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  104504             :         do {                                                                     \
  104505             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  104506             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  104507             :                 abort();                                                         \
  104508             :             }                                                                    \
  104509             :         } while (0);
  104510             : #endif
  104511             : 
  104512             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  104513             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  104514             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  104515             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  104516             : 
  104517             : /*! \brief New operator for SgOmpDepobjStatement.
  104518             : 
  104519             :    This new operator implements memory pools to provide most efficent 
  104520             :    use of the heap within construction of large ASTs.
  104521             : 
  104522             : \internal The new and delete operators use the lower level C malloc/free
  104523             :    function calls for performance and to make sure that mixing of malloc/free
  104524             :    and new/delete by the used can be caught more readily.  This may change
  104525             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  104526             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  104527             :    deallocate memory allocated using ROSE_MALLOC.
  104528             : */
  104529           3 : void *SgOmpDepobjStatement::operator new ( size_t Size )
  104530             : {
  104531             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  104532             :      * returning or throwing an exception. */
  104533           3 :     ALLOC_MUTEX(SgOmpDepobjStatement, lock);
  104534             : 
  104535             : #if ROSE_ALLOC_TRACE == 2
  104536             : //    printf("SgOmpDepobjStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgOmpDepobjStatement::next_node);
  104537             : #endif
  104538             : 
  104539             : #if USE_CPP_NEW_DELETE_OPERATORS
  104540             :     void *mem = ROSE_MALLOC(Size);
  104541             :     ALLOC_MUTEX(SgOmpDepobjStatement, unlock);
  104542             :     return mem;
  104543             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  104544             : #if ROSE_PEDANTIC_ALLOC
  104545             :     ROSE_ASSERT(Size == sizeof(SgOmpDepobjStatement));
  104546             : #else
  104547           3 :     if (Size != sizeof(SgOmpDepobjStatement)) {
  104548           0 :       void * object = ROSE_MALLOC(Size);
  104549           0 :       ALLOC_MUTEX(SgOmpDepobjStatement, unlock);
  104550             :       return object;
  104551             :     }
  104552             : #endif
  104553             : 
  104554           3 :     if (SgOmpDepobjStatement::next_node == nullptr) {
  104555           1 :         SgOmpDepobjStatement * alloc = (SgOmpDepobjStatement*) ROSE_MALLOC ( SgOmpDepobjStatement::pool_size * sizeof(SgOmpDepobjStatement) );
  104556           1 :         ROSE_ASSERT(alloc != nullptr);
  104557             : 
  104558             : #if ROSE_ALLOC_TRACE == 2
  104559             : //        printf("SgOmpDepobjStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgOmpDepobjStatement::pools.size(), alloc, alloc + SgOmpDepobjStatement::pool_size);
  104560             : #endif
  104561             : 
  104562             : #if ROSE_ALLOC_MEMSET == 1
  104563             : #elif ROSE_ALLOC_MEMSET == 2
  104564             :         memset(alloc, 0x00, SgOmpDepobjStatement::pool_size * sizeof(SgOmpDepobjStatement));
  104565             : #elif ROSE_ALLOC_MEMSET == 3
  104566             :         memset(alloc, 0xAA, SgOmpDepobjStatement::pool_size * sizeof(SgOmpDepobjStatement));
  104567             : #endif
  104568        2000 :         for (unsigned i=0; i < SgOmpDepobjStatement::pool_size-1; i++) {
  104569        1999 :           alloc[i].p_freepointer = &(alloc[i+1]);
  104570             :         }
  104571           1 :         alloc[SgOmpDepobjStatement::pool_size-1].p_freepointer = nullptr;
  104572             : 
  104573           1 :         SgOmpDepobjStatement::pools.push_back ( (unsigned char *) alloc );
  104574           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgOmpDepobjStatement::pool_size * sizeof(SgOmpDepobjStatement), V_SgOmpDepobjStatement ) );
  104575           1 :         SgOmpDepobjStatement::next_node = alloc;
  104576             :     }
  104577           3 :     ROSE_ASSERT(SgOmpDepobjStatement::next_node != nullptr);
  104578             : 
  104579           3 :     SgOmpDepobjStatement * object = SgOmpDepobjStatement::next_node;
  104580           3 :     SgOmpDepobjStatement::next_node = (SgOmpDepobjStatement*)(object->p_freepointer);
  104581             : 
  104582             : #if ROSE_ALLOC_TRACE == 2
  104583             :     printf("SgOmpDepobjStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpDepobjStatement::next_node);
  104584             : #endif
  104585             : 
  104586           3 :     SgNode * fp = object->p_freepointer;
  104587             : #if ROSE_ALLOC_MEMSET == 1
  104588             : #elif ROSE_ALLOC_MEMSET == 2
  104589             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpDepobjStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  104590             : #elif ROSE_ALLOC_MEMSET == 3
  104591             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgOmpDepobjStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  104592             : #endif
  104593           3 :     object->p_freepointer = fp;
  104594             : 
  104595             : #if ROSE_ALLOC_TRACE == 2
  104596             : //    printf("SgOmpDepobjStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpDepobjStatement::next_node);
  104597             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  104598             :     Rose::MemPool::snapshot(oss.str());
  104599             :     alloc_trace_cnt++;
  104600             : #endif
  104601             : 
  104602           3 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  104603             : 
  104604           3 :     ALLOC_MUTEX(SgOmpDepobjStatement, unlock);
  104605             : 
  104606             :     return object;
  104607             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  104608             : }
  104609             : 
  104610             : 
  104611             : 
  104612             : /*! \brief Delete operator for SgOmpDepobjStatement.
  104613             : 
  104614             :    This delete operator implements deallocation using memory pools to 
  104615             :    provide most efficent use of the heap within construction of large ASTs.
  104616             : 
  104617             : \internal The new and delete operators use the lower level C malloc/free
  104618             :    function calls for performance and to make sure that mixing of malloc/free
  104619             :    and new/delete by the used can be caught more readily.  This may change
  104620             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  104621             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  104622             :    deallocate memory allocated using ROSE_MALLOC.
  104623             : */
  104624           0 : void SgOmpDepobjStatement::operator delete(void *Pointer, size_t Size)
  104625             : {
  104626             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  104627             :      * or throwing an exception. */
  104628           0 :     ALLOC_MUTEX(SgOmpDepobjStatement, lock);
  104629             : 
  104630             : #if USE_CPP_NEW_DELETE_OPERATORS
  104631             :     ROSE_FREE(Pointer);
  104632             : #else
  104633             : #if ROSE_PEDANTIC_ALLOC
  104634             :     ROSE_ASSERT(Size == sizeof(SgOmpDepobjStatement));
  104635             : #else
  104636           0 :     if (Size != sizeof(SgOmpDepobjStatement)) {
  104637           0 :       ROSE_FREE(Pointer);
  104638           0 :       ALLOC_MUTEX(SgOmpDepobjStatement, unlock);
  104639             :       return;
  104640             :     }
  104641             : #endif
  104642             : 
  104643           0 :     SgOmpDepobjStatement * object = (SgOmpDepobjStatement*) Pointer;
  104644           0 :     ROSE_ASSERT(object != nullptr);
  104645             : 
  104646             : #if ROSE_ALLOC_TRACE == 2
  104647             : //  printf("SgOmpDepobjStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpDepobjStatement::next_node);
  104648             :     printf("SgOmpDepobjStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpDepobjStatement::next_node);
  104649             : #endif
  104650             : 
  104651             : #if ROSE_PEDANTIC_ALLOC
  104652             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  104653             : #endif
  104654             : 
  104655             : #if ROSE_ALLOC_MEMSET == 1
  104656             : #elif ROSE_ALLOC_MEMSET == 2
  104657             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpDepobjStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  104658             : #elif ROSE_ALLOC_MEMSET == 3
  104659             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgOmpDepobjStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  104660             : #endif
  104661             : 
  104662             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  104663             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  104664             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  104665             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  104666             : #else
  104667           0 :     object->p_freepointer = SgOmpDepobjStatement::next_node;
  104668           0 :     SgOmpDepobjStatement::next_node = object;
  104669             : #endif
  104670             : 
  104671             : #if ROSE_ALLOC_TRACE == 2
  104672             : //  printf("SgOmpDepobjStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpDepobjStatement::next_node);
  104673             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  104674             :     Rose::MemPool::snapshot(oss.str());
  104675             :     alloc_trace_cnt++;
  104676             : #endif
  104677             : 
  104678             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  104679             : 
  104680           0 :     ALLOC_MUTEX(SgOmpDepobjStatement, unlock);
  104681             : }
  104682             : 
  104683             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  104684             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  104685             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  104686             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  104687             : // Also, note comment below from Robb (copied from the Common.code file).
  104688             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  104689             : //
  104690             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  104691             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  104692             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  104693             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  104694             : #if 0
  104695             : void SgOmpDepobjStatement::operator delete(void* pointer) { SgOmpDepobjStatement::operator delete (pointer, sizeof(SgOmpDepobjStatement)); };
  104696             : #endif
  104697             : /* #line 104698 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  104698             : 
  104699             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  104700             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  104701             : // obviously imply C++.
  104702             : 
  104703             : // This implements the support within ROSE for memory pools.  Memory pools
  104704             : // support the most condensed usage of memory within the construction of
  104705             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  104706             : // by a new operator written for each class.
  104707             : 
  104708             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  104709             :     // User wants multi-thread support and POSIX threads are available.
  104710             : #   include <pthread.h>
  104711             :     static pthread_mutex_t SgOmpTargetEnterDataStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  104712             : #else
  104713             :      // Cause synchronization to be skipped.
  104714             : #    ifndef ALLOC_MUTEX
  104715             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  104716             : #    endif
  104717             : #    ifdef _REENTRANT
  104718             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  104719             : #       ifdef _MSC_VER
  104720             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  104721             : #       else
  104722             : #           warning "POSIX threads are not available; synchronization being skipped"
  104723             : #       endif
  104724             : #    endif
  104725             : #endif
  104726             : 
  104727             : #ifndef ROSE_ALLOC_TRACE
  104728             : #  define ROSE_ALLOC_TRACE 0
  104729             : #endif
  104730             : 
  104731             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  104732             : #define ROSE_ALLOC_TRACE_CNT
  104733             : #include "memory-pool-snapshot.h"
  104734             : unsigned long alloc_trace_cnt = 0;
  104735             : #endif
  104736             : 
  104737             : #if ROSE_ALLOC_TRACE
  104738             : const unsigned SgOmpTargetEnterDataStatement::pool_size = 5;
  104739             : #else
  104740             : const unsigned SgOmpTargetEnterDataStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  104741             : #endif
  104742             : 
  104743             : #ifndef ROSE_ALLOC_MEMSET
  104744             : #  define ROSE_ALLOC_MEMSET 0
  104745             : #endif
  104746             : 
  104747             : #ifndef ROSE_PEDANTIC_ALLOC
  104748             : #  define ROSE_PEDANTIC_ALLOC 0
  104749             : #endif
  104750             : 
  104751             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  104752             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  104753             : #endif
  104754             : 
  104755             : #if !defined(SGNODE__ALL_POOLS)
  104756             : #define SGNODE__ALL_POOLS
  104757             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  104758             : #endif
  104759             : 
  104760             : SgOmpTargetEnterDataStatement* SgOmpTargetEnterDataStatement::next_node = nullptr;
  104761             : std::vector<unsigned char*> SgOmpTargetEnterDataStatement::pools;
  104762             : 
  104763             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  104764             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  104765             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  104766             : // around this macro definition rather than each use).
  104767             : #ifndef ALLOC_MUTEX
  104768             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  104769             :         do {                                                                     \
  104770             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  104771             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  104772             :                 abort();                                                         \
  104773             :             }                                                                    \
  104774             :         } while (0);
  104775             : #endif
  104776             : 
  104777             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  104778             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  104779             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  104780             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  104781             : 
  104782             : /*! \brief New operator for SgOmpTargetEnterDataStatement.
  104783             : 
  104784             :    This new operator implements memory pools to provide most efficent 
  104785             :    use of the heap within construction of large ASTs.
  104786             : 
  104787             : \internal The new and delete operators use the lower level C malloc/free
  104788             :    function calls for performance and to make sure that mixing of malloc/free
  104789             :    and new/delete by the used can be caught more readily.  This may change
  104790             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  104791             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  104792             :    deallocate memory allocated using ROSE_MALLOC.
  104793             : */
  104794           0 : void *SgOmpTargetEnterDataStatement::operator new ( size_t Size )
  104795             : {
  104796             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  104797             :      * returning or throwing an exception. */
  104798           0 :     ALLOC_MUTEX(SgOmpTargetEnterDataStatement, lock);
  104799             : 
  104800             : #if ROSE_ALLOC_TRACE == 2
  104801             : //    printf("SgOmpTargetEnterDataStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgOmpTargetEnterDataStatement::next_node);
  104802             : #endif
  104803             : 
  104804             : #if USE_CPP_NEW_DELETE_OPERATORS
  104805             :     void *mem = ROSE_MALLOC(Size);
  104806             :     ALLOC_MUTEX(SgOmpTargetEnterDataStatement, unlock);
  104807             :     return mem;
  104808             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  104809             : #if ROSE_PEDANTIC_ALLOC
  104810             :     ROSE_ASSERT(Size == sizeof(SgOmpTargetEnterDataStatement));
  104811             : #else
  104812           0 :     if (Size != sizeof(SgOmpTargetEnterDataStatement)) {
  104813           0 :       void * object = ROSE_MALLOC(Size);
  104814           0 :       ALLOC_MUTEX(SgOmpTargetEnterDataStatement, unlock);
  104815             :       return object;
  104816             :     }
  104817             : #endif
  104818             : 
  104819           0 :     if (SgOmpTargetEnterDataStatement::next_node == nullptr) {
  104820           0 :         SgOmpTargetEnterDataStatement * alloc = (SgOmpTargetEnterDataStatement*) ROSE_MALLOC ( SgOmpTargetEnterDataStatement::pool_size * sizeof(SgOmpTargetEnterDataStatement) );
  104821           0 :         ROSE_ASSERT(alloc != nullptr);
  104822             : 
  104823             : #if ROSE_ALLOC_TRACE == 2
  104824             : //        printf("SgOmpTargetEnterDataStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgOmpTargetEnterDataStatement::pools.size(), alloc, alloc + SgOmpTargetEnterDataStatement::pool_size);
  104825             : #endif
  104826             : 
  104827             : #if ROSE_ALLOC_MEMSET == 1
  104828             : #elif ROSE_ALLOC_MEMSET == 2
  104829             :         memset(alloc, 0x00, SgOmpTargetEnterDataStatement::pool_size * sizeof(SgOmpTargetEnterDataStatement));
  104830             : #elif ROSE_ALLOC_MEMSET == 3
  104831             :         memset(alloc, 0xAA, SgOmpTargetEnterDataStatement::pool_size * sizeof(SgOmpTargetEnterDataStatement));
  104832             : #endif
  104833           0 :         for (unsigned i=0; i < SgOmpTargetEnterDataStatement::pool_size-1; i++) {
  104834           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
  104835             :         }
  104836           0 :         alloc[SgOmpTargetEnterDataStatement::pool_size-1].p_freepointer = nullptr;
  104837             : 
  104838           0 :         SgOmpTargetEnterDataStatement::pools.push_back ( (unsigned char *) alloc );
  104839           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgOmpTargetEnterDataStatement::pool_size * sizeof(SgOmpTargetEnterDataStatement), V_SgOmpTargetEnterDataStatement ) );
  104840           0 :         SgOmpTargetEnterDataStatement::next_node = alloc;
  104841             :     }
  104842           0 :     ROSE_ASSERT(SgOmpTargetEnterDataStatement::next_node != nullptr);
  104843             : 
  104844           0 :     SgOmpTargetEnterDataStatement * object = SgOmpTargetEnterDataStatement::next_node;
  104845           0 :     SgOmpTargetEnterDataStatement::next_node = (SgOmpTargetEnterDataStatement*)(object->p_freepointer);
  104846             : 
  104847             : #if ROSE_ALLOC_TRACE == 2
  104848             :     printf("SgOmpTargetEnterDataStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpTargetEnterDataStatement::next_node);
  104849             : #endif
  104850             : 
  104851           0 :     SgNode * fp = object->p_freepointer;
  104852             : #if ROSE_ALLOC_MEMSET == 1
  104853             : #elif ROSE_ALLOC_MEMSET == 2
  104854             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpTargetEnterDataStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  104855             : #elif ROSE_ALLOC_MEMSET == 3
  104856             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgOmpTargetEnterDataStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  104857             : #endif
  104858           0 :     object->p_freepointer = fp;
  104859             : 
  104860             : #if ROSE_ALLOC_TRACE == 2
  104861             : //    printf("SgOmpTargetEnterDataStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpTargetEnterDataStatement::next_node);
  104862             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  104863             :     Rose::MemPool::snapshot(oss.str());
  104864             :     alloc_trace_cnt++;
  104865             : #endif
  104866             : 
  104867           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  104868             : 
  104869           0 :     ALLOC_MUTEX(SgOmpTargetEnterDataStatement, unlock);
  104870             : 
  104871             :     return object;
  104872             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  104873             : }
  104874             : 
  104875             : 
  104876             : 
  104877             : /*! \brief Delete operator for SgOmpTargetEnterDataStatement.
  104878             : 
  104879             :    This delete operator implements deallocation using memory pools to 
  104880             :    provide most efficent use of the heap within construction of large ASTs.
  104881             : 
  104882             : \internal The new and delete operators use the lower level C malloc/free
  104883             :    function calls for performance and to make sure that mixing of malloc/free
  104884             :    and new/delete by the used can be caught more readily.  This may change
  104885             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  104886             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  104887             :    deallocate memory allocated using ROSE_MALLOC.
  104888             : */
  104889           0 : void SgOmpTargetEnterDataStatement::operator delete(void *Pointer, size_t Size)
  104890             : {
  104891             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  104892             :      * or throwing an exception. */
  104893           0 :     ALLOC_MUTEX(SgOmpTargetEnterDataStatement, lock);
  104894             : 
  104895             : #if USE_CPP_NEW_DELETE_OPERATORS
  104896             :     ROSE_FREE(Pointer);
  104897             : #else
  104898             : #if ROSE_PEDANTIC_ALLOC
  104899             :     ROSE_ASSERT(Size == sizeof(SgOmpTargetEnterDataStatement));
  104900             : #else
  104901           0 :     if (Size != sizeof(SgOmpTargetEnterDataStatement)) {
  104902           0 :       ROSE_FREE(Pointer);
  104903           0 :       ALLOC_MUTEX(SgOmpTargetEnterDataStatement, unlock);
  104904             :       return;
  104905             :     }
  104906             : #endif
  104907             : 
  104908           0 :     SgOmpTargetEnterDataStatement * object = (SgOmpTargetEnterDataStatement*) Pointer;
  104909           0 :     ROSE_ASSERT(object != nullptr);
  104910             : 
  104911             : #if ROSE_ALLOC_TRACE == 2
  104912             : //  printf("SgOmpTargetEnterDataStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpTargetEnterDataStatement::next_node);
  104913             :     printf("SgOmpTargetEnterDataStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpTargetEnterDataStatement::next_node);
  104914             : #endif
  104915             : 
  104916             : #if ROSE_PEDANTIC_ALLOC
  104917             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  104918             : #endif
  104919             : 
  104920             : #if ROSE_ALLOC_MEMSET == 1
  104921             : #elif ROSE_ALLOC_MEMSET == 2
  104922             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpTargetEnterDataStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  104923             : #elif ROSE_ALLOC_MEMSET == 3
  104924             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgOmpTargetEnterDataStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  104925             : #endif
  104926             : 
  104927             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  104928             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  104929             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  104930             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  104931             : #else
  104932           0 :     object->p_freepointer = SgOmpTargetEnterDataStatement::next_node;
  104933           0 :     SgOmpTargetEnterDataStatement::next_node = object;
  104934             : #endif
  104935             : 
  104936             : #if ROSE_ALLOC_TRACE == 2
  104937             : //  printf("SgOmpTargetEnterDataStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpTargetEnterDataStatement::next_node);
  104938             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  104939             :     Rose::MemPool::snapshot(oss.str());
  104940             :     alloc_trace_cnt++;
  104941             : #endif
  104942             : 
  104943             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  104944             : 
  104945           0 :     ALLOC_MUTEX(SgOmpTargetEnterDataStatement, unlock);
  104946             : }
  104947             : 
  104948             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  104949             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  104950             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  104951             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  104952             : // Also, note comment below from Robb (copied from the Common.code file).
  104953             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  104954             : //
  104955             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  104956             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  104957             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  104958             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  104959             : #if 0
  104960             : void SgOmpTargetEnterDataStatement::operator delete(void* pointer) { SgOmpTargetEnterDataStatement::operator delete (pointer, sizeof(SgOmpTargetEnterDataStatement)); };
  104961             : #endif
  104962             : /* #line 104963 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  104963             : 
  104964             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  104965             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  104966             : // obviously imply C++.
  104967             : 
  104968             : // This implements the support within ROSE for memory pools.  Memory pools
  104969             : // support the most condensed usage of memory within the construction of
  104970             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  104971             : // by a new operator written for each class.
  104972             : 
  104973             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  104974             :     // User wants multi-thread support and POSIX threads are available.
  104975             : #   include <pthread.h>
  104976             :     static pthread_mutex_t SgOmpTargetExitDataStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  104977             : #else
  104978             :      // Cause synchronization to be skipped.
  104979             : #    ifndef ALLOC_MUTEX
  104980             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  104981             : #    endif
  104982             : #    ifdef _REENTRANT
  104983             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  104984             : #       ifdef _MSC_VER
  104985             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  104986             : #       else
  104987             : #           warning "POSIX threads are not available; synchronization being skipped"
  104988             : #       endif
  104989             : #    endif
  104990             : #endif
  104991             : 
  104992             : #ifndef ROSE_ALLOC_TRACE
  104993             : #  define ROSE_ALLOC_TRACE 0
  104994             : #endif
  104995             : 
  104996             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  104997             : #define ROSE_ALLOC_TRACE_CNT
  104998             : #include "memory-pool-snapshot.h"
  104999             : unsigned long alloc_trace_cnt = 0;
  105000             : #endif
  105001             : 
  105002             : #if ROSE_ALLOC_TRACE
  105003             : const unsigned SgOmpTargetExitDataStatement::pool_size = 5;
  105004             : #else
  105005             : const unsigned SgOmpTargetExitDataStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  105006             : #endif
  105007             : 
  105008             : #ifndef ROSE_ALLOC_MEMSET
  105009             : #  define ROSE_ALLOC_MEMSET 0
  105010             : #endif
  105011             : 
  105012             : #ifndef ROSE_PEDANTIC_ALLOC
  105013             : #  define ROSE_PEDANTIC_ALLOC 0
  105014             : #endif
  105015             : 
  105016             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  105017             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  105018             : #endif
  105019             : 
  105020             : #if !defined(SGNODE__ALL_POOLS)
  105021             : #define SGNODE__ALL_POOLS
  105022             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  105023             : #endif
  105024             : 
  105025             : SgOmpTargetExitDataStatement* SgOmpTargetExitDataStatement::next_node = nullptr;
  105026             : std::vector<unsigned char*> SgOmpTargetExitDataStatement::pools;
  105027             : 
  105028             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  105029             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  105030             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  105031             : // around this macro definition rather than each use).
  105032             : #ifndef ALLOC_MUTEX
  105033             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  105034             :         do {                                                                     \
  105035             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  105036             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  105037             :                 abort();                                                         \
  105038             :             }                                                                    \
  105039             :         } while (0);
  105040             : #endif
  105041             : 
  105042             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  105043             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  105044             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  105045             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  105046             : 
  105047             : /*! \brief New operator for SgOmpTargetExitDataStatement.
  105048             : 
  105049             :    This new operator implements memory pools to provide most efficent 
  105050             :    use of the heap within construction of large ASTs.
  105051             : 
  105052             : \internal The new and delete operators use the lower level C malloc/free
  105053             :    function calls for performance and to make sure that mixing of malloc/free
  105054             :    and new/delete by the used can be caught more readily.  This may change
  105055             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  105056             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  105057             :    deallocate memory allocated using ROSE_MALLOC.
  105058             : */
  105059           0 : void *SgOmpTargetExitDataStatement::operator new ( size_t Size )
  105060             : {
  105061             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  105062             :      * returning or throwing an exception. */
  105063           0 :     ALLOC_MUTEX(SgOmpTargetExitDataStatement, lock);
  105064             : 
  105065             : #if ROSE_ALLOC_TRACE == 2
  105066             : //    printf("SgOmpTargetExitDataStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgOmpTargetExitDataStatement::next_node);
  105067             : #endif
  105068             : 
  105069             : #if USE_CPP_NEW_DELETE_OPERATORS
  105070             :     void *mem = ROSE_MALLOC(Size);
  105071             :     ALLOC_MUTEX(SgOmpTargetExitDataStatement, unlock);
  105072             :     return mem;
  105073             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  105074             : #if ROSE_PEDANTIC_ALLOC
  105075             :     ROSE_ASSERT(Size == sizeof(SgOmpTargetExitDataStatement));
  105076             : #else
  105077           0 :     if (Size != sizeof(SgOmpTargetExitDataStatement)) {
  105078           0 :       void * object = ROSE_MALLOC(Size);
  105079           0 :       ALLOC_MUTEX(SgOmpTargetExitDataStatement, unlock);
  105080             :       return object;
  105081             :     }
  105082             : #endif
  105083             : 
  105084           0 :     if (SgOmpTargetExitDataStatement::next_node == nullptr) {
  105085           0 :         SgOmpTargetExitDataStatement * alloc = (SgOmpTargetExitDataStatement*) ROSE_MALLOC ( SgOmpTargetExitDataStatement::pool_size * sizeof(SgOmpTargetExitDataStatement) );
  105086           0 :         ROSE_ASSERT(alloc != nullptr);
  105087             : 
  105088             : #if ROSE_ALLOC_TRACE == 2
  105089             : //        printf("SgOmpTargetExitDataStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgOmpTargetExitDataStatement::pools.size(), alloc, alloc + SgOmpTargetExitDataStatement::pool_size);
  105090             : #endif
  105091             : 
  105092             : #if ROSE_ALLOC_MEMSET == 1
  105093             : #elif ROSE_ALLOC_MEMSET == 2
  105094             :         memset(alloc, 0x00, SgOmpTargetExitDataStatement::pool_size * sizeof(SgOmpTargetExitDataStatement));
  105095             : #elif ROSE_ALLOC_MEMSET == 3
  105096             :         memset(alloc, 0xAA, SgOmpTargetExitDataStatement::pool_size * sizeof(SgOmpTargetExitDataStatement));
  105097             : #endif
  105098           0 :         for (unsigned i=0; i < SgOmpTargetExitDataStatement::pool_size-1; i++) {
  105099           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
  105100             :         }
  105101           0 :         alloc[SgOmpTargetExitDataStatement::pool_size-1].p_freepointer = nullptr;
  105102             : 
  105103           0 :         SgOmpTargetExitDataStatement::pools.push_back ( (unsigned char *) alloc );
  105104           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgOmpTargetExitDataStatement::pool_size * sizeof(SgOmpTargetExitDataStatement), V_SgOmpTargetExitDataStatement ) );
  105105           0 :         SgOmpTargetExitDataStatement::next_node = alloc;
  105106             :     }
  105107           0 :     ROSE_ASSERT(SgOmpTargetExitDataStatement::next_node != nullptr);
  105108             : 
  105109           0 :     SgOmpTargetExitDataStatement * object = SgOmpTargetExitDataStatement::next_node;
  105110           0 :     SgOmpTargetExitDataStatement::next_node = (SgOmpTargetExitDataStatement*)(object->p_freepointer);
  105111             : 
  105112             : #if ROSE_ALLOC_TRACE == 2
  105113             :     printf("SgOmpTargetExitDataStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpTargetExitDataStatement::next_node);
  105114             : #endif
  105115             : 
  105116           0 :     SgNode * fp = object->p_freepointer;
  105117             : #if ROSE_ALLOC_MEMSET == 1
  105118             : #elif ROSE_ALLOC_MEMSET == 2
  105119             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpTargetExitDataStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  105120             : #elif ROSE_ALLOC_MEMSET == 3
  105121             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgOmpTargetExitDataStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  105122             : #endif
  105123           0 :     object->p_freepointer = fp;
  105124             : 
  105125             : #if ROSE_ALLOC_TRACE == 2
  105126             : //    printf("SgOmpTargetExitDataStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpTargetExitDataStatement::next_node);
  105127             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  105128             :     Rose::MemPool::snapshot(oss.str());
  105129             :     alloc_trace_cnt++;
  105130             : #endif
  105131             : 
  105132           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  105133             : 
  105134           0 :     ALLOC_MUTEX(SgOmpTargetExitDataStatement, unlock);
  105135             : 
  105136             :     return object;
  105137             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  105138             : }
  105139             : 
  105140             : 
  105141             : 
  105142             : /*! \brief Delete operator for SgOmpTargetExitDataStatement.
  105143             : 
  105144             :    This delete operator implements deallocation using memory pools to 
  105145             :    provide most efficent use of the heap within construction of large ASTs.
  105146             : 
  105147             : \internal The new and delete operators use the lower level C malloc/free
  105148             :    function calls for performance and to make sure that mixing of malloc/free
  105149             :    and new/delete by the used can be caught more readily.  This may change
  105150             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  105151             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  105152             :    deallocate memory allocated using ROSE_MALLOC.
  105153             : */
  105154           0 : void SgOmpTargetExitDataStatement::operator delete(void *Pointer, size_t Size)
  105155             : {
  105156             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  105157             :      * or throwing an exception. */
  105158           0 :     ALLOC_MUTEX(SgOmpTargetExitDataStatement, lock);
  105159             : 
  105160             : #if USE_CPP_NEW_DELETE_OPERATORS
  105161             :     ROSE_FREE(Pointer);
  105162             : #else
  105163             : #if ROSE_PEDANTIC_ALLOC
  105164             :     ROSE_ASSERT(Size == sizeof(SgOmpTargetExitDataStatement));
  105165             : #else
  105166           0 :     if (Size != sizeof(SgOmpTargetExitDataStatement)) {
  105167           0 :       ROSE_FREE(Pointer);
  105168           0 :       ALLOC_MUTEX(SgOmpTargetExitDataStatement, unlock);
  105169             :       return;
  105170             :     }
  105171             : #endif
  105172             : 
  105173           0 :     SgOmpTargetExitDataStatement * object = (SgOmpTargetExitDataStatement*) Pointer;
  105174           0 :     ROSE_ASSERT(object != nullptr);
  105175             : 
  105176             : #if ROSE_ALLOC_TRACE == 2
  105177             : //  printf("SgOmpTargetExitDataStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpTargetExitDataStatement::next_node);
  105178             :     printf("SgOmpTargetExitDataStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpTargetExitDataStatement::next_node);
  105179             : #endif
  105180             : 
  105181             : #if ROSE_PEDANTIC_ALLOC
  105182             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  105183             : #endif
  105184             : 
  105185             : #if ROSE_ALLOC_MEMSET == 1
  105186             : #elif ROSE_ALLOC_MEMSET == 2
  105187             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpTargetExitDataStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  105188             : #elif ROSE_ALLOC_MEMSET == 3
  105189             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgOmpTargetExitDataStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  105190             : #endif
  105191             : 
  105192             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  105193             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  105194             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  105195             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  105196             : #else
  105197           0 :     object->p_freepointer = SgOmpTargetExitDataStatement::next_node;
  105198           0 :     SgOmpTargetExitDataStatement::next_node = object;
  105199             : #endif
  105200             : 
  105201             : #if ROSE_ALLOC_TRACE == 2
  105202             : //  printf("SgOmpTargetExitDataStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpTargetExitDataStatement::next_node);
  105203             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  105204             :     Rose::MemPool::snapshot(oss.str());
  105205             :     alloc_trace_cnt++;
  105206             : #endif
  105207             : 
  105208             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  105209             : 
  105210           0 :     ALLOC_MUTEX(SgOmpTargetExitDataStatement, unlock);
  105211             : }
  105212             : 
  105213             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  105214             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  105215             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  105216             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  105217             : // Also, note comment below from Robb (copied from the Common.code file).
  105218             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  105219             : //
  105220             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  105221             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  105222             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  105223             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  105224             : #if 0
  105225             : void SgOmpTargetExitDataStatement::operator delete(void* pointer) { SgOmpTargetExitDataStatement::operator delete (pointer, sizeof(SgOmpTargetExitDataStatement)); };
  105226             : #endif
  105227             : /* #line 105228 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  105228             : 
  105229             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  105230             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  105231             : // obviously imply C++.
  105232             : 
  105233             : // This implements the support within ROSE for memory pools.  Memory pools
  105234             : // support the most condensed usage of memory within the construction of
  105235             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  105236             : // by a new operator written for each class.
  105237             : 
  105238             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  105239             :     // User wants multi-thread support and POSIX threads are available.
  105240             : #   include <pthread.h>
  105241             :     static pthread_mutex_t SgOmpParallelMasterStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  105242             : #else
  105243             :      // Cause synchronization to be skipped.
  105244             : #    ifndef ALLOC_MUTEX
  105245             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  105246             : #    endif
  105247             : #    ifdef _REENTRANT
  105248             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  105249             : #       ifdef _MSC_VER
  105250             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  105251             : #       else
  105252             : #           warning "POSIX threads are not available; synchronization being skipped"
  105253             : #       endif
  105254             : #    endif
  105255             : #endif
  105256             : 
  105257             : #ifndef ROSE_ALLOC_TRACE
  105258             : #  define ROSE_ALLOC_TRACE 0
  105259             : #endif
  105260             : 
  105261             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  105262             : #define ROSE_ALLOC_TRACE_CNT
  105263             : #include "memory-pool-snapshot.h"
  105264             : unsigned long alloc_trace_cnt = 0;
  105265             : #endif
  105266             : 
  105267             : #if ROSE_ALLOC_TRACE
  105268             : const unsigned SgOmpParallelMasterStatement::pool_size = 5;
  105269             : #else
  105270             : const unsigned SgOmpParallelMasterStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  105271             : #endif
  105272             : 
  105273             : #ifndef ROSE_ALLOC_MEMSET
  105274             : #  define ROSE_ALLOC_MEMSET 0
  105275             : #endif
  105276             : 
  105277             : #ifndef ROSE_PEDANTIC_ALLOC
  105278             : #  define ROSE_PEDANTIC_ALLOC 0
  105279             : #endif
  105280             : 
  105281             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  105282             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  105283             : #endif
  105284             : 
  105285             : #if !defined(SGNODE__ALL_POOLS)
  105286             : #define SGNODE__ALL_POOLS
  105287             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  105288             : #endif
  105289             : 
  105290             : SgOmpParallelMasterStatement* SgOmpParallelMasterStatement::next_node = nullptr;
  105291             : std::vector<unsigned char*> SgOmpParallelMasterStatement::pools;
  105292             : 
  105293             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  105294             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  105295             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  105296             : // around this macro definition rather than each use).
  105297             : #ifndef ALLOC_MUTEX
  105298             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  105299             :         do {                                                                     \
  105300             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  105301             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  105302             :                 abort();                                                         \
  105303             :             }                                                                    \
  105304             :         } while (0);
  105305             : #endif
  105306             : 
  105307             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  105308             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  105309             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  105310             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  105311             : 
  105312             : /*! \brief New operator for SgOmpParallelMasterStatement.
  105313             : 
  105314             :    This new operator implements memory pools to provide most efficent 
  105315             :    use of the heap within construction of large ASTs.
  105316             : 
  105317             : \internal The new and delete operators use the lower level C malloc/free
  105318             :    function calls for performance and to make sure that mixing of malloc/free
  105319             :    and new/delete by the used can be caught more readily.  This may change
  105320             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  105321             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  105322             :    deallocate memory allocated using ROSE_MALLOC.
  105323             : */
  105324           3 : void *SgOmpParallelMasterStatement::operator new ( size_t Size )
  105325             : {
  105326             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  105327             :      * returning or throwing an exception. */
  105328           3 :     ALLOC_MUTEX(SgOmpParallelMasterStatement, lock);
  105329             : 
  105330             : #if ROSE_ALLOC_TRACE == 2
  105331             : //    printf("SgOmpParallelMasterStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgOmpParallelMasterStatement::next_node);
  105332             : #endif
  105333             : 
  105334             : #if USE_CPP_NEW_DELETE_OPERATORS
  105335             :     void *mem = ROSE_MALLOC(Size);
  105336             :     ALLOC_MUTEX(SgOmpParallelMasterStatement, unlock);
  105337             :     return mem;
  105338             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  105339             : #if ROSE_PEDANTIC_ALLOC
  105340             :     ROSE_ASSERT(Size == sizeof(SgOmpParallelMasterStatement));
  105341             : #else
  105342           3 :     if (Size != sizeof(SgOmpParallelMasterStatement)) {
  105343           0 :       void * object = ROSE_MALLOC(Size);
  105344           0 :       ALLOC_MUTEX(SgOmpParallelMasterStatement, unlock);
  105345             :       return object;
  105346             :     }
  105347             : #endif
  105348             : 
  105349           3 :     if (SgOmpParallelMasterStatement::next_node == nullptr) {
  105350           2 :         SgOmpParallelMasterStatement * alloc = (SgOmpParallelMasterStatement*) ROSE_MALLOC ( SgOmpParallelMasterStatement::pool_size * sizeof(SgOmpParallelMasterStatement) );
  105351           2 :         ROSE_ASSERT(alloc != nullptr);
  105352             : 
  105353             : #if ROSE_ALLOC_TRACE == 2
  105354             : //        printf("SgOmpParallelMasterStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgOmpParallelMasterStatement::pools.size(), alloc, alloc + SgOmpParallelMasterStatement::pool_size);
  105355             : #endif
  105356             : 
  105357             : #if ROSE_ALLOC_MEMSET == 1
  105358             : #elif ROSE_ALLOC_MEMSET == 2
  105359             :         memset(alloc, 0x00, SgOmpParallelMasterStatement::pool_size * sizeof(SgOmpParallelMasterStatement));
  105360             : #elif ROSE_ALLOC_MEMSET == 3
  105361             :         memset(alloc, 0xAA, SgOmpParallelMasterStatement::pool_size * sizeof(SgOmpParallelMasterStatement));
  105362             : #endif
  105363        4000 :         for (unsigned i=0; i < SgOmpParallelMasterStatement::pool_size-1; i++) {
  105364        3998 :           alloc[i].p_freepointer = &(alloc[i+1]);
  105365             :         }
  105366           2 :         alloc[SgOmpParallelMasterStatement::pool_size-1].p_freepointer = nullptr;
  105367             : 
  105368           2 :         SgOmpParallelMasterStatement::pools.push_back ( (unsigned char *) alloc );
  105369           2 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgOmpParallelMasterStatement::pool_size * sizeof(SgOmpParallelMasterStatement), V_SgOmpParallelMasterStatement ) );
  105370           2 :         SgOmpParallelMasterStatement::next_node = alloc;
  105371             :     }
  105372           3 :     ROSE_ASSERT(SgOmpParallelMasterStatement::next_node != nullptr);
  105373             : 
  105374           3 :     SgOmpParallelMasterStatement * object = SgOmpParallelMasterStatement::next_node;
  105375           3 :     SgOmpParallelMasterStatement::next_node = (SgOmpParallelMasterStatement*)(object->p_freepointer);
  105376             : 
  105377             : #if ROSE_ALLOC_TRACE == 2
  105378             :     printf("SgOmpParallelMasterStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpParallelMasterStatement::next_node);
  105379             : #endif
  105380             : 
  105381           3 :     SgNode * fp = object->p_freepointer;
  105382             : #if ROSE_ALLOC_MEMSET == 1
  105383             : #elif ROSE_ALLOC_MEMSET == 2
  105384             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpParallelMasterStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  105385             : #elif ROSE_ALLOC_MEMSET == 3
  105386             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgOmpParallelMasterStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  105387             : #endif
  105388           3 :     object->p_freepointer = fp;
  105389             : 
  105390             : #if ROSE_ALLOC_TRACE == 2
  105391             : //    printf("SgOmpParallelMasterStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpParallelMasterStatement::next_node);
  105392             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  105393             :     Rose::MemPool::snapshot(oss.str());
  105394             :     alloc_trace_cnt++;
  105395             : #endif
  105396             : 
  105397           3 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  105398             : 
  105399           3 :     ALLOC_MUTEX(SgOmpParallelMasterStatement, unlock);
  105400             : 
  105401             :     return object;
  105402             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  105403             : }
  105404             : 
  105405             : 
  105406             : 
  105407             : /*! \brief Delete operator for SgOmpParallelMasterStatement.
  105408             : 
  105409             :    This delete operator implements deallocation using memory pools to 
  105410             :    provide most efficent use of the heap within construction of large ASTs.
  105411             : 
  105412             : \internal The new and delete operators use the lower level C malloc/free
  105413             :    function calls for performance and to make sure that mixing of malloc/free
  105414             :    and new/delete by the used can be caught more readily.  This may change
  105415             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  105416             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  105417             :    deallocate memory allocated using ROSE_MALLOC.
  105418             : */
  105419           0 : void SgOmpParallelMasterStatement::operator delete(void *Pointer, size_t Size)
  105420             : {
  105421             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  105422             :      * or throwing an exception. */
  105423           0 :     ALLOC_MUTEX(SgOmpParallelMasterStatement, lock);
  105424             : 
  105425             : #if USE_CPP_NEW_DELETE_OPERATORS
  105426             :     ROSE_FREE(Pointer);
  105427             : #else
  105428             : #if ROSE_PEDANTIC_ALLOC
  105429             :     ROSE_ASSERT(Size == sizeof(SgOmpParallelMasterStatement));
  105430             : #else
  105431           0 :     if (Size != sizeof(SgOmpParallelMasterStatement)) {
  105432           0 :       ROSE_FREE(Pointer);
  105433           0 :       ALLOC_MUTEX(SgOmpParallelMasterStatement, unlock);
  105434             :       return;
  105435             :     }
  105436             : #endif
  105437             : 
  105438           0 :     SgOmpParallelMasterStatement * object = (SgOmpParallelMasterStatement*) Pointer;
  105439           0 :     ROSE_ASSERT(object != nullptr);
  105440             : 
  105441             : #if ROSE_ALLOC_TRACE == 2
  105442             : //  printf("SgOmpParallelMasterStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpParallelMasterStatement::next_node);
  105443             :     printf("SgOmpParallelMasterStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpParallelMasterStatement::next_node);
  105444             : #endif
  105445             : 
  105446             : #if ROSE_PEDANTIC_ALLOC
  105447             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  105448             : #endif
  105449             : 
  105450             : #if ROSE_ALLOC_MEMSET == 1
  105451             : #elif ROSE_ALLOC_MEMSET == 2
  105452             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpParallelMasterStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  105453             : #elif ROSE_ALLOC_MEMSET == 3
  105454             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgOmpParallelMasterStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  105455             : #endif
  105456             : 
  105457             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  105458             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  105459             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  105460             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  105461             : #else
  105462           0 :     object->p_freepointer = SgOmpParallelMasterStatement::next_node;
  105463           0 :     SgOmpParallelMasterStatement::next_node = object;
  105464             : #endif
  105465             : 
  105466             : #if ROSE_ALLOC_TRACE == 2
  105467             : //  printf("SgOmpParallelMasterStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpParallelMasterStatement::next_node);
  105468             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  105469             :     Rose::MemPool::snapshot(oss.str());
  105470             :     alloc_trace_cnt++;
  105471             : #endif
  105472             : 
  105473             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  105474             : 
  105475           0 :     ALLOC_MUTEX(SgOmpParallelMasterStatement, unlock);
  105476             : }
  105477             : 
  105478             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  105479             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  105480             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  105481             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  105482             : // Also, note comment below from Robb (copied from the Common.code file).
  105483             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  105484             : //
  105485             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  105486             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  105487             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  105488             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  105489             : #if 0
  105490             : void SgOmpParallelMasterStatement::operator delete(void* pointer) { SgOmpParallelMasterStatement::operator delete (pointer, sizeof(SgOmpParallelMasterStatement)); };
  105491             : #endif
  105492             : /* #line 105493 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  105493             : 
  105494             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  105495             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  105496             : // obviously imply C++.
  105497             : 
  105498             : // This implements the support within ROSE for memory pools.  Memory pools
  105499             : // support the most condensed usage of memory within the construction of
  105500             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  105501             : // by a new operator written for each class.
  105502             : 
  105503             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  105504             :     // User wants multi-thread support and POSIX threads are available.
  105505             : #   include <pthread.h>
  105506             :     static pthread_mutex_t SgOmpMasterTaskloopStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  105507             : #else
  105508             :      // Cause synchronization to be skipped.
  105509             : #    ifndef ALLOC_MUTEX
  105510             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  105511             : #    endif
  105512             : #    ifdef _REENTRANT
  105513             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  105514             : #       ifdef _MSC_VER
  105515             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  105516             : #       else
  105517             : #           warning "POSIX threads are not available; synchronization being skipped"
  105518             : #       endif
  105519             : #    endif
  105520             : #endif
  105521             : 
  105522             : #ifndef ROSE_ALLOC_TRACE
  105523             : #  define ROSE_ALLOC_TRACE 0
  105524             : #endif
  105525             : 
  105526             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  105527             : #define ROSE_ALLOC_TRACE_CNT
  105528             : #include "memory-pool-snapshot.h"
  105529             : unsigned long alloc_trace_cnt = 0;
  105530             : #endif
  105531             : 
  105532             : #if ROSE_ALLOC_TRACE
  105533             : const unsigned SgOmpMasterTaskloopStatement::pool_size = 5;
  105534             : #else
  105535             : const unsigned SgOmpMasterTaskloopStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  105536             : #endif
  105537             : 
  105538             : #ifndef ROSE_ALLOC_MEMSET
  105539             : #  define ROSE_ALLOC_MEMSET 0
  105540             : #endif
  105541             : 
  105542             : #ifndef ROSE_PEDANTIC_ALLOC
  105543             : #  define ROSE_PEDANTIC_ALLOC 0
  105544             : #endif
  105545             : 
  105546             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  105547             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  105548             : #endif
  105549             : 
  105550             : #if !defined(SGNODE__ALL_POOLS)
  105551             : #define SGNODE__ALL_POOLS
  105552             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  105553             : #endif
  105554             : 
  105555             : SgOmpMasterTaskloopStatement* SgOmpMasterTaskloopStatement::next_node = nullptr;
  105556             : std::vector<unsigned char*> SgOmpMasterTaskloopStatement::pools;
  105557             : 
  105558             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  105559             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  105560             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  105561             : // around this macro definition rather than each use).
  105562             : #ifndef ALLOC_MUTEX
  105563             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  105564             :         do {                                                                     \
  105565             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  105566             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  105567             :                 abort();                                                         \
  105568             :             }                                                                    \
  105569             :         } while (0);
  105570             : #endif
  105571             : 
  105572             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  105573             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  105574             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  105575             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  105576             : 
  105577             : /*! \brief New operator for SgOmpMasterTaskloopStatement.
  105578             : 
  105579             :    This new operator implements memory pools to provide most efficent 
  105580             :    use of the heap within construction of large ASTs.
  105581             : 
  105582             : \internal The new and delete operators use the lower level C malloc/free
  105583             :    function calls for performance and to make sure that mixing of malloc/free
  105584             :    and new/delete by the used can be caught more readily.  This may change
  105585             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  105586             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  105587             :    deallocate memory allocated using ROSE_MALLOC.
  105588             : */
  105589           2 : void *SgOmpMasterTaskloopStatement::operator new ( size_t Size )
  105590             : {
  105591             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  105592             :      * returning or throwing an exception. */
  105593           2 :     ALLOC_MUTEX(SgOmpMasterTaskloopStatement, lock);
  105594             : 
  105595             : #if ROSE_ALLOC_TRACE == 2
  105596             : //    printf("SgOmpMasterTaskloopStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgOmpMasterTaskloopStatement::next_node);
  105597             : #endif
  105598             : 
  105599             : #if USE_CPP_NEW_DELETE_OPERATORS
  105600             :     void *mem = ROSE_MALLOC(Size);
  105601             :     ALLOC_MUTEX(SgOmpMasterTaskloopStatement, unlock);
  105602             :     return mem;
  105603             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  105604             : #if ROSE_PEDANTIC_ALLOC
  105605             :     ROSE_ASSERT(Size == sizeof(SgOmpMasterTaskloopStatement));
  105606             : #else
  105607           2 :     if (Size != sizeof(SgOmpMasterTaskloopStatement)) {
  105608           0 :       void * object = ROSE_MALLOC(Size);
  105609           0 :       ALLOC_MUTEX(SgOmpMasterTaskloopStatement, unlock);
  105610             :       return object;
  105611             :     }
  105612             : #endif
  105613             : 
  105614           2 :     if (SgOmpMasterTaskloopStatement::next_node == nullptr) {
  105615           2 :         SgOmpMasterTaskloopStatement * alloc = (SgOmpMasterTaskloopStatement*) ROSE_MALLOC ( SgOmpMasterTaskloopStatement::pool_size * sizeof(SgOmpMasterTaskloopStatement) );
  105616           2 :         ROSE_ASSERT(alloc != nullptr);
  105617             : 
  105618             : #if ROSE_ALLOC_TRACE == 2
  105619             : //        printf("SgOmpMasterTaskloopStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgOmpMasterTaskloopStatement::pools.size(), alloc, alloc + SgOmpMasterTaskloopStatement::pool_size);
  105620             : #endif
  105621             : 
  105622             : #if ROSE_ALLOC_MEMSET == 1
  105623             : #elif ROSE_ALLOC_MEMSET == 2
  105624             :         memset(alloc, 0x00, SgOmpMasterTaskloopStatement::pool_size * sizeof(SgOmpMasterTaskloopStatement));
  105625             : #elif ROSE_ALLOC_MEMSET == 3
  105626             :         memset(alloc, 0xAA, SgOmpMasterTaskloopStatement::pool_size * sizeof(SgOmpMasterTaskloopStatement));
  105627             : #endif
  105628        4000 :         for (unsigned i=0; i < SgOmpMasterTaskloopStatement::pool_size-1; i++) {
  105629        3998 :           alloc[i].p_freepointer = &(alloc[i+1]);
  105630             :         }
  105631           2 :         alloc[SgOmpMasterTaskloopStatement::pool_size-1].p_freepointer = nullptr;
  105632             : 
  105633           2 :         SgOmpMasterTaskloopStatement::pools.push_back ( (unsigned char *) alloc );
  105634           2 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgOmpMasterTaskloopStatement::pool_size * sizeof(SgOmpMasterTaskloopStatement), V_SgOmpMasterTaskloopStatement ) );
  105635           2 :         SgOmpMasterTaskloopStatement::next_node = alloc;
  105636             :     }
  105637           2 :     ROSE_ASSERT(SgOmpMasterTaskloopStatement::next_node != nullptr);
  105638             : 
  105639           2 :     SgOmpMasterTaskloopStatement * object = SgOmpMasterTaskloopStatement::next_node;
  105640           2 :     SgOmpMasterTaskloopStatement::next_node = (SgOmpMasterTaskloopStatement*)(object->p_freepointer);
  105641             : 
  105642             : #if ROSE_ALLOC_TRACE == 2
  105643             :     printf("SgOmpMasterTaskloopStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpMasterTaskloopStatement::next_node);
  105644             : #endif
  105645             : 
  105646           2 :     SgNode * fp = object->p_freepointer;
  105647             : #if ROSE_ALLOC_MEMSET == 1
  105648             : #elif ROSE_ALLOC_MEMSET == 2
  105649             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpMasterTaskloopStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  105650             : #elif ROSE_ALLOC_MEMSET == 3
  105651             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgOmpMasterTaskloopStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  105652             : #endif
  105653           2 :     object->p_freepointer = fp;
  105654             : 
  105655             : #if ROSE_ALLOC_TRACE == 2
  105656             : //    printf("SgOmpMasterTaskloopStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpMasterTaskloopStatement::next_node);
  105657             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  105658             :     Rose::MemPool::snapshot(oss.str());
  105659             :     alloc_trace_cnt++;
  105660             : #endif
  105661             : 
  105662           2 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  105663             : 
  105664           2 :     ALLOC_MUTEX(SgOmpMasterTaskloopStatement, unlock);
  105665             : 
  105666             :     return object;
  105667             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  105668             : }
  105669             : 
  105670             : 
  105671             : 
  105672             : /*! \brief Delete operator for SgOmpMasterTaskloopStatement.
  105673             : 
  105674             :    This delete operator implements deallocation using memory pools to 
  105675             :    provide most efficent use of the heap within construction of large ASTs.
  105676             : 
  105677             : \internal The new and delete operators use the lower level C malloc/free
  105678             :    function calls for performance and to make sure that mixing of malloc/free
  105679             :    and new/delete by the used can be caught more readily.  This may change
  105680             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  105681             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  105682             :    deallocate memory allocated using ROSE_MALLOC.
  105683             : */
  105684           0 : void SgOmpMasterTaskloopStatement::operator delete(void *Pointer, size_t Size)
  105685             : {
  105686             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  105687             :      * or throwing an exception. */
  105688           0 :     ALLOC_MUTEX(SgOmpMasterTaskloopStatement, lock);
  105689             : 
  105690             : #if USE_CPP_NEW_DELETE_OPERATORS
  105691             :     ROSE_FREE(Pointer);
  105692             : #else
  105693             : #if ROSE_PEDANTIC_ALLOC
  105694             :     ROSE_ASSERT(Size == sizeof(SgOmpMasterTaskloopStatement));
  105695             : #else
  105696           0 :     if (Size != sizeof(SgOmpMasterTaskloopStatement)) {
  105697           0 :       ROSE_FREE(Pointer);
  105698           0 :       ALLOC_MUTEX(SgOmpMasterTaskloopStatement, unlock);
  105699             :       return;
  105700             :     }
  105701             : #endif
  105702             : 
  105703           0 :     SgOmpMasterTaskloopStatement * object = (SgOmpMasterTaskloopStatement*) Pointer;
  105704           0 :     ROSE_ASSERT(object != nullptr);
  105705             : 
  105706             : #if ROSE_ALLOC_TRACE == 2
  105707             : //  printf("SgOmpMasterTaskloopStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpMasterTaskloopStatement::next_node);
  105708             :     printf("SgOmpMasterTaskloopStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpMasterTaskloopStatement::next_node);
  105709             : #endif
  105710             : 
  105711             : #if ROSE_PEDANTIC_ALLOC
  105712             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  105713             : #endif
  105714             : 
  105715             : #if ROSE_ALLOC_MEMSET == 1
  105716             : #elif ROSE_ALLOC_MEMSET == 2
  105717             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpMasterTaskloopStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  105718             : #elif ROSE_ALLOC_MEMSET == 3
  105719             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgOmpMasterTaskloopStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  105720             : #endif
  105721             : 
  105722             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  105723             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  105724             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  105725             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  105726             : #else
  105727           0 :     object->p_freepointer = SgOmpMasterTaskloopStatement::next_node;
  105728           0 :     SgOmpMasterTaskloopStatement::next_node = object;
  105729             : #endif
  105730             : 
  105731             : #if ROSE_ALLOC_TRACE == 2
  105732             : //  printf("SgOmpMasterTaskloopStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpMasterTaskloopStatement::next_node);
  105733             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  105734             :     Rose::MemPool::snapshot(oss.str());
  105735             :     alloc_trace_cnt++;
  105736             : #endif
  105737             : 
  105738             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  105739             : 
  105740           0 :     ALLOC_MUTEX(SgOmpMasterTaskloopStatement, unlock);
  105741             : }
  105742             : 
  105743             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  105744             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  105745             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  105746             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  105747             : // Also, note comment below from Robb (copied from the Common.code file).
  105748             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  105749             : //
  105750             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  105751             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  105752             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  105753             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  105754             : #if 0
  105755             : void SgOmpMasterTaskloopStatement::operator delete(void* pointer) { SgOmpMasterTaskloopStatement::operator delete (pointer, sizeof(SgOmpMasterTaskloopStatement)); };
  105756             : #endif
  105757             : /* #line 105758 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  105758             : 
  105759             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  105760             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  105761             : // obviously imply C++.
  105762             : 
  105763             : // This implements the support within ROSE for memory pools.  Memory pools
  105764             : // support the most condensed usage of memory within the construction of
  105765             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  105766             : // by a new operator written for each class.
  105767             : 
  105768             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  105769             :     // User wants multi-thread support and POSIX threads are available.
  105770             : #   include <pthread.h>
  105771             :     static pthread_mutex_t SgOmpTaskStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  105772             : #else
  105773             :      // Cause synchronization to be skipped.
  105774             : #    ifndef ALLOC_MUTEX
  105775             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  105776             : #    endif
  105777             : #    ifdef _REENTRANT
  105778             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  105779             : #       ifdef _MSC_VER
  105780             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  105781             : #       else
  105782             : #           warning "POSIX threads are not available; synchronization being skipped"
  105783             : #       endif
  105784             : #    endif
  105785             : #endif
  105786             : 
  105787             : #ifndef ROSE_ALLOC_TRACE
  105788             : #  define ROSE_ALLOC_TRACE 0
  105789             : #endif
  105790             : 
  105791             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  105792             : #define ROSE_ALLOC_TRACE_CNT
  105793             : #include "memory-pool-snapshot.h"
  105794             : unsigned long alloc_trace_cnt = 0;
  105795             : #endif
  105796             : 
  105797             : #if ROSE_ALLOC_TRACE
  105798             : const unsigned SgOmpTaskStatement::pool_size = 5;
  105799             : #else
  105800             : const unsigned SgOmpTaskStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  105801             : #endif
  105802             : 
  105803             : #ifndef ROSE_ALLOC_MEMSET
  105804             : #  define ROSE_ALLOC_MEMSET 0
  105805             : #endif
  105806             : 
  105807             : #ifndef ROSE_PEDANTIC_ALLOC
  105808             : #  define ROSE_PEDANTIC_ALLOC 0
  105809             : #endif
  105810             : 
  105811             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  105812             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  105813             : #endif
  105814             : 
  105815             : #if !defined(SGNODE__ALL_POOLS)
  105816             : #define SGNODE__ALL_POOLS
  105817             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  105818             : #endif
  105819             : 
  105820             : SgOmpTaskStatement* SgOmpTaskStatement::next_node = nullptr;
  105821             : std::vector<unsigned char*> SgOmpTaskStatement::pools;
  105822             : 
  105823             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  105824             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  105825             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  105826             : // around this macro definition rather than each use).
  105827             : #ifndef ALLOC_MUTEX
  105828             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  105829             :         do {                                                                     \
  105830             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  105831             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  105832             :                 abort();                                                         \
  105833             :             }                                                                    \
  105834             :         } while (0);
  105835             : #endif
  105836             : 
  105837             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  105838             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  105839             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  105840             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  105841             : 
  105842             : /*! \brief New operator for SgOmpTaskStatement.
  105843             : 
  105844             :    This new operator implements memory pools to provide most efficent 
  105845             :    use of the heap within construction of large ASTs.
  105846             : 
  105847             : \internal The new and delete operators use the lower level C malloc/free
  105848             :    function calls for performance and to make sure that mixing of malloc/free
  105849             :    and new/delete by the used can be caught more readily.  This may change
  105850             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  105851             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  105852             :    deallocate memory allocated using ROSE_MALLOC.
  105853             : */
  105854          74 : void *SgOmpTaskStatement::operator new ( size_t Size )
  105855             : {
  105856             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  105857             :      * returning or throwing an exception. */
  105858          74 :     ALLOC_MUTEX(SgOmpTaskStatement, lock);
  105859             : 
  105860             : #if ROSE_ALLOC_TRACE == 2
  105861             : //    printf("SgOmpTaskStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgOmpTaskStatement::next_node);
  105862             : #endif
  105863             : 
  105864             : #if USE_CPP_NEW_DELETE_OPERATORS
  105865             :     void *mem = ROSE_MALLOC(Size);
  105866             :     ALLOC_MUTEX(SgOmpTaskStatement, unlock);
  105867             :     return mem;
  105868             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  105869             : #if ROSE_PEDANTIC_ALLOC
  105870             :     ROSE_ASSERT(Size == sizeof(SgOmpTaskStatement));
  105871             : #else
  105872          74 :     if (Size != sizeof(SgOmpTaskStatement)) {
  105873           0 :       void * object = ROSE_MALLOC(Size);
  105874           0 :       ALLOC_MUTEX(SgOmpTaskStatement, unlock);
  105875             :       return object;
  105876             :     }
  105877             : #endif
  105878             : 
  105879          74 :     if (SgOmpTaskStatement::next_node == nullptr) {
  105880          30 :         SgOmpTaskStatement * alloc = (SgOmpTaskStatement*) ROSE_MALLOC ( SgOmpTaskStatement::pool_size * sizeof(SgOmpTaskStatement) );
  105881          30 :         ROSE_ASSERT(alloc != nullptr);
  105882             : 
  105883             : #if ROSE_ALLOC_TRACE == 2
  105884             : //        printf("SgOmpTaskStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgOmpTaskStatement::pools.size(), alloc, alloc + SgOmpTaskStatement::pool_size);
  105885             : #endif
  105886             : 
  105887             : #if ROSE_ALLOC_MEMSET == 1
  105888             : #elif ROSE_ALLOC_MEMSET == 2
  105889             :         memset(alloc, 0x00, SgOmpTaskStatement::pool_size * sizeof(SgOmpTaskStatement));
  105890             : #elif ROSE_ALLOC_MEMSET == 3
  105891             :         memset(alloc, 0xAA, SgOmpTaskStatement::pool_size * sizeof(SgOmpTaskStatement));
  105892             : #endif
  105893       60000 :         for (unsigned i=0; i < SgOmpTaskStatement::pool_size-1; i++) {
  105894       59970 :           alloc[i].p_freepointer = &(alloc[i+1]);
  105895             :         }
  105896          30 :         alloc[SgOmpTaskStatement::pool_size-1].p_freepointer = nullptr;
  105897             : 
  105898          30 :         SgOmpTaskStatement::pools.push_back ( (unsigned char *) alloc );
  105899          30 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgOmpTaskStatement::pool_size * sizeof(SgOmpTaskStatement), V_SgOmpTaskStatement ) );
  105900          30 :         SgOmpTaskStatement::next_node = alloc;
  105901             :     }
  105902          74 :     ROSE_ASSERT(SgOmpTaskStatement::next_node != nullptr);
  105903             : 
  105904          74 :     SgOmpTaskStatement * object = SgOmpTaskStatement::next_node;
  105905          74 :     SgOmpTaskStatement::next_node = (SgOmpTaskStatement*)(object->p_freepointer);
  105906             : 
  105907             : #if ROSE_ALLOC_TRACE == 2
  105908             :     printf("SgOmpTaskStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpTaskStatement::next_node);
  105909             : #endif
  105910             : 
  105911          74 :     SgNode * fp = object->p_freepointer;
  105912             : #if ROSE_ALLOC_MEMSET == 1
  105913             : #elif ROSE_ALLOC_MEMSET == 2
  105914             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpTaskStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  105915             : #elif ROSE_ALLOC_MEMSET == 3
  105916             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgOmpTaskStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  105917             : #endif
  105918          74 :     object->p_freepointer = fp;
  105919             : 
  105920             : #if ROSE_ALLOC_TRACE == 2
  105921             : //    printf("SgOmpTaskStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpTaskStatement::next_node);
  105922             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  105923             :     Rose::MemPool::snapshot(oss.str());
  105924             :     alloc_trace_cnt++;
  105925             : #endif
  105926             : 
  105927          74 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  105928             : 
  105929          74 :     ALLOC_MUTEX(SgOmpTaskStatement, unlock);
  105930             : 
  105931             :     return object;
  105932             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  105933             : }
  105934             : 
  105935             : 
  105936             : 
  105937             : /*! \brief Delete operator for SgOmpTaskStatement.
  105938             : 
  105939             :    This delete operator implements deallocation using memory pools to 
  105940             :    provide most efficent use of the heap within construction of large ASTs.
  105941             : 
  105942             : \internal The new and delete operators use the lower level C malloc/free
  105943             :    function calls for performance and to make sure that mixing of malloc/free
  105944             :    and new/delete by the used can be caught more readily.  This may change
  105945             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  105946             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  105947             :    deallocate memory allocated using ROSE_MALLOC.
  105948             : */
  105949           0 : void SgOmpTaskStatement::operator delete(void *Pointer, size_t Size)
  105950             : {
  105951             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  105952             :      * or throwing an exception. */
  105953           0 :     ALLOC_MUTEX(SgOmpTaskStatement, lock);
  105954             : 
  105955             : #if USE_CPP_NEW_DELETE_OPERATORS
  105956             :     ROSE_FREE(Pointer);
  105957             : #else
  105958             : #if ROSE_PEDANTIC_ALLOC
  105959             :     ROSE_ASSERT(Size == sizeof(SgOmpTaskStatement));
  105960             : #else
  105961           0 :     if (Size != sizeof(SgOmpTaskStatement)) {
  105962           0 :       ROSE_FREE(Pointer);
  105963           0 :       ALLOC_MUTEX(SgOmpTaskStatement, unlock);
  105964             :       return;
  105965             :     }
  105966             : #endif
  105967             : 
  105968           0 :     SgOmpTaskStatement * object = (SgOmpTaskStatement*) Pointer;
  105969           0 :     ROSE_ASSERT(object != nullptr);
  105970             : 
  105971             : #if ROSE_ALLOC_TRACE == 2
  105972             : //  printf("SgOmpTaskStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpTaskStatement::next_node);
  105973             :     printf("SgOmpTaskStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpTaskStatement::next_node);
  105974             : #endif
  105975             : 
  105976             : #if ROSE_PEDANTIC_ALLOC
  105977             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  105978             : #endif
  105979             : 
  105980             : #if ROSE_ALLOC_MEMSET == 1
  105981             : #elif ROSE_ALLOC_MEMSET == 2
  105982             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpTaskStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  105983             : #elif ROSE_ALLOC_MEMSET == 3
  105984             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgOmpTaskStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  105985             : #endif
  105986             : 
  105987             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  105988             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  105989             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  105990             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  105991             : #else
  105992           0 :     object->p_freepointer = SgOmpTaskStatement::next_node;
  105993           0 :     SgOmpTaskStatement::next_node = object;
  105994             : #endif
  105995             : 
  105996             : #if ROSE_ALLOC_TRACE == 2
  105997             : //  printf("SgOmpTaskStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpTaskStatement::next_node);
  105998             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  105999             :     Rose::MemPool::snapshot(oss.str());
  106000             :     alloc_trace_cnt++;
  106001             : #endif
  106002             : 
  106003             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  106004             : 
  106005           0 :     ALLOC_MUTEX(SgOmpTaskStatement, unlock);
  106006             : }
  106007             : 
  106008             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  106009             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  106010             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  106011             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  106012             : // Also, note comment below from Robb (copied from the Common.code file).
  106013             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  106014             : //
  106015             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  106016             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  106017             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  106018             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  106019             : #if 0
  106020             : void SgOmpTaskStatement::operator delete(void* pointer) { SgOmpTaskStatement::operator delete (pointer, sizeof(SgOmpTaskStatement)); };
  106021             : #endif
  106022             : /* #line 106023 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  106023             : 
  106024             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  106025             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  106026             : // obviously imply C++.
  106027             : 
  106028             : // This implements the support within ROSE for memory pools.  Memory pools
  106029             : // support the most condensed usage of memory within the construction of
  106030             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  106031             : // by a new operator written for each class.
  106032             : 
  106033             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  106034             :     // User wants multi-thread support and POSIX threads are available.
  106035             : #   include <pthread.h>
  106036             :     static pthread_mutex_t SgOmpDoStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  106037             : #else
  106038             :      // Cause synchronization to be skipped.
  106039             : #    ifndef ALLOC_MUTEX
  106040             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  106041             : #    endif
  106042             : #    ifdef _REENTRANT
  106043             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  106044             : #       ifdef _MSC_VER
  106045             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  106046             : #       else
  106047             : #           warning "POSIX threads are not available; synchronization being skipped"
  106048             : #       endif
  106049             : #    endif
  106050             : #endif
  106051             : 
  106052             : #ifndef ROSE_ALLOC_TRACE
  106053             : #  define ROSE_ALLOC_TRACE 0
  106054             : #endif
  106055             : 
  106056             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  106057             : #define ROSE_ALLOC_TRACE_CNT
  106058             : #include "memory-pool-snapshot.h"
  106059             : unsigned long alloc_trace_cnt = 0;
  106060             : #endif
  106061             : 
  106062             : #if ROSE_ALLOC_TRACE
  106063             : const unsigned SgOmpDoStatement::pool_size = 5;
  106064             : #else
  106065             : const unsigned SgOmpDoStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  106066             : #endif
  106067             : 
  106068             : #ifndef ROSE_ALLOC_MEMSET
  106069             : #  define ROSE_ALLOC_MEMSET 0
  106070             : #endif
  106071             : 
  106072             : #ifndef ROSE_PEDANTIC_ALLOC
  106073             : #  define ROSE_PEDANTIC_ALLOC 0
  106074             : #endif
  106075             : 
  106076             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  106077             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  106078             : #endif
  106079             : 
  106080             : #if !defined(SGNODE__ALL_POOLS)
  106081             : #define SGNODE__ALL_POOLS
  106082             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  106083             : #endif
  106084             : 
  106085             : SgOmpDoStatement* SgOmpDoStatement::next_node = nullptr;
  106086             : std::vector<unsigned char*> SgOmpDoStatement::pools;
  106087             : 
  106088             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  106089             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  106090             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  106091             : // around this macro definition rather than each use).
  106092             : #ifndef ALLOC_MUTEX
  106093             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  106094             :         do {                                                                     \
  106095             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  106096             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  106097             :                 abort();                                                         \
  106098             :             }                                                                    \
  106099             :         } while (0);
  106100             : #endif
  106101             : 
  106102             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  106103             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  106104             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  106105             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  106106             : 
  106107             : /*! \brief New operator for SgOmpDoStatement.
  106108             : 
  106109             :    This new operator implements memory pools to provide most efficent 
  106110             :    use of the heap within construction of large ASTs.
  106111             : 
  106112             : \internal The new and delete operators use the lower level C malloc/free
  106113             :    function calls for performance and to make sure that mixing of malloc/free
  106114             :    and new/delete by the used can be caught more readily.  This may change
  106115             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  106116             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  106117             :    deallocate memory allocated using ROSE_MALLOC.
  106118             : */
  106119          12 : void *SgOmpDoStatement::operator new ( size_t Size )
  106120             : {
  106121             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  106122             :      * returning or throwing an exception. */
  106123          12 :     ALLOC_MUTEX(SgOmpDoStatement, lock);
  106124             : 
  106125             : #if ROSE_ALLOC_TRACE == 2
  106126             : //    printf("SgOmpDoStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgOmpDoStatement::next_node);
  106127             : #endif
  106128             : 
  106129             : #if USE_CPP_NEW_DELETE_OPERATORS
  106130             :     void *mem = ROSE_MALLOC(Size);
  106131             :     ALLOC_MUTEX(SgOmpDoStatement, unlock);
  106132             :     return mem;
  106133             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  106134             : #if ROSE_PEDANTIC_ALLOC
  106135             :     ROSE_ASSERT(Size == sizeof(SgOmpDoStatement));
  106136             : #else
  106137          12 :     if (Size != sizeof(SgOmpDoStatement)) {
  106138           0 :       void * object = ROSE_MALLOC(Size);
  106139           0 :       ALLOC_MUTEX(SgOmpDoStatement, unlock);
  106140             :       return object;
  106141             :     }
  106142             : #endif
  106143             : 
  106144          12 :     if (SgOmpDoStatement::next_node == nullptr) {
  106145           9 :         SgOmpDoStatement * alloc = (SgOmpDoStatement*) ROSE_MALLOC ( SgOmpDoStatement::pool_size * sizeof(SgOmpDoStatement) );
  106146           9 :         ROSE_ASSERT(alloc != nullptr);
  106147             : 
  106148             : #if ROSE_ALLOC_TRACE == 2
  106149             : //        printf("SgOmpDoStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgOmpDoStatement::pools.size(), alloc, alloc + SgOmpDoStatement::pool_size);
  106150             : #endif
  106151             : 
  106152             : #if ROSE_ALLOC_MEMSET == 1
  106153             : #elif ROSE_ALLOC_MEMSET == 2
  106154             :         memset(alloc, 0x00, SgOmpDoStatement::pool_size * sizeof(SgOmpDoStatement));
  106155             : #elif ROSE_ALLOC_MEMSET == 3
  106156             :         memset(alloc, 0xAA, SgOmpDoStatement::pool_size * sizeof(SgOmpDoStatement));
  106157             : #endif
  106158       18000 :         for (unsigned i=0; i < SgOmpDoStatement::pool_size-1; i++) {
  106159       17991 :           alloc[i].p_freepointer = &(alloc[i+1]);
  106160             :         }
  106161           9 :         alloc[SgOmpDoStatement::pool_size-1].p_freepointer = nullptr;
  106162             : 
  106163           9 :         SgOmpDoStatement::pools.push_back ( (unsigned char *) alloc );
  106164           9 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgOmpDoStatement::pool_size * sizeof(SgOmpDoStatement), V_SgOmpDoStatement ) );
  106165           9 :         SgOmpDoStatement::next_node = alloc;
  106166             :     }
  106167          12 :     ROSE_ASSERT(SgOmpDoStatement::next_node != nullptr);
  106168             : 
  106169          12 :     SgOmpDoStatement * object = SgOmpDoStatement::next_node;
  106170          12 :     SgOmpDoStatement::next_node = (SgOmpDoStatement*)(object->p_freepointer);
  106171             : 
  106172             : #if ROSE_ALLOC_TRACE == 2
  106173             :     printf("SgOmpDoStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpDoStatement::next_node);
  106174             : #endif
  106175             : 
  106176          12 :     SgNode * fp = object->p_freepointer;
  106177             : #if ROSE_ALLOC_MEMSET == 1
  106178             : #elif ROSE_ALLOC_MEMSET == 2
  106179             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpDoStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  106180             : #elif ROSE_ALLOC_MEMSET == 3
  106181             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgOmpDoStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  106182             : #endif
  106183          12 :     object->p_freepointer = fp;
  106184             : 
  106185             : #if ROSE_ALLOC_TRACE == 2
  106186             : //    printf("SgOmpDoStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpDoStatement::next_node);
  106187             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  106188             :     Rose::MemPool::snapshot(oss.str());
  106189             :     alloc_trace_cnt++;
  106190             : #endif
  106191             : 
  106192          12 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  106193             : 
  106194          12 :     ALLOC_MUTEX(SgOmpDoStatement, unlock);
  106195             : 
  106196             :     return object;
  106197             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  106198             : }
  106199             : 
  106200             : 
  106201             : 
  106202             : /*! \brief Delete operator for SgOmpDoStatement.
  106203             : 
  106204             :    This delete operator implements deallocation using memory pools to 
  106205             :    provide most efficent use of the heap within construction of large ASTs.
  106206             : 
  106207             : \internal The new and delete operators use the lower level C malloc/free
  106208             :    function calls for performance and to make sure that mixing of malloc/free
  106209             :    and new/delete by the used can be caught more readily.  This may change
  106210             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  106211             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  106212             :    deallocate memory allocated using ROSE_MALLOC.
  106213             : */
  106214           0 : void SgOmpDoStatement::operator delete(void *Pointer, size_t Size)
  106215             : {
  106216             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  106217             :      * or throwing an exception. */
  106218           0 :     ALLOC_MUTEX(SgOmpDoStatement, lock);
  106219             : 
  106220             : #if USE_CPP_NEW_DELETE_OPERATORS
  106221             :     ROSE_FREE(Pointer);
  106222             : #else
  106223             : #if ROSE_PEDANTIC_ALLOC
  106224             :     ROSE_ASSERT(Size == sizeof(SgOmpDoStatement));
  106225             : #else
  106226           0 :     if (Size != sizeof(SgOmpDoStatement)) {
  106227           0 :       ROSE_FREE(Pointer);
  106228           0 :       ALLOC_MUTEX(SgOmpDoStatement, unlock);
  106229             :       return;
  106230             :     }
  106231             : #endif
  106232             : 
  106233           0 :     SgOmpDoStatement * object = (SgOmpDoStatement*) Pointer;
  106234           0 :     ROSE_ASSERT(object != nullptr);
  106235             : 
  106236             : #if ROSE_ALLOC_TRACE == 2
  106237             : //  printf("SgOmpDoStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpDoStatement::next_node);
  106238             :     printf("SgOmpDoStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpDoStatement::next_node);
  106239             : #endif
  106240             : 
  106241             : #if ROSE_PEDANTIC_ALLOC
  106242             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  106243             : #endif
  106244             : 
  106245             : #if ROSE_ALLOC_MEMSET == 1
  106246             : #elif ROSE_ALLOC_MEMSET == 2
  106247             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpDoStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  106248             : #elif ROSE_ALLOC_MEMSET == 3
  106249             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgOmpDoStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  106250             : #endif
  106251             : 
  106252             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  106253             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  106254             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  106255             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  106256             : #else
  106257           0 :     object->p_freepointer = SgOmpDoStatement::next_node;
  106258           0 :     SgOmpDoStatement::next_node = object;
  106259             : #endif
  106260             : 
  106261             : #if ROSE_ALLOC_TRACE == 2
  106262             : //  printf("SgOmpDoStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpDoStatement::next_node);
  106263             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  106264             :     Rose::MemPool::snapshot(oss.str());
  106265             :     alloc_trace_cnt++;
  106266             : #endif
  106267             : 
  106268             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  106269             : 
  106270           0 :     ALLOC_MUTEX(SgOmpDoStatement, unlock);
  106271             : }
  106272             : 
  106273             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  106274             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  106275             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  106276             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  106277             : // Also, note comment below from Robb (copied from the Common.code file).
  106278             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  106279             : //
  106280             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  106281             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  106282             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  106283             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  106284             : #if 0
  106285             : void SgOmpDoStatement::operator delete(void* pointer) { SgOmpDoStatement::operator delete (pointer, sizeof(SgOmpDoStatement)); };
  106286             : #endif
  106287             : /* #line 106288 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  106288             : 
  106289             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  106290             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  106291             : // obviously imply C++.
  106292             : 
  106293             : // This implements the support within ROSE for memory pools.  Memory pools
  106294             : // support the most condensed usage of memory within the construction of
  106295             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  106296             : // by a new operator written for each class.
  106297             : 
  106298             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  106299             :     // User wants multi-thread support and POSIX threads are available.
  106300             : #   include <pthread.h>
  106301             :     static pthread_mutex_t SgOmpSectionsStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  106302             : #else
  106303             :      // Cause synchronization to be skipped.
  106304             : #    ifndef ALLOC_MUTEX
  106305             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  106306             : #    endif
  106307             : #    ifdef _REENTRANT
  106308             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  106309             : #       ifdef _MSC_VER
  106310             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  106311             : #       else
  106312             : #           warning "POSIX threads are not available; synchronization being skipped"
  106313             : #       endif
  106314             : #    endif
  106315             : #endif
  106316             : 
  106317             : #ifndef ROSE_ALLOC_TRACE
  106318             : #  define ROSE_ALLOC_TRACE 0
  106319             : #endif
  106320             : 
  106321             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  106322             : #define ROSE_ALLOC_TRACE_CNT
  106323             : #include "memory-pool-snapshot.h"
  106324             : unsigned long alloc_trace_cnt = 0;
  106325             : #endif
  106326             : 
  106327             : #if ROSE_ALLOC_TRACE
  106328             : const unsigned SgOmpSectionsStatement::pool_size = 5;
  106329             : #else
  106330             : const unsigned SgOmpSectionsStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  106331             : #endif
  106332             : 
  106333             : #ifndef ROSE_ALLOC_MEMSET
  106334             : #  define ROSE_ALLOC_MEMSET 0
  106335             : #endif
  106336             : 
  106337             : #ifndef ROSE_PEDANTIC_ALLOC
  106338             : #  define ROSE_PEDANTIC_ALLOC 0
  106339             : #endif
  106340             : 
  106341             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  106342             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  106343             : #endif
  106344             : 
  106345             : #if !defined(SGNODE__ALL_POOLS)
  106346             : #define SGNODE__ALL_POOLS
  106347             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  106348             : #endif
  106349             : 
  106350             : SgOmpSectionsStatement* SgOmpSectionsStatement::next_node = nullptr;
  106351             : std::vector<unsigned char*> SgOmpSectionsStatement::pools;
  106352             : 
  106353             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  106354             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  106355             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  106356             : // around this macro definition rather than each use).
  106357             : #ifndef ALLOC_MUTEX
  106358             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  106359             :         do {                                                                     \
  106360             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  106361             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  106362             :                 abort();                                                         \
  106363             :             }                                                                    \
  106364             :         } while (0);
  106365             : #endif
  106366             : 
  106367             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  106368             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  106369             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  106370             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  106371             : 
  106372             : /*! \brief New operator for SgOmpSectionsStatement.
  106373             : 
  106374             :    This new operator implements memory pools to provide most efficent 
  106375             :    use of the heap within construction of large ASTs.
  106376             : 
  106377             : \internal The new and delete operators use the lower level C malloc/free
  106378             :    function calls for performance and to make sure that mixing of malloc/free
  106379             :    and new/delete by the used can be caught more readily.  This may change
  106380             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  106381             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  106382             :    deallocate memory allocated using ROSE_MALLOC.
  106383             : */
  106384          11 : void *SgOmpSectionsStatement::operator new ( size_t Size )
  106385             : {
  106386             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  106387             :      * returning or throwing an exception. */
  106388          11 :     ALLOC_MUTEX(SgOmpSectionsStatement, lock);
  106389             : 
  106390             : #if ROSE_ALLOC_TRACE == 2
  106391             : //    printf("SgOmpSectionsStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgOmpSectionsStatement::next_node);
  106392             : #endif
  106393             : 
  106394             : #if USE_CPP_NEW_DELETE_OPERATORS
  106395             :     void *mem = ROSE_MALLOC(Size);
  106396             :     ALLOC_MUTEX(SgOmpSectionsStatement, unlock);
  106397             :     return mem;
  106398             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  106399             : #if ROSE_PEDANTIC_ALLOC
  106400             :     ROSE_ASSERT(Size == sizeof(SgOmpSectionsStatement));
  106401             : #else
  106402          11 :     if (Size != sizeof(SgOmpSectionsStatement)) {
  106403           0 :       void * object = ROSE_MALLOC(Size);
  106404           0 :       ALLOC_MUTEX(SgOmpSectionsStatement, unlock);
  106405             :       return object;
  106406             :     }
  106407             : #endif
  106408             : 
  106409          11 :     if (SgOmpSectionsStatement::next_node == nullptr) {
  106410           9 :         SgOmpSectionsStatement * alloc = (SgOmpSectionsStatement*) ROSE_MALLOC ( SgOmpSectionsStatement::pool_size * sizeof(SgOmpSectionsStatement) );
  106411           9 :         ROSE_ASSERT(alloc != nullptr);
  106412             : 
  106413             : #if ROSE_ALLOC_TRACE == 2
  106414             : //        printf("SgOmpSectionsStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgOmpSectionsStatement::pools.size(), alloc, alloc + SgOmpSectionsStatement::pool_size);
  106415             : #endif
  106416             : 
  106417             : #if ROSE_ALLOC_MEMSET == 1
  106418             : #elif ROSE_ALLOC_MEMSET == 2
  106419             :         memset(alloc, 0x00, SgOmpSectionsStatement::pool_size * sizeof(SgOmpSectionsStatement));
  106420             : #elif ROSE_ALLOC_MEMSET == 3
  106421             :         memset(alloc, 0xAA, SgOmpSectionsStatement::pool_size * sizeof(SgOmpSectionsStatement));
  106422             : #endif
  106423       18000 :         for (unsigned i=0; i < SgOmpSectionsStatement::pool_size-1; i++) {
  106424       17991 :           alloc[i].p_freepointer = &(alloc[i+1]);
  106425             :         }
  106426           9 :         alloc[SgOmpSectionsStatement::pool_size-1].p_freepointer = nullptr;
  106427             : 
  106428           9 :         SgOmpSectionsStatement::pools.push_back ( (unsigned char *) alloc );
  106429           9 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgOmpSectionsStatement::pool_size * sizeof(SgOmpSectionsStatement), V_SgOmpSectionsStatement ) );
  106430           9 :         SgOmpSectionsStatement::next_node = alloc;
  106431             :     }
  106432          11 :     ROSE_ASSERT(SgOmpSectionsStatement::next_node != nullptr);
  106433             : 
  106434          11 :     SgOmpSectionsStatement * object = SgOmpSectionsStatement::next_node;
  106435          11 :     SgOmpSectionsStatement::next_node = (SgOmpSectionsStatement*)(object->p_freepointer);
  106436             : 
  106437             : #if ROSE_ALLOC_TRACE == 2
  106438             :     printf("SgOmpSectionsStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpSectionsStatement::next_node);
  106439             : #endif
  106440             : 
  106441          11 :     SgNode * fp = object->p_freepointer;
  106442             : #if ROSE_ALLOC_MEMSET == 1
  106443             : #elif ROSE_ALLOC_MEMSET == 2
  106444             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpSectionsStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  106445             : #elif ROSE_ALLOC_MEMSET == 3
  106446             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgOmpSectionsStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  106447             : #endif
  106448          11 :     object->p_freepointer = fp;
  106449             : 
  106450             : #if ROSE_ALLOC_TRACE == 2
  106451             : //    printf("SgOmpSectionsStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpSectionsStatement::next_node);
  106452             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  106453             :     Rose::MemPool::snapshot(oss.str());
  106454             :     alloc_trace_cnt++;
  106455             : #endif
  106456             : 
  106457          11 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  106458             : 
  106459          11 :     ALLOC_MUTEX(SgOmpSectionsStatement, unlock);
  106460             : 
  106461             :     return object;
  106462             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  106463             : }
  106464             : 
  106465             : 
  106466             : 
  106467             : /*! \brief Delete operator for SgOmpSectionsStatement.
  106468             : 
  106469             :    This delete operator implements deallocation using memory pools to 
  106470             :    provide most efficent use of the heap within construction of large ASTs.
  106471             : 
  106472             : \internal The new and delete operators use the lower level C malloc/free
  106473             :    function calls for performance and to make sure that mixing of malloc/free
  106474             :    and new/delete by the used can be caught more readily.  This may change
  106475             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  106476             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  106477             :    deallocate memory allocated using ROSE_MALLOC.
  106478             : */
  106479           0 : void SgOmpSectionsStatement::operator delete(void *Pointer, size_t Size)
  106480             : {
  106481             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  106482             :      * or throwing an exception. */
  106483           0 :     ALLOC_MUTEX(SgOmpSectionsStatement, lock);
  106484             : 
  106485             : #if USE_CPP_NEW_DELETE_OPERATORS
  106486             :     ROSE_FREE(Pointer);
  106487             : #else
  106488             : #if ROSE_PEDANTIC_ALLOC
  106489             :     ROSE_ASSERT(Size == sizeof(SgOmpSectionsStatement));
  106490             : #else
  106491           0 :     if (Size != sizeof(SgOmpSectionsStatement)) {
  106492           0 :       ROSE_FREE(Pointer);
  106493           0 :       ALLOC_MUTEX(SgOmpSectionsStatement, unlock);
  106494             :       return;
  106495             :     }
  106496             : #endif
  106497             : 
  106498           0 :     SgOmpSectionsStatement * object = (SgOmpSectionsStatement*) Pointer;
  106499           0 :     ROSE_ASSERT(object != nullptr);
  106500             : 
  106501             : #if ROSE_ALLOC_TRACE == 2
  106502             : //  printf("SgOmpSectionsStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpSectionsStatement::next_node);
  106503             :     printf("SgOmpSectionsStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpSectionsStatement::next_node);
  106504             : #endif
  106505             : 
  106506             : #if ROSE_PEDANTIC_ALLOC
  106507             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  106508             : #endif
  106509             : 
  106510             : #if ROSE_ALLOC_MEMSET == 1
  106511             : #elif ROSE_ALLOC_MEMSET == 2
  106512             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpSectionsStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  106513             : #elif ROSE_ALLOC_MEMSET == 3
  106514             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgOmpSectionsStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  106515             : #endif
  106516             : 
  106517             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  106518             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  106519             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  106520             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  106521             : #else
  106522           0 :     object->p_freepointer = SgOmpSectionsStatement::next_node;
  106523           0 :     SgOmpSectionsStatement::next_node = object;
  106524             : #endif
  106525             : 
  106526             : #if ROSE_ALLOC_TRACE == 2
  106527             : //  printf("SgOmpSectionsStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpSectionsStatement::next_node);
  106528             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  106529             :     Rose::MemPool::snapshot(oss.str());
  106530             :     alloc_trace_cnt++;
  106531             : #endif
  106532             : 
  106533             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  106534             : 
  106535           0 :     ALLOC_MUTEX(SgOmpSectionsStatement, unlock);
  106536             : }
  106537             : 
  106538             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  106539             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  106540             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  106541             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  106542             : // Also, note comment below from Robb (copied from the Common.code file).
  106543             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  106544             : //
  106545             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  106546             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  106547             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  106548             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  106549             : #if 0
  106550             : void SgOmpSectionsStatement::operator delete(void* pointer) { SgOmpSectionsStatement::operator delete (pointer, sizeof(SgOmpSectionsStatement)); };
  106551             : #endif
  106552             : /* #line 106553 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  106553             : 
  106554             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  106555             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  106556             : // obviously imply C++.
  106557             : 
  106558             : // This implements the support within ROSE for memory pools.  Memory pools
  106559             : // support the most condensed usage of memory within the construction of
  106560             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  106561             : // by a new operator written for each class.
  106562             : 
  106563             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  106564             :     // User wants multi-thread support and POSIX threads are available.
  106565             : #   include <pthread.h>
  106566             :     static pthread_mutex_t SgUpirTaskStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  106567             : #else
  106568             :      // Cause synchronization to be skipped.
  106569             : #    ifndef ALLOC_MUTEX
  106570             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  106571             : #    endif
  106572             : #    ifdef _REENTRANT
  106573             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  106574             : #       ifdef _MSC_VER
  106575             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  106576             : #       else
  106577             : #           warning "POSIX threads are not available; synchronization being skipped"
  106578             : #       endif
  106579             : #    endif
  106580             : #endif
  106581             : 
  106582             : #ifndef ROSE_ALLOC_TRACE
  106583             : #  define ROSE_ALLOC_TRACE 0
  106584             : #endif
  106585             : 
  106586             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  106587             : #define ROSE_ALLOC_TRACE_CNT
  106588             : #include "memory-pool-snapshot.h"
  106589             : unsigned long alloc_trace_cnt = 0;
  106590             : #endif
  106591             : 
  106592             : #if ROSE_ALLOC_TRACE
  106593             : const unsigned SgUpirTaskStatement::pool_size = 5;
  106594             : #else
  106595             : const unsigned SgUpirTaskStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  106596             : #endif
  106597             : 
  106598             : #ifndef ROSE_ALLOC_MEMSET
  106599             : #  define ROSE_ALLOC_MEMSET 0
  106600             : #endif
  106601             : 
  106602             : #ifndef ROSE_PEDANTIC_ALLOC
  106603             : #  define ROSE_PEDANTIC_ALLOC 0
  106604             : #endif
  106605             : 
  106606             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  106607             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  106608             : #endif
  106609             : 
  106610             : #if !defined(SGNODE__ALL_POOLS)
  106611             : #define SGNODE__ALL_POOLS
  106612             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  106613             : #endif
  106614             : 
  106615             : SgUpirTaskStatement* SgUpirTaskStatement::next_node = nullptr;
  106616             : std::vector<unsigned char*> SgUpirTaskStatement::pools;
  106617             : 
  106618             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  106619             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  106620             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  106621             : // around this macro definition rather than each use).
  106622             : #ifndef ALLOC_MUTEX
  106623             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  106624             :         do {                                                                     \
  106625             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  106626             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  106627             :                 abort();                                                         \
  106628             :             }                                                                    \
  106629             :         } while (0);
  106630             : #endif
  106631             : 
  106632             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  106633             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  106634             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  106635             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  106636             : 
  106637             : /*! \brief New operator for SgUpirTaskStatement.
  106638             : 
  106639             :    This new operator implements memory pools to provide most efficent 
  106640             :    use of the heap within construction of large ASTs.
  106641             : 
  106642             : \internal The new and delete operators use the lower level C malloc/free
  106643             :    function calls for performance and to make sure that mixing of malloc/free
  106644             :    and new/delete by the used can be caught more readily.  This may change
  106645             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  106646             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  106647             :    deallocate memory allocated using ROSE_MALLOC.
  106648             : */
  106649          24 : void *SgUpirTaskStatement::operator new ( size_t Size )
  106650             : {
  106651             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  106652             :      * returning or throwing an exception. */
  106653          24 :     ALLOC_MUTEX(SgUpirTaskStatement, lock);
  106654             : 
  106655             : #if ROSE_ALLOC_TRACE == 2
  106656             : //    printf("SgUpirTaskStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgUpirTaskStatement::next_node);
  106657             : #endif
  106658             : 
  106659             : #if USE_CPP_NEW_DELETE_OPERATORS
  106660             :     void *mem = ROSE_MALLOC(Size);
  106661             :     ALLOC_MUTEX(SgUpirTaskStatement, unlock);
  106662             :     return mem;
  106663             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  106664             : #if ROSE_PEDANTIC_ALLOC
  106665             :     ROSE_ASSERT(Size == sizeof(SgUpirTaskStatement));
  106666             : #else
  106667          24 :     if (Size != sizeof(SgUpirTaskStatement)) {
  106668           0 :       void * object = ROSE_MALLOC(Size);
  106669           0 :       ALLOC_MUTEX(SgUpirTaskStatement, unlock);
  106670             :       return object;
  106671             :     }
  106672             : #endif
  106673             : 
  106674          24 :     if (SgUpirTaskStatement::next_node == nullptr) {
  106675          17 :         SgUpirTaskStatement * alloc = (SgUpirTaskStatement*) ROSE_MALLOC ( SgUpirTaskStatement::pool_size * sizeof(SgUpirTaskStatement) );
  106676          17 :         ROSE_ASSERT(alloc != nullptr);
  106677             : 
  106678             : #if ROSE_ALLOC_TRACE == 2
  106679             : //        printf("SgUpirTaskStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgUpirTaskStatement::pools.size(), alloc, alloc + SgUpirTaskStatement::pool_size);
  106680             : #endif
  106681             : 
  106682             : #if ROSE_ALLOC_MEMSET == 1
  106683             : #elif ROSE_ALLOC_MEMSET == 2
  106684             :         memset(alloc, 0x00, SgUpirTaskStatement::pool_size * sizeof(SgUpirTaskStatement));
  106685             : #elif ROSE_ALLOC_MEMSET == 3
  106686             :         memset(alloc, 0xAA, SgUpirTaskStatement::pool_size * sizeof(SgUpirTaskStatement));
  106687             : #endif
  106688       34000 :         for (unsigned i=0; i < SgUpirTaskStatement::pool_size-1; i++) {
  106689       33983 :           alloc[i].p_freepointer = &(alloc[i+1]);
  106690             :         }
  106691          17 :         alloc[SgUpirTaskStatement::pool_size-1].p_freepointer = nullptr;
  106692             : 
  106693          17 :         SgUpirTaskStatement::pools.push_back ( (unsigned char *) alloc );
  106694          17 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgUpirTaskStatement::pool_size * sizeof(SgUpirTaskStatement), V_SgUpirTaskStatement ) );
  106695          17 :         SgUpirTaskStatement::next_node = alloc;
  106696             :     }
  106697          24 :     ROSE_ASSERT(SgUpirTaskStatement::next_node != nullptr);
  106698             : 
  106699          24 :     SgUpirTaskStatement * object = SgUpirTaskStatement::next_node;
  106700          24 :     SgUpirTaskStatement::next_node = (SgUpirTaskStatement*)(object->p_freepointer);
  106701             : 
  106702             : #if ROSE_ALLOC_TRACE == 2
  106703             :     printf("SgUpirTaskStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUpirTaskStatement::next_node);
  106704             : #endif
  106705             : 
  106706          24 :     SgNode * fp = object->p_freepointer;
  106707             : #if ROSE_ALLOC_MEMSET == 1
  106708             : #elif ROSE_ALLOC_MEMSET == 2
  106709             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgUpirTaskStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  106710             : #elif ROSE_ALLOC_MEMSET == 3
  106711             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgUpirTaskStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  106712             : #endif
  106713          24 :     object->p_freepointer = fp;
  106714             : 
  106715             : #if ROSE_ALLOC_TRACE == 2
  106716             : //    printf("SgUpirTaskStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUpirTaskStatement::next_node);
  106717             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  106718             :     Rose::MemPool::snapshot(oss.str());
  106719             :     alloc_trace_cnt++;
  106720             : #endif
  106721             : 
  106722          24 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  106723             : 
  106724          24 :     ALLOC_MUTEX(SgUpirTaskStatement, unlock);
  106725             : 
  106726             :     return object;
  106727             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  106728             : }
  106729             : 
  106730             : 
  106731             : 
  106732             : /*! \brief Delete operator for SgUpirTaskStatement.
  106733             : 
  106734             :    This delete operator implements deallocation using memory pools to 
  106735             :    provide most efficent use of the heap within construction of large ASTs.
  106736             : 
  106737             : \internal The new and delete operators use the lower level C malloc/free
  106738             :    function calls for performance and to make sure that mixing of malloc/free
  106739             :    and new/delete by the used can be caught more readily.  This may change
  106740             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  106741             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  106742             :    deallocate memory allocated using ROSE_MALLOC.
  106743             : */
  106744           0 : void SgUpirTaskStatement::operator delete(void *Pointer, size_t Size)
  106745             : {
  106746             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  106747             :      * or throwing an exception. */
  106748           0 :     ALLOC_MUTEX(SgUpirTaskStatement, lock);
  106749             : 
  106750             : #if USE_CPP_NEW_DELETE_OPERATORS
  106751             :     ROSE_FREE(Pointer);
  106752             : #else
  106753             : #if ROSE_PEDANTIC_ALLOC
  106754             :     ROSE_ASSERT(Size == sizeof(SgUpirTaskStatement));
  106755             : #else
  106756           0 :     if (Size != sizeof(SgUpirTaskStatement)) {
  106757           0 :       ROSE_FREE(Pointer);
  106758           0 :       ALLOC_MUTEX(SgUpirTaskStatement, unlock);
  106759             :       return;
  106760             :     }
  106761             : #endif
  106762             : 
  106763           0 :     SgUpirTaskStatement * object = (SgUpirTaskStatement*) Pointer;
  106764           0 :     ROSE_ASSERT(object != nullptr);
  106765             : 
  106766             : #if ROSE_ALLOC_TRACE == 2
  106767             : //  printf("SgUpirTaskStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUpirTaskStatement::next_node);
  106768             :     printf("SgUpirTaskStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUpirTaskStatement::next_node);
  106769             : #endif
  106770             : 
  106771             : #if ROSE_PEDANTIC_ALLOC
  106772             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  106773             : #endif
  106774             : 
  106775             : #if ROSE_ALLOC_MEMSET == 1
  106776             : #elif ROSE_ALLOC_MEMSET == 2
  106777             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgUpirTaskStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  106778             : #elif ROSE_ALLOC_MEMSET == 3
  106779             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgUpirTaskStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  106780             : #endif
  106781             : 
  106782             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  106783             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  106784             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  106785             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  106786             : #else
  106787           0 :     object->p_freepointer = SgUpirTaskStatement::next_node;
  106788           0 :     SgUpirTaskStatement::next_node = object;
  106789             : #endif
  106790             : 
  106791             : #if ROSE_ALLOC_TRACE == 2
  106792             : //  printf("SgUpirTaskStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUpirTaskStatement::next_node);
  106793             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  106794             :     Rose::MemPool::snapshot(oss.str());
  106795             :     alloc_trace_cnt++;
  106796             : #endif
  106797             : 
  106798             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  106799             : 
  106800           0 :     ALLOC_MUTEX(SgUpirTaskStatement, unlock);
  106801             : }
  106802             : 
  106803             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  106804             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  106805             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  106806             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  106807             : // Also, note comment below from Robb (copied from the Common.code file).
  106808             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  106809             : //
  106810             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  106811             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  106812             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  106813             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  106814             : #if 0
  106815             : void SgUpirTaskStatement::operator delete(void* pointer) { SgUpirTaskStatement::operator delete (pointer, sizeof(SgUpirTaskStatement)); };
  106816             : #endif
  106817             : /* #line 106818 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  106818             : 
  106819             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  106820             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  106821             : // obviously imply C++.
  106822             : 
  106823             : // This implements the support within ROSE for memory pools.  Memory pools
  106824             : // support the most condensed usage of memory within the construction of
  106825             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  106826             : // by a new operator written for each class.
  106827             : 
  106828             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  106829             :     // User wants multi-thread support and POSIX threads are available.
  106830             : #   include <pthread.h>
  106831             :     static pthread_mutex_t SgOmpTargetDataStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  106832             : #else
  106833             :      // Cause synchronization to be skipped.
  106834             : #    ifndef ALLOC_MUTEX
  106835             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  106836             : #    endif
  106837             : #    ifdef _REENTRANT
  106838             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  106839             : #       ifdef _MSC_VER
  106840             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  106841             : #       else
  106842             : #           warning "POSIX threads are not available; synchronization being skipped"
  106843             : #       endif
  106844             : #    endif
  106845             : #endif
  106846             : 
  106847             : #ifndef ROSE_ALLOC_TRACE
  106848             : #  define ROSE_ALLOC_TRACE 0
  106849             : #endif
  106850             : 
  106851             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  106852             : #define ROSE_ALLOC_TRACE_CNT
  106853             : #include "memory-pool-snapshot.h"
  106854             : unsigned long alloc_trace_cnt = 0;
  106855             : #endif
  106856             : 
  106857             : #if ROSE_ALLOC_TRACE
  106858             : const unsigned SgOmpTargetDataStatement::pool_size = 5;
  106859             : #else
  106860             : const unsigned SgOmpTargetDataStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  106861             : #endif
  106862             : 
  106863             : #ifndef ROSE_ALLOC_MEMSET
  106864             : #  define ROSE_ALLOC_MEMSET 0
  106865             : #endif
  106866             : 
  106867             : #ifndef ROSE_PEDANTIC_ALLOC
  106868             : #  define ROSE_PEDANTIC_ALLOC 0
  106869             : #endif
  106870             : 
  106871             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  106872             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  106873             : #endif
  106874             : 
  106875             : #if !defined(SGNODE__ALL_POOLS)
  106876             : #define SGNODE__ALL_POOLS
  106877             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  106878             : #endif
  106879             : 
  106880             : SgOmpTargetDataStatement* SgOmpTargetDataStatement::next_node = nullptr;
  106881             : std::vector<unsigned char*> SgOmpTargetDataStatement::pools;
  106882             : 
  106883             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  106884             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  106885             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  106886             : // around this macro definition rather than each use).
  106887             : #ifndef ALLOC_MUTEX
  106888             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  106889             :         do {                                                                     \
  106890             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  106891             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  106892             :                 abort();                                                         \
  106893             :             }                                                                    \
  106894             :         } while (0);
  106895             : #endif
  106896             : 
  106897             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  106898             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  106899             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  106900             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  106901             : 
  106902             : /*! \brief New operator for SgOmpTargetDataStatement.
  106903             : 
  106904             :    This new operator implements memory pools to provide most efficent 
  106905             :    use of the heap within construction of large ASTs.
  106906             : 
  106907             : \internal The new and delete operators use the lower level C malloc/free
  106908             :    function calls for performance and to make sure that mixing of malloc/free
  106909             :    and new/delete by the used can be caught more readily.  This may change
  106910             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  106911             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  106912             :    deallocate memory allocated using ROSE_MALLOC.
  106913             : */
  106914           7 : void *SgOmpTargetDataStatement::operator new ( size_t Size )
  106915             : {
  106916             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  106917             :      * returning or throwing an exception. */
  106918           7 :     ALLOC_MUTEX(SgOmpTargetDataStatement, lock);
  106919             : 
  106920             : #if ROSE_ALLOC_TRACE == 2
  106921             : //    printf("SgOmpTargetDataStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgOmpTargetDataStatement::next_node);
  106922             : #endif
  106923             : 
  106924             : #if USE_CPP_NEW_DELETE_OPERATORS
  106925             :     void *mem = ROSE_MALLOC(Size);
  106926             :     ALLOC_MUTEX(SgOmpTargetDataStatement, unlock);
  106927             :     return mem;
  106928             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  106929             : #if ROSE_PEDANTIC_ALLOC
  106930             :     ROSE_ASSERT(Size == sizeof(SgOmpTargetDataStatement));
  106931             : #else
  106932           7 :     if (Size != sizeof(SgOmpTargetDataStatement)) {
  106933           0 :       void * object = ROSE_MALLOC(Size);
  106934           0 :       ALLOC_MUTEX(SgOmpTargetDataStatement, unlock);
  106935             :       return object;
  106936             :     }
  106937             : #endif
  106938             : 
  106939           7 :     if (SgOmpTargetDataStatement::next_node == nullptr) {
  106940           7 :         SgOmpTargetDataStatement * alloc = (SgOmpTargetDataStatement*) ROSE_MALLOC ( SgOmpTargetDataStatement::pool_size * sizeof(SgOmpTargetDataStatement) );
  106941           7 :         ROSE_ASSERT(alloc != nullptr);
  106942             : 
  106943             : #if ROSE_ALLOC_TRACE == 2
  106944             : //        printf("SgOmpTargetDataStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgOmpTargetDataStatement::pools.size(), alloc, alloc + SgOmpTargetDataStatement::pool_size);
  106945             : #endif
  106946             : 
  106947             : #if ROSE_ALLOC_MEMSET == 1
  106948             : #elif ROSE_ALLOC_MEMSET == 2
  106949             :         memset(alloc, 0x00, SgOmpTargetDataStatement::pool_size * sizeof(SgOmpTargetDataStatement));
  106950             : #elif ROSE_ALLOC_MEMSET == 3
  106951             :         memset(alloc, 0xAA, SgOmpTargetDataStatement::pool_size * sizeof(SgOmpTargetDataStatement));
  106952             : #endif
  106953       14000 :         for (unsigned i=0; i < SgOmpTargetDataStatement::pool_size-1; i++) {
  106954       13993 :           alloc[i].p_freepointer = &(alloc[i+1]);
  106955             :         }
  106956           7 :         alloc[SgOmpTargetDataStatement::pool_size-1].p_freepointer = nullptr;
  106957             : 
  106958           7 :         SgOmpTargetDataStatement::pools.push_back ( (unsigned char *) alloc );
  106959           7 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgOmpTargetDataStatement::pool_size * sizeof(SgOmpTargetDataStatement), V_SgOmpTargetDataStatement ) );
  106960           7 :         SgOmpTargetDataStatement::next_node = alloc;
  106961             :     }
  106962           7 :     ROSE_ASSERT(SgOmpTargetDataStatement::next_node != nullptr);
  106963             : 
  106964           7 :     SgOmpTargetDataStatement * object = SgOmpTargetDataStatement::next_node;
  106965           7 :     SgOmpTargetDataStatement::next_node = (SgOmpTargetDataStatement*)(object->p_freepointer);
  106966             : 
  106967             : #if ROSE_ALLOC_TRACE == 2
  106968             :     printf("SgOmpTargetDataStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpTargetDataStatement::next_node);
  106969             : #endif
  106970             : 
  106971           7 :     SgNode * fp = object->p_freepointer;
  106972             : #if ROSE_ALLOC_MEMSET == 1
  106973             : #elif ROSE_ALLOC_MEMSET == 2
  106974             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpTargetDataStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  106975             : #elif ROSE_ALLOC_MEMSET == 3
  106976             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgOmpTargetDataStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  106977             : #endif
  106978           7 :     object->p_freepointer = fp;
  106979             : 
  106980             : #if ROSE_ALLOC_TRACE == 2
  106981             : //    printf("SgOmpTargetDataStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpTargetDataStatement::next_node);
  106982             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  106983             :     Rose::MemPool::snapshot(oss.str());
  106984             :     alloc_trace_cnt++;
  106985             : #endif
  106986             : 
  106987           7 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  106988             : 
  106989           7 :     ALLOC_MUTEX(SgOmpTargetDataStatement, unlock);
  106990             : 
  106991             :     return object;
  106992             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  106993             : }
  106994             : 
  106995             : 
  106996             : 
  106997             : /*! \brief Delete operator for SgOmpTargetDataStatement.
  106998             : 
  106999             :    This delete operator implements deallocation using memory pools to 
  107000             :    provide most efficent use of the heap within construction of large ASTs.
  107001             : 
  107002             : \internal The new and delete operators use the lower level C malloc/free
  107003             :    function calls for performance and to make sure that mixing of malloc/free
  107004             :    and new/delete by the used can be caught more readily.  This may change
  107005             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  107006             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  107007             :    deallocate memory allocated using ROSE_MALLOC.
  107008             : */
  107009           0 : void SgOmpTargetDataStatement::operator delete(void *Pointer, size_t Size)
  107010             : {
  107011             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  107012             :      * or throwing an exception. */
  107013           0 :     ALLOC_MUTEX(SgOmpTargetDataStatement, lock);
  107014             : 
  107015             : #if USE_CPP_NEW_DELETE_OPERATORS
  107016             :     ROSE_FREE(Pointer);
  107017             : #else
  107018             : #if ROSE_PEDANTIC_ALLOC
  107019             :     ROSE_ASSERT(Size == sizeof(SgOmpTargetDataStatement));
  107020             : #else
  107021           0 :     if (Size != sizeof(SgOmpTargetDataStatement)) {
  107022           0 :       ROSE_FREE(Pointer);
  107023           0 :       ALLOC_MUTEX(SgOmpTargetDataStatement, unlock);
  107024             :       return;
  107025             :     }
  107026             : #endif
  107027             : 
  107028           0 :     SgOmpTargetDataStatement * object = (SgOmpTargetDataStatement*) Pointer;
  107029           0 :     ROSE_ASSERT(object != nullptr);
  107030             : 
  107031             : #if ROSE_ALLOC_TRACE == 2
  107032             : //  printf("SgOmpTargetDataStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpTargetDataStatement::next_node);
  107033             :     printf("SgOmpTargetDataStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpTargetDataStatement::next_node);
  107034             : #endif
  107035             : 
  107036             : #if ROSE_PEDANTIC_ALLOC
  107037             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  107038             : #endif
  107039             : 
  107040             : #if ROSE_ALLOC_MEMSET == 1
  107041             : #elif ROSE_ALLOC_MEMSET == 2
  107042             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpTargetDataStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  107043             : #elif ROSE_ALLOC_MEMSET == 3
  107044             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgOmpTargetDataStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  107045             : #endif
  107046             : 
  107047             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  107048             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  107049             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  107050             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  107051             : #else
  107052           0 :     object->p_freepointer = SgOmpTargetDataStatement::next_node;
  107053           0 :     SgOmpTargetDataStatement::next_node = object;
  107054             : #endif
  107055             : 
  107056             : #if ROSE_ALLOC_TRACE == 2
  107057             : //  printf("SgOmpTargetDataStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpTargetDataStatement::next_node);
  107058             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  107059             :     Rose::MemPool::snapshot(oss.str());
  107060             :     alloc_trace_cnt++;
  107061             : #endif
  107062             : 
  107063             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  107064             : 
  107065           0 :     ALLOC_MUTEX(SgOmpTargetDataStatement, unlock);
  107066             : }
  107067             : 
  107068             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  107069             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  107070             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  107071             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  107072             : // Also, note comment below from Robb (copied from the Common.code file).
  107073             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  107074             : //
  107075             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  107076             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  107077             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  107078             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  107079             : #if 0
  107080             : void SgOmpTargetDataStatement::operator delete(void* pointer) { SgOmpTargetDataStatement::operator delete (pointer, sizeof(SgOmpTargetDataStatement)); };
  107081             : #endif
  107082             : /* #line 107083 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  107083             : 
  107084             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  107085             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  107086             : // obviously imply C++.
  107087             : 
  107088             : // This implements the support within ROSE for memory pools.  Memory pools
  107089             : // support the most condensed usage of memory within the construction of
  107090             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  107091             : // by a new operator written for each class.
  107092             : 
  107093             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  107094             :     // User wants multi-thread support and POSIX threads are available.
  107095             : #   include <pthread.h>
  107096             :     static pthread_mutex_t SgOmpTargetParallelForStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  107097             : #else
  107098             :      // Cause synchronization to be skipped.
  107099             : #    ifndef ALLOC_MUTEX
  107100             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  107101             : #    endif
  107102             : #    ifdef _REENTRANT
  107103             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  107104             : #       ifdef _MSC_VER
  107105             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  107106             : #       else
  107107             : #           warning "POSIX threads are not available; synchronization being skipped"
  107108             : #       endif
  107109             : #    endif
  107110             : #endif
  107111             : 
  107112             : #ifndef ROSE_ALLOC_TRACE
  107113             : #  define ROSE_ALLOC_TRACE 0
  107114             : #endif
  107115             : 
  107116             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  107117             : #define ROSE_ALLOC_TRACE_CNT
  107118             : #include "memory-pool-snapshot.h"
  107119             : unsigned long alloc_trace_cnt = 0;
  107120             : #endif
  107121             : 
  107122             : #if ROSE_ALLOC_TRACE
  107123             : const unsigned SgOmpTargetParallelForStatement::pool_size = 5;
  107124             : #else
  107125             : const unsigned SgOmpTargetParallelForStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  107126             : #endif
  107127             : 
  107128             : #ifndef ROSE_ALLOC_MEMSET
  107129             : #  define ROSE_ALLOC_MEMSET 0
  107130             : #endif
  107131             : 
  107132             : #ifndef ROSE_PEDANTIC_ALLOC
  107133             : #  define ROSE_PEDANTIC_ALLOC 0
  107134             : #endif
  107135             : 
  107136             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  107137             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  107138             : #endif
  107139             : 
  107140             : #if !defined(SGNODE__ALL_POOLS)
  107141             : #define SGNODE__ALL_POOLS
  107142             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  107143             : #endif
  107144             : 
  107145             : SgOmpTargetParallelForStatement* SgOmpTargetParallelForStatement::next_node = nullptr;
  107146             : std::vector<unsigned char*> SgOmpTargetParallelForStatement::pools;
  107147             : 
  107148             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  107149             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  107150             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  107151             : // around this macro definition rather than each use).
  107152             : #ifndef ALLOC_MUTEX
  107153             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  107154             :         do {                                                                     \
  107155             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  107156             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  107157             :                 abort();                                                         \
  107158             :             }                                                                    \
  107159             :         } while (0);
  107160             : #endif
  107161             : 
  107162             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  107163             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  107164             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  107165             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  107166             : 
  107167             : /*! \brief New operator for SgOmpTargetParallelForStatement.
  107168             : 
  107169             :    This new operator implements memory pools to provide most efficent 
  107170             :    use of the heap within construction of large ASTs.
  107171             : 
  107172             : \internal The new and delete operators use the lower level C malloc/free
  107173             :    function calls for performance and to make sure that mixing of malloc/free
  107174             :    and new/delete by the used can be caught more readily.  This may change
  107175             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  107176             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  107177             :    deallocate memory allocated using ROSE_MALLOC.
  107178             : */
  107179           0 : void *SgOmpTargetParallelForStatement::operator new ( size_t Size )
  107180             : {
  107181             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  107182             :      * returning or throwing an exception. */
  107183           0 :     ALLOC_MUTEX(SgOmpTargetParallelForStatement, lock);
  107184             : 
  107185             : #if ROSE_ALLOC_TRACE == 2
  107186             : //    printf("SgOmpTargetParallelForStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgOmpTargetParallelForStatement::next_node);
  107187             : #endif
  107188             : 
  107189             : #if USE_CPP_NEW_DELETE_OPERATORS
  107190             :     void *mem = ROSE_MALLOC(Size);
  107191             :     ALLOC_MUTEX(SgOmpTargetParallelForStatement, unlock);
  107192             :     return mem;
  107193             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  107194             : #if ROSE_PEDANTIC_ALLOC
  107195             :     ROSE_ASSERT(Size == sizeof(SgOmpTargetParallelForStatement));
  107196             : #else
  107197           0 :     if (Size != sizeof(SgOmpTargetParallelForStatement)) {
  107198           0 :       void * object = ROSE_MALLOC(Size);
  107199           0 :       ALLOC_MUTEX(SgOmpTargetParallelForStatement, unlock);
  107200             :       return object;
  107201             :     }
  107202             : #endif
  107203             : 
  107204           0 :     if (SgOmpTargetParallelForStatement::next_node == nullptr) {
  107205           0 :         SgOmpTargetParallelForStatement * alloc = (SgOmpTargetParallelForStatement*) ROSE_MALLOC ( SgOmpTargetParallelForStatement::pool_size * sizeof(SgOmpTargetParallelForStatement) );
  107206           0 :         ROSE_ASSERT(alloc != nullptr);
  107207             : 
  107208             : #if ROSE_ALLOC_TRACE == 2
  107209             : //        printf("SgOmpTargetParallelForStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgOmpTargetParallelForStatement::pools.size(), alloc, alloc + SgOmpTargetParallelForStatement::pool_size);
  107210             : #endif
  107211             : 
  107212             : #if ROSE_ALLOC_MEMSET == 1
  107213             : #elif ROSE_ALLOC_MEMSET == 2
  107214             :         memset(alloc, 0x00, SgOmpTargetParallelForStatement::pool_size * sizeof(SgOmpTargetParallelForStatement));
  107215             : #elif ROSE_ALLOC_MEMSET == 3
  107216             :         memset(alloc, 0xAA, SgOmpTargetParallelForStatement::pool_size * sizeof(SgOmpTargetParallelForStatement));
  107217             : #endif
  107218           0 :         for (unsigned i=0; i < SgOmpTargetParallelForStatement::pool_size-1; i++) {
  107219           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
  107220             :         }
  107221           0 :         alloc[SgOmpTargetParallelForStatement::pool_size-1].p_freepointer = nullptr;
  107222             : 
  107223           0 :         SgOmpTargetParallelForStatement::pools.push_back ( (unsigned char *) alloc );
  107224           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgOmpTargetParallelForStatement::pool_size * sizeof(SgOmpTargetParallelForStatement), V_SgOmpTargetParallelForStatement ) );
  107225           0 :         SgOmpTargetParallelForStatement::next_node = alloc;
  107226             :     }
  107227           0 :     ROSE_ASSERT(SgOmpTargetParallelForStatement::next_node != nullptr);
  107228             : 
  107229           0 :     SgOmpTargetParallelForStatement * object = SgOmpTargetParallelForStatement::next_node;
  107230           0 :     SgOmpTargetParallelForStatement::next_node = (SgOmpTargetParallelForStatement*)(object->p_freepointer);
  107231             : 
  107232             : #if ROSE_ALLOC_TRACE == 2
  107233             :     printf("SgOmpTargetParallelForStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpTargetParallelForStatement::next_node);
  107234             : #endif
  107235             : 
  107236           0 :     SgNode * fp = object->p_freepointer;
  107237             : #if ROSE_ALLOC_MEMSET == 1
  107238             : #elif ROSE_ALLOC_MEMSET == 2
  107239             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpTargetParallelForStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  107240             : #elif ROSE_ALLOC_MEMSET == 3
  107241             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgOmpTargetParallelForStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  107242             : #endif
  107243           0 :     object->p_freepointer = fp;
  107244             : 
  107245             : #if ROSE_ALLOC_TRACE == 2
  107246             : //    printf("SgOmpTargetParallelForStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpTargetParallelForStatement::next_node);
  107247             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  107248             :     Rose::MemPool::snapshot(oss.str());
  107249             :     alloc_trace_cnt++;
  107250             : #endif
  107251             : 
  107252           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  107253             : 
  107254           0 :     ALLOC_MUTEX(SgOmpTargetParallelForStatement, unlock);
  107255             : 
  107256             :     return object;
  107257             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  107258             : }
  107259             : 
  107260             : 
  107261             : 
  107262             : /*! \brief Delete operator for SgOmpTargetParallelForStatement.
  107263             : 
  107264             :    This delete operator implements deallocation using memory pools to 
  107265             :    provide most efficent use of the heap within construction of large ASTs.
  107266             : 
  107267             : \internal The new and delete operators use the lower level C malloc/free
  107268             :    function calls for performance and to make sure that mixing of malloc/free
  107269             :    and new/delete by the used can be caught more readily.  This may change
  107270             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  107271             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  107272             :    deallocate memory allocated using ROSE_MALLOC.
  107273             : */
  107274           0 : void SgOmpTargetParallelForStatement::operator delete(void *Pointer, size_t Size)
  107275             : {
  107276             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  107277             :      * or throwing an exception. */
  107278           0 :     ALLOC_MUTEX(SgOmpTargetParallelForStatement, lock);
  107279             : 
  107280             : #if USE_CPP_NEW_DELETE_OPERATORS
  107281             :     ROSE_FREE(Pointer);
  107282             : #else
  107283             : #if ROSE_PEDANTIC_ALLOC
  107284             :     ROSE_ASSERT(Size == sizeof(SgOmpTargetParallelForStatement));
  107285             : #else
  107286           0 :     if (Size != sizeof(SgOmpTargetParallelForStatement)) {
  107287           0 :       ROSE_FREE(Pointer);
  107288           0 :       ALLOC_MUTEX(SgOmpTargetParallelForStatement, unlock);
  107289             :       return;
  107290             :     }
  107291             : #endif
  107292             : 
  107293           0 :     SgOmpTargetParallelForStatement * object = (SgOmpTargetParallelForStatement*) Pointer;
  107294           0 :     ROSE_ASSERT(object != nullptr);
  107295             : 
  107296             : #if ROSE_ALLOC_TRACE == 2
  107297             : //  printf("SgOmpTargetParallelForStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpTargetParallelForStatement::next_node);
  107298             :     printf("SgOmpTargetParallelForStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpTargetParallelForStatement::next_node);
  107299             : #endif
  107300             : 
  107301             : #if ROSE_PEDANTIC_ALLOC
  107302             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  107303             : #endif
  107304             : 
  107305             : #if ROSE_ALLOC_MEMSET == 1
  107306             : #elif ROSE_ALLOC_MEMSET == 2
  107307             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpTargetParallelForStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  107308             : #elif ROSE_ALLOC_MEMSET == 3
  107309             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgOmpTargetParallelForStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  107310             : #endif
  107311             : 
  107312             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  107313             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  107314             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  107315             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  107316             : #else
  107317           0 :     object->p_freepointer = SgOmpTargetParallelForStatement::next_node;
  107318           0 :     SgOmpTargetParallelForStatement::next_node = object;
  107319             : #endif
  107320             : 
  107321             : #if ROSE_ALLOC_TRACE == 2
  107322             : //  printf("SgOmpTargetParallelForStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpTargetParallelForStatement::next_node);
  107323             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  107324             :     Rose::MemPool::snapshot(oss.str());
  107325             :     alloc_trace_cnt++;
  107326             : #endif
  107327             : 
  107328             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  107329             : 
  107330           0 :     ALLOC_MUTEX(SgOmpTargetParallelForStatement, unlock);
  107331             : }
  107332             : 
  107333             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  107334             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  107335             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  107336             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  107337             : // Also, note comment below from Robb (copied from the Common.code file).
  107338             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  107339             : //
  107340             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  107341             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  107342             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  107343             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  107344             : #if 0
  107345             : void SgOmpTargetParallelForStatement::operator delete(void* pointer) { SgOmpTargetParallelForStatement::operator delete (pointer, sizeof(SgOmpTargetParallelForStatement)); };
  107346             : #endif
  107347             : /* #line 107348 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  107348             : 
  107349             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  107350             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  107351             : // obviously imply C++.
  107352             : 
  107353             : // This implements the support within ROSE for memory pools.  Memory pools
  107354             : // support the most condensed usage of memory within the construction of
  107355             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  107356             : // by a new operator written for each class.
  107357             : 
  107358             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  107359             :     // User wants multi-thread support and POSIX threads are available.
  107360             : #   include <pthread.h>
  107361             :     static pthread_mutex_t SgOmpParallelLoopStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  107362             : #else
  107363             :      // Cause synchronization to be skipped.
  107364             : #    ifndef ALLOC_MUTEX
  107365             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  107366             : #    endif
  107367             : #    ifdef _REENTRANT
  107368             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  107369             : #       ifdef _MSC_VER
  107370             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  107371             : #       else
  107372             : #           warning "POSIX threads are not available; synchronization being skipped"
  107373             : #       endif
  107374             : #    endif
  107375             : #endif
  107376             : 
  107377             : #ifndef ROSE_ALLOC_TRACE
  107378             : #  define ROSE_ALLOC_TRACE 0
  107379             : #endif
  107380             : 
  107381             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  107382             : #define ROSE_ALLOC_TRACE_CNT
  107383             : #include "memory-pool-snapshot.h"
  107384             : unsigned long alloc_trace_cnt = 0;
  107385             : #endif
  107386             : 
  107387             : #if ROSE_ALLOC_TRACE
  107388             : const unsigned SgOmpParallelLoopStatement::pool_size = 5;
  107389             : #else
  107390             : const unsigned SgOmpParallelLoopStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  107391             : #endif
  107392             : 
  107393             : #ifndef ROSE_ALLOC_MEMSET
  107394             : #  define ROSE_ALLOC_MEMSET 0
  107395             : #endif
  107396             : 
  107397             : #ifndef ROSE_PEDANTIC_ALLOC
  107398             : #  define ROSE_PEDANTIC_ALLOC 0
  107399             : #endif
  107400             : 
  107401             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  107402             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  107403             : #endif
  107404             : 
  107405             : #if !defined(SGNODE__ALL_POOLS)
  107406             : #define SGNODE__ALL_POOLS
  107407             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  107408             : #endif
  107409             : 
  107410             : SgOmpParallelLoopStatement* SgOmpParallelLoopStatement::next_node = nullptr;
  107411             : std::vector<unsigned char*> SgOmpParallelLoopStatement::pools;
  107412             : 
  107413             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  107414             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  107415             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  107416             : // around this macro definition rather than each use).
  107417             : #ifndef ALLOC_MUTEX
  107418             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  107419             :         do {                                                                     \
  107420             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  107421             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  107422             :                 abort();                                                         \
  107423             :             }                                                                    \
  107424             :         } while (0);
  107425             : #endif
  107426             : 
  107427             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  107428             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  107429             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  107430             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  107431             : 
  107432             : /*! \brief New operator for SgOmpParallelLoopStatement.
  107433             : 
  107434             :    This new operator implements memory pools to provide most efficent 
  107435             :    use of the heap within construction of large ASTs.
  107436             : 
  107437             : \internal The new and delete operators use the lower level C malloc/free
  107438             :    function calls for performance and to make sure that mixing of malloc/free
  107439             :    and new/delete by the used can be caught more readily.  This may change
  107440             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  107441             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  107442             :    deallocate memory allocated using ROSE_MALLOC.
  107443             : */
  107444           1 : void *SgOmpParallelLoopStatement::operator new ( size_t Size )
  107445             : {
  107446             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  107447             :      * returning or throwing an exception. */
  107448           1 :     ALLOC_MUTEX(SgOmpParallelLoopStatement, lock);
  107449             : 
  107450             : #if ROSE_ALLOC_TRACE == 2
  107451             : //    printf("SgOmpParallelLoopStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgOmpParallelLoopStatement::next_node);
  107452             : #endif
  107453             : 
  107454             : #if USE_CPP_NEW_DELETE_OPERATORS
  107455             :     void *mem = ROSE_MALLOC(Size);
  107456             :     ALLOC_MUTEX(SgOmpParallelLoopStatement, unlock);
  107457             :     return mem;
  107458             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  107459             : #if ROSE_PEDANTIC_ALLOC
  107460             :     ROSE_ASSERT(Size == sizeof(SgOmpParallelLoopStatement));
  107461             : #else
  107462           1 :     if (Size != sizeof(SgOmpParallelLoopStatement)) {
  107463           0 :       void * object = ROSE_MALLOC(Size);
  107464           0 :       ALLOC_MUTEX(SgOmpParallelLoopStatement, unlock);
  107465             :       return object;
  107466             :     }
  107467             : #endif
  107468             : 
  107469           1 :     if (SgOmpParallelLoopStatement::next_node == nullptr) {
  107470           1 :         SgOmpParallelLoopStatement * alloc = (SgOmpParallelLoopStatement*) ROSE_MALLOC ( SgOmpParallelLoopStatement::pool_size * sizeof(SgOmpParallelLoopStatement) );
  107471           1 :         ROSE_ASSERT(alloc != nullptr);
  107472             : 
  107473             : #if ROSE_ALLOC_TRACE == 2
  107474             : //        printf("SgOmpParallelLoopStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgOmpParallelLoopStatement::pools.size(), alloc, alloc + SgOmpParallelLoopStatement::pool_size);
  107475             : #endif
  107476             : 
  107477             : #if ROSE_ALLOC_MEMSET == 1
  107478             : #elif ROSE_ALLOC_MEMSET == 2
  107479             :         memset(alloc, 0x00, SgOmpParallelLoopStatement::pool_size * sizeof(SgOmpParallelLoopStatement));
  107480             : #elif ROSE_ALLOC_MEMSET == 3
  107481             :         memset(alloc, 0xAA, SgOmpParallelLoopStatement::pool_size * sizeof(SgOmpParallelLoopStatement));
  107482             : #endif
  107483        2000 :         for (unsigned i=0; i < SgOmpParallelLoopStatement::pool_size-1; i++) {
  107484        1999 :           alloc[i].p_freepointer = &(alloc[i+1]);
  107485             :         }
  107486           1 :         alloc[SgOmpParallelLoopStatement::pool_size-1].p_freepointer = nullptr;
  107487             : 
  107488           1 :         SgOmpParallelLoopStatement::pools.push_back ( (unsigned char *) alloc );
  107489           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgOmpParallelLoopStatement::pool_size * sizeof(SgOmpParallelLoopStatement), V_SgOmpParallelLoopStatement ) );
  107490           1 :         SgOmpParallelLoopStatement::next_node = alloc;
  107491             :     }
  107492           1 :     ROSE_ASSERT(SgOmpParallelLoopStatement::next_node != nullptr);
  107493             : 
  107494           1 :     SgOmpParallelLoopStatement * object = SgOmpParallelLoopStatement::next_node;
  107495           1 :     SgOmpParallelLoopStatement::next_node = (SgOmpParallelLoopStatement*)(object->p_freepointer);
  107496             : 
  107497             : #if ROSE_ALLOC_TRACE == 2
  107498             :     printf("SgOmpParallelLoopStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpParallelLoopStatement::next_node);
  107499             : #endif
  107500             : 
  107501           1 :     SgNode * fp = object->p_freepointer;
  107502             : #if ROSE_ALLOC_MEMSET == 1
  107503             : #elif ROSE_ALLOC_MEMSET == 2
  107504             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpParallelLoopStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  107505             : #elif ROSE_ALLOC_MEMSET == 3
  107506             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgOmpParallelLoopStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  107507             : #endif
  107508           1 :     object->p_freepointer = fp;
  107509             : 
  107510             : #if ROSE_ALLOC_TRACE == 2
  107511             : //    printf("SgOmpParallelLoopStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpParallelLoopStatement::next_node);
  107512             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  107513             :     Rose::MemPool::snapshot(oss.str());
  107514             :     alloc_trace_cnt++;
  107515             : #endif
  107516             : 
  107517           1 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  107518             : 
  107519           1 :     ALLOC_MUTEX(SgOmpParallelLoopStatement, unlock);
  107520             : 
  107521             :     return object;
  107522             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  107523             : }
  107524             : 
  107525             : 
  107526             : 
  107527             : /*! \brief Delete operator for SgOmpParallelLoopStatement.
  107528             : 
  107529             :    This delete operator implements deallocation using memory pools to 
  107530             :    provide most efficent use of the heap within construction of large ASTs.
  107531             : 
  107532             : \internal The new and delete operators use the lower level C malloc/free
  107533             :    function calls for performance and to make sure that mixing of malloc/free
  107534             :    and new/delete by the used can be caught more readily.  This may change
  107535             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  107536             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  107537             :    deallocate memory allocated using ROSE_MALLOC.
  107538             : */
  107539           0 : void SgOmpParallelLoopStatement::operator delete(void *Pointer, size_t Size)
  107540             : {
  107541             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  107542             :      * or throwing an exception. */
  107543           0 :     ALLOC_MUTEX(SgOmpParallelLoopStatement, lock);
  107544             : 
  107545             : #if USE_CPP_NEW_DELETE_OPERATORS
  107546             :     ROSE_FREE(Pointer);
  107547             : #else
  107548             : #if ROSE_PEDANTIC_ALLOC
  107549             :     ROSE_ASSERT(Size == sizeof(SgOmpParallelLoopStatement));
  107550             : #else
  107551           0 :     if (Size != sizeof(SgOmpParallelLoopStatement)) {
  107552           0 :       ROSE_FREE(Pointer);
  107553           0 :       ALLOC_MUTEX(SgOmpParallelLoopStatement, unlock);
  107554             :       return;
  107555             :     }
  107556             : #endif
  107557             : 
  107558           0 :     SgOmpParallelLoopStatement * object = (SgOmpParallelLoopStatement*) Pointer;
  107559           0 :     ROSE_ASSERT(object != nullptr);
  107560             : 
  107561             : #if ROSE_ALLOC_TRACE == 2
  107562             : //  printf("SgOmpParallelLoopStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpParallelLoopStatement::next_node);
  107563             :     printf("SgOmpParallelLoopStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpParallelLoopStatement::next_node);
  107564             : #endif
  107565             : 
  107566             : #if ROSE_PEDANTIC_ALLOC
  107567             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  107568             : #endif
  107569             : 
  107570             : #if ROSE_ALLOC_MEMSET == 1
  107571             : #elif ROSE_ALLOC_MEMSET == 2
  107572             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpParallelLoopStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  107573             : #elif ROSE_ALLOC_MEMSET == 3
  107574             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgOmpParallelLoopStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  107575             : #endif
  107576             : 
  107577             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  107578             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  107579             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  107580             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  107581             : #else
  107582           0 :     object->p_freepointer = SgOmpParallelLoopStatement::next_node;
  107583           0 :     SgOmpParallelLoopStatement::next_node = object;
  107584             : #endif
  107585             : 
  107586             : #if ROSE_ALLOC_TRACE == 2
  107587             : //  printf("SgOmpParallelLoopStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpParallelLoopStatement::next_node);
  107588             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  107589             :     Rose::MemPool::snapshot(oss.str());
  107590             :     alloc_trace_cnt++;
  107591             : #endif
  107592             : 
  107593             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  107594             : 
  107595           0 :     ALLOC_MUTEX(SgOmpParallelLoopStatement, unlock);
  107596             : }
  107597             : 
  107598             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  107599             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  107600             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  107601             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  107602             : // Also, note comment below from Robb (copied from the Common.code file).
  107603             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  107604             : //
  107605             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  107606             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  107607             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  107608             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  107609             : #if 0
  107610             : void SgOmpParallelLoopStatement::operator delete(void* pointer) { SgOmpParallelLoopStatement::operator delete (pointer, sizeof(SgOmpParallelLoopStatement)); };
  107611             : #endif
  107612             : /* #line 107613 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  107613             : 
  107614             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  107615             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  107616             : // obviously imply C++.
  107617             : 
  107618             : // This implements the support within ROSE for memory pools.  Memory pools
  107619             : // support the most condensed usage of memory within the construction of
  107620             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  107621             : // by a new operator written for each class.
  107622             : 
  107623             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  107624             :     // User wants multi-thread support and POSIX threads are available.
  107625             : #   include <pthread.h>
  107626             :     static pthread_mutex_t SgOmpTargetParallelStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  107627             : #else
  107628             :      // Cause synchronization to be skipped.
  107629             : #    ifndef ALLOC_MUTEX
  107630             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  107631             : #    endif
  107632             : #    ifdef _REENTRANT
  107633             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  107634             : #       ifdef _MSC_VER
  107635             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  107636             : #       else
  107637             : #           warning "POSIX threads are not available; synchronization being skipped"
  107638             : #       endif
  107639             : #    endif
  107640             : #endif
  107641             : 
  107642             : #ifndef ROSE_ALLOC_TRACE
  107643             : #  define ROSE_ALLOC_TRACE 0
  107644             : #endif
  107645             : 
  107646             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  107647             : #define ROSE_ALLOC_TRACE_CNT
  107648             : #include "memory-pool-snapshot.h"
  107649             : unsigned long alloc_trace_cnt = 0;
  107650             : #endif
  107651             : 
  107652             : #if ROSE_ALLOC_TRACE
  107653             : const unsigned SgOmpTargetParallelStatement::pool_size = 5;
  107654             : #else
  107655             : const unsigned SgOmpTargetParallelStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  107656             : #endif
  107657             : 
  107658             : #ifndef ROSE_ALLOC_MEMSET
  107659             : #  define ROSE_ALLOC_MEMSET 0
  107660             : #endif
  107661             : 
  107662             : #ifndef ROSE_PEDANTIC_ALLOC
  107663             : #  define ROSE_PEDANTIC_ALLOC 0
  107664             : #endif
  107665             : 
  107666             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  107667             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  107668             : #endif
  107669             : 
  107670             : #if !defined(SGNODE__ALL_POOLS)
  107671             : #define SGNODE__ALL_POOLS
  107672             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  107673             : #endif
  107674             : 
  107675             : SgOmpTargetParallelStatement* SgOmpTargetParallelStatement::next_node = nullptr;
  107676             : std::vector<unsigned char*> SgOmpTargetParallelStatement::pools;
  107677             : 
  107678             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  107679             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  107680             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  107681             : // around this macro definition rather than each use).
  107682             : #ifndef ALLOC_MUTEX
  107683             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  107684             :         do {                                                                     \
  107685             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  107686             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  107687             :                 abort();                                                         \
  107688             :             }                                                                    \
  107689             :         } while (0);
  107690             : #endif
  107691             : 
  107692             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  107693             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  107694             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  107695             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  107696             : 
  107697             : /*! \brief New operator for SgOmpTargetParallelStatement.
  107698             : 
  107699             :    This new operator implements memory pools to provide most efficent 
  107700             :    use of the heap within construction of large ASTs.
  107701             : 
  107702             : \internal The new and delete operators use the lower level C malloc/free
  107703             :    function calls for performance and to make sure that mixing of malloc/free
  107704             :    and new/delete by the used can be caught more readily.  This may change
  107705             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  107706             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  107707             :    deallocate memory allocated using ROSE_MALLOC.
  107708             : */
  107709           1 : void *SgOmpTargetParallelStatement::operator new ( size_t Size )
  107710             : {
  107711             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  107712             :      * returning or throwing an exception. */
  107713           1 :     ALLOC_MUTEX(SgOmpTargetParallelStatement, lock);
  107714             : 
  107715             : #if ROSE_ALLOC_TRACE == 2
  107716             : //    printf("SgOmpTargetParallelStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgOmpTargetParallelStatement::next_node);
  107717             : #endif
  107718             : 
  107719             : #if USE_CPP_NEW_DELETE_OPERATORS
  107720             :     void *mem = ROSE_MALLOC(Size);
  107721             :     ALLOC_MUTEX(SgOmpTargetParallelStatement, unlock);
  107722             :     return mem;
  107723             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  107724             : #if ROSE_PEDANTIC_ALLOC
  107725             :     ROSE_ASSERT(Size == sizeof(SgOmpTargetParallelStatement));
  107726             : #else
  107727           1 :     if (Size != sizeof(SgOmpTargetParallelStatement)) {
  107728           0 :       void * object = ROSE_MALLOC(Size);
  107729           0 :       ALLOC_MUTEX(SgOmpTargetParallelStatement, unlock);
  107730             :       return object;
  107731             :     }
  107732             : #endif
  107733             : 
  107734           1 :     if (SgOmpTargetParallelStatement::next_node == nullptr) {
  107735           1 :         SgOmpTargetParallelStatement * alloc = (SgOmpTargetParallelStatement*) ROSE_MALLOC ( SgOmpTargetParallelStatement::pool_size * sizeof(SgOmpTargetParallelStatement) );
  107736           1 :         ROSE_ASSERT(alloc != nullptr);
  107737             : 
  107738             : #if ROSE_ALLOC_TRACE == 2
  107739             : //        printf("SgOmpTargetParallelStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgOmpTargetParallelStatement::pools.size(), alloc, alloc + SgOmpTargetParallelStatement::pool_size);
  107740             : #endif
  107741             : 
  107742             : #if ROSE_ALLOC_MEMSET == 1
  107743             : #elif ROSE_ALLOC_MEMSET == 2
  107744             :         memset(alloc, 0x00, SgOmpTargetParallelStatement::pool_size * sizeof(SgOmpTargetParallelStatement));
  107745             : #elif ROSE_ALLOC_MEMSET == 3
  107746             :         memset(alloc, 0xAA, SgOmpTargetParallelStatement::pool_size * sizeof(SgOmpTargetParallelStatement));
  107747             : #endif
  107748        2000 :         for (unsigned i=0; i < SgOmpTargetParallelStatement::pool_size-1; i++) {
  107749        1999 :           alloc[i].p_freepointer = &(alloc[i+1]);
  107750             :         }
  107751           1 :         alloc[SgOmpTargetParallelStatement::pool_size-1].p_freepointer = nullptr;
  107752             : 
  107753           1 :         SgOmpTargetParallelStatement::pools.push_back ( (unsigned char *) alloc );
  107754           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgOmpTargetParallelStatement::pool_size * sizeof(SgOmpTargetParallelStatement), V_SgOmpTargetParallelStatement ) );
  107755           1 :         SgOmpTargetParallelStatement::next_node = alloc;
  107756             :     }
  107757           1 :     ROSE_ASSERT(SgOmpTargetParallelStatement::next_node != nullptr);
  107758             : 
  107759           1 :     SgOmpTargetParallelStatement * object = SgOmpTargetParallelStatement::next_node;
  107760           1 :     SgOmpTargetParallelStatement::next_node = (SgOmpTargetParallelStatement*)(object->p_freepointer);
  107761             : 
  107762             : #if ROSE_ALLOC_TRACE == 2
  107763             :     printf("SgOmpTargetParallelStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpTargetParallelStatement::next_node);
  107764             : #endif
  107765             : 
  107766           1 :     SgNode * fp = object->p_freepointer;
  107767             : #if ROSE_ALLOC_MEMSET == 1
  107768             : #elif ROSE_ALLOC_MEMSET == 2
  107769             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpTargetParallelStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  107770             : #elif ROSE_ALLOC_MEMSET == 3
  107771             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgOmpTargetParallelStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  107772             : #endif
  107773           1 :     object->p_freepointer = fp;
  107774             : 
  107775             : #if ROSE_ALLOC_TRACE == 2
  107776             : //    printf("SgOmpTargetParallelStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpTargetParallelStatement::next_node);
  107777             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  107778             :     Rose::MemPool::snapshot(oss.str());
  107779             :     alloc_trace_cnt++;
  107780             : #endif
  107781             : 
  107782           1 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  107783             : 
  107784           1 :     ALLOC_MUTEX(SgOmpTargetParallelStatement, unlock);
  107785             : 
  107786             :     return object;
  107787             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  107788             : }
  107789             : 
  107790             : 
  107791             : 
  107792             : /*! \brief Delete operator for SgOmpTargetParallelStatement.
  107793             : 
  107794             :    This delete operator implements deallocation using memory pools to 
  107795             :    provide most efficent use of the heap within construction of large ASTs.
  107796             : 
  107797             : \internal The new and delete operators use the lower level C malloc/free
  107798             :    function calls for performance and to make sure that mixing of malloc/free
  107799             :    and new/delete by the used can be caught more readily.  This may change
  107800             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  107801             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  107802             :    deallocate memory allocated using ROSE_MALLOC.
  107803             : */
  107804           0 : void SgOmpTargetParallelStatement::operator delete(void *Pointer, size_t Size)
  107805             : {
  107806             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  107807             :      * or throwing an exception. */
  107808           0 :     ALLOC_MUTEX(SgOmpTargetParallelStatement, lock);
  107809             : 
  107810             : #if USE_CPP_NEW_DELETE_OPERATORS
  107811             :     ROSE_FREE(Pointer);
  107812             : #else
  107813             : #if ROSE_PEDANTIC_ALLOC
  107814             :     ROSE_ASSERT(Size == sizeof(SgOmpTargetParallelStatement));
  107815             : #else
  107816           0 :     if (Size != sizeof(SgOmpTargetParallelStatement)) {
  107817           0 :       ROSE_FREE(Pointer);
  107818           0 :       ALLOC_MUTEX(SgOmpTargetParallelStatement, unlock);
  107819             :       return;
  107820             :     }
  107821             : #endif
  107822             : 
  107823           0 :     SgOmpTargetParallelStatement * object = (SgOmpTargetParallelStatement*) Pointer;
  107824           0 :     ROSE_ASSERT(object != nullptr);
  107825             : 
  107826             : #if ROSE_ALLOC_TRACE == 2
  107827             : //  printf("SgOmpTargetParallelStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpTargetParallelStatement::next_node);
  107828             :     printf("SgOmpTargetParallelStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpTargetParallelStatement::next_node);
  107829             : #endif
  107830             : 
  107831             : #if ROSE_PEDANTIC_ALLOC
  107832             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  107833             : #endif
  107834             : 
  107835             : #if ROSE_ALLOC_MEMSET == 1
  107836             : #elif ROSE_ALLOC_MEMSET == 2
  107837             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpTargetParallelStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  107838             : #elif ROSE_ALLOC_MEMSET == 3
  107839             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgOmpTargetParallelStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  107840             : #endif
  107841             : 
  107842             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  107843             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  107844             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  107845             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  107846             : #else
  107847           0 :     object->p_freepointer = SgOmpTargetParallelStatement::next_node;
  107848           0 :     SgOmpTargetParallelStatement::next_node = object;
  107849             : #endif
  107850             : 
  107851             : #if ROSE_ALLOC_TRACE == 2
  107852             : //  printf("SgOmpTargetParallelStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpTargetParallelStatement::next_node);
  107853             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  107854             :     Rose::MemPool::snapshot(oss.str());
  107855             :     alloc_trace_cnt++;
  107856             : #endif
  107857             : 
  107858             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  107859             : 
  107860           0 :     ALLOC_MUTEX(SgOmpTargetParallelStatement, unlock);
  107861             : }
  107862             : 
  107863             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  107864             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  107865             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  107866             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  107867             : // Also, note comment below from Robb (copied from the Common.code file).
  107868             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  107869             : //
  107870             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  107871             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  107872             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  107873             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  107874             : #if 0
  107875             : void SgOmpTargetParallelStatement::operator delete(void* pointer) { SgOmpTargetParallelStatement::operator delete (pointer, sizeof(SgOmpTargetParallelStatement)); };
  107876             : #endif
  107877             : /* #line 107878 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  107878             : 
  107879             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  107880             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  107881             : // obviously imply C++.
  107882             : 
  107883             : // This implements the support within ROSE for memory pools.  Memory pools
  107884             : // support the most condensed usage of memory within the construction of
  107885             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  107886             : // by a new operator written for each class.
  107887             : 
  107888             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  107889             :     // User wants multi-thread support and POSIX threads are available.
  107890             : #   include <pthread.h>
  107891             :     static pthread_mutex_t SgOmpTargetParallelForSimdStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  107892             : #else
  107893             :      // Cause synchronization to be skipped.
  107894             : #    ifndef ALLOC_MUTEX
  107895             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  107896             : #    endif
  107897             : #    ifdef _REENTRANT
  107898             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  107899             : #       ifdef _MSC_VER
  107900             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  107901             : #       else
  107902             : #           warning "POSIX threads are not available; synchronization being skipped"
  107903             : #       endif
  107904             : #    endif
  107905             : #endif
  107906             : 
  107907             : #ifndef ROSE_ALLOC_TRACE
  107908             : #  define ROSE_ALLOC_TRACE 0
  107909             : #endif
  107910             : 
  107911             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  107912             : #define ROSE_ALLOC_TRACE_CNT
  107913             : #include "memory-pool-snapshot.h"
  107914             : unsigned long alloc_trace_cnt = 0;
  107915             : #endif
  107916             : 
  107917             : #if ROSE_ALLOC_TRACE
  107918             : const unsigned SgOmpTargetParallelForSimdStatement::pool_size = 5;
  107919             : #else
  107920             : const unsigned SgOmpTargetParallelForSimdStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  107921             : #endif
  107922             : 
  107923             : #ifndef ROSE_ALLOC_MEMSET
  107924             : #  define ROSE_ALLOC_MEMSET 0
  107925             : #endif
  107926             : 
  107927             : #ifndef ROSE_PEDANTIC_ALLOC
  107928             : #  define ROSE_PEDANTIC_ALLOC 0
  107929             : #endif
  107930             : 
  107931             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  107932             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  107933             : #endif
  107934             : 
  107935             : #if !defined(SGNODE__ALL_POOLS)
  107936             : #define SGNODE__ALL_POOLS
  107937             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  107938             : #endif
  107939             : 
  107940             : SgOmpTargetParallelForSimdStatement* SgOmpTargetParallelForSimdStatement::next_node = nullptr;
  107941             : std::vector<unsigned char*> SgOmpTargetParallelForSimdStatement::pools;
  107942             : 
  107943             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  107944             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  107945             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  107946             : // around this macro definition rather than each use).
  107947             : #ifndef ALLOC_MUTEX
  107948             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  107949             :         do {                                                                     \
  107950             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  107951             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  107952             :                 abort();                                                         \
  107953             :             }                                                                    \
  107954             :         } while (0);
  107955             : #endif
  107956             : 
  107957             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  107958             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  107959             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  107960             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  107961             : 
  107962             : /*! \brief New operator for SgOmpTargetParallelForSimdStatement.
  107963             : 
  107964             :    This new operator implements memory pools to provide most efficent 
  107965             :    use of the heap within construction of large ASTs.
  107966             : 
  107967             : \internal The new and delete operators use the lower level C malloc/free
  107968             :    function calls for performance and to make sure that mixing of malloc/free
  107969             :    and new/delete by the used can be caught more readily.  This may change
  107970             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  107971             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  107972             :    deallocate memory allocated using ROSE_MALLOC.
  107973             : */
  107974           1 : void *SgOmpTargetParallelForSimdStatement::operator new ( size_t Size )
  107975             : {
  107976             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  107977             :      * returning or throwing an exception. */
  107978           1 :     ALLOC_MUTEX(SgOmpTargetParallelForSimdStatement, lock);
  107979             : 
  107980             : #if ROSE_ALLOC_TRACE == 2
  107981             : //    printf("SgOmpTargetParallelForSimdStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgOmpTargetParallelForSimdStatement::next_node);
  107982             : #endif
  107983             : 
  107984             : #if USE_CPP_NEW_DELETE_OPERATORS
  107985             :     void *mem = ROSE_MALLOC(Size);
  107986             :     ALLOC_MUTEX(SgOmpTargetParallelForSimdStatement, unlock);
  107987             :     return mem;
  107988             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  107989             : #if ROSE_PEDANTIC_ALLOC
  107990             :     ROSE_ASSERT(Size == sizeof(SgOmpTargetParallelForSimdStatement));
  107991             : #else
  107992           1 :     if (Size != sizeof(SgOmpTargetParallelForSimdStatement)) {
  107993           0 :       void * object = ROSE_MALLOC(Size);
  107994           0 :       ALLOC_MUTEX(SgOmpTargetParallelForSimdStatement, unlock);
  107995             :       return object;
  107996             :     }
  107997             : #endif
  107998             : 
  107999           1 :     if (SgOmpTargetParallelForSimdStatement::next_node == nullptr) {
  108000           1 :         SgOmpTargetParallelForSimdStatement * alloc = (SgOmpTargetParallelForSimdStatement*) ROSE_MALLOC ( SgOmpTargetParallelForSimdStatement::pool_size * sizeof(SgOmpTargetParallelForSimdStatement) );
  108001           1 :         ROSE_ASSERT(alloc != nullptr);
  108002             : 
  108003             : #if ROSE_ALLOC_TRACE == 2
  108004             : //        printf("SgOmpTargetParallelForSimdStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgOmpTargetParallelForSimdStatement::pools.size(), alloc, alloc + SgOmpTargetParallelForSimdStatement::pool_size);
  108005             : #endif
  108006             : 
  108007             : #if ROSE_ALLOC_MEMSET == 1
  108008             : #elif ROSE_ALLOC_MEMSET == 2
  108009             :         memset(alloc, 0x00, SgOmpTargetParallelForSimdStatement::pool_size * sizeof(SgOmpTargetParallelForSimdStatement));
  108010             : #elif ROSE_ALLOC_MEMSET == 3
  108011             :         memset(alloc, 0xAA, SgOmpTargetParallelForSimdStatement::pool_size * sizeof(SgOmpTargetParallelForSimdStatement));
  108012             : #endif
  108013        2000 :         for (unsigned i=0; i < SgOmpTargetParallelForSimdStatement::pool_size-1; i++) {
  108014        1999 :           alloc[i].p_freepointer = &(alloc[i+1]);
  108015             :         }
  108016           1 :         alloc[SgOmpTargetParallelForSimdStatement::pool_size-1].p_freepointer = nullptr;
  108017             : 
  108018           1 :         SgOmpTargetParallelForSimdStatement::pools.push_back ( (unsigned char *) alloc );
  108019           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgOmpTargetParallelForSimdStatement::pool_size * sizeof(SgOmpTargetParallelForSimdStatement), V_SgOmpTargetParallelForSimdStatement ) );
  108020           1 :         SgOmpTargetParallelForSimdStatement::next_node = alloc;
  108021             :     }
  108022           1 :     ROSE_ASSERT(SgOmpTargetParallelForSimdStatement::next_node != nullptr);
  108023             : 
  108024           1 :     SgOmpTargetParallelForSimdStatement * object = SgOmpTargetParallelForSimdStatement::next_node;
  108025           1 :     SgOmpTargetParallelForSimdStatement::next_node = (SgOmpTargetParallelForSimdStatement*)(object->p_freepointer);
  108026             : 
  108027             : #if ROSE_ALLOC_TRACE == 2
  108028             :     printf("SgOmpTargetParallelForSimdStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpTargetParallelForSimdStatement::next_node);
  108029             : #endif
  108030             : 
  108031           1 :     SgNode * fp = object->p_freepointer;
  108032             : #if ROSE_ALLOC_MEMSET == 1
  108033             : #elif ROSE_ALLOC_MEMSET == 2
  108034             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpTargetParallelForSimdStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  108035             : #elif ROSE_ALLOC_MEMSET == 3
  108036             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgOmpTargetParallelForSimdStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  108037             : #endif
  108038           1 :     object->p_freepointer = fp;
  108039             : 
  108040             : #if ROSE_ALLOC_TRACE == 2
  108041             : //    printf("SgOmpTargetParallelForSimdStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpTargetParallelForSimdStatement::next_node);
  108042             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  108043             :     Rose::MemPool::snapshot(oss.str());
  108044             :     alloc_trace_cnt++;
  108045             : #endif
  108046             : 
  108047           1 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  108048             : 
  108049           1 :     ALLOC_MUTEX(SgOmpTargetParallelForSimdStatement, unlock);
  108050             : 
  108051             :     return object;
  108052             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  108053             : }
  108054             : 
  108055             : 
  108056             : 
  108057             : /*! \brief Delete operator for SgOmpTargetParallelForSimdStatement.
  108058             : 
  108059             :    This delete operator implements deallocation using memory pools to 
  108060             :    provide most efficent use of the heap within construction of large ASTs.
  108061             : 
  108062             : \internal The new and delete operators use the lower level C malloc/free
  108063             :    function calls for performance and to make sure that mixing of malloc/free
  108064             :    and new/delete by the used can be caught more readily.  This may change
  108065             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  108066             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  108067             :    deallocate memory allocated using ROSE_MALLOC.
  108068             : */
  108069           0 : void SgOmpTargetParallelForSimdStatement::operator delete(void *Pointer, size_t Size)
  108070             : {
  108071             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  108072             :      * or throwing an exception. */
  108073           0 :     ALLOC_MUTEX(SgOmpTargetParallelForSimdStatement, lock);
  108074             : 
  108075             : #if USE_CPP_NEW_DELETE_OPERATORS
  108076             :     ROSE_FREE(Pointer);
  108077             : #else
  108078             : #if ROSE_PEDANTIC_ALLOC
  108079             :     ROSE_ASSERT(Size == sizeof(SgOmpTargetParallelForSimdStatement));
  108080             : #else
  108081           0 :     if (Size != sizeof(SgOmpTargetParallelForSimdStatement)) {
  108082           0 :       ROSE_FREE(Pointer);
  108083           0 :       ALLOC_MUTEX(SgOmpTargetParallelForSimdStatement, unlock);
  108084             :       return;
  108085             :     }
  108086             : #endif
  108087             : 
  108088           0 :     SgOmpTargetParallelForSimdStatement * object = (SgOmpTargetParallelForSimdStatement*) Pointer;
  108089           0 :     ROSE_ASSERT(object != nullptr);
  108090             : 
  108091             : #if ROSE_ALLOC_TRACE == 2
  108092             : //  printf("SgOmpTargetParallelForSimdStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpTargetParallelForSimdStatement::next_node);
  108093             :     printf("SgOmpTargetParallelForSimdStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpTargetParallelForSimdStatement::next_node);
  108094             : #endif
  108095             : 
  108096             : #if ROSE_PEDANTIC_ALLOC
  108097             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  108098             : #endif
  108099             : 
  108100             : #if ROSE_ALLOC_MEMSET == 1
  108101             : #elif ROSE_ALLOC_MEMSET == 2
  108102             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpTargetParallelForSimdStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  108103             : #elif ROSE_ALLOC_MEMSET == 3
  108104             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgOmpTargetParallelForSimdStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  108105             : #endif
  108106             : 
  108107             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  108108             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  108109             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  108110             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  108111             : #else
  108112           0 :     object->p_freepointer = SgOmpTargetParallelForSimdStatement::next_node;
  108113           0 :     SgOmpTargetParallelForSimdStatement::next_node = object;
  108114             : #endif
  108115             : 
  108116             : #if ROSE_ALLOC_TRACE == 2
  108117             : //  printf("SgOmpTargetParallelForSimdStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpTargetParallelForSimdStatement::next_node);
  108118             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  108119             :     Rose::MemPool::snapshot(oss.str());
  108120             :     alloc_trace_cnt++;
  108121             : #endif
  108122             : 
  108123             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  108124             : 
  108125           0 :     ALLOC_MUTEX(SgOmpTargetParallelForSimdStatement, unlock);
  108126             : }
  108127             : 
  108128             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  108129             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  108130             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  108131             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  108132             : // Also, note comment below from Robb (copied from the Common.code file).
  108133             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  108134             : //
  108135             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  108136             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  108137             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  108138             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  108139             : #if 0
  108140             : void SgOmpTargetParallelForSimdStatement::operator delete(void* pointer) { SgOmpTargetParallelForSimdStatement::operator delete (pointer, sizeof(SgOmpTargetParallelForSimdStatement)); };
  108141             : #endif
  108142             : /* #line 108143 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  108143             : 
  108144             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  108145             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  108146             : // obviously imply C++.
  108147             : 
  108148             : // This implements the support within ROSE for memory pools.  Memory pools
  108149             : // support the most condensed usage of memory within the construction of
  108150             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  108151             : // by a new operator written for each class.
  108152             : 
  108153             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  108154             :     // User wants multi-thread support and POSIX threads are available.
  108155             : #   include <pthread.h>
  108156             :     static pthread_mutex_t SgOmpTargetParallelLoopStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  108157             : #else
  108158             :      // Cause synchronization to be skipped.
  108159             : #    ifndef ALLOC_MUTEX
  108160             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  108161             : #    endif
  108162             : #    ifdef _REENTRANT
  108163             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  108164             : #       ifdef _MSC_VER
  108165             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  108166             : #       else
  108167             : #           warning "POSIX threads are not available; synchronization being skipped"
  108168             : #       endif
  108169             : #    endif
  108170             : #endif
  108171             : 
  108172             : #ifndef ROSE_ALLOC_TRACE
  108173             : #  define ROSE_ALLOC_TRACE 0
  108174             : #endif
  108175             : 
  108176             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  108177             : #define ROSE_ALLOC_TRACE_CNT
  108178             : #include "memory-pool-snapshot.h"
  108179             : unsigned long alloc_trace_cnt = 0;
  108180             : #endif
  108181             : 
  108182             : #if ROSE_ALLOC_TRACE
  108183             : const unsigned SgOmpTargetParallelLoopStatement::pool_size = 5;
  108184             : #else
  108185             : const unsigned SgOmpTargetParallelLoopStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  108186             : #endif
  108187             : 
  108188             : #ifndef ROSE_ALLOC_MEMSET
  108189             : #  define ROSE_ALLOC_MEMSET 0
  108190             : #endif
  108191             : 
  108192             : #ifndef ROSE_PEDANTIC_ALLOC
  108193             : #  define ROSE_PEDANTIC_ALLOC 0
  108194             : #endif
  108195             : 
  108196             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  108197             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  108198             : #endif
  108199             : 
  108200             : #if !defined(SGNODE__ALL_POOLS)
  108201             : #define SGNODE__ALL_POOLS
  108202             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  108203             : #endif
  108204             : 
  108205             : SgOmpTargetParallelLoopStatement* SgOmpTargetParallelLoopStatement::next_node = nullptr;
  108206             : std::vector<unsigned char*> SgOmpTargetParallelLoopStatement::pools;
  108207             : 
  108208             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  108209             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  108210             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  108211             : // around this macro definition rather than each use).
  108212             : #ifndef ALLOC_MUTEX
  108213             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  108214             :         do {                                                                     \
  108215             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  108216             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  108217             :                 abort();                                                         \
  108218             :             }                                                                    \
  108219             :         } while (0);
  108220             : #endif
  108221             : 
  108222             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  108223             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  108224             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  108225             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  108226             : 
  108227             : /*! \brief New operator for SgOmpTargetParallelLoopStatement.
  108228             : 
  108229             :    This new operator implements memory pools to provide most efficent 
  108230             :    use of the heap within construction of large ASTs.
  108231             : 
  108232             : \internal The new and delete operators use the lower level C malloc/free
  108233             :    function calls for performance and to make sure that mixing of malloc/free
  108234             :    and new/delete by the used can be caught more readily.  This may change
  108235             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  108236             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  108237             :    deallocate memory allocated using ROSE_MALLOC.
  108238             : */
  108239           1 : void *SgOmpTargetParallelLoopStatement::operator new ( size_t Size )
  108240             : {
  108241             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  108242             :      * returning or throwing an exception. */
  108243           1 :     ALLOC_MUTEX(SgOmpTargetParallelLoopStatement, lock);
  108244             : 
  108245             : #if ROSE_ALLOC_TRACE == 2
  108246             : //    printf("SgOmpTargetParallelLoopStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgOmpTargetParallelLoopStatement::next_node);
  108247             : #endif
  108248             : 
  108249             : #if USE_CPP_NEW_DELETE_OPERATORS
  108250             :     void *mem = ROSE_MALLOC(Size);
  108251             :     ALLOC_MUTEX(SgOmpTargetParallelLoopStatement, unlock);
  108252             :     return mem;
  108253             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  108254             : #if ROSE_PEDANTIC_ALLOC
  108255             :     ROSE_ASSERT(Size == sizeof(SgOmpTargetParallelLoopStatement));
  108256             : #else
  108257           1 :     if (Size != sizeof(SgOmpTargetParallelLoopStatement)) {
  108258           0 :       void * object = ROSE_MALLOC(Size);
  108259           0 :       ALLOC_MUTEX(SgOmpTargetParallelLoopStatement, unlock);
  108260             :       return object;
  108261             :     }
  108262             : #endif
  108263             : 
  108264           1 :     if (SgOmpTargetParallelLoopStatement::next_node == nullptr) {
  108265           1 :         SgOmpTargetParallelLoopStatement * alloc = (SgOmpTargetParallelLoopStatement*) ROSE_MALLOC ( SgOmpTargetParallelLoopStatement::pool_size * sizeof(SgOmpTargetParallelLoopStatement) );
  108266           1 :         ROSE_ASSERT(alloc != nullptr);
  108267             : 
  108268             : #if ROSE_ALLOC_TRACE == 2
  108269             : //        printf("SgOmpTargetParallelLoopStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgOmpTargetParallelLoopStatement::pools.size(), alloc, alloc + SgOmpTargetParallelLoopStatement::pool_size);
  108270             : #endif
  108271             : 
  108272             : #if ROSE_ALLOC_MEMSET == 1
  108273             : #elif ROSE_ALLOC_MEMSET == 2
  108274             :         memset(alloc, 0x00, SgOmpTargetParallelLoopStatement::pool_size * sizeof(SgOmpTargetParallelLoopStatement));
  108275             : #elif ROSE_ALLOC_MEMSET == 3
  108276             :         memset(alloc, 0xAA, SgOmpTargetParallelLoopStatement::pool_size * sizeof(SgOmpTargetParallelLoopStatement));
  108277             : #endif
  108278        2000 :         for (unsigned i=0; i < SgOmpTargetParallelLoopStatement::pool_size-1; i++) {
  108279        1999 :           alloc[i].p_freepointer = &(alloc[i+1]);
  108280             :         }
  108281           1 :         alloc[SgOmpTargetParallelLoopStatement::pool_size-1].p_freepointer = nullptr;
  108282             : 
  108283           1 :         SgOmpTargetParallelLoopStatement::pools.push_back ( (unsigned char *) alloc );
  108284           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgOmpTargetParallelLoopStatement::pool_size * sizeof(SgOmpTargetParallelLoopStatement), V_SgOmpTargetParallelLoopStatement ) );
  108285           1 :         SgOmpTargetParallelLoopStatement::next_node = alloc;
  108286             :     }
  108287           1 :     ROSE_ASSERT(SgOmpTargetParallelLoopStatement::next_node != nullptr);
  108288             : 
  108289           1 :     SgOmpTargetParallelLoopStatement * object = SgOmpTargetParallelLoopStatement::next_node;
  108290           1 :     SgOmpTargetParallelLoopStatement::next_node = (SgOmpTargetParallelLoopStatement*)(object->p_freepointer);
  108291             : 
  108292             : #if ROSE_ALLOC_TRACE == 2
  108293             :     printf("SgOmpTargetParallelLoopStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpTargetParallelLoopStatement::next_node);
  108294             : #endif
  108295             : 
  108296           1 :     SgNode * fp = object->p_freepointer;
  108297             : #if ROSE_ALLOC_MEMSET == 1
  108298             : #elif ROSE_ALLOC_MEMSET == 2
  108299             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpTargetParallelLoopStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  108300             : #elif ROSE_ALLOC_MEMSET == 3
  108301             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgOmpTargetParallelLoopStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  108302             : #endif
  108303           1 :     object->p_freepointer = fp;
  108304             : 
  108305             : #if ROSE_ALLOC_TRACE == 2
  108306             : //    printf("SgOmpTargetParallelLoopStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpTargetParallelLoopStatement::next_node);
  108307             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  108308             :     Rose::MemPool::snapshot(oss.str());
  108309             :     alloc_trace_cnt++;
  108310             : #endif
  108311             : 
  108312           1 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  108313             : 
  108314           1 :     ALLOC_MUTEX(SgOmpTargetParallelLoopStatement, unlock);
  108315             : 
  108316             :     return object;
  108317             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  108318             : }
  108319             : 
  108320             : 
  108321             : 
  108322             : /*! \brief Delete operator for SgOmpTargetParallelLoopStatement.
  108323             : 
  108324             :    This delete operator implements deallocation using memory pools to 
  108325             :    provide most efficent use of the heap within construction of large ASTs.
  108326             : 
  108327             : \internal The new and delete operators use the lower level C malloc/free
  108328             :    function calls for performance and to make sure that mixing of malloc/free
  108329             :    and new/delete by the used can be caught more readily.  This may change
  108330             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  108331             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  108332             :    deallocate memory allocated using ROSE_MALLOC.
  108333             : */
  108334           0 : void SgOmpTargetParallelLoopStatement::operator delete(void *Pointer, size_t Size)
  108335             : {
  108336             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  108337             :      * or throwing an exception. */
  108338           0 :     ALLOC_MUTEX(SgOmpTargetParallelLoopStatement, lock);
  108339             : 
  108340             : #if USE_CPP_NEW_DELETE_OPERATORS
  108341             :     ROSE_FREE(Pointer);
  108342             : #else
  108343             : #if ROSE_PEDANTIC_ALLOC
  108344             :     ROSE_ASSERT(Size == sizeof(SgOmpTargetParallelLoopStatement));
  108345             : #else
  108346           0 :     if (Size != sizeof(SgOmpTargetParallelLoopStatement)) {
  108347           0 :       ROSE_FREE(Pointer);
  108348           0 :       ALLOC_MUTEX(SgOmpTargetParallelLoopStatement, unlock);
  108349             :       return;
  108350             :     }
  108351             : #endif
  108352             : 
  108353           0 :     SgOmpTargetParallelLoopStatement * object = (SgOmpTargetParallelLoopStatement*) Pointer;
  108354           0 :     ROSE_ASSERT(object != nullptr);
  108355             : 
  108356             : #if ROSE_ALLOC_TRACE == 2
  108357             : //  printf("SgOmpTargetParallelLoopStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpTargetParallelLoopStatement::next_node);
  108358             :     printf("SgOmpTargetParallelLoopStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpTargetParallelLoopStatement::next_node);
  108359             : #endif
  108360             : 
  108361             : #if ROSE_PEDANTIC_ALLOC
  108362             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  108363             : #endif
  108364             : 
  108365             : #if ROSE_ALLOC_MEMSET == 1
  108366             : #elif ROSE_ALLOC_MEMSET == 2
  108367             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpTargetParallelLoopStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  108368             : #elif ROSE_ALLOC_MEMSET == 3
  108369             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgOmpTargetParallelLoopStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  108370             : #endif
  108371             : 
  108372             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  108373             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  108374             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  108375             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  108376             : #else
  108377           0 :     object->p_freepointer = SgOmpTargetParallelLoopStatement::next_node;
  108378           0 :     SgOmpTargetParallelLoopStatement::next_node = object;
  108379             : #endif
  108380             : 
  108381             : #if ROSE_ALLOC_TRACE == 2
  108382             : //  printf("SgOmpTargetParallelLoopStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpTargetParallelLoopStatement::next_node);
  108383             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  108384             :     Rose::MemPool::snapshot(oss.str());
  108385             :     alloc_trace_cnt++;
  108386             : #endif
  108387             : 
  108388             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  108389             : 
  108390           0 :     ALLOC_MUTEX(SgOmpTargetParallelLoopStatement, unlock);
  108391             : }
  108392             : 
  108393             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  108394             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  108395             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  108396             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  108397             : // Also, note comment below from Robb (copied from the Common.code file).
  108398             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  108399             : //
  108400             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  108401             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  108402             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  108403             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  108404             : #if 0
  108405             : void SgOmpTargetParallelLoopStatement::operator delete(void* pointer) { SgOmpTargetParallelLoopStatement::operator delete (pointer, sizeof(SgOmpTargetParallelLoopStatement)); };
  108406             : #endif
  108407             : /* #line 108408 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  108408             : 
  108409             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  108410             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  108411             : // obviously imply C++.
  108412             : 
  108413             : // This implements the support within ROSE for memory pools.  Memory pools
  108414             : // support the most condensed usage of memory within the construction of
  108415             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  108416             : // by a new operator written for each class.
  108417             : 
  108418             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  108419             :     // User wants multi-thread support and POSIX threads are available.
  108420             : #   include <pthread.h>
  108421             :     static pthread_mutex_t SgOmpTargetSimdStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  108422             : #else
  108423             :      // Cause synchronization to be skipped.
  108424             : #    ifndef ALLOC_MUTEX
  108425             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  108426             : #    endif
  108427             : #    ifdef _REENTRANT
  108428             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  108429             : #       ifdef _MSC_VER
  108430             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  108431             : #       else
  108432             : #           warning "POSIX threads are not available; synchronization being skipped"
  108433             : #       endif
  108434             : #    endif
  108435             : #endif
  108436             : 
  108437             : #ifndef ROSE_ALLOC_TRACE
  108438             : #  define ROSE_ALLOC_TRACE 0
  108439             : #endif
  108440             : 
  108441             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  108442             : #define ROSE_ALLOC_TRACE_CNT
  108443             : #include "memory-pool-snapshot.h"
  108444             : unsigned long alloc_trace_cnt = 0;
  108445             : #endif
  108446             : 
  108447             : #if ROSE_ALLOC_TRACE
  108448             : const unsigned SgOmpTargetSimdStatement::pool_size = 5;
  108449             : #else
  108450             : const unsigned SgOmpTargetSimdStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  108451             : #endif
  108452             : 
  108453             : #ifndef ROSE_ALLOC_MEMSET
  108454             : #  define ROSE_ALLOC_MEMSET 0
  108455             : #endif
  108456             : 
  108457             : #ifndef ROSE_PEDANTIC_ALLOC
  108458             : #  define ROSE_PEDANTIC_ALLOC 0
  108459             : #endif
  108460             : 
  108461             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  108462             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  108463             : #endif
  108464             : 
  108465             : #if !defined(SGNODE__ALL_POOLS)
  108466             : #define SGNODE__ALL_POOLS
  108467             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  108468             : #endif
  108469             : 
  108470             : SgOmpTargetSimdStatement* SgOmpTargetSimdStatement::next_node = nullptr;
  108471             : std::vector<unsigned char*> SgOmpTargetSimdStatement::pools;
  108472             : 
  108473             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  108474             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  108475             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  108476             : // around this macro definition rather than each use).
  108477             : #ifndef ALLOC_MUTEX
  108478             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  108479             :         do {                                                                     \
  108480             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  108481             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  108482             :                 abort();                                                         \
  108483             :             }                                                                    \
  108484             :         } while (0);
  108485             : #endif
  108486             : 
  108487             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  108488             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  108489             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  108490             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  108491             : 
  108492             : /*! \brief New operator for SgOmpTargetSimdStatement.
  108493             : 
  108494             :    This new operator implements memory pools to provide most efficent 
  108495             :    use of the heap within construction of large ASTs.
  108496             : 
  108497             : \internal The new and delete operators use the lower level C malloc/free
  108498             :    function calls for performance and to make sure that mixing of malloc/free
  108499             :    and new/delete by the used can be caught more readily.  This may change
  108500             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  108501             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  108502             :    deallocate memory allocated using ROSE_MALLOC.
  108503             : */
  108504           1 : void *SgOmpTargetSimdStatement::operator new ( size_t Size )
  108505             : {
  108506             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  108507             :      * returning or throwing an exception. */
  108508           1 :     ALLOC_MUTEX(SgOmpTargetSimdStatement, lock);
  108509             : 
  108510             : #if ROSE_ALLOC_TRACE == 2
  108511             : //    printf("SgOmpTargetSimdStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgOmpTargetSimdStatement::next_node);
  108512             : #endif
  108513             : 
  108514             : #if USE_CPP_NEW_DELETE_OPERATORS
  108515             :     void *mem = ROSE_MALLOC(Size);
  108516             :     ALLOC_MUTEX(SgOmpTargetSimdStatement, unlock);
  108517             :     return mem;
  108518             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  108519             : #if ROSE_PEDANTIC_ALLOC
  108520             :     ROSE_ASSERT(Size == sizeof(SgOmpTargetSimdStatement));
  108521             : #else
  108522           1 :     if (Size != sizeof(SgOmpTargetSimdStatement)) {
  108523           0 :       void * object = ROSE_MALLOC(Size);
  108524           0 :       ALLOC_MUTEX(SgOmpTargetSimdStatement, unlock);
  108525             :       return object;
  108526             :     }
  108527             : #endif
  108528             : 
  108529           1 :     if (SgOmpTargetSimdStatement::next_node == nullptr) {
  108530           1 :         SgOmpTargetSimdStatement * alloc = (SgOmpTargetSimdStatement*) ROSE_MALLOC ( SgOmpTargetSimdStatement::pool_size * sizeof(SgOmpTargetSimdStatement) );
  108531           1 :         ROSE_ASSERT(alloc != nullptr);
  108532             : 
  108533             : #if ROSE_ALLOC_TRACE == 2
  108534             : //        printf("SgOmpTargetSimdStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgOmpTargetSimdStatement::pools.size(), alloc, alloc + SgOmpTargetSimdStatement::pool_size);
  108535             : #endif
  108536             : 
  108537             : #if ROSE_ALLOC_MEMSET == 1
  108538             : #elif ROSE_ALLOC_MEMSET == 2
  108539             :         memset(alloc, 0x00, SgOmpTargetSimdStatement::pool_size * sizeof(SgOmpTargetSimdStatement));
  108540             : #elif ROSE_ALLOC_MEMSET == 3
  108541             :         memset(alloc, 0xAA, SgOmpTargetSimdStatement::pool_size * sizeof(SgOmpTargetSimdStatement));
  108542             : #endif
  108543        2000 :         for (unsigned i=0; i < SgOmpTargetSimdStatement::pool_size-1; i++) {
  108544        1999 :           alloc[i].p_freepointer = &(alloc[i+1]);
  108545             :         }
  108546           1 :         alloc[SgOmpTargetSimdStatement::pool_size-1].p_freepointer = nullptr;
  108547             : 
  108548           1 :         SgOmpTargetSimdStatement::pools.push_back ( (unsigned char *) alloc );
  108549           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgOmpTargetSimdStatement::pool_size * sizeof(SgOmpTargetSimdStatement), V_SgOmpTargetSimdStatement ) );
  108550           1 :         SgOmpTargetSimdStatement::next_node = alloc;
  108551             :     }
  108552           1 :     ROSE_ASSERT(SgOmpTargetSimdStatement::next_node != nullptr);
  108553             : 
  108554           1 :     SgOmpTargetSimdStatement * object = SgOmpTargetSimdStatement::next_node;
  108555           1 :     SgOmpTargetSimdStatement::next_node = (SgOmpTargetSimdStatement*)(object->p_freepointer);
  108556             : 
  108557             : #if ROSE_ALLOC_TRACE == 2
  108558             :     printf("SgOmpTargetSimdStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpTargetSimdStatement::next_node);
  108559             : #endif
  108560             : 
  108561           1 :     SgNode * fp = object->p_freepointer;
  108562             : #if ROSE_ALLOC_MEMSET == 1
  108563             : #elif ROSE_ALLOC_MEMSET == 2
  108564             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpTargetSimdStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  108565             : #elif ROSE_ALLOC_MEMSET == 3
  108566             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgOmpTargetSimdStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  108567             : #endif
  108568           1 :     object->p_freepointer = fp;
  108569             : 
  108570             : #if ROSE_ALLOC_TRACE == 2
  108571             : //    printf("SgOmpTargetSimdStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpTargetSimdStatement::next_node);
  108572             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  108573             :     Rose::MemPool::snapshot(oss.str());
  108574             :     alloc_trace_cnt++;
  108575             : #endif
  108576             : 
  108577           1 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  108578             : 
  108579           1 :     ALLOC_MUTEX(SgOmpTargetSimdStatement, unlock);
  108580             : 
  108581             :     return object;
  108582             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  108583             : }
  108584             : 
  108585             : 
  108586             : 
  108587             : /*! \brief Delete operator for SgOmpTargetSimdStatement.
  108588             : 
  108589             :    This delete operator implements deallocation using memory pools to 
  108590             :    provide most efficent use of the heap within construction of large ASTs.
  108591             : 
  108592             : \internal The new and delete operators use the lower level C malloc/free
  108593             :    function calls for performance and to make sure that mixing of malloc/free
  108594             :    and new/delete by the used can be caught more readily.  This may change
  108595             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  108596             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  108597             :    deallocate memory allocated using ROSE_MALLOC.
  108598             : */
  108599           0 : void SgOmpTargetSimdStatement::operator delete(void *Pointer, size_t Size)
  108600             : {
  108601             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  108602             :      * or throwing an exception. */
  108603           0 :     ALLOC_MUTEX(SgOmpTargetSimdStatement, lock);
  108604             : 
  108605             : #if USE_CPP_NEW_DELETE_OPERATORS
  108606             :     ROSE_FREE(Pointer);
  108607             : #else
  108608             : #if ROSE_PEDANTIC_ALLOC
  108609             :     ROSE_ASSERT(Size == sizeof(SgOmpTargetSimdStatement));
  108610             : #else
  108611           0 :     if (Size != sizeof(SgOmpTargetSimdStatement)) {
  108612           0 :       ROSE_FREE(Pointer);
  108613           0 :       ALLOC_MUTEX(SgOmpTargetSimdStatement, unlock);
  108614             :       return;
  108615             :     }
  108616             : #endif
  108617             : 
  108618           0 :     SgOmpTargetSimdStatement * object = (SgOmpTargetSimdStatement*) Pointer;
  108619           0 :     ROSE_ASSERT(object != nullptr);
  108620             : 
  108621             : #if ROSE_ALLOC_TRACE == 2
  108622             : //  printf("SgOmpTargetSimdStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpTargetSimdStatement::next_node);
  108623             :     printf("SgOmpTargetSimdStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpTargetSimdStatement::next_node);
  108624             : #endif
  108625             : 
  108626             : #if ROSE_PEDANTIC_ALLOC
  108627             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  108628             : #endif
  108629             : 
  108630             : #if ROSE_ALLOC_MEMSET == 1
  108631             : #elif ROSE_ALLOC_MEMSET == 2
  108632             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpTargetSimdStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  108633             : #elif ROSE_ALLOC_MEMSET == 3
  108634             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgOmpTargetSimdStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  108635             : #endif
  108636             : 
  108637             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  108638             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  108639             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  108640             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  108641             : #else
  108642           0 :     object->p_freepointer = SgOmpTargetSimdStatement::next_node;
  108643           0 :     SgOmpTargetSimdStatement::next_node = object;
  108644             : #endif
  108645             : 
  108646             : #if ROSE_ALLOC_TRACE == 2
  108647             : //  printf("SgOmpTargetSimdStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpTargetSimdStatement::next_node);
  108648             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  108649             :     Rose::MemPool::snapshot(oss.str());
  108650             :     alloc_trace_cnt++;
  108651             : #endif
  108652             : 
  108653             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  108654             : 
  108655           0 :     ALLOC_MUTEX(SgOmpTargetSimdStatement, unlock);
  108656             : }
  108657             : 
  108658             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  108659             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  108660             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  108661             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  108662             : // Also, note comment below from Robb (copied from the Common.code file).
  108663             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  108664             : //
  108665             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  108666             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  108667             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  108668             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  108669             : #if 0
  108670             : void SgOmpTargetSimdStatement::operator delete(void* pointer) { SgOmpTargetSimdStatement::operator delete (pointer, sizeof(SgOmpTargetSimdStatement)); };
  108671             : #endif
  108672             : /* #line 108673 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  108673             : 
  108674             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  108675             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  108676             : // obviously imply C++.
  108677             : 
  108678             : // This implements the support within ROSE for memory pools.  Memory pools
  108679             : // support the most condensed usage of memory within the construction of
  108680             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  108681             : // by a new operator written for each class.
  108682             : 
  108683             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  108684             :     // User wants multi-thread support and POSIX threads are available.
  108685             : #   include <pthread.h>
  108686             :     static pthread_mutex_t SgOmpTargetTeamsStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  108687             : #else
  108688             :      // Cause synchronization to be skipped.
  108689             : #    ifndef ALLOC_MUTEX
  108690             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  108691             : #    endif
  108692             : #    ifdef _REENTRANT
  108693             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  108694             : #       ifdef _MSC_VER
  108695             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  108696             : #       else
  108697             : #           warning "POSIX threads are not available; synchronization being skipped"
  108698             : #       endif
  108699             : #    endif
  108700             : #endif
  108701             : 
  108702             : #ifndef ROSE_ALLOC_TRACE
  108703             : #  define ROSE_ALLOC_TRACE 0
  108704             : #endif
  108705             : 
  108706             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  108707             : #define ROSE_ALLOC_TRACE_CNT
  108708             : #include "memory-pool-snapshot.h"
  108709             : unsigned long alloc_trace_cnt = 0;
  108710             : #endif
  108711             : 
  108712             : #if ROSE_ALLOC_TRACE
  108713             : const unsigned SgOmpTargetTeamsStatement::pool_size = 5;
  108714             : #else
  108715             : const unsigned SgOmpTargetTeamsStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  108716             : #endif
  108717             : 
  108718             : #ifndef ROSE_ALLOC_MEMSET
  108719             : #  define ROSE_ALLOC_MEMSET 0
  108720             : #endif
  108721             : 
  108722             : #ifndef ROSE_PEDANTIC_ALLOC
  108723             : #  define ROSE_PEDANTIC_ALLOC 0
  108724             : #endif
  108725             : 
  108726             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  108727             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  108728             : #endif
  108729             : 
  108730             : #if !defined(SGNODE__ALL_POOLS)
  108731             : #define SGNODE__ALL_POOLS
  108732             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  108733             : #endif
  108734             : 
  108735             : SgOmpTargetTeamsStatement* SgOmpTargetTeamsStatement::next_node = nullptr;
  108736             : std::vector<unsigned char*> SgOmpTargetTeamsStatement::pools;
  108737             : 
  108738             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  108739             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  108740             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  108741             : // around this macro definition rather than each use).
  108742             : #ifndef ALLOC_MUTEX
  108743             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  108744             :         do {                                                                     \
  108745             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  108746             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  108747             :                 abort();                                                         \
  108748             :             }                                                                    \
  108749             :         } while (0);
  108750             : #endif
  108751             : 
  108752             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  108753             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  108754             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  108755             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  108756             : 
  108757             : /*! \brief New operator for SgOmpTargetTeamsStatement.
  108758             : 
  108759             :    This new operator implements memory pools to provide most efficent 
  108760             :    use of the heap within construction of large ASTs.
  108761             : 
  108762             : \internal The new and delete operators use the lower level C malloc/free
  108763             :    function calls for performance and to make sure that mixing of malloc/free
  108764             :    and new/delete by the used can be caught more readily.  This may change
  108765             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  108766             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  108767             :    deallocate memory allocated using ROSE_MALLOC.
  108768             : */
  108769           4 : void *SgOmpTargetTeamsStatement::operator new ( size_t Size )
  108770             : {
  108771             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  108772             :      * returning or throwing an exception. */
  108773           4 :     ALLOC_MUTEX(SgOmpTargetTeamsStatement, lock);
  108774             : 
  108775             : #if ROSE_ALLOC_TRACE == 2
  108776             : //    printf("SgOmpTargetTeamsStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgOmpTargetTeamsStatement::next_node);
  108777             : #endif
  108778             : 
  108779             : #if USE_CPP_NEW_DELETE_OPERATORS
  108780             :     void *mem = ROSE_MALLOC(Size);
  108781             :     ALLOC_MUTEX(SgOmpTargetTeamsStatement, unlock);
  108782             :     return mem;
  108783             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  108784             : #if ROSE_PEDANTIC_ALLOC
  108785             :     ROSE_ASSERT(Size == sizeof(SgOmpTargetTeamsStatement));
  108786             : #else
  108787           4 :     if (Size != sizeof(SgOmpTargetTeamsStatement)) {
  108788           0 :       void * object = ROSE_MALLOC(Size);
  108789           0 :       ALLOC_MUTEX(SgOmpTargetTeamsStatement, unlock);
  108790             :       return object;
  108791             :     }
  108792             : #endif
  108793             : 
  108794           4 :     if (SgOmpTargetTeamsStatement::next_node == nullptr) {
  108795           4 :         SgOmpTargetTeamsStatement * alloc = (SgOmpTargetTeamsStatement*) ROSE_MALLOC ( SgOmpTargetTeamsStatement::pool_size * sizeof(SgOmpTargetTeamsStatement) );
  108796           4 :         ROSE_ASSERT(alloc != nullptr);
  108797             : 
  108798             : #if ROSE_ALLOC_TRACE == 2
  108799             : //        printf("SgOmpTargetTeamsStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgOmpTargetTeamsStatement::pools.size(), alloc, alloc + SgOmpTargetTeamsStatement::pool_size);
  108800             : #endif
  108801             : 
  108802             : #if ROSE_ALLOC_MEMSET == 1
  108803             : #elif ROSE_ALLOC_MEMSET == 2
  108804             :         memset(alloc, 0x00, SgOmpTargetTeamsStatement::pool_size * sizeof(SgOmpTargetTeamsStatement));
  108805             : #elif ROSE_ALLOC_MEMSET == 3
  108806             :         memset(alloc, 0xAA, SgOmpTargetTeamsStatement::pool_size * sizeof(SgOmpTargetTeamsStatement));
  108807             : #endif
  108808        8000 :         for (unsigned i=0; i < SgOmpTargetTeamsStatement::pool_size-1; i++) {
  108809        7996 :           alloc[i].p_freepointer = &(alloc[i+1]);
  108810             :         }
  108811           4 :         alloc[SgOmpTargetTeamsStatement::pool_size-1].p_freepointer = nullptr;
  108812             : 
  108813           4 :         SgOmpTargetTeamsStatement::pools.push_back ( (unsigned char *) alloc );
  108814           4 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgOmpTargetTeamsStatement::pool_size * sizeof(SgOmpTargetTeamsStatement), V_SgOmpTargetTeamsStatement ) );
  108815           4 :         SgOmpTargetTeamsStatement::next_node = alloc;
  108816             :     }
  108817           4 :     ROSE_ASSERT(SgOmpTargetTeamsStatement::next_node != nullptr);
  108818             : 
  108819           4 :     SgOmpTargetTeamsStatement * object = SgOmpTargetTeamsStatement::next_node;
  108820           4 :     SgOmpTargetTeamsStatement::next_node = (SgOmpTargetTeamsStatement*)(object->p_freepointer);
  108821             : 
  108822             : #if ROSE_ALLOC_TRACE == 2
  108823             :     printf("SgOmpTargetTeamsStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpTargetTeamsStatement::next_node);
  108824             : #endif
  108825             : 
  108826           4 :     SgNode * fp = object->p_freepointer;
  108827             : #if ROSE_ALLOC_MEMSET == 1
  108828             : #elif ROSE_ALLOC_MEMSET == 2
  108829             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpTargetTeamsStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  108830             : #elif ROSE_ALLOC_MEMSET == 3
  108831             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgOmpTargetTeamsStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  108832             : #endif
  108833           4 :     object->p_freepointer = fp;
  108834             : 
  108835             : #if ROSE_ALLOC_TRACE == 2
  108836             : //    printf("SgOmpTargetTeamsStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpTargetTeamsStatement::next_node);
  108837             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  108838             :     Rose::MemPool::snapshot(oss.str());
  108839             :     alloc_trace_cnt++;
  108840             : #endif
  108841             : 
  108842           4 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  108843             : 
  108844           4 :     ALLOC_MUTEX(SgOmpTargetTeamsStatement, unlock);
  108845             : 
  108846             :     return object;
  108847             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  108848             : }
  108849             : 
  108850             : 
  108851             : 
  108852             : /*! \brief Delete operator for SgOmpTargetTeamsStatement.
  108853             : 
  108854             :    This delete operator implements deallocation using memory pools to 
  108855             :    provide most efficent use of the heap within construction of large ASTs.
  108856             : 
  108857             : \internal The new and delete operators use the lower level C malloc/free
  108858             :    function calls for performance and to make sure that mixing of malloc/free
  108859             :    and new/delete by the used can be caught more readily.  This may change
  108860             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  108861             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  108862             :    deallocate memory allocated using ROSE_MALLOC.
  108863             : */
  108864           0 : void SgOmpTargetTeamsStatement::operator delete(void *Pointer, size_t Size)
  108865             : {
  108866             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  108867             :      * or throwing an exception. */
  108868           0 :     ALLOC_MUTEX(SgOmpTargetTeamsStatement, lock);
  108869             : 
  108870             : #if USE_CPP_NEW_DELETE_OPERATORS
  108871             :     ROSE_FREE(Pointer);
  108872             : #else
  108873             : #if ROSE_PEDANTIC_ALLOC
  108874             :     ROSE_ASSERT(Size == sizeof(SgOmpTargetTeamsStatement));
  108875             : #else
  108876           0 :     if (Size != sizeof(SgOmpTargetTeamsStatement)) {
  108877           0 :       ROSE_FREE(Pointer);
  108878           0 :       ALLOC_MUTEX(SgOmpTargetTeamsStatement, unlock);
  108879             :       return;
  108880             :     }
  108881             : #endif
  108882             : 
  108883           0 :     SgOmpTargetTeamsStatement * object = (SgOmpTargetTeamsStatement*) Pointer;
  108884           0 :     ROSE_ASSERT(object != nullptr);
  108885             : 
  108886             : #if ROSE_ALLOC_TRACE == 2
  108887             : //  printf("SgOmpTargetTeamsStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpTargetTeamsStatement::next_node);
  108888             :     printf("SgOmpTargetTeamsStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpTargetTeamsStatement::next_node);
  108889             : #endif
  108890             : 
  108891             : #if ROSE_PEDANTIC_ALLOC
  108892             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  108893             : #endif
  108894             : 
  108895             : #if ROSE_ALLOC_MEMSET == 1
  108896             : #elif ROSE_ALLOC_MEMSET == 2
  108897             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpTargetTeamsStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  108898             : #elif ROSE_ALLOC_MEMSET == 3
  108899             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgOmpTargetTeamsStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  108900             : #endif
  108901             : 
  108902             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  108903             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  108904             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  108905             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  108906             : #else
  108907           0 :     object->p_freepointer = SgOmpTargetTeamsStatement::next_node;
  108908           0 :     SgOmpTargetTeamsStatement::next_node = object;
  108909             : #endif
  108910             : 
  108911             : #if ROSE_ALLOC_TRACE == 2
  108912             : //  printf("SgOmpTargetTeamsStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpTargetTeamsStatement::next_node);
  108913             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  108914             :     Rose::MemPool::snapshot(oss.str());
  108915             :     alloc_trace_cnt++;
  108916             : #endif
  108917             : 
  108918             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  108919             : 
  108920           0 :     ALLOC_MUTEX(SgOmpTargetTeamsStatement, unlock);
  108921             : }
  108922             : 
  108923             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  108924             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  108925             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  108926             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  108927             : // Also, note comment below from Robb (copied from the Common.code file).
  108928             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  108929             : //
  108930             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  108931             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  108932             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  108933             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  108934             : #if 0
  108935             : void SgOmpTargetTeamsStatement::operator delete(void* pointer) { SgOmpTargetTeamsStatement::operator delete (pointer, sizeof(SgOmpTargetTeamsStatement)); };
  108936             : #endif
  108937             : /* #line 108938 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  108938             : 
  108939             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  108940             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  108941             : // obviously imply C++.
  108942             : 
  108943             : // This implements the support within ROSE for memory pools.  Memory pools
  108944             : // support the most condensed usage of memory within the construction of
  108945             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  108946             : // by a new operator written for each class.
  108947             : 
  108948             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  108949             :     // User wants multi-thread support and POSIX threads are available.
  108950             : #   include <pthread.h>
  108951             :     static pthread_mutex_t SgOmpTargetTeamsDistributeStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  108952             : #else
  108953             :      // Cause synchronization to be skipped.
  108954             : #    ifndef ALLOC_MUTEX
  108955             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  108956             : #    endif
  108957             : #    ifdef _REENTRANT
  108958             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  108959             : #       ifdef _MSC_VER
  108960             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  108961             : #       else
  108962             : #           warning "POSIX threads are not available; synchronization being skipped"
  108963             : #       endif
  108964             : #    endif
  108965             : #endif
  108966             : 
  108967             : #ifndef ROSE_ALLOC_TRACE
  108968             : #  define ROSE_ALLOC_TRACE 0
  108969             : #endif
  108970             : 
  108971             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  108972             : #define ROSE_ALLOC_TRACE_CNT
  108973             : #include "memory-pool-snapshot.h"
  108974             : unsigned long alloc_trace_cnt = 0;
  108975             : #endif
  108976             : 
  108977             : #if ROSE_ALLOC_TRACE
  108978             : const unsigned SgOmpTargetTeamsDistributeStatement::pool_size = 5;
  108979             : #else
  108980             : const unsigned SgOmpTargetTeamsDistributeStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  108981             : #endif
  108982             : 
  108983             : #ifndef ROSE_ALLOC_MEMSET
  108984             : #  define ROSE_ALLOC_MEMSET 0
  108985             : #endif
  108986             : 
  108987             : #ifndef ROSE_PEDANTIC_ALLOC
  108988             : #  define ROSE_PEDANTIC_ALLOC 0
  108989             : #endif
  108990             : 
  108991             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  108992             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  108993             : #endif
  108994             : 
  108995             : #if !defined(SGNODE__ALL_POOLS)
  108996             : #define SGNODE__ALL_POOLS
  108997             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  108998             : #endif
  108999             : 
  109000             : SgOmpTargetTeamsDistributeStatement* SgOmpTargetTeamsDistributeStatement::next_node = nullptr;
  109001             : std::vector<unsigned char*> SgOmpTargetTeamsDistributeStatement::pools;
  109002             : 
  109003             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  109004             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  109005             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  109006             : // around this macro definition rather than each use).
  109007             : #ifndef ALLOC_MUTEX
  109008             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  109009             :         do {                                                                     \
  109010             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  109011             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  109012             :                 abort();                                                         \
  109013             :             }                                                                    \
  109014             :         } while (0);
  109015             : #endif
  109016             : 
  109017             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  109018             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  109019             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  109020             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  109021             : 
  109022             : /*! \brief New operator for SgOmpTargetTeamsDistributeStatement.
  109023             : 
  109024             :    This new operator implements memory pools to provide most efficent 
  109025             :    use of the heap within construction of large ASTs.
  109026             : 
  109027             : \internal The new and delete operators use the lower level C malloc/free
  109028             :    function calls for performance and to make sure that mixing of malloc/free
  109029             :    and new/delete by the used can be caught more readily.  This may change
  109030             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  109031             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  109032             :    deallocate memory allocated using ROSE_MALLOC.
  109033             : */
  109034           1 : void *SgOmpTargetTeamsDistributeStatement::operator new ( size_t Size )
  109035             : {
  109036             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  109037             :      * returning or throwing an exception. */
  109038           1 :     ALLOC_MUTEX(SgOmpTargetTeamsDistributeStatement, lock);
  109039             : 
  109040             : #if ROSE_ALLOC_TRACE == 2
  109041             : //    printf("SgOmpTargetTeamsDistributeStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgOmpTargetTeamsDistributeStatement::next_node);
  109042             : #endif
  109043             : 
  109044             : #if USE_CPP_NEW_DELETE_OPERATORS
  109045             :     void *mem = ROSE_MALLOC(Size);
  109046             :     ALLOC_MUTEX(SgOmpTargetTeamsDistributeStatement, unlock);
  109047             :     return mem;
  109048             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  109049             : #if ROSE_PEDANTIC_ALLOC
  109050             :     ROSE_ASSERT(Size == sizeof(SgOmpTargetTeamsDistributeStatement));
  109051             : #else
  109052           1 :     if (Size != sizeof(SgOmpTargetTeamsDistributeStatement)) {
  109053           0 :       void * object = ROSE_MALLOC(Size);
  109054           0 :       ALLOC_MUTEX(SgOmpTargetTeamsDistributeStatement, unlock);
  109055             :       return object;
  109056             :     }
  109057             : #endif
  109058             : 
  109059           1 :     if (SgOmpTargetTeamsDistributeStatement::next_node == nullptr) {
  109060           1 :         SgOmpTargetTeamsDistributeStatement * alloc = (SgOmpTargetTeamsDistributeStatement*) ROSE_MALLOC ( SgOmpTargetTeamsDistributeStatement::pool_size * sizeof(SgOmpTargetTeamsDistributeStatement) );
  109061           1 :         ROSE_ASSERT(alloc != nullptr);
  109062             : 
  109063             : #if ROSE_ALLOC_TRACE == 2
  109064             : //        printf("SgOmpTargetTeamsDistributeStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgOmpTargetTeamsDistributeStatement::pools.size(), alloc, alloc + SgOmpTargetTeamsDistributeStatement::pool_size);
  109065             : #endif
  109066             : 
  109067             : #if ROSE_ALLOC_MEMSET == 1
  109068             : #elif ROSE_ALLOC_MEMSET == 2
  109069             :         memset(alloc, 0x00, SgOmpTargetTeamsDistributeStatement::pool_size * sizeof(SgOmpTargetTeamsDistributeStatement));
  109070             : #elif ROSE_ALLOC_MEMSET == 3
  109071             :         memset(alloc, 0xAA, SgOmpTargetTeamsDistributeStatement::pool_size * sizeof(SgOmpTargetTeamsDistributeStatement));
  109072             : #endif
  109073        2000 :         for (unsigned i=0; i < SgOmpTargetTeamsDistributeStatement::pool_size-1; i++) {
  109074        1999 :           alloc[i].p_freepointer = &(alloc[i+1]);
  109075             :         }
  109076           1 :         alloc[SgOmpTargetTeamsDistributeStatement::pool_size-1].p_freepointer = nullptr;
  109077             : 
  109078           1 :         SgOmpTargetTeamsDistributeStatement::pools.push_back ( (unsigned char *) alloc );
  109079           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgOmpTargetTeamsDistributeStatement::pool_size * sizeof(SgOmpTargetTeamsDistributeStatement), V_SgOmpTargetTeamsDistributeStatement ) );
  109080           1 :         SgOmpTargetTeamsDistributeStatement::next_node = alloc;
  109081             :     }
  109082           1 :     ROSE_ASSERT(SgOmpTargetTeamsDistributeStatement::next_node != nullptr);
  109083             : 
  109084           1 :     SgOmpTargetTeamsDistributeStatement * object = SgOmpTargetTeamsDistributeStatement::next_node;
  109085           1 :     SgOmpTargetTeamsDistributeStatement::next_node = (SgOmpTargetTeamsDistributeStatement*)(object->p_freepointer);
  109086             : 
  109087             : #if ROSE_ALLOC_TRACE == 2
  109088             :     printf("SgOmpTargetTeamsDistributeStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpTargetTeamsDistributeStatement::next_node);
  109089             : #endif
  109090             : 
  109091           1 :     SgNode * fp = object->p_freepointer;
  109092             : #if ROSE_ALLOC_MEMSET == 1
  109093             : #elif ROSE_ALLOC_MEMSET == 2
  109094             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpTargetTeamsDistributeStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  109095             : #elif ROSE_ALLOC_MEMSET == 3
  109096             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgOmpTargetTeamsDistributeStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  109097             : #endif
  109098           1 :     object->p_freepointer = fp;
  109099             : 
  109100             : #if ROSE_ALLOC_TRACE == 2
  109101             : //    printf("SgOmpTargetTeamsDistributeStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpTargetTeamsDistributeStatement::next_node);
  109102             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  109103             :     Rose::MemPool::snapshot(oss.str());
  109104             :     alloc_trace_cnt++;
  109105             : #endif
  109106             : 
  109107           1 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  109108             : 
  109109           1 :     ALLOC_MUTEX(SgOmpTargetTeamsDistributeStatement, unlock);
  109110             : 
  109111             :     return object;
  109112             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  109113             : }
  109114             : 
  109115             : 
  109116             : 
  109117             : /*! \brief Delete operator for SgOmpTargetTeamsDistributeStatement.
  109118             : 
  109119             :    This delete operator implements deallocation using memory pools to 
  109120             :    provide most efficent use of the heap within construction of large ASTs.
  109121             : 
  109122             : \internal The new and delete operators use the lower level C malloc/free
  109123             :    function calls for performance and to make sure that mixing of malloc/free
  109124             :    and new/delete by the used can be caught more readily.  This may change
  109125             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  109126             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  109127             :    deallocate memory allocated using ROSE_MALLOC.
  109128             : */
  109129           0 : void SgOmpTargetTeamsDistributeStatement::operator delete(void *Pointer, size_t Size)
  109130             : {
  109131             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  109132             :      * or throwing an exception. */
  109133           0 :     ALLOC_MUTEX(SgOmpTargetTeamsDistributeStatement, lock);
  109134             : 
  109135             : #if USE_CPP_NEW_DELETE_OPERATORS
  109136             :     ROSE_FREE(Pointer);
  109137             : #else
  109138             : #if ROSE_PEDANTIC_ALLOC
  109139             :     ROSE_ASSERT(Size == sizeof(SgOmpTargetTeamsDistributeStatement));
  109140             : #else
  109141           0 :     if (Size != sizeof(SgOmpTargetTeamsDistributeStatement)) {
  109142           0 :       ROSE_FREE(Pointer);
  109143           0 :       ALLOC_MUTEX(SgOmpTargetTeamsDistributeStatement, unlock);
  109144             :       return;
  109145             :     }
  109146             : #endif
  109147             : 
  109148           0 :     SgOmpTargetTeamsDistributeStatement * object = (SgOmpTargetTeamsDistributeStatement*) Pointer;
  109149           0 :     ROSE_ASSERT(object != nullptr);
  109150             : 
  109151             : #if ROSE_ALLOC_TRACE == 2
  109152             : //  printf("SgOmpTargetTeamsDistributeStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpTargetTeamsDistributeStatement::next_node);
  109153             :     printf("SgOmpTargetTeamsDistributeStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpTargetTeamsDistributeStatement::next_node);
  109154             : #endif
  109155             : 
  109156             : #if ROSE_PEDANTIC_ALLOC
  109157             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  109158             : #endif
  109159             : 
  109160             : #if ROSE_ALLOC_MEMSET == 1
  109161             : #elif ROSE_ALLOC_MEMSET == 2
  109162             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpTargetTeamsDistributeStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  109163             : #elif ROSE_ALLOC_MEMSET == 3
  109164             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgOmpTargetTeamsDistributeStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  109165             : #endif
  109166             : 
  109167             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  109168             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  109169             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  109170             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  109171             : #else
  109172           0 :     object->p_freepointer = SgOmpTargetTeamsDistributeStatement::next_node;
  109173           0 :     SgOmpTargetTeamsDistributeStatement::next_node = object;
  109174             : #endif
  109175             : 
  109176             : #if ROSE_ALLOC_TRACE == 2
  109177             : //  printf("SgOmpTargetTeamsDistributeStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpTargetTeamsDistributeStatement::next_node);
  109178             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  109179             :     Rose::MemPool::snapshot(oss.str());
  109180             :     alloc_trace_cnt++;
  109181             : #endif
  109182             : 
  109183             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  109184             : 
  109185           0 :     ALLOC_MUTEX(SgOmpTargetTeamsDistributeStatement, unlock);
  109186             : }
  109187             : 
  109188             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  109189             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  109190             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  109191             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  109192             : // Also, note comment below from Robb (copied from the Common.code file).
  109193             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  109194             : //
  109195             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  109196             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  109197             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  109198             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  109199             : #if 0
  109200             : void SgOmpTargetTeamsDistributeStatement::operator delete(void* pointer) { SgOmpTargetTeamsDistributeStatement::operator delete (pointer, sizeof(SgOmpTargetTeamsDistributeStatement)); };
  109201             : #endif
  109202             : /* #line 109203 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  109203             : 
  109204             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  109205             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  109206             : // obviously imply C++.
  109207             : 
  109208             : // This implements the support within ROSE for memory pools.  Memory pools
  109209             : // support the most condensed usage of memory within the construction of
  109210             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  109211             : // by a new operator written for each class.
  109212             : 
  109213             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  109214             :     // User wants multi-thread support and POSIX threads are available.
  109215             : #   include <pthread.h>
  109216             :     static pthread_mutex_t SgOmpTargetTeamsDistributeSimdStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  109217             : #else
  109218             :      // Cause synchronization to be skipped.
  109219             : #    ifndef ALLOC_MUTEX
  109220             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  109221             : #    endif
  109222             : #    ifdef _REENTRANT
  109223             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  109224             : #       ifdef _MSC_VER
  109225             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  109226             : #       else
  109227             : #           warning "POSIX threads are not available; synchronization being skipped"
  109228             : #       endif
  109229             : #    endif
  109230             : #endif
  109231             : 
  109232             : #ifndef ROSE_ALLOC_TRACE
  109233             : #  define ROSE_ALLOC_TRACE 0
  109234             : #endif
  109235             : 
  109236             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  109237             : #define ROSE_ALLOC_TRACE_CNT
  109238             : #include "memory-pool-snapshot.h"
  109239             : unsigned long alloc_trace_cnt = 0;
  109240             : #endif
  109241             : 
  109242             : #if ROSE_ALLOC_TRACE
  109243             : const unsigned SgOmpTargetTeamsDistributeSimdStatement::pool_size = 5;
  109244             : #else
  109245             : const unsigned SgOmpTargetTeamsDistributeSimdStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  109246             : #endif
  109247             : 
  109248             : #ifndef ROSE_ALLOC_MEMSET
  109249             : #  define ROSE_ALLOC_MEMSET 0
  109250             : #endif
  109251             : 
  109252             : #ifndef ROSE_PEDANTIC_ALLOC
  109253             : #  define ROSE_PEDANTIC_ALLOC 0
  109254             : #endif
  109255             : 
  109256             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  109257             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  109258             : #endif
  109259             : 
  109260             : #if !defined(SGNODE__ALL_POOLS)
  109261             : #define SGNODE__ALL_POOLS
  109262             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  109263             : #endif
  109264             : 
  109265             : SgOmpTargetTeamsDistributeSimdStatement* SgOmpTargetTeamsDistributeSimdStatement::next_node = nullptr;
  109266             : std::vector<unsigned char*> SgOmpTargetTeamsDistributeSimdStatement::pools;
  109267             : 
  109268             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  109269             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  109270             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  109271             : // around this macro definition rather than each use).
  109272             : #ifndef ALLOC_MUTEX
  109273             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  109274             :         do {                                                                     \
  109275             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  109276             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  109277             :                 abort();                                                         \
  109278             :             }                                                                    \
  109279             :         } while (0);
  109280             : #endif
  109281             : 
  109282             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  109283             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  109284             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  109285             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  109286             : 
  109287             : /*! \brief New operator for SgOmpTargetTeamsDistributeSimdStatement.
  109288             : 
  109289             :    This new operator implements memory pools to provide most efficent 
  109290             :    use of the heap within construction of large ASTs.
  109291             : 
  109292             : \internal The new and delete operators use the lower level C malloc/free
  109293             :    function calls for performance and to make sure that mixing of malloc/free
  109294             :    and new/delete by the used can be caught more readily.  This may change
  109295             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  109296             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  109297             :    deallocate memory allocated using ROSE_MALLOC.
  109298             : */
  109299           1 : void *SgOmpTargetTeamsDistributeSimdStatement::operator new ( size_t Size )
  109300             : {
  109301             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  109302             :      * returning or throwing an exception. */
  109303           1 :     ALLOC_MUTEX(SgOmpTargetTeamsDistributeSimdStatement, lock);
  109304             : 
  109305             : #if ROSE_ALLOC_TRACE == 2
  109306             : //    printf("SgOmpTargetTeamsDistributeSimdStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgOmpTargetTeamsDistributeSimdStatement::next_node);
  109307             : #endif
  109308             : 
  109309             : #if USE_CPP_NEW_DELETE_OPERATORS
  109310             :     void *mem = ROSE_MALLOC(Size);
  109311             :     ALLOC_MUTEX(SgOmpTargetTeamsDistributeSimdStatement, unlock);
  109312             :     return mem;
  109313             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  109314             : #if ROSE_PEDANTIC_ALLOC
  109315             :     ROSE_ASSERT(Size == sizeof(SgOmpTargetTeamsDistributeSimdStatement));
  109316             : #else
  109317           1 :     if (Size != sizeof(SgOmpTargetTeamsDistributeSimdStatement)) {
  109318           0 :       void * object = ROSE_MALLOC(Size);
  109319           0 :       ALLOC_MUTEX(SgOmpTargetTeamsDistributeSimdStatement, unlock);
  109320             :       return object;
  109321             :     }
  109322             : #endif
  109323             : 
  109324           1 :     if (SgOmpTargetTeamsDistributeSimdStatement::next_node == nullptr) {
  109325           1 :         SgOmpTargetTeamsDistributeSimdStatement * alloc = (SgOmpTargetTeamsDistributeSimdStatement*) ROSE_MALLOC ( SgOmpTargetTeamsDistributeSimdStatement::pool_size * sizeof(SgOmpTargetTeamsDistributeSimdStatement) );
  109326           1 :         ROSE_ASSERT(alloc != nullptr);
  109327             : 
  109328             : #if ROSE_ALLOC_TRACE == 2
  109329             : //        printf("SgOmpTargetTeamsDistributeSimdStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgOmpTargetTeamsDistributeSimdStatement::pools.size(), alloc, alloc + SgOmpTargetTeamsDistributeSimdStatement::pool_size);
  109330             : #endif
  109331             : 
  109332             : #if ROSE_ALLOC_MEMSET == 1
  109333             : #elif ROSE_ALLOC_MEMSET == 2
  109334             :         memset(alloc, 0x00, SgOmpTargetTeamsDistributeSimdStatement::pool_size * sizeof(SgOmpTargetTeamsDistributeSimdStatement));
  109335             : #elif ROSE_ALLOC_MEMSET == 3
  109336             :         memset(alloc, 0xAA, SgOmpTargetTeamsDistributeSimdStatement::pool_size * sizeof(SgOmpTargetTeamsDistributeSimdStatement));
  109337             : #endif
  109338        2000 :         for (unsigned i=0; i < SgOmpTargetTeamsDistributeSimdStatement::pool_size-1; i++) {
  109339        1999 :           alloc[i].p_freepointer = &(alloc[i+1]);
  109340             :         }
  109341           1 :         alloc[SgOmpTargetTeamsDistributeSimdStatement::pool_size-1].p_freepointer = nullptr;
  109342             : 
  109343           1 :         SgOmpTargetTeamsDistributeSimdStatement::pools.push_back ( (unsigned char *) alloc );
  109344           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgOmpTargetTeamsDistributeSimdStatement::pool_size * sizeof(SgOmpTargetTeamsDistributeSimdStatement), V_SgOmpTargetTeamsDistributeSimdStatement ) );
  109345           1 :         SgOmpTargetTeamsDistributeSimdStatement::next_node = alloc;
  109346             :     }
  109347           1 :     ROSE_ASSERT(SgOmpTargetTeamsDistributeSimdStatement::next_node != nullptr);
  109348             : 
  109349           1 :     SgOmpTargetTeamsDistributeSimdStatement * object = SgOmpTargetTeamsDistributeSimdStatement::next_node;
  109350           1 :     SgOmpTargetTeamsDistributeSimdStatement::next_node = (SgOmpTargetTeamsDistributeSimdStatement*)(object->p_freepointer);
  109351             : 
  109352             : #if ROSE_ALLOC_TRACE == 2
  109353             :     printf("SgOmpTargetTeamsDistributeSimdStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpTargetTeamsDistributeSimdStatement::next_node);
  109354             : #endif
  109355             : 
  109356           1 :     SgNode * fp = object->p_freepointer;
  109357             : #if ROSE_ALLOC_MEMSET == 1
  109358             : #elif ROSE_ALLOC_MEMSET == 2
  109359             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpTargetTeamsDistributeSimdStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  109360             : #elif ROSE_ALLOC_MEMSET == 3
  109361             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgOmpTargetTeamsDistributeSimdStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  109362             : #endif
  109363           1 :     object->p_freepointer = fp;
  109364             : 
  109365             : #if ROSE_ALLOC_TRACE == 2
  109366             : //    printf("SgOmpTargetTeamsDistributeSimdStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpTargetTeamsDistributeSimdStatement::next_node);
  109367             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  109368             :     Rose::MemPool::snapshot(oss.str());
  109369             :     alloc_trace_cnt++;
  109370             : #endif
  109371             : 
  109372           1 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  109373             : 
  109374           1 :     ALLOC_MUTEX(SgOmpTargetTeamsDistributeSimdStatement, unlock);
  109375             : 
  109376             :     return object;
  109377             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  109378             : }
  109379             : 
  109380             : 
  109381             : 
  109382             : /*! \brief Delete operator for SgOmpTargetTeamsDistributeSimdStatement.
  109383             : 
  109384             :    This delete operator implements deallocation using memory pools to 
  109385             :    provide most efficent use of the heap within construction of large ASTs.
  109386             : 
  109387             : \internal The new and delete operators use the lower level C malloc/free
  109388             :    function calls for performance and to make sure that mixing of malloc/free
  109389             :    and new/delete by the used can be caught more readily.  This may change
  109390             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  109391             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  109392             :    deallocate memory allocated using ROSE_MALLOC.
  109393             : */
  109394           0 : void SgOmpTargetTeamsDistributeSimdStatement::operator delete(void *Pointer, size_t Size)
  109395             : {
  109396             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  109397             :      * or throwing an exception. */
  109398           0 :     ALLOC_MUTEX(SgOmpTargetTeamsDistributeSimdStatement, lock);
  109399             : 
  109400             : #if USE_CPP_NEW_DELETE_OPERATORS
  109401             :     ROSE_FREE(Pointer);
  109402             : #else
  109403             : #if ROSE_PEDANTIC_ALLOC
  109404             :     ROSE_ASSERT(Size == sizeof(SgOmpTargetTeamsDistributeSimdStatement));
  109405             : #else
  109406           0 :     if (Size != sizeof(SgOmpTargetTeamsDistributeSimdStatement)) {
  109407           0 :       ROSE_FREE(Pointer);
  109408           0 :       ALLOC_MUTEX(SgOmpTargetTeamsDistributeSimdStatement, unlock);
  109409             :       return;
  109410             :     }
  109411             : #endif
  109412             : 
  109413           0 :     SgOmpTargetTeamsDistributeSimdStatement * object = (SgOmpTargetTeamsDistributeSimdStatement*) Pointer;
  109414           0 :     ROSE_ASSERT(object != nullptr);
  109415             : 
  109416             : #if ROSE_ALLOC_TRACE == 2
  109417             : //  printf("SgOmpTargetTeamsDistributeSimdStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpTargetTeamsDistributeSimdStatement::next_node);
  109418             :     printf("SgOmpTargetTeamsDistributeSimdStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpTargetTeamsDistributeSimdStatement::next_node);
  109419             : #endif
  109420             : 
  109421             : #if ROSE_PEDANTIC_ALLOC
  109422             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  109423             : #endif
  109424             : 
  109425             : #if ROSE_ALLOC_MEMSET == 1
  109426             : #elif ROSE_ALLOC_MEMSET == 2
  109427             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpTargetTeamsDistributeSimdStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  109428             : #elif ROSE_ALLOC_MEMSET == 3
  109429             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgOmpTargetTeamsDistributeSimdStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  109430             : #endif
  109431             : 
  109432             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  109433             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  109434             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  109435             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  109436             : #else
  109437           0 :     object->p_freepointer = SgOmpTargetTeamsDistributeSimdStatement::next_node;
  109438           0 :     SgOmpTargetTeamsDistributeSimdStatement::next_node = object;
  109439             : #endif
  109440             : 
  109441             : #if ROSE_ALLOC_TRACE == 2
  109442             : //  printf("SgOmpTargetTeamsDistributeSimdStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpTargetTeamsDistributeSimdStatement::next_node);
  109443             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  109444             :     Rose::MemPool::snapshot(oss.str());
  109445             :     alloc_trace_cnt++;
  109446             : #endif
  109447             : 
  109448             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  109449             : 
  109450           0 :     ALLOC_MUTEX(SgOmpTargetTeamsDistributeSimdStatement, unlock);
  109451             : }
  109452             : 
  109453             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  109454             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  109455             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  109456             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  109457             : // Also, note comment below from Robb (copied from the Common.code file).
  109458             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  109459             : //
  109460             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  109461             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  109462             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  109463             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  109464             : #if 0
  109465             : void SgOmpTargetTeamsDistributeSimdStatement::operator delete(void* pointer) { SgOmpTargetTeamsDistributeSimdStatement::operator delete (pointer, sizeof(SgOmpTargetTeamsDistributeSimdStatement)); };
  109466             : #endif
  109467             : /* #line 109468 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  109468             : 
  109469             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  109470             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  109471             : // obviously imply C++.
  109472             : 
  109473             : // This implements the support within ROSE for memory pools.  Memory pools
  109474             : // support the most condensed usage of memory within the construction of
  109475             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  109476             : // by a new operator written for each class.
  109477             : 
  109478             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  109479             :     // User wants multi-thread support and POSIX threads are available.
  109480             : #   include <pthread.h>
  109481             :     static pthread_mutex_t SgOmpTargetTeamsLoopStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  109482             : #else
  109483             :      // Cause synchronization to be skipped.
  109484             : #    ifndef ALLOC_MUTEX
  109485             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  109486             : #    endif
  109487             : #    ifdef _REENTRANT
  109488             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  109489             : #       ifdef _MSC_VER
  109490             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  109491             : #       else
  109492             : #           warning "POSIX threads are not available; synchronization being skipped"
  109493             : #       endif
  109494             : #    endif
  109495             : #endif
  109496             : 
  109497             : #ifndef ROSE_ALLOC_TRACE
  109498             : #  define ROSE_ALLOC_TRACE 0
  109499             : #endif
  109500             : 
  109501             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  109502             : #define ROSE_ALLOC_TRACE_CNT
  109503             : #include "memory-pool-snapshot.h"
  109504             : unsigned long alloc_trace_cnt = 0;
  109505             : #endif
  109506             : 
  109507             : #if ROSE_ALLOC_TRACE
  109508             : const unsigned SgOmpTargetTeamsLoopStatement::pool_size = 5;
  109509             : #else
  109510             : const unsigned SgOmpTargetTeamsLoopStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  109511             : #endif
  109512             : 
  109513             : #ifndef ROSE_ALLOC_MEMSET
  109514             : #  define ROSE_ALLOC_MEMSET 0
  109515             : #endif
  109516             : 
  109517             : #ifndef ROSE_PEDANTIC_ALLOC
  109518             : #  define ROSE_PEDANTIC_ALLOC 0
  109519             : #endif
  109520             : 
  109521             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  109522             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  109523             : #endif
  109524             : 
  109525             : #if !defined(SGNODE__ALL_POOLS)
  109526             : #define SGNODE__ALL_POOLS
  109527             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  109528             : #endif
  109529             : 
  109530             : SgOmpTargetTeamsLoopStatement* SgOmpTargetTeamsLoopStatement::next_node = nullptr;
  109531             : std::vector<unsigned char*> SgOmpTargetTeamsLoopStatement::pools;
  109532             : 
  109533             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  109534             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  109535             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  109536             : // around this macro definition rather than each use).
  109537             : #ifndef ALLOC_MUTEX
  109538             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  109539             :         do {                                                                     \
  109540             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  109541             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  109542             :                 abort();                                                         \
  109543             :             }                                                                    \
  109544             :         } while (0);
  109545             : #endif
  109546             : 
  109547             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  109548             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  109549             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  109550             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  109551             : 
  109552             : /*! \brief New operator for SgOmpTargetTeamsLoopStatement.
  109553             : 
  109554             :    This new operator implements memory pools to provide most efficent 
  109555             :    use of the heap within construction of large ASTs.
  109556             : 
  109557             : \internal The new and delete operators use the lower level C malloc/free
  109558             :    function calls for performance and to make sure that mixing of malloc/free
  109559             :    and new/delete by the used can be caught more readily.  This may change
  109560             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  109561             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  109562             :    deallocate memory allocated using ROSE_MALLOC.
  109563             : */
  109564           1 : void *SgOmpTargetTeamsLoopStatement::operator new ( size_t Size )
  109565             : {
  109566             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  109567             :      * returning or throwing an exception. */
  109568           1 :     ALLOC_MUTEX(SgOmpTargetTeamsLoopStatement, lock);
  109569             : 
  109570             : #if ROSE_ALLOC_TRACE == 2
  109571             : //    printf("SgOmpTargetTeamsLoopStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgOmpTargetTeamsLoopStatement::next_node);
  109572             : #endif
  109573             : 
  109574             : #if USE_CPP_NEW_DELETE_OPERATORS
  109575             :     void *mem = ROSE_MALLOC(Size);
  109576             :     ALLOC_MUTEX(SgOmpTargetTeamsLoopStatement, unlock);
  109577             :     return mem;
  109578             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  109579             : #if ROSE_PEDANTIC_ALLOC
  109580             :     ROSE_ASSERT(Size == sizeof(SgOmpTargetTeamsLoopStatement));
  109581             : #else
  109582           1 :     if (Size != sizeof(SgOmpTargetTeamsLoopStatement)) {
  109583           0 :       void * object = ROSE_MALLOC(Size);
  109584           0 :       ALLOC_MUTEX(SgOmpTargetTeamsLoopStatement, unlock);
  109585             :       return object;
  109586             :     }
  109587             : #endif
  109588             : 
  109589           1 :     if (SgOmpTargetTeamsLoopStatement::next_node == nullptr) {
  109590           1 :         SgOmpTargetTeamsLoopStatement * alloc = (SgOmpTargetTeamsLoopStatement*) ROSE_MALLOC ( SgOmpTargetTeamsLoopStatement::pool_size * sizeof(SgOmpTargetTeamsLoopStatement) );
  109591           1 :         ROSE_ASSERT(alloc != nullptr);
  109592             : 
  109593             : #if ROSE_ALLOC_TRACE == 2
  109594             : //        printf("SgOmpTargetTeamsLoopStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgOmpTargetTeamsLoopStatement::pools.size(), alloc, alloc + SgOmpTargetTeamsLoopStatement::pool_size);
  109595             : #endif
  109596             : 
  109597             : #if ROSE_ALLOC_MEMSET == 1
  109598             : #elif ROSE_ALLOC_MEMSET == 2
  109599             :         memset(alloc, 0x00, SgOmpTargetTeamsLoopStatement::pool_size * sizeof(SgOmpTargetTeamsLoopStatement));
  109600             : #elif ROSE_ALLOC_MEMSET == 3
  109601             :         memset(alloc, 0xAA, SgOmpTargetTeamsLoopStatement::pool_size * sizeof(SgOmpTargetTeamsLoopStatement));
  109602             : #endif
  109603        2000 :         for (unsigned i=0; i < SgOmpTargetTeamsLoopStatement::pool_size-1; i++) {
  109604        1999 :           alloc[i].p_freepointer = &(alloc[i+1]);
  109605             :         }
  109606           1 :         alloc[SgOmpTargetTeamsLoopStatement::pool_size-1].p_freepointer = nullptr;
  109607             : 
  109608           1 :         SgOmpTargetTeamsLoopStatement::pools.push_back ( (unsigned char *) alloc );
  109609           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgOmpTargetTeamsLoopStatement::pool_size * sizeof(SgOmpTargetTeamsLoopStatement), V_SgOmpTargetTeamsLoopStatement ) );
  109610           1 :         SgOmpTargetTeamsLoopStatement::next_node = alloc;
  109611             :     }
  109612           1 :     ROSE_ASSERT(SgOmpTargetTeamsLoopStatement::next_node != nullptr);
  109613             : 
  109614           1 :     SgOmpTargetTeamsLoopStatement * object = SgOmpTargetTeamsLoopStatement::next_node;
  109615           1 :     SgOmpTargetTeamsLoopStatement::next_node = (SgOmpTargetTeamsLoopStatement*)(object->p_freepointer);
  109616             : 
  109617             : #if ROSE_ALLOC_TRACE == 2
  109618             :     printf("SgOmpTargetTeamsLoopStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpTargetTeamsLoopStatement::next_node);
  109619             : #endif
  109620             : 
  109621           1 :     SgNode * fp = object->p_freepointer;
  109622             : #if ROSE_ALLOC_MEMSET == 1
  109623             : #elif ROSE_ALLOC_MEMSET == 2
  109624             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpTargetTeamsLoopStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  109625             : #elif ROSE_ALLOC_MEMSET == 3
  109626             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgOmpTargetTeamsLoopStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  109627             : #endif
  109628           1 :     object->p_freepointer = fp;
  109629             : 
  109630             : #if ROSE_ALLOC_TRACE == 2
  109631             : //    printf("SgOmpTargetTeamsLoopStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpTargetTeamsLoopStatement::next_node);
  109632             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  109633             :     Rose::MemPool::snapshot(oss.str());
  109634             :     alloc_trace_cnt++;
  109635             : #endif
  109636             : 
  109637           1 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  109638             : 
  109639           1 :     ALLOC_MUTEX(SgOmpTargetTeamsLoopStatement, unlock);
  109640             : 
  109641             :     return object;
  109642             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  109643             : }
  109644             : 
  109645             : 
  109646             : 
  109647             : /*! \brief Delete operator for SgOmpTargetTeamsLoopStatement.
  109648             : 
  109649             :    This delete operator implements deallocation using memory pools to 
  109650             :    provide most efficent use of the heap within construction of large ASTs.
  109651             : 
  109652             : \internal The new and delete operators use the lower level C malloc/free
  109653             :    function calls for performance and to make sure that mixing of malloc/free
  109654             :    and new/delete by the used can be caught more readily.  This may change
  109655             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  109656             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  109657             :    deallocate memory allocated using ROSE_MALLOC.
  109658             : */
  109659           0 : void SgOmpTargetTeamsLoopStatement::operator delete(void *Pointer, size_t Size)
  109660             : {
  109661             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  109662             :      * or throwing an exception. */
  109663           0 :     ALLOC_MUTEX(SgOmpTargetTeamsLoopStatement, lock);
  109664             : 
  109665             : #if USE_CPP_NEW_DELETE_OPERATORS
  109666             :     ROSE_FREE(Pointer);
  109667             : #else
  109668             : #if ROSE_PEDANTIC_ALLOC
  109669             :     ROSE_ASSERT(Size == sizeof(SgOmpTargetTeamsLoopStatement));
  109670             : #else
  109671           0 :     if (Size != sizeof(SgOmpTargetTeamsLoopStatement)) {
  109672           0 :       ROSE_FREE(Pointer);
  109673           0 :       ALLOC_MUTEX(SgOmpTargetTeamsLoopStatement, unlock);
  109674             :       return;
  109675             :     }
  109676             : #endif
  109677             : 
  109678           0 :     SgOmpTargetTeamsLoopStatement * object = (SgOmpTargetTeamsLoopStatement*) Pointer;
  109679           0 :     ROSE_ASSERT(object != nullptr);
  109680             : 
  109681             : #if ROSE_ALLOC_TRACE == 2
  109682             : //  printf("SgOmpTargetTeamsLoopStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpTargetTeamsLoopStatement::next_node);
  109683             :     printf("SgOmpTargetTeamsLoopStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpTargetTeamsLoopStatement::next_node);
  109684             : #endif
  109685             : 
  109686             : #if ROSE_PEDANTIC_ALLOC
  109687             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  109688             : #endif
  109689             : 
  109690             : #if ROSE_ALLOC_MEMSET == 1
  109691             : #elif ROSE_ALLOC_MEMSET == 2
  109692             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpTargetTeamsLoopStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  109693             : #elif ROSE_ALLOC_MEMSET == 3
  109694             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgOmpTargetTeamsLoopStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  109695             : #endif
  109696             : 
  109697             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  109698             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  109699             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  109700             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  109701             : #else
  109702           0 :     object->p_freepointer = SgOmpTargetTeamsLoopStatement::next_node;
  109703           0 :     SgOmpTargetTeamsLoopStatement::next_node = object;
  109704             : #endif
  109705             : 
  109706             : #if ROSE_ALLOC_TRACE == 2
  109707             : //  printf("SgOmpTargetTeamsLoopStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpTargetTeamsLoopStatement::next_node);
  109708             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  109709             :     Rose::MemPool::snapshot(oss.str());
  109710             :     alloc_trace_cnt++;
  109711             : #endif
  109712             : 
  109713             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  109714             : 
  109715           0 :     ALLOC_MUTEX(SgOmpTargetTeamsLoopStatement, unlock);
  109716             : }
  109717             : 
  109718             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  109719             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  109720             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  109721             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  109722             : // Also, note comment below from Robb (copied from the Common.code file).
  109723             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  109724             : //
  109725             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  109726             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  109727             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  109728             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  109729             : #if 0
  109730             : void SgOmpTargetTeamsLoopStatement::operator delete(void* pointer) { SgOmpTargetTeamsLoopStatement::operator delete (pointer, sizeof(SgOmpTargetTeamsLoopStatement)); };
  109731             : #endif
  109732             : /* #line 109733 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  109733             : 
  109734             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  109735             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  109736             : // obviously imply C++.
  109737             : 
  109738             : // This implements the support within ROSE for memory pools.  Memory pools
  109739             : // support the most condensed usage of memory within the construction of
  109740             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  109741             : // by a new operator written for each class.
  109742             : 
  109743             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  109744             :     // User wants multi-thread support and POSIX threads are available.
  109745             : #   include <pthread.h>
  109746             :     static pthread_mutex_t SgOmpTargetTeamsDistributeParallelForStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  109747             : #else
  109748             :      // Cause synchronization to be skipped.
  109749             : #    ifndef ALLOC_MUTEX
  109750             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  109751             : #    endif
  109752             : #    ifdef _REENTRANT
  109753             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  109754             : #       ifdef _MSC_VER
  109755             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  109756             : #       else
  109757             : #           warning "POSIX threads are not available; synchronization being skipped"
  109758             : #       endif
  109759             : #    endif
  109760             : #endif
  109761             : 
  109762             : #ifndef ROSE_ALLOC_TRACE
  109763             : #  define ROSE_ALLOC_TRACE 0
  109764             : #endif
  109765             : 
  109766             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  109767             : #define ROSE_ALLOC_TRACE_CNT
  109768             : #include "memory-pool-snapshot.h"
  109769             : unsigned long alloc_trace_cnt = 0;
  109770             : #endif
  109771             : 
  109772             : #if ROSE_ALLOC_TRACE
  109773             : const unsigned SgOmpTargetTeamsDistributeParallelForStatement::pool_size = 5;
  109774             : #else
  109775             : const unsigned SgOmpTargetTeamsDistributeParallelForStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  109776             : #endif
  109777             : 
  109778             : #ifndef ROSE_ALLOC_MEMSET
  109779             : #  define ROSE_ALLOC_MEMSET 0
  109780             : #endif
  109781             : 
  109782             : #ifndef ROSE_PEDANTIC_ALLOC
  109783             : #  define ROSE_PEDANTIC_ALLOC 0
  109784             : #endif
  109785             : 
  109786             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  109787             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  109788             : #endif
  109789             : 
  109790             : #if !defined(SGNODE__ALL_POOLS)
  109791             : #define SGNODE__ALL_POOLS
  109792             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  109793             : #endif
  109794             : 
  109795             : SgOmpTargetTeamsDistributeParallelForStatement* SgOmpTargetTeamsDistributeParallelForStatement::next_node = nullptr;
  109796             : std::vector<unsigned char*> SgOmpTargetTeamsDistributeParallelForStatement::pools;
  109797             : 
  109798             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  109799             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  109800             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  109801             : // around this macro definition rather than each use).
  109802             : #ifndef ALLOC_MUTEX
  109803             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  109804             :         do {                                                                     \
  109805             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  109806             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  109807             :                 abort();                                                         \
  109808             :             }                                                                    \
  109809             :         } while (0);
  109810             : #endif
  109811             : 
  109812             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  109813             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  109814             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  109815             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  109816             : 
  109817             : /*! \brief New operator for SgOmpTargetTeamsDistributeParallelForStatement.
  109818             : 
  109819             :    This new operator implements memory pools to provide most efficent 
  109820             :    use of the heap within construction of large ASTs.
  109821             : 
  109822             : \internal The new and delete operators use the lower level C malloc/free
  109823             :    function calls for performance and to make sure that mixing of malloc/free
  109824             :    and new/delete by the used can be caught more readily.  This may change
  109825             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  109826             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  109827             :    deallocate memory allocated using ROSE_MALLOC.
  109828             : */
  109829           1 : void *SgOmpTargetTeamsDistributeParallelForStatement::operator new ( size_t Size )
  109830             : {
  109831             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  109832             :      * returning or throwing an exception. */
  109833           1 :     ALLOC_MUTEX(SgOmpTargetTeamsDistributeParallelForStatement, lock);
  109834             : 
  109835             : #if ROSE_ALLOC_TRACE == 2
  109836             : //    printf("SgOmpTargetTeamsDistributeParallelForStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgOmpTargetTeamsDistributeParallelForStatement::next_node);
  109837             : #endif
  109838             : 
  109839             : #if USE_CPP_NEW_DELETE_OPERATORS
  109840             :     void *mem = ROSE_MALLOC(Size);
  109841             :     ALLOC_MUTEX(SgOmpTargetTeamsDistributeParallelForStatement, unlock);
  109842             :     return mem;
  109843             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  109844             : #if ROSE_PEDANTIC_ALLOC
  109845             :     ROSE_ASSERT(Size == sizeof(SgOmpTargetTeamsDistributeParallelForStatement));
  109846             : #else
  109847           1 :     if (Size != sizeof(SgOmpTargetTeamsDistributeParallelForStatement)) {
  109848           0 :       void * object = ROSE_MALLOC(Size);
  109849           0 :       ALLOC_MUTEX(SgOmpTargetTeamsDistributeParallelForStatement, unlock);
  109850             :       return object;
  109851             :     }
  109852             : #endif
  109853             : 
  109854           1 :     if (SgOmpTargetTeamsDistributeParallelForStatement::next_node == nullptr) {
  109855           1 :         SgOmpTargetTeamsDistributeParallelForStatement * alloc = (SgOmpTargetTeamsDistributeParallelForStatement*) ROSE_MALLOC ( SgOmpTargetTeamsDistributeParallelForStatement::pool_size * sizeof(SgOmpTargetTeamsDistributeParallelForStatement) );
  109856           1 :         ROSE_ASSERT(alloc != nullptr);
  109857             : 
  109858             : #if ROSE_ALLOC_TRACE == 2
  109859             : //        printf("SgOmpTargetTeamsDistributeParallelForStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgOmpTargetTeamsDistributeParallelForStatement::pools.size(), alloc, alloc + SgOmpTargetTeamsDistributeParallelForStatement::pool_size);
  109860             : #endif
  109861             : 
  109862             : #if ROSE_ALLOC_MEMSET == 1
  109863             : #elif ROSE_ALLOC_MEMSET == 2
  109864             :         memset(alloc, 0x00, SgOmpTargetTeamsDistributeParallelForStatement::pool_size * sizeof(SgOmpTargetTeamsDistributeParallelForStatement));
  109865             : #elif ROSE_ALLOC_MEMSET == 3
  109866             :         memset(alloc, 0xAA, SgOmpTargetTeamsDistributeParallelForStatement::pool_size * sizeof(SgOmpTargetTeamsDistributeParallelForStatement));
  109867             : #endif
  109868        2000 :         for (unsigned i=0; i < SgOmpTargetTeamsDistributeParallelForStatement::pool_size-1; i++) {
  109869        1999 :           alloc[i].p_freepointer = &(alloc[i+1]);
  109870             :         }
  109871           1 :         alloc[SgOmpTargetTeamsDistributeParallelForStatement::pool_size-1].p_freepointer = nullptr;
  109872             : 
  109873           1 :         SgOmpTargetTeamsDistributeParallelForStatement::pools.push_back ( (unsigned char *) alloc );
  109874           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgOmpTargetTeamsDistributeParallelForStatement::pool_size * sizeof(SgOmpTargetTeamsDistributeParallelForStatement), V_SgOmpTargetTeamsDistributeParallelForStatement ) );
  109875           1 :         SgOmpTargetTeamsDistributeParallelForStatement::next_node = alloc;
  109876             :     }
  109877           1 :     ROSE_ASSERT(SgOmpTargetTeamsDistributeParallelForStatement::next_node != nullptr);
  109878             : 
  109879           1 :     SgOmpTargetTeamsDistributeParallelForStatement * object = SgOmpTargetTeamsDistributeParallelForStatement::next_node;
  109880           1 :     SgOmpTargetTeamsDistributeParallelForStatement::next_node = (SgOmpTargetTeamsDistributeParallelForStatement*)(object->p_freepointer);
  109881             : 
  109882             : #if ROSE_ALLOC_TRACE == 2
  109883             :     printf("SgOmpTargetTeamsDistributeParallelForStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpTargetTeamsDistributeParallelForStatement::next_node);
  109884             : #endif
  109885             : 
  109886           1 :     SgNode * fp = object->p_freepointer;
  109887             : #if ROSE_ALLOC_MEMSET == 1
  109888             : #elif ROSE_ALLOC_MEMSET == 2
  109889             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpTargetTeamsDistributeParallelForStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  109890             : #elif ROSE_ALLOC_MEMSET == 3
  109891             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgOmpTargetTeamsDistributeParallelForStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  109892             : #endif
  109893           1 :     object->p_freepointer = fp;
  109894             : 
  109895             : #if ROSE_ALLOC_TRACE == 2
  109896             : //    printf("SgOmpTargetTeamsDistributeParallelForStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpTargetTeamsDistributeParallelForStatement::next_node);
  109897             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  109898             :     Rose::MemPool::snapshot(oss.str());
  109899             :     alloc_trace_cnt++;
  109900             : #endif
  109901             : 
  109902           1 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  109903             : 
  109904           1 :     ALLOC_MUTEX(SgOmpTargetTeamsDistributeParallelForStatement, unlock);
  109905             : 
  109906             :     return object;
  109907             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  109908             : }
  109909             : 
  109910             : 
  109911             : 
  109912             : /*! \brief Delete operator for SgOmpTargetTeamsDistributeParallelForStatement.
  109913             : 
  109914             :    This delete operator implements deallocation using memory pools to 
  109915             :    provide most efficent use of the heap within construction of large ASTs.
  109916             : 
  109917             : \internal The new and delete operators use the lower level C malloc/free
  109918             :    function calls for performance and to make sure that mixing of malloc/free
  109919             :    and new/delete by the used can be caught more readily.  This may change
  109920             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  109921             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  109922             :    deallocate memory allocated using ROSE_MALLOC.
  109923             : */
  109924           0 : void SgOmpTargetTeamsDistributeParallelForStatement::operator delete(void *Pointer, size_t Size)
  109925             : {
  109926             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  109927             :      * or throwing an exception. */
  109928           0 :     ALLOC_MUTEX(SgOmpTargetTeamsDistributeParallelForStatement, lock);
  109929             : 
  109930             : #if USE_CPP_NEW_DELETE_OPERATORS
  109931             :     ROSE_FREE(Pointer);
  109932             : #else
  109933             : #if ROSE_PEDANTIC_ALLOC
  109934             :     ROSE_ASSERT(Size == sizeof(SgOmpTargetTeamsDistributeParallelForStatement));
  109935             : #else
  109936           0 :     if (Size != sizeof(SgOmpTargetTeamsDistributeParallelForStatement)) {
  109937           0 :       ROSE_FREE(Pointer);
  109938           0 :       ALLOC_MUTEX(SgOmpTargetTeamsDistributeParallelForStatement, unlock);
  109939             :       return;
  109940             :     }
  109941             : #endif
  109942             : 
  109943           0 :     SgOmpTargetTeamsDistributeParallelForStatement * object = (SgOmpTargetTeamsDistributeParallelForStatement*) Pointer;
  109944           0 :     ROSE_ASSERT(object != nullptr);
  109945             : 
  109946             : #if ROSE_ALLOC_TRACE == 2
  109947             : //  printf("SgOmpTargetTeamsDistributeParallelForStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpTargetTeamsDistributeParallelForStatement::next_node);
  109948             :     printf("SgOmpTargetTeamsDistributeParallelForStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpTargetTeamsDistributeParallelForStatement::next_node);
  109949             : #endif
  109950             : 
  109951             : #if ROSE_PEDANTIC_ALLOC
  109952             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  109953             : #endif
  109954             : 
  109955             : #if ROSE_ALLOC_MEMSET == 1
  109956             : #elif ROSE_ALLOC_MEMSET == 2
  109957             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpTargetTeamsDistributeParallelForStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  109958             : #elif ROSE_ALLOC_MEMSET == 3
  109959             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgOmpTargetTeamsDistributeParallelForStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  109960             : #endif
  109961             : 
  109962             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  109963             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  109964             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  109965             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  109966             : #else
  109967           0 :     object->p_freepointer = SgOmpTargetTeamsDistributeParallelForStatement::next_node;
  109968           0 :     SgOmpTargetTeamsDistributeParallelForStatement::next_node = object;
  109969             : #endif
  109970             : 
  109971             : #if ROSE_ALLOC_TRACE == 2
  109972             : //  printf("SgOmpTargetTeamsDistributeParallelForStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpTargetTeamsDistributeParallelForStatement::next_node);
  109973             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  109974             :     Rose::MemPool::snapshot(oss.str());
  109975             :     alloc_trace_cnt++;
  109976             : #endif
  109977             : 
  109978             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  109979             : 
  109980           0 :     ALLOC_MUTEX(SgOmpTargetTeamsDistributeParallelForStatement, unlock);
  109981             : }
  109982             : 
  109983             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  109984             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  109985             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  109986             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  109987             : // Also, note comment below from Robb (copied from the Common.code file).
  109988             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  109989             : //
  109990             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  109991             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  109992             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  109993             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  109994             : #if 0
  109995             : void SgOmpTargetTeamsDistributeParallelForStatement::operator delete(void* pointer) { SgOmpTargetTeamsDistributeParallelForStatement::operator delete (pointer, sizeof(SgOmpTargetTeamsDistributeParallelForStatement)); };
  109996             : #endif
  109997             : /* #line 109998 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  109998             : 
  109999             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  110000             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  110001             : // obviously imply C++.
  110002             : 
  110003             : // This implements the support within ROSE for memory pools.  Memory pools
  110004             : // support the most condensed usage of memory within the construction of
  110005             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  110006             : // by a new operator written for each class.
  110007             : 
  110008             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  110009             :     // User wants multi-thread support and POSIX threads are available.
  110010             : #   include <pthread.h>
  110011             :     static pthread_mutex_t SgOmpTargetTeamsDistributeParallelForSimdStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  110012             : #else
  110013             :      // Cause synchronization to be skipped.
  110014             : #    ifndef ALLOC_MUTEX
  110015             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  110016             : #    endif
  110017             : #    ifdef _REENTRANT
  110018             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  110019             : #       ifdef _MSC_VER
  110020             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  110021             : #       else
  110022             : #           warning "POSIX threads are not available; synchronization being skipped"
  110023             : #       endif
  110024             : #    endif
  110025             : #endif
  110026             : 
  110027             : #ifndef ROSE_ALLOC_TRACE
  110028             : #  define ROSE_ALLOC_TRACE 0
  110029             : #endif
  110030             : 
  110031             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  110032             : #define ROSE_ALLOC_TRACE_CNT
  110033             : #include "memory-pool-snapshot.h"
  110034             : unsigned long alloc_trace_cnt = 0;
  110035             : #endif
  110036             : 
  110037             : #if ROSE_ALLOC_TRACE
  110038             : const unsigned SgOmpTargetTeamsDistributeParallelForSimdStatement::pool_size = 5;
  110039             : #else
  110040             : const unsigned SgOmpTargetTeamsDistributeParallelForSimdStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  110041             : #endif
  110042             : 
  110043             : #ifndef ROSE_ALLOC_MEMSET
  110044             : #  define ROSE_ALLOC_MEMSET 0
  110045             : #endif
  110046             : 
  110047             : #ifndef ROSE_PEDANTIC_ALLOC
  110048             : #  define ROSE_PEDANTIC_ALLOC 0
  110049             : #endif
  110050             : 
  110051             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  110052             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  110053             : #endif
  110054             : 
  110055             : #if !defined(SGNODE__ALL_POOLS)
  110056             : #define SGNODE__ALL_POOLS
  110057             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  110058             : #endif
  110059             : 
  110060             : SgOmpTargetTeamsDistributeParallelForSimdStatement* SgOmpTargetTeamsDistributeParallelForSimdStatement::next_node = nullptr;
  110061             : std::vector<unsigned char*> SgOmpTargetTeamsDistributeParallelForSimdStatement::pools;
  110062             : 
  110063             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  110064             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  110065             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  110066             : // around this macro definition rather than each use).
  110067             : #ifndef ALLOC_MUTEX
  110068             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  110069             :         do {                                                                     \
  110070             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  110071             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  110072             :                 abort();                                                         \
  110073             :             }                                                                    \
  110074             :         } while (0);
  110075             : #endif
  110076             : 
  110077             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  110078             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  110079             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  110080             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  110081             : 
  110082             : /*! \brief New operator for SgOmpTargetTeamsDistributeParallelForSimdStatement.
  110083             : 
  110084             :    This new operator implements memory pools to provide most efficent 
  110085             :    use of the heap within construction of large ASTs.
  110086             : 
  110087             : \internal The new and delete operators use the lower level C malloc/free
  110088             :    function calls for performance and to make sure that mixing of malloc/free
  110089             :    and new/delete by the used can be caught more readily.  This may change
  110090             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  110091             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  110092             :    deallocate memory allocated using ROSE_MALLOC.
  110093             : */
  110094           1 : void *SgOmpTargetTeamsDistributeParallelForSimdStatement::operator new ( size_t Size )
  110095             : {
  110096             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  110097             :      * returning or throwing an exception. */
  110098           1 :     ALLOC_MUTEX(SgOmpTargetTeamsDistributeParallelForSimdStatement, lock);
  110099             : 
  110100             : #if ROSE_ALLOC_TRACE == 2
  110101             : //    printf("SgOmpTargetTeamsDistributeParallelForSimdStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgOmpTargetTeamsDistributeParallelForSimdStatement::next_node);
  110102             : #endif
  110103             : 
  110104             : #if USE_CPP_NEW_DELETE_OPERATORS
  110105             :     void *mem = ROSE_MALLOC(Size);
  110106             :     ALLOC_MUTEX(SgOmpTargetTeamsDistributeParallelForSimdStatement, unlock);
  110107             :     return mem;
  110108             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  110109             : #if ROSE_PEDANTIC_ALLOC
  110110             :     ROSE_ASSERT(Size == sizeof(SgOmpTargetTeamsDistributeParallelForSimdStatement));
  110111             : #else
  110112           1 :     if (Size != sizeof(SgOmpTargetTeamsDistributeParallelForSimdStatement)) {
  110113           0 :       void * object = ROSE_MALLOC(Size);
  110114           0 :       ALLOC_MUTEX(SgOmpTargetTeamsDistributeParallelForSimdStatement, unlock);
  110115             :       return object;
  110116             :     }
  110117             : #endif
  110118             : 
  110119           1 :     if (SgOmpTargetTeamsDistributeParallelForSimdStatement::next_node == nullptr) {
  110120           1 :         SgOmpTargetTeamsDistributeParallelForSimdStatement * alloc = (SgOmpTargetTeamsDistributeParallelForSimdStatement*) ROSE_MALLOC ( SgOmpTargetTeamsDistributeParallelForSimdStatement::pool_size * sizeof(SgOmpTargetTeamsDistributeParallelForSimdStatement) );
  110121           1 :         ROSE_ASSERT(alloc != nullptr);
  110122             : 
  110123             : #if ROSE_ALLOC_TRACE == 2
  110124             : //        printf("SgOmpTargetTeamsDistributeParallelForSimdStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgOmpTargetTeamsDistributeParallelForSimdStatement::pools.size(), alloc, alloc + SgOmpTargetTeamsDistributeParallelForSimdStatement::pool_size);
  110125             : #endif
  110126             : 
  110127             : #if ROSE_ALLOC_MEMSET == 1
  110128             : #elif ROSE_ALLOC_MEMSET == 2
  110129             :         memset(alloc, 0x00, SgOmpTargetTeamsDistributeParallelForSimdStatement::pool_size * sizeof(SgOmpTargetTeamsDistributeParallelForSimdStatement));
  110130             : #elif ROSE_ALLOC_MEMSET == 3
  110131             :         memset(alloc, 0xAA, SgOmpTargetTeamsDistributeParallelForSimdStatement::pool_size * sizeof(SgOmpTargetTeamsDistributeParallelForSimdStatement));
  110132             : #endif
  110133        2000 :         for (unsigned i=0; i < SgOmpTargetTeamsDistributeParallelForSimdStatement::pool_size-1; i++) {
  110134        1999 :           alloc[i].p_freepointer = &(alloc[i+1]);
  110135             :         }
  110136           1 :         alloc[SgOmpTargetTeamsDistributeParallelForSimdStatement::pool_size-1].p_freepointer = nullptr;
  110137             : 
  110138           1 :         SgOmpTargetTeamsDistributeParallelForSimdStatement::pools.push_back ( (unsigned char *) alloc );
  110139           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgOmpTargetTeamsDistributeParallelForSimdStatement::pool_size * sizeof(SgOmpTargetTeamsDistributeParallelForSimdStatement), V_SgOmpTargetTeamsDistributeParallelForSimdStatement ) );
  110140           1 :         SgOmpTargetTeamsDistributeParallelForSimdStatement::next_node = alloc;
  110141             :     }
  110142           1 :     ROSE_ASSERT(SgOmpTargetTeamsDistributeParallelForSimdStatement::next_node != nullptr);
  110143             : 
  110144           1 :     SgOmpTargetTeamsDistributeParallelForSimdStatement * object = SgOmpTargetTeamsDistributeParallelForSimdStatement::next_node;
  110145           1 :     SgOmpTargetTeamsDistributeParallelForSimdStatement::next_node = (SgOmpTargetTeamsDistributeParallelForSimdStatement*)(object->p_freepointer);
  110146             : 
  110147             : #if ROSE_ALLOC_TRACE == 2
  110148             :     printf("SgOmpTargetTeamsDistributeParallelForSimdStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpTargetTeamsDistributeParallelForSimdStatement::next_node);
  110149             : #endif
  110150             : 
  110151           1 :     SgNode * fp = object->p_freepointer;
  110152             : #if ROSE_ALLOC_MEMSET == 1
  110153             : #elif ROSE_ALLOC_MEMSET == 2
  110154             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpTargetTeamsDistributeParallelForSimdStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  110155             : #elif ROSE_ALLOC_MEMSET == 3
  110156             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgOmpTargetTeamsDistributeParallelForSimdStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  110157             : #endif
  110158           1 :     object->p_freepointer = fp;
  110159             : 
  110160             : #if ROSE_ALLOC_TRACE == 2
  110161             : //    printf("SgOmpTargetTeamsDistributeParallelForSimdStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpTargetTeamsDistributeParallelForSimdStatement::next_node);
  110162             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  110163             :     Rose::MemPool::snapshot(oss.str());
  110164             :     alloc_trace_cnt++;
  110165             : #endif
  110166             : 
  110167           1 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  110168             : 
  110169           1 :     ALLOC_MUTEX(SgOmpTargetTeamsDistributeParallelForSimdStatement, unlock);
  110170             : 
  110171             :     return object;
  110172             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  110173             : }
  110174             : 
  110175             : 
  110176             : 
  110177             : /*! \brief Delete operator for SgOmpTargetTeamsDistributeParallelForSimdStatement.
  110178             : 
  110179             :    This delete operator implements deallocation using memory pools to 
  110180             :    provide most efficent use of the heap within construction of large ASTs.
  110181             : 
  110182             : \internal The new and delete operators use the lower level C malloc/free
  110183             :    function calls for performance and to make sure that mixing of malloc/free
  110184             :    and new/delete by the used can be caught more readily.  This may change
  110185             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  110186             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  110187             :    deallocate memory allocated using ROSE_MALLOC.
  110188             : */
  110189           0 : void SgOmpTargetTeamsDistributeParallelForSimdStatement::operator delete(void *Pointer, size_t Size)
  110190             : {
  110191             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  110192             :      * or throwing an exception. */
  110193           0 :     ALLOC_MUTEX(SgOmpTargetTeamsDistributeParallelForSimdStatement, lock);
  110194             : 
  110195             : #if USE_CPP_NEW_DELETE_OPERATORS
  110196             :     ROSE_FREE(Pointer);
  110197             : #else
  110198             : #if ROSE_PEDANTIC_ALLOC
  110199             :     ROSE_ASSERT(Size == sizeof(SgOmpTargetTeamsDistributeParallelForSimdStatement));
  110200             : #else
  110201           0 :     if (Size != sizeof(SgOmpTargetTeamsDistributeParallelForSimdStatement)) {
  110202           0 :       ROSE_FREE(Pointer);
  110203           0 :       ALLOC_MUTEX(SgOmpTargetTeamsDistributeParallelForSimdStatement, unlock);
  110204             :       return;
  110205             :     }
  110206             : #endif
  110207             : 
  110208           0 :     SgOmpTargetTeamsDistributeParallelForSimdStatement * object = (SgOmpTargetTeamsDistributeParallelForSimdStatement*) Pointer;
  110209           0 :     ROSE_ASSERT(object != nullptr);
  110210             : 
  110211             : #if ROSE_ALLOC_TRACE == 2
  110212             : //  printf("SgOmpTargetTeamsDistributeParallelForSimdStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpTargetTeamsDistributeParallelForSimdStatement::next_node);
  110213             :     printf("SgOmpTargetTeamsDistributeParallelForSimdStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpTargetTeamsDistributeParallelForSimdStatement::next_node);
  110214             : #endif
  110215             : 
  110216             : #if ROSE_PEDANTIC_ALLOC
  110217             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  110218             : #endif
  110219             : 
  110220             : #if ROSE_ALLOC_MEMSET == 1
  110221             : #elif ROSE_ALLOC_MEMSET == 2
  110222             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpTargetTeamsDistributeParallelForSimdStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  110223             : #elif ROSE_ALLOC_MEMSET == 3
  110224             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgOmpTargetTeamsDistributeParallelForSimdStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  110225             : #endif
  110226             : 
  110227             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  110228             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  110229             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  110230             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  110231             : #else
  110232           0 :     object->p_freepointer = SgOmpTargetTeamsDistributeParallelForSimdStatement::next_node;
  110233           0 :     SgOmpTargetTeamsDistributeParallelForSimdStatement::next_node = object;
  110234             : #endif
  110235             : 
  110236             : #if ROSE_ALLOC_TRACE == 2
  110237             : //  printf("SgOmpTargetTeamsDistributeParallelForSimdStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpTargetTeamsDistributeParallelForSimdStatement::next_node);
  110238             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  110239             :     Rose::MemPool::snapshot(oss.str());
  110240             :     alloc_trace_cnt++;
  110241             : #endif
  110242             : 
  110243             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  110244             : 
  110245           0 :     ALLOC_MUTEX(SgOmpTargetTeamsDistributeParallelForSimdStatement, unlock);
  110246             : }
  110247             : 
  110248             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  110249             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  110250             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  110251             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  110252             : // Also, note comment below from Robb (copied from the Common.code file).
  110253             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  110254             : //
  110255             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  110256             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  110257             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  110258             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  110259             : #if 0
  110260             : void SgOmpTargetTeamsDistributeParallelForSimdStatement::operator delete(void* pointer) { SgOmpTargetTeamsDistributeParallelForSimdStatement::operator delete (pointer, sizeof(SgOmpTargetTeamsDistributeParallelForSimdStatement)); };
  110261             : #endif
  110262             : /* #line 110263 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  110263             : 
  110264             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  110265             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  110266             : // obviously imply C++.
  110267             : 
  110268             : // This implements the support within ROSE for memory pools.  Memory pools
  110269             : // support the most condensed usage of memory within the construction of
  110270             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  110271             : // by a new operator written for each class.
  110272             : 
  110273             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  110274             :     // User wants multi-thread support and POSIX threads are available.
  110275             : #   include <pthread.h>
  110276             :     static pthread_mutex_t SgOmpDistributeSimdStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  110277             : #else
  110278             :      // Cause synchronization to be skipped.
  110279             : #    ifndef ALLOC_MUTEX
  110280             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  110281             : #    endif
  110282             : #    ifdef _REENTRANT
  110283             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  110284             : #       ifdef _MSC_VER
  110285             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  110286             : #       else
  110287             : #           warning "POSIX threads are not available; synchronization being skipped"
  110288             : #       endif
  110289             : #    endif
  110290             : #endif
  110291             : 
  110292             : #ifndef ROSE_ALLOC_TRACE
  110293             : #  define ROSE_ALLOC_TRACE 0
  110294             : #endif
  110295             : 
  110296             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  110297             : #define ROSE_ALLOC_TRACE_CNT
  110298             : #include "memory-pool-snapshot.h"
  110299             : unsigned long alloc_trace_cnt = 0;
  110300             : #endif
  110301             : 
  110302             : #if ROSE_ALLOC_TRACE
  110303             : const unsigned SgOmpDistributeSimdStatement::pool_size = 5;
  110304             : #else
  110305             : const unsigned SgOmpDistributeSimdStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  110306             : #endif
  110307             : 
  110308             : #ifndef ROSE_ALLOC_MEMSET
  110309             : #  define ROSE_ALLOC_MEMSET 0
  110310             : #endif
  110311             : 
  110312             : #ifndef ROSE_PEDANTIC_ALLOC
  110313             : #  define ROSE_PEDANTIC_ALLOC 0
  110314             : #endif
  110315             : 
  110316             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  110317             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  110318             : #endif
  110319             : 
  110320             : #if !defined(SGNODE__ALL_POOLS)
  110321             : #define SGNODE__ALL_POOLS
  110322             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  110323             : #endif
  110324             : 
  110325             : SgOmpDistributeSimdStatement* SgOmpDistributeSimdStatement::next_node = nullptr;
  110326             : std::vector<unsigned char*> SgOmpDistributeSimdStatement::pools;
  110327             : 
  110328             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  110329             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  110330             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  110331             : // around this macro definition rather than each use).
  110332             : #ifndef ALLOC_MUTEX
  110333             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  110334             :         do {                                                                     \
  110335             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  110336             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  110337             :                 abort();                                                         \
  110338             :             }                                                                    \
  110339             :         } while (0);
  110340             : #endif
  110341             : 
  110342             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  110343             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  110344             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  110345             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  110346             : 
  110347             : /*! \brief New operator for SgOmpDistributeSimdStatement.
  110348             : 
  110349             :    This new operator implements memory pools to provide most efficent 
  110350             :    use of the heap within construction of large ASTs.
  110351             : 
  110352             : \internal The new and delete operators use the lower level C malloc/free
  110353             :    function calls for performance and to make sure that mixing of malloc/free
  110354             :    and new/delete by the used can be caught more readily.  This may change
  110355             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  110356             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  110357             :    deallocate memory allocated using ROSE_MALLOC.
  110358             : */
  110359           1 : void *SgOmpDistributeSimdStatement::operator new ( size_t Size )
  110360             : {
  110361             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  110362             :      * returning or throwing an exception. */
  110363           1 :     ALLOC_MUTEX(SgOmpDistributeSimdStatement, lock);
  110364             : 
  110365             : #if ROSE_ALLOC_TRACE == 2
  110366             : //    printf("SgOmpDistributeSimdStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgOmpDistributeSimdStatement::next_node);
  110367             : #endif
  110368             : 
  110369             : #if USE_CPP_NEW_DELETE_OPERATORS
  110370             :     void *mem = ROSE_MALLOC(Size);
  110371             :     ALLOC_MUTEX(SgOmpDistributeSimdStatement, unlock);
  110372             :     return mem;
  110373             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  110374             : #if ROSE_PEDANTIC_ALLOC
  110375             :     ROSE_ASSERT(Size == sizeof(SgOmpDistributeSimdStatement));
  110376             : #else
  110377           1 :     if (Size != sizeof(SgOmpDistributeSimdStatement)) {
  110378           0 :       void * object = ROSE_MALLOC(Size);
  110379           0 :       ALLOC_MUTEX(SgOmpDistributeSimdStatement, unlock);
  110380             :       return object;
  110381             :     }
  110382             : #endif
  110383             : 
  110384           1 :     if (SgOmpDistributeSimdStatement::next_node == nullptr) {
  110385           1 :         SgOmpDistributeSimdStatement * alloc = (SgOmpDistributeSimdStatement*) ROSE_MALLOC ( SgOmpDistributeSimdStatement::pool_size * sizeof(SgOmpDistributeSimdStatement) );
  110386           1 :         ROSE_ASSERT(alloc != nullptr);
  110387             : 
  110388             : #if ROSE_ALLOC_TRACE == 2
  110389             : //        printf("SgOmpDistributeSimdStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgOmpDistributeSimdStatement::pools.size(), alloc, alloc + SgOmpDistributeSimdStatement::pool_size);
  110390             : #endif
  110391             : 
  110392             : #if ROSE_ALLOC_MEMSET == 1
  110393             : #elif ROSE_ALLOC_MEMSET == 2
  110394             :         memset(alloc, 0x00, SgOmpDistributeSimdStatement::pool_size * sizeof(SgOmpDistributeSimdStatement));
  110395             : #elif ROSE_ALLOC_MEMSET == 3
  110396             :         memset(alloc, 0xAA, SgOmpDistributeSimdStatement::pool_size * sizeof(SgOmpDistributeSimdStatement));
  110397             : #endif
  110398        2000 :         for (unsigned i=0; i < SgOmpDistributeSimdStatement::pool_size-1; i++) {
  110399        1999 :           alloc[i].p_freepointer = &(alloc[i+1]);
  110400             :         }
  110401           1 :         alloc[SgOmpDistributeSimdStatement::pool_size-1].p_freepointer = nullptr;
  110402             : 
  110403           1 :         SgOmpDistributeSimdStatement::pools.push_back ( (unsigned char *) alloc );
  110404           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgOmpDistributeSimdStatement::pool_size * sizeof(SgOmpDistributeSimdStatement), V_SgOmpDistributeSimdStatement ) );
  110405           1 :         SgOmpDistributeSimdStatement::next_node = alloc;
  110406             :     }
  110407           1 :     ROSE_ASSERT(SgOmpDistributeSimdStatement::next_node != nullptr);
  110408             : 
  110409           1 :     SgOmpDistributeSimdStatement * object = SgOmpDistributeSimdStatement::next_node;
  110410           1 :     SgOmpDistributeSimdStatement::next_node = (SgOmpDistributeSimdStatement*)(object->p_freepointer);
  110411             : 
  110412             : #if ROSE_ALLOC_TRACE == 2
  110413             :     printf("SgOmpDistributeSimdStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpDistributeSimdStatement::next_node);
  110414             : #endif
  110415             : 
  110416           1 :     SgNode * fp = object->p_freepointer;
  110417             : #if ROSE_ALLOC_MEMSET == 1
  110418             : #elif ROSE_ALLOC_MEMSET == 2
  110419             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpDistributeSimdStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  110420             : #elif ROSE_ALLOC_MEMSET == 3
  110421             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgOmpDistributeSimdStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  110422             : #endif
  110423           1 :     object->p_freepointer = fp;
  110424             : 
  110425             : #if ROSE_ALLOC_TRACE == 2
  110426             : //    printf("SgOmpDistributeSimdStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpDistributeSimdStatement::next_node);
  110427             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  110428             :     Rose::MemPool::snapshot(oss.str());
  110429             :     alloc_trace_cnt++;
  110430             : #endif
  110431             : 
  110432           1 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  110433             : 
  110434           1 :     ALLOC_MUTEX(SgOmpDistributeSimdStatement, unlock);
  110435             : 
  110436             :     return object;
  110437             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  110438             : }
  110439             : 
  110440             : 
  110441             : 
  110442             : /*! \brief Delete operator for SgOmpDistributeSimdStatement.
  110443             : 
  110444             :    This delete operator implements deallocation using memory pools to 
  110445             :    provide most efficent use of the heap within construction of large ASTs.
  110446             : 
  110447             : \internal The new and delete operators use the lower level C malloc/free
  110448             :    function calls for performance and to make sure that mixing of malloc/free
  110449             :    and new/delete by the used can be caught more readily.  This may change
  110450             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  110451             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  110452             :    deallocate memory allocated using ROSE_MALLOC.
  110453             : */
  110454           0 : void SgOmpDistributeSimdStatement::operator delete(void *Pointer, size_t Size)
  110455             : {
  110456             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  110457             :      * or throwing an exception. */
  110458           0 :     ALLOC_MUTEX(SgOmpDistributeSimdStatement, lock);
  110459             : 
  110460             : #if USE_CPP_NEW_DELETE_OPERATORS
  110461             :     ROSE_FREE(Pointer);
  110462             : #else
  110463             : #if ROSE_PEDANTIC_ALLOC
  110464             :     ROSE_ASSERT(Size == sizeof(SgOmpDistributeSimdStatement));
  110465             : #else
  110466           0 :     if (Size != sizeof(SgOmpDistributeSimdStatement)) {
  110467           0 :       ROSE_FREE(Pointer);
  110468           0 :       ALLOC_MUTEX(SgOmpDistributeSimdStatement, unlock);
  110469             :       return;
  110470             :     }
  110471             : #endif
  110472             : 
  110473           0 :     SgOmpDistributeSimdStatement * object = (SgOmpDistributeSimdStatement*) Pointer;
  110474           0 :     ROSE_ASSERT(object != nullptr);
  110475             : 
  110476             : #if ROSE_ALLOC_TRACE == 2
  110477             : //  printf("SgOmpDistributeSimdStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpDistributeSimdStatement::next_node);
  110478             :     printf("SgOmpDistributeSimdStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpDistributeSimdStatement::next_node);
  110479             : #endif
  110480             : 
  110481             : #if ROSE_PEDANTIC_ALLOC
  110482             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  110483             : #endif
  110484             : 
  110485             : #if ROSE_ALLOC_MEMSET == 1
  110486             : #elif ROSE_ALLOC_MEMSET == 2
  110487             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpDistributeSimdStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  110488             : #elif ROSE_ALLOC_MEMSET == 3
  110489             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgOmpDistributeSimdStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  110490             : #endif
  110491             : 
  110492             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  110493             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  110494             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  110495             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  110496             : #else
  110497           0 :     object->p_freepointer = SgOmpDistributeSimdStatement::next_node;
  110498           0 :     SgOmpDistributeSimdStatement::next_node = object;
  110499             : #endif
  110500             : 
  110501             : #if ROSE_ALLOC_TRACE == 2
  110502             : //  printf("SgOmpDistributeSimdStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpDistributeSimdStatement::next_node);
  110503             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  110504             :     Rose::MemPool::snapshot(oss.str());
  110505             :     alloc_trace_cnt++;
  110506             : #endif
  110507             : 
  110508             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  110509             : 
  110510           0 :     ALLOC_MUTEX(SgOmpDistributeSimdStatement, unlock);
  110511             : }
  110512             : 
  110513             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  110514             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  110515             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  110516             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  110517             : // Also, note comment below from Robb (copied from the Common.code file).
  110518             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  110519             : //
  110520             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  110521             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  110522             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  110523             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  110524             : #if 0
  110525             : void SgOmpDistributeSimdStatement::operator delete(void* pointer) { SgOmpDistributeSimdStatement::operator delete (pointer, sizeof(SgOmpDistributeSimdStatement)); };
  110526             : #endif
  110527             : /* #line 110528 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  110528             : 
  110529             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  110530             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  110531             : // obviously imply C++.
  110532             : 
  110533             : // This implements the support within ROSE for memory pools.  Memory pools
  110534             : // support the most condensed usage of memory within the construction of
  110535             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  110536             : // by a new operator written for each class.
  110537             : 
  110538             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  110539             :     // User wants multi-thread support and POSIX threads are available.
  110540             : #   include <pthread.h>
  110541             :     static pthread_mutex_t SgOmpDistributeParallelForStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  110542             : #else
  110543             :      // Cause synchronization to be skipped.
  110544             : #    ifndef ALLOC_MUTEX
  110545             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  110546             : #    endif
  110547             : #    ifdef _REENTRANT
  110548             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  110549             : #       ifdef _MSC_VER
  110550             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  110551             : #       else
  110552             : #           warning "POSIX threads are not available; synchronization being skipped"
  110553             : #       endif
  110554             : #    endif
  110555             : #endif
  110556             : 
  110557             : #ifndef ROSE_ALLOC_TRACE
  110558             : #  define ROSE_ALLOC_TRACE 0
  110559             : #endif
  110560             : 
  110561             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  110562             : #define ROSE_ALLOC_TRACE_CNT
  110563             : #include "memory-pool-snapshot.h"
  110564             : unsigned long alloc_trace_cnt = 0;
  110565             : #endif
  110566             : 
  110567             : #if ROSE_ALLOC_TRACE
  110568             : const unsigned SgOmpDistributeParallelForStatement::pool_size = 5;
  110569             : #else
  110570             : const unsigned SgOmpDistributeParallelForStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  110571             : #endif
  110572             : 
  110573             : #ifndef ROSE_ALLOC_MEMSET
  110574             : #  define ROSE_ALLOC_MEMSET 0
  110575             : #endif
  110576             : 
  110577             : #ifndef ROSE_PEDANTIC_ALLOC
  110578             : #  define ROSE_PEDANTIC_ALLOC 0
  110579             : #endif
  110580             : 
  110581             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  110582             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  110583             : #endif
  110584             : 
  110585             : #if !defined(SGNODE__ALL_POOLS)
  110586             : #define SGNODE__ALL_POOLS
  110587             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  110588             : #endif
  110589             : 
  110590             : SgOmpDistributeParallelForStatement* SgOmpDistributeParallelForStatement::next_node = nullptr;
  110591             : std::vector<unsigned char*> SgOmpDistributeParallelForStatement::pools;
  110592             : 
  110593             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  110594             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  110595             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  110596             : // around this macro definition rather than each use).
  110597             : #ifndef ALLOC_MUTEX
  110598             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  110599             :         do {                                                                     \
  110600             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  110601             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  110602             :                 abort();                                                         \
  110603             :             }                                                                    \
  110604             :         } while (0);
  110605             : #endif
  110606             : 
  110607             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  110608             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  110609             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  110610             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  110611             : 
  110612             : /*! \brief New operator for SgOmpDistributeParallelForStatement.
  110613             : 
  110614             :    This new operator implements memory pools to provide most efficent 
  110615             :    use of the heap within construction of large ASTs.
  110616             : 
  110617             : \internal The new and delete operators use the lower level C malloc/free
  110618             :    function calls for performance and to make sure that mixing of malloc/free
  110619             :    and new/delete by the used can be caught more readily.  This may change
  110620             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  110621             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  110622             :    deallocate memory allocated using ROSE_MALLOC.
  110623             : */
  110624           1 : void *SgOmpDistributeParallelForStatement::operator new ( size_t Size )
  110625             : {
  110626             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  110627             :      * returning or throwing an exception. */
  110628           1 :     ALLOC_MUTEX(SgOmpDistributeParallelForStatement, lock);
  110629             : 
  110630             : #if ROSE_ALLOC_TRACE == 2
  110631             : //    printf("SgOmpDistributeParallelForStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgOmpDistributeParallelForStatement::next_node);
  110632             : #endif
  110633             : 
  110634             : #if USE_CPP_NEW_DELETE_OPERATORS
  110635             :     void *mem = ROSE_MALLOC(Size);
  110636             :     ALLOC_MUTEX(SgOmpDistributeParallelForStatement, unlock);
  110637             :     return mem;
  110638             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  110639             : #if ROSE_PEDANTIC_ALLOC
  110640             :     ROSE_ASSERT(Size == sizeof(SgOmpDistributeParallelForStatement));
  110641             : #else
  110642           1 :     if (Size != sizeof(SgOmpDistributeParallelForStatement)) {
  110643           0 :       void * object = ROSE_MALLOC(Size);
  110644           0 :       ALLOC_MUTEX(SgOmpDistributeParallelForStatement, unlock);
  110645             :       return object;
  110646             :     }
  110647             : #endif
  110648             : 
  110649           1 :     if (SgOmpDistributeParallelForStatement::next_node == nullptr) {
  110650           1 :         SgOmpDistributeParallelForStatement * alloc = (SgOmpDistributeParallelForStatement*) ROSE_MALLOC ( SgOmpDistributeParallelForStatement::pool_size * sizeof(SgOmpDistributeParallelForStatement) );
  110651           1 :         ROSE_ASSERT(alloc != nullptr);
  110652             : 
  110653             : #if ROSE_ALLOC_TRACE == 2
  110654             : //        printf("SgOmpDistributeParallelForStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgOmpDistributeParallelForStatement::pools.size(), alloc, alloc + SgOmpDistributeParallelForStatement::pool_size);
  110655             : #endif
  110656             : 
  110657             : #if ROSE_ALLOC_MEMSET == 1
  110658             : #elif ROSE_ALLOC_MEMSET == 2
  110659             :         memset(alloc, 0x00, SgOmpDistributeParallelForStatement::pool_size * sizeof(SgOmpDistributeParallelForStatement));
  110660             : #elif ROSE_ALLOC_MEMSET == 3
  110661             :         memset(alloc, 0xAA, SgOmpDistributeParallelForStatement::pool_size * sizeof(SgOmpDistributeParallelForStatement));
  110662             : #endif
  110663        2000 :         for (unsigned i=0; i < SgOmpDistributeParallelForStatement::pool_size-1; i++) {
  110664        1999 :           alloc[i].p_freepointer = &(alloc[i+1]);
  110665             :         }
  110666           1 :         alloc[SgOmpDistributeParallelForStatement::pool_size-1].p_freepointer = nullptr;
  110667             : 
  110668           1 :         SgOmpDistributeParallelForStatement::pools.push_back ( (unsigned char *) alloc );
  110669           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgOmpDistributeParallelForStatement::pool_size * sizeof(SgOmpDistributeParallelForStatement), V_SgOmpDistributeParallelForStatement ) );
  110670           1 :         SgOmpDistributeParallelForStatement::next_node = alloc;
  110671             :     }
  110672           1 :     ROSE_ASSERT(SgOmpDistributeParallelForStatement::next_node != nullptr);
  110673             : 
  110674           1 :     SgOmpDistributeParallelForStatement * object = SgOmpDistributeParallelForStatement::next_node;
  110675           1 :     SgOmpDistributeParallelForStatement::next_node = (SgOmpDistributeParallelForStatement*)(object->p_freepointer);
  110676             : 
  110677             : #if ROSE_ALLOC_TRACE == 2
  110678             :     printf("SgOmpDistributeParallelForStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpDistributeParallelForStatement::next_node);
  110679             : #endif
  110680             : 
  110681           1 :     SgNode * fp = object->p_freepointer;
  110682             : #if ROSE_ALLOC_MEMSET == 1
  110683             : #elif ROSE_ALLOC_MEMSET == 2
  110684             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpDistributeParallelForStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  110685             : #elif ROSE_ALLOC_MEMSET == 3
  110686             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgOmpDistributeParallelForStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  110687             : #endif
  110688           1 :     object->p_freepointer = fp;
  110689             : 
  110690             : #if ROSE_ALLOC_TRACE == 2
  110691             : //    printf("SgOmpDistributeParallelForStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpDistributeParallelForStatement::next_node);
  110692             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  110693             :     Rose::MemPool::snapshot(oss.str());
  110694             :     alloc_trace_cnt++;
  110695             : #endif
  110696             : 
  110697           1 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  110698             : 
  110699           1 :     ALLOC_MUTEX(SgOmpDistributeParallelForStatement, unlock);
  110700             : 
  110701             :     return object;
  110702             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  110703             : }
  110704             : 
  110705             : 
  110706             : 
  110707             : /*! \brief Delete operator for SgOmpDistributeParallelForStatement.
  110708             : 
  110709             :    This delete operator implements deallocation using memory pools to 
  110710             :    provide most efficent use of the heap within construction of large ASTs.
  110711             : 
  110712             : \internal The new and delete operators use the lower level C malloc/free
  110713             :    function calls for performance and to make sure that mixing of malloc/free
  110714             :    and new/delete by the used can be caught more readily.  This may change
  110715             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  110716             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  110717             :    deallocate memory allocated using ROSE_MALLOC.
  110718             : */
  110719           0 : void SgOmpDistributeParallelForStatement::operator delete(void *Pointer, size_t Size)
  110720             : {
  110721             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  110722             :      * or throwing an exception. */
  110723           0 :     ALLOC_MUTEX(SgOmpDistributeParallelForStatement, lock);
  110724             : 
  110725             : #if USE_CPP_NEW_DELETE_OPERATORS
  110726             :     ROSE_FREE(Pointer);
  110727             : #else
  110728             : #if ROSE_PEDANTIC_ALLOC
  110729             :     ROSE_ASSERT(Size == sizeof(SgOmpDistributeParallelForStatement));
  110730             : #else
  110731           0 :     if (Size != sizeof(SgOmpDistributeParallelForStatement)) {
  110732           0 :       ROSE_FREE(Pointer);
  110733           0 :       ALLOC_MUTEX(SgOmpDistributeParallelForStatement, unlock);
  110734             :       return;
  110735             :     }
  110736             : #endif
  110737             : 
  110738           0 :     SgOmpDistributeParallelForStatement * object = (SgOmpDistributeParallelForStatement*) Pointer;
  110739           0 :     ROSE_ASSERT(object != nullptr);
  110740             : 
  110741             : #if ROSE_ALLOC_TRACE == 2
  110742             : //  printf("SgOmpDistributeParallelForStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpDistributeParallelForStatement::next_node);
  110743             :     printf("SgOmpDistributeParallelForStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpDistributeParallelForStatement::next_node);
  110744             : #endif
  110745             : 
  110746             : #if ROSE_PEDANTIC_ALLOC
  110747             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  110748             : #endif
  110749             : 
  110750             : #if ROSE_ALLOC_MEMSET == 1
  110751             : #elif ROSE_ALLOC_MEMSET == 2
  110752             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpDistributeParallelForStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  110753             : #elif ROSE_ALLOC_MEMSET == 3
  110754             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgOmpDistributeParallelForStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  110755             : #endif
  110756             : 
  110757             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  110758             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  110759             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  110760             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  110761             : #else
  110762           0 :     object->p_freepointer = SgOmpDistributeParallelForStatement::next_node;
  110763           0 :     SgOmpDistributeParallelForStatement::next_node = object;
  110764             : #endif
  110765             : 
  110766             : #if ROSE_ALLOC_TRACE == 2
  110767             : //  printf("SgOmpDistributeParallelForStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpDistributeParallelForStatement::next_node);
  110768             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  110769             :     Rose::MemPool::snapshot(oss.str());
  110770             :     alloc_trace_cnt++;
  110771             : #endif
  110772             : 
  110773             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  110774             : 
  110775           0 :     ALLOC_MUTEX(SgOmpDistributeParallelForStatement, unlock);
  110776             : }
  110777             : 
  110778             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  110779             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  110780             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  110781             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  110782             : // Also, note comment below from Robb (copied from the Common.code file).
  110783             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  110784             : //
  110785             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  110786             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  110787             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  110788             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  110789             : #if 0
  110790             : void SgOmpDistributeParallelForStatement::operator delete(void* pointer) { SgOmpDistributeParallelForStatement::operator delete (pointer, sizeof(SgOmpDistributeParallelForStatement)); };
  110791             : #endif
  110792             : /* #line 110793 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  110793             : 
  110794             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  110795             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  110796             : // obviously imply C++.
  110797             : 
  110798             : // This implements the support within ROSE for memory pools.  Memory pools
  110799             : // support the most condensed usage of memory within the construction of
  110800             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  110801             : // by a new operator written for each class.
  110802             : 
  110803             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  110804             :     // User wants multi-thread support and POSIX threads are available.
  110805             : #   include <pthread.h>
  110806             :     static pthread_mutex_t SgOmpDistributeParallelForSimdStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  110807             : #else
  110808             :      // Cause synchronization to be skipped.
  110809             : #    ifndef ALLOC_MUTEX
  110810             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  110811             : #    endif
  110812             : #    ifdef _REENTRANT
  110813             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  110814             : #       ifdef _MSC_VER
  110815             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  110816             : #       else
  110817             : #           warning "POSIX threads are not available; synchronization being skipped"
  110818             : #       endif
  110819             : #    endif
  110820             : #endif
  110821             : 
  110822             : #ifndef ROSE_ALLOC_TRACE
  110823             : #  define ROSE_ALLOC_TRACE 0
  110824             : #endif
  110825             : 
  110826             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  110827             : #define ROSE_ALLOC_TRACE_CNT
  110828             : #include "memory-pool-snapshot.h"
  110829             : unsigned long alloc_trace_cnt = 0;
  110830             : #endif
  110831             : 
  110832             : #if ROSE_ALLOC_TRACE
  110833             : const unsigned SgOmpDistributeParallelForSimdStatement::pool_size = 5;
  110834             : #else
  110835             : const unsigned SgOmpDistributeParallelForSimdStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  110836             : #endif
  110837             : 
  110838             : #ifndef ROSE_ALLOC_MEMSET
  110839             : #  define ROSE_ALLOC_MEMSET 0
  110840             : #endif
  110841             : 
  110842             : #ifndef ROSE_PEDANTIC_ALLOC
  110843             : #  define ROSE_PEDANTIC_ALLOC 0
  110844             : #endif
  110845             : 
  110846             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  110847             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  110848             : #endif
  110849             : 
  110850             : #if !defined(SGNODE__ALL_POOLS)
  110851             : #define SGNODE__ALL_POOLS
  110852             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  110853             : #endif
  110854             : 
  110855             : SgOmpDistributeParallelForSimdStatement* SgOmpDistributeParallelForSimdStatement::next_node = nullptr;
  110856             : std::vector<unsigned char*> SgOmpDistributeParallelForSimdStatement::pools;
  110857             : 
  110858             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  110859             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  110860             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  110861             : // around this macro definition rather than each use).
  110862             : #ifndef ALLOC_MUTEX
  110863             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  110864             :         do {                                                                     \
  110865             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  110866             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  110867             :                 abort();                                                         \
  110868             :             }                                                                    \
  110869             :         } while (0);
  110870             : #endif
  110871             : 
  110872             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  110873             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  110874             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  110875             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  110876             : 
  110877             : /*! \brief New operator for SgOmpDistributeParallelForSimdStatement.
  110878             : 
  110879             :    This new operator implements memory pools to provide most efficent 
  110880             :    use of the heap within construction of large ASTs.
  110881             : 
  110882             : \internal The new and delete operators use the lower level C malloc/free
  110883             :    function calls for performance and to make sure that mixing of malloc/free
  110884             :    and new/delete by the used can be caught more readily.  This may change
  110885             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  110886             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  110887             :    deallocate memory allocated using ROSE_MALLOC.
  110888             : */
  110889           1 : void *SgOmpDistributeParallelForSimdStatement::operator new ( size_t Size )
  110890             : {
  110891             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  110892             :      * returning or throwing an exception. */
  110893           1 :     ALLOC_MUTEX(SgOmpDistributeParallelForSimdStatement, lock);
  110894             : 
  110895             : #if ROSE_ALLOC_TRACE == 2
  110896             : //    printf("SgOmpDistributeParallelForSimdStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgOmpDistributeParallelForSimdStatement::next_node);
  110897             : #endif
  110898             : 
  110899             : #if USE_CPP_NEW_DELETE_OPERATORS
  110900             :     void *mem = ROSE_MALLOC(Size);
  110901             :     ALLOC_MUTEX(SgOmpDistributeParallelForSimdStatement, unlock);
  110902             :     return mem;
  110903             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  110904             : #if ROSE_PEDANTIC_ALLOC
  110905             :     ROSE_ASSERT(Size == sizeof(SgOmpDistributeParallelForSimdStatement));
  110906             : #else
  110907           1 :     if (Size != sizeof(SgOmpDistributeParallelForSimdStatement)) {
  110908           0 :       void * object = ROSE_MALLOC(Size);
  110909           0 :       ALLOC_MUTEX(SgOmpDistributeParallelForSimdStatement, unlock);
  110910             :       return object;
  110911             :     }
  110912             : #endif
  110913             : 
  110914           1 :     if (SgOmpDistributeParallelForSimdStatement::next_node == nullptr) {
  110915           1 :         SgOmpDistributeParallelForSimdStatement * alloc = (SgOmpDistributeParallelForSimdStatement*) ROSE_MALLOC ( SgOmpDistributeParallelForSimdStatement::pool_size * sizeof(SgOmpDistributeParallelForSimdStatement) );
  110916           1 :         ROSE_ASSERT(alloc != nullptr);
  110917             : 
  110918             : #if ROSE_ALLOC_TRACE == 2
  110919             : //        printf("SgOmpDistributeParallelForSimdStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgOmpDistributeParallelForSimdStatement::pools.size(), alloc, alloc + SgOmpDistributeParallelForSimdStatement::pool_size);
  110920             : #endif
  110921             : 
  110922             : #if ROSE_ALLOC_MEMSET == 1
  110923             : #elif ROSE_ALLOC_MEMSET == 2
  110924             :         memset(alloc, 0x00, SgOmpDistributeParallelForSimdStatement::pool_size * sizeof(SgOmpDistributeParallelForSimdStatement));
  110925             : #elif ROSE_ALLOC_MEMSET == 3
  110926             :         memset(alloc, 0xAA, SgOmpDistributeParallelForSimdStatement::pool_size * sizeof(SgOmpDistributeParallelForSimdStatement));
  110927             : #endif
  110928        2000 :         for (unsigned i=0; i < SgOmpDistributeParallelForSimdStatement::pool_size-1; i++) {
  110929        1999 :           alloc[i].p_freepointer = &(alloc[i+1]);
  110930             :         }
  110931           1 :         alloc[SgOmpDistributeParallelForSimdStatement::pool_size-1].p_freepointer = nullptr;
  110932             : 
  110933           1 :         SgOmpDistributeParallelForSimdStatement::pools.push_back ( (unsigned char *) alloc );
  110934           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgOmpDistributeParallelForSimdStatement::pool_size * sizeof(SgOmpDistributeParallelForSimdStatement), V_SgOmpDistributeParallelForSimdStatement ) );
  110935           1 :         SgOmpDistributeParallelForSimdStatement::next_node = alloc;
  110936             :     }
  110937           1 :     ROSE_ASSERT(SgOmpDistributeParallelForSimdStatement::next_node != nullptr);
  110938             : 
  110939           1 :     SgOmpDistributeParallelForSimdStatement * object = SgOmpDistributeParallelForSimdStatement::next_node;
  110940           1 :     SgOmpDistributeParallelForSimdStatement::next_node = (SgOmpDistributeParallelForSimdStatement*)(object->p_freepointer);
  110941             : 
  110942             : #if ROSE_ALLOC_TRACE == 2
  110943             :     printf("SgOmpDistributeParallelForSimdStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpDistributeParallelForSimdStatement::next_node);
  110944             : #endif
  110945             : 
  110946           1 :     SgNode * fp = object->p_freepointer;
  110947             : #if ROSE_ALLOC_MEMSET == 1
  110948             : #elif ROSE_ALLOC_MEMSET == 2
  110949             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpDistributeParallelForSimdStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  110950             : #elif ROSE_ALLOC_MEMSET == 3
  110951             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgOmpDistributeParallelForSimdStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  110952             : #endif
  110953           1 :     object->p_freepointer = fp;
  110954             : 
  110955             : #if ROSE_ALLOC_TRACE == 2
  110956             : //    printf("SgOmpDistributeParallelForSimdStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpDistributeParallelForSimdStatement::next_node);
  110957             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  110958             :     Rose::MemPool::snapshot(oss.str());
  110959             :     alloc_trace_cnt++;
  110960             : #endif
  110961             : 
  110962           1 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  110963             : 
  110964           1 :     ALLOC_MUTEX(SgOmpDistributeParallelForSimdStatement, unlock);
  110965             : 
  110966             :     return object;
  110967             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  110968             : }
  110969             : 
  110970             : 
  110971             : 
  110972             : /*! \brief Delete operator for SgOmpDistributeParallelForSimdStatement.
  110973             : 
  110974             :    This delete operator implements deallocation using memory pools to 
  110975             :    provide most efficent use of the heap within construction of large ASTs.
  110976             : 
  110977             : \internal The new and delete operators use the lower level C malloc/free
  110978             :    function calls for performance and to make sure that mixing of malloc/free
  110979             :    and new/delete by the used can be caught more readily.  This may change
  110980             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  110981             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  110982             :    deallocate memory allocated using ROSE_MALLOC.
  110983             : */
  110984           0 : void SgOmpDistributeParallelForSimdStatement::operator delete(void *Pointer, size_t Size)
  110985             : {
  110986             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  110987             :      * or throwing an exception. */
  110988           0 :     ALLOC_MUTEX(SgOmpDistributeParallelForSimdStatement, lock);
  110989             : 
  110990             : #if USE_CPP_NEW_DELETE_OPERATORS
  110991             :     ROSE_FREE(Pointer);
  110992             : #else
  110993             : #if ROSE_PEDANTIC_ALLOC
  110994             :     ROSE_ASSERT(Size == sizeof(SgOmpDistributeParallelForSimdStatement));
  110995             : #else
  110996           0 :     if (Size != sizeof(SgOmpDistributeParallelForSimdStatement)) {
  110997           0 :       ROSE_FREE(Pointer);
  110998           0 :       ALLOC_MUTEX(SgOmpDistributeParallelForSimdStatement, unlock);
  110999             :       return;
  111000             :     }
  111001             : #endif
  111002             : 
  111003           0 :     SgOmpDistributeParallelForSimdStatement * object = (SgOmpDistributeParallelForSimdStatement*) Pointer;
  111004           0 :     ROSE_ASSERT(object != nullptr);
  111005             : 
  111006             : #if ROSE_ALLOC_TRACE == 2
  111007             : //  printf("SgOmpDistributeParallelForSimdStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpDistributeParallelForSimdStatement::next_node);
  111008             :     printf("SgOmpDistributeParallelForSimdStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpDistributeParallelForSimdStatement::next_node);
  111009             : #endif
  111010             : 
  111011             : #if ROSE_PEDANTIC_ALLOC
  111012             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  111013             : #endif
  111014             : 
  111015             : #if ROSE_ALLOC_MEMSET == 1
  111016             : #elif ROSE_ALLOC_MEMSET == 2
  111017             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpDistributeParallelForSimdStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  111018             : #elif ROSE_ALLOC_MEMSET == 3
  111019             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgOmpDistributeParallelForSimdStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  111020             : #endif
  111021             : 
  111022             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  111023             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  111024             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  111025             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  111026             : #else
  111027           0 :     object->p_freepointer = SgOmpDistributeParallelForSimdStatement::next_node;
  111028           0 :     SgOmpDistributeParallelForSimdStatement::next_node = object;
  111029             : #endif
  111030             : 
  111031             : #if ROSE_ALLOC_TRACE == 2
  111032             : //  printf("SgOmpDistributeParallelForSimdStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpDistributeParallelForSimdStatement::next_node);
  111033             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  111034             :     Rose::MemPool::snapshot(oss.str());
  111035             :     alloc_trace_cnt++;
  111036             : #endif
  111037             : 
  111038             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  111039             : 
  111040           0 :     ALLOC_MUTEX(SgOmpDistributeParallelForSimdStatement, unlock);
  111041             : }
  111042             : 
  111043             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  111044             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  111045             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  111046             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  111047             : // Also, note comment below from Robb (copied from the Common.code file).
  111048             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  111049             : //
  111050             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  111051             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  111052             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  111053             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  111054             : #if 0
  111055             : void SgOmpDistributeParallelForSimdStatement::operator delete(void* pointer) { SgOmpDistributeParallelForSimdStatement::operator delete (pointer, sizeof(SgOmpDistributeParallelForSimdStatement)); };
  111056             : #endif
  111057             : /* #line 111058 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  111058             : 
  111059             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  111060             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  111061             : // obviously imply C++.
  111062             : 
  111063             : // This implements the support within ROSE for memory pools.  Memory pools
  111064             : // support the most condensed usage of memory within the construction of
  111065             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  111066             : // by a new operator written for each class.
  111067             : 
  111068             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  111069             :     // User wants multi-thread support and POSIX threads are available.
  111070             : #   include <pthread.h>
  111071             :     static pthread_mutex_t SgOmpTaskloopSimdStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  111072             : #else
  111073             :      // Cause synchronization to be skipped.
  111074             : #    ifndef ALLOC_MUTEX
  111075             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  111076             : #    endif
  111077             : #    ifdef _REENTRANT
  111078             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  111079             : #       ifdef _MSC_VER
  111080             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  111081             : #       else
  111082             : #           warning "POSIX threads are not available; synchronization being skipped"
  111083             : #       endif
  111084             : #    endif
  111085             : #endif
  111086             : 
  111087             : #ifndef ROSE_ALLOC_TRACE
  111088             : #  define ROSE_ALLOC_TRACE 0
  111089             : #endif
  111090             : 
  111091             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  111092             : #define ROSE_ALLOC_TRACE_CNT
  111093             : #include "memory-pool-snapshot.h"
  111094             : unsigned long alloc_trace_cnt = 0;
  111095             : #endif
  111096             : 
  111097             : #if ROSE_ALLOC_TRACE
  111098             : const unsigned SgOmpTaskloopSimdStatement::pool_size = 5;
  111099             : #else
  111100             : const unsigned SgOmpTaskloopSimdStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  111101             : #endif
  111102             : 
  111103             : #ifndef ROSE_ALLOC_MEMSET
  111104             : #  define ROSE_ALLOC_MEMSET 0
  111105             : #endif
  111106             : 
  111107             : #ifndef ROSE_PEDANTIC_ALLOC
  111108             : #  define ROSE_PEDANTIC_ALLOC 0
  111109             : #endif
  111110             : 
  111111             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  111112             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  111113             : #endif
  111114             : 
  111115             : #if !defined(SGNODE__ALL_POOLS)
  111116             : #define SGNODE__ALL_POOLS
  111117             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  111118             : #endif
  111119             : 
  111120             : SgOmpTaskloopSimdStatement* SgOmpTaskloopSimdStatement::next_node = nullptr;
  111121             : std::vector<unsigned char*> SgOmpTaskloopSimdStatement::pools;
  111122             : 
  111123             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  111124             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  111125             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  111126             : // around this macro definition rather than each use).
  111127             : #ifndef ALLOC_MUTEX
  111128             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  111129             :         do {                                                                     \
  111130             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  111131             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  111132             :                 abort();                                                         \
  111133             :             }                                                                    \
  111134             :         } while (0);
  111135             : #endif
  111136             : 
  111137             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  111138             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  111139             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  111140             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  111141             : 
  111142             : /*! \brief New operator for SgOmpTaskloopSimdStatement.
  111143             : 
  111144             :    This new operator implements memory pools to provide most efficent 
  111145             :    use of the heap within construction of large ASTs.
  111146             : 
  111147             : \internal The new and delete operators use the lower level C malloc/free
  111148             :    function calls for performance and to make sure that mixing of malloc/free
  111149             :    and new/delete by the used can be caught more readily.  This may change
  111150             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  111151             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  111152             :    deallocate memory allocated using ROSE_MALLOC.
  111153             : */
  111154           1 : void *SgOmpTaskloopSimdStatement::operator new ( size_t Size )
  111155             : {
  111156             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  111157             :      * returning or throwing an exception. */
  111158           1 :     ALLOC_MUTEX(SgOmpTaskloopSimdStatement, lock);
  111159             : 
  111160             : #if ROSE_ALLOC_TRACE == 2
  111161             : //    printf("SgOmpTaskloopSimdStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgOmpTaskloopSimdStatement::next_node);
  111162             : #endif
  111163             : 
  111164             : #if USE_CPP_NEW_DELETE_OPERATORS
  111165             :     void *mem = ROSE_MALLOC(Size);
  111166             :     ALLOC_MUTEX(SgOmpTaskloopSimdStatement, unlock);
  111167             :     return mem;
  111168             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  111169             : #if ROSE_PEDANTIC_ALLOC
  111170             :     ROSE_ASSERT(Size == sizeof(SgOmpTaskloopSimdStatement));
  111171             : #else
  111172           1 :     if (Size != sizeof(SgOmpTaskloopSimdStatement)) {
  111173           0 :       void * object = ROSE_MALLOC(Size);
  111174           0 :       ALLOC_MUTEX(SgOmpTaskloopSimdStatement, unlock);
  111175             :       return object;
  111176             :     }
  111177             : #endif
  111178             : 
  111179           1 :     if (SgOmpTaskloopSimdStatement::next_node == nullptr) {
  111180           1 :         SgOmpTaskloopSimdStatement * alloc = (SgOmpTaskloopSimdStatement*) ROSE_MALLOC ( SgOmpTaskloopSimdStatement::pool_size * sizeof(SgOmpTaskloopSimdStatement) );
  111181           1 :         ROSE_ASSERT(alloc != nullptr);
  111182             : 
  111183             : #if ROSE_ALLOC_TRACE == 2
  111184             : //        printf("SgOmpTaskloopSimdStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgOmpTaskloopSimdStatement::pools.size(), alloc, alloc + SgOmpTaskloopSimdStatement::pool_size);
  111185             : #endif
  111186             : 
  111187             : #if ROSE_ALLOC_MEMSET == 1
  111188             : #elif ROSE_ALLOC_MEMSET == 2
  111189             :         memset(alloc, 0x00, SgOmpTaskloopSimdStatement::pool_size * sizeof(SgOmpTaskloopSimdStatement));
  111190             : #elif ROSE_ALLOC_MEMSET == 3
  111191             :         memset(alloc, 0xAA, SgOmpTaskloopSimdStatement::pool_size * sizeof(SgOmpTaskloopSimdStatement));
  111192             : #endif
  111193        2000 :         for (unsigned i=0; i < SgOmpTaskloopSimdStatement::pool_size-1; i++) {
  111194        1999 :           alloc[i].p_freepointer = &(alloc[i+1]);
  111195             :         }
  111196           1 :         alloc[SgOmpTaskloopSimdStatement::pool_size-1].p_freepointer = nullptr;
  111197             : 
  111198           1 :         SgOmpTaskloopSimdStatement::pools.push_back ( (unsigned char *) alloc );
  111199           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgOmpTaskloopSimdStatement::pool_size * sizeof(SgOmpTaskloopSimdStatement), V_SgOmpTaskloopSimdStatement ) );
  111200           1 :         SgOmpTaskloopSimdStatement::next_node = alloc;
  111201             :     }
  111202           1 :     ROSE_ASSERT(SgOmpTaskloopSimdStatement::next_node != nullptr);
  111203             : 
  111204           1 :     SgOmpTaskloopSimdStatement * object = SgOmpTaskloopSimdStatement::next_node;
  111205           1 :     SgOmpTaskloopSimdStatement::next_node = (SgOmpTaskloopSimdStatement*)(object->p_freepointer);
  111206             : 
  111207             : #if ROSE_ALLOC_TRACE == 2
  111208             :     printf("SgOmpTaskloopSimdStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpTaskloopSimdStatement::next_node);
  111209             : #endif
  111210             : 
  111211           1 :     SgNode * fp = object->p_freepointer;
  111212             : #if ROSE_ALLOC_MEMSET == 1
  111213             : #elif ROSE_ALLOC_MEMSET == 2
  111214             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpTaskloopSimdStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  111215             : #elif ROSE_ALLOC_MEMSET == 3
  111216             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgOmpTaskloopSimdStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  111217             : #endif
  111218           1 :     object->p_freepointer = fp;
  111219             : 
  111220             : #if ROSE_ALLOC_TRACE == 2
  111221             : //    printf("SgOmpTaskloopSimdStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpTaskloopSimdStatement::next_node);
  111222             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  111223             :     Rose::MemPool::snapshot(oss.str());
  111224             :     alloc_trace_cnt++;
  111225             : #endif
  111226             : 
  111227           1 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  111228             : 
  111229           1 :     ALLOC_MUTEX(SgOmpTaskloopSimdStatement, unlock);
  111230             : 
  111231             :     return object;
  111232             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  111233             : }
  111234             : 
  111235             : 
  111236             : 
  111237             : /*! \brief Delete operator for SgOmpTaskloopSimdStatement.
  111238             : 
  111239             :    This delete operator implements deallocation using memory pools to 
  111240             :    provide most efficent use of the heap within construction of large ASTs.
  111241             : 
  111242             : \internal The new and delete operators use the lower level C malloc/free
  111243             :    function calls for performance and to make sure that mixing of malloc/free
  111244             :    and new/delete by the used can be caught more readily.  This may change
  111245             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  111246             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  111247             :    deallocate memory allocated using ROSE_MALLOC.
  111248             : */
  111249           0 : void SgOmpTaskloopSimdStatement::operator delete(void *Pointer, size_t Size)
  111250             : {
  111251             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  111252             :      * or throwing an exception. */
  111253           0 :     ALLOC_MUTEX(SgOmpTaskloopSimdStatement, lock);
  111254             : 
  111255             : #if USE_CPP_NEW_DELETE_OPERATORS
  111256             :     ROSE_FREE(Pointer);
  111257             : #else
  111258             : #if ROSE_PEDANTIC_ALLOC
  111259             :     ROSE_ASSERT(Size == sizeof(SgOmpTaskloopSimdStatement));
  111260             : #else
  111261           0 :     if (Size != sizeof(SgOmpTaskloopSimdStatement)) {
  111262           0 :       ROSE_FREE(Pointer);
  111263           0 :       ALLOC_MUTEX(SgOmpTaskloopSimdStatement, unlock);
  111264             :       return;
  111265             :     }
  111266             : #endif
  111267             : 
  111268           0 :     SgOmpTaskloopSimdStatement * object = (SgOmpTaskloopSimdStatement*) Pointer;
  111269           0 :     ROSE_ASSERT(object != nullptr);
  111270             : 
  111271             : #if ROSE_ALLOC_TRACE == 2
  111272             : //  printf("SgOmpTaskloopSimdStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpTaskloopSimdStatement::next_node);
  111273             :     printf("SgOmpTaskloopSimdStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpTaskloopSimdStatement::next_node);
  111274             : #endif
  111275             : 
  111276             : #if ROSE_PEDANTIC_ALLOC
  111277             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  111278             : #endif
  111279             : 
  111280             : #if ROSE_ALLOC_MEMSET == 1
  111281             : #elif ROSE_ALLOC_MEMSET == 2
  111282             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpTaskloopSimdStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  111283             : #elif ROSE_ALLOC_MEMSET == 3
  111284             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgOmpTaskloopSimdStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  111285             : #endif
  111286             : 
  111287             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  111288             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  111289             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  111290             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  111291             : #else
  111292           0 :     object->p_freepointer = SgOmpTaskloopSimdStatement::next_node;
  111293           0 :     SgOmpTaskloopSimdStatement::next_node = object;
  111294             : #endif
  111295             : 
  111296             : #if ROSE_ALLOC_TRACE == 2
  111297             : //  printf("SgOmpTaskloopSimdStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpTaskloopSimdStatement::next_node);
  111298             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  111299             :     Rose::MemPool::snapshot(oss.str());
  111300             :     alloc_trace_cnt++;
  111301             : #endif
  111302             : 
  111303             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  111304             : 
  111305           0 :     ALLOC_MUTEX(SgOmpTaskloopSimdStatement, unlock);
  111306             : }
  111307             : 
  111308             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  111309             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  111310             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  111311             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  111312             : // Also, note comment below from Robb (copied from the Common.code file).
  111313             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  111314             : //
  111315             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  111316             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  111317             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  111318             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  111319             : #if 0
  111320             : void SgOmpTaskloopSimdStatement::operator delete(void* pointer) { SgOmpTaskloopSimdStatement::operator delete (pointer, sizeof(SgOmpTaskloopSimdStatement)); };
  111321             : #endif
  111322             : /* #line 111323 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  111323             : 
  111324             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  111325             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  111326             : // obviously imply C++.
  111327             : 
  111328             : // This implements the support within ROSE for memory pools.  Memory pools
  111329             : // support the most condensed usage of memory within the construction of
  111330             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  111331             : // by a new operator written for each class.
  111332             : 
  111333             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  111334             :     // User wants multi-thread support and POSIX threads are available.
  111335             : #   include <pthread.h>
  111336             :     static pthread_mutex_t SgOmpMasterTaskloopSimdStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  111337             : #else
  111338             :      // Cause synchronization to be skipped.
  111339             : #    ifndef ALLOC_MUTEX
  111340             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  111341             : #    endif
  111342             : #    ifdef _REENTRANT
  111343             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  111344             : #       ifdef _MSC_VER
  111345             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  111346             : #       else
  111347             : #           warning "POSIX threads are not available; synchronization being skipped"
  111348             : #       endif
  111349             : #    endif
  111350             : #endif
  111351             : 
  111352             : #ifndef ROSE_ALLOC_TRACE
  111353             : #  define ROSE_ALLOC_TRACE 0
  111354             : #endif
  111355             : 
  111356             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  111357             : #define ROSE_ALLOC_TRACE_CNT
  111358             : #include "memory-pool-snapshot.h"
  111359             : unsigned long alloc_trace_cnt = 0;
  111360             : #endif
  111361             : 
  111362             : #if ROSE_ALLOC_TRACE
  111363             : const unsigned SgOmpMasterTaskloopSimdStatement::pool_size = 5;
  111364             : #else
  111365             : const unsigned SgOmpMasterTaskloopSimdStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  111366             : #endif
  111367             : 
  111368             : #ifndef ROSE_ALLOC_MEMSET
  111369             : #  define ROSE_ALLOC_MEMSET 0
  111370             : #endif
  111371             : 
  111372             : #ifndef ROSE_PEDANTIC_ALLOC
  111373             : #  define ROSE_PEDANTIC_ALLOC 0
  111374             : #endif
  111375             : 
  111376             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  111377             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  111378             : #endif
  111379             : 
  111380             : #if !defined(SGNODE__ALL_POOLS)
  111381             : #define SGNODE__ALL_POOLS
  111382             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  111383             : #endif
  111384             : 
  111385             : SgOmpMasterTaskloopSimdStatement* SgOmpMasterTaskloopSimdStatement::next_node = nullptr;
  111386             : std::vector<unsigned char*> SgOmpMasterTaskloopSimdStatement::pools;
  111387             : 
  111388             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  111389             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  111390             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  111391             : // around this macro definition rather than each use).
  111392             : #ifndef ALLOC_MUTEX
  111393             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  111394             :         do {                                                                     \
  111395             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  111396             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  111397             :                 abort();                                                         \
  111398             :             }                                                                    \
  111399             :         } while (0);
  111400             : #endif
  111401             : 
  111402             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  111403             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  111404             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  111405             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  111406             : 
  111407             : /*! \brief New operator for SgOmpMasterTaskloopSimdStatement.
  111408             : 
  111409             :    This new operator implements memory pools to provide most efficent 
  111410             :    use of the heap within construction of large ASTs.
  111411             : 
  111412             : \internal The new and delete operators use the lower level C malloc/free
  111413             :    function calls for performance and to make sure that mixing of malloc/free
  111414             :    and new/delete by the used can be caught more readily.  This may change
  111415             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  111416             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  111417             :    deallocate memory allocated using ROSE_MALLOC.
  111418             : */
  111419           2 : void *SgOmpMasterTaskloopSimdStatement::operator new ( size_t Size )
  111420             : {
  111421             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  111422             :      * returning or throwing an exception. */
  111423           2 :     ALLOC_MUTEX(SgOmpMasterTaskloopSimdStatement, lock);
  111424             : 
  111425             : #if ROSE_ALLOC_TRACE == 2
  111426             : //    printf("SgOmpMasterTaskloopSimdStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgOmpMasterTaskloopSimdStatement::next_node);
  111427             : #endif
  111428             : 
  111429             : #if USE_CPP_NEW_DELETE_OPERATORS
  111430             :     void *mem = ROSE_MALLOC(Size);
  111431             :     ALLOC_MUTEX(SgOmpMasterTaskloopSimdStatement, unlock);
  111432             :     return mem;
  111433             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  111434             : #if ROSE_PEDANTIC_ALLOC
  111435             :     ROSE_ASSERT(Size == sizeof(SgOmpMasterTaskloopSimdStatement));
  111436             : #else
  111437           2 :     if (Size != sizeof(SgOmpMasterTaskloopSimdStatement)) {
  111438           0 :       void * object = ROSE_MALLOC(Size);
  111439           0 :       ALLOC_MUTEX(SgOmpMasterTaskloopSimdStatement, unlock);
  111440             :       return object;
  111441             :     }
  111442             : #endif
  111443             : 
  111444           2 :     if (SgOmpMasterTaskloopSimdStatement::next_node == nullptr) {
  111445           2 :         SgOmpMasterTaskloopSimdStatement * alloc = (SgOmpMasterTaskloopSimdStatement*) ROSE_MALLOC ( SgOmpMasterTaskloopSimdStatement::pool_size * sizeof(SgOmpMasterTaskloopSimdStatement) );
  111446           2 :         ROSE_ASSERT(alloc != nullptr);
  111447             : 
  111448             : #if ROSE_ALLOC_TRACE == 2
  111449             : //        printf("SgOmpMasterTaskloopSimdStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgOmpMasterTaskloopSimdStatement::pools.size(), alloc, alloc + SgOmpMasterTaskloopSimdStatement::pool_size);
  111450             : #endif
  111451             : 
  111452             : #if ROSE_ALLOC_MEMSET == 1
  111453             : #elif ROSE_ALLOC_MEMSET == 2
  111454             :         memset(alloc, 0x00, SgOmpMasterTaskloopSimdStatement::pool_size * sizeof(SgOmpMasterTaskloopSimdStatement));
  111455             : #elif ROSE_ALLOC_MEMSET == 3
  111456             :         memset(alloc, 0xAA, SgOmpMasterTaskloopSimdStatement::pool_size * sizeof(SgOmpMasterTaskloopSimdStatement));
  111457             : #endif
  111458        4000 :         for (unsigned i=0; i < SgOmpMasterTaskloopSimdStatement::pool_size-1; i++) {
  111459        3998 :           alloc[i].p_freepointer = &(alloc[i+1]);
  111460             :         }
  111461           2 :         alloc[SgOmpMasterTaskloopSimdStatement::pool_size-1].p_freepointer = nullptr;
  111462             : 
  111463           2 :         SgOmpMasterTaskloopSimdStatement::pools.push_back ( (unsigned char *) alloc );
  111464           2 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgOmpMasterTaskloopSimdStatement::pool_size * sizeof(SgOmpMasterTaskloopSimdStatement), V_SgOmpMasterTaskloopSimdStatement ) );
  111465           2 :         SgOmpMasterTaskloopSimdStatement::next_node = alloc;
  111466             :     }
  111467           2 :     ROSE_ASSERT(SgOmpMasterTaskloopSimdStatement::next_node != nullptr);
  111468             : 
  111469           2 :     SgOmpMasterTaskloopSimdStatement * object = SgOmpMasterTaskloopSimdStatement::next_node;
  111470           2 :     SgOmpMasterTaskloopSimdStatement::next_node = (SgOmpMasterTaskloopSimdStatement*)(object->p_freepointer);
  111471             : 
  111472             : #if ROSE_ALLOC_TRACE == 2
  111473             :     printf("SgOmpMasterTaskloopSimdStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpMasterTaskloopSimdStatement::next_node);
  111474             : #endif
  111475             : 
  111476           2 :     SgNode * fp = object->p_freepointer;
  111477             : #if ROSE_ALLOC_MEMSET == 1
  111478             : #elif ROSE_ALLOC_MEMSET == 2
  111479             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpMasterTaskloopSimdStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  111480             : #elif ROSE_ALLOC_MEMSET == 3
  111481             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgOmpMasterTaskloopSimdStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  111482             : #endif
  111483           2 :     object->p_freepointer = fp;
  111484             : 
  111485             : #if ROSE_ALLOC_TRACE == 2
  111486             : //    printf("SgOmpMasterTaskloopSimdStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpMasterTaskloopSimdStatement::next_node);
  111487             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  111488             :     Rose::MemPool::snapshot(oss.str());
  111489             :     alloc_trace_cnt++;
  111490             : #endif
  111491             : 
  111492           2 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  111493             : 
  111494           2 :     ALLOC_MUTEX(SgOmpMasterTaskloopSimdStatement, unlock);
  111495             : 
  111496             :     return object;
  111497             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  111498             : }
  111499             : 
  111500             : 
  111501             : 
  111502             : /*! \brief Delete operator for SgOmpMasterTaskloopSimdStatement.
  111503             : 
  111504             :    This delete operator implements deallocation using memory pools to 
  111505             :    provide most efficent use of the heap within construction of large ASTs.
  111506             : 
  111507             : \internal The new and delete operators use the lower level C malloc/free
  111508             :    function calls for performance and to make sure that mixing of malloc/free
  111509             :    and new/delete by the used can be caught more readily.  This may change
  111510             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  111511             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  111512             :    deallocate memory allocated using ROSE_MALLOC.
  111513             : */
  111514           0 : void SgOmpMasterTaskloopSimdStatement::operator delete(void *Pointer, size_t Size)
  111515             : {
  111516             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  111517             :      * or throwing an exception. */
  111518           0 :     ALLOC_MUTEX(SgOmpMasterTaskloopSimdStatement, lock);
  111519             : 
  111520             : #if USE_CPP_NEW_DELETE_OPERATORS
  111521             :     ROSE_FREE(Pointer);
  111522             : #else
  111523             : #if ROSE_PEDANTIC_ALLOC
  111524             :     ROSE_ASSERT(Size == sizeof(SgOmpMasterTaskloopSimdStatement));
  111525             : #else
  111526           0 :     if (Size != sizeof(SgOmpMasterTaskloopSimdStatement)) {
  111527           0 :       ROSE_FREE(Pointer);
  111528           0 :       ALLOC_MUTEX(SgOmpMasterTaskloopSimdStatement, unlock);
  111529             :       return;
  111530             :     }
  111531             : #endif
  111532             : 
  111533           0 :     SgOmpMasterTaskloopSimdStatement * object = (SgOmpMasterTaskloopSimdStatement*) Pointer;
  111534           0 :     ROSE_ASSERT(object != nullptr);
  111535             : 
  111536             : #if ROSE_ALLOC_TRACE == 2
  111537             : //  printf("SgOmpMasterTaskloopSimdStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpMasterTaskloopSimdStatement::next_node);
  111538             :     printf("SgOmpMasterTaskloopSimdStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpMasterTaskloopSimdStatement::next_node);
  111539             : #endif
  111540             : 
  111541             : #if ROSE_PEDANTIC_ALLOC
  111542             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  111543             : #endif
  111544             : 
  111545             : #if ROSE_ALLOC_MEMSET == 1
  111546             : #elif ROSE_ALLOC_MEMSET == 2
  111547             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpMasterTaskloopSimdStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  111548             : #elif ROSE_ALLOC_MEMSET == 3
  111549             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgOmpMasterTaskloopSimdStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  111550             : #endif
  111551             : 
  111552             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  111553             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  111554             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  111555             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  111556             : #else
  111557           0 :     object->p_freepointer = SgOmpMasterTaskloopSimdStatement::next_node;
  111558           0 :     SgOmpMasterTaskloopSimdStatement::next_node = object;
  111559             : #endif
  111560             : 
  111561             : #if ROSE_ALLOC_TRACE == 2
  111562             : //  printf("SgOmpMasterTaskloopSimdStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpMasterTaskloopSimdStatement::next_node);
  111563             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  111564             :     Rose::MemPool::snapshot(oss.str());
  111565             :     alloc_trace_cnt++;
  111566             : #endif
  111567             : 
  111568             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  111569             : 
  111570           0 :     ALLOC_MUTEX(SgOmpMasterTaskloopSimdStatement, unlock);
  111571             : }
  111572             : 
  111573             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  111574             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  111575             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  111576             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  111577             : // Also, note comment below from Robb (copied from the Common.code file).
  111578             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  111579             : //
  111580             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  111581             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  111582             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  111583             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  111584             : #if 0
  111585             : void SgOmpMasterTaskloopSimdStatement::operator delete(void* pointer) { SgOmpMasterTaskloopSimdStatement::operator delete (pointer, sizeof(SgOmpMasterTaskloopSimdStatement)); };
  111586             : #endif
  111587             : /* #line 111588 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  111588             : 
  111589             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  111590             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  111591             : // obviously imply C++.
  111592             : 
  111593             : // This implements the support within ROSE for memory pools.  Memory pools
  111594             : // support the most condensed usage of memory within the construction of
  111595             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  111596             : // by a new operator written for each class.
  111597             : 
  111598             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  111599             :     // User wants multi-thread support and POSIX threads are available.
  111600             : #   include <pthread.h>
  111601             :     static pthread_mutex_t SgOmpParallelMasterTaskloopStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  111602             : #else
  111603             :      // Cause synchronization to be skipped.
  111604             : #    ifndef ALLOC_MUTEX
  111605             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  111606             : #    endif
  111607             : #    ifdef _REENTRANT
  111608             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  111609             : #       ifdef _MSC_VER
  111610             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  111611             : #       else
  111612             : #           warning "POSIX threads are not available; synchronization being skipped"
  111613             : #       endif
  111614             : #    endif
  111615             : #endif
  111616             : 
  111617             : #ifndef ROSE_ALLOC_TRACE
  111618             : #  define ROSE_ALLOC_TRACE 0
  111619             : #endif
  111620             : 
  111621             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  111622             : #define ROSE_ALLOC_TRACE_CNT
  111623             : #include "memory-pool-snapshot.h"
  111624             : unsigned long alloc_trace_cnt = 0;
  111625             : #endif
  111626             : 
  111627             : #if ROSE_ALLOC_TRACE
  111628             : const unsigned SgOmpParallelMasterTaskloopStatement::pool_size = 5;
  111629             : #else
  111630             : const unsigned SgOmpParallelMasterTaskloopStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  111631             : #endif
  111632             : 
  111633             : #ifndef ROSE_ALLOC_MEMSET
  111634             : #  define ROSE_ALLOC_MEMSET 0
  111635             : #endif
  111636             : 
  111637             : #ifndef ROSE_PEDANTIC_ALLOC
  111638             : #  define ROSE_PEDANTIC_ALLOC 0
  111639             : #endif
  111640             : 
  111641             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  111642             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  111643             : #endif
  111644             : 
  111645             : #if !defined(SGNODE__ALL_POOLS)
  111646             : #define SGNODE__ALL_POOLS
  111647             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  111648             : #endif
  111649             : 
  111650             : SgOmpParallelMasterTaskloopStatement* SgOmpParallelMasterTaskloopStatement::next_node = nullptr;
  111651             : std::vector<unsigned char*> SgOmpParallelMasterTaskloopStatement::pools;
  111652             : 
  111653             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  111654             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  111655             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  111656             : // around this macro definition rather than each use).
  111657             : #ifndef ALLOC_MUTEX
  111658             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  111659             :         do {                                                                     \
  111660             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  111661             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  111662             :                 abort();                                                         \
  111663             :             }                                                                    \
  111664             :         } while (0);
  111665             : #endif
  111666             : 
  111667             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  111668             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  111669             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  111670             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  111671             : 
  111672             : /*! \brief New operator for SgOmpParallelMasterTaskloopStatement.
  111673             : 
  111674             :    This new operator implements memory pools to provide most efficent 
  111675             :    use of the heap within construction of large ASTs.
  111676             : 
  111677             : \internal The new and delete operators use the lower level C malloc/free
  111678             :    function calls for performance and to make sure that mixing of malloc/free
  111679             :    and new/delete by the used can be caught more readily.  This may change
  111680             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  111681             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  111682             :    deallocate memory allocated using ROSE_MALLOC.
  111683             : */
  111684           1 : void *SgOmpParallelMasterTaskloopStatement::operator new ( size_t Size )
  111685             : {
  111686             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  111687             :      * returning or throwing an exception. */
  111688           1 :     ALLOC_MUTEX(SgOmpParallelMasterTaskloopStatement, lock);
  111689             : 
  111690             : #if ROSE_ALLOC_TRACE == 2
  111691             : //    printf("SgOmpParallelMasterTaskloopStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgOmpParallelMasterTaskloopStatement::next_node);
  111692             : #endif
  111693             : 
  111694             : #if USE_CPP_NEW_DELETE_OPERATORS
  111695             :     void *mem = ROSE_MALLOC(Size);
  111696             :     ALLOC_MUTEX(SgOmpParallelMasterTaskloopStatement, unlock);
  111697             :     return mem;
  111698             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  111699             : #if ROSE_PEDANTIC_ALLOC
  111700             :     ROSE_ASSERT(Size == sizeof(SgOmpParallelMasterTaskloopStatement));
  111701             : #else
  111702           1 :     if (Size != sizeof(SgOmpParallelMasterTaskloopStatement)) {
  111703           0 :       void * object = ROSE_MALLOC(Size);
  111704           0 :       ALLOC_MUTEX(SgOmpParallelMasterTaskloopStatement, unlock);
  111705             :       return object;
  111706             :     }
  111707             : #endif
  111708             : 
  111709           1 :     if (SgOmpParallelMasterTaskloopStatement::next_node == nullptr) {
  111710           1 :         SgOmpParallelMasterTaskloopStatement * alloc = (SgOmpParallelMasterTaskloopStatement*) ROSE_MALLOC ( SgOmpParallelMasterTaskloopStatement::pool_size * sizeof(SgOmpParallelMasterTaskloopStatement) );
  111711           1 :         ROSE_ASSERT(alloc != nullptr);
  111712             : 
  111713             : #if ROSE_ALLOC_TRACE == 2
  111714             : //        printf("SgOmpParallelMasterTaskloopStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgOmpParallelMasterTaskloopStatement::pools.size(), alloc, alloc + SgOmpParallelMasterTaskloopStatement::pool_size);
  111715             : #endif
  111716             : 
  111717             : #if ROSE_ALLOC_MEMSET == 1
  111718             : #elif ROSE_ALLOC_MEMSET == 2
  111719             :         memset(alloc, 0x00, SgOmpParallelMasterTaskloopStatement::pool_size * sizeof(SgOmpParallelMasterTaskloopStatement));
  111720             : #elif ROSE_ALLOC_MEMSET == 3
  111721             :         memset(alloc, 0xAA, SgOmpParallelMasterTaskloopStatement::pool_size * sizeof(SgOmpParallelMasterTaskloopStatement));
  111722             : #endif
  111723        2000 :         for (unsigned i=0; i < SgOmpParallelMasterTaskloopStatement::pool_size-1; i++) {
  111724        1999 :           alloc[i].p_freepointer = &(alloc[i+1]);
  111725             :         }
  111726           1 :         alloc[SgOmpParallelMasterTaskloopStatement::pool_size-1].p_freepointer = nullptr;
  111727             : 
  111728           1 :         SgOmpParallelMasterTaskloopStatement::pools.push_back ( (unsigned char *) alloc );
  111729           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgOmpParallelMasterTaskloopStatement::pool_size * sizeof(SgOmpParallelMasterTaskloopStatement), V_SgOmpParallelMasterTaskloopStatement ) );
  111730           1 :         SgOmpParallelMasterTaskloopStatement::next_node = alloc;
  111731             :     }
  111732           1 :     ROSE_ASSERT(SgOmpParallelMasterTaskloopStatement::next_node != nullptr);
  111733             : 
  111734           1 :     SgOmpParallelMasterTaskloopStatement * object = SgOmpParallelMasterTaskloopStatement::next_node;
  111735           1 :     SgOmpParallelMasterTaskloopStatement::next_node = (SgOmpParallelMasterTaskloopStatement*)(object->p_freepointer);
  111736             : 
  111737             : #if ROSE_ALLOC_TRACE == 2
  111738             :     printf("SgOmpParallelMasterTaskloopStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpParallelMasterTaskloopStatement::next_node);
  111739             : #endif
  111740             : 
  111741           1 :     SgNode * fp = object->p_freepointer;
  111742             : #if ROSE_ALLOC_MEMSET == 1
  111743             : #elif ROSE_ALLOC_MEMSET == 2
  111744             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpParallelMasterTaskloopStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  111745             : #elif ROSE_ALLOC_MEMSET == 3
  111746             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgOmpParallelMasterTaskloopStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  111747             : #endif
  111748           1 :     object->p_freepointer = fp;
  111749             : 
  111750             : #if ROSE_ALLOC_TRACE == 2
  111751             : //    printf("SgOmpParallelMasterTaskloopStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpParallelMasterTaskloopStatement::next_node);
  111752             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  111753             :     Rose::MemPool::snapshot(oss.str());
  111754             :     alloc_trace_cnt++;
  111755             : #endif
  111756             : 
  111757           1 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  111758             : 
  111759           1 :     ALLOC_MUTEX(SgOmpParallelMasterTaskloopStatement, unlock);
  111760             : 
  111761             :     return object;
  111762             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  111763             : }
  111764             : 
  111765             : 
  111766             : 
  111767             : /*! \brief Delete operator for SgOmpParallelMasterTaskloopStatement.
  111768             : 
  111769             :    This delete operator implements deallocation using memory pools to 
  111770             :    provide most efficent use of the heap within construction of large ASTs.
  111771             : 
  111772             : \internal The new and delete operators use the lower level C malloc/free
  111773             :    function calls for performance and to make sure that mixing of malloc/free
  111774             :    and new/delete by the used can be caught more readily.  This may change
  111775             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  111776             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  111777             :    deallocate memory allocated using ROSE_MALLOC.
  111778             : */
  111779           0 : void SgOmpParallelMasterTaskloopStatement::operator delete(void *Pointer, size_t Size)
  111780             : {
  111781             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  111782             :      * or throwing an exception. */
  111783           0 :     ALLOC_MUTEX(SgOmpParallelMasterTaskloopStatement, lock);
  111784             : 
  111785             : #if USE_CPP_NEW_DELETE_OPERATORS
  111786             :     ROSE_FREE(Pointer);
  111787             : #else
  111788             : #if ROSE_PEDANTIC_ALLOC
  111789             :     ROSE_ASSERT(Size == sizeof(SgOmpParallelMasterTaskloopStatement));
  111790             : #else
  111791           0 :     if (Size != sizeof(SgOmpParallelMasterTaskloopStatement)) {
  111792           0 :       ROSE_FREE(Pointer);
  111793           0 :       ALLOC_MUTEX(SgOmpParallelMasterTaskloopStatement, unlock);
  111794             :       return;
  111795             :     }
  111796             : #endif
  111797             : 
  111798           0 :     SgOmpParallelMasterTaskloopStatement * object = (SgOmpParallelMasterTaskloopStatement*) Pointer;
  111799           0 :     ROSE_ASSERT(object != nullptr);
  111800             : 
  111801             : #if ROSE_ALLOC_TRACE == 2
  111802             : //  printf("SgOmpParallelMasterTaskloopStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpParallelMasterTaskloopStatement::next_node);
  111803             :     printf("SgOmpParallelMasterTaskloopStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpParallelMasterTaskloopStatement::next_node);
  111804             : #endif
  111805             : 
  111806             : #if ROSE_PEDANTIC_ALLOC
  111807             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  111808             : #endif
  111809             : 
  111810             : #if ROSE_ALLOC_MEMSET == 1
  111811             : #elif ROSE_ALLOC_MEMSET == 2
  111812             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpParallelMasterTaskloopStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  111813             : #elif ROSE_ALLOC_MEMSET == 3
  111814             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgOmpParallelMasterTaskloopStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  111815             : #endif
  111816             : 
  111817             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  111818             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  111819             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  111820             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  111821             : #else
  111822           0 :     object->p_freepointer = SgOmpParallelMasterTaskloopStatement::next_node;
  111823           0 :     SgOmpParallelMasterTaskloopStatement::next_node = object;
  111824             : #endif
  111825             : 
  111826             : #if ROSE_ALLOC_TRACE == 2
  111827             : //  printf("SgOmpParallelMasterTaskloopStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpParallelMasterTaskloopStatement::next_node);
  111828             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  111829             :     Rose::MemPool::snapshot(oss.str());
  111830             :     alloc_trace_cnt++;
  111831             : #endif
  111832             : 
  111833             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  111834             : 
  111835           0 :     ALLOC_MUTEX(SgOmpParallelMasterTaskloopStatement, unlock);
  111836             : }
  111837             : 
  111838             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  111839             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  111840             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  111841             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  111842             : // Also, note comment below from Robb (copied from the Common.code file).
  111843             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  111844             : //
  111845             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  111846             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  111847             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  111848             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  111849             : #if 0
  111850             : void SgOmpParallelMasterTaskloopStatement::operator delete(void* pointer) { SgOmpParallelMasterTaskloopStatement::operator delete (pointer, sizeof(SgOmpParallelMasterTaskloopStatement)); };
  111851             : #endif
  111852             : /* #line 111853 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  111853             : 
  111854             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  111855             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  111856             : // obviously imply C++.
  111857             : 
  111858             : // This implements the support within ROSE for memory pools.  Memory pools
  111859             : // support the most condensed usage of memory within the construction of
  111860             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  111861             : // by a new operator written for each class.
  111862             : 
  111863             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  111864             :     // User wants multi-thread support and POSIX threads are available.
  111865             : #   include <pthread.h>
  111866             :     static pthread_mutex_t SgOmpParallelMasterTaskloopSimdStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  111867             : #else
  111868             :      // Cause synchronization to be skipped.
  111869             : #    ifndef ALLOC_MUTEX
  111870             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  111871             : #    endif
  111872             : #    ifdef _REENTRANT
  111873             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  111874             : #       ifdef _MSC_VER
  111875             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  111876             : #       else
  111877             : #           warning "POSIX threads are not available; synchronization being skipped"
  111878             : #       endif
  111879             : #    endif
  111880             : #endif
  111881             : 
  111882             : #ifndef ROSE_ALLOC_TRACE
  111883             : #  define ROSE_ALLOC_TRACE 0
  111884             : #endif
  111885             : 
  111886             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  111887             : #define ROSE_ALLOC_TRACE_CNT
  111888             : #include "memory-pool-snapshot.h"
  111889             : unsigned long alloc_trace_cnt = 0;
  111890             : #endif
  111891             : 
  111892             : #if ROSE_ALLOC_TRACE
  111893             : const unsigned SgOmpParallelMasterTaskloopSimdStatement::pool_size = 5;
  111894             : #else
  111895             : const unsigned SgOmpParallelMasterTaskloopSimdStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  111896             : #endif
  111897             : 
  111898             : #ifndef ROSE_ALLOC_MEMSET
  111899             : #  define ROSE_ALLOC_MEMSET 0
  111900             : #endif
  111901             : 
  111902             : #ifndef ROSE_PEDANTIC_ALLOC
  111903             : #  define ROSE_PEDANTIC_ALLOC 0
  111904             : #endif
  111905             : 
  111906             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  111907             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  111908             : #endif
  111909             : 
  111910             : #if !defined(SGNODE__ALL_POOLS)
  111911             : #define SGNODE__ALL_POOLS
  111912             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  111913             : #endif
  111914             : 
  111915             : SgOmpParallelMasterTaskloopSimdStatement* SgOmpParallelMasterTaskloopSimdStatement::next_node = nullptr;
  111916             : std::vector<unsigned char*> SgOmpParallelMasterTaskloopSimdStatement::pools;
  111917             : 
  111918             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  111919             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  111920             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  111921             : // around this macro definition rather than each use).
  111922             : #ifndef ALLOC_MUTEX
  111923             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  111924             :         do {                                                                     \
  111925             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  111926             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  111927             :                 abort();                                                         \
  111928             :             }                                                                    \
  111929             :         } while (0);
  111930             : #endif
  111931             : 
  111932             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  111933             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  111934             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  111935             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  111936             : 
  111937             : /*! \brief New operator for SgOmpParallelMasterTaskloopSimdStatement.
  111938             : 
  111939             :    This new operator implements memory pools to provide most efficent 
  111940             :    use of the heap within construction of large ASTs.
  111941             : 
  111942             : \internal The new and delete operators use the lower level C malloc/free
  111943             :    function calls for performance and to make sure that mixing of malloc/free
  111944             :    and new/delete by the used can be caught more readily.  This may change
  111945             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  111946             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  111947             :    deallocate memory allocated using ROSE_MALLOC.
  111948             : */
  111949           1 : void *SgOmpParallelMasterTaskloopSimdStatement::operator new ( size_t Size )
  111950             : {
  111951             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  111952             :      * returning or throwing an exception. */
  111953           1 :     ALLOC_MUTEX(SgOmpParallelMasterTaskloopSimdStatement, lock);
  111954             : 
  111955             : #if ROSE_ALLOC_TRACE == 2
  111956             : //    printf("SgOmpParallelMasterTaskloopSimdStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgOmpParallelMasterTaskloopSimdStatement::next_node);
  111957             : #endif
  111958             : 
  111959             : #if USE_CPP_NEW_DELETE_OPERATORS
  111960             :     void *mem = ROSE_MALLOC(Size);
  111961             :     ALLOC_MUTEX(SgOmpParallelMasterTaskloopSimdStatement, unlock);
  111962             :     return mem;
  111963             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  111964             : #if ROSE_PEDANTIC_ALLOC
  111965             :     ROSE_ASSERT(Size == sizeof(SgOmpParallelMasterTaskloopSimdStatement));
  111966             : #else
  111967           1 :     if (Size != sizeof(SgOmpParallelMasterTaskloopSimdStatement)) {
  111968           0 :       void * object = ROSE_MALLOC(Size);
  111969           0 :       ALLOC_MUTEX(SgOmpParallelMasterTaskloopSimdStatement, unlock);
  111970             :       return object;
  111971             :     }
  111972             : #endif
  111973             : 
  111974           1 :     if (SgOmpParallelMasterTaskloopSimdStatement::next_node == nullptr) {
  111975           1 :         SgOmpParallelMasterTaskloopSimdStatement * alloc = (SgOmpParallelMasterTaskloopSimdStatement*) ROSE_MALLOC ( SgOmpParallelMasterTaskloopSimdStatement::pool_size * sizeof(SgOmpParallelMasterTaskloopSimdStatement) );
  111976           1 :         ROSE_ASSERT(alloc != nullptr);
  111977             : 
  111978             : #if ROSE_ALLOC_TRACE == 2
  111979             : //        printf("SgOmpParallelMasterTaskloopSimdStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgOmpParallelMasterTaskloopSimdStatement::pools.size(), alloc, alloc + SgOmpParallelMasterTaskloopSimdStatement::pool_size);
  111980             : #endif
  111981             : 
  111982             : #if ROSE_ALLOC_MEMSET == 1
  111983             : #elif ROSE_ALLOC_MEMSET == 2
  111984             :         memset(alloc, 0x00, SgOmpParallelMasterTaskloopSimdStatement::pool_size * sizeof(SgOmpParallelMasterTaskloopSimdStatement));
  111985             : #elif ROSE_ALLOC_MEMSET == 3
  111986             :         memset(alloc, 0xAA, SgOmpParallelMasterTaskloopSimdStatement::pool_size * sizeof(SgOmpParallelMasterTaskloopSimdStatement));
  111987             : #endif
  111988        2000 :         for (unsigned i=0; i < SgOmpParallelMasterTaskloopSimdStatement::pool_size-1; i++) {
  111989        1999 :           alloc[i].p_freepointer = &(alloc[i+1]);
  111990             :         }
  111991           1 :         alloc[SgOmpParallelMasterTaskloopSimdStatement::pool_size-1].p_freepointer = nullptr;
  111992             : 
  111993           1 :         SgOmpParallelMasterTaskloopSimdStatement::pools.push_back ( (unsigned char *) alloc );
  111994           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgOmpParallelMasterTaskloopSimdStatement::pool_size * sizeof(SgOmpParallelMasterTaskloopSimdStatement), V_SgOmpParallelMasterTaskloopSimdStatement ) );
  111995           1 :         SgOmpParallelMasterTaskloopSimdStatement::next_node = alloc;
  111996             :     }
  111997           1 :     ROSE_ASSERT(SgOmpParallelMasterTaskloopSimdStatement::next_node != nullptr);
  111998             : 
  111999           1 :     SgOmpParallelMasterTaskloopSimdStatement * object = SgOmpParallelMasterTaskloopSimdStatement::next_node;
  112000           1 :     SgOmpParallelMasterTaskloopSimdStatement::next_node = (SgOmpParallelMasterTaskloopSimdStatement*)(object->p_freepointer);
  112001             : 
  112002             : #if ROSE_ALLOC_TRACE == 2
  112003             :     printf("SgOmpParallelMasterTaskloopSimdStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpParallelMasterTaskloopSimdStatement::next_node);
  112004             : #endif
  112005             : 
  112006           1 :     SgNode * fp = object->p_freepointer;
  112007             : #if ROSE_ALLOC_MEMSET == 1
  112008             : #elif ROSE_ALLOC_MEMSET == 2
  112009             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpParallelMasterTaskloopSimdStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  112010             : #elif ROSE_ALLOC_MEMSET == 3
  112011             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgOmpParallelMasterTaskloopSimdStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  112012             : #endif
  112013           1 :     object->p_freepointer = fp;
  112014             : 
  112015             : #if ROSE_ALLOC_TRACE == 2
  112016             : //    printf("SgOmpParallelMasterTaskloopSimdStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpParallelMasterTaskloopSimdStatement::next_node);
  112017             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  112018             :     Rose::MemPool::snapshot(oss.str());
  112019             :     alloc_trace_cnt++;
  112020             : #endif
  112021             : 
  112022           1 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  112023             : 
  112024           1 :     ALLOC_MUTEX(SgOmpParallelMasterTaskloopSimdStatement, unlock);
  112025             : 
  112026             :     return object;
  112027             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  112028             : }
  112029             : 
  112030             : 
  112031             : 
  112032             : /*! \brief Delete operator for SgOmpParallelMasterTaskloopSimdStatement.
  112033             : 
  112034             :    This delete operator implements deallocation using memory pools to 
  112035             :    provide most efficent use of the heap within construction of large ASTs.
  112036             : 
  112037             : \internal The new and delete operators use the lower level C malloc/free
  112038             :    function calls for performance and to make sure that mixing of malloc/free
  112039             :    and new/delete by the used can be caught more readily.  This may change
  112040             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  112041             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  112042             :    deallocate memory allocated using ROSE_MALLOC.
  112043             : */
  112044           0 : void SgOmpParallelMasterTaskloopSimdStatement::operator delete(void *Pointer, size_t Size)
  112045             : {
  112046             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  112047             :      * or throwing an exception. */
  112048           0 :     ALLOC_MUTEX(SgOmpParallelMasterTaskloopSimdStatement, lock);
  112049             : 
  112050             : #if USE_CPP_NEW_DELETE_OPERATORS
  112051             :     ROSE_FREE(Pointer);
  112052             : #else
  112053             : #if ROSE_PEDANTIC_ALLOC
  112054             :     ROSE_ASSERT(Size == sizeof(SgOmpParallelMasterTaskloopSimdStatement));
  112055             : #else
  112056           0 :     if (Size != sizeof(SgOmpParallelMasterTaskloopSimdStatement)) {
  112057           0 :       ROSE_FREE(Pointer);
  112058           0 :       ALLOC_MUTEX(SgOmpParallelMasterTaskloopSimdStatement, unlock);
  112059             :       return;
  112060             :     }
  112061             : #endif
  112062             : 
  112063           0 :     SgOmpParallelMasterTaskloopSimdStatement * object = (SgOmpParallelMasterTaskloopSimdStatement*) Pointer;
  112064           0 :     ROSE_ASSERT(object != nullptr);
  112065             : 
  112066             : #if ROSE_ALLOC_TRACE == 2
  112067             : //  printf("SgOmpParallelMasterTaskloopSimdStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpParallelMasterTaskloopSimdStatement::next_node);
  112068             :     printf("SgOmpParallelMasterTaskloopSimdStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpParallelMasterTaskloopSimdStatement::next_node);
  112069             : #endif
  112070             : 
  112071             : #if ROSE_PEDANTIC_ALLOC
  112072             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  112073             : #endif
  112074             : 
  112075             : #if ROSE_ALLOC_MEMSET == 1
  112076             : #elif ROSE_ALLOC_MEMSET == 2
  112077             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpParallelMasterTaskloopSimdStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  112078             : #elif ROSE_ALLOC_MEMSET == 3
  112079             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgOmpParallelMasterTaskloopSimdStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  112080             : #endif
  112081             : 
  112082             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  112083             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  112084             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  112085             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  112086             : #else
  112087           0 :     object->p_freepointer = SgOmpParallelMasterTaskloopSimdStatement::next_node;
  112088           0 :     SgOmpParallelMasterTaskloopSimdStatement::next_node = object;
  112089             : #endif
  112090             : 
  112091             : #if ROSE_ALLOC_TRACE == 2
  112092             : //  printf("SgOmpParallelMasterTaskloopSimdStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpParallelMasterTaskloopSimdStatement::next_node);
  112093             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  112094             :     Rose::MemPool::snapshot(oss.str());
  112095             :     alloc_trace_cnt++;
  112096             : #endif
  112097             : 
  112098             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  112099             : 
  112100           0 :     ALLOC_MUTEX(SgOmpParallelMasterTaskloopSimdStatement, unlock);
  112101             : }
  112102             : 
  112103             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  112104             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  112105             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  112106             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  112107             : // Also, note comment below from Robb (copied from the Common.code file).
  112108             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  112109             : //
  112110             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  112111             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  112112             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  112113             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  112114             : #if 0
  112115             : void SgOmpParallelMasterTaskloopSimdStatement::operator delete(void* pointer) { SgOmpParallelMasterTaskloopSimdStatement::operator delete (pointer, sizeof(SgOmpParallelMasterTaskloopSimdStatement)); };
  112116             : #endif
  112117             : /* #line 112118 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  112118             : 
  112119             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  112120             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  112121             : // obviously imply C++.
  112122             : 
  112123             : // This implements the support within ROSE for memory pools.  Memory pools
  112124             : // support the most condensed usage of memory within the construction of
  112125             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  112126             : // by a new operator written for each class.
  112127             : 
  112128             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  112129             :     // User wants multi-thread support and POSIX threads are available.
  112130             : #   include <pthread.h>
  112131             :     static pthread_mutex_t SgOmpTeamsDistributeStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  112132             : #else
  112133             :      // Cause synchronization to be skipped.
  112134             : #    ifndef ALLOC_MUTEX
  112135             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  112136             : #    endif
  112137             : #    ifdef _REENTRANT
  112138             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  112139             : #       ifdef _MSC_VER
  112140             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  112141             : #       else
  112142             : #           warning "POSIX threads are not available; synchronization being skipped"
  112143             : #       endif
  112144             : #    endif
  112145             : #endif
  112146             : 
  112147             : #ifndef ROSE_ALLOC_TRACE
  112148             : #  define ROSE_ALLOC_TRACE 0
  112149             : #endif
  112150             : 
  112151             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  112152             : #define ROSE_ALLOC_TRACE_CNT
  112153             : #include "memory-pool-snapshot.h"
  112154             : unsigned long alloc_trace_cnt = 0;
  112155             : #endif
  112156             : 
  112157             : #if ROSE_ALLOC_TRACE
  112158             : const unsigned SgOmpTeamsDistributeStatement::pool_size = 5;
  112159             : #else
  112160             : const unsigned SgOmpTeamsDistributeStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  112161             : #endif
  112162             : 
  112163             : #ifndef ROSE_ALLOC_MEMSET
  112164             : #  define ROSE_ALLOC_MEMSET 0
  112165             : #endif
  112166             : 
  112167             : #ifndef ROSE_PEDANTIC_ALLOC
  112168             : #  define ROSE_PEDANTIC_ALLOC 0
  112169             : #endif
  112170             : 
  112171             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  112172             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  112173             : #endif
  112174             : 
  112175             : #if !defined(SGNODE__ALL_POOLS)
  112176             : #define SGNODE__ALL_POOLS
  112177             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  112178             : #endif
  112179             : 
  112180             : SgOmpTeamsDistributeStatement* SgOmpTeamsDistributeStatement::next_node = nullptr;
  112181             : std::vector<unsigned char*> SgOmpTeamsDistributeStatement::pools;
  112182             : 
  112183             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  112184             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  112185             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  112186             : // around this macro definition rather than each use).
  112187             : #ifndef ALLOC_MUTEX
  112188             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  112189             :         do {                                                                     \
  112190             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  112191             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  112192             :                 abort();                                                         \
  112193             :             }                                                                    \
  112194             :         } while (0);
  112195             : #endif
  112196             : 
  112197             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  112198             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  112199             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  112200             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  112201             : 
  112202             : /*! \brief New operator for SgOmpTeamsDistributeStatement.
  112203             : 
  112204             :    This new operator implements memory pools to provide most efficent 
  112205             :    use of the heap within construction of large ASTs.
  112206             : 
  112207             : \internal The new and delete operators use the lower level C malloc/free
  112208             :    function calls for performance and to make sure that mixing of malloc/free
  112209             :    and new/delete by the used can be caught more readily.  This may change
  112210             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  112211             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  112212             :    deallocate memory allocated using ROSE_MALLOC.
  112213             : */
  112214           1 : void *SgOmpTeamsDistributeStatement::operator new ( size_t Size )
  112215             : {
  112216             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  112217             :      * returning or throwing an exception. */
  112218           1 :     ALLOC_MUTEX(SgOmpTeamsDistributeStatement, lock);
  112219             : 
  112220             : #if ROSE_ALLOC_TRACE == 2
  112221             : //    printf("SgOmpTeamsDistributeStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgOmpTeamsDistributeStatement::next_node);
  112222             : #endif
  112223             : 
  112224             : #if USE_CPP_NEW_DELETE_OPERATORS
  112225             :     void *mem = ROSE_MALLOC(Size);
  112226             :     ALLOC_MUTEX(SgOmpTeamsDistributeStatement, unlock);
  112227             :     return mem;
  112228             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  112229             : #if ROSE_PEDANTIC_ALLOC
  112230             :     ROSE_ASSERT(Size == sizeof(SgOmpTeamsDistributeStatement));
  112231             : #else
  112232           1 :     if (Size != sizeof(SgOmpTeamsDistributeStatement)) {
  112233           0 :       void * object = ROSE_MALLOC(Size);
  112234           0 :       ALLOC_MUTEX(SgOmpTeamsDistributeStatement, unlock);
  112235             :       return object;
  112236             :     }
  112237             : #endif
  112238             : 
  112239           1 :     if (SgOmpTeamsDistributeStatement::next_node == nullptr) {
  112240           1 :         SgOmpTeamsDistributeStatement * alloc = (SgOmpTeamsDistributeStatement*) ROSE_MALLOC ( SgOmpTeamsDistributeStatement::pool_size * sizeof(SgOmpTeamsDistributeStatement) );
  112241           1 :         ROSE_ASSERT(alloc != nullptr);
  112242             : 
  112243             : #if ROSE_ALLOC_TRACE == 2
  112244             : //        printf("SgOmpTeamsDistributeStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgOmpTeamsDistributeStatement::pools.size(), alloc, alloc + SgOmpTeamsDistributeStatement::pool_size);
  112245             : #endif
  112246             : 
  112247             : #if ROSE_ALLOC_MEMSET == 1
  112248             : #elif ROSE_ALLOC_MEMSET == 2
  112249             :         memset(alloc, 0x00, SgOmpTeamsDistributeStatement::pool_size * sizeof(SgOmpTeamsDistributeStatement));
  112250             : #elif ROSE_ALLOC_MEMSET == 3
  112251             :         memset(alloc, 0xAA, SgOmpTeamsDistributeStatement::pool_size * sizeof(SgOmpTeamsDistributeStatement));
  112252             : #endif
  112253        2000 :         for (unsigned i=0; i < SgOmpTeamsDistributeStatement::pool_size-1; i++) {
  112254        1999 :           alloc[i].p_freepointer = &(alloc[i+1]);
  112255             :         }
  112256           1 :         alloc[SgOmpTeamsDistributeStatement::pool_size-1].p_freepointer = nullptr;
  112257             : 
  112258           1 :         SgOmpTeamsDistributeStatement::pools.push_back ( (unsigned char *) alloc );
  112259           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgOmpTeamsDistributeStatement::pool_size * sizeof(SgOmpTeamsDistributeStatement), V_SgOmpTeamsDistributeStatement ) );
  112260           1 :         SgOmpTeamsDistributeStatement::next_node = alloc;
  112261             :     }
  112262           1 :     ROSE_ASSERT(SgOmpTeamsDistributeStatement::next_node != nullptr);
  112263             : 
  112264           1 :     SgOmpTeamsDistributeStatement * object = SgOmpTeamsDistributeStatement::next_node;
  112265           1 :     SgOmpTeamsDistributeStatement::next_node = (SgOmpTeamsDistributeStatement*)(object->p_freepointer);
  112266             : 
  112267             : #if ROSE_ALLOC_TRACE == 2
  112268             :     printf("SgOmpTeamsDistributeStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpTeamsDistributeStatement::next_node);
  112269             : #endif
  112270             : 
  112271           1 :     SgNode * fp = object->p_freepointer;
  112272             : #if ROSE_ALLOC_MEMSET == 1
  112273             : #elif ROSE_ALLOC_MEMSET == 2
  112274             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpTeamsDistributeStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  112275             : #elif ROSE_ALLOC_MEMSET == 3
  112276             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgOmpTeamsDistributeStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  112277             : #endif
  112278           1 :     object->p_freepointer = fp;
  112279             : 
  112280             : #if ROSE_ALLOC_TRACE == 2
  112281             : //    printf("SgOmpTeamsDistributeStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpTeamsDistributeStatement::next_node);
  112282             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  112283             :     Rose::MemPool::snapshot(oss.str());
  112284             :     alloc_trace_cnt++;
  112285             : #endif
  112286             : 
  112287           1 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  112288             : 
  112289           1 :     ALLOC_MUTEX(SgOmpTeamsDistributeStatement, unlock);
  112290             : 
  112291             :     return object;
  112292             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  112293             : }
  112294             : 
  112295             : 
  112296             : 
  112297             : /*! \brief Delete operator for SgOmpTeamsDistributeStatement.
  112298             : 
  112299             :    This delete operator implements deallocation using memory pools to 
  112300             :    provide most efficent use of the heap within construction of large ASTs.
  112301             : 
  112302             : \internal The new and delete operators use the lower level C malloc/free
  112303             :    function calls for performance and to make sure that mixing of malloc/free
  112304             :    and new/delete by the used can be caught more readily.  This may change
  112305             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  112306             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  112307             :    deallocate memory allocated using ROSE_MALLOC.
  112308             : */
  112309           0 : void SgOmpTeamsDistributeStatement::operator delete(void *Pointer, size_t Size)
  112310             : {
  112311             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  112312             :      * or throwing an exception. */
  112313           0 :     ALLOC_MUTEX(SgOmpTeamsDistributeStatement, lock);
  112314             : 
  112315             : #if USE_CPP_NEW_DELETE_OPERATORS
  112316             :     ROSE_FREE(Pointer);
  112317             : #else
  112318             : #if ROSE_PEDANTIC_ALLOC
  112319             :     ROSE_ASSERT(Size == sizeof(SgOmpTeamsDistributeStatement));
  112320             : #else
  112321           0 :     if (Size != sizeof(SgOmpTeamsDistributeStatement)) {
  112322           0 :       ROSE_FREE(Pointer);
  112323           0 :       ALLOC_MUTEX(SgOmpTeamsDistributeStatement, unlock);
  112324             :       return;
  112325             :     }
  112326             : #endif
  112327             : 
  112328           0 :     SgOmpTeamsDistributeStatement * object = (SgOmpTeamsDistributeStatement*) Pointer;
  112329           0 :     ROSE_ASSERT(object != nullptr);
  112330             : 
  112331             : #if ROSE_ALLOC_TRACE == 2
  112332             : //  printf("SgOmpTeamsDistributeStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpTeamsDistributeStatement::next_node);
  112333             :     printf("SgOmpTeamsDistributeStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpTeamsDistributeStatement::next_node);
  112334             : #endif
  112335             : 
  112336             : #if ROSE_PEDANTIC_ALLOC
  112337             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  112338             : #endif
  112339             : 
  112340             : #if ROSE_ALLOC_MEMSET == 1
  112341             : #elif ROSE_ALLOC_MEMSET == 2
  112342             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpTeamsDistributeStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  112343             : #elif ROSE_ALLOC_MEMSET == 3
  112344             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgOmpTeamsDistributeStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  112345             : #endif
  112346             : 
  112347             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  112348             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  112349             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  112350             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  112351             : #else
  112352           0 :     object->p_freepointer = SgOmpTeamsDistributeStatement::next_node;
  112353           0 :     SgOmpTeamsDistributeStatement::next_node = object;
  112354             : #endif
  112355             : 
  112356             : #if ROSE_ALLOC_TRACE == 2
  112357             : //  printf("SgOmpTeamsDistributeStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpTeamsDistributeStatement::next_node);
  112358             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  112359             :     Rose::MemPool::snapshot(oss.str());
  112360             :     alloc_trace_cnt++;
  112361             : #endif
  112362             : 
  112363             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  112364             : 
  112365           0 :     ALLOC_MUTEX(SgOmpTeamsDistributeStatement, unlock);
  112366             : }
  112367             : 
  112368             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  112369             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  112370             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  112371             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  112372             : // Also, note comment below from Robb (copied from the Common.code file).
  112373             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  112374             : //
  112375             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  112376             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  112377             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  112378             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  112379             : #if 0
  112380             : void SgOmpTeamsDistributeStatement::operator delete(void* pointer) { SgOmpTeamsDistributeStatement::operator delete (pointer, sizeof(SgOmpTeamsDistributeStatement)); };
  112381             : #endif
  112382             : /* #line 112383 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  112383             : 
  112384             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  112385             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  112386             : // obviously imply C++.
  112387             : 
  112388             : // This implements the support within ROSE for memory pools.  Memory pools
  112389             : // support the most condensed usage of memory within the construction of
  112390             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  112391             : // by a new operator written for each class.
  112392             : 
  112393             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  112394             :     // User wants multi-thread support and POSIX threads are available.
  112395             : #   include <pthread.h>
  112396             :     static pthread_mutex_t SgOmpTeamsDistributeSimdStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  112397             : #else
  112398             :      // Cause synchronization to be skipped.
  112399             : #    ifndef ALLOC_MUTEX
  112400             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  112401             : #    endif
  112402             : #    ifdef _REENTRANT
  112403             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  112404             : #       ifdef _MSC_VER
  112405             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  112406             : #       else
  112407             : #           warning "POSIX threads are not available; synchronization being skipped"
  112408             : #       endif
  112409             : #    endif
  112410             : #endif
  112411             : 
  112412             : #ifndef ROSE_ALLOC_TRACE
  112413             : #  define ROSE_ALLOC_TRACE 0
  112414             : #endif
  112415             : 
  112416             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  112417             : #define ROSE_ALLOC_TRACE_CNT
  112418             : #include "memory-pool-snapshot.h"
  112419             : unsigned long alloc_trace_cnt = 0;
  112420             : #endif
  112421             : 
  112422             : #if ROSE_ALLOC_TRACE
  112423             : const unsigned SgOmpTeamsDistributeSimdStatement::pool_size = 5;
  112424             : #else
  112425             : const unsigned SgOmpTeamsDistributeSimdStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  112426             : #endif
  112427             : 
  112428             : #ifndef ROSE_ALLOC_MEMSET
  112429             : #  define ROSE_ALLOC_MEMSET 0
  112430             : #endif
  112431             : 
  112432             : #ifndef ROSE_PEDANTIC_ALLOC
  112433             : #  define ROSE_PEDANTIC_ALLOC 0
  112434             : #endif
  112435             : 
  112436             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  112437             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  112438             : #endif
  112439             : 
  112440             : #if !defined(SGNODE__ALL_POOLS)
  112441             : #define SGNODE__ALL_POOLS
  112442             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  112443             : #endif
  112444             : 
  112445             : SgOmpTeamsDistributeSimdStatement* SgOmpTeamsDistributeSimdStatement::next_node = nullptr;
  112446             : std::vector<unsigned char*> SgOmpTeamsDistributeSimdStatement::pools;
  112447             : 
  112448             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  112449             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  112450             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  112451             : // around this macro definition rather than each use).
  112452             : #ifndef ALLOC_MUTEX
  112453             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  112454             :         do {                                                                     \
  112455             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  112456             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  112457             :                 abort();                                                         \
  112458             :             }                                                                    \
  112459             :         } while (0);
  112460             : #endif
  112461             : 
  112462             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  112463             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  112464             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  112465             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  112466             : 
  112467             : /*! \brief New operator for SgOmpTeamsDistributeSimdStatement.
  112468             : 
  112469             :    This new operator implements memory pools to provide most efficent 
  112470             :    use of the heap within construction of large ASTs.
  112471             : 
  112472             : \internal The new and delete operators use the lower level C malloc/free
  112473             :    function calls for performance and to make sure that mixing of malloc/free
  112474             :    and new/delete by the used can be caught more readily.  This may change
  112475             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  112476             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  112477             :    deallocate memory allocated using ROSE_MALLOC.
  112478             : */
  112479           1 : void *SgOmpTeamsDistributeSimdStatement::operator new ( size_t Size )
  112480             : {
  112481             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  112482             :      * returning or throwing an exception. */
  112483           1 :     ALLOC_MUTEX(SgOmpTeamsDistributeSimdStatement, lock);
  112484             : 
  112485             : #if ROSE_ALLOC_TRACE == 2
  112486             : //    printf("SgOmpTeamsDistributeSimdStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgOmpTeamsDistributeSimdStatement::next_node);
  112487             : #endif
  112488             : 
  112489             : #if USE_CPP_NEW_DELETE_OPERATORS
  112490             :     void *mem = ROSE_MALLOC(Size);
  112491             :     ALLOC_MUTEX(SgOmpTeamsDistributeSimdStatement, unlock);
  112492             :     return mem;
  112493             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  112494             : #if ROSE_PEDANTIC_ALLOC
  112495             :     ROSE_ASSERT(Size == sizeof(SgOmpTeamsDistributeSimdStatement));
  112496             : #else
  112497           1 :     if (Size != sizeof(SgOmpTeamsDistributeSimdStatement)) {
  112498           0 :       void * object = ROSE_MALLOC(Size);
  112499           0 :       ALLOC_MUTEX(SgOmpTeamsDistributeSimdStatement, unlock);
  112500             :       return object;
  112501             :     }
  112502             : #endif
  112503             : 
  112504           1 :     if (SgOmpTeamsDistributeSimdStatement::next_node == nullptr) {
  112505           1 :         SgOmpTeamsDistributeSimdStatement * alloc = (SgOmpTeamsDistributeSimdStatement*) ROSE_MALLOC ( SgOmpTeamsDistributeSimdStatement::pool_size * sizeof(SgOmpTeamsDistributeSimdStatement) );
  112506           1 :         ROSE_ASSERT(alloc != nullptr);
  112507             : 
  112508             : #if ROSE_ALLOC_TRACE == 2
  112509             : //        printf("SgOmpTeamsDistributeSimdStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgOmpTeamsDistributeSimdStatement::pools.size(), alloc, alloc + SgOmpTeamsDistributeSimdStatement::pool_size);
  112510             : #endif
  112511             : 
  112512             : #if ROSE_ALLOC_MEMSET == 1
  112513             : #elif ROSE_ALLOC_MEMSET == 2
  112514             :         memset(alloc, 0x00, SgOmpTeamsDistributeSimdStatement::pool_size * sizeof(SgOmpTeamsDistributeSimdStatement));
  112515             : #elif ROSE_ALLOC_MEMSET == 3
  112516             :         memset(alloc, 0xAA, SgOmpTeamsDistributeSimdStatement::pool_size * sizeof(SgOmpTeamsDistributeSimdStatement));
  112517             : #endif
  112518        2000 :         for (unsigned i=0; i < SgOmpTeamsDistributeSimdStatement::pool_size-1; i++) {
  112519        1999 :           alloc[i].p_freepointer = &(alloc[i+1]);
  112520             :         }
  112521           1 :         alloc[SgOmpTeamsDistributeSimdStatement::pool_size-1].p_freepointer = nullptr;
  112522             : 
  112523           1 :         SgOmpTeamsDistributeSimdStatement::pools.push_back ( (unsigned char *) alloc );
  112524           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgOmpTeamsDistributeSimdStatement::pool_size * sizeof(SgOmpTeamsDistributeSimdStatement), V_SgOmpTeamsDistributeSimdStatement ) );
  112525           1 :         SgOmpTeamsDistributeSimdStatement::next_node = alloc;
  112526             :     }
  112527           1 :     ROSE_ASSERT(SgOmpTeamsDistributeSimdStatement::next_node != nullptr);
  112528             : 
  112529           1 :     SgOmpTeamsDistributeSimdStatement * object = SgOmpTeamsDistributeSimdStatement::next_node;
  112530           1 :     SgOmpTeamsDistributeSimdStatement::next_node = (SgOmpTeamsDistributeSimdStatement*)(object->p_freepointer);
  112531             : 
  112532             : #if ROSE_ALLOC_TRACE == 2
  112533             :     printf("SgOmpTeamsDistributeSimdStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpTeamsDistributeSimdStatement::next_node);
  112534             : #endif
  112535             : 
  112536           1 :     SgNode * fp = object->p_freepointer;
  112537             : #if ROSE_ALLOC_MEMSET == 1
  112538             : #elif ROSE_ALLOC_MEMSET == 2
  112539             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpTeamsDistributeSimdStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  112540             : #elif ROSE_ALLOC_MEMSET == 3
  112541             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgOmpTeamsDistributeSimdStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  112542             : #endif
  112543           1 :     object->p_freepointer = fp;
  112544             : 
  112545             : #if ROSE_ALLOC_TRACE == 2
  112546             : //    printf("SgOmpTeamsDistributeSimdStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpTeamsDistributeSimdStatement::next_node);
  112547             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  112548             :     Rose::MemPool::snapshot(oss.str());
  112549             :     alloc_trace_cnt++;
  112550             : #endif
  112551             : 
  112552           1 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  112553             : 
  112554           1 :     ALLOC_MUTEX(SgOmpTeamsDistributeSimdStatement, unlock);
  112555             : 
  112556             :     return object;
  112557             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  112558             : }
  112559             : 
  112560             : 
  112561             : 
  112562             : /*! \brief Delete operator for SgOmpTeamsDistributeSimdStatement.
  112563             : 
  112564             :    This delete operator implements deallocation using memory pools to 
  112565             :    provide most efficent use of the heap within construction of large ASTs.
  112566             : 
  112567             : \internal The new and delete operators use the lower level C malloc/free
  112568             :    function calls for performance and to make sure that mixing of malloc/free
  112569             :    and new/delete by the used can be caught more readily.  This may change
  112570             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  112571             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  112572             :    deallocate memory allocated using ROSE_MALLOC.
  112573             : */
  112574           0 : void SgOmpTeamsDistributeSimdStatement::operator delete(void *Pointer, size_t Size)
  112575             : {
  112576             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  112577             :      * or throwing an exception. */
  112578           0 :     ALLOC_MUTEX(SgOmpTeamsDistributeSimdStatement, lock);
  112579             : 
  112580             : #if USE_CPP_NEW_DELETE_OPERATORS
  112581             :     ROSE_FREE(Pointer);
  112582             : #else
  112583             : #if ROSE_PEDANTIC_ALLOC
  112584             :     ROSE_ASSERT(Size == sizeof(SgOmpTeamsDistributeSimdStatement));
  112585             : #else
  112586           0 :     if (Size != sizeof(SgOmpTeamsDistributeSimdStatement)) {
  112587           0 :       ROSE_FREE(Pointer);
  112588           0 :       ALLOC_MUTEX(SgOmpTeamsDistributeSimdStatement, unlock);
  112589             :       return;
  112590             :     }
  112591             : #endif
  112592             : 
  112593           0 :     SgOmpTeamsDistributeSimdStatement * object = (SgOmpTeamsDistributeSimdStatement*) Pointer;
  112594           0 :     ROSE_ASSERT(object != nullptr);
  112595             : 
  112596             : #if ROSE_ALLOC_TRACE == 2
  112597             : //  printf("SgOmpTeamsDistributeSimdStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpTeamsDistributeSimdStatement::next_node);
  112598             :     printf("SgOmpTeamsDistributeSimdStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpTeamsDistributeSimdStatement::next_node);
  112599             : #endif
  112600             : 
  112601             : #if ROSE_PEDANTIC_ALLOC
  112602             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  112603             : #endif
  112604             : 
  112605             : #if ROSE_ALLOC_MEMSET == 1
  112606             : #elif ROSE_ALLOC_MEMSET == 2
  112607             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpTeamsDistributeSimdStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  112608             : #elif ROSE_ALLOC_MEMSET == 3
  112609             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgOmpTeamsDistributeSimdStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  112610             : #endif
  112611             : 
  112612             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  112613             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  112614             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  112615             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  112616             : #else
  112617           0 :     object->p_freepointer = SgOmpTeamsDistributeSimdStatement::next_node;
  112618           0 :     SgOmpTeamsDistributeSimdStatement::next_node = object;
  112619             : #endif
  112620             : 
  112621             : #if ROSE_ALLOC_TRACE == 2
  112622             : //  printf("SgOmpTeamsDistributeSimdStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpTeamsDistributeSimdStatement::next_node);
  112623             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  112624             :     Rose::MemPool::snapshot(oss.str());
  112625             :     alloc_trace_cnt++;
  112626             : #endif
  112627             : 
  112628             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  112629             : 
  112630           0 :     ALLOC_MUTEX(SgOmpTeamsDistributeSimdStatement, unlock);
  112631             : }
  112632             : 
  112633             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  112634             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  112635             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  112636             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  112637             : // Also, note comment below from Robb (copied from the Common.code file).
  112638             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  112639             : //
  112640             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  112641             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  112642             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  112643             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  112644             : #if 0
  112645             : void SgOmpTeamsDistributeSimdStatement::operator delete(void* pointer) { SgOmpTeamsDistributeSimdStatement::operator delete (pointer, sizeof(SgOmpTeamsDistributeSimdStatement)); };
  112646             : #endif
  112647             : /* #line 112648 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  112648             : 
  112649             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  112650             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  112651             : // obviously imply C++.
  112652             : 
  112653             : // This implements the support within ROSE for memory pools.  Memory pools
  112654             : // support the most condensed usage of memory within the construction of
  112655             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  112656             : // by a new operator written for each class.
  112657             : 
  112658             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  112659             :     // User wants multi-thread support and POSIX threads are available.
  112660             : #   include <pthread.h>
  112661             :     static pthread_mutex_t SgOmpTeamsDistributeParallelForStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  112662             : #else
  112663             :      // Cause synchronization to be skipped.
  112664             : #    ifndef ALLOC_MUTEX
  112665             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  112666             : #    endif
  112667             : #    ifdef _REENTRANT
  112668             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  112669             : #       ifdef _MSC_VER
  112670             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  112671             : #       else
  112672             : #           warning "POSIX threads are not available; synchronization being skipped"
  112673             : #       endif
  112674             : #    endif
  112675             : #endif
  112676             : 
  112677             : #ifndef ROSE_ALLOC_TRACE
  112678             : #  define ROSE_ALLOC_TRACE 0
  112679             : #endif
  112680             : 
  112681             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  112682             : #define ROSE_ALLOC_TRACE_CNT
  112683             : #include "memory-pool-snapshot.h"
  112684             : unsigned long alloc_trace_cnt = 0;
  112685             : #endif
  112686             : 
  112687             : #if ROSE_ALLOC_TRACE
  112688             : const unsigned SgOmpTeamsDistributeParallelForStatement::pool_size = 5;
  112689             : #else
  112690             : const unsigned SgOmpTeamsDistributeParallelForStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  112691             : #endif
  112692             : 
  112693             : #ifndef ROSE_ALLOC_MEMSET
  112694             : #  define ROSE_ALLOC_MEMSET 0
  112695             : #endif
  112696             : 
  112697             : #ifndef ROSE_PEDANTIC_ALLOC
  112698             : #  define ROSE_PEDANTIC_ALLOC 0
  112699             : #endif
  112700             : 
  112701             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  112702             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  112703             : #endif
  112704             : 
  112705             : #if !defined(SGNODE__ALL_POOLS)
  112706             : #define SGNODE__ALL_POOLS
  112707             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  112708             : #endif
  112709             : 
  112710             : SgOmpTeamsDistributeParallelForStatement* SgOmpTeamsDistributeParallelForStatement::next_node = nullptr;
  112711             : std::vector<unsigned char*> SgOmpTeamsDistributeParallelForStatement::pools;
  112712             : 
  112713             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  112714             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  112715             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  112716             : // around this macro definition rather than each use).
  112717             : #ifndef ALLOC_MUTEX
  112718             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  112719             :         do {                                                                     \
  112720             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  112721             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  112722             :                 abort();                                                         \
  112723             :             }                                                                    \
  112724             :         } while (0);
  112725             : #endif
  112726             : 
  112727             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  112728             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  112729             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  112730             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  112731             : 
  112732             : /*! \brief New operator for SgOmpTeamsDistributeParallelForStatement.
  112733             : 
  112734             :    This new operator implements memory pools to provide most efficent 
  112735             :    use of the heap within construction of large ASTs.
  112736             : 
  112737             : \internal The new and delete operators use the lower level C malloc/free
  112738             :    function calls for performance and to make sure that mixing of malloc/free
  112739             :    and new/delete by the used can be caught more readily.  This may change
  112740             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  112741             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  112742             :    deallocate memory allocated using ROSE_MALLOC.
  112743             : */
  112744           1 : void *SgOmpTeamsDistributeParallelForStatement::operator new ( size_t Size )
  112745             : {
  112746             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  112747             :      * returning or throwing an exception. */
  112748           1 :     ALLOC_MUTEX(SgOmpTeamsDistributeParallelForStatement, lock);
  112749             : 
  112750             : #if ROSE_ALLOC_TRACE == 2
  112751             : //    printf("SgOmpTeamsDistributeParallelForStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgOmpTeamsDistributeParallelForStatement::next_node);
  112752             : #endif
  112753             : 
  112754             : #if USE_CPP_NEW_DELETE_OPERATORS
  112755             :     void *mem = ROSE_MALLOC(Size);
  112756             :     ALLOC_MUTEX(SgOmpTeamsDistributeParallelForStatement, unlock);
  112757             :     return mem;
  112758             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  112759             : #if ROSE_PEDANTIC_ALLOC
  112760             :     ROSE_ASSERT(Size == sizeof(SgOmpTeamsDistributeParallelForStatement));
  112761             : #else
  112762           1 :     if (Size != sizeof(SgOmpTeamsDistributeParallelForStatement)) {
  112763           0 :       void * object = ROSE_MALLOC(Size);
  112764           0 :       ALLOC_MUTEX(SgOmpTeamsDistributeParallelForStatement, unlock);
  112765             :       return object;
  112766             :     }
  112767             : #endif
  112768             : 
  112769           1 :     if (SgOmpTeamsDistributeParallelForStatement::next_node == nullptr) {
  112770           1 :         SgOmpTeamsDistributeParallelForStatement * alloc = (SgOmpTeamsDistributeParallelForStatement*) ROSE_MALLOC ( SgOmpTeamsDistributeParallelForStatement::pool_size * sizeof(SgOmpTeamsDistributeParallelForStatement) );
  112771           1 :         ROSE_ASSERT(alloc != nullptr);
  112772             : 
  112773             : #if ROSE_ALLOC_TRACE == 2
  112774             : //        printf("SgOmpTeamsDistributeParallelForStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgOmpTeamsDistributeParallelForStatement::pools.size(), alloc, alloc + SgOmpTeamsDistributeParallelForStatement::pool_size);
  112775             : #endif
  112776             : 
  112777             : #if ROSE_ALLOC_MEMSET == 1
  112778             : #elif ROSE_ALLOC_MEMSET == 2
  112779             :         memset(alloc, 0x00, SgOmpTeamsDistributeParallelForStatement::pool_size * sizeof(SgOmpTeamsDistributeParallelForStatement));
  112780             : #elif ROSE_ALLOC_MEMSET == 3
  112781             :         memset(alloc, 0xAA, SgOmpTeamsDistributeParallelForStatement::pool_size * sizeof(SgOmpTeamsDistributeParallelForStatement));
  112782             : #endif
  112783        2000 :         for (unsigned i=0; i < SgOmpTeamsDistributeParallelForStatement::pool_size-1; i++) {
  112784        1999 :           alloc[i].p_freepointer = &(alloc[i+1]);
  112785             :         }
  112786           1 :         alloc[SgOmpTeamsDistributeParallelForStatement::pool_size-1].p_freepointer = nullptr;
  112787             : 
  112788           1 :         SgOmpTeamsDistributeParallelForStatement::pools.push_back ( (unsigned char *) alloc );
  112789           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgOmpTeamsDistributeParallelForStatement::pool_size * sizeof(SgOmpTeamsDistributeParallelForStatement), V_SgOmpTeamsDistributeParallelForStatement ) );
  112790           1 :         SgOmpTeamsDistributeParallelForStatement::next_node = alloc;
  112791             :     }
  112792           1 :     ROSE_ASSERT(SgOmpTeamsDistributeParallelForStatement::next_node != nullptr);
  112793             : 
  112794           1 :     SgOmpTeamsDistributeParallelForStatement * object = SgOmpTeamsDistributeParallelForStatement::next_node;
  112795           1 :     SgOmpTeamsDistributeParallelForStatement::next_node = (SgOmpTeamsDistributeParallelForStatement*)(object->p_freepointer);
  112796             : 
  112797             : #if ROSE_ALLOC_TRACE == 2
  112798             :     printf("SgOmpTeamsDistributeParallelForStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpTeamsDistributeParallelForStatement::next_node);
  112799             : #endif
  112800             : 
  112801           1 :     SgNode * fp = object->p_freepointer;
  112802             : #if ROSE_ALLOC_MEMSET == 1
  112803             : #elif ROSE_ALLOC_MEMSET == 2
  112804             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpTeamsDistributeParallelForStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  112805             : #elif ROSE_ALLOC_MEMSET == 3
  112806             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgOmpTeamsDistributeParallelForStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  112807             : #endif
  112808           1 :     object->p_freepointer = fp;
  112809             : 
  112810             : #if ROSE_ALLOC_TRACE == 2
  112811             : //    printf("SgOmpTeamsDistributeParallelForStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpTeamsDistributeParallelForStatement::next_node);
  112812             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  112813             :     Rose::MemPool::snapshot(oss.str());
  112814             :     alloc_trace_cnt++;
  112815             : #endif
  112816             : 
  112817           1 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  112818             : 
  112819           1 :     ALLOC_MUTEX(SgOmpTeamsDistributeParallelForStatement, unlock);
  112820             : 
  112821             :     return object;
  112822             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  112823             : }
  112824             : 
  112825             : 
  112826             : 
  112827             : /*! \brief Delete operator for SgOmpTeamsDistributeParallelForStatement.
  112828             : 
  112829             :    This delete operator implements deallocation using memory pools to 
  112830             :    provide most efficent use of the heap within construction of large ASTs.
  112831             : 
  112832             : \internal The new and delete operators use the lower level C malloc/free
  112833             :    function calls for performance and to make sure that mixing of malloc/free
  112834             :    and new/delete by the used can be caught more readily.  This may change
  112835             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  112836             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  112837             :    deallocate memory allocated using ROSE_MALLOC.
  112838             : */
  112839           0 : void SgOmpTeamsDistributeParallelForStatement::operator delete(void *Pointer, size_t Size)
  112840             : {
  112841             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  112842             :      * or throwing an exception. */
  112843           0 :     ALLOC_MUTEX(SgOmpTeamsDistributeParallelForStatement, lock);
  112844             : 
  112845             : #if USE_CPP_NEW_DELETE_OPERATORS
  112846             :     ROSE_FREE(Pointer);
  112847             : #else
  112848             : #if ROSE_PEDANTIC_ALLOC
  112849             :     ROSE_ASSERT(Size == sizeof(SgOmpTeamsDistributeParallelForStatement));
  112850             : #else
  112851           0 :     if (Size != sizeof(SgOmpTeamsDistributeParallelForStatement)) {
  112852           0 :       ROSE_FREE(Pointer);
  112853           0 :       ALLOC_MUTEX(SgOmpTeamsDistributeParallelForStatement, unlock);
  112854             :       return;
  112855             :     }
  112856             : #endif
  112857             : 
  112858           0 :     SgOmpTeamsDistributeParallelForStatement * object = (SgOmpTeamsDistributeParallelForStatement*) Pointer;
  112859           0 :     ROSE_ASSERT(object != nullptr);
  112860             : 
  112861             : #if ROSE_ALLOC_TRACE == 2
  112862             : //  printf("SgOmpTeamsDistributeParallelForStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpTeamsDistributeParallelForStatement::next_node);
  112863             :     printf("SgOmpTeamsDistributeParallelForStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpTeamsDistributeParallelForStatement::next_node);
  112864             : #endif
  112865             : 
  112866             : #if ROSE_PEDANTIC_ALLOC
  112867             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  112868             : #endif
  112869             : 
  112870             : #if ROSE_ALLOC_MEMSET == 1
  112871             : #elif ROSE_ALLOC_MEMSET == 2
  112872             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpTeamsDistributeParallelForStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  112873             : #elif ROSE_ALLOC_MEMSET == 3
  112874             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgOmpTeamsDistributeParallelForStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  112875             : #endif
  112876             : 
  112877             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  112878             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  112879             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  112880             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  112881             : #else
  112882           0 :     object->p_freepointer = SgOmpTeamsDistributeParallelForStatement::next_node;
  112883           0 :     SgOmpTeamsDistributeParallelForStatement::next_node = object;
  112884             : #endif
  112885             : 
  112886             : #if ROSE_ALLOC_TRACE == 2
  112887             : //  printf("SgOmpTeamsDistributeParallelForStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpTeamsDistributeParallelForStatement::next_node);
  112888             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  112889             :     Rose::MemPool::snapshot(oss.str());
  112890             :     alloc_trace_cnt++;
  112891             : #endif
  112892             : 
  112893             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  112894             : 
  112895           0 :     ALLOC_MUTEX(SgOmpTeamsDistributeParallelForStatement, unlock);
  112896             : }
  112897             : 
  112898             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  112899             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  112900             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  112901             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  112902             : // Also, note comment below from Robb (copied from the Common.code file).
  112903             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  112904             : //
  112905             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  112906             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  112907             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  112908             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  112909             : #if 0
  112910             : void SgOmpTeamsDistributeParallelForStatement::operator delete(void* pointer) { SgOmpTeamsDistributeParallelForStatement::operator delete (pointer, sizeof(SgOmpTeamsDistributeParallelForStatement)); };
  112911             : #endif
  112912             : /* #line 112913 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  112913             : 
  112914             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  112915             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  112916             : // obviously imply C++.
  112917             : 
  112918             : // This implements the support within ROSE for memory pools.  Memory pools
  112919             : // support the most condensed usage of memory within the construction of
  112920             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  112921             : // by a new operator written for each class.
  112922             : 
  112923             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  112924             :     // User wants multi-thread support and POSIX threads are available.
  112925             : #   include <pthread.h>
  112926             :     static pthread_mutex_t SgOmpTeamsDistributeParallelForSimdStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  112927             : #else
  112928             :      // Cause synchronization to be skipped.
  112929             : #    ifndef ALLOC_MUTEX
  112930             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  112931             : #    endif
  112932             : #    ifdef _REENTRANT
  112933             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  112934             : #       ifdef _MSC_VER
  112935             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  112936             : #       else
  112937             : #           warning "POSIX threads are not available; synchronization being skipped"
  112938             : #       endif
  112939             : #    endif
  112940             : #endif
  112941             : 
  112942             : #ifndef ROSE_ALLOC_TRACE
  112943             : #  define ROSE_ALLOC_TRACE 0
  112944             : #endif
  112945             : 
  112946             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  112947             : #define ROSE_ALLOC_TRACE_CNT
  112948             : #include "memory-pool-snapshot.h"
  112949             : unsigned long alloc_trace_cnt = 0;
  112950             : #endif
  112951             : 
  112952             : #if ROSE_ALLOC_TRACE
  112953             : const unsigned SgOmpTeamsDistributeParallelForSimdStatement::pool_size = 5;
  112954             : #else
  112955             : const unsigned SgOmpTeamsDistributeParallelForSimdStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  112956             : #endif
  112957             : 
  112958             : #ifndef ROSE_ALLOC_MEMSET
  112959             : #  define ROSE_ALLOC_MEMSET 0
  112960             : #endif
  112961             : 
  112962             : #ifndef ROSE_PEDANTIC_ALLOC
  112963             : #  define ROSE_PEDANTIC_ALLOC 0
  112964             : #endif
  112965             : 
  112966             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  112967             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  112968             : #endif
  112969             : 
  112970             : #if !defined(SGNODE__ALL_POOLS)
  112971             : #define SGNODE__ALL_POOLS
  112972             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  112973             : #endif
  112974             : 
  112975             : SgOmpTeamsDistributeParallelForSimdStatement* SgOmpTeamsDistributeParallelForSimdStatement::next_node = nullptr;
  112976             : std::vector<unsigned char*> SgOmpTeamsDistributeParallelForSimdStatement::pools;
  112977             : 
  112978             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  112979             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  112980             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  112981             : // around this macro definition rather than each use).
  112982             : #ifndef ALLOC_MUTEX
  112983             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  112984             :         do {                                                                     \
  112985             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  112986             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  112987             :                 abort();                                                         \
  112988             :             }                                                                    \
  112989             :         } while (0);
  112990             : #endif
  112991             : 
  112992             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  112993             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  112994             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  112995             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  112996             : 
  112997             : /*! \brief New operator for SgOmpTeamsDistributeParallelForSimdStatement.
  112998             : 
  112999             :    This new operator implements memory pools to provide most efficent 
  113000             :    use of the heap within construction of large ASTs.
  113001             : 
  113002             : \internal The new and delete operators use the lower level C malloc/free
  113003             :    function calls for performance and to make sure that mixing of malloc/free
  113004             :    and new/delete by the used can be caught more readily.  This may change
  113005             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  113006             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  113007             :    deallocate memory allocated using ROSE_MALLOC.
  113008             : */
  113009           1 : void *SgOmpTeamsDistributeParallelForSimdStatement::operator new ( size_t Size )
  113010             : {
  113011             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  113012             :      * returning or throwing an exception. */
  113013           1 :     ALLOC_MUTEX(SgOmpTeamsDistributeParallelForSimdStatement, lock);
  113014             : 
  113015             : #if ROSE_ALLOC_TRACE == 2
  113016             : //    printf("SgOmpTeamsDistributeParallelForSimdStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgOmpTeamsDistributeParallelForSimdStatement::next_node);
  113017             : #endif
  113018             : 
  113019             : #if USE_CPP_NEW_DELETE_OPERATORS
  113020             :     void *mem = ROSE_MALLOC(Size);
  113021             :     ALLOC_MUTEX(SgOmpTeamsDistributeParallelForSimdStatement, unlock);
  113022             :     return mem;
  113023             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  113024             : #if ROSE_PEDANTIC_ALLOC
  113025             :     ROSE_ASSERT(Size == sizeof(SgOmpTeamsDistributeParallelForSimdStatement));
  113026             : #else
  113027           1 :     if (Size != sizeof(SgOmpTeamsDistributeParallelForSimdStatement)) {
  113028           0 :       void * object = ROSE_MALLOC(Size);
  113029           0 :       ALLOC_MUTEX(SgOmpTeamsDistributeParallelForSimdStatement, unlock);
  113030             :       return object;
  113031             :     }
  113032             : #endif
  113033             : 
  113034           1 :     if (SgOmpTeamsDistributeParallelForSimdStatement::next_node == nullptr) {
  113035           1 :         SgOmpTeamsDistributeParallelForSimdStatement * alloc = (SgOmpTeamsDistributeParallelForSimdStatement*) ROSE_MALLOC ( SgOmpTeamsDistributeParallelForSimdStatement::pool_size * sizeof(SgOmpTeamsDistributeParallelForSimdStatement) );
  113036           1 :         ROSE_ASSERT(alloc != nullptr);
  113037             : 
  113038             : #if ROSE_ALLOC_TRACE == 2
  113039             : //        printf("SgOmpTeamsDistributeParallelForSimdStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgOmpTeamsDistributeParallelForSimdStatement::pools.size(), alloc, alloc + SgOmpTeamsDistributeParallelForSimdStatement::pool_size);
  113040             : #endif
  113041             : 
  113042             : #if ROSE_ALLOC_MEMSET == 1
  113043             : #elif ROSE_ALLOC_MEMSET == 2
  113044             :         memset(alloc, 0x00, SgOmpTeamsDistributeParallelForSimdStatement::pool_size * sizeof(SgOmpTeamsDistributeParallelForSimdStatement));
  113045             : #elif ROSE_ALLOC_MEMSET == 3
  113046             :         memset(alloc, 0xAA, SgOmpTeamsDistributeParallelForSimdStatement::pool_size * sizeof(SgOmpTeamsDistributeParallelForSimdStatement));
  113047             : #endif
  113048        2000 :         for (unsigned i=0; i < SgOmpTeamsDistributeParallelForSimdStatement::pool_size-1; i++) {
  113049        1999 :           alloc[i].p_freepointer = &(alloc[i+1]);
  113050             :         }
  113051           1 :         alloc[SgOmpTeamsDistributeParallelForSimdStatement::pool_size-1].p_freepointer = nullptr;
  113052             : 
  113053           1 :         SgOmpTeamsDistributeParallelForSimdStatement::pools.push_back ( (unsigned char *) alloc );
  113054           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgOmpTeamsDistributeParallelForSimdStatement::pool_size * sizeof(SgOmpTeamsDistributeParallelForSimdStatement), V_SgOmpTeamsDistributeParallelForSimdStatement ) );
  113055           1 :         SgOmpTeamsDistributeParallelForSimdStatement::next_node = alloc;
  113056             :     }
  113057           1 :     ROSE_ASSERT(SgOmpTeamsDistributeParallelForSimdStatement::next_node != nullptr);
  113058             : 
  113059           1 :     SgOmpTeamsDistributeParallelForSimdStatement * object = SgOmpTeamsDistributeParallelForSimdStatement::next_node;
  113060           1 :     SgOmpTeamsDistributeParallelForSimdStatement::next_node = (SgOmpTeamsDistributeParallelForSimdStatement*)(object->p_freepointer);
  113061             : 
  113062             : #if ROSE_ALLOC_TRACE == 2
  113063             :     printf("SgOmpTeamsDistributeParallelForSimdStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpTeamsDistributeParallelForSimdStatement::next_node);
  113064             : #endif
  113065             : 
  113066           1 :     SgNode * fp = object->p_freepointer;
  113067             : #if ROSE_ALLOC_MEMSET == 1
  113068             : #elif ROSE_ALLOC_MEMSET == 2
  113069             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpTeamsDistributeParallelForSimdStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  113070             : #elif ROSE_ALLOC_MEMSET == 3
  113071             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgOmpTeamsDistributeParallelForSimdStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  113072             : #endif
  113073           1 :     object->p_freepointer = fp;
  113074             : 
  113075             : #if ROSE_ALLOC_TRACE == 2
  113076             : //    printf("SgOmpTeamsDistributeParallelForSimdStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpTeamsDistributeParallelForSimdStatement::next_node);
  113077             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  113078             :     Rose::MemPool::snapshot(oss.str());
  113079             :     alloc_trace_cnt++;
  113080             : #endif
  113081             : 
  113082           1 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  113083             : 
  113084           1 :     ALLOC_MUTEX(SgOmpTeamsDistributeParallelForSimdStatement, unlock);
  113085             : 
  113086             :     return object;
  113087             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  113088             : }
  113089             : 
  113090             : 
  113091             : 
  113092             : /*! \brief Delete operator for SgOmpTeamsDistributeParallelForSimdStatement.
  113093             : 
  113094             :    This delete operator implements deallocation using memory pools to 
  113095             :    provide most efficent use of the heap within construction of large ASTs.
  113096             : 
  113097             : \internal The new and delete operators use the lower level C malloc/free
  113098             :    function calls for performance and to make sure that mixing of malloc/free
  113099             :    and new/delete by the used can be caught more readily.  This may change
  113100             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  113101             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  113102             :    deallocate memory allocated using ROSE_MALLOC.
  113103             : */
  113104           0 : void SgOmpTeamsDistributeParallelForSimdStatement::operator delete(void *Pointer, size_t Size)
  113105             : {
  113106             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  113107             :      * or throwing an exception. */
  113108           0 :     ALLOC_MUTEX(SgOmpTeamsDistributeParallelForSimdStatement, lock);
  113109             : 
  113110             : #if USE_CPP_NEW_DELETE_OPERATORS
  113111             :     ROSE_FREE(Pointer);
  113112             : #else
  113113             : #if ROSE_PEDANTIC_ALLOC
  113114             :     ROSE_ASSERT(Size == sizeof(SgOmpTeamsDistributeParallelForSimdStatement));
  113115             : #else
  113116           0 :     if (Size != sizeof(SgOmpTeamsDistributeParallelForSimdStatement)) {
  113117           0 :       ROSE_FREE(Pointer);
  113118           0 :       ALLOC_MUTEX(SgOmpTeamsDistributeParallelForSimdStatement, unlock);
  113119             :       return;
  113120             :     }
  113121             : #endif
  113122             : 
  113123           0 :     SgOmpTeamsDistributeParallelForSimdStatement * object = (SgOmpTeamsDistributeParallelForSimdStatement*) Pointer;
  113124           0 :     ROSE_ASSERT(object != nullptr);
  113125             : 
  113126             : #if ROSE_ALLOC_TRACE == 2
  113127             : //  printf("SgOmpTeamsDistributeParallelForSimdStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpTeamsDistributeParallelForSimdStatement::next_node);
  113128             :     printf("SgOmpTeamsDistributeParallelForSimdStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpTeamsDistributeParallelForSimdStatement::next_node);
  113129             : #endif
  113130             : 
  113131             : #if ROSE_PEDANTIC_ALLOC
  113132             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  113133             : #endif
  113134             : 
  113135             : #if ROSE_ALLOC_MEMSET == 1
  113136             : #elif ROSE_ALLOC_MEMSET == 2
  113137             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpTeamsDistributeParallelForSimdStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  113138             : #elif ROSE_ALLOC_MEMSET == 3
  113139             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgOmpTeamsDistributeParallelForSimdStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  113140             : #endif
  113141             : 
  113142             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  113143             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  113144             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  113145             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  113146             : #else
  113147           0 :     object->p_freepointer = SgOmpTeamsDistributeParallelForSimdStatement::next_node;
  113148           0 :     SgOmpTeamsDistributeParallelForSimdStatement::next_node = object;
  113149             : #endif
  113150             : 
  113151             : #if ROSE_ALLOC_TRACE == 2
  113152             : //  printf("SgOmpTeamsDistributeParallelForSimdStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpTeamsDistributeParallelForSimdStatement::next_node);
  113153             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  113154             :     Rose::MemPool::snapshot(oss.str());
  113155             :     alloc_trace_cnt++;
  113156             : #endif
  113157             : 
  113158             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  113159             : 
  113160           0 :     ALLOC_MUTEX(SgOmpTeamsDistributeParallelForSimdStatement, unlock);
  113161             : }
  113162             : 
  113163             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  113164             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  113165             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  113166             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  113167             : // Also, note comment below from Robb (copied from the Common.code file).
  113168             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  113169             : //
  113170             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  113171             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  113172             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  113173             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  113174             : #if 0
  113175             : void SgOmpTeamsDistributeParallelForSimdStatement::operator delete(void* pointer) { SgOmpTeamsDistributeParallelForSimdStatement::operator delete (pointer, sizeof(SgOmpTeamsDistributeParallelForSimdStatement)); };
  113176             : #endif
  113177             : /* #line 113178 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  113178             : 
  113179             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  113180             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  113181             : // obviously imply C++.
  113182             : 
  113183             : // This implements the support within ROSE for memory pools.  Memory pools
  113184             : // support the most condensed usage of memory within the construction of
  113185             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  113186             : // by a new operator written for each class.
  113187             : 
  113188             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  113189             :     // User wants multi-thread support and POSIX threads are available.
  113190             : #   include <pthread.h>
  113191             :     static pthread_mutex_t SgOmpTeamsLoopStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  113192             : #else
  113193             :      // Cause synchronization to be skipped.
  113194             : #    ifndef ALLOC_MUTEX
  113195             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  113196             : #    endif
  113197             : #    ifdef _REENTRANT
  113198             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  113199             : #       ifdef _MSC_VER
  113200             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  113201             : #       else
  113202             : #           warning "POSIX threads are not available; synchronization being skipped"
  113203             : #       endif
  113204             : #    endif
  113205             : #endif
  113206             : 
  113207             : #ifndef ROSE_ALLOC_TRACE
  113208             : #  define ROSE_ALLOC_TRACE 0
  113209             : #endif
  113210             : 
  113211             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  113212             : #define ROSE_ALLOC_TRACE_CNT
  113213             : #include "memory-pool-snapshot.h"
  113214             : unsigned long alloc_trace_cnt = 0;
  113215             : #endif
  113216             : 
  113217             : #if ROSE_ALLOC_TRACE
  113218             : const unsigned SgOmpTeamsLoopStatement::pool_size = 5;
  113219             : #else
  113220             : const unsigned SgOmpTeamsLoopStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  113221             : #endif
  113222             : 
  113223             : #ifndef ROSE_ALLOC_MEMSET
  113224             : #  define ROSE_ALLOC_MEMSET 0
  113225             : #endif
  113226             : 
  113227             : #ifndef ROSE_PEDANTIC_ALLOC
  113228             : #  define ROSE_PEDANTIC_ALLOC 0
  113229             : #endif
  113230             : 
  113231             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  113232             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  113233             : #endif
  113234             : 
  113235             : #if !defined(SGNODE__ALL_POOLS)
  113236             : #define SGNODE__ALL_POOLS
  113237             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  113238             : #endif
  113239             : 
  113240             : SgOmpTeamsLoopStatement* SgOmpTeamsLoopStatement::next_node = nullptr;
  113241             : std::vector<unsigned char*> SgOmpTeamsLoopStatement::pools;
  113242             : 
  113243             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  113244             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  113245             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  113246             : // around this macro definition rather than each use).
  113247             : #ifndef ALLOC_MUTEX
  113248             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  113249             :         do {                                                                     \
  113250             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  113251             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  113252             :                 abort();                                                         \
  113253             :             }                                                                    \
  113254             :         } while (0);
  113255             : #endif
  113256             : 
  113257             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  113258             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  113259             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  113260             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  113261             : 
  113262             : /*! \brief New operator for SgOmpTeamsLoopStatement.
  113263             : 
  113264             :    This new operator implements memory pools to provide most efficent 
  113265             :    use of the heap within construction of large ASTs.
  113266             : 
  113267             : \internal The new and delete operators use the lower level C malloc/free
  113268             :    function calls for performance and to make sure that mixing of malloc/free
  113269             :    and new/delete by the used can be caught more readily.  This may change
  113270             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  113271             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  113272             :    deallocate memory allocated using ROSE_MALLOC.
  113273             : */
  113274           1 : void *SgOmpTeamsLoopStatement::operator new ( size_t Size )
  113275             : {
  113276             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  113277             :      * returning or throwing an exception. */
  113278           1 :     ALLOC_MUTEX(SgOmpTeamsLoopStatement, lock);
  113279             : 
  113280             : #if ROSE_ALLOC_TRACE == 2
  113281             : //    printf("SgOmpTeamsLoopStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgOmpTeamsLoopStatement::next_node);
  113282             : #endif
  113283             : 
  113284             : #if USE_CPP_NEW_DELETE_OPERATORS
  113285             :     void *mem = ROSE_MALLOC(Size);
  113286             :     ALLOC_MUTEX(SgOmpTeamsLoopStatement, unlock);
  113287             :     return mem;
  113288             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  113289             : #if ROSE_PEDANTIC_ALLOC
  113290             :     ROSE_ASSERT(Size == sizeof(SgOmpTeamsLoopStatement));
  113291             : #else
  113292           1 :     if (Size != sizeof(SgOmpTeamsLoopStatement)) {
  113293           0 :       void * object = ROSE_MALLOC(Size);
  113294           0 :       ALLOC_MUTEX(SgOmpTeamsLoopStatement, unlock);
  113295             :       return object;
  113296             :     }
  113297             : #endif
  113298             : 
  113299           1 :     if (SgOmpTeamsLoopStatement::next_node == nullptr) {
  113300           1 :         SgOmpTeamsLoopStatement * alloc = (SgOmpTeamsLoopStatement*) ROSE_MALLOC ( SgOmpTeamsLoopStatement::pool_size * sizeof(SgOmpTeamsLoopStatement) );
  113301           1 :         ROSE_ASSERT(alloc != nullptr);
  113302             : 
  113303             : #if ROSE_ALLOC_TRACE == 2
  113304             : //        printf("SgOmpTeamsLoopStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgOmpTeamsLoopStatement::pools.size(), alloc, alloc + SgOmpTeamsLoopStatement::pool_size);
  113305             : #endif
  113306             : 
  113307             : #if ROSE_ALLOC_MEMSET == 1
  113308             : #elif ROSE_ALLOC_MEMSET == 2
  113309             :         memset(alloc, 0x00, SgOmpTeamsLoopStatement::pool_size * sizeof(SgOmpTeamsLoopStatement));
  113310             : #elif ROSE_ALLOC_MEMSET == 3
  113311             :         memset(alloc, 0xAA, SgOmpTeamsLoopStatement::pool_size * sizeof(SgOmpTeamsLoopStatement));
  113312             : #endif
  113313        2000 :         for (unsigned i=0; i < SgOmpTeamsLoopStatement::pool_size-1; i++) {
  113314        1999 :           alloc[i].p_freepointer = &(alloc[i+1]);
  113315             :         }
  113316           1 :         alloc[SgOmpTeamsLoopStatement::pool_size-1].p_freepointer = nullptr;
  113317             : 
  113318           1 :         SgOmpTeamsLoopStatement::pools.push_back ( (unsigned char *) alloc );
  113319           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgOmpTeamsLoopStatement::pool_size * sizeof(SgOmpTeamsLoopStatement), V_SgOmpTeamsLoopStatement ) );
  113320           1 :         SgOmpTeamsLoopStatement::next_node = alloc;
  113321             :     }
  113322           1 :     ROSE_ASSERT(SgOmpTeamsLoopStatement::next_node != nullptr);
  113323             : 
  113324           1 :     SgOmpTeamsLoopStatement * object = SgOmpTeamsLoopStatement::next_node;
  113325           1 :     SgOmpTeamsLoopStatement::next_node = (SgOmpTeamsLoopStatement*)(object->p_freepointer);
  113326             : 
  113327             : #if ROSE_ALLOC_TRACE == 2
  113328             :     printf("SgOmpTeamsLoopStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpTeamsLoopStatement::next_node);
  113329             : #endif
  113330             : 
  113331           1 :     SgNode * fp = object->p_freepointer;
  113332             : #if ROSE_ALLOC_MEMSET == 1
  113333             : #elif ROSE_ALLOC_MEMSET == 2
  113334             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpTeamsLoopStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  113335             : #elif ROSE_ALLOC_MEMSET == 3
  113336             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgOmpTeamsLoopStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  113337             : #endif
  113338           1 :     object->p_freepointer = fp;
  113339             : 
  113340             : #if ROSE_ALLOC_TRACE == 2
  113341             : //    printf("SgOmpTeamsLoopStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpTeamsLoopStatement::next_node);
  113342             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  113343             :     Rose::MemPool::snapshot(oss.str());
  113344             :     alloc_trace_cnt++;
  113345             : #endif
  113346             : 
  113347           1 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  113348             : 
  113349           1 :     ALLOC_MUTEX(SgOmpTeamsLoopStatement, unlock);
  113350             : 
  113351             :     return object;
  113352             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  113353             : }
  113354             : 
  113355             : 
  113356             : 
  113357             : /*! \brief Delete operator for SgOmpTeamsLoopStatement.
  113358             : 
  113359             :    This delete operator implements deallocation using memory pools to 
  113360             :    provide most efficent use of the heap within construction of large ASTs.
  113361             : 
  113362             : \internal The new and delete operators use the lower level C malloc/free
  113363             :    function calls for performance and to make sure that mixing of malloc/free
  113364             :    and new/delete by the used can be caught more readily.  This may change
  113365             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  113366             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  113367             :    deallocate memory allocated using ROSE_MALLOC.
  113368             : */
  113369           0 : void SgOmpTeamsLoopStatement::operator delete(void *Pointer, size_t Size)
  113370             : {
  113371             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  113372             :      * or throwing an exception. */
  113373           0 :     ALLOC_MUTEX(SgOmpTeamsLoopStatement, lock);
  113374             : 
  113375             : #if USE_CPP_NEW_DELETE_OPERATORS
  113376             :     ROSE_FREE(Pointer);
  113377             : #else
  113378             : #if ROSE_PEDANTIC_ALLOC
  113379             :     ROSE_ASSERT(Size == sizeof(SgOmpTeamsLoopStatement));
  113380             : #else
  113381           0 :     if (Size != sizeof(SgOmpTeamsLoopStatement)) {
  113382           0 :       ROSE_FREE(Pointer);
  113383           0 :       ALLOC_MUTEX(SgOmpTeamsLoopStatement, unlock);
  113384             :       return;
  113385             :     }
  113386             : #endif
  113387             : 
  113388           0 :     SgOmpTeamsLoopStatement * object = (SgOmpTeamsLoopStatement*) Pointer;
  113389           0 :     ROSE_ASSERT(object != nullptr);
  113390             : 
  113391             : #if ROSE_ALLOC_TRACE == 2
  113392             : //  printf("SgOmpTeamsLoopStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpTeamsLoopStatement::next_node);
  113393             :     printf("SgOmpTeamsLoopStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpTeamsLoopStatement::next_node);
  113394             : #endif
  113395             : 
  113396             : #if ROSE_PEDANTIC_ALLOC
  113397             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  113398             : #endif
  113399             : 
  113400             : #if ROSE_ALLOC_MEMSET == 1
  113401             : #elif ROSE_ALLOC_MEMSET == 2
  113402             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpTeamsLoopStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  113403             : #elif ROSE_ALLOC_MEMSET == 3
  113404             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgOmpTeamsLoopStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  113405             : #endif
  113406             : 
  113407             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  113408             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  113409             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  113410             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  113411             : #else
  113412           0 :     object->p_freepointer = SgOmpTeamsLoopStatement::next_node;
  113413           0 :     SgOmpTeamsLoopStatement::next_node = object;
  113414             : #endif
  113415             : 
  113416             : #if ROSE_ALLOC_TRACE == 2
  113417             : //  printf("SgOmpTeamsLoopStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpTeamsLoopStatement::next_node);
  113418             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  113419             :     Rose::MemPool::snapshot(oss.str());
  113420             :     alloc_trace_cnt++;
  113421             : #endif
  113422             : 
  113423             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  113424             : 
  113425           0 :     ALLOC_MUTEX(SgOmpTeamsLoopStatement, unlock);
  113426             : }
  113427             : 
  113428             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  113429             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  113430             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  113431             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  113432             : // Also, note comment below from Robb (copied from the Common.code file).
  113433             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  113434             : //
  113435             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  113436             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  113437             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  113438             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  113439             : #if 0
  113440             : void SgOmpTeamsLoopStatement::operator delete(void* pointer) { SgOmpTeamsLoopStatement::operator delete (pointer, sizeof(SgOmpTeamsLoopStatement)); };
  113441             : #endif
  113442             : /* #line 113443 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  113443             : 
  113444             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  113445             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  113446             : // obviously imply C++.
  113447             : 
  113448             : // This implements the support within ROSE for memory pools.  Memory pools
  113449             : // support the most condensed usage of memory within the construction of
  113450             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  113451             : // by a new operator written for each class.
  113452             : 
  113453             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  113454             :     // User wants multi-thread support and POSIX threads are available.
  113455             : #   include <pthread.h>
  113456             :     static pthread_mutex_t SgOmpForSimdStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  113457             : #else
  113458             :      // Cause synchronization to be skipped.
  113459             : #    ifndef ALLOC_MUTEX
  113460             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  113461             : #    endif
  113462             : #    ifdef _REENTRANT
  113463             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  113464             : #       ifdef _MSC_VER
  113465             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  113466             : #       else
  113467             : #           warning "POSIX threads are not available; synchronization being skipped"
  113468             : #       endif
  113469             : #    endif
  113470             : #endif
  113471             : 
  113472             : #ifndef ROSE_ALLOC_TRACE
  113473             : #  define ROSE_ALLOC_TRACE 0
  113474             : #endif
  113475             : 
  113476             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  113477             : #define ROSE_ALLOC_TRACE_CNT
  113478             : #include "memory-pool-snapshot.h"
  113479             : unsigned long alloc_trace_cnt = 0;
  113480             : #endif
  113481             : 
  113482             : #if ROSE_ALLOC_TRACE
  113483             : const unsigned SgOmpForSimdStatement::pool_size = 5;
  113484             : #else
  113485             : const unsigned SgOmpForSimdStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  113486             : #endif
  113487             : 
  113488             : #ifndef ROSE_ALLOC_MEMSET
  113489             : #  define ROSE_ALLOC_MEMSET 0
  113490             : #endif
  113491             : 
  113492             : #ifndef ROSE_PEDANTIC_ALLOC
  113493             : #  define ROSE_PEDANTIC_ALLOC 0
  113494             : #endif
  113495             : 
  113496             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  113497             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  113498             : #endif
  113499             : 
  113500             : #if !defined(SGNODE__ALL_POOLS)
  113501             : #define SGNODE__ALL_POOLS
  113502             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  113503             : #endif
  113504             : 
  113505             : SgOmpForSimdStatement* SgOmpForSimdStatement::next_node = nullptr;
  113506             : std::vector<unsigned char*> SgOmpForSimdStatement::pools;
  113507             : 
  113508             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  113509             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  113510             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  113511             : // around this macro definition rather than each use).
  113512             : #ifndef ALLOC_MUTEX
  113513             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  113514             :         do {                                                                     \
  113515             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  113516             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  113517             :                 abort();                                                         \
  113518             :             }                                                                    \
  113519             :         } while (0);
  113520             : #endif
  113521             : 
  113522             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  113523             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  113524             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  113525             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  113526             : 
  113527             : /*! \brief New operator for SgOmpForSimdStatement.
  113528             : 
  113529             :    This new operator implements memory pools to provide most efficent 
  113530             :    use of the heap within construction of large ASTs.
  113531             : 
  113532             : \internal The new and delete operators use the lower level C malloc/free
  113533             :    function calls for performance and to make sure that mixing of malloc/free
  113534             :    and new/delete by the used can be caught more readily.  This may change
  113535             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  113536             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  113537             :    deallocate memory allocated using ROSE_MALLOC.
  113538             : */
  113539           1 : void *SgOmpForSimdStatement::operator new ( size_t Size )
  113540             : {
  113541             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  113542             :      * returning or throwing an exception. */
  113543           1 :     ALLOC_MUTEX(SgOmpForSimdStatement, lock);
  113544             : 
  113545             : #if ROSE_ALLOC_TRACE == 2
  113546             : //    printf("SgOmpForSimdStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgOmpForSimdStatement::next_node);
  113547             : #endif
  113548             : 
  113549             : #if USE_CPP_NEW_DELETE_OPERATORS
  113550             :     void *mem = ROSE_MALLOC(Size);
  113551             :     ALLOC_MUTEX(SgOmpForSimdStatement, unlock);
  113552             :     return mem;
  113553             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  113554             : #if ROSE_PEDANTIC_ALLOC
  113555             :     ROSE_ASSERT(Size == sizeof(SgOmpForSimdStatement));
  113556             : #else
  113557           1 :     if (Size != sizeof(SgOmpForSimdStatement)) {
  113558           0 :       void * object = ROSE_MALLOC(Size);
  113559           0 :       ALLOC_MUTEX(SgOmpForSimdStatement, unlock);
  113560             :       return object;
  113561             :     }
  113562             : #endif
  113563             : 
  113564           1 :     if (SgOmpForSimdStatement::next_node == nullptr) {
  113565           1 :         SgOmpForSimdStatement * alloc = (SgOmpForSimdStatement*) ROSE_MALLOC ( SgOmpForSimdStatement::pool_size * sizeof(SgOmpForSimdStatement) );
  113566           1 :         ROSE_ASSERT(alloc != nullptr);
  113567             : 
  113568             : #if ROSE_ALLOC_TRACE == 2
  113569             : //        printf("SgOmpForSimdStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgOmpForSimdStatement::pools.size(), alloc, alloc + SgOmpForSimdStatement::pool_size);
  113570             : #endif
  113571             : 
  113572             : #if ROSE_ALLOC_MEMSET == 1
  113573             : #elif ROSE_ALLOC_MEMSET == 2
  113574             :         memset(alloc, 0x00, SgOmpForSimdStatement::pool_size * sizeof(SgOmpForSimdStatement));
  113575             : #elif ROSE_ALLOC_MEMSET == 3
  113576             :         memset(alloc, 0xAA, SgOmpForSimdStatement::pool_size * sizeof(SgOmpForSimdStatement));
  113577             : #endif
  113578        2000 :         for (unsigned i=0; i < SgOmpForSimdStatement::pool_size-1; i++) {
  113579        1999 :           alloc[i].p_freepointer = &(alloc[i+1]);
  113580             :         }
  113581           1 :         alloc[SgOmpForSimdStatement::pool_size-1].p_freepointer = nullptr;
  113582             : 
  113583           1 :         SgOmpForSimdStatement::pools.push_back ( (unsigned char *) alloc );
  113584           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgOmpForSimdStatement::pool_size * sizeof(SgOmpForSimdStatement), V_SgOmpForSimdStatement ) );
  113585           1 :         SgOmpForSimdStatement::next_node = alloc;
  113586             :     }
  113587           1 :     ROSE_ASSERT(SgOmpForSimdStatement::next_node != nullptr);
  113588             : 
  113589           1 :     SgOmpForSimdStatement * object = SgOmpForSimdStatement::next_node;
  113590           1 :     SgOmpForSimdStatement::next_node = (SgOmpForSimdStatement*)(object->p_freepointer);
  113591             : 
  113592             : #if ROSE_ALLOC_TRACE == 2
  113593             :     printf("SgOmpForSimdStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpForSimdStatement::next_node);
  113594             : #endif
  113595             : 
  113596           1 :     SgNode * fp = object->p_freepointer;
  113597             : #if ROSE_ALLOC_MEMSET == 1
  113598             : #elif ROSE_ALLOC_MEMSET == 2
  113599             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpForSimdStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  113600             : #elif ROSE_ALLOC_MEMSET == 3
  113601             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgOmpForSimdStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  113602             : #endif
  113603           1 :     object->p_freepointer = fp;
  113604             : 
  113605             : #if ROSE_ALLOC_TRACE == 2
  113606             : //    printf("SgOmpForSimdStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpForSimdStatement::next_node);
  113607             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  113608             :     Rose::MemPool::snapshot(oss.str());
  113609             :     alloc_trace_cnt++;
  113610             : #endif
  113611             : 
  113612           1 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  113613             : 
  113614           1 :     ALLOC_MUTEX(SgOmpForSimdStatement, unlock);
  113615             : 
  113616             :     return object;
  113617             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  113618             : }
  113619             : 
  113620             : 
  113621             : 
  113622             : /*! \brief Delete operator for SgOmpForSimdStatement.
  113623             : 
  113624             :    This delete operator implements deallocation using memory pools to 
  113625             :    provide most efficent use of the heap within construction of large ASTs.
  113626             : 
  113627             : \internal The new and delete operators use the lower level C malloc/free
  113628             :    function calls for performance and to make sure that mixing of malloc/free
  113629             :    and new/delete by the used can be caught more readily.  This may change
  113630             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  113631             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  113632             :    deallocate memory allocated using ROSE_MALLOC.
  113633             : */
  113634           0 : void SgOmpForSimdStatement::operator delete(void *Pointer, size_t Size)
  113635             : {
  113636             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  113637             :      * or throwing an exception. */
  113638           0 :     ALLOC_MUTEX(SgOmpForSimdStatement, lock);
  113639             : 
  113640             : #if USE_CPP_NEW_DELETE_OPERATORS
  113641             :     ROSE_FREE(Pointer);
  113642             : #else
  113643             : #if ROSE_PEDANTIC_ALLOC
  113644             :     ROSE_ASSERT(Size == sizeof(SgOmpForSimdStatement));
  113645             : #else
  113646           0 :     if (Size != sizeof(SgOmpForSimdStatement)) {
  113647           0 :       ROSE_FREE(Pointer);
  113648           0 :       ALLOC_MUTEX(SgOmpForSimdStatement, unlock);
  113649             :       return;
  113650             :     }
  113651             : #endif
  113652             : 
  113653           0 :     SgOmpForSimdStatement * object = (SgOmpForSimdStatement*) Pointer;
  113654           0 :     ROSE_ASSERT(object != nullptr);
  113655             : 
  113656             : #if ROSE_ALLOC_TRACE == 2
  113657             : //  printf("SgOmpForSimdStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpForSimdStatement::next_node);
  113658             :     printf("SgOmpForSimdStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpForSimdStatement::next_node);
  113659             : #endif
  113660             : 
  113661             : #if ROSE_PEDANTIC_ALLOC
  113662             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  113663             : #endif
  113664             : 
  113665             : #if ROSE_ALLOC_MEMSET == 1
  113666             : #elif ROSE_ALLOC_MEMSET == 2
  113667             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpForSimdStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  113668             : #elif ROSE_ALLOC_MEMSET == 3
  113669             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgOmpForSimdStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  113670             : #endif
  113671             : 
  113672             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  113673             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  113674             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  113675             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  113676             : #else
  113677           0 :     object->p_freepointer = SgOmpForSimdStatement::next_node;
  113678           0 :     SgOmpForSimdStatement::next_node = object;
  113679             : #endif
  113680             : 
  113681             : #if ROSE_ALLOC_TRACE == 2
  113682             : //  printf("SgOmpForSimdStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpForSimdStatement::next_node);
  113683             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  113684             :     Rose::MemPool::snapshot(oss.str());
  113685             :     alloc_trace_cnt++;
  113686             : #endif
  113687             : 
  113688             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  113689             : 
  113690           0 :     ALLOC_MUTEX(SgOmpForSimdStatement, unlock);
  113691             : }
  113692             : 
  113693             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  113694             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  113695             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  113696             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  113697             : // Also, note comment below from Robb (copied from the Common.code file).
  113698             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  113699             : //
  113700             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  113701             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  113702             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  113703             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  113704             : #if 0
  113705             : void SgOmpForSimdStatement::operator delete(void* pointer) { SgOmpForSimdStatement::operator delete (pointer, sizeof(SgOmpForSimdStatement)); };
  113706             : #endif
  113707             : /* #line 113708 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  113708             : 
  113709             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  113710             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  113711             : // obviously imply C++.
  113712             : 
  113713             : // This implements the support within ROSE for memory pools.  Memory pools
  113714             : // support the most condensed usage of memory within the construction of
  113715             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  113716             : // by a new operator written for each class.
  113717             : 
  113718             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  113719             :     // User wants multi-thread support and POSIX threads are available.
  113720             : #   include <pthread.h>
  113721             :     static pthread_mutex_t SgOmpCriticalStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  113722             : #else
  113723             :      // Cause synchronization to be skipped.
  113724             : #    ifndef ALLOC_MUTEX
  113725             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  113726             : #    endif
  113727             : #    ifdef _REENTRANT
  113728             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  113729             : #       ifdef _MSC_VER
  113730             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  113731             : #       else
  113732             : #           warning "POSIX threads are not available; synchronization being skipped"
  113733             : #       endif
  113734             : #    endif
  113735             : #endif
  113736             : 
  113737             : #ifndef ROSE_ALLOC_TRACE
  113738             : #  define ROSE_ALLOC_TRACE 0
  113739             : #endif
  113740             : 
  113741             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  113742             : #define ROSE_ALLOC_TRACE_CNT
  113743             : #include "memory-pool-snapshot.h"
  113744             : unsigned long alloc_trace_cnt = 0;
  113745             : #endif
  113746             : 
  113747             : #if ROSE_ALLOC_TRACE
  113748             : const unsigned SgOmpCriticalStatement::pool_size = 5;
  113749             : #else
  113750             : const unsigned SgOmpCriticalStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  113751             : #endif
  113752             : 
  113753             : #ifndef ROSE_ALLOC_MEMSET
  113754             : #  define ROSE_ALLOC_MEMSET 0
  113755             : #endif
  113756             : 
  113757             : #ifndef ROSE_PEDANTIC_ALLOC
  113758             : #  define ROSE_PEDANTIC_ALLOC 0
  113759             : #endif
  113760             : 
  113761             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  113762             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  113763             : #endif
  113764             : 
  113765             : #if !defined(SGNODE__ALL_POOLS)
  113766             : #define SGNODE__ALL_POOLS
  113767             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  113768             : #endif
  113769             : 
  113770             : SgOmpCriticalStatement* SgOmpCriticalStatement::next_node = nullptr;
  113771             : std::vector<unsigned char*> SgOmpCriticalStatement::pools;
  113772             : 
  113773             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  113774             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  113775             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  113776             : // around this macro definition rather than each use).
  113777             : #ifndef ALLOC_MUTEX
  113778             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  113779             :         do {                                                                     \
  113780             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  113781             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  113782             :                 abort();                                                         \
  113783             :             }                                                                    \
  113784             :         } while (0);
  113785             : #endif
  113786             : 
  113787             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  113788             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  113789             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  113790             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  113791             : 
  113792             : /*! \brief New operator for SgOmpCriticalStatement.
  113793             : 
  113794             :    This new operator implements memory pools to provide most efficent 
  113795             :    use of the heap within construction of large ASTs.
  113796             : 
  113797             : \internal The new and delete operators use the lower level C malloc/free
  113798             :    function calls for performance and to make sure that mixing of malloc/free
  113799             :    and new/delete by the used can be caught more readily.  This may change
  113800             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  113801             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  113802             :    deallocate memory allocated using ROSE_MALLOC.
  113803             : */
  113804          61 : void *SgOmpCriticalStatement::operator new ( size_t Size )
  113805             : {
  113806             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  113807             :      * returning or throwing an exception. */
  113808          61 :     ALLOC_MUTEX(SgOmpCriticalStatement, lock);
  113809             : 
  113810             : #if ROSE_ALLOC_TRACE == 2
  113811             : //    printf("SgOmpCriticalStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgOmpCriticalStatement::next_node);
  113812             : #endif
  113813             : 
  113814             : #if USE_CPP_NEW_DELETE_OPERATORS
  113815             :     void *mem = ROSE_MALLOC(Size);
  113816             :     ALLOC_MUTEX(SgOmpCriticalStatement, unlock);
  113817             :     return mem;
  113818             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  113819             : #if ROSE_PEDANTIC_ALLOC
  113820             :     ROSE_ASSERT(Size == sizeof(SgOmpCriticalStatement));
  113821             : #else
  113822          61 :     if (Size != sizeof(SgOmpCriticalStatement)) {
  113823           0 :       void * object = ROSE_MALLOC(Size);
  113824           0 :       ALLOC_MUTEX(SgOmpCriticalStatement, unlock);
  113825             :       return object;
  113826             :     }
  113827             : #endif
  113828             : 
  113829          61 :     if (SgOmpCriticalStatement::next_node == nullptr) {
  113830          30 :         SgOmpCriticalStatement * alloc = (SgOmpCriticalStatement*) ROSE_MALLOC ( SgOmpCriticalStatement::pool_size * sizeof(SgOmpCriticalStatement) );
  113831          30 :         ROSE_ASSERT(alloc != nullptr);
  113832             : 
  113833             : #if ROSE_ALLOC_TRACE == 2
  113834             : //        printf("SgOmpCriticalStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgOmpCriticalStatement::pools.size(), alloc, alloc + SgOmpCriticalStatement::pool_size);
  113835             : #endif
  113836             : 
  113837             : #if ROSE_ALLOC_MEMSET == 1
  113838             : #elif ROSE_ALLOC_MEMSET == 2
  113839             :         memset(alloc, 0x00, SgOmpCriticalStatement::pool_size * sizeof(SgOmpCriticalStatement));
  113840             : #elif ROSE_ALLOC_MEMSET == 3
  113841             :         memset(alloc, 0xAA, SgOmpCriticalStatement::pool_size * sizeof(SgOmpCriticalStatement));
  113842             : #endif
  113843       60000 :         for (unsigned i=0; i < SgOmpCriticalStatement::pool_size-1; i++) {
  113844       59970 :           alloc[i].p_freepointer = &(alloc[i+1]);
  113845             :         }
  113846          30 :         alloc[SgOmpCriticalStatement::pool_size-1].p_freepointer = nullptr;
  113847             : 
  113848          30 :         SgOmpCriticalStatement::pools.push_back ( (unsigned char *) alloc );
  113849          30 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgOmpCriticalStatement::pool_size * sizeof(SgOmpCriticalStatement), V_SgOmpCriticalStatement ) );
  113850          30 :         SgOmpCriticalStatement::next_node = alloc;
  113851             :     }
  113852          61 :     ROSE_ASSERT(SgOmpCriticalStatement::next_node != nullptr);
  113853             : 
  113854          61 :     SgOmpCriticalStatement * object = SgOmpCriticalStatement::next_node;
  113855          61 :     SgOmpCriticalStatement::next_node = (SgOmpCriticalStatement*)(object->p_freepointer);
  113856             : 
  113857             : #if ROSE_ALLOC_TRACE == 2
  113858             :     printf("SgOmpCriticalStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpCriticalStatement::next_node);
  113859             : #endif
  113860             : 
  113861          61 :     SgNode * fp = object->p_freepointer;
  113862             : #if ROSE_ALLOC_MEMSET == 1
  113863             : #elif ROSE_ALLOC_MEMSET == 2
  113864             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpCriticalStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  113865             : #elif ROSE_ALLOC_MEMSET == 3
  113866             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgOmpCriticalStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  113867             : #endif
  113868          61 :     object->p_freepointer = fp;
  113869             : 
  113870             : #if ROSE_ALLOC_TRACE == 2
  113871             : //    printf("SgOmpCriticalStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpCriticalStatement::next_node);
  113872             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  113873             :     Rose::MemPool::snapshot(oss.str());
  113874             :     alloc_trace_cnt++;
  113875             : #endif
  113876             : 
  113877          61 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  113878             : 
  113879          61 :     ALLOC_MUTEX(SgOmpCriticalStatement, unlock);
  113880             : 
  113881             :     return object;
  113882             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  113883             : }
  113884             : 
  113885             : 
  113886             : 
  113887             : /*! \brief Delete operator for SgOmpCriticalStatement.
  113888             : 
  113889             :    This delete operator implements deallocation using memory pools to 
  113890             :    provide most efficent use of the heap within construction of large ASTs.
  113891             : 
  113892             : \internal The new and delete operators use the lower level C malloc/free
  113893             :    function calls for performance and to make sure that mixing of malloc/free
  113894             :    and new/delete by the used can be caught more readily.  This may change
  113895             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  113896             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  113897             :    deallocate memory allocated using ROSE_MALLOC.
  113898             : */
  113899           0 : void SgOmpCriticalStatement::operator delete(void *Pointer, size_t Size)
  113900             : {
  113901             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  113902             :      * or throwing an exception. */
  113903           0 :     ALLOC_MUTEX(SgOmpCriticalStatement, lock);
  113904             : 
  113905             : #if USE_CPP_NEW_DELETE_OPERATORS
  113906             :     ROSE_FREE(Pointer);
  113907             : #else
  113908             : #if ROSE_PEDANTIC_ALLOC
  113909             :     ROSE_ASSERT(Size == sizeof(SgOmpCriticalStatement));
  113910             : #else
  113911           0 :     if (Size != sizeof(SgOmpCriticalStatement)) {
  113912           0 :       ROSE_FREE(Pointer);
  113913           0 :       ALLOC_MUTEX(SgOmpCriticalStatement, unlock);
  113914             :       return;
  113915             :     }
  113916             : #endif
  113917             : 
  113918           0 :     SgOmpCriticalStatement * object = (SgOmpCriticalStatement*) Pointer;
  113919           0 :     ROSE_ASSERT(object != nullptr);
  113920             : 
  113921             : #if ROSE_ALLOC_TRACE == 2
  113922             : //  printf("SgOmpCriticalStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpCriticalStatement::next_node);
  113923             :     printf("SgOmpCriticalStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpCriticalStatement::next_node);
  113924             : #endif
  113925             : 
  113926             : #if ROSE_PEDANTIC_ALLOC
  113927             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  113928             : #endif
  113929             : 
  113930             : #if ROSE_ALLOC_MEMSET == 1
  113931             : #elif ROSE_ALLOC_MEMSET == 2
  113932             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpCriticalStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  113933             : #elif ROSE_ALLOC_MEMSET == 3
  113934             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgOmpCriticalStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  113935             : #endif
  113936             : 
  113937             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  113938             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  113939             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  113940             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  113941             : #else
  113942           0 :     object->p_freepointer = SgOmpCriticalStatement::next_node;
  113943           0 :     SgOmpCriticalStatement::next_node = object;
  113944             : #endif
  113945             : 
  113946             : #if ROSE_ALLOC_TRACE == 2
  113947             : //  printf("SgOmpCriticalStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpCriticalStatement::next_node);
  113948             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  113949             :     Rose::MemPool::snapshot(oss.str());
  113950             :     alloc_trace_cnt++;
  113951             : #endif
  113952             : 
  113953             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  113954             : 
  113955           0 :     ALLOC_MUTEX(SgOmpCriticalStatement, unlock);
  113956             : }
  113957             : 
  113958             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  113959             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  113960             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  113961             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  113962             : // Also, note comment below from Robb (copied from the Common.code file).
  113963             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  113964             : //
  113965             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  113966             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  113967             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  113968             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  113969             : #if 0
  113970             : void SgOmpCriticalStatement::operator delete(void* pointer) { SgOmpCriticalStatement::operator delete (pointer, sizeof(SgOmpCriticalStatement)); };
  113971             : #endif
  113972             : /* #line 113973 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  113973             : 
  113974             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  113975             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  113976             : // obviously imply C++.
  113977             : 
  113978             : // This implements the support within ROSE for memory pools.  Memory pools
  113979             : // support the most condensed usage of memory within the construction of
  113980             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  113981             : // by a new operator written for each class.
  113982             : 
  113983             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  113984             :     // User wants multi-thread support and POSIX threads are available.
  113985             : #   include <pthread.h>
  113986             :     static pthread_mutex_t SgOmpDistributeStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  113987             : #else
  113988             :      // Cause synchronization to be skipped.
  113989             : #    ifndef ALLOC_MUTEX
  113990             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  113991             : #    endif
  113992             : #    ifdef _REENTRANT
  113993             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  113994             : #       ifdef _MSC_VER
  113995             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  113996             : #       else
  113997             : #           warning "POSIX threads are not available; synchronization being skipped"
  113998             : #       endif
  113999             : #    endif
  114000             : #endif
  114001             : 
  114002             : #ifndef ROSE_ALLOC_TRACE
  114003             : #  define ROSE_ALLOC_TRACE 0
  114004             : #endif
  114005             : 
  114006             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  114007             : #define ROSE_ALLOC_TRACE_CNT
  114008             : #include "memory-pool-snapshot.h"
  114009             : unsigned long alloc_trace_cnt = 0;
  114010             : #endif
  114011             : 
  114012             : #if ROSE_ALLOC_TRACE
  114013             : const unsigned SgOmpDistributeStatement::pool_size = 5;
  114014             : #else
  114015             : const unsigned SgOmpDistributeStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  114016             : #endif
  114017             : 
  114018             : #ifndef ROSE_ALLOC_MEMSET
  114019             : #  define ROSE_ALLOC_MEMSET 0
  114020             : #endif
  114021             : 
  114022             : #ifndef ROSE_PEDANTIC_ALLOC
  114023             : #  define ROSE_PEDANTIC_ALLOC 0
  114024             : #endif
  114025             : 
  114026             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  114027             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  114028             : #endif
  114029             : 
  114030             : #if !defined(SGNODE__ALL_POOLS)
  114031             : #define SGNODE__ALL_POOLS
  114032             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  114033             : #endif
  114034             : 
  114035             : SgOmpDistributeStatement* SgOmpDistributeStatement::next_node = nullptr;
  114036             : std::vector<unsigned char*> SgOmpDistributeStatement::pools;
  114037             : 
  114038             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  114039             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  114040             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  114041             : // around this macro definition rather than each use).
  114042             : #ifndef ALLOC_MUTEX
  114043             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  114044             :         do {                                                                     \
  114045             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  114046             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  114047             :                 abort();                                                         \
  114048             :             }                                                                    \
  114049             :         } while (0);
  114050             : #endif
  114051             : 
  114052             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  114053             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  114054             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  114055             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  114056             : 
  114057             : /*! \brief New operator for SgOmpDistributeStatement.
  114058             : 
  114059             :    This new operator implements memory pools to provide most efficent 
  114060             :    use of the heap within construction of large ASTs.
  114061             : 
  114062             : \internal The new and delete operators use the lower level C malloc/free
  114063             :    function calls for performance and to make sure that mixing of malloc/free
  114064             :    and new/delete by the used can be caught more readily.  This may change
  114065             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  114066             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  114067             :    deallocate memory allocated using ROSE_MALLOC.
  114068             : */
  114069           2 : void *SgOmpDistributeStatement::operator new ( size_t Size )
  114070             : {
  114071             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  114072             :      * returning or throwing an exception. */
  114073           2 :     ALLOC_MUTEX(SgOmpDistributeStatement, lock);
  114074             : 
  114075             : #if ROSE_ALLOC_TRACE == 2
  114076             : //    printf("SgOmpDistributeStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgOmpDistributeStatement::next_node);
  114077             : #endif
  114078             : 
  114079             : #if USE_CPP_NEW_DELETE_OPERATORS
  114080             :     void *mem = ROSE_MALLOC(Size);
  114081             :     ALLOC_MUTEX(SgOmpDistributeStatement, unlock);
  114082             :     return mem;
  114083             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  114084             : #if ROSE_PEDANTIC_ALLOC
  114085             :     ROSE_ASSERT(Size == sizeof(SgOmpDistributeStatement));
  114086             : #else
  114087           2 :     if (Size != sizeof(SgOmpDistributeStatement)) {
  114088           0 :       void * object = ROSE_MALLOC(Size);
  114089           0 :       ALLOC_MUTEX(SgOmpDistributeStatement, unlock);
  114090             :       return object;
  114091             :     }
  114092             : #endif
  114093             : 
  114094           2 :     if (SgOmpDistributeStatement::next_node == nullptr) {
  114095           2 :         SgOmpDistributeStatement * alloc = (SgOmpDistributeStatement*) ROSE_MALLOC ( SgOmpDistributeStatement::pool_size * sizeof(SgOmpDistributeStatement) );
  114096           2 :         ROSE_ASSERT(alloc != nullptr);
  114097             : 
  114098             : #if ROSE_ALLOC_TRACE == 2
  114099             : //        printf("SgOmpDistributeStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgOmpDistributeStatement::pools.size(), alloc, alloc + SgOmpDistributeStatement::pool_size);
  114100             : #endif
  114101             : 
  114102             : #if ROSE_ALLOC_MEMSET == 1
  114103             : #elif ROSE_ALLOC_MEMSET == 2
  114104             :         memset(alloc, 0x00, SgOmpDistributeStatement::pool_size * sizeof(SgOmpDistributeStatement));
  114105             : #elif ROSE_ALLOC_MEMSET == 3
  114106             :         memset(alloc, 0xAA, SgOmpDistributeStatement::pool_size * sizeof(SgOmpDistributeStatement));
  114107             : #endif
  114108        4000 :         for (unsigned i=0; i < SgOmpDistributeStatement::pool_size-1; i++) {
  114109        3998 :           alloc[i].p_freepointer = &(alloc[i+1]);
  114110             :         }
  114111           2 :         alloc[SgOmpDistributeStatement::pool_size-1].p_freepointer = nullptr;
  114112             : 
  114113           2 :         SgOmpDistributeStatement::pools.push_back ( (unsigned char *) alloc );
  114114           2 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgOmpDistributeStatement::pool_size * sizeof(SgOmpDistributeStatement), V_SgOmpDistributeStatement ) );
  114115           2 :         SgOmpDistributeStatement::next_node = alloc;
  114116             :     }
  114117           2 :     ROSE_ASSERT(SgOmpDistributeStatement::next_node != nullptr);
  114118             : 
  114119           2 :     SgOmpDistributeStatement * object = SgOmpDistributeStatement::next_node;
  114120           2 :     SgOmpDistributeStatement::next_node = (SgOmpDistributeStatement*)(object->p_freepointer);
  114121             : 
  114122             : #if ROSE_ALLOC_TRACE == 2
  114123             :     printf("SgOmpDistributeStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpDistributeStatement::next_node);
  114124             : #endif
  114125             : 
  114126           2 :     SgNode * fp = object->p_freepointer;
  114127             : #if ROSE_ALLOC_MEMSET == 1
  114128             : #elif ROSE_ALLOC_MEMSET == 2
  114129             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpDistributeStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  114130             : #elif ROSE_ALLOC_MEMSET == 3
  114131             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgOmpDistributeStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  114132             : #endif
  114133           2 :     object->p_freepointer = fp;
  114134             : 
  114135             : #if ROSE_ALLOC_TRACE == 2
  114136             : //    printf("SgOmpDistributeStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpDistributeStatement::next_node);
  114137             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  114138             :     Rose::MemPool::snapshot(oss.str());
  114139             :     alloc_trace_cnt++;
  114140             : #endif
  114141             : 
  114142           2 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  114143             : 
  114144           2 :     ALLOC_MUTEX(SgOmpDistributeStatement, unlock);
  114145             : 
  114146             :     return object;
  114147             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  114148             : }
  114149             : 
  114150             : 
  114151             : 
  114152             : /*! \brief Delete operator for SgOmpDistributeStatement.
  114153             : 
  114154             :    This delete operator implements deallocation using memory pools to 
  114155             :    provide most efficent use of the heap within construction of large ASTs.
  114156             : 
  114157             : \internal The new and delete operators use the lower level C malloc/free
  114158             :    function calls for performance and to make sure that mixing of malloc/free
  114159             :    and new/delete by the used can be caught more readily.  This may change
  114160             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  114161             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  114162             :    deallocate memory allocated using ROSE_MALLOC.
  114163             : */
  114164           0 : void SgOmpDistributeStatement::operator delete(void *Pointer, size_t Size)
  114165             : {
  114166             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  114167             :      * or throwing an exception. */
  114168           0 :     ALLOC_MUTEX(SgOmpDistributeStatement, lock);
  114169             : 
  114170             : #if USE_CPP_NEW_DELETE_OPERATORS
  114171             :     ROSE_FREE(Pointer);
  114172             : #else
  114173             : #if ROSE_PEDANTIC_ALLOC
  114174             :     ROSE_ASSERT(Size == sizeof(SgOmpDistributeStatement));
  114175             : #else
  114176           0 :     if (Size != sizeof(SgOmpDistributeStatement)) {
  114177           0 :       ROSE_FREE(Pointer);
  114178           0 :       ALLOC_MUTEX(SgOmpDistributeStatement, unlock);
  114179             :       return;
  114180             :     }
  114181             : #endif
  114182             : 
  114183           0 :     SgOmpDistributeStatement * object = (SgOmpDistributeStatement*) Pointer;
  114184           0 :     ROSE_ASSERT(object != nullptr);
  114185             : 
  114186             : #if ROSE_ALLOC_TRACE == 2
  114187             : //  printf("SgOmpDistributeStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpDistributeStatement::next_node);
  114188             :     printf("SgOmpDistributeStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpDistributeStatement::next_node);
  114189             : #endif
  114190             : 
  114191             : #if ROSE_PEDANTIC_ALLOC
  114192             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  114193             : #endif
  114194             : 
  114195             : #if ROSE_ALLOC_MEMSET == 1
  114196             : #elif ROSE_ALLOC_MEMSET == 2
  114197             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpDistributeStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  114198             : #elif ROSE_ALLOC_MEMSET == 3
  114199             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgOmpDistributeStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  114200             : #endif
  114201             : 
  114202             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  114203             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  114204             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  114205             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  114206             : #else
  114207           0 :     object->p_freepointer = SgOmpDistributeStatement::next_node;
  114208           0 :     SgOmpDistributeStatement::next_node = object;
  114209             : #endif
  114210             : 
  114211             : #if ROSE_ALLOC_TRACE == 2
  114212             : //  printf("SgOmpDistributeStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpDistributeStatement::next_node);
  114213             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  114214             :     Rose::MemPool::snapshot(oss.str());
  114215             :     alloc_trace_cnt++;
  114216             : #endif
  114217             : 
  114218             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  114219             : 
  114220           0 :     ALLOC_MUTEX(SgOmpDistributeStatement, unlock);
  114221             : }
  114222             : 
  114223             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  114224             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  114225             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  114226             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  114227             : // Also, note comment below from Robb (copied from the Common.code file).
  114228             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  114229             : //
  114230             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  114231             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  114232             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  114233             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  114234             : #if 0
  114235             : void SgOmpDistributeStatement::operator delete(void* pointer) { SgOmpDistributeStatement::operator delete (pointer, sizeof(SgOmpDistributeStatement)); };
  114236             : #endif
  114237             : /* #line 114238 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  114238             : 
  114239             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  114240             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  114241             : // obviously imply C++.
  114242             : 
  114243             : // This implements the support within ROSE for memory pools.  Memory pools
  114244             : // support the most condensed usage of memory within the construction of
  114245             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  114246             : // by a new operator written for each class.
  114247             : 
  114248             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  114249             :     // User wants multi-thread support and POSIX threads are available.
  114250             : #   include <pthread.h>
  114251             :     static pthread_mutex_t SgOmpUnrollStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  114252             : #else
  114253             :      // Cause synchronization to be skipped.
  114254             : #    ifndef ALLOC_MUTEX
  114255             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  114256             : #    endif
  114257             : #    ifdef _REENTRANT
  114258             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  114259             : #       ifdef _MSC_VER
  114260             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  114261             : #       else
  114262             : #           warning "POSIX threads are not available; synchronization being skipped"
  114263             : #       endif
  114264             : #    endif
  114265             : #endif
  114266             : 
  114267             : #ifndef ROSE_ALLOC_TRACE
  114268             : #  define ROSE_ALLOC_TRACE 0
  114269             : #endif
  114270             : 
  114271             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  114272             : #define ROSE_ALLOC_TRACE_CNT
  114273             : #include "memory-pool-snapshot.h"
  114274             : unsigned long alloc_trace_cnt = 0;
  114275             : #endif
  114276             : 
  114277             : #if ROSE_ALLOC_TRACE
  114278             : const unsigned SgOmpUnrollStatement::pool_size = 5;
  114279             : #else
  114280             : const unsigned SgOmpUnrollStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  114281             : #endif
  114282             : 
  114283             : #ifndef ROSE_ALLOC_MEMSET
  114284             : #  define ROSE_ALLOC_MEMSET 0
  114285             : #endif
  114286             : 
  114287             : #ifndef ROSE_PEDANTIC_ALLOC
  114288             : #  define ROSE_PEDANTIC_ALLOC 0
  114289             : #endif
  114290             : 
  114291             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  114292             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  114293             : #endif
  114294             : 
  114295             : #if !defined(SGNODE__ALL_POOLS)
  114296             : #define SGNODE__ALL_POOLS
  114297             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  114298             : #endif
  114299             : 
  114300             : SgOmpUnrollStatement* SgOmpUnrollStatement::next_node = nullptr;
  114301             : std::vector<unsigned char*> SgOmpUnrollStatement::pools;
  114302             : 
  114303             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  114304             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  114305             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  114306             : // around this macro definition rather than each use).
  114307             : #ifndef ALLOC_MUTEX
  114308             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  114309             :         do {                                                                     \
  114310             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  114311             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  114312             :                 abort();                                                         \
  114313             :             }                                                                    \
  114314             :         } while (0);
  114315             : #endif
  114316             : 
  114317             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  114318             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  114319             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  114320             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  114321             : 
  114322             : /*! \brief New operator for SgOmpUnrollStatement.
  114323             : 
  114324             :    This new operator implements memory pools to provide most efficent 
  114325             :    use of the heap within construction of large ASTs.
  114326             : 
  114327             : \internal The new and delete operators use the lower level C malloc/free
  114328             :    function calls for performance and to make sure that mixing of malloc/free
  114329             :    and new/delete by the used can be caught more readily.  This may change
  114330             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  114331             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  114332             :    deallocate memory allocated using ROSE_MALLOC.
  114333             : */
  114334           0 : void *SgOmpUnrollStatement::operator new ( size_t Size )
  114335             : {
  114336             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  114337             :      * returning or throwing an exception. */
  114338           0 :     ALLOC_MUTEX(SgOmpUnrollStatement, lock);
  114339             : 
  114340             : #if ROSE_ALLOC_TRACE == 2
  114341             : //    printf("SgOmpUnrollStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgOmpUnrollStatement::next_node);
  114342             : #endif
  114343             : 
  114344             : #if USE_CPP_NEW_DELETE_OPERATORS
  114345             :     void *mem = ROSE_MALLOC(Size);
  114346             :     ALLOC_MUTEX(SgOmpUnrollStatement, unlock);
  114347             :     return mem;
  114348             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  114349             : #if ROSE_PEDANTIC_ALLOC
  114350             :     ROSE_ASSERT(Size == sizeof(SgOmpUnrollStatement));
  114351             : #else
  114352           0 :     if (Size != sizeof(SgOmpUnrollStatement)) {
  114353           0 :       void * object = ROSE_MALLOC(Size);
  114354           0 :       ALLOC_MUTEX(SgOmpUnrollStatement, unlock);
  114355             :       return object;
  114356             :     }
  114357             : #endif
  114358             : 
  114359           0 :     if (SgOmpUnrollStatement::next_node == nullptr) {
  114360           0 :         SgOmpUnrollStatement * alloc = (SgOmpUnrollStatement*) ROSE_MALLOC ( SgOmpUnrollStatement::pool_size * sizeof(SgOmpUnrollStatement) );
  114361           0 :         ROSE_ASSERT(alloc != nullptr);
  114362             : 
  114363             : #if ROSE_ALLOC_TRACE == 2
  114364             : //        printf("SgOmpUnrollStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgOmpUnrollStatement::pools.size(), alloc, alloc + SgOmpUnrollStatement::pool_size);
  114365             : #endif
  114366             : 
  114367             : #if ROSE_ALLOC_MEMSET == 1
  114368             : #elif ROSE_ALLOC_MEMSET == 2
  114369             :         memset(alloc, 0x00, SgOmpUnrollStatement::pool_size * sizeof(SgOmpUnrollStatement));
  114370             : #elif ROSE_ALLOC_MEMSET == 3
  114371             :         memset(alloc, 0xAA, SgOmpUnrollStatement::pool_size * sizeof(SgOmpUnrollStatement));
  114372             : #endif
  114373           0 :         for (unsigned i=0; i < SgOmpUnrollStatement::pool_size-1; i++) {
  114374           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
  114375             :         }
  114376           0 :         alloc[SgOmpUnrollStatement::pool_size-1].p_freepointer = nullptr;
  114377             : 
  114378           0 :         SgOmpUnrollStatement::pools.push_back ( (unsigned char *) alloc );
  114379           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgOmpUnrollStatement::pool_size * sizeof(SgOmpUnrollStatement), V_SgOmpUnrollStatement ) );
  114380           0 :         SgOmpUnrollStatement::next_node = alloc;
  114381             :     }
  114382           0 :     ROSE_ASSERT(SgOmpUnrollStatement::next_node != nullptr);
  114383             : 
  114384           0 :     SgOmpUnrollStatement * object = SgOmpUnrollStatement::next_node;
  114385           0 :     SgOmpUnrollStatement::next_node = (SgOmpUnrollStatement*)(object->p_freepointer);
  114386             : 
  114387             : #if ROSE_ALLOC_TRACE == 2
  114388             :     printf("SgOmpUnrollStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpUnrollStatement::next_node);
  114389             : #endif
  114390             : 
  114391           0 :     SgNode * fp = object->p_freepointer;
  114392             : #if ROSE_ALLOC_MEMSET == 1
  114393             : #elif ROSE_ALLOC_MEMSET == 2
  114394             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpUnrollStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  114395             : #elif ROSE_ALLOC_MEMSET == 3
  114396             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgOmpUnrollStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  114397             : #endif
  114398           0 :     object->p_freepointer = fp;
  114399             : 
  114400             : #if ROSE_ALLOC_TRACE == 2
  114401             : //    printf("SgOmpUnrollStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpUnrollStatement::next_node);
  114402             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  114403             :     Rose::MemPool::snapshot(oss.str());
  114404             :     alloc_trace_cnt++;
  114405             : #endif
  114406             : 
  114407           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  114408             : 
  114409           0 :     ALLOC_MUTEX(SgOmpUnrollStatement, unlock);
  114410             : 
  114411             :     return object;
  114412             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  114413             : }
  114414             : 
  114415             : 
  114416             : 
  114417             : /*! \brief Delete operator for SgOmpUnrollStatement.
  114418             : 
  114419             :    This delete operator implements deallocation using memory pools to 
  114420             :    provide most efficent use of the heap within construction of large ASTs.
  114421             : 
  114422             : \internal The new and delete operators use the lower level C malloc/free
  114423             :    function calls for performance and to make sure that mixing of malloc/free
  114424             :    and new/delete by the used can be caught more readily.  This may change
  114425             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  114426             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  114427             :    deallocate memory allocated using ROSE_MALLOC.
  114428             : */
  114429           0 : void SgOmpUnrollStatement::operator delete(void *Pointer, size_t Size)
  114430             : {
  114431             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  114432             :      * or throwing an exception. */
  114433           0 :     ALLOC_MUTEX(SgOmpUnrollStatement, lock);
  114434             : 
  114435             : #if USE_CPP_NEW_DELETE_OPERATORS
  114436             :     ROSE_FREE(Pointer);
  114437             : #else
  114438             : #if ROSE_PEDANTIC_ALLOC
  114439             :     ROSE_ASSERT(Size == sizeof(SgOmpUnrollStatement));
  114440             : #else
  114441           0 :     if (Size != sizeof(SgOmpUnrollStatement)) {
  114442           0 :       ROSE_FREE(Pointer);
  114443           0 :       ALLOC_MUTEX(SgOmpUnrollStatement, unlock);
  114444             :       return;
  114445             :     }
  114446             : #endif
  114447             : 
  114448           0 :     SgOmpUnrollStatement * object = (SgOmpUnrollStatement*) Pointer;
  114449           0 :     ROSE_ASSERT(object != nullptr);
  114450             : 
  114451             : #if ROSE_ALLOC_TRACE == 2
  114452             : //  printf("SgOmpUnrollStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpUnrollStatement::next_node);
  114453             :     printf("SgOmpUnrollStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpUnrollStatement::next_node);
  114454             : #endif
  114455             : 
  114456             : #if ROSE_PEDANTIC_ALLOC
  114457             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  114458             : #endif
  114459             : 
  114460             : #if ROSE_ALLOC_MEMSET == 1
  114461             : #elif ROSE_ALLOC_MEMSET == 2
  114462             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpUnrollStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  114463             : #elif ROSE_ALLOC_MEMSET == 3
  114464             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgOmpUnrollStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  114465             : #endif
  114466             : 
  114467             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  114468             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  114469             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  114470             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  114471             : #else
  114472           0 :     object->p_freepointer = SgOmpUnrollStatement::next_node;
  114473           0 :     SgOmpUnrollStatement::next_node = object;
  114474             : #endif
  114475             : 
  114476             : #if ROSE_ALLOC_TRACE == 2
  114477             : //  printf("SgOmpUnrollStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpUnrollStatement::next_node);
  114478             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  114479             :     Rose::MemPool::snapshot(oss.str());
  114480             :     alloc_trace_cnt++;
  114481             : #endif
  114482             : 
  114483             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  114484             : 
  114485           0 :     ALLOC_MUTEX(SgOmpUnrollStatement, unlock);
  114486             : }
  114487             : 
  114488             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  114489             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  114490             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  114491             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  114492             : // Also, note comment below from Robb (copied from the Common.code file).
  114493             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  114494             : //
  114495             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  114496             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  114497             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  114498             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  114499             : #if 0
  114500             : void SgOmpUnrollStatement::operator delete(void* pointer) { SgOmpUnrollStatement::operator delete (pointer, sizeof(SgOmpUnrollStatement)); };
  114501             : #endif
  114502             : /* #line 114503 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  114503             : 
  114504             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  114505             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  114506             : // obviously imply C++.
  114507             : 
  114508             : // This implements the support within ROSE for memory pools.  Memory pools
  114509             : // support the most condensed usage of memory within the construction of
  114510             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  114511             : // by a new operator written for each class.
  114512             : 
  114513             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  114514             :     // User wants multi-thread support and POSIX threads are available.
  114515             : #   include <pthread.h>
  114516             :     static pthread_mutex_t SgOmpTileStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  114517             : #else
  114518             :      // Cause synchronization to be skipped.
  114519             : #    ifndef ALLOC_MUTEX
  114520             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  114521             : #    endif
  114522             : #    ifdef _REENTRANT
  114523             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  114524             : #       ifdef _MSC_VER
  114525             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  114526             : #       else
  114527             : #           warning "POSIX threads are not available; synchronization being skipped"
  114528             : #       endif
  114529             : #    endif
  114530             : #endif
  114531             : 
  114532             : #ifndef ROSE_ALLOC_TRACE
  114533             : #  define ROSE_ALLOC_TRACE 0
  114534             : #endif
  114535             : 
  114536             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  114537             : #define ROSE_ALLOC_TRACE_CNT
  114538             : #include "memory-pool-snapshot.h"
  114539             : unsigned long alloc_trace_cnt = 0;
  114540             : #endif
  114541             : 
  114542             : #if ROSE_ALLOC_TRACE
  114543             : const unsigned SgOmpTileStatement::pool_size = 5;
  114544             : #else
  114545             : const unsigned SgOmpTileStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  114546             : #endif
  114547             : 
  114548             : #ifndef ROSE_ALLOC_MEMSET
  114549             : #  define ROSE_ALLOC_MEMSET 0
  114550             : #endif
  114551             : 
  114552             : #ifndef ROSE_PEDANTIC_ALLOC
  114553             : #  define ROSE_PEDANTIC_ALLOC 0
  114554             : #endif
  114555             : 
  114556             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  114557             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  114558             : #endif
  114559             : 
  114560             : #if !defined(SGNODE__ALL_POOLS)
  114561             : #define SGNODE__ALL_POOLS
  114562             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  114563             : #endif
  114564             : 
  114565             : SgOmpTileStatement* SgOmpTileStatement::next_node = nullptr;
  114566             : std::vector<unsigned char*> SgOmpTileStatement::pools;
  114567             : 
  114568             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  114569             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  114570             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  114571             : // around this macro definition rather than each use).
  114572             : #ifndef ALLOC_MUTEX
  114573             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  114574             :         do {                                                                     \
  114575             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  114576             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  114577             :                 abort();                                                         \
  114578             :             }                                                                    \
  114579             :         } while (0);
  114580             : #endif
  114581             : 
  114582             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  114583             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  114584             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  114585             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  114586             : 
  114587             : /*! \brief New operator for SgOmpTileStatement.
  114588             : 
  114589             :    This new operator implements memory pools to provide most efficent 
  114590             :    use of the heap within construction of large ASTs.
  114591             : 
  114592             : \internal The new and delete operators use the lower level C malloc/free
  114593             :    function calls for performance and to make sure that mixing of malloc/free
  114594             :    and new/delete by the used can be caught more readily.  This may change
  114595             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  114596             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  114597             :    deallocate memory allocated using ROSE_MALLOC.
  114598             : */
  114599           0 : void *SgOmpTileStatement::operator new ( size_t Size )
  114600             : {
  114601             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  114602             :      * returning or throwing an exception. */
  114603           0 :     ALLOC_MUTEX(SgOmpTileStatement, lock);
  114604             : 
  114605             : #if ROSE_ALLOC_TRACE == 2
  114606             : //    printf("SgOmpTileStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgOmpTileStatement::next_node);
  114607             : #endif
  114608             : 
  114609             : #if USE_CPP_NEW_DELETE_OPERATORS
  114610             :     void *mem = ROSE_MALLOC(Size);
  114611             :     ALLOC_MUTEX(SgOmpTileStatement, unlock);
  114612             :     return mem;
  114613             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  114614             : #if ROSE_PEDANTIC_ALLOC
  114615             :     ROSE_ASSERT(Size == sizeof(SgOmpTileStatement));
  114616             : #else
  114617           0 :     if (Size != sizeof(SgOmpTileStatement)) {
  114618           0 :       void * object = ROSE_MALLOC(Size);
  114619           0 :       ALLOC_MUTEX(SgOmpTileStatement, unlock);
  114620             :       return object;
  114621             :     }
  114622             : #endif
  114623             : 
  114624           0 :     if (SgOmpTileStatement::next_node == nullptr) {
  114625           0 :         SgOmpTileStatement * alloc = (SgOmpTileStatement*) ROSE_MALLOC ( SgOmpTileStatement::pool_size * sizeof(SgOmpTileStatement) );
  114626           0 :         ROSE_ASSERT(alloc != nullptr);
  114627             : 
  114628             : #if ROSE_ALLOC_TRACE == 2
  114629             : //        printf("SgOmpTileStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgOmpTileStatement::pools.size(), alloc, alloc + SgOmpTileStatement::pool_size);
  114630             : #endif
  114631             : 
  114632             : #if ROSE_ALLOC_MEMSET == 1
  114633             : #elif ROSE_ALLOC_MEMSET == 2
  114634             :         memset(alloc, 0x00, SgOmpTileStatement::pool_size * sizeof(SgOmpTileStatement));
  114635             : #elif ROSE_ALLOC_MEMSET == 3
  114636             :         memset(alloc, 0xAA, SgOmpTileStatement::pool_size * sizeof(SgOmpTileStatement));
  114637             : #endif
  114638           0 :         for (unsigned i=0; i < SgOmpTileStatement::pool_size-1; i++) {
  114639           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
  114640             :         }
  114641           0 :         alloc[SgOmpTileStatement::pool_size-1].p_freepointer = nullptr;
  114642             : 
  114643           0 :         SgOmpTileStatement::pools.push_back ( (unsigned char *) alloc );
  114644           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgOmpTileStatement::pool_size * sizeof(SgOmpTileStatement), V_SgOmpTileStatement ) );
  114645           0 :         SgOmpTileStatement::next_node = alloc;
  114646             :     }
  114647           0 :     ROSE_ASSERT(SgOmpTileStatement::next_node != nullptr);
  114648             : 
  114649           0 :     SgOmpTileStatement * object = SgOmpTileStatement::next_node;
  114650           0 :     SgOmpTileStatement::next_node = (SgOmpTileStatement*)(object->p_freepointer);
  114651             : 
  114652             : #if ROSE_ALLOC_TRACE == 2
  114653             :     printf("SgOmpTileStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpTileStatement::next_node);
  114654             : #endif
  114655             : 
  114656           0 :     SgNode * fp = object->p_freepointer;
  114657             : #if ROSE_ALLOC_MEMSET == 1
  114658             : #elif ROSE_ALLOC_MEMSET == 2
  114659             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpTileStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  114660             : #elif ROSE_ALLOC_MEMSET == 3
  114661             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgOmpTileStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  114662             : #endif
  114663           0 :     object->p_freepointer = fp;
  114664             : 
  114665             : #if ROSE_ALLOC_TRACE == 2
  114666             : //    printf("SgOmpTileStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpTileStatement::next_node);
  114667             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  114668             :     Rose::MemPool::snapshot(oss.str());
  114669             :     alloc_trace_cnt++;
  114670             : #endif
  114671             : 
  114672           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  114673             : 
  114674           0 :     ALLOC_MUTEX(SgOmpTileStatement, unlock);
  114675             : 
  114676             :     return object;
  114677             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  114678             : }
  114679             : 
  114680             : 
  114681             : 
  114682             : /*! \brief Delete operator for SgOmpTileStatement.
  114683             : 
  114684             :    This delete operator implements deallocation using memory pools to 
  114685             :    provide most efficent use of the heap within construction of large ASTs.
  114686             : 
  114687             : \internal The new and delete operators use the lower level C malloc/free
  114688             :    function calls for performance and to make sure that mixing of malloc/free
  114689             :    and new/delete by the used can be caught more readily.  This may change
  114690             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  114691             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  114692             :    deallocate memory allocated using ROSE_MALLOC.
  114693             : */
  114694           0 : void SgOmpTileStatement::operator delete(void *Pointer, size_t Size)
  114695             : {
  114696             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  114697             :      * or throwing an exception. */
  114698           0 :     ALLOC_MUTEX(SgOmpTileStatement, lock);
  114699             : 
  114700             : #if USE_CPP_NEW_DELETE_OPERATORS
  114701             :     ROSE_FREE(Pointer);
  114702             : #else
  114703             : #if ROSE_PEDANTIC_ALLOC
  114704             :     ROSE_ASSERT(Size == sizeof(SgOmpTileStatement));
  114705             : #else
  114706           0 :     if (Size != sizeof(SgOmpTileStatement)) {
  114707           0 :       ROSE_FREE(Pointer);
  114708           0 :       ALLOC_MUTEX(SgOmpTileStatement, unlock);
  114709             :       return;
  114710             :     }
  114711             : #endif
  114712             : 
  114713           0 :     SgOmpTileStatement * object = (SgOmpTileStatement*) Pointer;
  114714           0 :     ROSE_ASSERT(object != nullptr);
  114715             : 
  114716             : #if ROSE_ALLOC_TRACE == 2
  114717             : //  printf("SgOmpTileStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpTileStatement::next_node);
  114718             :     printf("SgOmpTileStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpTileStatement::next_node);
  114719             : #endif
  114720             : 
  114721             : #if ROSE_PEDANTIC_ALLOC
  114722             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  114723             : #endif
  114724             : 
  114725             : #if ROSE_ALLOC_MEMSET == 1
  114726             : #elif ROSE_ALLOC_MEMSET == 2
  114727             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpTileStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  114728             : #elif ROSE_ALLOC_MEMSET == 3
  114729             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgOmpTileStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  114730             : #endif
  114731             : 
  114732             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  114733             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  114734             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  114735             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  114736             : #else
  114737           0 :     object->p_freepointer = SgOmpTileStatement::next_node;
  114738           0 :     SgOmpTileStatement::next_node = object;
  114739             : #endif
  114740             : 
  114741             : #if ROSE_ALLOC_TRACE == 2
  114742             : //  printf("SgOmpTileStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpTileStatement::next_node);
  114743             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  114744             :     Rose::MemPool::snapshot(oss.str());
  114745             :     alloc_trace_cnt++;
  114746             : #endif
  114747             : 
  114748             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  114749             : 
  114750           0 :     ALLOC_MUTEX(SgOmpTileStatement, unlock);
  114751             : }
  114752             : 
  114753             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  114754             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  114755             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  114756             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  114757             : // Also, note comment below from Robb (copied from the Common.code file).
  114758             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  114759             : //
  114760             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  114761             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  114762             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  114763             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  114764             : #if 0
  114765             : void SgOmpTileStatement::operator delete(void* pointer) { SgOmpTileStatement::operator delete (pointer, sizeof(SgOmpTileStatement)); };
  114766             : #endif
  114767             : /* #line 114768 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  114768             : 
  114769             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  114770             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  114771             : // obviously imply C++.
  114772             : 
  114773             : // This implements the support within ROSE for memory pools.  Memory pools
  114774             : // support the most condensed usage of memory within the construction of
  114775             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  114776             : // by a new operator written for each class.
  114777             : 
  114778             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  114779             :     // User wants multi-thread support and POSIX threads are available.
  114780             : #   include <pthread.h>
  114781             :     static pthread_mutex_t SgUpirLoopStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  114782             : #else
  114783             :      // Cause synchronization to be skipped.
  114784             : #    ifndef ALLOC_MUTEX
  114785             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  114786             : #    endif
  114787             : #    ifdef _REENTRANT
  114788             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  114789             : #       ifdef _MSC_VER
  114790             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  114791             : #       else
  114792             : #           warning "POSIX threads are not available; synchronization being skipped"
  114793             : #       endif
  114794             : #    endif
  114795             : #endif
  114796             : 
  114797             : #ifndef ROSE_ALLOC_TRACE
  114798             : #  define ROSE_ALLOC_TRACE 0
  114799             : #endif
  114800             : 
  114801             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  114802             : #define ROSE_ALLOC_TRACE_CNT
  114803             : #include "memory-pool-snapshot.h"
  114804             : unsigned long alloc_trace_cnt = 0;
  114805             : #endif
  114806             : 
  114807             : #if ROSE_ALLOC_TRACE
  114808             : const unsigned SgUpirLoopStatement::pool_size = 5;
  114809             : #else
  114810             : const unsigned SgUpirLoopStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  114811             : #endif
  114812             : 
  114813             : #ifndef ROSE_ALLOC_MEMSET
  114814             : #  define ROSE_ALLOC_MEMSET 0
  114815             : #endif
  114816             : 
  114817             : #ifndef ROSE_PEDANTIC_ALLOC
  114818             : #  define ROSE_PEDANTIC_ALLOC 0
  114819             : #endif
  114820             : 
  114821             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  114822             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  114823             : #endif
  114824             : 
  114825             : #if !defined(SGNODE__ALL_POOLS)
  114826             : #define SGNODE__ALL_POOLS
  114827             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  114828             : #endif
  114829             : 
  114830             : SgUpirLoopStatement* SgUpirLoopStatement::next_node = nullptr;
  114831             : std::vector<unsigned char*> SgUpirLoopStatement::pools;
  114832             : 
  114833             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  114834             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  114835             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  114836             : // around this macro definition rather than each use).
  114837             : #ifndef ALLOC_MUTEX
  114838             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  114839             :         do {                                                                     \
  114840             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  114841             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  114842             :                 abort();                                                         \
  114843             :             }                                                                    \
  114844             :         } while (0);
  114845             : #endif
  114846             : 
  114847             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  114848             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  114849             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  114850             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  114851             : 
  114852             : /*! \brief New operator for SgUpirLoopStatement.
  114853             : 
  114854             :    This new operator implements memory pools to provide most efficent 
  114855             :    use of the heap within construction of large ASTs.
  114856             : 
  114857             : \internal The new and delete operators use the lower level C malloc/free
  114858             :    function calls for performance and to make sure that mixing of malloc/free
  114859             :    and new/delete by the used can be caught more readily.  This may change
  114860             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  114861             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  114862             :    deallocate memory allocated using ROSE_MALLOC.
  114863             : */
  114864         199 : void *SgUpirLoopStatement::operator new ( size_t Size )
  114865             : {
  114866             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  114867             :      * returning or throwing an exception. */
  114868         199 :     ALLOC_MUTEX(SgUpirLoopStatement, lock);
  114869             : 
  114870             : #if ROSE_ALLOC_TRACE == 2
  114871             : //    printf("SgUpirLoopStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgUpirLoopStatement::next_node);
  114872             : #endif
  114873             : 
  114874             : #if USE_CPP_NEW_DELETE_OPERATORS
  114875             :     void *mem = ROSE_MALLOC(Size);
  114876             :     ALLOC_MUTEX(SgUpirLoopStatement, unlock);
  114877             :     return mem;
  114878             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  114879             : #if ROSE_PEDANTIC_ALLOC
  114880             :     ROSE_ASSERT(Size == sizeof(SgUpirLoopStatement));
  114881             : #else
  114882         199 :     if (Size != sizeof(SgUpirLoopStatement)) {
  114883           0 :       void * object = ROSE_MALLOC(Size);
  114884           0 :       ALLOC_MUTEX(SgUpirLoopStatement, unlock);
  114885             :       return object;
  114886             :     }
  114887             : #endif
  114888             : 
  114889         199 :     if (SgUpirLoopStatement::next_node == nullptr) {
  114890          91 :         SgUpirLoopStatement * alloc = (SgUpirLoopStatement*) ROSE_MALLOC ( SgUpirLoopStatement::pool_size * sizeof(SgUpirLoopStatement) );
  114891          91 :         ROSE_ASSERT(alloc != nullptr);
  114892             : 
  114893             : #if ROSE_ALLOC_TRACE == 2
  114894             : //        printf("SgUpirLoopStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgUpirLoopStatement::pools.size(), alloc, alloc + SgUpirLoopStatement::pool_size);
  114895             : #endif
  114896             : 
  114897             : #if ROSE_ALLOC_MEMSET == 1
  114898             : #elif ROSE_ALLOC_MEMSET == 2
  114899             :         memset(alloc, 0x00, SgUpirLoopStatement::pool_size * sizeof(SgUpirLoopStatement));
  114900             : #elif ROSE_ALLOC_MEMSET == 3
  114901             :         memset(alloc, 0xAA, SgUpirLoopStatement::pool_size * sizeof(SgUpirLoopStatement));
  114902             : #endif
  114903      182000 :         for (unsigned i=0; i < SgUpirLoopStatement::pool_size-1; i++) {
  114904      181909 :           alloc[i].p_freepointer = &(alloc[i+1]);
  114905             :         }
  114906          91 :         alloc[SgUpirLoopStatement::pool_size-1].p_freepointer = nullptr;
  114907             : 
  114908          91 :         SgUpirLoopStatement::pools.push_back ( (unsigned char *) alloc );
  114909          91 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgUpirLoopStatement::pool_size * sizeof(SgUpirLoopStatement), V_SgUpirLoopStatement ) );
  114910          91 :         SgUpirLoopStatement::next_node = alloc;
  114911             :     }
  114912         199 :     ROSE_ASSERT(SgUpirLoopStatement::next_node != nullptr);
  114913             : 
  114914         199 :     SgUpirLoopStatement * object = SgUpirLoopStatement::next_node;
  114915         199 :     SgUpirLoopStatement::next_node = (SgUpirLoopStatement*)(object->p_freepointer);
  114916             : 
  114917             : #if ROSE_ALLOC_TRACE == 2
  114918             :     printf("SgUpirLoopStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUpirLoopStatement::next_node);
  114919             : #endif
  114920             : 
  114921         199 :     SgNode * fp = object->p_freepointer;
  114922             : #if ROSE_ALLOC_MEMSET == 1
  114923             : #elif ROSE_ALLOC_MEMSET == 2
  114924             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgUpirLoopStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  114925             : #elif ROSE_ALLOC_MEMSET == 3
  114926             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgUpirLoopStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  114927             : #endif
  114928         199 :     object->p_freepointer = fp;
  114929             : 
  114930             : #if ROSE_ALLOC_TRACE == 2
  114931             : //    printf("SgUpirLoopStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUpirLoopStatement::next_node);
  114932             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  114933             :     Rose::MemPool::snapshot(oss.str());
  114934             :     alloc_trace_cnt++;
  114935             : #endif
  114936             : 
  114937         199 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  114938             : 
  114939         199 :     ALLOC_MUTEX(SgUpirLoopStatement, unlock);
  114940             : 
  114941             :     return object;
  114942             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  114943             : }
  114944             : 
  114945             : 
  114946             : 
  114947             : /*! \brief Delete operator for SgUpirLoopStatement.
  114948             : 
  114949             :    This delete operator implements deallocation using memory pools to 
  114950             :    provide most efficent use of the heap within construction of large ASTs.
  114951             : 
  114952             : \internal The new and delete operators use the lower level C malloc/free
  114953             :    function calls for performance and to make sure that mixing of malloc/free
  114954             :    and new/delete by the used can be caught more readily.  This may change
  114955             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  114956             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  114957             :    deallocate memory allocated using ROSE_MALLOC.
  114958             : */
  114959           0 : void SgUpirLoopStatement::operator delete(void *Pointer, size_t Size)
  114960             : {
  114961             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  114962             :      * or throwing an exception. */
  114963           0 :     ALLOC_MUTEX(SgUpirLoopStatement, lock);
  114964             : 
  114965             : #if USE_CPP_NEW_DELETE_OPERATORS
  114966             :     ROSE_FREE(Pointer);
  114967             : #else
  114968             : #if ROSE_PEDANTIC_ALLOC
  114969             :     ROSE_ASSERT(Size == sizeof(SgUpirLoopStatement));
  114970             : #else
  114971           0 :     if (Size != sizeof(SgUpirLoopStatement)) {
  114972           0 :       ROSE_FREE(Pointer);
  114973           0 :       ALLOC_MUTEX(SgUpirLoopStatement, unlock);
  114974             :       return;
  114975             :     }
  114976             : #endif
  114977             : 
  114978           0 :     SgUpirLoopStatement * object = (SgUpirLoopStatement*) Pointer;
  114979           0 :     ROSE_ASSERT(object != nullptr);
  114980             : 
  114981             : #if ROSE_ALLOC_TRACE == 2
  114982             : //  printf("SgUpirLoopStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUpirLoopStatement::next_node);
  114983             :     printf("SgUpirLoopStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUpirLoopStatement::next_node);
  114984             : #endif
  114985             : 
  114986             : #if ROSE_PEDANTIC_ALLOC
  114987             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  114988             : #endif
  114989             : 
  114990             : #if ROSE_ALLOC_MEMSET == 1
  114991             : #elif ROSE_ALLOC_MEMSET == 2
  114992             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgUpirLoopStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  114993             : #elif ROSE_ALLOC_MEMSET == 3
  114994             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgUpirLoopStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  114995             : #endif
  114996             : 
  114997             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  114998             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  114999             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  115000             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  115001             : #else
  115002           0 :     object->p_freepointer = SgUpirLoopStatement::next_node;
  115003           0 :     SgUpirLoopStatement::next_node = object;
  115004             : #endif
  115005             : 
  115006             : #if ROSE_ALLOC_TRACE == 2
  115007             : //  printf("SgUpirLoopStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUpirLoopStatement::next_node);
  115008             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  115009             :     Rose::MemPool::snapshot(oss.str());
  115010             :     alloc_trace_cnt++;
  115011             : #endif
  115012             : 
  115013             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  115014             : 
  115015           0 :     ALLOC_MUTEX(SgUpirLoopStatement, unlock);
  115016             : }
  115017             : 
  115018             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  115019             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  115020             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  115021             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  115022             : // Also, note comment below from Robb (copied from the Common.code file).
  115023             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  115024             : //
  115025             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  115026             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  115027             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  115028             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  115029             : #if 0
  115030             : void SgUpirLoopStatement::operator delete(void* pointer) { SgUpirLoopStatement::operator delete (pointer, sizeof(SgUpirLoopStatement)); };
  115031             : #endif
  115032             : /* #line 115033 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  115033             : 
  115034             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  115035             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  115036             : // obviously imply C++.
  115037             : 
  115038             : // This implements the support within ROSE for memory pools.  Memory pools
  115039             : // support the most condensed usage of memory within the construction of
  115040             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  115041             : // by a new operator written for each class.
  115042             : 
  115043             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  115044             :     // User wants multi-thread support and POSIX threads are available.
  115045             : #   include <pthread.h>
  115046             :     static pthread_mutex_t SgUpirFieldStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  115047             : #else
  115048             :      // Cause synchronization to be skipped.
  115049             : #    ifndef ALLOC_MUTEX
  115050             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  115051             : #    endif
  115052             : #    ifdef _REENTRANT
  115053             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  115054             : #       ifdef _MSC_VER
  115055             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  115056             : #       else
  115057             : #           warning "POSIX threads are not available; synchronization being skipped"
  115058             : #       endif
  115059             : #    endif
  115060             : #endif
  115061             : 
  115062             : #ifndef ROSE_ALLOC_TRACE
  115063             : #  define ROSE_ALLOC_TRACE 0
  115064             : #endif
  115065             : 
  115066             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  115067             : #define ROSE_ALLOC_TRACE_CNT
  115068             : #include "memory-pool-snapshot.h"
  115069             : unsigned long alloc_trace_cnt = 0;
  115070             : #endif
  115071             : 
  115072             : #if ROSE_ALLOC_TRACE
  115073             : const unsigned SgUpirFieldStatement::pool_size = 5;
  115074             : #else
  115075             : const unsigned SgUpirFieldStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  115076             : #endif
  115077             : 
  115078             : #ifndef ROSE_ALLOC_MEMSET
  115079             : #  define ROSE_ALLOC_MEMSET 0
  115080             : #endif
  115081             : 
  115082             : #ifndef ROSE_PEDANTIC_ALLOC
  115083             : #  define ROSE_PEDANTIC_ALLOC 0
  115084             : #endif
  115085             : 
  115086             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  115087             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  115088             : #endif
  115089             : 
  115090             : #if !defined(SGNODE__ALL_POOLS)
  115091             : #define SGNODE__ALL_POOLS
  115092             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  115093             : #endif
  115094             : 
  115095             : SgUpirFieldStatement* SgUpirFieldStatement::next_node = nullptr;
  115096             : std::vector<unsigned char*> SgUpirFieldStatement::pools;
  115097             : 
  115098             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  115099             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  115100             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  115101             : // around this macro definition rather than each use).
  115102             : #ifndef ALLOC_MUTEX
  115103             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  115104             :         do {                                                                     \
  115105             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  115106             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  115107             :                 abort();                                                         \
  115108             :             }                                                                    \
  115109             :         } while (0);
  115110             : #endif
  115111             : 
  115112             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  115113             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  115114             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  115115             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  115116             : 
  115117             : /*! \brief New operator for SgUpirFieldStatement.
  115118             : 
  115119             :    This new operator implements memory pools to provide most efficent 
  115120             :    use of the heap within construction of large ASTs.
  115121             : 
  115122             : \internal The new and delete operators use the lower level C malloc/free
  115123             :    function calls for performance and to make sure that mixing of malloc/free
  115124             :    and new/delete by the used can be caught more readily.  This may change
  115125             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  115126             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  115127             :    deallocate memory allocated using ROSE_MALLOC.
  115128             : */
  115129           0 : void *SgUpirFieldStatement::operator new ( size_t Size )
  115130             : {
  115131             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  115132             :      * returning or throwing an exception. */
  115133           0 :     ALLOC_MUTEX(SgUpirFieldStatement, lock);
  115134             : 
  115135             : #if ROSE_ALLOC_TRACE == 2
  115136             : //    printf("SgUpirFieldStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgUpirFieldStatement::next_node);
  115137             : #endif
  115138             : 
  115139             : #if USE_CPP_NEW_DELETE_OPERATORS
  115140             :     void *mem = ROSE_MALLOC(Size);
  115141             :     ALLOC_MUTEX(SgUpirFieldStatement, unlock);
  115142             :     return mem;
  115143             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  115144             : #if ROSE_PEDANTIC_ALLOC
  115145             :     ROSE_ASSERT(Size == sizeof(SgUpirFieldStatement));
  115146             : #else
  115147           0 :     if (Size != sizeof(SgUpirFieldStatement)) {
  115148           0 :       void * object = ROSE_MALLOC(Size);
  115149           0 :       ALLOC_MUTEX(SgUpirFieldStatement, unlock);
  115150             :       return object;
  115151             :     }
  115152             : #endif
  115153             : 
  115154           0 :     if (SgUpirFieldStatement::next_node == nullptr) {
  115155           0 :         SgUpirFieldStatement * alloc = (SgUpirFieldStatement*) ROSE_MALLOC ( SgUpirFieldStatement::pool_size * sizeof(SgUpirFieldStatement) );
  115156           0 :         ROSE_ASSERT(alloc != nullptr);
  115157             : 
  115158             : #if ROSE_ALLOC_TRACE == 2
  115159             : //        printf("SgUpirFieldStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgUpirFieldStatement::pools.size(), alloc, alloc + SgUpirFieldStatement::pool_size);
  115160             : #endif
  115161             : 
  115162             : #if ROSE_ALLOC_MEMSET == 1
  115163             : #elif ROSE_ALLOC_MEMSET == 2
  115164             :         memset(alloc, 0x00, SgUpirFieldStatement::pool_size * sizeof(SgUpirFieldStatement));
  115165             : #elif ROSE_ALLOC_MEMSET == 3
  115166             :         memset(alloc, 0xAA, SgUpirFieldStatement::pool_size * sizeof(SgUpirFieldStatement));
  115167             : #endif
  115168           0 :         for (unsigned i=0; i < SgUpirFieldStatement::pool_size-1; i++) {
  115169           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
  115170             :         }
  115171           0 :         alloc[SgUpirFieldStatement::pool_size-1].p_freepointer = nullptr;
  115172             : 
  115173           0 :         SgUpirFieldStatement::pools.push_back ( (unsigned char *) alloc );
  115174           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgUpirFieldStatement::pool_size * sizeof(SgUpirFieldStatement), V_SgUpirFieldStatement ) );
  115175           0 :         SgUpirFieldStatement::next_node = alloc;
  115176             :     }
  115177           0 :     ROSE_ASSERT(SgUpirFieldStatement::next_node != nullptr);
  115178             : 
  115179           0 :     SgUpirFieldStatement * object = SgUpirFieldStatement::next_node;
  115180           0 :     SgUpirFieldStatement::next_node = (SgUpirFieldStatement*)(object->p_freepointer);
  115181             : 
  115182             : #if ROSE_ALLOC_TRACE == 2
  115183             :     printf("SgUpirFieldStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUpirFieldStatement::next_node);
  115184             : #endif
  115185             : 
  115186           0 :     SgNode * fp = object->p_freepointer;
  115187             : #if ROSE_ALLOC_MEMSET == 1
  115188             : #elif ROSE_ALLOC_MEMSET == 2
  115189             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgUpirFieldStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  115190             : #elif ROSE_ALLOC_MEMSET == 3
  115191             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgUpirFieldStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  115192             : #endif
  115193           0 :     object->p_freepointer = fp;
  115194             : 
  115195             : #if ROSE_ALLOC_TRACE == 2
  115196             : //    printf("SgUpirFieldStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUpirFieldStatement::next_node);
  115197             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  115198             :     Rose::MemPool::snapshot(oss.str());
  115199             :     alloc_trace_cnt++;
  115200             : #endif
  115201             : 
  115202           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  115203             : 
  115204           0 :     ALLOC_MUTEX(SgUpirFieldStatement, unlock);
  115205             : 
  115206             :     return object;
  115207             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  115208             : }
  115209             : 
  115210             : 
  115211             : 
  115212             : /*! \brief Delete operator for SgUpirFieldStatement.
  115213             : 
  115214             :    This delete operator implements deallocation using memory pools to 
  115215             :    provide most efficent use of the heap within construction of large ASTs.
  115216             : 
  115217             : \internal The new and delete operators use the lower level C malloc/free
  115218             :    function calls for performance and to make sure that mixing of malloc/free
  115219             :    and new/delete by the used can be caught more readily.  This may change
  115220             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  115221             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  115222             :    deallocate memory allocated using ROSE_MALLOC.
  115223             : */
  115224           0 : void SgUpirFieldStatement::operator delete(void *Pointer, size_t Size)
  115225             : {
  115226             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  115227             :      * or throwing an exception. */
  115228           0 :     ALLOC_MUTEX(SgUpirFieldStatement, lock);
  115229             : 
  115230             : #if USE_CPP_NEW_DELETE_OPERATORS
  115231             :     ROSE_FREE(Pointer);
  115232             : #else
  115233             : #if ROSE_PEDANTIC_ALLOC
  115234             :     ROSE_ASSERT(Size == sizeof(SgUpirFieldStatement));
  115235             : #else
  115236           0 :     if (Size != sizeof(SgUpirFieldStatement)) {
  115237           0 :       ROSE_FREE(Pointer);
  115238           0 :       ALLOC_MUTEX(SgUpirFieldStatement, unlock);
  115239             :       return;
  115240             :     }
  115241             : #endif
  115242             : 
  115243           0 :     SgUpirFieldStatement * object = (SgUpirFieldStatement*) Pointer;
  115244           0 :     ROSE_ASSERT(object != nullptr);
  115245             : 
  115246             : #if ROSE_ALLOC_TRACE == 2
  115247             : //  printf("SgUpirFieldStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUpirFieldStatement::next_node);
  115248             :     printf("SgUpirFieldStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUpirFieldStatement::next_node);
  115249             : #endif
  115250             : 
  115251             : #if ROSE_PEDANTIC_ALLOC
  115252             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  115253             : #endif
  115254             : 
  115255             : #if ROSE_ALLOC_MEMSET == 1
  115256             : #elif ROSE_ALLOC_MEMSET == 2
  115257             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgUpirFieldStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  115258             : #elif ROSE_ALLOC_MEMSET == 3
  115259             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgUpirFieldStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  115260             : #endif
  115261             : 
  115262             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  115263             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  115264             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  115265             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  115266             : #else
  115267           0 :     object->p_freepointer = SgUpirFieldStatement::next_node;
  115268           0 :     SgUpirFieldStatement::next_node = object;
  115269             : #endif
  115270             : 
  115271             : #if ROSE_ALLOC_TRACE == 2
  115272             : //  printf("SgUpirFieldStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUpirFieldStatement::next_node);
  115273             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  115274             :     Rose::MemPool::snapshot(oss.str());
  115275             :     alloc_trace_cnt++;
  115276             : #endif
  115277             : 
  115278             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  115279             : 
  115280           0 :     ALLOC_MUTEX(SgUpirFieldStatement, unlock);
  115281             : }
  115282             : 
  115283             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  115284             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  115285             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  115286             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  115287             : // Also, note comment below from Robb (copied from the Common.code file).
  115288             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  115289             : //
  115290             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  115291             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  115292             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  115293             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  115294             : #if 0
  115295             : void SgUpirFieldStatement::operator delete(void* pointer) { SgUpirFieldStatement::operator delete (pointer, sizeof(SgUpirFieldStatement)); };
  115296             : #endif
  115297             : /* #line 115298 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  115298             : 
  115299             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  115300             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  115301             : // obviously imply C++.
  115302             : 
  115303             : // This implements the support within ROSE for memory pools.  Memory pools
  115304             : // support the most condensed usage of memory within the construction of
  115305             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  115306             : // by a new operator written for each class.
  115307             : 
  115308             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  115309             :     // User wants multi-thread support and POSIX threads are available.
  115310             : #   include <pthread.h>
  115311             :     static pthread_mutex_t SgOmpCancelStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  115312             : #else
  115313             :      // Cause synchronization to be skipped.
  115314             : #    ifndef ALLOC_MUTEX
  115315             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  115316             : #    endif
  115317             : #    ifdef _REENTRANT
  115318             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  115319             : #       ifdef _MSC_VER
  115320             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  115321             : #       else
  115322             : #           warning "POSIX threads are not available; synchronization being skipped"
  115323             : #       endif
  115324             : #    endif
  115325             : #endif
  115326             : 
  115327             : #ifndef ROSE_ALLOC_TRACE
  115328             : #  define ROSE_ALLOC_TRACE 0
  115329             : #endif
  115330             : 
  115331             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  115332             : #define ROSE_ALLOC_TRACE_CNT
  115333             : #include "memory-pool-snapshot.h"
  115334             : unsigned long alloc_trace_cnt = 0;
  115335             : #endif
  115336             : 
  115337             : #if ROSE_ALLOC_TRACE
  115338             : const unsigned SgOmpCancelStatement::pool_size = 5;
  115339             : #else
  115340             : const unsigned SgOmpCancelStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  115341             : #endif
  115342             : 
  115343             : #ifndef ROSE_ALLOC_MEMSET
  115344             : #  define ROSE_ALLOC_MEMSET 0
  115345             : #endif
  115346             : 
  115347             : #ifndef ROSE_PEDANTIC_ALLOC
  115348             : #  define ROSE_PEDANTIC_ALLOC 0
  115349             : #endif
  115350             : 
  115351             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  115352             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  115353             : #endif
  115354             : 
  115355             : #if !defined(SGNODE__ALL_POOLS)
  115356             : #define SGNODE__ALL_POOLS
  115357             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  115358             : #endif
  115359             : 
  115360             : SgOmpCancelStatement* SgOmpCancelStatement::next_node = nullptr;
  115361             : std::vector<unsigned char*> SgOmpCancelStatement::pools;
  115362             : 
  115363             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  115364             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  115365             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  115366             : // around this macro definition rather than each use).
  115367             : #ifndef ALLOC_MUTEX
  115368             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  115369             :         do {                                                                     \
  115370             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  115371             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  115372             :                 abort();                                                         \
  115373             :             }                                                                    \
  115374             :         } while (0);
  115375             : #endif
  115376             : 
  115377             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  115378             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  115379             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  115380             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  115381             : 
  115382             : /*! \brief New operator for SgOmpCancelStatement.
  115383             : 
  115384             :    This new operator implements memory pools to provide most efficent 
  115385             :    use of the heap within construction of large ASTs.
  115386             : 
  115387             : \internal The new and delete operators use the lower level C malloc/free
  115388             :    function calls for performance and to make sure that mixing of malloc/free
  115389             :    and new/delete by the used can be caught more readily.  This may change
  115390             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  115391             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  115392             :    deallocate memory allocated using ROSE_MALLOC.
  115393             : */
  115394           1 : void *SgOmpCancelStatement::operator new ( size_t Size )
  115395             : {
  115396             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  115397             :      * returning or throwing an exception. */
  115398           1 :     ALLOC_MUTEX(SgOmpCancelStatement, lock);
  115399             : 
  115400             : #if ROSE_ALLOC_TRACE == 2
  115401             : //    printf("SgOmpCancelStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgOmpCancelStatement::next_node);
  115402             : #endif
  115403             : 
  115404             : #if USE_CPP_NEW_DELETE_OPERATORS
  115405             :     void *mem = ROSE_MALLOC(Size);
  115406             :     ALLOC_MUTEX(SgOmpCancelStatement, unlock);
  115407             :     return mem;
  115408             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  115409             : #if ROSE_PEDANTIC_ALLOC
  115410             :     ROSE_ASSERT(Size == sizeof(SgOmpCancelStatement));
  115411             : #else
  115412           1 :     if (Size != sizeof(SgOmpCancelStatement)) {
  115413           0 :       void * object = ROSE_MALLOC(Size);
  115414           0 :       ALLOC_MUTEX(SgOmpCancelStatement, unlock);
  115415             :       return object;
  115416             :     }
  115417             : #endif
  115418             : 
  115419           1 :     if (SgOmpCancelStatement::next_node == nullptr) {
  115420           1 :         SgOmpCancelStatement * alloc = (SgOmpCancelStatement*) ROSE_MALLOC ( SgOmpCancelStatement::pool_size * sizeof(SgOmpCancelStatement) );
  115421           1 :         ROSE_ASSERT(alloc != nullptr);
  115422             : 
  115423             : #if ROSE_ALLOC_TRACE == 2
  115424             : //        printf("SgOmpCancelStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgOmpCancelStatement::pools.size(), alloc, alloc + SgOmpCancelStatement::pool_size);
  115425             : #endif
  115426             : 
  115427             : #if ROSE_ALLOC_MEMSET == 1
  115428             : #elif ROSE_ALLOC_MEMSET == 2
  115429             :         memset(alloc, 0x00, SgOmpCancelStatement::pool_size * sizeof(SgOmpCancelStatement));
  115430             : #elif ROSE_ALLOC_MEMSET == 3
  115431             :         memset(alloc, 0xAA, SgOmpCancelStatement::pool_size * sizeof(SgOmpCancelStatement));
  115432             : #endif
  115433        2000 :         for (unsigned i=0; i < SgOmpCancelStatement::pool_size-1; i++) {
  115434        1999 :           alloc[i].p_freepointer = &(alloc[i+1]);
  115435             :         }
  115436           1 :         alloc[SgOmpCancelStatement::pool_size-1].p_freepointer = nullptr;
  115437             : 
  115438           1 :         SgOmpCancelStatement::pools.push_back ( (unsigned char *) alloc );
  115439           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgOmpCancelStatement::pool_size * sizeof(SgOmpCancelStatement), V_SgOmpCancelStatement ) );
  115440           1 :         SgOmpCancelStatement::next_node = alloc;
  115441             :     }
  115442           1 :     ROSE_ASSERT(SgOmpCancelStatement::next_node != nullptr);
  115443             : 
  115444           1 :     SgOmpCancelStatement * object = SgOmpCancelStatement::next_node;
  115445           1 :     SgOmpCancelStatement::next_node = (SgOmpCancelStatement*)(object->p_freepointer);
  115446             : 
  115447             : #if ROSE_ALLOC_TRACE == 2
  115448             :     printf("SgOmpCancelStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpCancelStatement::next_node);
  115449             : #endif
  115450             : 
  115451           1 :     SgNode * fp = object->p_freepointer;
  115452             : #if ROSE_ALLOC_MEMSET == 1
  115453             : #elif ROSE_ALLOC_MEMSET == 2
  115454             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpCancelStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  115455             : #elif ROSE_ALLOC_MEMSET == 3
  115456             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgOmpCancelStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  115457             : #endif
  115458           1 :     object->p_freepointer = fp;
  115459             : 
  115460             : #if ROSE_ALLOC_TRACE == 2
  115461             : //    printf("SgOmpCancelStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpCancelStatement::next_node);
  115462             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  115463             :     Rose::MemPool::snapshot(oss.str());
  115464             :     alloc_trace_cnt++;
  115465             : #endif
  115466             : 
  115467           1 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  115468             : 
  115469           1 :     ALLOC_MUTEX(SgOmpCancelStatement, unlock);
  115470             : 
  115471             :     return object;
  115472             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  115473             : }
  115474             : 
  115475             : 
  115476             : 
  115477             : /*! \brief Delete operator for SgOmpCancelStatement.
  115478             : 
  115479             :    This delete operator implements deallocation using memory pools to 
  115480             :    provide most efficent use of the heap within construction of large ASTs.
  115481             : 
  115482             : \internal The new and delete operators use the lower level C malloc/free
  115483             :    function calls for performance and to make sure that mixing of malloc/free
  115484             :    and new/delete by the used can be caught more readily.  This may change
  115485             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  115486             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  115487             :    deallocate memory allocated using ROSE_MALLOC.
  115488             : */
  115489           0 : void SgOmpCancelStatement::operator delete(void *Pointer, size_t Size)
  115490             : {
  115491             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  115492             :      * or throwing an exception. */
  115493           0 :     ALLOC_MUTEX(SgOmpCancelStatement, lock);
  115494             : 
  115495             : #if USE_CPP_NEW_DELETE_OPERATORS
  115496             :     ROSE_FREE(Pointer);
  115497             : #else
  115498             : #if ROSE_PEDANTIC_ALLOC
  115499             :     ROSE_ASSERT(Size == sizeof(SgOmpCancelStatement));
  115500             : #else
  115501           0 :     if (Size != sizeof(SgOmpCancelStatement)) {
  115502           0 :       ROSE_FREE(Pointer);
  115503           0 :       ALLOC_MUTEX(SgOmpCancelStatement, unlock);
  115504             :       return;
  115505             :     }
  115506             : #endif
  115507             : 
  115508           0 :     SgOmpCancelStatement * object = (SgOmpCancelStatement*) Pointer;
  115509           0 :     ROSE_ASSERT(object != nullptr);
  115510             : 
  115511             : #if ROSE_ALLOC_TRACE == 2
  115512             : //  printf("SgOmpCancelStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpCancelStatement::next_node);
  115513             :     printf("SgOmpCancelStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpCancelStatement::next_node);
  115514             : #endif
  115515             : 
  115516             : #if ROSE_PEDANTIC_ALLOC
  115517             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  115518             : #endif
  115519             : 
  115520             : #if ROSE_ALLOC_MEMSET == 1
  115521             : #elif ROSE_ALLOC_MEMSET == 2
  115522             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpCancelStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  115523             : #elif ROSE_ALLOC_MEMSET == 3
  115524             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgOmpCancelStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  115525             : #endif
  115526             : 
  115527             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  115528             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  115529             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  115530             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  115531             : #else
  115532           0 :     object->p_freepointer = SgOmpCancelStatement::next_node;
  115533           0 :     SgOmpCancelStatement::next_node = object;
  115534             : #endif
  115535             : 
  115536             : #if ROSE_ALLOC_TRACE == 2
  115537             : //  printf("SgOmpCancelStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpCancelStatement::next_node);
  115538             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  115539             :     Rose::MemPool::snapshot(oss.str());
  115540             :     alloc_trace_cnt++;
  115541             : #endif
  115542             : 
  115543             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  115544             : 
  115545           0 :     ALLOC_MUTEX(SgOmpCancelStatement, unlock);
  115546             : }
  115547             : 
  115548             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  115549             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  115550             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  115551             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  115552             : // Also, note comment below from Robb (copied from the Common.code file).
  115553             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  115554             : //
  115555             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  115556             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  115557             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  115558             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  115559             : #if 0
  115560             : void SgOmpCancelStatement::operator delete(void* pointer) { SgOmpCancelStatement::operator delete (pointer, sizeof(SgOmpCancelStatement)); };
  115561             : #endif
  115562             : /* #line 115563 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  115563             : 
  115564             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  115565             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  115566             : // obviously imply C++.
  115567             : 
  115568             : // This implements the support within ROSE for memory pools.  Memory pools
  115569             : // support the most condensed usage of memory within the construction of
  115570             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  115571             : // by a new operator written for each class.
  115572             : 
  115573             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  115574             :     // User wants multi-thread support and POSIX threads are available.
  115575             : #   include <pthread.h>
  115576             :     static pthread_mutex_t SgOmpCancellationPointStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  115577             : #else
  115578             :      // Cause synchronization to be skipped.
  115579             : #    ifndef ALLOC_MUTEX
  115580             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  115581             : #    endif
  115582             : #    ifdef _REENTRANT
  115583             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  115584             : #       ifdef _MSC_VER
  115585             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  115586             : #       else
  115587             : #           warning "POSIX threads are not available; synchronization being skipped"
  115588             : #       endif
  115589             : #    endif
  115590             : #endif
  115591             : 
  115592             : #ifndef ROSE_ALLOC_TRACE
  115593             : #  define ROSE_ALLOC_TRACE 0
  115594             : #endif
  115595             : 
  115596             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  115597             : #define ROSE_ALLOC_TRACE_CNT
  115598             : #include "memory-pool-snapshot.h"
  115599             : unsigned long alloc_trace_cnt = 0;
  115600             : #endif
  115601             : 
  115602             : #if ROSE_ALLOC_TRACE
  115603             : const unsigned SgOmpCancellationPointStatement::pool_size = 5;
  115604             : #else
  115605             : const unsigned SgOmpCancellationPointStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  115606             : #endif
  115607             : 
  115608             : #ifndef ROSE_ALLOC_MEMSET
  115609             : #  define ROSE_ALLOC_MEMSET 0
  115610             : #endif
  115611             : 
  115612             : #ifndef ROSE_PEDANTIC_ALLOC
  115613             : #  define ROSE_PEDANTIC_ALLOC 0
  115614             : #endif
  115615             : 
  115616             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  115617             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  115618             : #endif
  115619             : 
  115620             : #if !defined(SGNODE__ALL_POOLS)
  115621             : #define SGNODE__ALL_POOLS
  115622             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  115623             : #endif
  115624             : 
  115625             : SgOmpCancellationPointStatement* SgOmpCancellationPointStatement::next_node = nullptr;
  115626             : std::vector<unsigned char*> SgOmpCancellationPointStatement::pools;
  115627             : 
  115628             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  115629             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  115630             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  115631             : // around this macro definition rather than each use).
  115632             : #ifndef ALLOC_MUTEX
  115633             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  115634             :         do {                                                                     \
  115635             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  115636             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  115637             :                 abort();                                                         \
  115638             :             }                                                                    \
  115639             :         } while (0);
  115640             : #endif
  115641             : 
  115642             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  115643             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  115644             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  115645             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  115646             : 
  115647             : /*! \brief New operator for SgOmpCancellationPointStatement.
  115648             : 
  115649             :    This new operator implements memory pools to provide most efficent 
  115650             :    use of the heap within construction of large ASTs.
  115651             : 
  115652             : \internal The new and delete operators use the lower level C malloc/free
  115653             :    function calls for performance and to make sure that mixing of malloc/free
  115654             :    and new/delete by the used can be caught more readily.  This may change
  115655             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  115656             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  115657             :    deallocate memory allocated using ROSE_MALLOC.
  115658             : */
  115659           1 : void *SgOmpCancellationPointStatement::operator new ( size_t Size )
  115660             : {
  115661             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  115662             :      * returning or throwing an exception. */
  115663           1 :     ALLOC_MUTEX(SgOmpCancellationPointStatement, lock);
  115664             : 
  115665             : #if ROSE_ALLOC_TRACE == 2
  115666             : //    printf("SgOmpCancellationPointStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgOmpCancellationPointStatement::next_node);
  115667             : #endif
  115668             : 
  115669             : #if USE_CPP_NEW_DELETE_OPERATORS
  115670             :     void *mem = ROSE_MALLOC(Size);
  115671             :     ALLOC_MUTEX(SgOmpCancellationPointStatement, unlock);
  115672             :     return mem;
  115673             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  115674             : #if ROSE_PEDANTIC_ALLOC
  115675             :     ROSE_ASSERT(Size == sizeof(SgOmpCancellationPointStatement));
  115676             : #else
  115677           1 :     if (Size != sizeof(SgOmpCancellationPointStatement)) {
  115678           0 :       void * object = ROSE_MALLOC(Size);
  115679           0 :       ALLOC_MUTEX(SgOmpCancellationPointStatement, unlock);
  115680             :       return object;
  115681             :     }
  115682             : #endif
  115683             : 
  115684           1 :     if (SgOmpCancellationPointStatement::next_node == nullptr) {
  115685           1 :         SgOmpCancellationPointStatement * alloc = (SgOmpCancellationPointStatement*) ROSE_MALLOC ( SgOmpCancellationPointStatement::pool_size * sizeof(SgOmpCancellationPointStatement) );
  115686           1 :         ROSE_ASSERT(alloc != nullptr);
  115687             : 
  115688             : #if ROSE_ALLOC_TRACE == 2
  115689             : //        printf("SgOmpCancellationPointStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgOmpCancellationPointStatement::pools.size(), alloc, alloc + SgOmpCancellationPointStatement::pool_size);
  115690             : #endif
  115691             : 
  115692             : #if ROSE_ALLOC_MEMSET == 1
  115693             : #elif ROSE_ALLOC_MEMSET == 2
  115694             :         memset(alloc, 0x00, SgOmpCancellationPointStatement::pool_size * sizeof(SgOmpCancellationPointStatement));
  115695             : #elif ROSE_ALLOC_MEMSET == 3
  115696             :         memset(alloc, 0xAA, SgOmpCancellationPointStatement::pool_size * sizeof(SgOmpCancellationPointStatement));
  115697             : #endif
  115698        2000 :         for (unsigned i=0; i < SgOmpCancellationPointStatement::pool_size-1; i++) {
  115699        1999 :           alloc[i].p_freepointer = &(alloc[i+1]);
  115700             :         }
  115701           1 :         alloc[SgOmpCancellationPointStatement::pool_size-1].p_freepointer = nullptr;
  115702             : 
  115703           1 :         SgOmpCancellationPointStatement::pools.push_back ( (unsigned char *) alloc );
  115704           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgOmpCancellationPointStatement::pool_size * sizeof(SgOmpCancellationPointStatement), V_SgOmpCancellationPointStatement ) );
  115705           1 :         SgOmpCancellationPointStatement::next_node = alloc;
  115706             :     }
  115707           1 :     ROSE_ASSERT(SgOmpCancellationPointStatement::next_node != nullptr);
  115708             : 
  115709           1 :     SgOmpCancellationPointStatement * object = SgOmpCancellationPointStatement::next_node;
  115710           1 :     SgOmpCancellationPointStatement::next_node = (SgOmpCancellationPointStatement*)(object->p_freepointer);
  115711             : 
  115712             : #if ROSE_ALLOC_TRACE == 2
  115713             :     printf("SgOmpCancellationPointStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpCancellationPointStatement::next_node);
  115714             : #endif
  115715             : 
  115716           1 :     SgNode * fp = object->p_freepointer;
  115717             : #if ROSE_ALLOC_MEMSET == 1
  115718             : #elif ROSE_ALLOC_MEMSET == 2
  115719             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpCancellationPointStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  115720             : #elif ROSE_ALLOC_MEMSET == 3
  115721             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgOmpCancellationPointStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  115722             : #endif
  115723           1 :     object->p_freepointer = fp;
  115724             : 
  115725             : #if ROSE_ALLOC_TRACE == 2
  115726             : //    printf("SgOmpCancellationPointStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpCancellationPointStatement::next_node);
  115727             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  115728             :     Rose::MemPool::snapshot(oss.str());
  115729             :     alloc_trace_cnt++;
  115730             : #endif
  115731             : 
  115732           1 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  115733             : 
  115734           1 :     ALLOC_MUTEX(SgOmpCancellationPointStatement, unlock);
  115735             : 
  115736             :     return object;
  115737             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  115738             : }
  115739             : 
  115740             : 
  115741             : 
  115742             : /*! \brief Delete operator for SgOmpCancellationPointStatement.
  115743             : 
  115744             :    This delete operator implements deallocation using memory pools to 
  115745             :    provide most efficent use of the heap within construction of large ASTs.
  115746             : 
  115747             : \internal The new and delete operators use the lower level C malloc/free
  115748             :    function calls for performance and to make sure that mixing of malloc/free
  115749             :    and new/delete by the used can be caught more readily.  This may change
  115750             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  115751             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  115752             :    deallocate memory allocated using ROSE_MALLOC.
  115753             : */
  115754           0 : void SgOmpCancellationPointStatement::operator delete(void *Pointer, size_t Size)
  115755             : {
  115756             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  115757             :      * or throwing an exception. */
  115758           0 :     ALLOC_MUTEX(SgOmpCancellationPointStatement, lock);
  115759             : 
  115760             : #if USE_CPP_NEW_DELETE_OPERATORS
  115761             :     ROSE_FREE(Pointer);
  115762             : #else
  115763             : #if ROSE_PEDANTIC_ALLOC
  115764             :     ROSE_ASSERT(Size == sizeof(SgOmpCancellationPointStatement));
  115765             : #else
  115766           0 :     if (Size != sizeof(SgOmpCancellationPointStatement)) {
  115767           0 :       ROSE_FREE(Pointer);
  115768           0 :       ALLOC_MUTEX(SgOmpCancellationPointStatement, unlock);
  115769             :       return;
  115770             :     }
  115771             : #endif
  115772             : 
  115773           0 :     SgOmpCancellationPointStatement * object = (SgOmpCancellationPointStatement*) Pointer;
  115774           0 :     ROSE_ASSERT(object != nullptr);
  115775             : 
  115776             : #if ROSE_ALLOC_TRACE == 2
  115777             : //  printf("SgOmpCancellationPointStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpCancellationPointStatement::next_node);
  115778             :     printf("SgOmpCancellationPointStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpCancellationPointStatement::next_node);
  115779             : #endif
  115780             : 
  115781             : #if ROSE_PEDANTIC_ALLOC
  115782             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  115783             : #endif
  115784             : 
  115785             : #if ROSE_ALLOC_MEMSET == 1
  115786             : #elif ROSE_ALLOC_MEMSET == 2
  115787             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpCancellationPointStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  115788             : #elif ROSE_ALLOC_MEMSET == 3
  115789             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgOmpCancellationPointStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  115790             : #endif
  115791             : 
  115792             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  115793             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  115794             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  115795             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  115796             : #else
  115797           0 :     object->p_freepointer = SgOmpCancellationPointStatement::next_node;
  115798           0 :     SgOmpCancellationPointStatement::next_node = object;
  115799             : #endif
  115800             : 
  115801             : #if ROSE_ALLOC_TRACE == 2
  115802             : //  printf("SgOmpCancellationPointStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpCancellationPointStatement::next_node);
  115803             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  115804             :     Rose::MemPool::snapshot(oss.str());
  115805             :     alloc_trace_cnt++;
  115806             : #endif
  115807             : 
  115808             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  115809             : 
  115810           0 :     ALLOC_MUTEX(SgOmpCancellationPointStatement, unlock);
  115811             : }
  115812             : 
  115813             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  115814             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  115815             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  115816             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  115817             : // Also, note comment below from Robb (copied from the Common.code file).
  115818             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  115819             : //
  115820             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  115821             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  115822             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  115823             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  115824             : #if 0
  115825             : void SgOmpCancellationPointStatement::operator delete(void* pointer) { SgOmpCancellationPointStatement::operator delete (pointer, sizeof(SgOmpCancellationPointStatement)); };
  115826             : #endif
  115827             : /* #line 115828 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  115828             : 
  115829             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  115830             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  115831             : // obviously imply C++.
  115832             : 
  115833             : // This implements the support within ROSE for memory pools.  Memory pools
  115834             : // support the most condensed usage of memory within the construction of
  115835             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  115836             : // by a new operator written for each class.
  115837             : 
  115838             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  115839             :     // User wants multi-thread support and POSIX threads are available.
  115840             : #   include <pthread.h>
  115841             :     static pthread_mutex_t SgOmpTargetUpdateStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  115842             : #else
  115843             :      // Cause synchronization to be skipped.
  115844             : #    ifndef ALLOC_MUTEX
  115845             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  115846             : #    endif
  115847             : #    ifdef _REENTRANT
  115848             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  115849             : #       ifdef _MSC_VER
  115850             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  115851             : #       else
  115852             : #           warning "POSIX threads are not available; synchronization being skipped"
  115853             : #       endif
  115854             : #    endif
  115855             : #endif
  115856             : 
  115857             : #ifndef ROSE_ALLOC_TRACE
  115858             : #  define ROSE_ALLOC_TRACE 0
  115859             : #endif
  115860             : 
  115861             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  115862             : #define ROSE_ALLOC_TRACE_CNT
  115863             : #include "memory-pool-snapshot.h"
  115864             : unsigned long alloc_trace_cnt = 0;
  115865             : #endif
  115866             : 
  115867             : #if ROSE_ALLOC_TRACE
  115868             : const unsigned SgOmpTargetUpdateStatement::pool_size = 5;
  115869             : #else
  115870             : const unsigned SgOmpTargetUpdateStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  115871             : #endif
  115872             : 
  115873             : #ifndef ROSE_ALLOC_MEMSET
  115874             : #  define ROSE_ALLOC_MEMSET 0
  115875             : #endif
  115876             : 
  115877             : #ifndef ROSE_PEDANTIC_ALLOC
  115878             : #  define ROSE_PEDANTIC_ALLOC 0
  115879             : #endif
  115880             : 
  115881             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  115882             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  115883             : #endif
  115884             : 
  115885             : #if !defined(SGNODE__ALL_POOLS)
  115886             : #define SGNODE__ALL_POOLS
  115887             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  115888             : #endif
  115889             : 
  115890             : SgOmpTargetUpdateStatement* SgOmpTargetUpdateStatement::next_node = nullptr;
  115891             : std::vector<unsigned char*> SgOmpTargetUpdateStatement::pools;
  115892             : 
  115893             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  115894             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  115895             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  115896             : // around this macro definition rather than each use).
  115897             : #ifndef ALLOC_MUTEX
  115898             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  115899             :         do {                                                                     \
  115900             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  115901             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  115902             :                 abort();                                                         \
  115903             :             }                                                                    \
  115904             :         } while (0);
  115905             : #endif
  115906             : 
  115907             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  115908             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  115909             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  115910             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  115911             : 
  115912             : /*! \brief New operator for SgOmpTargetUpdateStatement.
  115913             : 
  115914             :    This new operator implements memory pools to provide most efficent 
  115915             :    use of the heap within construction of large ASTs.
  115916             : 
  115917             : \internal The new and delete operators use the lower level C malloc/free
  115918             :    function calls for performance and to make sure that mixing of malloc/free
  115919             :    and new/delete by the used can be caught more readily.  This may change
  115920             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  115921             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  115922             :    deallocate memory allocated using ROSE_MALLOC.
  115923             : */
  115924           5 : void *SgOmpTargetUpdateStatement::operator new ( size_t Size )
  115925             : {
  115926             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  115927             :      * returning or throwing an exception. */
  115928           5 :     ALLOC_MUTEX(SgOmpTargetUpdateStatement, lock);
  115929             : 
  115930             : #if ROSE_ALLOC_TRACE == 2
  115931             : //    printf("SgOmpTargetUpdateStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgOmpTargetUpdateStatement::next_node);
  115932             : #endif
  115933             : 
  115934             : #if USE_CPP_NEW_DELETE_OPERATORS
  115935             :     void *mem = ROSE_MALLOC(Size);
  115936             :     ALLOC_MUTEX(SgOmpTargetUpdateStatement, unlock);
  115937             :     return mem;
  115938             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  115939             : #if ROSE_PEDANTIC_ALLOC
  115940             :     ROSE_ASSERT(Size == sizeof(SgOmpTargetUpdateStatement));
  115941             : #else
  115942           5 :     if (Size != sizeof(SgOmpTargetUpdateStatement)) {
  115943           0 :       void * object = ROSE_MALLOC(Size);
  115944           0 :       ALLOC_MUTEX(SgOmpTargetUpdateStatement, unlock);
  115945             :       return object;
  115946             :     }
  115947             : #endif
  115948             : 
  115949           5 :     if (SgOmpTargetUpdateStatement::next_node == nullptr) {
  115950           5 :         SgOmpTargetUpdateStatement * alloc = (SgOmpTargetUpdateStatement*) ROSE_MALLOC ( SgOmpTargetUpdateStatement::pool_size * sizeof(SgOmpTargetUpdateStatement) );
  115951           5 :         ROSE_ASSERT(alloc != nullptr);
  115952             : 
  115953             : #if ROSE_ALLOC_TRACE == 2
  115954             : //        printf("SgOmpTargetUpdateStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgOmpTargetUpdateStatement::pools.size(), alloc, alloc + SgOmpTargetUpdateStatement::pool_size);
  115955             : #endif
  115956             : 
  115957             : #if ROSE_ALLOC_MEMSET == 1
  115958             : #elif ROSE_ALLOC_MEMSET == 2
  115959             :         memset(alloc, 0x00, SgOmpTargetUpdateStatement::pool_size * sizeof(SgOmpTargetUpdateStatement));
  115960             : #elif ROSE_ALLOC_MEMSET == 3
  115961             :         memset(alloc, 0xAA, SgOmpTargetUpdateStatement::pool_size * sizeof(SgOmpTargetUpdateStatement));
  115962             : #endif
  115963       10000 :         for (unsigned i=0; i < SgOmpTargetUpdateStatement::pool_size-1; i++) {
  115964        9995 :           alloc[i].p_freepointer = &(alloc[i+1]);
  115965             :         }
  115966           5 :         alloc[SgOmpTargetUpdateStatement::pool_size-1].p_freepointer = nullptr;
  115967             : 
  115968           5 :         SgOmpTargetUpdateStatement::pools.push_back ( (unsigned char *) alloc );
  115969           5 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgOmpTargetUpdateStatement::pool_size * sizeof(SgOmpTargetUpdateStatement), V_SgOmpTargetUpdateStatement ) );
  115970           5 :         SgOmpTargetUpdateStatement::next_node = alloc;
  115971             :     }
  115972           5 :     ROSE_ASSERT(SgOmpTargetUpdateStatement::next_node != nullptr);
  115973             : 
  115974           5 :     SgOmpTargetUpdateStatement * object = SgOmpTargetUpdateStatement::next_node;
  115975           5 :     SgOmpTargetUpdateStatement::next_node = (SgOmpTargetUpdateStatement*)(object->p_freepointer);
  115976             : 
  115977             : #if ROSE_ALLOC_TRACE == 2
  115978             :     printf("SgOmpTargetUpdateStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpTargetUpdateStatement::next_node);
  115979             : #endif
  115980             : 
  115981           5 :     SgNode * fp = object->p_freepointer;
  115982             : #if ROSE_ALLOC_MEMSET == 1
  115983             : #elif ROSE_ALLOC_MEMSET == 2
  115984             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpTargetUpdateStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  115985             : #elif ROSE_ALLOC_MEMSET == 3
  115986             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgOmpTargetUpdateStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  115987             : #endif
  115988           5 :     object->p_freepointer = fp;
  115989             : 
  115990             : #if ROSE_ALLOC_TRACE == 2
  115991             : //    printf("SgOmpTargetUpdateStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpTargetUpdateStatement::next_node);
  115992             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  115993             :     Rose::MemPool::snapshot(oss.str());
  115994             :     alloc_trace_cnt++;
  115995             : #endif
  115996             : 
  115997           5 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  115998             : 
  115999           5 :     ALLOC_MUTEX(SgOmpTargetUpdateStatement, unlock);
  116000             : 
  116001             :     return object;
  116002             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  116003             : }
  116004             : 
  116005             : 
  116006             : 
  116007             : /*! \brief Delete operator for SgOmpTargetUpdateStatement.
  116008             : 
  116009             :    This delete operator implements deallocation using memory pools to 
  116010             :    provide most efficent use of the heap within construction of large ASTs.
  116011             : 
  116012             : \internal The new and delete operators use the lower level C malloc/free
  116013             :    function calls for performance and to make sure that mixing of malloc/free
  116014             :    and new/delete by the used can be caught more readily.  This may change
  116015             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  116016             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  116017             :    deallocate memory allocated using ROSE_MALLOC.
  116018             : */
  116019           0 : void SgOmpTargetUpdateStatement::operator delete(void *Pointer, size_t Size)
  116020             : {
  116021             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  116022             :      * or throwing an exception. */
  116023           0 :     ALLOC_MUTEX(SgOmpTargetUpdateStatement, lock);
  116024             : 
  116025             : #if USE_CPP_NEW_DELETE_OPERATORS
  116026             :     ROSE_FREE(Pointer);
  116027             : #else
  116028             : #if ROSE_PEDANTIC_ALLOC
  116029             :     ROSE_ASSERT(Size == sizeof(SgOmpTargetUpdateStatement));
  116030             : #else
  116031           0 :     if (Size != sizeof(SgOmpTargetUpdateStatement)) {
  116032           0 :       ROSE_FREE(Pointer);
  116033           0 :       ALLOC_MUTEX(SgOmpTargetUpdateStatement, unlock);
  116034             :       return;
  116035             :     }
  116036             : #endif
  116037             : 
  116038           0 :     SgOmpTargetUpdateStatement * object = (SgOmpTargetUpdateStatement*) Pointer;
  116039           0 :     ROSE_ASSERT(object != nullptr);
  116040             : 
  116041             : #if ROSE_ALLOC_TRACE == 2
  116042             : //  printf("SgOmpTargetUpdateStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpTargetUpdateStatement::next_node);
  116043             :     printf("SgOmpTargetUpdateStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpTargetUpdateStatement::next_node);
  116044             : #endif
  116045             : 
  116046             : #if ROSE_PEDANTIC_ALLOC
  116047             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  116048             : #endif
  116049             : 
  116050             : #if ROSE_ALLOC_MEMSET == 1
  116051             : #elif ROSE_ALLOC_MEMSET == 2
  116052             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpTargetUpdateStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  116053             : #elif ROSE_ALLOC_MEMSET == 3
  116054             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgOmpTargetUpdateStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  116055             : #endif
  116056             : 
  116057             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  116058             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  116059             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  116060             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  116061             : #else
  116062           0 :     object->p_freepointer = SgOmpTargetUpdateStatement::next_node;
  116063           0 :     SgOmpTargetUpdateStatement::next_node = object;
  116064             : #endif
  116065             : 
  116066             : #if ROSE_ALLOC_TRACE == 2
  116067             : //  printf("SgOmpTargetUpdateStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpTargetUpdateStatement::next_node);
  116068             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  116069             :     Rose::MemPool::snapshot(oss.str());
  116070             :     alloc_trace_cnt++;
  116071             : #endif
  116072             : 
  116073             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  116074             : 
  116075           0 :     ALLOC_MUTEX(SgOmpTargetUpdateStatement, unlock);
  116076             : }
  116077             : 
  116078             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  116079             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  116080             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  116081             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  116082             : // Also, note comment below from Robb (copied from the Common.code file).
  116083             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  116084             : //
  116085             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  116086             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  116087             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  116088             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  116089             : #if 0
  116090             : void SgOmpTargetUpdateStatement::operator delete(void* pointer) { SgOmpTargetUpdateStatement::operator delete (pointer, sizeof(SgOmpTargetUpdateStatement)); };
  116091             : #endif
  116092             : /* #line 116093 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  116093             : 
  116094             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  116095             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  116096             : // obviously imply C++.
  116097             : 
  116098             : // This implements the support within ROSE for memory pools.  Memory pools
  116099             : // support the most condensed usage of memory within the construction of
  116100             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  116101             : // by a new operator written for each class.
  116102             : 
  116103             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  116104             :     // User wants multi-thread support and POSIX threads are available.
  116105             : #   include <pthread.h>
  116106             :     static pthread_mutex_t SgOmpFlushStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  116107             : #else
  116108             :      // Cause synchronization to be skipped.
  116109             : #    ifndef ALLOC_MUTEX
  116110             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  116111             : #    endif
  116112             : #    ifdef _REENTRANT
  116113             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  116114             : #       ifdef _MSC_VER
  116115             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  116116             : #       else
  116117             : #           warning "POSIX threads are not available; synchronization being skipped"
  116118             : #       endif
  116119             : #    endif
  116120             : #endif
  116121             : 
  116122             : #ifndef ROSE_ALLOC_TRACE
  116123             : #  define ROSE_ALLOC_TRACE 0
  116124             : #endif
  116125             : 
  116126             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  116127             : #define ROSE_ALLOC_TRACE_CNT
  116128             : #include "memory-pool-snapshot.h"
  116129             : unsigned long alloc_trace_cnt = 0;
  116130             : #endif
  116131             : 
  116132             : #if ROSE_ALLOC_TRACE
  116133             : const unsigned SgOmpFlushStatement::pool_size = 5;
  116134             : #else
  116135             : const unsigned SgOmpFlushStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  116136             : #endif
  116137             : 
  116138             : #ifndef ROSE_ALLOC_MEMSET
  116139             : #  define ROSE_ALLOC_MEMSET 0
  116140             : #endif
  116141             : 
  116142             : #ifndef ROSE_PEDANTIC_ALLOC
  116143             : #  define ROSE_PEDANTIC_ALLOC 0
  116144             : #endif
  116145             : 
  116146             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  116147             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  116148             : #endif
  116149             : 
  116150             : #if !defined(SGNODE__ALL_POOLS)
  116151             : #define SGNODE__ALL_POOLS
  116152             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  116153             : #endif
  116154             : 
  116155             : SgOmpFlushStatement* SgOmpFlushStatement::next_node = nullptr;
  116156             : std::vector<unsigned char*> SgOmpFlushStatement::pools;
  116157             : 
  116158             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  116159             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  116160             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  116161             : // around this macro definition rather than each use).
  116162             : #ifndef ALLOC_MUTEX
  116163             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  116164             :         do {                                                                     \
  116165             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  116166             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  116167             :                 abort();                                                         \
  116168             :             }                                                                    \
  116169             :         } while (0);
  116170             : #endif
  116171             : 
  116172             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  116173             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  116174             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  116175             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  116176             : 
  116177             : /*! \brief New operator for SgOmpFlushStatement.
  116178             : 
  116179             :    This new operator implements memory pools to provide most efficent 
  116180             :    use of the heap within construction of large ASTs.
  116181             : 
  116182             : \internal The new and delete operators use the lower level C malloc/free
  116183             :    function calls for performance and to make sure that mixing of malloc/free
  116184             :    and new/delete by the used can be caught more readily.  This may change
  116185             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  116186             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  116187             :    deallocate memory allocated using ROSE_MALLOC.
  116188             : */
  116189           9 : void *SgOmpFlushStatement::operator new ( size_t Size )
  116190             : {
  116191             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  116192             :      * returning or throwing an exception. */
  116193           9 :     ALLOC_MUTEX(SgOmpFlushStatement, lock);
  116194             : 
  116195             : #if ROSE_ALLOC_TRACE == 2
  116196             : //    printf("SgOmpFlushStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgOmpFlushStatement::next_node);
  116197             : #endif
  116198             : 
  116199             : #if USE_CPP_NEW_DELETE_OPERATORS
  116200             :     void *mem = ROSE_MALLOC(Size);
  116201             :     ALLOC_MUTEX(SgOmpFlushStatement, unlock);
  116202             :     return mem;
  116203             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  116204             : #if ROSE_PEDANTIC_ALLOC
  116205             :     ROSE_ASSERT(Size == sizeof(SgOmpFlushStatement));
  116206             : #else
  116207           9 :     if (Size != sizeof(SgOmpFlushStatement)) {
  116208           0 :       void * object = ROSE_MALLOC(Size);
  116209           0 :       ALLOC_MUTEX(SgOmpFlushStatement, unlock);
  116210             :       return object;
  116211             :     }
  116212             : #endif
  116213             : 
  116214           9 :     if (SgOmpFlushStatement::next_node == nullptr) {
  116215           4 :         SgOmpFlushStatement * alloc = (SgOmpFlushStatement*) ROSE_MALLOC ( SgOmpFlushStatement::pool_size * sizeof(SgOmpFlushStatement) );
  116216           4 :         ROSE_ASSERT(alloc != nullptr);
  116217             : 
  116218             : #if ROSE_ALLOC_TRACE == 2
  116219             : //        printf("SgOmpFlushStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgOmpFlushStatement::pools.size(), alloc, alloc + SgOmpFlushStatement::pool_size);
  116220             : #endif
  116221             : 
  116222             : #if ROSE_ALLOC_MEMSET == 1
  116223             : #elif ROSE_ALLOC_MEMSET == 2
  116224             :         memset(alloc, 0x00, SgOmpFlushStatement::pool_size * sizeof(SgOmpFlushStatement));
  116225             : #elif ROSE_ALLOC_MEMSET == 3
  116226             :         memset(alloc, 0xAA, SgOmpFlushStatement::pool_size * sizeof(SgOmpFlushStatement));
  116227             : #endif
  116228        8000 :         for (unsigned i=0; i < SgOmpFlushStatement::pool_size-1; i++) {
  116229        7996 :           alloc[i].p_freepointer = &(alloc[i+1]);
  116230             :         }
  116231           4 :         alloc[SgOmpFlushStatement::pool_size-1].p_freepointer = nullptr;
  116232             : 
  116233           4 :         SgOmpFlushStatement::pools.push_back ( (unsigned char *) alloc );
  116234           4 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgOmpFlushStatement::pool_size * sizeof(SgOmpFlushStatement), V_SgOmpFlushStatement ) );
  116235           4 :         SgOmpFlushStatement::next_node = alloc;
  116236             :     }
  116237           9 :     ROSE_ASSERT(SgOmpFlushStatement::next_node != nullptr);
  116238             : 
  116239           9 :     SgOmpFlushStatement * object = SgOmpFlushStatement::next_node;
  116240           9 :     SgOmpFlushStatement::next_node = (SgOmpFlushStatement*)(object->p_freepointer);
  116241             : 
  116242             : #if ROSE_ALLOC_TRACE == 2
  116243             :     printf("SgOmpFlushStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpFlushStatement::next_node);
  116244             : #endif
  116245             : 
  116246           9 :     SgNode * fp = object->p_freepointer;
  116247             : #if ROSE_ALLOC_MEMSET == 1
  116248             : #elif ROSE_ALLOC_MEMSET == 2
  116249             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpFlushStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  116250             : #elif ROSE_ALLOC_MEMSET == 3
  116251             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgOmpFlushStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  116252             : #endif
  116253           9 :     object->p_freepointer = fp;
  116254             : 
  116255             : #if ROSE_ALLOC_TRACE == 2
  116256             : //    printf("SgOmpFlushStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpFlushStatement::next_node);
  116257             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  116258             :     Rose::MemPool::snapshot(oss.str());
  116259             :     alloc_trace_cnt++;
  116260             : #endif
  116261             : 
  116262           9 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  116263             : 
  116264           9 :     ALLOC_MUTEX(SgOmpFlushStatement, unlock);
  116265             : 
  116266             :     return object;
  116267             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  116268             : }
  116269             : 
  116270             : 
  116271             : 
  116272             : /*! \brief Delete operator for SgOmpFlushStatement.
  116273             : 
  116274             :    This delete operator implements deallocation using memory pools to 
  116275             :    provide most efficent use of the heap within construction of large ASTs.
  116276             : 
  116277             : \internal The new and delete operators use the lower level C malloc/free
  116278             :    function calls for performance and to make sure that mixing of malloc/free
  116279             :    and new/delete by the used can be caught more readily.  This may change
  116280             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  116281             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  116282             :    deallocate memory allocated using ROSE_MALLOC.
  116283             : */
  116284           0 : void SgOmpFlushStatement::operator delete(void *Pointer, size_t Size)
  116285             : {
  116286             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  116287             :      * or throwing an exception. */
  116288           0 :     ALLOC_MUTEX(SgOmpFlushStatement, lock);
  116289             : 
  116290             : #if USE_CPP_NEW_DELETE_OPERATORS
  116291             :     ROSE_FREE(Pointer);
  116292             : #else
  116293             : #if ROSE_PEDANTIC_ALLOC
  116294             :     ROSE_ASSERT(Size == sizeof(SgOmpFlushStatement));
  116295             : #else
  116296           0 :     if (Size != sizeof(SgOmpFlushStatement)) {
  116297           0 :       ROSE_FREE(Pointer);
  116298           0 :       ALLOC_MUTEX(SgOmpFlushStatement, unlock);
  116299             :       return;
  116300             :     }
  116301             : #endif
  116302             : 
  116303           0 :     SgOmpFlushStatement * object = (SgOmpFlushStatement*) Pointer;
  116304           0 :     ROSE_ASSERT(object != nullptr);
  116305             : 
  116306             : #if ROSE_ALLOC_TRACE == 2
  116307             : //  printf("SgOmpFlushStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpFlushStatement::next_node);
  116308             :     printf("SgOmpFlushStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpFlushStatement::next_node);
  116309             : #endif
  116310             : 
  116311             : #if ROSE_PEDANTIC_ALLOC
  116312             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  116313             : #endif
  116314             : 
  116315             : #if ROSE_ALLOC_MEMSET == 1
  116316             : #elif ROSE_ALLOC_MEMSET == 2
  116317             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpFlushStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  116318             : #elif ROSE_ALLOC_MEMSET == 3
  116319             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgOmpFlushStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  116320             : #endif
  116321             : 
  116322             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  116323             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  116324             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  116325             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  116326             : #else
  116327           0 :     object->p_freepointer = SgOmpFlushStatement::next_node;
  116328           0 :     SgOmpFlushStatement::next_node = object;
  116329             : #endif
  116330             : 
  116331             : #if ROSE_ALLOC_TRACE == 2
  116332             : //  printf("SgOmpFlushStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpFlushStatement::next_node);
  116333             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  116334             :     Rose::MemPool::snapshot(oss.str());
  116335             :     alloc_trace_cnt++;
  116336             : #endif
  116337             : 
  116338             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  116339             : 
  116340           0 :     ALLOC_MUTEX(SgOmpFlushStatement, unlock);
  116341             : }
  116342             : 
  116343             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  116344             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  116345             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  116346             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  116347             : // Also, note comment below from Robb (copied from the Common.code file).
  116348             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  116349             : //
  116350             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  116351             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  116352             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  116353             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  116354             : #if 0
  116355             : void SgOmpFlushStatement::operator delete(void* pointer) { SgOmpFlushStatement::operator delete (pointer, sizeof(SgOmpFlushStatement)); };
  116356             : #endif
  116357             : /* #line 116358 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  116358             : 
  116359             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  116360             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  116361             : // obviously imply C++.
  116362             : 
  116363             : // This implements the support within ROSE for memory pools.  Memory pools
  116364             : // support the most condensed usage of memory within the construction of
  116365             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  116366             : // by a new operator written for each class.
  116367             : 
  116368             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  116369             :     // User wants multi-thread support and POSIX threads are available.
  116370             : #   include <pthread.h>
  116371             :     static pthread_mutex_t SgOmpAllocateStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  116372             : #else
  116373             :      // Cause synchronization to be skipped.
  116374             : #    ifndef ALLOC_MUTEX
  116375             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  116376             : #    endif
  116377             : #    ifdef _REENTRANT
  116378             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  116379             : #       ifdef _MSC_VER
  116380             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  116381             : #       else
  116382             : #           warning "POSIX threads are not available; synchronization being skipped"
  116383             : #       endif
  116384             : #    endif
  116385             : #endif
  116386             : 
  116387             : #ifndef ROSE_ALLOC_TRACE
  116388             : #  define ROSE_ALLOC_TRACE 0
  116389             : #endif
  116390             : 
  116391             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  116392             : #define ROSE_ALLOC_TRACE_CNT
  116393             : #include "memory-pool-snapshot.h"
  116394             : unsigned long alloc_trace_cnt = 0;
  116395             : #endif
  116396             : 
  116397             : #if ROSE_ALLOC_TRACE
  116398             : const unsigned SgOmpAllocateStatement::pool_size = 5;
  116399             : #else
  116400             : const unsigned SgOmpAllocateStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  116401             : #endif
  116402             : 
  116403             : #ifndef ROSE_ALLOC_MEMSET
  116404             : #  define ROSE_ALLOC_MEMSET 0
  116405             : #endif
  116406             : 
  116407             : #ifndef ROSE_PEDANTIC_ALLOC
  116408             : #  define ROSE_PEDANTIC_ALLOC 0
  116409             : #endif
  116410             : 
  116411             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  116412             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  116413             : #endif
  116414             : 
  116415             : #if !defined(SGNODE__ALL_POOLS)
  116416             : #define SGNODE__ALL_POOLS
  116417             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  116418             : #endif
  116419             : 
  116420             : SgOmpAllocateStatement* SgOmpAllocateStatement::next_node = nullptr;
  116421             : std::vector<unsigned char*> SgOmpAllocateStatement::pools;
  116422             : 
  116423             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  116424             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  116425             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  116426             : // around this macro definition rather than each use).
  116427             : #ifndef ALLOC_MUTEX
  116428             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  116429             :         do {                                                                     \
  116430             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  116431             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  116432             :                 abort();                                                         \
  116433             :             }                                                                    \
  116434             :         } while (0);
  116435             : #endif
  116436             : 
  116437             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  116438             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  116439             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  116440             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  116441             : 
  116442             : /*! \brief New operator for SgOmpAllocateStatement.
  116443             : 
  116444             :    This new operator implements memory pools to provide most efficent 
  116445             :    use of the heap within construction of large ASTs.
  116446             : 
  116447             : \internal The new and delete operators use the lower level C malloc/free
  116448             :    function calls for performance and to make sure that mixing of malloc/free
  116449             :    and new/delete by the used can be caught more readily.  This may change
  116450             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  116451             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  116452             :    deallocate memory allocated using ROSE_MALLOC.
  116453             : */
  116454           1 : void *SgOmpAllocateStatement::operator new ( size_t Size )
  116455             : {
  116456             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  116457             :      * returning or throwing an exception. */
  116458           1 :     ALLOC_MUTEX(SgOmpAllocateStatement, lock);
  116459             : 
  116460             : #if ROSE_ALLOC_TRACE == 2
  116461             : //    printf("SgOmpAllocateStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgOmpAllocateStatement::next_node);
  116462             : #endif
  116463             : 
  116464             : #if USE_CPP_NEW_DELETE_OPERATORS
  116465             :     void *mem = ROSE_MALLOC(Size);
  116466             :     ALLOC_MUTEX(SgOmpAllocateStatement, unlock);
  116467             :     return mem;
  116468             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  116469             : #if ROSE_PEDANTIC_ALLOC
  116470             :     ROSE_ASSERT(Size == sizeof(SgOmpAllocateStatement));
  116471             : #else
  116472           1 :     if (Size != sizeof(SgOmpAllocateStatement)) {
  116473           0 :       void * object = ROSE_MALLOC(Size);
  116474           0 :       ALLOC_MUTEX(SgOmpAllocateStatement, unlock);
  116475             :       return object;
  116476             :     }
  116477             : #endif
  116478             : 
  116479           1 :     if (SgOmpAllocateStatement::next_node == nullptr) {
  116480           1 :         SgOmpAllocateStatement * alloc = (SgOmpAllocateStatement*) ROSE_MALLOC ( SgOmpAllocateStatement::pool_size * sizeof(SgOmpAllocateStatement) );
  116481           1 :         ROSE_ASSERT(alloc != nullptr);
  116482             : 
  116483             : #if ROSE_ALLOC_TRACE == 2
  116484             : //        printf("SgOmpAllocateStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgOmpAllocateStatement::pools.size(), alloc, alloc + SgOmpAllocateStatement::pool_size);
  116485             : #endif
  116486             : 
  116487             : #if ROSE_ALLOC_MEMSET == 1
  116488             : #elif ROSE_ALLOC_MEMSET == 2
  116489             :         memset(alloc, 0x00, SgOmpAllocateStatement::pool_size * sizeof(SgOmpAllocateStatement));
  116490             : #elif ROSE_ALLOC_MEMSET == 3
  116491             :         memset(alloc, 0xAA, SgOmpAllocateStatement::pool_size * sizeof(SgOmpAllocateStatement));
  116492             : #endif
  116493        2000 :         for (unsigned i=0; i < SgOmpAllocateStatement::pool_size-1; i++) {
  116494        1999 :           alloc[i].p_freepointer = &(alloc[i+1]);
  116495             :         }
  116496           1 :         alloc[SgOmpAllocateStatement::pool_size-1].p_freepointer = nullptr;
  116497             : 
  116498           1 :         SgOmpAllocateStatement::pools.push_back ( (unsigned char *) alloc );
  116499           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgOmpAllocateStatement::pool_size * sizeof(SgOmpAllocateStatement), V_SgOmpAllocateStatement ) );
  116500           1 :         SgOmpAllocateStatement::next_node = alloc;
  116501             :     }
  116502           1 :     ROSE_ASSERT(SgOmpAllocateStatement::next_node != nullptr);
  116503             : 
  116504           1 :     SgOmpAllocateStatement * object = SgOmpAllocateStatement::next_node;
  116505           1 :     SgOmpAllocateStatement::next_node = (SgOmpAllocateStatement*)(object->p_freepointer);
  116506             : 
  116507             : #if ROSE_ALLOC_TRACE == 2
  116508             :     printf("SgOmpAllocateStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpAllocateStatement::next_node);
  116509             : #endif
  116510             : 
  116511           1 :     SgNode * fp = object->p_freepointer;
  116512             : #if ROSE_ALLOC_MEMSET == 1
  116513             : #elif ROSE_ALLOC_MEMSET == 2
  116514             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpAllocateStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  116515             : #elif ROSE_ALLOC_MEMSET == 3
  116516             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgOmpAllocateStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  116517             : #endif
  116518           1 :     object->p_freepointer = fp;
  116519             : 
  116520             : #if ROSE_ALLOC_TRACE == 2
  116521             : //    printf("SgOmpAllocateStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpAllocateStatement::next_node);
  116522             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  116523             :     Rose::MemPool::snapshot(oss.str());
  116524             :     alloc_trace_cnt++;
  116525             : #endif
  116526             : 
  116527           1 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  116528             : 
  116529           1 :     ALLOC_MUTEX(SgOmpAllocateStatement, unlock);
  116530             : 
  116531             :     return object;
  116532             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  116533             : }
  116534             : 
  116535             : 
  116536             : 
  116537             : /*! \brief Delete operator for SgOmpAllocateStatement.
  116538             : 
  116539             :    This delete operator implements deallocation using memory pools to 
  116540             :    provide most efficent use of the heap within construction of large ASTs.
  116541             : 
  116542             : \internal The new and delete operators use the lower level C malloc/free
  116543             :    function calls for performance and to make sure that mixing of malloc/free
  116544             :    and new/delete by the used can be caught more readily.  This may change
  116545             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  116546             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  116547             :    deallocate memory allocated using ROSE_MALLOC.
  116548             : */
  116549           0 : void SgOmpAllocateStatement::operator delete(void *Pointer, size_t Size)
  116550             : {
  116551             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  116552             :      * or throwing an exception. */
  116553           0 :     ALLOC_MUTEX(SgOmpAllocateStatement, lock);
  116554             : 
  116555             : #if USE_CPP_NEW_DELETE_OPERATORS
  116556             :     ROSE_FREE(Pointer);
  116557             : #else
  116558             : #if ROSE_PEDANTIC_ALLOC
  116559             :     ROSE_ASSERT(Size == sizeof(SgOmpAllocateStatement));
  116560             : #else
  116561           0 :     if (Size != sizeof(SgOmpAllocateStatement)) {
  116562           0 :       ROSE_FREE(Pointer);
  116563           0 :       ALLOC_MUTEX(SgOmpAllocateStatement, unlock);
  116564             :       return;
  116565             :     }
  116566             : #endif
  116567             : 
  116568           0 :     SgOmpAllocateStatement * object = (SgOmpAllocateStatement*) Pointer;
  116569           0 :     ROSE_ASSERT(object != nullptr);
  116570             : 
  116571             : #if ROSE_ALLOC_TRACE == 2
  116572             : //  printf("SgOmpAllocateStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpAllocateStatement::next_node);
  116573             :     printf("SgOmpAllocateStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpAllocateStatement::next_node);
  116574             : #endif
  116575             : 
  116576             : #if ROSE_PEDANTIC_ALLOC
  116577             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  116578             : #endif
  116579             : 
  116580             : #if ROSE_ALLOC_MEMSET == 1
  116581             : #elif ROSE_ALLOC_MEMSET == 2
  116582             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpAllocateStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  116583             : #elif ROSE_ALLOC_MEMSET == 3
  116584             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgOmpAllocateStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  116585             : #endif
  116586             : 
  116587             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  116588             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  116589             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  116590             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  116591             : #else
  116592           0 :     object->p_freepointer = SgOmpAllocateStatement::next_node;
  116593           0 :     SgOmpAllocateStatement::next_node = object;
  116594             : #endif
  116595             : 
  116596             : #if ROSE_ALLOC_TRACE == 2
  116597             : //  printf("SgOmpAllocateStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpAllocateStatement::next_node);
  116598             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  116599             :     Rose::MemPool::snapshot(oss.str());
  116600             :     alloc_trace_cnt++;
  116601             : #endif
  116602             : 
  116603             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  116604             : 
  116605           0 :     ALLOC_MUTEX(SgOmpAllocateStatement, unlock);
  116606             : }
  116607             : 
  116608             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  116609             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  116610             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  116611             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  116612             : // Also, note comment below from Robb (copied from the Common.code file).
  116613             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  116614             : //
  116615             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  116616             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  116617             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  116618             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  116619             : #if 0
  116620             : void SgOmpAllocateStatement::operator delete(void* pointer) { SgOmpAllocateStatement::operator delete (pointer, sizeof(SgOmpAllocateStatement)); };
  116621             : #endif
  116622             : /* #line 116623 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  116623             : 
  116624             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  116625             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  116626             : // obviously imply C++.
  116627             : 
  116628             : // This implements the support within ROSE for memory pools.  Memory pools
  116629             : // support the most condensed usage of memory within the construction of
  116630             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  116631             : // by a new operator written for each class.
  116632             : 
  116633             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  116634             :     // User wants multi-thread support and POSIX threads are available.
  116635             : #   include <pthread.h>
  116636             :     static pthread_mutex_t SgOmpOrderedDependStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  116637             : #else
  116638             :      // Cause synchronization to be skipped.
  116639             : #    ifndef ALLOC_MUTEX
  116640             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  116641             : #    endif
  116642             : #    ifdef _REENTRANT
  116643             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  116644             : #       ifdef _MSC_VER
  116645             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  116646             : #       else
  116647             : #           warning "POSIX threads are not available; synchronization being skipped"
  116648             : #       endif
  116649             : #    endif
  116650             : #endif
  116651             : 
  116652             : #ifndef ROSE_ALLOC_TRACE
  116653             : #  define ROSE_ALLOC_TRACE 0
  116654             : #endif
  116655             : 
  116656             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  116657             : #define ROSE_ALLOC_TRACE_CNT
  116658             : #include "memory-pool-snapshot.h"
  116659             : unsigned long alloc_trace_cnt = 0;
  116660             : #endif
  116661             : 
  116662             : #if ROSE_ALLOC_TRACE
  116663             : const unsigned SgOmpOrderedDependStatement::pool_size = 5;
  116664             : #else
  116665             : const unsigned SgOmpOrderedDependStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  116666             : #endif
  116667             : 
  116668             : #ifndef ROSE_ALLOC_MEMSET
  116669             : #  define ROSE_ALLOC_MEMSET 0
  116670             : #endif
  116671             : 
  116672             : #ifndef ROSE_PEDANTIC_ALLOC
  116673             : #  define ROSE_PEDANTIC_ALLOC 0
  116674             : #endif
  116675             : 
  116676             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  116677             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  116678             : #endif
  116679             : 
  116680             : #if !defined(SGNODE__ALL_POOLS)
  116681             : #define SGNODE__ALL_POOLS
  116682             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  116683             : #endif
  116684             : 
  116685             : SgOmpOrderedDependStatement* SgOmpOrderedDependStatement::next_node = nullptr;
  116686             : std::vector<unsigned char*> SgOmpOrderedDependStatement::pools;
  116687             : 
  116688             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  116689             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  116690             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  116691             : // around this macro definition rather than each use).
  116692             : #ifndef ALLOC_MUTEX
  116693             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  116694             :         do {                                                                     \
  116695             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  116696             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  116697             :                 abort();                                                         \
  116698             :             }                                                                    \
  116699             :         } while (0);
  116700             : #endif
  116701             : 
  116702             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  116703             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  116704             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  116705             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  116706             : 
  116707             : /*! \brief New operator for SgOmpOrderedDependStatement.
  116708             : 
  116709             :    This new operator implements memory pools to provide most efficent 
  116710             :    use of the heap within construction of large ASTs.
  116711             : 
  116712             : \internal The new and delete operators use the lower level C malloc/free
  116713             :    function calls for performance and to make sure that mixing of malloc/free
  116714             :    and new/delete by the used can be caught more readily.  This may change
  116715             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  116716             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  116717             :    deallocate memory allocated using ROSE_MALLOC.
  116718             : */
  116719           2 : void *SgOmpOrderedDependStatement::operator new ( size_t Size )
  116720             : {
  116721             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  116722             :      * returning or throwing an exception. */
  116723           2 :     ALLOC_MUTEX(SgOmpOrderedDependStatement, lock);
  116724             : 
  116725             : #if ROSE_ALLOC_TRACE == 2
  116726             : //    printf("SgOmpOrderedDependStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgOmpOrderedDependStatement::next_node);
  116727             : #endif
  116728             : 
  116729             : #if USE_CPP_NEW_DELETE_OPERATORS
  116730             :     void *mem = ROSE_MALLOC(Size);
  116731             :     ALLOC_MUTEX(SgOmpOrderedDependStatement, unlock);
  116732             :     return mem;
  116733             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  116734             : #if ROSE_PEDANTIC_ALLOC
  116735             :     ROSE_ASSERT(Size == sizeof(SgOmpOrderedDependStatement));
  116736             : #else
  116737           2 :     if (Size != sizeof(SgOmpOrderedDependStatement)) {
  116738           0 :       void * object = ROSE_MALLOC(Size);
  116739           0 :       ALLOC_MUTEX(SgOmpOrderedDependStatement, unlock);
  116740             :       return object;
  116741             :     }
  116742             : #endif
  116743             : 
  116744           2 :     if (SgOmpOrderedDependStatement::next_node == nullptr) {
  116745           1 :         SgOmpOrderedDependStatement * alloc = (SgOmpOrderedDependStatement*) ROSE_MALLOC ( SgOmpOrderedDependStatement::pool_size * sizeof(SgOmpOrderedDependStatement) );
  116746           1 :         ROSE_ASSERT(alloc != nullptr);
  116747             : 
  116748             : #if ROSE_ALLOC_TRACE == 2
  116749             : //        printf("SgOmpOrderedDependStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgOmpOrderedDependStatement::pools.size(), alloc, alloc + SgOmpOrderedDependStatement::pool_size);
  116750             : #endif
  116751             : 
  116752             : #if ROSE_ALLOC_MEMSET == 1
  116753             : #elif ROSE_ALLOC_MEMSET == 2
  116754             :         memset(alloc, 0x00, SgOmpOrderedDependStatement::pool_size * sizeof(SgOmpOrderedDependStatement));
  116755             : #elif ROSE_ALLOC_MEMSET == 3
  116756             :         memset(alloc, 0xAA, SgOmpOrderedDependStatement::pool_size * sizeof(SgOmpOrderedDependStatement));
  116757             : #endif
  116758        2000 :         for (unsigned i=0; i < SgOmpOrderedDependStatement::pool_size-1; i++) {
  116759        1999 :           alloc[i].p_freepointer = &(alloc[i+1]);
  116760             :         }
  116761           1 :         alloc[SgOmpOrderedDependStatement::pool_size-1].p_freepointer = nullptr;
  116762             : 
  116763           1 :         SgOmpOrderedDependStatement::pools.push_back ( (unsigned char *) alloc );
  116764           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgOmpOrderedDependStatement::pool_size * sizeof(SgOmpOrderedDependStatement), V_SgOmpOrderedDependStatement ) );
  116765           1 :         SgOmpOrderedDependStatement::next_node = alloc;
  116766             :     }
  116767           2 :     ROSE_ASSERT(SgOmpOrderedDependStatement::next_node != nullptr);
  116768             : 
  116769           2 :     SgOmpOrderedDependStatement * object = SgOmpOrderedDependStatement::next_node;
  116770           2 :     SgOmpOrderedDependStatement::next_node = (SgOmpOrderedDependStatement*)(object->p_freepointer);
  116771             : 
  116772             : #if ROSE_ALLOC_TRACE == 2
  116773             :     printf("SgOmpOrderedDependStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpOrderedDependStatement::next_node);
  116774             : #endif
  116775             : 
  116776           2 :     SgNode * fp = object->p_freepointer;
  116777             : #if ROSE_ALLOC_MEMSET == 1
  116778             : #elif ROSE_ALLOC_MEMSET == 2
  116779             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpOrderedDependStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  116780             : #elif ROSE_ALLOC_MEMSET == 3
  116781             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgOmpOrderedDependStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  116782             : #endif
  116783           2 :     object->p_freepointer = fp;
  116784             : 
  116785             : #if ROSE_ALLOC_TRACE == 2
  116786             : //    printf("SgOmpOrderedDependStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpOrderedDependStatement::next_node);
  116787             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  116788             :     Rose::MemPool::snapshot(oss.str());
  116789             :     alloc_trace_cnt++;
  116790             : #endif
  116791             : 
  116792           2 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  116793             : 
  116794           2 :     ALLOC_MUTEX(SgOmpOrderedDependStatement, unlock);
  116795             : 
  116796             :     return object;
  116797             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  116798             : }
  116799             : 
  116800             : 
  116801             : 
  116802             : /*! \brief Delete operator for SgOmpOrderedDependStatement.
  116803             : 
  116804             :    This delete operator implements deallocation using memory pools to 
  116805             :    provide most efficent use of the heap within construction of large ASTs.
  116806             : 
  116807             : \internal The new and delete operators use the lower level C malloc/free
  116808             :    function calls for performance and to make sure that mixing of malloc/free
  116809             :    and new/delete by the used can be caught more readily.  This may change
  116810             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  116811             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  116812             :    deallocate memory allocated using ROSE_MALLOC.
  116813             : */
  116814           0 : void SgOmpOrderedDependStatement::operator delete(void *Pointer, size_t Size)
  116815             : {
  116816             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  116817             :      * or throwing an exception. */
  116818           0 :     ALLOC_MUTEX(SgOmpOrderedDependStatement, lock);
  116819             : 
  116820             : #if USE_CPP_NEW_DELETE_OPERATORS
  116821             :     ROSE_FREE(Pointer);
  116822             : #else
  116823             : #if ROSE_PEDANTIC_ALLOC
  116824             :     ROSE_ASSERT(Size == sizeof(SgOmpOrderedDependStatement));
  116825             : #else
  116826           0 :     if (Size != sizeof(SgOmpOrderedDependStatement)) {
  116827           0 :       ROSE_FREE(Pointer);
  116828           0 :       ALLOC_MUTEX(SgOmpOrderedDependStatement, unlock);
  116829             :       return;
  116830             :     }
  116831             : #endif
  116832             : 
  116833           0 :     SgOmpOrderedDependStatement * object = (SgOmpOrderedDependStatement*) Pointer;
  116834           0 :     ROSE_ASSERT(object != nullptr);
  116835             : 
  116836             : #if ROSE_ALLOC_TRACE == 2
  116837             : //  printf("SgOmpOrderedDependStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpOrderedDependStatement::next_node);
  116838             :     printf("SgOmpOrderedDependStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpOrderedDependStatement::next_node);
  116839             : #endif
  116840             : 
  116841             : #if ROSE_PEDANTIC_ALLOC
  116842             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  116843             : #endif
  116844             : 
  116845             : #if ROSE_ALLOC_MEMSET == 1
  116846             : #elif ROSE_ALLOC_MEMSET == 2
  116847             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpOrderedDependStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  116848             : #elif ROSE_ALLOC_MEMSET == 3
  116849             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgOmpOrderedDependStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  116850             : #endif
  116851             : 
  116852             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  116853             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  116854             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  116855             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  116856             : #else
  116857           0 :     object->p_freepointer = SgOmpOrderedDependStatement::next_node;
  116858           0 :     SgOmpOrderedDependStatement::next_node = object;
  116859             : #endif
  116860             : 
  116861             : #if ROSE_ALLOC_TRACE == 2
  116862             : //  printf("SgOmpOrderedDependStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpOrderedDependStatement::next_node);
  116863             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  116864             :     Rose::MemPool::snapshot(oss.str());
  116865             :     alloc_trace_cnt++;
  116866             : #endif
  116867             : 
  116868             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  116869             : 
  116870           0 :     ALLOC_MUTEX(SgOmpOrderedDependStatement, unlock);
  116871             : }
  116872             : 
  116873             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  116874             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  116875             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  116876             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  116877             : // Also, note comment below from Robb (copied from the Common.code file).
  116878             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  116879             : //
  116880             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  116881             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  116882             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  116883             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  116884             : #if 0
  116885             : void SgOmpOrderedDependStatement::operator delete(void* pointer) { SgOmpOrderedDependStatement::operator delete (pointer, sizeof(SgOmpOrderedDependStatement)); };
  116886             : #endif
  116887             : /* #line 116888 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  116888             : 
  116889             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  116890             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  116891             : // obviously imply C++.
  116892             : 
  116893             : // This implements the support within ROSE for memory pools.  Memory pools
  116894             : // support the most condensed usage of memory within the construction of
  116895             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  116896             : // by a new operator written for each class.
  116897             : 
  116898             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  116899             :     // User wants multi-thread support and POSIX threads are available.
  116900             : #   include <pthread.h>
  116901             :     static pthread_mutex_t SgUpirSyncStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  116902             : #else
  116903             :      // Cause synchronization to be skipped.
  116904             : #    ifndef ALLOC_MUTEX
  116905             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  116906             : #    endif
  116907             : #    ifdef _REENTRANT
  116908             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  116909             : #       ifdef _MSC_VER
  116910             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  116911             : #       else
  116912             : #           warning "POSIX threads are not available; synchronization being skipped"
  116913             : #       endif
  116914             : #    endif
  116915             : #endif
  116916             : 
  116917             : #ifndef ROSE_ALLOC_TRACE
  116918             : #  define ROSE_ALLOC_TRACE 0
  116919             : #endif
  116920             : 
  116921             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  116922             : #define ROSE_ALLOC_TRACE_CNT
  116923             : #include "memory-pool-snapshot.h"
  116924             : unsigned long alloc_trace_cnt = 0;
  116925             : #endif
  116926             : 
  116927             : #if ROSE_ALLOC_TRACE
  116928             : const unsigned SgUpirSyncStatement::pool_size = 5;
  116929             : #else
  116930             : const unsigned SgUpirSyncStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  116931             : #endif
  116932             : 
  116933             : #ifndef ROSE_ALLOC_MEMSET
  116934             : #  define ROSE_ALLOC_MEMSET 0
  116935             : #endif
  116936             : 
  116937             : #ifndef ROSE_PEDANTIC_ALLOC
  116938             : #  define ROSE_PEDANTIC_ALLOC 0
  116939             : #endif
  116940             : 
  116941             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  116942             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  116943             : #endif
  116944             : 
  116945             : #if !defined(SGNODE__ALL_POOLS)
  116946             : #define SGNODE__ALL_POOLS
  116947             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  116948             : #endif
  116949             : 
  116950             : SgUpirSyncStatement* SgUpirSyncStatement::next_node = nullptr;
  116951             : std::vector<unsigned char*> SgUpirSyncStatement::pools;
  116952             : 
  116953             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  116954             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  116955             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  116956             : // around this macro definition rather than each use).
  116957             : #ifndef ALLOC_MUTEX
  116958             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  116959             :         do {                                                                     \
  116960             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  116961             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  116962             :                 abort();                                                         \
  116963             :             }                                                                    \
  116964             :         } while (0);
  116965             : #endif
  116966             : 
  116967             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  116968             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  116969             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  116970             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  116971             : 
  116972             : /*! \brief New operator for SgUpirSyncStatement.
  116973             : 
  116974             :    This new operator implements memory pools to provide most efficent 
  116975             :    use of the heap within construction of large ASTs.
  116976             : 
  116977             : \internal The new and delete operators use the lower level C malloc/free
  116978             :    function calls for performance and to make sure that mixing of malloc/free
  116979             :    and new/delete by the used can be caught more readily.  This may change
  116980             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  116981             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  116982             :    deallocate memory allocated using ROSE_MALLOC.
  116983             : */
  116984           0 : void *SgUpirSyncStatement::operator new ( size_t Size )
  116985             : {
  116986             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  116987             :      * returning or throwing an exception. */
  116988           0 :     ALLOC_MUTEX(SgUpirSyncStatement, lock);
  116989             : 
  116990             : #if ROSE_ALLOC_TRACE == 2
  116991             : //    printf("SgUpirSyncStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgUpirSyncStatement::next_node);
  116992             : #endif
  116993             : 
  116994             : #if USE_CPP_NEW_DELETE_OPERATORS
  116995             :     void *mem = ROSE_MALLOC(Size);
  116996             :     ALLOC_MUTEX(SgUpirSyncStatement, unlock);
  116997             :     return mem;
  116998             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  116999             : #if ROSE_PEDANTIC_ALLOC
  117000             :     ROSE_ASSERT(Size == sizeof(SgUpirSyncStatement));
  117001             : #else
  117002           0 :     if (Size != sizeof(SgUpirSyncStatement)) {
  117003           0 :       void * object = ROSE_MALLOC(Size);
  117004           0 :       ALLOC_MUTEX(SgUpirSyncStatement, unlock);
  117005             :       return object;
  117006             :     }
  117007             : #endif
  117008             : 
  117009           0 :     if (SgUpirSyncStatement::next_node == nullptr) {
  117010           0 :         SgUpirSyncStatement * alloc = (SgUpirSyncStatement*) ROSE_MALLOC ( SgUpirSyncStatement::pool_size * sizeof(SgUpirSyncStatement) );
  117011           0 :         ROSE_ASSERT(alloc != nullptr);
  117012             : 
  117013             : #if ROSE_ALLOC_TRACE == 2
  117014             : //        printf("SgUpirSyncStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgUpirSyncStatement::pools.size(), alloc, alloc + SgUpirSyncStatement::pool_size);
  117015             : #endif
  117016             : 
  117017             : #if ROSE_ALLOC_MEMSET == 1
  117018             : #elif ROSE_ALLOC_MEMSET == 2
  117019             :         memset(alloc, 0x00, SgUpirSyncStatement::pool_size * sizeof(SgUpirSyncStatement));
  117020             : #elif ROSE_ALLOC_MEMSET == 3
  117021             :         memset(alloc, 0xAA, SgUpirSyncStatement::pool_size * sizeof(SgUpirSyncStatement));
  117022             : #endif
  117023           0 :         for (unsigned i=0; i < SgUpirSyncStatement::pool_size-1; i++) {
  117024           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
  117025             :         }
  117026           0 :         alloc[SgUpirSyncStatement::pool_size-1].p_freepointer = nullptr;
  117027             : 
  117028           0 :         SgUpirSyncStatement::pools.push_back ( (unsigned char *) alloc );
  117029           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgUpirSyncStatement::pool_size * sizeof(SgUpirSyncStatement), V_SgUpirSyncStatement ) );
  117030           0 :         SgUpirSyncStatement::next_node = alloc;
  117031             :     }
  117032           0 :     ROSE_ASSERT(SgUpirSyncStatement::next_node != nullptr);
  117033             : 
  117034           0 :     SgUpirSyncStatement * object = SgUpirSyncStatement::next_node;
  117035           0 :     SgUpirSyncStatement::next_node = (SgUpirSyncStatement*)(object->p_freepointer);
  117036             : 
  117037             : #if ROSE_ALLOC_TRACE == 2
  117038             :     printf("SgUpirSyncStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUpirSyncStatement::next_node);
  117039             : #endif
  117040             : 
  117041           0 :     SgNode * fp = object->p_freepointer;
  117042             : #if ROSE_ALLOC_MEMSET == 1
  117043             : #elif ROSE_ALLOC_MEMSET == 2
  117044             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgUpirSyncStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  117045             : #elif ROSE_ALLOC_MEMSET == 3
  117046             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgUpirSyncStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  117047             : #endif
  117048           0 :     object->p_freepointer = fp;
  117049             : 
  117050             : #if ROSE_ALLOC_TRACE == 2
  117051             : //    printf("SgUpirSyncStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUpirSyncStatement::next_node);
  117052             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  117053             :     Rose::MemPool::snapshot(oss.str());
  117054             :     alloc_trace_cnt++;
  117055             : #endif
  117056             : 
  117057           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  117058             : 
  117059           0 :     ALLOC_MUTEX(SgUpirSyncStatement, unlock);
  117060             : 
  117061             :     return object;
  117062             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  117063             : }
  117064             : 
  117065             : 
  117066             : 
  117067             : /*! \brief Delete operator for SgUpirSyncStatement.
  117068             : 
  117069             :    This delete operator implements deallocation using memory pools to 
  117070             :    provide most efficent use of the heap within construction of large ASTs.
  117071             : 
  117072             : \internal The new and delete operators use the lower level C malloc/free
  117073             :    function calls for performance and to make sure that mixing of malloc/free
  117074             :    and new/delete by the used can be caught more readily.  This may change
  117075             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  117076             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  117077             :    deallocate memory allocated using ROSE_MALLOC.
  117078             : */
  117079           0 : void SgUpirSyncStatement::operator delete(void *Pointer, size_t Size)
  117080             : {
  117081             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  117082             :      * or throwing an exception. */
  117083           0 :     ALLOC_MUTEX(SgUpirSyncStatement, lock);
  117084             : 
  117085             : #if USE_CPP_NEW_DELETE_OPERATORS
  117086             :     ROSE_FREE(Pointer);
  117087             : #else
  117088             : #if ROSE_PEDANTIC_ALLOC
  117089             :     ROSE_ASSERT(Size == sizeof(SgUpirSyncStatement));
  117090             : #else
  117091           0 :     if (Size != sizeof(SgUpirSyncStatement)) {
  117092           0 :       ROSE_FREE(Pointer);
  117093           0 :       ALLOC_MUTEX(SgUpirSyncStatement, unlock);
  117094             :       return;
  117095             :     }
  117096             : #endif
  117097             : 
  117098           0 :     SgUpirSyncStatement * object = (SgUpirSyncStatement*) Pointer;
  117099           0 :     ROSE_ASSERT(object != nullptr);
  117100             : 
  117101             : #if ROSE_ALLOC_TRACE == 2
  117102             : //  printf("SgUpirSyncStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUpirSyncStatement::next_node);
  117103             :     printf("SgUpirSyncStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUpirSyncStatement::next_node);
  117104             : #endif
  117105             : 
  117106             : #if ROSE_PEDANTIC_ALLOC
  117107             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  117108             : #endif
  117109             : 
  117110             : #if ROSE_ALLOC_MEMSET == 1
  117111             : #elif ROSE_ALLOC_MEMSET == 2
  117112             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgUpirSyncStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  117113             : #elif ROSE_ALLOC_MEMSET == 3
  117114             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgUpirSyncStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  117115             : #endif
  117116             : 
  117117             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  117118             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  117119             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  117120             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  117121             : #else
  117122           0 :     object->p_freepointer = SgUpirSyncStatement::next_node;
  117123           0 :     SgUpirSyncStatement::next_node = object;
  117124             : #endif
  117125             : 
  117126             : #if ROSE_ALLOC_TRACE == 2
  117127             : //  printf("SgUpirSyncStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUpirSyncStatement::next_node);
  117128             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  117129             :     Rose::MemPool::snapshot(oss.str());
  117130             :     alloc_trace_cnt++;
  117131             : #endif
  117132             : 
  117133             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  117134             : 
  117135           0 :     ALLOC_MUTEX(SgUpirSyncStatement, unlock);
  117136             : }
  117137             : 
  117138             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  117139             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  117140             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  117141             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  117142             : // Also, note comment below from Robb (copied from the Common.code file).
  117143             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  117144             : //
  117145             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  117146             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  117147             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  117148             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  117149             : #if 0
  117150             : void SgUpirSyncStatement::operator delete(void* pointer) { SgUpirSyncStatement::operator delete (pointer, sizeof(SgUpirSyncStatement)); };
  117151             : #endif
  117152             : /* #line 117153 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  117153             : 
  117154             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  117155             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  117156             : // obviously imply C++.
  117157             : 
  117158             : // This implements the support within ROSE for memory pools.  Memory pools
  117159             : // support the most condensed usage of memory within the construction of
  117160             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  117161             : // by a new operator written for each class.
  117162             : 
  117163             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  117164             :     // User wants multi-thread support and POSIX threads are available.
  117165             : #   include <pthread.h>
  117166             :     static pthread_mutex_t SgUpirLoopParallelStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  117167             : #else
  117168             :      // Cause synchronization to be skipped.
  117169             : #    ifndef ALLOC_MUTEX
  117170             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  117171             : #    endif
  117172             : #    ifdef _REENTRANT
  117173             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  117174             : #       ifdef _MSC_VER
  117175             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  117176             : #       else
  117177             : #           warning "POSIX threads are not available; synchronization being skipped"
  117178             : #       endif
  117179             : #    endif
  117180             : #endif
  117181             : 
  117182             : #ifndef ROSE_ALLOC_TRACE
  117183             : #  define ROSE_ALLOC_TRACE 0
  117184             : #endif
  117185             : 
  117186             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  117187             : #define ROSE_ALLOC_TRACE_CNT
  117188             : #include "memory-pool-snapshot.h"
  117189             : unsigned long alloc_trace_cnt = 0;
  117190             : #endif
  117191             : 
  117192             : #if ROSE_ALLOC_TRACE
  117193             : const unsigned SgUpirLoopParallelStatement::pool_size = 5;
  117194             : #else
  117195             : const unsigned SgUpirLoopParallelStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  117196             : #endif
  117197             : 
  117198             : #ifndef ROSE_ALLOC_MEMSET
  117199             : #  define ROSE_ALLOC_MEMSET 0
  117200             : #endif
  117201             : 
  117202             : #ifndef ROSE_PEDANTIC_ALLOC
  117203             : #  define ROSE_PEDANTIC_ALLOC 0
  117204             : #endif
  117205             : 
  117206             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  117207             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  117208             : #endif
  117209             : 
  117210             : #if !defined(SGNODE__ALL_POOLS)
  117211             : #define SGNODE__ALL_POOLS
  117212             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  117213             : #endif
  117214             : 
  117215             : SgUpirLoopParallelStatement* SgUpirLoopParallelStatement::next_node = nullptr;
  117216             : std::vector<unsigned char*> SgUpirLoopParallelStatement::pools;
  117217             : 
  117218             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  117219             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  117220             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  117221             : // around this macro definition rather than each use).
  117222             : #ifndef ALLOC_MUTEX
  117223             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  117224             :         do {                                                                     \
  117225             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  117226             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  117227             :                 abort();                                                         \
  117228             :             }                                                                    \
  117229             :         } while (0);
  117230             : #endif
  117231             : 
  117232             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  117233             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  117234             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  117235             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  117236             : 
  117237             : /*! \brief New operator for SgUpirLoopParallelStatement.
  117238             : 
  117239             :    This new operator implements memory pools to provide most efficent 
  117240             :    use of the heap within construction of large ASTs.
  117241             : 
  117242             : \internal The new and delete operators use the lower level C malloc/free
  117243             :    function calls for performance and to make sure that mixing of malloc/free
  117244             :    and new/delete by the used can be caught more readily.  This may change
  117245             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  117246             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  117247             :    deallocate memory allocated using ROSE_MALLOC.
  117248             : */
  117249         199 : void *SgUpirLoopParallelStatement::operator new ( size_t Size )
  117250             : {
  117251             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  117252             :      * returning or throwing an exception. */
  117253         199 :     ALLOC_MUTEX(SgUpirLoopParallelStatement, lock);
  117254             : 
  117255             : #if ROSE_ALLOC_TRACE == 2
  117256             : //    printf("SgUpirLoopParallelStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgUpirLoopParallelStatement::next_node);
  117257             : #endif
  117258             : 
  117259             : #if USE_CPP_NEW_DELETE_OPERATORS
  117260             :     void *mem = ROSE_MALLOC(Size);
  117261             :     ALLOC_MUTEX(SgUpirLoopParallelStatement, unlock);
  117262             :     return mem;
  117263             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  117264             : #if ROSE_PEDANTIC_ALLOC
  117265             :     ROSE_ASSERT(Size == sizeof(SgUpirLoopParallelStatement));
  117266             : #else
  117267         199 :     if (Size != sizeof(SgUpirLoopParallelStatement)) {
  117268           0 :       void * object = ROSE_MALLOC(Size);
  117269           0 :       ALLOC_MUTEX(SgUpirLoopParallelStatement, unlock);
  117270             :       return object;
  117271             :     }
  117272             : #endif
  117273             : 
  117274         199 :     if (SgUpirLoopParallelStatement::next_node == nullptr) {
  117275          91 :         SgUpirLoopParallelStatement * alloc = (SgUpirLoopParallelStatement*) ROSE_MALLOC ( SgUpirLoopParallelStatement::pool_size * sizeof(SgUpirLoopParallelStatement) );
  117276          91 :         ROSE_ASSERT(alloc != nullptr);
  117277             : 
  117278             : #if ROSE_ALLOC_TRACE == 2
  117279             : //        printf("SgUpirLoopParallelStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgUpirLoopParallelStatement::pools.size(), alloc, alloc + SgUpirLoopParallelStatement::pool_size);
  117280             : #endif
  117281             : 
  117282             : #if ROSE_ALLOC_MEMSET == 1
  117283             : #elif ROSE_ALLOC_MEMSET == 2
  117284             :         memset(alloc, 0x00, SgUpirLoopParallelStatement::pool_size * sizeof(SgUpirLoopParallelStatement));
  117285             : #elif ROSE_ALLOC_MEMSET == 3
  117286             :         memset(alloc, 0xAA, SgUpirLoopParallelStatement::pool_size * sizeof(SgUpirLoopParallelStatement));
  117287             : #endif
  117288      182000 :         for (unsigned i=0; i < SgUpirLoopParallelStatement::pool_size-1; i++) {
  117289      181909 :           alloc[i].p_freepointer = &(alloc[i+1]);
  117290             :         }
  117291          91 :         alloc[SgUpirLoopParallelStatement::pool_size-1].p_freepointer = nullptr;
  117292             : 
  117293          91 :         SgUpirLoopParallelStatement::pools.push_back ( (unsigned char *) alloc );
  117294          91 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgUpirLoopParallelStatement::pool_size * sizeof(SgUpirLoopParallelStatement), V_SgUpirLoopParallelStatement ) );
  117295          91 :         SgUpirLoopParallelStatement::next_node = alloc;
  117296             :     }
  117297         199 :     ROSE_ASSERT(SgUpirLoopParallelStatement::next_node != nullptr);
  117298             : 
  117299         199 :     SgUpirLoopParallelStatement * object = SgUpirLoopParallelStatement::next_node;
  117300         199 :     SgUpirLoopParallelStatement::next_node = (SgUpirLoopParallelStatement*)(object->p_freepointer);
  117301             : 
  117302             : #if ROSE_ALLOC_TRACE == 2
  117303             :     printf("SgUpirLoopParallelStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUpirLoopParallelStatement::next_node);
  117304             : #endif
  117305             : 
  117306         199 :     SgNode * fp = object->p_freepointer;
  117307             : #if ROSE_ALLOC_MEMSET == 1
  117308             : #elif ROSE_ALLOC_MEMSET == 2
  117309             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgUpirLoopParallelStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  117310             : #elif ROSE_ALLOC_MEMSET == 3
  117311             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgUpirLoopParallelStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  117312             : #endif
  117313         199 :     object->p_freepointer = fp;
  117314             : 
  117315             : #if ROSE_ALLOC_TRACE == 2
  117316             : //    printf("SgUpirLoopParallelStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUpirLoopParallelStatement::next_node);
  117317             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  117318             :     Rose::MemPool::snapshot(oss.str());
  117319             :     alloc_trace_cnt++;
  117320             : #endif
  117321             : 
  117322         199 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  117323             : 
  117324         199 :     ALLOC_MUTEX(SgUpirLoopParallelStatement, unlock);
  117325             : 
  117326             :     return object;
  117327             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  117328             : }
  117329             : 
  117330             : 
  117331             : 
  117332             : /*! \brief Delete operator for SgUpirLoopParallelStatement.
  117333             : 
  117334             :    This delete operator implements deallocation using memory pools to 
  117335             :    provide most efficent use of the heap within construction of large ASTs.
  117336             : 
  117337             : \internal The new and delete operators use the lower level C malloc/free
  117338             :    function calls for performance and to make sure that mixing of malloc/free
  117339             :    and new/delete by the used can be caught more readily.  This may change
  117340             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  117341             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  117342             :    deallocate memory allocated using ROSE_MALLOC.
  117343             : */
  117344           0 : void SgUpirLoopParallelStatement::operator delete(void *Pointer, size_t Size)
  117345             : {
  117346             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  117347             :      * or throwing an exception. */
  117348           0 :     ALLOC_MUTEX(SgUpirLoopParallelStatement, lock);
  117349             : 
  117350             : #if USE_CPP_NEW_DELETE_OPERATORS
  117351             :     ROSE_FREE(Pointer);
  117352             : #else
  117353             : #if ROSE_PEDANTIC_ALLOC
  117354             :     ROSE_ASSERT(Size == sizeof(SgUpirLoopParallelStatement));
  117355             : #else
  117356           0 :     if (Size != sizeof(SgUpirLoopParallelStatement)) {
  117357           0 :       ROSE_FREE(Pointer);
  117358           0 :       ALLOC_MUTEX(SgUpirLoopParallelStatement, unlock);
  117359             :       return;
  117360             :     }
  117361             : #endif
  117362             : 
  117363           0 :     SgUpirLoopParallelStatement * object = (SgUpirLoopParallelStatement*) Pointer;
  117364           0 :     ROSE_ASSERT(object != nullptr);
  117365             : 
  117366             : #if ROSE_ALLOC_TRACE == 2
  117367             : //  printf("SgUpirLoopParallelStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUpirLoopParallelStatement::next_node);
  117368             :     printf("SgUpirLoopParallelStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUpirLoopParallelStatement::next_node);
  117369             : #endif
  117370             : 
  117371             : #if ROSE_PEDANTIC_ALLOC
  117372             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  117373             : #endif
  117374             : 
  117375             : #if ROSE_ALLOC_MEMSET == 1
  117376             : #elif ROSE_ALLOC_MEMSET == 2
  117377             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgUpirLoopParallelStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  117378             : #elif ROSE_ALLOC_MEMSET == 3
  117379             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgUpirLoopParallelStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  117380             : #endif
  117381             : 
  117382             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  117383             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  117384             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  117385             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  117386             : #else
  117387           0 :     object->p_freepointer = SgUpirLoopParallelStatement::next_node;
  117388           0 :     SgUpirLoopParallelStatement::next_node = object;
  117389             : #endif
  117390             : 
  117391             : #if ROSE_ALLOC_TRACE == 2
  117392             : //  printf("SgUpirLoopParallelStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUpirLoopParallelStatement::next_node);
  117393             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  117394             :     Rose::MemPool::snapshot(oss.str());
  117395             :     alloc_trace_cnt++;
  117396             : #endif
  117397             : 
  117398             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  117399             : 
  117400           0 :     ALLOC_MUTEX(SgUpirLoopParallelStatement, unlock);
  117401             : }
  117402             : 
  117403             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  117404             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  117405             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  117406             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  117407             : // Also, note comment below from Robb (copied from the Common.code file).
  117408             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  117409             : //
  117410             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  117411             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  117412             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  117413             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  117414             : #if 0
  117415             : void SgUpirLoopParallelStatement::operator delete(void* pointer) { SgUpirLoopParallelStatement::operator delete (pointer, sizeof(SgUpirLoopParallelStatement)); };
  117416             : #endif
  117417             : /* #line 117418 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  117418             : 
  117419             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  117420             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  117421             : // obviously imply C++.
  117422             : 
  117423             : // This implements the support within ROSE for memory pools.  Memory pools
  117424             : // support the most condensed usage of memory within the construction of
  117425             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  117426             : // by a new operator written for each class.
  117427             : 
  117428             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  117429             :     // User wants multi-thread support and POSIX threads are available.
  117430             : #   include <pthread.h>
  117431             :     static pthread_mutex_t SgUpirWorksharingStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  117432             : #else
  117433             :      // Cause synchronization to be skipped.
  117434             : #    ifndef ALLOC_MUTEX
  117435             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  117436             : #    endif
  117437             : #    ifdef _REENTRANT
  117438             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  117439             : #       ifdef _MSC_VER
  117440             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  117441             : #       else
  117442             : #           warning "POSIX threads are not available; synchronization being skipped"
  117443             : #       endif
  117444             : #    endif
  117445             : #endif
  117446             : 
  117447             : #ifndef ROSE_ALLOC_TRACE
  117448             : #  define ROSE_ALLOC_TRACE 0
  117449             : #endif
  117450             : 
  117451             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  117452             : #define ROSE_ALLOC_TRACE_CNT
  117453             : #include "memory-pool-snapshot.h"
  117454             : unsigned long alloc_trace_cnt = 0;
  117455             : #endif
  117456             : 
  117457             : #if ROSE_ALLOC_TRACE
  117458             : const unsigned SgUpirWorksharingStatement::pool_size = 5;
  117459             : #else
  117460             : const unsigned SgUpirWorksharingStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  117461             : #endif
  117462             : 
  117463             : #ifndef ROSE_ALLOC_MEMSET
  117464             : #  define ROSE_ALLOC_MEMSET 0
  117465             : #endif
  117466             : 
  117467             : #ifndef ROSE_PEDANTIC_ALLOC
  117468             : #  define ROSE_PEDANTIC_ALLOC 0
  117469             : #endif
  117470             : 
  117471             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  117472             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  117473             : #endif
  117474             : 
  117475             : #if !defined(SGNODE__ALL_POOLS)
  117476             : #define SGNODE__ALL_POOLS
  117477             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  117478             : #endif
  117479             : 
  117480             : SgUpirWorksharingStatement* SgUpirWorksharingStatement::next_node = nullptr;
  117481             : std::vector<unsigned char*> SgUpirWorksharingStatement::pools;
  117482             : 
  117483             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  117484             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  117485             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  117486             : // around this macro definition rather than each use).
  117487             : #ifndef ALLOC_MUTEX
  117488             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  117489             :         do {                                                                     \
  117490             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  117491             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  117492             :                 abort();                                                         \
  117493             :             }                                                                    \
  117494             :         } while (0);
  117495             : #endif
  117496             : 
  117497             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  117498             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  117499             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  117500             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  117501             : 
  117502             : /*! \brief New operator for SgUpirWorksharingStatement.
  117503             : 
  117504             :    This new operator implements memory pools to provide most efficent 
  117505             :    use of the heap within construction of large ASTs.
  117506             : 
  117507             : \internal The new and delete operators use the lower level C malloc/free
  117508             :    function calls for performance and to make sure that mixing of malloc/free
  117509             :    and new/delete by the used can be caught more readily.  This may change
  117510             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  117511             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  117512             :    deallocate memory allocated using ROSE_MALLOC.
  117513             : */
  117514         185 : void *SgUpirWorksharingStatement::operator new ( size_t Size )
  117515             : {
  117516             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  117517             :      * returning or throwing an exception. */
  117518         185 :     ALLOC_MUTEX(SgUpirWorksharingStatement, lock);
  117519             : 
  117520             : #if ROSE_ALLOC_TRACE == 2
  117521             : //    printf("SgUpirWorksharingStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgUpirWorksharingStatement::next_node);
  117522             : #endif
  117523             : 
  117524             : #if USE_CPP_NEW_DELETE_OPERATORS
  117525             :     void *mem = ROSE_MALLOC(Size);
  117526             :     ALLOC_MUTEX(SgUpirWorksharingStatement, unlock);
  117527             :     return mem;
  117528             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  117529             : #if ROSE_PEDANTIC_ALLOC
  117530             :     ROSE_ASSERT(Size == sizeof(SgUpirWorksharingStatement));
  117531             : #else
  117532         185 :     if (Size != sizeof(SgUpirWorksharingStatement)) {
  117533           0 :       void * object = ROSE_MALLOC(Size);
  117534           0 :       ALLOC_MUTEX(SgUpirWorksharingStatement, unlock);
  117535             :       return object;
  117536             :     }
  117537             : #endif
  117538             : 
  117539         185 :     if (SgUpirWorksharingStatement::next_node == nullptr) {
  117540          86 :         SgUpirWorksharingStatement * alloc = (SgUpirWorksharingStatement*) ROSE_MALLOC ( SgUpirWorksharingStatement::pool_size * sizeof(SgUpirWorksharingStatement) );
  117541          86 :         ROSE_ASSERT(alloc != nullptr);
  117542             : 
  117543             : #if ROSE_ALLOC_TRACE == 2
  117544             : //        printf("SgUpirWorksharingStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgUpirWorksharingStatement::pools.size(), alloc, alloc + SgUpirWorksharingStatement::pool_size);
  117545             : #endif
  117546             : 
  117547             : #if ROSE_ALLOC_MEMSET == 1
  117548             : #elif ROSE_ALLOC_MEMSET == 2
  117549             :         memset(alloc, 0x00, SgUpirWorksharingStatement::pool_size * sizeof(SgUpirWorksharingStatement));
  117550             : #elif ROSE_ALLOC_MEMSET == 3
  117551             :         memset(alloc, 0xAA, SgUpirWorksharingStatement::pool_size * sizeof(SgUpirWorksharingStatement));
  117552             : #endif
  117553      172000 :         for (unsigned i=0; i < SgUpirWorksharingStatement::pool_size-1; i++) {
  117554      171914 :           alloc[i].p_freepointer = &(alloc[i+1]);
  117555             :         }
  117556          86 :         alloc[SgUpirWorksharingStatement::pool_size-1].p_freepointer = nullptr;
  117557             : 
  117558          86 :         SgUpirWorksharingStatement::pools.push_back ( (unsigned char *) alloc );
  117559          86 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgUpirWorksharingStatement::pool_size * sizeof(SgUpirWorksharingStatement), V_SgUpirWorksharingStatement ) );
  117560          86 :         SgUpirWorksharingStatement::next_node = alloc;
  117561             :     }
  117562         185 :     ROSE_ASSERT(SgUpirWorksharingStatement::next_node != nullptr);
  117563             : 
  117564         185 :     SgUpirWorksharingStatement * object = SgUpirWorksharingStatement::next_node;
  117565         185 :     SgUpirWorksharingStatement::next_node = (SgUpirWorksharingStatement*)(object->p_freepointer);
  117566             : 
  117567             : #if ROSE_ALLOC_TRACE == 2
  117568             :     printf("SgUpirWorksharingStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUpirWorksharingStatement::next_node);
  117569             : #endif
  117570             : 
  117571         185 :     SgNode * fp = object->p_freepointer;
  117572             : #if ROSE_ALLOC_MEMSET == 1
  117573             : #elif ROSE_ALLOC_MEMSET == 2
  117574             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgUpirWorksharingStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  117575             : #elif ROSE_ALLOC_MEMSET == 3
  117576             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgUpirWorksharingStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  117577             : #endif
  117578         185 :     object->p_freepointer = fp;
  117579             : 
  117580             : #if ROSE_ALLOC_TRACE == 2
  117581             : //    printf("SgUpirWorksharingStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUpirWorksharingStatement::next_node);
  117582             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  117583             :     Rose::MemPool::snapshot(oss.str());
  117584             :     alloc_trace_cnt++;
  117585             : #endif
  117586             : 
  117587         185 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  117588             : 
  117589         185 :     ALLOC_MUTEX(SgUpirWorksharingStatement, unlock);
  117590             : 
  117591             :     return object;
  117592             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  117593             : }
  117594             : 
  117595             : 
  117596             : 
  117597             : /*! \brief Delete operator for SgUpirWorksharingStatement.
  117598             : 
  117599             :    This delete operator implements deallocation using memory pools to 
  117600             :    provide most efficent use of the heap within construction of large ASTs.
  117601             : 
  117602             : \internal The new and delete operators use the lower level C malloc/free
  117603             :    function calls for performance and to make sure that mixing of malloc/free
  117604             :    and new/delete by the used can be caught more readily.  This may change
  117605             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  117606             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  117607             :    deallocate memory allocated using ROSE_MALLOC.
  117608             : */
  117609           0 : void SgUpirWorksharingStatement::operator delete(void *Pointer, size_t Size)
  117610             : {
  117611             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  117612             :      * or throwing an exception. */
  117613           0 :     ALLOC_MUTEX(SgUpirWorksharingStatement, lock);
  117614             : 
  117615             : #if USE_CPP_NEW_DELETE_OPERATORS
  117616             :     ROSE_FREE(Pointer);
  117617             : #else
  117618             : #if ROSE_PEDANTIC_ALLOC
  117619             :     ROSE_ASSERT(Size == sizeof(SgUpirWorksharingStatement));
  117620             : #else
  117621           0 :     if (Size != sizeof(SgUpirWorksharingStatement)) {
  117622           0 :       ROSE_FREE(Pointer);
  117623           0 :       ALLOC_MUTEX(SgUpirWorksharingStatement, unlock);
  117624             :       return;
  117625             :     }
  117626             : #endif
  117627             : 
  117628           0 :     SgUpirWorksharingStatement * object = (SgUpirWorksharingStatement*) Pointer;
  117629           0 :     ROSE_ASSERT(object != nullptr);
  117630             : 
  117631             : #if ROSE_ALLOC_TRACE == 2
  117632             : //  printf("SgUpirWorksharingStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUpirWorksharingStatement::next_node);
  117633             :     printf("SgUpirWorksharingStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUpirWorksharingStatement::next_node);
  117634             : #endif
  117635             : 
  117636             : #if ROSE_PEDANTIC_ALLOC
  117637             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  117638             : #endif
  117639             : 
  117640             : #if ROSE_ALLOC_MEMSET == 1
  117641             : #elif ROSE_ALLOC_MEMSET == 2
  117642             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgUpirWorksharingStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  117643             : #elif ROSE_ALLOC_MEMSET == 3
  117644             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgUpirWorksharingStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  117645             : #endif
  117646             : 
  117647             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  117648             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  117649             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  117650             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  117651             : #else
  117652           0 :     object->p_freepointer = SgUpirWorksharingStatement::next_node;
  117653           0 :     SgUpirWorksharingStatement::next_node = object;
  117654             : #endif
  117655             : 
  117656             : #if ROSE_ALLOC_TRACE == 2
  117657             : //  printf("SgUpirWorksharingStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUpirWorksharingStatement::next_node);
  117658             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  117659             :     Rose::MemPool::snapshot(oss.str());
  117660             :     alloc_trace_cnt++;
  117661             : #endif
  117662             : 
  117663             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  117664             : 
  117665           0 :     ALLOC_MUTEX(SgUpirWorksharingStatement, unlock);
  117666             : }
  117667             : 
  117668             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  117669             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  117670             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  117671             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  117672             : // Also, note comment below from Robb (copied from the Common.code file).
  117673             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  117674             : //
  117675             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  117676             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  117677             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  117678             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  117679             : #if 0
  117680             : void SgUpirWorksharingStatement::operator delete(void* pointer) { SgUpirWorksharingStatement::operator delete (pointer, sizeof(SgUpirWorksharingStatement)); };
  117681             : #endif
  117682             : /* #line 117683 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  117683             : 
  117684             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  117685             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  117686             : // obviously imply C++.
  117687             : 
  117688             : // This implements the support within ROSE for memory pools.  Memory pools
  117689             : // support the most condensed usage of memory within the construction of
  117690             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  117691             : // by a new operator written for each class.
  117692             : 
  117693             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  117694             :     // User wants multi-thread support and POSIX threads are available.
  117695             : #   include <pthread.h>
  117696             :     static pthread_mutex_t SgUpirSimdStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  117697             : #else
  117698             :      // Cause synchronization to be skipped.
  117699             : #    ifndef ALLOC_MUTEX
  117700             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  117701             : #    endif
  117702             : #    ifdef _REENTRANT
  117703             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  117704             : #       ifdef _MSC_VER
  117705             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  117706             : #       else
  117707             : #           warning "POSIX threads are not available; synchronization being skipped"
  117708             : #       endif
  117709             : #    endif
  117710             : #endif
  117711             : 
  117712             : #ifndef ROSE_ALLOC_TRACE
  117713             : #  define ROSE_ALLOC_TRACE 0
  117714             : #endif
  117715             : 
  117716             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  117717             : #define ROSE_ALLOC_TRACE_CNT
  117718             : #include "memory-pool-snapshot.h"
  117719             : unsigned long alloc_trace_cnt = 0;
  117720             : #endif
  117721             : 
  117722             : #if ROSE_ALLOC_TRACE
  117723             : const unsigned SgUpirSimdStatement::pool_size = 5;
  117724             : #else
  117725             : const unsigned SgUpirSimdStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  117726             : #endif
  117727             : 
  117728             : #ifndef ROSE_ALLOC_MEMSET
  117729             : #  define ROSE_ALLOC_MEMSET 0
  117730             : #endif
  117731             : 
  117732             : #ifndef ROSE_PEDANTIC_ALLOC
  117733             : #  define ROSE_PEDANTIC_ALLOC 0
  117734             : #endif
  117735             : 
  117736             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  117737             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  117738             : #endif
  117739             : 
  117740             : #if !defined(SGNODE__ALL_POOLS)
  117741             : #define SGNODE__ALL_POOLS
  117742             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  117743             : #endif
  117744             : 
  117745             : SgUpirSimdStatement* SgUpirSimdStatement::next_node = nullptr;
  117746             : std::vector<unsigned char*> SgUpirSimdStatement::pools;
  117747             : 
  117748             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  117749             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  117750             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  117751             : // around this macro definition rather than each use).
  117752             : #ifndef ALLOC_MUTEX
  117753             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  117754             :         do {                                                                     \
  117755             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  117756             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  117757             :                 abort();                                                         \
  117758             :             }                                                                    \
  117759             :         } while (0);
  117760             : #endif
  117761             : 
  117762             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  117763             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  117764             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  117765             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  117766             : 
  117767             : /*! \brief New operator for SgUpirSimdStatement.
  117768             : 
  117769             :    This new operator implements memory pools to provide most efficent 
  117770             :    use of the heap within construction of large ASTs.
  117771             : 
  117772             : \internal The new and delete operators use the lower level C malloc/free
  117773             :    function calls for performance and to make sure that mixing of malloc/free
  117774             :    and new/delete by the used can be caught more readily.  This may change
  117775             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  117776             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  117777             :    deallocate memory allocated using ROSE_MALLOC.
  117778             : */
  117779          14 : void *SgUpirSimdStatement::operator new ( size_t Size )
  117780             : {
  117781             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  117782             :      * returning or throwing an exception. */
  117783          14 :     ALLOC_MUTEX(SgUpirSimdStatement, lock);
  117784             : 
  117785             : #if ROSE_ALLOC_TRACE == 2
  117786             : //    printf("SgUpirSimdStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgUpirSimdStatement::next_node);
  117787             : #endif
  117788             : 
  117789             : #if USE_CPP_NEW_DELETE_OPERATORS
  117790             :     void *mem = ROSE_MALLOC(Size);
  117791             :     ALLOC_MUTEX(SgUpirSimdStatement, unlock);
  117792             :     return mem;
  117793             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  117794             : #if ROSE_PEDANTIC_ALLOC
  117795             :     ROSE_ASSERT(Size == sizeof(SgUpirSimdStatement));
  117796             : #else
  117797          14 :     if (Size != sizeof(SgUpirSimdStatement)) {
  117798           0 :       void * object = ROSE_MALLOC(Size);
  117799           0 :       ALLOC_MUTEX(SgUpirSimdStatement, unlock);
  117800             :       return object;
  117801             :     }
  117802             : #endif
  117803             : 
  117804          14 :     if (SgUpirSimdStatement::next_node == nullptr) {
  117805           6 :         SgUpirSimdStatement * alloc = (SgUpirSimdStatement*) ROSE_MALLOC ( SgUpirSimdStatement::pool_size * sizeof(SgUpirSimdStatement) );
  117806           6 :         ROSE_ASSERT(alloc != nullptr);
  117807             : 
  117808             : #if ROSE_ALLOC_TRACE == 2
  117809             : //        printf("SgUpirSimdStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgUpirSimdStatement::pools.size(), alloc, alloc + SgUpirSimdStatement::pool_size);
  117810             : #endif
  117811             : 
  117812             : #if ROSE_ALLOC_MEMSET == 1
  117813             : #elif ROSE_ALLOC_MEMSET == 2
  117814             :         memset(alloc, 0x00, SgUpirSimdStatement::pool_size * sizeof(SgUpirSimdStatement));
  117815             : #elif ROSE_ALLOC_MEMSET == 3
  117816             :         memset(alloc, 0xAA, SgUpirSimdStatement::pool_size * sizeof(SgUpirSimdStatement));
  117817             : #endif
  117818       12000 :         for (unsigned i=0; i < SgUpirSimdStatement::pool_size-1; i++) {
  117819       11994 :           alloc[i].p_freepointer = &(alloc[i+1]);
  117820             :         }
  117821           6 :         alloc[SgUpirSimdStatement::pool_size-1].p_freepointer = nullptr;
  117822             : 
  117823           6 :         SgUpirSimdStatement::pools.push_back ( (unsigned char *) alloc );
  117824           6 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgUpirSimdStatement::pool_size * sizeof(SgUpirSimdStatement), V_SgUpirSimdStatement ) );
  117825           6 :         SgUpirSimdStatement::next_node = alloc;
  117826             :     }
  117827          14 :     ROSE_ASSERT(SgUpirSimdStatement::next_node != nullptr);
  117828             : 
  117829          14 :     SgUpirSimdStatement * object = SgUpirSimdStatement::next_node;
  117830          14 :     SgUpirSimdStatement::next_node = (SgUpirSimdStatement*)(object->p_freepointer);
  117831             : 
  117832             : #if ROSE_ALLOC_TRACE == 2
  117833             :     printf("SgUpirSimdStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUpirSimdStatement::next_node);
  117834             : #endif
  117835             : 
  117836          14 :     SgNode * fp = object->p_freepointer;
  117837             : #if ROSE_ALLOC_MEMSET == 1
  117838             : #elif ROSE_ALLOC_MEMSET == 2
  117839             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgUpirSimdStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  117840             : #elif ROSE_ALLOC_MEMSET == 3
  117841             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgUpirSimdStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  117842             : #endif
  117843          14 :     object->p_freepointer = fp;
  117844             : 
  117845             : #if ROSE_ALLOC_TRACE == 2
  117846             : //    printf("SgUpirSimdStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUpirSimdStatement::next_node);
  117847             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  117848             :     Rose::MemPool::snapshot(oss.str());
  117849             :     alloc_trace_cnt++;
  117850             : #endif
  117851             : 
  117852          14 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  117853             : 
  117854          14 :     ALLOC_MUTEX(SgUpirSimdStatement, unlock);
  117855             : 
  117856             :     return object;
  117857             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  117858             : }
  117859             : 
  117860             : 
  117861             : 
  117862             : /*! \brief Delete operator for SgUpirSimdStatement.
  117863             : 
  117864             :    This delete operator implements deallocation using memory pools to 
  117865             :    provide most efficent use of the heap within construction of large ASTs.
  117866             : 
  117867             : \internal The new and delete operators use the lower level C malloc/free
  117868             :    function calls for performance and to make sure that mixing of malloc/free
  117869             :    and new/delete by the used can be caught more readily.  This may change
  117870             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  117871             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  117872             :    deallocate memory allocated using ROSE_MALLOC.
  117873             : */
  117874           0 : void SgUpirSimdStatement::operator delete(void *Pointer, size_t Size)
  117875             : {
  117876             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  117877             :      * or throwing an exception. */
  117878           0 :     ALLOC_MUTEX(SgUpirSimdStatement, lock);
  117879             : 
  117880             : #if USE_CPP_NEW_DELETE_OPERATORS
  117881             :     ROSE_FREE(Pointer);
  117882             : #else
  117883             : #if ROSE_PEDANTIC_ALLOC
  117884             :     ROSE_ASSERT(Size == sizeof(SgUpirSimdStatement));
  117885             : #else
  117886           0 :     if (Size != sizeof(SgUpirSimdStatement)) {
  117887           0 :       ROSE_FREE(Pointer);
  117888           0 :       ALLOC_MUTEX(SgUpirSimdStatement, unlock);
  117889             :       return;
  117890             :     }
  117891             : #endif
  117892             : 
  117893           0 :     SgUpirSimdStatement * object = (SgUpirSimdStatement*) Pointer;
  117894           0 :     ROSE_ASSERT(object != nullptr);
  117895             : 
  117896             : #if ROSE_ALLOC_TRACE == 2
  117897             : //  printf("SgUpirSimdStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUpirSimdStatement::next_node);
  117898             :     printf("SgUpirSimdStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUpirSimdStatement::next_node);
  117899             : #endif
  117900             : 
  117901             : #if ROSE_PEDANTIC_ALLOC
  117902             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  117903             : #endif
  117904             : 
  117905             : #if ROSE_ALLOC_MEMSET == 1
  117906             : #elif ROSE_ALLOC_MEMSET == 2
  117907             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgUpirSimdStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  117908             : #elif ROSE_ALLOC_MEMSET == 3
  117909             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgUpirSimdStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  117910             : #endif
  117911             : 
  117912             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  117913             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  117914             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  117915             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  117916             : #else
  117917           0 :     object->p_freepointer = SgUpirSimdStatement::next_node;
  117918           0 :     SgUpirSimdStatement::next_node = object;
  117919             : #endif
  117920             : 
  117921             : #if ROSE_ALLOC_TRACE == 2
  117922             : //  printf("SgUpirSimdStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUpirSimdStatement::next_node);
  117923             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  117924             :     Rose::MemPool::snapshot(oss.str());
  117925             :     alloc_trace_cnt++;
  117926             : #endif
  117927             : 
  117928             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  117929             : 
  117930           0 :     ALLOC_MUTEX(SgUpirSimdStatement, unlock);
  117931             : }
  117932             : 
  117933             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  117934             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  117935             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  117936             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  117937             : // Also, note comment below from Robb (copied from the Common.code file).
  117938             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  117939             : //
  117940             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  117941             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  117942             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  117943             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  117944             : #if 0
  117945             : void SgUpirSimdStatement::operator delete(void* pointer) { SgUpirSimdStatement::operator delete (pointer, sizeof(SgUpirSimdStatement)); };
  117946             : #endif
  117947             : /* #line 117948 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  117948             : 
  117949             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  117950             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  117951             : // obviously imply C++.
  117952             : 
  117953             : // This implements the support within ROSE for memory pools.  Memory pools
  117954             : // support the most condensed usage of memory within the construction of
  117955             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  117956             : // by a new operator written for each class.
  117957             : 
  117958             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  117959             :     // User wants multi-thread support and POSIX threads are available.
  117960             : #   include <pthread.h>
  117961             :     static pthread_mutex_t SgOmpDeclareMapperStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  117962             : #else
  117963             :      // Cause synchronization to be skipped.
  117964             : #    ifndef ALLOC_MUTEX
  117965             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  117966             : #    endif
  117967             : #    ifdef _REENTRANT
  117968             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  117969             : #       ifdef _MSC_VER
  117970             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  117971             : #       else
  117972             : #           warning "POSIX threads are not available; synchronization being skipped"
  117973             : #       endif
  117974             : #    endif
  117975             : #endif
  117976             : 
  117977             : #ifndef ROSE_ALLOC_TRACE
  117978             : #  define ROSE_ALLOC_TRACE 0
  117979             : #endif
  117980             : 
  117981             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  117982             : #define ROSE_ALLOC_TRACE_CNT
  117983             : #include "memory-pool-snapshot.h"
  117984             : unsigned long alloc_trace_cnt = 0;
  117985             : #endif
  117986             : 
  117987             : #if ROSE_ALLOC_TRACE
  117988             : const unsigned SgOmpDeclareMapperStatement::pool_size = 5;
  117989             : #else
  117990             : const unsigned SgOmpDeclareMapperStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  117991             : #endif
  117992             : 
  117993             : #ifndef ROSE_ALLOC_MEMSET
  117994             : #  define ROSE_ALLOC_MEMSET 0
  117995             : #endif
  117996             : 
  117997             : #ifndef ROSE_PEDANTIC_ALLOC
  117998             : #  define ROSE_PEDANTIC_ALLOC 0
  117999             : #endif
  118000             : 
  118001             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  118002             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  118003             : #endif
  118004             : 
  118005             : #if !defined(SGNODE__ALL_POOLS)
  118006             : #define SGNODE__ALL_POOLS
  118007             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  118008             : #endif
  118009             : 
  118010             : SgOmpDeclareMapperStatement* SgOmpDeclareMapperStatement::next_node = nullptr;
  118011             : std::vector<unsigned char*> SgOmpDeclareMapperStatement::pools;
  118012             : 
  118013             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  118014             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  118015             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  118016             : // around this macro definition rather than each use).
  118017             : #ifndef ALLOC_MUTEX
  118018             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  118019             :         do {                                                                     \
  118020             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  118021             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  118022             :                 abort();                                                         \
  118023             :             }                                                                    \
  118024             :         } while (0);
  118025             : #endif
  118026             : 
  118027             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  118028             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  118029             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  118030             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  118031             : 
  118032             : /*! \brief New operator for SgOmpDeclareMapperStatement.
  118033             : 
  118034             :    This new operator implements memory pools to provide most efficent 
  118035             :    use of the heap within construction of large ASTs.
  118036             : 
  118037             : \internal The new and delete operators use the lower level C malloc/free
  118038             :    function calls for performance and to make sure that mixing of malloc/free
  118039             :    and new/delete by the used can be caught more readily.  This may change
  118040             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  118041             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  118042             :    deallocate memory allocated using ROSE_MALLOC.
  118043             : */
  118044           0 : void *SgOmpDeclareMapperStatement::operator new ( size_t Size )
  118045             : {
  118046             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  118047             :      * returning or throwing an exception. */
  118048           0 :     ALLOC_MUTEX(SgOmpDeclareMapperStatement, lock);
  118049             : 
  118050             : #if ROSE_ALLOC_TRACE == 2
  118051             : //    printf("SgOmpDeclareMapperStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgOmpDeclareMapperStatement::next_node);
  118052             : #endif
  118053             : 
  118054             : #if USE_CPP_NEW_DELETE_OPERATORS
  118055             :     void *mem = ROSE_MALLOC(Size);
  118056             :     ALLOC_MUTEX(SgOmpDeclareMapperStatement, unlock);
  118057             :     return mem;
  118058             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  118059             : #if ROSE_PEDANTIC_ALLOC
  118060             :     ROSE_ASSERT(Size == sizeof(SgOmpDeclareMapperStatement));
  118061             : #else
  118062           0 :     if (Size != sizeof(SgOmpDeclareMapperStatement)) {
  118063           0 :       void * object = ROSE_MALLOC(Size);
  118064           0 :       ALLOC_MUTEX(SgOmpDeclareMapperStatement, unlock);
  118065             :       return object;
  118066             :     }
  118067             : #endif
  118068             : 
  118069           0 :     if (SgOmpDeclareMapperStatement::next_node == nullptr) {
  118070           0 :         SgOmpDeclareMapperStatement * alloc = (SgOmpDeclareMapperStatement*) ROSE_MALLOC ( SgOmpDeclareMapperStatement::pool_size * sizeof(SgOmpDeclareMapperStatement) );
  118071           0 :         ROSE_ASSERT(alloc != nullptr);
  118072             : 
  118073             : #if ROSE_ALLOC_TRACE == 2
  118074             : //        printf("SgOmpDeclareMapperStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgOmpDeclareMapperStatement::pools.size(), alloc, alloc + SgOmpDeclareMapperStatement::pool_size);
  118075             : #endif
  118076             : 
  118077             : #if ROSE_ALLOC_MEMSET == 1
  118078             : #elif ROSE_ALLOC_MEMSET == 2
  118079             :         memset(alloc, 0x00, SgOmpDeclareMapperStatement::pool_size * sizeof(SgOmpDeclareMapperStatement));
  118080             : #elif ROSE_ALLOC_MEMSET == 3
  118081             :         memset(alloc, 0xAA, SgOmpDeclareMapperStatement::pool_size * sizeof(SgOmpDeclareMapperStatement));
  118082             : #endif
  118083           0 :         for (unsigned i=0; i < SgOmpDeclareMapperStatement::pool_size-1; i++) {
  118084           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
  118085             :         }
  118086           0 :         alloc[SgOmpDeclareMapperStatement::pool_size-1].p_freepointer = nullptr;
  118087             : 
  118088           0 :         SgOmpDeclareMapperStatement::pools.push_back ( (unsigned char *) alloc );
  118089           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgOmpDeclareMapperStatement::pool_size * sizeof(SgOmpDeclareMapperStatement), V_SgOmpDeclareMapperStatement ) );
  118090           0 :         SgOmpDeclareMapperStatement::next_node = alloc;
  118091             :     }
  118092           0 :     ROSE_ASSERT(SgOmpDeclareMapperStatement::next_node != nullptr);
  118093             : 
  118094           0 :     SgOmpDeclareMapperStatement * object = SgOmpDeclareMapperStatement::next_node;
  118095           0 :     SgOmpDeclareMapperStatement::next_node = (SgOmpDeclareMapperStatement*)(object->p_freepointer);
  118096             : 
  118097             : #if ROSE_ALLOC_TRACE == 2
  118098             :     printf("SgOmpDeclareMapperStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpDeclareMapperStatement::next_node);
  118099             : #endif
  118100             : 
  118101           0 :     SgNode * fp = object->p_freepointer;
  118102             : #if ROSE_ALLOC_MEMSET == 1
  118103             : #elif ROSE_ALLOC_MEMSET == 2
  118104             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpDeclareMapperStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  118105             : #elif ROSE_ALLOC_MEMSET == 3
  118106             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgOmpDeclareMapperStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  118107             : #endif
  118108           0 :     object->p_freepointer = fp;
  118109             : 
  118110             : #if ROSE_ALLOC_TRACE == 2
  118111             : //    printf("SgOmpDeclareMapperStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpDeclareMapperStatement::next_node);
  118112             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  118113             :     Rose::MemPool::snapshot(oss.str());
  118114             :     alloc_trace_cnt++;
  118115             : #endif
  118116             : 
  118117           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  118118             : 
  118119           0 :     ALLOC_MUTEX(SgOmpDeclareMapperStatement, unlock);
  118120             : 
  118121             :     return object;
  118122             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  118123             : }
  118124             : 
  118125             : 
  118126             : 
  118127             : /*! \brief Delete operator for SgOmpDeclareMapperStatement.
  118128             : 
  118129             :    This delete operator implements deallocation using memory pools to 
  118130             :    provide most efficent use of the heap within construction of large ASTs.
  118131             : 
  118132             : \internal The new and delete operators use the lower level C malloc/free
  118133             :    function calls for performance and to make sure that mixing of malloc/free
  118134             :    and new/delete by the used can be caught more readily.  This may change
  118135             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  118136             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  118137             :    deallocate memory allocated using ROSE_MALLOC.
  118138             : */
  118139           0 : void SgOmpDeclareMapperStatement::operator delete(void *Pointer, size_t Size)
  118140             : {
  118141             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  118142             :      * or throwing an exception. */
  118143           0 :     ALLOC_MUTEX(SgOmpDeclareMapperStatement, lock);
  118144             : 
  118145             : #if USE_CPP_NEW_DELETE_OPERATORS
  118146             :     ROSE_FREE(Pointer);
  118147             : #else
  118148             : #if ROSE_PEDANTIC_ALLOC
  118149             :     ROSE_ASSERT(Size == sizeof(SgOmpDeclareMapperStatement));
  118150             : #else
  118151           0 :     if (Size != sizeof(SgOmpDeclareMapperStatement)) {
  118152           0 :       ROSE_FREE(Pointer);
  118153           0 :       ALLOC_MUTEX(SgOmpDeclareMapperStatement, unlock);
  118154             :       return;
  118155             :     }
  118156             : #endif
  118157             : 
  118158           0 :     SgOmpDeclareMapperStatement * object = (SgOmpDeclareMapperStatement*) Pointer;
  118159           0 :     ROSE_ASSERT(object != nullptr);
  118160             : 
  118161             : #if ROSE_ALLOC_TRACE == 2
  118162             : //  printf("SgOmpDeclareMapperStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpDeclareMapperStatement::next_node);
  118163             :     printf("SgOmpDeclareMapperStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpDeclareMapperStatement::next_node);
  118164             : #endif
  118165             : 
  118166             : #if ROSE_PEDANTIC_ALLOC
  118167             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  118168             : #endif
  118169             : 
  118170             : #if ROSE_ALLOC_MEMSET == 1
  118171             : #elif ROSE_ALLOC_MEMSET == 2
  118172             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOmpDeclareMapperStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  118173             : #elif ROSE_ALLOC_MEMSET == 3
  118174             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgOmpDeclareMapperStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  118175             : #endif
  118176             : 
  118177             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  118178             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  118179             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  118180             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  118181             : #else
  118182           0 :     object->p_freepointer = SgOmpDeclareMapperStatement::next_node;
  118183           0 :     SgOmpDeclareMapperStatement::next_node = object;
  118184             : #endif
  118185             : 
  118186             : #if ROSE_ALLOC_TRACE == 2
  118187             : //  printf("SgOmpDeclareMapperStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOmpDeclareMapperStatement::next_node);
  118188             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  118189             :     Rose::MemPool::snapshot(oss.str());
  118190             :     alloc_trace_cnt++;
  118191             : #endif
  118192             : 
  118193             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  118194             : 
  118195           0 :     ALLOC_MUTEX(SgOmpDeclareMapperStatement, unlock);
  118196             : }
  118197             : 
  118198             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  118199             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  118200             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  118201             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  118202             : // Also, note comment below from Robb (copied from the Common.code file).
  118203             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  118204             : //
  118205             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  118206             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  118207             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  118208             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  118209             : #if 0
  118210             : void SgOmpDeclareMapperStatement::operator delete(void* pointer) { SgOmpDeclareMapperStatement::operator delete (pointer, sizeof(SgOmpDeclareMapperStatement)); };
  118211             : #endif
  118212             : /* #line 118213 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  118213             : 
  118214             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  118215             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  118216             : // obviously imply C++.
  118217             : 
  118218             : // This implements the support within ROSE for memory pools.  Memory pools
  118219             : // support the most condensed usage of memory within the construction of
  118220             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  118221             : // by a new operator written for each class.
  118222             : 
  118223             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  118224             :     // User wants multi-thread support and POSIX threads are available.
  118225             : #   include <pthread.h>
  118226             :     static pthread_mutex_t SgSequenceStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  118227             : #else
  118228             :      // Cause synchronization to be skipped.
  118229             : #    ifndef ALLOC_MUTEX
  118230             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  118231             : #    endif
  118232             : #    ifdef _REENTRANT
  118233             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  118234             : #       ifdef _MSC_VER
  118235             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  118236             : #       else
  118237             : #           warning "POSIX threads are not available; synchronization being skipped"
  118238             : #       endif
  118239             : #    endif
  118240             : #endif
  118241             : 
  118242             : #ifndef ROSE_ALLOC_TRACE
  118243             : #  define ROSE_ALLOC_TRACE 0
  118244             : #endif
  118245             : 
  118246             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  118247             : #define ROSE_ALLOC_TRACE_CNT
  118248             : #include "memory-pool-snapshot.h"
  118249             : unsigned long alloc_trace_cnt = 0;
  118250             : #endif
  118251             : 
  118252             : #if ROSE_ALLOC_TRACE
  118253             : const unsigned SgSequenceStatement::pool_size = 5;
  118254             : #else
  118255             : const unsigned SgSequenceStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  118256             : #endif
  118257             : 
  118258             : #ifndef ROSE_ALLOC_MEMSET
  118259             : #  define ROSE_ALLOC_MEMSET 0
  118260             : #endif
  118261             : 
  118262             : #ifndef ROSE_PEDANTIC_ALLOC
  118263             : #  define ROSE_PEDANTIC_ALLOC 0
  118264             : #endif
  118265             : 
  118266             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  118267             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  118268             : #endif
  118269             : 
  118270             : #if !defined(SGNODE__ALL_POOLS)
  118271             : #define SGNODE__ALL_POOLS
  118272             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  118273             : #endif
  118274             : 
  118275             : SgSequenceStatement* SgSequenceStatement::next_node = nullptr;
  118276             : std::vector<unsigned char*> SgSequenceStatement::pools;
  118277             : 
  118278             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  118279             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  118280             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  118281             : // around this macro definition rather than each use).
  118282             : #ifndef ALLOC_MUTEX
  118283             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  118284             :         do {                                                                     \
  118285             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  118286             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  118287             :                 abort();                                                         \
  118288             :             }                                                                    \
  118289             :         } while (0);
  118290             : #endif
  118291             : 
  118292             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  118293             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  118294             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  118295             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  118296             : 
  118297             : /*! \brief New operator for SgSequenceStatement.
  118298             : 
  118299             :    This new operator implements memory pools to provide most efficent 
  118300             :    use of the heap within construction of large ASTs.
  118301             : 
  118302             : \internal The new and delete operators use the lower level C malloc/free
  118303             :    function calls for performance and to make sure that mixing of malloc/free
  118304             :    and new/delete by the used can be caught more readily.  This may change
  118305             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  118306             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  118307             :    deallocate memory allocated using ROSE_MALLOC.
  118308             : */
  118309           0 : void *SgSequenceStatement::operator new ( size_t Size )
  118310             : {
  118311             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  118312             :      * returning or throwing an exception. */
  118313           0 :     ALLOC_MUTEX(SgSequenceStatement, lock);
  118314             : 
  118315             : #if ROSE_ALLOC_TRACE == 2
  118316             : //    printf("SgSequenceStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgSequenceStatement::next_node);
  118317             : #endif
  118318             : 
  118319             : #if USE_CPP_NEW_DELETE_OPERATORS
  118320             :     void *mem = ROSE_MALLOC(Size);
  118321             :     ALLOC_MUTEX(SgSequenceStatement, unlock);
  118322             :     return mem;
  118323             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  118324             : #if ROSE_PEDANTIC_ALLOC
  118325             :     ROSE_ASSERT(Size == sizeof(SgSequenceStatement));
  118326             : #else
  118327           0 :     if (Size != sizeof(SgSequenceStatement)) {
  118328           0 :       void * object = ROSE_MALLOC(Size);
  118329           0 :       ALLOC_MUTEX(SgSequenceStatement, unlock);
  118330             :       return object;
  118331             :     }
  118332             : #endif
  118333             : 
  118334           0 :     if (SgSequenceStatement::next_node == nullptr) {
  118335           0 :         SgSequenceStatement * alloc = (SgSequenceStatement*) ROSE_MALLOC ( SgSequenceStatement::pool_size * sizeof(SgSequenceStatement) );
  118336           0 :         ROSE_ASSERT(alloc != nullptr);
  118337             : 
  118338             : #if ROSE_ALLOC_TRACE == 2
  118339             : //        printf("SgSequenceStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgSequenceStatement::pools.size(), alloc, alloc + SgSequenceStatement::pool_size);
  118340             : #endif
  118341             : 
  118342             : #if ROSE_ALLOC_MEMSET == 1
  118343             : #elif ROSE_ALLOC_MEMSET == 2
  118344             :         memset(alloc, 0x00, SgSequenceStatement::pool_size * sizeof(SgSequenceStatement));
  118345             : #elif ROSE_ALLOC_MEMSET == 3
  118346             :         memset(alloc, 0xAA, SgSequenceStatement::pool_size * sizeof(SgSequenceStatement));
  118347             : #endif
  118348           0 :         for (unsigned i=0; i < SgSequenceStatement::pool_size-1; i++) {
  118349           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
  118350             :         }
  118351           0 :         alloc[SgSequenceStatement::pool_size-1].p_freepointer = nullptr;
  118352             : 
  118353           0 :         SgSequenceStatement::pools.push_back ( (unsigned char *) alloc );
  118354           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgSequenceStatement::pool_size * sizeof(SgSequenceStatement), V_SgSequenceStatement ) );
  118355           0 :         SgSequenceStatement::next_node = alloc;
  118356             :     }
  118357           0 :     ROSE_ASSERT(SgSequenceStatement::next_node != nullptr);
  118358             : 
  118359           0 :     SgSequenceStatement * object = SgSequenceStatement::next_node;
  118360           0 :     SgSequenceStatement::next_node = (SgSequenceStatement*)(object->p_freepointer);
  118361             : 
  118362             : #if ROSE_ALLOC_TRACE == 2
  118363             :     printf("SgSequenceStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgSequenceStatement::next_node);
  118364             : #endif
  118365             : 
  118366           0 :     SgNode * fp = object->p_freepointer;
  118367             : #if ROSE_ALLOC_MEMSET == 1
  118368             : #elif ROSE_ALLOC_MEMSET == 2
  118369             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgSequenceStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  118370             : #elif ROSE_ALLOC_MEMSET == 3
  118371             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgSequenceStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  118372             : #endif
  118373           0 :     object->p_freepointer = fp;
  118374             : 
  118375             : #if ROSE_ALLOC_TRACE == 2
  118376             : //    printf("SgSequenceStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgSequenceStatement::next_node);
  118377             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  118378             :     Rose::MemPool::snapshot(oss.str());
  118379             :     alloc_trace_cnt++;
  118380             : #endif
  118381             : 
  118382           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  118383             : 
  118384           0 :     ALLOC_MUTEX(SgSequenceStatement, unlock);
  118385             : 
  118386             :     return object;
  118387             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  118388             : }
  118389             : 
  118390             : 
  118391             : 
  118392             : /*! \brief Delete operator for SgSequenceStatement.
  118393             : 
  118394             :    This delete operator implements deallocation using memory pools to 
  118395             :    provide most efficent use of the heap within construction of large ASTs.
  118396             : 
  118397             : \internal The new and delete operators use the lower level C malloc/free
  118398             :    function calls for performance and to make sure that mixing of malloc/free
  118399             :    and new/delete by the used can be caught more readily.  This may change
  118400             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  118401             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  118402             :    deallocate memory allocated using ROSE_MALLOC.
  118403             : */
  118404           0 : void SgSequenceStatement::operator delete(void *Pointer, size_t Size)
  118405             : {
  118406             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  118407             :      * or throwing an exception. */
  118408           0 :     ALLOC_MUTEX(SgSequenceStatement, lock);
  118409             : 
  118410             : #if USE_CPP_NEW_DELETE_OPERATORS
  118411             :     ROSE_FREE(Pointer);
  118412             : #else
  118413             : #if ROSE_PEDANTIC_ALLOC
  118414             :     ROSE_ASSERT(Size == sizeof(SgSequenceStatement));
  118415             : #else
  118416           0 :     if (Size != sizeof(SgSequenceStatement)) {
  118417           0 :       ROSE_FREE(Pointer);
  118418           0 :       ALLOC_MUTEX(SgSequenceStatement, unlock);
  118419             :       return;
  118420             :     }
  118421             : #endif
  118422             : 
  118423           0 :     SgSequenceStatement * object = (SgSequenceStatement*) Pointer;
  118424           0 :     ROSE_ASSERT(object != nullptr);
  118425             : 
  118426             : #if ROSE_ALLOC_TRACE == 2
  118427             : //  printf("SgSequenceStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgSequenceStatement::next_node);
  118428             :     printf("SgSequenceStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgSequenceStatement::next_node);
  118429             : #endif
  118430             : 
  118431             : #if ROSE_PEDANTIC_ALLOC
  118432             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  118433             : #endif
  118434             : 
  118435             : #if ROSE_ALLOC_MEMSET == 1
  118436             : #elif ROSE_ALLOC_MEMSET == 2
  118437             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgSequenceStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  118438             : #elif ROSE_ALLOC_MEMSET == 3
  118439             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgSequenceStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  118440             : #endif
  118441             : 
  118442             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  118443             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  118444             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  118445             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  118446             : #else
  118447           0 :     object->p_freepointer = SgSequenceStatement::next_node;
  118448           0 :     SgSequenceStatement::next_node = object;
  118449             : #endif
  118450             : 
  118451             : #if ROSE_ALLOC_TRACE == 2
  118452             : //  printf("SgSequenceStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgSequenceStatement::next_node);
  118453             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  118454             :     Rose::MemPool::snapshot(oss.str());
  118455             :     alloc_trace_cnt++;
  118456             : #endif
  118457             : 
  118458             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  118459             : 
  118460           0 :     ALLOC_MUTEX(SgSequenceStatement, unlock);
  118461             : }
  118462             : 
  118463             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  118464             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  118465             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  118466             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  118467             : // Also, note comment below from Robb (copied from the Common.code file).
  118468             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  118469             : //
  118470             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  118471             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  118472             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  118473             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  118474             : #if 0
  118475             : void SgSequenceStatement::operator delete(void* pointer) { SgSequenceStatement::operator delete (pointer, sizeof(SgSequenceStatement)); };
  118476             : #endif
  118477             : /* #line 118478 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  118478             : 
  118479             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  118480             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  118481             : // obviously imply C++.
  118482             : 
  118483             : // This implements the support within ROSE for memory pools.  Memory pools
  118484             : // support the most condensed usage of memory within the construction of
  118485             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  118486             : // by a new operator written for each class.
  118487             : 
  118488             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  118489             :     // User wants multi-thread support and POSIX threads are available.
  118490             : #   include <pthread.h>
  118491             :     static pthread_mutex_t SgWithStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  118492             : #else
  118493             :      // Cause synchronization to be skipped.
  118494             : #    ifndef ALLOC_MUTEX
  118495             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  118496             : #    endif
  118497             : #    ifdef _REENTRANT
  118498             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  118499             : #       ifdef _MSC_VER
  118500             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  118501             : #       else
  118502             : #           warning "POSIX threads are not available; synchronization being skipped"
  118503             : #       endif
  118504             : #    endif
  118505             : #endif
  118506             : 
  118507             : #ifndef ROSE_ALLOC_TRACE
  118508             : #  define ROSE_ALLOC_TRACE 0
  118509             : #endif
  118510             : 
  118511             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  118512             : #define ROSE_ALLOC_TRACE_CNT
  118513             : #include "memory-pool-snapshot.h"
  118514             : unsigned long alloc_trace_cnt = 0;
  118515             : #endif
  118516             : 
  118517             : #if ROSE_ALLOC_TRACE
  118518             : const unsigned SgWithStatement::pool_size = 5;
  118519             : #else
  118520             : const unsigned SgWithStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  118521             : #endif
  118522             : 
  118523             : #ifndef ROSE_ALLOC_MEMSET
  118524             : #  define ROSE_ALLOC_MEMSET 0
  118525             : #endif
  118526             : 
  118527             : #ifndef ROSE_PEDANTIC_ALLOC
  118528             : #  define ROSE_PEDANTIC_ALLOC 0
  118529             : #endif
  118530             : 
  118531             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  118532             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  118533             : #endif
  118534             : 
  118535             : #if !defined(SGNODE__ALL_POOLS)
  118536             : #define SGNODE__ALL_POOLS
  118537             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  118538             : #endif
  118539             : 
  118540             : SgWithStatement* SgWithStatement::next_node = nullptr;
  118541             : std::vector<unsigned char*> SgWithStatement::pools;
  118542             : 
  118543             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  118544             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  118545             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  118546             : // around this macro definition rather than each use).
  118547             : #ifndef ALLOC_MUTEX
  118548             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  118549             :         do {                                                                     \
  118550             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  118551             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  118552             :                 abort();                                                         \
  118553             :             }                                                                    \
  118554             :         } while (0);
  118555             : #endif
  118556             : 
  118557             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  118558             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  118559             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  118560             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  118561             : 
  118562             : /*! \brief New operator for SgWithStatement.
  118563             : 
  118564             :    This new operator implements memory pools to provide most efficent 
  118565             :    use of the heap within construction of large ASTs.
  118566             : 
  118567             : \internal The new and delete operators use the lower level C malloc/free
  118568             :    function calls for performance and to make sure that mixing of malloc/free
  118569             :    and new/delete by the used can be caught more readily.  This may change
  118570             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  118571             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  118572             :    deallocate memory allocated using ROSE_MALLOC.
  118573             : */
  118574           0 : void *SgWithStatement::operator new ( size_t Size )
  118575             : {
  118576             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  118577             :      * returning or throwing an exception. */
  118578           0 :     ALLOC_MUTEX(SgWithStatement, lock);
  118579             : 
  118580             : #if ROSE_ALLOC_TRACE == 2
  118581             : //    printf("SgWithStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgWithStatement::next_node);
  118582             : #endif
  118583             : 
  118584             : #if USE_CPP_NEW_DELETE_OPERATORS
  118585             :     void *mem = ROSE_MALLOC(Size);
  118586             :     ALLOC_MUTEX(SgWithStatement, unlock);
  118587             :     return mem;
  118588             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  118589             : #if ROSE_PEDANTIC_ALLOC
  118590             :     ROSE_ASSERT(Size == sizeof(SgWithStatement));
  118591             : #else
  118592           0 :     if (Size != sizeof(SgWithStatement)) {
  118593           0 :       void * object = ROSE_MALLOC(Size);
  118594           0 :       ALLOC_MUTEX(SgWithStatement, unlock);
  118595             :       return object;
  118596             :     }
  118597             : #endif
  118598             : 
  118599           0 :     if (SgWithStatement::next_node == nullptr) {
  118600           0 :         SgWithStatement * alloc = (SgWithStatement*) ROSE_MALLOC ( SgWithStatement::pool_size * sizeof(SgWithStatement) );
  118601           0 :         ROSE_ASSERT(alloc != nullptr);
  118602             : 
  118603             : #if ROSE_ALLOC_TRACE == 2
  118604             : //        printf("SgWithStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgWithStatement::pools.size(), alloc, alloc + SgWithStatement::pool_size);
  118605             : #endif
  118606             : 
  118607             : #if ROSE_ALLOC_MEMSET == 1
  118608             : #elif ROSE_ALLOC_MEMSET == 2
  118609             :         memset(alloc, 0x00, SgWithStatement::pool_size * sizeof(SgWithStatement));
  118610             : #elif ROSE_ALLOC_MEMSET == 3
  118611             :         memset(alloc, 0xAA, SgWithStatement::pool_size * sizeof(SgWithStatement));
  118612             : #endif
  118613           0 :         for (unsigned i=0; i < SgWithStatement::pool_size-1; i++) {
  118614           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
  118615             :         }
  118616           0 :         alloc[SgWithStatement::pool_size-1].p_freepointer = nullptr;
  118617             : 
  118618           0 :         SgWithStatement::pools.push_back ( (unsigned char *) alloc );
  118619           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgWithStatement::pool_size * sizeof(SgWithStatement), V_SgWithStatement ) );
  118620           0 :         SgWithStatement::next_node = alloc;
  118621             :     }
  118622           0 :     ROSE_ASSERT(SgWithStatement::next_node != nullptr);
  118623             : 
  118624           0 :     SgWithStatement * object = SgWithStatement::next_node;
  118625           0 :     SgWithStatement::next_node = (SgWithStatement*)(object->p_freepointer);
  118626             : 
  118627             : #if ROSE_ALLOC_TRACE == 2
  118628             :     printf("SgWithStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgWithStatement::next_node);
  118629             : #endif
  118630             : 
  118631           0 :     SgNode * fp = object->p_freepointer;
  118632             : #if ROSE_ALLOC_MEMSET == 1
  118633             : #elif ROSE_ALLOC_MEMSET == 2
  118634             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgWithStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  118635             : #elif ROSE_ALLOC_MEMSET == 3
  118636             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgWithStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  118637             : #endif
  118638           0 :     object->p_freepointer = fp;
  118639             : 
  118640             : #if ROSE_ALLOC_TRACE == 2
  118641             : //    printf("SgWithStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgWithStatement::next_node);
  118642             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  118643             :     Rose::MemPool::snapshot(oss.str());
  118644             :     alloc_trace_cnt++;
  118645             : #endif
  118646             : 
  118647           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  118648             : 
  118649           0 :     ALLOC_MUTEX(SgWithStatement, unlock);
  118650             : 
  118651             :     return object;
  118652             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  118653             : }
  118654             : 
  118655             : 
  118656             : 
  118657             : /*! \brief Delete operator for SgWithStatement.
  118658             : 
  118659             :    This delete operator implements deallocation using memory pools to 
  118660             :    provide most efficent use of the heap within construction of large ASTs.
  118661             : 
  118662             : \internal The new and delete operators use the lower level C malloc/free
  118663             :    function calls for performance and to make sure that mixing of malloc/free
  118664             :    and new/delete by the used can be caught more readily.  This may change
  118665             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  118666             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  118667             :    deallocate memory allocated using ROSE_MALLOC.
  118668             : */
  118669           0 : void SgWithStatement::operator delete(void *Pointer, size_t Size)
  118670             : {
  118671             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  118672             :      * or throwing an exception. */
  118673           0 :     ALLOC_MUTEX(SgWithStatement, lock);
  118674             : 
  118675             : #if USE_CPP_NEW_DELETE_OPERATORS
  118676             :     ROSE_FREE(Pointer);
  118677             : #else
  118678             : #if ROSE_PEDANTIC_ALLOC
  118679             :     ROSE_ASSERT(Size == sizeof(SgWithStatement));
  118680             : #else
  118681           0 :     if (Size != sizeof(SgWithStatement)) {
  118682           0 :       ROSE_FREE(Pointer);
  118683           0 :       ALLOC_MUTEX(SgWithStatement, unlock);
  118684             :       return;
  118685             :     }
  118686             : #endif
  118687             : 
  118688           0 :     SgWithStatement * object = (SgWithStatement*) Pointer;
  118689           0 :     ROSE_ASSERT(object != nullptr);
  118690             : 
  118691             : #if ROSE_ALLOC_TRACE == 2
  118692             : //  printf("SgWithStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgWithStatement::next_node);
  118693             :     printf("SgWithStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgWithStatement::next_node);
  118694             : #endif
  118695             : 
  118696             : #if ROSE_PEDANTIC_ALLOC
  118697             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  118698             : #endif
  118699             : 
  118700             : #if ROSE_ALLOC_MEMSET == 1
  118701             : #elif ROSE_ALLOC_MEMSET == 2
  118702             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgWithStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  118703             : #elif ROSE_ALLOC_MEMSET == 3
  118704             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgWithStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  118705             : #endif
  118706             : 
  118707             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  118708             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  118709             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  118710             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  118711             : #else
  118712           0 :     object->p_freepointer = SgWithStatement::next_node;
  118713           0 :     SgWithStatement::next_node = object;
  118714             : #endif
  118715             : 
  118716             : #if ROSE_ALLOC_TRACE == 2
  118717             : //  printf("SgWithStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgWithStatement::next_node);
  118718             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  118719             :     Rose::MemPool::snapshot(oss.str());
  118720             :     alloc_trace_cnt++;
  118721             : #endif
  118722             : 
  118723             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  118724             : 
  118725           0 :     ALLOC_MUTEX(SgWithStatement, unlock);
  118726             : }
  118727             : 
  118728             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  118729             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  118730             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  118731             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  118732             : // Also, note comment below from Robb (copied from the Common.code file).
  118733             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  118734             : //
  118735             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  118736             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  118737             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  118738             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  118739             : #if 0
  118740             : void SgWithStatement::operator delete(void* pointer) { SgWithStatement::operator delete (pointer, sizeof(SgWithStatement)); };
  118741             : #endif
  118742             : /* #line 118743 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  118743             : 
  118744             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  118745             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  118746             : // obviously imply C++.
  118747             : 
  118748             : // This implements the support within ROSE for memory pools.  Memory pools
  118749             : // support the most condensed usage of memory within the construction of
  118750             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  118751             : // by a new operator written for each class.
  118752             : 
  118753             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  118754             :     // User wants multi-thread support and POSIX threads are available.
  118755             : #   include <pthread.h>
  118756             :     static pthread_mutex_t SgPassStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  118757             : #else
  118758             :      // Cause synchronization to be skipped.
  118759             : #    ifndef ALLOC_MUTEX
  118760             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  118761             : #    endif
  118762             : #    ifdef _REENTRANT
  118763             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  118764             : #       ifdef _MSC_VER
  118765             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  118766             : #       else
  118767             : #           warning "POSIX threads are not available; synchronization being skipped"
  118768             : #       endif
  118769             : #    endif
  118770             : #endif
  118771             : 
  118772             : #ifndef ROSE_ALLOC_TRACE
  118773             : #  define ROSE_ALLOC_TRACE 0
  118774             : #endif
  118775             : 
  118776             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  118777             : #define ROSE_ALLOC_TRACE_CNT
  118778             : #include "memory-pool-snapshot.h"
  118779             : unsigned long alloc_trace_cnt = 0;
  118780             : #endif
  118781             : 
  118782             : #if ROSE_ALLOC_TRACE
  118783             : const unsigned SgPassStatement::pool_size = 5;
  118784             : #else
  118785             : const unsigned SgPassStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  118786             : #endif
  118787             : 
  118788             : #ifndef ROSE_ALLOC_MEMSET
  118789             : #  define ROSE_ALLOC_MEMSET 0
  118790             : #endif
  118791             : 
  118792             : #ifndef ROSE_PEDANTIC_ALLOC
  118793             : #  define ROSE_PEDANTIC_ALLOC 0
  118794             : #endif
  118795             : 
  118796             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  118797             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  118798             : #endif
  118799             : 
  118800             : #if !defined(SGNODE__ALL_POOLS)
  118801             : #define SGNODE__ALL_POOLS
  118802             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  118803             : #endif
  118804             : 
  118805             : SgPassStatement* SgPassStatement::next_node = nullptr;
  118806             : std::vector<unsigned char*> SgPassStatement::pools;
  118807             : 
  118808             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  118809             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  118810             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  118811             : // around this macro definition rather than each use).
  118812             : #ifndef ALLOC_MUTEX
  118813             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  118814             :         do {                                                                     \
  118815             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  118816             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  118817             :                 abort();                                                         \
  118818             :             }                                                                    \
  118819             :         } while (0);
  118820             : #endif
  118821             : 
  118822             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  118823             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  118824             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  118825             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  118826             : 
  118827             : /*! \brief New operator for SgPassStatement.
  118828             : 
  118829             :    This new operator implements memory pools to provide most efficent 
  118830             :    use of the heap within construction of large ASTs.
  118831             : 
  118832             : \internal The new and delete operators use the lower level C malloc/free
  118833             :    function calls for performance and to make sure that mixing of malloc/free
  118834             :    and new/delete by the used can be caught more readily.  This may change
  118835             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  118836             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  118837             :    deallocate memory allocated using ROSE_MALLOC.
  118838             : */
  118839           0 : void *SgPassStatement::operator new ( size_t Size )
  118840             : {
  118841             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  118842             :      * returning or throwing an exception. */
  118843           0 :     ALLOC_MUTEX(SgPassStatement, lock);
  118844             : 
  118845             : #if ROSE_ALLOC_TRACE == 2
  118846             : //    printf("SgPassStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgPassStatement::next_node);
  118847             : #endif
  118848             : 
  118849             : #if USE_CPP_NEW_DELETE_OPERATORS
  118850             :     void *mem = ROSE_MALLOC(Size);
  118851             :     ALLOC_MUTEX(SgPassStatement, unlock);
  118852             :     return mem;
  118853             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  118854             : #if ROSE_PEDANTIC_ALLOC
  118855             :     ROSE_ASSERT(Size == sizeof(SgPassStatement));
  118856             : #else
  118857           0 :     if (Size != sizeof(SgPassStatement)) {
  118858           0 :       void * object = ROSE_MALLOC(Size);
  118859           0 :       ALLOC_MUTEX(SgPassStatement, unlock);
  118860             :       return object;
  118861             :     }
  118862             : #endif
  118863             : 
  118864           0 :     if (SgPassStatement::next_node == nullptr) {
  118865           0 :         SgPassStatement * alloc = (SgPassStatement*) ROSE_MALLOC ( SgPassStatement::pool_size * sizeof(SgPassStatement) );
  118866           0 :         ROSE_ASSERT(alloc != nullptr);
  118867             : 
  118868             : #if ROSE_ALLOC_TRACE == 2
  118869             : //        printf("SgPassStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgPassStatement::pools.size(), alloc, alloc + SgPassStatement::pool_size);
  118870             : #endif
  118871             : 
  118872             : #if ROSE_ALLOC_MEMSET == 1
  118873             : #elif ROSE_ALLOC_MEMSET == 2
  118874             :         memset(alloc, 0x00, SgPassStatement::pool_size * sizeof(SgPassStatement));
  118875             : #elif ROSE_ALLOC_MEMSET == 3
  118876             :         memset(alloc, 0xAA, SgPassStatement::pool_size * sizeof(SgPassStatement));
  118877             : #endif
  118878           0 :         for (unsigned i=0; i < SgPassStatement::pool_size-1; i++) {
  118879           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
  118880             :         }
  118881           0 :         alloc[SgPassStatement::pool_size-1].p_freepointer = nullptr;
  118882             : 
  118883           0 :         SgPassStatement::pools.push_back ( (unsigned char *) alloc );
  118884           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgPassStatement::pool_size * sizeof(SgPassStatement), V_SgPassStatement ) );
  118885           0 :         SgPassStatement::next_node = alloc;
  118886             :     }
  118887           0 :     ROSE_ASSERT(SgPassStatement::next_node != nullptr);
  118888             : 
  118889           0 :     SgPassStatement * object = SgPassStatement::next_node;
  118890           0 :     SgPassStatement::next_node = (SgPassStatement*)(object->p_freepointer);
  118891             : 
  118892             : #if ROSE_ALLOC_TRACE == 2
  118893             :     printf("SgPassStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgPassStatement::next_node);
  118894             : #endif
  118895             : 
  118896           0 :     SgNode * fp = object->p_freepointer;
  118897             : #if ROSE_ALLOC_MEMSET == 1
  118898             : #elif ROSE_ALLOC_MEMSET == 2
  118899             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgPassStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  118900             : #elif ROSE_ALLOC_MEMSET == 3
  118901             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgPassStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  118902             : #endif
  118903           0 :     object->p_freepointer = fp;
  118904             : 
  118905             : #if ROSE_ALLOC_TRACE == 2
  118906             : //    printf("SgPassStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgPassStatement::next_node);
  118907             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  118908             :     Rose::MemPool::snapshot(oss.str());
  118909             :     alloc_trace_cnt++;
  118910             : #endif
  118911             : 
  118912           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  118913             : 
  118914           0 :     ALLOC_MUTEX(SgPassStatement, unlock);
  118915             : 
  118916             :     return object;
  118917             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  118918             : }
  118919             : 
  118920             : 
  118921             : 
  118922             : /*! \brief Delete operator for SgPassStatement.
  118923             : 
  118924             :    This delete operator implements deallocation using memory pools to 
  118925             :    provide most efficent use of the heap within construction of large ASTs.
  118926             : 
  118927             : \internal The new and delete operators use the lower level C malloc/free
  118928             :    function calls for performance and to make sure that mixing of malloc/free
  118929             :    and new/delete by the used can be caught more readily.  This may change
  118930             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  118931             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  118932             :    deallocate memory allocated using ROSE_MALLOC.
  118933             : */
  118934           0 : void SgPassStatement::operator delete(void *Pointer, size_t Size)
  118935             : {
  118936             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  118937             :      * or throwing an exception. */
  118938           0 :     ALLOC_MUTEX(SgPassStatement, lock);
  118939             : 
  118940             : #if USE_CPP_NEW_DELETE_OPERATORS
  118941             :     ROSE_FREE(Pointer);
  118942             : #else
  118943             : #if ROSE_PEDANTIC_ALLOC
  118944             :     ROSE_ASSERT(Size == sizeof(SgPassStatement));
  118945             : #else
  118946           0 :     if (Size != sizeof(SgPassStatement)) {
  118947           0 :       ROSE_FREE(Pointer);
  118948           0 :       ALLOC_MUTEX(SgPassStatement, unlock);
  118949             :       return;
  118950             :     }
  118951             : #endif
  118952             : 
  118953           0 :     SgPassStatement * object = (SgPassStatement*) Pointer;
  118954           0 :     ROSE_ASSERT(object != nullptr);
  118955             : 
  118956             : #if ROSE_ALLOC_TRACE == 2
  118957             : //  printf("SgPassStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgPassStatement::next_node);
  118958             :     printf("SgPassStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgPassStatement::next_node);
  118959             : #endif
  118960             : 
  118961             : #if ROSE_PEDANTIC_ALLOC
  118962             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  118963             : #endif
  118964             : 
  118965             : #if ROSE_ALLOC_MEMSET == 1
  118966             : #elif ROSE_ALLOC_MEMSET == 2
  118967             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgPassStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  118968             : #elif ROSE_ALLOC_MEMSET == 3
  118969             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgPassStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  118970             : #endif
  118971             : 
  118972             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  118973             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  118974             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  118975             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  118976             : #else
  118977           0 :     object->p_freepointer = SgPassStatement::next_node;
  118978           0 :     SgPassStatement::next_node = object;
  118979             : #endif
  118980             : 
  118981             : #if ROSE_ALLOC_TRACE == 2
  118982             : //  printf("SgPassStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgPassStatement::next_node);
  118983             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  118984             :     Rose::MemPool::snapshot(oss.str());
  118985             :     alloc_trace_cnt++;
  118986             : #endif
  118987             : 
  118988             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  118989             : 
  118990           0 :     ALLOC_MUTEX(SgPassStatement, unlock);
  118991             : }
  118992             : 
  118993             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  118994             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  118995             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  118996             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  118997             : // Also, note comment below from Robb (copied from the Common.code file).
  118998             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  118999             : //
  119000             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  119001             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  119002             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  119003             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  119004             : #if 0
  119005             : void SgPassStatement::operator delete(void* pointer) { SgPassStatement::operator delete (pointer, sizeof(SgPassStatement)); };
  119006             : #endif
  119007             : /* #line 119008 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  119008             : 
  119009             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  119010             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  119011             : // obviously imply C++.
  119012             : 
  119013             : // This implements the support within ROSE for memory pools.  Memory pools
  119014             : // support the most condensed usage of memory within the construction of
  119015             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  119016             : // by a new operator written for each class.
  119017             : 
  119018             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  119019             :     // User wants multi-thread support and POSIX threads are available.
  119020             : #   include <pthread.h>
  119021             :     static pthread_mutex_t SgAssertStmt_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  119022             : #else
  119023             :      // Cause synchronization to be skipped.
  119024             : #    ifndef ALLOC_MUTEX
  119025             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  119026             : #    endif
  119027             : #    ifdef _REENTRANT
  119028             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  119029             : #       ifdef _MSC_VER
  119030             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  119031             : #       else
  119032             : #           warning "POSIX threads are not available; synchronization being skipped"
  119033             : #       endif
  119034             : #    endif
  119035             : #endif
  119036             : 
  119037             : #ifndef ROSE_ALLOC_TRACE
  119038             : #  define ROSE_ALLOC_TRACE 0
  119039             : #endif
  119040             : 
  119041             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  119042             : #define ROSE_ALLOC_TRACE_CNT
  119043             : #include "memory-pool-snapshot.h"
  119044             : unsigned long alloc_trace_cnt = 0;
  119045             : #endif
  119046             : 
  119047             : #if ROSE_ALLOC_TRACE
  119048             : const unsigned SgAssertStmt::pool_size = 5;
  119049             : #else
  119050             : const unsigned SgAssertStmt::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  119051             : #endif
  119052             : 
  119053             : #ifndef ROSE_ALLOC_MEMSET
  119054             : #  define ROSE_ALLOC_MEMSET 0
  119055             : #endif
  119056             : 
  119057             : #ifndef ROSE_PEDANTIC_ALLOC
  119058             : #  define ROSE_PEDANTIC_ALLOC 0
  119059             : #endif
  119060             : 
  119061             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  119062             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  119063             : #endif
  119064             : 
  119065             : #if !defined(SGNODE__ALL_POOLS)
  119066             : #define SGNODE__ALL_POOLS
  119067             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  119068             : #endif
  119069             : 
  119070             : SgAssertStmt* SgAssertStmt::next_node = nullptr;
  119071             : std::vector<unsigned char*> SgAssertStmt::pools;
  119072             : 
  119073             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  119074             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  119075             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  119076             : // around this macro definition rather than each use).
  119077             : #ifndef ALLOC_MUTEX
  119078             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  119079             :         do {                                                                     \
  119080             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  119081             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  119082             :                 abort();                                                         \
  119083             :             }                                                                    \
  119084             :         } while (0);
  119085             : #endif
  119086             : 
  119087             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  119088             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  119089             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  119090             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  119091             : 
  119092             : /*! \brief New operator for SgAssertStmt.
  119093             : 
  119094             :    This new operator implements memory pools to provide most efficent 
  119095             :    use of the heap within construction of large ASTs.
  119096             : 
  119097             : \internal The new and delete operators use the lower level C malloc/free
  119098             :    function calls for performance and to make sure that mixing of malloc/free
  119099             :    and new/delete by the used can be caught more readily.  This may change
  119100             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  119101             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  119102             :    deallocate memory allocated using ROSE_MALLOC.
  119103             : */
  119104           0 : void *SgAssertStmt::operator new ( size_t Size )
  119105             : {
  119106             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  119107             :      * returning or throwing an exception. */
  119108           0 :     ALLOC_MUTEX(SgAssertStmt, lock);
  119109             : 
  119110             : #if ROSE_ALLOC_TRACE == 2
  119111             : //    printf("SgAssertStmt::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgAssertStmt::next_node);
  119112             : #endif
  119113             : 
  119114             : #if USE_CPP_NEW_DELETE_OPERATORS
  119115             :     void *mem = ROSE_MALLOC(Size);
  119116             :     ALLOC_MUTEX(SgAssertStmt, unlock);
  119117             :     return mem;
  119118             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  119119             : #if ROSE_PEDANTIC_ALLOC
  119120             :     ROSE_ASSERT(Size == sizeof(SgAssertStmt));
  119121             : #else
  119122           0 :     if (Size != sizeof(SgAssertStmt)) {
  119123           0 :       void * object = ROSE_MALLOC(Size);
  119124           0 :       ALLOC_MUTEX(SgAssertStmt, unlock);
  119125             :       return object;
  119126             :     }
  119127             : #endif
  119128             : 
  119129           0 :     if (SgAssertStmt::next_node == nullptr) {
  119130           0 :         SgAssertStmt * alloc = (SgAssertStmt*) ROSE_MALLOC ( SgAssertStmt::pool_size * sizeof(SgAssertStmt) );
  119131           0 :         ROSE_ASSERT(alloc != nullptr);
  119132             : 
  119133             : #if ROSE_ALLOC_TRACE == 2
  119134             : //        printf("SgAssertStmt::alloc\n  block[%zi] = [ %p , %p [\n", SgAssertStmt::pools.size(), alloc, alloc + SgAssertStmt::pool_size);
  119135             : #endif
  119136             : 
  119137             : #if ROSE_ALLOC_MEMSET == 1
  119138             : #elif ROSE_ALLOC_MEMSET == 2
  119139             :         memset(alloc, 0x00, SgAssertStmt::pool_size * sizeof(SgAssertStmt));
  119140             : #elif ROSE_ALLOC_MEMSET == 3
  119141             :         memset(alloc, 0xAA, SgAssertStmt::pool_size * sizeof(SgAssertStmt));
  119142             : #endif
  119143           0 :         for (unsigned i=0; i < SgAssertStmt::pool_size-1; i++) {
  119144           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
  119145             :         }
  119146           0 :         alloc[SgAssertStmt::pool_size-1].p_freepointer = nullptr;
  119147             : 
  119148           0 :         SgAssertStmt::pools.push_back ( (unsigned char *) alloc );
  119149           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgAssertStmt::pool_size * sizeof(SgAssertStmt), V_SgAssertStmt ) );
  119150           0 :         SgAssertStmt::next_node = alloc;
  119151             :     }
  119152           0 :     ROSE_ASSERT(SgAssertStmt::next_node != nullptr);
  119153             : 
  119154           0 :     SgAssertStmt * object = SgAssertStmt::next_node;
  119155           0 :     SgAssertStmt::next_node = (SgAssertStmt*)(object->p_freepointer);
  119156             : 
  119157             : #if ROSE_ALLOC_TRACE == 2
  119158             :     printf("SgAssertStmt::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgAssertStmt::next_node);
  119159             : #endif
  119160             : 
  119161           0 :     SgNode * fp = object->p_freepointer;
  119162             : #if ROSE_ALLOC_MEMSET == 1
  119163             : #elif ROSE_ALLOC_MEMSET == 2
  119164             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgAssertStmt) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  119165             : #elif ROSE_ALLOC_MEMSET == 3
  119166             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgAssertStmt) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  119167             : #endif
  119168           0 :     object->p_freepointer = fp;
  119169             : 
  119170             : #if ROSE_ALLOC_TRACE == 2
  119171             : //    printf("SgAssertStmt::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgAssertStmt::next_node);
  119172             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  119173             :     Rose::MemPool::snapshot(oss.str());
  119174             :     alloc_trace_cnt++;
  119175             : #endif
  119176             : 
  119177           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  119178             : 
  119179           0 :     ALLOC_MUTEX(SgAssertStmt, unlock);
  119180             : 
  119181             :     return object;
  119182             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  119183             : }
  119184             : 
  119185             : 
  119186             : 
  119187             : /*! \brief Delete operator for SgAssertStmt.
  119188             : 
  119189             :    This delete operator implements deallocation using memory pools to 
  119190             :    provide most efficent use of the heap within construction of large ASTs.
  119191             : 
  119192             : \internal The new and delete operators use the lower level C malloc/free
  119193             :    function calls for performance and to make sure that mixing of malloc/free
  119194             :    and new/delete by the used can be caught more readily.  This may change
  119195             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  119196             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  119197             :    deallocate memory allocated using ROSE_MALLOC.
  119198             : */
  119199           0 : void SgAssertStmt::operator delete(void *Pointer, size_t Size)
  119200             : {
  119201             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  119202             :      * or throwing an exception. */
  119203           0 :     ALLOC_MUTEX(SgAssertStmt, lock);
  119204             : 
  119205             : #if USE_CPP_NEW_DELETE_OPERATORS
  119206             :     ROSE_FREE(Pointer);
  119207             : #else
  119208             : #if ROSE_PEDANTIC_ALLOC
  119209             :     ROSE_ASSERT(Size == sizeof(SgAssertStmt));
  119210             : #else
  119211           0 :     if (Size != sizeof(SgAssertStmt)) {
  119212           0 :       ROSE_FREE(Pointer);
  119213           0 :       ALLOC_MUTEX(SgAssertStmt, unlock);
  119214             :       return;
  119215             :     }
  119216             : #endif
  119217             : 
  119218           0 :     SgAssertStmt * object = (SgAssertStmt*) Pointer;
  119219           0 :     ROSE_ASSERT(object != nullptr);
  119220             : 
  119221             : #if ROSE_ALLOC_TRACE == 2
  119222             : //  printf("SgAssertStmt::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgAssertStmt::next_node);
  119223             :     printf("SgAssertStmt::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgAssertStmt::next_node);
  119224             : #endif
  119225             : 
  119226             : #if ROSE_PEDANTIC_ALLOC
  119227             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  119228             : #endif
  119229             : 
  119230             : #if ROSE_ALLOC_MEMSET == 1
  119231             : #elif ROSE_ALLOC_MEMSET == 2
  119232             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgAssertStmt) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  119233             : #elif ROSE_ALLOC_MEMSET == 3
  119234             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgAssertStmt) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  119235             : #endif
  119236             : 
  119237             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  119238             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  119239             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  119240             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  119241             : #else
  119242           0 :     object->p_freepointer = SgAssertStmt::next_node;
  119243           0 :     SgAssertStmt::next_node = object;
  119244             : #endif
  119245             : 
  119246             : #if ROSE_ALLOC_TRACE == 2
  119247             : //  printf("SgAssertStmt::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgAssertStmt::next_node);
  119248             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  119249             :     Rose::MemPool::snapshot(oss.str());
  119250             :     alloc_trace_cnt++;
  119251             : #endif
  119252             : 
  119253             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  119254             : 
  119255           0 :     ALLOC_MUTEX(SgAssertStmt, unlock);
  119256             : }
  119257             : 
  119258             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  119259             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  119260             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  119261             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  119262             : // Also, note comment below from Robb (copied from the Common.code file).
  119263             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  119264             : //
  119265             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  119266             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  119267             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  119268             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  119269             : #if 0
  119270             : void SgAssertStmt::operator delete(void* pointer) { SgAssertStmt::operator delete (pointer, sizeof(SgAssertStmt)); };
  119271             : #endif
  119272             : /* #line 119273 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  119273             : 
  119274             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  119275             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  119276             : // obviously imply C++.
  119277             : 
  119278             : // This implements the support within ROSE for memory pools.  Memory pools
  119279             : // support the most condensed usage of memory within the construction of
  119280             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  119281             : // by a new operator written for each class.
  119282             : 
  119283             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  119284             :     // User wants multi-thread support and POSIX threads are available.
  119285             : #   include <pthread.h>
  119286             :     static pthread_mutex_t SgExecStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  119287             : #else
  119288             :      // Cause synchronization to be skipped.
  119289             : #    ifndef ALLOC_MUTEX
  119290             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  119291             : #    endif
  119292             : #    ifdef _REENTRANT
  119293             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  119294             : #       ifdef _MSC_VER
  119295             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  119296             : #       else
  119297             : #           warning "POSIX threads are not available; synchronization being skipped"
  119298             : #       endif
  119299             : #    endif
  119300             : #endif
  119301             : 
  119302             : #ifndef ROSE_ALLOC_TRACE
  119303             : #  define ROSE_ALLOC_TRACE 0
  119304             : #endif
  119305             : 
  119306             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  119307             : #define ROSE_ALLOC_TRACE_CNT
  119308             : #include "memory-pool-snapshot.h"
  119309             : unsigned long alloc_trace_cnt = 0;
  119310             : #endif
  119311             : 
  119312             : #if ROSE_ALLOC_TRACE
  119313             : const unsigned SgExecStatement::pool_size = 5;
  119314             : #else
  119315             : const unsigned SgExecStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  119316             : #endif
  119317             : 
  119318             : #ifndef ROSE_ALLOC_MEMSET
  119319             : #  define ROSE_ALLOC_MEMSET 0
  119320             : #endif
  119321             : 
  119322             : #ifndef ROSE_PEDANTIC_ALLOC
  119323             : #  define ROSE_PEDANTIC_ALLOC 0
  119324             : #endif
  119325             : 
  119326             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  119327             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  119328             : #endif
  119329             : 
  119330             : #if !defined(SGNODE__ALL_POOLS)
  119331             : #define SGNODE__ALL_POOLS
  119332             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  119333             : #endif
  119334             : 
  119335             : SgExecStatement* SgExecStatement::next_node = nullptr;
  119336             : std::vector<unsigned char*> SgExecStatement::pools;
  119337             : 
  119338             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  119339             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  119340             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  119341             : // around this macro definition rather than each use).
  119342             : #ifndef ALLOC_MUTEX
  119343             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  119344             :         do {                                                                     \
  119345             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  119346             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  119347             :                 abort();                                                         \
  119348             :             }                                                                    \
  119349             :         } while (0);
  119350             : #endif
  119351             : 
  119352             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  119353             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  119354             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  119355             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  119356             : 
  119357             : /*! \brief New operator for SgExecStatement.
  119358             : 
  119359             :    This new operator implements memory pools to provide most efficent 
  119360             :    use of the heap within construction of large ASTs.
  119361             : 
  119362             : \internal The new and delete operators use the lower level C malloc/free
  119363             :    function calls for performance and to make sure that mixing of malloc/free
  119364             :    and new/delete by the used can be caught more readily.  This may change
  119365             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  119366             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  119367             :    deallocate memory allocated using ROSE_MALLOC.
  119368             : */
  119369           0 : void *SgExecStatement::operator new ( size_t Size )
  119370             : {
  119371             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  119372             :      * returning or throwing an exception. */
  119373           0 :     ALLOC_MUTEX(SgExecStatement, lock);
  119374             : 
  119375             : #if ROSE_ALLOC_TRACE == 2
  119376             : //    printf("SgExecStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgExecStatement::next_node);
  119377             : #endif
  119378             : 
  119379             : #if USE_CPP_NEW_DELETE_OPERATORS
  119380             :     void *mem = ROSE_MALLOC(Size);
  119381             :     ALLOC_MUTEX(SgExecStatement, unlock);
  119382             :     return mem;
  119383             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  119384             : #if ROSE_PEDANTIC_ALLOC
  119385             :     ROSE_ASSERT(Size == sizeof(SgExecStatement));
  119386             : #else
  119387           0 :     if (Size != sizeof(SgExecStatement)) {
  119388           0 :       void * object = ROSE_MALLOC(Size);
  119389           0 :       ALLOC_MUTEX(SgExecStatement, unlock);
  119390             :       return object;
  119391             :     }
  119392             : #endif
  119393             : 
  119394           0 :     if (SgExecStatement::next_node == nullptr) {
  119395           0 :         SgExecStatement * alloc = (SgExecStatement*) ROSE_MALLOC ( SgExecStatement::pool_size * sizeof(SgExecStatement) );
  119396           0 :         ROSE_ASSERT(alloc != nullptr);
  119397             : 
  119398             : #if ROSE_ALLOC_TRACE == 2
  119399             : //        printf("SgExecStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgExecStatement::pools.size(), alloc, alloc + SgExecStatement::pool_size);
  119400             : #endif
  119401             : 
  119402             : #if ROSE_ALLOC_MEMSET == 1
  119403             : #elif ROSE_ALLOC_MEMSET == 2
  119404             :         memset(alloc, 0x00, SgExecStatement::pool_size * sizeof(SgExecStatement));
  119405             : #elif ROSE_ALLOC_MEMSET == 3
  119406             :         memset(alloc, 0xAA, SgExecStatement::pool_size * sizeof(SgExecStatement));
  119407             : #endif
  119408           0 :         for (unsigned i=0; i < SgExecStatement::pool_size-1; i++) {
  119409           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
  119410             :         }
  119411           0 :         alloc[SgExecStatement::pool_size-1].p_freepointer = nullptr;
  119412             : 
  119413           0 :         SgExecStatement::pools.push_back ( (unsigned char *) alloc );
  119414           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgExecStatement::pool_size * sizeof(SgExecStatement), V_SgExecStatement ) );
  119415           0 :         SgExecStatement::next_node = alloc;
  119416             :     }
  119417           0 :     ROSE_ASSERT(SgExecStatement::next_node != nullptr);
  119418             : 
  119419           0 :     SgExecStatement * object = SgExecStatement::next_node;
  119420           0 :     SgExecStatement::next_node = (SgExecStatement*)(object->p_freepointer);
  119421             : 
  119422             : #if ROSE_ALLOC_TRACE == 2
  119423             :     printf("SgExecStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgExecStatement::next_node);
  119424             : #endif
  119425             : 
  119426           0 :     SgNode * fp = object->p_freepointer;
  119427             : #if ROSE_ALLOC_MEMSET == 1
  119428             : #elif ROSE_ALLOC_MEMSET == 2
  119429             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgExecStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  119430             : #elif ROSE_ALLOC_MEMSET == 3
  119431             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgExecStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  119432             : #endif
  119433           0 :     object->p_freepointer = fp;
  119434             : 
  119435             : #if ROSE_ALLOC_TRACE == 2
  119436             : //    printf("SgExecStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgExecStatement::next_node);
  119437             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  119438             :     Rose::MemPool::snapshot(oss.str());
  119439             :     alloc_trace_cnt++;
  119440             : #endif
  119441             : 
  119442           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  119443             : 
  119444           0 :     ALLOC_MUTEX(SgExecStatement, unlock);
  119445             : 
  119446             :     return object;
  119447             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  119448             : }
  119449             : 
  119450             : 
  119451             : 
  119452             : /*! \brief Delete operator for SgExecStatement.
  119453             : 
  119454             :    This delete operator implements deallocation using memory pools to 
  119455             :    provide most efficent use of the heap within construction of large ASTs.
  119456             : 
  119457             : \internal The new and delete operators use the lower level C malloc/free
  119458             :    function calls for performance and to make sure that mixing of malloc/free
  119459             :    and new/delete by the used can be caught more readily.  This may change
  119460             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  119461             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  119462             :    deallocate memory allocated using ROSE_MALLOC.
  119463             : */
  119464           0 : void SgExecStatement::operator delete(void *Pointer, size_t Size)
  119465             : {
  119466             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  119467             :      * or throwing an exception. */
  119468           0 :     ALLOC_MUTEX(SgExecStatement, lock);
  119469             : 
  119470             : #if USE_CPP_NEW_DELETE_OPERATORS
  119471             :     ROSE_FREE(Pointer);
  119472             : #else
  119473             : #if ROSE_PEDANTIC_ALLOC
  119474             :     ROSE_ASSERT(Size == sizeof(SgExecStatement));
  119475             : #else
  119476           0 :     if (Size != sizeof(SgExecStatement)) {
  119477           0 :       ROSE_FREE(Pointer);
  119478           0 :       ALLOC_MUTEX(SgExecStatement, unlock);
  119479             :       return;
  119480             :     }
  119481             : #endif
  119482             : 
  119483           0 :     SgExecStatement * object = (SgExecStatement*) Pointer;
  119484           0 :     ROSE_ASSERT(object != nullptr);
  119485             : 
  119486             : #if ROSE_ALLOC_TRACE == 2
  119487             : //  printf("SgExecStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgExecStatement::next_node);
  119488             :     printf("SgExecStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgExecStatement::next_node);
  119489             : #endif
  119490             : 
  119491             : #if ROSE_PEDANTIC_ALLOC
  119492             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  119493             : #endif
  119494             : 
  119495             : #if ROSE_ALLOC_MEMSET == 1
  119496             : #elif ROSE_ALLOC_MEMSET == 2
  119497             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgExecStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  119498             : #elif ROSE_ALLOC_MEMSET == 3
  119499             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgExecStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  119500             : #endif
  119501             : 
  119502             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  119503             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  119504             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  119505             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  119506             : #else
  119507           0 :     object->p_freepointer = SgExecStatement::next_node;
  119508           0 :     SgExecStatement::next_node = object;
  119509             : #endif
  119510             : 
  119511             : #if ROSE_ALLOC_TRACE == 2
  119512             : //  printf("SgExecStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgExecStatement::next_node);
  119513             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  119514             :     Rose::MemPool::snapshot(oss.str());
  119515             :     alloc_trace_cnt++;
  119516             : #endif
  119517             : 
  119518             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  119519             : 
  119520           0 :     ALLOC_MUTEX(SgExecStatement, unlock);
  119521             : }
  119522             : 
  119523             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  119524             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  119525             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  119526             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  119527             : // Also, note comment below from Robb (copied from the Common.code file).
  119528             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  119529             : //
  119530             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  119531             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  119532             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  119533             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  119534             : #if 0
  119535             : void SgExecStatement::operator delete(void* pointer) { SgExecStatement::operator delete (pointer, sizeof(SgExecStatement)); };
  119536             : #endif
  119537             : /* #line 119538 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  119538             : 
  119539             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  119540             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  119541             : // obviously imply C++.
  119542             : 
  119543             : // This implements the support within ROSE for memory pools.  Memory pools
  119544             : // support the most condensed usage of memory within the construction of
  119545             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  119546             : // by a new operator written for each class.
  119547             : 
  119548             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  119549             :     // User wants multi-thread support and POSIX threads are available.
  119550             : #   include <pthread.h>
  119551             :     static pthread_mutex_t SgImageControlStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  119552             : #else
  119553             :      // Cause synchronization to be skipped.
  119554             : #    ifndef ALLOC_MUTEX
  119555             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  119556             : #    endif
  119557             : #    ifdef _REENTRANT
  119558             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  119559             : #       ifdef _MSC_VER
  119560             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  119561             : #       else
  119562             : #           warning "POSIX threads are not available; synchronization being skipped"
  119563             : #       endif
  119564             : #    endif
  119565             : #endif
  119566             : 
  119567             : #ifndef ROSE_ALLOC_TRACE
  119568             : #  define ROSE_ALLOC_TRACE 0
  119569             : #endif
  119570             : 
  119571             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  119572             : #define ROSE_ALLOC_TRACE_CNT
  119573             : #include "memory-pool-snapshot.h"
  119574             : unsigned long alloc_trace_cnt = 0;
  119575             : #endif
  119576             : 
  119577             : #if ROSE_ALLOC_TRACE
  119578             : const unsigned SgImageControlStatement::pool_size = 5;
  119579             : #else
  119580             : const unsigned SgImageControlStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  119581             : #endif
  119582             : 
  119583             : #ifndef ROSE_ALLOC_MEMSET
  119584             : #  define ROSE_ALLOC_MEMSET 0
  119585             : #endif
  119586             : 
  119587             : #ifndef ROSE_PEDANTIC_ALLOC
  119588             : #  define ROSE_PEDANTIC_ALLOC 0
  119589             : #endif
  119590             : 
  119591             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  119592             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  119593             : #endif
  119594             : 
  119595             : #if !defined(SGNODE__ALL_POOLS)
  119596             : #define SGNODE__ALL_POOLS
  119597             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  119598             : #endif
  119599             : 
  119600             : SgImageControlStatement* SgImageControlStatement::next_node = nullptr;
  119601             : std::vector<unsigned char*> SgImageControlStatement::pools;
  119602             : 
  119603             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  119604             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  119605             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  119606             : // around this macro definition rather than each use).
  119607             : #ifndef ALLOC_MUTEX
  119608             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  119609             :         do {                                                                     \
  119610             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  119611             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  119612             :                 abort();                                                         \
  119613             :             }                                                                    \
  119614             :         } while (0);
  119615             : #endif
  119616             : 
  119617             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  119618             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  119619             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  119620             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  119621             : 
  119622             : /*! \brief New operator for SgImageControlStatement.
  119623             : 
  119624             :    This new operator implements memory pools to provide most efficent 
  119625             :    use of the heap within construction of large ASTs.
  119626             : 
  119627             : \internal The new and delete operators use the lower level C malloc/free
  119628             :    function calls for performance and to make sure that mixing of malloc/free
  119629             :    and new/delete by the used can be caught more readily.  This may change
  119630             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  119631             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  119632             :    deallocate memory allocated using ROSE_MALLOC.
  119633             : */
  119634           0 : void *SgImageControlStatement::operator new ( size_t Size )
  119635             : {
  119636             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  119637             :      * returning or throwing an exception. */
  119638           0 :     ALLOC_MUTEX(SgImageControlStatement, lock);
  119639             : 
  119640             : #if ROSE_ALLOC_TRACE == 2
  119641             : //    printf("SgImageControlStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgImageControlStatement::next_node);
  119642             : #endif
  119643             : 
  119644             : #if USE_CPP_NEW_DELETE_OPERATORS
  119645             :     void *mem = ROSE_MALLOC(Size);
  119646             :     ALLOC_MUTEX(SgImageControlStatement, unlock);
  119647             :     return mem;
  119648             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  119649             : #if ROSE_PEDANTIC_ALLOC
  119650             :     ROSE_ASSERT(Size == sizeof(SgImageControlStatement));
  119651             : #else
  119652           0 :     if (Size != sizeof(SgImageControlStatement)) {
  119653           0 :       void * object = ROSE_MALLOC(Size);
  119654           0 :       ALLOC_MUTEX(SgImageControlStatement, unlock);
  119655             :       return object;
  119656             :     }
  119657             : #endif
  119658             : 
  119659           0 :     if (SgImageControlStatement::next_node == nullptr) {
  119660           0 :         SgImageControlStatement * alloc = (SgImageControlStatement*) ROSE_MALLOC ( SgImageControlStatement::pool_size * sizeof(SgImageControlStatement) );
  119661           0 :         ROSE_ASSERT(alloc != nullptr);
  119662             : 
  119663             : #if ROSE_ALLOC_TRACE == 2
  119664             : //        printf("SgImageControlStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgImageControlStatement::pools.size(), alloc, alloc + SgImageControlStatement::pool_size);
  119665             : #endif
  119666             : 
  119667             : #if ROSE_ALLOC_MEMSET == 1
  119668             : #elif ROSE_ALLOC_MEMSET == 2
  119669             :         memset(alloc, 0x00, SgImageControlStatement::pool_size * sizeof(SgImageControlStatement));
  119670             : #elif ROSE_ALLOC_MEMSET == 3
  119671             :         memset(alloc, 0xAA, SgImageControlStatement::pool_size * sizeof(SgImageControlStatement));
  119672             : #endif
  119673           0 :         for (unsigned i=0; i < SgImageControlStatement::pool_size-1; i++) {
  119674           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
  119675             :         }
  119676           0 :         alloc[SgImageControlStatement::pool_size-1].p_freepointer = nullptr;
  119677             : 
  119678           0 :         SgImageControlStatement::pools.push_back ( (unsigned char *) alloc );
  119679           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgImageControlStatement::pool_size * sizeof(SgImageControlStatement), V_SgImageControlStatement ) );
  119680           0 :         SgImageControlStatement::next_node = alloc;
  119681             :     }
  119682           0 :     ROSE_ASSERT(SgImageControlStatement::next_node != nullptr);
  119683             : 
  119684           0 :     SgImageControlStatement * object = SgImageControlStatement::next_node;
  119685           0 :     SgImageControlStatement::next_node = (SgImageControlStatement*)(object->p_freepointer);
  119686             : 
  119687             : #if ROSE_ALLOC_TRACE == 2
  119688             :     printf("SgImageControlStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgImageControlStatement::next_node);
  119689             : #endif
  119690             : 
  119691           0 :     SgNode * fp = object->p_freepointer;
  119692             : #if ROSE_ALLOC_MEMSET == 1
  119693             : #elif ROSE_ALLOC_MEMSET == 2
  119694             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgImageControlStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  119695             : #elif ROSE_ALLOC_MEMSET == 3
  119696             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgImageControlStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  119697             : #endif
  119698           0 :     object->p_freepointer = fp;
  119699             : 
  119700             : #if ROSE_ALLOC_TRACE == 2
  119701             : //    printf("SgImageControlStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgImageControlStatement::next_node);
  119702             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  119703             :     Rose::MemPool::snapshot(oss.str());
  119704             :     alloc_trace_cnt++;
  119705             : #endif
  119706             : 
  119707           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  119708             : 
  119709           0 :     ALLOC_MUTEX(SgImageControlStatement, unlock);
  119710             : 
  119711             :     return object;
  119712             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  119713             : }
  119714             : 
  119715             : 
  119716             : 
  119717             : /*! \brief Delete operator for SgImageControlStatement.
  119718             : 
  119719             :    This delete operator implements deallocation using memory pools to 
  119720             :    provide most efficent use of the heap within construction of large ASTs.
  119721             : 
  119722             : \internal The new and delete operators use the lower level C malloc/free
  119723             :    function calls for performance and to make sure that mixing of malloc/free
  119724             :    and new/delete by the used can be caught more readily.  This may change
  119725             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  119726             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  119727             :    deallocate memory allocated using ROSE_MALLOC.
  119728             : */
  119729           0 : void SgImageControlStatement::operator delete(void *Pointer, size_t Size)
  119730             : {
  119731             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  119732             :      * or throwing an exception. */
  119733           0 :     ALLOC_MUTEX(SgImageControlStatement, lock);
  119734             : 
  119735             : #if USE_CPP_NEW_DELETE_OPERATORS
  119736             :     ROSE_FREE(Pointer);
  119737             : #else
  119738             : #if ROSE_PEDANTIC_ALLOC
  119739             :     ROSE_ASSERT(Size == sizeof(SgImageControlStatement));
  119740             : #else
  119741           0 :     if (Size != sizeof(SgImageControlStatement)) {
  119742           0 :       ROSE_FREE(Pointer);
  119743           0 :       ALLOC_MUTEX(SgImageControlStatement, unlock);
  119744             :       return;
  119745             :     }
  119746             : #endif
  119747             : 
  119748           0 :     SgImageControlStatement * object = (SgImageControlStatement*) Pointer;
  119749           0 :     ROSE_ASSERT(object != nullptr);
  119750             : 
  119751             : #if ROSE_ALLOC_TRACE == 2
  119752             : //  printf("SgImageControlStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgImageControlStatement::next_node);
  119753             :     printf("SgImageControlStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgImageControlStatement::next_node);
  119754             : #endif
  119755             : 
  119756             : #if ROSE_PEDANTIC_ALLOC
  119757             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  119758             : #endif
  119759             : 
  119760             : #if ROSE_ALLOC_MEMSET == 1
  119761             : #elif ROSE_ALLOC_MEMSET == 2
  119762             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgImageControlStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  119763             : #elif ROSE_ALLOC_MEMSET == 3
  119764             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgImageControlStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  119765             : #endif
  119766             : 
  119767             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  119768             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  119769             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  119770             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  119771             : #else
  119772           0 :     object->p_freepointer = SgImageControlStatement::next_node;
  119773           0 :     SgImageControlStatement::next_node = object;
  119774             : #endif
  119775             : 
  119776             : #if ROSE_ALLOC_TRACE == 2
  119777             : //  printf("SgImageControlStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgImageControlStatement::next_node);
  119778             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  119779             :     Rose::MemPool::snapshot(oss.str());
  119780             :     alloc_trace_cnt++;
  119781             : #endif
  119782             : 
  119783             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  119784             : 
  119785           0 :     ALLOC_MUTEX(SgImageControlStatement, unlock);
  119786             : }
  119787             : 
  119788             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  119789             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  119790             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  119791             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  119792             : // Also, note comment below from Robb (copied from the Common.code file).
  119793             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  119794             : //
  119795             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  119796             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  119797             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  119798             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  119799             : #if 0
  119800             : void SgImageControlStatement::operator delete(void* pointer) { SgImageControlStatement::operator delete (pointer, sizeof(SgImageControlStatement)); };
  119801             : #endif
  119802             : /* #line 119803 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  119803             : 
  119804             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  119805             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  119806             : // obviously imply C++.
  119807             : 
  119808             : // This implements the support within ROSE for memory pools.  Memory pools
  119809             : // support the most condensed usage of memory within the construction of
  119810             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  119811             : // by a new operator written for each class.
  119812             : 
  119813             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  119814             :     // User wants multi-thread support and POSIX threads are available.
  119815             : #   include <pthread.h>
  119816             :     static pthread_mutex_t SgSyncAllStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  119817             : #else
  119818             :      // Cause synchronization to be skipped.
  119819             : #    ifndef ALLOC_MUTEX
  119820             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  119821             : #    endif
  119822             : #    ifdef _REENTRANT
  119823             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  119824             : #       ifdef _MSC_VER
  119825             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  119826             : #       else
  119827             : #           warning "POSIX threads are not available; synchronization being skipped"
  119828             : #       endif
  119829             : #    endif
  119830             : #endif
  119831             : 
  119832             : #ifndef ROSE_ALLOC_TRACE
  119833             : #  define ROSE_ALLOC_TRACE 0
  119834             : #endif
  119835             : 
  119836             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  119837             : #define ROSE_ALLOC_TRACE_CNT
  119838             : #include "memory-pool-snapshot.h"
  119839             : unsigned long alloc_trace_cnt = 0;
  119840             : #endif
  119841             : 
  119842             : #if ROSE_ALLOC_TRACE
  119843             : const unsigned SgSyncAllStatement::pool_size = 5;
  119844             : #else
  119845             : const unsigned SgSyncAllStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  119846             : #endif
  119847             : 
  119848             : #ifndef ROSE_ALLOC_MEMSET
  119849             : #  define ROSE_ALLOC_MEMSET 0
  119850             : #endif
  119851             : 
  119852             : #ifndef ROSE_PEDANTIC_ALLOC
  119853             : #  define ROSE_PEDANTIC_ALLOC 0
  119854             : #endif
  119855             : 
  119856             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  119857             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  119858             : #endif
  119859             : 
  119860             : #if !defined(SGNODE__ALL_POOLS)
  119861             : #define SGNODE__ALL_POOLS
  119862             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  119863             : #endif
  119864             : 
  119865             : SgSyncAllStatement* SgSyncAllStatement::next_node = nullptr;
  119866             : std::vector<unsigned char*> SgSyncAllStatement::pools;
  119867             : 
  119868             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  119869             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  119870             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  119871             : // around this macro definition rather than each use).
  119872             : #ifndef ALLOC_MUTEX
  119873             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  119874             :         do {                                                                     \
  119875             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  119876             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  119877             :                 abort();                                                         \
  119878             :             }                                                                    \
  119879             :         } while (0);
  119880             : #endif
  119881             : 
  119882             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  119883             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  119884             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  119885             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  119886             : 
  119887             : /*! \brief New operator for SgSyncAllStatement.
  119888             : 
  119889             :    This new operator implements memory pools to provide most efficent 
  119890             :    use of the heap within construction of large ASTs.
  119891             : 
  119892             : \internal The new and delete operators use the lower level C malloc/free
  119893             :    function calls for performance and to make sure that mixing of malloc/free
  119894             :    and new/delete by the used can be caught more readily.  This may change
  119895             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  119896             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  119897             :    deallocate memory allocated using ROSE_MALLOC.
  119898             : */
  119899           0 : void *SgSyncAllStatement::operator new ( size_t Size )
  119900             : {
  119901             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  119902             :      * returning or throwing an exception. */
  119903           0 :     ALLOC_MUTEX(SgSyncAllStatement, lock);
  119904             : 
  119905             : #if ROSE_ALLOC_TRACE == 2
  119906             : //    printf("SgSyncAllStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgSyncAllStatement::next_node);
  119907             : #endif
  119908             : 
  119909             : #if USE_CPP_NEW_DELETE_OPERATORS
  119910             :     void *mem = ROSE_MALLOC(Size);
  119911             :     ALLOC_MUTEX(SgSyncAllStatement, unlock);
  119912             :     return mem;
  119913             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  119914             : #if ROSE_PEDANTIC_ALLOC
  119915             :     ROSE_ASSERT(Size == sizeof(SgSyncAllStatement));
  119916             : #else
  119917           0 :     if (Size != sizeof(SgSyncAllStatement)) {
  119918           0 :       void * object = ROSE_MALLOC(Size);
  119919           0 :       ALLOC_MUTEX(SgSyncAllStatement, unlock);
  119920             :       return object;
  119921             :     }
  119922             : #endif
  119923             : 
  119924           0 :     if (SgSyncAllStatement::next_node == nullptr) {
  119925           0 :         SgSyncAllStatement * alloc = (SgSyncAllStatement*) ROSE_MALLOC ( SgSyncAllStatement::pool_size * sizeof(SgSyncAllStatement) );
  119926           0 :         ROSE_ASSERT(alloc != nullptr);
  119927             : 
  119928             : #if ROSE_ALLOC_TRACE == 2
  119929             : //        printf("SgSyncAllStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgSyncAllStatement::pools.size(), alloc, alloc + SgSyncAllStatement::pool_size);
  119930             : #endif
  119931             : 
  119932             : #if ROSE_ALLOC_MEMSET == 1
  119933             : #elif ROSE_ALLOC_MEMSET == 2
  119934             :         memset(alloc, 0x00, SgSyncAllStatement::pool_size * sizeof(SgSyncAllStatement));
  119935             : #elif ROSE_ALLOC_MEMSET == 3
  119936             :         memset(alloc, 0xAA, SgSyncAllStatement::pool_size * sizeof(SgSyncAllStatement));
  119937             : #endif
  119938           0 :         for (unsigned i=0; i < SgSyncAllStatement::pool_size-1; i++) {
  119939           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
  119940             :         }
  119941           0 :         alloc[SgSyncAllStatement::pool_size-1].p_freepointer = nullptr;
  119942             : 
  119943           0 :         SgSyncAllStatement::pools.push_back ( (unsigned char *) alloc );
  119944           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgSyncAllStatement::pool_size * sizeof(SgSyncAllStatement), V_SgSyncAllStatement ) );
  119945           0 :         SgSyncAllStatement::next_node = alloc;
  119946             :     }
  119947           0 :     ROSE_ASSERT(SgSyncAllStatement::next_node != nullptr);
  119948             : 
  119949           0 :     SgSyncAllStatement * object = SgSyncAllStatement::next_node;
  119950           0 :     SgSyncAllStatement::next_node = (SgSyncAllStatement*)(object->p_freepointer);
  119951             : 
  119952             : #if ROSE_ALLOC_TRACE == 2
  119953             :     printf("SgSyncAllStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgSyncAllStatement::next_node);
  119954             : #endif
  119955             : 
  119956           0 :     SgNode * fp = object->p_freepointer;
  119957             : #if ROSE_ALLOC_MEMSET == 1
  119958             : #elif ROSE_ALLOC_MEMSET == 2
  119959             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgSyncAllStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  119960             : #elif ROSE_ALLOC_MEMSET == 3
  119961             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgSyncAllStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  119962             : #endif
  119963           0 :     object->p_freepointer = fp;
  119964             : 
  119965             : #if ROSE_ALLOC_TRACE == 2
  119966             : //    printf("SgSyncAllStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgSyncAllStatement::next_node);
  119967             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  119968             :     Rose::MemPool::snapshot(oss.str());
  119969             :     alloc_trace_cnt++;
  119970             : #endif
  119971             : 
  119972           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  119973             : 
  119974           0 :     ALLOC_MUTEX(SgSyncAllStatement, unlock);
  119975             : 
  119976             :     return object;
  119977             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  119978             : }
  119979             : 
  119980             : 
  119981             : 
  119982             : /*! \brief Delete operator for SgSyncAllStatement.
  119983             : 
  119984             :    This delete operator implements deallocation using memory pools to 
  119985             :    provide most efficent use of the heap within construction of large ASTs.
  119986             : 
  119987             : \internal The new and delete operators use the lower level C malloc/free
  119988             :    function calls for performance and to make sure that mixing of malloc/free
  119989             :    and new/delete by the used can be caught more readily.  This may change
  119990             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  119991             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  119992             :    deallocate memory allocated using ROSE_MALLOC.
  119993             : */
  119994           0 : void SgSyncAllStatement::operator delete(void *Pointer, size_t Size)
  119995             : {
  119996             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  119997             :      * or throwing an exception. */
  119998           0 :     ALLOC_MUTEX(SgSyncAllStatement, lock);
  119999             : 
  120000             : #if USE_CPP_NEW_DELETE_OPERATORS
  120001             :     ROSE_FREE(Pointer);
  120002             : #else
  120003             : #if ROSE_PEDANTIC_ALLOC
  120004             :     ROSE_ASSERT(Size == sizeof(SgSyncAllStatement));
  120005             : #else
  120006           0 :     if (Size != sizeof(SgSyncAllStatement)) {
  120007           0 :       ROSE_FREE(Pointer);
  120008           0 :       ALLOC_MUTEX(SgSyncAllStatement, unlock);
  120009             :       return;
  120010             :     }
  120011             : #endif
  120012             : 
  120013           0 :     SgSyncAllStatement * object = (SgSyncAllStatement*) Pointer;
  120014           0 :     ROSE_ASSERT(object != nullptr);
  120015             : 
  120016             : #if ROSE_ALLOC_TRACE == 2
  120017             : //  printf("SgSyncAllStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgSyncAllStatement::next_node);
  120018             :     printf("SgSyncAllStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgSyncAllStatement::next_node);
  120019             : #endif
  120020             : 
  120021             : #if ROSE_PEDANTIC_ALLOC
  120022             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  120023             : #endif
  120024             : 
  120025             : #if ROSE_ALLOC_MEMSET == 1
  120026             : #elif ROSE_ALLOC_MEMSET == 2
  120027             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgSyncAllStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  120028             : #elif ROSE_ALLOC_MEMSET == 3
  120029             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgSyncAllStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  120030             : #endif
  120031             : 
  120032             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  120033             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  120034             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  120035             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  120036             : #else
  120037           0 :     object->p_freepointer = SgSyncAllStatement::next_node;
  120038           0 :     SgSyncAllStatement::next_node = object;
  120039             : #endif
  120040             : 
  120041             : #if ROSE_ALLOC_TRACE == 2
  120042             : //  printf("SgSyncAllStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgSyncAllStatement::next_node);
  120043             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  120044             :     Rose::MemPool::snapshot(oss.str());
  120045             :     alloc_trace_cnt++;
  120046             : #endif
  120047             : 
  120048             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  120049             : 
  120050           0 :     ALLOC_MUTEX(SgSyncAllStatement, unlock);
  120051             : }
  120052             : 
  120053             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  120054             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  120055             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  120056             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  120057             : // Also, note comment below from Robb (copied from the Common.code file).
  120058             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  120059             : //
  120060             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  120061             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  120062             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  120063             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  120064             : #if 0
  120065             : void SgSyncAllStatement::operator delete(void* pointer) { SgSyncAllStatement::operator delete (pointer, sizeof(SgSyncAllStatement)); };
  120066             : #endif
  120067             : /* #line 120068 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  120068             : 
  120069             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  120070             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  120071             : // obviously imply C++.
  120072             : 
  120073             : // This implements the support within ROSE for memory pools.  Memory pools
  120074             : // support the most condensed usage of memory within the construction of
  120075             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  120076             : // by a new operator written for each class.
  120077             : 
  120078             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  120079             :     // User wants multi-thread support and POSIX threads are available.
  120080             : #   include <pthread.h>
  120081             :     static pthread_mutex_t SgSyncImagesStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  120082             : #else
  120083             :      // Cause synchronization to be skipped.
  120084             : #    ifndef ALLOC_MUTEX
  120085             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  120086             : #    endif
  120087             : #    ifdef _REENTRANT
  120088             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  120089             : #       ifdef _MSC_VER
  120090             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  120091             : #       else
  120092             : #           warning "POSIX threads are not available; synchronization being skipped"
  120093             : #       endif
  120094             : #    endif
  120095             : #endif
  120096             : 
  120097             : #ifndef ROSE_ALLOC_TRACE
  120098             : #  define ROSE_ALLOC_TRACE 0
  120099             : #endif
  120100             : 
  120101             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  120102             : #define ROSE_ALLOC_TRACE_CNT
  120103             : #include "memory-pool-snapshot.h"
  120104             : unsigned long alloc_trace_cnt = 0;
  120105             : #endif
  120106             : 
  120107             : #if ROSE_ALLOC_TRACE
  120108             : const unsigned SgSyncImagesStatement::pool_size = 5;
  120109             : #else
  120110             : const unsigned SgSyncImagesStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  120111             : #endif
  120112             : 
  120113             : #ifndef ROSE_ALLOC_MEMSET
  120114             : #  define ROSE_ALLOC_MEMSET 0
  120115             : #endif
  120116             : 
  120117             : #ifndef ROSE_PEDANTIC_ALLOC
  120118             : #  define ROSE_PEDANTIC_ALLOC 0
  120119             : #endif
  120120             : 
  120121             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  120122             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  120123             : #endif
  120124             : 
  120125             : #if !defined(SGNODE__ALL_POOLS)
  120126             : #define SGNODE__ALL_POOLS
  120127             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  120128             : #endif
  120129             : 
  120130             : SgSyncImagesStatement* SgSyncImagesStatement::next_node = nullptr;
  120131             : std::vector<unsigned char*> SgSyncImagesStatement::pools;
  120132             : 
  120133             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  120134             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  120135             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  120136             : // around this macro definition rather than each use).
  120137             : #ifndef ALLOC_MUTEX
  120138             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  120139             :         do {                                                                     \
  120140             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  120141             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  120142             :                 abort();                                                         \
  120143             :             }                                                                    \
  120144             :         } while (0);
  120145             : #endif
  120146             : 
  120147             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  120148             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  120149             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  120150             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  120151             : 
  120152             : /*! \brief New operator for SgSyncImagesStatement.
  120153             : 
  120154             :    This new operator implements memory pools to provide most efficent 
  120155             :    use of the heap within construction of large ASTs.
  120156             : 
  120157             : \internal The new and delete operators use the lower level C malloc/free
  120158             :    function calls for performance and to make sure that mixing of malloc/free
  120159             :    and new/delete by the used can be caught more readily.  This may change
  120160             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  120161             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  120162             :    deallocate memory allocated using ROSE_MALLOC.
  120163             : */
  120164           0 : void *SgSyncImagesStatement::operator new ( size_t Size )
  120165             : {
  120166             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  120167             :      * returning or throwing an exception. */
  120168           0 :     ALLOC_MUTEX(SgSyncImagesStatement, lock);
  120169             : 
  120170             : #if ROSE_ALLOC_TRACE == 2
  120171             : //    printf("SgSyncImagesStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgSyncImagesStatement::next_node);
  120172             : #endif
  120173             : 
  120174             : #if USE_CPP_NEW_DELETE_OPERATORS
  120175             :     void *mem = ROSE_MALLOC(Size);
  120176             :     ALLOC_MUTEX(SgSyncImagesStatement, unlock);
  120177             :     return mem;
  120178             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  120179             : #if ROSE_PEDANTIC_ALLOC
  120180             :     ROSE_ASSERT(Size == sizeof(SgSyncImagesStatement));
  120181             : #else
  120182           0 :     if (Size != sizeof(SgSyncImagesStatement)) {
  120183           0 :       void * object = ROSE_MALLOC(Size);
  120184           0 :       ALLOC_MUTEX(SgSyncImagesStatement, unlock);
  120185             :       return object;
  120186             :     }
  120187             : #endif
  120188             : 
  120189           0 :     if (SgSyncImagesStatement::next_node == nullptr) {
  120190           0 :         SgSyncImagesStatement * alloc = (SgSyncImagesStatement*) ROSE_MALLOC ( SgSyncImagesStatement::pool_size * sizeof(SgSyncImagesStatement) );
  120191           0 :         ROSE_ASSERT(alloc != nullptr);
  120192             : 
  120193             : #if ROSE_ALLOC_TRACE == 2
  120194             : //        printf("SgSyncImagesStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgSyncImagesStatement::pools.size(), alloc, alloc + SgSyncImagesStatement::pool_size);
  120195             : #endif
  120196             : 
  120197             : #if ROSE_ALLOC_MEMSET == 1
  120198             : #elif ROSE_ALLOC_MEMSET == 2
  120199             :         memset(alloc, 0x00, SgSyncImagesStatement::pool_size * sizeof(SgSyncImagesStatement));
  120200             : #elif ROSE_ALLOC_MEMSET == 3
  120201             :         memset(alloc, 0xAA, SgSyncImagesStatement::pool_size * sizeof(SgSyncImagesStatement));
  120202             : #endif
  120203           0 :         for (unsigned i=0; i < SgSyncImagesStatement::pool_size-1; i++) {
  120204           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
  120205             :         }
  120206           0 :         alloc[SgSyncImagesStatement::pool_size-1].p_freepointer = nullptr;
  120207             : 
  120208           0 :         SgSyncImagesStatement::pools.push_back ( (unsigned char *) alloc );
  120209           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgSyncImagesStatement::pool_size * sizeof(SgSyncImagesStatement), V_SgSyncImagesStatement ) );
  120210           0 :         SgSyncImagesStatement::next_node = alloc;
  120211             :     }
  120212           0 :     ROSE_ASSERT(SgSyncImagesStatement::next_node != nullptr);
  120213             : 
  120214           0 :     SgSyncImagesStatement * object = SgSyncImagesStatement::next_node;
  120215           0 :     SgSyncImagesStatement::next_node = (SgSyncImagesStatement*)(object->p_freepointer);
  120216             : 
  120217             : #if ROSE_ALLOC_TRACE == 2
  120218             :     printf("SgSyncImagesStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgSyncImagesStatement::next_node);
  120219             : #endif
  120220             : 
  120221           0 :     SgNode * fp = object->p_freepointer;
  120222             : #if ROSE_ALLOC_MEMSET == 1
  120223             : #elif ROSE_ALLOC_MEMSET == 2
  120224             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgSyncImagesStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  120225             : #elif ROSE_ALLOC_MEMSET == 3
  120226             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgSyncImagesStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  120227             : #endif
  120228           0 :     object->p_freepointer = fp;
  120229             : 
  120230             : #if ROSE_ALLOC_TRACE == 2
  120231             : //    printf("SgSyncImagesStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgSyncImagesStatement::next_node);
  120232             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  120233             :     Rose::MemPool::snapshot(oss.str());
  120234             :     alloc_trace_cnt++;
  120235             : #endif
  120236             : 
  120237           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  120238             : 
  120239           0 :     ALLOC_MUTEX(SgSyncImagesStatement, unlock);
  120240             : 
  120241             :     return object;
  120242             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  120243             : }
  120244             : 
  120245             : 
  120246             : 
  120247             : /*! \brief Delete operator for SgSyncImagesStatement.
  120248             : 
  120249             :    This delete operator implements deallocation using memory pools to 
  120250             :    provide most efficent use of the heap within construction of large ASTs.
  120251             : 
  120252             : \internal The new and delete operators use the lower level C malloc/free
  120253             :    function calls for performance and to make sure that mixing of malloc/free
  120254             :    and new/delete by the used can be caught more readily.  This may change
  120255             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  120256             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  120257             :    deallocate memory allocated using ROSE_MALLOC.
  120258             : */
  120259           0 : void SgSyncImagesStatement::operator delete(void *Pointer, size_t Size)
  120260             : {
  120261             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  120262             :      * or throwing an exception. */
  120263           0 :     ALLOC_MUTEX(SgSyncImagesStatement, lock);
  120264             : 
  120265             : #if USE_CPP_NEW_DELETE_OPERATORS
  120266             :     ROSE_FREE(Pointer);
  120267             : #else
  120268             : #if ROSE_PEDANTIC_ALLOC
  120269             :     ROSE_ASSERT(Size == sizeof(SgSyncImagesStatement));
  120270             : #else
  120271           0 :     if (Size != sizeof(SgSyncImagesStatement)) {
  120272           0 :       ROSE_FREE(Pointer);
  120273           0 :       ALLOC_MUTEX(SgSyncImagesStatement, unlock);
  120274             :       return;
  120275             :     }
  120276             : #endif
  120277             : 
  120278           0 :     SgSyncImagesStatement * object = (SgSyncImagesStatement*) Pointer;
  120279           0 :     ROSE_ASSERT(object != nullptr);
  120280             : 
  120281             : #if ROSE_ALLOC_TRACE == 2
  120282             : //  printf("SgSyncImagesStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgSyncImagesStatement::next_node);
  120283             :     printf("SgSyncImagesStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgSyncImagesStatement::next_node);
  120284             : #endif
  120285             : 
  120286             : #if ROSE_PEDANTIC_ALLOC
  120287             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  120288             : #endif
  120289             : 
  120290             : #if ROSE_ALLOC_MEMSET == 1
  120291             : #elif ROSE_ALLOC_MEMSET == 2
  120292             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgSyncImagesStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  120293             : #elif ROSE_ALLOC_MEMSET == 3
  120294             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgSyncImagesStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  120295             : #endif
  120296             : 
  120297             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  120298             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  120299             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  120300             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  120301             : #else
  120302           0 :     object->p_freepointer = SgSyncImagesStatement::next_node;
  120303           0 :     SgSyncImagesStatement::next_node = object;
  120304             : #endif
  120305             : 
  120306             : #if ROSE_ALLOC_TRACE == 2
  120307             : //  printf("SgSyncImagesStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgSyncImagesStatement::next_node);
  120308             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  120309             :     Rose::MemPool::snapshot(oss.str());
  120310             :     alloc_trace_cnt++;
  120311             : #endif
  120312             : 
  120313             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  120314             : 
  120315           0 :     ALLOC_MUTEX(SgSyncImagesStatement, unlock);
  120316             : }
  120317             : 
  120318             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  120319             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  120320             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  120321             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  120322             : // Also, note comment below from Robb (copied from the Common.code file).
  120323             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  120324             : //
  120325             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  120326             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  120327             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  120328             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  120329             : #if 0
  120330             : void SgSyncImagesStatement::operator delete(void* pointer) { SgSyncImagesStatement::operator delete (pointer, sizeof(SgSyncImagesStatement)); };
  120331             : #endif
  120332             : /* #line 120333 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  120333             : 
  120334             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  120335             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  120336             : // obviously imply C++.
  120337             : 
  120338             : // This implements the support within ROSE for memory pools.  Memory pools
  120339             : // support the most condensed usage of memory within the construction of
  120340             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  120341             : // by a new operator written for each class.
  120342             : 
  120343             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  120344             :     // User wants multi-thread support and POSIX threads are available.
  120345             : #   include <pthread.h>
  120346             :     static pthread_mutex_t SgSyncMemoryStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  120347             : #else
  120348             :      // Cause synchronization to be skipped.
  120349             : #    ifndef ALLOC_MUTEX
  120350             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  120351             : #    endif
  120352             : #    ifdef _REENTRANT
  120353             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  120354             : #       ifdef _MSC_VER
  120355             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  120356             : #       else
  120357             : #           warning "POSIX threads are not available; synchronization being skipped"
  120358             : #       endif
  120359             : #    endif
  120360             : #endif
  120361             : 
  120362             : #ifndef ROSE_ALLOC_TRACE
  120363             : #  define ROSE_ALLOC_TRACE 0
  120364             : #endif
  120365             : 
  120366             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  120367             : #define ROSE_ALLOC_TRACE_CNT
  120368             : #include "memory-pool-snapshot.h"
  120369             : unsigned long alloc_trace_cnt = 0;
  120370             : #endif
  120371             : 
  120372             : #if ROSE_ALLOC_TRACE
  120373             : const unsigned SgSyncMemoryStatement::pool_size = 5;
  120374             : #else
  120375             : const unsigned SgSyncMemoryStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  120376             : #endif
  120377             : 
  120378             : #ifndef ROSE_ALLOC_MEMSET
  120379             : #  define ROSE_ALLOC_MEMSET 0
  120380             : #endif
  120381             : 
  120382             : #ifndef ROSE_PEDANTIC_ALLOC
  120383             : #  define ROSE_PEDANTIC_ALLOC 0
  120384             : #endif
  120385             : 
  120386             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  120387             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  120388             : #endif
  120389             : 
  120390             : #if !defined(SGNODE__ALL_POOLS)
  120391             : #define SGNODE__ALL_POOLS
  120392             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  120393             : #endif
  120394             : 
  120395             : SgSyncMemoryStatement* SgSyncMemoryStatement::next_node = nullptr;
  120396             : std::vector<unsigned char*> SgSyncMemoryStatement::pools;
  120397             : 
  120398             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  120399             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  120400             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  120401             : // around this macro definition rather than each use).
  120402             : #ifndef ALLOC_MUTEX
  120403             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  120404             :         do {                                                                     \
  120405             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  120406             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  120407             :                 abort();                                                         \
  120408             :             }                                                                    \
  120409             :         } while (0);
  120410             : #endif
  120411             : 
  120412             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  120413             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  120414             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  120415             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  120416             : 
  120417             : /*! \brief New operator for SgSyncMemoryStatement.
  120418             : 
  120419             :    This new operator implements memory pools to provide most efficent 
  120420             :    use of the heap within construction of large ASTs.
  120421             : 
  120422             : \internal The new and delete operators use the lower level C malloc/free
  120423             :    function calls for performance and to make sure that mixing of malloc/free
  120424             :    and new/delete by the used can be caught more readily.  This may change
  120425             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  120426             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  120427             :    deallocate memory allocated using ROSE_MALLOC.
  120428             : */
  120429           0 : void *SgSyncMemoryStatement::operator new ( size_t Size )
  120430             : {
  120431             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  120432             :      * returning or throwing an exception. */
  120433           0 :     ALLOC_MUTEX(SgSyncMemoryStatement, lock);
  120434             : 
  120435             : #if ROSE_ALLOC_TRACE == 2
  120436             : //    printf("SgSyncMemoryStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgSyncMemoryStatement::next_node);
  120437             : #endif
  120438             : 
  120439             : #if USE_CPP_NEW_DELETE_OPERATORS
  120440             :     void *mem = ROSE_MALLOC(Size);
  120441             :     ALLOC_MUTEX(SgSyncMemoryStatement, unlock);
  120442             :     return mem;
  120443             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  120444             : #if ROSE_PEDANTIC_ALLOC
  120445             :     ROSE_ASSERT(Size == sizeof(SgSyncMemoryStatement));
  120446             : #else
  120447           0 :     if (Size != sizeof(SgSyncMemoryStatement)) {
  120448           0 :       void * object = ROSE_MALLOC(Size);
  120449           0 :       ALLOC_MUTEX(SgSyncMemoryStatement, unlock);
  120450             :       return object;
  120451             :     }
  120452             : #endif
  120453             : 
  120454           0 :     if (SgSyncMemoryStatement::next_node == nullptr) {
  120455           0 :         SgSyncMemoryStatement * alloc = (SgSyncMemoryStatement*) ROSE_MALLOC ( SgSyncMemoryStatement::pool_size * sizeof(SgSyncMemoryStatement) );
  120456           0 :         ROSE_ASSERT(alloc != nullptr);
  120457             : 
  120458             : #if ROSE_ALLOC_TRACE == 2
  120459             : //        printf("SgSyncMemoryStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgSyncMemoryStatement::pools.size(), alloc, alloc + SgSyncMemoryStatement::pool_size);
  120460             : #endif
  120461             : 
  120462             : #if ROSE_ALLOC_MEMSET == 1
  120463             : #elif ROSE_ALLOC_MEMSET == 2
  120464             :         memset(alloc, 0x00, SgSyncMemoryStatement::pool_size * sizeof(SgSyncMemoryStatement));
  120465             : #elif ROSE_ALLOC_MEMSET == 3
  120466             :         memset(alloc, 0xAA, SgSyncMemoryStatement::pool_size * sizeof(SgSyncMemoryStatement));
  120467             : #endif
  120468           0 :         for (unsigned i=0; i < SgSyncMemoryStatement::pool_size-1; i++) {
  120469           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
  120470             :         }
  120471           0 :         alloc[SgSyncMemoryStatement::pool_size-1].p_freepointer = nullptr;
  120472             : 
  120473           0 :         SgSyncMemoryStatement::pools.push_back ( (unsigned char *) alloc );
  120474           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgSyncMemoryStatement::pool_size * sizeof(SgSyncMemoryStatement), V_SgSyncMemoryStatement ) );
  120475           0 :         SgSyncMemoryStatement::next_node = alloc;
  120476             :     }
  120477           0 :     ROSE_ASSERT(SgSyncMemoryStatement::next_node != nullptr);
  120478             : 
  120479           0 :     SgSyncMemoryStatement * object = SgSyncMemoryStatement::next_node;
  120480           0 :     SgSyncMemoryStatement::next_node = (SgSyncMemoryStatement*)(object->p_freepointer);
  120481             : 
  120482             : #if ROSE_ALLOC_TRACE == 2
  120483             :     printf("SgSyncMemoryStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgSyncMemoryStatement::next_node);
  120484             : #endif
  120485             : 
  120486           0 :     SgNode * fp = object->p_freepointer;
  120487             : #if ROSE_ALLOC_MEMSET == 1
  120488             : #elif ROSE_ALLOC_MEMSET == 2
  120489             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgSyncMemoryStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  120490             : #elif ROSE_ALLOC_MEMSET == 3
  120491             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgSyncMemoryStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  120492             : #endif
  120493           0 :     object->p_freepointer = fp;
  120494             : 
  120495             : #if ROSE_ALLOC_TRACE == 2
  120496             : //    printf("SgSyncMemoryStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgSyncMemoryStatement::next_node);
  120497             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  120498             :     Rose::MemPool::snapshot(oss.str());
  120499             :     alloc_trace_cnt++;
  120500             : #endif
  120501             : 
  120502           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  120503             : 
  120504           0 :     ALLOC_MUTEX(SgSyncMemoryStatement, unlock);
  120505             : 
  120506             :     return object;
  120507             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  120508             : }
  120509             : 
  120510             : 
  120511             : 
  120512             : /*! \brief Delete operator for SgSyncMemoryStatement.
  120513             : 
  120514             :    This delete operator implements deallocation using memory pools to 
  120515             :    provide most efficent use of the heap within construction of large ASTs.
  120516             : 
  120517             : \internal The new and delete operators use the lower level C malloc/free
  120518             :    function calls for performance and to make sure that mixing of malloc/free
  120519             :    and new/delete by the used can be caught more readily.  This may change
  120520             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  120521             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  120522             :    deallocate memory allocated using ROSE_MALLOC.
  120523             : */
  120524           0 : void SgSyncMemoryStatement::operator delete(void *Pointer, size_t Size)
  120525             : {
  120526             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  120527             :      * or throwing an exception. */
  120528           0 :     ALLOC_MUTEX(SgSyncMemoryStatement, lock);
  120529             : 
  120530             : #if USE_CPP_NEW_DELETE_OPERATORS
  120531             :     ROSE_FREE(Pointer);
  120532             : #else
  120533             : #if ROSE_PEDANTIC_ALLOC
  120534             :     ROSE_ASSERT(Size == sizeof(SgSyncMemoryStatement));
  120535             : #else
  120536           0 :     if (Size != sizeof(SgSyncMemoryStatement)) {
  120537           0 :       ROSE_FREE(Pointer);
  120538           0 :       ALLOC_MUTEX(SgSyncMemoryStatement, unlock);
  120539             :       return;
  120540             :     }
  120541             : #endif
  120542             : 
  120543           0 :     SgSyncMemoryStatement * object = (SgSyncMemoryStatement*) Pointer;
  120544           0 :     ROSE_ASSERT(object != nullptr);
  120545             : 
  120546             : #if ROSE_ALLOC_TRACE == 2
  120547             : //  printf("SgSyncMemoryStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgSyncMemoryStatement::next_node);
  120548             :     printf("SgSyncMemoryStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgSyncMemoryStatement::next_node);
  120549             : #endif
  120550             : 
  120551             : #if ROSE_PEDANTIC_ALLOC
  120552             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  120553             : #endif
  120554             : 
  120555             : #if ROSE_ALLOC_MEMSET == 1
  120556             : #elif ROSE_ALLOC_MEMSET == 2
  120557             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgSyncMemoryStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  120558             : #elif ROSE_ALLOC_MEMSET == 3
  120559             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgSyncMemoryStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  120560             : #endif
  120561             : 
  120562             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  120563             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  120564             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  120565             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  120566             : #else
  120567           0 :     object->p_freepointer = SgSyncMemoryStatement::next_node;
  120568           0 :     SgSyncMemoryStatement::next_node = object;
  120569             : #endif
  120570             : 
  120571             : #if ROSE_ALLOC_TRACE == 2
  120572             : //  printf("SgSyncMemoryStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgSyncMemoryStatement::next_node);
  120573             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  120574             :     Rose::MemPool::snapshot(oss.str());
  120575             :     alloc_trace_cnt++;
  120576             : #endif
  120577             : 
  120578             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  120579             : 
  120580           0 :     ALLOC_MUTEX(SgSyncMemoryStatement, unlock);
  120581             : }
  120582             : 
  120583             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  120584             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  120585             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  120586             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  120587             : // Also, note comment below from Robb (copied from the Common.code file).
  120588             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  120589             : //
  120590             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  120591             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  120592             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  120593             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  120594             : #if 0
  120595             : void SgSyncMemoryStatement::operator delete(void* pointer) { SgSyncMemoryStatement::operator delete (pointer, sizeof(SgSyncMemoryStatement)); };
  120596             : #endif
  120597             : /* #line 120598 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  120598             : 
  120599             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  120600             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  120601             : // obviously imply C++.
  120602             : 
  120603             : // This implements the support within ROSE for memory pools.  Memory pools
  120604             : // support the most condensed usage of memory within the construction of
  120605             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  120606             : // by a new operator written for each class.
  120607             : 
  120608             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  120609             :     // User wants multi-thread support and POSIX threads are available.
  120610             : #   include <pthread.h>
  120611             :     static pthread_mutex_t SgSyncTeamStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  120612             : #else
  120613             :      // Cause synchronization to be skipped.
  120614             : #    ifndef ALLOC_MUTEX
  120615             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  120616             : #    endif
  120617             : #    ifdef _REENTRANT
  120618             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  120619             : #       ifdef _MSC_VER
  120620             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  120621             : #       else
  120622             : #           warning "POSIX threads are not available; synchronization being skipped"
  120623             : #       endif
  120624             : #    endif
  120625             : #endif
  120626             : 
  120627             : #ifndef ROSE_ALLOC_TRACE
  120628             : #  define ROSE_ALLOC_TRACE 0
  120629             : #endif
  120630             : 
  120631             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  120632             : #define ROSE_ALLOC_TRACE_CNT
  120633             : #include "memory-pool-snapshot.h"
  120634             : unsigned long alloc_trace_cnt = 0;
  120635             : #endif
  120636             : 
  120637             : #if ROSE_ALLOC_TRACE
  120638             : const unsigned SgSyncTeamStatement::pool_size = 5;
  120639             : #else
  120640             : const unsigned SgSyncTeamStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  120641             : #endif
  120642             : 
  120643             : #ifndef ROSE_ALLOC_MEMSET
  120644             : #  define ROSE_ALLOC_MEMSET 0
  120645             : #endif
  120646             : 
  120647             : #ifndef ROSE_PEDANTIC_ALLOC
  120648             : #  define ROSE_PEDANTIC_ALLOC 0
  120649             : #endif
  120650             : 
  120651             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  120652             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  120653             : #endif
  120654             : 
  120655             : #if !defined(SGNODE__ALL_POOLS)
  120656             : #define SGNODE__ALL_POOLS
  120657             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  120658             : #endif
  120659             : 
  120660             : SgSyncTeamStatement* SgSyncTeamStatement::next_node = nullptr;
  120661             : std::vector<unsigned char*> SgSyncTeamStatement::pools;
  120662             : 
  120663             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  120664             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  120665             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  120666             : // around this macro definition rather than each use).
  120667             : #ifndef ALLOC_MUTEX
  120668             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  120669             :         do {                                                                     \
  120670             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  120671             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  120672             :                 abort();                                                         \
  120673             :             }                                                                    \
  120674             :         } while (0);
  120675             : #endif
  120676             : 
  120677             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  120678             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  120679             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  120680             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  120681             : 
  120682             : /*! \brief New operator for SgSyncTeamStatement.
  120683             : 
  120684             :    This new operator implements memory pools to provide most efficent 
  120685             :    use of the heap within construction of large ASTs.
  120686             : 
  120687             : \internal The new and delete operators use the lower level C malloc/free
  120688             :    function calls for performance and to make sure that mixing of malloc/free
  120689             :    and new/delete by the used can be caught more readily.  This may change
  120690             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  120691             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  120692             :    deallocate memory allocated using ROSE_MALLOC.
  120693             : */
  120694           0 : void *SgSyncTeamStatement::operator new ( size_t Size )
  120695             : {
  120696             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  120697             :      * returning or throwing an exception. */
  120698           0 :     ALLOC_MUTEX(SgSyncTeamStatement, lock);
  120699             : 
  120700             : #if ROSE_ALLOC_TRACE == 2
  120701             : //    printf("SgSyncTeamStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgSyncTeamStatement::next_node);
  120702             : #endif
  120703             : 
  120704             : #if USE_CPP_NEW_DELETE_OPERATORS
  120705             :     void *mem = ROSE_MALLOC(Size);
  120706             :     ALLOC_MUTEX(SgSyncTeamStatement, unlock);
  120707             :     return mem;
  120708             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  120709             : #if ROSE_PEDANTIC_ALLOC
  120710             :     ROSE_ASSERT(Size == sizeof(SgSyncTeamStatement));
  120711             : #else
  120712           0 :     if (Size != sizeof(SgSyncTeamStatement)) {
  120713           0 :       void * object = ROSE_MALLOC(Size);
  120714           0 :       ALLOC_MUTEX(SgSyncTeamStatement, unlock);
  120715             :       return object;
  120716             :     }
  120717             : #endif
  120718             : 
  120719           0 :     if (SgSyncTeamStatement::next_node == nullptr) {
  120720           0 :         SgSyncTeamStatement * alloc = (SgSyncTeamStatement*) ROSE_MALLOC ( SgSyncTeamStatement::pool_size * sizeof(SgSyncTeamStatement) );
  120721           0 :         ROSE_ASSERT(alloc != nullptr);
  120722             : 
  120723             : #if ROSE_ALLOC_TRACE == 2
  120724             : //        printf("SgSyncTeamStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgSyncTeamStatement::pools.size(), alloc, alloc + SgSyncTeamStatement::pool_size);
  120725             : #endif
  120726             : 
  120727             : #if ROSE_ALLOC_MEMSET == 1
  120728             : #elif ROSE_ALLOC_MEMSET == 2
  120729             :         memset(alloc, 0x00, SgSyncTeamStatement::pool_size * sizeof(SgSyncTeamStatement));
  120730             : #elif ROSE_ALLOC_MEMSET == 3
  120731             :         memset(alloc, 0xAA, SgSyncTeamStatement::pool_size * sizeof(SgSyncTeamStatement));
  120732             : #endif
  120733           0 :         for (unsigned i=0; i < SgSyncTeamStatement::pool_size-1; i++) {
  120734           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
  120735             :         }
  120736           0 :         alloc[SgSyncTeamStatement::pool_size-1].p_freepointer = nullptr;
  120737             : 
  120738           0 :         SgSyncTeamStatement::pools.push_back ( (unsigned char *) alloc );
  120739           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgSyncTeamStatement::pool_size * sizeof(SgSyncTeamStatement), V_SgSyncTeamStatement ) );
  120740           0 :         SgSyncTeamStatement::next_node = alloc;
  120741             :     }
  120742           0 :     ROSE_ASSERT(SgSyncTeamStatement::next_node != nullptr);
  120743             : 
  120744           0 :     SgSyncTeamStatement * object = SgSyncTeamStatement::next_node;
  120745           0 :     SgSyncTeamStatement::next_node = (SgSyncTeamStatement*)(object->p_freepointer);
  120746             : 
  120747             : #if ROSE_ALLOC_TRACE == 2
  120748             :     printf("SgSyncTeamStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgSyncTeamStatement::next_node);
  120749             : #endif
  120750             : 
  120751           0 :     SgNode * fp = object->p_freepointer;
  120752             : #if ROSE_ALLOC_MEMSET == 1
  120753             : #elif ROSE_ALLOC_MEMSET == 2
  120754             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgSyncTeamStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  120755             : #elif ROSE_ALLOC_MEMSET == 3
  120756             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgSyncTeamStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  120757             : #endif
  120758           0 :     object->p_freepointer = fp;
  120759             : 
  120760             : #if ROSE_ALLOC_TRACE == 2
  120761             : //    printf("SgSyncTeamStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgSyncTeamStatement::next_node);
  120762             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  120763             :     Rose::MemPool::snapshot(oss.str());
  120764             :     alloc_trace_cnt++;
  120765             : #endif
  120766             : 
  120767           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  120768             : 
  120769           0 :     ALLOC_MUTEX(SgSyncTeamStatement, unlock);
  120770             : 
  120771             :     return object;
  120772             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  120773             : }
  120774             : 
  120775             : 
  120776             : 
  120777             : /*! \brief Delete operator for SgSyncTeamStatement.
  120778             : 
  120779             :    This delete operator implements deallocation using memory pools to 
  120780             :    provide most efficent use of the heap within construction of large ASTs.
  120781             : 
  120782             : \internal The new and delete operators use the lower level C malloc/free
  120783             :    function calls for performance and to make sure that mixing of malloc/free
  120784             :    and new/delete by the used can be caught more readily.  This may change
  120785             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  120786             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  120787             :    deallocate memory allocated using ROSE_MALLOC.
  120788             : */
  120789           0 : void SgSyncTeamStatement::operator delete(void *Pointer, size_t Size)
  120790             : {
  120791             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  120792             :      * or throwing an exception. */
  120793           0 :     ALLOC_MUTEX(SgSyncTeamStatement, lock);
  120794             : 
  120795             : #if USE_CPP_NEW_DELETE_OPERATORS
  120796             :     ROSE_FREE(Pointer);
  120797             : #else
  120798             : #if ROSE_PEDANTIC_ALLOC
  120799             :     ROSE_ASSERT(Size == sizeof(SgSyncTeamStatement));
  120800             : #else
  120801           0 :     if (Size != sizeof(SgSyncTeamStatement)) {
  120802           0 :       ROSE_FREE(Pointer);
  120803           0 :       ALLOC_MUTEX(SgSyncTeamStatement, unlock);
  120804             :       return;
  120805             :     }
  120806             : #endif
  120807             : 
  120808           0 :     SgSyncTeamStatement * object = (SgSyncTeamStatement*) Pointer;
  120809           0 :     ROSE_ASSERT(object != nullptr);
  120810             : 
  120811             : #if ROSE_ALLOC_TRACE == 2
  120812             : //  printf("SgSyncTeamStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgSyncTeamStatement::next_node);
  120813             :     printf("SgSyncTeamStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgSyncTeamStatement::next_node);
  120814             : #endif
  120815             : 
  120816             : #if ROSE_PEDANTIC_ALLOC
  120817             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  120818             : #endif
  120819             : 
  120820             : #if ROSE_ALLOC_MEMSET == 1
  120821             : #elif ROSE_ALLOC_MEMSET == 2
  120822             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgSyncTeamStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  120823             : #elif ROSE_ALLOC_MEMSET == 3
  120824             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgSyncTeamStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  120825             : #endif
  120826             : 
  120827             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  120828             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  120829             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  120830             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  120831             : #else
  120832           0 :     object->p_freepointer = SgSyncTeamStatement::next_node;
  120833           0 :     SgSyncTeamStatement::next_node = object;
  120834             : #endif
  120835             : 
  120836             : #if ROSE_ALLOC_TRACE == 2
  120837             : //  printf("SgSyncTeamStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgSyncTeamStatement::next_node);
  120838             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  120839             :     Rose::MemPool::snapshot(oss.str());
  120840             :     alloc_trace_cnt++;
  120841             : #endif
  120842             : 
  120843             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  120844             : 
  120845           0 :     ALLOC_MUTEX(SgSyncTeamStatement, unlock);
  120846             : }
  120847             : 
  120848             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  120849             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  120850             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  120851             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  120852             : // Also, note comment below from Robb (copied from the Common.code file).
  120853             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  120854             : //
  120855             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  120856             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  120857             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  120858             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  120859             : #if 0
  120860             : void SgSyncTeamStatement::operator delete(void* pointer) { SgSyncTeamStatement::operator delete (pointer, sizeof(SgSyncTeamStatement)); };
  120861             : #endif
  120862             : /* #line 120863 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  120863             : 
  120864             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  120865             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  120866             : // obviously imply C++.
  120867             : 
  120868             : // This implements the support within ROSE for memory pools.  Memory pools
  120869             : // support the most condensed usage of memory within the construction of
  120870             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  120871             : // by a new operator written for each class.
  120872             : 
  120873             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  120874             :     // User wants multi-thread support and POSIX threads are available.
  120875             : #   include <pthread.h>
  120876             :     static pthread_mutex_t SgLockStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  120877             : #else
  120878             :      // Cause synchronization to be skipped.
  120879             : #    ifndef ALLOC_MUTEX
  120880             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  120881             : #    endif
  120882             : #    ifdef _REENTRANT
  120883             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  120884             : #       ifdef _MSC_VER
  120885             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  120886             : #       else
  120887             : #           warning "POSIX threads are not available; synchronization being skipped"
  120888             : #       endif
  120889             : #    endif
  120890             : #endif
  120891             : 
  120892             : #ifndef ROSE_ALLOC_TRACE
  120893             : #  define ROSE_ALLOC_TRACE 0
  120894             : #endif
  120895             : 
  120896             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  120897             : #define ROSE_ALLOC_TRACE_CNT
  120898             : #include "memory-pool-snapshot.h"
  120899             : unsigned long alloc_trace_cnt = 0;
  120900             : #endif
  120901             : 
  120902             : #if ROSE_ALLOC_TRACE
  120903             : const unsigned SgLockStatement::pool_size = 5;
  120904             : #else
  120905             : const unsigned SgLockStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  120906             : #endif
  120907             : 
  120908             : #ifndef ROSE_ALLOC_MEMSET
  120909             : #  define ROSE_ALLOC_MEMSET 0
  120910             : #endif
  120911             : 
  120912             : #ifndef ROSE_PEDANTIC_ALLOC
  120913             : #  define ROSE_PEDANTIC_ALLOC 0
  120914             : #endif
  120915             : 
  120916             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  120917             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  120918             : #endif
  120919             : 
  120920             : #if !defined(SGNODE__ALL_POOLS)
  120921             : #define SGNODE__ALL_POOLS
  120922             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  120923             : #endif
  120924             : 
  120925             : SgLockStatement* SgLockStatement::next_node = nullptr;
  120926             : std::vector<unsigned char*> SgLockStatement::pools;
  120927             : 
  120928             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  120929             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  120930             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  120931             : // around this macro definition rather than each use).
  120932             : #ifndef ALLOC_MUTEX
  120933             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  120934             :         do {                                                                     \
  120935             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  120936             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  120937             :                 abort();                                                         \
  120938             :             }                                                                    \
  120939             :         } while (0);
  120940             : #endif
  120941             : 
  120942             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  120943             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  120944             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  120945             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  120946             : 
  120947             : /*! \brief New operator for SgLockStatement.
  120948             : 
  120949             :    This new operator implements memory pools to provide most efficent 
  120950             :    use of the heap within construction of large ASTs.
  120951             : 
  120952             : \internal The new and delete operators use the lower level C malloc/free
  120953             :    function calls for performance and to make sure that mixing of malloc/free
  120954             :    and new/delete by the used can be caught more readily.  This may change
  120955             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  120956             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  120957             :    deallocate memory allocated using ROSE_MALLOC.
  120958             : */
  120959           0 : void *SgLockStatement::operator new ( size_t Size )
  120960             : {
  120961             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  120962             :      * returning or throwing an exception. */
  120963           0 :     ALLOC_MUTEX(SgLockStatement, lock);
  120964             : 
  120965             : #if ROSE_ALLOC_TRACE == 2
  120966             : //    printf("SgLockStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgLockStatement::next_node);
  120967             : #endif
  120968             : 
  120969             : #if USE_CPP_NEW_DELETE_OPERATORS
  120970             :     void *mem = ROSE_MALLOC(Size);
  120971             :     ALLOC_MUTEX(SgLockStatement, unlock);
  120972             :     return mem;
  120973             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  120974             : #if ROSE_PEDANTIC_ALLOC
  120975             :     ROSE_ASSERT(Size == sizeof(SgLockStatement));
  120976             : #else
  120977           0 :     if (Size != sizeof(SgLockStatement)) {
  120978           0 :       void * object = ROSE_MALLOC(Size);
  120979           0 :       ALLOC_MUTEX(SgLockStatement, unlock);
  120980             :       return object;
  120981             :     }
  120982             : #endif
  120983             : 
  120984           0 :     if (SgLockStatement::next_node == nullptr) {
  120985           0 :         SgLockStatement * alloc = (SgLockStatement*) ROSE_MALLOC ( SgLockStatement::pool_size * sizeof(SgLockStatement) );
  120986           0 :         ROSE_ASSERT(alloc != nullptr);
  120987             : 
  120988             : #if ROSE_ALLOC_TRACE == 2
  120989             : //        printf("SgLockStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgLockStatement::pools.size(), alloc, alloc + SgLockStatement::pool_size);
  120990             : #endif
  120991             : 
  120992             : #if ROSE_ALLOC_MEMSET == 1
  120993             : #elif ROSE_ALLOC_MEMSET == 2
  120994             :         memset(alloc, 0x00, SgLockStatement::pool_size * sizeof(SgLockStatement));
  120995             : #elif ROSE_ALLOC_MEMSET == 3
  120996             :         memset(alloc, 0xAA, SgLockStatement::pool_size * sizeof(SgLockStatement));
  120997             : #endif
  120998           0 :         for (unsigned i=0; i < SgLockStatement::pool_size-1; i++) {
  120999           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
  121000             :         }
  121001           0 :         alloc[SgLockStatement::pool_size-1].p_freepointer = nullptr;
  121002             : 
  121003           0 :         SgLockStatement::pools.push_back ( (unsigned char *) alloc );
  121004           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgLockStatement::pool_size * sizeof(SgLockStatement), V_SgLockStatement ) );
  121005           0 :         SgLockStatement::next_node = alloc;
  121006             :     }
  121007           0 :     ROSE_ASSERT(SgLockStatement::next_node != nullptr);
  121008             : 
  121009           0 :     SgLockStatement * object = SgLockStatement::next_node;
  121010           0 :     SgLockStatement::next_node = (SgLockStatement*)(object->p_freepointer);
  121011             : 
  121012             : #if ROSE_ALLOC_TRACE == 2
  121013             :     printf("SgLockStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgLockStatement::next_node);
  121014             : #endif
  121015             : 
  121016           0 :     SgNode * fp = object->p_freepointer;
  121017             : #if ROSE_ALLOC_MEMSET == 1
  121018             : #elif ROSE_ALLOC_MEMSET == 2
  121019             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgLockStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  121020             : #elif ROSE_ALLOC_MEMSET == 3
  121021             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgLockStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  121022             : #endif
  121023           0 :     object->p_freepointer = fp;
  121024             : 
  121025             : #if ROSE_ALLOC_TRACE == 2
  121026             : //    printf("SgLockStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgLockStatement::next_node);
  121027             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  121028             :     Rose::MemPool::snapshot(oss.str());
  121029             :     alloc_trace_cnt++;
  121030             : #endif
  121031             : 
  121032           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  121033             : 
  121034           0 :     ALLOC_MUTEX(SgLockStatement, unlock);
  121035             : 
  121036             :     return object;
  121037             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  121038             : }
  121039             : 
  121040             : 
  121041             : 
  121042             : /*! \brief Delete operator for SgLockStatement.
  121043             : 
  121044             :    This delete operator implements deallocation using memory pools to 
  121045             :    provide most efficent use of the heap within construction of large ASTs.
  121046             : 
  121047             : \internal The new and delete operators use the lower level C malloc/free
  121048             :    function calls for performance and to make sure that mixing of malloc/free
  121049             :    and new/delete by the used can be caught more readily.  This may change
  121050             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  121051             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  121052             :    deallocate memory allocated using ROSE_MALLOC.
  121053             : */
  121054           0 : void SgLockStatement::operator delete(void *Pointer, size_t Size)
  121055             : {
  121056             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  121057             :      * or throwing an exception. */
  121058           0 :     ALLOC_MUTEX(SgLockStatement, lock);
  121059             : 
  121060             : #if USE_CPP_NEW_DELETE_OPERATORS
  121061             :     ROSE_FREE(Pointer);
  121062             : #else
  121063             : #if ROSE_PEDANTIC_ALLOC
  121064             :     ROSE_ASSERT(Size == sizeof(SgLockStatement));
  121065             : #else
  121066           0 :     if (Size != sizeof(SgLockStatement)) {
  121067           0 :       ROSE_FREE(Pointer);
  121068           0 :       ALLOC_MUTEX(SgLockStatement, unlock);
  121069             :       return;
  121070             :     }
  121071             : #endif
  121072             : 
  121073           0 :     SgLockStatement * object = (SgLockStatement*) Pointer;
  121074           0 :     ROSE_ASSERT(object != nullptr);
  121075             : 
  121076             : #if ROSE_ALLOC_TRACE == 2
  121077             : //  printf("SgLockStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgLockStatement::next_node);
  121078             :     printf("SgLockStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgLockStatement::next_node);
  121079             : #endif
  121080             : 
  121081             : #if ROSE_PEDANTIC_ALLOC
  121082             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  121083             : #endif
  121084             : 
  121085             : #if ROSE_ALLOC_MEMSET == 1
  121086             : #elif ROSE_ALLOC_MEMSET == 2
  121087             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgLockStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  121088             : #elif ROSE_ALLOC_MEMSET == 3
  121089             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgLockStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  121090             : #endif
  121091             : 
  121092             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  121093             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  121094             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  121095             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  121096             : #else
  121097           0 :     object->p_freepointer = SgLockStatement::next_node;
  121098           0 :     SgLockStatement::next_node = object;
  121099             : #endif
  121100             : 
  121101             : #if ROSE_ALLOC_TRACE == 2
  121102             : //  printf("SgLockStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgLockStatement::next_node);
  121103             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  121104             :     Rose::MemPool::snapshot(oss.str());
  121105             :     alloc_trace_cnt++;
  121106             : #endif
  121107             : 
  121108             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  121109             : 
  121110           0 :     ALLOC_MUTEX(SgLockStatement, unlock);
  121111             : }
  121112             : 
  121113             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  121114             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  121115             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  121116             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  121117             : // Also, note comment below from Robb (copied from the Common.code file).
  121118             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  121119             : //
  121120             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  121121             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  121122             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  121123             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  121124             : #if 0
  121125             : void SgLockStatement::operator delete(void* pointer) { SgLockStatement::operator delete (pointer, sizeof(SgLockStatement)); };
  121126             : #endif
  121127             : /* #line 121128 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  121128             : 
  121129             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  121130             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  121131             : // obviously imply C++.
  121132             : 
  121133             : // This implements the support within ROSE for memory pools.  Memory pools
  121134             : // support the most condensed usage of memory within the construction of
  121135             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  121136             : // by a new operator written for each class.
  121137             : 
  121138             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  121139             :     // User wants multi-thread support and POSIX threads are available.
  121140             : #   include <pthread.h>
  121141             :     static pthread_mutex_t SgUnlockStatement_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  121142             : #else
  121143             :      // Cause synchronization to be skipped.
  121144             : #    ifndef ALLOC_MUTEX
  121145             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  121146             : #    endif
  121147             : #    ifdef _REENTRANT
  121148             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  121149             : #       ifdef _MSC_VER
  121150             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  121151             : #       else
  121152             : #           warning "POSIX threads are not available; synchronization being skipped"
  121153             : #       endif
  121154             : #    endif
  121155             : #endif
  121156             : 
  121157             : #ifndef ROSE_ALLOC_TRACE
  121158             : #  define ROSE_ALLOC_TRACE 0
  121159             : #endif
  121160             : 
  121161             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  121162             : #define ROSE_ALLOC_TRACE_CNT
  121163             : #include "memory-pool-snapshot.h"
  121164             : unsigned long alloc_trace_cnt = 0;
  121165             : #endif
  121166             : 
  121167             : #if ROSE_ALLOC_TRACE
  121168             : const unsigned SgUnlockStatement::pool_size = 5;
  121169             : #else
  121170             : const unsigned SgUnlockStatement::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  121171             : #endif
  121172             : 
  121173             : #ifndef ROSE_ALLOC_MEMSET
  121174             : #  define ROSE_ALLOC_MEMSET 0
  121175             : #endif
  121176             : 
  121177             : #ifndef ROSE_PEDANTIC_ALLOC
  121178             : #  define ROSE_PEDANTIC_ALLOC 0
  121179             : #endif
  121180             : 
  121181             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  121182             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  121183             : #endif
  121184             : 
  121185             : #if !defined(SGNODE__ALL_POOLS)
  121186             : #define SGNODE__ALL_POOLS
  121187             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  121188             : #endif
  121189             : 
  121190             : SgUnlockStatement* SgUnlockStatement::next_node = nullptr;
  121191             : std::vector<unsigned char*> SgUnlockStatement::pools;
  121192             : 
  121193             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  121194             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  121195             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  121196             : // around this macro definition rather than each use).
  121197             : #ifndef ALLOC_MUTEX
  121198             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  121199             :         do {                                                                     \
  121200             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  121201             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  121202             :                 abort();                                                         \
  121203             :             }                                                                    \
  121204             :         } while (0);
  121205             : #endif
  121206             : 
  121207             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  121208             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  121209             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  121210             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  121211             : 
  121212             : /*! \brief New operator for SgUnlockStatement.
  121213             : 
  121214             :    This new operator implements memory pools to provide most efficent 
  121215             :    use of the heap within construction of large ASTs.
  121216             : 
  121217             : \internal The new and delete operators use the lower level C malloc/free
  121218             :    function calls for performance and to make sure that mixing of malloc/free
  121219             :    and new/delete by the used can be caught more readily.  This may change
  121220             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  121221             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  121222             :    deallocate memory allocated using ROSE_MALLOC.
  121223             : */
  121224           0 : void *SgUnlockStatement::operator new ( size_t Size )
  121225             : {
  121226             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  121227             :      * returning or throwing an exception. */
  121228           0 :     ALLOC_MUTEX(SgUnlockStatement, lock);
  121229             : 
  121230             : #if ROSE_ALLOC_TRACE == 2
  121231             : //    printf("SgUnlockStatement::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgUnlockStatement::next_node);
  121232             : #endif
  121233             : 
  121234             : #if USE_CPP_NEW_DELETE_OPERATORS
  121235             :     void *mem = ROSE_MALLOC(Size);
  121236             :     ALLOC_MUTEX(SgUnlockStatement, unlock);
  121237             :     return mem;
  121238             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  121239             : #if ROSE_PEDANTIC_ALLOC
  121240             :     ROSE_ASSERT(Size == sizeof(SgUnlockStatement));
  121241             : #else
  121242           0 :     if (Size != sizeof(SgUnlockStatement)) {
  121243           0 :       void * object = ROSE_MALLOC(Size);
  121244           0 :       ALLOC_MUTEX(SgUnlockStatement, unlock);
  121245             :       return object;
  121246             :     }
  121247             : #endif
  121248             : 
  121249           0 :     if (SgUnlockStatement::next_node == nullptr) {
  121250           0 :         SgUnlockStatement * alloc = (SgUnlockStatement*) ROSE_MALLOC ( SgUnlockStatement::pool_size * sizeof(SgUnlockStatement) );
  121251           0 :         ROSE_ASSERT(alloc != nullptr);
  121252             : 
  121253             : #if ROSE_ALLOC_TRACE == 2
  121254             : //        printf("SgUnlockStatement::alloc\n  block[%zi] = [ %p , %p [\n", SgUnlockStatement::pools.size(), alloc, alloc + SgUnlockStatement::pool_size);
  121255             : #endif
  121256             : 
  121257             : #if ROSE_ALLOC_MEMSET == 1
  121258             : #elif ROSE_ALLOC_MEMSET == 2
  121259             :         memset(alloc, 0x00, SgUnlockStatement::pool_size * sizeof(SgUnlockStatement));
  121260             : #elif ROSE_ALLOC_MEMSET == 3
  121261             :         memset(alloc, 0xAA, SgUnlockStatement::pool_size * sizeof(SgUnlockStatement));
  121262             : #endif
  121263           0 :         for (unsigned i=0; i < SgUnlockStatement::pool_size-1; i++) {
  121264           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
  121265             :         }
  121266           0 :         alloc[SgUnlockStatement::pool_size-1].p_freepointer = nullptr;
  121267             : 
  121268           0 :         SgUnlockStatement::pools.push_back ( (unsigned char *) alloc );
  121269           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgUnlockStatement::pool_size * sizeof(SgUnlockStatement), V_SgUnlockStatement ) );
  121270           0 :         SgUnlockStatement::next_node = alloc;
  121271             :     }
  121272           0 :     ROSE_ASSERT(SgUnlockStatement::next_node != nullptr);
  121273             : 
  121274           0 :     SgUnlockStatement * object = SgUnlockStatement::next_node;
  121275           0 :     SgUnlockStatement::next_node = (SgUnlockStatement*)(object->p_freepointer);
  121276             : 
  121277             : #if ROSE_ALLOC_TRACE == 2
  121278             :     printf("SgUnlockStatement::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUnlockStatement::next_node);
  121279             : #endif
  121280             : 
  121281           0 :     SgNode * fp = object->p_freepointer;
  121282             : #if ROSE_ALLOC_MEMSET == 1
  121283             : #elif ROSE_ALLOC_MEMSET == 2
  121284             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgUnlockStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  121285             : #elif ROSE_ALLOC_MEMSET == 3
  121286             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgUnlockStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  121287             : #endif
  121288           0 :     object->p_freepointer = fp;
  121289             : 
  121290             : #if ROSE_ALLOC_TRACE == 2
  121291             : //    printf("SgUnlockStatement::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUnlockStatement::next_node);
  121292             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  121293             :     Rose::MemPool::snapshot(oss.str());
  121294             :     alloc_trace_cnt++;
  121295             : #endif
  121296             : 
  121297           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  121298             : 
  121299           0 :     ALLOC_MUTEX(SgUnlockStatement, unlock);
  121300             : 
  121301             :     return object;
  121302             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  121303             : }
  121304             : 
  121305             : 
  121306             : 
  121307             : /*! \brief Delete operator for SgUnlockStatement.
  121308             : 
  121309             :    This delete operator implements deallocation using memory pools to 
  121310             :    provide most efficent use of the heap within construction of large ASTs.
  121311             : 
  121312             : \internal The new and delete operators use the lower level C malloc/free
  121313             :    function calls for performance and to make sure that mixing of malloc/free
  121314             :    and new/delete by the used can be caught more readily.  This may change
  121315             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  121316             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  121317             :    deallocate memory allocated using ROSE_MALLOC.
  121318             : */
  121319           0 : void SgUnlockStatement::operator delete(void *Pointer, size_t Size)
  121320             : {
  121321             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  121322             :      * or throwing an exception. */
  121323           0 :     ALLOC_MUTEX(SgUnlockStatement, lock);
  121324             : 
  121325             : #if USE_CPP_NEW_DELETE_OPERATORS
  121326             :     ROSE_FREE(Pointer);
  121327             : #else
  121328             : #if ROSE_PEDANTIC_ALLOC
  121329             :     ROSE_ASSERT(Size == sizeof(SgUnlockStatement));
  121330             : #else
  121331           0 :     if (Size != sizeof(SgUnlockStatement)) {
  121332           0 :       ROSE_FREE(Pointer);
  121333           0 :       ALLOC_MUTEX(SgUnlockStatement, unlock);
  121334             :       return;
  121335             :     }
  121336             : #endif
  121337             : 
  121338           0 :     SgUnlockStatement * object = (SgUnlockStatement*) Pointer;
  121339           0 :     ROSE_ASSERT(object != nullptr);
  121340             : 
  121341             : #if ROSE_ALLOC_TRACE == 2
  121342             : //  printf("SgUnlockStatement::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUnlockStatement::next_node);
  121343             :     printf("SgUnlockStatement::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUnlockStatement::next_node);
  121344             : #endif
  121345             : 
  121346             : #if ROSE_PEDANTIC_ALLOC
  121347             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  121348             : #endif
  121349             : 
  121350             : #if ROSE_ALLOC_MEMSET == 1
  121351             : #elif ROSE_ALLOC_MEMSET == 2
  121352             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgUnlockStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  121353             : #elif ROSE_ALLOC_MEMSET == 3
  121354             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgUnlockStatement) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  121355             : #endif
  121356             : 
  121357             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  121358             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  121359             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  121360             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  121361             : #else
  121362           0 :     object->p_freepointer = SgUnlockStatement::next_node;
  121363           0 :     SgUnlockStatement::next_node = object;
  121364             : #endif
  121365             : 
  121366             : #if ROSE_ALLOC_TRACE == 2
  121367             : //  printf("SgUnlockStatement::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUnlockStatement::next_node);
  121368             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  121369             :     Rose::MemPool::snapshot(oss.str());
  121370             :     alloc_trace_cnt++;
  121371             : #endif
  121372             : 
  121373             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  121374             : 
  121375           0 :     ALLOC_MUTEX(SgUnlockStatement, unlock);
  121376             : }
  121377             : 
  121378             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  121379             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  121380             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  121381             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  121382             : // Also, note comment below from Robb (copied from the Common.code file).
  121383             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  121384             : //
  121385             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  121386             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  121387             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  121388             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  121389             : #if 0
  121390             : void SgUnlockStatement::operator delete(void* pointer) { SgUnlockStatement::operator delete (pointer, sizeof(SgUnlockStatement)); };
  121391             : #endif
  121392             : /* #line 121393 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  121393             : 
  121394             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  121395             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  121396             : // obviously imply C++.
  121397             : 
  121398             : // This implements the support within ROSE for memory pools.  Memory pools
  121399             : // support the most condensed usage of memory within the construction of
  121400             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  121401             : // by a new operator written for each class.
  121402             : 
  121403             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  121404             :     // User wants multi-thread support and POSIX threads are available.
  121405             : #   include <pthread.h>
  121406             :     static pthread_mutex_t SgExpression_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  121407             : #else
  121408             :      // Cause synchronization to be skipped.
  121409             : #    ifndef ALLOC_MUTEX
  121410             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  121411             : #    endif
  121412             : #    ifdef _REENTRANT
  121413             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  121414             : #       ifdef _MSC_VER
  121415             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  121416             : #       else
  121417             : #           warning "POSIX threads are not available; synchronization being skipped"
  121418             : #       endif
  121419             : #    endif
  121420             : #endif
  121421             : 
  121422             : #ifndef ROSE_ALLOC_TRACE
  121423             : #  define ROSE_ALLOC_TRACE 0
  121424             : #endif
  121425             : 
  121426             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  121427             : #define ROSE_ALLOC_TRACE_CNT
  121428             : #include "memory-pool-snapshot.h"
  121429             : unsigned long alloc_trace_cnt = 0;
  121430             : #endif
  121431             : 
  121432             : #if ROSE_ALLOC_TRACE
  121433             : const unsigned SgExpression::pool_size = 5;
  121434             : #else
  121435             : const unsigned SgExpression::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  121436             : #endif
  121437             : 
  121438             : #ifndef ROSE_ALLOC_MEMSET
  121439             : #  define ROSE_ALLOC_MEMSET 0
  121440             : #endif
  121441             : 
  121442             : #ifndef ROSE_PEDANTIC_ALLOC
  121443             : #  define ROSE_PEDANTIC_ALLOC 0
  121444             : #endif
  121445             : 
  121446             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  121447             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  121448             : #endif
  121449             : 
  121450             : #if !defined(SGNODE__ALL_POOLS)
  121451             : #define SGNODE__ALL_POOLS
  121452             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  121453             : #endif
  121454             : 
  121455             : SgExpression* SgExpression::next_node = nullptr;
  121456             : std::vector<unsigned char*> SgExpression::pools;
  121457             : 
  121458             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  121459             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  121460             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  121461             : // around this macro definition rather than each use).
  121462             : #ifndef ALLOC_MUTEX
  121463             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  121464             :         do {                                                                     \
  121465             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  121466             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  121467             :                 abort();                                                         \
  121468             :             }                                                                    \
  121469             :         } while (0);
  121470             : #endif
  121471             : 
  121472             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  121473             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  121474             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  121475             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  121476             : 
  121477             : /*! \brief New operator for SgExpression.
  121478             : 
  121479             :    This new operator implements memory pools to provide most efficent 
  121480             :    use of the heap within construction of large ASTs.
  121481             : 
  121482             : \internal The new and delete operators use the lower level C malloc/free
  121483             :    function calls for performance and to make sure that mixing of malloc/free
  121484             :    and new/delete by the used can be caught more readily.  This may change
  121485             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  121486             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  121487             :    deallocate memory allocated using ROSE_MALLOC.
  121488             : */
  121489           0 : void *SgExpression::operator new ( size_t Size )
  121490             : {
  121491             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  121492             :      * returning or throwing an exception. */
  121493           0 :     ALLOC_MUTEX(SgExpression, lock);
  121494             : 
  121495             : #if ROSE_ALLOC_TRACE == 2
  121496             : //    printf("SgExpression::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgExpression::next_node);
  121497             : #endif
  121498             : 
  121499             : #if USE_CPP_NEW_DELETE_OPERATORS
  121500             :     void *mem = ROSE_MALLOC(Size);
  121501             :     ALLOC_MUTEX(SgExpression, unlock);
  121502             :     return mem;
  121503             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  121504             : #if ROSE_PEDANTIC_ALLOC
  121505             :     ROSE_ASSERT(Size == sizeof(SgExpression));
  121506             : #else
  121507           0 :     if (Size != sizeof(SgExpression)) {
  121508           0 :       void * object = ROSE_MALLOC(Size);
  121509           0 :       ALLOC_MUTEX(SgExpression, unlock);
  121510             :       return object;
  121511             :     }
  121512             : #endif
  121513             : 
  121514           0 :     if (SgExpression::next_node == nullptr) {
  121515           0 :         SgExpression * alloc = (SgExpression*) ROSE_MALLOC ( SgExpression::pool_size * sizeof(SgExpression) );
  121516           0 :         ROSE_ASSERT(alloc != nullptr);
  121517             : 
  121518             : #if ROSE_ALLOC_TRACE == 2
  121519             : //        printf("SgExpression::alloc\n  block[%zi] = [ %p , %p [\n", SgExpression::pools.size(), alloc, alloc + SgExpression::pool_size);
  121520             : #endif
  121521             : 
  121522             : #if ROSE_ALLOC_MEMSET == 1
  121523             : #elif ROSE_ALLOC_MEMSET == 2
  121524             :         memset(alloc, 0x00, SgExpression::pool_size * sizeof(SgExpression));
  121525             : #elif ROSE_ALLOC_MEMSET == 3
  121526             :         memset(alloc, 0xAA, SgExpression::pool_size * sizeof(SgExpression));
  121527             : #endif
  121528           0 :         for (unsigned i=0; i < SgExpression::pool_size-1; i++) {
  121529           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
  121530             :         }
  121531           0 :         alloc[SgExpression::pool_size-1].p_freepointer = nullptr;
  121532             : 
  121533           0 :         SgExpression::pools.push_back ( (unsigned char *) alloc );
  121534           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgExpression::pool_size * sizeof(SgExpression), V_SgExpression ) );
  121535           0 :         SgExpression::next_node = alloc;
  121536             :     }
  121537           0 :     ROSE_ASSERT(SgExpression::next_node != nullptr);
  121538             : 
  121539           0 :     SgExpression * object = SgExpression::next_node;
  121540           0 :     SgExpression::next_node = (SgExpression*)(object->p_freepointer);
  121541             : 
  121542             : #if ROSE_ALLOC_TRACE == 2
  121543             :     printf("SgExpression::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgExpression::next_node);
  121544             : #endif
  121545             : 
  121546           0 :     SgNode * fp = object->p_freepointer;
  121547             : #if ROSE_ALLOC_MEMSET == 1
  121548             : #elif ROSE_ALLOC_MEMSET == 2
  121549             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgExpression) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  121550             : #elif ROSE_ALLOC_MEMSET == 3
  121551             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgExpression) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  121552             : #endif
  121553           0 :     object->p_freepointer = fp;
  121554             : 
  121555             : #if ROSE_ALLOC_TRACE == 2
  121556             : //    printf("SgExpression::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgExpression::next_node);
  121557             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  121558             :     Rose::MemPool::snapshot(oss.str());
  121559             :     alloc_trace_cnt++;
  121560             : #endif
  121561             : 
  121562           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  121563             : 
  121564           0 :     ALLOC_MUTEX(SgExpression, unlock);
  121565             : 
  121566             :     return object;
  121567             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  121568             : }
  121569             : 
  121570             : 
  121571             : 
  121572             : /*! \brief Delete operator for SgExpression.
  121573             : 
  121574             :    This delete operator implements deallocation using memory pools to 
  121575             :    provide most efficent use of the heap within construction of large ASTs.
  121576             : 
  121577             : \internal The new and delete operators use the lower level C malloc/free
  121578             :    function calls for performance and to make sure that mixing of malloc/free
  121579             :    and new/delete by the used can be caught more readily.  This may change
  121580             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  121581             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  121582             :    deallocate memory allocated using ROSE_MALLOC.
  121583             : */
  121584           0 : void SgExpression::operator delete(void *Pointer, size_t Size)
  121585             : {
  121586             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  121587             :      * or throwing an exception. */
  121588           0 :     ALLOC_MUTEX(SgExpression, lock);
  121589             : 
  121590             : #if USE_CPP_NEW_DELETE_OPERATORS
  121591             :     ROSE_FREE(Pointer);
  121592             : #else
  121593             : #if ROSE_PEDANTIC_ALLOC
  121594             :     ROSE_ASSERT(Size == sizeof(SgExpression));
  121595             : #else
  121596           0 :     if (Size != sizeof(SgExpression)) {
  121597           0 :       ROSE_FREE(Pointer);
  121598           0 :       ALLOC_MUTEX(SgExpression, unlock);
  121599             :       return;
  121600             :     }
  121601             : #endif
  121602             : 
  121603           0 :     SgExpression * object = (SgExpression*) Pointer;
  121604           0 :     ROSE_ASSERT(object != nullptr);
  121605             : 
  121606             : #if ROSE_ALLOC_TRACE == 2
  121607             : //  printf("SgExpression::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgExpression::next_node);
  121608             :     printf("SgExpression::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgExpression::next_node);
  121609             : #endif
  121610             : 
  121611             : #if ROSE_PEDANTIC_ALLOC
  121612             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  121613             : #endif
  121614             : 
  121615             : #if ROSE_ALLOC_MEMSET == 1
  121616             : #elif ROSE_ALLOC_MEMSET == 2
  121617             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgExpression) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  121618             : #elif ROSE_ALLOC_MEMSET == 3
  121619             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgExpression) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  121620             : #endif
  121621             : 
  121622             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  121623             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  121624             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  121625             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  121626             : #else
  121627           0 :     object->p_freepointer = SgExpression::next_node;
  121628           0 :     SgExpression::next_node = object;
  121629             : #endif
  121630             : 
  121631             : #if ROSE_ALLOC_TRACE == 2
  121632             : //  printf("SgExpression::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgExpression::next_node);
  121633             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  121634             :     Rose::MemPool::snapshot(oss.str());
  121635             :     alloc_trace_cnt++;
  121636             : #endif
  121637             : 
  121638             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  121639             : 
  121640           0 :     ALLOC_MUTEX(SgExpression, unlock);
  121641             : }
  121642             : 
  121643             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  121644             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  121645             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  121646             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  121647             : // Also, note comment below from Robb (copied from the Common.code file).
  121648             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  121649             : //
  121650             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  121651             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  121652             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  121653             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  121654             : #if 0
  121655             : void SgExpression::operator delete(void* pointer) { SgExpression::operator delete (pointer, sizeof(SgExpression)); };
  121656             : #endif
  121657             : /* #line 121658 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  121658             : 
  121659             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  121660             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  121661             : // obviously imply C++.
  121662             : 
  121663             : // This implements the support within ROSE for memory pools.  Memory pools
  121664             : // support the most condensed usage of memory within the construction of
  121665             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  121666             : // by a new operator written for each class.
  121667             : 
  121668             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  121669             :     // User wants multi-thread support and POSIX threads are available.
  121670             : #   include <pthread.h>
  121671             :     static pthread_mutex_t SgUnaryOp_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  121672             : #else
  121673             :      // Cause synchronization to be skipped.
  121674             : #    ifndef ALLOC_MUTEX
  121675             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  121676             : #    endif
  121677             : #    ifdef _REENTRANT
  121678             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  121679             : #       ifdef _MSC_VER
  121680             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  121681             : #       else
  121682             : #           warning "POSIX threads are not available; synchronization being skipped"
  121683             : #       endif
  121684             : #    endif
  121685             : #endif
  121686             : 
  121687             : #ifndef ROSE_ALLOC_TRACE
  121688             : #  define ROSE_ALLOC_TRACE 0
  121689             : #endif
  121690             : 
  121691             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  121692             : #define ROSE_ALLOC_TRACE_CNT
  121693             : #include "memory-pool-snapshot.h"
  121694             : unsigned long alloc_trace_cnt = 0;
  121695             : #endif
  121696             : 
  121697             : #if ROSE_ALLOC_TRACE
  121698             : const unsigned SgUnaryOp::pool_size = 5;
  121699             : #else
  121700             : const unsigned SgUnaryOp::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  121701             : #endif
  121702             : 
  121703             : #ifndef ROSE_ALLOC_MEMSET
  121704             : #  define ROSE_ALLOC_MEMSET 0
  121705             : #endif
  121706             : 
  121707             : #ifndef ROSE_PEDANTIC_ALLOC
  121708             : #  define ROSE_PEDANTIC_ALLOC 0
  121709             : #endif
  121710             : 
  121711             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  121712             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  121713             : #endif
  121714             : 
  121715             : #if !defined(SGNODE__ALL_POOLS)
  121716             : #define SGNODE__ALL_POOLS
  121717             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  121718             : #endif
  121719             : 
  121720             : SgUnaryOp* SgUnaryOp::next_node = nullptr;
  121721             : std::vector<unsigned char*> SgUnaryOp::pools;
  121722             : 
  121723             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  121724             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  121725             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  121726             : // around this macro definition rather than each use).
  121727             : #ifndef ALLOC_MUTEX
  121728             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  121729             :         do {                                                                     \
  121730             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  121731             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  121732             :                 abort();                                                         \
  121733             :             }                                                                    \
  121734             :         } while (0);
  121735             : #endif
  121736             : 
  121737             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  121738             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  121739             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  121740             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  121741             : 
  121742             : /*! \brief New operator for SgUnaryOp.
  121743             : 
  121744             :    This new operator implements memory pools to provide most efficent 
  121745             :    use of the heap within construction of large ASTs.
  121746             : 
  121747             : \internal The new and delete operators use the lower level C malloc/free
  121748             :    function calls for performance and to make sure that mixing of malloc/free
  121749             :    and new/delete by the used can be caught more readily.  This may change
  121750             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  121751             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  121752             :    deallocate memory allocated using ROSE_MALLOC.
  121753             : */
  121754           0 : void *SgUnaryOp::operator new ( size_t Size )
  121755             : {
  121756             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  121757             :      * returning or throwing an exception. */
  121758           0 :     ALLOC_MUTEX(SgUnaryOp, lock);
  121759             : 
  121760             : #if ROSE_ALLOC_TRACE == 2
  121761             : //    printf("SgUnaryOp::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgUnaryOp::next_node);
  121762             : #endif
  121763             : 
  121764             : #if USE_CPP_NEW_DELETE_OPERATORS
  121765             :     void *mem = ROSE_MALLOC(Size);
  121766             :     ALLOC_MUTEX(SgUnaryOp, unlock);
  121767             :     return mem;
  121768             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  121769             : #if ROSE_PEDANTIC_ALLOC
  121770             :     ROSE_ASSERT(Size == sizeof(SgUnaryOp));
  121771             : #else
  121772           0 :     if (Size != sizeof(SgUnaryOp)) {
  121773           0 :       void * object = ROSE_MALLOC(Size);
  121774           0 :       ALLOC_MUTEX(SgUnaryOp, unlock);
  121775             :       return object;
  121776             :     }
  121777             : #endif
  121778             : 
  121779           0 :     if (SgUnaryOp::next_node == nullptr) {
  121780           0 :         SgUnaryOp * alloc = (SgUnaryOp*) ROSE_MALLOC ( SgUnaryOp::pool_size * sizeof(SgUnaryOp) );
  121781           0 :         ROSE_ASSERT(alloc != nullptr);
  121782             : 
  121783             : #if ROSE_ALLOC_TRACE == 2
  121784             : //        printf("SgUnaryOp::alloc\n  block[%zi] = [ %p , %p [\n", SgUnaryOp::pools.size(), alloc, alloc + SgUnaryOp::pool_size);
  121785             : #endif
  121786             : 
  121787             : #if ROSE_ALLOC_MEMSET == 1
  121788             : #elif ROSE_ALLOC_MEMSET == 2
  121789             :         memset(alloc, 0x00, SgUnaryOp::pool_size * sizeof(SgUnaryOp));
  121790             : #elif ROSE_ALLOC_MEMSET == 3
  121791             :         memset(alloc, 0xAA, SgUnaryOp::pool_size * sizeof(SgUnaryOp));
  121792             : #endif
  121793           0 :         for (unsigned i=0; i < SgUnaryOp::pool_size-1; i++) {
  121794           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
  121795             :         }
  121796           0 :         alloc[SgUnaryOp::pool_size-1].p_freepointer = nullptr;
  121797             : 
  121798           0 :         SgUnaryOp::pools.push_back ( (unsigned char *) alloc );
  121799           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgUnaryOp::pool_size * sizeof(SgUnaryOp), V_SgUnaryOp ) );
  121800           0 :         SgUnaryOp::next_node = alloc;
  121801             :     }
  121802           0 :     ROSE_ASSERT(SgUnaryOp::next_node != nullptr);
  121803             : 
  121804           0 :     SgUnaryOp * object = SgUnaryOp::next_node;
  121805           0 :     SgUnaryOp::next_node = (SgUnaryOp*)(object->p_freepointer);
  121806             : 
  121807             : #if ROSE_ALLOC_TRACE == 2
  121808             :     printf("SgUnaryOp::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUnaryOp::next_node);
  121809             : #endif
  121810             : 
  121811           0 :     SgNode * fp = object->p_freepointer;
  121812             : #if ROSE_ALLOC_MEMSET == 1
  121813             : #elif ROSE_ALLOC_MEMSET == 2
  121814             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgUnaryOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  121815             : #elif ROSE_ALLOC_MEMSET == 3
  121816             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgUnaryOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  121817             : #endif
  121818           0 :     object->p_freepointer = fp;
  121819             : 
  121820             : #if ROSE_ALLOC_TRACE == 2
  121821             : //    printf("SgUnaryOp::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUnaryOp::next_node);
  121822             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  121823             :     Rose::MemPool::snapshot(oss.str());
  121824             :     alloc_trace_cnt++;
  121825             : #endif
  121826             : 
  121827           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  121828             : 
  121829           0 :     ALLOC_MUTEX(SgUnaryOp, unlock);
  121830             : 
  121831             :     return object;
  121832             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  121833             : }
  121834             : 
  121835             : 
  121836             : 
  121837             : /*! \brief Delete operator for SgUnaryOp.
  121838             : 
  121839             :    This delete operator implements deallocation using memory pools to 
  121840             :    provide most efficent use of the heap within construction of large ASTs.
  121841             : 
  121842             : \internal The new and delete operators use the lower level C malloc/free
  121843             :    function calls for performance and to make sure that mixing of malloc/free
  121844             :    and new/delete by the used can be caught more readily.  This may change
  121845             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  121846             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  121847             :    deallocate memory allocated using ROSE_MALLOC.
  121848             : */
  121849           0 : void SgUnaryOp::operator delete(void *Pointer, size_t Size)
  121850             : {
  121851             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  121852             :      * or throwing an exception. */
  121853           0 :     ALLOC_MUTEX(SgUnaryOp, lock);
  121854             : 
  121855             : #if USE_CPP_NEW_DELETE_OPERATORS
  121856             :     ROSE_FREE(Pointer);
  121857             : #else
  121858             : #if ROSE_PEDANTIC_ALLOC
  121859             :     ROSE_ASSERT(Size == sizeof(SgUnaryOp));
  121860             : #else
  121861           0 :     if (Size != sizeof(SgUnaryOp)) {
  121862           0 :       ROSE_FREE(Pointer);
  121863           0 :       ALLOC_MUTEX(SgUnaryOp, unlock);
  121864             :       return;
  121865             :     }
  121866             : #endif
  121867             : 
  121868           0 :     SgUnaryOp * object = (SgUnaryOp*) Pointer;
  121869           0 :     ROSE_ASSERT(object != nullptr);
  121870             : 
  121871             : #if ROSE_ALLOC_TRACE == 2
  121872             : //  printf("SgUnaryOp::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUnaryOp::next_node);
  121873             :     printf("SgUnaryOp::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUnaryOp::next_node);
  121874             : #endif
  121875             : 
  121876             : #if ROSE_PEDANTIC_ALLOC
  121877             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  121878             : #endif
  121879             : 
  121880             : #if ROSE_ALLOC_MEMSET == 1
  121881             : #elif ROSE_ALLOC_MEMSET == 2
  121882             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgUnaryOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  121883             : #elif ROSE_ALLOC_MEMSET == 3
  121884             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgUnaryOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  121885             : #endif
  121886             : 
  121887             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  121888             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  121889             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  121890             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  121891             : #else
  121892           0 :     object->p_freepointer = SgUnaryOp::next_node;
  121893           0 :     SgUnaryOp::next_node = object;
  121894             : #endif
  121895             : 
  121896             : #if ROSE_ALLOC_TRACE == 2
  121897             : //  printf("SgUnaryOp::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUnaryOp::next_node);
  121898             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  121899             :     Rose::MemPool::snapshot(oss.str());
  121900             :     alloc_trace_cnt++;
  121901             : #endif
  121902             : 
  121903             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  121904             : 
  121905           0 :     ALLOC_MUTEX(SgUnaryOp, unlock);
  121906             : }
  121907             : 
  121908             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  121909             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  121910             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  121911             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  121912             : // Also, note comment below from Robb (copied from the Common.code file).
  121913             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  121914             : //
  121915             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  121916             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  121917             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  121918             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  121919             : #if 0
  121920             : void SgUnaryOp::operator delete(void* pointer) { SgUnaryOp::operator delete (pointer, sizeof(SgUnaryOp)); };
  121921             : #endif
  121922             : /* #line 121923 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  121923             : 
  121924             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  121925             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  121926             : // obviously imply C++.
  121927             : 
  121928             : // This implements the support within ROSE for memory pools.  Memory pools
  121929             : // support the most condensed usage of memory within the construction of
  121930             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  121931             : // by a new operator written for each class.
  121932             : 
  121933             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  121934             :     // User wants multi-thread support and POSIX threads are available.
  121935             : #   include <pthread.h>
  121936             :     static pthread_mutex_t SgExpressionRoot_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  121937             : #else
  121938             :      // Cause synchronization to be skipped.
  121939             : #    ifndef ALLOC_MUTEX
  121940             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  121941             : #    endif
  121942             : #    ifdef _REENTRANT
  121943             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  121944             : #       ifdef _MSC_VER
  121945             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  121946             : #       else
  121947             : #           warning "POSIX threads are not available; synchronization being skipped"
  121948             : #       endif
  121949             : #    endif
  121950             : #endif
  121951             : 
  121952             : #ifndef ROSE_ALLOC_TRACE
  121953             : #  define ROSE_ALLOC_TRACE 0
  121954             : #endif
  121955             : 
  121956             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  121957             : #define ROSE_ALLOC_TRACE_CNT
  121958             : #include "memory-pool-snapshot.h"
  121959             : unsigned long alloc_trace_cnt = 0;
  121960             : #endif
  121961             : 
  121962             : #if ROSE_ALLOC_TRACE
  121963             : const unsigned SgExpressionRoot::pool_size = 5;
  121964             : #else
  121965             : const unsigned SgExpressionRoot::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  121966             : #endif
  121967             : 
  121968             : #ifndef ROSE_ALLOC_MEMSET
  121969             : #  define ROSE_ALLOC_MEMSET 0
  121970             : #endif
  121971             : 
  121972             : #ifndef ROSE_PEDANTIC_ALLOC
  121973             : #  define ROSE_PEDANTIC_ALLOC 0
  121974             : #endif
  121975             : 
  121976             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  121977             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  121978             : #endif
  121979             : 
  121980             : #if !defined(SGNODE__ALL_POOLS)
  121981             : #define SGNODE__ALL_POOLS
  121982             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  121983             : #endif
  121984             : 
  121985             : SgExpressionRoot* SgExpressionRoot::next_node = nullptr;
  121986             : std::vector<unsigned char*> SgExpressionRoot::pools;
  121987             : 
  121988             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  121989             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  121990             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  121991             : // around this macro definition rather than each use).
  121992             : #ifndef ALLOC_MUTEX
  121993             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  121994             :         do {                                                                     \
  121995             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  121996             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  121997             :                 abort();                                                         \
  121998             :             }                                                                    \
  121999             :         } while (0);
  122000             : #endif
  122001             : 
  122002             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  122003             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  122004             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  122005             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  122006             : 
  122007             : /*! \brief New operator for SgExpressionRoot.
  122008             : 
  122009             :    This new operator implements memory pools to provide most efficent 
  122010             :    use of the heap within construction of large ASTs.
  122011             : 
  122012             : \internal The new and delete operators use the lower level C malloc/free
  122013             :    function calls for performance and to make sure that mixing of malloc/free
  122014             :    and new/delete by the used can be caught more readily.  This may change
  122015             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  122016             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  122017             :    deallocate memory allocated using ROSE_MALLOC.
  122018             : */
  122019           0 : void *SgExpressionRoot::operator new ( size_t Size )
  122020             : {
  122021             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  122022             :      * returning or throwing an exception. */
  122023           0 :     ALLOC_MUTEX(SgExpressionRoot, lock);
  122024             : 
  122025             : #if ROSE_ALLOC_TRACE == 2
  122026             : //    printf("SgExpressionRoot::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgExpressionRoot::next_node);
  122027             : #endif
  122028             : 
  122029             : #if USE_CPP_NEW_DELETE_OPERATORS
  122030             :     void *mem = ROSE_MALLOC(Size);
  122031             :     ALLOC_MUTEX(SgExpressionRoot, unlock);
  122032             :     return mem;
  122033             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  122034             : #if ROSE_PEDANTIC_ALLOC
  122035             :     ROSE_ASSERT(Size == sizeof(SgExpressionRoot));
  122036             : #else
  122037           0 :     if (Size != sizeof(SgExpressionRoot)) {
  122038           0 :       void * object = ROSE_MALLOC(Size);
  122039           0 :       ALLOC_MUTEX(SgExpressionRoot, unlock);
  122040             :       return object;
  122041             :     }
  122042             : #endif
  122043             : 
  122044           0 :     if (SgExpressionRoot::next_node == nullptr) {
  122045           0 :         SgExpressionRoot * alloc = (SgExpressionRoot*) ROSE_MALLOC ( SgExpressionRoot::pool_size * sizeof(SgExpressionRoot) );
  122046           0 :         ROSE_ASSERT(alloc != nullptr);
  122047             : 
  122048             : #if ROSE_ALLOC_TRACE == 2
  122049             : //        printf("SgExpressionRoot::alloc\n  block[%zi] = [ %p , %p [\n", SgExpressionRoot::pools.size(), alloc, alloc + SgExpressionRoot::pool_size);
  122050             : #endif
  122051             : 
  122052             : #if ROSE_ALLOC_MEMSET == 1
  122053             : #elif ROSE_ALLOC_MEMSET == 2
  122054             :         memset(alloc, 0x00, SgExpressionRoot::pool_size * sizeof(SgExpressionRoot));
  122055             : #elif ROSE_ALLOC_MEMSET == 3
  122056             :         memset(alloc, 0xAA, SgExpressionRoot::pool_size * sizeof(SgExpressionRoot));
  122057             : #endif
  122058           0 :         for (unsigned i=0; i < SgExpressionRoot::pool_size-1; i++) {
  122059           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
  122060             :         }
  122061           0 :         alloc[SgExpressionRoot::pool_size-1].p_freepointer = nullptr;
  122062             : 
  122063           0 :         SgExpressionRoot::pools.push_back ( (unsigned char *) alloc );
  122064           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgExpressionRoot::pool_size * sizeof(SgExpressionRoot), V_SgExpressionRoot ) );
  122065           0 :         SgExpressionRoot::next_node = alloc;
  122066             :     }
  122067           0 :     ROSE_ASSERT(SgExpressionRoot::next_node != nullptr);
  122068             : 
  122069           0 :     SgExpressionRoot * object = SgExpressionRoot::next_node;
  122070           0 :     SgExpressionRoot::next_node = (SgExpressionRoot*)(object->p_freepointer);
  122071             : 
  122072             : #if ROSE_ALLOC_TRACE == 2
  122073             :     printf("SgExpressionRoot::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgExpressionRoot::next_node);
  122074             : #endif
  122075             : 
  122076           0 :     SgNode * fp = object->p_freepointer;
  122077             : #if ROSE_ALLOC_MEMSET == 1
  122078             : #elif ROSE_ALLOC_MEMSET == 2
  122079             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgExpressionRoot) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  122080             : #elif ROSE_ALLOC_MEMSET == 3
  122081             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgExpressionRoot) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  122082             : #endif
  122083           0 :     object->p_freepointer = fp;
  122084             : 
  122085             : #if ROSE_ALLOC_TRACE == 2
  122086             : //    printf("SgExpressionRoot::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgExpressionRoot::next_node);
  122087             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  122088             :     Rose::MemPool::snapshot(oss.str());
  122089             :     alloc_trace_cnt++;
  122090             : #endif
  122091             : 
  122092           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  122093             : 
  122094           0 :     ALLOC_MUTEX(SgExpressionRoot, unlock);
  122095             : 
  122096             :     return object;
  122097             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  122098             : }
  122099             : 
  122100             : 
  122101             : 
  122102             : /*! \brief Delete operator for SgExpressionRoot.
  122103             : 
  122104             :    This delete operator implements deallocation using memory pools to 
  122105             :    provide most efficent use of the heap within construction of large ASTs.
  122106             : 
  122107             : \internal The new and delete operators use the lower level C malloc/free
  122108             :    function calls for performance and to make sure that mixing of malloc/free
  122109             :    and new/delete by the used can be caught more readily.  This may change
  122110             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  122111             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  122112             :    deallocate memory allocated using ROSE_MALLOC.
  122113             : */
  122114           0 : void SgExpressionRoot::operator delete(void *Pointer, size_t Size)
  122115             : {
  122116             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  122117             :      * or throwing an exception. */
  122118           0 :     ALLOC_MUTEX(SgExpressionRoot, lock);
  122119             : 
  122120             : #if USE_CPP_NEW_DELETE_OPERATORS
  122121             :     ROSE_FREE(Pointer);
  122122             : #else
  122123             : #if ROSE_PEDANTIC_ALLOC
  122124             :     ROSE_ASSERT(Size == sizeof(SgExpressionRoot));
  122125             : #else
  122126           0 :     if (Size != sizeof(SgExpressionRoot)) {
  122127           0 :       ROSE_FREE(Pointer);
  122128           0 :       ALLOC_MUTEX(SgExpressionRoot, unlock);
  122129             :       return;
  122130             :     }
  122131             : #endif
  122132             : 
  122133           0 :     SgExpressionRoot * object = (SgExpressionRoot*) Pointer;
  122134           0 :     ROSE_ASSERT(object != nullptr);
  122135             : 
  122136             : #if ROSE_ALLOC_TRACE == 2
  122137             : //  printf("SgExpressionRoot::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgExpressionRoot::next_node);
  122138             :     printf("SgExpressionRoot::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgExpressionRoot::next_node);
  122139             : #endif
  122140             : 
  122141             : #if ROSE_PEDANTIC_ALLOC
  122142             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  122143             : #endif
  122144             : 
  122145             : #if ROSE_ALLOC_MEMSET == 1
  122146             : #elif ROSE_ALLOC_MEMSET == 2
  122147             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgExpressionRoot) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  122148             : #elif ROSE_ALLOC_MEMSET == 3
  122149             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgExpressionRoot) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  122150             : #endif
  122151             : 
  122152             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  122153             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  122154             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  122155             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  122156             : #else
  122157           0 :     object->p_freepointer = SgExpressionRoot::next_node;
  122158           0 :     SgExpressionRoot::next_node = object;
  122159             : #endif
  122160             : 
  122161             : #if ROSE_ALLOC_TRACE == 2
  122162             : //  printf("SgExpressionRoot::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgExpressionRoot::next_node);
  122163             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  122164             :     Rose::MemPool::snapshot(oss.str());
  122165             :     alloc_trace_cnt++;
  122166             : #endif
  122167             : 
  122168             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  122169             : 
  122170           0 :     ALLOC_MUTEX(SgExpressionRoot, unlock);
  122171             : }
  122172             : 
  122173             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  122174             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  122175             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  122176             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  122177             : // Also, note comment below from Robb (copied from the Common.code file).
  122178             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  122179             : //
  122180             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  122181             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  122182             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  122183             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  122184             : #if 0
  122185             : void SgExpressionRoot::operator delete(void* pointer) { SgExpressionRoot::operator delete (pointer, sizeof(SgExpressionRoot)); };
  122186             : #endif
  122187             : /* #line 122188 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  122188             : 
  122189             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  122190             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  122191             : // obviously imply C++.
  122192             : 
  122193             : // This implements the support within ROSE for memory pools.  Memory pools
  122194             : // support the most condensed usage of memory within the construction of
  122195             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  122196             : // by a new operator written for each class.
  122197             : 
  122198             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  122199             :     // User wants multi-thread support and POSIX threads are available.
  122200             : #   include <pthread.h>
  122201             :     static pthread_mutex_t SgMinusOp_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  122202             : #else
  122203             :      // Cause synchronization to be skipped.
  122204             : #    ifndef ALLOC_MUTEX
  122205             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  122206             : #    endif
  122207             : #    ifdef _REENTRANT
  122208             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  122209             : #       ifdef _MSC_VER
  122210             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  122211             : #       else
  122212             : #           warning "POSIX threads are not available; synchronization being skipped"
  122213             : #       endif
  122214             : #    endif
  122215             : #endif
  122216             : 
  122217             : #ifndef ROSE_ALLOC_TRACE
  122218             : #  define ROSE_ALLOC_TRACE 0
  122219             : #endif
  122220             : 
  122221             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  122222             : #define ROSE_ALLOC_TRACE_CNT
  122223             : #include "memory-pool-snapshot.h"
  122224             : unsigned long alloc_trace_cnt = 0;
  122225             : #endif
  122226             : 
  122227             : #if ROSE_ALLOC_TRACE
  122228             : const unsigned SgMinusOp::pool_size = 5;
  122229             : #else
  122230             : const unsigned SgMinusOp::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  122231             : #endif
  122232             : 
  122233             : #ifndef ROSE_ALLOC_MEMSET
  122234             : #  define ROSE_ALLOC_MEMSET 0
  122235             : #endif
  122236             : 
  122237             : #ifndef ROSE_PEDANTIC_ALLOC
  122238             : #  define ROSE_PEDANTIC_ALLOC 0
  122239             : #endif
  122240             : 
  122241             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  122242             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  122243             : #endif
  122244             : 
  122245             : #if !defined(SGNODE__ALL_POOLS)
  122246             : #define SGNODE__ALL_POOLS
  122247             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  122248             : #endif
  122249             : 
  122250             : SgMinusOp* SgMinusOp::next_node = nullptr;
  122251             : std::vector<unsigned char*> SgMinusOp::pools;
  122252             : 
  122253             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  122254             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  122255             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  122256             : // around this macro definition rather than each use).
  122257             : #ifndef ALLOC_MUTEX
  122258             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  122259             :         do {                                                                     \
  122260             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  122261             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  122262             :                 abort();                                                         \
  122263             :             }                                                                    \
  122264             :         } while (0);
  122265             : #endif
  122266             : 
  122267             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  122268             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  122269             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  122270             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  122271             : 
  122272             : /*! \brief New operator for SgMinusOp.
  122273             : 
  122274             :    This new operator implements memory pools to provide most efficent 
  122275             :    use of the heap within construction of large ASTs.
  122276             : 
  122277             : \internal The new and delete operators use the lower level C malloc/free
  122278             :    function calls for performance and to make sure that mixing of malloc/free
  122279             :    and new/delete by the used can be caught more readily.  This may change
  122280             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  122281             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  122282             :    deallocate memory allocated using ROSE_MALLOC.
  122283             : */
  122284         666 : void *SgMinusOp::operator new ( size_t Size )
  122285             : {
  122286             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  122287             :      * returning or throwing an exception. */
  122288         666 :     ALLOC_MUTEX(SgMinusOp, lock);
  122289             : 
  122290             : #if ROSE_ALLOC_TRACE == 2
  122291             : //    printf("SgMinusOp::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgMinusOp::next_node);
  122292             : #endif
  122293             : 
  122294             : #if USE_CPP_NEW_DELETE_OPERATORS
  122295             :     void *mem = ROSE_MALLOC(Size);
  122296             :     ALLOC_MUTEX(SgMinusOp, unlock);
  122297             :     return mem;
  122298             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  122299             : #if ROSE_PEDANTIC_ALLOC
  122300             :     ROSE_ASSERT(Size == sizeof(SgMinusOp));
  122301             : #else
  122302         666 :     if (Size != sizeof(SgMinusOp)) {
  122303           0 :       void * object = ROSE_MALLOC(Size);
  122304           0 :       ALLOC_MUTEX(SgMinusOp, unlock);
  122305             :       return object;
  122306             :     }
  122307             : #endif
  122308             : 
  122309         666 :     if (SgMinusOp::next_node == nullptr) {
  122310          46 :         SgMinusOp * alloc = (SgMinusOp*) ROSE_MALLOC ( SgMinusOp::pool_size * sizeof(SgMinusOp) );
  122311          46 :         ROSE_ASSERT(alloc != nullptr);
  122312             : 
  122313             : #if ROSE_ALLOC_TRACE == 2
  122314             : //        printf("SgMinusOp::alloc\n  block[%zi] = [ %p , %p [\n", SgMinusOp::pools.size(), alloc, alloc + SgMinusOp::pool_size);
  122315             : #endif
  122316             : 
  122317             : #if ROSE_ALLOC_MEMSET == 1
  122318             : #elif ROSE_ALLOC_MEMSET == 2
  122319             :         memset(alloc, 0x00, SgMinusOp::pool_size * sizeof(SgMinusOp));
  122320             : #elif ROSE_ALLOC_MEMSET == 3
  122321             :         memset(alloc, 0xAA, SgMinusOp::pool_size * sizeof(SgMinusOp));
  122322             : #endif
  122323       92000 :         for (unsigned i=0; i < SgMinusOp::pool_size-1; i++) {
  122324       91954 :           alloc[i].p_freepointer = &(alloc[i+1]);
  122325             :         }
  122326          46 :         alloc[SgMinusOp::pool_size-1].p_freepointer = nullptr;
  122327             : 
  122328          46 :         SgMinusOp::pools.push_back ( (unsigned char *) alloc );
  122329          46 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgMinusOp::pool_size * sizeof(SgMinusOp), V_SgMinusOp ) );
  122330          46 :         SgMinusOp::next_node = alloc;
  122331             :     }
  122332         666 :     ROSE_ASSERT(SgMinusOp::next_node != nullptr);
  122333             : 
  122334         666 :     SgMinusOp * object = SgMinusOp::next_node;
  122335         666 :     SgMinusOp::next_node = (SgMinusOp*)(object->p_freepointer);
  122336             : 
  122337             : #if ROSE_ALLOC_TRACE == 2
  122338             :     printf("SgMinusOp::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgMinusOp::next_node);
  122339             : #endif
  122340             : 
  122341         666 :     SgNode * fp = object->p_freepointer;
  122342             : #if ROSE_ALLOC_MEMSET == 1
  122343             : #elif ROSE_ALLOC_MEMSET == 2
  122344             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgMinusOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  122345             : #elif ROSE_ALLOC_MEMSET == 3
  122346             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgMinusOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  122347             : #endif
  122348         666 :     object->p_freepointer = fp;
  122349             : 
  122350             : #if ROSE_ALLOC_TRACE == 2
  122351             : //    printf("SgMinusOp::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgMinusOp::next_node);
  122352             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  122353             :     Rose::MemPool::snapshot(oss.str());
  122354             :     alloc_trace_cnt++;
  122355             : #endif
  122356             : 
  122357         666 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  122358             : 
  122359         666 :     ALLOC_MUTEX(SgMinusOp, unlock);
  122360             : 
  122361             :     return object;
  122362             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  122363             : }
  122364             : 
  122365             : 
  122366             : 
  122367             : /*! \brief Delete operator for SgMinusOp.
  122368             : 
  122369             :    This delete operator implements deallocation using memory pools to 
  122370             :    provide most efficent use of the heap within construction of large ASTs.
  122371             : 
  122372             : \internal The new and delete operators use the lower level C malloc/free
  122373             :    function calls for performance and to make sure that mixing of malloc/free
  122374             :    and new/delete by the used can be caught more readily.  This may change
  122375             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  122376             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  122377             :    deallocate memory allocated using ROSE_MALLOC.
  122378             : */
  122379         115 : void SgMinusOp::operator delete(void *Pointer, size_t Size)
  122380             : {
  122381             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  122382             :      * or throwing an exception. */
  122383         115 :     ALLOC_MUTEX(SgMinusOp, lock);
  122384             : 
  122385             : #if USE_CPP_NEW_DELETE_OPERATORS
  122386             :     ROSE_FREE(Pointer);
  122387             : #else
  122388             : #if ROSE_PEDANTIC_ALLOC
  122389             :     ROSE_ASSERT(Size == sizeof(SgMinusOp));
  122390             : #else
  122391         115 :     if (Size != sizeof(SgMinusOp)) {
  122392           0 :       ROSE_FREE(Pointer);
  122393           0 :       ALLOC_MUTEX(SgMinusOp, unlock);
  122394             :       return;
  122395             :     }
  122396             : #endif
  122397             : 
  122398         115 :     SgMinusOp * object = (SgMinusOp*) Pointer;
  122399         115 :     ROSE_ASSERT(object != nullptr);
  122400             : 
  122401             : #if ROSE_ALLOC_TRACE == 2
  122402             : //  printf("SgMinusOp::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgMinusOp::next_node);
  122403             :     printf("SgMinusOp::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgMinusOp::next_node);
  122404             : #endif
  122405             : 
  122406             : #if ROSE_PEDANTIC_ALLOC
  122407             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  122408             : #endif
  122409             : 
  122410             : #if ROSE_ALLOC_MEMSET == 1
  122411             : #elif ROSE_ALLOC_MEMSET == 2
  122412             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgMinusOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  122413             : #elif ROSE_ALLOC_MEMSET == 3
  122414             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgMinusOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  122415             : #endif
  122416             : 
  122417             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  122418             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  122419             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  122420             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  122421             : #else
  122422         115 :     object->p_freepointer = SgMinusOp::next_node;
  122423         115 :     SgMinusOp::next_node = object;
  122424             : #endif
  122425             : 
  122426             : #if ROSE_ALLOC_TRACE == 2
  122427             : //  printf("SgMinusOp::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgMinusOp::next_node);
  122428             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  122429             :     Rose::MemPool::snapshot(oss.str());
  122430             :     alloc_trace_cnt++;
  122431             : #endif
  122432             : 
  122433             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  122434             : 
  122435         115 :     ALLOC_MUTEX(SgMinusOp, unlock);
  122436             : }
  122437             : 
  122438             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  122439             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  122440             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  122441             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  122442             : // Also, note comment below from Robb (copied from the Common.code file).
  122443             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  122444             : //
  122445             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  122446             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  122447             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  122448             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  122449             : #if 0
  122450             : void SgMinusOp::operator delete(void* pointer) { SgMinusOp::operator delete (pointer, sizeof(SgMinusOp)); };
  122451             : #endif
  122452             : /* #line 122453 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  122453             : 
  122454             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  122455             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  122456             : // obviously imply C++.
  122457             : 
  122458             : // This implements the support within ROSE for memory pools.  Memory pools
  122459             : // support the most condensed usage of memory within the construction of
  122460             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  122461             : // by a new operator written for each class.
  122462             : 
  122463             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  122464             :     // User wants multi-thread support and POSIX threads are available.
  122465             : #   include <pthread.h>
  122466             :     static pthread_mutex_t SgUnaryAddOp_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  122467             : #else
  122468             :      // Cause synchronization to be skipped.
  122469             : #    ifndef ALLOC_MUTEX
  122470             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  122471             : #    endif
  122472             : #    ifdef _REENTRANT
  122473             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  122474             : #       ifdef _MSC_VER
  122475             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  122476             : #       else
  122477             : #           warning "POSIX threads are not available; synchronization being skipped"
  122478             : #       endif
  122479             : #    endif
  122480             : #endif
  122481             : 
  122482             : #ifndef ROSE_ALLOC_TRACE
  122483             : #  define ROSE_ALLOC_TRACE 0
  122484             : #endif
  122485             : 
  122486             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  122487             : #define ROSE_ALLOC_TRACE_CNT
  122488             : #include "memory-pool-snapshot.h"
  122489             : unsigned long alloc_trace_cnt = 0;
  122490             : #endif
  122491             : 
  122492             : #if ROSE_ALLOC_TRACE
  122493             : const unsigned SgUnaryAddOp::pool_size = 5;
  122494             : #else
  122495             : const unsigned SgUnaryAddOp::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  122496             : #endif
  122497             : 
  122498             : #ifndef ROSE_ALLOC_MEMSET
  122499             : #  define ROSE_ALLOC_MEMSET 0
  122500             : #endif
  122501             : 
  122502             : #ifndef ROSE_PEDANTIC_ALLOC
  122503             : #  define ROSE_PEDANTIC_ALLOC 0
  122504             : #endif
  122505             : 
  122506             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  122507             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  122508             : #endif
  122509             : 
  122510             : #if !defined(SGNODE__ALL_POOLS)
  122511             : #define SGNODE__ALL_POOLS
  122512             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  122513             : #endif
  122514             : 
  122515             : SgUnaryAddOp* SgUnaryAddOp::next_node = nullptr;
  122516             : std::vector<unsigned char*> SgUnaryAddOp::pools;
  122517             : 
  122518             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  122519             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  122520             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  122521             : // around this macro definition rather than each use).
  122522             : #ifndef ALLOC_MUTEX
  122523             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  122524             :         do {                                                                     \
  122525             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  122526             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  122527             :                 abort();                                                         \
  122528             :             }                                                                    \
  122529             :         } while (0);
  122530             : #endif
  122531             : 
  122532             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  122533             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  122534             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  122535             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  122536             : 
  122537             : /*! \brief New operator for SgUnaryAddOp.
  122538             : 
  122539             :    This new operator implements memory pools to provide most efficent 
  122540             :    use of the heap within construction of large ASTs.
  122541             : 
  122542             : \internal The new and delete operators use the lower level C malloc/free
  122543             :    function calls for performance and to make sure that mixing of malloc/free
  122544             :    and new/delete by the used can be caught more readily.  This may change
  122545             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  122546             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  122547             :    deallocate memory allocated using ROSE_MALLOC.
  122548             : */
  122549           1 : void *SgUnaryAddOp::operator new ( size_t Size )
  122550             : {
  122551             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  122552             :      * returning or throwing an exception. */
  122553           1 :     ALLOC_MUTEX(SgUnaryAddOp, lock);
  122554             : 
  122555             : #if ROSE_ALLOC_TRACE == 2
  122556             : //    printf("SgUnaryAddOp::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgUnaryAddOp::next_node);
  122557             : #endif
  122558             : 
  122559             : #if USE_CPP_NEW_DELETE_OPERATORS
  122560             :     void *mem = ROSE_MALLOC(Size);
  122561             :     ALLOC_MUTEX(SgUnaryAddOp, unlock);
  122562             :     return mem;
  122563             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  122564             : #if ROSE_PEDANTIC_ALLOC
  122565             :     ROSE_ASSERT(Size == sizeof(SgUnaryAddOp));
  122566             : #else
  122567           1 :     if (Size != sizeof(SgUnaryAddOp)) {
  122568           0 :       void * object = ROSE_MALLOC(Size);
  122569           0 :       ALLOC_MUTEX(SgUnaryAddOp, unlock);
  122570             :       return object;
  122571             :     }
  122572             : #endif
  122573             : 
  122574           1 :     if (SgUnaryAddOp::next_node == nullptr) {
  122575           1 :         SgUnaryAddOp * alloc = (SgUnaryAddOp*) ROSE_MALLOC ( SgUnaryAddOp::pool_size * sizeof(SgUnaryAddOp) );
  122576           1 :         ROSE_ASSERT(alloc != nullptr);
  122577             : 
  122578             : #if ROSE_ALLOC_TRACE == 2
  122579             : //        printf("SgUnaryAddOp::alloc\n  block[%zi] = [ %p , %p [\n", SgUnaryAddOp::pools.size(), alloc, alloc + SgUnaryAddOp::pool_size);
  122580             : #endif
  122581             : 
  122582             : #if ROSE_ALLOC_MEMSET == 1
  122583             : #elif ROSE_ALLOC_MEMSET == 2
  122584             :         memset(alloc, 0x00, SgUnaryAddOp::pool_size * sizeof(SgUnaryAddOp));
  122585             : #elif ROSE_ALLOC_MEMSET == 3
  122586             :         memset(alloc, 0xAA, SgUnaryAddOp::pool_size * sizeof(SgUnaryAddOp));
  122587             : #endif
  122588        2000 :         for (unsigned i=0; i < SgUnaryAddOp::pool_size-1; i++) {
  122589        1999 :           alloc[i].p_freepointer = &(alloc[i+1]);
  122590             :         }
  122591           1 :         alloc[SgUnaryAddOp::pool_size-1].p_freepointer = nullptr;
  122592             : 
  122593           1 :         SgUnaryAddOp::pools.push_back ( (unsigned char *) alloc );
  122594           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgUnaryAddOp::pool_size * sizeof(SgUnaryAddOp), V_SgUnaryAddOp ) );
  122595           1 :         SgUnaryAddOp::next_node = alloc;
  122596             :     }
  122597           1 :     ROSE_ASSERT(SgUnaryAddOp::next_node != nullptr);
  122598             : 
  122599           1 :     SgUnaryAddOp * object = SgUnaryAddOp::next_node;
  122600           1 :     SgUnaryAddOp::next_node = (SgUnaryAddOp*)(object->p_freepointer);
  122601             : 
  122602             : #if ROSE_ALLOC_TRACE == 2
  122603             :     printf("SgUnaryAddOp::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUnaryAddOp::next_node);
  122604             : #endif
  122605             : 
  122606           1 :     SgNode * fp = object->p_freepointer;
  122607             : #if ROSE_ALLOC_MEMSET == 1
  122608             : #elif ROSE_ALLOC_MEMSET == 2
  122609             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgUnaryAddOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  122610             : #elif ROSE_ALLOC_MEMSET == 3
  122611             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgUnaryAddOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  122612             : #endif
  122613           1 :     object->p_freepointer = fp;
  122614             : 
  122615             : #if ROSE_ALLOC_TRACE == 2
  122616             : //    printf("SgUnaryAddOp::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUnaryAddOp::next_node);
  122617             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  122618             :     Rose::MemPool::snapshot(oss.str());
  122619             :     alloc_trace_cnt++;
  122620             : #endif
  122621             : 
  122622           1 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  122623             : 
  122624           1 :     ALLOC_MUTEX(SgUnaryAddOp, unlock);
  122625             : 
  122626             :     return object;
  122627             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  122628             : }
  122629             : 
  122630             : 
  122631             : 
  122632             : /*! \brief Delete operator for SgUnaryAddOp.
  122633             : 
  122634             :    This delete operator implements deallocation using memory pools to 
  122635             :    provide most efficent use of the heap within construction of large ASTs.
  122636             : 
  122637             : \internal The new and delete operators use the lower level C malloc/free
  122638             :    function calls for performance and to make sure that mixing of malloc/free
  122639             :    and new/delete by the used can be caught more readily.  This may change
  122640             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  122641             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  122642             :    deallocate memory allocated using ROSE_MALLOC.
  122643             : */
  122644           0 : void SgUnaryAddOp::operator delete(void *Pointer, size_t Size)
  122645             : {
  122646             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  122647             :      * or throwing an exception. */
  122648           0 :     ALLOC_MUTEX(SgUnaryAddOp, lock);
  122649             : 
  122650             : #if USE_CPP_NEW_DELETE_OPERATORS
  122651             :     ROSE_FREE(Pointer);
  122652             : #else
  122653             : #if ROSE_PEDANTIC_ALLOC
  122654             :     ROSE_ASSERT(Size == sizeof(SgUnaryAddOp));
  122655             : #else
  122656           0 :     if (Size != sizeof(SgUnaryAddOp)) {
  122657           0 :       ROSE_FREE(Pointer);
  122658           0 :       ALLOC_MUTEX(SgUnaryAddOp, unlock);
  122659             :       return;
  122660             :     }
  122661             : #endif
  122662             : 
  122663           0 :     SgUnaryAddOp * object = (SgUnaryAddOp*) Pointer;
  122664           0 :     ROSE_ASSERT(object != nullptr);
  122665             : 
  122666             : #if ROSE_ALLOC_TRACE == 2
  122667             : //  printf("SgUnaryAddOp::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUnaryAddOp::next_node);
  122668             :     printf("SgUnaryAddOp::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUnaryAddOp::next_node);
  122669             : #endif
  122670             : 
  122671             : #if ROSE_PEDANTIC_ALLOC
  122672             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  122673             : #endif
  122674             : 
  122675             : #if ROSE_ALLOC_MEMSET == 1
  122676             : #elif ROSE_ALLOC_MEMSET == 2
  122677             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgUnaryAddOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  122678             : #elif ROSE_ALLOC_MEMSET == 3
  122679             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgUnaryAddOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  122680             : #endif
  122681             : 
  122682             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  122683             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  122684             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  122685             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  122686             : #else
  122687           0 :     object->p_freepointer = SgUnaryAddOp::next_node;
  122688           0 :     SgUnaryAddOp::next_node = object;
  122689             : #endif
  122690             : 
  122691             : #if ROSE_ALLOC_TRACE == 2
  122692             : //  printf("SgUnaryAddOp::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUnaryAddOp::next_node);
  122693             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  122694             :     Rose::MemPool::snapshot(oss.str());
  122695             :     alloc_trace_cnt++;
  122696             : #endif
  122697             : 
  122698             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  122699             : 
  122700           0 :     ALLOC_MUTEX(SgUnaryAddOp, unlock);
  122701             : }
  122702             : 
  122703             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  122704             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  122705             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  122706             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  122707             : // Also, note comment below from Robb (copied from the Common.code file).
  122708             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  122709             : //
  122710             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  122711             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  122712             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  122713             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  122714             : #if 0
  122715             : void SgUnaryAddOp::operator delete(void* pointer) { SgUnaryAddOp::operator delete (pointer, sizeof(SgUnaryAddOp)); };
  122716             : #endif
  122717             : /* #line 122718 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  122718             : 
  122719             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  122720             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  122721             : // obviously imply C++.
  122722             : 
  122723             : // This implements the support within ROSE for memory pools.  Memory pools
  122724             : // support the most condensed usage of memory within the construction of
  122725             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  122726             : // by a new operator written for each class.
  122727             : 
  122728             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  122729             :     // User wants multi-thread support and POSIX threads are available.
  122730             : #   include <pthread.h>
  122731             :     static pthread_mutex_t SgNotOp_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  122732             : #else
  122733             :      // Cause synchronization to be skipped.
  122734             : #    ifndef ALLOC_MUTEX
  122735             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  122736             : #    endif
  122737             : #    ifdef _REENTRANT
  122738             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  122739             : #       ifdef _MSC_VER
  122740             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  122741             : #       else
  122742             : #           warning "POSIX threads are not available; synchronization being skipped"
  122743             : #       endif
  122744             : #    endif
  122745             : #endif
  122746             : 
  122747             : #ifndef ROSE_ALLOC_TRACE
  122748             : #  define ROSE_ALLOC_TRACE 0
  122749             : #endif
  122750             : 
  122751             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  122752             : #define ROSE_ALLOC_TRACE_CNT
  122753             : #include "memory-pool-snapshot.h"
  122754             : unsigned long alloc_trace_cnt = 0;
  122755             : #endif
  122756             : 
  122757             : #if ROSE_ALLOC_TRACE
  122758             : const unsigned SgNotOp::pool_size = 5;
  122759             : #else
  122760             : const unsigned SgNotOp::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  122761             : #endif
  122762             : 
  122763             : #ifndef ROSE_ALLOC_MEMSET
  122764             : #  define ROSE_ALLOC_MEMSET 0
  122765             : #endif
  122766             : 
  122767             : #ifndef ROSE_PEDANTIC_ALLOC
  122768             : #  define ROSE_PEDANTIC_ALLOC 0
  122769             : #endif
  122770             : 
  122771             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  122772             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  122773             : #endif
  122774             : 
  122775             : #if !defined(SGNODE__ALL_POOLS)
  122776             : #define SGNODE__ALL_POOLS
  122777             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  122778             : #endif
  122779             : 
  122780             : SgNotOp* SgNotOp::next_node = nullptr;
  122781             : std::vector<unsigned char*> SgNotOp::pools;
  122782             : 
  122783             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  122784             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  122785             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  122786             : // around this macro definition rather than each use).
  122787             : #ifndef ALLOC_MUTEX
  122788             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  122789             :         do {                                                                     \
  122790             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  122791             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  122792             :                 abort();                                                         \
  122793             :             }                                                                    \
  122794             :         } while (0);
  122795             : #endif
  122796             : 
  122797             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  122798             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  122799             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  122800             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  122801             : 
  122802             : /*! \brief New operator for SgNotOp.
  122803             : 
  122804             :    This new operator implements memory pools to provide most efficent 
  122805             :    use of the heap within construction of large ASTs.
  122806             : 
  122807             : \internal The new and delete operators use the lower level C malloc/free
  122808             :    function calls for performance and to make sure that mixing of malloc/free
  122809             :    and new/delete by the used can be caught more readily.  This may change
  122810             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  122811             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  122812             :    deallocate memory allocated using ROSE_MALLOC.
  122813             : */
  122814        2693 : void *SgNotOp::operator new ( size_t Size )
  122815             : {
  122816             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  122817             :      * returning or throwing an exception. */
  122818        2693 :     ALLOC_MUTEX(SgNotOp, lock);
  122819             : 
  122820             : #if ROSE_ALLOC_TRACE == 2
  122821             : //    printf("SgNotOp::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgNotOp::next_node);
  122822             : #endif
  122823             : 
  122824             : #if USE_CPP_NEW_DELETE_OPERATORS
  122825             :     void *mem = ROSE_MALLOC(Size);
  122826             :     ALLOC_MUTEX(SgNotOp, unlock);
  122827             :     return mem;
  122828             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  122829             : #if ROSE_PEDANTIC_ALLOC
  122830             :     ROSE_ASSERT(Size == sizeof(SgNotOp));
  122831             : #else
  122832        2693 :     if (Size != sizeof(SgNotOp)) {
  122833           0 :       void * object = ROSE_MALLOC(Size);
  122834           0 :       ALLOC_MUTEX(SgNotOp, unlock);
  122835             :       return object;
  122836             :     }
  122837             : #endif
  122838             : 
  122839        2693 :     if (SgNotOp::next_node == nullptr) {
  122840          17 :         SgNotOp * alloc = (SgNotOp*) ROSE_MALLOC ( SgNotOp::pool_size * sizeof(SgNotOp) );
  122841          17 :         ROSE_ASSERT(alloc != nullptr);
  122842             : 
  122843             : #if ROSE_ALLOC_TRACE == 2
  122844             : //        printf("SgNotOp::alloc\n  block[%zi] = [ %p , %p [\n", SgNotOp::pools.size(), alloc, alloc + SgNotOp::pool_size);
  122845             : #endif
  122846             : 
  122847             : #if ROSE_ALLOC_MEMSET == 1
  122848             : #elif ROSE_ALLOC_MEMSET == 2
  122849             :         memset(alloc, 0x00, SgNotOp::pool_size * sizeof(SgNotOp));
  122850             : #elif ROSE_ALLOC_MEMSET == 3
  122851             :         memset(alloc, 0xAA, SgNotOp::pool_size * sizeof(SgNotOp));
  122852             : #endif
  122853       34000 :         for (unsigned i=0; i < SgNotOp::pool_size-1; i++) {
  122854       33983 :           alloc[i].p_freepointer = &(alloc[i+1]);
  122855             :         }
  122856          17 :         alloc[SgNotOp::pool_size-1].p_freepointer = nullptr;
  122857             : 
  122858          17 :         SgNotOp::pools.push_back ( (unsigned char *) alloc );
  122859          17 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgNotOp::pool_size * sizeof(SgNotOp), V_SgNotOp ) );
  122860          17 :         SgNotOp::next_node = alloc;
  122861             :     }
  122862        2693 :     ROSE_ASSERT(SgNotOp::next_node != nullptr);
  122863             : 
  122864        2693 :     SgNotOp * object = SgNotOp::next_node;
  122865        2693 :     SgNotOp::next_node = (SgNotOp*)(object->p_freepointer);
  122866             : 
  122867             : #if ROSE_ALLOC_TRACE == 2
  122868             :     printf("SgNotOp::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgNotOp::next_node);
  122869             : #endif
  122870             : 
  122871        2693 :     SgNode * fp = object->p_freepointer;
  122872             : #if ROSE_ALLOC_MEMSET == 1
  122873             : #elif ROSE_ALLOC_MEMSET == 2
  122874             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgNotOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  122875             : #elif ROSE_ALLOC_MEMSET == 3
  122876             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgNotOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  122877             : #endif
  122878        2693 :     object->p_freepointer = fp;
  122879             : 
  122880             : #if ROSE_ALLOC_TRACE == 2
  122881             : //    printf("SgNotOp::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgNotOp::next_node);
  122882             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  122883             :     Rose::MemPool::snapshot(oss.str());
  122884             :     alloc_trace_cnt++;
  122885             : #endif
  122886             : 
  122887        2693 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  122888             : 
  122889        2693 :     ALLOC_MUTEX(SgNotOp, unlock);
  122890             : 
  122891             :     return object;
  122892             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  122893             : }
  122894             : 
  122895             : 
  122896             : 
  122897             : /*! \brief Delete operator for SgNotOp.
  122898             : 
  122899             :    This delete operator implements deallocation using memory pools to 
  122900             :    provide most efficent use of the heap within construction of large ASTs.
  122901             : 
  122902             : \internal The new and delete operators use the lower level C malloc/free
  122903             :    function calls for performance and to make sure that mixing of malloc/free
  122904             :    and new/delete by the used can be caught more readily.  This may change
  122905             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  122906             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  122907             :    deallocate memory allocated using ROSE_MALLOC.
  122908             : */
  122909         746 : void SgNotOp::operator delete(void *Pointer, size_t Size)
  122910             : {
  122911             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  122912             :      * or throwing an exception. */
  122913         746 :     ALLOC_MUTEX(SgNotOp, lock);
  122914             : 
  122915             : #if USE_CPP_NEW_DELETE_OPERATORS
  122916             :     ROSE_FREE(Pointer);
  122917             : #else
  122918             : #if ROSE_PEDANTIC_ALLOC
  122919             :     ROSE_ASSERT(Size == sizeof(SgNotOp));
  122920             : #else
  122921         746 :     if (Size != sizeof(SgNotOp)) {
  122922           0 :       ROSE_FREE(Pointer);
  122923           0 :       ALLOC_MUTEX(SgNotOp, unlock);
  122924             :       return;
  122925             :     }
  122926             : #endif
  122927             : 
  122928         746 :     SgNotOp * object = (SgNotOp*) Pointer;
  122929         746 :     ROSE_ASSERT(object != nullptr);
  122930             : 
  122931             : #if ROSE_ALLOC_TRACE == 2
  122932             : //  printf("SgNotOp::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgNotOp::next_node);
  122933             :     printf("SgNotOp::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgNotOp::next_node);
  122934             : #endif
  122935             : 
  122936             : #if ROSE_PEDANTIC_ALLOC
  122937             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  122938             : #endif
  122939             : 
  122940             : #if ROSE_ALLOC_MEMSET == 1
  122941             : #elif ROSE_ALLOC_MEMSET == 2
  122942             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgNotOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  122943             : #elif ROSE_ALLOC_MEMSET == 3
  122944             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgNotOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  122945             : #endif
  122946             : 
  122947             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  122948             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  122949             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  122950             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  122951             : #else
  122952         746 :     object->p_freepointer = SgNotOp::next_node;
  122953         746 :     SgNotOp::next_node = object;
  122954             : #endif
  122955             : 
  122956             : #if ROSE_ALLOC_TRACE == 2
  122957             : //  printf("SgNotOp::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgNotOp::next_node);
  122958             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  122959             :     Rose::MemPool::snapshot(oss.str());
  122960             :     alloc_trace_cnt++;
  122961             : #endif
  122962             : 
  122963             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  122964             : 
  122965         746 :     ALLOC_MUTEX(SgNotOp, unlock);
  122966             : }
  122967             : 
  122968             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  122969             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  122970             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  122971             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  122972             : // Also, note comment below from Robb (copied from the Common.code file).
  122973             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  122974             : //
  122975             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  122976             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  122977             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  122978             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  122979             : #if 0
  122980             : void SgNotOp::operator delete(void* pointer) { SgNotOp::operator delete (pointer, sizeof(SgNotOp)); };
  122981             : #endif
  122982             : /* #line 122983 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  122983             : 
  122984             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  122985             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  122986             : // obviously imply C++.
  122987             : 
  122988             : // This implements the support within ROSE for memory pools.  Memory pools
  122989             : // support the most condensed usage of memory within the construction of
  122990             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  122991             : // by a new operator written for each class.
  122992             : 
  122993             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  122994             :     // User wants multi-thread support and POSIX threads are available.
  122995             : #   include <pthread.h>
  122996             :     static pthread_mutex_t SgPointerDerefExp_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  122997             : #else
  122998             :      // Cause synchronization to be skipped.
  122999             : #    ifndef ALLOC_MUTEX
  123000             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  123001             : #    endif
  123002             : #    ifdef _REENTRANT
  123003             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  123004             : #       ifdef _MSC_VER
  123005             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  123006             : #       else
  123007             : #           warning "POSIX threads are not available; synchronization being skipped"
  123008             : #       endif
  123009             : #    endif
  123010             : #endif
  123011             : 
  123012             : #ifndef ROSE_ALLOC_TRACE
  123013             : #  define ROSE_ALLOC_TRACE 0
  123014             : #endif
  123015             : 
  123016             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  123017             : #define ROSE_ALLOC_TRACE_CNT
  123018             : #include "memory-pool-snapshot.h"
  123019             : unsigned long alloc_trace_cnt = 0;
  123020             : #endif
  123021             : 
  123022             : #if ROSE_ALLOC_TRACE
  123023             : const unsigned SgPointerDerefExp::pool_size = 5;
  123024             : #else
  123025             : const unsigned SgPointerDerefExp::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  123026             : #endif
  123027             : 
  123028             : #ifndef ROSE_ALLOC_MEMSET
  123029             : #  define ROSE_ALLOC_MEMSET 0
  123030             : #endif
  123031             : 
  123032             : #ifndef ROSE_PEDANTIC_ALLOC
  123033             : #  define ROSE_PEDANTIC_ALLOC 0
  123034             : #endif
  123035             : 
  123036             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  123037             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  123038             : #endif
  123039             : 
  123040             : #if !defined(SGNODE__ALL_POOLS)
  123041             : #define SGNODE__ALL_POOLS
  123042             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  123043             : #endif
  123044             : 
  123045             : SgPointerDerefExp* SgPointerDerefExp::next_node = nullptr;
  123046             : std::vector<unsigned char*> SgPointerDerefExp::pools;
  123047             : 
  123048             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  123049             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  123050             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  123051             : // around this macro definition rather than each use).
  123052             : #ifndef ALLOC_MUTEX
  123053             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  123054             :         do {                                                                     \
  123055             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  123056             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  123057             :                 abort();                                                         \
  123058             :             }                                                                    \
  123059             :         } while (0);
  123060             : #endif
  123061             : 
  123062             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  123063             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  123064             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  123065             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  123066             : 
  123067             : /*! \brief New operator for SgPointerDerefExp.
  123068             : 
  123069             :    This new operator implements memory pools to provide most efficent 
  123070             :    use of the heap within construction of large ASTs.
  123071             : 
  123072             : \internal The new and delete operators use the lower level C malloc/free
  123073             :    function calls for performance and to make sure that mixing of malloc/free
  123074             :    and new/delete by the used can be caught more readily.  This may change
  123075             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  123076             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  123077             :    deallocate memory allocated using ROSE_MALLOC.
  123078             : */
  123079        4108 : void *SgPointerDerefExp::operator new ( size_t Size )
  123080             : {
  123081             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  123082             :      * returning or throwing an exception. */
  123083        4108 :     ALLOC_MUTEX(SgPointerDerefExp, lock);
  123084             : 
  123085             : #if ROSE_ALLOC_TRACE == 2
  123086             : //    printf("SgPointerDerefExp::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgPointerDerefExp::next_node);
  123087             : #endif
  123088             : 
  123089             : #if USE_CPP_NEW_DELETE_OPERATORS
  123090             :     void *mem = ROSE_MALLOC(Size);
  123091             :     ALLOC_MUTEX(SgPointerDerefExp, unlock);
  123092             :     return mem;
  123093             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  123094             : #if ROSE_PEDANTIC_ALLOC
  123095             :     ROSE_ASSERT(Size == sizeof(SgPointerDerefExp));
  123096             : #else
  123097        4108 :     if (Size != sizeof(SgPointerDerefExp)) {
  123098           0 :       void * object = ROSE_MALLOC(Size);
  123099           0 :       ALLOC_MUTEX(SgPointerDerefExp, unlock);
  123100             :       return object;
  123101             :     }
  123102             : #endif
  123103             : 
  123104        4108 :     if (SgPointerDerefExp::next_node == nullptr) {
  123105          19 :         SgPointerDerefExp * alloc = (SgPointerDerefExp*) ROSE_MALLOC ( SgPointerDerefExp::pool_size * sizeof(SgPointerDerefExp) );
  123106          19 :         ROSE_ASSERT(alloc != nullptr);
  123107             : 
  123108             : #if ROSE_ALLOC_TRACE == 2
  123109             : //        printf("SgPointerDerefExp::alloc\n  block[%zi] = [ %p , %p [\n", SgPointerDerefExp::pools.size(), alloc, alloc + SgPointerDerefExp::pool_size);
  123110             : #endif
  123111             : 
  123112             : #if ROSE_ALLOC_MEMSET == 1
  123113             : #elif ROSE_ALLOC_MEMSET == 2
  123114             :         memset(alloc, 0x00, SgPointerDerefExp::pool_size * sizeof(SgPointerDerefExp));
  123115             : #elif ROSE_ALLOC_MEMSET == 3
  123116             :         memset(alloc, 0xAA, SgPointerDerefExp::pool_size * sizeof(SgPointerDerefExp));
  123117             : #endif
  123118       38000 :         for (unsigned i=0; i < SgPointerDerefExp::pool_size-1; i++) {
  123119       37981 :           alloc[i].p_freepointer = &(alloc[i+1]);
  123120             :         }
  123121          19 :         alloc[SgPointerDerefExp::pool_size-1].p_freepointer = nullptr;
  123122             : 
  123123          19 :         SgPointerDerefExp::pools.push_back ( (unsigned char *) alloc );
  123124          19 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgPointerDerefExp::pool_size * sizeof(SgPointerDerefExp), V_SgPointerDerefExp ) );
  123125          19 :         SgPointerDerefExp::next_node = alloc;
  123126             :     }
  123127        4108 :     ROSE_ASSERT(SgPointerDerefExp::next_node != nullptr);
  123128             : 
  123129        4108 :     SgPointerDerefExp * object = SgPointerDerefExp::next_node;
  123130        4108 :     SgPointerDerefExp::next_node = (SgPointerDerefExp*)(object->p_freepointer);
  123131             : 
  123132             : #if ROSE_ALLOC_TRACE == 2
  123133             :     printf("SgPointerDerefExp::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgPointerDerefExp::next_node);
  123134             : #endif
  123135             : 
  123136        4108 :     SgNode * fp = object->p_freepointer;
  123137             : #if ROSE_ALLOC_MEMSET == 1
  123138             : #elif ROSE_ALLOC_MEMSET == 2
  123139             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgPointerDerefExp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  123140             : #elif ROSE_ALLOC_MEMSET == 3
  123141             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgPointerDerefExp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  123142             : #endif
  123143        4108 :     object->p_freepointer = fp;
  123144             : 
  123145             : #if ROSE_ALLOC_TRACE == 2
  123146             : //    printf("SgPointerDerefExp::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgPointerDerefExp::next_node);
  123147             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  123148             :     Rose::MemPool::snapshot(oss.str());
  123149             :     alloc_trace_cnt++;
  123150             : #endif
  123151             : 
  123152        4108 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  123153             : 
  123154        4108 :     ALLOC_MUTEX(SgPointerDerefExp, unlock);
  123155             : 
  123156             :     return object;
  123157             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  123158             : }
  123159             : 
  123160             : 
  123161             : 
  123162             : /*! \brief Delete operator for SgPointerDerefExp.
  123163             : 
  123164             :    This delete operator implements deallocation using memory pools to 
  123165             :    provide most efficent use of the heap within construction of large ASTs.
  123166             : 
  123167             : \internal The new and delete operators use the lower level C malloc/free
  123168             :    function calls for performance and to make sure that mixing of malloc/free
  123169             :    and new/delete by the used can be caught more readily.  This may change
  123170             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  123171             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  123172             :    deallocate memory allocated using ROSE_MALLOC.
  123173             : */
  123174         808 : void SgPointerDerefExp::operator delete(void *Pointer, size_t Size)
  123175             : {
  123176             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  123177             :      * or throwing an exception. */
  123178         808 :     ALLOC_MUTEX(SgPointerDerefExp, lock);
  123179             : 
  123180             : #if USE_CPP_NEW_DELETE_OPERATORS
  123181             :     ROSE_FREE(Pointer);
  123182             : #else
  123183             : #if ROSE_PEDANTIC_ALLOC
  123184             :     ROSE_ASSERT(Size == sizeof(SgPointerDerefExp));
  123185             : #else
  123186         808 :     if (Size != sizeof(SgPointerDerefExp)) {
  123187           0 :       ROSE_FREE(Pointer);
  123188           0 :       ALLOC_MUTEX(SgPointerDerefExp, unlock);
  123189             :       return;
  123190             :     }
  123191             : #endif
  123192             : 
  123193         808 :     SgPointerDerefExp * object = (SgPointerDerefExp*) Pointer;
  123194         808 :     ROSE_ASSERT(object != nullptr);
  123195             : 
  123196             : #if ROSE_ALLOC_TRACE == 2
  123197             : //  printf("SgPointerDerefExp::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgPointerDerefExp::next_node);
  123198             :     printf("SgPointerDerefExp::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgPointerDerefExp::next_node);
  123199             : #endif
  123200             : 
  123201             : #if ROSE_PEDANTIC_ALLOC
  123202             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  123203             : #endif
  123204             : 
  123205             : #if ROSE_ALLOC_MEMSET == 1
  123206             : #elif ROSE_ALLOC_MEMSET == 2
  123207             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgPointerDerefExp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  123208             : #elif ROSE_ALLOC_MEMSET == 3
  123209             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgPointerDerefExp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  123210             : #endif
  123211             : 
  123212             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  123213             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  123214             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  123215             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  123216             : #else
  123217         808 :     object->p_freepointer = SgPointerDerefExp::next_node;
  123218         808 :     SgPointerDerefExp::next_node = object;
  123219             : #endif
  123220             : 
  123221             : #if ROSE_ALLOC_TRACE == 2
  123222             : //  printf("SgPointerDerefExp::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgPointerDerefExp::next_node);
  123223             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  123224             :     Rose::MemPool::snapshot(oss.str());
  123225             :     alloc_trace_cnt++;
  123226             : #endif
  123227             : 
  123228             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  123229             : 
  123230         808 :     ALLOC_MUTEX(SgPointerDerefExp, unlock);
  123231             : }
  123232             : 
  123233             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  123234             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  123235             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  123236             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  123237             : // Also, note comment below from Robb (copied from the Common.code file).
  123238             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  123239             : //
  123240             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  123241             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  123242             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  123243             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  123244             : #if 0
  123245             : void SgPointerDerefExp::operator delete(void* pointer) { SgPointerDerefExp::operator delete (pointer, sizeof(SgPointerDerefExp)); };
  123246             : #endif
  123247             : /* #line 123248 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  123248             : 
  123249             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  123250             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  123251             : // obviously imply C++.
  123252             : 
  123253             : // This implements the support within ROSE for memory pools.  Memory pools
  123254             : // support the most condensed usage of memory within the construction of
  123255             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  123256             : // by a new operator written for each class.
  123257             : 
  123258             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  123259             :     // User wants multi-thread support and POSIX threads are available.
  123260             : #   include <pthread.h>
  123261             :     static pthread_mutex_t SgAddressOfOp_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  123262             : #else
  123263             :      // Cause synchronization to be skipped.
  123264             : #    ifndef ALLOC_MUTEX
  123265             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  123266             : #    endif
  123267             : #    ifdef _REENTRANT
  123268             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  123269             : #       ifdef _MSC_VER
  123270             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  123271             : #       else
  123272             : #           warning "POSIX threads are not available; synchronization being skipped"
  123273             : #       endif
  123274             : #    endif
  123275             : #endif
  123276             : 
  123277             : #ifndef ROSE_ALLOC_TRACE
  123278             : #  define ROSE_ALLOC_TRACE 0
  123279             : #endif
  123280             : 
  123281             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  123282             : #define ROSE_ALLOC_TRACE_CNT
  123283             : #include "memory-pool-snapshot.h"
  123284             : unsigned long alloc_trace_cnt = 0;
  123285             : #endif
  123286             : 
  123287             : #if ROSE_ALLOC_TRACE
  123288             : const unsigned SgAddressOfOp::pool_size = 5;
  123289             : #else
  123290             : const unsigned SgAddressOfOp::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  123291             : #endif
  123292             : 
  123293             : #ifndef ROSE_ALLOC_MEMSET
  123294             : #  define ROSE_ALLOC_MEMSET 0
  123295             : #endif
  123296             : 
  123297             : #ifndef ROSE_PEDANTIC_ALLOC
  123298             : #  define ROSE_PEDANTIC_ALLOC 0
  123299             : #endif
  123300             : 
  123301             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  123302             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  123303             : #endif
  123304             : 
  123305             : #if !defined(SGNODE__ALL_POOLS)
  123306             : #define SGNODE__ALL_POOLS
  123307             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  123308             : #endif
  123309             : 
  123310             : SgAddressOfOp* SgAddressOfOp::next_node = nullptr;
  123311             : std::vector<unsigned char*> SgAddressOfOp::pools;
  123312             : 
  123313             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  123314             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  123315             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  123316             : // around this macro definition rather than each use).
  123317             : #ifndef ALLOC_MUTEX
  123318             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  123319             :         do {                                                                     \
  123320             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  123321             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  123322             :                 abort();                                                         \
  123323             :             }                                                                    \
  123324             :         } while (0);
  123325             : #endif
  123326             : 
  123327             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  123328             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  123329             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  123330             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  123331             : 
  123332             : /*! \brief New operator for SgAddressOfOp.
  123333             : 
  123334             :    This new operator implements memory pools to provide most efficent 
  123335             :    use of the heap within construction of large ASTs.
  123336             : 
  123337             : \internal The new and delete operators use the lower level C malloc/free
  123338             :    function calls for performance and to make sure that mixing of malloc/free
  123339             :    and new/delete by the used can be caught more readily.  This may change
  123340             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  123341             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  123342             :    deallocate memory allocated using ROSE_MALLOC.
  123343             : */
  123344         880 : void *SgAddressOfOp::operator new ( size_t Size )
  123345             : {
  123346             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  123347             :      * returning or throwing an exception. */
  123348         880 :     ALLOC_MUTEX(SgAddressOfOp, lock);
  123349             : 
  123350             : #if ROSE_ALLOC_TRACE == 2
  123351             : //    printf("SgAddressOfOp::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgAddressOfOp::next_node);
  123352             : #endif
  123353             : 
  123354             : #if USE_CPP_NEW_DELETE_OPERATORS
  123355             :     void *mem = ROSE_MALLOC(Size);
  123356             :     ALLOC_MUTEX(SgAddressOfOp, unlock);
  123357             :     return mem;
  123358             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  123359             : #if ROSE_PEDANTIC_ALLOC
  123360             :     ROSE_ASSERT(Size == sizeof(SgAddressOfOp));
  123361             : #else
  123362         880 :     if (Size != sizeof(SgAddressOfOp)) {
  123363           0 :       void * object = ROSE_MALLOC(Size);
  123364           0 :       ALLOC_MUTEX(SgAddressOfOp, unlock);
  123365             :       return object;
  123366             :     }
  123367             : #endif
  123368             : 
  123369         880 :     if (SgAddressOfOp::next_node == nullptr) {
  123370          39 :         SgAddressOfOp * alloc = (SgAddressOfOp*) ROSE_MALLOC ( SgAddressOfOp::pool_size * sizeof(SgAddressOfOp) );
  123371          39 :         ROSE_ASSERT(alloc != nullptr);
  123372             : 
  123373             : #if ROSE_ALLOC_TRACE == 2
  123374             : //        printf("SgAddressOfOp::alloc\n  block[%zi] = [ %p , %p [\n", SgAddressOfOp::pools.size(), alloc, alloc + SgAddressOfOp::pool_size);
  123375             : #endif
  123376             : 
  123377             : #if ROSE_ALLOC_MEMSET == 1
  123378             : #elif ROSE_ALLOC_MEMSET == 2
  123379             :         memset(alloc, 0x00, SgAddressOfOp::pool_size * sizeof(SgAddressOfOp));
  123380             : #elif ROSE_ALLOC_MEMSET == 3
  123381             :         memset(alloc, 0xAA, SgAddressOfOp::pool_size * sizeof(SgAddressOfOp));
  123382             : #endif
  123383       78000 :         for (unsigned i=0; i < SgAddressOfOp::pool_size-1; i++) {
  123384       77961 :           alloc[i].p_freepointer = &(alloc[i+1]);
  123385             :         }
  123386          39 :         alloc[SgAddressOfOp::pool_size-1].p_freepointer = nullptr;
  123387             : 
  123388          39 :         SgAddressOfOp::pools.push_back ( (unsigned char *) alloc );
  123389          39 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgAddressOfOp::pool_size * sizeof(SgAddressOfOp), V_SgAddressOfOp ) );
  123390          39 :         SgAddressOfOp::next_node = alloc;
  123391             :     }
  123392         880 :     ROSE_ASSERT(SgAddressOfOp::next_node != nullptr);
  123393             : 
  123394         880 :     SgAddressOfOp * object = SgAddressOfOp::next_node;
  123395         880 :     SgAddressOfOp::next_node = (SgAddressOfOp*)(object->p_freepointer);
  123396             : 
  123397             : #if ROSE_ALLOC_TRACE == 2
  123398             :     printf("SgAddressOfOp::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgAddressOfOp::next_node);
  123399             : #endif
  123400             : 
  123401         880 :     SgNode * fp = object->p_freepointer;
  123402             : #if ROSE_ALLOC_MEMSET == 1
  123403             : #elif ROSE_ALLOC_MEMSET == 2
  123404             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgAddressOfOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  123405             : #elif ROSE_ALLOC_MEMSET == 3
  123406             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgAddressOfOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  123407             : #endif
  123408         880 :     object->p_freepointer = fp;
  123409             : 
  123410             : #if ROSE_ALLOC_TRACE == 2
  123411             : //    printf("SgAddressOfOp::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgAddressOfOp::next_node);
  123412             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  123413             :     Rose::MemPool::snapshot(oss.str());
  123414             :     alloc_trace_cnt++;
  123415             : #endif
  123416             : 
  123417         880 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  123418             : 
  123419         880 :     ALLOC_MUTEX(SgAddressOfOp, unlock);
  123420             : 
  123421             :     return object;
  123422             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  123423             : }
  123424             : 
  123425             : 
  123426             : 
  123427             : /*! \brief Delete operator for SgAddressOfOp.
  123428             : 
  123429             :    This delete operator implements deallocation using memory pools to 
  123430             :    provide most efficent use of the heap within construction of large ASTs.
  123431             : 
  123432             : \internal The new and delete operators use the lower level C malloc/free
  123433             :    function calls for performance and to make sure that mixing of malloc/free
  123434             :    and new/delete by the used can be caught more readily.  This may change
  123435             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  123436             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  123437             :    deallocate memory allocated using ROSE_MALLOC.
  123438             : */
  123439         169 : void SgAddressOfOp::operator delete(void *Pointer, size_t Size)
  123440             : {
  123441             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  123442             :      * or throwing an exception. */
  123443         169 :     ALLOC_MUTEX(SgAddressOfOp, lock);
  123444             : 
  123445             : #if USE_CPP_NEW_DELETE_OPERATORS
  123446             :     ROSE_FREE(Pointer);
  123447             : #else
  123448             : #if ROSE_PEDANTIC_ALLOC
  123449             :     ROSE_ASSERT(Size == sizeof(SgAddressOfOp));
  123450             : #else
  123451         169 :     if (Size != sizeof(SgAddressOfOp)) {
  123452           0 :       ROSE_FREE(Pointer);
  123453           0 :       ALLOC_MUTEX(SgAddressOfOp, unlock);
  123454             :       return;
  123455             :     }
  123456             : #endif
  123457             : 
  123458         169 :     SgAddressOfOp * object = (SgAddressOfOp*) Pointer;
  123459         169 :     ROSE_ASSERT(object != nullptr);
  123460             : 
  123461             : #if ROSE_ALLOC_TRACE == 2
  123462             : //  printf("SgAddressOfOp::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgAddressOfOp::next_node);
  123463             :     printf("SgAddressOfOp::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgAddressOfOp::next_node);
  123464             : #endif
  123465             : 
  123466             : #if ROSE_PEDANTIC_ALLOC
  123467             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  123468             : #endif
  123469             : 
  123470             : #if ROSE_ALLOC_MEMSET == 1
  123471             : #elif ROSE_ALLOC_MEMSET == 2
  123472             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgAddressOfOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  123473             : #elif ROSE_ALLOC_MEMSET == 3
  123474             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgAddressOfOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  123475             : #endif
  123476             : 
  123477             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  123478             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  123479             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  123480             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  123481             : #else
  123482         169 :     object->p_freepointer = SgAddressOfOp::next_node;
  123483         169 :     SgAddressOfOp::next_node = object;
  123484             : #endif
  123485             : 
  123486             : #if ROSE_ALLOC_TRACE == 2
  123487             : //  printf("SgAddressOfOp::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgAddressOfOp::next_node);
  123488             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  123489             :     Rose::MemPool::snapshot(oss.str());
  123490             :     alloc_trace_cnt++;
  123491             : #endif
  123492             : 
  123493             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  123494             : 
  123495         169 :     ALLOC_MUTEX(SgAddressOfOp, unlock);
  123496             : }
  123497             : 
  123498             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  123499             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  123500             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  123501             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  123502             : // Also, note comment below from Robb (copied from the Common.code file).
  123503             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  123504             : //
  123505             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  123506             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  123507             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  123508             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  123509             : #if 0
  123510             : void SgAddressOfOp::operator delete(void* pointer) { SgAddressOfOp::operator delete (pointer, sizeof(SgAddressOfOp)); };
  123511             : #endif
  123512             : /* #line 123513 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  123513             : 
  123514             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  123515             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  123516             : // obviously imply C++.
  123517             : 
  123518             : // This implements the support within ROSE for memory pools.  Memory pools
  123519             : // support the most condensed usage of memory within the construction of
  123520             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  123521             : // by a new operator written for each class.
  123522             : 
  123523             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  123524             :     // User wants multi-thread support and POSIX threads are available.
  123525             : #   include <pthread.h>
  123526             :     static pthread_mutex_t SgMinusMinusOp_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  123527             : #else
  123528             :      // Cause synchronization to be skipped.
  123529             : #    ifndef ALLOC_MUTEX
  123530             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  123531             : #    endif
  123532             : #    ifdef _REENTRANT
  123533             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  123534             : #       ifdef _MSC_VER
  123535             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  123536             : #       else
  123537             : #           warning "POSIX threads are not available; synchronization being skipped"
  123538             : #       endif
  123539             : #    endif
  123540             : #endif
  123541             : 
  123542             : #ifndef ROSE_ALLOC_TRACE
  123543             : #  define ROSE_ALLOC_TRACE 0
  123544             : #endif
  123545             : 
  123546             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  123547             : #define ROSE_ALLOC_TRACE_CNT
  123548             : #include "memory-pool-snapshot.h"
  123549             : unsigned long alloc_trace_cnt = 0;
  123550             : #endif
  123551             : 
  123552             : #if ROSE_ALLOC_TRACE
  123553             : const unsigned SgMinusMinusOp::pool_size = 5;
  123554             : #else
  123555             : const unsigned SgMinusMinusOp::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  123556             : #endif
  123557             : 
  123558             : #ifndef ROSE_ALLOC_MEMSET
  123559             : #  define ROSE_ALLOC_MEMSET 0
  123560             : #endif
  123561             : 
  123562             : #ifndef ROSE_PEDANTIC_ALLOC
  123563             : #  define ROSE_PEDANTIC_ALLOC 0
  123564             : #endif
  123565             : 
  123566             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  123567             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  123568             : #endif
  123569             : 
  123570             : #if !defined(SGNODE__ALL_POOLS)
  123571             : #define SGNODE__ALL_POOLS
  123572             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  123573             : #endif
  123574             : 
  123575             : SgMinusMinusOp* SgMinusMinusOp::next_node = nullptr;
  123576             : std::vector<unsigned char*> SgMinusMinusOp::pools;
  123577             : 
  123578             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  123579             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  123580             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  123581             : // around this macro definition rather than each use).
  123582             : #ifndef ALLOC_MUTEX
  123583             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  123584             :         do {                                                                     \
  123585             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  123586             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  123587             :                 abort();                                                         \
  123588             :             }                                                                    \
  123589             :         } while (0);
  123590             : #endif
  123591             : 
  123592             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  123593             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  123594             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  123595             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  123596             : 
  123597             : /*! \brief New operator for SgMinusMinusOp.
  123598             : 
  123599             :    This new operator implements memory pools to provide most efficent 
  123600             :    use of the heap within construction of large ASTs.
  123601             : 
  123602             : \internal The new and delete operators use the lower level C malloc/free
  123603             :    function calls for performance and to make sure that mixing of malloc/free
  123604             :    and new/delete by the used can be caught more readily.  This may change
  123605             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  123606             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  123607             :    deallocate memory allocated using ROSE_MALLOC.
  123608             : */
  123609         612 : void *SgMinusMinusOp::operator new ( size_t Size )
  123610             : {
  123611             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  123612             :      * returning or throwing an exception. */
  123613         612 :     ALLOC_MUTEX(SgMinusMinusOp, lock);
  123614             : 
  123615             : #if ROSE_ALLOC_TRACE == 2
  123616             : //    printf("SgMinusMinusOp::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgMinusMinusOp::next_node);
  123617             : #endif
  123618             : 
  123619             : #if USE_CPP_NEW_DELETE_OPERATORS
  123620             :     void *mem = ROSE_MALLOC(Size);
  123621             :     ALLOC_MUTEX(SgMinusMinusOp, unlock);
  123622             :     return mem;
  123623             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  123624             : #if ROSE_PEDANTIC_ALLOC
  123625             :     ROSE_ASSERT(Size == sizeof(SgMinusMinusOp));
  123626             : #else
  123627         612 :     if (Size != sizeof(SgMinusMinusOp)) {
  123628           0 :       void * object = ROSE_MALLOC(Size);
  123629           0 :       ALLOC_MUTEX(SgMinusMinusOp, unlock);
  123630             :       return object;
  123631             :     }
  123632             : #endif
  123633             : 
  123634         612 :     if (SgMinusMinusOp::next_node == nullptr) {
  123635          19 :         SgMinusMinusOp * alloc = (SgMinusMinusOp*) ROSE_MALLOC ( SgMinusMinusOp::pool_size * sizeof(SgMinusMinusOp) );
  123636          19 :         ROSE_ASSERT(alloc != nullptr);
  123637             : 
  123638             : #if ROSE_ALLOC_TRACE == 2
  123639             : //        printf("SgMinusMinusOp::alloc\n  block[%zi] = [ %p , %p [\n", SgMinusMinusOp::pools.size(), alloc, alloc + SgMinusMinusOp::pool_size);
  123640             : #endif
  123641             : 
  123642             : #if ROSE_ALLOC_MEMSET == 1
  123643             : #elif ROSE_ALLOC_MEMSET == 2
  123644             :         memset(alloc, 0x00, SgMinusMinusOp::pool_size * sizeof(SgMinusMinusOp));
  123645             : #elif ROSE_ALLOC_MEMSET == 3
  123646             :         memset(alloc, 0xAA, SgMinusMinusOp::pool_size * sizeof(SgMinusMinusOp));
  123647             : #endif
  123648       38000 :         for (unsigned i=0; i < SgMinusMinusOp::pool_size-1; i++) {
  123649       37981 :           alloc[i].p_freepointer = &(alloc[i+1]);
  123650             :         }
  123651          19 :         alloc[SgMinusMinusOp::pool_size-1].p_freepointer = nullptr;
  123652             : 
  123653          19 :         SgMinusMinusOp::pools.push_back ( (unsigned char *) alloc );
  123654          19 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgMinusMinusOp::pool_size * sizeof(SgMinusMinusOp), V_SgMinusMinusOp ) );
  123655          19 :         SgMinusMinusOp::next_node = alloc;
  123656             :     }
  123657         612 :     ROSE_ASSERT(SgMinusMinusOp::next_node != nullptr);
  123658             : 
  123659         612 :     SgMinusMinusOp * object = SgMinusMinusOp::next_node;
  123660         612 :     SgMinusMinusOp::next_node = (SgMinusMinusOp*)(object->p_freepointer);
  123661             : 
  123662             : #if ROSE_ALLOC_TRACE == 2
  123663             :     printf("SgMinusMinusOp::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgMinusMinusOp::next_node);
  123664             : #endif
  123665             : 
  123666         612 :     SgNode * fp = object->p_freepointer;
  123667             : #if ROSE_ALLOC_MEMSET == 1
  123668             : #elif ROSE_ALLOC_MEMSET == 2
  123669             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgMinusMinusOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  123670             : #elif ROSE_ALLOC_MEMSET == 3
  123671             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgMinusMinusOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  123672             : #endif
  123673         612 :     object->p_freepointer = fp;
  123674             : 
  123675             : #if ROSE_ALLOC_TRACE == 2
  123676             : //    printf("SgMinusMinusOp::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgMinusMinusOp::next_node);
  123677             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  123678             :     Rose::MemPool::snapshot(oss.str());
  123679             :     alloc_trace_cnt++;
  123680             : #endif
  123681             : 
  123682         612 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  123683             : 
  123684         612 :     ALLOC_MUTEX(SgMinusMinusOp, unlock);
  123685             : 
  123686             :     return object;
  123687             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  123688             : }
  123689             : 
  123690             : 
  123691             : 
  123692             : /*! \brief Delete operator for SgMinusMinusOp.
  123693             : 
  123694             :    This delete operator implements deallocation using memory pools to 
  123695             :    provide most efficent use of the heap within construction of large ASTs.
  123696             : 
  123697             : \internal The new and delete operators use the lower level C malloc/free
  123698             :    function calls for performance and to make sure that mixing of malloc/free
  123699             :    and new/delete by the used can be caught more readily.  This may change
  123700             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  123701             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  123702             :    deallocate memory allocated using ROSE_MALLOC.
  123703             : */
  123704         157 : void SgMinusMinusOp::operator delete(void *Pointer, size_t Size)
  123705             : {
  123706             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  123707             :      * or throwing an exception. */
  123708         157 :     ALLOC_MUTEX(SgMinusMinusOp, lock);
  123709             : 
  123710             : #if USE_CPP_NEW_DELETE_OPERATORS
  123711             :     ROSE_FREE(Pointer);
  123712             : #else
  123713             : #if ROSE_PEDANTIC_ALLOC
  123714             :     ROSE_ASSERT(Size == sizeof(SgMinusMinusOp));
  123715             : #else
  123716         157 :     if (Size != sizeof(SgMinusMinusOp)) {
  123717           0 :       ROSE_FREE(Pointer);
  123718           0 :       ALLOC_MUTEX(SgMinusMinusOp, unlock);
  123719             :       return;
  123720             :     }
  123721             : #endif
  123722             : 
  123723         157 :     SgMinusMinusOp * object = (SgMinusMinusOp*) Pointer;
  123724         157 :     ROSE_ASSERT(object != nullptr);
  123725             : 
  123726             : #if ROSE_ALLOC_TRACE == 2
  123727             : //  printf("SgMinusMinusOp::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgMinusMinusOp::next_node);
  123728             :     printf("SgMinusMinusOp::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgMinusMinusOp::next_node);
  123729             : #endif
  123730             : 
  123731             : #if ROSE_PEDANTIC_ALLOC
  123732             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  123733             : #endif
  123734             : 
  123735             : #if ROSE_ALLOC_MEMSET == 1
  123736             : #elif ROSE_ALLOC_MEMSET == 2
  123737             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgMinusMinusOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  123738             : #elif ROSE_ALLOC_MEMSET == 3
  123739             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgMinusMinusOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  123740             : #endif
  123741             : 
  123742             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  123743             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  123744             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  123745             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  123746             : #else
  123747         157 :     object->p_freepointer = SgMinusMinusOp::next_node;
  123748         157 :     SgMinusMinusOp::next_node = object;
  123749             : #endif
  123750             : 
  123751             : #if ROSE_ALLOC_TRACE == 2
  123752             : //  printf("SgMinusMinusOp::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgMinusMinusOp::next_node);
  123753             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  123754             :     Rose::MemPool::snapshot(oss.str());
  123755             :     alloc_trace_cnt++;
  123756             : #endif
  123757             : 
  123758             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  123759             : 
  123760         157 :     ALLOC_MUTEX(SgMinusMinusOp, unlock);
  123761             : }
  123762             : 
  123763             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  123764             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  123765             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  123766             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  123767             : // Also, note comment below from Robb (copied from the Common.code file).
  123768             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  123769             : //
  123770             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  123771             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  123772             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  123773             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  123774             : #if 0
  123775             : void SgMinusMinusOp::operator delete(void* pointer) { SgMinusMinusOp::operator delete (pointer, sizeof(SgMinusMinusOp)); };
  123776             : #endif
  123777             : /* #line 123778 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  123778             : 
  123779             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  123780             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  123781             : // obviously imply C++.
  123782             : 
  123783             : // This implements the support within ROSE for memory pools.  Memory pools
  123784             : // support the most condensed usage of memory within the construction of
  123785             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  123786             : // by a new operator written for each class.
  123787             : 
  123788             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  123789             :     // User wants multi-thread support and POSIX threads are available.
  123790             : #   include <pthread.h>
  123791             :     static pthread_mutex_t SgPlusPlusOp_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  123792             : #else
  123793             :      // Cause synchronization to be skipped.
  123794             : #    ifndef ALLOC_MUTEX
  123795             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  123796             : #    endif
  123797             : #    ifdef _REENTRANT
  123798             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  123799             : #       ifdef _MSC_VER
  123800             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  123801             : #       else
  123802             : #           warning "POSIX threads are not available; synchronization being skipped"
  123803             : #       endif
  123804             : #    endif
  123805             : #endif
  123806             : 
  123807             : #ifndef ROSE_ALLOC_TRACE
  123808             : #  define ROSE_ALLOC_TRACE 0
  123809             : #endif
  123810             : 
  123811             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  123812             : #define ROSE_ALLOC_TRACE_CNT
  123813             : #include "memory-pool-snapshot.h"
  123814             : unsigned long alloc_trace_cnt = 0;
  123815             : #endif
  123816             : 
  123817             : #if ROSE_ALLOC_TRACE
  123818             : const unsigned SgPlusPlusOp::pool_size = 5;
  123819             : #else
  123820             : const unsigned SgPlusPlusOp::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  123821             : #endif
  123822             : 
  123823             : #ifndef ROSE_ALLOC_MEMSET
  123824             : #  define ROSE_ALLOC_MEMSET 0
  123825             : #endif
  123826             : 
  123827             : #ifndef ROSE_PEDANTIC_ALLOC
  123828             : #  define ROSE_PEDANTIC_ALLOC 0
  123829             : #endif
  123830             : 
  123831             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  123832             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  123833             : #endif
  123834             : 
  123835             : #if !defined(SGNODE__ALL_POOLS)
  123836             : #define SGNODE__ALL_POOLS
  123837             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  123838             : #endif
  123839             : 
  123840             : SgPlusPlusOp* SgPlusPlusOp::next_node = nullptr;
  123841             : std::vector<unsigned char*> SgPlusPlusOp::pools;
  123842             : 
  123843             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  123844             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  123845             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  123846             : // around this macro definition rather than each use).
  123847             : #ifndef ALLOC_MUTEX
  123848             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  123849             :         do {                                                                     \
  123850             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  123851             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  123852             :                 abort();                                                         \
  123853             :             }                                                                    \
  123854             :         } while (0);
  123855             : #endif
  123856             : 
  123857             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  123858             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  123859             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  123860             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  123861             : 
  123862             : /*! \brief New operator for SgPlusPlusOp.
  123863             : 
  123864             :    This new operator implements memory pools to provide most efficent 
  123865             :    use of the heap within construction of large ASTs.
  123866             : 
  123867             : \internal The new and delete operators use the lower level C malloc/free
  123868             :    function calls for performance and to make sure that mixing of malloc/free
  123869             :    and new/delete by the used can be caught more readily.  This may change
  123870             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  123871             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  123872             :    deallocate memory allocated using ROSE_MALLOC.
  123873             : */
  123874        2060 : void *SgPlusPlusOp::operator new ( size_t Size )
  123875             : {
  123876             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  123877             :      * returning or throwing an exception. */
  123878        2060 :     ALLOC_MUTEX(SgPlusPlusOp, lock);
  123879             : 
  123880             : #if ROSE_ALLOC_TRACE == 2
  123881             : //    printf("SgPlusPlusOp::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgPlusPlusOp::next_node);
  123882             : #endif
  123883             : 
  123884             : #if USE_CPP_NEW_DELETE_OPERATORS
  123885             :     void *mem = ROSE_MALLOC(Size);
  123886             :     ALLOC_MUTEX(SgPlusPlusOp, unlock);
  123887             :     return mem;
  123888             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  123889             : #if ROSE_PEDANTIC_ALLOC
  123890             :     ROSE_ASSERT(Size == sizeof(SgPlusPlusOp));
  123891             : #else
  123892        2060 :     if (Size != sizeof(SgPlusPlusOp)) {
  123893           0 :       void * object = ROSE_MALLOC(Size);
  123894           0 :       ALLOC_MUTEX(SgPlusPlusOp, unlock);
  123895             :       return object;
  123896             :     }
  123897             : #endif
  123898             : 
  123899        2060 :     if (SgPlusPlusOp::next_node == nullptr) {
  123900         170 :         SgPlusPlusOp * alloc = (SgPlusPlusOp*) ROSE_MALLOC ( SgPlusPlusOp::pool_size * sizeof(SgPlusPlusOp) );
  123901         170 :         ROSE_ASSERT(alloc != nullptr);
  123902             : 
  123903             : #if ROSE_ALLOC_TRACE == 2
  123904             : //        printf("SgPlusPlusOp::alloc\n  block[%zi] = [ %p , %p [\n", SgPlusPlusOp::pools.size(), alloc, alloc + SgPlusPlusOp::pool_size);
  123905             : #endif
  123906             : 
  123907             : #if ROSE_ALLOC_MEMSET == 1
  123908             : #elif ROSE_ALLOC_MEMSET == 2
  123909             :         memset(alloc, 0x00, SgPlusPlusOp::pool_size * sizeof(SgPlusPlusOp));
  123910             : #elif ROSE_ALLOC_MEMSET == 3
  123911             :         memset(alloc, 0xAA, SgPlusPlusOp::pool_size * sizeof(SgPlusPlusOp));
  123912             : #endif
  123913      340000 :         for (unsigned i=0; i < SgPlusPlusOp::pool_size-1; i++) {
  123914      339830 :           alloc[i].p_freepointer = &(alloc[i+1]);
  123915             :         }
  123916         170 :         alloc[SgPlusPlusOp::pool_size-1].p_freepointer = nullptr;
  123917             : 
  123918         170 :         SgPlusPlusOp::pools.push_back ( (unsigned char *) alloc );
  123919         170 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgPlusPlusOp::pool_size * sizeof(SgPlusPlusOp), V_SgPlusPlusOp ) );
  123920         170 :         SgPlusPlusOp::next_node = alloc;
  123921             :     }
  123922        2060 :     ROSE_ASSERT(SgPlusPlusOp::next_node != nullptr);
  123923             : 
  123924        2060 :     SgPlusPlusOp * object = SgPlusPlusOp::next_node;
  123925        2060 :     SgPlusPlusOp::next_node = (SgPlusPlusOp*)(object->p_freepointer);
  123926             : 
  123927             : #if ROSE_ALLOC_TRACE == 2
  123928             :     printf("SgPlusPlusOp::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgPlusPlusOp::next_node);
  123929             : #endif
  123930             : 
  123931        2060 :     SgNode * fp = object->p_freepointer;
  123932             : #if ROSE_ALLOC_MEMSET == 1
  123933             : #elif ROSE_ALLOC_MEMSET == 2
  123934             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgPlusPlusOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  123935             : #elif ROSE_ALLOC_MEMSET == 3
  123936             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgPlusPlusOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  123937             : #endif
  123938        2060 :     object->p_freepointer = fp;
  123939             : 
  123940             : #if ROSE_ALLOC_TRACE == 2
  123941             : //    printf("SgPlusPlusOp::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgPlusPlusOp::next_node);
  123942             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  123943             :     Rose::MemPool::snapshot(oss.str());
  123944             :     alloc_trace_cnt++;
  123945             : #endif
  123946             : 
  123947        2060 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  123948             : 
  123949        2060 :     ALLOC_MUTEX(SgPlusPlusOp, unlock);
  123950             : 
  123951             :     return object;
  123952             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  123953             : }
  123954             : 
  123955             : 
  123956             : 
  123957             : /*! \brief Delete operator for SgPlusPlusOp.
  123958             : 
  123959             :    This delete operator implements deallocation using memory pools to 
  123960             :    provide most efficent use of the heap within construction of large ASTs.
  123961             : 
  123962             : \internal The new and delete operators use the lower level C malloc/free
  123963             :    function calls for performance and to make sure that mixing of malloc/free
  123964             :    and new/delete by the used can be caught more readily.  This may change
  123965             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  123966             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  123967             :    deallocate memory allocated using ROSE_MALLOC.
  123968             : */
  123969         276 : void SgPlusPlusOp::operator delete(void *Pointer, size_t Size)
  123970             : {
  123971             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  123972             :      * or throwing an exception. */
  123973         276 :     ALLOC_MUTEX(SgPlusPlusOp, lock);
  123974             : 
  123975             : #if USE_CPP_NEW_DELETE_OPERATORS
  123976             :     ROSE_FREE(Pointer);
  123977             : #else
  123978             : #if ROSE_PEDANTIC_ALLOC
  123979             :     ROSE_ASSERT(Size == sizeof(SgPlusPlusOp));
  123980             : #else
  123981         276 :     if (Size != sizeof(SgPlusPlusOp)) {
  123982           0 :       ROSE_FREE(Pointer);
  123983           0 :       ALLOC_MUTEX(SgPlusPlusOp, unlock);
  123984             :       return;
  123985             :     }
  123986             : #endif
  123987             : 
  123988         276 :     SgPlusPlusOp * object = (SgPlusPlusOp*) Pointer;
  123989         276 :     ROSE_ASSERT(object != nullptr);
  123990             : 
  123991             : #if ROSE_ALLOC_TRACE == 2
  123992             : //  printf("SgPlusPlusOp::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgPlusPlusOp::next_node);
  123993             :     printf("SgPlusPlusOp::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgPlusPlusOp::next_node);
  123994             : #endif
  123995             : 
  123996             : #if ROSE_PEDANTIC_ALLOC
  123997             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  123998             : #endif
  123999             : 
  124000             : #if ROSE_ALLOC_MEMSET == 1
  124001             : #elif ROSE_ALLOC_MEMSET == 2
  124002             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgPlusPlusOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  124003             : #elif ROSE_ALLOC_MEMSET == 3
  124004             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgPlusPlusOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  124005             : #endif
  124006             : 
  124007             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  124008             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  124009             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  124010             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  124011             : #else
  124012         276 :     object->p_freepointer = SgPlusPlusOp::next_node;
  124013         276 :     SgPlusPlusOp::next_node = object;
  124014             : #endif
  124015             : 
  124016             : #if ROSE_ALLOC_TRACE == 2
  124017             : //  printf("SgPlusPlusOp::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgPlusPlusOp::next_node);
  124018             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  124019             :     Rose::MemPool::snapshot(oss.str());
  124020             :     alloc_trace_cnt++;
  124021             : #endif
  124022             : 
  124023             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  124024             : 
  124025         276 :     ALLOC_MUTEX(SgPlusPlusOp, unlock);
  124026             : }
  124027             : 
  124028             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  124029             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  124030             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  124031             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  124032             : // Also, note comment below from Robb (copied from the Common.code file).
  124033             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  124034             : //
  124035             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  124036             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  124037             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  124038             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  124039             : #if 0
  124040             : void SgPlusPlusOp::operator delete(void* pointer) { SgPlusPlusOp::operator delete (pointer, sizeof(SgPlusPlusOp)); };
  124041             : #endif
  124042             : /* #line 124043 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  124043             : 
  124044             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  124045             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  124046             : // obviously imply C++.
  124047             : 
  124048             : // This implements the support within ROSE for memory pools.  Memory pools
  124049             : // support the most condensed usage of memory within the construction of
  124050             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  124051             : // by a new operator written for each class.
  124052             : 
  124053             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  124054             :     // User wants multi-thread support and POSIX threads are available.
  124055             : #   include <pthread.h>
  124056             :     static pthread_mutex_t SgBitComplementOp_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  124057             : #else
  124058             :      // Cause synchronization to be skipped.
  124059             : #    ifndef ALLOC_MUTEX
  124060             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  124061             : #    endif
  124062             : #    ifdef _REENTRANT
  124063             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  124064             : #       ifdef _MSC_VER
  124065             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  124066             : #       else
  124067             : #           warning "POSIX threads are not available; synchronization being skipped"
  124068             : #       endif
  124069             : #    endif
  124070             : #endif
  124071             : 
  124072             : #ifndef ROSE_ALLOC_TRACE
  124073             : #  define ROSE_ALLOC_TRACE 0
  124074             : #endif
  124075             : 
  124076             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  124077             : #define ROSE_ALLOC_TRACE_CNT
  124078             : #include "memory-pool-snapshot.h"
  124079             : unsigned long alloc_trace_cnt = 0;
  124080             : #endif
  124081             : 
  124082             : #if ROSE_ALLOC_TRACE
  124083             : const unsigned SgBitComplementOp::pool_size = 5;
  124084             : #else
  124085             : const unsigned SgBitComplementOp::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  124086             : #endif
  124087             : 
  124088             : #ifndef ROSE_ALLOC_MEMSET
  124089             : #  define ROSE_ALLOC_MEMSET 0
  124090             : #endif
  124091             : 
  124092             : #ifndef ROSE_PEDANTIC_ALLOC
  124093             : #  define ROSE_PEDANTIC_ALLOC 0
  124094             : #endif
  124095             : 
  124096             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  124097             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  124098             : #endif
  124099             : 
  124100             : #if !defined(SGNODE__ALL_POOLS)
  124101             : #define SGNODE__ALL_POOLS
  124102             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  124103             : #endif
  124104             : 
  124105             : SgBitComplementOp* SgBitComplementOp::next_node = nullptr;
  124106             : std::vector<unsigned char*> SgBitComplementOp::pools;
  124107             : 
  124108             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  124109             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  124110             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  124111             : // around this macro definition rather than each use).
  124112             : #ifndef ALLOC_MUTEX
  124113             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  124114             :         do {                                                                     \
  124115             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  124116             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  124117             :                 abort();                                                         \
  124118             :             }                                                                    \
  124119             :         } while (0);
  124120             : #endif
  124121             : 
  124122             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  124123             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  124124             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  124125             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  124126             : 
  124127             : /*! \brief New operator for SgBitComplementOp.
  124128             : 
  124129             :    This new operator implements memory pools to provide most efficent 
  124130             :    use of the heap within construction of large ASTs.
  124131             : 
  124132             : \internal The new and delete operators use the lower level C malloc/free
  124133             :    function calls for performance and to make sure that mixing of malloc/free
  124134             :    and new/delete by the used can be caught more readily.  This may change
  124135             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  124136             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  124137             :    deallocate memory allocated using ROSE_MALLOC.
  124138             : */
  124139         178 : void *SgBitComplementOp::operator new ( size_t Size )
  124140             : {
  124141             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  124142             :      * returning or throwing an exception. */
  124143         178 :     ALLOC_MUTEX(SgBitComplementOp, lock);
  124144             : 
  124145             : #if ROSE_ALLOC_TRACE == 2
  124146             : //    printf("SgBitComplementOp::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgBitComplementOp::next_node);
  124147             : #endif
  124148             : 
  124149             : #if USE_CPP_NEW_DELETE_OPERATORS
  124150             :     void *mem = ROSE_MALLOC(Size);
  124151             :     ALLOC_MUTEX(SgBitComplementOp, unlock);
  124152             :     return mem;
  124153             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  124154             : #if ROSE_PEDANTIC_ALLOC
  124155             :     ROSE_ASSERT(Size == sizeof(SgBitComplementOp));
  124156             : #else
  124157         178 :     if (Size != sizeof(SgBitComplementOp)) {
  124158           0 :       void * object = ROSE_MALLOC(Size);
  124159           0 :       ALLOC_MUTEX(SgBitComplementOp, unlock);
  124160             :       return object;
  124161             :     }
  124162             : #endif
  124163             : 
  124164         178 :     if (SgBitComplementOp::next_node == nullptr) {
  124165          10 :         SgBitComplementOp * alloc = (SgBitComplementOp*) ROSE_MALLOC ( SgBitComplementOp::pool_size * sizeof(SgBitComplementOp) );
  124166          10 :         ROSE_ASSERT(alloc != nullptr);
  124167             : 
  124168             : #if ROSE_ALLOC_TRACE == 2
  124169             : //        printf("SgBitComplementOp::alloc\n  block[%zi] = [ %p , %p [\n", SgBitComplementOp::pools.size(), alloc, alloc + SgBitComplementOp::pool_size);
  124170             : #endif
  124171             : 
  124172             : #if ROSE_ALLOC_MEMSET == 1
  124173             : #elif ROSE_ALLOC_MEMSET == 2
  124174             :         memset(alloc, 0x00, SgBitComplementOp::pool_size * sizeof(SgBitComplementOp));
  124175             : #elif ROSE_ALLOC_MEMSET == 3
  124176             :         memset(alloc, 0xAA, SgBitComplementOp::pool_size * sizeof(SgBitComplementOp));
  124177             : #endif
  124178       20000 :         for (unsigned i=0; i < SgBitComplementOp::pool_size-1; i++) {
  124179       19990 :           alloc[i].p_freepointer = &(alloc[i+1]);
  124180             :         }
  124181          10 :         alloc[SgBitComplementOp::pool_size-1].p_freepointer = nullptr;
  124182             : 
  124183          10 :         SgBitComplementOp::pools.push_back ( (unsigned char *) alloc );
  124184          10 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgBitComplementOp::pool_size * sizeof(SgBitComplementOp), V_SgBitComplementOp ) );
  124185          10 :         SgBitComplementOp::next_node = alloc;
  124186             :     }
  124187         178 :     ROSE_ASSERT(SgBitComplementOp::next_node != nullptr);
  124188             : 
  124189         178 :     SgBitComplementOp * object = SgBitComplementOp::next_node;
  124190         178 :     SgBitComplementOp::next_node = (SgBitComplementOp*)(object->p_freepointer);
  124191             : 
  124192             : #if ROSE_ALLOC_TRACE == 2
  124193             :     printf("SgBitComplementOp::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgBitComplementOp::next_node);
  124194             : #endif
  124195             : 
  124196         178 :     SgNode * fp = object->p_freepointer;
  124197             : #if ROSE_ALLOC_MEMSET == 1
  124198             : #elif ROSE_ALLOC_MEMSET == 2
  124199             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgBitComplementOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  124200             : #elif ROSE_ALLOC_MEMSET == 3
  124201             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgBitComplementOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  124202             : #endif
  124203         178 :     object->p_freepointer = fp;
  124204             : 
  124205             : #if ROSE_ALLOC_TRACE == 2
  124206             : //    printf("SgBitComplementOp::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgBitComplementOp::next_node);
  124207             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  124208             :     Rose::MemPool::snapshot(oss.str());
  124209             :     alloc_trace_cnt++;
  124210             : #endif
  124211             : 
  124212         178 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  124213             : 
  124214         178 :     ALLOC_MUTEX(SgBitComplementOp, unlock);
  124215             : 
  124216             :     return object;
  124217             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  124218             : }
  124219             : 
  124220             : 
  124221             : 
  124222             : /*! \brief Delete operator for SgBitComplementOp.
  124223             : 
  124224             :    This delete operator implements deallocation using memory pools to 
  124225             :    provide most efficent use of the heap within construction of large ASTs.
  124226             : 
  124227             : \internal The new and delete operators use the lower level C malloc/free
  124228             :    function calls for performance and to make sure that mixing of malloc/free
  124229             :    and new/delete by the used can be caught more readily.  This may change
  124230             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  124231             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  124232             :    deallocate memory allocated using ROSE_MALLOC.
  124233             : */
  124234          70 : void SgBitComplementOp::operator delete(void *Pointer, size_t Size)
  124235             : {
  124236             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  124237             :      * or throwing an exception. */
  124238          70 :     ALLOC_MUTEX(SgBitComplementOp, lock);
  124239             : 
  124240             : #if USE_CPP_NEW_DELETE_OPERATORS
  124241             :     ROSE_FREE(Pointer);
  124242             : #else
  124243             : #if ROSE_PEDANTIC_ALLOC
  124244             :     ROSE_ASSERT(Size == sizeof(SgBitComplementOp));
  124245             : #else
  124246          70 :     if (Size != sizeof(SgBitComplementOp)) {
  124247           0 :       ROSE_FREE(Pointer);
  124248           0 :       ALLOC_MUTEX(SgBitComplementOp, unlock);
  124249             :       return;
  124250             :     }
  124251             : #endif
  124252             : 
  124253          70 :     SgBitComplementOp * object = (SgBitComplementOp*) Pointer;
  124254          70 :     ROSE_ASSERT(object != nullptr);
  124255             : 
  124256             : #if ROSE_ALLOC_TRACE == 2
  124257             : //  printf("SgBitComplementOp::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgBitComplementOp::next_node);
  124258             :     printf("SgBitComplementOp::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgBitComplementOp::next_node);
  124259             : #endif
  124260             : 
  124261             : #if ROSE_PEDANTIC_ALLOC
  124262             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  124263             : #endif
  124264             : 
  124265             : #if ROSE_ALLOC_MEMSET == 1
  124266             : #elif ROSE_ALLOC_MEMSET == 2
  124267             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgBitComplementOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  124268             : #elif ROSE_ALLOC_MEMSET == 3
  124269             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgBitComplementOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  124270             : #endif
  124271             : 
  124272             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  124273             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  124274             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  124275             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  124276             : #else
  124277          70 :     object->p_freepointer = SgBitComplementOp::next_node;
  124278          70 :     SgBitComplementOp::next_node = object;
  124279             : #endif
  124280             : 
  124281             : #if ROSE_ALLOC_TRACE == 2
  124282             : //  printf("SgBitComplementOp::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgBitComplementOp::next_node);
  124283             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  124284             :     Rose::MemPool::snapshot(oss.str());
  124285             :     alloc_trace_cnt++;
  124286             : #endif
  124287             : 
  124288             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  124289             : 
  124290          70 :     ALLOC_MUTEX(SgBitComplementOp, unlock);
  124291             : }
  124292             : 
  124293             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  124294             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  124295             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  124296             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  124297             : // Also, note comment below from Robb (copied from the Common.code file).
  124298             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  124299             : //
  124300             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  124301             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  124302             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  124303             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  124304             : #if 0
  124305             : void SgBitComplementOp::operator delete(void* pointer) { SgBitComplementOp::operator delete (pointer, sizeof(SgBitComplementOp)); };
  124306             : #endif
  124307             : /* #line 124308 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  124308             : 
  124309             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  124310             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  124311             : // obviously imply C++.
  124312             : 
  124313             : // This implements the support within ROSE for memory pools.  Memory pools
  124314             : // support the most condensed usage of memory within the construction of
  124315             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  124316             : // by a new operator written for each class.
  124317             : 
  124318             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  124319             :     // User wants multi-thread support and POSIX threads are available.
  124320             : #   include <pthread.h>
  124321             :     static pthread_mutex_t SgCastExp_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  124322             : #else
  124323             :      // Cause synchronization to be skipped.
  124324             : #    ifndef ALLOC_MUTEX
  124325             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  124326             : #    endif
  124327             : #    ifdef _REENTRANT
  124328             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  124329             : #       ifdef _MSC_VER
  124330             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  124331             : #       else
  124332             : #           warning "POSIX threads are not available; synchronization being skipped"
  124333             : #       endif
  124334             : #    endif
  124335             : #endif
  124336             : 
  124337             : #ifndef ROSE_ALLOC_TRACE
  124338             : #  define ROSE_ALLOC_TRACE 0
  124339             : #endif
  124340             : 
  124341             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  124342             : #define ROSE_ALLOC_TRACE_CNT
  124343             : #include "memory-pool-snapshot.h"
  124344             : unsigned long alloc_trace_cnt = 0;
  124345             : #endif
  124346             : 
  124347             : #if ROSE_ALLOC_TRACE
  124348             : const unsigned SgCastExp::pool_size = 5;
  124349             : #else
  124350             : const unsigned SgCastExp::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  124351             : #endif
  124352             : 
  124353             : #ifndef ROSE_ALLOC_MEMSET
  124354             : #  define ROSE_ALLOC_MEMSET 0
  124355             : #endif
  124356             : 
  124357             : #ifndef ROSE_PEDANTIC_ALLOC
  124358             : #  define ROSE_PEDANTIC_ALLOC 0
  124359             : #endif
  124360             : 
  124361             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  124362             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  124363             : #endif
  124364             : 
  124365             : #if !defined(SGNODE__ALL_POOLS)
  124366             : #define SGNODE__ALL_POOLS
  124367             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  124368             : #endif
  124369             : 
  124370             : SgCastExp* SgCastExp::next_node = nullptr;
  124371             : std::vector<unsigned char*> SgCastExp::pools;
  124372             : 
  124373             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  124374             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  124375             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  124376             : // around this macro definition rather than each use).
  124377             : #ifndef ALLOC_MUTEX
  124378             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  124379             :         do {                                                                     \
  124380             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  124381             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  124382             :                 abort();                                                         \
  124383             :             }                                                                    \
  124384             :         } while (0);
  124385             : #endif
  124386             : 
  124387             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  124388             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  124389             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  124390             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  124391             : 
  124392             : /*! \brief New operator for SgCastExp.
  124393             : 
  124394             :    This new operator implements memory pools to provide most efficent 
  124395             :    use of the heap within construction of large ASTs.
  124396             : 
  124397             : \internal The new and delete operators use the lower level C malloc/free
  124398             :    function calls for performance and to make sure that mixing of malloc/free
  124399             :    and new/delete by the used can be caught more readily.  This may change
  124400             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  124401             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  124402             :    deallocate memory allocated using ROSE_MALLOC.
  124403             : */
  124404       30406 : void *SgCastExp::operator new ( size_t Size )
  124405             : {
  124406             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  124407             :      * returning or throwing an exception. */
  124408       30406 :     ALLOC_MUTEX(SgCastExp, lock);
  124409             : 
  124410             : #if ROSE_ALLOC_TRACE == 2
  124411             : //    printf("SgCastExp::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgCastExp::next_node);
  124412             : #endif
  124413             : 
  124414             : #if USE_CPP_NEW_DELETE_OPERATORS
  124415             :     void *mem = ROSE_MALLOC(Size);
  124416             :     ALLOC_MUTEX(SgCastExp, unlock);
  124417             :     return mem;
  124418             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  124419             : #if ROSE_PEDANTIC_ALLOC
  124420             :     ROSE_ASSERT(Size == sizeof(SgCastExp));
  124421             : #else
  124422       30406 :     if (Size != sizeof(SgCastExp)) {
  124423           0 :       void * object = ROSE_MALLOC(Size);
  124424           0 :       ALLOC_MUTEX(SgCastExp, unlock);
  124425             :       return object;
  124426             :     }
  124427             : #endif
  124428             : 
  124429       30406 :     if (SgCastExp::next_node == nullptr) {
  124430         230 :         SgCastExp * alloc = (SgCastExp*) ROSE_MALLOC ( SgCastExp::pool_size * sizeof(SgCastExp) );
  124431         230 :         ROSE_ASSERT(alloc != nullptr);
  124432             : 
  124433             : #if ROSE_ALLOC_TRACE == 2
  124434             : //        printf("SgCastExp::alloc\n  block[%zi] = [ %p , %p [\n", SgCastExp::pools.size(), alloc, alloc + SgCastExp::pool_size);
  124435             : #endif
  124436             : 
  124437             : #if ROSE_ALLOC_MEMSET == 1
  124438             : #elif ROSE_ALLOC_MEMSET == 2
  124439             :         memset(alloc, 0x00, SgCastExp::pool_size * sizeof(SgCastExp));
  124440             : #elif ROSE_ALLOC_MEMSET == 3
  124441             :         memset(alloc, 0xAA, SgCastExp::pool_size * sizeof(SgCastExp));
  124442             : #endif
  124443      460000 :         for (unsigned i=0; i < SgCastExp::pool_size-1; i++) {
  124444      459770 :           alloc[i].p_freepointer = &(alloc[i+1]);
  124445             :         }
  124446         230 :         alloc[SgCastExp::pool_size-1].p_freepointer = nullptr;
  124447             : 
  124448         230 :         SgCastExp::pools.push_back ( (unsigned char *) alloc );
  124449         230 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgCastExp::pool_size * sizeof(SgCastExp), V_SgCastExp ) );
  124450         230 :         SgCastExp::next_node = alloc;
  124451             :     }
  124452       30406 :     ROSE_ASSERT(SgCastExp::next_node != nullptr);
  124453             : 
  124454       30406 :     SgCastExp * object = SgCastExp::next_node;
  124455       30406 :     SgCastExp::next_node = (SgCastExp*)(object->p_freepointer);
  124456             : 
  124457             : #if ROSE_ALLOC_TRACE == 2
  124458             :     printf("SgCastExp::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgCastExp::next_node);
  124459             : #endif
  124460             : 
  124461       30406 :     SgNode * fp = object->p_freepointer;
  124462             : #if ROSE_ALLOC_MEMSET == 1
  124463             : #elif ROSE_ALLOC_MEMSET == 2
  124464             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgCastExp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  124465             : #elif ROSE_ALLOC_MEMSET == 3
  124466             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgCastExp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  124467             : #endif
  124468       30406 :     object->p_freepointer = fp;
  124469             : 
  124470             : #if ROSE_ALLOC_TRACE == 2
  124471             : //    printf("SgCastExp::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgCastExp::next_node);
  124472             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  124473             :     Rose::MemPool::snapshot(oss.str());
  124474             :     alloc_trace_cnt++;
  124475             : #endif
  124476             : 
  124477       30406 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  124478             : 
  124479       30406 :     ALLOC_MUTEX(SgCastExp, unlock);
  124480             : 
  124481             :     return object;
  124482             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  124483             : }
  124484             : 
  124485             : 
  124486             : 
  124487             : /*! \brief Delete operator for SgCastExp.
  124488             : 
  124489             :    This delete operator implements deallocation using memory pools to 
  124490             :    provide most efficent use of the heap within construction of large ASTs.
  124491             : 
  124492             : \internal The new and delete operators use the lower level C malloc/free
  124493             :    function calls for performance and to make sure that mixing of malloc/free
  124494             :    and new/delete by the used can be caught more readily.  This may change
  124495             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  124496             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  124497             :    deallocate memory allocated using ROSE_MALLOC.
  124498             : */
  124499        8044 : void SgCastExp::operator delete(void *Pointer, size_t Size)
  124500             : {
  124501             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  124502             :      * or throwing an exception. */
  124503        8044 :     ALLOC_MUTEX(SgCastExp, lock);
  124504             : 
  124505             : #if USE_CPP_NEW_DELETE_OPERATORS
  124506             :     ROSE_FREE(Pointer);
  124507             : #else
  124508             : #if ROSE_PEDANTIC_ALLOC
  124509             :     ROSE_ASSERT(Size == sizeof(SgCastExp));
  124510             : #else
  124511        8044 :     if (Size != sizeof(SgCastExp)) {
  124512           0 :       ROSE_FREE(Pointer);
  124513           0 :       ALLOC_MUTEX(SgCastExp, unlock);
  124514             :       return;
  124515             :     }
  124516             : #endif
  124517             : 
  124518        8044 :     SgCastExp * object = (SgCastExp*) Pointer;
  124519        8044 :     ROSE_ASSERT(object != nullptr);
  124520             : 
  124521             : #if ROSE_ALLOC_TRACE == 2
  124522             : //  printf("SgCastExp::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgCastExp::next_node);
  124523             :     printf("SgCastExp::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgCastExp::next_node);
  124524             : #endif
  124525             : 
  124526             : #if ROSE_PEDANTIC_ALLOC
  124527             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  124528             : #endif
  124529             : 
  124530             : #if ROSE_ALLOC_MEMSET == 1
  124531             : #elif ROSE_ALLOC_MEMSET == 2
  124532             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgCastExp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  124533             : #elif ROSE_ALLOC_MEMSET == 3
  124534             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgCastExp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  124535             : #endif
  124536             : 
  124537             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  124538             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  124539             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  124540             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  124541             : #else
  124542        8044 :     object->p_freepointer = SgCastExp::next_node;
  124543        8044 :     SgCastExp::next_node = object;
  124544             : #endif
  124545             : 
  124546             : #if ROSE_ALLOC_TRACE == 2
  124547             : //  printf("SgCastExp::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgCastExp::next_node);
  124548             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  124549             :     Rose::MemPool::snapshot(oss.str());
  124550             :     alloc_trace_cnt++;
  124551             : #endif
  124552             : 
  124553             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  124554             : 
  124555        8044 :     ALLOC_MUTEX(SgCastExp, unlock);
  124556             : }
  124557             : 
  124558             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  124559             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  124560             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  124561             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  124562             : // Also, note comment below from Robb (copied from the Common.code file).
  124563             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  124564             : //
  124565             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  124566             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  124567             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  124568             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  124569             : #if 0
  124570             : void SgCastExp::operator delete(void* pointer) { SgCastExp::operator delete (pointer, sizeof(SgCastExp)); };
  124571             : #endif
  124572             : /* #line 124573 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  124573             : 
  124574             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  124575             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  124576             : // obviously imply C++.
  124577             : 
  124578             : // This implements the support within ROSE for memory pools.  Memory pools
  124579             : // support the most condensed usage of memory within the construction of
  124580             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  124581             : // by a new operator written for each class.
  124582             : 
  124583             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  124584             :     // User wants multi-thread support and POSIX threads are available.
  124585             : #   include <pthread.h>
  124586             :     static pthread_mutex_t SgThrowOp_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  124587             : #else
  124588             :      // Cause synchronization to be skipped.
  124589             : #    ifndef ALLOC_MUTEX
  124590             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  124591             : #    endif
  124592             : #    ifdef _REENTRANT
  124593             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  124594             : #       ifdef _MSC_VER
  124595             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  124596             : #       else
  124597             : #           warning "POSIX threads are not available; synchronization being skipped"
  124598             : #       endif
  124599             : #    endif
  124600             : #endif
  124601             : 
  124602             : #ifndef ROSE_ALLOC_TRACE
  124603             : #  define ROSE_ALLOC_TRACE 0
  124604             : #endif
  124605             : 
  124606             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  124607             : #define ROSE_ALLOC_TRACE_CNT
  124608             : #include "memory-pool-snapshot.h"
  124609             : unsigned long alloc_trace_cnt = 0;
  124610             : #endif
  124611             : 
  124612             : #if ROSE_ALLOC_TRACE
  124613             : const unsigned SgThrowOp::pool_size = 5;
  124614             : #else
  124615             : const unsigned SgThrowOp::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  124616             : #endif
  124617             : 
  124618             : #ifndef ROSE_ALLOC_MEMSET
  124619             : #  define ROSE_ALLOC_MEMSET 0
  124620             : #endif
  124621             : 
  124622             : #ifndef ROSE_PEDANTIC_ALLOC
  124623             : #  define ROSE_PEDANTIC_ALLOC 0
  124624             : #endif
  124625             : 
  124626             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  124627             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  124628             : #endif
  124629             : 
  124630             : #if !defined(SGNODE__ALL_POOLS)
  124631             : #define SGNODE__ALL_POOLS
  124632             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  124633             : #endif
  124634             : 
  124635             : SgThrowOp* SgThrowOp::next_node = nullptr;
  124636             : std::vector<unsigned char*> SgThrowOp::pools;
  124637             : 
  124638             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  124639             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  124640             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  124641             : // around this macro definition rather than each use).
  124642             : #ifndef ALLOC_MUTEX
  124643             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  124644             :         do {                                                                     \
  124645             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  124646             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  124647             :                 abort();                                                         \
  124648             :             }                                                                    \
  124649             :         } while (0);
  124650             : #endif
  124651             : 
  124652             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  124653             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  124654             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  124655             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  124656             : 
  124657             : /*! \brief New operator for SgThrowOp.
  124658             : 
  124659             :    This new operator implements memory pools to provide most efficent 
  124660             :    use of the heap within construction of large ASTs.
  124661             : 
  124662             : \internal The new and delete operators use the lower level C malloc/free
  124663             :    function calls for performance and to make sure that mixing of malloc/free
  124664             :    and new/delete by the used can be caught more readily.  This may change
  124665             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  124666             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  124667             :    deallocate memory allocated using ROSE_MALLOC.
  124668             : */
  124669         547 : void *SgThrowOp::operator new ( size_t Size )
  124670             : {
  124671             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  124672             :      * returning or throwing an exception. */
  124673         547 :     ALLOC_MUTEX(SgThrowOp, lock);
  124674             : 
  124675             : #if ROSE_ALLOC_TRACE == 2
  124676             : //    printf("SgThrowOp::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgThrowOp::next_node);
  124677             : #endif
  124678             : 
  124679             : #if USE_CPP_NEW_DELETE_OPERATORS
  124680             :     void *mem = ROSE_MALLOC(Size);
  124681             :     ALLOC_MUTEX(SgThrowOp, unlock);
  124682             :     return mem;
  124683             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  124684             : #if ROSE_PEDANTIC_ALLOC
  124685             :     ROSE_ASSERT(Size == sizeof(SgThrowOp));
  124686             : #else
  124687         547 :     if (Size != sizeof(SgThrowOp)) {
  124688           0 :       void * object = ROSE_MALLOC(Size);
  124689           0 :       ALLOC_MUTEX(SgThrowOp, unlock);
  124690             :       return object;
  124691             :     }
  124692             : #endif
  124693             : 
  124694         547 :     if (SgThrowOp::next_node == nullptr) {
  124695          10 :         SgThrowOp * alloc = (SgThrowOp*) ROSE_MALLOC ( SgThrowOp::pool_size * sizeof(SgThrowOp) );
  124696          10 :         ROSE_ASSERT(alloc != nullptr);
  124697             : 
  124698             : #if ROSE_ALLOC_TRACE == 2
  124699             : //        printf("SgThrowOp::alloc\n  block[%zi] = [ %p , %p [\n", SgThrowOp::pools.size(), alloc, alloc + SgThrowOp::pool_size);
  124700             : #endif
  124701             : 
  124702             : #if ROSE_ALLOC_MEMSET == 1
  124703             : #elif ROSE_ALLOC_MEMSET == 2
  124704             :         memset(alloc, 0x00, SgThrowOp::pool_size * sizeof(SgThrowOp));
  124705             : #elif ROSE_ALLOC_MEMSET == 3
  124706             :         memset(alloc, 0xAA, SgThrowOp::pool_size * sizeof(SgThrowOp));
  124707             : #endif
  124708       20000 :         for (unsigned i=0; i < SgThrowOp::pool_size-1; i++) {
  124709       19990 :           alloc[i].p_freepointer = &(alloc[i+1]);
  124710             :         }
  124711          10 :         alloc[SgThrowOp::pool_size-1].p_freepointer = nullptr;
  124712             : 
  124713          10 :         SgThrowOp::pools.push_back ( (unsigned char *) alloc );
  124714          10 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgThrowOp::pool_size * sizeof(SgThrowOp), V_SgThrowOp ) );
  124715          10 :         SgThrowOp::next_node = alloc;
  124716             :     }
  124717         547 :     ROSE_ASSERT(SgThrowOp::next_node != nullptr);
  124718             : 
  124719         547 :     SgThrowOp * object = SgThrowOp::next_node;
  124720         547 :     SgThrowOp::next_node = (SgThrowOp*)(object->p_freepointer);
  124721             : 
  124722             : #if ROSE_ALLOC_TRACE == 2
  124723             :     printf("SgThrowOp::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgThrowOp::next_node);
  124724             : #endif
  124725             : 
  124726         547 :     SgNode * fp = object->p_freepointer;
  124727             : #if ROSE_ALLOC_MEMSET == 1
  124728             : #elif ROSE_ALLOC_MEMSET == 2
  124729             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgThrowOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  124730             : #elif ROSE_ALLOC_MEMSET == 3
  124731             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgThrowOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  124732             : #endif
  124733         547 :     object->p_freepointer = fp;
  124734             : 
  124735             : #if ROSE_ALLOC_TRACE == 2
  124736             : //    printf("SgThrowOp::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgThrowOp::next_node);
  124737             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  124738             :     Rose::MemPool::snapshot(oss.str());
  124739             :     alloc_trace_cnt++;
  124740             : #endif
  124741             : 
  124742         547 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  124743             : 
  124744         547 :     ALLOC_MUTEX(SgThrowOp, unlock);
  124745             : 
  124746             :     return object;
  124747             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  124748             : }
  124749             : 
  124750             : 
  124751             : 
  124752             : /*! \brief Delete operator for SgThrowOp.
  124753             : 
  124754             :    This delete operator implements deallocation using memory pools to 
  124755             :    provide most efficent use of the heap within construction of large ASTs.
  124756             : 
  124757             : \internal The new and delete operators use the lower level C malloc/free
  124758             :    function calls for performance and to make sure that mixing of malloc/free
  124759             :    and new/delete by the used can be caught more readily.  This may change
  124760             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  124761             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  124762             :    deallocate memory allocated using ROSE_MALLOC.
  124763             : */
  124764         104 : void SgThrowOp::operator delete(void *Pointer, size_t Size)
  124765             : {
  124766             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  124767             :      * or throwing an exception. */
  124768         104 :     ALLOC_MUTEX(SgThrowOp, lock);
  124769             : 
  124770             : #if USE_CPP_NEW_DELETE_OPERATORS
  124771             :     ROSE_FREE(Pointer);
  124772             : #else
  124773             : #if ROSE_PEDANTIC_ALLOC
  124774             :     ROSE_ASSERT(Size == sizeof(SgThrowOp));
  124775             : #else
  124776         104 :     if (Size != sizeof(SgThrowOp)) {
  124777           0 :       ROSE_FREE(Pointer);
  124778           0 :       ALLOC_MUTEX(SgThrowOp, unlock);
  124779             :       return;
  124780             :     }
  124781             : #endif
  124782             : 
  124783         104 :     SgThrowOp * object = (SgThrowOp*) Pointer;
  124784         104 :     ROSE_ASSERT(object != nullptr);
  124785             : 
  124786             : #if ROSE_ALLOC_TRACE == 2
  124787             : //  printf("SgThrowOp::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgThrowOp::next_node);
  124788             :     printf("SgThrowOp::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgThrowOp::next_node);
  124789             : #endif
  124790             : 
  124791             : #if ROSE_PEDANTIC_ALLOC
  124792             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  124793             : #endif
  124794             : 
  124795             : #if ROSE_ALLOC_MEMSET == 1
  124796             : #elif ROSE_ALLOC_MEMSET == 2
  124797             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgThrowOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  124798             : #elif ROSE_ALLOC_MEMSET == 3
  124799             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgThrowOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  124800             : #endif
  124801             : 
  124802             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  124803             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  124804             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  124805             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  124806             : #else
  124807         104 :     object->p_freepointer = SgThrowOp::next_node;
  124808         104 :     SgThrowOp::next_node = object;
  124809             : #endif
  124810             : 
  124811             : #if ROSE_ALLOC_TRACE == 2
  124812             : //  printf("SgThrowOp::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgThrowOp::next_node);
  124813             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  124814             :     Rose::MemPool::snapshot(oss.str());
  124815             :     alloc_trace_cnt++;
  124816             : #endif
  124817             : 
  124818             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  124819             : 
  124820         104 :     ALLOC_MUTEX(SgThrowOp, unlock);
  124821             : }
  124822             : 
  124823             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  124824             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  124825             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  124826             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  124827             : // Also, note comment below from Robb (copied from the Common.code file).
  124828             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  124829             : //
  124830             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  124831             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  124832             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  124833             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  124834             : #if 0
  124835             : void SgThrowOp::operator delete(void* pointer) { SgThrowOp::operator delete (pointer, sizeof(SgThrowOp)); };
  124836             : #endif
  124837             : /* #line 124838 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  124838             : 
  124839             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  124840             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  124841             : // obviously imply C++.
  124842             : 
  124843             : // This implements the support within ROSE for memory pools.  Memory pools
  124844             : // support the most condensed usage of memory within the construction of
  124845             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  124846             : // by a new operator written for each class.
  124847             : 
  124848             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  124849             :     // User wants multi-thread support and POSIX threads are available.
  124850             : #   include <pthread.h>
  124851             :     static pthread_mutex_t SgRealPartOp_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  124852             : #else
  124853             :      // Cause synchronization to be skipped.
  124854             : #    ifndef ALLOC_MUTEX
  124855             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  124856             : #    endif
  124857             : #    ifdef _REENTRANT
  124858             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  124859             : #       ifdef _MSC_VER
  124860             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  124861             : #       else
  124862             : #           warning "POSIX threads are not available; synchronization being skipped"
  124863             : #       endif
  124864             : #    endif
  124865             : #endif
  124866             : 
  124867             : #ifndef ROSE_ALLOC_TRACE
  124868             : #  define ROSE_ALLOC_TRACE 0
  124869             : #endif
  124870             : 
  124871             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  124872             : #define ROSE_ALLOC_TRACE_CNT
  124873             : #include "memory-pool-snapshot.h"
  124874             : unsigned long alloc_trace_cnt = 0;
  124875             : #endif
  124876             : 
  124877             : #if ROSE_ALLOC_TRACE
  124878             : const unsigned SgRealPartOp::pool_size = 5;
  124879             : #else
  124880             : const unsigned SgRealPartOp::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  124881             : #endif
  124882             : 
  124883             : #ifndef ROSE_ALLOC_MEMSET
  124884             : #  define ROSE_ALLOC_MEMSET 0
  124885             : #endif
  124886             : 
  124887             : #ifndef ROSE_PEDANTIC_ALLOC
  124888             : #  define ROSE_PEDANTIC_ALLOC 0
  124889             : #endif
  124890             : 
  124891             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  124892             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  124893             : #endif
  124894             : 
  124895             : #if !defined(SGNODE__ALL_POOLS)
  124896             : #define SGNODE__ALL_POOLS
  124897             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  124898             : #endif
  124899             : 
  124900             : SgRealPartOp* SgRealPartOp::next_node = nullptr;
  124901             : std::vector<unsigned char*> SgRealPartOp::pools;
  124902             : 
  124903             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  124904             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  124905             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  124906             : // around this macro definition rather than each use).
  124907             : #ifndef ALLOC_MUTEX
  124908             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  124909             :         do {                                                                     \
  124910             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  124911             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  124912             :                 abort();                                                         \
  124913             :             }                                                                    \
  124914             :         } while (0);
  124915             : #endif
  124916             : 
  124917             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  124918             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  124919             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  124920             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  124921             : 
  124922             : /*! \brief New operator for SgRealPartOp.
  124923             : 
  124924             :    This new operator implements memory pools to provide most efficent 
  124925             :    use of the heap within construction of large ASTs.
  124926             : 
  124927             : \internal The new and delete operators use the lower level C malloc/free
  124928             :    function calls for performance and to make sure that mixing of malloc/free
  124929             :    and new/delete by the used can be caught more readily.  This may change
  124930             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  124931             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  124932             :    deallocate memory allocated using ROSE_MALLOC.
  124933             : */
  124934           0 : void *SgRealPartOp::operator new ( size_t Size )
  124935             : {
  124936             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  124937             :      * returning or throwing an exception. */
  124938           0 :     ALLOC_MUTEX(SgRealPartOp, lock);
  124939             : 
  124940             : #if ROSE_ALLOC_TRACE == 2
  124941             : //    printf("SgRealPartOp::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgRealPartOp::next_node);
  124942             : #endif
  124943             : 
  124944             : #if USE_CPP_NEW_DELETE_OPERATORS
  124945             :     void *mem = ROSE_MALLOC(Size);
  124946             :     ALLOC_MUTEX(SgRealPartOp, unlock);
  124947             :     return mem;
  124948             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  124949             : #if ROSE_PEDANTIC_ALLOC
  124950             :     ROSE_ASSERT(Size == sizeof(SgRealPartOp));
  124951             : #else
  124952           0 :     if (Size != sizeof(SgRealPartOp)) {
  124953           0 :       void * object = ROSE_MALLOC(Size);
  124954           0 :       ALLOC_MUTEX(SgRealPartOp, unlock);
  124955             :       return object;
  124956             :     }
  124957             : #endif
  124958             : 
  124959           0 :     if (SgRealPartOp::next_node == nullptr) {
  124960           0 :         SgRealPartOp * alloc = (SgRealPartOp*) ROSE_MALLOC ( SgRealPartOp::pool_size * sizeof(SgRealPartOp) );
  124961           0 :         ROSE_ASSERT(alloc != nullptr);
  124962             : 
  124963             : #if ROSE_ALLOC_TRACE == 2
  124964             : //        printf("SgRealPartOp::alloc\n  block[%zi] = [ %p , %p [\n", SgRealPartOp::pools.size(), alloc, alloc + SgRealPartOp::pool_size);
  124965             : #endif
  124966             : 
  124967             : #if ROSE_ALLOC_MEMSET == 1
  124968             : #elif ROSE_ALLOC_MEMSET == 2
  124969             :         memset(alloc, 0x00, SgRealPartOp::pool_size * sizeof(SgRealPartOp));
  124970             : #elif ROSE_ALLOC_MEMSET == 3
  124971             :         memset(alloc, 0xAA, SgRealPartOp::pool_size * sizeof(SgRealPartOp));
  124972             : #endif
  124973           0 :         for (unsigned i=0; i < SgRealPartOp::pool_size-1; i++) {
  124974           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
  124975             :         }
  124976           0 :         alloc[SgRealPartOp::pool_size-1].p_freepointer = nullptr;
  124977             : 
  124978           0 :         SgRealPartOp::pools.push_back ( (unsigned char *) alloc );
  124979           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgRealPartOp::pool_size * sizeof(SgRealPartOp), V_SgRealPartOp ) );
  124980           0 :         SgRealPartOp::next_node = alloc;
  124981             :     }
  124982           0 :     ROSE_ASSERT(SgRealPartOp::next_node != nullptr);
  124983             : 
  124984           0 :     SgRealPartOp * object = SgRealPartOp::next_node;
  124985           0 :     SgRealPartOp::next_node = (SgRealPartOp*)(object->p_freepointer);
  124986             : 
  124987             : #if ROSE_ALLOC_TRACE == 2
  124988             :     printf("SgRealPartOp::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgRealPartOp::next_node);
  124989             : #endif
  124990             : 
  124991           0 :     SgNode * fp = object->p_freepointer;
  124992             : #if ROSE_ALLOC_MEMSET == 1
  124993             : #elif ROSE_ALLOC_MEMSET == 2
  124994             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgRealPartOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  124995             : #elif ROSE_ALLOC_MEMSET == 3
  124996             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgRealPartOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  124997             : #endif
  124998           0 :     object->p_freepointer = fp;
  124999             : 
  125000             : #if ROSE_ALLOC_TRACE == 2
  125001             : //    printf("SgRealPartOp::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgRealPartOp::next_node);
  125002             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  125003             :     Rose::MemPool::snapshot(oss.str());
  125004             :     alloc_trace_cnt++;
  125005             : #endif
  125006             : 
  125007           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  125008             : 
  125009           0 :     ALLOC_MUTEX(SgRealPartOp, unlock);
  125010             : 
  125011             :     return object;
  125012             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  125013             : }
  125014             : 
  125015             : 
  125016             : 
  125017             : /*! \brief Delete operator for SgRealPartOp.
  125018             : 
  125019             :    This delete operator implements deallocation using memory pools to 
  125020             :    provide most efficent use of the heap within construction of large ASTs.
  125021             : 
  125022             : \internal The new and delete operators use the lower level C malloc/free
  125023             :    function calls for performance and to make sure that mixing of malloc/free
  125024             :    and new/delete by the used can be caught more readily.  This may change
  125025             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  125026             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  125027             :    deallocate memory allocated using ROSE_MALLOC.
  125028             : */
  125029           0 : void SgRealPartOp::operator delete(void *Pointer, size_t Size)
  125030             : {
  125031             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  125032             :      * or throwing an exception. */
  125033           0 :     ALLOC_MUTEX(SgRealPartOp, lock);
  125034             : 
  125035             : #if USE_CPP_NEW_DELETE_OPERATORS
  125036             :     ROSE_FREE(Pointer);
  125037             : #else
  125038             : #if ROSE_PEDANTIC_ALLOC
  125039             :     ROSE_ASSERT(Size == sizeof(SgRealPartOp));
  125040             : #else
  125041           0 :     if (Size != sizeof(SgRealPartOp)) {
  125042           0 :       ROSE_FREE(Pointer);
  125043           0 :       ALLOC_MUTEX(SgRealPartOp, unlock);
  125044             :       return;
  125045             :     }
  125046             : #endif
  125047             : 
  125048           0 :     SgRealPartOp * object = (SgRealPartOp*) Pointer;
  125049           0 :     ROSE_ASSERT(object != nullptr);
  125050             : 
  125051             : #if ROSE_ALLOC_TRACE == 2
  125052             : //  printf("SgRealPartOp::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgRealPartOp::next_node);
  125053             :     printf("SgRealPartOp::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgRealPartOp::next_node);
  125054             : #endif
  125055             : 
  125056             : #if ROSE_PEDANTIC_ALLOC
  125057             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  125058             : #endif
  125059             : 
  125060             : #if ROSE_ALLOC_MEMSET == 1
  125061             : #elif ROSE_ALLOC_MEMSET == 2
  125062             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgRealPartOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  125063             : #elif ROSE_ALLOC_MEMSET == 3
  125064             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgRealPartOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  125065             : #endif
  125066             : 
  125067             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  125068             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  125069             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  125070             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  125071             : #else
  125072           0 :     object->p_freepointer = SgRealPartOp::next_node;
  125073           0 :     SgRealPartOp::next_node = object;
  125074             : #endif
  125075             : 
  125076             : #if ROSE_ALLOC_TRACE == 2
  125077             : //  printf("SgRealPartOp::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgRealPartOp::next_node);
  125078             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  125079             :     Rose::MemPool::snapshot(oss.str());
  125080             :     alloc_trace_cnt++;
  125081             : #endif
  125082             : 
  125083             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  125084             : 
  125085           0 :     ALLOC_MUTEX(SgRealPartOp, unlock);
  125086             : }
  125087             : 
  125088             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  125089             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  125090             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  125091             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  125092             : // Also, note comment below from Robb (copied from the Common.code file).
  125093             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  125094             : //
  125095             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  125096             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  125097             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  125098             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  125099             : #if 0
  125100             : void SgRealPartOp::operator delete(void* pointer) { SgRealPartOp::operator delete (pointer, sizeof(SgRealPartOp)); };
  125101             : #endif
  125102             : /* #line 125103 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  125103             : 
  125104             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  125105             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  125106             : // obviously imply C++.
  125107             : 
  125108             : // This implements the support within ROSE for memory pools.  Memory pools
  125109             : // support the most condensed usage of memory within the construction of
  125110             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  125111             : // by a new operator written for each class.
  125112             : 
  125113             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  125114             :     // User wants multi-thread support and POSIX threads are available.
  125115             : #   include <pthread.h>
  125116             :     static pthread_mutex_t SgImagPartOp_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  125117             : #else
  125118             :      // Cause synchronization to be skipped.
  125119             : #    ifndef ALLOC_MUTEX
  125120             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  125121             : #    endif
  125122             : #    ifdef _REENTRANT
  125123             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  125124             : #       ifdef _MSC_VER
  125125             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  125126             : #       else
  125127             : #           warning "POSIX threads are not available; synchronization being skipped"
  125128             : #       endif
  125129             : #    endif
  125130             : #endif
  125131             : 
  125132             : #ifndef ROSE_ALLOC_TRACE
  125133             : #  define ROSE_ALLOC_TRACE 0
  125134             : #endif
  125135             : 
  125136             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  125137             : #define ROSE_ALLOC_TRACE_CNT
  125138             : #include "memory-pool-snapshot.h"
  125139             : unsigned long alloc_trace_cnt = 0;
  125140             : #endif
  125141             : 
  125142             : #if ROSE_ALLOC_TRACE
  125143             : const unsigned SgImagPartOp::pool_size = 5;
  125144             : #else
  125145             : const unsigned SgImagPartOp::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  125146             : #endif
  125147             : 
  125148             : #ifndef ROSE_ALLOC_MEMSET
  125149             : #  define ROSE_ALLOC_MEMSET 0
  125150             : #endif
  125151             : 
  125152             : #ifndef ROSE_PEDANTIC_ALLOC
  125153             : #  define ROSE_PEDANTIC_ALLOC 0
  125154             : #endif
  125155             : 
  125156             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  125157             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  125158             : #endif
  125159             : 
  125160             : #if !defined(SGNODE__ALL_POOLS)
  125161             : #define SGNODE__ALL_POOLS
  125162             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  125163             : #endif
  125164             : 
  125165             : SgImagPartOp* SgImagPartOp::next_node = nullptr;
  125166             : std::vector<unsigned char*> SgImagPartOp::pools;
  125167             : 
  125168             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  125169             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  125170             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  125171             : // around this macro definition rather than each use).
  125172             : #ifndef ALLOC_MUTEX
  125173             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  125174             :         do {                                                                     \
  125175             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  125176             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  125177             :                 abort();                                                         \
  125178             :             }                                                                    \
  125179             :         } while (0);
  125180             : #endif
  125181             : 
  125182             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  125183             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  125184             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  125185             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  125186             : 
  125187             : /*! \brief New operator for SgImagPartOp.
  125188             : 
  125189             :    This new operator implements memory pools to provide most efficent 
  125190             :    use of the heap within construction of large ASTs.
  125191             : 
  125192             : \internal The new and delete operators use the lower level C malloc/free
  125193             :    function calls for performance and to make sure that mixing of malloc/free
  125194             :    and new/delete by the used can be caught more readily.  This may change
  125195             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  125196             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  125197             :    deallocate memory allocated using ROSE_MALLOC.
  125198             : */
  125199           0 : void *SgImagPartOp::operator new ( size_t Size )
  125200             : {
  125201             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  125202             :      * returning or throwing an exception. */
  125203           0 :     ALLOC_MUTEX(SgImagPartOp, lock);
  125204             : 
  125205             : #if ROSE_ALLOC_TRACE == 2
  125206             : //    printf("SgImagPartOp::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgImagPartOp::next_node);
  125207             : #endif
  125208             : 
  125209             : #if USE_CPP_NEW_DELETE_OPERATORS
  125210             :     void *mem = ROSE_MALLOC(Size);
  125211             :     ALLOC_MUTEX(SgImagPartOp, unlock);
  125212             :     return mem;
  125213             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  125214             : #if ROSE_PEDANTIC_ALLOC
  125215             :     ROSE_ASSERT(Size == sizeof(SgImagPartOp));
  125216             : #else
  125217           0 :     if (Size != sizeof(SgImagPartOp)) {
  125218           0 :       void * object = ROSE_MALLOC(Size);
  125219           0 :       ALLOC_MUTEX(SgImagPartOp, unlock);
  125220             :       return object;
  125221             :     }
  125222             : #endif
  125223             : 
  125224           0 :     if (SgImagPartOp::next_node == nullptr) {
  125225           0 :         SgImagPartOp * alloc = (SgImagPartOp*) ROSE_MALLOC ( SgImagPartOp::pool_size * sizeof(SgImagPartOp) );
  125226           0 :         ROSE_ASSERT(alloc != nullptr);
  125227             : 
  125228             : #if ROSE_ALLOC_TRACE == 2
  125229             : //        printf("SgImagPartOp::alloc\n  block[%zi] = [ %p , %p [\n", SgImagPartOp::pools.size(), alloc, alloc + SgImagPartOp::pool_size);
  125230             : #endif
  125231             : 
  125232             : #if ROSE_ALLOC_MEMSET == 1
  125233             : #elif ROSE_ALLOC_MEMSET == 2
  125234             :         memset(alloc, 0x00, SgImagPartOp::pool_size * sizeof(SgImagPartOp));
  125235             : #elif ROSE_ALLOC_MEMSET == 3
  125236             :         memset(alloc, 0xAA, SgImagPartOp::pool_size * sizeof(SgImagPartOp));
  125237             : #endif
  125238           0 :         for (unsigned i=0; i < SgImagPartOp::pool_size-1; i++) {
  125239           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
  125240             :         }
  125241           0 :         alloc[SgImagPartOp::pool_size-1].p_freepointer = nullptr;
  125242             : 
  125243           0 :         SgImagPartOp::pools.push_back ( (unsigned char *) alloc );
  125244           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgImagPartOp::pool_size * sizeof(SgImagPartOp), V_SgImagPartOp ) );
  125245           0 :         SgImagPartOp::next_node = alloc;
  125246             :     }
  125247           0 :     ROSE_ASSERT(SgImagPartOp::next_node != nullptr);
  125248             : 
  125249           0 :     SgImagPartOp * object = SgImagPartOp::next_node;
  125250           0 :     SgImagPartOp::next_node = (SgImagPartOp*)(object->p_freepointer);
  125251             : 
  125252             : #if ROSE_ALLOC_TRACE == 2
  125253             :     printf("SgImagPartOp::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgImagPartOp::next_node);
  125254             : #endif
  125255             : 
  125256           0 :     SgNode * fp = object->p_freepointer;
  125257             : #if ROSE_ALLOC_MEMSET == 1
  125258             : #elif ROSE_ALLOC_MEMSET == 2
  125259             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgImagPartOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  125260             : #elif ROSE_ALLOC_MEMSET == 3
  125261             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgImagPartOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  125262             : #endif
  125263           0 :     object->p_freepointer = fp;
  125264             : 
  125265             : #if ROSE_ALLOC_TRACE == 2
  125266             : //    printf("SgImagPartOp::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgImagPartOp::next_node);
  125267             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  125268             :     Rose::MemPool::snapshot(oss.str());
  125269             :     alloc_trace_cnt++;
  125270             : #endif
  125271             : 
  125272           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  125273             : 
  125274           0 :     ALLOC_MUTEX(SgImagPartOp, unlock);
  125275             : 
  125276             :     return object;
  125277             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  125278             : }
  125279             : 
  125280             : 
  125281             : 
  125282             : /*! \brief Delete operator for SgImagPartOp.
  125283             : 
  125284             :    This delete operator implements deallocation using memory pools to 
  125285             :    provide most efficent use of the heap within construction of large ASTs.
  125286             : 
  125287             : \internal The new and delete operators use the lower level C malloc/free
  125288             :    function calls for performance and to make sure that mixing of malloc/free
  125289             :    and new/delete by the used can be caught more readily.  This may change
  125290             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  125291             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  125292             :    deallocate memory allocated using ROSE_MALLOC.
  125293             : */
  125294           0 : void SgImagPartOp::operator delete(void *Pointer, size_t Size)
  125295             : {
  125296             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  125297             :      * or throwing an exception. */
  125298           0 :     ALLOC_MUTEX(SgImagPartOp, lock);
  125299             : 
  125300             : #if USE_CPP_NEW_DELETE_OPERATORS
  125301             :     ROSE_FREE(Pointer);
  125302             : #else
  125303             : #if ROSE_PEDANTIC_ALLOC
  125304             :     ROSE_ASSERT(Size == sizeof(SgImagPartOp));
  125305             : #else
  125306           0 :     if (Size != sizeof(SgImagPartOp)) {
  125307           0 :       ROSE_FREE(Pointer);
  125308           0 :       ALLOC_MUTEX(SgImagPartOp, unlock);
  125309             :       return;
  125310             :     }
  125311             : #endif
  125312             : 
  125313           0 :     SgImagPartOp * object = (SgImagPartOp*) Pointer;
  125314           0 :     ROSE_ASSERT(object != nullptr);
  125315             : 
  125316             : #if ROSE_ALLOC_TRACE == 2
  125317             : //  printf("SgImagPartOp::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgImagPartOp::next_node);
  125318             :     printf("SgImagPartOp::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgImagPartOp::next_node);
  125319             : #endif
  125320             : 
  125321             : #if ROSE_PEDANTIC_ALLOC
  125322             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  125323             : #endif
  125324             : 
  125325             : #if ROSE_ALLOC_MEMSET == 1
  125326             : #elif ROSE_ALLOC_MEMSET == 2
  125327             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgImagPartOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  125328             : #elif ROSE_ALLOC_MEMSET == 3
  125329             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgImagPartOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  125330             : #endif
  125331             : 
  125332             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  125333             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  125334             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  125335             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  125336             : #else
  125337           0 :     object->p_freepointer = SgImagPartOp::next_node;
  125338           0 :     SgImagPartOp::next_node = object;
  125339             : #endif
  125340             : 
  125341             : #if ROSE_ALLOC_TRACE == 2
  125342             : //  printf("SgImagPartOp::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgImagPartOp::next_node);
  125343             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  125344             :     Rose::MemPool::snapshot(oss.str());
  125345             :     alloc_trace_cnt++;
  125346             : #endif
  125347             : 
  125348             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  125349             : 
  125350           0 :     ALLOC_MUTEX(SgImagPartOp, unlock);
  125351             : }
  125352             : 
  125353             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  125354             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  125355             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  125356             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  125357             : // Also, note comment below from Robb (copied from the Common.code file).
  125358             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  125359             : //
  125360             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  125361             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  125362             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  125363             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  125364             : #if 0
  125365             : void SgImagPartOp::operator delete(void* pointer) { SgImagPartOp::operator delete (pointer, sizeof(SgImagPartOp)); };
  125366             : #endif
  125367             : /* #line 125368 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  125368             : 
  125369             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  125370             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  125371             : // obviously imply C++.
  125372             : 
  125373             : // This implements the support within ROSE for memory pools.  Memory pools
  125374             : // support the most condensed usage of memory within the construction of
  125375             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  125376             : // by a new operator written for each class.
  125377             : 
  125378             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  125379             :     // User wants multi-thread support and POSIX threads are available.
  125380             : #   include <pthread.h>
  125381             :     static pthread_mutex_t SgConjugateOp_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  125382             : #else
  125383             :      // Cause synchronization to be skipped.
  125384             : #    ifndef ALLOC_MUTEX
  125385             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  125386             : #    endif
  125387             : #    ifdef _REENTRANT
  125388             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  125389             : #       ifdef _MSC_VER
  125390             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  125391             : #       else
  125392             : #           warning "POSIX threads are not available; synchronization being skipped"
  125393             : #       endif
  125394             : #    endif
  125395             : #endif
  125396             : 
  125397             : #ifndef ROSE_ALLOC_TRACE
  125398             : #  define ROSE_ALLOC_TRACE 0
  125399             : #endif
  125400             : 
  125401             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  125402             : #define ROSE_ALLOC_TRACE_CNT
  125403             : #include "memory-pool-snapshot.h"
  125404             : unsigned long alloc_trace_cnt = 0;
  125405             : #endif
  125406             : 
  125407             : #if ROSE_ALLOC_TRACE
  125408             : const unsigned SgConjugateOp::pool_size = 5;
  125409             : #else
  125410             : const unsigned SgConjugateOp::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  125411             : #endif
  125412             : 
  125413             : #ifndef ROSE_ALLOC_MEMSET
  125414             : #  define ROSE_ALLOC_MEMSET 0
  125415             : #endif
  125416             : 
  125417             : #ifndef ROSE_PEDANTIC_ALLOC
  125418             : #  define ROSE_PEDANTIC_ALLOC 0
  125419             : #endif
  125420             : 
  125421             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  125422             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  125423             : #endif
  125424             : 
  125425             : #if !defined(SGNODE__ALL_POOLS)
  125426             : #define SGNODE__ALL_POOLS
  125427             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  125428             : #endif
  125429             : 
  125430             : SgConjugateOp* SgConjugateOp::next_node = nullptr;
  125431             : std::vector<unsigned char*> SgConjugateOp::pools;
  125432             : 
  125433             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  125434             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  125435             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  125436             : // around this macro definition rather than each use).
  125437             : #ifndef ALLOC_MUTEX
  125438             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  125439             :         do {                                                                     \
  125440             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  125441             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  125442             :                 abort();                                                         \
  125443             :             }                                                                    \
  125444             :         } while (0);
  125445             : #endif
  125446             : 
  125447             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  125448             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  125449             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  125450             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  125451             : 
  125452             : /*! \brief New operator for SgConjugateOp.
  125453             : 
  125454             :    This new operator implements memory pools to provide most efficent 
  125455             :    use of the heap within construction of large ASTs.
  125456             : 
  125457             : \internal The new and delete operators use the lower level C malloc/free
  125458             :    function calls for performance and to make sure that mixing of malloc/free
  125459             :    and new/delete by the used can be caught more readily.  This may change
  125460             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  125461             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  125462             :    deallocate memory allocated using ROSE_MALLOC.
  125463             : */
  125464           0 : void *SgConjugateOp::operator new ( size_t Size )
  125465             : {
  125466             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  125467             :      * returning or throwing an exception. */
  125468           0 :     ALLOC_MUTEX(SgConjugateOp, lock);
  125469             : 
  125470             : #if ROSE_ALLOC_TRACE == 2
  125471             : //    printf("SgConjugateOp::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgConjugateOp::next_node);
  125472             : #endif
  125473             : 
  125474             : #if USE_CPP_NEW_DELETE_OPERATORS
  125475             :     void *mem = ROSE_MALLOC(Size);
  125476             :     ALLOC_MUTEX(SgConjugateOp, unlock);
  125477             :     return mem;
  125478             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  125479             : #if ROSE_PEDANTIC_ALLOC
  125480             :     ROSE_ASSERT(Size == sizeof(SgConjugateOp));
  125481             : #else
  125482           0 :     if (Size != sizeof(SgConjugateOp)) {
  125483           0 :       void * object = ROSE_MALLOC(Size);
  125484           0 :       ALLOC_MUTEX(SgConjugateOp, unlock);
  125485             :       return object;
  125486             :     }
  125487             : #endif
  125488             : 
  125489           0 :     if (SgConjugateOp::next_node == nullptr) {
  125490           0 :         SgConjugateOp * alloc = (SgConjugateOp*) ROSE_MALLOC ( SgConjugateOp::pool_size * sizeof(SgConjugateOp) );
  125491           0 :         ROSE_ASSERT(alloc != nullptr);
  125492             : 
  125493             : #if ROSE_ALLOC_TRACE == 2
  125494             : //        printf("SgConjugateOp::alloc\n  block[%zi] = [ %p , %p [\n", SgConjugateOp::pools.size(), alloc, alloc + SgConjugateOp::pool_size);
  125495             : #endif
  125496             : 
  125497             : #if ROSE_ALLOC_MEMSET == 1
  125498             : #elif ROSE_ALLOC_MEMSET == 2
  125499             :         memset(alloc, 0x00, SgConjugateOp::pool_size * sizeof(SgConjugateOp));
  125500             : #elif ROSE_ALLOC_MEMSET == 3
  125501             :         memset(alloc, 0xAA, SgConjugateOp::pool_size * sizeof(SgConjugateOp));
  125502             : #endif
  125503           0 :         for (unsigned i=0; i < SgConjugateOp::pool_size-1; i++) {
  125504           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
  125505             :         }
  125506           0 :         alloc[SgConjugateOp::pool_size-1].p_freepointer = nullptr;
  125507             : 
  125508           0 :         SgConjugateOp::pools.push_back ( (unsigned char *) alloc );
  125509           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgConjugateOp::pool_size * sizeof(SgConjugateOp), V_SgConjugateOp ) );
  125510           0 :         SgConjugateOp::next_node = alloc;
  125511             :     }
  125512           0 :     ROSE_ASSERT(SgConjugateOp::next_node != nullptr);
  125513             : 
  125514           0 :     SgConjugateOp * object = SgConjugateOp::next_node;
  125515           0 :     SgConjugateOp::next_node = (SgConjugateOp*)(object->p_freepointer);
  125516             : 
  125517             : #if ROSE_ALLOC_TRACE == 2
  125518             :     printf("SgConjugateOp::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgConjugateOp::next_node);
  125519             : #endif
  125520             : 
  125521           0 :     SgNode * fp = object->p_freepointer;
  125522             : #if ROSE_ALLOC_MEMSET == 1
  125523             : #elif ROSE_ALLOC_MEMSET == 2
  125524             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgConjugateOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  125525             : #elif ROSE_ALLOC_MEMSET == 3
  125526             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgConjugateOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  125527             : #endif
  125528           0 :     object->p_freepointer = fp;
  125529             : 
  125530             : #if ROSE_ALLOC_TRACE == 2
  125531             : //    printf("SgConjugateOp::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgConjugateOp::next_node);
  125532             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  125533             :     Rose::MemPool::snapshot(oss.str());
  125534             :     alloc_trace_cnt++;
  125535             : #endif
  125536             : 
  125537           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  125538             : 
  125539           0 :     ALLOC_MUTEX(SgConjugateOp, unlock);
  125540             : 
  125541             :     return object;
  125542             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  125543             : }
  125544             : 
  125545             : 
  125546             : 
  125547             : /*! \brief Delete operator for SgConjugateOp.
  125548             : 
  125549             :    This delete operator implements deallocation using memory pools to 
  125550             :    provide most efficent use of the heap within construction of large ASTs.
  125551             : 
  125552             : \internal The new and delete operators use the lower level C malloc/free
  125553             :    function calls for performance and to make sure that mixing of malloc/free
  125554             :    and new/delete by the used can be caught more readily.  This may change
  125555             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  125556             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  125557             :    deallocate memory allocated using ROSE_MALLOC.
  125558             : */
  125559           0 : void SgConjugateOp::operator delete(void *Pointer, size_t Size)
  125560             : {
  125561             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  125562             :      * or throwing an exception. */
  125563           0 :     ALLOC_MUTEX(SgConjugateOp, lock);
  125564             : 
  125565             : #if USE_CPP_NEW_DELETE_OPERATORS
  125566             :     ROSE_FREE(Pointer);
  125567             : #else
  125568             : #if ROSE_PEDANTIC_ALLOC
  125569             :     ROSE_ASSERT(Size == sizeof(SgConjugateOp));
  125570             : #else
  125571           0 :     if (Size != sizeof(SgConjugateOp)) {
  125572           0 :       ROSE_FREE(Pointer);
  125573           0 :       ALLOC_MUTEX(SgConjugateOp, unlock);
  125574             :       return;
  125575             :     }
  125576             : #endif
  125577             : 
  125578           0 :     SgConjugateOp * object = (SgConjugateOp*) Pointer;
  125579           0 :     ROSE_ASSERT(object != nullptr);
  125580             : 
  125581             : #if ROSE_ALLOC_TRACE == 2
  125582             : //  printf("SgConjugateOp::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgConjugateOp::next_node);
  125583             :     printf("SgConjugateOp::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgConjugateOp::next_node);
  125584             : #endif
  125585             : 
  125586             : #if ROSE_PEDANTIC_ALLOC
  125587             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  125588             : #endif
  125589             : 
  125590             : #if ROSE_ALLOC_MEMSET == 1
  125591             : #elif ROSE_ALLOC_MEMSET == 2
  125592             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgConjugateOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  125593             : #elif ROSE_ALLOC_MEMSET == 3
  125594             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgConjugateOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  125595             : #endif
  125596             : 
  125597             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  125598             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  125599             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  125600             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  125601             : #else
  125602           0 :     object->p_freepointer = SgConjugateOp::next_node;
  125603           0 :     SgConjugateOp::next_node = object;
  125604             : #endif
  125605             : 
  125606             : #if ROSE_ALLOC_TRACE == 2
  125607             : //  printf("SgConjugateOp::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgConjugateOp::next_node);
  125608             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  125609             :     Rose::MemPool::snapshot(oss.str());
  125610             :     alloc_trace_cnt++;
  125611             : #endif
  125612             : 
  125613             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  125614             : 
  125615           0 :     ALLOC_MUTEX(SgConjugateOp, unlock);
  125616             : }
  125617             : 
  125618             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  125619             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  125620             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  125621             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  125622             : // Also, note comment below from Robb (copied from the Common.code file).
  125623             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  125624             : //
  125625             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  125626             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  125627             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  125628             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  125629             : #if 0
  125630             : void SgConjugateOp::operator delete(void* pointer) { SgConjugateOp::operator delete (pointer, sizeof(SgConjugateOp)); };
  125631             : #endif
  125632             : /* #line 125633 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  125633             : 
  125634             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  125635             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  125636             : // obviously imply C++.
  125637             : 
  125638             : // This implements the support within ROSE for memory pools.  Memory pools
  125639             : // support the most condensed usage of memory within the construction of
  125640             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  125641             : // by a new operator written for each class.
  125642             : 
  125643             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  125644             :     // User wants multi-thread support and POSIX threads are available.
  125645             : #   include <pthread.h>
  125646             :     static pthread_mutex_t SgUserDefinedUnaryOp_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  125647             : #else
  125648             :      // Cause synchronization to be skipped.
  125649             : #    ifndef ALLOC_MUTEX
  125650             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  125651             : #    endif
  125652             : #    ifdef _REENTRANT
  125653             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  125654             : #       ifdef _MSC_VER
  125655             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  125656             : #       else
  125657             : #           warning "POSIX threads are not available; synchronization being skipped"
  125658             : #       endif
  125659             : #    endif
  125660             : #endif
  125661             : 
  125662             : #ifndef ROSE_ALLOC_TRACE
  125663             : #  define ROSE_ALLOC_TRACE 0
  125664             : #endif
  125665             : 
  125666             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  125667             : #define ROSE_ALLOC_TRACE_CNT
  125668             : #include "memory-pool-snapshot.h"
  125669             : unsigned long alloc_trace_cnt = 0;
  125670             : #endif
  125671             : 
  125672             : #if ROSE_ALLOC_TRACE
  125673             : const unsigned SgUserDefinedUnaryOp::pool_size = 5;
  125674             : #else
  125675             : const unsigned SgUserDefinedUnaryOp::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  125676             : #endif
  125677             : 
  125678             : #ifndef ROSE_ALLOC_MEMSET
  125679             : #  define ROSE_ALLOC_MEMSET 0
  125680             : #endif
  125681             : 
  125682             : #ifndef ROSE_PEDANTIC_ALLOC
  125683             : #  define ROSE_PEDANTIC_ALLOC 0
  125684             : #endif
  125685             : 
  125686             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  125687             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  125688             : #endif
  125689             : 
  125690             : #if !defined(SGNODE__ALL_POOLS)
  125691             : #define SGNODE__ALL_POOLS
  125692             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  125693             : #endif
  125694             : 
  125695             : SgUserDefinedUnaryOp* SgUserDefinedUnaryOp::next_node = nullptr;
  125696             : std::vector<unsigned char*> SgUserDefinedUnaryOp::pools;
  125697             : 
  125698             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  125699             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  125700             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  125701             : // around this macro definition rather than each use).
  125702             : #ifndef ALLOC_MUTEX
  125703             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  125704             :         do {                                                                     \
  125705             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  125706             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  125707             :                 abort();                                                         \
  125708             :             }                                                                    \
  125709             :         } while (0);
  125710             : #endif
  125711             : 
  125712             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  125713             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  125714             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  125715             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  125716             : 
  125717             : /*! \brief New operator for SgUserDefinedUnaryOp.
  125718             : 
  125719             :    This new operator implements memory pools to provide most efficent 
  125720             :    use of the heap within construction of large ASTs.
  125721             : 
  125722             : \internal The new and delete operators use the lower level C malloc/free
  125723             :    function calls for performance and to make sure that mixing of malloc/free
  125724             :    and new/delete by the used can be caught more readily.  This may change
  125725             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  125726             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  125727             :    deallocate memory allocated using ROSE_MALLOC.
  125728             : */
  125729           0 : void *SgUserDefinedUnaryOp::operator new ( size_t Size )
  125730             : {
  125731             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  125732             :      * returning or throwing an exception. */
  125733           0 :     ALLOC_MUTEX(SgUserDefinedUnaryOp, lock);
  125734             : 
  125735             : #if ROSE_ALLOC_TRACE == 2
  125736             : //    printf("SgUserDefinedUnaryOp::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgUserDefinedUnaryOp::next_node);
  125737             : #endif
  125738             : 
  125739             : #if USE_CPP_NEW_DELETE_OPERATORS
  125740             :     void *mem = ROSE_MALLOC(Size);
  125741             :     ALLOC_MUTEX(SgUserDefinedUnaryOp, unlock);
  125742             :     return mem;
  125743             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  125744             : #if ROSE_PEDANTIC_ALLOC
  125745             :     ROSE_ASSERT(Size == sizeof(SgUserDefinedUnaryOp));
  125746             : #else
  125747           0 :     if (Size != sizeof(SgUserDefinedUnaryOp)) {
  125748           0 :       void * object = ROSE_MALLOC(Size);
  125749           0 :       ALLOC_MUTEX(SgUserDefinedUnaryOp, unlock);
  125750             :       return object;
  125751             :     }
  125752             : #endif
  125753             : 
  125754           0 :     if (SgUserDefinedUnaryOp::next_node == nullptr) {
  125755           0 :         SgUserDefinedUnaryOp * alloc = (SgUserDefinedUnaryOp*) ROSE_MALLOC ( SgUserDefinedUnaryOp::pool_size * sizeof(SgUserDefinedUnaryOp) );
  125756           0 :         ROSE_ASSERT(alloc != nullptr);
  125757             : 
  125758             : #if ROSE_ALLOC_TRACE == 2
  125759             : //        printf("SgUserDefinedUnaryOp::alloc\n  block[%zi] = [ %p , %p [\n", SgUserDefinedUnaryOp::pools.size(), alloc, alloc + SgUserDefinedUnaryOp::pool_size);
  125760             : #endif
  125761             : 
  125762             : #if ROSE_ALLOC_MEMSET == 1
  125763             : #elif ROSE_ALLOC_MEMSET == 2
  125764             :         memset(alloc, 0x00, SgUserDefinedUnaryOp::pool_size * sizeof(SgUserDefinedUnaryOp));
  125765             : #elif ROSE_ALLOC_MEMSET == 3
  125766             :         memset(alloc, 0xAA, SgUserDefinedUnaryOp::pool_size * sizeof(SgUserDefinedUnaryOp));
  125767             : #endif
  125768           0 :         for (unsigned i=0; i < SgUserDefinedUnaryOp::pool_size-1; i++) {
  125769           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
  125770             :         }
  125771           0 :         alloc[SgUserDefinedUnaryOp::pool_size-1].p_freepointer = nullptr;
  125772             : 
  125773           0 :         SgUserDefinedUnaryOp::pools.push_back ( (unsigned char *) alloc );
  125774           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgUserDefinedUnaryOp::pool_size * sizeof(SgUserDefinedUnaryOp), V_SgUserDefinedUnaryOp ) );
  125775           0 :         SgUserDefinedUnaryOp::next_node = alloc;
  125776             :     }
  125777           0 :     ROSE_ASSERT(SgUserDefinedUnaryOp::next_node != nullptr);
  125778             : 
  125779           0 :     SgUserDefinedUnaryOp * object = SgUserDefinedUnaryOp::next_node;
  125780           0 :     SgUserDefinedUnaryOp::next_node = (SgUserDefinedUnaryOp*)(object->p_freepointer);
  125781             : 
  125782             : #if ROSE_ALLOC_TRACE == 2
  125783             :     printf("SgUserDefinedUnaryOp::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUserDefinedUnaryOp::next_node);
  125784             : #endif
  125785             : 
  125786           0 :     SgNode * fp = object->p_freepointer;
  125787             : #if ROSE_ALLOC_MEMSET == 1
  125788             : #elif ROSE_ALLOC_MEMSET == 2
  125789             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgUserDefinedUnaryOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  125790             : #elif ROSE_ALLOC_MEMSET == 3
  125791             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgUserDefinedUnaryOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  125792             : #endif
  125793           0 :     object->p_freepointer = fp;
  125794             : 
  125795             : #if ROSE_ALLOC_TRACE == 2
  125796             : //    printf("SgUserDefinedUnaryOp::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUserDefinedUnaryOp::next_node);
  125797             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  125798             :     Rose::MemPool::snapshot(oss.str());
  125799             :     alloc_trace_cnt++;
  125800             : #endif
  125801             : 
  125802           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  125803             : 
  125804           0 :     ALLOC_MUTEX(SgUserDefinedUnaryOp, unlock);
  125805             : 
  125806             :     return object;
  125807             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  125808             : }
  125809             : 
  125810             : 
  125811             : 
  125812             : /*! \brief Delete operator for SgUserDefinedUnaryOp.
  125813             : 
  125814             :    This delete operator implements deallocation using memory pools to 
  125815             :    provide most efficent use of the heap within construction of large ASTs.
  125816             : 
  125817             : \internal The new and delete operators use the lower level C malloc/free
  125818             :    function calls for performance and to make sure that mixing of malloc/free
  125819             :    and new/delete by the used can be caught more readily.  This may change
  125820             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  125821             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  125822             :    deallocate memory allocated using ROSE_MALLOC.
  125823             : */
  125824           0 : void SgUserDefinedUnaryOp::operator delete(void *Pointer, size_t Size)
  125825             : {
  125826             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  125827             :      * or throwing an exception. */
  125828           0 :     ALLOC_MUTEX(SgUserDefinedUnaryOp, lock);
  125829             : 
  125830             : #if USE_CPP_NEW_DELETE_OPERATORS
  125831             :     ROSE_FREE(Pointer);
  125832             : #else
  125833             : #if ROSE_PEDANTIC_ALLOC
  125834             :     ROSE_ASSERT(Size == sizeof(SgUserDefinedUnaryOp));
  125835             : #else
  125836           0 :     if (Size != sizeof(SgUserDefinedUnaryOp)) {
  125837           0 :       ROSE_FREE(Pointer);
  125838           0 :       ALLOC_MUTEX(SgUserDefinedUnaryOp, unlock);
  125839             :       return;
  125840             :     }
  125841             : #endif
  125842             : 
  125843           0 :     SgUserDefinedUnaryOp * object = (SgUserDefinedUnaryOp*) Pointer;
  125844           0 :     ROSE_ASSERT(object != nullptr);
  125845             : 
  125846             : #if ROSE_ALLOC_TRACE == 2
  125847             : //  printf("SgUserDefinedUnaryOp::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUserDefinedUnaryOp::next_node);
  125848             :     printf("SgUserDefinedUnaryOp::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUserDefinedUnaryOp::next_node);
  125849             : #endif
  125850             : 
  125851             : #if ROSE_PEDANTIC_ALLOC
  125852             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  125853             : #endif
  125854             : 
  125855             : #if ROSE_ALLOC_MEMSET == 1
  125856             : #elif ROSE_ALLOC_MEMSET == 2
  125857             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgUserDefinedUnaryOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  125858             : #elif ROSE_ALLOC_MEMSET == 3
  125859             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgUserDefinedUnaryOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  125860             : #endif
  125861             : 
  125862             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  125863             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  125864             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  125865             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  125866             : #else
  125867           0 :     object->p_freepointer = SgUserDefinedUnaryOp::next_node;
  125868           0 :     SgUserDefinedUnaryOp::next_node = object;
  125869             : #endif
  125870             : 
  125871             : #if ROSE_ALLOC_TRACE == 2
  125872             : //  printf("SgUserDefinedUnaryOp::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUserDefinedUnaryOp::next_node);
  125873             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  125874             :     Rose::MemPool::snapshot(oss.str());
  125875             :     alloc_trace_cnt++;
  125876             : #endif
  125877             : 
  125878             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  125879             : 
  125880           0 :     ALLOC_MUTEX(SgUserDefinedUnaryOp, unlock);
  125881             : }
  125882             : 
  125883             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  125884             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  125885             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  125886             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  125887             : // Also, note comment below from Robb (copied from the Common.code file).
  125888             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  125889             : //
  125890             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  125891             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  125892             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  125893             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  125894             : #if 0
  125895             : void SgUserDefinedUnaryOp::operator delete(void* pointer) { SgUserDefinedUnaryOp::operator delete (pointer, sizeof(SgUserDefinedUnaryOp)); };
  125896             : #endif
  125897             : /* #line 125898 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  125898             : 
  125899             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  125900             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  125901             : // obviously imply C++.
  125902             : 
  125903             : // This implements the support within ROSE for memory pools.  Memory pools
  125904             : // support the most condensed usage of memory within the construction of
  125905             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  125906             : // by a new operator written for each class.
  125907             : 
  125908             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  125909             :     // User wants multi-thread support and POSIX threads are available.
  125910             : #   include <pthread.h>
  125911             :     static pthread_mutex_t SgMatrixTransposeOp_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  125912             : #else
  125913             :      // Cause synchronization to be skipped.
  125914             : #    ifndef ALLOC_MUTEX
  125915             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  125916             : #    endif
  125917             : #    ifdef _REENTRANT
  125918             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  125919             : #       ifdef _MSC_VER
  125920             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  125921             : #       else
  125922             : #           warning "POSIX threads are not available; synchronization being skipped"
  125923             : #       endif
  125924             : #    endif
  125925             : #endif
  125926             : 
  125927             : #ifndef ROSE_ALLOC_TRACE
  125928             : #  define ROSE_ALLOC_TRACE 0
  125929             : #endif
  125930             : 
  125931             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  125932             : #define ROSE_ALLOC_TRACE_CNT
  125933             : #include "memory-pool-snapshot.h"
  125934             : unsigned long alloc_trace_cnt = 0;
  125935             : #endif
  125936             : 
  125937             : #if ROSE_ALLOC_TRACE
  125938             : const unsigned SgMatrixTransposeOp::pool_size = 5;
  125939             : #else
  125940             : const unsigned SgMatrixTransposeOp::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  125941             : #endif
  125942             : 
  125943             : #ifndef ROSE_ALLOC_MEMSET
  125944             : #  define ROSE_ALLOC_MEMSET 0
  125945             : #endif
  125946             : 
  125947             : #ifndef ROSE_PEDANTIC_ALLOC
  125948             : #  define ROSE_PEDANTIC_ALLOC 0
  125949             : #endif
  125950             : 
  125951             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  125952             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  125953             : #endif
  125954             : 
  125955             : #if !defined(SGNODE__ALL_POOLS)
  125956             : #define SGNODE__ALL_POOLS
  125957             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  125958             : #endif
  125959             : 
  125960             : SgMatrixTransposeOp* SgMatrixTransposeOp::next_node = nullptr;
  125961             : std::vector<unsigned char*> SgMatrixTransposeOp::pools;
  125962             : 
  125963             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  125964             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  125965             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  125966             : // around this macro definition rather than each use).
  125967             : #ifndef ALLOC_MUTEX
  125968             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  125969             :         do {                                                                     \
  125970             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  125971             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  125972             :                 abort();                                                         \
  125973             :             }                                                                    \
  125974             :         } while (0);
  125975             : #endif
  125976             : 
  125977             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  125978             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  125979             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  125980             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  125981             : 
  125982             : /*! \brief New operator for SgMatrixTransposeOp.
  125983             : 
  125984             :    This new operator implements memory pools to provide most efficent 
  125985             :    use of the heap within construction of large ASTs.
  125986             : 
  125987             : \internal The new and delete operators use the lower level C malloc/free
  125988             :    function calls for performance and to make sure that mixing of malloc/free
  125989             :    and new/delete by the used can be caught more readily.  This may change
  125990             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  125991             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  125992             :    deallocate memory allocated using ROSE_MALLOC.
  125993             : */
  125994           0 : void *SgMatrixTransposeOp::operator new ( size_t Size )
  125995             : {
  125996             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  125997             :      * returning or throwing an exception. */
  125998           0 :     ALLOC_MUTEX(SgMatrixTransposeOp, lock);
  125999             : 
  126000             : #if ROSE_ALLOC_TRACE == 2
  126001             : //    printf("SgMatrixTransposeOp::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgMatrixTransposeOp::next_node);
  126002             : #endif
  126003             : 
  126004             : #if USE_CPP_NEW_DELETE_OPERATORS
  126005             :     void *mem = ROSE_MALLOC(Size);
  126006             :     ALLOC_MUTEX(SgMatrixTransposeOp, unlock);
  126007             :     return mem;
  126008             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  126009             : #if ROSE_PEDANTIC_ALLOC
  126010             :     ROSE_ASSERT(Size == sizeof(SgMatrixTransposeOp));
  126011             : #else
  126012           0 :     if (Size != sizeof(SgMatrixTransposeOp)) {
  126013           0 :       void * object = ROSE_MALLOC(Size);
  126014           0 :       ALLOC_MUTEX(SgMatrixTransposeOp, unlock);
  126015             :       return object;
  126016             :     }
  126017             : #endif
  126018             : 
  126019           0 :     if (SgMatrixTransposeOp::next_node == nullptr) {
  126020           0 :         SgMatrixTransposeOp * alloc = (SgMatrixTransposeOp*) ROSE_MALLOC ( SgMatrixTransposeOp::pool_size * sizeof(SgMatrixTransposeOp) );
  126021           0 :         ROSE_ASSERT(alloc != nullptr);
  126022             : 
  126023             : #if ROSE_ALLOC_TRACE == 2
  126024             : //        printf("SgMatrixTransposeOp::alloc\n  block[%zi] = [ %p , %p [\n", SgMatrixTransposeOp::pools.size(), alloc, alloc + SgMatrixTransposeOp::pool_size);
  126025             : #endif
  126026             : 
  126027             : #if ROSE_ALLOC_MEMSET == 1
  126028             : #elif ROSE_ALLOC_MEMSET == 2
  126029             :         memset(alloc, 0x00, SgMatrixTransposeOp::pool_size * sizeof(SgMatrixTransposeOp));
  126030             : #elif ROSE_ALLOC_MEMSET == 3
  126031             :         memset(alloc, 0xAA, SgMatrixTransposeOp::pool_size * sizeof(SgMatrixTransposeOp));
  126032             : #endif
  126033           0 :         for (unsigned i=0; i < SgMatrixTransposeOp::pool_size-1; i++) {
  126034           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
  126035             :         }
  126036           0 :         alloc[SgMatrixTransposeOp::pool_size-1].p_freepointer = nullptr;
  126037             : 
  126038           0 :         SgMatrixTransposeOp::pools.push_back ( (unsigned char *) alloc );
  126039           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgMatrixTransposeOp::pool_size * sizeof(SgMatrixTransposeOp), V_SgMatrixTransposeOp ) );
  126040           0 :         SgMatrixTransposeOp::next_node = alloc;
  126041             :     }
  126042           0 :     ROSE_ASSERT(SgMatrixTransposeOp::next_node != nullptr);
  126043             : 
  126044           0 :     SgMatrixTransposeOp * object = SgMatrixTransposeOp::next_node;
  126045           0 :     SgMatrixTransposeOp::next_node = (SgMatrixTransposeOp*)(object->p_freepointer);
  126046             : 
  126047             : #if ROSE_ALLOC_TRACE == 2
  126048             :     printf("SgMatrixTransposeOp::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgMatrixTransposeOp::next_node);
  126049             : #endif
  126050             : 
  126051           0 :     SgNode * fp = object->p_freepointer;
  126052             : #if ROSE_ALLOC_MEMSET == 1
  126053             : #elif ROSE_ALLOC_MEMSET == 2
  126054             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgMatrixTransposeOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  126055             : #elif ROSE_ALLOC_MEMSET == 3
  126056             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgMatrixTransposeOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  126057             : #endif
  126058           0 :     object->p_freepointer = fp;
  126059             : 
  126060             : #if ROSE_ALLOC_TRACE == 2
  126061             : //    printf("SgMatrixTransposeOp::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgMatrixTransposeOp::next_node);
  126062             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  126063             :     Rose::MemPool::snapshot(oss.str());
  126064             :     alloc_trace_cnt++;
  126065             : #endif
  126066             : 
  126067           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  126068             : 
  126069           0 :     ALLOC_MUTEX(SgMatrixTransposeOp, unlock);
  126070             : 
  126071             :     return object;
  126072             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  126073             : }
  126074             : 
  126075             : 
  126076             : 
  126077             : /*! \brief Delete operator for SgMatrixTransposeOp.
  126078             : 
  126079             :    This delete operator implements deallocation using memory pools to 
  126080             :    provide most efficent use of the heap within construction of large ASTs.
  126081             : 
  126082             : \internal The new and delete operators use the lower level C malloc/free
  126083             :    function calls for performance and to make sure that mixing of malloc/free
  126084             :    and new/delete by the used can be caught more readily.  This may change
  126085             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  126086             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  126087             :    deallocate memory allocated using ROSE_MALLOC.
  126088             : */
  126089           0 : void SgMatrixTransposeOp::operator delete(void *Pointer, size_t Size)
  126090             : {
  126091             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  126092             :      * or throwing an exception. */
  126093           0 :     ALLOC_MUTEX(SgMatrixTransposeOp, lock);
  126094             : 
  126095             : #if USE_CPP_NEW_DELETE_OPERATORS
  126096             :     ROSE_FREE(Pointer);
  126097             : #else
  126098             : #if ROSE_PEDANTIC_ALLOC
  126099             :     ROSE_ASSERT(Size == sizeof(SgMatrixTransposeOp));
  126100             : #else
  126101           0 :     if (Size != sizeof(SgMatrixTransposeOp)) {
  126102           0 :       ROSE_FREE(Pointer);
  126103           0 :       ALLOC_MUTEX(SgMatrixTransposeOp, unlock);
  126104             :       return;
  126105             :     }
  126106             : #endif
  126107             : 
  126108           0 :     SgMatrixTransposeOp * object = (SgMatrixTransposeOp*) Pointer;
  126109           0 :     ROSE_ASSERT(object != nullptr);
  126110             : 
  126111             : #if ROSE_ALLOC_TRACE == 2
  126112             : //  printf("SgMatrixTransposeOp::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgMatrixTransposeOp::next_node);
  126113             :     printf("SgMatrixTransposeOp::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgMatrixTransposeOp::next_node);
  126114             : #endif
  126115             : 
  126116             : #if ROSE_PEDANTIC_ALLOC
  126117             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  126118             : #endif
  126119             : 
  126120             : #if ROSE_ALLOC_MEMSET == 1
  126121             : #elif ROSE_ALLOC_MEMSET == 2
  126122             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgMatrixTransposeOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  126123             : #elif ROSE_ALLOC_MEMSET == 3
  126124             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgMatrixTransposeOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  126125             : #endif
  126126             : 
  126127             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  126128             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  126129             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  126130             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  126131             : #else
  126132           0 :     object->p_freepointer = SgMatrixTransposeOp::next_node;
  126133           0 :     SgMatrixTransposeOp::next_node = object;
  126134             : #endif
  126135             : 
  126136             : #if ROSE_ALLOC_TRACE == 2
  126137             : //  printf("SgMatrixTransposeOp::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgMatrixTransposeOp::next_node);
  126138             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  126139             :     Rose::MemPool::snapshot(oss.str());
  126140             :     alloc_trace_cnt++;
  126141             : #endif
  126142             : 
  126143             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  126144             : 
  126145           0 :     ALLOC_MUTEX(SgMatrixTransposeOp, unlock);
  126146             : }
  126147             : 
  126148             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  126149             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  126150             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  126151             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  126152             : // Also, note comment below from Robb (copied from the Common.code file).
  126153             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  126154             : //
  126155             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  126156             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  126157             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  126158             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  126159             : #if 0
  126160             : void SgMatrixTransposeOp::operator delete(void* pointer) { SgMatrixTransposeOp::operator delete (pointer, sizeof(SgMatrixTransposeOp)); };
  126161             : #endif
  126162             : /* #line 126163 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  126163             : 
  126164             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  126165             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  126166             : // obviously imply C++.
  126167             : 
  126168             : // This implements the support within ROSE for memory pools.  Memory pools
  126169             : // support the most condensed usage of memory within the construction of
  126170             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  126171             : // by a new operator written for each class.
  126172             : 
  126173             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  126174             :     // User wants multi-thread support and POSIX threads are available.
  126175             : #   include <pthread.h>
  126176             :     static pthread_mutex_t SgBinaryOp_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  126177             : #else
  126178             :      // Cause synchronization to be skipped.
  126179             : #    ifndef ALLOC_MUTEX
  126180             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  126181             : #    endif
  126182             : #    ifdef _REENTRANT
  126183             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  126184             : #       ifdef _MSC_VER
  126185             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  126186             : #       else
  126187             : #           warning "POSIX threads are not available; synchronization being skipped"
  126188             : #       endif
  126189             : #    endif
  126190             : #endif
  126191             : 
  126192             : #ifndef ROSE_ALLOC_TRACE
  126193             : #  define ROSE_ALLOC_TRACE 0
  126194             : #endif
  126195             : 
  126196             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  126197             : #define ROSE_ALLOC_TRACE_CNT
  126198             : #include "memory-pool-snapshot.h"
  126199             : unsigned long alloc_trace_cnt = 0;
  126200             : #endif
  126201             : 
  126202             : #if ROSE_ALLOC_TRACE
  126203             : const unsigned SgBinaryOp::pool_size = 5;
  126204             : #else
  126205             : const unsigned SgBinaryOp::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  126206             : #endif
  126207             : 
  126208             : #ifndef ROSE_ALLOC_MEMSET
  126209             : #  define ROSE_ALLOC_MEMSET 0
  126210             : #endif
  126211             : 
  126212             : #ifndef ROSE_PEDANTIC_ALLOC
  126213             : #  define ROSE_PEDANTIC_ALLOC 0
  126214             : #endif
  126215             : 
  126216             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  126217             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  126218             : #endif
  126219             : 
  126220             : #if !defined(SGNODE__ALL_POOLS)
  126221             : #define SGNODE__ALL_POOLS
  126222             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  126223             : #endif
  126224             : 
  126225             : SgBinaryOp* SgBinaryOp::next_node = nullptr;
  126226             : std::vector<unsigned char*> SgBinaryOp::pools;
  126227             : 
  126228             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  126229             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  126230             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  126231             : // around this macro definition rather than each use).
  126232             : #ifndef ALLOC_MUTEX
  126233             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  126234             :         do {                                                                     \
  126235             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  126236             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  126237             :                 abort();                                                         \
  126238             :             }                                                                    \
  126239             :         } while (0);
  126240             : #endif
  126241             : 
  126242             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  126243             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  126244             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  126245             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  126246             : 
  126247             : /*! \brief New operator for SgBinaryOp.
  126248             : 
  126249             :    This new operator implements memory pools to provide most efficent 
  126250             :    use of the heap within construction of large ASTs.
  126251             : 
  126252             : \internal The new and delete operators use the lower level C malloc/free
  126253             :    function calls for performance and to make sure that mixing of malloc/free
  126254             :    and new/delete by the used can be caught more readily.  This may change
  126255             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  126256             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  126257             :    deallocate memory allocated using ROSE_MALLOC.
  126258             : */
  126259           0 : void *SgBinaryOp::operator new ( size_t Size )
  126260             : {
  126261             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  126262             :      * returning or throwing an exception. */
  126263           0 :     ALLOC_MUTEX(SgBinaryOp, lock);
  126264             : 
  126265             : #if ROSE_ALLOC_TRACE == 2
  126266             : //    printf("SgBinaryOp::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgBinaryOp::next_node);
  126267             : #endif
  126268             : 
  126269             : #if USE_CPP_NEW_DELETE_OPERATORS
  126270             :     void *mem = ROSE_MALLOC(Size);
  126271             :     ALLOC_MUTEX(SgBinaryOp, unlock);
  126272             :     return mem;
  126273             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  126274             : #if ROSE_PEDANTIC_ALLOC
  126275             :     ROSE_ASSERT(Size == sizeof(SgBinaryOp));
  126276             : #else
  126277           0 :     if (Size != sizeof(SgBinaryOp)) {
  126278           0 :       void * object = ROSE_MALLOC(Size);
  126279           0 :       ALLOC_MUTEX(SgBinaryOp, unlock);
  126280             :       return object;
  126281             :     }
  126282             : #endif
  126283             : 
  126284           0 :     if (SgBinaryOp::next_node == nullptr) {
  126285           0 :         SgBinaryOp * alloc = (SgBinaryOp*) ROSE_MALLOC ( SgBinaryOp::pool_size * sizeof(SgBinaryOp) );
  126286           0 :         ROSE_ASSERT(alloc != nullptr);
  126287             : 
  126288             : #if ROSE_ALLOC_TRACE == 2
  126289             : //        printf("SgBinaryOp::alloc\n  block[%zi] = [ %p , %p [\n", SgBinaryOp::pools.size(), alloc, alloc + SgBinaryOp::pool_size);
  126290             : #endif
  126291             : 
  126292             : #if ROSE_ALLOC_MEMSET == 1
  126293             : #elif ROSE_ALLOC_MEMSET == 2
  126294             :         memset(alloc, 0x00, SgBinaryOp::pool_size * sizeof(SgBinaryOp));
  126295             : #elif ROSE_ALLOC_MEMSET == 3
  126296             :         memset(alloc, 0xAA, SgBinaryOp::pool_size * sizeof(SgBinaryOp));
  126297             : #endif
  126298           0 :         for (unsigned i=0; i < SgBinaryOp::pool_size-1; i++) {
  126299           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
  126300             :         }
  126301           0 :         alloc[SgBinaryOp::pool_size-1].p_freepointer = nullptr;
  126302             : 
  126303           0 :         SgBinaryOp::pools.push_back ( (unsigned char *) alloc );
  126304           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgBinaryOp::pool_size * sizeof(SgBinaryOp), V_SgBinaryOp ) );
  126305           0 :         SgBinaryOp::next_node = alloc;
  126306             :     }
  126307           0 :     ROSE_ASSERT(SgBinaryOp::next_node != nullptr);
  126308             : 
  126309           0 :     SgBinaryOp * object = SgBinaryOp::next_node;
  126310           0 :     SgBinaryOp::next_node = (SgBinaryOp*)(object->p_freepointer);
  126311             : 
  126312             : #if ROSE_ALLOC_TRACE == 2
  126313             :     printf("SgBinaryOp::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgBinaryOp::next_node);
  126314             : #endif
  126315             : 
  126316           0 :     SgNode * fp = object->p_freepointer;
  126317             : #if ROSE_ALLOC_MEMSET == 1
  126318             : #elif ROSE_ALLOC_MEMSET == 2
  126319             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgBinaryOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  126320             : #elif ROSE_ALLOC_MEMSET == 3
  126321             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgBinaryOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  126322             : #endif
  126323           0 :     object->p_freepointer = fp;
  126324             : 
  126325             : #if ROSE_ALLOC_TRACE == 2
  126326             : //    printf("SgBinaryOp::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgBinaryOp::next_node);
  126327             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  126328             :     Rose::MemPool::snapshot(oss.str());
  126329             :     alloc_trace_cnt++;
  126330             : #endif
  126331             : 
  126332           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  126333             : 
  126334           0 :     ALLOC_MUTEX(SgBinaryOp, unlock);
  126335             : 
  126336             :     return object;
  126337             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  126338             : }
  126339             : 
  126340             : 
  126341             : 
  126342             : /*! \brief Delete operator for SgBinaryOp.
  126343             : 
  126344             :    This delete operator implements deallocation using memory pools to 
  126345             :    provide most efficent use of the heap within construction of large ASTs.
  126346             : 
  126347             : \internal The new and delete operators use the lower level C malloc/free
  126348             :    function calls for performance and to make sure that mixing of malloc/free
  126349             :    and new/delete by the used can be caught more readily.  This may change
  126350             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  126351             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  126352             :    deallocate memory allocated using ROSE_MALLOC.
  126353             : */
  126354           0 : void SgBinaryOp::operator delete(void *Pointer, size_t Size)
  126355             : {
  126356             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  126357             :      * or throwing an exception. */
  126358           0 :     ALLOC_MUTEX(SgBinaryOp, lock);
  126359             : 
  126360             : #if USE_CPP_NEW_DELETE_OPERATORS
  126361             :     ROSE_FREE(Pointer);
  126362             : #else
  126363             : #if ROSE_PEDANTIC_ALLOC
  126364             :     ROSE_ASSERT(Size == sizeof(SgBinaryOp));
  126365             : #else
  126366           0 :     if (Size != sizeof(SgBinaryOp)) {
  126367           0 :       ROSE_FREE(Pointer);
  126368           0 :       ALLOC_MUTEX(SgBinaryOp, unlock);
  126369             :       return;
  126370             :     }
  126371             : #endif
  126372             : 
  126373           0 :     SgBinaryOp * object = (SgBinaryOp*) Pointer;
  126374           0 :     ROSE_ASSERT(object != nullptr);
  126375             : 
  126376             : #if ROSE_ALLOC_TRACE == 2
  126377             : //  printf("SgBinaryOp::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgBinaryOp::next_node);
  126378             :     printf("SgBinaryOp::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgBinaryOp::next_node);
  126379             : #endif
  126380             : 
  126381             : #if ROSE_PEDANTIC_ALLOC
  126382             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  126383             : #endif
  126384             : 
  126385             : #if ROSE_ALLOC_MEMSET == 1
  126386             : #elif ROSE_ALLOC_MEMSET == 2
  126387             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgBinaryOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  126388             : #elif ROSE_ALLOC_MEMSET == 3
  126389             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgBinaryOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  126390             : #endif
  126391             : 
  126392             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  126393             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  126394             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  126395             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  126396             : #else
  126397           0 :     object->p_freepointer = SgBinaryOp::next_node;
  126398           0 :     SgBinaryOp::next_node = object;
  126399             : #endif
  126400             : 
  126401             : #if ROSE_ALLOC_TRACE == 2
  126402             : //  printf("SgBinaryOp::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgBinaryOp::next_node);
  126403             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  126404             :     Rose::MemPool::snapshot(oss.str());
  126405             :     alloc_trace_cnt++;
  126406             : #endif
  126407             : 
  126408             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  126409             : 
  126410           0 :     ALLOC_MUTEX(SgBinaryOp, unlock);
  126411             : }
  126412             : 
  126413             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  126414             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  126415             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  126416             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  126417             : // Also, note comment below from Robb (copied from the Common.code file).
  126418             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  126419             : //
  126420             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  126421             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  126422             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  126423             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  126424             : #if 0
  126425             : void SgBinaryOp::operator delete(void* pointer) { SgBinaryOp::operator delete (pointer, sizeof(SgBinaryOp)); };
  126426             : #endif
  126427             : /* #line 126428 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  126428             : 
  126429             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  126430             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  126431             : // obviously imply C++.
  126432             : 
  126433             : // This implements the support within ROSE for memory pools.  Memory pools
  126434             : // support the most condensed usage of memory within the construction of
  126435             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  126436             : // by a new operator written for each class.
  126437             : 
  126438             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  126439             :     // User wants multi-thread support and POSIX threads are available.
  126440             : #   include <pthread.h>
  126441             :     static pthread_mutex_t SgArrowExp_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  126442             : #else
  126443             :      // Cause synchronization to be skipped.
  126444             : #    ifndef ALLOC_MUTEX
  126445             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  126446             : #    endif
  126447             : #    ifdef _REENTRANT
  126448             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  126449             : #       ifdef _MSC_VER
  126450             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  126451             : #       else
  126452             : #           warning "POSIX threads are not available; synchronization being skipped"
  126453             : #       endif
  126454             : #    endif
  126455             : #endif
  126456             : 
  126457             : #ifndef ROSE_ALLOC_TRACE
  126458             : #  define ROSE_ALLOC_TRACE 0
  126459             : #endif
  126460             : 
  126461             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  126462             : #define ROSE_ALLOC_TRACE_CNT
  126463             : #include "memory-pool-snapshot.h"
  126464             : unsigned long alloc_trace_cnt = 0;
  126465             : #endif
  126466             : 
  126467             : #if ROSE_ALLOC_TRACE
  126468             : const unsigned SgArrowExp::pool_size = 5;
  126469             : #else
  126470             : const unsigned SgArrowExp::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  126471             : #endif
  126472             : 
  126473             : #ifndef ROSE_ALLOC_MEMSET
  126474             : #  define ROSE_ALLOC_MEMSET 0
  126475             : #endif
  126476             : 
  126477             : #ifndef ROSE_PEDANTIC_ALLOC
  126478             : #  define ROSE_PEDANTIC_ALLOC 0
  126479             : #endif
  126480             : 
  126481             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  126482             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  126483             : #endif
  126484             : 
  126485             : #if !defined(SGNODE__ALL_POOLS)
  126486             : #define SGNODE__ALL_POOLS
  126487             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  126488             : #endif
  126489             : 
  126490             : SgArrowExp* SgArrowExp::next_node = nullptr;
  126491             : std::vector<unsigned char*> SgArrowExp::pools;
  126492             : 
  126493             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  126494             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  126495             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  126496             : // around this macro definition rather than each use).
  126497             : #ifndef ALLOC_MUTEX
  126498             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  126499             :         do {                                                                     \
  126500             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  126501             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  126502             :                 abort();                                                         \
  126503             :             }                                                                    \
  126504             :         } while (0);
  126505             : #endif
  126506             : 
  126507             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  126508             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  126509             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  126510             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  126511             : 
  126512             : /*! \brief New operator for SgArrowExp.
  126513             : 
  126514             :    This new operator implements memory pools to provide most efficent 
  126515             :    use of the heap within construction of large ASTs.
  126516             : 
  126517             : \internal The new and delete operators use the lower level C malloc/free
  126518             :    function calls for performance and to make sure that mixing of malloc/free
  126519             :    and new/delete by the used can be caught more readily.  This may change
  126520             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  126521             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  126522             :    deallocate memory allocated using ROSE_MALLOC.
  126523             : */
  126524       13388 : void *SgArrowExp::operator new ( size_t Size )
  126525             : {
  126526             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  126527             :      * returning or throwing an exception. */
  126528       13388 :     ALLOC_MUTEX(SgArrowExp, lock);
  126529             : 
  126530             : #if ROSE_ALLOC_TRACE == 2
  126531             : //    printf("SgArrowExp::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgArrowExp::next_node);
  126532             : #endif
  126533             : 
  126534             : #if USE_CPP_NEW_DELETE_OPERATORS
  126535             :     void *mem = ROSE_MALLOC(Size);
  126536             :     ALLOC_MUTEX(SgArrowExp, unlock);
  126537             :     return mem;
  126538             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  126539             : #if ROSE_PEDANTIC_ALLOC
  126540             :     ROSE_ASSERT(Size == sizeof(SgArrowExp));
  126541             : #else
  126542       13388 :     if (Size != sizeof(SgArrowExp)) {
  126543           0 :       void * object = ROSE_MALLOC(Size);
  126544           0 :       ALLOC_MUTEX(SgArrowExp, unlock);
  126545             :       return object;
  126546             :     }
  126547             : #endif
  126548             : 
  126549       13388 :     if (SgArrowExp::next_node == nullptr) {
  126550          14 :         SgArrowExp * alloc = (SgArrowExp*) ROSE_MALLOC ( SgArrowExp::pool_size * sizeof(SgArrowExp) );
  126551          14 :         ROSE_ASSERT(alloc != nullptr);
  126552             : 
  126553             : #if ROSE_ALLOC_TRACE == 2
  126554             : //        printf("SgArrowExp::alloc\n  block[%zi] = [ %p , %p [\n", SgArrowExp::pools.size(), alloc, alloc + SgArrowExp::pool_size);
  126555             : #endif
  126556             : 
  126557             : #if ROSE_ALLOC_MEMSET == 1
  126558             : #elif ROSE_ALLOC_MEMSET == 2
  126559             :         memset(alloc, 0x00, SgArrowExp::pool_size * sizeof(SgArrowExp));
  126560             : #elif ROSE_ALLOC_MEMSET == 3
  126561             :         memset(alloc, 0xAA, SgArrowExp::pool_size * sizeof(SgArrowExp));
  126562             : #endif
  126563       28000 :         for (unsigned i=0; i < SgArrowExp::pool_size-1; i++) {
  126564       27986 :           alloc[i].p_freepointer = &(alloc[i+1]);
  126565             :         }
  126566          14 :         alloc[SgArrowExp::pool_size-1].p_freepointer = nullptr;
  126567             : 
  126568          14 :         SgArrowExp::pools.push_back ( (unsigned char *) alloc );
  126569          14 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgArrowExp::pool_size * sizeof(SgArrowExp), V_SgArrowExp ) );
  126570          14 :         SgArrowExp::next_node = alloc;
  126571             :     }
  126572       13388 :     ROSE_ASSERT(SgArrowExp::next_node != nullptr);
  126573             : 
  126574       13388 :     SgArrowExp * object = SgArrowExp::next_node;
  126575       13388 :     SgArrowExp::next_node = (SgArrowExp*)(object->p_freepointer);
  126576             : 
  126577             : #if ROSE_ALLOC_TRACE == 2
  126578             :     printf("SgArrowExp::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgArrowExp::next_node);
  126579             : #endif
  126580             : 
  126581       13388 :     SgNode * fp = object->p_freepointer;
  126582             : #if ROSE_ALLOC_MEMSET == 1
  126583             : #elif ROSE_ALLOC_MEMSET == 2
  126584             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgArrowExp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  126585             : #elif ROSE_ALLOC_MEMSET == 3
  126586             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgArrowExp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  126587             : #endif
  126588       13388 :     object->p_freepointer = fp;
  126589             : 
  126590             : #if ROSE_ALLOC_TRACE == 2
  126591             : //    printf("SgArrowExp::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgArrowExp::next_node);
  126592             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  126593             :     Rose::MemPool::snapshot(oss.str());
  126594             :     alloc_trace_cnt++;
  126595             : #endif
  126596             : 
  126597       13388 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  126598             : 
  126599       13388 :     ALLOC_MUTEX(SgArrowExp, unlock);
  126600             : 
  126601             :     return object;
  126602             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  126603             : }
  126604             : 
  126605             : 
  126606             : 
  126607             : /*! \brief Delete operator for SgArrowExp.
  126608             : 
  126609             :    This delete operator implements deallocation using memory pools to 
  126610             :    provide most efficent use of the heap within construction of large ASTs.
  126611             : 
  126612             : \internal The new and delete operators use the lower level C malloc/free
  126613             :    function calls for performance and to make sure that mixing of malloc/free
  126614             :    and new/delete by the used can be caught more readily.  This may change
  126615             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  126616             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  126617             :    deallocate memory allocated using ROSE_MALLOC.
  126618             : */
  126619        2634 : void SgArrowExp::operator delete(void *Pointer, size_t Size)
  126620             : {
  126621             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  126622             :      * or throwing an exception. */
  126623        2634 :     ALLOC_MUTEX(SgArrowExp, lock);
  126624             : 
  126625             : #if USE_CPP_NEW_DELETE_OPERATORS
  126626             :     ROSE_FREE(Pointer);
  126627             : #else
  126628             : #if ROSE_PEDANTIC_ALLOC
  126629             :     ROSE_ASSERT(Size == sizeof(SgArrowExp));
  126630             : #else
  126631        2634 :     if (Size != sizeof(SgArrowExp)) {
  126632           0 :       ROSE_FREE(Pointer);
  126633           0 :       ALLOC_MUTEX(SgArrowExp, unlock);
  126634             :       return;
  126635             :     }
  126636             : #endif
  126637             : 
  126638        2634 :     SgArrowExp * object = (SgArrowExp*) Pointer;
  126639        2634 :     ROSE_ASSERT(object != nullptr);
  126640             : 
  126641             : #if ROSE_ALLOC_TRACE == 2
  126642             : //  printf("SgArrowExp::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgArrowExp::next_node);
  126643             :     printf("SgArrowExp::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgArrowExp::next_node);
  126644             : #endif
  126645             : 
  126646             : #if ROSE_PEDANTIC_ALLOC
  126647             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  126648             : #endif
  126649             : 
  126650             : #if ROSE_ALLOC_MEMSET == 1
  126651             : #elif ROSE_ALLOC_MEMSET == 2
  126652             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgArrowExp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  126653             : #elif ROSE_ALLOC_MEMSET == 3
  126654             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgArrowExp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  126655             : #endif
  126656             : 
  126657             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  126658             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  126659             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  126660             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  126661             : #else
  126662        2634 :     object->p_freepointer = SgArrowExp::next_node;
  126663        2634 :     SgArrowExp::next_node = object;
  126664             : #endif
  126665             : 
  126666             : #if ROSE_ALLOC_TRACE == 2
  126667             : //  printf("SgArrowExp::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgArrowExp::next_node);
  126668             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  126669             :     Rose::MemPool::snapshot(oss.str());
  126670             :     alloc_trace_cnt++;
  126671             : #endif
  126672             : 
  126673             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  126674             : 
  126675        2634 :     ALLOC_MUTEX(SgArrowExp, unlock);
  126676             : }
  126677             : 
  126678             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  126679             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  126680             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  126681             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  126682             : // Also, note comment below from Robb (copied from the Common.code file).
  126683             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  126684             : //
  126685             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  126686             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  126687             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  126688             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  126689             : #if 0
  126690             : void SgArrowExp::operator delete(void* pointer) { SgArrowExp::operator delete (pointer, sizeof(SgArrowExp)); };
  126691             : #endif
  126692             : /* #line 126693 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  126693             : 
  126694             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  126695             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  126696             : // obviously imply C++.
  126697             : 
  126698             : // This implements the support within ROSE for memory pools.  Memory pools
  126699             : // support the most condensed usage of memory within the construction of
  126700             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  126701             : // by a new operator written for each class.
  126702             : 
  126703             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  126704             :     // User wants multi-thread support and POSIX threads are available.
  126705             : #   include <pthread.h>
  126706             :     static pthread_mutex_t SgDotExp_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  126707             : #else
  126708             :      // Cause synchronization to be skipped.
  126709             : #    ifndef ALLOC_MUTEX
  126710             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  126711             : #    endif
  126712             : #    ifdef _REENTRANT
  126713             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  126714             : #       ifdef _MSC_VER
  126715             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  126716             : #       else
  126717             : #           warning "POSIX threads are not available; synchronization being skipped"
  126718             : #       endif
  126719             : #    endif
  126720             : #endif
  126721             : 
  126722             : #ifndef ROSE_ALLOC_TRACE
  126723             : #  define ROSE_ALLOC_TRACE 0
  126724             : #endif
  126725             : 
  126726             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  126727             : #define ROSE_ALLOC_TRACE_CNT
  126728             : #include "memory-pool-snapshot.h"
  126729             : unsigned long alloc_trace_cnt = 0;
  126730             : #endif
  126731             : 
  126732             : #if ROSE_ALLOC_TRACE
  126733             : const unsigned SgDotExp::pool_size = 5;
  126734             : #else
  126735             : const unsigned SgDotExp::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  126736             : #endif
  126737             : 
  126738             : #ifndef ROSE_ALLOC_MEMSET
  126739             : #  define ROSE_ALLOC_MEMSET 0
  126740             : #endif
  126741             : 
  126742             : #ifndef ROSE_PEDANTIC_ALLOC
  126743             : #  define ROSE_PEDANTIC_ALLOC 0
  126744             : #endif
  126745             : 
  126746             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  126747             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  126748             : #endif
  126749             : 
  126750             : #if !defined(SGNODE__ALL_POOLS)
  126751             : #define SGNODE__ALL_POOLS
  126752             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  126753             : #endif
  126754             : 
  126755             : SgDotExp* SgDotExp::next_node = nullptr;
  126756             : std::vector<unsigned char*> SgDotExp::pools;
  126757             : 
  126758             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  126759             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  126760             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  126761             : // around this macro definition rather than each use).
  126762             : #ifndef ALLOC_MUTEX
  126763             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  126764             :         do {                                                                     \
  126765             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  126766             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  126767             :                 abort();                                                         \
  126768             :             }                                                                    \
  126769             :         } while (0);
  126770             : #endif
  126771             : 
  126772             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  126773             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  126774             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  126775             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  126776             : 
  126777             : /*! \brief New operator for SgDotExp.
  126778             : 
  126779             :    This new operator implements memory pools to provide most efficent 
  126780             :    use of the heap within construction of large ASTs.
  126781             : 
  126782             : \internal The new and delete operators use the lower level C malloc/free
  126783             :    function calls for performance and to make sure that mixing of malloc/free
  126784             :    and new/delete by the used can be caught more readily.  This may change
  126785             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  126786             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  126787             :    deallocate memory allocated using ROSE_MALLOC.
  126788             : */
  126789        9566 : void *SgDotExp::operator new ( size_t Size )
  126790             : {
  126791             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  126792             :      * returning or throwing an exception. */
  126793        9566 :     ALLOC_MUTEX(SgDotExp, lock);
  126794             : 
  126795             : #if ROSE_ALLOC_TRACE == 2
  126796             : //    printf("SgDotExp::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgDotExp::next_node);
  126797             : #endif
  126798             : 
  126799             : #if USE_CPP_NEW_DELETE_OPERATORS
  126800             :     void *mem = ROSE_MALLOC(Size);
  126801             :     ALLOC_MUTEX(SgDotExp, unlock);
  126802             :     return mem;
  126803             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  126804             : #if ROSE_PEDANTIC_ALLOC
  126805             :     ROSE_ASSERT(Size == sizeof(SgDotExp));
  126806             : #else
  126807        9566 :     if (Size != sizeof(SgDotExp)) {
  126808           0 :       void * object = ROSE_MALLOC(Size);
  126809           0 :       ALLOC_MUTEX(SgDotExp, unlock);
  126810             :       return object;
  126811             :     }
  126812             : #endif
  126813             : 
  126814        9566 :     if (SgDotExp::next_node == nullptr) {
  126815          27 :         SgDotExp * alloc = (SgDotExp*) ROSE_MALLOC ( SgDotExp::pool_size * sizeof(SgDotExp) );
  126816          27 :         ROSE_ASSERT(alloc != nullptr);
  126817             : 
  126818             : #if ROSE_ALLOC_TRACE == 2
  126819             : //        printf("SgDotExp::alloc\n  block[%zi] = [ %p , %p [\n", SgDotExp::pools.size(), alloc, alloc + SgDotExp::pool_size);
  126820             : #endif
  126821             : 
  126822             : #if ROSE_ALLOC_MEMSET == 1
  126823             : #elif ROSE_ALLOC_MEMSET == 2
  126824             :         memset(alloc, 0x00, SgDotExp::pool_size * sizeof(SgDotExp));
  126825             : #elif ROSE_ALLOC_MEMSET == 3
  126826             :         memset(alloc, 0xAA, SgDotExp::pool_size * sizeof(SgDotExp));
  126827             : #endif
  126828       54000 :         for (unsigned i=0; i < SgDotExp::pool_size-1; i++) {
  126829       53973 :           alloc[i].p_freepointer = &(alloc[i+1]);
  126830             :         }
  126831          27 :         alloc[SgDotExp::pool_size-1].p_freepointer = nullptr;
  126832             : 
  126833          27 :         SgDotExp::pools.push_back ( (unsigned char *) alloc );
  126834          27 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgDotExp::pool_size * sizeof(SgDotExp), V_SgDotExp ) );
  126835          27 :         SgDotExp::next_node = alloc;
  126836             :     }
  126837        9566 :     ROSE_ASSERT(SgDotExp::next_node != nullptr);
  126838             : 
  126839        9566 :     SgDotExp * object = SgDotExp::next_node;
  126840        9566 :     SgDotExp::next_node = (SgDotExp*)(object->p_freepointer);
  126841             : 
  126842             : #if ROSE_ALLOC_TRACE == 2
  126843             :     printf("SgDotExp::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgDotExp::next_node);
  126844             : #endif
  126845             : 
  126846        9566 :     SgNode * fp = object->p_freepointer;
  126847             : #if ROSE_ALLOC_MEMSET == 1
  126848             : #elif ROSE_ALLOC_MEMSET == 2
  126849             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgDotExp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  126850             : #elif ROSE_ALLOC_MEMSET == 3
  126851             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgDotExp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  126852             : #endif
  126853        9566 :     object->p_freepointer = fp;
  126854             : 
  126855             : #if ROSE_ALLOC_TRACE == 2
  126856             : //    printf("SgDotExp::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgDotExp::next_node);
  126857             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  126858             :     Rose::MemPool::snapshot(oss.str());
  126859             :     alloc_trace_cnt++;
  126860             : #endif
  126861             : 
  126862        9566 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  126863             : 
  126864        9566 :     ALLOC_MUTEX(SgDotExp, unlock);
  126865             : 
  126866             :     return object;
  126867             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  126868             : }
  126869             : 
  126870             : 
  126871             : 
  126872             : /*! \brief Delete operator for SgDotExp.
  126873             : 
  126874             :    This delete operator implements deallocation using memory pools to 
  126875             :    provide most efficent use of the heap within construction of large ASTs.
  126876             : 
  126877             : \internal The new and delete operators use the lower level C malloc/free
  126878             :    function calls for performance and to make sure that mixing of malloc/free
  126879             :    and new/delete by the used can be caught more readily.  This may change
  126880             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  126881             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  126882             :    deallocate memory allocated using ROSE_MALLOC.
  126883             : */
  126884        1657 : void SgDotExp::operator delete(void *Pointer, size_t Size)
  126885             : {
  126886             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  126887             :      * or throwing an exception. */
  126888        1657 :     ALLOC_MUTEX(SgDotExp, lock);
  126889             : 
  126890             : #if USE_CPP_NEW_DELETE_OPERATORS
  126891             :     ROSE_FREE(Pointer);
  126892             : #else
  126893             : #if ROSE_PEDANTIC_ALLOC
  126894             :     ROSE_ASSERT(Size == sizeof(SgDotExp));
  126895             : #else
  126896        1657 :     if (Size != sizeof(SgDotExp)) {
  126897           0 :       ROSE_FREE(Pointer);
  126898           0 :       ALLOC_MUTEX(SgDotExp, unlock);
  126899             :       return;
  126900             :     }
  126901             : #endif
  126902             : 
  126903        1657 :     SgDotExp * object = (SgDotExp*) Pointer;
  126904        1657 :     ROSE_ASSERT(object != nullptr);
  126905             : 
  126906             : #if ROSE_ALLOC_TRACE == 2
  126907             : //  printf("SgDotExp::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgDotExp::next_node);
  126908             :     printf("SgDotExp::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgDotExp::next_node);
  126909             : #endif
  126910             : 
  126911             : #if ROSE_PEDANTIC_ALLOC
  126912             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  126913             : #endif
  126914             : 
  126915             : #if ROSE_ALLOC_MEMSET == 1
  126916             : #elif ROSE_ALLOC_MEMSET == 2
  126917             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgDotExp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  126918             : #elif ROSE_ALLOC_MEMSET == 3
  126919             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgDotExp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  126920             : #endif
  126921             : 
  126922             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  126923             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  126924             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  126925             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  126926             : #else
  126927        1657 :     object->p_freepointer = SgDotExp::next_node;
  126928        1657 :     SgDotExp::next_node = object;
  126929             : #endif
  126930             : 
  126931             : #if ROSE_ALLOC_TRACE == 2
  126932             : //  printf("SgDotExp::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgDotExp::next_node);
  126933             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  126934             :     Rose::MemPool::snapshot(oss.str());
  126935             :     alloc_trace_cnt++;
  126936             : #endif
  126937             : 
  126938             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  126939             : 
  126940        1657 :     ALLOC_MUTEX(SgDotExp, unlock);
  126941             : }
  126942             : 
  126943             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  126944             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  126945             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  126946             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  126947             : // Also, note comment below from Robb (copied from the Common.code file).
  126948             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  126949             : //
  126950             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  126951             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  126952             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  126953             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  126954             : #if 0
  126955             : void SgDotExp::operator delete(void* pointer) { SgDotExp::operator delete (pointer, sizeof(SgDotExp)); };
  126956             : #endif
  126957             : /* #line 126958 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  126958             : 
  126959             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  126960             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  126961             : // obviously imply C++.
  126962             : 
  126963             : // This implements the support within ROSE for memory pools.  Memory pools
  126964             : // support the most condensed usage of memory within the construction of
  126965             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  126966             : // by a new operator written for each class.
  126967             : 
  126968             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  126969             :     // User wants multi-thread support and POSIX threads are available.
  126970             : #   include <pthread.h>
  126971             :     static pthread_mutex_t SgDotStarOp_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  126972             : #else
  126973             :      // Cause synchronization to be skipped.
  126974             : #    ifndef ALLOC_MUTEX
  126975             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  126976             : #    endif
  126977             : #    ifdef _REENTRANT
  126978             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  126979             : #       ifdef _MSC_VER
  126980             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  126981             : #       else
  126982             : #           warning "POSIX threads are not available; synchronization being skipped"
  126983             : #       endif
  126984             : #    endif
  126985             : #endif
  126986             : 
  126987             : #ifndef ROSE_ALLOC_TRACE
  126988             : #  define ROSE_ALLOC_TRACE 0
  126989             : #endif
  126990             : 
  126991             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  126992             : #define ROSE_ALLOC_TRACE_CNT
  126993             : #include "memory-pool-snapshot.h"
  126994             : unsigned long alloc_trace_cnt = 0;
  126995             : #endif
  126996             : 
  126997             : #if ROSE_ALLOC_TRACE
  126998             : const unsigned SgDotStarOp::pool_size = 5;
  126999             : #else
  127000             : const unsigned SgDotStarOp::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  127001             : #endif
  127002             : 
  127003             : #ifndef ROSE_ALLOC_MEMSET
  127004             : #  define ROSE_ALLOC_MEMSET 0
  127005             : #endif
  127006             : 
  127007             : #ifndef ROSE_PEDANTIC_ALLOC
  127008             : #  define ROSE_PEDANTIC_ALLOC 0
  127009             : #endif
  127010             : 
  127011             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  127012             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  127013             : #endif
  127014             : 
  127015             : #if !defined(SGNODE__ALL_POOLS)
  127016             : #define SGNODE__ALL_POOLS
  127017             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  127018             : #endif
  127019             : 
  127020             : SgDotStarOp* SgDotStarOp::next_node = nullptr;
  127021             : std::vector<unsigned char*> SgDotStarOp::pools;
  127022             : 
  127023             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  127024             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  127025             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  127026             : // around this macro definition rather than each use).
  127027             : #ifndef ALLOC_MUTEX
  127028             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  127029             :         do {                                                                     \
  127030             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  127031             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  127032             :                 abort();                                                         \
  127033             :             }                                                                    \
  127034             :         } while (0);
  127035             : #endif
  127036             : 
  127037             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  127038             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  127039             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  127040             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  127041             : 
  127042             : /*! \brief New operator for SgDotStarOp.
  127043             : 
  127044             :    This new operator implements memory pools to provide most efficent 
  127045             :    use of the heap within construction of large ASTs.
  127046             : 
  127047             : \internal The new and delete operators use the lower level C malloc/free
  127048             :    function calls for performance and to make sure that mixing of malloc/free
  127049             :    and new/delete by the used can be caught more readily.  This may change
  127050             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  127051             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  127052             :    deallocate memory allocated using ROSE_MALLOC.
  127053             : */
  127054         124 : void *SgDotStarOp::operator new ( size_t Size )
  127055             : {
  127056             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  127057             :      * returning or throwing an exception. */
  127058         124 :     ALLOC_MUTEX(SgDotStarOp, lock);
  127059             : 
  127060             : #if ROSE_ALLOC_TRACE == 2
  127061             : //    printf("SgDotStarOp::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgDotStarOp::next_node);
  127062             : #endif
  127063             : 
  127064             : #if USE_CPP_NEW_DELETE_OPERATORS
  127065             :     void *mem = ROSE_MALLOC(Size);
  127066             :     ALLOC_MUTEX(SgDotStarOp, unlock);
  127067             :     return mem;
  127068             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  127069             : #if ROSE_PEDANTIC_ALLOC
  127070             :     ROSE_ASSERT(Size == sizeof(SgDotStarOp));
  127071             : #else
  127072         124 :     if (Size != sizeof(SgDotStarOp)) {
  127073           0 :       void * object = ROSE_MALLOC(Size);
  127074           0 :       ALLOC_MUTEX(SgDotStarOp, unlock);
  127075             :       return object;
  127076             :     }
  127077             : #endif
  127078             : 
  127079         124 :     if (SgDotStarOp::next_node == nullptr) {
  127080          10 :         SgDotStarOp * alloc = (SgDotStarOp*) ROSE_MALLOC ( SgDotStarOp::pool_size * sizeof(SgDotStarOp) );
  127081          10 :         ROSE_ASSERT(alloc != nullptr);
  127082             : 
  127083             : #if ROSE_ALLOC_TRACE == 2
  127084             : //        printf("SgDotStarOp::alloc\n  block[%zi] = [ %p , %p [\n", SgDotStarOp::pools.size(), alloc, alloc + SgDotStarOp::pool_size);
  127085             : #endif
  127086             : 
  127087             : #if ROSE_ALLOC_MEMSET == 1
  127088             : #elif ROSE_ALLOC_MEMSET == 2
  127089             :         memset(alloc, 0x00, SgDotStarOp::pool_size * sizeof(SgDotStarOp));
  127090             : #elif ROSE_ALLOC_MEMSET == 3
  127091             :         memset(alloc, 0xAA, SgDotStarOp::pool_size * sizeof(SgDotStarOp));
  127092             : #endif
  127093       20000 :         for (unsigned i=0; i < SgDotStarOp::pool_size-1; i++) {
  127094       19990 :           alloc[i].p_freepointer = &(alloc[i+1]);
  127095             :         }
  127096          10 :         alloc[SgDotStarOp::pool_size-1].p_freepointer = nullptr;
  127097             : 
  127098          10 :         SgDotStarOp::pools.push_back ( (unsigned char *) alloc );
  127099          10 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgDotStarOp::pool_size * sizeof(SgDotStarOp), V_SgDotStarOp ) );
  127100          10 :         SgDotStarOp::next_node = alloc;
  127101             :     }
  127102         124 :     ROSE_ASSERT(SgDotStarOp::next_node != nullptr);
  127103             : 
  127104         124 :     SgDotStarOp * object = SgDotStarOp::next_node;
  127105         124 :     SgDotStarOp::next_node = (SgDotStarOp*)(object->p_freepointer);
  127106             : 
  127107             : #if ROSE_ALLOC_TRACE == 2
  127108             :     printf("SgDotStarOp::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgDotStarOp::next_node);
  127109             : #endif
  127110             : 
  127111         124 :     SgNode * fp = object->p_freepointer;
  127112             : #if ROSE_ALLOC_MEMSET == 1
  127113             : #elif ROSE_ALLOC_MEMSET == 2
  127114             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgDotStarOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  127115             : #elif ROSE_ALLOC_MEMSET == 3
  127116             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgDotStarOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  127117             : #endif
  127118         124 :     object->p_freepointer = fp;
  127119             : 
  127120             : #if ROSE_ALLOC_TRACE == 2
  127121             : //    printf("SgDotStarOp::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgDotStarOp::next_node);
  127122             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  127123             :     Rose::MemPool::snapshot(oss.str());
  127124             :     alloc_trace_cnt++;
  127125             : #endif
  127126             : 
  127127         124 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  127128             : 
  127129         124 :     ALLOC_MUTEX(SgDotStarOp, unlock);
  127130             : 
  127131             :     return object;
  127132             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  127133             : }
  127134             : 
  127135             : 
  127136             : 
  127137             : /*! \brief Delete operator for SgDotStarOp.
  127138             : 
  127139             :    This delete operator implements deallocation using memory pools to 
  127140             :    provide most efficent use of the heap within construction of large ASTs.
  127141             : 
  127142             : \internal The new and delete operators use the lower level C malloc/free
  127143             :    function calls for performance and to make sure that mixing of malloc/free
  127144             :    and new/delete by the used can be caught more readily.  This may change
  127145             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  127146             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  127147             :    deallocate memory allocated using ROSE_MALLOC.
  127148             : */
  127149          24 : void SgDotStarOp::operator delete(void *Pointer, size_t Size)
  127150             : {
  127151             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  127152             :      * or throwing an exception. */
  127153          24 :     ALLOC_MUTEX(SgDotStarOp, lock);
  127154             : 
  127155             : #if USE_CPP_NEW_DELETE_OPERATORS
  127156             :     ROSE_FREE(Pointer);
  127157             : #else
  127158             : #if ROSE_PEDANTIC_ALLOC
  127159             :     ROSE_ASSERT(Size == sizeof(SgDotStarOp));
  127160             : #else
  127161          24 :     if (Size != sizeof(SgDotStarOp)) {
  127162           0 :       ROSE_FREE(Pointer);
  127163           0 :       ALLOC_MUTEX(SgDotStarOp, unlock);
  127164             :       return;
  127165             :     }
  127166             : #endif
  127167             : 
  127168          24 :     SgDotStarOp * object = (SgDotStarOp*) Pointer;
  127169          24 :     ROSE_ASSERT(object != nullptr);
  127170             : 
  127171             : #if ROSE_ALLOC_TRACE == 2
  127172             : //  printf("SgDotStarOp::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgDotStarOp::next_node);
  127173             :     printf("SgDotStarOp::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgDotStarOp::next_node);
  127174             : #endif
  127175             : 
  127176             : #if ROSE_PEDANTIC_ALLOC
  127177             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  127178             : #endif
  127179             : 
  127180             : #if ROSE_ALLOC_MEMSET == 1
  127181             : #elif ROSE_ALLOC_MEMSET == 2
  127182             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgDotStarOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  127183             : #elif ROSE_ALLOC_MEMSET == 3
  127184             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgDotStarOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  127185             : #endif
  127186             : 
  127187             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  127188             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  127189             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  127190             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  127191             : #else
  127192          24 :     object->p_freepointer = SgDotStarOp::next_node;
  127193          24 :     SgDotStarOp::next_node = object;
  127194             : #endif
  127195             : 
  127196             : #if ROSE_ALLOC_TRACE == 2
  127197             : //  printf("SgDotStarOp::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgDotStarOp::next_node);
  127198             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  127199             :     Rose::MemPool::snapshot(oss.str());
  127200             :     alloc_trace_cnt++;
  127201             : #endif
  127202             : 
  127203             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  127204             : 
  127205          24 :     ALLOC_MUTEX(SgDotStarOp, unlock);
  127206             : }
  127207             : 
  127208             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  127209             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  127210             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  127211             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  127212             : // Also, note comment below from Robb (copied from the Common.code file).
  127213             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  127214             : //
  127215             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  127216             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  127217             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  127218             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  127219             : #if 0
  127220             : void SgDotStarOp::operator delete(void* pointer) { SgDotStarOp::operator delete (pointer, sizeof(SgDotStarOp)); };
  127221             : #endif
  127222             : /* #line 127223 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  127223             : 
  127224             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  127225             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  127226             : // obviously imply C++.
  127227             : 
  127228             : // This implements the support within ROSE for memory pools.  Memory pools
  127229             : // support the most condensed usage of memory within the construction of
  127230             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  127231             : // by a new operator written for each class.
  127232             : 
  127233             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  127234             :     // User wants multi-thread support and POSIX threads are available.
  127235             : #   include <pthread.h>
  127236             :     static pthread_mutex_t SgArrowStarOp_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  127237             : #else
  127238             :      // Cause synchronization to be skipped.
  127239             : #    ifndef ALLOC_MUTEX
  127240             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  127241             : #    endif
  127242             : #    ifdef _REENTRANT
  127243             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  127244             : #       ifdef _MSC_VER
  127245             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  127246             : #       else
  127247             : #           warning "POSIX threads are not available; synchronization being skipped"
  127248             : #       endif
  127249             : #    endif
  127250             : #endif
  127251             : 
  127252             : #ifndef ROSE_ALLOC_TRACE
  127253             : #  define ROSE_ALLOC_TRACE 0
  127254             : #endif
  127255             : 
  127256             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  127257             : #define ROSE_ALLOC_TRACE_CNT
  127258             : #include "memory-pool-snapshot.h"
  127259             : unsigned long alloc_trace_cnt = 0;
  127260             : #endif
  127261             : 
  127262             : #if ROSE_ALLOC_TRACE
  127263             : const unsigned SgArrowStarOp::pool_size = 5;
  127264             : #else
  127265             : const unsigned SgArrowStarOp::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  127266             : #endif
  127267             : 
  127268             : #ifndef ROSE_ALLOC_MEMSET
  127269             : #  define ROSE_ALLOC_MEMSET 0
  127270             : #endif
  127271             : 
  127272             : #ifndef ROSE_PEDANTIC_ALLOC
  127273             : #  define ROSE_PEDANTIC_ALLOC 0
  127274             : #endif
  127275             : 
  127276             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  127277             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  127278             : #endif
  127279             : 
  127280             : #if !defined(SGNODE__ALL_POOLS)
  127281             : #define SGNODE__ALL_POOLS
  127282             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  127283             : #endif
  127284             : 
  127285             : SgArrowStarOp* SgArrowStarOp::next_node = nullptr;
  127286             : std::vector<unsigned char*> SgArrowStarOp::pools;
  127287             : 
  127288             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  127289             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  127290             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  127291             : // around this macro definition rather than each use).
  127292             : #ifndef ALLOC_MUTEX
  127293             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  127294             :         do {                                                                     \
  127295             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  127296             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  127297             :                 abort();                                                         \
  127298             :             }                                                                    \
  127299             :         } while (0);
  127300             : #endif
  127301             : 
  127302             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  127303             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  127304             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  127305             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  127306             : 
  127307             : /*! \brief New operator for SgArrowStarOp.
  127308             : 
  127309             :    This new operator implements memory pools to provide most efficent 
  127310             :    use of the heap within construction of large ASTs.
  127311             : 
  127312             : \internal The new and delete operators use the lower level C malloc/free
  127313             :    function calls for performance and to make sure that mixing of malloc/free
  127314             :    and new/delete by the used can be caught more readily.  This may change
  127315             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  127316             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  127317             :    deallocate memory allocated using ROSE_MALLOC.
  127318             : */
  127319          36 : void *SgArrowStarOp::operator new ( size_t Size )
  127320             : {
  127321             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  127322             :      * returning or throwing an exception. */
  127323          36 :     ALLOC_MUTEX(SgArrowStarOp, lock);
  127324             : 
  127325             : #if ROSE_ALLOC_TRACE == 2
  127326             : //    printf("SgArrowStarOp::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgArrowStarOp::next_node);
  127327             : #endif
  127328             : 
  127329             : #if USE_CPP_NEW_DELETE_OPERATORS
  127330             :     void *mem = ROSE_MALLOC(Size);
  127331             :     ALLOC_MUTEX(SgArrowStarOp, unlock);
  127332             :     return mem;
  127333             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  127334             : #if ROSE_PEDANTIC_ALLOC
  127335             :     ROSE_ASSERT(Size == sizeof(SgArrowStarOp));
  127336             : #else
  127337          36 :     if (Size != sizeof(SgArrowStarOp)) {
  127338           0 :       void * object = ROSE_MALLOC(Size);
  127339           0 :       ALLOC_MUTEX(SgArrowStarOp, unlock);
  127340             :       return object;
  127341             :     }
  127342             : #endif
  127343             : 
  127344          36 :     if (SgArrowStarOp::next_node == nullptr) {
  127345           8 :         SgArrowStarOp * alloc = (SgArrowStarOp*) ROSE_MALLOC ( SgArrowStarOp::pool_size * sizeof(SgArrowStarOp) );
  127346           8 :         ROSE_ASSERT(alloc != nullptr);
  127347             : 
  127348             : #if ROSE_ALLOC_TRACE == 2
  127349             : //        printf("SgArrowStarOp::alloc\n  block[%zi] = [ %p , %p [\n", SgArrowStarOp::pools.size(), alloc, alloc + SgArrowStarOp::pool_size);
  127350             : #endif
  127351             : 
  127352             : #if ROSE_ALLOC_MEMSET == 1
  127353             : #elif ROSE_ALLOC_MEMSET == 2
  127354             :         memset(alloc, 0x00, SgArrowStarOp::pool_size * sizeof(SgArrowStarOp));
  127355             : #elif ROSE_ALLOC_MEMSET == 3
  127356             :         memset(alloc, 0xAA, SgArrowStarOp::pool_size * sizeof(SgArrowStarOp));
  127357             : #endif
  127358       16000 :         for (unsigned i=0; i < SgArrowStarOp::pool_size-1; i++) {
  127359       15992 :           alloc[i].p_freepointer = &(alloc[i+1]);
  127360             :         }
  127361           8 :         alloc[SgArrowStarOp::pool_size-1].p_freepointer = nullptr;
  127362             : 
  127363           8 :         SgArrowStarOp::pools.push_back ( (unsigned char *) alloc );
  127364           8 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgArrowStarOp::pool_size * sizeof(SgArrowStarOp), V_SgArrowStarOp ) );
  127365           8 :         SgArrowStarOp::next_node = alloc;
  127366             :     }
  127367          36 :     ROSE_ASSERT(SgArrowStarOp::next_node != nullptr);
  127368             : 
  127369          36 :     SgArrowStarOp * object = SgArrowStarOp::next_node;
  127370          36 :     SgArrowStarOp::next_node = (SgArrowStarOp*)(object->p_freepointer);
  127371             : 
  127372             : #if ROSE_ALLOC_TRACE == 2
  127373             :     printf("SgArrowStarOp::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgArrowStarOp::next_node);
  127374             : #endif
  127375             : 
  127376          36 :     SgNode * fp = object->p_freepointer;
  127377             : #if ROSE_ALLOC_MEMSET == 1
  127378             : #elif ROSE_ALLOC_MEMSET == 2
  127379             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgArrowStarOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  127380             : #elif ROSE_ALLOC_MEMSET == 3
  127381             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgArrowStarOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  127382             : #endif
  127383          36 :     object->p_freepointer = fp;
  127384             : 
  127385             : #if ROSE_ALLOC_TRACE == 2
  127386             : //    printf("SgArrowStarOp::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgArrowStarOp::next_node);
  127387             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  127388             :     Rose::MemPool::snapshot(oss.str());
  127389             :     alloc_trace_cnt++;
  127390             : #endif
  127391             : 
  127392          36 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  127393             : 
  127394          36 :     ALLOC_MUTEX(SgArrowStarOp, unlock);
  127395             : 
  127396             :     return object;
  127397             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  127398             : }
  127399             : 
  127400             : 
  127401             : 
  127402             : /*! \brief Delete operator for SgArrowStarOp.
  127403             : 
  127404             :    This delete operator implements deallocation using memory pools to 
  127405             :    provide most efficent use of the heap within construction of large ASTs.
  127406             : 
  127407             : \internal The new and delete operators use the lower level C malloc/free
  127408             :    function calls for performance and to make sure that mixing of malloc/free
  127409             :    and new/delete by the used can be caught more readily.  This may change
  127410             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  127411             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  127412             :    deallocate memory allocated using ROSE_MALLOC.
  127413             : */
  127414           8 : void SgArrowStarOp::operator delete(void *Pointer, size_t Size)
  127415             : {
  127416             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  127417             :      * or throwing an exception. */
  127418           8 :     ALLOC_MUTEX(SgArrowStarOp, lock);
  127419             : 
  127420             : #if USE_CPP_NEW_DELETE_OPERATORS
  127421             :     ROSE_FREE(Pointer);
  127422             : #else
  127423             : #if ROSE_PEDANTIC_ALLOC
  127424             :     ROSE_ASSERT(Size == sizeof(SgArrowStarOp));
  127425             : #else
  127426           8 :     if (Size != sizeof(SgArrowStarOp)) {
  127427           0 :       ROSE_FREE(Pointer);
  127428           0 :       ALLOC_MUTEX(SgArrowStarOp, unlock);
  127429             :       return;
  127430             :     }
  127431             : #endif
  127432             : 
  127433           8 :     SgArrowStarOp * object = (SgArrowStarOp*) Pointer;
  127434           8 :     ROSE_ASSERT(object != nullptr);
  127435             : 
  127436             : #if ROSE_ALLOC_TRACE == 2
  127437             : //  printf("SgArrowStarOp::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgArrowStarOp::next_node);
  127438             :     printf("SgArrowStarOp::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgArrowStarOp::next_node);
  127439             : #endif
  127440             : 
  127441             : #if ROSE_PEDANTIC_ALLOC
  127442             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  127443             : #endif
  127444             : 
  127445             : #if ROSE_ALLOC_MEMSET == 1
  127446             : #elif ROSE_ALLOC_MEMSET == 2
  127447             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgArrowStarOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  127448             : #elif ROSE_ALLOC_MEMSET == 3
  127449             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgArrowStarOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  127450             : #endif
  127451             : 
  127452             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  127453             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  127454             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  127455             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  127456             : #else
  127457           8 :     object->p_freepointer = SgArrowStarOp::next_node;
  127458           8 :     SgArrowStarOp::next_node = object;
  127459             : #endif
  127460             : 
  127461             : #if ROSE_ALLOC_TRACE == 2
  127462             : //  printf("SgArrowStarOp::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgArrowStarOp::next_node);
  127463             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  127464             :     Rose::MemPool::snapshot(oss.str());
  127465             :     alloc_trace_cnt++;
  127466             : #endif
  127467             : 
  127468             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  127469             : 
  127470           8 :     ALLOC_MUTEX(SgArrowStarOp, unlock);
  127471             : }
  127472             : 
  127473             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  127474             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  127475             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  127476             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  127477             : // Also, note comment below from Robb (copied from the Common.code file).
  127478             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  127479             : //
  127480             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  127481             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  127482             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  127483             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  127484             : #if 0
  127485             : void SgArrowStarOp::operator delete(void* pointer) { SgArrowStarOp::operator delete (pointer, sizeof(SgArrowStarOp)); };
  127486             : #endif
  127487             : /* #line 127488 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  127488             : 
  127489             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  127490             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  127491             : // obviously imply C++.
  127492             : 
  127493             : // This implements the support within ROSE for memory pools.  Memory pools
  127494             : // support the most condensed usage of memory within the construction of
  127495             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  127496             : // by a new operator written for each class.
  127497             : 
  127498             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  127499             :     // User wants multi-thread support and POSIX threads are available.
  127500             : #   include <pthread.h>
  127501             :     static pthread_mutex_t SgEqualityOp_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  127502             : #else
  127503             :      // Cause synchronization to be skipped.
  127504             : #    ifndef ALLOC_MUTEX
  127505             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  127506             : #    endif
  127507             : #    ifdef _REENTRANT
  127508             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  127509             : #       ifdef _MSC_VER
  127510             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  127511             : #       else
  127512             : #           warning "POSIX threads are not available; synchronization being skipped"
  127513             : #       endif
  127514             : #    endif
  127515             : #endif
  127516             : 
  127517             : #ifndef ROSE_ALLOC_TRACE
  127518             : #  define ROSE_ALLOC_TRACE 0
  127519             : #endif
  127520             : 
  127521             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  127522             : #define ROSE_ALLOC_TRACE_CNT
  127523             : #include "memory-pool-snapshot.h"
  127524             : unsigned long alloc_trace_cnt = 0;
  127525             : #endif
  127526             : 
  127527             : #if ROSE_ALLOC_TRACE
  127528             : const unsigned SgEqualityOp::pool_size = 5;
  127529             : #else
  127530             : const unsigned SgEqualityOp::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  127531             : #endif
  127532             : 
  127533             : #ifndef ROSE_ALLOC_MEMSET
  127534             : #  define ROSE_ALLOC_MEMSET 0
  127535             : #endif
  127536             : 
  127537             : #ifndef ROSE_PEDANTIC_ALLOC
  127538             : #  define ROSE_PEDANTIC_ALLOC 0
  127539             : #endif
  127540             : 
  127541             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  127542             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  127543             : #endif
  127544             : 
  127545             : #if !defined(SGNODE__ALL_POOLS)
  127546             : #define SGNODE__ALL_POOLS
  127547             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  127548             : #endif
  127549             : 
  127550             : SgEqualityOp* SgEqualityOp::next_node = nullptr;
  127551             : std::vector<unsigned char*> SgEqualityOp::pools;
  127552             : 
  127553             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  127554             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  127555             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  127556             : // around this macro definition rather than each use).
  127557             : #ifndef ALLOC_MUTEX
  127558             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  127559             :         do {                                                                     \
  127560             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  127561             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  127562             :                 abort();                                                         \
  127563             :             }                                                                    \
  127564             :         } while (0);
  127565             : #endif
  127566             : 
  127567             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  127568             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  127569             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  127570             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  127571             : 
  127572             : /*! \brief New operator for SgEqualityOp.
  127573             : 
  127574             :    This new operator implements memory pools to provide most efficent 
  127575             :    use of the heap within construction of large ASTs.
  127576             : 
  127577             : \internal The new and delete operators use the lower level C malloc/free
  127578             :    function calls for performance and to make sure that mixing of malloc/free
  127579             :    and new/delete by the used can be caught more readily.  This may change
  127580             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  127581             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  127582             :    deallocate memory allocated using ROSE_MALLOC.
  127583             : */
  127584        2971 : void *SgEqualityOp::operator new ( size_t Size )
  127585             : {
  127586             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  127587             :      * returning or throwing an exception. */
  127588        2971 :     ALLOC_MUTEX(SgEqualityOp, lock);
  127589             : 
  127590             : #if ROSE_ALLOC_TRACE == 2
  127591             : //    printf("SgEqualityOp::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgEqualityOp::next_node);
  127592             : #endif
  127593             : 
  127594             : #if USE_CPP_NEW_DELETE_OPERATORS
  127595             :     void *mem = ROSE_MALLOC(Size);
  127596             :     ALLOC_MUTEX(SgEqualityOp, unlock);
  127597             :     return mem;
  127598             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  127599             : #if ROSE_PEDANTIC_ALLOC
  127600             :     ROSE_ASSERT(Size == sizeof(SgEqualityOp));
  127601             : #else
  127602        2971 :     if (Size != sizeof(SgEqualityOp)) {
  127603           0 :       void * object = ROSE_MALLOC(Size);
  127604           0 :       ALLOC_MUTEX(SgEqualityOp, unlock);
  127605             :       return object;
  127606             :     }
  127607             : #endif
  127608             : 
  127609        2971 :     if (SgEqualityOp::next_node == nullptr) {
  127610          85 :         SgEqualityOp * alloc = (SgEqualityOp*) ROSE_MALLOC ( SgEqualityOp::pool_size * sizeof(SgEqualityOp) );
  127611          85 :         ROSE_ASSERT(alloc != nullptr);
  127612             : 
  127613             : #if ROSE_ALLOC_TRACE == 2
  127614             : //        printf("SgEqualityOp::alloc\n  block[%zi] = [ %p , %p [\n", SgEqualityOp::pools.size(), alloc, alloc + SgEqualityOp::pool_size);
  127615             : #endif
  127616             : 
  127617             : #if ROSE_ALLOC_MEMSET == 1
  127618             : #elif ROSE_ALLOC_MEMSET == 2
  127619             :         memset(alloc, 0x00, SgEqualityOp::pool_size * sizeof(SgEqualityOp));
  127620             : #elif ROSE_ALLOC_MEMSET == 3
  127621             :         memset(alloc, 0xAA, SgEqualityOp::pool_size * sizeof(SgEqualityOp));
  127622             : #endif
  127623      170000 :         for (unsigned i=0; i < SgEqualityOp::pool_size-1; i++) {
  127624      169915 :           alloc[i].p_freepointer = &(alloc[i+1]);
  127625             :         }
  127626          85 :         alloc[SgEqualityOp::pool_size-1].p_freepointer = nullptr;
  127627             : 
  127628          85 :         SgEqualityOp::pools.push_back ( (unsigned char *) alloc );
  127629          85 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgEqualityOp::pool_size * sizeof(SgEqualityOp), V_SgEqualityOp ) );
  127630          85 :         SgEqualityOp::next_node = alloc;
  127631             :     }
  127632        2971 :     ROSE_ASSERT(SgEqualityOp::next_node != nullptr);
  127633             : 
  127634        2971 :     SgEqualityOp * object = SgEqualityOp::next_node;
  127635        2971 :     SgEqualityOp::next_node = (SgEqualityOp*)(object->p_freepointer);
  127636             : 
  127637             : #if ROSE_ALLOC_TRACE == 2
  127638             :     printf("SgEqualityOp::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgEqualityOp::next_node);
  127639             : #endif
  127640             : 
  127641        2971 :     SgNode * fp = object->p_freepointer;
  127642             : #if ROSE_ALLOC_MEMSET == 1
  127643             : #elif ROSE_ALLOC_MEMSET == 2
  127644             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgEqualityOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  127645             : #elif ROSE_ALLOC_MEMSET == 3
  127646             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgEqualityOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  127647             : #endif
  127648        2971 :     object->p_freepointer = fp;
  127649             : 
  127650             : #if ROSE_ALLOC_TRACE == 2
  127651             : //    printf("SgEqualityOp::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgEqualityOp::next_node);
  127652             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  127653             :     Rose::MemPool::snapshot(oss.str());
  127654             :     alloc_trace_cnt++;
  127655             : #endif
  127656             : 
  127657        2971 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  127658             : 
  127659        2971 :     ALLOC_MUTEX(SgEqualityOp, unlock);
  127660             : 
  127661             :     return object;
  127662             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  127663             : }
  127664             : 
  127665             : 
  127666             : 
  127667             : /*! \brief Delete operator for SgEqualityOp.
  127668             : 
  127669             :    This delete operator implements deallocation using memory pools to 
  127670             :    provide most efficent use of the heap within construction of large ASTs.
  127671             : 
  127672             : \internal The new and delete operators use the lower level C malloc/free
  127673             :    function calls for performance and to make sure that mixing of malloc/free
  127674             :    and new/delete by the used can be caught more readily.  This may change
  127675             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  127676             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  127677             :    deallocate memory allocated using ROSE_MALLOC.
  127678             : */
  127679         528 : void SgEqualityOp::operator delete(void *Pointer, size_t Size)
  127680             : {
  127681             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  127682             :      * or throwing an exception. */
  127683         528 :     ALLOC_MUTEX(SgEqualityOp, lock);
  127684             : 
  127685             : #if USE_CPP_NEW_DELETE_OPERATORS
  127686             :     ROSE_FREE(Pointer);
  127687             : #else
  127688             : #if ROSE_PEDANTIC_ALLOC
  127689             :     ROSE_ASSERT(Size == sizeof(SgEqualityOp));
  127690             : #else
  127691         528 :     if (Size != sizeof(SgEqualityOp)) {
  127692           0 :       ROSE_FREE(Pointer);
  127693           0 :       ALLOC_MUTEX(SgEqualityOp, unlock);
  127694             :       return;
  127695             :     }
  127696             : #endif
  127697             : 
  127698         528 :     SgEqualityOp * object = (SgEqualityOp*) Pointer;
  127699         528 :     ROSE_ASSERT(object != nullptr);
  127700             : 
  127701             : #if ROSE_ALLOC_TRACE == 2
  127702             : //  printf("SgEqualityOp::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgEqualityOp::next_node);
  127703             :     printf("SgEqualityOp::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgEqualityOp::next_node);
  127704             : #endif
  127705             : 
  127706             : #if ROSE_PEDANTIC_ALLOC
  127707             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  127708             : #endif
  127709             : 
  127710             : #if ROSE_ALLOC_MEMSET == 1
  127711             : #elif ROSE_ALLOC_MEMSET == 2
  127712             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgEqualityOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  127713             : #elif ROSE_ALLOC_MEMSET == 3
  127714             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgEqualityOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  127715             : #endif
  127716             : 
  127717             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  127718             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  127719             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  127720             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  127721             : #else
  127722         528 :     object->p_freepointer = SgEqualityOp::next_node;
  127723         528 :     SgEqualityOp::next_node = object;
  127724             : #endif
  127725             : 
  127726             : #if ROSE_ALLOC_TRACE == 2
  127727             : //  printf("SgEqualityOp::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgEqualityOp::next_node);
  127728             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  127729             :     Rose::MemPool::snapshot(oss.str());
  127730             :     alloc_trace_cnt++;
  127731             : #endif
  127732             : 
  127733             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  127734             : 
  127735         528 :     ALLOC_MUTEX(SgEqualityOp, unlock);
  127736             : }
  127737             : 
  127738             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  127739             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  127740             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  127741             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  127742             : // Also, note comment below from Robb (copied from the Common.code file).
  127743             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  127744             : //
  127745             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  127746             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  127747             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  127748             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  127749             : #if 0
  127750             : void SgEqualityOp::operator delete(void* pointer) { SgEqualityOp::operator delete (pointer, sizeof(SgEqualityOp)); };
  127751             : #endif
  127752             : /* #line 127753 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  127753             : 
  127754             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  127755             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  127756             : // obviously imply C++.
  127757             : 
  127758             : // This implements the support within ROSE for memory pools.  Memory pools
  127759             : // support the most condensed usage of memory within the construction of
  127760             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  127761             : // by a new operator written for each class.
  127762             : 
  127763             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  127764             :     // User wants multi-thread support and POSIX threads are available.
  127765             : #   include <pthread.h>
  127766             :     static pthread_mutex_t SgLessThanOp_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  127767             : #else
  127768             :      // Cause synchronization to be skipped.
  127769             : #    ifndef ALLOC_MUTEX
  127770             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  127771             : #    endif
  127772             : #    ifdef _REENTRANT
  127773             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  127774             : #       ifdef _MSC_VER
  127775             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  127776             : #       else
  127777             : #           warning "POSIX threads are not available; synchronization being skipped"
  127778             : #       endif
  127779             : #    endif
  127780             : #endif
  127781             : 
  127782             : #ifndef ROSE_ALLOC_TRACE
  127783             : #  define ROSE_ALLOC_TRACE 0
  127784             : #endif
  127785             : 
  127786             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  127787             : #define ROSE_ALLOC_TRACE_CNT
  127788             : #include "memory-pool-snapshot.h"
  127789             : unsigned long alloc_trace_cnt = 0;
  127790             : #endif
  127791             : 
  127792             : #if ROSE_ALLOC_TRACE
  127793             : const unsigned SgLessThanOp::pool_size = 5;
  127794             : #else
  127795             : const unsigned SgLessThanOp::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  127796             : #endif
  127797             : 
  127798             : #ifndef ROSE_ALLOC_MEMSET
  127799             : #  define ROSE_ALLOC_MEMSET 0
  127800             : #endif
  127801             : 
  127802             : #ifndef ROSE_PEDANTIC_ALLOC
  127803             : #  define ROSE_PEDANTIC_ALLOC 0
  127804             : #endif
  127805             : 
  127806             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  127807             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  127808             : #endif
  127809             : 
  127810             : #if !defined(SGNODE__ALL_POOLS)
  127811             : #define SGNODE__ALL_POOLS
  127812             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  127813             : #endif
  127814             : 
  127815             : SgLessThanOp* SgLessThanOp::next_node = nullptr;
  127816             : std::vector<unsigned char*> SgLessThanOp::pools;
  127817             : 
  127818             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  127819             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  127820             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  127821             : // around this macro definition rather than each use).
  127822             : #ifndef ALLOC_MUTEX
  127823             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  127824             :         do {                                                                     \
  127825             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  127826             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  127827             :                 abort();                                                         \
  127828             :             }                                                                    \
  127829             :         } while (0);
  127830             : #endif
  127831             : 
  127832             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  127833             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  127834             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  127835             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  127836             : 
  127837             : /*! \brief New operator for SgLessThanOp.
  127838             : 
  127839             :    This new operator implements memory pools to provide most efficent 
  127840             :    use of the heap within construction of large ASTs.
  127841             : 
  127842             : \internal The new and delete operators use the lower level C malloc/free
  127843             :    function calls for performance and to make sure that mixing of malloc/free
  127844             :    and new/delete by the used can be caught more readily.  This may change
  127845             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  127846             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  127847             :    deallocate memory allocated using ROSE_MALLOC.
  127848             : */
  127849        2860 : void *SgLessThanOp::operator new ( size_t Size )
  127850             : {
  127851             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  127852             :      * returning or throwing an exception. */
  127853        2860 :     ALLOC_MUTEX(SgLessThanOp, lock);
  127854             : 
  127855             : #if ROSE_ALLOC_TRACE == 2
  127856             : //    printf("SgLessThanOp::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgLessThanOp::next_node);
  127857             : #endif
  127858             : 
  127859             : #if USE_CPP_NEW_DELETE_OPERATORS
  127860             :     void *mem = ROSE_MALLOC(Size);
  127861             :     ALLOC_MUTEX(SgLessThanOp, unlock);
  127862             :     return mem;
  127863             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  127864             : #if ROSE_PEDANTIC_ALLOC
  127865             :     ROSE_ASSERT(Size == sizeof(SgLessThanOp));
  127866             : #else
  127867        2860 :     if (Size != sizeof(SgLessThanOp)) {
  127868           0 :       void * object = ROSE_MALLOC(Size);
  127869           0 :       ALLOC_MUTEX(SgLessThanOp, unlock);
  127870             :       return object;
  127871             :     }
  127872             : #endif
  127873             : 
  127874        2860 :     if (SgLessThanOp::next_node == nullptr) {
  127875         157 :         SgLessThanOp * alloc = (SgLessThanOp*) ROSE_MALLOC ( SgLessThanOp::pool_size * sizeof(SgLessThanOp) );
  127876         157 :         ROSE_ASSERT(alloc != nullptr);
  127877             : 
  127878             : #if ROSE_ALLOC_TRACE == 2
  127879             : //        printf("SgLessThanOp::alloc\n  block[%zi] = [ %p , %p [\n", SgLessThanOp::pools.size(), alloc, alloc + SgLessThanOp::pool_size);
  127880             : #endif
  127881             : 
  127882             : #if ROSE_ALLOC_MEMSET == 1
  127883             : #elif ROSE_ALLOC_MEMSET == 2
  127884             :         memset(alloc, 0x00, SgLessThanOp::pool_size * sizeof(SgLessThanOp));
  127885             : #elif ROSE_ALLOC_MEMSET == 3
  127886             :         memset(alloc, 0xAA, SgLessThanOp::pool_size * sizeof(SgLessThanOp));
  127887             : #endif
  127888      314000 :         for (unsigned i=0; i < SgLessThanOp::pool_size-1; i++) {
  127889      313843 :           alloc[i].p_freepointer = &(alloc[i+1]);
  127890             :         }
  127891         157 :         alloc[SgLessThanOp::pool_size-1].p_freepointer = nullptr;
  127892             : 
  127893         157 :         SgLessThanOp::pools.push_back ( (unsigned char *) alloc );
  127894         157 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgLessThanOp::pool_size * sizeof(SgLessThanOp), V_SgLessThanOp ) );
  127895         157 :         SgLessThanOp::next_node = alloc;
  127896             :     }
  127897        2860 :     ROSE_ASSERT(SgLessThanOp::next_node != nullptr);
  127898             : 
  127899        2860 :     SgLessThanOp * object = SgLessThanOp::next_node;
  127900        2860 :     SgLessThanOp::next_node = (SgLessThanOp*)(object->p_freepointer);
  127901             : 
  127902             : #if ROSE_ALLOC_TRACE == 2
  127903             :     printf("SgLessThanOp::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgLessThanOp::next_node);
  127904             : #endif
  127905             : 
  127906        2860 :     SgNode * fp = object->p_freepointer;
  127907             : #if ROSE_ALLOC_MEMSET == 1
  127908             : #elif ROSE_ALLOC_MEMSET == 2
  127909             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgLessThanOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  127910             : #elif ROSE_ALLOC_MEMSET == 3
  127911             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgLessThanOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  127912             : #endif
  127913        2860 :     object->p_freepointer = fp;
  127914             : 
  127915             : #if ROSE_ALLOC_TRACE == 2
  127916             : //    printf("SgLessThanOp::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgLessThanOp::next_node);
  127917             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  127918             :     Rose::MemPool::snapshot(oss.str());
  127919             :     alloc_trace_cnt++;
  127920             : #endif
  127921             : 
  127922        2860 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  127923             : 
  127924        2860 :     ALLOC_MUTEX(SgLessThanOp, unlock);
  127925             : 
  127926             :     return object;
  127927             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  127928             : }
  127929             : 
  127930             : 
  127931             : 
  127932             : /*! \brief Delete operator for SgLessThanOp.
  127933             : 
  127934             :    This delete operator implements deallocation using memory pools to 
  127935             :    provide most efficent use of the heap within construction of large ASTs.
  127936             : 
  127937             : \internal The new and delete operators use the lower level C malloc/free
  127938             :    function calls for performance and to make sure that mixing of malloc/free
  127939             :    and new/delete by the used can be caught more readily.  This may change
  127940             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  127941             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  127942             :    deallocate memory allocated using ROSE_MALLOC.
  127943             : */
  127944        1177 : void SgLessThanOp::operator delete(void *Pointer, size_t Size)
  127945             : {
  127946             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  127947             :      * or throwing an exception. */
  127948        1177 :     ALLOC_MUTEX(SgLessThanOp, lock);
  127949             : 
  127950             : #if USE_CPP_NEW_DELETE_OPERATORS
  127951             :     ROSE_FREE(Pointer);
  127952             : #else
  127953             : #if ROSE_PEDANTIC_ALLOC
  127954             :     ROSE_ASSERT(Size == sizeof(SgLessThanOp));
  127955             : #else
  127956        1177 :     if (Size != sizeof(SgLessThanOp)) {
  127957           0 :       ROSE_FREE(Pointer);
  127958           0 :       ALLOC_MUTEX(SgLessThanOp, unlock);
  127959             :       return;
  127960             :     }
  127961             : #endif
  127962             : 
  127963        1177 :     SgLessThanOp * object = (SgLessThanOp*) Pointer;
  127964        1177 :     ROSE_ASSERT(object != nullptr);
  127965             : 
  127966             : #if ROSE_ALLOC_TRACE == 2
  127967             : //  printf("SgLessThanOp::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgLessThanOp::next_node);
  127968             :     printf("SgLessThanOp::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgLessThanOp::next_node);
  127969             : #endif
  127970             : 
  127971             : #if ROSE_PEDANTIC_ALLOC
  127972             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  127973             : #endif
  127974             : 
  127975             : #if ROSE_ALLOC_MEMSET == 1
  127976             : #elif ROSE_ALLOC_MEMSET == 2
  127977             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgLessThanOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  127978             : #elif ROSE_ALLOC_MEMSET == 3
  127979             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgLessThanOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  127980             : #endif
  127981             : 
  127982             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  127983             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  127984             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  127985             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  127986             : #else
  127987        1177 :     object->p_freepointer = SgLessThanOp::next_node;
  127988        1177 :     SgLessThanOp::next_node = object;
  127989             : #endif
  127990             : 
  127991             : #if ROSE_ALLOC_TRACE == 2
  127992             : //  printf("SgLessThanOp::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgLessThanOp::next_node);
  127993             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  127994             :     Rose::MemPool::snapshot(oss.str());
  127995             :     alloc_trace_cnt++;
  127996             : #endif
  127997             : 
  127998             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  127999             : 
  128000        1177 :     ALLOC_MUTEX(SgLessThanOp, unlock);
  128001             : }
  128002             : 
  128003             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  128004             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  128005             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  128006             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  128007             : // Also, note comment below from Robb (copied from the Common.code file).
  128008             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  128009             : //
  128010             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  128011             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  128012             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  128013             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  128014             : #if 0
  128015             : void SgLessThanOp::operator delete(void* pointer) { SgLessThanOp::operator delete (pointer, sizeof(SgLessThanOp)); };
  128016             : #endif
  128017             : /* #line 128018 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  128018             : 
  128019             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  128020             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  128021             : // obviously imply C++.
  128022             : 
  128023             : // This implements the support within ROSE for memory pools.  Memory pools
  128024             : // support the most condensed usage of memory within the construction of
  128025             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  128026             : // by a new operator written for each class.
  128027             : 
  128028             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  128029             :     // User wants multi-thread support and POSIX threads are available.
  128030             : #   include <pthread.h>
  128031             :     static pthread_mutex_t SgGreaterThanOp_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  128032             : #else
  128033             :      // Cause synchronization to be skipped.
  128034             : #    ifndef ALLOC_MUTEX
  128035             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  128036             : #    endif
  128037             : #    ifdef _REENTRANT
  128038             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  128039             : #       ifdef _MSC_VER
  128040             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  128041             : #       else
  128042             : #           warning "POSIX threads are not available; synchronization being skipped"
  128043             : #       endif
  128044             : #    endif
  128045             : #endif
  128046             : 
  128047             : #ifndef ROSE_ALLOC_TRACE
  128048             : #  define ROSE_ALLOC_TRACE 0
  128049             : #endif
  128050             : 
  128051             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  128052             : #define ROSE_ALLOC_TRACE_CNT
  128053             : #include "memory-pool-snapshot.h"
  128054             : unsigned long alloc_trace_cnt = 0;
  128055             : #endif
  128056             : 
  128057             : #if ROSE_ALLOC_TRACE
  128058             : const unsigned SgGreaterThanOp::pool_size = 5;
  128059             : #else
  128060             : const unsigned SgGreaterThanOp::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  128061             : #endif
  128062             : 
  128063             : #ifndef ROSE_ALLOC_MEMSET
  128064             : #  define ROSE_ALLOC_MEMSET 0
  128065             : #endif
  128066             : 
  128067             : #ifndef ROSE_PEDANTIC_ALLOC
  128068             : #  define ROSE_PEDANTIC_ALLOC 0
  128069             : #endif
  128070             : 
  128071             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  128072             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  128073             : #endif
  128074             : 
  128075             : #if !defined(SGNODE__ALL_POOLS)
  128076             : #define SGNODE__ALL_POOLS
  128077             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  128078             : #endif
  128079             : 
  128080             : SgGreaterThanOp* SgGreaterThanOp::next_node = nullptr;
  128081             : std::vector<unsigned char*> SgGreaterThanOp::pools;
  128082             : 
  128083             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  128084             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  128085             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  128086             : // around this macro definition rather than each use).
  128087             : #ifndef ALLOC_MUTEX
  128088             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  128089             :         do {                                                                     \
  128090             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  128091             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  128092             :                 abort();                                                         \
  128093             :             }                                                                    \
  128094             :         } while (0);
  128095             : #endif
  128096             : 
  128097             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  128098             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  128099             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  128100             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  128101             : 
  128102             : /*! \brief New operator for SgGreaterThanOp.
  128103             : 
  128104             :    This new operator implements memory pools to provide most efficent 
  128105             :    use of the heap within construction of large ASTs.
  128106             : 
  128107             : \internal The new and delete operators use the lower level C malloc/free
  128108             :    function calls for performance and to make sure that mixing of malloc/free
  128109             :    and new/delete by the used can be caught more readily.  This may change
  128110             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  128111             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  128112             :    deallocate memory allocated using ROSE_MALLOC.
  128113             : */
  128114        1289 : void *SgGreaterThanOp::operator new ( size_t Size )
  128115             : {
  128116             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  128117             :      * returning or throwing an exception. */
  128118        1289 :     ALLOC_MUTEX(SgGreaterThanOp, lock);
  128119             : 
  128120             : #if ROSE_ALLOC_TRACE == 2
  128121             : //    printf("SgGreaterThanOp::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgGreaterThanOp::next_node);
  128122             : #endif
  128123             : 
  128124             : #if USE_CPP_NEW_DELETE_OPERATORS
  128125             :     void *mem = ROSE_MALLOC(Size);
  128126             :     ALLOC_MUTEX(SgGreaterThanOp, unlock);
  128127             :     return mem;
  128128             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  128129             : #if ROSE_PEDANTIC_ALLOC
  128130             :     ROSE_ASSERT(Size == sizeof(SgGreaterThanOp));
  128131             : #else
  128132        1289 :     if (Size != sizeof(SgGreaterThanOp)) {
  128133           0 :       void * object = ROSE_MALLOC(Size);
  128134           0 :       ALLOC_MUTEX(SgGreaterThanOp, unlock);
  128135             :       return object;
  128136             :     }
  128137             : #endif
  128138             : 
  128139        1289 :     if (SgGreaterThanOp::next_node == nullptr) {
  128140          35 :         SgGreaterThanOp * alloc = (SgGreaterThanOp*) ROSE_MALLOC ( SgGreaterThanOp::pool_size * sizeof(SgGreaterThanOp) );
  128141          35 :         ROSE_ASSERT(alloc != nullptr);
  128142             : 
  128143             : #if ROSE_ALLOC_TRACE == 2
  128144             : //        printf("SgGreaterThanOp::alloc\n  block[%zi] = [ %p , %p [\n", SgGreaterThanOp::pools.size(), alloc, alloc + SgGreaterThanOp::pool_size);
  128145             : #endif
  128146             : 
  128147             : #if ROSE_ALLOC_MEMSET == 1
  128148             : #elif ROSE_ALLOC_MEMSET == 2
  128149             :         memset(alloc, 0x00, SgGreaterThanOp::pool_size * sizeof(SgGreaterThanOp));
  128150             : #elif ROSE_ALLOC_MEMSET == 3
  128151             :         memset(alloc, 0xAA, SgGreaterThanOp::pool_size * sizeof(SgGreaterThanOp));
  128152             : #endif
  128153       70000 :         for (unsigned i=0; i < SgGreaterThanOp::pool_size-1; i++) {
  128154       69965 :           alloc[i].p_freepointer = &(alloc[i+1]);
  128155             :         }
  128156          35 :         alloc[SgGreaterThanOp::pool_size-1].p_freepointer = nullptr;
  128157             : 
  128158          35 :         SgGreaterThanOp::pools.push_back ( (unsigned char *) alloc );
  128159          35 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgGreaterThanOp::pool_size * sizeof(SgGreaterThanOp), V_SgGreaterThanOp ) );
  128160          35 :         SgGreaterThanOp::next_node = alloc;
  128161             :     }
  128162        1289 :     ROSE_ASSERT(SgGreaterThanOp::next_node != nullptr);
  128163             : 
  128164        1289 :     SgGreaterThanOp * object = SgGreaterThanOp::next_node;
  128165        1289 :     SgGreaterThanOp::next_node = (SgGreaterThanOp*)(object->p_freepointer);
  128166             : 
  128167             : #if ROSE_ALLOC_TRACE == 2
  128168             :     printf("SgGreaterThanOp::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgGreaterThanOp::next_node);
  128169             : #endif
  128170             : 
  128171        1289 :     SgNode * fp = object->p_freepointer;
  128172             : #if ROSE_ALLOC_MEMSET == 1
  128173             : #elif ROSE_ALLOC_MEMSET == 2
  128174             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgGreaterThanOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  128175             : #elif ROSE_ALLOC_MEMSET == 3
  128176             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgGreaterThanOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  128177             : #endif
  128178        1289 :     object->p_freepointer = fp;
  128179             : 
  128180             : #if ROSE_ALLOC_TRACE == 2
  128181             : //    printf("SgGreaterThanOp::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgGreaterThanOp::next_node);
  128182             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  128183             :     Rose::MemPool::snapshot(oss.str());
  128184             :     alloc_trace_cnt++;
  128185             : #endif
  128186             : 
  128187        1289 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  128188             : 
  128189        1289 :     ALLOC_MUTEX(SgGreaterThanOp, unlock);
  128190             : 
  128191             :     return object;
  128192             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  128193             : }
  128194             : 
  128195             : 
  128196             : 
  128197             : /*! \brief Delete operator for SgGreaterThanOp.
  128198             : 
  128199             :    This delete operator implements deallocation using memory pools to 
  128200             :    provide most efficent use of the heap within construction of large ASTs.
  128201             : 
  128202             : \internal The new and delete operators use the lower level C malloc/free
  128203             :    function calls for performance and to make sure that mixing of malloc/free
  128204             :    and new/delete by the used can be caught more readily.  This may change
  128205             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  128206             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  128207             :    deallocate memory allocated using ROSE_MALLOC.
  128208             : */
  128209         236 : void SgGreaterThanOp::operator delete(void *Pointer, size_t Size)
  128210             : {
  128211             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  128212             :      * or throwing an exception. */
  128213         236 :     ALLOC_MUTEX(SgGreaterThanOp, lock);
  128214             : 
  128215             : #if USE_CPP_NEW_DELETE_OPERATORS
  128216             :     ROSE_FREE(Pointer);
  128217             : #else
  128218             : #if ROSE_PEDANTIC_ALLOC
  128219             :     ROSE_ASSERT(Size == sizeof(SgGreaterThanOp));
  128220             : #else
  128221         236 :     if (Size != sizeof(SgGreaterThanOp)) {
  128222           0 :       ROSE_FREE(Pointer);
  128223           0 :       ALLOC_MUTEX(SgGreaterThanOp, unlock);
  128224             :       return;
  128225             :     }
  128226             : #endif
  128227             : 
  128228         236 :     SgGreaterThanOp * object = (SgGreaterThanOp*) Pointer;
  128229         236 :     ROSE_ASSERT(object != nullptr);
  128230             : 
  128231             : #if ROSE_ALLOC_TRACE == 2
  128232             : //  printf("SgGreaterThanOp::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgGreaterThanOp::next_node);
  128233             :     printf("SgGreaterThanOp::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgGreaterThanOp::next_node);
  128234             : #endif
  128235             : 
  128236             : #if ROSE_PEDANTIC_ALLOC
  128237             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  128238             : #endif
  128239             : 
  128240             : #if ROSE_ALLOC_MEMSET == 1
  128241             : #elif ROSE_ALLOC_MEMSET == 2
  128242             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgGreaterThanOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  128243             : #elif ROSE_ALLOC_MEMSET == 3
  128244             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgGreaterThanOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  128245             : #endif
  128246             : 
  128247             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  128248             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  128249             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  128250             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  128251             : #else
  128252         236 :     object->p_freepointer = SgGreaterThanOp::next_node;
  128253         236 :     SgGreaterThanOp::next_node = object;
  128254             : #endif
  128255             : 
  128256             : #if ROSE_ALLOC_TRACE == 2
  128257             : //  printf("SgGreaterThanOp::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgGreaterThanOp::next_node);
  128258             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  128259             :     Rose::MemPool::snapshot(oss.str());
  128260             :     alloc_trace_cnt++;
  128261             : #endif
  128262             : 
  128263             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  128264             : 
  128265         236 :     ALLOC_MUTEX(SgGreaterThanOp, unlock);
  128266             : }
  128267             : 
  128268             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  128269             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  128270             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  128271             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  128272             : // Also, note comment below from Robb (copied from the Common.code file).
  128273             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  128274             : //
  128275             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  128276             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  128277             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  128278             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  128279             : #if 0
  128280             : void SgGreaterThanOp::operator delete(void* pointer) { SgGreaterThanOp::operator delete (pointer, sizeof(SgGreaterThanOp)); };
  128281             : #endif
  128282             : /* #line 128283 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  128283             : 
  128284             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  128285             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  128286             : // obviously imply C++.
  128287             : 
  128288             : // This implements the support within ROSE for memory pools.  Memory pools
  128289             : // support the most condensed usage of memory within the construction of
  128290             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  128291             : // by a new operator written for each class.
  128292             : 
  128293             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  128294             :     // User wants multi-thread support and POSIX threads are available.
  128295             : #   include <pthread.h>
  128296             :     static pthread_mutex_t SgNotEqualOp_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  128297             : #else
  128298             :      // Cause synchronization to be skipped.
  128299             : #    ifndef ALLOC_MUTEX
  128300             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  128301             : #    endif
  128302             : #    ifdef _REENTRANT
  128303             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  128304             : #       ifdef _MSC_VER
  128305             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  128306             : #       else
  128307             : #           warning "POSIX threads are not available; synchronization being skipped"
  128308             : #       endif
  128309             : #    endif
  128310             : #endif
  128311             : 
  128312             : #ifndef ROSE_ALLOC_TRACE
  128313             : #  define ROSE_ALLOC_TRACE 0
  128314             : #endif
  128315             : 
  128316             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  128317             : #define ROSE_ALLOC_TRACE_CNT
  128318             : #include "memory-pool-snapshot.h"
  128319             : unsigned long alloc_trace_cnt = 0;
  128320             : #endif
  128321             : 
  128322             : #if ROSE_ALLOC_TRACE
  128323             : const unsigned SgNotEqualOp::pool_size = 5;
  128324             : #else
  128325             : const unsigned SgNotEqualOp::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  128326             : #endif
  128327             : 
  128328             : #ifndef ROSE_ALLOC_MEMSET
  128329             : #  define ROSE_ALLOC_MEMSET 0
  128330             : #endif
  128331             : 
  128332             : #ifndef ROSE_PEDANTIC_ALLOC
  128333             : #  define ROSE_PEDANTIC_ALLOC 0
  128334             : #endif
  128335             : 
  128336             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  128337             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  128338             : #endif
  128339             : 
  128340             : #if !defined(SGNODE__ALL_POOLS)
  128341             : #define SGNODE__ALL_POOLS
  128342             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  128343             : #endif
  128344             : 
  128345             : SgNotEqualOp* SgNotEqualOp::next_node = nullptr;
  128346             : std::vector<unsigned char*> SgNotEqualOp::pools;
  128347             : 
  128348             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  128349             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  128350             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  128351             : // around this macro definition rather than each use).
  128352             : #ifndef ALLOC_MUTEX
  128353             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  128354             :         do {                                                                     \
  128355             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  128356             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  128357             :                 abort();                                                         \
  128358             :             }                                                                    \
  128359             :         } while (0);
  128360             : #endif
  128361             : 
  128362             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  128363             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  128364             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  128365             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  128366             : 
  128367             : /*! \brief New operator for SgNotEqualOp.
  128368             : 
  128369             :    This new operator implements memory pools to provide most efficent 
  128370             :    use of the heap within construction of large ASTs.
  128371             : 
  128372             : \internal The new and delete operators use the lower level C malloc/free
  128373             :    function calls for performance and to make sure that mixing of malloc/free
  128374             :    and new/delete by the used can be caught more readily.  This may change
  128375             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  128376             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  128377             :    deallocate memory allocated using ROSE_MALLOC.
  128378             : */
  128379        1953 : void *SgNotEqualOp::operator new ( size_t Size )
  128380             : {
  128381             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  128382             :      * returning or throwing an exception. */
  128383        1953 :     ALLOC_MUTEX(SgNotEqualOp, lock);
  128384             : 
  128385             : #if ROSE_ALLOC_TRACE == 2
  128386             : //    printf("SgNotEqualOp::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgNotEqualOp::next_node);
  128387             : #endif
  128388             : 
  128389             : #if USE_CPP_NEW_DELETE_OPERATORS
  128390             :     void *mem = ROSE_MALLOC(Size);
  128391             :     ALLOC_MUTEX(SgNotEqualOp, unlock);
  128392             :     return mem;
  128393             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  128394             : #if ROSE_PEDANTIC_ALLOC
  128395             :     ROSE_ASSERT(Size == sizeof(SgNotEqualOp));
  128396             : #else
  128397        1953 :     if (Size != sizeof(SgNotEqualOp)) {
  128398           0 :       void * object = ROSE_MALLOC(Size);
  128399           0 :       ALLOC_MUTEX(SgNotEqualOp, unlock);
  128400             :       return object;
  128401             :     }
  128402             : #endif
  128403             : 
  128404        1953 :     if (SgNotEqualOp::next_node == nullptr) {
  128405          45 :         SgNotEqualOp * alloc = (SgNotEqualOp*) ROSE_MALLOC ( SgNotEqualOp::pool_size * sizeof(SgNotEqualOp) );
  128406          45 :         ROSE_ASSERT(alloc != nullptr);
  128407             : 
  128408             : #if ROSE_ALLOC_TRACE == 2
  128409             : //        printf("SgNotEqualOp::alloc\n  block[%zi] = [ %p , %p [\n", SgNotEqualOp::pools.size(), alloc, alloc + SgNotEqualOp::pool_size);
  128410             : #endif
  128411             : 
  128412             : #if ROSE_ALLOC_MEMSET == 1
  128413             : #elif ROSE_ALLOC_MEMSET == 2
  128414             :         memset(alloc, 0x00, SgNotEqualOp::pool_size * sizeof(SgNotEqualOp));
  128415             : #elif ROSE_ALLOC_MEMSET == 3
  128416             :         memset(alloc, 0xAA, SgNotEqualOp::pool_size * sizeof(SgNotEqualOp));
  128417             : #endif
  128418       90000 :         for (unsigned i=0; i < SgNotEqualOp::pool_size-1; i++) {
  128419       89955 :           alloc[i].p_freepointer = &(alloc[i+1]);
  128420             :         }
  128421          45 :         alloc[SgNotEqualOp::pool_size-1].p_freepointer = nullptr;
  128422             : 
  128423          45 :         SgNotEqualOp::pools.push_back ( (unsigned char *) alloc );
  128424          45 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgNotEqualOp::pool_size * sizeof(SgNotEqualOp), V_SgNotEqualOp ) );
  128425          45 :         SgNotEqualOp::next_node = alloc;
  128426             :     }
  128427        1953 :     ROSE_ASSERT(SgNotEqualOp::next_node != nullptr);
  128428             : 
  128429        1953 :     SgNotEqualOp * object = SgNotEqualOp::next_node;
  128430        1953 :     SgNotEqualOp::next_node = (SgNotEqualOp*)(object->p_freepointer);
  128431             : 
  128432             : #if ROSE_ALLOC_TRACE == 2
  128433             :     printf("SgNotEqualOp::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgNotEqualOp::next_node);
  128434             : #endif
  128435             : 
  128436        1953 :     SgNode * fp = object->p_freepointer;
  128437             : #if ROSE_ALLOC_MEMSET == 1
  128438             : #elif ROSE_ALLOC_MEMSET == 2
  128439             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgNotEqualOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  128440             : #elif ROSE_ALLOC_MEMSET == 3
  128441             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgNotEqualOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  128442             : #endif
  128443        1953 :     object->p_freepointer = fp;
  128444             : 
  128445             : #if ROSE_ALLOC_TRACE == 2
  128446             : //    printf("SgNotEqualOp::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgNotEqualOp::next_node);
  128447             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  128448             :     Rose::MemPool::snapshot(oss.str());
  128449             :     alloc_trace_cnt++;
  128450             : #endif
  128451             : 
  128452        1953 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  128453             : 
  128454        1953 :     ALLOC_MUTEX(SgNotEqualOp, unlock);
  128455             : 
  128456             :     return object;
  128457             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  128458             : }
  128459             : 
  128460             : 
  128461             : 
  128462             : /*! \brief Delete operator for SgNotEqualOp.
  128463             : 
  128464             :    This delete operator implements deallocation using memory pools to 
  128465             :    provide most efficent use of the heap within construction of large ASTs.
  128466             : 
  128467             : \internal The new and delete operators use the lower level C malloc/free
  128468             :    function calls for performance and to make sure that mixing of malloc/free
  128469             :    and new/delete by the used can be caught more readily.  This may change
  128470             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  128471             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  128472             :    deallocate memory allocated using ROSE_MALLOC.
  128473             : */
  128474         206 : void SgNotEqualOp::operator delete(void *Pointer, size_t Size)
  128475             : {
  128476             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  128477             :      * or throwing an exception. */
  128478         206 :     ALLOC_MUTEX(SgNotEqualOp, lock);
  128479             : 
  128480             : #if USE_CPP_NEW_DELETE_OPERATORS
  128481             :     ROSE_FREE(Pointer);
  128482             : #else
  128483             : #if ROSE_PEDANTIC_ALLOC
  128484             :     ROSE_ASSERT(Size == sizeof(SgNotEqualOp));
  128485             : #else
  128486         206 :     if (Size != sizeof(SgNotEqualOp)) {
  128487           0 :       ROSE_FREE(Pointer);
  128488           0 :       ALLOC_MUTEX(SgNotEqualOp, unlock);
  128489             :       return;
  128490             :     }
  128491             : #endif
  128492             : 
  128493         206 :     SgNotEqualOp * object = (SgNotEqualOp*) Pointer;
  128494         206 :     ROSE_ASSERT(object != nullptr);
  128495             : 
  128496             : #if ROSE_ALLOC_TRACE == 2
  128497             : //  printf("SgNotEqualOp::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgNotEqualOp::next_node);
  128498             :     printf("SgNotEqualOp::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgNotEqualOp::next_node);
  128499             : #endif
  128500             : 
  128501             : #if ROSE_PEDANTIC_ALLOC
  128502             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  128503             : #endif
  128504             : 
  128505             : #if ROSE_ALLOC_MEMSET == 1
  128506             : #elif ROSE_ALLOC_MEMSET == 2
  128507             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgNotEqualOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  128508             : #elif ROSE_ALLOC_MEMSET == 3
  128509             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgNotEqualOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  128510             : #endif
  128511             : 
  128512             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  128513             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  128514             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  128515             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  128516             : #else
  128517         206 :     object->p_freepointer = SgNotEqualOp::next_node;
  128518         206 :     SgNotEqualOp::next_node = object;
  128519             : #endif
  128520             : 
  128521             : #if ROSE_ALLOC_TRACE == 2
  128522             : //  printf("SgNotEqualOp::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgNotEqualOp::next_node);
  128523             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  128524             :     Rose::MemPool::snapshot(oss.str());
  128525             :     alloc_trace_cnt++;
  128526             : #endif
  128527             : 
  128528             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  128529             : 
  128530         206 :     ALLOC_MUTEX(SgNotEqualOp, unlock);
  128531             : }
  128532             : 
  128533             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  128534             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  128535             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  128536             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  128537             : // Also, note comment below from Robb (copied from the Common.code file).
  128538             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  128539             : //
  128540             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  128541             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  128542             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  128543             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  128544             : #if 0
  128545             : void SgNotEqualOp::operator delete(void* pointer) { SgNotEqualOp::operator delete (pointer, sizeof(SgNotEqualOp)); };
  128546             : #endif
  128547             : /* #line 128548 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  128548             : 
  128549             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  128550             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  128551             : // obviously imply C++.
  128552             : 
  128553             : // This implements the support within ROSE for memory pools.  Memory pools
  128554             : // support the most condensed usage of memory within the construction of
  128555             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  128556             : // by a new operator written for each class.
  128557             : 
  128558             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  128559             :     // User wants multi-thread support and POSIX threads are available.
  128560             : #   include <pthread.h>
  128561             :     static pthread_mutex_t SgLessOrEqualOp_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  128562             : #else
  128563             :      // Cause synchronization to be skipped.
  128564             : #    ifndef ALLOC_MUTEX
  128565             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  128566             : #    endif
  128567             : #    ifdef _REENTRANT
  128568             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  128569             : #       ifdef _MSC_VER
  128570             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  128571             : #       else
  128572             : #           warning "POSIX threads are not available; synchronization being skipped"
  128573             : #       endif
  128574             : #    endif
  128575             : #endif
  128576             : 
  128577             : #ifndef ROSE_ALLOC_TRACE
  128578             : #  define ROSE_ALLOC_TRACE 0
  128579             : #endif
  128580             : 
  128581             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  128582             : #define ROSE_ALLOC_TRACE_CNT
  128583             : #include "memory-pool-snapshot.h"
  128584             : unsigned long alloc_trace_cnt = 0;
  128585             : #endif
  128586             : 
  128587             : #if ROSE_ALLOC_TRACE
  128588             : const unsigned SgLessOrEqualOp::pool_size = 5;
  128589             : #else
  128590             : const unsigned SgLessOrEqualOp::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  128591             : #endif
  128592             : 
  128593             : #ifndef ROSE_ALLOC_MEMSET
  128594             : #  define ROSE_ALLOC_MEMSET 0
  128595             : #endif
  128596             : 
  128597             : #ifndef ROSE_PEDANTIC_ALLOC
  128598             : #  define ROSE_PEDANTIC_ALLOC 0
  128599             : #endif
  128600             : 
  128601             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  128602             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  128603             : #endif
  128604             : 
  128605             : #if !defined(SGNODE__ALL_POOLS)
  128606             : #define SGNODE__ALL_POOLS
  128607             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  128608             : #endif
  128609             : 
  128610             : SgLessOrEqualOp* SgLessOrEqualOp::next_node = nullptr;
  128611             : std::vector<unsigned char*> SgLessOrEqualOp::pools;
  128612             : 
  128613             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  128614             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  128615             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  128616             : // around this macro definition rather than each use).
  128617             : #ifndef ALLOC_MUTEX
  128618             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  128619             :         do {                                                                     \
  128620             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  128621             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  128622             :                 abort();                                                         \
  128623             :             }                                                                    \
  128624             :         } while (0);
  128625             : #endif
  128626             : 
  128627             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  128628             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  128629             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  128630             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  128631             : 
  128632             : /*! \brief New operator for SgLessOrEqualOp.
  128633             : 
  128634             :    This new operator implements memory pools to provide most efficent 
  128635             :    use of the heap within construction of large ASTs.
  128636             : 
  128637             : \internal The new and delete operators use the lower level C malloc/free
  128638             :    function calls for performance and to make sure that mixing of malloc/free
  128639             :    and new/delete by the used can be caught more readily.  This may change
  128640             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  128641             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  128642             :    deallocate memory allocated using ROSE_MALLOC.
  128643             : */
  128644         398 : void *SgLessOrEqualOp::operator new ( size_t Size )
  128645             : {
  128646             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  128647             :      * returning or throwing an exception. */
  128648         398 :     ALLOC_MUTEX(SgLessOrEqualOp, lock);
  128649             : 
  128650             : #if ROSE_ALLOC_TRACE == 2
  128651             : //    printf("SgLessOrEqualOp::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgLessOrEqualOp::next_node);
  128652             : #endif
  128653             : 
  128654             : #if USE_CPP_NEW_DELETE_OPERATORS
  128655             :     void *mem = ROSE_MALLOC(Size);
  128656             :     ALLOC_MUTEX(SgLessOrEqualOp, unlock);
  128657             :     return mem;
  128658             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  128659             : #if ROSE_PEDANTIC_ALLOC
  128660             :     ROSE_ASSERT(Size == sizeof(SgLessOrEqualOp));
  128661             : #else
  128662         398 :     if (Size != sizeof(SgLessOrEqualOp)) {
  128663           0 :       void * object = ROSE_MALLOC(Size);
  128664           0 :       ALLOC_MUTEX(SgLessOrEqualOp, unlock);
  128665             :       return object;
  128666             :     }
  128667             : #endif
  128668             : 
  128669         398 :     if (SgLessOrEqualOp::next_node == nullptr) {
  128670          48 :         SgLessOrEqualOp * alloc = (SgLessOrEqualOp*) ROSE_MALLOC ( SgLessOrEqualOp::pool_size * sizeof(SgLessOrEqualOp) );
  128671          48 :         ROSE_ASSERT(alloc != nullptr);
  128672             : 
  128673             : #if ROSE_ALLOC_TRACE == 2
  128674             : //        printf("SgLessOrEqualOp::alloc\n  block[%zi] = [ %p , %p [\n", SgLessOrEqualOp::pools.size(), alloc, alloc + SgLessOrEqualOp::pool_size);
  128675             : #endif
  128676             : 
  128677             : #if ROSE_ALLOC_MEMSET == 1
  128678             : #elif ROSE_ALLOC_MEMSET == 2
  128679             :         memset(alloc, 0x00, SgLessOrEqualOp::pool_size * sizeof(SgLessOrEqualOp));
  128680             : #elif ROSE_ALLOC_MEMSET == 3
  128681             :         memset(alloc, 0xAA, SgLessOrEqualOp::pool_size * sizeof(SgLessOrEqualOp));
  128682             : #endif
  128683       96000 :         for (unsigned i=0; i < SgLessOrEqualOp::pool_size-1; i++) {
  128684       95952 :           alloc[i].p_freepointer = &(alloc[i+1]);
  128685             :         }
  128686          48 :         alloc[SgLessOrEqualOp::pool_size-1].p_freepointer = nullptr;
  128687             : 
  128688          48 :         SgLessOrEqualOp::pools.push_back ( (unsigned char *) alloc );
  128689          48 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgLessOrEqualOp::pool_size * sizeof(SgLessOrEqualOp), V_SgLessOrEqualOp ) );
  128690          48 :         SgLessOrEqualOp::next_node = alloc;
  128691             :     }
  128692         398 :     ROSE_ASSERT(SgLessOrEqualOp::next_node != nullptr);
  128693             : 
  128694         398 :     SgLessOrEqualOp * object = SgLessOrEqualOp::next_node;
  128695         398 :     SgLessOrEqualOp::next_node = (SgLessOrEqualOp*)(object->p_freepointer);
  128696             : 
  128697             : #if ROSE_ALLOC_TRACE == 2
  128698             :     printf("SgLessOrEqualOp::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgLessOrEqualOp::next_node);
  128699             : #endif
  128700             : 
  128701         398 :     SgNode * fp = object->p_freepointer;
  128702             : #if ROSE_ALLOC_MEMSET == 1
  128703             : #elif ROSE_ALLOC_MEMSET == 2
  128704             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgLessOrEqualOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  128705             : #elif ROSE_ALLOC_MEMSET == 3
  128706             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgLessOrEqualOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  128707             : #endif
  128708         398 :     object->p_freepointer = fp;
  128709             : 
  128710             : #if ROSE_ALLOC_TRACE == 2
  128711             : //    printf("SgLessOrEqualOp::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgLessOrEqualOp::next_node);
  128712             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  128713             :     Rose::MemPool::snapshot(oss.str());
  128714             :     alloc_trace_cnt++;
  128715             : #endif
  128716             : 
  128717         398 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  128718             : 
  128719         398 :     ALLOC_MUTEX(SgLessOrEqualOp, unlock);
  128720             : 
  128721             :     return object;
  128722             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  128723             : }
  128724             : 
  128725             : 
  128726             : 
  128727             : /*! \brief Delete operator for SgLessOrEqualOp.
  128728             : 
  128729             :    This delete operator implements deallocation using memory pools to 
  128730             :    provide most efficent use of the heap within construction of large ASTs.
  128731             : 
  128732             : \internal The new and delete operators use the lower level C malloc/free
  128733             :    function calls for performance and to make sure that mixing of malloc/free
  128734             :    and new/delete by the used can be caught more readily.  This may change
  128735             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  128736             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  128737             :    deallocate memory allocated using ROSE_MALLOC.
  128738             : */
  128739          62 : void SgLessOrEqualOp::operator delete(void *Pointer, size_t Size)
  128740             : {
  128741             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  128742             :      * or throwing an exception. */
  128743          62 :     ALLOC_MUTEX(SgLessOrEqualOp, lock);
  128744             : 
  128745             : #if USE_CPP_NEW_DELETE_OPERATORS
  128746             :     ROSE_FREE(Pointer);
  128747             : #else
  128748             : #if ROSE_PEDANTIC_ALLOC
  128749             :     ROSE_ASSERT(Size == sizeof(SgLessOrEqualOp));
  128750             : #else
  128751          62 :     if (Size != sizeof(SgLessOrEqualOp)) {
  128752           0 :       ROSE_FREE(Pointer);
  128753           0 :       ALLOC_MUTEX(SgLessOrEqualOp, unlock);
  128754             :       return;
  128755             :     }
  128756             : #endif
  128757             : 
  128758          62 :     SgLessOrEqualOp * object = (SgLessOrEqualOp*) Pointer;
  128759          62 :     ROSE_ASSERT(object != nullptr);
  128760             : 
  128761             : #if ROSE_ALLOC_TRACE == 2
  128762             : //  printf("SgLessOrEqualOp::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgLessOrEqualOp::next_node);
  128763             :     printf("SgLessOrEqualOp::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgLessOrEqualOp::next_node);
  128764             : #endif
  128765             : 
  128766             : #if ROSE_PEDANTIC_ALLOC
  128767             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  128768             : #endif
  128769             : 
  128770             : #if ROSE_ALLOC_MEMSET == 1
  128771             : #elif ROSE_ALLOC_MEMSET == 2
  128772             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgLessOrEqualOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  128773             : #elif ROSE_ALLOC_MEMSET == 3
  128774             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgLessOrEqualOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  128775             : #endif
  128776             : 
  128777             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  128778             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  128779             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  128780             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  128781             : #else
  128782          62 :     object->p_freepointer = SgLessOrEqualOp::next_node;
  128783          62 :     SgLessOrEqualOp::next_node = object;
  128784             : #endif
  128785             : 
  128786             : #if ROSE_ALLOC_TRACE == 2
  128787             : //  printf("SgLessOrEqualOp::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgLessOrEqualOp::next_node);
  128788             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  128789             :     Rose::MemPool::snapshot(oss.str());
  128790             :     alloc_trace_cnt++;
  128791             : #endif
  128792             : 
  128793             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  128794             : 
  128795          62 :     ALLOC_MUTEX(SgLessOrEqualOp, unlock);
  128796             : }
  128797             : 
  128798             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  128799             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  128800             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  128801             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  128802             : // Also, note comment below from Robb (copied from the Common.code file).
  128803             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  128804             : //
  128805             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  128806             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  128807             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  128808             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  128809             : #if 0
  128810             : void SgLessOrEqualOp::operator delete(void* pointer) { SgLessOrEqualOp::operator delete (pointer, sizeof(SgLessOrEqualOp)); };
  128811             : #endif
  128812             : /* #line 128813 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  128813             : 
  128814             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  128815             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  128816             : // obviously imply C++.
  128817             : 
  128818             : // This implements the support within ROSE for memory pools.  Memory pools
  128819             : // support the most condensed usage of memory within the construction of
  128820             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  128821             : // by a new operator written for each class.
  128822             : 
  128823             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  128824             :     // User wants multi-thread support and POSIX threads are available.
  128825             : #   include <pthread.h>
  128826             :     static pthread_mutex_t SgGreaterOrEqualOp_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  128827             : #else
  128828             :      // Cause synchronization to be skipped.
  128829             : #    ifndef ALLOC_MUTEX
  128830             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  128831             : #    endif
  128832             : #    ifdef _REENTRANT
  128833             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  128834             : #       ifdef _MSC_VER
  128835             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  128836             : #       else
  128837             : #           warning "POSIX threads are not available; synchronization being skipped"
  128838             : #       endif
  128839             : #    endif
  128840             : #endif
  128841             : 
  128842             : #ifndef ROSE_ALLOC_TRACE
  128843             : #  define ROSE_ALLOC_TRACE 0
  128844             : #endif
  128845             : 
  128846             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  128847             : #define ROSE_ALLOC_TRACE_CNT
  128848             : #include "memory-pool-snapshot.h"
  128849             : unsigned long alloc_trace_cnt = 0;
  128850             : #endif
  128851             : 
  128852             : #if ROSE_ALLOC_TRACE
  128853             : const unsigned SgGreaterOrEqualOp::pool_size = 5;
  128854             : #else
  128855             : const unsigned SgGreaterOrEqualOp::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  128856             : #endif
  128857             : 
  128858             : #ifndef ROSE_ALLOC_MEMSET
  128859             : #  define ROSE_ALLOC_MEMSET 0
  128860             : #endif
  128861             : 
  128862             : #ifndef ROSE_PEDANTIC_ALLOC
  128863             : #  define ROSE_PEDANTIC_ALLOC 0
  128864             : #endif
  128865             : 
  128866             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  128867             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  128868             : #endif
  128869             : 
  128870             : #if !defined(SGNODE__ALL_POOLS)
  128871             : #define SGNODE__ALL_POOLS
  128872             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  128873             : #endif
  128874             : 
  128875             : SgGreaterOrEqualOp* SgGreaterOrEqualOp::next_node = nullptr;
  128876             : std::vector<unsigned char*> SgGreaterOrEqualOp::pools;
  128877             : 
  128878             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  128879             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  128880             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  128881             : // around this macro definition rather than each use).
  128882             : #ifndef ALLOC_MUTEX
  128883             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  128884             :         do {                                                                     \
  128885             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  128886             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  128887             :                 abort();                                                         \
  128888             :             }                                                                    \
  128889             :         } while (0);
  128890             : #endif
  128891             : 
  128892             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  128893             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  128894             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  128895             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  128896             : 
  128897             : /*! \brief New operator for SgGreaterOrEqualOp.
  128898             : 
  128899             :    This new operator implements memory pools to provide most efficent 
  128900             :    use of the heap within construction of large ASTs.
  128901             : 
  128902             : \internal The new and delete operators use the lower level C malloc/free
  128903             :    function calls for performance and to make sure that mixing of malloc/free
  128904             :    and new/delete by the used can be caught more readily.  This may change
  128905             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  128906             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  128907             :    deallocate memory allocated using ROSE_MALLOC.
  128908             : */
  128909         356 : void *SgGreaterOrEqualOp::operator new ( size_t Size )
  128910             : {
  128911             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  128912             :      * returning or throwing an exception. */
  128913         356 :     ALLOC_MUTEX(SgGreaterOrEqualOp, lock);
  128914             : 
  128915             : #if ROSE_ALLOC_TRACE == 2
  128916             : //    printf("SgGreaterOrEqualOp::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgGreaterOrEqualOp::next_node);
  128917             : #endif
  128918             : 
  128919             : #if USE_CPP_NEW_DELETE_OPERATORS
  128920             :     void *mem = ROSE_MALLOC(Size);
  128921             :     ALLOC_MUTEX(SgGreaterOrEqualOp, unlock);
  128922             :     return mem;
  128923             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  128924             : #if ROSE_PEDANTIC_ALLOC
  128925             :     ROSE_ASSERT(Size == sizeof(SgGreaterOrEqualOp));
  128926             : #else
  128927         356 :     if (Size != sizeof(SgGreaterOrEqualOp)) {
  128928           0 :       void * object = ROSE_MALLOC(Size);
  128929           0 :       ALLOC_MUTEX(SgGreaterOrEqualOp, unlock);
  128930             :       return object;
  128931             :     }
  128932             : #endif
  128933             : 
  128934         356 :     if (SgGreaterOrEqualOp::next_node == nullptr) {
  128935          26 :         SgGreaterOrEqualOp * alloc = (SgGreaterOrEqualOp*) ROSE_MALLOC ( SgGreaterOrEqualOp::pool_size * sizeof(SgGreaterOrEqualOp) );
  128936          26 :         ROSE_ASSERT(alloc != nullptr);
  128937             : 
  128938             : #if ROSE_ALLOC_TRACE == 2
  128939             : //        printf("SgGreaterOrEqualOp::alloc\n  block[%zi] = [ %p , %p [\n", SgGreaterOrEqualOp::pools.size(), alloc, alloc + SgGreaterOrEqualOp::pool_size);
  128940             : #endif
  128941             : 
  128942             : #if ROSE_ALLOC_MEMSET == 1
  128943             : #elif ROSE_ALLOC_MEMSET == 2
  128944             :         memset(alloc, 0x00, SgGreaterOrEqualOp::pool_size * sizeof(SgGreaterOrEqualOp));
  128945             : #elif ROSE_ALLOC_MEMSET == 3
  128946             :         memset(alloc, 0xAA, SgGreaterOrEqualOp::pool_size * sizeof(SgGreaterOrEqualOp));
  128947             : #endif
  128948       52000 :         for (unsigned i=0; i < SgGreaterOrEqualOp::pool_size-1; i++) {
  128949       51974 :           alloc[i].p_freepointer = &(alloc[i+1]);
  128950             :         }
  128951          26 :         alloc[SgGreaterOrEqualOp::pool_size-1].p_freepointer = nullptr;
  128952             : 
  128953          26 :         SgGreaterOrEqualOp::pools.push_back ( (unsigned char *) alloc );
  128954          26 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgGreaterOrEqualOp::pool_size * sizeof(SgGreaterOrEqualOp), V_SgGreaterOrEqualOp ) );
  128955          26 :         SgGreaterOrEqualOp::next_node = alloc;
  128956             :     }
  128957         356 :     ROSE_ASSERT(SgGreaterOrEqualOp::next_node != nullptr);
  128958             : 
  128959         356 :     SgGreaterOrEqualOp * object = SgGreaterOrEqualOp::next_node;
  128960         356 :     SgGreaterOrEqualOp::next_node = (SgGreaterOrEqualOp*)(object->p_freepointer);
  128961             : 
  128962             : #if ROSE_ALLOC_TRACE == 2
  128963             :     printf("SgGreaterOrEqualOp::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgGreaterOrEqualOp::next_node);
  128964             : #endif
  128965             : 
  128966         356 :     SgNode * fp = object->p_freepointer;
  128967             : #if ROSE_ALLOC_MEMSET == 1
  128968             : #elif ROSE_ALLOC_MEMSET == 2
  128969             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgGreaterOrEqualOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  128970             : #elif ROSE_ALLOC_MEMSET == 3
  128971             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgGreaterOrEqualOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  128972             : #endif
  128973         356 :     object->p_freepointer = fp;
  128974             : 
  128975             : #if ROSE_ALLOC_TRACE == 2
  128976             : //    printf("SgGreaterOrEqualOp::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgGreaterOrEqualOp::next_node);
  128977             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  128978             :     Rose::MemPool::snapshot(oss.str());
  128979             :     alloc_trace_cnt++;
  128980             : #endif
  128981             : 
  128982         356 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  128983             : 
  128984         356 :     ALLOC_MUTEX(SgGreaterOrEqualOp, unlock);
  128985             : 
  128986             :     return object;
  128987             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  128988             : }
  128989             : 
  128990             : 
  128991             : 
  128992             : /*! \brief Delete operator for SgGreaterOrEqualOp.
  128993             : 
  128994             :    This delete operator implements deallocation using memory pools to 
  128995             :    provide most efficent use of the heap within construction of large ASTs.
  128996             : 
  128997             : \internal The new and delete operators use the lower level C malloc/free
  128998             :    function calls for performance and to make sure that mixing of malloc/free
  128999             :    and new/delete by the used can be caught more readily.  This may change
  129000             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  129001             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  129002             :    deallocate memory allocated using ROSE_MALLOC.
  129003             : */
  129004          56 : void SgGreaterOrEqualOp::operator delete(void *Pointer, size_t Size)
  129005             : {
  129006             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  129007             :      * or throwing an exception. */
  129008          56 :     ALLOC_MUTEX(SgGreaterOrEqualOp, lock);
  129009             : 
  129010             : #if USE_CPP_NEW_DELETE_OPERATORS
  129011             :     ROSE_FREE(Pointer);
  129012             : #else
  129013             : #if ROSE_PEDANTIC_ALLOC
  129014             :     ROSE_ASSERT(Size == sizeof(SgGreaterOrEqualOp));
  129015             : #else
  129016          56 :     if (Size != sizeof(SgGreaterOrEqualOp)) {
  129017           0 :       ROSE_FREE(Pointer);
  129018           0 :       ALLOC_MUTEX(SgGreaterOrEqualOp, unlock);
  129019             :       return;
  129020             :     }
  129021             : #endif
  129022             : 
  129023          56 :     SgGreaterOrEqualOp * object = (SgGreaterOrEqualOp*) Pointer;
  129024          56 :     ROSE_ASSERT(object != nullptr);
  129025             : 
  129026             : #if ROSE_ALLOC_TRACE == 2
  129027             : //  printf("SgGreaterOrEqualOp::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgGreaterOrEqualOp::next_node);
  129028             :     printf("SgGreaterOrEqualOp::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgGreaterOrEqualOp::next_node);
  129029             : #endif
  129030             : 
  129031             : #if ROSE_PEDANTIC_ALLOC
  129032             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  129033             : #endif
  129034             : 
  129035             : #if ROSE_ALLOC_MEMSET == 1
  129036             : #elif ROSE_ALLOC_MEMSET == 2
  129037             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgGreaterOrEqualOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  129038             : #elif ROSE_ALLOC_MEMSET == 3
  129039             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgGreaterOrEqualOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  129040             : #endif
  129041             : 
  129042             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  129043             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  129044             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  129045             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  129046             : #else
  129047          56 :     object->p_freepointer = SgGreaterOrEqualOp::next_node;
  129048          56 :     SgGreaterOrEqualOp::next_node = object;
  129049             : #endif
  129050             : 
  129051             : #if ROSE_ALLOC_TRACE == 2
  129052             : //  printf("SgGreaterOrEqualOp::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgGreaterOrEqualOp::next_node);
  129053             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  129054             :     Rose::MemPool::snapshot(oss.str());
  129055             :     alloc_trace_cnt++;
  129056             : #endif
  129057             : 
  129058             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  129059             : 
  129060          56 :     ALLOC_MUTEX(SgGreaterOrEqualOp, unlock);
  129061             : }
  129062             : 
  129063             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  129064             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  129065             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  129066             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  129067             : // Also, note comment below from Robb (copied from the Common.code file).
  129068             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  129069             : //
  129070             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  129071             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  129072             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  129073             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  129074             : #if 0
  129075             : void SgGreaterOrEqualOp::operator delete(void* pointer) { SgGreaterOrEqualOp::operator delete (pointer, sizeof(SgGreaterOrEqualOp)); };
  129076             : #endif
  129077             : /* #line 129078 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  129078             : 
  129079             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  129080             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  129081             : // obviously imply C++.
  129082             : 
  129083             : // This implements the support within ROSE for memory pools.  Memory pools
  129084             : // support the most condensed usage of memory within the construction of
  129085             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  129086             : // by a new operator written for each class.
  129087             : 
  129088             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  129089             :     // User wants multi-thread support and POSIX threads are available.
  129090             : #   include <pthread.h>
  129091             :     static pthread_mutex_t SgAddOp_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  129092             : #else
  129093             :      // Cause synchronization to be skipped.
  129094             : #    ifndef ALLOC_MUTEX
  129095             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  129096             : #    endif
  129097             : #    ifdef _REENTRANT
  129098             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  129099             : #       ifdef _MSC_VER
  129100             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  129101             : #       else
  129102             : #           warning "POSIX threads are not available; synchronization being skipped"
  129103             : #       endif
  129104             : #    endif
  129105             : #endif
  129106             : 
  129107             : #ifndef ROSE_ALLOC_TRACE
  129108             : #  define ROSE_ALLOC_TRACE 0
  129109             : #endif
  129110             : 
  129111             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  129112             : #define ROSE_ALLOC_TRACE_CNT
  129113             : #include "memory-pool-snapshot.h"
  129114             : unsigned long alloc_trace_cnt = 0;
  129115             : #endif
  129116             : 
  129117             : #if ROSE_ALLOC_TRACE
  129118             : const unsigned SgAddOp::pool_size = 5;
  129119             : #else
  129120             : const unsigned SgAddOp::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  129121             : #endif
  129122             : 
  129123             : #ifndef ROSE_ALLOC_MEMSET
  129124             : #  define ROSE_ALLOC_MEMSET 0
  129125             : #endif
  129126             : 
  129127             : #ifndef ROSE_PEDANTIC_ALLOC
  129128             : #  define ROSE_PEDANTIC_ALLOC 0
  129129             : #endif
  129130             : 
  129131             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  129132             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  129133             : #endif
  129134             : 
  129135             : #if !defined(SGNODE__ALL_POOLS)
  129136             : #define SGNODE__ALL_POOLS
  129137             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  129138             : #endif
  129139             : 
  129140             : SgAddOp* SgAddOp::next_node = nullptr;
  129141             : std::vector<unsigned char*> SgAddOp::pools;
  129142             : 
  129143             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  129144             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  129145             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  129146             : // around this macro definition rather than each use).
  129147             : #ifndef ALLOC_MUTEX
  129148             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  129149             :         do {                                                                     \
  129150             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  129151             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  129152             :                 abort();                                                         \
  129153             :             }                                                                    \
  129154             :         } while (0);
  129155             : #endif
  129156             : 
  129157             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  129158             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  129159             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  129160             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  129161             : 
  129162             : /*! \brief New operator for SgAddOp.
  129163             : 
  129164             :    This new operator implements memory pools to provide most efficent 
  129165             :    use of the heap within construction of large ASTs.
  129166             : 
  129167             : \internal The new and delete operators use the lower level C malloc/free
  129168             :    function calls for performance and to make sure that mixing of malloc/free
  129169             :    and new/delete by the used can be caught more readily.  This may change
  129170             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  129171             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  129172             :    deallocate memory allocated using ROSE_MALLOC.
  129173             : */
  129174        3070 : void *SgAddOp::operator new ( size_t Size )
  129175             : {
  129176             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  129177             :      * returning or throwing an exception. */
  129178        3070 :     ALLOC_MUTEX(SgAddOp, lock);
  129179             : 
  129180             : #if ROSE_ALLOC_TRACE == 2
  129181             : //    printf("SgAddOp::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgAddOp::next_node);
  129182             : #endif
  129183             : 
  129184             : #if USE_CPP_NEW_DELETE_OPERATORS
  129185             :     void *mem = ROSE_MALLOC(Size);
  129186             :     ALLOC_MUTEX(SgAddOp, unlock);
  129187             :     return mem;
  129188             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  129189             : #if ROSE_PEDANTIC_ALLOC
  129190             :     ROSE_ASSERT(Size == sizeof(SgAddOp));
  129191             : #else
  129192        3070 :     if (Size != sizeof(SgAddOp)) {
  129193           0 :       void * object = ROSE_MALLOC(Size);
  129194           0 :       ALLOC_MUTEX(SgAddOp, unlock);
  129195             :       return object;
  129196             :     }
  129197             : #endif
  129198             : 
  129199        3070 :     if (SgAddOp::next_node == nullptr) {
  129200         140 :         SgAddOp * alloc = (SgAddOp*) ROSE_MALLOC ( SgAddOp::pool_size * sizeof(SgAddOp) );
  129201         140 :         ROSE_ASSERT(alloc != nullptr);
  129202             : 
  129203             : #if ROSE_ALLOC_TRACE == 2
  129204             : //        printf("SgAddOp::alloc\n  block[%zi] = [ %p , %p [\n", SgAddOp::pools.size(), alloc, alloc + SgAddOp::pool_size);
  129205             : #endif
  129206             : 
  129207             : #if ROSE_ALLOC_MEMSET == 1
  129208             : #elif ROSE_ALLOC_MEMSET == 2
  129209             :         memset(alloc, 0x00, SgAddOp::pool_size * sizeof(SgAddOp));
  129210             : #elif ROSE_ALLOC_MEMSET == 3
  129211             :         memset(alloc, 0xAA, SgAddOp::pool_size * sizeof(SgAddOp));
  129212             : #endif
  129213      280000 :         for (unsigned i=0; i < SgAddOp::pool_size-1; i++) {
  129214      279860 :           alloc[i].p_freepointer = &(alloc[i+1]);
  129215             :         }
  129216         140 :         alloc[SgAddOp::pool_size-1].p_freepointer = nullptr;
  129217             : 
  129218         140 :         SgAddOp::pools.push_back ( (unsigned char *) alloc );
  129219         140 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgAddOp::pool_size * sizeof(SgAddOp), V_SgAddOp ) );
  129220         140 :         SgAddOp::next_node = alloc;
  129221             :     }
  129222        3070 :     ROSE_ASSERT(SgAddOp::next_node != nullptr);
  129223             : 
  129224        3070 :     SgAddOp * object = SgAddOp::next_node;
  129225        3070 :     SgAddOp::next_node = (SgAddOp*)(object->p_freepointer);
  129226             : 
  129227             : #if ROSE_ALLOC_TRACE == 2
  129228             :     printf("SgAddOp::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgAddOp::next_node);
  129229             : #endif
  129230             : 
  129231        3070 :     SgNode * fp = object->p_freepointer;
  129232             : #if ROSE_ALLOC_MEMSET == 1
  129233             : #elif ROSE_ALLOC_MEMSET == 2
  129234             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgAddOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  129235             : #elif ROSE_ALLOC_MEMSET == 3
  129236             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgAddOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  129237             : #endif
  129238        3070 :     object->p_freepointer = fp;
  129239             : 
  129240             : #if ROSE_ALLOC_TRACE == 2
  129241             : //    printf("SgAddOp::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgAddOp::next_node);
  129242             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  129243             :     Rose::MemPool::snapshot(oss.str());
  129244             :     alloc_trace_cnt++;
  129245             : #endif
  129246             : 
  129247        3070 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  129248             : 
  129249        3070 :     ALLOC_MUTEX(SgAddOp, unlock);
  129250             : 
  129251             :     return object;
  129252             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  129253             : }
  129254             : 
  129255             : 
  129256             : 
  129257             : /*! \brief Delete operator for SgAddOp.
  129258             : 
  129259             :    This delete operator implements deallocation using memory pools to 
  129260             :    provide most efficent use of the heap within construction of large ASTs.
  129261             : 
  129262             : \internal The new and delete operators use the lower level C malloc/free
  129263             :    function calls for performance and to make sure that mixing of malloc/free
  129264             :    and new/delete by the used can be caught more readily.  This may change
  129265             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  129266             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  129267             :    deallocate memory allocated using ROSE_MALLOC.
  129268             : */
  129269         764 : void SgAddOp::operator delete(void *Pointer, size_t Size)
  129270             : {
  129271             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  129272             :      * or throwing an exception. */
  129273         764 :     ALLOC_MUTEX(SgAddOp, lock);
  129274             : 
  129275             : #if USE_CPP_NEW_DELETE_OPERATORS
  129276             :     ROSE_FREE(Pointer);
  129277             : #else
  129278             : #if ROSE_PEDANTIC_ALLOC
  129279             :     ROSE_ASSERT(Size == sizeof(SgAddOp));
  129280             : #else
  129281         764 :     if (Size != sizeof(SgAddOp)) {
  129282           0 :       ROSE_FREE(Pointer);
  129283           0 :       ALLOC_MUTEX(SgAddOp, unlock);
  129284             :       return;
  129285             :     }
  129286             : #endif
  129287             : 
  129288         764 :     SgAddOp * object = (SgAddOp*) Pointer;
  129289         764 :     ROSE_ASSERT(object != nullptr);
  129290             : 
  129291             : #if ROSE_ALLOC_TRACE == 2
  129292             : //  printf("SgAddOp::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgAddOp::next_node);
  129293             :     printf("SgAddOp::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgAddOp::next_node);
  129294             : #endif
  129295             : 
  129296             : #if ROSE_PEDANTIC_ALLOC
  129297             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  129298             : #endif
  129299             : 
  129300             : #if ROSE_ALLOC_MEMSET == 1
  129301             : #elif ROSE_ALLOC_MEMSET == 2
  129302             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgAddOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  129303             : #elif ROSE_ALLOC_MEMSET == 3
  129304             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgAddOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  129305             : #endif
  129306             : 
  129307             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  129308             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  129309             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  129310             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  129311             : #else
  129312         764 :     object->p_freepointer = SgAddOp::next_node;
  129313         764 :     SgAddOp::next_node = object;
  129314             : #endif
  129315             : 
  129316             : #if ROSE_ALLOC_TRACE == 2
  129317             : //  printf("SgAddOp::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgAddOp::next_node);
  129318             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  129319             :     Rose::MemPool::snapshot(oss.str());
  129320             :     alloc_trace_cnt++;
  129321             : #endif
  129322             : 
  129323             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  129324             : 
  129325         764 :     ALLOC_MUTEX(SgAddOp, unlock);
  129326             : }
  129327             : 
  129328             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  129329             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  129330             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  129331             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  129332             : // Also, note comment below from Robb (copied from the Common.code file).
  129333             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  129334             : //
  129335             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  129336             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  129337             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  129338             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  129339             : #if 0
  129340             : void SgAddOp::operator delete(void* pointer) { SgAddOp::operator delete (pointer, sizeof(SgAddOp)); };
  129341             : #endif
  129342             : /* #line 129343 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  129343             : 
  129344             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  129345             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  129346             : // obviously imply C++.
  129347             : 
  129348             : // This implements the support within ROSE for memory pools.  Memory pools
  129349             : // support the most condensed usage of memory within the construction of
  129350             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  129351             : // by a new operator written for each class.
  129352             : 
  129353             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  129354             :     // User wants multi-thread support and POSIX threads are available.
  129355             : #   include <pthread.h>
  129356             :     static pthread_mutex_t SgSubtractOp_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  129357             : #else
  129358             :      // Cause synchronization to be skipped.
  129359             : #    ifndef ALLOC_MUTEX
  129360             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  129361             : #    endif
  129362             : #    ifdef _REENTRANT
  129363             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  129364             : #       ifdef _MSC_VER
  129365             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  129366             : #       else
  129367             : #           warning "POSIX threads are not available; synchronization being skipped"
  129368             : #       endif
  129369             : #    endif
  129370             : #endif
  129371             : 
  129372             : #ifndef ROSE_ALLOC_TRACE
  129373             : #  define ROSE_ALLOC_TRACE 0
  129374             : #endif
  129375             : 
  129376             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  129377             : #define ROSE_ALLOC_TRACE_CNT
  129378             : #include "memory-pool-snapshot.h"
  129379             : unsigned long alloc_trace_cnt = 0;
  129380             : #endif
  129381             : 
  129382             : #if ROSE_ALLOC_TRACE
  129383             : const unsigned SgSubtractOp::pool_size = 5;
  129384             : #else
  129385             : const unsigned SgSubtractOp::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  129386             : #endif
  129387             : 
  129388             : #ifndef ROSE_ALLOC_MEMSET
  129389             : #  define ROSE_ALLOC_MEMSET 0
  129390             : #endif
  129391             : 
  129392             : #ifndef ROSE_PEDANTIC_ALLOC
  129393             : #  define ROSE_PEDANTIC_ALLOC 0
  129394             : #endif
  129395             : 
  129396             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  129397             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  129398             : #endif
  129399             : 
  129400             : #if !defined(SGNODE__ALL_POOLS)
  129401             : #define SGNODE__ALL_POOLS
  129402             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  129403             : #endif
  129404             : 
  129405             : SgSubtractOp* SgSubtractOp::next_node = nullptr;
  129406             : std::vector<unsigned char*> SgSubtractOp::pools;
  129407             : 
  129408             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  129409             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  129410             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  129411             : // around this macro definition rather than each use).
  129412             : #ifndef ALLOC_MUTEX
  129413             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  129414             :         do {                                                                     \
  129415             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  129416             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  129417             :                 abort();                                                         \
  129418             :             }                                                                    \
  129419             :         } while (0);
  129420             : #endif
  129421             : 
  129422             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  129423             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  129424             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  129425             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  129426             : 
  129427             : /*! \brief New operator for SgSubtractOp.
  129428             : 
  129429             :    This new operator implements memory pools to provide most efficent 
  129430             :    use of the heap within construction of large ASTs.
  129431             : 
  129432             : \internal The new and delete operators use the lower level C malloc/free
  129433             :    function calls for performance and to make sure that mixing of malloc/free
  129434             :    and new/delete by the used can be caught more readily.  This may change
  129435             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  129436             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  129437             :    deallocate memory allocated using ROSE_MALLOC.
  129438             : */
  129439        3009 : void *SgSubtractOp::operator new ( size_t Size )
  129440             : {
  129441             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  129442             :      * returning or throwing an exception. */
  129443        3009 :     ALLOC_MUTEX(SgSubtractOp, lock);
  129444             : 
  129445             : #if ROSE_ALLOC_TRACE == 2
  129446             : //    printf("SgSubtractOp::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgSubtractOp::next_node);
  129447             : #endif
  129448             : 
  129449             : #if USE_CPP_NEW_DELETE_OPERATORS
  129450             :     void *mem = ROSE_MALLOC(Size);
  129451             :     ALLOC_MUTEX(SgSubtractOp, unlock);
  129452             :     return mem;
  129453             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  129454             : #if ROSE_PEDANTIC_ALLOC
  129455             :     ROSE_ASSERT(Size == sizeof(SgSubtractOp));
  129456             : #else
  129457        3009 :     if (Size != sizeof(SgSubtractOp)) {
  129458           0 :       void * object = ROSE_MALLOC(Size);
  129459           0 :       ALLOC_MUTEX(SgSubtractOp, unlock);
  129460             :       return object;
  129461             :     }
  129462             : #endif
  129463             : 
  129464        3009 :     if (SgSubtractOp::next_node == nullptr) {
  129465         191 :         SgSubtractOp * alloc = (SgSubtractOp*) ROSE_MALLOC ( SgSubtractOp::pool_size * sizeof(SgSubtractOp) );
  129466         191 :         ROSE_ASSERT(alloc != nullptr);
  129467             : 
  129468             : #if ROSE_ALLOC_TRACE == 2
  129469             : //        printf("SgSubtractOp::alloc\n  block[%zi] = [ %p , %p [\n", SgSubtractOp::pools.size(), alloc, alloc + SgSubtractOp::pool_size);
  129470             : #endif
  129471             : 
  129472             : #if ROSE_ALLOC_MEMSET == 1
  129473             : #elif ROSE_ALLOC_MEMSET == 2
  129474             :         memset(alloc, 0x00, SgSubtractOp::pool_size * sizeof(SgSubtractOp));
  129475             : #elif ROSE_ALLOC_MEMSET == 3
  129476             :         memset(alloc, 0xAA, SgSubtractOp::pool_size * sizeof(SgSubtractOp));
  129477             : #endif
  129478      382000 :         for (unsigned i=0; i < SgSubtractOp::pool_size-1; i++) {
  129479      381809 :           alloc[i].p_freepointer = &(alloc[i+1]);
  129480             :         }
  129481         191 :         alloc[SgSubtractOp::pool_size-1].p_freepointer = nullptr;
  129482             : 
  129483         191 :         SgSubtractOp::pools.push_back ( (unsigned char *) alloc );
  129484         191 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgSubtractOp::pool_size * sizeof(SgSubtractOp), V_SgSubtractOp ) );
  129485         191 :         SgSubtractOp::next_node = alloc;
  129486             :     }
  129487        3009 :     ROSE_ASSERT(SgSubtractOp::next_node != nullptr);
  129488             : 
  129489        3009 :     SgSubtractOp * object = SgSubtractOp::next_node;
  129490        3009 :     SgSubtractOp::next_node = (SgSubtractOp*)(object->p_freepointer);
  129491             : 
  129492             : #if ROSE_ALLOC_TRACE == 2
  129493             :     printf("SgSubtractOp::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgSubtractOp::next_node);
  129494             : #endif
  129495             : 
  129496        3009 :     SgNode * fp = object->p_freepointer;
  129497             : #if ROSE_ALLOC_MEMSET == 1
  129498             : #elif ROSE_ALLOC_MEMSET == 2
  129499             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgSubtractOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  129500             : #elif ROSE_ALLOC_MEMSET == 3
  129501             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgSubtractOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  129502             : #endif
  129503        3009 :     object->p_freepointer = fp;
  129504             : 
  129505             : #if ROSE_ALLOC_TRACE == 2
  129506             : //    printf("SgSubtractOp::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgSubtractOp::next_node);
  129507             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  129508             :     Rose::MemPool::snapshot(oss.str());
  129509             :     alloc_trace_cnt++;
  129510             : #endif
  129511             : 
  129512        3009 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  129513             : 
  129514        3009 :     ALLOC_MUTEX(SgSubtractOp, unlock);
  129515             : 
  129516             :     return object;
  129517             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  129518             : }
  129519             : 
  129520             : 
  129521             : 
  129522             : /*! \brief Delete operator for SgSubtractOp.
  129523             : 
  129524             :    This delete operator implements deallocation using memory pools to 
  129525             :    provide most efficent use of the heap within construction of large ASTs.
  129526             : 
  129527             : \internal The new and delete operators use the lower level C malloc/free
  129528             :    function calls for performance and to make sure that mixing of malloc/free
  129529             :    and new/delete by the used can be caught more readily.  This may change
  129530             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  129531             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  129532             :    deallocate memory allocated using ROSE_MALLOC.
  129533             : */
  129534         448 : void SgSubtractOp::operator delete(void *Pointer, size_t Size)
  129535             : {
  129536             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  129537             :      * or throwing an exception. */
  129538         448 :     ALLOC_MUTEX(SgSubtractOp, lock);
  129539             : 
  129540             : #if USE_CPP_NEW_DELETE_OPERATORS
  129541             :     ROSE_FREE(Pointer);
  129542             : #else
  129543             : #if ROSE_PEDANTIC_ALLOC
  129544             :     ROSE_ASSERT(Size == sizeof(SgSubtractOp));
  129545             : #else
  129546         448 :     if (Size != sizeof(SgSubtractOp)) {
  129547           0 :       ROSE_FREE(Pointer);
  129548           0 :       ALLOC_MUTEX(SgSubtractOp, unlock);
  129549             :       return;
  129550             :     }
  129551             : #endif
  129552             : 
  129553         448 :     SgSubtractOp * object = (SgSubtractOp*) Pointer;
  129554         448 :     ROSE_ASSERT(object != nullptr);
  129555             : 
  129556             : #if ROSE_ALLOC_TRACE == 2
  129557             : //  printf("SgSubtractOp::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgSubtractOp::next_node);
  129558             :     printf("SgSubtractOp::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgSubtractOp::next_node);
  129559             : #endif
  129560             : 
  129561             : #if ROSE_PEDANTIC_ALLOC
  129562             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  129563             : #endif
  129564             : 
  129565             : #if ROSE_ALLOC_MEMSET == 1
  129566             : #elif ROSE_ALLOC_MEMSET == 2
  129567             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgSubtractOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  129568             : #elif ROSE_ALLOC_MEMSET == 3
  129569             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgSubtractOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  129570             : #endif
  129571             : 
  129572             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  129573             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  129574             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  129575             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  129576             : #else
  129577         448 :     object->p_freepointer = SgSubtractOp::next_node;
  129578         448 :     SgSubtractOp::next_node = object;
  129579             : #endif
  129580             : 
  129581             : #if ROSE_ALLOC_TRACE == 2
  129582             : //  printf("SgSubtractOp::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgSubtractOp::next_node);
  129583             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  129584             :     Rose::MemPool::snapshot(oss.str());
  129585             :     alloc_trace_cnt++;
  129586             : #endif
  129587             : 
  129588             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  129589             : 
  129590         448 :     ALLOC_MUTEX(SgSubtractOp, unlock);
  129591             : }
  129592             : 
  129593             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  129594             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  129595             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  129596             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  129597             : // Also, note comment below from Robb (copied from the Common.code file).
  129598             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  129599             : //
  129600             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  129601             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  129602             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  129603             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  129604             : #if 0
  129605             : void SgSubtractOp::operator delete(void* pointer) { SgSubtractOp::operator delete (pointer, sizeof(SgSubtractOp)); };
  129606             : #endif
  129607             : /* #line 129608 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  129608             : 
  129609             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  129610             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  129611             : // obviously imply C++.
  129612             : 
  129613             : // This implements the support within ROSE for memory pools.  Memory pools
  129614             : // support the most condensed usage of memory within the construction of
  129615             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  129616             : // by a new operator written for each class.
  129617             : 
  129618             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  129619             :     // User wants multi-thread support and POSIX threads are available.
  129620             : #   include <pthread.h>
  129621             :     static pthread_mutex_t SgMultiplyOp_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  129622             : #else
  129623             :      // Cause synchronization to be skipped.
  129624             : #    ifndef ALLOC_MUTEX
  129625             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  129626             : #    endif
  129627             : #    ifdef _REENTRANT
  129628             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  129629             : #       ifdef _MSC_VER
  129630             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  129631             : #       else
  129632             : #           warning "POSIX threads are not available; synchronization being skipped"
  129633             : #       endif
  129634             : #    endif
  129635             : #endif
  129636             : 
  129637             : #ifndef ROSE_ALLOC_TRACE
  129638             : #  define ROSE_ALLOC_TRACE 0
  129639             : #endif
  129640             : 
  129641             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  129642             : #define ROSE_ALLOC_TRACE_CNT
  129643             : #include "memory-pool-snapshot.h"
  129644             : unsigned long alloc_trace_cnt = 0;
  129645             : #endif
  129646             : 
  129647             : #if ROSE_ALLOC_TRACE
  129648             : const unsigned SgMultiplyOp::pool_size = 5;
  129649             : #else
  129650             : const unsigned SgMultiplyOp::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  129651             : #endif
  129652             : 
  129653             : #ifndef ROSE_ALLOC_MEMSET
  129654             : #  define ROSE_ALLOC_MEMSET 0
  129655             : #endif
  129656             : 
  129657             : #ifndef ROSE_PEDANTIC_ALLOC
  129658             : #  define ROSE_PEDANTIC_ALLOC 0
  129659             : #endif
  129660             : 
  129661             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  129662             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  129663             : #endif
  129664             : 
  129665             : #if !defined(SGNODE__ALL_POOLS)
  129666             : #define SGNODE__ALL_POOLS
  129667             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  129668             : #endif
  129669             : 
  129670             : SgMultiplyOp* SgMultiplyOp::next_node = nullptr;
  129671             : std::vector<unsigned char*> SgMultiplyOp::pools;
  129672             : 
  129673             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  129674             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  129675             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  129676             : // around this macro definition rather than each use).
  129677             : #ifndef ALLOC_MUTEX
  129678             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  129679             :         do {                                                                     \
  129680             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  129681             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  129682             :                 abort();                                                         \
  129683             :             }                                                                    \
  129684             :         } while (0);
  129685             : #endif
  129686             : 
  129687             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  129688             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  129689             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  129690             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  129691             : 
  129692             : /*! \brief New operator for SgMultiplyOp.
  129693             : 
  129694             :    This new operator implements memory pools to provide most efficent 
  129695             :    use of the heap within construction of large ASTs.
  129696             : 
  129697             : \internal The new and delete operators use the lower level C malloc/free
  129698             :    function calls for performance and to make sure that mixing of malloc/free
  129699             :    and new/delete by the used can be caught more readily.  This may change
  129700             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  129701             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  129702             :    deallocate memory allocated using ROSE_MALLOC.
  129703             : */
  129704        2117 : void *SgMultiplyOp::operator new ( size_t Size )
  129705             : {
  129706             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  129707             :      * returning or throwing an exception. */
  129708        2117 :     ALLOC_MUTEX(SgMultiplyOp, lock);
  129709             : 
  129710             : #if ROSE_ALLOC_TRACE == 2
  129711             : //    printf("SgMultiplyOp::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgMultiplyOp::next_node);
  129712             : #endif
  129713             : 
  129714             : #if USE_CPP_NEW_DELETE_OPERATORS
  129715             :     void *mem = ROSE_MALLOC(Size);
  129716             :     ALLOC_MUTEX(SgMultiplyOp, unlock);
  129717             :     return mem;
  129718             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  129719             : #if ROSE_PEDANTIC_ALLOC
  129720             :     ROSE_ASSERT(Size == sizeof(SgMultiplyOp));
  129721             : #else
  129722        2117 :     if (Size != sizeof(SgMultiplyOp)) {
  129723           0 :       void * object = ROSE_MALLOC(Size);
  129724           0 :       ALLOC_MUTEX(SgMultiplyOp, unlock);
  129725             :       return object;
  129726             :     }
  129727             : #endif
  129728             : 
  129729        2117 :     if (SgMultiplyOp::next_node == nullptr) {
  129730         221 :         SgMultiplyOp * alloc = (SgMultiplyOp*) ROSE_MALLOC ( SgMultiplyOp::pool_size * sizeof(SgMultiplyOp) );
  129731         221 :         ROSE_ASSERT(alloc != nullptr);
  129732             : 
  129733             : #if ROSE_ALLOC_TRACE == 2
  129734             : //        printf("SgMultiplyOp::alloc\n  block[%zi] = [ %p , %p [\n", SgMultiplyOp::pools.size(), alloc, alloc + SgMultiplyOp::pool_size);
  129735             : #endif
  129736             : 
  129737             : #if ROSE_ALLOC_MEMSET == 1
  129738             : #elif ROSE_ALLOC_MEMSET == 2
  129739             :         memset(alloc, 0x00, SgMultiplyOp::pool_size * sizeof(SgMultiplyOp));
  129740             : #elif ROSE_ALLOC_MEMSET == 3
  129741             :         memset(alloc, 0xAA, SgMultiplyOp::pool_size * sizeof(SgMultiplyOp));
  129742             : #endif
  129743      442000 :         for (unsigned i=0; i < SgMultiplyOp::pool_size-1; i++) {
  129744      441779 :           alloc[i].p_freepointer = &(alloc[i+1]);
  129745             :         }
  129746         221 :         alloc[SgMultiplyOp::pool_size-1].p_freepointer = nullptr;
  129747             : 
  129748         221 :         SgMultiplyOp::pools.push_back ( (unsigned char *) alloc );
  129749         221 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgMultiplyOp::pool_size * sizeof(SgMultiplyOp), V_SgMultiplyOp ) );
  129750         221 :         SgMultiplyOp::next_node = alloc;
  129751             :     }
  129752        2117 :     ROSE_ASSERT(SgMultiplyOp::next_node != nullptr);
  129753             : 
  129754        2117 :     SgMultiplyOp * object = SgMultiplyOp::next_node;
  129755        2117 :     SgMultiplyOp::next_node = (SgMultiplyOp*)(object->p_freepointer);
  129756             : 
  129757             : #if ROSE_ALLOC_TRACE == 2
  129758             :     printf("SgMultiplyOp::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgMultiplyOp::next_node);
  129759             : #endif
  129760             : 
  129761        2117 :     SgNode * fp = object->p_freepointer;
  129762             : #if ROSE_ALLOC_MEMSET == 1
  129763             : #elif ROSE_ALLOC_MEMSET == 2
  129764             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgMultiplyOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  129765             : #elif ROSE_ALLOC_MEMSET == 3
  129766             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgMultiplyOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  129767             : #endif
  129768        2117 :     object->p_freepointer = fp;
  129769             : 
  129770             : #if ROSE_ALLOC_TRACE == 2
  129771             : //    printf("SgMultiplyOp::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgMultiplyOp::next_node);
  129772             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  129773             :     Rose::MemPool::snapshot(oss.str());
  129774             :     alloc_trace_cnt++;
  129775             : #endif
  129776             : 
  129777        2117 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  129778             : 
  129779        2117 :     ALLOC_MUTEX(SgMultiplyOp, unlock);
  129780             : 
  129781             :     return object;
  129782             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  129783             : }
  129784             : 
  129785             : 
  129786             : 
  129787             : /*! \brief Delete operator for SgMultiplyOp.
  129788             : 
  129789             :    This delete operator implements deallocation using memory pools to 
  129790             :    provide most efficent use of the heap within construction of large ASTs.
  129791             : 
  129792             : \internal The new and delete operators use the lower level C malloc/free
  129793             :    function calls for performance and to make sure that mixing of malloc/free
  129794             :    and new/delete by the used can be caught more readily.  This may change
  129795             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  129796             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  129797             :    deallocate memory allocated using ROSE_MALLOC.
  129798             : */
  129799         373 : void SgMultiplyOp::operator delete(void *Pointer, size_t Size)
  129800             : {
  129801             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  129802             :      * or throwing an exception. */
  129803         373 :     ALLOC_MUTEX(SgMultiplyOp, lock);
  129804             : 
  129805             : #if USE_CPP_NEW_DELETE_OPERATORS
  129806             :     ROSE_FREE(Pointer);
  129807             : #else
  129808             : #if ROSE_PEDANTIC_ALLOC
  129809             :     ROSE_ASSERT(Size == sizeof(SgMultiplyOp));
  129810             : #else
  129811         373 :     if (Size != sizeof(SgMultiplyOp)) {
  129812           0 :       ROSE_FREE(Pointer);
  129813           0 :       ALLOC_MUTEX(SgMultiplyOp, unlock);
  129814             :       return;
  129815             :     }
  129816             : #endif
  129817             : 
  129818         373 :     SgMultiplyOp * object = (SgMultiplyOp*) Pointer;
  129819         373 :     ROSE_ASSERT(object != nullptr);
  129820             : 
  129821             : #if ROSE_ALLOC_TRACE == 2
  129822             : //  printf("SgMultiplyOp::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgMultiplyOp::next_node);
  129823             :     printf("SgMultiplyOp::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgMultiplyOp::next_node);
  129824             : #endif
  129825             : 
  129826             : #if ROSE_PEDANTIC_ALLOC
  129827             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  129828             : #endif
  129829             : 
  129830             : #if ROSE_ALLOC_MEMSET == 1
  129831             : #elif ROSE_ALLOC_MEMSET == 2
  129832             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgMultiplyOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  129833             : #elif ROSE_ALLOC_MEMSET == 3
  129834             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgMultiplyOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  129835             : #endif
  129836             : 
  129837             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  129838             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  129839             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  129840             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  129841             : #else
  129842         373 :     object->p_freepointer = SgMultiplyOp::next_node;
  129843         373 :     SgMultiplyOp::next_node = object;
  129844             : #endif
  129845             : 
  129846             : #if ROSE_ALLOC_TRACE == 2
  129847             : //  printf("SgMultiplyOp::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgMultiplyOp::next_node);
  129848             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  129849             :     Rose::MemPool::snapshot(oss.str());
  129850             :     alloc_trace_cnt++;
  129851             : #endif
  129852             : 
  129853             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  129854             : 
  129855         373 :     ALLOC_MUTEX(SgMultiplyOp, unlock);
  129856             : }
  129857             : 
  129858             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  129859             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  129860             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  129861             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  129862             : // Also, note comment below from Robb (copied from the Common.code file).
  129863             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  129864             : //
  129865             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  129866             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  129867             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  129868             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  129869             : #if 0
  129870             : void SgMultiplyOp::operator delete(void* pointer) { SgMultiplyOp::operator delete (pointer, sizeof(SgMultiplyOp)); };
  129871             : #endif
  129872             : /* #line 129873 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  129873             : 
  129874             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  129875             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  129876             : // obviously imply C++.
  129877             : 
  129878             : // This implements the support within ROSE for memory pools.  Memory pools
  129879             : // support the most condensed usage of memory within the construction of
  129880             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  129881             : // by a new operator written for each class.
  129882             : 
  129883             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  129884             :     // User wants multi-thread support and POSIX threads are available.
  129885             : #   include <pthread.h>
  129886             :     static pthread_mutex_t SgDivideOp_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  129887             : #else
  129888             :      // Cause synchronization to be skipped.
  129889             : #    ifndef ALLOC_MUTEX
  129890             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  129891             : #    endif
  129892             : #    ifdef _REENTRANT
  129893             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  129894             : #       ifdef _MSC_VER
  129895             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  129896             : #       else
  129897             : #           warning "POSIX threads are not available; synchronization being skipped"
  129898             : #       endif
  129899             : #    endif
  129900             : #endif
  129901             : 
  129902             : #ifndef ROSE_ALLOC_TRACE
  129903             : #  define ROSE_ALLOC_TRACE 0
  129904             : #endif
  129905             : 
  129906             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  129907             : #define ROSE_ALLOC_TRACE_CNT
  129908             : #include "memory-pool-snapshot.h"
  129909             : unsigned long alloc_trace_cnt = 0;
  129910             : #endif
  129911             : 
  129912             : #if ROSE_ALLOC_TRACE
  129913             : const unsigned SgDivideOp::pool_size = 5;
  129914             : #else
  129915             : const unsigned SgDivideOp::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  129916             : #endif
  129917             : 
  129918             : #ifndef ROSE_ALLOC_MEMSET
  129919             : #  define ROSE_ALLOC_MEMSET 0
  129920             : #endif
  129921             : 
  129922             : #ifndef ROSE_PEDANTIC_ALLOC
  129923             : #  define ROSE_PEDANTIC_ALLOC 0
  129924             : #endif
  129925             : 
  129926             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  129927             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  129928             : #endif
  129929             : 
  129930             : #if !defined(SGNODE__ALL_POOLS)
  129931             : #define SGNODE__ALL_POOLS
  129932             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  129933             : #endif
  129934             : 
  129935             : SgDivideOp* SgDivideOp::next_node = nullptr;
  129936             : std::vector<unsigned char*> SgDivideOp::pools;
  129937             : 
  129938             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  129939             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  129940             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  129941             : // around this macro definition rather than each use).
  129942             : #ifndef ALLOC_MUTEX
  129943             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  129944             :         do {                                                                     \
  129945             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  129946             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  129947             :                 abort();                                                         \
  129948             :             }                                                                    \
  129949             :         } while (0);
  129950             : #endif
  129951             : 
  129952             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  129953             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  129954             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  129955             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  129956             : 
  129957             : /*! \brief New operator for SgDivideOp.
  129958             : 
  129959             :    This new operator implements memory pools to provide most efficent 
  129960             :    use of the heap within construction of large ASTs.
  129961             : 
  129962             : \internal The new and delete operators use the lower level C malloc/free
  129963             :    function calls for performance and to make sure that mixing of malloc/free
  129964             :    and new/delete by the used can be caught more readily.  This may change
  129965             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  129966             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  129967             :    deallocate memory allocated using ROSE_MALLOC.
  129968             : */
  129969        1211 : void *SgDivideOp::operator new ( size_t Size )
  129970             : {
  129971             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  129972             :      * returning or throwing an exception. */
  129973        1211 :     ALLOC_MUTEX(SgDivideOp, lock);
  129974             : 
  129975             : #if ROSE_ALLOC_TRACE == 2
  129976             : //    printf("SgDivideOp::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgDivideOp::next_node);
  129977             : #endif
  129978             : 
  129979             : #if USE_CPP_NEW_DELETE_OPERATORS
  129980             :     void *mem = ROSE_MALLOC(Size);
  129981             :     ALLOC_MUTEX(SgDivideOp, unlock);
  129982             :     return mem;
  129983             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  129984             : #if ROSE_PEDANTIC_ALLOC
  129985             :     ROSE_ASSERT(Size == sizeof(SgDivideOp));
  129986             : #else
  129987        1211 :     if (Size != sizeof(SgDivideOp)) {
  129988           0 :       void * object = ROSE_MALLOC(Size);
  129989           0 :       ALLOC_MUTEX(SgDivideOp, unlock);
  129990             :       return object;
  129991             :     }
  129992             : #endif
  129993             : 
  129994        1211 :     if (SgDivideOp::next_node == nullptr) {
  129995         191 :         SgDivideOp * alloc = (SgDivideOp*) ROSE_MALLOC ( SgDivideOp::pool_size * sizeof(SgDivideOp) );
  129996         191 :         ROSE_ASSERT(alloc != nullptr);
  129997             : 
  129998             : #if ROSE_ALLOC_TRACE == 2
  129999             : //        printf("SgDivideOp::alloc\n  block[%zi] = [ %p , %p [\n", SgDivideOp::pools.size(), alloc, alloc + SgDivideOp::pool_size);
  130000             : #endif
  130001             : 
  130002             : #if ROSE_ALLOC_MEMSET == 1
  130003             : #elif ROSE_ALLOC_MEMSET == 2
  130004             :         memset(alloc, 0x00, SgDivideOp::pool_size * sizeof(SgDivideOp));
  130005             : #elif ROSE_ALLOC_MEMSET == 3
  130006             :         memset(alloc, 0xAA, SgDivideOp::pool_size * sizeof(SgDivideOp));
  130007             : #endif
  130008      382000 :         for (unsigned i=0; i < SgDivideOp::pool_size-1; i++) {
  130009      381809 :           alloc[i].p_freepointer = &(alloc[i+1]);
  130010             :         }
  130011         191 :         alloc[SgDivideOp::pool_size-1].p_freepointer = nullptr;
  130012             : 
  130013         191 :         SgDivideOp::pools.push_back ( (unsigned char *) alloc );
  130014         191 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgDivideOp::pool_size * sizeof(SgDivideOp), V_SgDivideOp ) );
  130015         191 :         SgDivideOp::next_node = alloc;
  130016             :     }
  130017        1211 :     ROSE_ASSERT(SgDivideOp::next_node != nullptr);
  130018             : 
  130019        1211 :     SgDivideOp * object = SgDivideOp::next_node;
  130020        1211 :     SgDivideOp::next_node = (SgDivideOp*)(object->p_freepointer);
  130021             : 
  130022             : #if ROSE_ALLOC_TRACE == 2
  130023             :     printf("SgDivideOp::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgDivideOp::next_node);
  130024             : #endif
  130025             : 
  130026        1211 :     SgNode * fp = object->p_freepointer;
  130027             : #if ROSE_ALLOC_MEMSET == 1
  130028             : #elif ROSE_ALLOC_MEMSET == 2
  130029             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgDivideOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  130030             : #elif ROSE_ALLOC_MEMSET == 3
  130031             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgDivideOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  130032             : #endif
  130033        1211 :     object->p_freepointer = fp;
  130034             : 
  130035             : #if ROSE_ALLOC_TRACE == 2
  130036             : //    printf("SgDivideOp::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgDivideOp::next_node);
  130037             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  130038             :     Rose::MemPool::snapshot(oss.str());
  130039             :     alloc_trace_cnt++;
  130040             : #endif
  130041             : 
  130042        1211 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  130043             : 
  130044        1211 :     ALLOC_MUTEX(SgDivideOp, unlock);
  130045             : 
  130046             :     return object;
  130047             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  130048             : }
  130049             : 
  130050             : 
  130051             : 
  130052             : /*! \brief Delete operator for SgDivideOp.
  130053             : 
  130054             :    This delete operator implements deallocation using memory pools to 
  130055             :    provide most efficent use of the heap within construction of large ASTs.
  130056             : 
  130057             : \internal The new and delete operators use the lower level C malloc/free
  130058             :    function calls for performance and to make sure that mixing of malloc/free
  130059             :    and new/delete by the used can be caught more readily.  This may change
  130060             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  130061             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  130062             :    deallocate memory allocated using ROSE_MALLOC.
  130063             : */
  130064         276 : void SgDivideOp::operator delete(void *Pointer, size_t Size)
  130065             : {
  130066             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  130067             :      * or throwing an exception. */
  130068         276 :     ALLOC_MUTEX(SgDivideOp, lock);
  130069             : 
  130070             : #if USE_CPP_NEW_DELETE_OPERATORS
  130071             :     ROSE_FREE(Pointer);
  130072             : #else
  130073             : #if ROSE_PEDANTIC_ALLOC
  130074             :     ROSE_ASSERT(Size == sizeof(SgDivideOp));
  130075             : #else
  130076         276 :     if (Size != sizeof(SgDivideOp)) {
  130077           0 :       ROSE_FREE(Pointer);
  130078           0 :       ALLOC_MUTEX(SgDivideOp, unlock);
  130079             :       return;
  130080             :     }
  130081             : #endif
  130082             : 
  130083         276 :     SgDivideOp * object = (SgDivideOp*) Pointer;
  130084         276 :     ROSE_ASSERT(object != nullptr);
  130085             : 
  130086             : #if ROSE_ALLOC_TRACE == 2
  130087             : //  printf("SgDivideOp::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgDivideOp::next_node);
  130088             :     printf("SgDivideOp::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgDivideOp::next_node);
  130089             : #endif
  130090             : 
  130091             : #if ROSE_PEDANTIC_ALLOC
  130092             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  130093             : #endif
  130094             : 
  130095             : #if ROSE_ALLOC_MEMSET == 1
  130096             : #elif ROSE_ALLOC_MEMSET == 2
  130097             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgDivideOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  130098             : #elif ROSE_ALLOC_MEMSET == 3
  130099             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgDivideOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  130100             : #endif
  130101             : 
  130102             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  130103             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  130104             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  130105             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  130106             : #else
  130107         276 :     object->p_freepointer = SgDivideOp::next_node;
  130108         276 :     SgDivideOp::next_node = object;
  130109             : #endif
  130110             : 
  130111             : #if ROSE_ALLOC_TRACE == 2
  130112             : //  printf("SgDivideOp::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgDivideOp::next_node);
  130113             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  130114             :     Rose::MemPool::snapshot(oss.str());
  130115             :     alloc_trace_cnt++;
  130116             : #endif
  130117             : 
  130118             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  130119             : 
  130120         276 :     ALLOC_MUTEX(SgDivideOp, unlock);
  130121             : }
  130122             : 
  130123             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  130124             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  130125             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  130126             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  130127             : // Also, note comment below from Robb (copied from the Common.code file).
  130128             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  130129             : //
  130130             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  130131             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  130132             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  130133             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  130134             : #if 0
  130135             : void SgDivideOp::operator delete(void* pointer) { SgDivideOp::operator delete (pointer, sizeof(SgDivideOp)); };
  130136             : #endif
  130137             : /* #line 130138 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  130138             : 
  130139             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  130140             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  130141             : // obviously imply C++.
  130142             : 
  130143             : // This implements the support within ROSE for memory pools.  Memory pools
  130144             : // support the most condensed usage of memory within the construction of
  130145             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  130146             : // by a new operator written for each class.
  130147             : 
  130148             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  130149             :     // User wants multi-thread support and POSIX threads are available.
  130150             : #   include <pthread.h>
  130151             :     static pthread_mutex_t SgIntegerDivideOp_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  130152             : #else
  130153             :      // Cause synchronization to be skipped.
  130154             : #    ifndef ALLOC_MUTEX
  130155             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  130156             : #    endif
  130157             : #    ifdef _REENTRANT
  130158             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  130159             : #       ifdef _MSC_VER
  130160             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  130161             : #       else
  130162             : #           warning "POSIX threads are not available; synchronization being skipped"
  130163             : #       endif
  130164             : #    endif
  130165             : #endif
  130166             : 
  130167             : #ifndef ROSE_ALLOC_TRACE
  130168             : #  define ROSE_ALLOC_TRACE 0
  130169             : #endif
  130170             : 
  130171             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  130172             : #define ROSE_ALLOC_TRACE_CNT
  130173             : #include "memory-pool-snapshot.h"
  130174             : unsigned long alloc_trace_cnt = 0;
  130175             : #endif
  130176             : 
  130177             : #if ROSE_ALLOC_TRACE
  130178             : const unsigned SgIntegerDivideOp::pool_size = 5;
  130179             : #else
  130180             : const unsigned SgIntegerDivideOp::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  130181             : #endif
  130182             : 
  130183             : #ifndef ROSE_ALLOC_MEMSET
  130184             : #  define ROSE_ALLOC_MEMSET 0
  130185             : #endif
  130186             : 
  130187             : #ifndef ROSE_PEDANTIC_ALLOC
  130188             : #  define ROSE_PEDANTIC_ALLOC 0
  130189             : #endif
  130190             : 
  130191             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  130192             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  130193             : #endif
  130194             : 
  130195             : #if !defined(SGNODE__ALL_POOLS)
  130196             : #define SGNODE__ALL_POOLS
  130197             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  130198             : #endif
  130199             : 
  130200             : SgIntegerDivideOp* SgIntegerDivideOp::next_node = nullptr;
  130201             : std::vector<unsigned char*> SgIntegerDivideOp::pools;
  130202             : 
  130203             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  130204             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  130205             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  130206             : // around this macro definition rather than each use).
  130207             : #ifndef ALLOC_MUTEX
  130208             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  130209             :         do {                                                                     \
  130210             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  130211             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  130212             :                 abort();                                                         \
  130213             :             }                                                                    \
  130214             :         } while (0);
  130215             : #endif
  130216             : 
  130217             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  130218             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  130219             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  130220             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  130221             : 
  130222             : /*! \brief New operator for SgIntegerDivideOp.
  130223             : 
  130224             :    This new operator implements memory pools to provide most efficent 
  130225             :    use of the heap within construction of large ASTs.
  130226             : 
  130227             : \internal The new and delete operators use the lower level C malloc/free
  130228             :    function calls for performance and to make sure that mixing of malloc/free
  130229             :    and new/delete by the used can be caught more readily.  This may change
  130230             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  130231             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  130232             :    deallocate memory allocated using ROSE_MALLOC.
  130233             : */
  130234           0 : void *SgIntegerDivideOp::operator new ( size_t Size )
  130235             : {
  130236             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  130237             :      * returning or throwing an exception. */
  130238           0 :     ALLOC_MUTEX(SgIntegerDivideOp, lock);
  130239             : 
  130240             : #if ROSE_ALLOC_TRACE == 2
  130241             : //    printf("SgIntegerDivideOp::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgIntegerDivideOp::next_node);
  130242             : #endif
  130243             : 
  130244             : #if USE_CPP_NEW_DELETE_OPERATORS
  130245             :     void *mem = ROSE_MALLOC(Size);
  130246             :     ALLOC_MUTEX(SgIntegerDivideOp, unlock);
  130247             :     return mem;
  130248             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  130249             : #if ROSE_PEDANTIC_ALLOC
  130250             :     ROSE_ASSERT(Size == sizeof(SgIntegerDivideOp));
  130251             : #else
  130252           0 :     if (Size != sizeof(SgIntegerDivideOp)) {
  130253           0 :       void * object = ROSE_MALLOC(Size);
  130254           0 :       ALLOC_MUTEX(SgIntegerDivideOp, unlock);
  130255             :       return object;
  130256             :     }
  130257             : #endif
  130258             : 
  130259           0 :     if (SgIntegerDivideOp::next_node == nullptr) {
  130260           0 :         SgIntegerDivideOp * alloc = (SgIntegerDivideOp*) ROSE_MALLOC ( SgIntegerDivideOp::pool_size * sizeof(SgIntegerDivideOp) );
  130261           0 :         ROSE_ASSERT(alloc != nullptr);
  130262             : 
  130263             : #if ROSE_ALLOC_TRACE == 2
  130264             : //        printf("SgIntegerDivideOp::alloc\n  block[%zi] = [ %p , %p [\n", SgIntegerDivideOp::pools.size(), alloc, alloc + SgIntegerDivideOp::pool_size);
  130265             : #endif
  130266             : 
  130267             : #if ROSE_ALLOC_MEMSET == 1
  130268             : #elif ROSE_ALLOC_MEMSET == 2
  130269             :         memset(alloc, 0x00, SgIntegerDivideOp::pool_size * sizeof(SgIntegerDivideOp));
  130270             : #elif ROSE_ALLOC_MEMSET == 3
  130271             :         memset(alloc, 0xAA, SgIntegerDivideOp::pool_size * sizeof(SgIntegerDivideOp));
  130272             : #endif
  130273           0 :         for (unsigned i=0; i < SgIntegerDivideOp::pool_size-1; i++) {
  130274           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
  130275             :         }
  130276           0 :         alloc[SgIntegerDivideOp::pool_size-1].p_freepointer = nullptr;
  130277             : 
  130278           0 :         SgIntegerDivideOp::pools.push_back ( (unsigned char *) alloc );
  130279           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgIntegerDivideOp::pool_size * sizeof(SgIntegerDivideOp), V_SgIntegerDivideOp ) );
  130280           0 :         SgIntegerDivideOp::next_node = alloc;
  130281             :     }
  130282           0 :     ROSE_ASSERT(SgIntegerDivideOp::next_node != nullptr);
  130283             : 
  130284           0 :     SgIntegerDivideOp * object = SgIntegerDivideOp::next_node;
  130285           0 :     SgIntegerDivideOp::next_node = (SgIntegerDivideOp*)(object->p_freepointer);
  130286             : 
  130287             : #if ROSE_ALLOC_TRACE == 2
  130288             :     printf("SgIntegerDivideOp::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgIntegerDivideOp::next_node);
  130289             : #endif
  130290             : 
  130291           0 :     SgNode * fp = object->p_freepointer;
  130292             : #if ROSE_ALLOC_MEMSET == 1
  130293             : #elif ROSE_ALLOC_MEMSET == 2
  130294             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgIntegerDivideOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  130295             : #elif ROSE_ALLOC_MEMSET == 3
  130296             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgIntegerDivideOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  130297             : #endif
  130298           0 :     object->p_freepointer = fp;
  130299             : 
  130300             : #if ROSE_ALLOC_TRACE == 2
  130301             : //    printf("SgIntegerDivideOp::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgIntegerDivideOp::next_node);
  130302             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  130303             :     Rose::MemPool::snapshot(oss.str());
  130304             :     alloc_trace_cnt++;
  130305             : #endif
  130306             : 
  130307           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  130308             : 
  130309           0 :     ALLOC_MUTEX(SgIntegerDivideOp, unlock);
  130310             : 
  130311             :     return object;
  130312             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  130313             : }
  130314             : 
  130315             : 
  130316             : 
  130317             : /*! \brief Delete operator for SgIntegerDivideOp.
  130318             : 
  130319             :    This delete operator implements deallocation using memory pools to 
  130320             :    provide most efficent use of the heap within construction of large ASTs.
  130321             : 
  130322             : \internal The new and delete operators use the lower level C malloc/free
  130323             :    function calls for performance and to make sure that mixing of malloc/free
  130324             :    and new/delete by the used can be caught more readily.  This may change
  130325             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  130326             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  130327             :    deallocate memory allocated using ROSE_MALLOC.
  130328             : */
  130329           0 : void SgIntegerDivideOp::operator delete(void *Pointer, size_t Size)
  130330             : {
  130331             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  130332             :      * or throwing an exception. */
  130333           0 :     ALLOC_MUTEX(SgIntegerDivideOp, lock);
  130334             : 
  130335             : #if USE_CPP_NEW_DELETE_OPERATORS
  130336             :     ROSE_FREE(Pointer);
  130337             : #else
  130338             : #if ROSE_PEDANTIC_ALLOC
  130339             :     ROSE_ASSERT(Size == sizeof(SgIntegerDivideOp));
  130340             : #else
  130341           0 :     if (Size != sizeof(SgIntegerDivideOp)) {
  130342           0 :       ROSE_FREE(Pointer);
  130343           0 :       ALLOC_MUTEX(SgIntegerDivideOp, unlock);
  130344             :       return;
  130345             :     }
  130346             : #endif
  130347             : 
  130348           0 :     SgIntegerDivideOp * object = (SgIntegerDivideOp*) Pointer;
  130349           0 :     ROSE_ASSERT(object != nullptr);
  130350             : 
  130351             : #if ROSE_ALLOC_TRACE == 2
  130352             : //  printf("SgIntegerDivideOp::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgIntegerDivideOp::next_node);
  130353             :     printf("SgIntegerDivideOp::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgIntegerDivideOp::next_node);
  130354             : #endif
  130355             : 
  130356             : #if ROSE_PEDANTIC_ALLOC
  130357             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  130358             : #endif
  130359             : 
  130360             : #if ROSE_ALLOC_MEMSET == 1
  130361             : #elif ROSE_ALLOC_MEMSET == 2
  130362             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgIntegerDivideOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  130363             : #elif ROSE_ALLOC_MEMSET == 3
  130364             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgIntegerDivideOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  130365             : #endif
  130366             : 
  130367             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  130368             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  130369             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  130370             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  130371             : #else
  130372           0 :     object->p_freepointer = SgIntegerDivideOp::next_node;
  130373           0 :     SgIntegerDivideOp::next_node = object;
  130374             : #endif
  130375             : 
  130376             : #if ROSE_ALLOC_TRACE == 2
  130377             : //  printf("SgIntegerDivideOp::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgIntegerDivideOp::next_node);
  130378             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  130379             :     Rose::MemPool::snapshot(oss.str());
  130380             :     alloc_trace_cnt++;
  130381             : #endif
  130382             : 
  130383             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  130384             : 
  130385           0 :     ALLOC_MUTEX(SgIntegerDivideOp, unlock);
  130386             : }
  130387             : 
  130388             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  130389             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  130390             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  130391             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  130392             : // Also, note comment below from Robb (copied from the Common.code file).
  130393             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  130394             : //
  130395             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  130396             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  130397             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  130398             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  130399             : #if 0
  130400             : void SgIntegerDivideOp::operator delete(void* pointer) { SgIntegerDivideOp::operator delete (pointer, sizeof(SgIntegerDivideOp)); };
  130401             : #endif
  130402             : /* #line 130403 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  130403             : 
  130404             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  130405             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  130406             : // obviously imply C++.
  130407             : 
  130408             : // This implements the support within ROSE for memory pools.  Memory pools
  130409             : // support the most condensed usage of memory within the construction of
  130410             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  130411             : // by a new operator written for each class.
  130412             : 
  130413             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  130414             :     // User wants multi-thread support and POSIX threads are available.
  130415             : #   include <pthread.h>
  130416             :     static pthread_mutex_t SgModOp_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  130417             : #else
  130418             :      // Cause synchronization to be skipped.
  130419             : #    ifndef ALLOC_MUTEX
  130420             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  130421             : #    endif
  130422             : #    ifdef _REENTRANT
  130423             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  130424             : #       ifdef _MSC_VER
  130425             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  130426             : #       else
  130427             : #           warning "POSIX threads are not available; synchronization being skipped"
  130428             : #       endif
  130429             : #    endif
  130430             : #endif
  130431             : 
  130432             : #ifndef ROSE_ALLOC_TRACE
  130433             : #  define ROSE_ALLOC_TRACE 0
  130434             : #endif
  130435             : 
  130436             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  130437             : #define ROSE_ALLOC_TRACE_CNT
  130438             : #include "memory-pool-snapshot.h"
  130439             : unsigned long alloc_trace_cnt = 0;
  130440             : #endif
  130441             : 
  130442             : #if ROSE_ALLOC_TRACE
  130443             : const unsigned SgModOp::pool_size = 5;
  130444             : #else
  130445             : const unsigned SgModOp::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  130446             : #endif
  130447             : 
  130448             : #ifndef ROSE_ALLOC_MEMSET
  130449             : #  define ROSE_ALLOC_MEMSET 0
  130450             : #endif
  130451             : 
  130452             : #ifndef ROSE_PEDANTIC_ALLOC
  130453             : #  define ROSE_PEDANTIC_ALLOC 0
  130454             : #endif
  130455             : 
  130456             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  130457             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  130458             : #endif
  130459             : 
  130460             : #if !defined(SGNODE__ALL_POOLS)
  130461             : #define SGNODE__ALL_POOLS
  130462             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  130463             : #endif
  130464             : 
  130465             : SgModOp* SgModOp::next_node = nullptr;
  130466             : std::vector<unsigned char*> SgModOp::pools;
  130467             : 
  130468             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  130469             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  130470             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  130471             : // around this macro definition rather than each use).
  130472             : #ifndef ALLOC_MUTEX
  130473             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  130474             :         do {                                                                     \
  130475             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  130476             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  130477             :                 abort();                                                         \
  130478             :             }                                                                    \
  130479             :         } while (0);
  130480             : #endif
  130481             : 
  130482             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  130483             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  130484             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  130485             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  130486             : 
  130487             : /*! \brief New operator for SgModOp.
  130488             : 
  130489             :    This new operator implements memory pools to provide most efficent 
  130490             :    use of the heap within construction of large ASTs.
  130491             : 
  130492             : \internal The new and delete operators use the lower level C malloc/free
  130493             :    function calls for performance and to make sure that mixing of malloc/free
  130494             :    and new/delete by the used can be caught more readily.  This may change
  130495             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  130496             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  130497             :    deallocate memory allocated using ROSE_MALLOC.
  130498             : */
  130499         113 : void *SgModOp::operator new ( size_t Size )
  130500             : {
  130501             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  130502             :      * returning or throwing an exception. */
  130503         113 :     ALLOC_MUTEX(SgModOp, lock);
  130504             : 
  130505             : #if ROSE_ALLOC_TRACE == 2
  130506             : //    printf("SgModOp::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgModOp::next_node);
  130507             : #endif
  130508             : 
  130509             : #if USE_CPP_NEW_DELETE_OPERATORS
  130510             :     void *mem = ROSE_MALLOC(Size);
  130511             :     ALLOC_MUTEX(SgModOp, unlock);
  130512             :     return mem;
  130513             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  130514             : #if ROSE_PEDANTIC_ALLOC
  130515             :     ROSE_ASSERT(Size == sizeof(SgModOp));
  130516             : #else
  130517         113 :     if (Size != sizeof(SgModOp)) {
  130518           0 :       void * object = ROSE_MALLOC(Size);
  130519           0 :       ALLOC_MUTEX(SgModOp, unlock);
  130520             :       return object;
  130521             :     }
  130522             : #endif
  130523             : 
  130524         113 :     if (SgModOp::next_node == nullptr) {
  130525          32 :         SgModOp * alloc = (SgModOp*) ROSE_MALLOC ( SgModOp::pool_size * sizeof(SgModOp) );
  130526          32 :         ROSE_ASSERT(alloc != nullptr);
  130527             : 
  130528             : #if ROSE_ALLOC_TRACE == 2
  130529             : //        printf("SgModOp::alloc\n  block[%zi] = [ %p , %p [\n", SgModOp::pools.size(), alloc, alloc + SgModOp::pool_size);
  130530             : #endif
  130531             : 
  130532             : #if ROSE_ALLOC_MEMSET == 1
  130533             : #elif ROSE_ALLOC_MEMSET == 2
  130534             :         memset(alloc, 0x00, SgModOp::pool_size * sizeof(SgModOp));
  130535             : #elif ROSE_ALLOC_MEMSET == 3
  130536             :         memset(alloc, 0xAA, SgModOp::pool_size * sizeof(SgModOp));
  130537             : #endif
  130538       64000 :         for (unsigned i=0; i < SgModOp::pool_size-1; i++) {
  130539       63968 :           alloc[i].p_freepointer = &(alloc[i+1]);
  130540             :         }
  130541          32 :         alloc[SgModOp::pool_size-1].p_freepointer = nullptr;
  130542             : 
  130543          32 :         SgModOp::pools.push_back ( (unsigned char *) alloc );
  130544          32 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgModOp::pool_size * sizeof(SgModOp), V_SgModOp ) );
  130545          32 :         SgModOp::next_node = alloc;
  130546             :     }
  130547         113 :     ROSE_ASSERT(SgModOp::next_node != nullptr);
  130548             : 
  130549         113 :     SgModOp * object = SgModOp::next_node;
  130550         113 :     SgModOp::next_node = (SgModOp*)(object->p_freepointer);
  130551             : 
  130552             : #if ROSE_ALLOC_TRACE == 2
  130553             :     printf("SgModOp::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgModOp::next_node);
  130554             : #endif
  130555             : 
  130556         113 :     SgNode * fp = object->p_freepointer;
  130557             : #if ROSE_ALLOC_MEMSET == 1
  130558             : #elif ROSE_ALLOC_MEMSET == 2
  130559             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgModOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  130560             : #elif ROSE_ALLOC_MEMSET == 3
  130561             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgModOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  130562             : #endif
  130563         113 :     object->p_freepointer = fp;
  130564             : 
  130565             : #if ROSE_ALLOC_TRACE == 2
  130566             : //    printf("SgModOp::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgModOp::next_node);
  130567             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  130568             :     Rose::MemPool::snapshot(oss.str());
  130569             :     alloc_trace_cnt++;
  130570             : #endif
  130571             : 
  130572         113 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  130573             : 
  130574         113 :     ALLOC_MUTEX(SgModOp, unlock);
  130575             : 
  130576             :     return object;
  130577             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  130578             : }
  130579             : 
  130580             : 
  130581             : 
  130582             : /*! \brief Delete operator for SgModOp.
  130583             : 
  130584             :    This delete operator implements deallocation using memory pools to 
  130585             :    provide most efficent use of the heap within construction of large ASTs.
  130586             : 
  130587             : \internal The new and delete operators use the lower level C malloc/free
  130588             :    function calls for performance and to make sure that mixing of malloc/free
  130589             :    and new/delete by the used can be caught more readily.  This may change
  130590             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  130591             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  130592             :    deallocate memory allocated using ROSE_MALLOC.
  130593             : */
  130594          10 : void SgModOp::operator delete(void *Pointer, size_t Size)
  130595             : {
  130596             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  130597             :      * or throwing an exception. */
  130598          10 :     ALLOC_MUTEX(SgModOp, lock);
  130599             : 
  130600             : #if USE_CPP_NEW_DELETE_OPERATORS
  130601             :     ROSE_FREE(Pointer);
  130602             : #else
  130603             : #if ROSE_PEDANTIC_ALLOC
  130604             :     ROSE_ASSERT(Size == sizeof(SgModOp));
  130605             : #else
  130606          10 :     if (Size != sizeof(SgModOp)) {
  130607           0 :       ROSE_FREE(Pointer);
  130608           0 :       ALLOC_MUTEX(SgModOp, unlock);
  130609             :       return;
  130610             :     }
  130611             : #endif
  130612             : 
  130613          10 :     SgModOp * object = (SgModOp*) Pointer;
  130614          10 :     ROSE_ASSERT(object != nullptr);
  130615             : 
  130616             : #if ROSE_ALLOC_TRACE == 2
  130617             : //  printf("SgModOp::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgModOp::next_node);
  130618             :     printf("SgModOp::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgModOp::next_node);
  130619             : #endif
  130620             : 
  130621             : #if ROSE_PEDANTIC_ALLOC
  130622             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  130623             : #endif
  130624             : 
  130625             : #if ROSE_ALLOC_MEMSET == 1
  130626             : #elif ROSE_ALLOC_MEMSET == 2
  130627             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgModOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  130628             : #elif ROSE_ALLOC_MEMSET == 3
  130629             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgModOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  130630             : #endif
  130631             : 
  130632             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  130633             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  130634             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  130635             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  130636             : #else
  130637          10 :     object->p_freepointer = SgModOp::next_node;
  130638          10 :     SgModOp::next_node = object;
  130639             : #endif
  130640             : 
  130641             : #if ROSE_ALLOC_TRACE == 2
  130642             : //  printf("SgModOp::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgModOp::next_node);
  130643             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  130644             :     Rose::MemPool::snapshot(oss.str());
  130645             :     alloc_trace_cnt++;
  130646             : #endif
  130647             : 
  130648             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  130649             : 
  130650          10 :     ALLOC_MUTEX(SgModOp, unlock);
  130651             : }
  130652             : 
  130653             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  130654             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  130655             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  130656             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  130657             : // Also, note comment below from Robb (copied from the Common.code file).
  130658             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  130659             : //
  130660             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  130661             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  130662             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  130663             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  130664             : #if 0
  130665             : void SgModOp::operator delete(void* pointer) { SgModOp::operator delete (pointer, sizeof(SgModOp)); };
  130666             : #endif
  130667             : /* #line 130668 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  130668             : 
  130669             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  130670             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  130671             : // obviously imply C++.
  130672             : 
  130673             : // This implements the support within ROSE for memory pools.  Memory pools
  130674             : // support the most condensed usage of memory within the construction of
  130675             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  130676             : // by a new operator written for each class.
  130677             : 
  130678             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  130679             :     // User wants multi-thread support and POSIX threads are available.
  130680             : #   include <pthread.h>
  130681             :     static pthread_mutex_t SgAndOp_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  130682             : #else
  130683             :      // Cause synchronization to be skipped.
  130684             : #    ifndef ALLOC_MUTEX
  130685             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  130686             : #    endif
  130687             : #    ifdef _REENTRANT
  130688             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  130689             : #       ifdef _MSC_VER
  130690             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  130691             : #       else
  130692             : #           warning "POSIX threads are not available; synchronization being skipped"
  130693             : #       endif
  130694             : #    endif
  130695             : #endif
  130696             : 
  130697             : #ifndef ROSE_ALLOC_TRACE
  130698             : #  define ROSE_ALLOC_TRACE 0
  130699             : #endif
  130700             : 
  130701             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  130702             : #define ROSE_ALLOC_TRACE_CNT
  130703             : #include "memory-pool-snapshot.h"
  130704             : unsigned long alloc_trace_cnt = 0;
  130705             : #endif
  130706             : 
  130707             : #if ROSE_ALLOC_TRACE
  130708             : const unsigned SgAndOp::pool_size = 5;
  130709             : #else
  130710             : const unsigned SgAndOp::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  130711             : #endif
  130712             : 
  130713             : #ifndef ROSE_ALLOC_MEMSET
  130714             : #  define ROSE_ALLOC_MEMSET 0
  130715             : #endif
  130716             : 
  130717             : #ifndef ROSE_PEDANTIC_ALLOC
  130718             : #  define ROSE_PEDANTIC_ALLOC 0
  130719             : #endif
  130720             : 
  130721             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  130722             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  130723             : #endif
  130724             : 
  130725             : #if !defined(SGNODE__ALL_POOLS)
  130726             : #define SGNODE__ALL_POOLS
  130727             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  130728             : #endif
  130729             : 
  130730             : SgAndOp* SgAndOp::next_node = nullptr;
  130731             : std::vector<unsigned char*> SgAndOp::pools;
  130732             : 
  130733             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  130734             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  130735             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  130736             : // around this macro definition rather than each use).
  130737             : #ifndef ALLOC_MUTEX
  130738             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  130739             :         do {                                                                     \
  130740             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  130741             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  130742             :                 abort();                                                         \
  130743             :             }                                                                    \
  130744             :         } while (0);
  130745             : #endif
  130746             : 
  130747             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  130748             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  130749             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  130750             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  130751             : 
  130752             : /*! \brief New operator for SgAndOp.
  130753             : 
  130754             :    This new operator implements memory pools to provide most efficent 
  130755             :    use of the heap within construction of large ASTs.
  130756             : 
  130757             : \internal The new and delete operators use the lower level C malloc/free
  130758             :    function calls for performance and to make sure that mixing of malloc/free
  130759             :    and new/delete by the used can be caught more readily.  This may change
  130760             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  130761             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  130762             :    deallocate memory allocated using ROSE_MALLOC.
  130763             : */
  130764        1964 : void *SgAndOp::operator new ( size_t Size )
  130765             : {
  130766             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  130767             :      * returning or throwing an exception. */
  130768        1964 :     ALLOC_MUTEX(SgAndOp, lock);
  130769             : 
  130770             : #if ROSE_ALLOC_TRACE == 2
  130771             : //    printf("SgAndOp::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgAndOp::next_node);
  130772             : #endif
  130773             : 
  130774             : #if USE_CPP_NEW_DELETE_OPERATORS
  130775             :     void *mem = ROSE_MALLOC(Size);
  130776             :     ALLOC_MUTEX(SgAndOp, unlock);
  130777             :     return mem;
  130778             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  130779             : #if ROSE_PEDANTIC_ALLOC
  130780             :     ROSE_ASSERT(Size == sizeof(SgAndOp));
  130781             : #else
  130782        1964 :     if (Size != sizeof(SgAndOp)) {
  130783           0 :       void * object = ROSE_MALLOC(Size);
  130784           0 :       ALLOC_MUTEX(SgAndOp, unlock);
  130785             :       return object;
  130786             :     }
  130787             : #endif
  130788             : 
  130789        1964 :     if (SgAndOp::next_node == nullptr) {
  130790          29 :         SgAndOp * alloc = (SgAndOp*) ROSE_MALLOC ( SgAndOp::pool_size * sizeof(SgAndOp) );
  130791          29 :         ROSE_ASSERT(alloc != nullptr);
  130792             : 
  130793             : #if ROSE_ALLOC_TRACE == 2
  130794             : //        printf("SgAndOp::alloc\n  block[%zi] = [ %p , %p [\n", SgAndOp::pools.size(), alloc, alloc + SgAndOp::pool_size);
  130795             : #endif
  130796             : 
  130797             : #if ROSE_ALLOC_MEMSET == 1
  130798             : #elif ROSE_ALLOC_MEMSET == 2
  130799             :         memset(alloc, 0x00, SgAndOp::pool_size * sizeof(SgAndOp));
  130800             : #elif ROSE_ALLOC_MEMSET == 3
  130801             :         memset(alloc, 0xAA, SgAndOp::pool_size * sizeof(SgAndOp));
  130802             : #endif
  130803       58000 :         for (unsigned i=0; i < SgAndOp::pool_size-1; i++) {
  130804       57971 :           alloc[i].p_freepointer = &(alloc[i+1]);
  130805             :         }
  130806          29 :         alloc[SgAndOp::pool_size-1].p_freepointer = nullptr;
  130807             : 
  130808          29 :         SgAndOp::pools.push_back ( (unsigned char *) alloc );
  130809          29 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgAndOp::pool_size * sizeof(SgAndOp), V_SgAndOp ) );
  130810          29 :         SgAndOp::next_node = alloc;
  130811             :     }
  130812        1964 :     ROSE_ASSERT(SgAndOp::next_node != nullptr);
  130813             : 
  130814        1964 :     SgAndOp * object = SgAndOp::next_node;
  130815        1964 :     SgAndOp::next_node = (SgAndOp*)(object->p_freepointer);
  130816             : 
  130817             : #if ROSE_ALLOC_TRACE == 2
  130818             :     printf("SgAndOp::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgAndOp::next_node);
  130819             : #endif
  130820             : 
  130821        1964 :     SgNode * fp = object->p_freepointer;
  130822             : #if ROSE_ALLOC_MEMSET == 1
  130823             : #elif ROSE_ALLOC_MEMSET == 2
  130824             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgAndOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  130825             : #elif ROSE_ALLOC_MEMSET == 3
  130826             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgAndOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  130827             : #endif
  130828        1964 :     object->p_freepointer = fp;
  130829             : 
  130830             : #if ROSE_ALLOC_TRACE == 2
  130831             : //    printf("SgAndOp::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgAndOp::next_node);
  130832             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  130833             :     Rose::MemPool::snapshot(oss.str());
  130834             :     alloc_trace_cnt++;
  130835             : #endif
  130836             : 
  130837        1964 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  130838             : 
  130839        1964 :     ALLOC_MUTEX(SgAndOp, unlock);
  130840             : 
  130841             :     return object;
  130842             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  130843             : }
  130844             : 
  130845             : 
  130846             : 
  130847             : /*! \brief Delete operator for SgAndOp.
  130848             : 
  130849             :    This delete operator implements deallocation using memory pools to 
  130850             :    provide most efficent use of the heap within construction of large ASTs.
  130851             : 
  130852             : \internal The new and delete operators use the lower level C malloc/free
  130853             :    function calls for performance and to make sure that mixing of malloc/free
  130854             :    and new/delete by the used can be caught more readily.  This may change
  130855             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  130856             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  130857             :    deallocate memory allocated using ROSE_MALLOC.
  130858             : */
  130859         386 : void SgAndOp::operator delete(void *Pointer, size_t Size)
  130860             : {
  130861             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  130862             :      * or throwing an exception. */
  130863         386 :     ALLOC_MUTEX(SgAndOp, lock);
  130864             : 
  130865             : #if USE_CPP_NEW_DELETE_OPERATORS
  130866             :     ROSE_FREE(Pointer);
  130867             : #else
  130868             : #if ROSE_PEDANTIC_ALLOC
  130869             :     ROSE_ASSERT(Size == sizeof(SgAndOp));
  130870             : #else
  130871         386 :     if (Size != sizeof(SgAndOp)) {
  130872           0 :       ROSE_FREE(Pointer);
  130873           0 :       ALLOC_MUTEX(SgAndOp, unlock);
  130874             :       return;
  130875             :     }
  130876             : #endif
  130877             : 
  130878         386 :     SgAndOp * object = (SgAndOp*) Pointer;
  130879         386 :     ROSE_ASSERT(object != nullptr);
  130880             : 
  130881             : #if ROSE_ALLOC_TRACE == 2
  130882             : //  printf("SgAndOp::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgAndOp::next_node);
  130883             :     printf("SgAndOp::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgAndOp::next_node);
  130884             : #endif
  130885             : 
  130886             : #if ROSE_PEDANTIC_ALLOC
  130887             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  130888             : #endif
  130889             : 
  130890             : #if ROSE_ALLOC_MEMSET == 1
  130891             : #elif ROSE_ALLOC_MEMSET == 2
  130892             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgAndOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  130893             : #elif ROSE_ALLOC_MEMSET == 3
  130894             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgAndOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  130895             : #endif
  130896             : 
  130897             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  130898             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  130899             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  130900             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  130901             : #else
  130902         386 :     object->p_freepointer = SgAndOp::next_node;
  130903         386 :     SgAndOp::next_node = object;
  130904             : #endif
  130905             : 
  130906             : #if ROSE_ALLOC_TRACE == 2
  130907             : //  printf("SgAndOp::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgAndOp::next_node);
  130908             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  130909             :     Rose::MemPool::snapshot(oss.str());
  130910             :     alloc_trace_cnt++;
  130911             : #endif
  130912             : 
  130913             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  130914             : 
  130915         386 :     ALLOC_MUTEX(SgAndOp, unlock);
  130916             : }
  130917             : 
  130918             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  130919             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  130920             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  130921             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  130922             : // Also, note comment below from Robb (copied from the Common.code file).
  130923             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  130924             : //
  130925             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  130926             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  130927             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  130928             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  130929             : #if 0
  130930             : void SgAndOp::operator delete(void* pointer) { SgAndOp::operator delete (pointer, sizeof(SgAndOp)); };
  130931             : #endif
  130932             : /* #line 130933 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  130933             : 
  130934             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  130935             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  130936             : // obviously imply C++.
  130937             : 
  130938             : // This implements the support within ROSE for memory pools.  Memory pools
  130939             : // support the most condensed usage of memory within the construction of
  130940             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  130941             : // by a new operator written for each class.
  130942             : 
  130943             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  130944             :     // User wants multi-thread support and POSIX threads are available.
  130945             : #   include <pthread.h>
  130946             :     static pthread_mutex_t SgOrOp_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  130947             : #else
  130948             :      // Cause synchronization to be skipped.
  130949             : #    ifndef ALLOC_MUTEX
  130950             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  130951             : #    endif
  130952             : #    ifdef _REENTRANT
  130953             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  130954             : #       ifdef _MSC_VER
  130955             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  130956             : #       else
  130957             : #           warning "POSIX threads are not available; synchronization being skipped"
  130958             : #       endif
  130959             : #    endif
  130960             : #endif
  130961             : 
  130962             : #ifndef ROSE_ALLOC_TRACE
  130963             : #  define ROSE_ALLOC_TRACE 0
  130964             : #endif
  130965             : 
  130966             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  130967             : #define ROSE_ALLOC_TRACE_CNT
  130968             : #include "memory-pool-snapshot.h"
  130969             : unsigned long alloc_trace_cnt = 0;
  130970             : #endif
  130971             : 
  130972             : #if ROSE_ALLOC_TRACE
  130973             : const unsigned SgOrOp::pool_size = 5;
  130974             : #else
  130975             : const unsigned SgOrOp::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  130976             : #endif
  130977             : 
  130978             : #ifndef ROSE_ALLOC_MEMSET
  130979             : #  define ROSE_ALLOC_MEMSET 0
  130980             : #endif
  130981             : 
  130982             : #ifndef ROSE_PEDANTIC_ALLOC
  130983             : #  define ROSE_PEDANTIC_ALLOC 0
  130984             : #endif
  130985             : 
  130986             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  130987             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  130988             : #endif
  130989             : 
  130990             : #if !defined(SGNODE__ALL_POOLS)
  130991             : #define SGNODE__ALL_POOLS
  130992             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  130993             : #endif
  130994             : 
  130995             : SgOrOp* SgOrOp::next_node = nullptr;
  130996             : std::vector<unsigned char*> SgOrOp::pools;
  130997             : 
  130998             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  130999             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  131000             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  131001             : // around this macro definition rather than each use).
  131002             : #ifndef ALLOC_MUTEX
  131003             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  131004             :         do {                                                                     \
  131005             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  131006             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  131007             :                 abort();                                                         \
  131008             :             }                                                                    \
  131009             :         } while (0);
  131010             : #endif
  131011             : 
  131012             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  131013             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  131014             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  131015             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  131016             : 
  131017             : /*! \brief New operator for SgOrOp.
  131018             : 
  131019             :    This new operator implements memory pools to provide most efficent 
  131020             :    use of the heap within construction of large ASTs.
  131021             : 
  131022             : \internal The new and delete operators use the lower level C malloc/free
  131023             :    function calls for performance and to make sure that mixing of malloc/free
  131024             :    and new/delete by the used can be caught more readily.  This may change
  131025             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  131026             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  131027             :    deallocate memory allocated using ROSE_MALLOC.
  131028             : */
  131029         891 : void *SgOrOp::operator new ( size_t Size )
  131030             : {
  131031             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  131032             :      * returning or throwing an exception. */
  131033         891 :     ALLOC_MUTEX(SgOrOp, lock);
  131034             : 
  131035             : #if ROSE_ALLOC_TRACE == 2
  131036             : //    printf("SgOrOp::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgOrOp::next_node);
  131037             : #endif
  131038             : 
  131039             : #if USE_CPP_NEW_DELETE_OPERATORS
  131040             :     void *mem = ROSE_MALLOC(Size);
  131041             :     ALLOC_MUTEX(SgOrOp, unlock);
  131042             :     return mem;
  131043             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  131044             : #if ROSE_PEDANTIC_ALLOC
  131045             :     ROSE_ASSERT(Size == sizeof(SgOrOp));
  131046             : #else
  131047         891 :     if (Size != sizeof(SgOrOp)) {
  131048           0 :       void * object = ROSE_MALLOC(Size);
  131049           0 :       ALLOC_MUTEX(SgOrOp, unlock);
  131050             :       return object;
  131051             :     }
  131052             : #endif
  131053             : 
  131054         891 :     if (SgOrOp::next_node == nullptr) {
  131055          14 :         SgOrOp * alloc = (SgOrOp*) ROSE_MALLOC ( SgOrOp::pool_size * sizeof(SgOrOp) );
  131056          14 :         ROSE_ASSERT(alloc != nullptr);
  131057             : 
  131058             : #if ROSE_ALLOC_TRACE == 2
  131059             : //        printf("SgOrOp::alloc\n  block[%zi] = [ %p , %p [\n", SgOrOp::pools.size(), alloc, alloc + SgOrOp::pool_size);
  131060             : #endif
  131061             : 
  131062             : #if ROSE_ALLOC_MEMSET == 1
  131063             : #elif ROSE_ALLOC_MEMSET == 2
  131064             :         memset(alloc, 0x00, SgOrOp::pool_size * sizeof(SgOrOp));
  131065             : #elif ROSE_ALLOC_MEMSET == 3
  131066             :         memset(alloc, 0xAA, SgOrOp::pool_size * sizeof(SgOrOp));
  131067             : #endif
  131068       28000 :         for (unsigned i=0; i < SgOrOp::pool_size-1; i++) {
  131069       27986 :           alloc[i].p_freepointer = &(alloc[i+1]);
  131070             :         }
  131071          14 :         alloc[SgOrOp::pool_size-1].p_freepointer = nullptr;
  131072             : 
  131073          14 :         SgOrOp::pools.push_back ( (unsigned char *) alloc );
  131074          14 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgOrOp::pool_size * sizeof(SgOrOp), V_SgOrOp ) );
  131075          14 :         SgOrOp::next_node = alloc;
  131076             :     }
  131077         891 :     ROSE_ASSERT(SgOrOp::next_node != nullptr);
  131078             : 
  131079         891 :     SgOrOp * object = SgOrOp::next_node;
  131080         891 :     SgOrOp::next_node = (SgOrOp*)(object->p_freepointer);
  131081             : 
  131082             : #if ROSE_ALLOC_TRACE == 2
  131083             :     printf("SgOrOp::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOrOp::next_node);
  131084             : #endif
  131085             : 
  131086         891 :     SgNode * fp = object->p_freepointer;
  131087             : #if ROSE_ALLOC_MEMSET == 1
  131088             : #elif ROSE_ALLOC_MEMSET == 2
  131089             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOrOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  131090             : #elif ROSE_ALLOC_MEMSET == 3
  131091             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgOrOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  131092             : #endif
  131093         891 :     object->p_freepointer = fp;
  131094             : 
  131095             : #if ROSE_ALLOC_TRACE == 2
  131096             : //    printf("SgOrOp::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOrOp::next_node);
  131097             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  131098             :     Rose::MemPool::snapshot(oss.str());
  131099             :     alloc_trace_cnt++;
  131100             : #endif
  131101             : 
  131102         891 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  131103             : 
  131104         891 :     ALLOC_MUTEX(SgOrOp, unlock);
  131105             : 
  131106             :     return object;
  131107             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  131108             : }
  131109             : 
  131110             : 
  131111             : 
  131112             : /*! \brief Delete operator for SgOrOp.
  131113             : 
  131114             :    This delete operator implements deallocation using memory pools to 
  131115             :    provide most efficent use of the heap within construction of large ASTs.
  131116             : 
  131117             : \internal The new and delete operators use the lower level C malloc/free
  131118             :    function calls for performance and to make sure that mixing of malloc/free
  131119             :    and new/delete by the used can be caught more readily.  This may change
  131120             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  131121             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  131122             :    deallocate memory allocated using ROSE_MALLOC.
  131123             : */
  131124         166 : void SgOrOp::operator delete(void *Pointer, size_t Size)
  131125             : {
  131126             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  131127             :      * or throwing an exception. */
  131128         166 :     ALLOC_MUTEX(SgOrOp, lock);
  131129             : 
  131130             : #if USE_CPP_NEW_DELETE_OPERATORS
  131131             :     ROSE_FREE(Pointer);
  131132             : #else
  131133             : #if ROSE_PEDANTIC_ALLOC
  131134             :     ROSE_ASSERT(Size == sizeof(SgOrOp));
  131135             : #else
  131136         166 :     if (Size != sizeof(SgOrOp)) {
  131137           0 :       ROSE_FREE(Pointer);
  131138           0 :       ALLOC_MUTEX(SgOrOp, unlock);
  131139             :       return;
  131140             :     }
  131141             : #endif
  131142             : 
  131143         166 :     SgOrOp * object = (SgOrOp*) Pointer;
  131144         166 :     ROSE_ASSERT(object != nullptr);
  131145             : 
  131146             : #if ROSE_ALLOC_TRACE == 2
  131147             : //  printf("SgOrOp::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOrOp::next_node);
  131148             :     printf("SgOrOp::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOrOp::next_node);
  131149             : #endif
  131150             : 
  131151             : #if ROSE_PEDANTIC_ALLOC
  131152             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  131153             : #endif
  131154             : 
  131155             : #if ROSE_ALLOC_MEMSET == 1
  131156             : #elif ROSE_ALLOC_MEMSET == 2
  131157             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgOrOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  131158             : #elif ROSE_ALLOC_MEMSET == 3
  131159             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgOrOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  131160             : #endif
  131161             : 
  131162             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  131163             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  131164             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  131165             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  131166             : #else
  131167         166 :     object->p_freepointer = SgOrOp::next_node;
  131168         166 :     SgOrOp::next_node = object;
  131169             : #endif
  131170             : 
  131171             : #if ROSE_ALLOC_TRACE == 2
  131172             : //  printf("SgOrOp::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgOrOp::next_node);
  131173             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  131174             :     Rose::MemPool::snapshot(oss.str());
  131175             :     alloc_trace_cnt++;
  131176             : #endif
  131177             : 
  131178             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  131179             : 
  131180         166 :     ALLOC_MUTEX(SgOrOp, unlock);
  131181             : }
  131182             : 
  131183             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  131184             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  131185             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  131186             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  131187             : // Also, note comment below from Robb (copied from the Common.code file).
  131188             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  131189             : //
  131190             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  131191             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  131192             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  131193             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  131194             : #if 0
  131195             : void SgOrOp::operator delete(void* pointer) { SgOrOp::operator delete (pointer, sizeof(SgOrOp)); };
  131196             : #endif
  131197             : /* #line 131198 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  131198             : 
  131199             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  131200             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  131201             : // obviously imply C++.
  131202             : 
  131203             : // This implements the support within ROSE for memory pools.  Memory pools
  131204             : // support the most condensed usage of memory within the construction of
  131205             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  131206             : // by a new operator written for each class.
  131207             : 
  131208             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  131209             :     // User wants multi-thread support and POSIX threads are available.
  131210             : #   include <pthread.h>
  131211             :     static pthread_mutex_t SgBitXorOp_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  131212             : #else
  131213             :      // Cause synchronization to be skipped.
  131214             : #    ifndef ALLOC_MUTEX
  131215             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  131216             : #    endif
  131217             : #    ifdef _REENTRANT
  131218             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  131219             : #       ifdef _MSC_VER
  131220             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  131221             : #       else
  131222             : #           warning "POSIX threads are not available; synchronization being skipped"
  131223             : #       endif
  131224             : #    endif
  131225             : #endif
  131226             : 
  131227             : #ifndef ROSE_ALLOC_TRACE
  131228             : #  define ROSE_ALLOC_TRACE 0
  131229             : #endif
  131230             : 
  131231             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  131232             : #define ROSE_ALLOC_TRACE_CNT
  131233             : #include "memory-pool-snapshot.h"
  131234             : unsigned long alloc_trace_cnt = 0;
  131235             : #endif
  131236             : 
  131237             : #if ROSE_ALLOC_TRACE
  131238             : const unsigned SgBitXorOp::pool_size = 5;
  131239             : #else
  131240             : const unsigned SgBitXorOp::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  131241             : #endif
  131242             : 
  131243             : #ifndef ROSE_ALLOC_MEMSET
  131244             : #  define ROSE_ALLOC_MEMSET 0
  131245             : #endif
  131246             : 
  131247             : #ifndef ROSE_PEDANTIC_ALLOC
  131248             : #  define ROSE_PEDANTIC_ALLOC 0
  131249             : #endif
  131250             : 
  131251             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  131252             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  131253             : #endif
  131254             : 
  131255             : #if !defined(SGNODE__ALL_POOLS)
  131256             : #define SGNODE__ALL_POOLS
  131257             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  131258             : #endif
  131259             : 
  131260             : SgBitXorOp* SgBitXorOp::next_node = nullptr;
  131261             : std::vector<unsigned char*> SgBitXorOp::pools;
  131262             : 
  131263             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  131264             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  131265             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  131266             : // around this macro definition rather than each use).
  131267             : #ifndef ALLOC_MUTEX
  131268             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  131269             :         do {                                                                     \
  131270             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  131271             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  131272             :                 abort();                                                         \
  131273             :             }                                                                    \
  131274             :         } while (0);
  131275             : #endif
  131276             : 
  131277             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  131278             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  131279             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  131280             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  131281             : 
  131282             : /*! \brief New operator for SgBitXorOp.
  131283             : 
  131284             :    This new operator implements memory pools to provide most efficent 
  131285             :    use of the heap within construction of large ASTs.
  131286             : 
  131287             : \internal The new and delete operators use the lower level C malloc/free
  131288             :    function calls for performance and to make sure that mixing of malloc/free
  131289             :    and new/delete by the used can be caught more readily.  This may change
  131290             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  131291             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  131292             :    deallocate memory allocated using ROSE_MALLOC.
  131293             : */
  131294          58 : void *SgBitXorOp::operator new ( size_t Size )
  131295             : {
  131296             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  131297             :      * returning or throwing an exception. */
  131298          58 :     ALLOC_MUTEX(SgBitXorOp, lock);
  131299             : 
  131300             : #if ROSE_ALLOC_TRACE == 2
  131301             : //    printf("SgBitXorOp::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgBitXorOp::next_node);
  131302             : #endif
  131303             : 
  131304             : #if USE_CPP_NEW_DELETE_OPERATORS
  131305             :     void *mem = ROSE_MALLOC(Size);
  131306             :     ALLOC_MUTEX(SgBitXorOp, unlock);
  131307             :     return mem;
  131308             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  131309             : #if ROSE_PEDANTIC_ALLOC
  131310             :     ROSE_ASSERT(Size == sizeof(SgBitXorOp));
  131311             : #else
  131312          58 :     if (Size != sizeof(SgBitXorOp)) {
  131313           0 :       void * object = ROSE_MALLOC(Size);
  131314           0 :       ALLOC_MUTEX(SgBitXorOp, unlock);
  131315             :       return object;
  131316             :     }
  131317             : #endif
  131318             : 
  131319          58 :     if (SgBitXorOp::next_node == nullptr) {
  131320          10 :         SgBitXorOp * alloc = (SgBitXorOp*) ROSE_MALLOC ( SgBitXorOp::pool_size * sizeof(SgBitXorOp) );
  131321          10 :         ROSE_ASSERT(alloc != nullptr);
  131322             : 
  131323             : #if ROSE_ALLOC_TRACE == 2
  131324             : //        printf("SgBitXorOp::alloc\n  block[%zi] = [ %p , %p [\n", SgBitXorOp::pools.size(), alloc, alloc + SgBitXorOp::pool_size);
  131325             : #endif
  131326             : 
  131327             : #if ROSE_ALLOC_MEMSET == 1
  131328             : #elif ROSE_ALLOC_MEMSET == 2
  131329             :         memset(alloc, 0x00, SgBitXorOp::pool_size * sizeof(SgBitXorOp));
  131330             : #elif ROSE_ALLOC_MEMSET == 3
  131331             :         memset(alloc, 0xAA, SgBitXorOp::pool_size * sizeof(SgBitXorOp));
  131332             : #endif
  131333       20000 :         for (unsigned i=0; i < SgBitXorOp::pool_size-1; i++) {
  131334       19990 :           alloc[i].p_freepointer = &(alloc[i+1]);
  131335             :         }
  131336          10 :         alloc[SgBitXorOp::pool_size-1].p_freepointer = nullptr;
  131337             : 
  131338          10 :         SgBitXorOp::pools.push_back ( (unsigned char *) alloc );
  131339          10 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgBitXorOp::pool_size * sizeof(SgBitXorOp), V_SgBitXorOp ) );
  131340          10 :         SgBitXorOp::next_node = alloc;
  131341             :     }
  131342          58 :     ROSE_ASSERT(SgBitXorOp::next_node != nullptr);
  131343             : 
  131344          58 :     SgBitXorOp * object = SgBitXorOp::next_node;
  131345          58 :     SgBitXorOp::next_node = (SgBitXorOp*)(object->p_freepointer);
  131346             : 
  131347             : #if ROSE_ALLOC_TRACE == 2
  131348             :     printf("SgBitXorOp::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgBitXorOp::next_node);
  131349             : #endif
  131350             : 
  131351          58 :     SgNode * fp = object->p_freepointer;
  131352             : #if ROSE_ALLOC_MEMSET == 1
  131353             : #elif ROSE_ALLOC_MEMSET == 2
  131354             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgBitXorOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  131355             : #elif ROSE_ALLOC_MEMSET == 3
  131356             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgBitXorOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  131357             : #endif
  131358          58 :     object->p_freepointer = fp;
  131359             : 
  131360             : #if ROSE_ALLOC_TRACE == 2
  131361             : //    printf("SgBitXorOp::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgBitXorOp::next_node);
  131362             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  131363             :     Rose::MemPool::snapshot(oss.str());
  131364             :     alloc_trace_cnt++;
  131365             : #endif
  131366             : 
  131367          58 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  131368             : 
  131369          58 :     ALLOC_MUTEX(SgBitXorOp, unlock);
  131370             : 
  131371             :     return object;
  131372             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  131373             : }
  131374             : 
  131375             : 
  131376             : 
  131377             : /*! \brief Delete operator for SgBitXorOp.
  131378             : 
  131379             :    This delete operator implements deallocation using memory pools to 
  131380             :    provide most efficent use of the heap within construction of large ASTs.
  131381             : 
  131382             : \internal The new and delete operators use the lower level C malloc/free
  131383             :    function calls for performance and to make sure that mixing of malloc/free
  131384             :    and new/delete by the used can be caught more readily.  This may change
  131385             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  131386             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  131387             :    deallocate memory allocated using ROSE_MALLOC.
  131388             : */
  131389          12 : void SgBitXorOp::operator delete(void *Pointer, size_t Size)
  131390             : {
  131391             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  131392             :      * or throwing an exception. */
  131393          12 :     ALLOC_MUTEX(SgBitXorOp, lock);
  131394             : 
  131395             : #if USE_CPP_NEW_DELETE_OPERATORS
  131396             :     ROSE_FREE(Pointer);
  131397             : #else
  131398             : #if ROSE_PEDANTIC_ALLOC
  131399             :     ROSE_ASSERT(Size == sizeof(SgBitXorOp));
  131400             : #else
  131401          12 :     if (Size != sizeof(SgBitXorOp)) {
  131402           0 :       ROSE_FREE(Pointer);
  131403           0 :       ALLOC_MUTEX(SgBitXorOp, unlock);
  131404             :       return;
  131405             :     }
  131406             : #endif
  131407             : 
  131408          12 :     SgBitXorOp * object = (SgBitXorOp*) Pointer;
  131409          12 :     ROSE_ASSERT(object != nullptr);
  131410             : 
  131411             : #if ROSE_ALLOC_TRACE == 2
  131412             : //  printf("SgBitXorOp::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgBitXorOp::next_node);
  131413             :     printf("SgBitXorOp::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgBitXorOp::next_node);
  131414             : #endif
  131415             : 
  131416             : #if ROSE_PEDANTIC_ALLOC
  131417             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  131418             : #endif
  131419             : 
  131420             : #if ROSE_ALLOC_MEMSET == 1
  131421             : #elif ROSE_ALLOC_MEMSET == 2
  131422             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgBitXorOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  131423             : #elif ROSE_ALLOC_MEMSET == 3
  131424             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgBitXorOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  131425             : #endif
  131426             : 
  131427             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  131428             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  131429             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  131430             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  131431             : #else
  131432          12 :     object->p_freepointer = SgBitXorOp::next_node;
  131433          12 :     SgBitXorOp::next_node = object;
  131434             : #endif
  131435             : 
  131436             : #if ROSE_ALLOC_TRACE == 2
  131437             : //  printf("SgBitXorOp::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgBitXorOp::next_node);
  131438             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  131439             :     Rose::MemPool::snapshot(oss.str());
  131440             :     alloc_trace_cnt++;
  131441             : #endif
  131442             : 
  131443             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  131444             : 
  131445          12 :     ALLOC_MUTEX(SgBitXorOp, unlock);
  131446             : }
  131447             : 
  131448             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  131449             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  131450             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  131451             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  131452             : // Also, note comment below from Robb (copied from the Common.code file).
  131453             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  131454             : //
  131455             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  131456             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  131457             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  131458             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  131459             : #if 0
  131460             : void SgBitXorOp::operator delete(void* pointer) { SgBitXorOp::operator delete (pointer, sizeof(SgBitXorOp)); };
  131461             : #endif
  131462             : /* #line 131463 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  131463             : 
  131464             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  131465             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  131466             : // obviously imply C++.
  131467             : 
  131468             : // This implements the support within ROSE for memory pools.  Memory pools
  131469             : // support the most condensed usage of memory within the construction of
  131470             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  131471             : // by a new operator written for each class.
  131472             : 
  131473             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  131474             :     // User wants multi-thread support and POSIX threads are available.
  131475             : #   include <pthread.h>
  131476             :     static pthread_mutex_t SgBitAndOp_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  131477             : #else
  131478             :      // Cause synchronization to be skipped.
  131479             : #    ifndef ALLOC_MUTEX
  131480             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  131481             : #    endif
  131482             : #    ifdef _REENTRANT
  131483             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  131484             : #       ifdef _MSC_VER
  131485             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  131486             : #       else
  131487             : #           warning "POSIX threads are not available; synchronization being skipped"
  131488             : #       endif
  131489             : #    endif
  131490             : #endif
  131491             : 
  131492             : #ifndef ROSE_ALLOC_TRACE
  131493             : #  define ROSE_ALLOC_TRACE 0
  131494             : #endif
  131495             : 
  131496             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  131497             : #define ROSE_ALLOC_TRACE_CNT
  131498             : #include "memory-pool-snapshot.h"
  131499             : unsigned long alloc_trace_cnt = 0;
  131500             : #endif
  131501             : 
  131502             : #if ROSE_ALLOC_TRACE
  131503             : const unsigned SgBitAndOp::pool_size = 5;
  131504             : #else
  131505             : const unsigned SgBitAndOp::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  131506             : #endif
  131507             : 
  131508             : #ifndef ROSE_ALLOC_MEMSET
  131509             : #  define ROSE_ALLOC_MEMSET 0
  131510             : #endif
  131511             : 
  131512             : #ifndef ROSE_PEDANTIC_ALLOC
  131513             : #  define ROSE_PEDANTIC_ALLOC 0
  131514             : #endif
  131515             : 
  131516             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  131517             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  131518             : #endif
  131519             : 
  131520             : #if !defined(SGNODE__ALL_POOLS)
  131521             : #define SGNODE__ALL_POOLS
  131522             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  131523             : #endif
  131524             : 
  131525             : SgBitAndOp* SgBitAndOp::next_node = nullptr;
  131526             : std::vector<unsigned char*> SgBitAndOp::pools;
  131527             : 
  131528             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  131529             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  131530             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  131531             : // around this macro definition rather than each use).
  131532             : #ifndef ALLOC_MUTEX
  131533             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  131534             :         do {                                                                     \
  131535             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  131536             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  131537             :                 abort();                                                         \
  131538             :             }                                                                    \
  131539             :         } while (0);
  131540             : #endif
  131541             : 
  131542             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  131543             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  131544             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  131545             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  131546             : 
  131547             : /*! \brief New operator for SgBitAndOp.
  131548             : 
  131549             :    This new operator implements memory pools to provide most efficent 
  131550             :    use of the heap within construction of large ASTs.
  131551             : 
  131552             : \internal The new and delete operators use the lower level C malloc/free
  131553             :    function calls for performance and to make sure that mixing of malloc/free
  131554             :    and new/delete by the used can be caught more readily.  This may change
  131555             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  131556             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  131557             :    deallocate memory allocated using ROSE_MALLOC.
  131558             : */
  131559         198 : void *SgBitAndOp::operator new ( size_t Size )
  131560             : {
  131561             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  131562             :      * returning or throwing an exception. */
  131563         198 :     ALLOC_MUTEX(SgBitAndOp, lock);
  131564             : 
  131565             : #if ROSE_ALLOC_TRACE == 2
  131566             : //    printf("SgBitAndOp::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgBitAndOp::next_node);
  131567             : #endif
  131568             : 
  131569             : #if USE_CPP_NEW_DELETE_OPERATORS
  131570             :     void *mem = ROSE_MALLOC(Size);
  131571             :     ALLOC_MUTEX(SgBitAndOp, unlock);
  131572             :     return mem;
  131573             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  131574             : #if ROSE_PEDANTIC_ALLOC
  131575             :     ROSE_ASSERT(Size == sizeof(SgBitAndOp));
  131576             : #else
  131577         198 :     if (Size != sizeof(SgBitAndOp)) {
  131578           0 :       void * object = ROSE_MALLOC(Size);
  131579           0 :       ALLOC_MUTEX(SgBitAndOp, unlock);
  131580             :       return object;
  131581             :     }
  131582             : #endif
  131583             : 
  131584         198 :     if (SgBitAndOp::next_node == nullptr) {
  131585          12 :         SgBitAndOp * alloc = (SgBitAndOp*) ROSE_MALLOC ( SgBitAndOp::pool_size * sizeof(SgBitAndOp) );
  131586          12 :         ROSE_ASSERT(alloc != nullptr);
  131587             : 
  131588             : #if ROSE_ALLOC_TRACE == 2
  131589             : //        printf("SgBitAndOp::alloc\n  block[%zi] = [ %p , %p [\n", SgBitAndOp::pools.size(), alloc, alloc + SgBitAndOp::pool_size);
  131590             : #endif
  131591             : 
  131592             : #if ROSE_ALLOC_MEMSET == 1
  131593             : #elif ROSE_ALLOC_MEMSET == 2
  131594             :         memset(alloc, 0x00, SgBitAndOp::pool_size * sizeof(SgBitAndOp));
  131595             : #elif ROSE_ALLOC_MEMSET == 3
  131596             :         memset(alloc, 0xAA, SgBitAndOp::pool_size * sizeof(SgBitAndOp));
  131597             : #endif
  131598       24000 :         for (unsigned i=0; i < SgBitAndOp::pool_size-1; i++) {
  131599       23988 :           alloc[i].p_freepointer = &(alloc[i+1]);
  131600             :         }
  131601          12 :         alloc[SgBitAndOp::pool_size-1].p_freepointer = nullptr;
  131602             : 
  131603          12 :         SgBitAndOp::pools.push_back ( (unsigned char *) alloc );
  131604          12 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgBitAndOp::pool_size * sizeof(SgBitAndOp), V_SgBitAndOp ) );
  131605          12 :         SgBitAndOp::next_node = alloc;
  131606             :     }
  131607         198 :     ROSE_ASSERT(SgBitAndOp::next_node != nullptr);
  131608             : 
  131609         198 :     SgBitAndOp * object = SgBitAndOp::next_node;
  131610         198 :     SgBitAndOp::next_node = (SgBitAndOp*)(object->p_freepointer);
  131611             : 
  131612             : #if ROSE_ALLOC_TRACE == 2
  131613             :     printf("SgBitAndOp::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgBitAndOp::next_node);
  131614             : #endif
  131615             : 
  131616         198 :     SgNode * fp = object->p_freepointer;
  131617             : #if ROSE_ALLOC_MEMSET == 1
  131618             : #elif ROSE_ALLOC_MEMSET == 2
  131619             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgBitAndOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  131620             : #elif ROSE_ALLOC_MEMSET == 3
  131621             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgBitAndOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  131622             : #endif
  131623         198 :     object->p_freepointer = fp;
  131624             : 
  131625             : #if ROSE_ALLOC_TRACE == 2
  131626             : //    printf("SgBitAndOp::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgBitAndOp::next_node);
  131627             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  131628             :     Rose::MemPool::snapshot(oss.str());
  131629             :     alloc_trace_cnt++;
  131630             : #endif
  131631             : 
  131632         198 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  131633             : 
  131634         198 :     ALLOC_MUTEX(SgBitAndOp, unlock);
  131635             : 
  131636             :     return object;
  131637             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  131638             : }
  131639             : 
  131640             : 
  131641             : 
  131642             : /*! \brief Delete operator for SgBitAndOp.
  131643             : 
  131644             :    This delete operator implements deallocation using memory pools to 
  131645             :    provide most efficent use of the heap within construction of large ASTs.
  131646             : 
  131647             : \internal The new and delete operators use the lower level C malloc/free
  131648             :    function calls for performance and to make sure that mixing of malloc/free
  131649             :    and new/delete by the used can be caught more readily.  This may change
  131650             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  131651             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  131652             :    deallocate memory allocated using ROSE_MALLOC.
  131653             : */
  131654          40 : void SgBitAndOp::operator delete(void *Pointer, size_t Size)
  131655             : {
  131656             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  131657             :      * or throwing an exception. */
  131658          40 :     ALLOC_MUTEX(SgBitAndOp, lock);
  131659             : 
  131660             : #if USE_CPP_NEW_DELETE_OPERATORS
  131661             :     ROSE_FREE(Pointer);
  131662             : #else
  131663             : #if ROSE_PEDANTIC_ALLOC
  131664             :     ROSE_ASSERT(Size == sizeof(SgBitAndOp));
  131665             : #else
  131666          40 :     if (Size != sizeof(SgBitAndOp)) {
  131667           0 :       ROSE_FREE(Pointer);
  131668           0 :       ALLOC_MUTEX(SgBitAndOp, unlock);
  131669             :       return;
  131670             :     }
  131671             : #endif
  131672             : 
  131673          40 :     SgBitAndOp * object = (SgBitAndOp*) Pointer;
  131674          40 :     ROSE_ASSERT(object != nullptr);
  131675             : 
  131676             : #if ROSE_ALLOC_TRACE == 2
  131677             : //  printf("SgBitAndOp::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgBitAndOp::next_node);
  131678             :     printf("SgBitAndOp::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgBitAndOp::next_node);
  131679             : #endif
  131680             : 
  131681             : #if ROSE_PEDANTIC_ALLOC
  131682             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  131683             : #endif
  131684             : 
  131685             : #if ROSE_ALLOC_MEMSET == 1
  131686             : #elif ROSE_ALLOC_MEMSET == 2
  131687             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgBitAndOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  131688             : #elif ROSE_ALLOC_MEMSET == 3
  131689             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgBitAndOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  131690             : #endif
  131691             : 
  131692             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  131693             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  131694             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  131695             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  131696             : #else
  131697          40 :     object->p_freepointer = SgBitAndOp::next_node;
  131698          40 :     SgBitAndOp::next_node = object;
  131699             : #endif
  131700             : 
  131701             : #if ROSE_ALLOC_TRACE == 2
  131702             : //  printf("SgBitAndOp::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgBitAndOp::next_node);
  131703             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  131704             :     Rose::MemPool::snapshot(oss.str());
  131705             :     alloc_trace_cnt++;
  131706             : #endif
  131707             : 
  131708             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  131709             : 
  131710          40 :     ALLOC_MUTEX(SgBitAndOp, unlock);
  131711             : }
  131712             : 
  131713             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  131714             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  131715             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  131716             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  131717             : // Also, note comment below from Robb (copied from the Common.code file).
  131718             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  131719             : //
  131720             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  131721             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  131722             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  131723             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  131724             : #if 0
  131725             : void SgBitAndOp::operator delete(void* pointer) { SgBitAndOp::operator delete (pointer, sizeof(SgBitAndOp)); };
  131726             : #endif
  131727             : /* #line 131728 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  131728             : 
  131729             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  131730             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  131731             : // obviously imply C++.
  131732             : 
  131733             : // This implements the support within ROSE for memory pools.  Memory pools
  131734             : // support the most condensed usage of memory within the construction of
  131735             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  131736             : // by a new operator written for each class.
  131737             : 
  131738             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  131739             :     // User wants multi-thread support and POSIX threads are available.
  131740             : #   include <pthread.h>
  131741             :     static pthread_mutex_t SgBitOrOp_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  131742             : #else
  131743             :      // Cause synchronization to be skipped.
  131744             : #    ifndef ALLOC_MUTEX
  131745             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  131746             : #    endif
  131747             : #    ifdef _REENTRANT
  131748             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  131749             : #       ifdef _MSC_VER
  131750             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  131751             : #       else
  131752             : #           warning "POSIX threads are not available; synchronization being skipped"
  131753             : #       endif
  131754             : #    endif
  131755             : #endif
  131756             : 
  131757             : #ifndef ROSE_ALLOC_TRACE
  131758             : #  define ROSE_ALLOC_TRACE 0
  131759             : #endif
  131760             : 
  131761             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  131762             : #define ROSE_ALLOC_TRACE_CNT
  131763             : #include "memory-pool-snapshot.h"
  131764             : unsigned long alloc_trace_cnt = 0;
  131765             : #endif
  131766             : 
  131767             : #if ROSE_ALLOC_TRACE
  131768             : const unsigned SgBitOrOp::pool_size = 5;
  131769             : #else
  131770             : const unsigned SgBitOrOp::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  131771             : #endif
  131772             : 
  131773             : #ifndef ROSE_ALLOC_MEMSET
  131774             : #  define ROSE_ALLOC_MEMSET 0
  131775             : #endif
  131776             : 
  131777             : #ifndef ROSE_PEDANTIC_ALLOC
  131778             : #  define ROSE_PEDANTIC_ALLOC 0
  131779             : #endif
  131780             : 
  131781             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  131782             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  131783             : #endif
  131784             : 
  131785             : #if !defined(SGNODE__ALL_POOLS)
  131786             : #define SGNODE__ALL_POOLS
  131787             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  131788             : #endif
  131789             : 
  131790             : SgBitOrOp* SgBitOrOp::next_node = nullptr;
  131791             : std::vector<unsigned char*> SgBitOrOp::pools;
  131792             : 
  131793             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  131794             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  131795             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  131796             : // around this macro definition rather than each use).
  131797             : #ifndef ALLOC_MUTEX
  131798             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  131799             :         do {                                                                     \
  131800             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  131801             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  131802             :                 abort();                                                         \
  131803             :             }                                                                    \
  131804             :         } while (0);
  131805             : #endif
  131806             : 
  131807             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  131808             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  131809             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  131810             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  131811             : 
  131812             : /*! \brief New operator for SgBitOrOp.
  131813             : 
  131814             :    This new operator implements memory pools to provide most efficent 
  131815             :    use of the heap within construction of large ASTs.
  131816             : 
  131817             : \internal The new and delete operators use the lower level C malloc/free
  131818             :    function calls for performance and to make sure that mixing of malloc/free
  131819             :    and new/delete by the used can be caught more readily.  This may change
  131820             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  131821             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  131822             :    deallocate memory allocated using ROSE_MALLOC.
  131823             : */
  131824         267 : void *SgBitOrOp::operator new ( size_t Size )
  131825             : {
  131826             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  131827             :      * returning or throwing an exception. */
  131828         267 :     ALLOC_MUTEX(SgBitOrOp, lock);
  131829             : 
  131830             : #if ROSE_ALLOC_TRACE == 2
  131831             : //    printf("SgBitOrOp::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgBitOrOp::next_node);
  131832             : #endif
  131833             : 
  131834             : #if USE_CPP_NEW_DELETE_OPERATORS
  131835             :     void *mem = ROSE_MALLOC(Size);
  131836             :     ALLOC_MUTEX(SgBitOrOp, unlock);
  131837             :     return mem;
  131838             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  131839             : #if ROSE_PEDANTIC_ALLOC
  131840             :     ROSE_ASSERT(Size == sizeof(SgBitOrOp));
  131841             : #else
  131842         267 :     if (Size != sizeof(SgBitOrOp)) {
  131843           0 :       void * object = ROSE_MALLOC(Size);
  131844           0 :       ALLOC_MUTEX(SgBitOrOp, unlock);
  131845             :       return object;
  131846             :     }
  131847             : #endif
  131848             : 
  131849         267 :     if (SgBitOrOp::next_node == nullptr) {
  131850          10 :         SgBitOrOp * alloc = (SgBitOrOp*) ROSE_MALLOC ( SgBitOrOp::pool_size * sizeof(SgBitOrOp) );
  131851          10 :         ROSE_ASSERT(alloc != nullptr);
  131852             : 
  131853             : #if ROSE_ALLOC_TRACE == 2
  131854             : //        printf("SgBitOrOp::alloc\n  block[%zi] = [ %p , %p [\n", SgBitOrOp::pools.size(), alloc, alloc + SgBitOrOp::pool_size);
  131855             : #endif
  131856             : 
  131857             : #if ROSE_ALLOC_MEMSET == 1
  131858             : #elif ROSE_ALLOC_MEMSET == 2
  131859             :         memset(alloc, 0x00, SgBitOrOp::pool_size * sizeof(SgBitOrOp));
  131860             : #elif ROSE_ALLOC_MEMSET == 3
  131861             :         memset(alloc, 0xAA, SgBitOrOp::pool_size * sizeof(SgBitOrOp));
  131862             : #endif
  131863       20000 :         for (unsigned i=0; i < SgBitOrOp::pool_size-1; i++) {
  131864       19990 :           alloc[i].p_freepointer = &(alloc[i+1]);
  131865             :         }
  131866          10 :         alloc[SgBitOrOp::pool_size-1].p_freepointer = nullptr;
  131867             : 
  131868          10 :         SgBitOrOp::pools.push_back ( (unsigned char *) alloc );
  131869          10 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgBitOrOp::pool_size * sizeof(SgBitOrOp), V_SgBitOrOp ) );
  131870          10 :         SgBitOrOp::next_node = alloc;
  131871             :     }
  131872         267 :     ROSE_ASSERT(SgBitOrOp::next_node != nullptr);
  131873             : 
  131874         267 :     SgBitOrOp * object = SgBitOrOp::next_node;
  131875         267 :     SgBitOrOp::next_node = (SgBitOrOp*)(object->p_freepointer);
  131876             : 
  131877             : #if ROSE_ALLOC_TRACE == 2
  131878             :     printf("SgBitOrOp::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgBitOrOp::next_node);
  131879             : #endif
  131880             : 
  131881         267 :     SgNode * fp = object->p_freepointer;
  131882             : #if ROSE_ALLOC_MEMSET == 1
  131883             : #elif ROSE_ALLOC_MEMSET == 2
  131884             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgBitOrOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  131885             : #elif ROSE_ALLOC_MEMSET == 3
  131886             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgBitOrOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  131887             : #endif
  131888         267 :     object->p_freepointer = fp;
  131889             : 
  131890             : #if ROSE_ALLOC_TRACE == 2
  131891             : //    printf("SgBitOrOp::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgBitOrOp::next_node);
  131892             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  131893             :     Rose::MemPool::snapshot(oss.str());
  131894             :     alloc_trace_cnt++;
  131895             : #endif
  131896             : 
  131897         267 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  131898             : 
  131899         267 :     ALLOC_MUTEX(SgBitOrOp, unlock);
  131900             : 
  131901             :     return object;
  131902             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  131903             : }
  131904             : 
  131905             : 
  131906             : 
  131907             : /*! \brief Delete operator for SgBitOrOp.
  131908             : 
  131909             :    This delete operator implements deallocation using memory pools to 
  131910             :    provide most efficent use of the heap within construction of large ASTs.
  131911             : 
  131912             : \internal The new and delete operators use the lower level C malloc/free
  131913             :    function calls for performance and to make sure that mixing of malloc/free
  131914             :    and new/delete by the used can be caught more readily.  This may change
  131915             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  131916             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  131917             :    deallocate memory allocated using ROSE_MALLOC.
  131918             : */
  131919         150 : void SgBitOrOp::operator delete(void *Pointer, size_t Size)
  131920             : {
  131921             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  131922             :      * or throwing an exception. */
  131923         150 :     ALLOC_MUTEX(SgBitOrOp, lock);
  131924             : 
  131925             : #if USE_CPP_NEW_DELETE_OPERATORS
  131926             :     ROSE_FREE(Pointer);
  131927             : #else
  131928             : #if ROSE_PEDANTIC_ALLOC
  131929             :     ROSE_ASSERT(Size == sizeof(SgBitOrOp));
  131930             : #else
  131931         150 :     if (Size != sizeof(SgBitOrOp)) {
  131932           0 :       ROSE_FREE(Pointer);
  131933           0 :       ALLOC_MUTEX(SgBitOrOp, unlock);
  131934             :       return;
  131935             :     }
  131936             : #endif
  131937             : 
  131938         150 :     SgBitOrOp * object = (SgBitOrOp*) Pointer;
  131939         150 :     ROSE_ASSERT(object != nullptr);
  131940             : 
  131941             : #if ROSE_ALLOC_TRACE == 2
  131942             : //  printf("SgBitOrOp::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgBitOrOp::next_node);
  131943             :     printf("SgBitOrOp::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgBitOrOp::next_node);
  131944             : #endif
  131945             : 
  131946             : #if ROSE_PEDANTIC_ALLOC
  131947             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  131948             : #endif
  131949             : 
  131950             : #if ROSE_ALLOC_MEMSET == 1
  131951             : #elif ROSE_ALLOC_MEMSET == 2
  131952             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgBitOrOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  131953             : #elif ROSE_ALLOC_MEMSET == 3
  131954             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgBitOrOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  131955             : #endif
  131956             : 
  131957             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  131958             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  131959             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  131960             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  131961             : #else
  131962         150 :     object->p_freepointer = SgBitOrOp::next_node;
  131963         150 :     SgBitOrOp::next_node = object;
  131964             : #endif
  131965             : 
  131966             : #if ROSE_ALLOC_TRACE == 2
  131967             : //  printf("SgBitOrOp::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgBitOrOp::next_node);
  131968             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  131969             :     Rose::MemPool::snapshot(oss.str());
  131970             :     alloc_trace_cnt++;
  131971             : #endif
  131972             : 
  131973             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  131974             : 
  131975         150 :     ALLOC_MUTEX(SgBitOrOp, unlock);
  131976             : }
  131977             : 
  131978             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  131979             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  131980             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  131981             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  131982             : // Also, note comment below from Robb (copied from the Common.code file).
  131983             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  131984             : //
  131985             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  131986             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  131987             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  131988             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  131989             : #if 0
  131990             : void SgBitOrOp::operator delete(void* pointer) { SgBitOrOp::operator delete (pointer, sizeof(SgBitOrOp)); };
  131991             : #endif
  131992             : /* #line 131993 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  131993             : 
  131994             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  131995             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  131996             : // obviously imply C++.
  131997             : 
  131998             : // This implements the support within ROSE for memory pools.  Memory pools
  131999             : // support the most condensed usage of memory within the construction of
  132000             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  132001             : // by a new operator written for each class.
  132002             : 
  132003             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  132004             :     // User wants multi-thread support and POSIX threads are available.
  132005             : #   include <pthread.h>
  132006             :     static pthread_mutex_t SgBitEqvOp_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  132007             : #else
  132008             :      // Cause synchronization to be skipped.
  132009             : #    ifndef ALLOC_MUTEX
  132010             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  132011             : #    endif
  132012             : #    ifdef _REENTRANT
  132013             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  132014             : #       ifdef _MSC_VER
  132015             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  132016             : #       else
  132017             : #           warning "POSIX threads are not available; synchronization being skipped"
  132018             : #       endif
  132019             : #    endif
  132020             : #endif
  132021             : 
  132022             : #ifndef ROSE_ALLOC_TRACE
  132023             : #  define ROSE_ALLOC_TRACE 0
  132024             : #endif
  132025             : 
  132026             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  132027             : #define ROSE_ALLOC_TRACE_CNT
  132028             : #include "memory-pool-snapshot.h"
  132029             : unsigned long alloc_trace_cnt = 0;
  132030             : #endif
  132031             : 
  132032             : #if ROSE_ALLOC_TRACE
  132033             : const unsigned SgBitEqvOp::pool_size = 5;
  132034             : #else
  132035             : const unsigned SgBitEqvOp::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  132036             : #endif
  132037             : 
  132038             : #ifndef ROSE_ALLOC_MEMSET
  132039             : #  define ROSE_ALLOC_MEMSET 0
  132040             : #endif
  132041             : 
  132042             : #ifndef ROSE_PEDANTIC_ALLOC
  132043             : #  define ROSE_PEDANTIC_ALLOC 0
  132044             : #endif
  132045             : 
  132046             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  132047             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  132048             : #endif
  132049             : 
  132050             : #if !defined(SGNODE__ALL_POOLS)
  132051             : #define SGNODE__ALL_POOLS
  132052             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  132053             : #endif
  132054             : 
  132055             : SgBitEqvOp* SgBitEqvOp::next_node = nullptr;
  132056             : std::vector<unsigned char*> SgBitEqvOp::pools;
  132057             : 
  132058             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  132059             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  132060             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  132061             : // around this macro definition rather than each use).
  132062             : #ifndef ALLOC_MUTEX
  132063             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  132064             :         do {                                                                     \
  132065             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  132066             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  132067             :                 abort();                                                         \
  132068             :             }                                                                    \
  132069             :         } while (0);
  132070             : #endif
  132071             : 
  132072             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  132073             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  132074             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  132075             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  132076             : 
  132077             : /*! \brief New operator for SgBitEqvOp.
  132078             : 
  132079             :    This new operator implements memory pools to provide most efficent 
  132080             :    use of the heap within construction of large ASTs.
  132081             : 
  132082             : \internal The new and delete operators use the lower level C malloc/free
  132083             :    function calls for performance and to make sure that mixing of malloc/free
  132084             :    and new/delete by the used can be caught more readily.  This may change
  132085             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  132086             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  132087             :    deallocate memory allocated using ROSE_MALLOC.
  132088             : */
  132089           0 : void *SgBitEqvOp::operator new ( size_t Size )
  132090             : {
  132091             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  132092             :      * returning or throwing an exception. */
  132093           0 :     ALLOC_MUTEX(SgBitEqvOp, lock);
  132094             : 
  132095             : #if ROSE_ALLOC_TRACE == 2
  132096             : //    printf("SgBitEqvOp::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgBitEqvOp::next_node);
  132097             : #endif
  132098             : 
  132099             : #if USE_CPP_NEW_DELETE_OPERATORS
  132100             :     void *mem = ROSE_MALLOC(Size);
  132101             :     ALLOC_MUTEX(SgBitEqvOp, unlock);
  132102             :     return mem;
  132103             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  132104             : #if ROSE_PEDANTIC_ALLOC
  132105             :     ROSE_ASSERT(Size == sizeof(SgBitEqvOp));
  132106             : #else
  132107           0 :     if (Size != sizeof(SgBitEqvOp)) {
  132108           0 :       void * object = ROSE_MALLOC(Size);
  132109           0 :       ALLOC_MUTEX(SgBitEqvOp, unlock);
  132110             :       return object;
  132111             :     }
  132112             : #endif
  132113             : 
  132114           0 :     if (SgBitEqvOp::next_node == nullptr) {
  132115           0 :         SgBitEqvOp * alloc = (SgBitEqvOp*) ROSE_MALLOC ( SgBitEqvOp::pool_size * sizeof(SgBitEqvOp) );
  132116           0 :         ROSE_ASSERT(alloc != nullptr);
  132117             : 
  132118             : #if ROSE_ALLOC_TRACE == 2
  132119             : //        printf("SgBitEqvOp::alloc\n  block[%zi] = [ %p , %p [\n", SgBitEqvOp::pools.size(), alloc, alloc + SgBitEqvOp::pool_size);
  132120             : #endif
  132121             : 
  132122             : #if ROSE_ALLOC_MEMSET == 1
  132123             : #elif ROSE_ALLOC_MEMSET == 2
  132124             :         memset(alloc, 0x00, SgBitEqvOp::pool_size * sizeof(SgBitEqvOp));
  132125             : #elif ROSE_ALLOC_MEMSET == 3
  132126             :         memset(alloc, 0xAA, SgBitEqvOp::pool_size * sizeof(SgBitEqvOp));
  132127             : #endif
  132128           0 :         for (unsigned i=0; i < SgBitEqvOp::pool_size-1; i++) {
  132129           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
  132130             :         }
  132131           0 :         alloc[SgBitEqvOp::pool_size-1].p_freepointer = nullptr;
  132132             : 
  132133           0 :         SgBitEqvOp::pools.push_back ( (unsigned char *) alloc );
  132134           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgBitEqvOp::pool_size * sizeof(SgBitEqvOp), V_SgBitEqvOp ) );
  132135           0 :         SgBitEqvOp::next_node = alloc;
  132136             :     }
  132137           0 :     ROSE_ASSERT(SgBitEqvOp::next_node != nullptr);
  132138             : 
  132139           0 :     SgBitEqvOp * object = SgBitEqvOp::next_node;
  132140           0 :     SgBitEqvOp::next_node = (SgBitEqvOp*)(object->p_freepointer);
  132141             : 
  132142             : #if ROSE_ALLOC_TRACE == 2
  132143             :     printf("SgBitEqvOp::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgBitEqvOp::next_node);
  132144             : #endif
  132145             : 
  132146           0 :     SgNode * fp = object->p_freepointer;
  132147             : #if ROSE_ALLOC_MEMSET == 1
  132148             : #elif ROSE_ALLOC_MEMSET == 2
  132149             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgBitEqvOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  132150             : #elif ROSE_ALLOC_MEMSET == 3
  132151             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgBitEqvOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  132152             : #endif
  132153           0 :     object->p_freepointer = fp;
  132154             : 
  132155             : #if ROSE_ALLOC_TRACE == 2
  132156             : //    printf("SgBitEqvOp::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgBitEqvOp::next_node);
  132157             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  132158             :     Rose::MemPool::snapshot(oss.str());
  132159             :     alloc_trace_cnt++;
  132160             : #endif
  132161             : 
  132162           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  132163             : 
  132164           0 :     ALLOC_MUTEX(SgBitEqvOp, unlock);
  132165             : 
  132166             :     return object;
  132167             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  132168             : }
  132169             : 
  132170             : 
  132171             : 
  132172             : /*! \brief Delete operator for SgBitEqvOp.
  132173             : 
  132174             :    This delete operator implements deallocation using memory pools to 
  132175             :    provide most efficent use of the heap within construction of large ASTs.
  132176             : 
  132177             : \internal The new and delete operators use the lower level C malloc/free
  132178             :    function calls for performance and to make sure that mixing of malloc/free
  132179             :    and new/delete by the used can be caught more readily.  This may change
  132180             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  132181             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  132182             :    deallocate memory allocated using ROSE_MALLOC.
  132183             : */
  132184           0 : void SgBitEqvOp::operator delete(void *Pointer, size_t Size)
  132185             : {
  132186             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  132187             :      * or throwing an exception. */
  132188           0 :     ALLOC_MUTEX(SgBitEqvOp, lock);
  132189             : 
  132190             : #if USE_CPP_NEW_DELETE_OPERATORS
  132191             :     ROSE_FREE(Pointer);
  132192             : #else
  132193             : #if ROSE_PEDANTIC_ALLOC
  132194             :     ROSE_ASSERT(Size == sizeof(SgBitEqvOp));
  132195             : #else
  132196           0 :     if (Size != sizeof(SgBitEqvOp)) {
  132197           0 :       ROSE_FREE(Pointer);
  132198           0 :       ALLOC_MUTEX(SgBitEqvOp, unlock);
  132199             :       return;
  132200             :     }
  132201             : #endif
  132202             : 
  132203           0 :     SgBitEqvOp * object = (SgBitEqvOp*) Pointer;
  132204           0 :     ROSE_ASSERT(object != nullptr);
  132205             : 
  132206             : #if ROSE_ALLOC_TRACE == 2
  132207             : //  printf("SgBitEqvOp::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgBitEqvOp::next_node);
  132208             :     printf("SgBitEqvOp::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgBitEqvOp::next_node);
  132209             : #endif
  132210             : 
  132211             : #if ROSE_PEDANTIC_ALLOC
  132212             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  132213             : #endif
  132214             : 
  132215             : #if ROSE_ALLOC_MEMSET == 1
  132216             : #elif ROSE_ALLOC_MEMSET == 2
  132217             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgBitEqvOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  132218             : #elif ROSE_ALLOC_MEMSET == 3
  132219             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgBitEqvOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  132220             : #endif
  132221             : 
  132222             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  132223             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  132224             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  132225             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  132226             : #else
  132227           0 :     object->p_freepointer = SgBitEqvOp::next_node;
  132228           0 :     SgBitEqvOp::next_node = object;
  132229             : #endif
  132230             : 
  132231             : #if ROSE_ALLOC_TRACE == 2
  132232             : //  printf("SgBitEqvOp::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgBitEqvOp::next_node);
  132233             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  132234             :     Rose::MemPool::snapshot(oss.str());
  132235             :     alloc_trace_cnt++;
  132236             : #endif
  132237             : 
  132238             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  132239             : 
  132240           0 :     ALLOC_MUTEX(SgBitEqvOp, unlock);
  132241             : }
  132242             : 
  132243             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  132244             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  132245             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  132246             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  132247             : // Also, note comment below from Robb (copied from the Common.code file).
  132248             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  132249             : //
  132250             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  132251             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  132252             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  132253             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  132254             : #if 0
  132255             : void SgBitEqvOp::operator delete(void* pointer) { SgBitEqvOp::operator delete (pointer, sizeof(SgBitEqvOp)); };
  132256             : #endif
  132257             : /* #line 132258 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  132258             : 
  132259             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  132260             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  132261             : // obviously imply C++.
  132262             : 
  132263             : // This implements the support within ROSE for memory pools.  Memory pools
  132264             : // support the most condensed usage of memory within the construction of
  132265             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  132266             : // by a new operator written for each class.
  132267             : 
  132268             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  132269             :     // User wants multi-thread support and POSIX threads are available.
  132270             : #   include <pthread.h>
  132271             :     static pthread_mutex_t SgCommaOpExp_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  132272             : #else
  132273             :      // Cause synchronization to be skipped.
  132274             : #    ifndef ALLOC_MUTEX
  132275             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  132276             : #    endif
  132277             : #    ifdef _REENTRANT
  132278             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  132279             : #       ifdef _MSC_VER
  132280             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  132281             : #       else
  132282             : #           warning "POSIX threads are not available; synchronization being skipped"
  132283             : #       endif
  132284             : #    endif
  132285             : #endif
  132286             : 
  132287             : #ifndef ROSE_ALLOC_TRACE
  132288             : #  define ROSE_ALLOC_TRACE 0
  132289             : #endif
  132290             : 
  132291             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  132292             : #define ROSE_ALLOC_TRACE_CNT
  132293             : #include "memory-pool-snapshot.h"
  132294             : unsigned long alloc_trace_cnt = 0;
  132295             : #endif
  132296             : 
  132297             : #if ROSE_ALLOC_TRACE
  132298             : const unsigned SgCommaOpExp::pool_size = 5;
  132299             : #else
  132300             : const unsigned SgCommaOpExp::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  132301             : #endif
  132302             : 
  132303             : #ifndef ROSE_ALLOC_MEMSET
  132304             : #  define ROSE_ALLOC_MEMSET 0
  132305             : #endif
  132306             : 
  132307             : #ifndef ROSE_PEDANTIC_ALLOC
  132308             : #  define ROSE_PEDANTIC_ALLOC 0
  132309             : #endif
  132310             : 
  132311             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  132312             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  132313             : #endif
  132314             : 
  132315             : #if !defined(SGNODE__ALL_POOLS)
  132316             : #define SGNODE__ALL_POOLS
  132317             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  132318             : #endif
  132319             : 
  132320             : SgCommaOpExp* SgCommaOpExp::next_node = nullptr;
  132321             : std::vector<unsigned char*> SgCommaOpExp::pools;
  132322             : 
  132323             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  132324             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  132325             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  132326             : // around this macro definition rather than each use).
  132327             : #ifndef ALLOC_MUTEX
  132328             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  132329             :         do {                                                                     \
  132330             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  132331             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  132332             :                 abort();                                                         \
  132333             :             }                                                                    \
  132334             :         } while (0);
  132335             : #endif
  132336             : 
  132337             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  132338             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  132339             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  132340             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  132341             : 
  132342             : /*! \brief New operator for SgCommaOpExp.
  132343             : 
  132344             :    This new operator implements memory pools to provide most efficent 
  132345             :    use of the heap within construction of large ASTs.
  132346             : 
  132347             : \internal The new and delete operators use the lower level C malloc/free
  132348             :    function calls for performance and to make sure that mixing of malloc/free
  132349             :    and new/delete by the used can be caught more readily.  This may change
  132350             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  132351             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  132352             :    deallocate memory allocated using ROSE_MALLOC.
  132353             : */
  132354         290 : void *SgCommaOpExp::operator new ( size_t Size )
  132355             : {
  132356             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  132357             :      * returning or throwing an exception. */
  132358         290 :     ALLOC_MUTEX(SgCommaOpExp, lock);
  132359             : 
  132360             : #if ROSE_ALLOC_TRACE == 2
  132361             : //    printf("SgCommaOpExp::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgCommaOpExp::next_node);
  132362             : #endif
  132363             : 
  132364             : #if USE_CPP_NEW_DELETE_OPERATORS
  132365             :     void *mem = ROSE_MALLOC(Size);
  132366             :     ALLOC_MUTEX(SgCommaOpExp, unlock);
  132367             :     return mem;
  132368             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  132369             : #if ROSE_PEDANTIC_ALLOC
  132370             :     ROSE_ASSERT(Size == sizeof(SgCommaOpExp));
  132371             : #else
  132372         290 :     if (Size != sizeof(SgCommaOpExp)) {
  132373           0 :       void * object = ROSE_MALLOC(Size);
  132374           0 :       ALLOC_MUTEX(SgCommaOpExp, unlock);
  132375             :       return object;
  132376             :     }
  132377             : #endif
  132378             : 
  132379         290 :     if (SgCommaOpExp::next_node == nullptr) {
  132380          43 :         SgCommaOpExp * alloc = (SgCommaOpExp*) ROSE_MALLOC ( SgCommaOpExp::pool_size * sizeof(SgCommaOpExp) );
  132381          43 :         ROSE_ASSERT(alloc != nullptr);
  132382             : 
  132383             : #if ROSE_ALLOC_TRACE == 2
  132384             : //        printf("SgCommaOpExp::alloc\n  block[%zi] = [ %p , %p [\n", SgCommaOpExp::pools.size(), alloc, alloc + SgCommaOpExp::pool_size);
  132385             : #endif
  132386             : 
  132387             : #if ROSE_ALLOC_MEMSET == 1
  132388             : #elif ROSE_ALLOC_MEMSET == 2
  132389             :         memset(alloc, 0x00, SgCommaOpExp::pool_size * sizeof(SgCommaOpExp));
  132390             : #elif ROSE_ALLOC_MEMSET == 3
  132391             :         memset(alloc, 0xAA, SgCommaOpExp::pool_size * sizeof(SgCommaOpExp));
  132392             : #endif
  132393       86000 :         for (unsigned i=0; i < SgCommaOpExp::pool_size-1; i++) {
  132394       85957 :           alloc[i].p_freepointer = &(alloc[i+1]);
  132395             :         }
  132396          43 :         alloc[SgCommaOpExp::pool_size-1].p_freepointer = nullptr;
  132397             : 
  132398          43 :         SgCommaOpExp::pools.push_back ( (unsigned char *) alloc );
  132399          43 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgCommaOpExp::pool_size * sizeof(SgCommaOpExp), V_SgCommaOpExp ) );
  132400          43 :         SgCommaOpExp::next_node = alloc;
  132401             :     }
  132402         290 :     ROSE_ASSERT(SgCommaOpExp::next_node != nullptr);
  132403             : 
  132404         290 :     SgCommaOpExp * object = SgCommaOpExp::next_node;
  132405         290 :     SgCommaOpExp::next_node = (SgCommaOpExp*)(object->p_freepointer);
  132406             : 
  132407             : #if ROSE_ALLOC_TRACE == 2
  132408             :     printf("SgCommaOpExp::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgCommaOpExp::next_node);
  132409             : #endif
  132410             : 
  132411         290 :     SgNode * fp = object->p_freepointer;
  132412             : #if ROSE_ALLOC_MEMSET == 1
  132413             : #elif ROSE_ALLOC_MEMSET == 2
  132414             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgCommaOpExp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  132415             : #elif ROSE_ALLOC_MEMSET == 3
  132416             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgCommaOpExp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  132417             : #endif
  132418         290 :     object->p_freepointer = fp;
  132419             : 
  132420             : #if ROSE_ALLOC_TRACE == 2
  132421             : //    printf("SgCommaOpExp::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgCommaOpExp::next_node);
  132422             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  132423             :     Rose::MemPool::snapshot(oss.str());
  132424             :     alloc_trace_cnt++;
  132425             : #endif
  132426             : 
  132427         290 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  132428             : 
  132429         290 :     ALLOC_MUTEX(SgCommaOpExp, unlock);
  132430             : 
  132431             :     return object;
  132432             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  132433             : }
  132434             : 
  132435             : 
  132436             : 
  132437             : /*! \brief Delete operator for SgCommaOpExp.
  132438             : 
  132439             :    This delete operator implements deallocation using memory pools to 
  132440             :    provide most efficent use of the heap within construction of large ASTs.
  132441             : 
  132442             : \internal The new and delete operators use the lower level C malloc/free
  132443             :    function calls for performance and to make sure that mixing of malloc/free
  132444             :    and new/delete by the used can be caught more readily.  This may change
  132445             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  132446             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  132447             :    deallocate memory allocated using ROSE_MALLOC.
  132448             : */
  132449          32 : void SgCommaOpExp::operator delete(void *Pointer, size_t Size)
  132450             : {
  132451             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  132452             :      * or throwing an exception. */
  132453          32 :     ALLOC_MUTEX(SgCommaOpExp, lock);
  132454             : 
  132455             : #if USE_CPP_NEW_DELETE_OPERATORS
  132456             :     ROSE_FREE(Pointer);
  132457             : #else
  132458             : #if ROSE_PEDANTIC_ALLOC
  132459             :     ROSE_ASSERT(Size == sizeof(SgCommaOpExp));
  132460             : #else
  132461          32 :     if (Size != sizeof(SgCommaOpExp)) {
  132462           0 :       ROSE_FREE(Pointer);
  132463           0 :       ALLOC_MUTEX(SgCommaOpExp, unlock);
  132464             :       return;
  132465             :     }
  132466             : #endif
  132467             : 
  132468          32 :     SgCommaOpExp * object = (SgCommaOpExp*) Pointer;
  132469          32 :     ROSE_ASSERT(object != nullptr);
  132470             : 
  132471             : #if ROSE_ALLOC_TRACE == 2
  132472             : //  printf("SgCommaOpExp::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgCommaOpExp::next_node);
  132473             :     printf("SgCommaOpExp::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgCommaOpExp::next_node);
  132474             : #endif
  132475             : 
  132476             : #if ROSE_PEDANTIC_ALLOC
  132477             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  132478             : #endif
  132479             : 
  132480             : #if ROSE_ALLOC_MEMSET == 1
  132481             : #elif ROSE_ALLOC_MEMSET == 2
  132482             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgCommaOpExp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  132483             : #elif ROSE_ALLOC_MEMSET == 3
  132484             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgCommaOpExp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  132485             : #endif
  132486             : 
  132487             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  132488             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  132489             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  132490             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  132491             : #else
  132492          32 :     object->p_freepointer = SgCommaOpExp::next_node;
  132493          32 :     SgCommaOpExp::next_node = object;
  132494             : #endif
  132495             : 
  132496             : #if ROSE_ALLOC_TRACE == 2
  132497             : //  printf("SgCommaOpExp::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgCommaOpExp::next_node);
  132498             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  132499             :     Rose::MemPool::snapshot(oss.str());
  132500             :     alloc_trace_cnt++;
  132501             : #endif
  132502             : 
  132503             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  132504             : 
  132505          32 :     ALLOC_MUTEX(SgCommaOpExp, unlock);
  132506             : }
  132507             : 
  132508             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  132509             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  132510             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  132511             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  132512             : // Also, note comment below from Robb (copied from the Common.code file).
  132513             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  132514             : //
  132515             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  132516             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  132517             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  132518             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  132519             : #if 0
  132520             : void SgCommaOpExp::operator delete(void* pointer) { SgCommaOpExp::operator delete (pointer, sizeof(SgCommaOpExp)); };
  132521             : #endif
  132522             : /* #line 132523 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  132523             : 
  132524             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  132525             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  132526             : // obviously imply C++.
  132527             : 
  132528             : // This implements the support within ROSE for memory pools.  Memory pools
  132529             : // support the most condensed usage of memory within the construction of
  132530             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  132531             : // by a new operator written for each class.
  132532             : 
  132533             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  132534             :     // User wants multi-thread support and POSIX threads are available.
  132535             : #   include <pthread.h>
  132536             :     static pthread_mutex_t SgLshiftOp_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  132537             : #else
  132538             :      // Cause synchronization to be skipped.
  132539             : #    ifndef ALLOC_MUTEX
  132540             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  132541             : #    endif
  132542             : #    ifdef _REENTRANT
  132543             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  132544             : #       ifdef _MSC_VER
  132545             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  132546             : #       else
  132547             : #           warning "POSIX threads are not available; synchronization being skipped"
  132548             : #       endif
  132549             : #    endif
  132550             : #endif
  132551             : 
  132552             : #ifndef ROSE_ALLOC_TRACE
  132553             : #  define ROSE_ALLOC_TRACE 0
  132554             : #endif
  132555             : 
  132556             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  132557             : #define ROSE_ALLOC_TRACE_CNT
  132558             : #include "memory-pool-snapshot.h"
  132559             : unsigned long alloc_trace_cnt = 0;
  132560             : #endif
  132561             : 
  132562             : #if ROSE_ALLOC_TRACE
  132563             : const unsigned SgLshiftOp::pool_size = 5;
  132564             : #else
  132565             : const unsigned SgLshiftOp::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  132566             : #endif
  132567             : 
  132568             : #ifndef ROSE_ALLOC_MEMSET
  132569             : #  define ROSE_ALLOC_MEMSET 0
  132570             : #endif
  132571             : 
  132572             : #ifndef ROSE_PEDANTIC_ALLOC
  132573             : #  define ROSE_PEDANTIC_ALLOC 0
  132574             : #endif
  132575             : 
  132576             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  132577             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  132578             : #endif
  132579             : 
  132580             : #if !defined(SGNODE__ALL_POOLS)
  132581             : #define SGNODE__ALL_POOLS
  132582             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  132583             : #endif
  132584             : 
  132585             : SgLshiftOp* SgLshiftOp::next_node = nullptr;
  132586             : std::vector<unsigned char*> SgLshiftOp::pools;
  132587             : 
  132588             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  132589             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  132590             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  132591             : // around this macro definition rather than each use).
  132592             : #ifndef ALLOC_MUTEX
  132593             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  132594             :         do {                                                                     \
  132595             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  132596             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  132597             :                 abort();                                                         \
  132598             :             }                                                                    \
  132599             :         } while (0);
  132600             : #endif
  132601             : 
  132602             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  132603             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  132604             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  132605             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  132606             : 
  132607             : /*! \brief New operator for SgLshiftOp.
  132608             : 
  132609             :    This new operator implements memory pools to provide most efficent 
  132610             :    use of the heap within construction of large ASTs.
  132611             : 
  132612             : \internal The new and delete operators use the lower level C malloc/free
  132613             :    function calls for performance and to make sure that mixing of malloc/free
  132614             :    and new/delete by the used can be caught more readily.  This may change
  132615             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  132616             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  132617             :    deallocate memory allocated using ROSE_MALLOC.
  132618             : */
  132619        3185 : void *SgLshiftOp::operator new ( size_t Size )
  132620             : {
  132621             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  132622             :      * returning or throwing an exception. */
  132623        3185 :     ALLOC_MUTEX(SgLshiftOp, lock);
  132624             : 
  132625             : #if ROSE_ALLOC_TRACE == 2
  132626             : //    printf("SgLshiftOp::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgLshiftOp::next_node);
  132627             : #endif
  132628             : 
  132629             : #if USE_CPP_NEW_DELETE_OPERATORS
  132630             :     void *mem = ROSE_MALLOC(Size);
  132631             :     ALLOC_MUTEX(SgLshiftOp, unlock);
  132632             :     return mem;
  132633             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  132634             : #if ROSE_PEDANTIC_ALLOC
  132635             :     ROSE_ASSERT(Size == sizeof(SgLshiftOp));
  132636             : #else
  132637        3185 :     if (Size != sizeof(SgLshiftOp)) {
  132638           0 :       void * object = ROSE_MALLOC(Size);
  132639           0 :       ALLOC_MUTEX(SgLshiftOp, unlock);
  132640             :       return object;
  132641             :     }
  132642             : #endif
  132643             : 
  132644        3185 :     if (SgLshiftOp::next_node == nullptr) {
  132645          12 :         SgLshiftOp * alloc = (SgLshiftOp*) ROSE_MALLOC ( SgLshiftOp::pool_size * sizeof(SgLshiftOp) );
  132646          12 :         ROSE_ASSERT(alloc != nullptr);
  132647             : 
  132648             : #if ROSE_ALLOC_TRACE == 2
  132649             : //        printf("SgLshiftOp::alloc\n  block[%zi] = [ %p , %p [\n", SgLshiftOp::pools.size(), alloc, alloc + SgLshiftOp::pool_size);
  132650             : #endif
  132651             : 
  132652             : #if ROSE_ALLOC_MEMSET == 1
  132653             : #elif ROSE_ALLOC_MEMSET == 2
  132654             :         memset(alloc, 0x00, SgLshiftOp::pool_size * sizeof(SgLshiftOp));
  132655             : #elif ROSE_ALLOC_MEMSET == 3
  132656             :         memset(alloc, 0xAA, SgLshiftOp::pool_size * sizeof(SgLshiftOp));
  132657             : #endif
  132658       24000 :         for (unsigned i=0; i < SgLshiftOp::pool_size-1; i++) {
  132659       23988 :           alloc[i].p_freepointer = &(alloc[i+1]);
  132660             :         }
  132661          12 :         alloc[SgLshiftOp::pool_size-1].p_freepointer = nullptr;
  132662             : 
  132663          12 :         SgLshiftOp::pools.push_back ( (unsigned char *) alloc );
  132664          12 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgLshiftOp::pool_size * sizeof(SgLshiftOp), V_SgLshiftOp ) );
  132665          12 :         SgLshiftOp::next_node = alloc;
  132666             :     }
  132667        3185 :     ROSE_ASSERT(SgLshiftOp::next_node != nullptr);
  132668             : 
  132669        3185 :     SgLshiftOp * object = SgLshiftOp::next_node;
  132670        3185 :     SgLshiftOp::next_node = (SgLshiftOp*)(object->p_freepointer);
  132671             : 
  132672             : #if ROSE_ALLOC_TRACE == 2
  132673             :     printf("SgLshiftOp::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgLshiftOp::next_node);
  132674             : #endif
  132675             : 
  132676        3185 :     SgNode * fp = object->p_freepointer;
  132677             : #if ROSE_ALLOC_MEMSET == 1
  132678             : #elif ROSE_ALLOC_MEMSET == 2
  132679             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgLshiftOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  132680             : #elif ROSE_ALLOC_MEMSET == 3
  132681             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgLshiftOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  132682             : #endif
  132683        3185 :     object->p_freepointer = fp;
  132684             : 
  132685             : #if ROSE_ALLOC_TRACE == 2
  132686             : //    printf("SgLshiftOp::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgLshiftOp::next_node);
  132687             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  132688             :     Rose::MemPool::snapshot(oss.str());
  132689             :     alloc_trace_cnt++;
  132690             : #endif
  132691             : 
  132692        3185 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  132693             : 
  132694        3185 :     ALLOC_MUTEX(SgLshiftOp, unlock);
  132695             : 
  132696             :     return object;
  132697             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  132698             : }
  132699             : 
  132700             : 
  132701             : 
  132702             : /*! \brief Delete operator for SgLshiftOp.
  132703             : 
  132704             :    This delete operator implements deallocation using memory pools to 
  132705             :    provide most efficent use of the heap within construction of large ASTs.
  132706             : 
  132707             : \internal The new and delete operators use the lower level C malloc/free
  132708             :    function calls for performance and to make sure that mixing of malloc/free
  132709             :    and new/delete by the used can be caught more readily.  This may change
  132710             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  132711             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  132712             :    deallocate memory allocated using ROSE_MALLOC.
  132713             : */
  132714        2974 : void SgLshiftOp::operator delete(void *Pointer, size_t Size)
  132715             : {
  132716             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  132717             :      * or throwing an exception. */
  132718        2974 :     ALLOC_MUTEX(SgLshiftOp, lock);
  132719             : 
  132720             : #if USE_CPP_NEW_DELETE_OPERATORS
  132721             :     ROSE_FREE(Pointer);
  132722             : #else
  132723             : #if ROSE_PEDANTIC_ALLOC
  132724             :     ROSE_ASSERT(Size == sizeof(SgLshiftOp));
  132725             : #else
  132726        2974 :     if (Size != sizeof(SgLshiftOp)) {
  132727           0 :       ROSE_FREE(Pointer);
  132728           0 :       ALLOC_MUTEX(SgLshiftOp, unlock);
  132729             :       return;
  132730             :     }
  132731             : #endif
  132732             : 
  132733        2974 :     SgLshiftOp * object = (SgLshiftOp*) Pointer;
  132734        2974 :     ROSE_ASSERT(object != nullptr);
  132735             : 
  132736             : #if ROSE_ALLOC_TRACE == 2
  132737             : //  printf("SgLshiftOp::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgLshiftOp::next_node);
  132738             :     printf("SgLshiftOp::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgLshiftOp::next_node);
  132739             : #endif
  132740             : 
  132741             : #if ROSE_PEDANTIC_ALLOC
  132742             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  132743             : #endif
  132744             : 
  132745             : #if ROSE_ALLOC_MEMSET == 1
  132746             : #elif ROSE_ALLOC_MEMSET == 2
  132747             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgLshiftOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  132748             : #elif ROSE_ALLOC_MEMSET == 3
  132749             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgLshiftOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  132750             : #endif
  132751             : 
  132752             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  132753             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  132754             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  132755             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  132756             : #else
  132757        2974 :     object->p_freepointer = SgLshiftOp::next_node;
  132758        2974 :     SgLshiftOp::next_node = object;
  132759             : #endif
  132760             : 
  132761             : #if ROSE_ALLOC_TRACE == 2
  132762             : //  printf("SgLshiftOp::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgLshiftOp::next_node);
  132763             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  132764             :     Rose::MemPool::snapshot(oss.str());
  132765             :     alloc_trace_cnt++;
  132766             : #endif
  132767             : 
  132768             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  132769             : 
  132770        2974 :     ALLOC_MUTEX(SgLshiftOp, unlock);
  132771             : }
  132772             : 
  132773             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  132774             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  132775             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  132776             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  132777             : // Also, note comment below from Robb (copied from the Common.code file).
  132778             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  132779             : //
  132780             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  132781             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  132782             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  132783             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  132784             : #if 0
  132785             : void SgLshiftOp::operator delete(void* pointer) { SgLshiftOp::operator delete (pointer, sizeof(SgLshiftOp)); };
  132786             : #endif
  132787             : /* #line 132788 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  132788             : 
  132789             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  132790             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  132791             : // obviously imply C++.
  132792             : 
  132793             : // This implements the support within ROSE for memory pools.  Memory pools
  132794             : // support the most condensed usage of memory within the construction of
  132795             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  132796             : // by a new operator written for each class.
  132797             : 
  132798             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  132799             :     // User wants multi-thread support and POSIX threads are available.
  132800             : #   include <pthread.h>
  132801             :     static pthread_mutex_t SgRshiftOp_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  132802             : #else
  132803             :      // Cause synchronization to be skipped.
  132804             : #    ifndef ALLOC_MUTEX
  132805             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  132806             : #    endif
  132807             : #    ifdef _REENTRANT
  132808             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  132809             : #       ifdef _MSC_VER
  132810             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  132811             : #       else
  132812             : #           warning "POSIX threads are not available; synchronization being skipped"
  132813             : #       endif
  132814             : #    endif
  132815             : #endif
  132816             : 
  132817             : #ifndef ROSE_ALLOC_TRACE
  132818             : #  define ROSE_ALLOC_TRACE 0
  132819             : #endif
  132820             : 
  132821             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  132822             : #define ROSE_ALLOC_TRACE_CNT
  132823             : #include "memory-pool-snapshot.h"
  132824             : unsigned long alloc_trace_cnt = 0;
  132825             : #endif
  132826             : 
  132827             : #if ROSE_ALLOC_TRACE
  132828             : const unsigned SgRshiftOp::pool_size = 5;
  132829             : #else
  132830             : const unsigned SgRshiftOp::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  132831             : #endif
  132832             : 
  132833             : #ifndef ROSE_ALLOC_MEMSET
  132834             : #  define ROSE_ALLOC_MEMSET 0
  132835             : #endif
  132836             : 
  132837             : #ifndef ROSE_PEDANTIC_ALLOC
  132838             : #  define ROSE_PEDANTIC_ALLOC 0
  132839             : #endif
  132840             : 
  132841             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  132842             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  132843             : #endif
  132844             : 
  132845             : #if !defined(SGNODE__ALL_POOLS)
  132846             : #define SGNODE__ALL_POOLS
  132847             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  132848             : #endif
  132849             : 
  132850             : SgRshiftOp* SgRshiftOp::next_node = nullptr;
  132851             : std::vector<unsigned char*> SgRshiftOp::pools;
  132852             : 
  132853             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  132854             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  132855             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  132856             : // around this macro definition rather than each use).
  132857             : #ifndef ALLOC_MUTEX
  132858             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  132859             :         do {                                                                     \
  132860             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  132861             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  132862             :                 abort();                                                         \
  132863             :             }                                                                    \
  132864             :         } while (0);
  132865             : #endif
  132866             : 
  132867             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  132868             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  132869             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  132870             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  132871             : 
  132872             : /*! \brief New operator for SgRshiftOp.
  132873             : 
  132874             :    This new operator implements memory pools to provide most efficent 
  132875             :    use of the heap within construction of large ASTs.
  132876             : 
  132877             : \internal The new and delete operators use the lower level C malloc/free
  132878             :    function calls for performance and to make sure that mixing of malloc/free
  132879             :    and new/delete by the used can be caught more readily.  This may change
  132880             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  132881             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  132882             :    deallocate memory allocated using ROSE_MALLOC.
  132883             : */
  132884         773 : void *SgRshiftOp::operator new ( size_t Size )
  132885             : {
  132886             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  132887             :      * returning or throwing an exception. */
  132888         773 :     ALLOC_MUTEX(SgRshiftOp, lock);
  132889             : 
  132890             : #if ROSE_ALLOC_TRACE == 2
  132891             : //    printf("SgRshiftOp::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgRshiftOp::next_node);
  132892             : #endif
  132893             : 
  132894             : #if USE_CPP_NEW_DELETE_OPERATORS
  132895             :     void *mem = ROSE_MALLOC(Size);
  132896             :     ALLOC_MUTEX(SgRshiftOp, unlock);
  132897             :     return mem;
  132898             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  132899             : #if ROSE_PEDANTIC_ALLOC
  132900             :     ROSE_ASSERT(Size == sizeof(SgRshiftOp));
  132901             : #else
  132902         773 :     if (Size != sizeof(SgRshiftOp)) {
  132903           0 :       void * object = ROSE_MALLOC(Size);
  132904           0 :       ALLOC_MUTEX(SgRshiftOp, unlock);
  132905             :       return object;
  132906             :     }
  132907             : #endif
  132908             : 
  132909         773 :     if (SgRshiftOp::next_node == nullptr) {
  132910          10 :         SgRshiftOp * alloc = (SgRshiftOp*) ROSE_MALLOC ( SgRshiftOp::pool_size * sizeof(SgRshiftOp) );
  132911          10 :         ROSE_ASSERT(alloc != nullptr);
  132912             : 
  132913             : #if ROSE_ALLOC_TRACE == 2
  132914             : //        printf("SgRshiftOp::alloc\n  block[%zi] = [ %p , %p [\n", SgRshiftOp::pools.size(), alloc, alloc + SgRshiftOp::pool_size);
  132915             : #endif
  132916             : 
  132917             : #if ROSE_ALLOC_MEMSET == 1
  132918             : #elif ROSE_ALLOC_MEMSET == 2
  132919             :         memset(alloc, 0x00, SgRshiftOp::pool_size * sizeof(SgRshiftOp));
  132920             : #elif ROSE_ALLOC_MEMSET == 3
  132921             :         memset(alloc, 0xAA, SgRshiftOp::pool_size * sizeof(SgRshiftOp));
  132922             : #endif
  132923       20000 :         for (unsigned i=0; i < SgRshiftOp::pool_size-1; i++) {
  132924       19990 :           alloc[i].p_freepointer = &(alloc[i+1]);
  132925             :         }
  132926          10 :         alloc[SgRshiftOp::pool_size-1].p_freepointer = nullptr;
  132927             : 
  132928          10 :         SgRshiftOp::pools.push_back ( (unsigned char *) alloc );
  132929          10 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgRshiftOp::pool_size * sizeof(SgRshiftOp), V_SgRshiftOp ) );
  132930          10 :         SgRshiftOp::next_node = alloc;
  132931             :     }
  132932         773 :     ROSE_ASSERT(SgRshiftOp::next_node != nullptr);
  132933             : 
  132934         773 :     SgRshiftOp * object = SgRshiftOp::next_node;
  132935         773 :     SgRshiftOp::next_node = (SgRshiftOp*)(object->p_freepointer);
  132936             : 
  132937             : #if ROSE_ALLOC_TRACE == 2
  132938             :     printf("SgRshiftOp::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgRshiftOp::next_node);
  132939             : #endif
  132940             : 
  132941         773 :     SgNode * fp = object->p_freepointer;
  132942             : #if ROSE_ALLOC_MEMSET == 1
  132943             : #elif ROSE_ALLOC_MEMSET == 2
  132944             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgRshiftOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  132945             : #elif ROSE_ALLOC_MEMSET == 3
  132946             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgRshiftOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  132947             : #endif
  132948         773 :     object->p_freepointer = fp;
  132949             : 
  132950             : #if ROSE_ALLOC_TRACE == 2
  132951             : //    printf("SgRshiftOp::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgRshiftOp::next_node);
  132952             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  132953             :     Rose::MemPool::snapshot(oss.str());
  132954             :     alloc_trace_cnt++;
  132955             : #endif
  132956             : 
  132957         773 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  132958             : 
  132959         773 :     ALLOC_MUTEX(SgRshiftOp, unlock);
  132960             : 
  132961             :     return object;
  132962             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  132963             : }
  132964             : 
  132965             : 
  132966             : 
  132967             : /*! \brief Delete operator for SgRshiftOp.
  132968             : 
  132969             :    This delete operator implements deallocation using memory pools to 
  132970             :    provide most efficent use of the heap within construction of large ASTs.
  132971             : 
  132972             : \internal The new and delete operators use the lower level C malloc/free
  132973             :    function calls for performance and to make sure that mixing of malloc/free
  132974             :    and new/delete by the used can be caught more readily.  This may change
  132975             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  132976             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  132977             :    deallocate memory allocated using ROSE_MALLOC.
  132978             : */
  132979         712 : void SgRshiftOp::operator delete(void *Pointer, size_t Size)
  132980             : {
  132981             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  132982             :      * or throwing an exception. */
  132983         712 :     ALLOC_MUTEX(SgRshiftOp, lock);
  132984             : 
  132985             : #if USE_CPP_NEW_DELETE_OPERATORS
  132986             :     ROSE_FREE(Pointer);
  132987             : #else
  132988             : #if ROSE_PEDANTIC_ALLOC
  132989             :     ROSE_ASSERT(Size == sizeof(SgRshiftOp));
  132990             : #else
  132991         712 :     if (Size != sizeof(SgRshiftOp)) {
  132992           0 :       ROSE_FREE(Pointer);
  132993           0 :       ALLOC_MUTEX(SgRshiftOp, unlock);
  132994             :       return;
  132995             :     }
  132996             : #endif
  132997             : 
  132998         712 :     SgRshiftOp * object = (SgRshiftOp*) Pointer;
  132999         712 :     ROSE_ASSERT(object != nullptr);
  133000             : 
  133001             : #if ROSE_ALLOC_TRACE == 2
  133002             : //  printf("SgRshiftOp::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgRshiftOp::next_node);
  133003             :     printf("SgRshiftOp::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgRshiftOp::next_node);
  133004             : #endif
  133005             : 
  133006             : #if ROSE_PEDANTIC_ALLOC
  133007             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  133008             : #endif
  133009             : 
  133010             : #if ROSE_ALLOC_MEMSET == 1
  133011             : #elif ROSE_ALLOC_MEMSET == 2
  133012             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgRshiftOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  133013             : #elif ROSE_ALLOC_MEMSET == 3
  133014             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgRshiftOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  133015             : #endif
  133016             : 
  133017             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  133018             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  133019             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  133020             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  133021             : #else
  133022         712 :     object->p_freepointer = SgRshiftOp::next_node;
  133023         712 :     SgRshiftOp::next_node = object;
  133024             : #endif
  133025             : 
  133026             : #if ROSE_ALLOC_TRACE == 2
  133027             : //  printf("SgRshiftOp::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgRshiftOp::next_node);
  133028             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  133029             :     Rose::MemPool::snapshot(oss.str());
  133030             :     alloc_trace_cnt++;
  133031             : #endif
  133032             : 
  133033             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  133034             : 
  133035         712 :     ALLOC_MUTEX(SgRshiftOp, unlock);
  133036             : }
  133037             : 
  133038             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  133039             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  133040             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  133041             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  133042             : // Also, note comment below from Robb (copied from the Common.code file).
  133043             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  133044             : //
  133045             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  133046             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  133047             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  133048             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  133049             : #if 0
  133050             : void SgRshiftOp::operator delete(void* pointer) { SgRshiftOp::operator delete (pointer, sizeof(SgRshiftOp)); };
  133051             : #endif
  133052             : /* #line 133053 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  133053             : 
  133054             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  133055             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  133056             : // obviously imply C++.
  133057             : 
  133058             : // This implements the support within ROSE for memory pools.  Memory pools
  133059             : // support the most condensed usage of memory within the construction of
  133060             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  133061             : // by a new operator written for each class.
  133062             : 
  133063             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  133064             :     // User wants multi-thread support and POSIX threads are available.
  133065             : #   include <pthread.h>
  133066             :     static pthread_mutex_t SgPntrArrRefExp_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  133067             : #else
  133068             :      // Cause synchronization to be skipped.
  133069             : #    ifndef ALLOC_MUTEX
  133070             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  133071             : #    endif
  133072             : #    ifdef _REENTRANT
  133073             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  133074             : #       ifdef _MSC_VER
  133075             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  133076             : #       else
  133077             : #           warning "POSIX threads are not available; synchronization being skipped"
  133078             : #       endif
  133079             : #    endif
  133080             : #endif
  133081             : 
  133082             : #ifndef ROSE_ALLOC_TRACE
  133083             : #  define ROSE_ALLOC_TRACE 0
  133084             : #endif
  133085             : 
  133086             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  133087             : #define ROSE_ALLOC_TRACE_CNT
  133088             : #include "memory-pool-snapshot.h"
  133089             : unsigned long alloc_trace_cnt = 0;
  133090             : #endif
  133091             : 
  133092             : #if ROSE_ALLOC_TRACE
  133093             : const unsigned SgPntrArrRefExp::pool_size = 5;
  133094             : #else
  133095             : const unsigned SgPntrArrRefExp::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  133096             : #endif
  133097             : 
  133098             : #ifndef ROSE_ALLOC_MEMSET
  133099             : #  define ROSE_ALLOC_MEMSET 0
  133100             : #endif
  133101             : 
  133102             : #ifndef ROSE_PEDANTIC_ALLOC
  133103             : #  define ROSE_PEDANTIC_ALLOC 0
  133104             : #endif
  133105             : 
  133106             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  133107             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  133108             : #endif
  133109             : 
  133110             : #if !defined(SGNODE__ALL_POOLS)
  133111             : #define SGNODE__ALL_POOLS
  133112             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  133113             : #endif
  133114             : 
  133115             : SgPntrArrRefExp* SgPntrArrRefExp::next_node = nullptr;
  133116             : std::vector<unsigned char*> SgPntrArrRefExp::pools;
  133117             : 
  133118             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  133119             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  133120             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  133121             : // around this macro definition rather than each use).
  133122             : #ifndef ALLOC_MUTEX
  133123             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  133124             :         do {                                                                     \
  133125             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  133126             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  133127             :                 abort();                                                         \
  133128             :             }                                                                    \
  133129             :         } while (0);
  133130             : #endif
  133131             : 
  133132             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  133133             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  133134             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  133135             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  133136             : 
  133137             : /*! \brief New operator for SgPntrArrRefExp.
  133138             : 
  133139             :    This new operator implements memory pools to provide most efficent 
  133140             :    use of the heap within construction of large ASTs.
  133141             : 
  133142             : \internal The new and delete operators use the lower level C malloc/free
  133143             :    function calls for performance and to make sure that mixing of malloc/free
  133144             :    and new/delete by the used can be caught more readily.  This may change
  133145             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  133146             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  133147             :    deallocate memory allocated using ROSE_MALLOC.
  133148             : */
  133149        2304 : void *SgPntrArrRefExp::operator new ( size_t Size )
  133150             : {
  133151             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  133152             :      * returning or throwing an exception. */
  133153        2304 :     ALLOC_MUTEX(SgPntrArrRefExp, lock);
  133154             : 
  133155             : #if ROSE_ALLOC_TRACE == 2
  133156             : //    printf("SgPntrArrRefExp::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgPntrArrRefExp::next_node);
  133157             : #endif
  133158             : 
  133159             : #if USE_CPP_NEW_DELETE_OPERATORS
  133160             :     void *mem = ROSE_MALLOC(Size);
  133161             :     ALLOC_MUTEX(SgPntrArrRefExp, unlock);
  133162             :     return mem;
  133163             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  133164             : #if ROSE_PEDANTIC_ALLOC
  133165             :     ROSE_ASSERT(Size == sizeof(SgPntrArrRefExp));
  133166             : #else
  133167        2304 :     if (Size != sizeof(SgPntrArrRefExp)) {
  133168           0 :       void * object = ROSE_MALLOC(Size);
  133169           0 :       ALLOC_MUTEX(SgPntrArrRefExp, unlock);
  133170             :       return object;
  133171             :     }
  133172             : #endif
  133173             : 
  133174        2304 :     if (SgPntrArrRefExp::next_node == nullptr) {
  133175         144 :         SgPntrArrRefExp * alloc = (SgPntrArrRefExp*) ROSE_MALLOC ( SgPntrArrRefExp::pool_size * sizeof(SgPntrArrRefExp) );
  133176         144 :         ROSE_ASSERT(alloc != nullptr);
  133177             : 
  133178             : #if ROSE_ALLOC_TRACE == 2
  133179             : //        printf("SgPntrArrRefExp::alloc\n  block[%zi] = [ %p , %p [\n", SgPntrArrRefExp::pools.size(), alloc, alloc + SgPntrArrRefExp::pool_size);
  133180             : #endif
  133181             : 
  133182             : #if ROSE_ALLOC_MEMSET == 1
  133183             : #elif ROSE_ALLOC_MEMSET == 2
  133184             :         memset(alloc, 0x00, SgPntrArrRefExp::pool_size * sizeof(SgPntrArrRefExp));
  133185             : #elif ROSE_ALLOC_MEMSET == 3
  133186             :         memset(alloc, 0xAA, SgPntrArrRefExp::pool_size * sizeof(SgPntrArrRefExp));
  133187             : #endif
  133188      288000 :         for (unsigned i=0; i < SgPntrArrRefExp::pool_size-1; i++) {
  133189      287856 :           alloc[i].p_freepointer = &(alloc[i+1]);
  133190             :         }
  133191         144 :         alloc[SgPntrArrRefExp::pool_size-1].p_freepointer = nullptr;
  133192             : 
  133193         144 :         SgPntrArrRefExp::pools.push_back ( (unsigned char *) alloc );
  133194         144 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgPntrArrRefExp::pool_size * sizeof(SgPntrArrRefExp), V_SgPntrArrRefExp ) );
  133195         144 :         SgPntrArrRefExp::next_node = alloc;
  133196             :     }
  133197        2304 :     ROSE_ASSERT(SgPntrArrRefExp::next_node != nullptr);
  133198             : 
  133199        2304 :     SgPntrArrRefExp * object = SgPntrArrRefExp::next_node;
  133200        2304 :     SgPntrArrRefExp::next_node = (SgPntrArrRefExp*)(object->p_freepointer);
  133201             : 
  133202             : #if ROSE_ALLOC_TRACE == 2
  133203             :     printf("SgPntrArrRefExp::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgPntrArrRefExp::next_node);
  133204             : #endif
  133205             : 
  133206        2304 :     SgNode * fp = object->p_freepointer;
  133207             : #if ROSE_ALLOC_MEMSET == 1
  133208             : #elif ROSE_ALLOC_MEMSET == 2
  133209             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgPntrArrRefExp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  133210             : #elif ROSE_ALLOC_MEMSET == 3
  133211             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgPntrArrRefExp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  133212             : #endif
  133213        2304 :     object->p_freepointer = fp;
  133214             : 
  133215             : #if ROSE_ALLOC_TRACE == 2
  133216             : //    printf("SgPntrArrRefExp::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgPntrArrRefExp::next_node);
  133217             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  133218             :     Rose::MemPool::snapshot(oss.str());
  133219             :     alloc_trace_cnt++;
  133220             : #endif
  133221             : 
  133222        2304 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  133223             : 
  133224        2304 :     ALLOC_MUTEX(SgPntrArrRefExp, unlock);
  133225             : 
  133226             :     return object;
  133227             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  133228             : }
  133229             : 
  133230             : 
  133231             : 
  133232             : /*! \brief Delete operator for SgPntrArrRefExp.
  133233             : 
  133234             :    This delete operator implements deallocation using memory pools to 
  133235             :    provide most efficent use of the heap within construction of large ASTs.
  133236             : 
  133237             : \internal The new and delete operators use the lower level C malloc/free
  133238             :    function calls for performance and to make sure that mixing of malloc/free
  133239             :    and new/delete by the used can be caught more readily.  This may change
  133240             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  133241             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  133242             :    deallocate memory allocated using ROSE_MALLOC.
  133243             : */
  133244         284 : void SgPntrArrRefExp::operator delete(void *Pointer, size_t Size)
  133245             : {
  133246             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  133247             :      * or throwing an exception. */
  133248         284 :     ALLOC_MUTEX(SgPntrArrRefExp, lock);
  133249             : 
  133250             : #if USE_CPP_NEW_DELETE_OPERATORS
  133251             :     ROSE_FREE(Pointer);
  133252             : #else
  133253             : #if ROSE_PEDANTIC_ALLOC
  133254             :     ROSE_ASSERT(Size == sizeof(SgPntrArrRefExp));
  133255             : #else
  133256         284 :     if (Size != sizeof(SgPntrArrRefExp)) {
  133257           0 :       ROSE_FREE(Pointer);
  133258           0 :       ALLOC_MUTEX(SgPntrArrRefExp, unlock);
  133259             :       return;
  133260             :     }
  133261             : #endif
  133262             : 
  133263         284 :     SgPntrArrRefExp * object = (SgPntrArrRefExp*) Pointer;
  133264         284 :     ROSE_ASSERT(object != nullptr);
  133265             : 
  133266             : #if ROSE_ALLOC_TRACE == 2
  133267             : //  printf("SgPntrArrRefExp::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgPntrArrRefExp::next_node);
  133268             :     printf("SgPntrArrRefExp::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgPntrArrRefExp::next_node);
  133269             : #endif
  133270             : 
  133271             : #if ROSE_PEDANTIC_ALLOC
  133272             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  133273             : #endif
  133274             : 
  133275             : #if ROSE_ALLOC_MEMSET == 1
  133276             : #elif ROSE_ALLOC_MEMSET == 2
  133277             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgPntrArrRefExp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  133278             : #elif ROSE_ALLOC_MEMSET == 3
  133279             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgPntrArrRefExp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  133280             : #endif
  133281             : 
  133282             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  133283             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  133284             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  133285             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  133286             : #else
  133287         284 :     object->p_freepointer = SgPntrArrRefExp::next_node;
  133288         284 :     SgPntrArrRefExp::next_node = object;
  133289             : #endif
  133290             : 
  133291             : #if ROSE_ALLOC_TRACE == 2
  133292             : //  printf("SgPntrArrRefExp::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgPntrArrRefExp::next_node);
  133293             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  133294             :     Rose::MemPool::snapshot(oss.str());
  133295             :     alloc_trace_cnt++;
  133296             : #endif
  133297             : 
  133298             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  133299             : 
  133300         284 :     ALLOC_MUTEX(SgPntrArrRefExp, unlock);
  133301             : }
  133302             : 
  133303             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  133304             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  133305             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  133306             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  133307             : // Also, note comment below from Robb (copied from the Common.code file).
  133308             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  133309             : //
  133310             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  133311             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  133312             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  133313             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  133314             : #if 0
  133315             : void SgPntrArrRefExp::operator delete(void* pointer) { SgPntrArrRefExp::operator delete (pointer, sizeof(SgPntrArrRefExp)); };
  133316             : #endif
  133317             : /* #line 133318 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  133318             : 
  133319             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  133320             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  133321             : // obviously imply C++.
  133322             : 
  133323             : // This implements the support within ROSE for memory pools.  Memory pools
  133324             : // support the most condensed usage of memory within the construction of
  133325             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  133326             : // by a new operator written for each class.
  133327             : 
  133328             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  133329             :     // User wants multi-thread support and POSIX threads are available.
  133330             : #   include <pthread.h>
  133331             :     static pthread_mutex_t SgScopeOp_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  133332             : #else
  133333             :      // Cause synchronization to be skipped.
  133334             : #    ifndef ALLOC_MUTEX
  133335             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  133336             : #    endif
  133337             : #    ifdef _REENTRANT
  133338             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  133339             : #       ifdef _MSC_VER
  133340             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  133341             : #       else
  133342             : #           warning "POSIX threads are not available; synchronization being skipped"
  133343             : #       endif
  133344             : #    endif
  133345             : #endif
  133346             : 
  133347             : #ifndef ROSE_ALLOC_TRACE
  133348             : #  define ROSE_ALLOC_TRACE 0
  133349             : #endif
  133350             : 
  133351             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  133352             : #define ROSE_ALLOC_TRACE_CNT
  133353             : #include "memory-pool-snapshot.h"
  133354             : unsigned long alloc_trace_cnt = 0;
  133355             : #endif
  133356             : 
  133357             : #if ROSE_ALLOC_TRACE
  133358             : const unsigned SgScopeOp::pool_size = 5;
  133359             : #else
  133360             : const unsigned SgScopeOp::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  133361             : #endif
  133362             : 
  133363             : #ifndef ROSE_ALLOC_MEMSET
  133364             : #  define ROSE_ALLOC_MEMSET 0
  133365             : #endif
  133366             : 
  133367             : #ifndef ROSE_PEDANTIC_ALLOC
  133368             : #  define ROSE_PEDANTIC_ALLOC 0
  133369             : #endif
  133370             : 
  133371             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  133372             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  133373             : #endif
  133374             : 
  133375             : #if !defined(SGNODE__ALL_POOLS)
  133376             : #define SGNODE__ALL_POOLS
  133377             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  133378             : #endif
  133379             : 
  133380             : SgScopeOp* SgScopeOp::next_node = nullptr;
  133381             : std::vector<unsigned char*> SgScopeOp::pools;
  133382             : 
  133383             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  133384             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  133385             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  133386             : // around this macro definition rather than each use).
  133387             : #ifndef ALLOC_MUTEX
  133388             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  133389             :         do {                                                                     \
  133390             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  133391             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  133392             :                 abort();                                                         \
  133393             :             }                                                                    \
  133394             :         } while (0);
  133395             : #endif
  133396             : 
  133397             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  133398             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  133399             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  133400             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  133401             : 
  133402             : /*! \brief New operator for SgScopeOp.
  133403             : 
  133404             :    This new operator implements memory pools to provide most efficent 
  133405             :    use of the heap within construction of large ASTs.
  133406             : 
  133407             : \internal The new and delete operators use the lower level C malloc/free
  133408             :    function calls for performance and to make sure that mixing of malloc/free
  133409             :    and new/delete by the used can be caught more readily.  This may change
  133410             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  133411             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  133412             :    deallocate memory allocated using ROSE_MALLOC.
  133413             : */
  133414           0 : void *SgScopeOp::operator new ( size_t Size )
  133415             : {
  133416             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  133417             :      * returning or throwing an exception. */
  133418           0 :     ALLOC_MUTEX(SgScopeOp, lock);
  133419             : 
  133420             : #if ROSE_ALLOC_TRACE == 2
  133421             : //    printf("SgScopeOp::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgScopeOp::next_node);
  133422             : #endif
  133423             : 
  133424             : #if USE_CPP_NEW_DELETE_OPERATORS
  133425             :     void *mem = ROSE_MALLOC(Size);
  133426             :     ALLOC_MUTEX(SgScopeOp, unlock);
  133427             :     return mem;
  133428             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  133429             : #if ROSE_PEDANTIC_ALLOC
  133430             :     ROSE_ASSERT(Size == sizeof(SgScopeOp));
  133431             : #else
  133432           0 :     if (Size != sizeof(SgScopeOp)) {
  133433           0 :       void * object = ROSE_MALLOC(Size);
  133434           0 :       ALLOC_MUTEX(SgScopeOp, unlock);
  133435             :       return object;
  133436             :     }
  133437             : #endif
  133438             : 
  133439           0 :     if (SgScopeOp::next_node == nullptr) {
  133440           0 :         SgScopeOp * alloc = (SgScopeOp*) ROSE_MALLOC ( SgScopeOp::pool_size * sizeof(SgScopeOp) );
  133441           0 :         ROSE_ASSERT(alloc != nullptr);
  133442             : 
  133443             : #if ROSE_ALLOC_TRACE == 2
  133444             : //        printf("SgScopeOp::alloc\n  block[%zi] = [ %p , %p [\n", SgScopeOp::pools.size(), alloc, alloc + SgScopeOp::pool_size);
  133445             : #endif
  133446             : 
  133447             : #if ROSE_ALLOC_MEMSET == 1
  133448             : #elif ROSE_ALLOC_MEMSET == 2
  133449             :         memset(alloc, 0x00, SgScopeOp::pool_size * sizeof(SgScopeOp));
  133450             : #elif ROSE_ALLOC_MEMSET == 3
  133451             :         memset(alloc, 0xAA, SgScopeOp::pool_size * sizeof(SgScopeOp));
  133452             : #endif
  133453           0 :         for (unsigned i=0; i < SgScopeOp::pool_size-1; i++) {
  133454           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
  133455             :         }
  133456           0 :         alloc[SgScopeOp::pool_size-1].p_freepointer = nullptr;
  133457             : 
  133458           0 :         SgScopeOp::pools.push_back ( (unsigned char *) alloc );
  133459           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgScopeOp::pool_size * sizeof(SgScopeOp), V_SgScopeOp ) );
  133460           0 :         SgScopeOp::next_node = alloc;
  133461             :     }
  133462           0 :     ROSE_ASSERT(SgScopeOp::next_node != nullptr);
  133463             : 
  133464           0 :     SgScopeOp * object = SgScopeOp::next_node;
  133465           0 :     SgScopeOp::next_node = (SgScopeOp*)(object->p_freepointer);
  133466             : 
  133467             : #if ROSE_ALLOC_TRACE == 2
  133468             :     printf("SgScopeOp::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgScopeOp::next_node);
  133469             : #endif
  133470             : 
  133471           0 :     SgNode * fp = object->p_freepointer;
  133472             : #if ROSE_ALLOC_MEMSET == 1
  133473             : #elif ROSE_ALLOC_MEMSET == 2
  133474             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgScopeOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  133475             : #elif ROSE_ALLOC_MEMSET == 3
  133476             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgScopeOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  133477             : #endif
  133478           0 :     object->p_freepointer = fp;
  133479             : 
  133480             : #if ROSE_ALLOC_TRACE == 2
  133481             : //    printf("SgScopeOp::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgScopeOp::next_node);
  133482             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  133483             :     Rose::MemPool::snapshot(oss.str());
  133484             :     alloc_trace_cnt++;
  133485             : #endif
  133486             : 
  133487           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  133488             : 
  133489           0 :     ALLOC_MUTEX(SgScopeOp, unlock);
  133490             : 
  133491             :     return object;
  133492             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  133493             : }
  133494             : 
  133495             : 
  133496             : 
  133497             : /*! \brief Delete operator for SgScopeOp.
  133498             : 
  133499             :    This delete operator implements deallocation using memory pools to 
  133500             :    provide most efficent use of the heap within construction of large ASTs.
  133501             : 
  133502             : \internal The new and delete operators use the lower level C malloc/free
  133503             :    function calls for performance and to make sure that mixing of malloc/free
  133504             :    and new/delete by the used can be caught more readily.  This may change
  133505             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  133506             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  133507             :    deallocate memory allocated using ROSE_MALLOC.
  133508             : */
  133509           0 : void SgScopeOp::operator delete(void *Pointer, size_t Size)
  133510             : {
  133511             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  133512             :      * or throwing an exception. */
  133513           0 :     ALLOC_MUTEX(SgScopeOp, lock);
  133514             : 
  133515             : #if USE_CPP_NEW_DELETE_OPERATORS
  133516             :     ROSE_FREE(Pointer);
  133517             : #else
  133518             : #if ROSE_PEDANTIC_ALLOC
  133519             :     ROSE_ASSERT(Size == sizeof(SgScopeOp));
  133520             : #else
  133521           0 :     if (Size != sizeof(SgScopeOp)) {
  133522           0 :       ROSE_FREE(Pointer);
  133523           0 :       ALLOC_MUTEX(SgScopeOp, unlock);
  133524             :       return;
  133525             :     }
  133526             : #endif
  133527             : 
  133528           0 :     SgScopeOp * object = (SgScopeOp*) Pointer;
  133529           0 :     ROSE_ASSERT(object != nullptr);
  133530             : 
  133531             : #if ROSE_ALLOC_TRACE == 2
  133532             : //  printf("SgScopeOp::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgScopeOp::next_node);
  133533             :     printf("SgScopeOp::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgScopeOp::next_node);
  133534             : #endif
  133535             : 
  133536             : #if ROSE_PEDANTIC_ALLOC
  133537             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  133538             : #endif
  133539             : 
  133540             : #if ROSE_ALLOC_MEMSET == 1
  133541             : #elif ROSE_ALLOC_MEMSET == 2
  133542             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgScopeOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  133543             : #elif ROSE_ALLOC_MEMSET == 3
  133544             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgScopeOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  133545             : #endif
  133546             : 
  133547             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  133548             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  133549             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  133550             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  133551             : #else
  133552           0 :     object->p_freepointer = SgScopeOp::next_node;
  133553           0 :     SgScopeOp::next_node = object;
  133554             : #endif
  133555             : 
  133556             : #if ROSE_ALLOC_TRACE == 2
  133557             : //  printf("SgScopeOp::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgScopeOp::next_node);
  133558             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  133559             :     Rose::MemPool::snapshot(oss.str());
  133560             :     alloc_trace_cnt++;
  133561             : #endif
  133562             : 
  133563             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  133564             : 
  133565           0 :     ALLOC_MUTEX(SgScopeOp, unlock);
  133566             : }
  133567             : 
  133568             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  133569             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  133570             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  133571             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  133572             : // Also, note comment below from Robb (copied from the Common.code file).
  133573             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  133574             : //
  133575             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  133576             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  133577             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  133578             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  133579             : #if 0
  133580             : void SgScopeOp::operator delete(void* pointer) { SgScopeOp::operator delete (pointer, sizeof(SgScopeOp)); };
  133581             : #endif
  133582             : /* #line 133583 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  133583             : 
  133584             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  133585             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  133586             : // obviously imply C++.
  133587             : 
  133588             : // This implements the support within ROSE for memory pools.  Memory pools
  133589             : // support the most condensed usage of memory within the construction of
  133590             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  133591             : // by a new operator written for each class.
  133592             : 
  133593             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  133594             :     // User wants multi-thread support and POSIX threads are available.
  133595             : #   include <pthread.h>
  133596             :     static pthread_mutex_t SgAssignOp_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  133597             : #else
  133598             :      // Cause synchronization to be skipped.
  133599             : #    ifndef ALLOC_MUTEX
  133600             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  133601             : #    endif
  133602             : #    ifdef _REENTRANT
  133603             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  133604             : #       ifdef _MSC_VER
  133605             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  133606             : #       else
  133607             : #           warning "POSIX threads are not available; synchronization being skipped"
  133608             : #       endif
  133609             : #    endif
  133610             : #endif
  133611             : 
  133612             : #ifndef ROSE_ALLOC_TRACE
  133613             : #  define ROSE_ALLOC_TRACE 0
  133614             : #endif
  133615             : 
  133616             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  133617             : #define ROSE_ALLOC_TRACE_CNT
  133618             : #include "memory-pool-snapshot.h"
  133619             : unsigned long alloc_trace_cnt = 0;
  133620             : #endif
  133621             : 
  133622             : #if ROSE_ALLOC_TRACE
  133623             : const unsigned SgAssignOp::pool_size = 5;
  133624             : #else
  133625             : const unsigned SgAssignOp::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  133626             : #endif
  133627             : 
  133628             : #ifndef ROSE_ALLOC_MEMSET
  133629             : #  define ROSE_ALLOC_MEMSET 0
  133630             : #endif
  133631             : 
  133632             : #ifndef ROSE_PEDANTIC_ALLOC
  133633             : #  define ROSE_PEDANTIC_ALLOC 0
  133634             : #endif
  133635             : 
  133636             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  133637             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  133638             : #endif
  133639             : 
  133640             : #if !defined(SGNODE__ALL_POOLS)
  133641             : #define SGNODE__ALL_POOLS
  133642             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  133643             : #endif
  133644             : 
  133645             : SgAssignOp* SgAssignOp::next_node = nullptr;
  133646             : std::vector<unsigned char*> SgAssignOp::pools;
  133647             : 
  133648             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  133649             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  133650             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  133651             : // around this macro definition rather than each use).
  133652             : #ifndef ALLOC_MUTEX
  133653             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  133654             :         do {                                                                     \
  133655             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  133656             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  133657             :                 abort();                                                         \
  133658             :             }                                                                    \
  133659             :         } while (0);
  133660             : #endif
  133661             : 
  133662             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  133663             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  133664             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  133665             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  133666             : 
  133667             : /*! \brief New operator for SgAssignOp.
  133668             : 
  133669             :    This new operator implements memory pools to provide most efficent 
  133670             :    use of the heap within construction of large ASTs.
  133671             : 
  133672             : \internal The new and delete operators use the lower level C malloc/free
  133673             :    function calls for performance and to make sure that mixing of malloc/free
  133674             :    and new/delete by the used can be caught more readily.  This may change
  133675             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  133676             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  133677             :    deallocate memory allocated using ROSE_MALLOC.
  133678             : */
  133679        6298 : void *SgAssignOp::operator new ( size_t Size )
  133680             : {
  133681             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  133682             :      * returning or throwing an exception. */
  133683        6298 :     ALLOC_MUTEX(SgAssignOp, lock);
  133684             : 
  133685             : #if ROSE_ALLOC_TRACE == 2
  133686             : //    printf("SgAssignOp::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgAssignOp::next_node);
  133687             : #endif
  133688             : 
  133689             : #if USE_CPP_NEW_DELETE_OPERATORS
  133690             :     void *mem = ROSE_MALLOC(Size);
  133691             :     ALLOC_MUTEX(SgAssignOp, unlock);
  133692             :     return mem;
  133693             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  133694             : #if ROSE_PEDANTIC_ALLOC
  133695             :     ROSE_ASSERT(Size == sizeof(SgAssignOp));
  133696             : #else
  133697        6298 :     if (Size != sizeof(SgAssignOp)) {
  133698           0 :       void * object = ROSE_MALLOC(Size);
  133699           0 :       ALLOC_MUTEX(SgAssignOp, unlock);
  133700             :       return object;
  133701             :     }
  133702             : #endif
  133703             : 
  133704        6298 :     if (SgAssignOp::next_node == nullptr) {
  133705         256 :         SgAssignOp * alloc = (SgAssignOp*) ROSE_MALLOC ( SgAssignOp::pool_size * sizeof(SgAssignOp) );
  133706         256 :         ROSE_ASSERT(alloc != nullptr);
  133707             : 
  133708             : #if ROSE_ALLOC_TRACE == 2
  133709             : //        printf("SgAssignOp::alloc\n  block[%zi] = [ %p , %p [\n", SgAssignOp::pools.size(), alloc, alloc + SgAssignOp::pool_size);
  133710             : #endif
  133711             : 
  133712             : #if ROSE_ALLOC_MEMSET == 1
  133713             : #elif ROSE_ALLOC_MEMSET == 2
  133714             :         memset(alloc, 0x00, SgAssignOp::pool_size * sizeof(SgAssignOp));
  133715             : #elif ROSE_ALLOC_MEMSET == 3
  133716             :         memset(alloc, 0xAA, SgAssignOp::pool_size * sizeof(SgAssignOp));
  133717             : #endif
  133718      512000 :         for (unsigned i=0; i < SgAssignOp::pool_size-1; i++) {
  133719      511744 :           alloc[i].p_freepointer = &(alloc[i+1]);
  133720             :         }
  133721         256 :         alloc[SgAssignOp::pool_size-1].p_freepointer = nullptr;
  133722             : 
  133723         256 :         SgAssignOp::pools.push_back ( (unsigned char *) alloc );
  133724         256 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgAssignOp::pool_size * sizeof(SgAssignOp), V_SgAssignOp ) );
  133725         256 :         SgAssignOp::next_node = alloc;
  133726             :     }
  133727        6298 :     ROSE_ASSERT(SgAssignOp::next_node != nullptr);
  133728             : 
  133729        6298 :     SgAssignOp * object = SgAssignOp::next_node;
  133730        6298 :     SgAssignOp::next_node = (SgAssignOp*)(object->p_freepointer);
  133731             : 
  133732             : #if ROSE_ALLOC_TRACE == 2
  133733             :     printf("SgAssignOp::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgAssignOp::next_node);
  133734             : #endif
  133735             : 
  133736        6298 :     SgNode * fp = object->p_freepointer;
  133737             : #if ROSE_ALLOC_MEMSET == 1
  133738             : #elif ROSE_ALLOC_MEMSET == 2
  133739             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgAssignOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  133740             : #elif ROSE_ALLOC_MEMSET == 3
  133741             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgAssignOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  133742             : #endif
  133743        6298 :     object->p_freepointer = fp;
  133744             : 
  133745             : #if ROSE_ALLOC_TRACE == 2
  133746             : //    printf("SgAssignOp::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgAssignOp::next_node);
  133747             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  133748             :     Rose::MemPool::snapshot(oss.str());
  133749             :     alloc_trace_cnt++;
  133750             : #endif
  133751             : 
  133752        6298 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  133753             : 
  133754        6298 :     ALLOC_MUTEX(SgAssignOp, unlock);
  133755             : 
  133756             :     return object;
  133757             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  133758             : }
  133759             : 
  133760             : 
  133761             : 
  133762             : /*! \brief Delete operator for SgAssignOp.
  133763             : 
  133764             :    This delete operator implements deallocation using memory pools to 
  133765             :    provide most efficent use of the heap within construction of large ASTs.
  133766             : 
  133767             : \internal The new and delete operators use the lower level C malloc/free
  133768             :    function calls for performance and to make sure that mixing of malloc/free
  133769             :    and new/delete by the used can be caught more readily.  This may change
  133770             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  133771             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  133772             :    deallocate memory allocated using ROSE_MALLOC.
  133773             : */
  133774         911 : void SgAssignOp::operator delete(void *Pointer, size_t Size)
  133775             : {
  133776             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  133777             :      * or throwing an exception. */
  133778         911 :     ALLOC_MUTEX(SgAssignOp, lock);
  133779             : 
  133780             : #if USE_CPP_NEW_DELETE_OPERATORS
  133781             :     ROSE_FREE(Pointer);
  133782             : #else
  133783             : #if ROSE_PEDANTIC_ALLOC
  133784             :     ROSE_ASSERT(Size == sizeof(SgAssignOp));
  133785             : #else
  133786         911 :     if (Size != sizeof(SgAssignOp)) {
  133787           0 :       ROSE_FREE(Pointer);
  133788           0 :       ALLOC_MUTEX(SgAssignOp, unlock);
  133789             :       return;
  133790             :     }
  133791             : #endif
  133792             : 
  133793         911 :     SgAssignOp * object = (SgAssignOp*) Pointer;
  133794         911 :     ROSE_ASSERT(object != nullptr);
  133795             : 
  133796             : #if ROSE_ALLOC_TRACE == 2
  133797             : //  printf("SgAssignOp::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgAssignOp::next_node);
  133798             :     printf("SgAssignOp::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgAssignOp::next_node);
  133799             : #endif
  133800             : 
  133801             : #if ROSE_PEDANTIC_ALLOC
  133802             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  133803             : #endif
  133804             : 
  133805             : #if ROSE_ALLOC_MEMSET == 1
  133806             : #elif ROSE_ALLOC_MEMSET == 2
  133807             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgAssignOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  133808             : #elif ROSE_ALLOC_MEMSET == 3
  133809             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgAssignOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  133810             : #endif
  133811             : 
  133812             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  133813             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  133814             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  133815             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  133816             : #else
  133817         911 :     object->p_freepointer = SgAssignOp::next_node;
  133818         911 :     SgAssignOp::next_node = object;
  133819             : #endif
  133820             : 
  133821             : #if ROSE_ALLOC_TRACE == 2
  133822             : //  printf("SgAssignOp::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgAssignOp::next_node);
  133823             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  133824             :     Rose::MemPool::snapshot(oss.str());
  133825             :     alloc_trace_cnt++;
  133826             : #endif
  133827             : 
  133828             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  133829             : 
  133830         911 :     ALLOC_MUTEX(SgAssignOp, unlock);
  133831             : }
  133832             : 
  133833             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  133834             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  133835             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  133836             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  133837             : // Also, note comment below from Robb (copied from the Common.code file).
  133838             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  133839             : //
  133840             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  133841             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  133842             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  133843             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  133844             : #if 0
  133845             : void SgAssignOp::operator delete(void* pointer) { SgAssignOp::operator delete (pointer, sizeof(SgAssignOp)); };
  133846             : #endif
  133847             : /* #line 133848 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  133848             : 
  133849             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  133850             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  133851             : // obviously imply C++.
  133852             : 
  133853             : // This implements the support within ROSE for memory pools.  Memory pools
  133854             : // support the most condensed usage of memory within the construction of
  133855             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  133856             : // by a new operator written for each class.
  133857             : 
  133858             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  133859             :     // User wants multi-thread support and POSIX threads are available.
  133860             : #   include <pthread.h>
  133861             :     static pthread_mutex_t SgExponentiationOp_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  133862             : #else
  133863             :      // Cause synchronization to be skipped.
  133864             : #    ifndef ALLOC_MUTEX
  133865             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  133866             : #    endif
  133867             : #    ifdef _REENTRANT
  133868             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  133869             : #       ifdef _MSC_VER
  133870             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  133871             : #       else
  133872             : #           warning "POSIX threads are not available; synchronization being skipped"
  133873             : #       endif
  133874             : #    endif
  133875             : #endif
  133876             : 
  133877             : #ifndef ROSE_ALLOC_TRACE
  133878             : #  define ROSE_ALLOC_TRACE 0
  133879             : #endif
  133880             : 
  133881             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  133882             : #define ROSE_ALLOC_TRACE_CNT
  133883             : #include "memory-pool-snapshot.h"
  133884             : unsigned long alloc_trace_cnt = 0;
  133885             : #endif
  133886             : 
  133887             : #if ROSE_ALLOC_TRACE
  133888             : const unsigned SgExponentiationOp::pool_size = 5;
  133889             : #else
  133890             : const unsigned SgExponentiationOp::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  133891             : #endif
  133892             : 
  133893             : #ifndef ROSE_ALLOC_MEMSET
  133894             : #  define ROSE_ALLOC_MEMSET 0
  133895             : #endif
  133896             : 
  133897             : #ifndef ROSE_PEDANTIC_ALLOC
  133898             : #  define ROSE_PEDANTIC_ALLOC 0
  133899             : #endif
  133900             : 
  133901             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  133902             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  133903             : #endif
  133904             : 
  133905             : #if !defined(SGNODE__ALL_POOLS)
  133906             : #define SGNODE__ALL_POOLS
  133907             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  133908             : #endif
  133909             : 
  133910             : SgExponentiationOp* SgExponentiationOp::next_node = nullptr;
  133911             : std::vector<unsigned char*> SgExponentiationOp::pools;
  133912             : 
  133913             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  133914             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  133915             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  133916             : // around this macro definition rather than each use).
  133917             : #ifndef ALLOC_MUTEX
  133918             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  133919             :         do {                                                                     \
  133920             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  133921             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  133922             :                 abort();                                                         \
  133923             :             }                                                                    \
  133924             :         } while (0);
  133925             : #endif
  133926             : 
  133927             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  133928             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  133929             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  133930             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  133931             : 
  133932             : /*! \brief New operator for SgExponentiationOp.
  133933             : 
  133934             :    This new operator implements memory pools to provide most efficent 
  133935             :    use of the heap within construction of large ASTs.
  133936             : 
  133937             : \internal The new and delete operators use the lower level C malloc/free
  133938             :    function calls for performance and to make sure that mixing of malloc/free
  133939             :    and new/delete by the used can be caught more readily.  This may change
  133940             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  133941             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  133942             :    deallocate memory allocated using ROSE_MALLOC.
  133943             : */
  133944           0 : void *SgExponentiationOp::operator new ( size_t Size )
  133945             : {
  133946             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  133947             :      * returning or throwing an exception. */
  133948           0 :     ALLOC_MUTEX(SgExponentiationOp, lock);
  133949             : 
  133950             : #if ROSE_ALLOC_TRACE == 2
  133951             : //    printf("SgExponentiationOp::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgExponentiationOp::next_node);
  133952             : #endif
  133953             : 
  133954             : #if USE_CPP_NEW_DELETE_OPERATORS
  133955             :     void *mem = ROSE_MALLOC(Size);
  133956             :     ALLOC_MUTEX(SgExponentiationOp, unlock);
  133957             :     return mem;
  133958             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  133959             : #if ROSE_PEDANTIC_ALLOC
  133960             :     ROSE_ASSERT(Size == sizeof(SgExponentiationOp));
  133961             : #else
  133962           0 :     if (Size != sizeof(SgExponentiationOp)) {
  133963           0 :       void * object = ROSE_MALLOC(Size);
  133964           0 :       ALLOC_MUTEX(SgExponentiationOp, unlock);
  133965             :       return object;
  133966             :     }
  133967             : #endif
  133968             : 
  133969           0 :     if (SgExponentiationOp::next_node == nullptr) {
  133970           0 :         SgExponentiationOp * alloc = (SgExponentiationOp*) ROSE_MALLOC ( SgExponentiationOp::pool_size * sizeof(SgExponentiationOp) );
  133971           0 :         ROSE_ASSERT(alloc != nullptr);
  133972             : 
  133973             : #if ROSE_ALLOC_TRACE == 2
  133974             : //        printf("SgExponentiationOp::alloc\n  block[%zi] = [ %p , %p [\n", SgExponentiationOp::pools.size(), alloc, alloc + SgExponentiationOp::pool_size);
  133975             : #endif
  133976             : 
  133977             : #if ROSE_ALLOC_MEMSET == 1
  133978             : #elif ROSE_ALLOC_MEMSET == 2
  133979             :         memset(alloc, 0x00, SgExponentiationOp::pool_size * sizeof(SgExponentiationOp));
  133980             : #elif ROSE_ALLOC_MEMSET == 3
  133981             :         memset(alloc, 0xAA, SgExponentiationOp::pool_size * sizeof(SgExponentiationOp));
  133982             : #endif
  133983           0 :         for (unsigned i=0; i < SgExponentiationOp::pool_size-1; i++) {
  133984           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
  133985             :         }
  133986           0 :         alloc[SgExponentiationOp::pool_size-1].p_freepointer = nullptr;
  133987             : 
  133988           0 :         SgExponentiationOp::pools.push_back ( (unsigned char *) alloc );
  133989           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgExponentiationOp::pool_size * sizeof(SgExponentiationOp), V_SgExponentiationOp ) );
  133990           0 :         SgExponentiationOp::next_node = alloc;
  133991             :     }
  133992           0 :     ROSE_ASSERT(SgExponentiationOp::next_node != nullptr);
  133993             : 
  133994           0 :     SgExponentiationOp * object = SgExponentiationOp::next_node;
  133995           0 :     SgExponentiationOp::next_node = (SgExponentiationOp*)(object->p_freepointer);
  133996             : 
  133997             : #if ROSE_ALLOC_TRACE == 2
  133998             :     printf("SgExponentiationOp::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgExponentiationOp::next_node);
  133999             : #endif
  134000             : 
  134001           0 :     SgNode * fp = object->p_freepointer;
  134002             : #if ROSE_ALLOC_MEMSET == 1
  134003             : #elif ROSE_ALLOC_MEMSET == 2
  134004             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgExponentiationOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  134005             : #elif ROSE_ALLOC_MEMSET == 3
  134006             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgExponentiationOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  134007             : #endif
  134008           0 :     object->p_freepointer = fp;
  134009             : 
  134010             : #if ROSE_ALLOC_TRACE == 2
  134011             : //    printf("SgExponentiationOp::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgExponentiationOp::next_node);
  134012             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  134013             :     Rose::MemPool::snapshot(oss.str());
  134014             :     alloc_trace_cnt++;
  134015             : #endif
  134016             : 
  134017           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  134018             : 
  134019           0 :     ALLOC_MUTEX(SgExponentiationOp, unlock);
  134020             : 
  134021             :     return object;
  134022             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  134023             : }
  134024             : 
  134025             : 
  134026             : 
  134027             : /*! \brief Delete operator for SgExponentiationOp.
  134028             : 
  134029             :    This delete operator implements deallocation using memory pools to 
  134030             :    provide most efficent use of the heap within construction of large ASTs.
  134031             : 
  134032             : \internal The new and delete operators use the lower level C malloc/free
  134033             :    function calls for performance and to make sure that mixing of malloc/free
  134034             :    and new/delete by the used can be caught more readily.  This may change
  134035             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  134036             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  134037             :    deallocate memory allocated using ROSE_MALLOC.
  134038             : */
  134039           0 : void SgExponentiationOp::operator delete(void *Pointer, size_t Size)
  134040             : {
  134041             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  134042             :      * or throwing an exception. */
  134043           0 :     ALLOC_MUTEX(SgExponentiationOp, lock);
  134044             : 
  134045             : #if USE_CPP_NEW_DELETE_OPERATORS
  134046             :     ROSE_FREE(Pointer);
  134047             : #else
  134048             : #if ROSE_PEDANTIC_ALLOC
  134049             :     ROSE_ASSERT(Size == sizeof(SgExponentiationOp));
  134050             : #else
  134051           0 :     if (Size != sizeof(SgExponentiationOp)) {
  134052           0 :       ROSE_FREE(Pointer);
  134053           0 :       ALLOC_MUTEX(SgExponentiationOp, unlock);
  134054             :       return;
  134055             :     }
  134056             : #endif
  134057             : 
  134058           0 :     SgExponentiationOp * object = (SgExponentiationOp*) Pointer;
  134059           0 :     ROSE_ASSERT(object != nullptr);
  134060             : 
  134061             : #if ROSE_ALLOC_TRACE == 2
  134062             : //  printf("SgExponentiationOp::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgExponentiationOp::next_node);
  134063             :     printf("SgExponentiationOp::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgExponentiationOp::next_node);
  134064             : #endif
  134065             : 
  134066             : #if ROSE_PEDANTIC_ALLOC
  134067             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  134068             : #endif
  134069             : 
  134070             : #if ROSE_ALLOC_MEMSET == 1
  134071             : #elif ROSE_ALLOC_MEMSET == 2
  134072             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgExponentiationOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  134073             : #elif ROSE_ALLOC_MEMSET == 3
  134074             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgExponentiationOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  134075             : #endif
  134076             : 
  134077             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  134078             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  134079             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  134080             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  134081             : #else
  134082           0 :     object->p_freepointer = SgExponentiationOp::next_node;
  134083           0 :     SgExponentiationOp::next_node = object;
  134084             : #endif
  134085             : 
  134086             : #if ROSE_ALLOC_TRACE == 2
  134087             : //  printf("SgExponentiationOp::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgExponentiationOp::next_node);
  134088             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  134089             :     Rose::MemPool::snapshot(oss.str());
  134090             :     alloc_trace_cnt++;
  134091             : #endif
  134092             : 
  134093             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  134094             : 
  134095           0 :     ALLOC_MUTEX(SgExponentiationOp, unlock);
  134096             : }
  134097             : 
  134098             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  134099             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  134100             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  134101             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  134102             : // Also, note comment below from Robb (copied from the Common.code file).
  134103             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  134104             : //
  134105             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  134106             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  134107             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  134108             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  134109             : #if 0
  134110             : void SgExponentiationOp::operator delete(void* pointer) { SgExponentiationOp::operator delete (pointer, sizeof(SgExponentiationOp)); };
  134111             : #endif
  134112             : /* #line 134113 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  134113             : 
  134114             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  134115             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  134116             : // obviously imply C++.
  134117             : 
  134118             : // This implements the support within ROSE for memory pools.  Memory pools
  134119             : // support the most condensed usage of memory within the construction of
  134120             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  134121             : // by a new operator written for each class.
  134122             : 
  134123             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  134124             :     // User wants multi-thread support and POSIX threads are available.
  134125             : #   include <pthread.h>
  134126             :     static pthread_mutex_t SgConcatenationOp_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  134127             : #else
  134128             :      // Cause synchronization to be skipped.
  134129             : #    ifndef ALLOC_MUTEX
  134130             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  134131             : #    endif
  134132             : #    ifdef _REENTRANT
  134133             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  134134             : #       ifdef _MSC_VER
  134135             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  134136             : #       else
  134137             : #           warning "POSIX threads are not available; synchronization being skipped"
  134138             : #       endif
  134139             : #    endif
  134140             : #endif
  134141             : 
  134142             : #ifndef ROSE_ALLOC_TRACE
  134143             : #  define ROSE_ALLOC_TRACE 0
  134144             : #endif
  134145             : 
  134146             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  134147             : #define ROSE_ALLOC_TRACE_CNT
  134148             : #include "memory-pool-snapshot.h"
  134149             : unsigned long alloc_trace_cnt = 0;
  134150             : #endif
  134151             : 
  134152             : #if ROSE_ALLOC_TRACE
  134153             : const unsigned SgConcatenationOp::pool_size = 5;
  134154             : #else
  134155             : const unsigned SgConcatenationOp::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  134156             : #endif
  134157             : 
  134158             : #ifndef ROSE_ALLOC_MEMSET
  134159             : #  define ROSE_ALLOC_MEMSET 0
  134160             : #endif
  134161             : 
  134162             : #ifndef ROSE_PEDANTIC_ALLOC
  134163             : #  define ROSE_PEDANTIC_ALLOC 0
  134164             : #endif
  134165             : 
  134166             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  134167             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  134168             : #endif
  134169             : 
  134170             : #if !defined(SGNODE__ALL_POOLS)
  134171             : #define SGNODE__ALL_POOLS
  134172             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  134173             : #endif
  134174             : 
  134175             : SgConcatenationOp* SgConcatenationOp::next_node = nullptr;
  134176             : std::vector<unsigned char*> SgConcatenationOp::pools;
  134177             : 
  134178             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  134179             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  134180             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  134181             : // around this macro definition rather than each use).
  134182             : #ifndef ALLOC_MUTEX
  134183             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  134184             :         do {                                                                     \
  134185             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  134186             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  134187             :                 abort();                                                         \
  134188             :             }                                                                    \
  134189             :         } while (0);
  134190             : #endif
  134191             : 
  134192             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  134193             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  134194             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  134195             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  134196             : 
  134197             : /*! \brief New operator for SgConcatenationOp.
  134198             : 
  134199             :    This new operator implements memory pools to provide most efficent 
  134200             :    use of the heap within construction of large ASTs.
  134201             : 
  134202             : \internal The new and delete operators use the lower level C malloc/free
  134203             :    function calls for performance and to make sure that mixing of malloc/free
  134204             :    and new/delete by the used can be caught more readily.  This may change
  134205             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  134206             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  134207             :    deallocate memory allocated using ROSE_MALLOC.
  134208             : */
  134209           0 : void *SgConcatenationOp::operator new ( size_t Size )
  134210             : {
  134211             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  134212             :      * returning or throwing an exception. */
  134213           0 :     ALLOC_MUTEX(SgConcatenationOp, lock);
  134214             : 
  134215             : #if ROSE_ALLOC_TRACE == 2
  134216             : //    printf("SgConcatenationOp::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgConcatenationOp::next_node);
  134217             : #endif
  134218             : 
  134219             : #if USE_CPP_NEW_DELETE_OPERATORS
  134220             :     void *mem = ROSE_MALLOC(Size);
  134221             :     ALLOC_MUTEX(SgConcatenationOp, unlock);
  134222             :     return mem;
  134223             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  134224             : #if ROSE_PEDANTIC_ALLOC
  134225             :     ROSE_ASSERT(Size == sizeof(SgConcatenationOp));
  134226             : #else
  134227           0 :     if (Size != sizeof(SgConcatenationOp)) {
  134228           0 :       void * object = ROSE_MALLOC(Size);
  134229           0 :       ALLOC_MUTEX(SgConcatenationOp, unlock);
  134230             :       return object;
  134231             :     }
  134232             : #endif
  134233             : 
  134234           0 :     if (SgConcatenationOp::next_node == nullptr) {
  134235           0 :         SgConcatenationOp * alloc = (SgConcatenationOp*) ROSE_MALLOC ( SgConcatenationOp::pool_size * sizeof(SgConcatenationOp) );
  134236           0 :         ROSE_ASSERT(alloc != nullptr);
  134237             : 
  134238             : #if ROSE_ALLOC_TRACE == 2
  134239             : //        printf("SgConcatenationOp::alloc\n  block[%zi] = [ %p , %p [\n", SgConcatenationOp::pools.size(), alloc, alloc + SgConcatenationOp::pool_size);
  134240             : #endif
  134241             : 
  134242             : #if ROSE_ALLOC_MEMSET == 1
  134243             : #elif ROSE_ALLOC_MEMSET == 2
  134244             :         memset(alloc, 0x00, SgConcatenationOp::pool_size * sizeof(SgConcatenationOp));
  134245             : #elif ROSE_ALLOC_MEMSET == 3
  134246             :         memset(alloc, 0xAA, SgConcatenationOp::pool_size * sizeof(SgConcatenationOp));
  134247             : #endif
  134248           0 :         for (unsigned i=0; i < SgConcatenationOp::pool_size-1; i++) {
  134249           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
  134250             :         }
  134251           0 :         alloc[SgConcatenationOp::pool_size-1].p_freepointer = nullptr;
  134252             : 
  134253           0 :         SgConcatenationOp::pools.push_back ( (unsigned char *) alloc );
  134254           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgConcatenationOp::pool_size * sizeof(SgConcatenationOp), V_SgConcatenationOp ) );
  134255           0 :         SgConcatenationOp::next_node = alloc;
  134256             :     }
  134257           0 :     ROSE_ASSERT(SgConcatenationOp::next_node != nullptr);
  134258             : 
  134259           0 :     SgConcatenationOp * object = SgConcatenationOp::next_node;
  134260           0 :     SgConcatenationOp::next_node = (SgConcatenationOp*)(object->p_freepointer);
  134261             : 
  134262             : #if ROSE_ALLOC_TRACE == 2
  134263             :     printf("SgConcatenationOp::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgConcatenationOp::next_node);
  134264             : #endif
  134265             : 
  134266           0 :     SgNode * fp = object->p_freepointer;
  134267             : #if ROSE_ALLOC_MEMSET == 1
  134268             : #elif ROSE_ALLOC_MEMSET == 2
  134269             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgConcatenationOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  134270             : #elif ROSE_ALLOC_MEMSET == 3
  134271             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgConcatenationOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  134272             : #endif
  134273           0 :     object->p_freepointer = fp;
  134274             : 
  134275             : #if ROSE_ALLOC_TRACE == 2
  134276             : //    printf("SgConcatenationOp::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgConcatenationOp::next_node);
  134277             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  134278             :     Rose::MemPool::snapshot(oss.str());
  134279             :     alloc_trace_cnt++;
  134280             : #endif
  134281             : 
  134282           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  134283             : 
  134284           0 :     ALLOC_MUTEX(SgConcatenationOp, unlock);
  134285             : 
  134286             :     return object;
  134287             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  134288             : }
  134289             : 
  134290             : 
  134291             : 
  134292             : /*! \brief Delete operator for SgConcatenationOp.
  134293             : 
  134294             :    This delete operator implements deallocation using memory pools to 
  134295             :    provide most efficent use of the heap within construction of large ASTs.
  134296             : 
  134297             : \internal The new and delete operators use the lower level C malloc/free
  134298             :    function calls for performance and to make sure that mixing of malloc/free
  134299             :    and new/delete by the used can be caught more readily.  This may change
  134300             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  134301             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  134302             :    deallocate memory allocated using ROSE_MALLOC.
  134303             : */
  134304           0 : void SgConcatenationOp::operator delete(void *Pointer, size_t Size)
  134305             : {
  134306             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  134307             :      * or throwing an exception. */
  134308           0 :     ALLOC_MUTEX(SgConcatenationOp, lock);
  134309             : 
  134310             : #if USE_CPP_NEW_DELETE_OPERATORS
  134311             :     ROSE_FREE(Pointer);
  134312             : #else
  134313             : #if ROSE_PEDANTIC_ALLOC
  134314             :     ROSE_ASSERT(Size == sizeof(SgConcatenationOp));
  134315             : #else
  134316           0 :     if (Size != sizeof(SgConcatenationOp)) {
  134317           0 :       ROSE_FREE(Pointer);
  134318           0 :       ALLOC_MUTEX(SgConcatenationOp, unlock);
  134319             :       return;
  134320             :     }
  134321             : #endif
  134322             : 
  134323           0 :     SgConcatenationOp * object = (SgConcatenationOp*) Pointer;
  134324           0 :     ROSE_ASSERT(object != nullptr);
  134325             : 
  134326             : #if ROSE_ALLOC_TRACE == 2
  134327             : //  printf("SgConcatenationOp::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgConcatenationOp::next_node);
  134328             :     printf("SgConcatenationOp::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgConcatenationOp::next_node);
  134329             : #endif
  134330             : 
  134331             : #if ROSE_PEDANTIC_ALLOC
  134332             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  134333             : #endif
  134334             : 
  134335             : #if ROSE_ALLOC_MEMSET == 1
  134336             : #elif ROSE_ALLOC_MEMSET == 2
  134337             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgConcatenationOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  134338             : #elif ROSE_ALLOC_MEMSET == 3
  134339             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgConcatenationOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  134340             : #endif
  134341             : 
  134342             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  134343             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  134344             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  134345             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  134346             : #else
  134347           0 :     object->p_freepointer = SgConcatenationOp::next_node;
  134348           0 :     SgConcatenationOp::next_node = object;
  134349             : #endif
  134350             : 
  134351             : #if ROSE_ALLOC_TRACE == 2
  134352             : //  printf("SgConcatenationOp::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgConcatenationOp::next_node);
  134353             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  134354             :     Rose::MemPool::snapshot(oss.str());
  134355             :     alloc_trace_cnt++;
  134356             : #endif
  134357             : 
  134358             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  134359             : 
  134360           0 :     ALLOC_MUTEX(SgConcatenationOp, unlock);
  134361             : }
  134362             : 
  134363             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  134364             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  134365             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  134366             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  134367             : // Also, note comment below from Robb (copied from the Common.code file).
  134368             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  134369             : //
  134370             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  134371             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  134372             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  134373             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  134374             : #if 0
  134375             : void SgConcatenationOp::operator delete(void* pointer) { SgConcatenationOp::operator delete (pointer, sizeof(SgConcatenationOp)); };
  134376             : #endif
  134377             : /* #line 134378 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  134378             : 
  134379             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  134380             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  134381             : // obviously imply C++.
  134382             : 
  134383             : // This implements the support within ROSE for memory pools.  Memory pools
  134384             : // support the most condensed usage of memory within the construction of
  134385             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  134386             : // by a new operator written for each class.
  134387             : 
  134388             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  134389             :     // User wants multi-thread support and POSIX threads are available.
  134390             : #   include <pthread.h>
  134391             :     static pthread_mutex_t SgPointerAssignOp_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  134392             : #else
  134393             :      // Cause synchronization to be skipped.
  134394             : #    ifndef ALLOC_MUTEX
  134395             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  134396             : #    endif
  134397             : #    ifdef _REENTRANT
  134398             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  134399             : #       ifdef _MSC_VER
  134400             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  134401             : #       else
  134402             : #           warning "POSIX threads are not available; synchronization being skipped"
  134403             : #       endif
  134404             : #    endif
  134405             : #endif
  134406             : 
  134407             : #ifndef ROSE_ALLOC_TRACE
  134408             : #  define ROSE_ALLOC_TRACE 0
  134409             : #endif
  134410             : 
  134411             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  134412             : #define ROSE_ALLOC_TRACE_CNT
  134413             : #include "memory-pool-snapshot.h"
  134414             : unsigned long alloc_trace_cnt = 0;
  134415             : #endif
  134416             : 
  134417             : #if ROSE_ALLOC_TRACE
  134418             : const unsigned SgPointerAssignOp::pool_size = 5;
  134419             : #else
  134420             : const unsigned SgPointerAssignOp::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  134421             : #endif
  134422             : 
  134423             : #ifndef ROSE_ALLOC_MEMSET
  134424             : #  define ROSE_ALLOC_MEMSET 0
  134425             : #endif
  134426             : 
  134427             : #ifndef ROSE_PEDANTIC_ALLOC
  134428             : #  define ROSE_PEDANTIC_ALLOC 0
  134429             : #endif
  134430             : 
  134431             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  134432             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  134433             : #endif
  134434             : 
  134435             : #if !defined(SGNODE__ALL_POOLS)
  134436             : #define SGNODE__ALL_POOLS
  134437             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  134438             : #endif
  134439             : 
  134440             : SgPointerAssignOp* SgPointerAssignOp::next_node = nullptr;
  134441             : std::vector<unsigned char*> SgPointerAssignOp::pools;
  134442             : 
  134443             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  134444             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  134445             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  134446             : // around this macro definition rather than each use).
  134447             : #ifndef ALLOC_MUTEX
  134448             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  134449             :         do {                                                                     \
  134450             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  134451             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  134452             :                 abort();                                                         \
  134453             :             }                                                                    \
  134454             :         } while (0);
  134455             : #endif
  134456             : 
  134457             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  134458             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  134459             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  134460             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  134461             : 
  134462             : /*! \brief New operator for SgPointerAssignOp.
  134463             : 
  134464             :    This new operator implements memory pools to provide most efficent 
  134465             :    use of the heap within construction of large ASTs.
  134466             : 
  134467             : \internal The new and delete operators use the lower level C malloc/free
  134468             :    function calls for performance and to make sure that mixing of malloc/free
  134469             :    and new/delete by the used can be caught more readily.  This may change
  134470             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  134471             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  134472             :    deallocate memory allocated using ROSE_MALLOC.
  134473             : */
  134474           1 : void *SgPointerAssignOp::operator new ( size_t Size )
  134475             : {
  134476             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  134477             :      * returning or throwing an exception. */
  134478           1 :     ALLOC_MUTEX(SgPointerAssignOp, lock);
  134479             : 
  134480             : #if ROSE_ALLOC_TRACE == 2
  134481             : //    printf("SgPointerAssignOp::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgPointerAssignOp::next_node);
  134482             : #endif
  134483             : 
  134484             : #if USE_CPP_NEW_DELETE_OPERATORS
  134485             :     void *mem = ROSE_MALLOC(Size);
  134486             :     ALLOC_MUTEX(SgPointerAssignOp, unlock);
  134487             :     return mem;
  134488             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  134489             : #if ROSE_PEDANTIC_ALLOC
  134490             :     ROSE_ASSERT(Size == sizeof(SgPointerAssignOp));
  134491             : #else
  134492           1 :     if (Size != sizeof(SgPointerAssignOp)) {
  134493           0 :       void * object = ROSE_MALLOC(Size);
  134494           0 :       ALLOC_MUTEX(SgPointerAssignOp, unlock);
  134495             :       return object;
  134496             :     }
  134497             : #endif
  134498             : 
  134499           1 :     if (SgPointerAssignOp::next_node == nullptr) {
  134500           1 :         SgPointerAssignOp * alloc = (SgPointerAssignOp*) ROSE_MALLOC ( SgPointerAssignOp::pool_size * sizeof(SgPointerAssignOp) );
  134501           1 :         ROSE_ASSERT(alloc != nullptr);
  134502             : 
  134503             : #if ROSE_ALLOC_TRACE == 2
  134504             : //        printf("SgPointerAssignOp::alloc\n  block[%zi] = [ %p , %p [\n", SgPointerAssignOp::pools.size(), alloc, alloc + SgPointerAssignOp::pool_size);
  134505             : #endif
  134506             : 
  134507             : #if ROSE_ALLOC_MEMSET == 1
  134508             : #elif ROSE_ALLOC_MEMSET == 2
  134509             :         memset(alloc, 0x00, SgPointerAssignOp::pool_size * sizeof(SgPointerAssignOp));
  134510             : #elif ROSE_ALLOC_MEMSET == 3
  134511             :         memset(alloc, 0xAA, SgPointerAssignOp::pool_size * sizeof(SgPointerAssignOp));
  134512             : #endif
  134513        2000 :         for (unsigned i=0; i < SgPointerAssignOp::pool_size-1; i++) {
  134514        1999 :           alloc[i].p_freepointer = &(alloc[i+1]);
  134515             :         }
  134516           1 :         alloc[SgPointerAssignOp::pool_size-1].p_freepointer = nullptr;
  134517             : 
  134518           1 :         SgPointerAssignOp::pools.push_back ( (unsigned char *) alloc );
  134519           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgPointerAssignOp::pool_size * sizeof(SgPointerAssignOp), V_SgPointerAssignOp ) );
  134520           1 :         SgPointerAssignOp::next_node = alloc;
  134521             :     }
  134522           1 :     ROSE_ASSERT(SgPointerAssignOp::next_node != nullptr);
  134523             : 
  134524           1 :     SgPointerAssignOp * object = SgPointerAssignOp::next_node;
  134525           1 :     SgPointerAssignOp::next_node = (SgPointerAssignOp*)(object->p_freepointer);
  134526             : 
  134527             : #if ROSE_ALLOC_TRACE == 2
  134528             :     printf("SgPointerAssignOp::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgPointerAssignOp::next_node);
  134529             : #endif
  134530             : 
  134531           1 :     SgNode * fp = object->p_freepointer;
  134532             : #if ROSE_ALLOC_MEMSET == 1
  134533             : #elif ROSE_ALLOC_MEMSET == 2
  134534             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgPointerAssignOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  134535             : #elif ROSE_ALLOC_MEMSET == 3
  134536             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgPointerAssignOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  134537             : #endif
  134538           1 :     object->p_freepointer = fp;
  134539             : 
  134540             : #if ROSE_ALLOC_TRACE == 2
  134541             : //    printf("SgPointerAssignOp::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgPointerAssignOp::next_node);
  134542             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  134543             :     Rose::MemPool::snapshot(oss.str());
  134544             :     alloc_trace_cnt++;
  134545             : #endif
  134546             : 
  134547           1 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  134548             : 
  134549           1 :     ALLOC_MUTEX(SgPointerAssignOp, unlock);
  134550             : 
  134551             :     return object;
  134552             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  134553             : }
  134554             : 
  134555             : 
  134556             : 
  134557             : /*! \brief Delete operator for SgPointerAssignOp.
  134558             : 
  134559             :    This delete operator implements deallocation using memory pools to 
  134560             :    provide most efficent use of the heap within construction of large ASTs.
  134561             : 
  134562             : \internal The new and delete operators use the lower level C malloc/free
  134563             :    function calls for performance and to make sure that mixing of malloc/free
  134564             :    and new/delete by the used can be caught more readily.  This may change
  134565             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  134566             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  134567             :    deallocate memory allocated using ROSE_MALLOC.
  134568             : */
  134569           0 : void SgPointerAssignOp::operator delete(void *Pointer, size_t Size)
  134570             : {
  134571             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  134572             :      * or throwing an exception. */
  134573           0 :     ALLOC_MUTEX(SgPointerAssignOp, lock);
  134574             : 
  134575             : #if USE_CPP_NEW_DELETE_OPERATORS
  134576             :     ROSE_FREE(Pointer);
  134577             : #else
  134578             : #if ROSE_PEDANTIC_ALLOC
  134579             :     ROSE_ASSERT(Size == sizeof(SgPointerAssignOp));
  134580             : #else
  134581           0 :     if (Size != sizeof(SgPointerAssignOp)) {
  134582           0 :       ROSE_FREE(Pointer);
  134583           0 :       ALLOC_MUTEX(SgPointerAssignOp, unlock);
  134584             :       return;
  134585             :     }
  134586             : #endif
  134587             : 
  134588           0 :     SgPointerAssignOp * object = (SgPointerAssignOp*) Pointer;
  134589           0 :     ROSE_ASSERT(object != nullptr);
  134590             : 
  134591             : #if ROSE_ALLOC_TRACE == 2
  134592             : //  printf("SgPointerAssignOp::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgPointerAssignOp::next_node);
  134593             :     printf("SgPointerAssignOp::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgPointerAssignOp::next_node);
  134594             : #endif
  134595             : 
  134596             : #if ROSE_PEDANTIC_ALLOC
  134597             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  134598             : #endif
  134599             : 
  134600             : #if ROSE_ALLOC_MEMSET == 1
  134601             : #elif ROSE_ALLOC_MEMSET == 2
  134602             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgPointerAssignOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  134603             : #elif ROSE_ALLOC_MEMSET == 3
  134604             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgPointerAssignOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  134605             : #endif
  134606             : 
  134607             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  134608             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  134609             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  134610             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  134611             : #else
  134612           0 :     object->p_freepointer = SgPointerAssignOp::next_node;
  134613           0 :     SgPointerAssignOp::next_node = object;
  134614             : #endif
  134615             : 
  134616             : #if ROSE_ALLOC_TRACE == 2
  134617             : //  printf("SgPointerAssignOp::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgPointerAssignOp::next_node);
  134618             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  134619             :     Rose::MemPool::snapshot(oss.str());
  134620             :     alloc_trace_cnt++;
  134621             : #endif
  134622             : 
  134623             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  134624             : 
  134625           0 :     ALLOC_MUTEX(SgPointerAssignOp, unlock);
  134626             : }
  134627             : 
  134628             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  134629             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  134630             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  134631             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  134632             : // Also, note comment below from Robb (copied from the Common.code file).
  134633             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  134634             : //
  134635             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  134636             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  134637             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  134638             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  134639             : #if 0
  134640             : void SgPointerAssignOp::operator delete(void* pointer) { SgPointerAssignOp::operator delete (pointer, sizeof(SgPointerAssignOp)); };
  134641             : #endif
  134642             : /* #line 134643 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  134643             : 
  134644             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  134645             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  134646             : // obviously imply C++.
  134647             : 
  134648             : // This implements the support within ROSE for memory pools.  Memory pools
  134649             : // support the most condensed usage of memory within the construction of
  134650             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  134651             : // by a new operator written for each class.
  134652             : 
  134653             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  134654             :     // User wants multi-thread support and POSIX threads are available.
  134655             : #   include <pthread.h>
  134656             :     static pthread_mutex_t SgUserDefinedBinaryOp_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  134657             : #else
  134658             :      // Cause synchronization to be skipped.
  134659             : #    ifndef ALLOC_MUTEX
  134660             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  134661             : #    endif
  134662             : #    ifdef _REENTRANT
  134663             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  134664             : #       ifdef _MSC_VER
  134665             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  134666             : #       else
  134667             : #           warning "POSIX threads are not available; synchronization being skipped"
  134668             : #       endif
  134669             : #    endif
  134670             : #endif
  134671             : 
  134672             : #ifndef ROSE_ALLOC_TRACE
  134673             : #  define ROSE_ALLOC_TRACE 0
  134674             : #endif
  134675             : 
  134676             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  134677             : #define ROSE_ALLOC_TRACE_CNT
  134678             : #include "memory-pool-snapshot.h"
  134679             : unsigned long alloc_trace_cnt = 0;
  134680             : #endif
  134681             : 
  134682             : #if ROSE_ALLOC_TRACE
  134683             : const unsigned SgUserDefinedBinaryOp::pool_size = 5;
  134684             : #else
  134685             : const unsigned SgUserDefinedBinaryOp::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  134686             : #endif
  134687             : 
  134688             : #ifndef ROSE_ALLOC_MEMSET
  134689             : #  define ROSE_ALLOC_MEMSET 0
  134690             : #endif
  134691             : 
  134692             : #ifndef ROSE_PEDANTIC_ALLOC
  134693             : #  define ROSE_PEDANTIC_ALLOC 0
  134694             : #endif
  134695             : 
  134696             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  134697             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  134698             : #endif
  134699             : 
  134700             : #if !defined(SGNODE__ALL_POOLS)
  134701             : #define SGNODE__ALL_POOLS
  134702             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  134703             : #endif
  134704             : 
  134705             : SgUserDefinedBinaryOp* SgUserDefinedBinaryOp::next_node = nullptr;
  134706             : std::vector<unsigned char*> SgUserDefinedBinaryOp::pools;
  134707             : 
  134708             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  134709             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  134710             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  134711             : // around this macro definition rather than each use).
  134712             : #ifndef ALLOC_MUTEX
  134713             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  134714             :         do {                                                                     \
  134715             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  134716             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  134717             :                 abort();                                                         \
  134718             :             }                                                                    \
  134719             :         } while (0);
  134720             : #endif
  134721             : 
  134722             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  134723             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  134724             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  134725             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  134726             : 
  134727             : /*! \brief New operator for SgUserDefinedBinaryOp.
  134728             : 
  134729             :    This new operator implements memory pools to provide most efficent 
  134730             :    use of the heap within construction of large ASTs.
  134731             : 
  134732             : \internal The new and delete operators use the lower level C malloc/free
  134733             :    function calls for performance and to make sure that mixing of malloc/free
  134734             :    and new/delete by the used can be caught more readily.  This may change
  134735             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  134736             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  134737             :    deallocate memory allocated using ROSE_MALLOC.
  134738             : */
  134739           0 : void *SgUserDefinedBinaryOp::operator new ( size_t Size )
  134740             : {
  134741             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  134742             :      * returning or throwing an exception. */
  134743           0 :     ALLOC_MUTEX(SgUserDefinedBinaryOp, lock);
  134744             : 
  134745             : #if ROSE_ALLOC_TRACE == 2
  134746             : //    printf("SgUserDefinedBinaryOp::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgUserDefinedBinaryOp::next_node);
  134747             : #endif
  134748             : 
  134749             : #if USE_CPP_NEW_DELETE_OPERATORS
  134750             :     void *mem = ROSE_MALLOC(Size);
  134751             :     ALLOC_MUTEX(SgUserDefinedBinaryOp, unlock);
  134752             :     return mem;
  134753             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  134754             : #if ROSE_PEDANTIC_ALLOC
  134755             :     ROSE_ASSERT(Size == sizeof(SgUserDefinedBinaryOp));
  134756             : #else
  134757           0 :     if (Size != sizeof(SgUserDefinedBinaryOp)) {
  134758           0 :       void * object = ROSE_MALLOC(Size);
  134759           0 :       ALLOC_MUTEX(SgUserDefinedBinaryOp, unlock);
  134760             :       return object;
  134761             :     }
  134762             : #endif
  134763             : 
  134764           0 :     if (SgUserDefinedBinaryOp::next_node == nullptr) {
  134765           0 :         SgUserDefinedBinaryOp * alloc = (SgUserDefinedBinaryOp*) ROSE_MALLOC ( SgUserDefinedBinaryOp::pool_size * sizeof(SgUserDefinedBinaryOp) );
  134766           0 :         ROSE_ASSERT(alloc != nullptr);
  134767             : 
  134768             : #if ROSE_ALLOC_TRACE == 2
  134769             : //        printf("SgUserDefinedBinaryOp::alloc\n  block[%zi] = [ %p , %p [\n", SgUserDefinedBinaryOp::pools.size(), alloc, alloc + SgUserDefinedBinaryOp::pool_size);
  134770             : #endif
  134771             : 
  134772             : #if ROSE_ALLOC_MEMSET == 1
  134773             : #elif ROSE_ALLOC_MEMSET == 2
  134774             :         memset(alloc, 0x00, SgUserDefinedBinaryOp::pool_size * sizeof(SgUserDefinedBinaryOp));
  134775             : #elif ROSE_ALLOC_MEMSET == 3
  134776             :         memset(alloc, 0xAA, SgUserDefinedBinaryOp::pool_size * sizeof(SgUserDefinedBinaryOp));
  134777             : #endif
  134778           0 :         for (unsigned i=0; i < SgUserDefinedBinaryOp::pool_size-1; i++) {
  134779           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
  134780             :         }
  134781           0 :         alloc[SgUserDefinedBinaryOp::pool_size-1].p_freepointer = nullptr;
  134782             : 
  134783           0 :         SgUserDefinedBinaryOp::pools.push_back ( (unsigned char *) alloc );
  134784           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgUserDefinedBinaryOp::pool_size * sizeof(SgUserDefinedBinaryOp), V_SgUserDefinedBinaryOp ) );
  134785           0 :         SgUserDefinedBinaryOp::next_node = alloc;
  134786             :     }
  134787           0 :     ROSE_ASSERT(SgUserDefinedBinaryOp::next_node != nullptr);
  134788             : 
  134789           0 :     SgUserDefinedBinaryOp * object = SgUserDefinedBinaryOp::next_node;
  134790           0 :     SgUserDefinedBinaryOp::next_node = (SgUserDefinedBinaryOp*)(object->p_freepointer);
  134791             : 
  134792             : #if ROSE_ALLOC_TRACE == 2
  134793             :     printf("SgUserDefinedBinaryOp::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUserDefinedBinaryOp::next_node);
  134794             : #endif
  134795             : 
  134796           0 :     SgNode * fp = object->p_freepointer;
  134797             : #if ROSE_ALLOC_MEMSET == 1
  134798             : #elif ROSE_ALLOC_MEMSET == 2
  134799             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgUserDefinedBinaryOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  134800             : #elif ROSE_ALLOC_MEMSET == 3
  134801             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgUserDefinedBinaryOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  134802             : #endif
  134803           0 :     object->p_freepointer = fp;
  134804             : 
  134805             : #if ROSE_ALLOC_TRACE == 2
  134806             : //    printf("SgUserDefinedBinaryOp::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUserDefinedBinaryOp::next_node);
  134807             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  134808             :     Rose::MemPool::snapshot(oss.str());
  134809             :     alloc_trace_cnt++;
  134810             : #endif
  134811             : 
  134812           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  134813             : 
  134814           0 :     ALLOC_MUTEX(SgUserDefinedBinaryOp, unlock);
  134815             : 
  134816             :     return object;
  134817             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  134818             : }
  134819             : 
  134820             : 
  134821             : 
  134822             : /*! \brief Delete operator for SgUserDefinedBinaryOp.
  134823             : 
  134824             :    This delete operator implements deallocation using memory pools to 
  134825             :    provide most efficent use of the heap within construction of large ASTs.
  134826             : 
  134827             : \internal The new and delete operators use the lower level C malloc/free
  134828             :    function calls for performance and to make sure that mixing of malloc/free
  134829             :    and new/delete by the used can be caught more readily.  This may change
  134830             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  134831             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  134832             :    deallocate memory allocated using ROSE_MALLOC.
  134833             : */
  134834           0 : void SgUserDefinedBinaryOp::operator delete(void *Pointer, size_t Size)
  134835             : {
  134836             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  134837             :      * or throwing an exception. */
  134838           0 :     ALLOC_MUTEX(SgUserDefinedBinaryOp, lock);
  134839             : 
  134840             : #if USE_CPP_NEW_DELETE_OPERATORS
  134841             :     ROSE_FREE(Pointer);
  134842             : #else
  134843             : #if ROSE_PEDANTIC_ALLOC
  134844             :     ROSE_ASSERT(Size == sizeof(SgUserDefinedBinaryOp));
  134845             : #else
  134846           0 :     if (Size != sizeof(SgUserDefinedBinaryOp)) {
  134847           0 :       ROSE_FREE(Pointer);
  134848           0 :       ALLOC_MUTEX(SgUserDefinedBinaryOp, unlock);
  134849             :       return;
  134850             :     }
  134851             : #endif
  134852             : 
  134853           0 :     SgUserDefinedBinaryOp * object = (SgUserDefinedBinaryOp*) Pointer;
  134854           0 :     ROSE_ASSERT(object != nullptr);
  134855             : 
  134856             : #if ROSE_ALLOC_TRACE == 2
  134857             : //  printf("SgUserDefinedBinaryOp::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUserDefinedBinaryOp::next_node);
  134858             :     printf("SgUserDefinedBinaryOp::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUserDefinedBinaryOp::next_node);
  134859             : #endif
  134860             : 
  134861             : #if ROSE_PEDANTIC_ALLOC
  134862             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  134863             : #endif
  134864             : 
  134865             : #if ROSE_ALLOC_MEMSET == 1
  134866             : #elif ROSE_ALLOC_MEMSET == 2
  134867             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgUserDefinedBinaryOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  134868             : #elif ROSE_ALLOC_MEMSET == 3
  134869             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgUserDefinedBinaryOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  134870             : #endif
  134871             : 
  134872             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  134873             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  134874             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  134875             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  134876             : #else
  134877           0 :     object->p_freepointer = SgUserDefinedBinaryOp::next_node;
  134878           0 :     SgUserDefinedBinaryOp::next_node = object;
  134879             : #endif
  134880             : 
  134881             : #if ROSE_ALLOC_TRACE == 2
  134882             : //  printf("SgUserDefinedBinaryOp::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUserDefinedBinaryOp::next_node);
  134883             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  134884             :     Rose::MemPool::snapshot(oss.str());
  134885             :     alloc_trace_cnt++;
  134886             : #endif
  134887             : 
  134888             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  134889             : 
  134890           0 :     ALLOC_MUTEX(SgUserDefinedBinaryOp, unlock);
  134891             : }
  134892             : 
  134893             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  134894             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  134895             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  134896             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  134897             : // Also, note comment below from Robb (copied from the Common.code file).
  134898             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  134899             : //
  134900             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  134901             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  134902             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  134903             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  134904             : #if 0
  134905             : void SgUserDefinedBinaryOp::operator delete(void* pointer) { SgUserDefinedBinaryOp::operator delete (pointer, sizeof(SgUserDefinedBinaryOp)); };
  134906             : #endif
  134907             : /* #line 134908 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  134908             : 
  134909             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  134910             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  134911             : // obviously imply C++.
  134912             : 
  134913             : // This implements the support within ROSE for memory pools.  Memory pools
  134914             : // support the most condensed usage of memory within the construction of
  134915             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  134916             : // by a new operator written for each class.
  134917             : 
  134918             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  134919             :     // User wants multi-thread support and POSIX threads are available.
  134920             : #   include <pthread.h>
  134921             :     static pthread_mutex_t SgCompoundAssignOp_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  134922             : #else
  134923             :      // Cause synchronization to be skipped.
  134924             : #    ifndef ALLOC_MUTEX
  134925             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  134926             : #    endif
  134927             : #    ifdef _REENTRANT
  134928             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  134929             : #       ifdef _MSC_VER
  134930             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  134931             : #       else
  134932             : #           warning "POSIX threads are not available; synchronization being skipped"
  134933             : #       endif
  134934             : #    endif
  134935             : #endif
  134936             : 
  134937             : #ifndef ROSE_ALLOC_TRACE
  134938             : #  define ROSE_ALLOC_TRACE 0
  134939             : #endif
  134940             : 
  134941             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  134942             : #define ROSE_ALLOC_TRACE_CNT
  134943             : #include "memory-pool-snapshot.h"
  134944             : unsigned long alloc_trace_cnt = 0;
  134945             : #endif
  134946             : 
  134947             : #if ROSE_ALLOC_TRACE
  134948             : const unsigned SgCompoundAssignOp::pool_size = 5;
  134949             : #else
  134950             : const unsigned SgCompoundAssignOp::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  134951             : #endif
  134952             : 
  134953             : #ifndef ROSE_ALLOC_MEMSET
  134954             : #  define ROSE_ALLOC_MEMSET 0
  134955             : #endif
  134956             : 
  134957             : #ifndef ROSE_PEDANTIC_ALLOC
  134958             : #  define ROSE_PEDANTIC_ALLOC 0
  134959             : #endif
  134960             : 
  134961             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  134962             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  134963             : #endif
  134964             : 
  134965             : #if !defined(SGNODE__ALL_POOLS)
  134966             : #define SGNODE__ALL_POOLS
  134967             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  134968             : #endif
  134969             : 
  134970             : SgCompoundAssignOp* SgCompoundAssignOp::next_node = nullptr;
  134971             : std::vector<unsigned char*> SgCompoundAssignOp::pools;
  134972             : 
  134973             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  134974             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  134975             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  134976             : // around this macro definition rather than each use).
  134977             : #ifndef ALLOC_MUTEX
  134978             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  134979             :         do {                                                                     \
  134980             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  134981             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  134982             :                 abort();                                                         \
  134983             :             }                                                                    \
  134984             :         } while (0);
  134985             : #endif
  134986             : 
  134987             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  134988             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  134989             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  134990             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  134991             : 
  134992             : /*! \brief New operator for SgCompoundAssignOp.
  134993             : 
  134994             :    This new operator implements memory pools to provide most efficent 
  134995             :    use of the heap within construction of large ASTs.
  134996             : 
  134997             : \internal The new and delete operators use the lower level C malloc/free
  134998             :    function calls for performance and to make sure that mixing of malloc/free
  134999             :    and new/delete by the used can be caught more readily.  This may change
  135000             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  135001             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  135002             :    deallocate memory allocated using ROSE_MALLOC.
  135003             : */
  135004           0 : void *SgCompoundAssignOp::operator new ( size_t Size )
  135005             : {
  135006             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  135007             :      * returning or throwing an exception. */
  135008           0 :     ALLOC_MUTEX(SgCompoundAssignOp, lock);
  135009             : 
  135010             : #if ROSE_ALLOC_TRACE == 2
  135011             : //    printf("SgCompoundAssignOp::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgCompoundAssignOp::next_node);
  135012             : #endif
  135013             : 
  135014             : #if USE_CPP_NEW_DELETE_OPERATORS
  135015             :     void *mem = ROSE_MALLOC(Size);
  135016             :     ALLOC_MUTEX(SgCompoundAssignOp, unlock);
  135017             :     return mem;
  135018             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  135019             : #if ROSE_PEDANTIC_ALLOC
  135020             :     ROSE_ASSERT(Size == sizeof(SgCompoundAssignOp));
  135021             : #else
  135022           0 :     if (Size != sizeof(SgCompoundAssignOp)) {
  135023           0 :       void * object = ROSE_MALLOC(Size);
  135024           0 :       ALLOC_MUTEX(SgCompoundAssignOp, unlock);
  135025             :       return object;
  135026             :     }
  135027             : #endif
  135028             : 
  135029           0 :     if (SgCompoundAssignOp::next_node == nullptr) {
  135030           0 :         SgCompoundAssignOp * alloc = (SgCompoundAssignOp*) ROSE_MALLOC ( SgCompoundAssignOp::pool_size * sizeof(SgCompoundAssignOp) );
  135031           0 :         ROSE_ASSERT(alloc != nullptr);
  135032             : 
  135033             : #if ROSE_ALLOC_TRACE == 2
  135034             : //        printf("SgCompoundAssignOp::alloc\n  block[%zi] = [ %p , %p [\n", SgCompoundAssignOp::pools.size(), alloc, alloc + SgCompoundAssignOp::pool_size);
  135035             : #endif
  135036             : 
  135037             : #if ROSE_ALLOC_MEMSET == 1
  135038             : #elif ROSE_ALLOC_MEMSET == 2
  135039             :         memset(alloc, 0x00, SgCompoundAssignOp::pool_size * sizeof(SgCompoundAssignOp));
  135040             : #elif ROSE_ALLOC_MEMSET == 3
  135041             :         memset(alloc, 0xAA, SgCompoundAssignOp::pool_size * sizeof(SgCompoundAssignOp));
  135042             : #endif
  135043           0 :         for (unsigned i=0; i < SgCompoundAssignOp::pool_size-1; i++) {
  135044           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
  135045             :         }
  135046           0 :         alloc[SgCompoundAssignOp::pool_size-1].p_freepointer = nullptr;
  135047             : 
  135048           0 :         SgCompoundAssignOp::pools.push_back ( (unsigned char *) alloc );
  135049           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgCompoundAssignOp::pool_size * sizeof(SgCompoundAssignOp), V_SgCompoundAssignOp ) );
  135050           0 :         SgCompoundAssignOp::next_node = alloc;
  135051             :     }
  135052           0 :     ROSE_ASSERT(SgCompoundAssignOp::next_node != nullptr);
  135053             : 
  135054           0 :     SgCompoundAssignOp * object = SgCompoundAssignOp::next_node;
  135055           0 :     SgCompoundAssignOp::next_node = (SgCompoundAssignOp*)(object->p_freepointer);
  135056             : 
  135057             : #if ROSE_ALLOC_TRACE == 2
  135058             :     printf("SgCompoundAssignOp::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgCompoundAssignOp::next_node);
  135059             : #endif
  135060             : 
  135061           0 :     SgNode * fp = object->p_freepointer;
  135062             : #if ROSE_ALLOC_MEMSET == 1
  135063             : #elif ROSE_ALLOC_MEMSET == 2
  135064             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgCompoundAssignOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  135065             : #elif ROSE_ALLOC_MEMSET == 3
  135066             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgCompoundAssignOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  135067             : #endif
  135068           0 :     object->p_freepointer = fp;
  135069             : 
  135070             : #if ROSE_ALLOC_TRACE == 2
  135071             : //    printf("SgCompoundAssignOp::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgCompoundAssignOp::next_node);
  135072             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  135073             :     Rose::MemPool::snapshot(oss.str());
  135074             :     alloc_trace_cnt++;
  135075             : #endif
  135076             : 
  135077           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  135078             : 
  135079           0 :     ALLOC_MUTEX(SgCompoundAssignOp, unlock);
  135080             : 
  135081             :     return object;
  135082             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  135083             : }
  135084             : 
  135085             : 
  135086             : 
  135087             : /*! \brief Delete operator for SgCompoundAssignOp.
  135088             : 
  135089             :    This delete operator implements deallocation using memory pools to 
  135090             :    provide most efficent use of the heap within construction of large ASTs.
  135091             : 
  135092             : \internal The new and delete operators use the lower level C malloc/free
  135093             :    function calls for performance and to make sure that mixing of malloc/free
  135094             :    and new/delete by the used can be caught more readily.  This may change
  135095             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  135096             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  135097             :    deallocate memory allocated using ROSE_MALLOC.
  135098             : */
  135099           0 : void SgCompoundAssignOp::operator delete(void *Pointer, size_t Size)
  135100             : {
  135101             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  135102             :      * or throwing an exception. */
  135103           0 :     ALLOC_MUTEX(SgCompoundAssignOp, lock);
  135104             : 
  135105             : #if USE_CPP_NEW_DELETE_OPERATORS
  135106             :     ROSE_FREE(Pointer);
  135107             : #else
  135108             : #if ROSE_PEDANTIC_ALLOC
  135109             :     ROSE_ASSERT(Size == sizeof(SgCompoundAssignOp));
  135110             : #else
  135111           0 :     if (Size != sizeof(SgCompoundAssignOp)) {
  135112           0 :       ROSE_FREE(Pointer);
  135113           0 :       ALLOC_MUTEX(SgCompoundAssignOp, unlock);
  135114             :       return;
  135115             :     }
  135116             : #endif
  135117             : 
  135118           0 :     SgCompoundAssignOp * object = (SgCompoundAssignOp*) Pointer;
  135119           0 :     ROSE_ASSERT(object != nullptr);
  135120             : 
  135121             : #if ROSE_ALLOC_TRACE == 2
  135122             : //  printf("SgCompoundAssignOp::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgCompoundAssignOp::next_node);
  135123             :     printf("SgCompoundAssignOp::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgCompoundAssignOp::next_node);
  135124             : #endif
  135125             : 
  135126             : #if ROSE_PEDANTIC_ALLOC
  135127             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  135128             : #endif
  135129             : 
  135130             : #if ROSE_ALLOC_MEMSET == 1
  135131             : #elif ROSE_ALLOC_MEMSET == 2
  135132             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgCompoundAssignOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  135133             : #elif ROSE_ALLOC_MEMSET == 3
  135134             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgCompoundAssignOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  135135             : #endif
  135136             : 
  135137             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  135138             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  135139             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  135140             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  135141             : #else
  135142           0 :     object->p_freepointer = SgCompoundAssignOp::next_node;
  135143           0 :     SgCompoundAssignOp::next_node = object;
  135144             : #endif
  135145             : 
  135146             : #if ROSE_ALLOC_TRACE == 2
  135147             : //  printf("SgCompoundAssignOp::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgCompoundAssignOp::next_node);
  135148             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  135149             :     Rose::MemPool::snapshot(oss.str());
  135150             :     alloc_trace_cnt++;
  135151             : #endif
  135152             : 
  135153             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  135154             : 
  135155           0 :     ALLOC_MUTEX(SgCompoundAssignOp, unlock);
  135156             : }
  135157             : 
  135158             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  135159             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  135160             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  135161             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  135162             : // Also, note comment below from Robb (copied from the Common.code file).
  135163             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  135164             : //
  135165             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  135166             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  135167             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  135168             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  135169             : #if 0
  135170             : void SgCompoundAssignOp::operator delete(void* pointer) { SgCompoundAssignOp::operator delete (pointer, sizeof(SgCompoundAssignOp)); };
  135171             : #endif
  135172             : /* #line 135173 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  135173             : 
  135174             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  135175             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  135176             : // obviously imply C++.
  135177             : 
  135178             : // This implements the support within ROSE for memory pools.  Memory pools
  135179             : // support the most condensed usage of memory within the construction of
  135180             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  135181             : // by a new operator written for each class.
  135182             : 
  135183             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  135184             :     // User wants multi-thread support and POSIX threads are available.
  135185             : #   include <pthread.h>
  135186             :     static pthread_mutex_t SgPlusAssignOp_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  135187             : #else
  135188             :      // Cause synchronization to be skipped.
  135189             : #    ifndef ALLOC_MUTEX
  135190             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  135191             : #    endif
  135192             : #    ifdef _REENTRANT
  135193             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  135194             : #       ifdef _MSC_VER
  135195             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  135196             : #       else
  135197             : #           warning "POSIX threads are not available; synchronization being skipped"
  135198             : #       endif
  135199             : #    endif
  135200             : #endif
  135201             : 
  135202             : #ifndef ROSE_ALLOC_TRACE
  135203             : #  define ROSE_ALLOC_TRACE 0
  135204             : #endif
  135205             : 
  135206             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  135207             : #define ROSE_ALLOC_TRACE_CNT
  135208             : #include "memory-pool-snapshot.h"
  135209             : unsigned long alloc_trace_cnt = 0;
  135210             : #endif
  135211             : 
  135212             : #if ROSE_ALLOC_TRACE
  135213             : const unsigned SgPlusAssignOp::pool_size = 5;
  135214             : #else
  135215             : const unsigned SgPlusAssignOp::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  135216             : #endif
  135217             : 
  135218             : #ifndef ROSE_ALLOC_MEMSET
  135219             : #  define ROSE_ALLOC_MEMSET 0
  135220             : #endif
  135221             : 
  135222             : #ifndef ROSE_PEDANTIC_ALLOC
  135223             : #  define ROSE_PEDANTIC_ALLOC 0
  135224             : #endif
  135225             : 
  135226             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  135227             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  135228             : #endif
  135229             : 
  135230             : #if !defined(SGNODE__ALL_POOLS)
  135231             : #define SGNODE__ALL_POOLS
  135232             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  135233             : #endif
  135234             : 
  135235             : SgPlusAssignOp* SgPlusAssignOp::next_node = nullptr;
  135236             : std::vector<unsigned char*> SgPlusAssignOp::pools;
  135237             : 
  135238             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  135239             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  135240             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  135241             : // around this macro definition rather than each use).
  135242             : #ifndef ALLOC_MUTEX
  135243             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  135244             :         do {                                                                     \
  135245             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  135246             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  135247             :                 abort();                                                         \
  135248             :             }                                                                    \
  135249             :         } while (0);
  135250             : #endif
  135251             : 
  135252             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  135253             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  135254             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  135255             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  135256             : 
  135257             : /*! \brief New operator for SgPlusAssignOp.
  135258             : 
  135259             :    This new operator implements memory pools to provide most efficent 
  135260             :    use of the heap within construction of large ASTs.
  135261             : 
  135262             : \internal The new and delete operators use the lower level C malloc/free
  135263             :    function calls for performance and to make sure that mixing of malloc/free
  135264             :    and new/delete by the used can be caught more readily.  This may change
  135265             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  135266             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  135267             :    deallocate memory allocated using ROSE_MALLOC.
  135268             : */
  135269         408 : void *SgPlusAssignOp::operator new ( size_t Size )
  135270             : {
  135271             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  135272             :      * returning or throwing an exception. */
  135273         408 :     ALLOC_MUTEX(SgPlusAssignOp, lock);
  135274             : 
  135275             : #if ROSE_ALLOC_TRACE == 2
  135276             : //    printf("SgPlusAssignOp::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgPlusAssignOp::next_node);
  135277             : #endif
  135278             : 
  135279             : #if USE_CPP_NEW_DELETE_OPERATORS
  135280             :     void *mem = ROSE_MALLOC(Size);
  135281             :     ALLOC_MUTEX(SgPlusAssignOp, unlock);
  135282             :     return mem;
  135283             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  135284             : #if ROSE_PEDANTIC_ALLOC
  135285             :     ROSE_ASSERT(Size == sizeof(SgPlusAssignOp));
  135286             : #else
  135287         408 :     if (Size != sizeof(SgPlusAssignOp)) {
  135288           0 :       void * object = ROSE_MALLOC(Size);
  135289           0 :       ALLOC_MUTEX(SgPlusAssignOp, unlock);
  135290             :       return object;
  135291             :     }
  135292             : #endif
  135293             : 
  135294         408 :     if (SgPlusAssignOp::next_node == nullptr) {
  135295          60 :         SgPlusAssignOp * alloc = (SgPlusAssignOp*) ROSE_MALLOC ( SgPlusAssignOp::pool_size * sizeof(SgPlusAssignOp) );
  135296          60 :         ROSE_ASSERT(alloc != nullptr);
  135297             : 
  135298             : #if ROSE_ALLOC_TRACE == 2
  135299             : //        printf("SgPlusAssignOp::alloc\n  block[%zi] = [ %p , %p [\n", SgPlusAssignOp::pools.size(), alloc, alloc + SgPlusAssignOp::pool_size);
  135300             : #endif
  135301             : 
  135302             : #if ROSE_ALLOC_MEMSET == 1
  135303             : #elif ROSE_ALLOC_MEMSET == 2
  135304             :         memset(alloc, 0x00, SgPlusAssignOp::pool_size * sizeof(SgPlusAssignOp));
  135305             : #elif ROSE_ALLOC_MEMSET == 3
  135306             :         memset(alloc, 0xAA, SgPlusAssignOp::pool_size * sizeof(SgPlusAssignOp));
  135307             : #endif
  135308      120000 :         for (unsigned i=0; i < SgPlusAssignOp::pool_size-1; i++) {
  135309      119940 :           alloc[i].p_freepointer = &(alloc[i+1]);
  135310             :         }
  135311          60 :         alloc[SgPlusAssignOp::pool_size-1].p_freepointer = nullptr;
  135312             : 
  135313          60 :         SgPlusAssignOp::pools.push_back ( (unsigned char *) alloc );
  135314          60 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgPlusAssignOp::pool_size * sizeof(SgPlusAssignOp), V_SgPlusAssignOp ) );
  135315          60 :         SgPlusAssignOp::next_node = alloc;
  135316             :     }
  135317         408 :     ROSE_ASSERT(SgPlusAssignOp::next_node != nullptr);
  135318             : 
  135319         408 :     SgPlusAssignOp * object = SgPlusAssignOp::next_node;
  135320         408 :     SgPlusAssignOp::next_node = (SgPlusAssignOp*)(object->p_freepointer);
  135321             : 
  135322             : #if ROSE_ALLOC_TRACE == 2
  135323             :     printf("SgPlusAssignOp::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgPlusAssignOp::next_node);
  135324             : #endif
  135325             : 
  135326         408 :     SgNode * fp = object->p_freepointer;
  135327             : #if ROSE_ALLOC_MEMSET == 1
  135328             : #elif ROSE_ALLOC_MEMSET == 2
  135329             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgPlusAssignOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  135330             : #elif ROSE_ALLOC_MEMSET == 3
  135331             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgPlusAssignOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  135332             : #endif
  135333         408 :     object->p_freepointer = fp;
  135334             : 
  135335             : #if ROSE_ALLOC_TRACE == 2
  135336             : //    printf("SgPlusAssignOp::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgPlusAssignOp::next_node);
  135337             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  135338             :     Rose::MemPool::snapshot(oss.str());
  135339             :     alloc_trace_cnt++;
  135340             : #endif
  135341             : 
  135342         408 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  135343             : 
  135344         408 :     ALLOC_MUTEX(SgPlusAssignOp, unlock);
  135345             : 
  135346             :     return object;
  135347             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  135348             : }
  135349             : 
  135350             : 
  135351             : 
  135352             : /*! \brief Delete operator for SgPlusAssignOp.
  135353             : 
  135354             :    This delete operator implements deallocation using memory pools to 
  135355             :    provide most efficent use of the heap within construction of large ASTs.
  135356             : 
  135357             : \internal The new and delete operators use the lower level C malloc/free
  135358             :    function calls for performance and to make sure that mixing of malloc/free
  135359             :    and new/delete by the used can be caught more readily.  This may change
  135360             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  135361             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  135362             :    deallocate memory allocated using ROSE_MALLOC.
  135363             : */
  135364          58 : void SgPlusAssignOp::operator delete(void *Pointer, size_t Size)
  135365             : {
  135366             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  135367             :      * or throwing an exception. */
  135368          58 :     ALLOC_MUTEX(SgPlusAssignOp, lock);
  135369             : 
  135370             : #if USE_CPP_NEW_DELETE_OPERATORS
  135371             :     ROSE_FREE(Pointer);
  135372             : #else
  135373             : #if ROSE_PEDANTIC_ALLOC
  135374             :     ROSE_ASSERT(Size == sizeof(SgPlusAssignOp));
  135375             : #else
  135376          58 :     if (Size != sizeof(SgPlusAssignOp)) {
  135377           0 :       ROSE_FREE(Pointer);
  135378           0 :       ALLOC_MUTEX(SgPlusAssignOp, unlock);
  135379             :       return;
  135380             :     }
  135381             : #endif
  135382             : 
  135383          58 :     SgPlusAssignOp * object = (SgPlusAssignOp*) Pointer;
  135384          58 :     ROSE_ASSERT(object != nullptr);
  135385             : 
  135386             : #if ROSE_ALLOC_TRACE == 2
  135387             : //  printf("SgPlusAssignOp::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgPlusAssignOp::next_node);
  135388             :     printf("SgPlusAssignOp::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgPlusAssignOp::next_node);
  135389             : #endif
  135390             : 
  135391             : #if ROSE_PEDANTIC_ALLOC
  135392             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  135393             : #endif
  135394             : 
  135395             : #if ROSE_ALLOC_MEMSET == 1
  135396             : #elif ROSE_ALLOC_MEMSET == 2
  135397             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgPlusAssignOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  135398             : #elif ROSE_ALLOC_MEMSET == 3
  135399             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgPlusAssignOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  135400             : #endif
  135401             : 
  135402             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  135403             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  135404             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  135405             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  135406             : #else
  135407          58 :     object->p_freepointer = SgPlusAssignOp::next_node;
  135408          58 :     SgPlusAssignOp::next_node = object;
  135409             : #endif
  135410             : 
  135411             : #if ROSE_ALLOC_TRACE == 2
  135412             : //  printf("SgPlusAssignOp::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgPlusAssignOp::next_node);
  135413             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  135414             :     Rose::MemPool::snapshot(oss.str());
  135415             :     alloc_trace_cnt++;
  135416             : #endif
  135417             : 
  135418             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  135419             : 
  135420          58 :     ALLOC_MUTEX(SgPlusAssignOp, unlock);
  135421             : }
  135422             : 
  135423             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  135424             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  135425             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  135426             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  135427             : // Also, note comment below from Robb (copied from the Common.code file).
  135428             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  135429             : //
  135430             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  135431             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  135432             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  135433             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  135434             : #if 0
  135435             : void SgPlusAssignOp::operator delete(void* pointer) { SgPlusAssignOp::operator delete (pointer, sizeof(SgPlusAssignOp)); };
  135436             : #endif
  135437             : /* #line 135438 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  135438             : 
  135439             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  135440             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  135441             : // obviously imply C++.
  135442             : 
  135443             : // This implements the support within ROSE for memory pools.  Memory pools
  135444             : // support the most condensed usage of memory within the construction of
  135445             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  135446             : // by a new operator written for each class.
  135447             : 
  135448             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  135449             :     // User wants multi-thread support and POSIX threads are available.
  135450             : #   include <pthread.h>
  135451             :     static pthread_mutex_t SgMinusAssignOp_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  135452             : #else
  135453             :      // Cause synchronization to be skipped.
  135454             : #    ifndef ALLOC_MUTEX
  135455             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  135456             : #    endif
  135457             : #    ifdef _REENTRANT
  135458             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  135459             : #       ifdef _MSC_VER
  135460             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  135461             : #       else
  135462             : #           warning "POSIX threads are not available; synchronization being skipped"
  135463             : #       endif
  135464             : #    endif
  135465             : #endif
  135466             : 
  135467             : #ifndef ROSE_ALLOC_TRACE
  135468             : #  define ROSE_ALLOC_TRACE 0
  135469             : #endif
  135470             : 
  135471             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  135472             : #define ROSE_ALLOC_TRACE_CNT
  135473             : #include "memory-pool-snapshot.h"
  135474             : unsigned long alloc_trace_cnt = 0;
  135475             : #endif
  135476             : 
  135477             : #if ROSE_ALLOC_TRACE
  135478             : const unsigned SgMinusAssignOp::pool_size = 5;
  135479             : #else
  135480             : const unsigned SgMinusAssignOp::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  135481             : #endif
  135482             : 
  135483             : #ifndef ROSE_ALLOC_MEMSET
  135484             : #  define ROSE_ALLOC_MEMSET 0
  135485             : #endif
  135486             : 
  135487             : #ifndef ROSE_PEDANTIC_ALLOC
  135488             : #  define ROSE_PEDANTIC_ALLOC 0
  135489             : #endif
  135490             : 
  135491             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  135492             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  135493             : #endif
  135494             : 
  135495             : #if !defined(SGNODE__ALL_POOLS)
  135496             : #define SGNODE__ALL_POOLS
  135497             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  135498             : #endif
  135499             : 
  135500             : SgMinusAssignOp* SgMinusAssignOp::next_node = nullptr;
  135501             : std::vector<unsigned char*> SgMinusAssignOp::pools;
  135502             : 
  135503             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  135504             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  135505             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  135506             : // around this macro definition rather than each use).
  135507             : #ifndef ALLOC_MUTEX
  135508             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  135509             :         do {                                                                     \
  135510             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  135511             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  135512             :                 abort();                                                         \
  135513             :             }                                                                    \
  135514             :         } while (0);
  135515             : #endif
  135516             : 
  135517             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  135518             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  135519             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  135520             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  135521             : 
  135522             : /*! \brief New operator for SgMinusAssignOp.
  135523             : 
  135524             :    This new operator implements memory pools to provide most efficent 
  135525             :    use of the heap within construction of large ASTs.
  135526             : 
  135527             : \internal The new and delete operators use the lower level C malloc/free
  135528             :    function calls for performance and to make sure that mixing of malloc/free
  135529             :    and new/delete by the used can be caught more readily.  This may change
  135530             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  135531             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  135532             :    deallocate memory allocated using ROSE_MALLOC.
  135533             : */
  135534         106 : void *SgMinusAssignOp::operator new ( size_t Size )
  135535             : {
  135536             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  135537             :      * returning or throwing an exception. */
  135538         106 :     ALLOC_MUTEX(SgMinusAssignOp, lock);
  135539             : 
  135540             : #if ROSE_ALLOC_TRACE == 2
  135541             : //    printf("SgMinusAssignOp::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgMinusAssignOp::next_node);
  135542             : #endif
  135543             : 
  135544             : #if USE_CPP_NEW_DELETE_OPERATORS
  135545             :     void *mem = ROSE_MALLOC(Size);
  135546             :     ALLOC_MUTEX(SgMinusAssignOp, unlock);
  135547             :     return mem;
  135548             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  135549             : #if ROSE_PEDANTIC_ALLOC
  135550             :     ROSE_ASSERT(Size == sizeof(SgMinusAssignOp));
  135551             : #else
  135552         106 :     if (Size != sizeof(SgMinusAssignOp)) {
  135553           0 :       void * object = ROSE_MALLOC(Size);
  135554           0 :       ALLOC_MUTEX(SgMinusAssignOp, unlock);
  135555             :       return object;
  135556             :     }
  135557             : #endif
  135558             : 
  135559         106 :     if (SgMinusAssignOp::next_node == nullptr) {
  135560          18 :         SgMinusAssignOp * alloc = (SgMinusAssignOp*) ROSE_MALLOC ( SgMinusAssignOp::pool_size * sizeof(SgMinusAssignOp) );
  135561          18 :         ROSE_ASSERT(alloc != nullptr);
  135562             : 
  135563             : #if ROSE_ALLOC_TRACE == 2
  135564             : //        printf("SgMinusAssignOp::alloc\n  block[%zi] = [ %p , %p [\n", SgMinusAssignOp::pools.size(), alloc, alloc + SgMinusAssignOp::pool_size);
  135565             : #endif
  135566             : 
  135567             : #if ROSE_ALLOC_MEMSET == 1
  135568             : #elif ROSE_ALLOC_MEMSET == 2
  135569             :         memset(alloc, 0x00, SgMinusAssignOp::pool_size * sizeof(SgMinusAssignOp));
  135570             : #elif ROSE_ALLOC_MEMSET == 3
  135571             :         memset(alloc, 0xAA, SgMinusAssignOp::pool_size * sizeof(SgMinusAssignOp));
  135572             : #endif
  135573       36000 :         for (unsigned i=0; i < SgMinusAssignOp::pool_size-1; i++) {
  135574       35982 :           alloc[i].p_freepointer = &(alloc[i+1]);
  135575             :         }
  135576          18 :         alloc[SgMinusAssignOp::pool_size-1].p_freepointer = nullptr;
  135577             : 
  135578          18 :         SgMinusAssignOp::pools.push_back ( (unsigned char *) alloc );
  135579          18 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgMinusAssignOp::pool_size * sizeof(SgMinusAssignOp), V_SgMinusAssignOp ) );
  135580          18 :         SgMinusAssignOp::next_node = alloc;
  135581             :     }
  135582         106 :     ROSE_ASSERT(SgMinusAssignOp::next_node != nullptr);
  135583             : 
  135584         106 :     SgMinusAssignOp * object = SgMinusAssignOp::next_node;
  135585         106 :     SgMinusAssignOp::next_node = (SgMinusAssignOp*)(object->p_freepointer);
  135586             : 
  135587             : #if ROSE_ALLOC_TRACE == 2
  135588             :     printf("SgMinusAssignOp::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgMinusAssignOp::next_node);
  135589             : #endif
  135590             : 
  135591         106 :     SgNode * fp = object->p_freepointer;
  135592             : #if ROSE_ALLOC_MEMSET == 1
  135593             : #elif ROSE_ALLOC_MEMSET == 2
  135594             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgMinusAssignOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  135595             : #elif ROSE_ALLOC_MEMSET == 3
  135596             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgMinusAssignOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  135597             : #endif
  135598         106 :     object->p_freepointer = fp;
  135599             : 
  135600             : #if ROSE_ALLOC_TRACE == 2
  135601             : //    printf("SgMinusAssignOp::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgMinusAssignOp::next_node);
  135602             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  135603             :     Rose::MemPool::snapshot(oss.str());
  135604             :     alloc_trace_cnt++;
  135605             : #endif
  135606             : 
  135607         106 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  135608             : 
  135609         106 :     ALLOC_MUTEX(SgMinusAssignOp, unlock);
  135610             : 
  135611             :     return object;
  135612             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  135613             : }
  135614             : 
  135615             : 
  135616             : 
  135617             : /*! \brief Delete operator for SgMinusAssignOp.
  135618             : 
  135619             :    This delete operator implements deallocation using memory pools to 
  135620             :    provide most efficent use of the heap within construction of large ASTs.
  135621             : 
  135622             : \internal The new and delete operators use the lower level C malloc/free
  135623             :    function calls for performance and to make sure that mixing of malloc/free
  135624             :    and new/delete by the used can be caught more readily.  This may change
  135625             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  135626             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  135627             :    deallocate memory allocated using ROSE_MALLOC.
  135628             : */
  135629          21 : void SgMinusAssignOp::operator delete(void *Pointer, size_t Size)
  135630             : {
  135631             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  135632             :      * or throwing an exception. */
  135633          21 :     ALLOC_MUTEX(SgMinusAssignOp, lock);
  135634             : 
  135635             : #if USE_CPP_NEW_DELETE_OPERATORS
  135636             :     ROSE_FREE(Pointer);
  135637             : #else
  135638             : #if ROSE_PEDANTIC_ALLOC
  135639             :     ROSE_ASSERT(Size == sizeof(SgMinusAssignOp));
  135640             : #else
  135641          21 :     if (Size != sizeof(SgMinusAssignOp)) {
  135642           0 :       ROSE_FREE(Pointer);
  135643           0 :       ALLOC_MUTEX(SgMinusAssignOp, unlock);
  135644             :       return;
  135645             :     }
  135646             : #endif
  135647             : 
  135648          21 :     SgMinusAssignOp * object = (SgMinusAssignOp*) Pointer;
  135649          21 :     ROSE_ASSERT(object != nullptr);
  135650             : 
  135651             : #if ROSE_ALLOC_TRACE == 2
  135652             : //  printf("SgMinusAssignOp::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgMinusAssignOp::next_node);
  135653             :     printf("SgMinusAssignOp::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgMinusAssignOp::next_node);
  135654             : #endif
  135655             : 
  135656             : #if ROSE_PEDANTIC_ALLOC
  135657             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  135658             : #endif
  135659             : 
  135660             : #if ROSE_ALLOC_MEMSET == 1
  135661             : #elif ROSE_ALLOC_MEMSET == 2
  135662             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgMinusAssignOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  135663             : #elif ROSE_ALLOC_MEMSET == 3
  135664             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgMinusAssignOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  135665             : #endif
  135666             : 
  135667             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  135668             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  135669             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  135670             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  135671             : #else
  135672          21 :     object->p_freepointer = SgMinusAssignOp::next_node;
  135673          21 :     SgMinusAssignOp::next_node = object;
  135674             : #endif
  135675             : 
  135676             : #if ROSE_ALLOC_TRACE == 2
  135677             : //  printf("SgMinusAssignOp::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgMinusAssignOp::next_node);
  135678             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  135679             :     Rose::MemPool::snapshot(oss.str());
  135680             :     alloc_trace_cnt++;
  135681             : #endif
  135682             : 
  135683             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  135684             : 
  135685          21 :     ALLOC_MUTEX(SgMinusAssignOp, unlock);
  135686             : }
  135687             : 
  135688             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  135689             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  135690             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  135691             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  135692             : // Also, note comment below from Robb (copied from the Common.code file).
  135693             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  135694             : //
  135695             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  135696             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  135697             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  135698             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  135699             : #if 0
  135700             : void SgMinusAssignOp::operator delete(void* pointer) { SgMinusAssignOp::operator delete (pointer, sizeof(SgMinusAssignOp)); };
  135701             : #endif
  135702             : /* #line 135703 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  135703             : 
  135704             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  135705             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  135706             : // obviously imply C++.
  135707             : 
  135708             : // This implements the support within ROSE for memory pools.  Memory pools
  135709             : // support the most condensed usage of memory within the construction of
  135710             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  135711             : // by a new operator written for each class.
  135712             : 
  135713             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  135714             :     // User wants multi-thread support and POSIX threads are available.
  135715             : #   include <pthread.h>
  135716             :     static pthread_mutex_t SgAndAssignOp_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  135717             : #else
  135718             :      // Cause synchronization to be skipped.
  135719             : #    ifndef ALLOC_MUTEX
  135720             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  135721             : #    endif
  135722             : #    ifdef _REENTRANT
  135723             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  135724             : #       ifdef _MSC_VER
  135725             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  135726             : #       else
  135727             : #           warning "POSIX threads are not available; synchronization being skipped"
  135728             : #       endif
  135729             : #    endif
  135730             : #endif
  135731             : 
  135732             : #ifndef ROSE_ALLOC_TRACE
  135733             : #  define ROSE_ALLOC_TRACE 0
  135734             : #endif
  135735             : 
  135736             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  135737             : #define ROSE_ALLOC_TRACE_CNT
  135738             : #include "memory-pool-snapshot.h"
  135739             : unsigned long alloc_trace_cnt = 0;
  135740             : #endif
  135741             : 
  135742             : #if ROSE_ALLOC_TRACE
  135743             : const unsigned SgAndAssignOp::pool_size = 5;
  135744             : #else
  135745             : const unsigned SgAndAssignOp::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  135746             : #endif
  135747             : 
  135748             : #ifndef ROSE_ALLOC_MEMSET
  135749             : #  define ROSE_ALLOC_MEMSET 0
  135750             : #endif
  135751             : 
  135752             : #ifndef ROSE_PEDANTIC_ALLOC
  135753             : #  define ROSE_PEDANTIC_ALLOC 0
  135754             : #endif
  135755             : 
  135756             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  135757             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  135758             : #endif
  135759             : 
  135760             : #if !defined(SGNODE__ALL_POOLS)
  135761             : #define SGNODE__ALL_POOLS
  135762             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  135763             : #endif
  135764             : 
  135765             : SgAndAssignOp* SgAndAssignOp::next_node = nullptr;
  135766             : std::vector<unsigned char*> SgAndAssignOp::pools;
  135767             : 
  135768             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  135769             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  135770             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  135771             : // around this macro definition rather than each use).
  135772             : #ifndef ALLOC_MUTEX
  135773             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  135774             :         do {                                                                     \
  135775             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  135776             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  135777             :                 abort();                                                         \
  135778             :             }                                                                    \
  135779             :         } while (0);
  135780             : #endif
  135781             : 
  135782             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  135783             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  135784             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  135785             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  135786             : 
  135787             : /*! \brief New operator for SgAndAssignOp.
  135788             : 
  135789             :    This new operator implements memory pools to provide most efficent 
  135790             :    use of the heap within construction of large ASTs.
  135791             : 
  135792             : \internal The new and delete operators use the lower level C malloc/free
  135793             :    function calls for performance and to make sure that mixing of malloc/free
  135794             :    and new/delete by the used can be caught more readily.  This may change
  135795             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  135796             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  135797             :    deallocate memory allocated using ROSE_MALLOC.
  135798             : */
  135799           9 : void *SgAndAssignOp::operator new ( size_t Size )
  135800             : {
  135801             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  135802             :      * returning or throwing an exception. */
  135803           9 :     ALLOC_MUTEX(SgAndAssignOp, lock);
  135804             : 
  135805             : #if ROSE_ALLOC_TRACE == 2
  135806             : //    printf("SgAndAssignOp::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgAndAssignOp::next_node);
  135807             : #endif
  135808             : 
  135809             : #if USE_CPP_NEW_DELETE_OPERATORS
  135810             :     void *mem = ROSE_MALLOC(Size);
  135811             :     ALLOC_MUTEX(SgAndAssignOp, unlock);
  135812             :     return mem;
  135813             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  135814             : #if ROSE_PEDANTIC_ALLOC
  135815             :     ROSE_ASSERT(Size == sizeof(SgAndAssignOp));
  135816             : #else
  135817           9 :     if (Size != sizeof(SgAndAssignOp)) {
  135818           0 :       void * object = ROSE_MALLOC(Size);
  135819           0 :       ALLOC_MUTEX(SgAndAssignOp, unlock);
  135820             :       return object;
  135821             :     }
  135822             : #endif
  135823             : 
  135824           9 :     if (SgAndAssignOp::next_node == nullptr) {
  135825           3 :         SgAndAssignOp * alloc = (SgAndAssignOp*) ROSE_MALLOC ( SgAndAssignOp::pool_size * sizeof(SgAndAssignOp) );
  135826           3 :         ROSE_ASSERT(alloc != nullptr);
  135827             : 
  135828             : #if ROSE_ALLOC_TRACE == 2
  135829             : //        printf("SgAndAssignOp::alloc\n  block[%zi] = [ %p , %p [\n", SgAndAssignOp::pools.size(), alloc, alloc + SgAndAssignOp::pool_size);
  135830             : #endif
  135831             : 
  135832             : #if ROSE_ALLOC_MEMSET == 1
  135833             : #elif ROSE_ALLOC_MEMSET == 2
  135834             :         memset(alloc, 0x00, SgAndAssignOp::pool_size * sizeof(SgAndAssignOp));
  135835             : #elif ROSE_ALLOC_MEMSET == 3
  135836             :         memset(alloc, 0xAA, SgAndAssignOp::pool_size * sizeof(SgAndAssignOp));
  135837             : #endif
  135838        6000 :         for (unsigned i=0; i < SgAndAssignOp::pool_size-1; i++) {
  135839        5997 :           alloc[i].p_freepointer = &(alloc[i+1]);
  135840             :         }
  135841           3 :         alloc[SgAndAssignOp::pool_size-1].p_freepointer = nullptr;
  135842             : 
  135843           3 :         SgAndAssignOp::pools.push_back ( (unsigned char *) alloc );
  135844           3 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgAndAssignOp::pool_size * sizeof(SgAndAssignOp), V_SgAndAssignOp ) );
  135845           3 :         SgAndAssignOp::next_node = alloc;
  135846             :     }
  135847           9 :     ROSE_ASSERT(SgAndAssignOp::next_node != nullptr);
  135848             : 
  135849           9 :     SgAndAssignOp * object = SgAndAssignOp::next_node;
  135850           9 :     SgAndAssignOp::next_node = (SgAndAssignOp*)(object->p_freepointer);
  135851             : 
  135852             : #if ROSE_ALLOC_TRACE == 2
  135853             :     printf("SgAndAssignOp::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgAndAssignOp::next_node);
  135854             : #endif
  135855             : 
  135856           9 :     SgNode * fp = object->p_freepointer;
  135857             : #if ROSE_ALLOC_MEMSET == 1
  135858             : #elif ROSE_ALLOC_MEMSET == 2
  135859             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgAndAssignOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  135860             : #elif ROSE_ALLOC_MEMSET == 3
  135861             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgAndAssignOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  135862             : #endif
  135863           9 :     object->p_freepointer = fp;
  135864             : 
  135865             : #if ROSE_ALLOC_TRACE == 2
  135866             : //    printf("SgAndAssignOp::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgAndAssignOp::next_node);
  135867             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  135868             :     Rose::MemPool::snapshot(oss.str());
  135869             :     alloc_trace_cnt++;
  135870             : #endif
  135871             : 
  135872           9 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  135873             : 
  135874           9 :     ALLOC_MUTEX(SgAndAssignOp, unlock);
  135875             : 
  135876             :     return object;
  135877             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  135878             : }
  135879             : 
  135880             : 
  135881             : 
  135882             : /*! \brief Delete operator for SgAndAssignOp.
  135883             : 
  135884             :    This delete operator implements deallocation using memory pools to 
  135885             :    provide most efficent use of the heap within construction of large ASTs.
  135886             : 
  135887             : \internal The new and delete operators use the lower level C malloc/free
  135888             :    function calls for performance and to make sure that mixing of malloc/free
  135889             :    and new/delete by the used can be caught more readily.  This may change
  135890             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  135891             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  135892             :    deallocate memory allocated using ROSE_MALLOC.
  135893             : */
  135894           0 : void SgAndAssignOp::operator delete(void *Pointer, size_t Size)
  135895             : {
  135896             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  135897             :      * or throwing an exception. */
  135898           0 :     ALLOC_MUTEX(SgAndAssignOp, lock);
  135899             : 
  135900             : #if USE_CPP_NEW_DELETE_OPERATORS
  135901             :     ROSE_FREE(Pointer);
  135902             : #else
  135903             : #if ROSE_PEDANTIC_ALLOC
  135904             :     ROSE_ASSERT(Size == sizeof(SgAndAssignOp));
  135905             : #else
  135906           0 :     if (Size != sizeof(SgAndAssignOp)) {
  135907           0 :       ROSE_FREE(Pointer);
  135908           0 :       ALLOC_MUTEX(SgAndAssignOp, unlock);
  135909             :       return;
  135910             :     }
  135911             : #endif
  135912             : 
  135913           0 :     SgAndAssignOp * object = (SgAndAssignOp*) Pointer;
  135914           0 :     ROSE_ASSERT(object != nullptr);
  135915             : 
  135916             : #if ROSE_ALLOC_TRACE == 2
  135917             : //  printf("SgAndAssignOp::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgAndAssignOp::next_node);
  135918             :     printf("SgAndAssignOp::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgAndAssignOp::next_node);
  135919             : #endif
  135920             : 
  135921             : #if ROSE_PEDANTIC_ALLOC
  135922             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  135923             : #endif
  135924             : 
  135925             : #if ROSE_ALLOC_MEMSET == 1
  135926             : #elif ROSE_ALLOC_MEMSET == 2
  135927             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgAndAssignOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  135928             : #elif ROSE_ALLOC_MEMSET == 3
  135929             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgAndAssignOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  135930             : #endif
  135931             : 
  135932             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  135933             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  135934             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  135935             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  135936             : #else
  135937           0 :     object->p_freepointer = SgAndAssignOp::next_node;
  135938           0 :     SgAndAssignOp::next_node = object;
  135939             : #endif
  135940             : 
  135941             : #if ROSE_ALLOC_TRACE == 2
  135942             : //  printf("SgAndAssignOp::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgAndAssignOp::next_node);
  135943             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  135944             :     Rose::MemPool::snapshot(oss.str());
  135945             :     alloc_trace_cnt++;
  135946             : #endif
  135947             : 
  135948             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  135949             : 
  135950           0 :     ALLOC_MUTEX(SgAndAssignOp, unlock);
  135951             : }
  135952             : 
  135953             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  135954             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  135955             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  135956             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  135957             : // Also, note comment below from Robb (copied from the Common.code file).
  135958             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  135959             : //
  135960             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  135961             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  135962             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  135963             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  135964             : #if 0
  135965             : void SgAndAssignOp::operator delete(void* pointer) { SgAndAssignOp::operator delete (pointer, sizeof(SgAndAssignOp)); };
  135966             : #endif
  135967             : /* #line 135968 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  135968             : 
  135969             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  135970             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  135971             : // obviously imply C++.
  135972             : 
  135973             : // This implements the support within ROSE for memory pools.  Memory pools
  135974             : // support the most condensed usage of memory within the construction of
  135975             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  135976             : // by a new operator written for each class.
  135977             : 
  135978             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  135979             :     // User wants multi-thread support and POSIX threads are available.
  135980             : #   include <pthread.h>
  135981             :     static pthread_mutex_t SgIorAssignOp_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  135982             : #else
  135983             :      // Cause synchronization to be skipped.
  135984             : #    ifndef ALLOC_MUTEX
  135985             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  135986             : #    endif
  135987             : #    ifdef _REENTRANT
  135988             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  135989             : #       ifdef _MSC_VER
  135990             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  135991             : #       else
  135992             : #           warning "POSIX threads are not available; synchronization being skipped"
  135993             : #       endif
  135994             : #    endif
  135995             : #endif
  135996             : 
  135997             : #ifndef ROSE_ALLOC_TRACE
  135998             : #  define ROSE_ALLOC_TRACE 0
  135999             : #endif
  136000             : 
  136001             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  136002             : #define ROSE_ALLOC_TRACE_CNT
  136003             : #include "memory-pool-snapshot.h"
  136004             : unsigned long alloc_trace_cnt = 0;
  136005             : #endif
  136006             : 
  136007             : #if ROSE_ALLOC_TRACE
  136008             : const unsigned SgIorAssignOp::pool_size = 5;
  136009             : #else
  136010             : const unsigned SgIorAssignOp::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  136011             : #endif
  136012             : 
  136013             : #ifndef ROSE_ALLOC_MEMSET
  136014             : #  define ROSE_ALLOC_MEMSET 0
  136015             : #endif
  136016             : 
  136017             : #ifndef ROSE_PEDANTIC_ALLOC
  136018             : #  define ROSE_PEDANTIC_ALLOC 0
  136019             : #endif
  136020             : 
  136021             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  136022             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  136023             : #endif
  136024             : 
  136025             : #if !defined(SGNODE__ALL_POOLS)
  136026             : #define SGNODE__ALL_POOLS
  136027             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  136028             : #endif
  136029             : 
  136030             : SgIorAssignOp* SgIorAssignOp::next_node = nullptr;
  136031             : std::vector<unsigned char*> SgIorAssignOp::pools;
  136032             : 
  136033             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  136034             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  136035             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  136036             : // around this macro definition rather than each use).
  136037             : #ifndef ALLOC_MUTEX
  136038             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  136039             :         do {                                                                     \
  136040             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  136041             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  136042             :                 abort();                                                         \
  136043             :             }                                                                    \
  136044             :         } while (0);
  136045             : #endif
  136046             : 
  136047             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  136048             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  136049             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  136050             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  136051             : 
  136052             : /*! \brief New operator for SgIorAssignOp.
  136053             : 
  136054             :    This new operator implements memory pools to provide most efficent 
  136055             :    use of the heap within construction of large ASTs.
  136056             : 
  136057             : \internal The new and delete operators use the lower level C malloc/free
  136058             :    function calls for performance and to make sure that mixing of malloc/free
  136059             :    and new/delete by the used can be caught more readily.  This may change
  136060             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  136061             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  136062             :    deallocate memory allocated using ROSE_MALLOC.
  136063             : */
  136064          69 : void *SgIorAssignOp::operator new ( size_t Size )
  136065             : {
  136066             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  136067             :      * returning or throwing an exception. */
  136068          69 :     ALLOC_MUTEX(SgIorAssignOp, lock);
  136069             : 
  136070             : #if ROSE_ALLOC_TRACE == 2
  136071             : //    printf("SgIorAssignOp::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgIorAssignOp::next_node);
  136072             : #endif
  136073             : 
  136074             : #if USE_CPP_NEW_DELETE_OPERATORS
  136075             :     void *mem = ROSE_MALLOC(Size);
  136076             :     ALLOC_MUTEX(SgIorAssignOp, unlock);
  136077             :     return mem;
  136078             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  136079             : #if ROSE_PEDANTIC_ALLOC
  136080             :     ROSE_ASSERT(Size == sizeof(SgIorAssignOp));
  136081             : #else
  136082          69 :     if (Size != sizeof(SgIorAssignOp)) {
  136083           0 :       void * object = ROSE_MALLOC(Size);
  136084           0 :       ALLOC_MUTEX(SgIorAssignOp, unlock);
  136085             :       return object;
  136086             :     }
  136087             : #endif
  136088             : 
  136089          69 :     if (SgIorAssignOp::next_node == nullptr) {
  136090          10 :         SgIorAssignOp * alloc = (SgIorAssignOp*) ROSE_MALLOC ( SgIorAssignOp::pool_size * sizeof(SgIorAssignOp) );
  136091          10 :         ROSE_ASSERT(alloc != nullptr);
  136092             : 
  136093             : #if ROSE_ALLOC_TRACE == 2
  136094             : //        printf("SgIorAssignOp::alloc\n  block[%zi] = [ %p , %p [\n", SgIorAssignOp::pools.size(), alloc, alloc + SgIorAssignOp::pool_size);
  136095             : #endif
  136096             : 
  136097             : #if ROSE_ALLOC_MEMSET == 1
  136098             : #elif ROSE_ALLOC_MEMSET == 2
  136099             :         memset(alloc, 0x00, SgIorAssignOp::pool_size * sizeof(SgIorAssignOp));
  136100             : #elif ROSE_ALLOC_MEMSET == 3
  136101             :         memset(alloc, 0xAA, SgIorAssignOp::pool_size * sizeof(SgIorAssignOp));
  136102             : #endif
  136103       20000 :         for (unsigned i=0; i < SgIorAssignOp::pool_size-1; i++) {
  136104       19990 :           alloc[i].p_freepointer = &(alloc[i+1]);
  136105             :         }
  136106          10 :         alloc[SgIorAssignOp::pool_size-1].p_freepointer = nullptr;
  136107             : 
  136108          10 :         SgIorAssignOp::pools.push_back ( (unsigned char *) alloc );
  136109          10 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgIorAssignOp::pool_size * sizeof(SgIorAssignOp), V_SgIorAssignOp ) );
  136110          10 :         SgIorAssignOp::next_node = alloc;
  136111             :     }
  136112          69 :     ROSE_ASSERT(SgIorAssignOp::next_node != nullptr);
  136113             : 
  136114          69 :     SgIorAssignOp * object = SgIorAssignOp::next_node;
  136115          69 :     SgIorAssignOp::next_node = (SgIorAssignOp*)(object->p_freepointer);
  136116             : 
  136117             : #if ROSE_ALLOC_TRACE == 2
  136118             :     printf("SgIorAssignOp::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgIorAssignOp::next_node);
  136119             : #endif
  136120             : 
  136121          69 :     SgNode * fp = object->p_freepointer;
  136122             : #if ROSE_ALLOC_MEMSET == 1
  136123             : #elif ROSE_ALLOC_MEMSET == 2
  136124             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgIorAssignOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  136125             : #elif ROSE_ALLOC_MEMSET == 3
  136126             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgIorAssignOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  136127             : #endif
  136128          69 :     object->p_freepointer = fp;
  136129             : 
  136130             : #if ROSE_ALLOC_TRACE == 2
  136131             : //    printf("SgIorAssignOp::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgIorAssignOp::next_node);
  136132             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  136133             :     Rose::MemPool::snapshot(oss.str());
  136134             :     alloc_trace_cnt++;
  136135             : #endif
  136136             : 
  136137          69 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  136138             : 
  136139          69 :     ALLOC_MUTEX(SgIorAssignOp, unlock);
  136140             : 
  136141             :     return object;
  136142             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  136143             : }
  136144             : 
  136145             : 
  136146             : 
  136147             : /*! \brief Delete operator for SgIorAssignOp.
  136148             : 
  136149             :    This delete operator implements deallocation using memory pools to 
  136150             :    provide most efficent use of the heap within construction of large ASTs.
  136151             : 
  136152             : \internal The new and delete operators use the lower level C malloc/free
  136153             :    function calls for performance and to make sure that mixing of malloc/free
  136154             :    and new/delete by the used can be caught more readily.  This may change
  136155             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  136156             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  136157             :    deallocate memory allocated using ROSE_MALLOC.
  136158             : */
  136159          14 : void SgIorAssignOp::operator delete(void *Pointer, size_t Size)
  136160             : {
  136161             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  136162             :      * or throwing an exception. */
  136163          14 :     ALLOC_MUTEX(SgIorAssignOp, lock);
  136164             : 
  136165             : #if USE_CPP_NEW_DELETE_OPERATORS
  136166             :     ROSE_FREE(Pointer);
  136167             : #else
  136168             : #if ROSE_PEDANTIC_ALLOC
  136169             :     ROSE_ASSERT(Size == sizeof(SgIorAssignOp));
  136170             : #else
  136171          14 :     if (Size != sizeof(SgIorAssignOp)) {
  136172           0 :       ROSE_FREE(Pointer);
  136173           0 :       ALLOC_MUTEX(SgIorAssignOp, unlock);
  136174             :       return;
  136175             :     }
  136176             : #endif
  136177             : 
  136178          14 :     SgIorAssignOp * object = (SgIorAssignOp*) Pointer;
  136179          14 :     ROSE_ASSERT(object != nullptr);
  136180             : 
  136181             : #if ROSE_ALLOC_TRACE == 2
  136182             : //  printf("SgIorAssignOp::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgIorAssignOp::next_node);
  136183             :     printf("SgIorAssignOp::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgIorAssignOp::next_node);
  136184             : #endif
  136185             : 
  136186             : #if ROSE_PEDANTIC_ALLOC
  136187             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  136188             : #endif
  136189             : 
  136190             : #if ROSE_ALLOC_MEMSET == 1
  136191             : #elif ROSE_ALLOC_MEMSET == 2
  136192             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgIorAssignOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  136193             : #elif ROSE_ALLOC_MEMSET == 3
  136194             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgIorAssignOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  136195             : #endif
  136196             : 
  136197             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  136198             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  136199             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  136200             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  136201             : #else
  136202          14 :     object->p_freepointer = SgIorAssignOp::next_node;
  136203          14 :     SgIorAssignOp::next_node = object;
  136204             : #endif
  136205             : 
  136206             : #if ROSE_ALLOC_TRACE == 2
  136207             : //  printf("SgIorAssignOp::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgIorAssignOp::next_node);
  136208             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  136209             :     Rose::MemPool::snapshot(oss.str());
  136210             :     alloc_trace_cnt++;
  136211             : #endif
  136212             : 
  136213             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  136214             : 
  136215          14 :     ALLOC_MUTEX(SgIorAssignOp, unlock);
  136216             : }
  136217             : 
  136218             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  136219             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  136220             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  136221             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  136222             : // Also, note comment below from Robb (copied from the Common.code file).
  136223             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  136224             : //
  136225             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  136226             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  136227             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  136228             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  136229             : #if 0
  136230             : void SgIorAssignOp::operator delete(void* pointer) { SgIorAssignOp::operator delete (pointer, sizeof(SgIorAssignOp)); };
  136231             : #endif
  136232             : /* #line 136233 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  136233             : 
  136234             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  136235             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  136236             : // obviously imply C++.
  136237             : 
  136238             : // This implements the support within ROSE for memory pools.  Memory pools
  136239             : // support the most condensed usage of memory within the construction of
  136240             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  136241             : // by a new operator written for each class.
  136242             : 
  136243             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  136244             :     // User wants multi-thread support and POSIX threads are available.
  136245             : #   include <pthread.h>
  136246             :     static pthread_mutex_t SgMultAssignOp_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  136247             : #else
  136248             :      // Cause synchronization to be skipped.
  136249             : #    ifndef ALLOC_MUTEX
  136250             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  136251             : #    endif
  136252             : #    ifdef _REENTRANT
  136253             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  136254             : #       ifdef _MSC_VER
  136255             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  136256             : #       else
  136257             : #           warning "POSIX threads are not available; synchronization being skipped"
  136258             : #       endif
  136259             : #    endif
  136260             : #endif
  136261             : 
  136262             : #ifndef ROSE_ALLOC_TRACE
  136263             : #  define ROSE_ALLOC_TRACE 0
  136264             : #endif
  136265             : 
  136266             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  136267             : #define ROSE_ALLOC_TRACE_CNT
  136268             : #include "memory-pool-snapshot.h"
  136269             : unsigned long alloc_trace_cnt = 0;
  136270             : #endif
  136271             : 
  136272             : #if ROSE_ALLOC_TRACE
  136273             : const unsigned SgMultAssignOp::pool_size = 5;
  136274             : #else
  136275             : const unsigned SgMultAssignOp::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  136276             : #endif
  136277             : 
  136278             : #ifndef ROSE_ALLOC_MEMSET
  136279             : #  define ROSE_ALLOC_MEMSET 0
  136280             : #endif
  136281             : 
  136282             : #ifndef ROSE_PEDANTIC_ALLOC
  136283             : #  define ROSE_PEDANTIC_ALLOC 0
  136284             : #endif
  136285             : 
  136286             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  136287             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  136288             : #endif
  136289             : 
  136290             : #if !defined(SGNODE__ALL_POOLS)
  136291             : #define SGNODE__ALL_POOLS
  136292             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  136293             : #endif
  136294             : 
  136295             : SgMultAssignOp* SgMultAssignOp::next_node = nullptr;
  136296             : std::vector<unsigned char*> SgMultAssignOp::pools;
  136297             : 
  136298             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  136299             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  136300             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  136301             : // around this macro definition rather than each use).
  136302             : #ifndef ALLOC_MUTEX
  136303             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  136304             :         do {                                                                     \
  136305             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  136306             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  136307             :                 abort();                                                         \
  136308             :             }                                                                    \
  136309             :         } while (0);
  136310             : #endif
  136311             : 
  136312             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  136313             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  136314             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  136315             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  136316             : 
  136317             : /*! \brief New operator for SgMultAssignOp.
  136318             : 
  136319             :    This new operator implements memory pools to provide most efficent 
  136320             :    use of the heap within construction of large ASTs.
  136321             : 
  136322             : \internal The new and delete operators use the lower level C malloc/free
  136323             :    function calls for performance and to make sure that mixing of malloc/free
  136324             :    and new/delete by the used can be caught more readily.  This may change
  136325             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  136326             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  136327             :    deallocate memory allocated using ROSE_MALLOC.
  136328             : */
  136329          32 : void *SgMultAssignOp::operator new ( size_t Size )
  136330             : {
  136331             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  136332             :      * returning or throwing an exception. */
  136333          32 :     ALLOC_MUTEX(SgMultAssignOp, lock);
  136334             : 
  136335             : #if ROSE_ALLOC_TRACE == 2
  136336             : //    printf("SgMultAssignOp::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgMultAssignOp::next_node);
  136337             : #endif
  136338             : 
  136339             : #if USE_CPP_NEW_DELETE_OPERATORS
  136340             :     void *mem = ROSE_MALLOC(Size);
  136341             :     ALLOC_MUTEX(SgMultAssignOp, unlock);
  136342             :     return mem;
  136343             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  136344             : #if ROSE_PEDANTIC_ALLOC
  136345             :     ROSE_ASSERT(Size == sizeof(SgMultAssignOp));
  136346             : #else
  136347          32 :     if (Size != sizeof(SgMultAssignOp)) {
  136348           0 :       void * object = ROSE_MALLOC(Size);
  136349           0 :       ALLOC_MUTEX(SgMultAssignOp, unlock);
  136350             :       return object;
  136351             :     }
  136352             : #endif
  136353             : 
  136354          32 :     if (SgMultAssignOp::next_node == nullptr) {
  136355          11 :         SgMultAssignOp * alloc = (SgMultAssignOp*) ROSE_MALLOC ( SgMultAssignOp::pool_size * sizeof(SgMultAssignOp) );
  136356          11 :         ROSE_ASSERT(alloc != nullptr);
  136357             : 
  136358             : #if ROSE_ALLOC_TRACE == 2
  136359             : //        printf("SgMultAssignOp::alloc\n  block[%zi] = [ %p , %p [\n", SgMultAssignOp::pools.size(), alloc, alloc + SgMultAssignOp::pool_size);
  136360             : #endif
  136361             : 
  136362             : #if ROSE_ALLOC_MEMSET == 1
  136363             : #elif ROSE_ALLOC_MEMSET == 2
  136364             :         memset(alloc, 0x00, SgMultAssignOp::pool_size * sizeof(SgMultAssignOp));
  136365             : #elif ROSE_ALLOC_MEMSET == 3
  136366             :         memset(alloc, 0xAA, SgMultAssignOp::pool_size * sizeof(SgMultAssignOp));
  136367             : #endif
  136368       22000 :         for (unsigned i=0; i < SgMultAssignOp::pool_size-1; i++) {
  136369       21989 :           alloc[i].p_freepointer = &(alloc[i+1]);
  136370             :         }
  136371          11 :         alloc[SgMultAssignOp::pool_size-1].p_freepointer = nullptr;
  136372             : 
  136373          11 :         SgMultAssignOp::pools.push_back ( (unsigned char *) alloc );
  136374          11 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgMultAssignOp::pool_size * sizeof(SgMultAssignOp), V_SgMultAssignOp ) );
  136375          11 :         SgMultAssignOp::next_node = alloc;
  136376             :     }
  136377          32 :     ROSE_ASSERT(SgMultAssignOp::next_node != nullptr);
  136378             : 
  136379          32 :     SgMultAssignOp * object = SgMultAssignOp::next_node;
  136380          32 :     SgMultAssignOp::next_node = (SgMultAssignOp*)(object->p_freepointer);
  136381             : 
  136382             : #if ROSE_ALLOC_TRACE == 2
  136383             :     printf("SgMultAssignOp::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgMultAssignOp::next_node);
  136384             : #endif
  136385             : 
  136386          32 :     SgNode * fp = object->p_freepointer;
  136387             : #if ROSE_ALLOC_MEMSET == 1
  136388             : #elif ROSE_ALLOC_MEMSET == 2
  136389             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgMultAssignOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  136390             : #elif ROSE_ALLOC_MEMSET == 3
  136391             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgMultAssignOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  136392             : #endif
  136393          32 :     object->p_freepointer = fp;
  136394             : 
  136395             : #if ROSE_ALLOC_TRACE == 2
  136396             : //    printf("SgMultAssignOp::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgMultAssignOp::next_node);
  136397             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  136398             :     Rose::MemPool::snapshot(oss.str());
  136399             :     alloc_trace_cnt++;
  136400             : #endif
  136401             : 
  136402          32 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  136403             : 
  136404          32 :     ALLOC_MUTEX(SgMultAssignOp, unlock);
  136405             : 
  136406             :     return object;
  136407             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  136408             : }
  136409             : 
  136410             : 
  136411             : 
  136412             : /*! \brief Delete operator for SgMultAssignOp.
  136413             : 
  136414             :    This delete operator implements deallocation using memory pools to 
  136415             :    provide most efficent use of the heap within construction of large ASTs.
  136416             : 
  136417             : \internal The new and delete operators use the lower level C malloc/free
  136418             :    function calls for performance and to make sure that mixing of malloc/free
  136419             :    and new/delete by the used can be caught more readily.  This may change
  136420             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  136421             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  136422             :    deallocate memory allocated using ROSE_MALLOC.
  136423             : */
  136424           4 : void SgMultAssignOp::operator delete(void *Pointer, size_t Size)
  136425             : {
  136426             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  136427             :      * or throwing an exception. */
  136428           4 :     ALLOC_MUTEX(SgMultAssignOp, lock);
  136429             : 
  136430             : #if USE_CPP_NEW_DELETE_OPERATORS
  136431             :     ROSE_FREE(Pointer);
  136432             : #else
  136433             : #if ROSE_PEDANTIC_ALLOC
  136434             :     ROSE_ASSERT(Size == sizeof(SgMultAssignOp));
  136435             : #else
  136436           4 :     if (Size != sizeof(SgMultAssignOp)) {
  136437           0 :       ROSE_FREE(Pointer);
  136438           0 :       ALLOC_MUTEX(SgMultAssignOp, unlock);
  136439             :       return;
  136440             :     }
  136441             : #endif
  136442             : 
  136443           4 :     SgMultAssignOp * object = (SgMultAssignOp*) Pointer;
  136444           4 :     ROSE_ASSERT(object != nullptr);
  136445             : 
  136446             : #if ROSE_ALLOC_TRACE == 2
  136447             : //  printf("SgMultAssignOp::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgMultAssignOp::next_node);
  136448             :     printf("SgMultAssignOp::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgMultAssignOp::next_node);
  136449             : #endif
  136450             : 
  136451             : #if ROSE_PEDANTIC_ALLOC
  136452             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  136453             : #endif
  136454             : 
  136455             : #if ROSE_ALLOC_MEMSET == 1
  136456             : #elif ROSE_ALLOC_MEMSET == 2
  136457             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgMultAssignOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  136458             : #elif ROSE_ALLOC_MEMSET == 3
  136459             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgMultAssignOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  136460             : #endif
  136461             : 
  136462             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  136463             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  136464             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  136465             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  136466             : #else
  136467           4 :     object->p_freepointer = SgMultAssignOp::next_node;
  136468           4 :     SgMultAssignOp::next_node = object;
  136469             : #endif
  136470             : 
  136471             : #if ROSE_ALLOC_TRACE == 2
  136472             : //  printf("SgMultAssignOp::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgMultAssignOp::next_node);
  136473             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  136474             :     Rose::MemPool::snapshot(oss.str());
  136475             :     alloc_trace_cnt++;
  136476             : #endif
  136477             : 
  136478             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  136479             : 
  136480           4 :     ALLOC_MUTEX(SgMultAssignOp, unlock);
  136481             : }
  136482             : 
  136483             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  136484             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  136485             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  136486             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  136487             : // Also, note comment below from Robb (copied from the Common.code file).
  136488             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  136489             : //
  136490             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  136491             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  136492             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  136493             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  136494             : #if 0
  136495             : void SgMultAssignOp::operator delete(void* pointer) { SgMultAssignOp::operator delete (pointer, sizeof(SgMultAssignOp)); };
  136496             : #endif
  136497             : /* #line 136498 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  136498             : 
  136499             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  136500             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  136501             : // obviously imply C++.
  136502             : 
  136503             : // This implements the support within ROSE for memory pools.  Memory pools
  136504             : // support the most condensed usage of memory within the construction of
  136505             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  136506             : // by a new operator written for each class.
  136507             : 
  136508             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  136509             :     // User wants multi-thread support and POSIX threads are available.
  136510             : #   include <pthread.h>
  136511             :     static pthread_mutex_t SgDivAssignOp_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  136512             : #else
  136513             :      // Cause synchronization to be skipped.
  136514             : #    ifndef ALLOC_MUTEX
  136515             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  136516             : #    endif
  136517             : #    ifdef _REENTRANT
  136518             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  136519             : #       ifdef _MSC_VER
  136520             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  136521             : #       else
  136522             : #           warning "POSIX threads are not available; synchronization being skipped"
  136523             : #       endif
  136524             : #    endif
  136525             : #endif
  136526             : 
  136527             : #ifndef ROSE_ALLOC_TRACE
  136528             : #  define ROSE_ALLOC_TRACE 0
  136529             : #endif
  136530             : 
  136531             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  136532             : #define ROSE_ALLOC_TRACE_CNT
  136533             : #include "memory-pool-snapshot.h"
  136534             : unsigned long alloc_trace_cnt = 0;
  136535             : #endif
  136536             : 
  136537             : #if ROSE_ALLOC_TRACE
  136538             : const unsigned SgDivAssignOp::pool_size = 5;
  136539             : #else
  136540             : const unsigned SgDivAssignOp::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  136541             : #endif
  136542             : 
  136543             : #ifndef ROSE_ALLOC_MEMSET
  136544             : #  define ROSE_ALLOC_MEMSET 0
  136545             : #endif
  136546             : 
  136547             : #ifndef ROSE_PEDANTIC_ALLOC
  136548             : #  define ROSE_PEDANTIC_ALLOC 0
  136549             : #endif
  136550             : 
  136551             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  136552             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  136553             : #endif
  136554             : 
  136555             : #if !defined(SGNODE__ALL_POOLS)
  136556             : #define SGNODE__ALL_POOLS
  136557             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  136558             : #endif
  136559             : 
  136560             : SgDivAssignOp* SgDivAssignOp::next_node = nullptr;
  136561             : std::vector<unsigned char*> SgDivAssignOp::pools;
  136562             : 
  136563             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  136564             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  136565             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  136566             : // around this macro definition rather than each use).
  136567             : #ifndef ALLOC_MUTEX
  136568             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  136569             :         do {                                                                     \
  136570             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  136571             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  136572             :                 abort();                                                         \
  136573             :             }                                                                    \
  136574             :         } while (0);
  136575             : #endif
  136576             : 
  136577             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  136578             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  136579             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  136580             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  136581             : 
  136582             : /*! \brief New operator for SgDivAssignOp.
  136583             : 
  136584             :    This new operator implements memory pools to provide most efficent 
  136585             :    use of the heap within construction of large ASTs.
  136586             : 
  136587             : \internal The new and delete operators use the lower level C malloc/free
  136588             :    function calls for performance and to make sure that mixing of malloc/free
  136589             :    and new/delete by the used can be caught more readily.  This may change
  136590             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  136591             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  136592             :    deallocate memory allocated using ROSE_MALLOC.
  136593             : */
  136594          10 : void *SgDivAssignOp::operator new ( size_t Size )
  136595             : {
  136596             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  136597             :      * returning or throwing an exception. */
  136598          10 :     ALLOC_MUTEX(SgDivAssignOp, lock);
  136599             : 
  136600             : #if ROSE_ALLOC_TRACE == 2
  136601             : //    printf("SgDivAssignOp::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgDivAssignOp::next_node);
  136602             : #endif
  136603             : 
  136604             : #if USE_CPP_NEW_DELETE_OPERATORS
  136605             :     void *mem = ROSE_MALLOC(Size);
  136606             :     ALLOC_MUTEX(SgDivAssignOp, unlock);
  136607             :     return mem;
  136608             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  136609             : #if ROSE_PEDANTIC_ALLOC
  136610             :     ROSE_ASSERT(Size == sizeof(SgDivAssignOp));
  136611             : #else
  136612          10 :     if (Size != sizeof(SgDivAssignOp)) {
  136613           0 :       void * object = ROSE_MALLOC(Size);
  136614           0 :       ALLOC_MUTEX(SgDivAssignOp, unlock);
  136615             :       return object;
  136616             :     }
  136617             : #endif
  136618             : 
  136619          10 :     if (SgDivAssignOp::next_node == nullptr) {
  136620           9 :         SgDivAssignOp * alloc = (SgDivAssignOp*) ROSE_MALLOC ( SgDivAssignOp::pool_size * sizeof(SgDivAssignOp) );
  136621           9 :         ROSE_ASSERT(alloc != nullptr);
  136622             : 
  136623             : #if ROSE_ALLOC_TRACE == 2
  136624             : //        printf("SgDivAssignOp::alloc\n  block[%zi] = [ %p , %p [\n", SgDivAssignOp::pools.size(), alloc, alloc + SgDivAssignOp::pool_size);
  136625             : #endif
  136626             : 
  136627             : #if ROSE_ALLOC_MEMSET == 1
  136628             : #elif ROSE_ALLOC_MEMSET == 2
  136629             :         memset(alloc, 0x00, SgDivAssignOp::pool_size * sizeof(SgDivAssignOp));
  136630             : #elif ROSE_ALLOC_MEMSET == 3
  136631             :         memset(alloc, 0xAA, SgDivAssignOp::pool_size * sizeof(SgDivAssignOp));
  136632             : #endif
  136633       18000 :         for (unsigned i=0; i < SgDivAssignOp::pool_size-1; i++) {
  136634       17991 :           alloc[i].p_freepointer = &(alloc[i+1]);
  136635             :         }
  136636           9 :         alloc[SgDivAssignOp::pool_size-1].p_freepointer = nullptr;
  136637             : 
  136638           9 :         SgDivAssignOp::pools.push_back ( (unsigned char *) alloc );
  136639           9 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgDivAssignOp::pool_size * sizeof(SgDivAssignOp), V_SgDivAssignOp ) );
  136640           9 :         SgDivAssignOp::next_node = alloc;
  136641             :     }
  136642          10 :     ROSE_ASSERT(SgDivAssignOp::next_node != nullptr);
  136643             : 
  136644          10 :     SgDivAssignOp * object = SgDivAssignOp::next_node;
  136645          10 :     SgDivAssignOp::next_node = (SgDivAssignOp*)(object->p_freepointer);
  136646             : 
  136647             : #if ROSE_ALLOC_TRACE == 2
  136648             :     printf("SgDivAssignOp::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgDivAssignOp::next_node);
  136649             : #endif
  136650             : 
  136651          10 :     SgNode * fp = object->p_freepointer;
  136652             : #if ROSE_ALLOC_MEMSET == 1
  136653             : #elif ROSE_ALLOC_MEMSET == 2
  136654             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgDivAssignOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  136655             : #elif ROSE_ALLOC_MEMSET == 3
  136656             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgDivAssignOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  136657             : #endif
  136658          10 :     object->p_freepointer = fp;
  136659             : 
  136660             : #if ROSE_ALLOC_TRACE == 2
  136661             : //    printf("SgDivAssignOp::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgDivAssignOp::next_node);
  136662             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  136663             :     Rose::MemPool::snapshot(oss.str());
  136664             :     alloc_trace_cnt++;
  136665             : #endif
  136666             : 
  136667          10 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  136668             : 
  136669          10 :     ALLOC_MUTEX(SgDivAssignOp, unlock);
  136670             : 
  136671             :     return object;
  136672             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  136673             : }
  136674             : 
  136675             : 
  136676             : 
  136677             : /*! \brief Delete operator for SgDivAssignOp.
  136678             : 
  136679             :    This delete operator implements deallocation using memory pools to 
  136680             :    provide most efficent use of the heap within construction of large ASTs.
  136681             : 
  136682             : \internal The new and delete operators use the lower level C malloc/free
  136683             :    function calls for performance and to make sure that mixing of malloc/free
  136684             :    and new/delete by the used can be caught more readily.  This may change
  136685             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  136686             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  136687             :    deallocate memory allocated using ROSE_MALLOC.
  136688             : */
  136689           2 : void SgDivAssignOp::operator delete(void *Pointer, size_t Size)
  136690             : {
  136691             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  136692             :      * or throwing an exception. */
  136693           2 :     ALLOC_MUTEX(SgDivAssignOp, lock);
  136694             : 
  136695             : #if USE_CPP_NEW_DELETE_OPERATORS
  136696             :     ROSE_FREE(Pointer);
  136697             : #else
  136698             : #if ROSE_PEDANTIC_ALLOC
  136699             :     ROSE_ASSERT(Size == sizeof(SgDivAssignOp));
  136700             : #else
  136701           2 :     if (Size != sizeof(SgDivAssignOp)) {
  136702           0 :       ROSE_FREE(Pointer);
  136703           0 :       ALLOC_MUTEX(SgDivAssignOp, unlock);
  136704             :       return;
  136705             :     }
  136706             : #endif
  136707             : 
  136708           2 :     SgDivAssignOp * object = (SgDivAssignOp*) Pointer;
  136709           2 :     ROSE_ASSERT(object != nullptr);
  136710             : 
  136711             : #if ROSE_ALLOC_TRACE == 2
  136712             : //  printf("SgDivAssignOp::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgDivAssignOp::next_node);
  136713             :     printf("SgDivAssignOp::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgDivAssignOp::next_node);
  136714             : #endif
  136715             : 
  136716             : #if ROSE_PEDANTIC_ALLOC
  136717             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  136718             : #endif
  136719             : 
  136720             : #if ROSE_ALLOC_MEMSET == 1
  136721             : #elif ROSE_ALLOC_MEMSET == 2
  136722             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgDivAssignOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  136723             : #elif ROSE_ALLOC_MEMSET == 3
  136724             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgDivAssignOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  136725             : #endif
  136726             : 
  136727             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  136728             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  136729             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  136730             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  136731             : #else
  136732           2 :     object->p_freepointer = SgDivAssignOp::next_node;
  136733           2 :     SgDivAssignOp::next_node = object;
  136734             : #endif
  136735             : 
  136736             : #if ROSE_ALLOC_TRACE == 2
  136737             : //  printf("SgDivAssignOp::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgDivAssignOp::next_node);
  136738             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  136739             :     Rose::MemPool::snapshot(oss.str());
  136740             :     alloc_trace_cnt++;
  136741             : #endif
  136742             : 
  136743             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  136744             : 
  136745           2 :     ALLOC_MUTEX(SgDivAssignOp, unlock);
  136746             : }
  136747             : 
  136748             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  136749             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  136750             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  136751             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  136752             : // Also, note comment below from Robb (copied from the Common.code file).
  136753             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  136754             : //
  136755             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  136756             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  136757             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  136758             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  136759             : #if 0
  136760             : void SgDivAssignOp::operator delete(void* pointer) { SgDivAssignOp::operator delete (pointer, sizeof(SgDivAssignOp)); };
  136761             : #endif
  136762             : /* #line 136763 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  136763             : 
  136764             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  136765             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  136766             : // obviously imply C++.
  136767             : 
  136768             : // This implements the support within ROSE for memory pools.  Memory pools
  136769             : // support the most condensed usage of memory within the construction of
  136770             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  136771             : // by a new operator written for each class.
  136772             : 
  136773             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  136774             :     // User wants multi-thread support and POSIX threads are available.
  136775             : #   include <pthread.h>
  136776             :     static pthread_mutex_t SgModAssignOp_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  136777             : #else
  136778             :      // Cause synchronization to be skipped.
  136779             : #    ifndef ALLOC_MUTEX
  136780             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  136781             : #    endif
  136782             : #    ifdef _REENTRANT
  136783             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  136784             : #       ifdef _MSC_VER
  136785             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  136786             : #       else
  136787             : #           warning "POSIX threads are not available; synchronization being skipped"
  136788             : #       endif
  136789             : #    endif
  136790             : #endif
  136791             : 
  136792             : #ifndef ROSE_ALLOC_TRACE
  136793             : #  define ROSE_ALLOC_TRACE 0
  136794             : #endif
  136795             : 
  136796             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  136797             : #define ROSE_ALLOC_TRACE_CNT
  136798             : #include "memory-pool-snapshot.h"
  136799             : unsigned long alloc_trace_cnt = 0;
  136800             : #endif
  136801             : 
  136802             : #if ROSE_ALLOC_TRACE
  136803             : const unsigned SgModAssignOp::pool_size = 5;
  136804             : #else
  136805             : const unsigned SgModAssignOp::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  136806             : #endif
  136807             : 
  136808             : #ifndef ROSE_ALLOC_MEMSET
  136809             : #  define ROSE_ALLOC_MEMSET 0
  136810             : #endif
  136811             : 
  136812             : #ifndef ROSE_PEDANTIC_ALLOC
  136813             : #  define ROSE_PEDANTIC_ALLOC 0
  136814             : #endif
  136815             : 
  136816             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  136817             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  136818             : #endif
  136819             : 
  136820             : #if !defined(SGNODE__ALL_POOLS)
  136821             : #define SGNODE__ALL_POOLS
  136822             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  136823             : #endif
  136824             : 
  136825             : SgModAssignOp* SgModAssignOp::next_node = nullptr;
  136826             : std::vector<unsigned char*> SgModAssignOp::pools;
  136827             : 
  136828             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  136829             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  136830             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  136831             : // around this macro definition rather than each use).
  136832             : #ifndef ALLOC_MUTEX
  136833             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  136834             :         do {                                                                     \
  136835             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  136836             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  136837             :                 abort();                                                         \
  136838             :             }                                                                    \
  136839             :         } while (0);
  136840             : #endif
  136841             : 
  136842             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  136843             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  136844             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  136845             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  136846             : 
  136847             : /*! \brief New operator for SgModAssignOp.
  136848             : 
  136849             :    This new operator implements memory pools to provide most efficent 
  136850             :    use of the heap within construction of large ASTs.
  136851             : 
  136852             : \internal The new and delete operators use the lower level C malloc/free
  136853             :    function calls for performance and to make sure that mixing of malloc/free
  136854             :    and new/delete by the used can be caught more readily.  This may change
  136855             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  136856             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  136857             :    deallocate memory allocated using ROSE_MALLOC.
  136858             : */
  136859           0 : void *SgModAssignOp::operator new ( size_t Size )
  136860             : {
  136861             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  136862             :      * returning or throwing an exception. */
  136863           0 :     ALLOC_MUTEX(SgModAssignOp, lock);
  136864             : 
  136865             : #if ROSE_ALLOC_TRACE == 2
  136866             : //    printf("SgModAssignOp::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgModAssignOp::next_node);
  136867             : #endif
  136868             : 
  136869             : #if USE_CPP_NEW_DELETE_OPERATORS
  136870             :     void *mem = ROSE_MALLOC(Size);
  136871             :     ALLOC_MUTEX(SgModAssignOp, unlock);
  136872             :     return mem;
  136873             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  136874             : #if ROSE_PEDANTIC_ALLOC
  136875             :     ROSE_ASSERT(Size == sizeof(SgModAssignOp));
  136876             : #else
  136877           0 :     if (Size != sizeof(SgModAssignOp)) {
  136878           0 :       void * object = ROSE_MALLOC(Size);
  136879           0 :       ALLOC_MUTEX(SgModAssignOp, unlock);
  136880             :       return object;
  136881             :     }
  136882             : #endif
  136883             : 
  136884           0 :     if (SgModAssignOp::next_node == nullptr) {
  136885           0 :         SgModAssignOp * alloc = (SgModAssignOp*) ROSE_MALLOC ( SgModAssignOp::pool_size * sizeof(SgModAssignOp) );
  136886           0 :         ROSE_ASSERT(alloc != nullptr);
  136887             : 
  136888             : #if ROSE_ALLOC_TRACE == 2
  136889             : //        printf("SgModAssignOp::alloc\n  block[%zi] = [ %p , %p [\n", SgModAssignOp::pools.size(), alloc, alloc + SgModAssignOp::pool_size);
  136890             : #endif
  136891             : 
  136892             : #if ROSE_ALLOC_MEMSET == 1
  136893             : #elif ROSE_ALLOC_MEMSET == 2
  136894             :         memset(alloc, 0x00, SgModAssignOp::pool_size * sizeof(SgModAssignOp));
  136895             : #elif ROSE_ALLOC_MEMSET == 3
  136896             :         memset(alloc, 0xAA, SgModAssignOp::pool_size * sizeof(SgModAssignOp));
  136897             : #endif
  136898           0 :         for (unsigned i=0; i < SgModAssignOp::pool_size-1; i++) {
  136899           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
  136900             :         }
  136901           0 :         alloc[SgModAssignOp::pool_size-1].p_freepointer = nullptr;
  136902             : 
  136903           0 :         SgModAssignOp::pools.push_back ( (unsigned char *) alloc );
  136904           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgModAssignOp::pool_size * sizeof(SgModAssignOp), V_SgModAssignOp ) );
  136905           0 :         SgModAssignOp::next_node = alloc;
  136906             :     }
  136907           0 :     ROSE_ASSERT(SgModAssignOp::next_node != nullptr);
  136908             : 
  136909           0 :     SgModAssignOp * object = SgModAssignOp::next_node;
  136910           0 :     SgModAssignOp::next_node = (SgModAssignOp*)(object->p_freepointer);
  136911             : 
  136912             : #if ROSE_ALLOC_TRACE == 2
  136913             :     printf("SgModAssignOp::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgModAssignOp::next_node);
  136914             : #endif
  136915             : 
  136916           0 :     SgNode * fp = object->p_freepointer;
  136917             : #if ROSE_ALLOC_MEMSET == 1
  136918             : #elif ROSE_ALLOC_MEMSET == 2
  136919             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgModAssignOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  136920             : #elif ROSE_ALLOC_MEMSET == 3
  136921             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgModAssignOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  136922             : #endif
  136923           0 :     object->p_freepointer = fp;
  136924             : 
  136925             : #if ROSE_ALLOC_TRACE == 2
  136926             : //    printf("SgModAssignOp::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgModAssignOp::next_node);
  136927             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  136928             :     Rose::MemPool::snapshot(oss.str());
  136929             :     alloc_trace_cnt++;
  136930             : #endif
  136931             : 
  136932           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  136933             : 
  136934           0 :     ALLOC_MUTEX(SgModAssignOp, unlock);
  136935             : 
  136936             :     return object;
  136937             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  136938             : }
  136939             : 
  136940             : 
  136941             : 
  136942             : /*! \brief Delete operator for SgModAssignOp.
  136943             : 
  136944             :    This delete operator implements deallocation using memory pools to 
  136945             :    provide most efficent use of the heap within construction of large ASTs.
  136946             : 
  136947             : \internal The new and delete operators use the lower level C malloc/free
  136948             :    function calls for performance and to make sure that mixing of malloc/free
  136949             :    and new/delete by the used can be caught more readily.  This may change
  136950             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  136951             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  136952             :    deallocate memory allocated using ROSE_MALLOC.
  136953             : */
  136954           0 : void SgModAssignOp::operator delete(void *Pointer, size_t Size)
  136955             : {
  136956             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  136957             :      * or throwing an exception. */
  136958           0 :     ALLOC_MUTEX(SgModAssignOp, lock);
  136959             : 
  136960             : #if USE_CPP_NEW_DELETE_OPERATORS
  136961             :     ROSE_FREE(Pointer);
  136962             : #else
  136963             : #if ROSE_PEDANTIC_ALLOC
  136964             :     ROSE_ASSERT(Size == sizeof(SgModAssignOp));
  136965             : #else
  136966           0 :     if (Size != sizeof(SgModAssignOp)) {
  136967           0 :       ROSE_FREE(Pointer);
  136968           0 :       ALLOC_MUTEX(SgModAssignOp, unlock);
  136969             :       return;
  136970             :     }
  136971             : #endif
  136972             : 
  136973           0 :     SgModAssignOp * object = (SgModAssignOp*) Pointer;
  136974           0 :     ROSE_ASSERT(object != nullptr);
  136975             : 
  136976             : #if ROSE_ALLOC_TRACE == 2
  136977             : //  printf("SgModAssignOp::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgModAssignOp::next_node);
  136978             :     printf("SgModAssignOp::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgModAssignOp::next_node);
  136979             : #endif
  136980             : 
  136981             : #if ROSE_PEDANTIC_ALLOC
  136982             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  136983             : #endif
  136984             : 
  136985             : #if ROSE_ALLOC_MEMSET == 1
  136986             : #elif ROSE_ALLOC_MEMSET == 2
  136987             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgModAssignOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  136988             : #elif ROSE_ALLOC_MEMSET == 3
  136989             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgModAssignOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  136990             : #endif
  136991             : 
  136992             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  136993             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  136994             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  136995             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  136996             : #else
  136997           0 :     object->p_freepointer = SgModAssignOp::next_node;
  136998           0 :     SgModAssignOp::next_node = object;
  136999             : #endif
  137000             : 
  137001             : #if ROSE_ALLOC_TRACE == 2
  137002             : //  printf("SgModAssignOp::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgModAssignOp::next_node);
  137003             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  137004             :     Rose::MemPool::snapshot(oss.str());
  137005             :     alloc_trace_cnt++;
  137006             : #endif
  137007             : 
  137008             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  137009             : 
  137010           0 :     ALLOC_MUTEX(SgModAssignOp, unlock);
  137011             : }
  137012             : 
  137013             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  137014             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  137015             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  137016             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  137017             : // Also, note comment below from Robb (copied from the Common.code file).
  137018             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  137019             : //
  137020             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  137021             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  137022             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  137023             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  137024             : #if 0
  137025             : void SgModAssignOp::operator delete(void* pointer) { SgModAssignOp::operator delete (pointer, sizeof(SgModAssignOp)); };
  137026             : #endif
  137027             : /* #line 137028 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  137028             : 
  137029             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  137030             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  137031             : // obviously imply C++.
  137032             : 
  137033             : // This implements the support within ROSE for memory pools.  Memory pools
  137034             : // support the most condensed usage of memory within the construction of
  137035             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  137036             : // by a new operator written for each class.
  137037             : 
  137038             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  137039             :     // User wants multi-thread support and POSIX threads are available.
  137040             : #   include <pthread.h>
  137041             :     static pthread_mutex_t SgXorAssignOp_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  137042             : #else
  137043             :      // Cause synchronization to be skipped.
  137044             : #    ifndef ALLOC_MUTEX
  137045             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  137046             : #    endif
  137047             : #    ifdef _REENTRANT
  137048             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  137049             : #       ifdef _MSC_VER
  137050             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  137051             : #       else
  137052             : #           warning "POSIX threads are not available; synchronization being skipped"
  137053             : #       endif
  137054             : #    endif
  137055             : #endif
  137056             : 
  137057             : #ifndef ROSE_ALLOC_TRACE
  137058             : #  define ROSE_ALLOC_TRACE 0
  137059             : #endif
  137060             : 
  137061             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  137062             : #define ROSE_ALLOC_TRACE_CNT
  137063             : #include "memory-pool-snapshot.h"
  137064             : unsigned long alloc_trace_cnt = 0;
  137065             : #endif
  137066             : 
  137067             : #if ROSE_ALLOC_TRACE
  137068             : const unsigned SgXorAssignOp::pool_size = 5;
  137069             : #else
  137070             : const unsigned SgXorAssignOp::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  137071             : #endif
  137072             : 
  137073             : #ifndef ROSE_ALLOC_MEMSET
  137074             : #  define ROSE_ALLOC_MEMSET 0
  137075             : #endif
  137076             : 
  137077             : #ifndef ROSE_PEDANTIC_ALLOC
  137078             : #  define ROSE_PEDANTIC_ALLOC 0
  137079             : #endif
  137080             : 
  137081             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  137082             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  137083             : #endif
  137084             : 
  137085             : #if !defined(SGNODE__ALL_POOLS)
  137086             : #define SGNODE__ALL_POOLS
  137087             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  137088             : #endif
  137089             : 
  137090             : SgXorAssignOp* SgXorAssignOp::next_node = nullptr;
  137091             : std::vector<unsigned char*> SgXorAssignOp::pools;
  137092             : 
  137093             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  137094             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  137095             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  137096             : // around this macro definition rather than each use).
  137097             : #ifndef ALLOC_MUTEX
  137098             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  137099             :         do {                                                                     \
  137100             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  137101             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  137102             :                 abort();                                                         \
  137103             :             }                                                                    \
  137104             :         } while (0);
  137105             : #endif
  137106             : 
  137107             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  137108             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  137109             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  137110             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  137111             : 
  137112             : /*! \brief New operator for SgXorAssignOp.
  137113             : 
  137114             :    This new operator implements memory pools to provide most efficent 
  137115             :    use of the heap within construction of large ASTs.
  137116             : 
  137117             : \internal The new and delete operators use the lower level C malloc/free
  137118             :    function calls for performance and to make sure that mixing of malloc/free
  137119             :    and new/delete by the used can be caught more readily.  This may change
  137120             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  137121             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  137122             :    deallocate memory allocated using ROSE_MALLOC.
  137123             : */
  137124           3 : void *SgXorAssignOp::operator new ( size_t Size )
  137125             : {
  137126             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  137127             :      * returning or throwing an exception. */
  137128           3 :     ALLOC_MUTEX(SgXorAssignOp, lock);
  137129             : 
  137130             : #if ROSE_ALLOC_TRACE == 2
  137131             : //    printf("SgXorAssignOp::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgXorAssignOp::next_node);
  137132             : #endif
  137133             : 
  137134             : #if USE_CPP_NEW_DELETE_OPERATORS
  137135             :     void *mem = ROSE_MALLOC(Size);
  137136             :     ALLOC_MUTEX(SgXorAssignOp, unlock);
  137137             :     return mem;
  137138             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  137139             : #if ROSE_PEDANTIC_ALLOC
  137140             :     ROSE_ASSERT(Size == sizeof(SgXorAssignOp));
  137141             : #else
  137142           3 :     if (Size != sizeof(SgXorAssignOp)) {
  137143           0 :       void * object = ROSE_MALLOC(Size);
  137144           0 :       ALLOC_MUTEX(SgXorAssignOp, unlock);
  137145             :       return object;
  137146             :     }
  137147             : #endif
  137148             : 
  137149           3 :     if (SgXorAssignOp::next_node == nullptr) {
  137150           3 :         SgXorAssignOp * alloc = (SgXorAssignOp*) ROSE_MALLOC ( SgXorAssignOp::pool_size * sizeof(SgXorAssignOp) );
  137151           3 :         ROSE_ASSERT(alloc != nullptr);
  137152             : 
  137153             : #if ROSE_ALLOC_TRACE == 2
  137154             : //        printf("SgXorAssignOp::alloc\n  block[%zi] = [ %p , %p [\n", SgXorAssignOp::pools.size(), alloc, alloc + SgXorAssignOp::pool_size);
  137155             : #endif
  137156             : 
  137157             : #if ROSE_ALLOC_MEMSET == 1
  137158             : #elif ROSE_ALLOC_MEMSET == 2
  137159             :         memset(alloc, 0x00, SgXorAssignOp::pool_size * sizeof(SgXorAssignOp));
  137160             : #elif ROSE_ALLOC_MEMSET == 3
  137161             :         memset(alloc, 0xAA, SgXorAssignOp::pool_size * sizeof(SgXorAssignOp));
  137162             : #endif
  137163        6000 :         for (unsigned i=0; i < SgXorAssignOp::pool_size-1; i++) {
  137164        5997 :           alloc[i].p_freepointer = &(alloc[i+1]);
  137165             :         }
  137166           3 :         alloc[SgXorAssignOp::pool_size-1].p_freepointer = nullptr;
  137167             : 
  137168           3 :         SgXorAssignOp::pools.push_back ( (unsigned char *) alloc );
  137169           3 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgXorAssignOp::pool_size * sizeof(SgXorAssignOp), V_SgXorAssignOp ) );
  137170           3 :         SgXorAssignOp::next_node = alloc;
  137171             :     }
  137172           3 :     ROSE_ASSERT(SgXorAssignOp::next_node != nullptr);
  137173             : 
  137174           3 :     SgXorAssignOp * object = SgXorAssignOp::next_node;
  137175           3 :     SgXorAssignOp::next_node = (SgXorAssignOp*)(object->p_freepointer);
  137176             : 
  137177             : #if ROSE_ALLOC_TRACE == 2
  137178             :     printf("SgXorAssignOp::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgXorAssignOp::next_node);
  137179             : #endif
  137180             : 
  137181           3 :     SgNode * fp = object->p_freepointer;
  137182             : #if ROSE_ALLOC_MEMSET == 1
  137183             : #elif ROSE_ALLOC_MEMSET == 2
  137184             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgXorAssignOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  137185             : #elif ROSE_ALLOC_MEMSET == 3
  137186             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgXorAssignOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  137187             : #endif
  137188           3 :     object->p_freepointer = fp;
  137189             : 
  137190             : #if ROSE_ALLOC_TRACE == 2
  137191             : //    printf("SgXorAssignOp::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgXorAssignOp::next_node);
  137192             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  137193             :     Rose::MemPool::snapshot(oss.str());
  137194             :     alloc_trace_cnt++;
  137195             : #endif
  137196             : 
  137197           3 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  137198             : 
  137199           3 :     ALLOC_MUTEX(SgXorAssignOp, unlock);
  137200             : 
  137201             :     return object;
  137202             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  137203             : }
  137204             : 
  137205             : 
  137206             : 
  137207             : /*! \brief Delete operator for SgXorAssignOp.
  137208             : 
  137209             :    This delete operator implements deallocation using memory pools to 
  137210             :    provide most efficent use of the heap within construction of large ASTs.
  137211             : 
  137212             : \internal The new and delete operators use the lower level C malloc/free
  137213             :    function calls for performance and to make sure that mixing of malloc/free
  137214             :    and new/delete by the used can be caught more readily.  This may change
  137215             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  137216             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  137217             :    deallocate memory allocated using ROSE_MALLOC.
  137218             : */
  137219           0 : void SgXorAssignOp::operator delete(void *Pointer, size_t Size)
  137220             : {
  137221             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  137222             :      * or throwing an exception. */
  137223           0 :     ALLOC_MUTEX(SgXorAssignOp, lock);
  137224             : 
  137225             : #if USE_CPP_NEW_DELETE_OPERATORS
  137226             :     ROSE_FREE(Pointer);
  137227             : #else
  137228             : #if ROSE_PEDANTIC_ALLOC
  137229             :     ROSE_ASSERT(Size == sizeof(SgXorAssignOp));
  137230             : #else
  137231           0 :     if (Size != sizeof(SgXorAssignOp)) {
  137232           0 :       ROSE_FREE(Pointer);
  137233           0 :       ALLOC_MUTEX(SgXorAssignOp, unlock);
  137234             :       return;
  137235             :     }
  137236             : #endif
  137237             : 
  137238           0 :     SgXorAssignOp * object = (SgXorAssignOp*) Pointer;
  137239           0 :     ROSE_ASSERT(object != nullptr);
  137240             : 
  137241             : #if ROSE_ALLOC_TRACE == 2
  137242             : //  printf("SgXorAssignOp::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgXorAssignOp::next_node);
  137243             :     printf("SgXorAssignOp::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgXorAssignOp::next_node);
  137244             : #endif
  137245             : 
  137246             : #if ROSE_PEDANTIC_ALLOC
  137247             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  137248             : #endif
  137249             : 
  137250             : #if ROSE_ALLOC_MEMSET == 1
  137251             : #elif ROSE_ALLOC_MEMSET == 2
  137252             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgXorAssignOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  137253             : #elif ROSE_ALLOC_MEMSET == 3
  137254             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgXorAssignOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  137255             : #endif
  137256             : 
  137257             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  137258             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  137259             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  137260             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  137261             : #else
  137262           0 :     object->p_freepointer = SgXorAssignOp::next_node;
  137263           0 :     SgXorAssignOp::next_node = object;
  137264             : #endif
  137265             : 
  137266             : #if ROSE_ALLOC_TRACE == 2
  137267             : //  printf("SgXorAssignOp::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgXorAssignOp::next_node);
  137268             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  137269             :     Rose::MemPool::snapshot(oss.str());
  137270             :     alloc_trace_cnt++;
  137271             : #endif
  137272             : 
  137273             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  137274             : 
  137275           0 :     ALLOC_MUTEX(SgXorAssignOp, unlock);
  137276             : }
  137277             : 
  137278             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  137279             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  137280             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  137281             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  137282             : // Also, note comment below from Robb (copied from the Common.code file).
  137283             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  137284             : //
  137285             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  137286             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  137287             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  137288             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  137289             : #if 0
  137290             : void SgXorAssignOp::operator delete(void* pointer) { SgXorAssignOp::operator delete (pointer, sizeof(SgXorAssignOp)); };
  137291             : #endif
  137292             : /* #line 137293 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  137293             : 
  137294             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  137295             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  137296             : // obviously imply C++.
  137297             : 
  137298             : // This implements the support within ROSE for memory pools.  Memory pools
  137299             : // support the most condensed usage of memory within the construction of
  137300             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  137301             : // by a new operator written for each class.
  137302             : 
  137303             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  137304             :     // User wants multi-thread support and POSIX threads are available.
  137305             : #   include <pthread.h>
  137306             :     static pthread_mutex_t SgLshiftAssignOp_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  137307             : #else
  137308             :      // Cause synchronization to be skipped.
  137309             : #    ifndef ALLOC_MUTEX
  137310             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  137311             : #    endif
  137312             : #    ifdef _REENTRANT
  137313             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  137314             : #       ifdef _MSC_VER
  137315             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  137316             : #       else
  137317             : #           warning "POSIX threads are not available; synchronization being skipped"
  137318             : #       endif
  137319             : #    endif
  137320             : #endif
  137321             : 
  137322             : #ifndef ROSE_ALLOC_TRACE
  137323             : #  define ROSE_ALLOC_TRACE 0
  137324             : #endif
  137325             : 
  137326             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  137327             : #define ROSE_ALLOC_TRACE_CNT
  137328             : #include "memory-pool-snapshot.h"
  137329             : unsigned long alloc_trace_cnt = 0;
  137330             : #endif
  137331             : 
  137332             : #if ROSE_ALLOC_TRACE
  137333             : const unsigned SgLshiftAssignOp::pool_size = 5;
  137334             : #else
  137335             : const unsigned SgLshiftAssignOp::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  137336             : #endif
  137337             : 
  137338             : #ifndef ROSE_ALLOC_MEMSET
  137339             : #  define ROSE_ALLOC_MEMSET 0
  137340             : #endif
  137341             : 
  137342             : #ifndef ROSE_PEDANTIC_ALLOC
  137343             : #  define ROSE_PEDANTIC_ALLOC 0
  137344             : #endif
  137345             : 
  137346             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  137347             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  137348             : #endif
  137349             : 
  137350             : #if !defined(SGNODE__ALL_POOLS)
  137351             : #define SGNODE__ALL_POOLS
  137352             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  137353             : #endif
  137354             : 
  137355             : SgLshiftAssignOp* SgLshiftAssignOp::next_node = nullptr;
  137356             : std::vector<unsigned char*> SgLshiftAssignOp::pools;
  137357             : 
  137358             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  137359             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  137360             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  137361             : // around this macro definition rather than each use).
  137362             : #ifndef ALLOC_MUTEX
  137363             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  137364             :         do {                                                                     \
  137365             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  137366             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  137367             :                 abort();                                                         \
  137368             :             }                                                                    \
  137369             :         } while (0);
  137370             : #endif
  137371             : 
  137372             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  137373             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  137374             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  137375             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  137376             : 
  137377             : /*! \brief New operator for SgLshiftAssignOp.
  137378             : 
  137379             :    This new operator implements memory pools to provide most efficent 
  137380             :    use of the heap within construction of large ASTs.
  137381             : 
  137382             : \internal The new and delete operators use the lower level C malloc/free
  137383             :    function calls for performance and to make sure that mixing of malloc/free
  137384             :    and new/delete by the used can be caught more readily.  This may change
  137385             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  137386             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  137387             :    deallocate memory allocated using ROSE_MALLOC.
  137388             : */
  137389           0 : void *SgLshiftAssignOp::operator new ( size_t Size )
  137390             : {
  137391             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  137392             :      * returning or throwing an exception. */
  137393           0 :     ALLOC_MUTEX(SgLshiftAssignOp, lock);
  137394             : 
  137395             : #if ROSE_ALLOC_TRACE == 2
  137396             : //    printf("SgLshiftAssignOp::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgLshiftAssignOp::next_node);
  137397             : #endif
  137398             : 
  137399             : #if USE_CPP_NEW_DELETE_OPERATORS
  137400             :     void *mem = ROSE_MALLOC(Size);
  137401             :     ALLOC_MUTEX(SgLshiftAssignOp, unlock);
  137402             :     return mem;
  137403             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  137404             : #if ROSE_PEDANTIC_ALLOC
  137405             :     ROSE_ASSERT(Size == sizeof(SgLshiftAssignOp));
  137406             : #else
  137407           0 :     if (Size != sizeof(SgLshiftAssignOp)) {
  137408           0 :       void * object = ROSE_MALLOC(Size);
  137409           0 :       ALLOC_MUTEX(SgLshiftAssignOp, unlock);
  137410             :       return object;
  137411             :     }
  137412             : #endif
  137413             : 
  137414           0 :     if (SgLshiftAssignOp::next_node == nullptr) {
  137415           0 :         SgLshiftAssignOp * alloc = (SgLshiftAssignOp*) ROSE_MALLOC ( SgLshiftAssignOp::pool_size * sizeof(SgLshiftAssignOp) );
  137416           0 :         ROSE_ASSERT(alloc != nullptr);
  137417             : 
  137418             : #if ROSE_ALLOC_TRACE == 2
  137419             : //        printf("SgLshiftAssignOp::alloc\n  block[%zi] = [ %p , %p [\n", SgLshiftAssignOp::pools.size(), alloc, alloc + SgLshiftAssignOp::pool_size);
  137420             : #endif
  137421             : 
  137422             : #if ROSE_ALLOC_MEMSET == 1
  137423             : #elif ROSE_ALLOC_MEMSET == 2
  137424             :         memset(alloc, 0x00, SgLshiftAssignOp::pool_size * sizeof(SgLshiftAssignOp));
  137425             : #elif ROSE_ALLOC_MEMSET == 3
  137426             :         memset(alloc, 0xAA, SgLshiftAssignOp::pool_size * sizeof(SgLshiftAssignOp));
  137427             : #endif
  137428           0 :         for (unsigned i=0; i < SgLshiftAssignOp::pool_size-1; i++) {
  137429           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
  137430             :         }
  137431           0 :         alloc[SgLshiftAssignOp::pool_size-1].p_freepointer = nullptr;
  137432             : 
  137433           0 :         SgLshiftAssignOp::pools.push_back ( (unsigned char *) alloc );
  137434           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgLshiftAssignOp::pool_size * sizeof(SgLshiftAssignOp), V_SgLshiftAssignOp ) );
  137435           0 :         SgLshiftAssignOp::next_node = alloc;
  137436             :     }
  137437           0 :     ROSE_ASSERT(SgLshiftAssignOp::next_node != nullptr);
  137438             : 
  137439           0 :     SgLshiftAssignOp * object = SgLshiftAssignOp::next_node;
  137440           0 :     SgLshiftAssignOp::next_node = (SgLshiftAssignOp*)(object->p_freepointer);
  137441             : 
  137442             : #if ROSE_ALLOC_TRACE == 2
  137443             :     printf("SgLshiftAssignOp::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgLshiftAssignOp::next_node);
  137444             : #endif
  137445             : 
  137446           0 :     SgNode * fp = object->p_freepointer;
  137447             : #if ROSE_ALLOC_MEMSET == 1
  137448             : #elif ROSE_ALLOC_MEMSET == 2
  137449             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgLshiftAssignOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  137450             : #elif ROSE_ALLOC_MEMSET == 3
  137451             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgLshiftAssignOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  137452             : #endif
  137453           0 :     object->p_freepointer = fp;
  137454             : 
  137455             : #if ROSE_ALLOC_TRACE == 2
  137456             : //    printf("SgLshiftAssignOp::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgLshiftAssignOp::next_node);
  137457             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  137458             :     Rose::MemPool::snapshot(oss.str());
  137459             :     alloc_trace_cnt++;
  137460             : #endif
  137461             : 
  137462           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  137463             : 
  137464           0 :     ALLOC_MUTEX(SgLshiftAssignOp, unlock);
  137465             : 
  137466             :     return object;
  137467             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  137468             : }
  137469             : 
  137470             : 
  137471             : 
  137472             : /*! \brief Delete operator for SgLshiftAssignOp.
  137473             : 
  137474             :    This delete operator implements deallocation using memory pools to 
  137475             :    provide most efficent use of the heap within construction of large ASTs.
  137476             : 
  137477             : \internal The new and delete operators use the lower level C malloc/free
  137478             :    function calls for performance and to make sure that mixing of malloc/free
  137479             :    and new/delete by the used can be caught more readily.  This may change
  137480             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  137481             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  137482             :    deallocate memory allocated using ROSE_MALLOC.
  137483             : */
  137484           0 : void SgLshiftAssignOp::operator delete(void *Pointer, size_t Size)
  137485             : {
  137486             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  137487             :      * or throwing an exception. */
  137488           0 :     ALLOC_MUTEX(SgLshiftAssignOp, lock);
  137489             : 
  137490             : #if USE_CPP_NEW_DELETE_OPERATORS
  137491             :     ROSE_FREE(Pointer);
  137492             : #else
  137493             : #if ROSE_PEDANTIC_ALLOC
  137494             :     ROSE_ASSERT(Size == sizeof(SgLshiftAssignOp));
  137495             : #else
  137496           0 :     if (Size != sizeof(SgLshiftAssignOp)) {
  137497           0 :       ROSE_FREE(Pointer);
  137498           0 :       ALLOC_MUTEX(SgLshiftAssignOp, unlock);
  137499             :       return;
  137500             :     }
  137501             : #endif
  137502             : 
  137503           0 :     SgLshiftAssignOp * object = (SgLshiftAssignOp*) Pointer;
  137504           0 :     ROSE_ASSERT(object != nullptr);
  137505             : 
  137506             : #if ROSE_ALLOC_TRACE == 2
  137507             : //  printf("SgLshiftAssignOp::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgLshiftAssignOp::next_node);
  137508             :     printf("SgLshiftAssignOp::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgLshiftAssignOp::next_node);
  137509             : #endif
  137510             : 
  137511             : #if ROSE_PEDANTIC_ALLOC
  137512             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  137513             : #endif
  137514             : 
  137515             : #if ROSE_ALLOC_MEMSET == 1
  137516             : #elif ROSE_ALLOC_MEMSET == 2
  137517             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgLshiftAssignOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  137518             : #elif ROSE_ALLOC_MEMSET == 3
  137519             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgLshiftAssignOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  137520             : #endif
  137521             : 
  137522             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  137523             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  137524             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  137525             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  137526             : #else
  137527           0 :     object->p_freepointer = SgLshiftAssignOp::next_node;
  137528           0 :     SgLshiftAssignOp::next_node = object;
  137529             : #endif
  137530             : 
  137531             : #if ROSE_ALLOC_TRACE == 2
  137532             : //  printf("SgLshiftAssignOp::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgLshiftAssignOp::next_node);
  137533             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  137534             :     Rose::MemPool::snapshot(oss.str());
  137535             :     alloc_trace_cnt++;
  137536             : #endif
  137537             : 
  137538             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  137539             : 
  137540           0 :     ALLOC_MUTEX(SgLshiftAssignOp, unlock);
  137541             : }
  137542             : 
  137543             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  137544             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  137545             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  137546             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  137547             : // Also, note comment below from Robb (copied from the Common.code file).
  137548             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  137549             : //
  137550             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  137551             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  137552             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  137553             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  137554             : #if 0
  137555             : void SgLshiftAssignOp::operator delete(void* pointer) { SgLshiftAssignOp::operator delete (pointer, sizeof(SgLshiftAssignOp)); };
  137556             : #endif
  137557             : /* #line 137558 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  137558             : 
  137559             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  137560             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  137561             : // obviously imply C++.
  137562             : 
  137563             : // This implements the support within ROSE for memory pools.  Memory pools
  137564             : // support the most condensed usage of memory within the construction of
  137565             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  137566             : // by a new operator written for each class.
  137567             : 
  137568             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  137569             :     // User wants multi-thread support and POSIX threads are available.
  137570             : #   include <pthread.h>
  137571             :     static pthread_mutex_t SgRshiftAssignOp_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  137572             : #else
  137573             :      // Cause synchronization to be skipped.
  137574             : #    ifndef ALLOC_MUTEX
  137575             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  137576             : #    endif
  137577             : #    ifdef _REENTRANT
  137578             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  137579             : #       ifdef _MSC_VER
  137580             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  137581             : #       else
  137582             : #           warning "POSIX threads are not available; synchronization being skipped"
  137583             : #       endif
  137584             : #    endif
  137585             : #endif
  137586             : 
  137587             : #ifndef ROSE_ALLOC_TRACE
  137588             : #  define ROSE_ALLOC_TRACE 0
  137589             : #endif
  137590             : 
  137591             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  137592             : #define ROSE_ALLOC_TRACE_CNT
  137593             : #include "memory-pool-snapshot.h"
  137594             : unsigned long alloc_trace_cnt = 0;
  137595             : #endif
  137596             : 
  137597             : #if ROSE_ALLOC_TRACE
  137598             : const unsigned SgRshiftAssignOp::pool_size = 5;
  137599             : #else
  137600             : const unsigned SgRshiftAssignOp::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  137601             : #endif
  137602             : 
  137603             : #ifndef ROSE_ALLOC_MEMSET
  137604             : #  define ROSE_ALLOC_MEMSET 0
  137605             : #endif
  137606             : 
  137607             : #ifndef ROSE_PEDANTIC_ALLOC
  137608             : #  define ROSE_PEDANTIC_ALLOC 0
  137609             : #endif
  137610             : 
  137611             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  137612             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  137613             : #endif
  137614             : 
  137615             : #if !defined(SGNODE__ALL_POOLS)
  137616             : #define SGNODE__ALL_POOLS
  137617             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  137618             : #endif
  137619             : 
  137620             : SgRshiftAssignOp* SgRshiftAssignOp::next_node = nullptr;
  137621             : std::vector<unsigned char*> SgRshiftAssignOp::pools;
  137622             : 
  137623             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  137624             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  137625             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  137626             : // around this macro definition rather than each use).
  137627             : #ifndef ALLOC_MUTEX
  137628             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  137629             :         do {                                                                     \
  137630             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  137631             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  137632             :                 abort();                                                         \
  137633             :             }                                                                    \
  137634             :         } while (0);
  137635             : #endif
  137636             : 
  137637             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  137638             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  137639             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  137640             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  137641             : 
  137642             : /*! \brief New operator for SgRshiftAssignOp.
  137643             : 
  137644             :    This new operator implements memory pools to provide most efficent 
  137645             :    use of the heap within construction of large ASTs.
  137646             : 
  137647             : \internal The new and delete operators use the lower level C malloc/free
  137648             :    function calls for performance and to make sure that mixing of malloc/free
  137649             :    and new/delete by the used can be caught more readily.  This may change
  137650             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  137651             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  137652             :    deallocate memory allocated using ROSE_MALLOC.
  137653             : */
  137654          18 : void *SgRshiftAssignOp::operator new ( size_t Size )
  137655             : {
  137656             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  137657             :      * returning or throwing an exception. */
  137658          18 :     ALLOC_MUTEX(SgRshiftAssignOp, lock);
  137659             : 
  137660             : #if ROSE_ALLOC_TRACE == 2
  137661             : //    printf("SgRshiftAssignOp::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgRshiftAssignOp::next_node);
  137662             : #endif
  137663             : 
  137664             : #if USE_CPP_NEW_DELETE_OPERATORS
  137665             :     void *mem = ROSE_MALLOC(Size);
  137666             :     ALLOC_MUTEX(SgRshiftAssignOp, unlock);
  137667             :     return mem;
  137668             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  137669             : #if ROSE_PEDANTIC_ALLOC
  137670             :     ROSE_ASSERT(Size == sizeof(SgRshiftAssignOp));
  137671             : #else
  137672          18 :     if (Size != sizeof(SgRshiftAssignOp)) {
  137673           0 :       void * object = ROSE_MALLOC(Size);
  137674           0 :       ALLOC_MUTEX(SgRshiftAssignOp, unlock);
  137675             :       return object;
  137676             :     }
  137677             : #endif
  137678             : 
  137679          18 :     if (SgRshiftAssignOp::next_node == nullptr) {
  137680           8 :         SgRshiftAssignOp * alloc = (SgRshiftAssignOp*) ROSE_MALLOC ( SgRshiftAssignOp::pool_size * sizeof(SgRshiftAssignOp) );
  137681           8 :         ROSE_ASSERT(alloc != nullptr);
  137682             : 
  137683             : #if ROSE_ALLOC_TRACE == 2
  137684             : //        printf("SgRshiftAssignOp::alloc\n  block[%zi] = [ %p , %p [\n", SgRshiftAssignOp::pools.size(), alloc, alloc + SgRshiftAssignOp::pool_size);
  137685             : #endif
  137686             : 
  137687             : #if ROSE_ALLOC_MEMSET == 1
  137688             : #elif ROSE_ALLOC_MEMSET == 2
  137689             :         memset(alloc, 0x00, SgRshiftAssignOp::pool_size * sizeof(SgRshiftAssignOp));
  137690             : #elif ROSE_ALLOC_MEMSET == 3
  137691             :         memset(alloc, 0xAA, SgRshiftAssignOp::pool_size * sizeof(SgRshiftAssignOp));
  137692             : #endif
  137693       16000 :         for (unsigned i=0; i < SgRshiftAssignOp::pool_size-1; i++) {
  137694       15992 :           alloc[i].p_freepointer = &(alloc[i+1]);
  137695             :         }
  137696           8 :         alloc[SgRshiftAssignOp::pool_size-1].p_freepointer = nullptr;
  137697             : 
  137698           8 :         SgRshiftAssignOp::pools.push_back ( (unsigned char *) alloc );
  137699           8 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgRshiftAssignOp::pool_size * sizeof(SgRshiftAssignOp), V_SgRshiftAssignOp ) );
  137700           8 :         SgRshiftAssignOp::next_node = alloc;
  137701             :     }
  137702          18 :     ROSE_ASSERT(SgRshiftAssignOp::next_node != nullptr);
  137703             : 
  137704          18 :     SgRshiftAssignOp * object = SgRshiftAssignOp::next_node;
  137705          18 :     SgRshiftAssignOp::next_node = (SgRshiftAssignOp*)(object->p_freepointer);
  137706             : 
  137707             : #if ROSE_ALLOC_TRACE == 2
  137708             :     printf("SgRshiftAssignOp::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgRshiftAssignOp::next_node);
  137709             : #endif
  137710             : 
  137711          18 :     SgNode * fp = object->p_freepointer;
  137712             : #if ROSE_ALLOC_MEMSET == 1
  137713             : #elif ROSE_ALLOC_MEMSET == 2
  137714             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgRshiftAssignOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  137715             : #elif ROSE_ALLOC_MEMSET == 3
  137716             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgRshiftAssignOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  137717             : #endif
  137718          18 :     object->p_freepointer = fp;
  137719             : 
  137720             : #if ROSE_ALLOC_TRACE == 2
  137721             : //    printf("SgRshiftAssignOp::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgRshiftAssignOp::next_node);
  137722             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  137723             :     Rose::MemPool::snapshot(oss.str());
  137724             :     alloc_trace_cnt++;
  137725             : #endif
  137726             : 
  137727          18 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  137728             : 
  137729          18 :     ALLOC_MUTEX(SgRshiftAssignOp, unlock);
  137730             : 
  137731             :     return object;
  137732             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  137733             : }
  137734             : 
  137735             : 
  137736             : 
  137737             : /*! \brief Delete operator for SgRshiftAssignOp.
  137738             : 
  137739             :    This delete operator implements deallocation using memory pools to 
  137740             :    provide most efficent use of the heap within construction of large ASTs.
  137741             : 
  137742             : \internal The new and delete operators use the lower level C malloc/free
  137743             :    function calls for performance and to make sure that mixing of malloc/free
  137744             :    and new/delete by the used can be caught more readily.  This may change
  137745             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  137746             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  137747             :    deallocate memory allocated using ROSE_MALLOC.
  137748             : */
  137749           4 : void SgRshiftAssignOp::operator delete(void *Pointer, size_t Size)
  137750             : {
  137751             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  137752             :      * or throwing an exception. */
  137753           4 :     ALLOC_MUTEX(SgRshiftAssignOp, lock);
  137754             : 
  137755             : #if USE_CPP_NEW_DELETE_OPERATORS
  137756             :     ROSE_FREE(Pointer);
  137757             : #else
  137758             : #if ROSE_PEDANTIC_ALLOC
  137759             :     ROSE_ASSERT(Size == sizeof(SgRshiftAssignOp));
  137760             : #else
  137761           4 :     if (Size != sizeof(SgRshiftAssignOp)) {
  137762           0 :       ROSE_FREE(Pointer);
  137763           0 :       ALLOC_MUTEX(SgRshiftAssignOp, unlock);
  137764             :       return;
  137765             :     }
  137766             : #endif
  137767             : 
  137768           4 :     SgRshiftAssignOp * object = (SgRshiftAssignOp*) Pointer;
  137769           4 :     ROSE_ASSERT(object != nullptr);
  137770             : 
  137771             : #if ROSE_ALLOC_TRACE == 2
  137772             : //  printf("SgRshiftAssignOp::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgRshiftAssignOp::next_node);
  137773             :     printf("SgRshiftAssignOp::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgRshiftAssignOp::next_node);
  137774             : #endif
  137775             : 
  137776             : #if ROSE_PEDANTIC_ALLOC
  137777             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  137778             : #endif
  137779             : 
  137780             : #if ROSE_ALLOC_MEMSET == 1
  137781             : #elif ROSE_ALLOC_MEMSET == 2
  137782             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgRshiftAssignOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  137783             : #elif ROSE_ALLOC_MEMSET == 3
  137784             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgRshiftAssignOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  137785             : #endif
  137786             : 
  137787             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  137788             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  137789             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  137790             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  137791             : #else
  137792           4 :     object->p_freepointer = SgRshiftAssignOp::next_node;
  137793           4 :     SgRshiftAssignOp::next_node = object;
  137794             : #endif
  137795             : 
  137796             : #if ROSE_ALLOC_TRACE == 2
  137797             : //  printf("SgRshiftAssignOp::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgRshiftAssignOp::next_node);
  137798             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  137799             :     Rose::MemPool::snapshot(oss.str());
  137800             :     alloc_trace_cnt++;
  137801             : #endif
  137802             : 
  137803             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  137804             : 
  137805           4 :     ALLOC_MUTEX(SgRshiftAssignOp, unlock);
  137806             : }
  137807             : 
  137808             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  137809             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  137810             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  137811             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  137812             : // Also, note comment below from Robb (copied from the Common.code file).
  137813             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  137814             : //
  137815             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  137816             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  137817             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  137818             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  137819             : #if 0
  137820             : void SgRshiftAssignOp::operator delete(void* pointer) { SgRshiftAssignOp::operator delete (pointer, sizeof(SgRshiftAssignOp)); };
  137821             : #endif
  137822             : /* #line 137823 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  137823             : 
  137824             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  137825             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  137826             : // obviously imply C++.
  137827             : 
  137828             : // This implements the support within ROSE for memory pools.  Memory pools
  137829             : // support the most condensed usage of memory within the construction of
  137830             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  137831             : // by a new operator written for each class.
  137832             : 
  137833             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  137834             :     // User wants multi-thread support and POSIX threads are available.
  137835             : #   include <pthread.h>
  137836             :     static pthread_mutex_t SgIntegerDivideAssignOp_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  137837             : #else
  137838             :      // Cause synchronization to be skipped.
  137839             : #    ifndef ALLOC_MUTEX
  137840             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  137841             : #    endif
  137842             : #    ifdef _REENTRANT
  137843             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  137844             : #       ifdef _MSC_VER
  137845             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  137846             : #       else
  137847             : #           warning "POSIX threads are not available; synchronization being skipped"
  137848             : #       endif
  137849             : #    endif
  137850             : #endif
  137851             : 
  137852             : #ifndef ROSE_ALLOC_TRACE
  137853             : #  define ROSE_ALLOC_TRACE 0
  137854             : #endif
  137855             : 
  137856             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  137857             : #define ROSE_ALLOC_TRACE_CNT
  137858             : #include "memory-pool-snapshot.h"
  137859             : unsigned long alloc_trace_cnt = 0;
  137860             : #endif
  137861             : 
  137862             : #if ROSE_ALLOC_TRACE
  137863             : const unsigned SgIntegerDivideAssignOp::pool_size = 5;
  137864             : #else
  137865             : const unsigned SgIntegerDivideAssignOp::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  137866             : #endif
  137867             : 
  137868             : #ifndef ROSE_ALLOC_MEMSET
  137869             : #  define ROSE_ALLOC_MEMSET 0
  137870             : #endif
  137871             : 
  137872             : #ifndef ROSE_PEDANTIC_ALLOC
  137873             : #  define ROSE_PEDANTIC_ALLOC 0
  137874             : #endif
  137875             : 
  137876             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  137877             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  137878             : #endif
  137879             : 
  137880             : #if !defined(SGNODE__ALL_POOLS)
  137881             : #define SGNODE__ALL_POOLS
  137882             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  137883             : #endif
  137884             : 
  137885             : SgIntegerDivideAssignOp* SgIntegerDivideAssignOp::next_node = nullptr;
  137886             : std::vector<unsigned char*> SgIntegerDivideAssignOp::pools;
  137887             : 
  137888             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  137889             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  137890             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  137891             : // around this macro definition rather than each use).
  137892             : #ifndef ALLOC_MUTEX
  137893             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  137894             :         do {                                                                     \
  137895             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  137896             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  137897             :                 abort();                                                         \
  137898             :             }                                                                    \
  137899             :         } while (0);
  137900             : #endif
  137901             : 
  137902             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  137903             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  137904             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  137905             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  137906             : 
  137907             : /*! \brief New operator for SgIntegerDivideAssignOp.
  137908             : 
  137909             :    This new operator implements memory pools to provide most efficent 
  137910             :    use of the heap within construction of large ASTs.
  137911             : 
  137912             : \internal The new and delete operators use the lower level C malloc/free
  137913             :    function calls for performance and to make sure that mixing of malloc/free
  137914             :    and new/delete by the used can be caught more readily.  This may change
  137915             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  137916             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  137917             :    deallocate memory allocated using ROSE_MALLOC.
  137918             : */
  137919           0 : void *SgIntegerDivideAssignOp::operator new ( size_t Size )
  137920             : {
  137921             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  137922             :      * returning or throwing an exception. */
  137923           0 :     ALLOC_MUTEX(SgIntegerDivideAssignOp, lock);
  137924             : 
  137925             : #if ROSE_ALLOC_TRACE == 2
  137926             : //    printf("SgIntegerDivideAssignOp::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgIntegerDivideAssignOp::next_node);
  137927             : #endif
  137928             : 
  137929             : #if USE_CPP_NEW_DELETE_OPERATORS
  137930             :     void *mem = ROSE_MALLOC(Size);
  137931             :     ALLOC_MUTEX(SgIntegerDivideAssignOp, unlock);
  137932             :     return mem;
  137933             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  137934             : #if ROSE_PEDANTIC_ALLOC
  137935             :     ROSE_ASSERT(Size == sizeof(SgIntegerDivideAssignOp));
  137936             : #else
  137937           0 :     if (Size != sizeof(SgIntegerDivideAssignOp)) {
  137938           0 :       void * object = ROSE_MALLOC(Size);
  137939           0 :       ALLOC_MUTEX(SgIntegerDivideAssignOp, unlock);
  137940             :       return object;
  137941             :     }
  137942             : #endif
  137943             : 
  137944           0 :     if (SgIntegerDivideAssignOp::next_node == nullptr) {
  137945           0 :         SgIntegerDivideAssignOp * alloc = (SgIntegerDivideAssignOp*) ROSE_MALLOC ( SgIntegerDivideAssignOp::pool_size * sizeof(SgIntegerDivideAssignOp) );
  137946           0 :         ROSE_ASSERT(alloc != nullptr);
  137947             : 
  137948             : #if ROSE_ALLOC_TRACE == 2
  137949             : //        printf("SgIntegerDivideAssignOp::alloc\n  block[%zi] = [ %p , %p [\n", SgIntegerDivideAssignOp::pools.size(), alloc, alloc + SgIntegerDivideAssignOp::pool_size);
  137950             : #endif
  137951             : 
  137952             : #if ROSE_ALLOC_MEMSET == 1
  137953             : #elif ROSE_ALLOC_MEMSET == 2
  137954             :         memset(alloc, 0x00, SgIntegerDivideAssignOp::pool_size * sizeof(SgIntegerDivideAssignOp));
  137955             : #elif ROSE_ALLOC_MEMSET == 3
  137956             :         memset(alloc, 0xAA, SgIntegerDivideAssignOp::pool_size * sizeof(SgIntegerDivideAssignOp));
  137957             : #endif
  137958           0 :         for (unsigned i=0; i < SgIntegerDivideAssignOp::pool_size-1; i++) {
  137959           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
  137960             :         }
  137961           0 :         alloc[SgIntegerDivideAssignOp::pool_size-1].p_freepointer = nullptr;
  137962             : 
  137963           0 :         SgIntegerDivideAssignOp::pools.push_back ( (unsigned char *) alloc );
  137964           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgIntegerDivideAssignOp::pool_size * sizeof(SgIntegerDivideAssignOp), V_SgIntegerDivideAssignOp ) );
  137965           0 :         SgIntegerDivideAssignOp::next_node = alloc;
  137966             :     }
  137967           0 :     ROSE_ASSERT(SgIntegerDivideAssignOp::next_node != nullptr);
  137968             : 
  137969           0 :     SgIntegerDivideAssignOp * object = SgIntegerDivideAssignOp::next_node;
  137970           0 :     SgIntegerDivideAssignOp::next_node = (SgIntegerDivideAssignOp*)(object->p_freepointer);
  137971             : 
  137972             : #if ROSE_ALLOC_TRACE == 2
  137973             :     printf("SgIntegerDivideAssignOp::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgIntegerDivideAssignOp::next_node);
  137974             : #endif
  137975             : 
  137976           0 :     SgNode * fp = object->p_freepointer;
  137977             : #if ROSE_ALLOC_MEMSET == 1
  137978             : #elif ROSE_ALLOC_MEMSET == 2
  137979             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgIntegerDivideAssignOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  137980             : #elif ROSE_ALLOC_MEMSET == 3
  137981             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgIntegerDivideAssignOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  137982             : #endif
  137983           0 :     object->p_freepointer = fp;
  137984             : 
  137985             : #if ROSE_ALLOC_TRACE == 2
  137986             : //    printf("SgIntegerDivideAssignOp::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgIntegerDivideAssignOp::next_node);
  137987             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  137988             :     Rose::MemPool::snapshot(oss.str());
  137989             :     alloc_trace_cnt++;
  137990             : #endif
  137991             : 
  137992           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  137993             : 
  137994           0 :     ALLOC_MUTEX(SgIntegerDivideAssignOp, unlock);
  137995             : 
  137996             :     return object;
  137997             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  137998             : }
  137999             : 
  138000             : 
  138001             : 
  138002             : /*! \brief Delete operator for SgIntegerDivideAssignOp.
  138003             : 
  138004             :    This delete operator implements deallocation using memory pools to 
  138005             :    provide most efficent use of the heap within construction of large ASTs.
  138006             : 
  138007             : \internal The new and delete operators use the lower level C malloc/free
  138008             :    function calls for performance and to make sure that mixing of malloc/free
  138009             :    and new/delete by the used can be caught more readily.  This may change
  138010             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  138011             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  138012             :    deallocate memory allocated using ROSE_MALLOC.
  138013             : */
  138014           0 : void SgIntegerDivideAssignOp::operator delete(void *Pointer, size_t Size)
  138015             : {
  138016             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  138017             :      * or throwing an exception. */
  138018           0 :     ALLOC_MUTEX(SgIntegerDivideAssignOp, lock);
  138019             : 
  138020             : #if USE_CPP_NEW_DELETE_OPERATORS
  138021             :     ROSE_FREE(Pointer);
  138022             : #else
  138023             : #if ROSE_PEDANTIC_ALLOC
  138024             :     ROSE_ASSERT(Size == sizeof(SgIntegerDivideAssignOp));
  138025             : #else
  138026           0 :     if (Size != sizeof(SgIntegerDivideAssignOp)) {
  138027           0 :       ROSE_FREE(Pointer);
  138028           0 :       ALLOC_MUTEX(SgIntegerDivideAssignOp, unlock);
  138029             :       return;
  138030             :     }
  138031             : #endif
  138032             : 
  138033           0 :     SgIntegerDivideAssignOp * object = (SgIntegerDivideAssignOp*) Pointer;
  138034           0 :     ROSE_ASSERT(object != nullptr);
  138035             : 
  138036             : #if ROSE_ALLOC_TRACE == 2
  138037             : //  printf("SgIntegerDivideAssignOp::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgIntegerDivideAssignOp::next_node);
  138038             :     printf("SgIntegerDivideAssignOp::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgIntegerDivideAssignOp::next_node);
  138039             : #endif
  138040             : 
  138041             : #if ROSE_PEDANTIC_ALLOC
  138042             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  138043             : #endif
  138044             : 
  138045             : #if ROSE_ALLOC_MEMSET == 1
  138046             : #elif ROSE_ALLOC_MEMSET == 2
  138047             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgIntegerDivideAssignOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  138048             : #elif ROSE_ALLOC_MEMSET == 3
  138049             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgIntegerDivideAssignOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  138050             : #endif
  138051             : 
  138052             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  138053             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  138054             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  138055             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  138056             : #else
  138057           0 :     object->p_freepointer = SgIntegerDivideAssignOp::next_node;
  138058           0 :     SgIntegerDivideAssignOp::next_node = object;
  138059             : #endif
  138060             : 
  138061             : #if ROSE_ALLOC_TRACE == 2
  138062             : //  printf("SgIntegerDivideAssignOp::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgIntegerDivideAssignOp::next_node);
  138063             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  138064             :     Rose::MemPool::snapshot(oss.str());
  138065             :     alloc_trace_cnt++;
  138066             : #endif
  138067             : 
  138068             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  138069             : 
  138070           0 :     ALLOC_MUTEX(SgIntegerDivideAssignOp, unlock);
  138071             : }
  138072             : 
  138073             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  138074             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  138075             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  138076             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  138077             : // Also, note comment below from Robb (copied from the Common.code file).
  138078             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  138079             : //
  138080             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  138081             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  138082             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  138083             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  138084             : #if 0
  138085             : void SgIntegerDivideAssignOp::operator delete(void* pointer) { SgIntegerDivideAssignOp::operator delete (pointer, sizeof(SgIntegerDivideAssignOp)); };
  138086             : #endif
  138087             : /* #line 138088 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  138088             : 
  138089             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  138090             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  138091             : // obviously imply C++.
  138092             : 
  138093             : // This implements the support within ROSE for memory pools.  Memory pools
  138094             : // support the most condensed usage of memory within the construction of
  138095             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  138096             : // by a new operator written for each class.
  138097             : 
  138098             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  138099             :     // User wants multi-thread support and POSIX threads are available.
  138100             : #   include <pthread.h>
  138101             :     static pthread_mutex_t SgExponentiationAssignOp_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  138102             : #else
  138103             :      // Cause synchronization to be skipped.
  138104             : #    ifndef ALLOC_MUTEX
  138105             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  138106             : #    endif
  138107             : #    ifdef _REENTRANT
  138108             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  138109             : #       ifdef _MSC_VER
  138110             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  138111             : #       else
  138112             : #           warning "POSIX threads are not available; synchronization being skipped"
  138113             : #       endif
  138114             : #    endif
  138115             : #endif
  138116             : 
  138117             : #ifndef ROSE_ALLOC_TRACE
  138118             : #  define ROSE_ALLOC_TRACE 0
  138119             : #endif
  138120             : 
  138121             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  138122             : #define ROSE_ALLOC_TRACE_CNT
  138123             : #include "memory-pool-snapshot.h"
  138124             : unsigned long alloc_trace_cnt = 0;
  138125             : #endif
  138126             : 
  138127             : #if ROSE_ALLOC_TRACE
  138128             : const unsigned SgExponentiationAssignOp::pool_size = 5;
  138129             : #else
  138130             : const unsigned SgExponentiationAssignOp::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  138131             : #endif
  138132             : 
  138133             : #ifndef ROSE_ALLOC_MEMSET
  138134             : #  define ROSE_ALLOC_MEMSET 0
  138135             : #endif
  138136             : 
  138137             : #ifndef ROSE_PEDANTIC_ALLOC
  138138             : #  define ROSE_PEDANTIC_ALLOC 0
  138139             : #endif
  138140             : 
  138141             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  138142             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  138143             : #endif
  138144             : 
  138145             : #if !defined(SGNODE__ALL_POOLS)
  138146             : #define SGNODE__ALL_POOLS
  138147             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  138148             : #endif
  138149             : 
  138150             : SgExponentiationAssignOp* SgExponentiationAssignOp::next_node = nullptr;
  138151             : std::vector<unsigned char*> SgExponentiationAssignOp::pools;
  138152             : 
  138153             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  138154             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  138155             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  138156             : // around this macro definition rather than each use).
  138157             : #ifndef ALLOC_MUTEX
  138158             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  138159             :         do {                                                                     \
  138160             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  138161             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  138162             :                 abort();                                                         \
  138163             :             }                                                                    \
  138164             :         } while (0);
  138165             : #endif
  138166             : 
  138167             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  138168             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  138169             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  138170             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  138171             : 
  138172             : /*! \brief New operator for SgExponentiationAssignOp.
  138173             : 
  138174             :    This new operator implements memory pools to provide most efficent 
  138175             :    use of the heap within construction of large ASTs.
  138176             : 
  138177             : \internal The new and delete operators use the lower level C malloc/free
  138178             :    function calls for performance and to make sure that mixing of malloc/free
  138179             :    and new/delete by the used can be caught more readily.  This may change
  138180             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  138181             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  138182             :    deallocate memory allocated using ROSE_MALLOC.
  138183             : */
  138184           0 : void *SgExponentiationAssignOp::operator new ( size_t Size )
  138185             : {
  138186             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  138187             :      * returning or throwing an exception. */
  138188           0 :     ALLOC_MUTEX(SgExponentiationAssignOp, lock);
  138189             : 
  138190             : #if ROSE_ALLOC_TRACE == 2
  138191             : //    printf("SgExponentiationAssignOp::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgExponentiationAssignOp::next_node);
  138192             : #endif
  138193             : 
  138194             : #if USE_CPP_NEW_DELETE_OPERATORS
  138195             :     void *mem = ROSE_MALLOC(Size);
  138196             :     ALLOC_MUTEX(SgExponentiationAssignOp, unlock);
  138197             :     return mem;
  138198             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  138199             : #if ROSE_PEDANTIC_ALLOC
  138200             :     ROSE_ASSERT(Size == sizeof(SgExponentiationAssignOp));
  138201             : #else
  138202           0 :     if (Size != sizeof(SgExponentiationAssignOp)) {
  138203           0 :       void * object = ROSE_MALLOC(Size);
  138204           0 :       ALLOC_MUTEX(SgExponentiationAssignOp, unlock);
  138205             :       return object;
  138206             :     }
  138207             : #endif
  138208             : 
  138209           0 :     if (SgExponentiationAssignOp::next_node == nullptr) {
  138210           0 :         SgExponentiationAssignOp * alloc = (SgExponentiationAssignOp*) ROSE_MALLOC ( SgExponentiationAssignOp::pool_size * sizeof(SgExponentiationAssignOp) );
  138211           0 :         ROSE_ASSERT(alloc != nullptr);
  138212             : 
  138213             : #if ROSE_ALLOC_TRACE == 2
  138214             : //        printf("SgExponentiationAssignOp::alloc\n  block[%zi] = [ %p , %p [\n", SgExponentiationAssignOp::pools.size(), alloc, alloc + SgExponentiationAssignOp::pool_size);
  138215             : #endif
  138216             : 
  138217             : #if ROSE_ALLOC_MEMSET == 1
  138218             : #elif ROSE_ALLOC_MEMSET == 2
  138219             :         memset(alloc, 0x00, SgExponentiationAssignOp::pool_size * sizeof(SgExponentiationAssignOp));
  138220             : #elif ROSE_ALLOC_MEMSET == 3
  138221             :         memset(alloc, 0xAA, SgExponentiationAssignOp::pool_size * sizeof(SgExponentiationAssignOp));
  138222             : #endif
  138223           0 :         for (unsigned i=0; i < SgExponentiationAssignOp::pool_size-1; i++) {
  138224           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
  138225             :         }
  138226           0 :         alloc[SgExponentiationAssignOp::pool_size-1].p_freepointer = nullptr;
  138227             : 
  138228           0 :         SgExponentiationAssignOp::pools.push_back ( (unsigned char *) alloc );
  138229           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgExponentiationAssignOp::pool_size * sizeof(SgExponentiationAssignOp), V_SgExponentiationAssignOp ) );
  138230           0 :         SgExponentiationAssignOp::next_node = alloc;
  138231             :     }
  138232           0 :     ROSE_ASSERT(SgExponentiationAssignOp::next_node != nullptr);
  138233             : 
  138234           0 :     SgExponentiationAssignOp * object = SgExponentiationAssignOp::next_node;
  138235           0 :     SgExponentiationAssignOp::next_node = (SgExponentiationAssignOp*)(object->p_freepointer);
  138236             : 
  138237             : #if ROSE_ALLOC_TRACE == 2
  138238             :     printf("SgExponentiationAssignOp::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgExponentiationAssignOp::next_node);
  138239             : #endif
  138240             : 
  138241           0 :     SgNode * fp = object->p_freepointer;
  138242             : #if ROSE_ALLOC_MEMSET == 1
  138243             : #elif ROSE_ALLOC_MEMSET == 2
  138244             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgExponentiationAssignOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  138245             : #elif ROSE_ALLOC_MEMSET == 3
  138246             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgExponentiationAssignOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  138247             : #endif
  138248           0 :     object->p_freepointer = fp;
  138249             : 
  138250             : #if ROSE_ALLOC_TRACE == 2
  138251             : //    printf("SgExponentiationAssignOp::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgExponentiationAssignOp::next_node);
  138252             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  138253             :     Rose::MemPool::snapshot(oss.str());
  138254             :     alloc_trace_cnt++;
  138255             : #endif
  138256             : 
  138257           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  138258             : 
  138259           0 :     ALLOC_MUTEX(SgExponentiationAssignOp, unlock);
  138260             : 
  138261             :     return object;
  138262             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  138263             : }
  138264             : 
  138265             : 
  138266             : 
  138267             : /*! \brief Delete operator for SgExponentiationAssignOp.
  138268             : 
  138269             :    This delete operator implements deallocation using memory pools to 
  138270             :    provide most efficent use of the heap within construction of large ASTs.
  138271             : 
  138272             : \internal The new and delete operators use the lower level C malloc/free
  138273             :    function calls for performance and to make sure that mixing of malloc/free
  138274             :    and new/delete by the used can be caught more readily.  This may change
  138275             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  138276             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  138277             :    deallocate memory allocated using ROSE_MALLOC.
  138278             : */
  138279           0 : void SgExponentiationAssignOp::operator delete(void *Pointer, size_t Size)
  138280             : {
  138281             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  138282             :      * or throwing an exception. */
  138283           0 :     ALLOC_MUTEX(SgExponentiationAssignOp, lock);
  138284             : 
  138285             : #if USE_CPP_NEW_DELETE_OPERATORS
  138286             :     ROSE_FREE(Pointer);
  138287             : #else
  138288             : #if ROSE_PEDANTIC_ALLOC
  138289             :     ROSE_ASSERT(Size == sizeof(SgExponentiationAssignOp));
  138290             : #else
  138291           0 :     if (Size != sizeof(SgExponentiationAssignOp)) {
  138292           0 :       ROSE_FREE(Pointer);
  138293           0 :       ALLOC_MUTEX(SgExponentiationAssignOp, unlock);
  138294             :       return;
  138295             :     }
  138296             : #endif
  138297             : 
  138298           0 :     SgExponentiationAssignOp * object = (SgExponentiationAssignOp*) Pointer;
  138299           0 :     ROSE_ASSERT(object != nullptr);
  138300             : 
  138301             : #if ROSE_ALLOC_TRACE == 2
  138302             : //  printf("SgExponentiationAssignOp::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgExponentiationAssignOp::next_node);
  138303             :     printf("SgExponentiationAssignOp::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgExponentiationAssignOp::next_node);
  138304             : #endif
  138305             : 
  138306             : #if ROSE_PEDANTIC_ALLOC
  138307             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  138308             : #endif
  138309             : 
  138310             : #if ROSE_ALLOC_MEMSET == 1
  138311             : #elif ROSE_ALLOC_MEMSET == 2
  138312             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgExponentiationAssignOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  138313             : #elif ROSE_ALLOC_MEMSET == 3
  138314             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgExponentiationAssignOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  138315             : #endif
  138316             : 
  138317             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  138318             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  138319             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  138320             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  138321             : #else
  138322           0 :     object->p_freepointer = SgExponentiationAssignOp::next_node;
  138323           0 :     SgExponentiationAssignOp::next_node = object;
  138324             : #endif
  138325             : 
  138326             : #if ROSE_ALLOC_TRACE == 2
  138327             : //  printf("SgExponentiationAssignOp::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgExponentiationAssignOp::next_node);
  138328             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  138329             :     Rose::MemPool::snapshot(oss.str());
  138330             :     alloc_trace_cnt++;
  138331             : #endif
  138332             : 
  138333             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  138334             : 
  138335           0 :     ALLOC_MUTEX(SgExponentiationAssignOp, unlock);
  138336             : }
  138337             : 
  138338             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  138339             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  138340             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  138341             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  138342             : // Also, note comment below from Robb (copied from the Common.code file).
  138343             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  138344             : //
  138345             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  138346             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  138347             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  138348             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  138349             : #if 0
  138350             : void SgExponentiationAssignOp::operator delete(void* pointer) { SgExponentiationAssignOp::operator delete (pointer, sizeof(SgExponentiationAssignOp)); };
  138351             : #endif
  138352             : /* #line 138353 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  138353             : 
  138354             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  138355             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  138356             : // obviously imply C++.
  138357             : 
  138358             : // This implements the support within ROSE for memory pools.  Memory pools
  138359             : // support the most condensed usage of memory within the construction of
  138360             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  138361             : // by a new operator written for each class.
  138362             : 
  138363             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  138364             :     // User wants multi-thread support and POSIX threads are available.
  138365             : #   include <pthread.h>
  138366             :     static pthread_mutex_t SgMembershipOp_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  138367             : #else
  138368             :      // Cause synchronization to be skipped.
  138369             : #    ifndef ALLOC_MUTEX
  138370             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  138371             : #    endif
  138372             : #    ifdef _REENTRANT
  138373             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  138374             : #       ifdef _MSC_VER
  138375             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  138376             : #       else
  138377             : #           warning "POSIX threads are not available; synchronization being skipped"
  138378             : #       endif
  138379             : #    endif
  138380             : #endif
  138381             : 
  138382             : #ifndef ROSE_ALLOC_TRACE
  138383             : #  define ROSE_ALLOC_TRACE 0
  138384             : #endif
  138385             : 
  138386             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  138387             : #define ROSE_ALLOC_TRACE_CNT
  138388             : #include "memory-pool-snapshot.h"
  138389             : unsigned long alloc_trace_cnt = 0;
  138390             : #endif
  138391             : 
  138392             : #if ROSE_ALLOC_TRACE
  138393             : const unsigned SgMembershipOp::pool_size = 5;
  138394             : #else
  138395             : const unsigned SgMembershipOp::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  138396             : #endif
  138397             : 
  138398             : #ifndef ROSE_ALLOC_MEMSET
  138399             : #  define ROSE_ALLOC_MEMSET 0
  138400             : #endif
  138401             : 
  138402             : #ifndef ROSE_PEDANTIC_ALLOC
  138403             : #  define ROSE_PEDANTIC_ALLOC 0
  138404             : #endif
  138405             : 
  138406             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  138407             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  138408             : #endif
  138409             : 
  138410             : #if !defined(SGNODE__ALL_POOLS)
  138411             : #define SGNODE__ALL_POOLS
  138412             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  138413             : #endif
  138414             : 
  138415             : SgMembershipOp* SgMembershipOp::next_node = nullptr;
  138416             : std::vector<unsigned char*> SgMembershipOp::pools;
  138417             : 
  138418             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  138419             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  138420             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  138421             : // around this macro definition rather than each use).
  138422             : #ifndef ALLOC_MUTEX
  138423             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  138424             :         do {                                                                     \
  138425             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  138426             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  138427             :                 abort();                                                         \
  138428             :             }                                                                    \
  138429             :         } while (0);
  138430             : #endif
  138431             : 
  138432             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  138433             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  138434             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  138435             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  138436             : 
  138437             : /*! \brief New operator for SgMembershipOp.
  138438             : 
  138439             :    This new operator implements memory pools to provide most efficent 
  138440             :    use of the heap within construction of large ASTs.
  138441             : 
  138442             : \internal The new and delete operators use the lower level C malloc/free
  138443             :    function calls for performance and to make sure that mixing of malloc/free
  138444             :    and new/delete by the used can be caught more readily.  This may change
  138445             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  138446             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  138447             :    deallocate memory allocated using ROSE_MALLOC.
  138448             : */
  138449           0 : void *SgMembershipOp::operator new ( size_t Size )
  138450             : {
  138451             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  138452             :      * returning or throwing an exception. */
  138453           0 :     ALLOC_MUTEX(SgMembershipOp, lock);
  138454             : 
  138455             : #if ROSE_ALLOC_TRACE == 2
  138456             : //    printf("SgMembershipOp::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgMembershipOp::next_node);
  138457             : #endif
  138458             : 
  138459             : #if USE_CPP_NEW_DELETE_OPERATORS
  138460             :     void *mem = ROSE_MALLOC(Size);
  138461             :     ALLOC_MUTEX(SgMembershipOp, unlock);
  138462             :     return mem;
  138463             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  138464             : #if ROSE_PEDANTIC_ALLOC
  138465             :     ROSE_ASSERT(Size == sizeof(SgMembershipOp));
  138466             : #else
  138467           0 :     if (Size != sizeof(SgMembershipOp)) {
  138468           0 :       void * object = ROSE_MALLOC(Size);
  138469           0 :       ALLOC_MUTEX(SgMembershipOp, unlock);
  138470             :       return object;
  138471             :     }
  138472             : #endif
  138473             : 
  138474           0 :     if (SgMembershipOp::next_node == nullptr) {
  138475           0 :         SgMembershipOp * alloc = (SgMembershipOp*) ROSE_MALLOC ( SgMembershipOp::pool_size * sizeof(SgMembershipOp) );
  138476           0 :         ROSE_ASSERT(alloc != nullptr);
  138477             : 
  138478             : #if ROSE_ALLOC_TRACE == 2
  138479             : //        printf("SgMembershipOp::alloc\n  block[%zi] = [ %p , %p [\n", SgMembershipOp::pools.size(), alloc, alloc + SgMembershipOp::pool_size);
  138480             : #endif
  138481             : 
  138482             : #if ROSE_ALLOC_MEMSET == 1
  138483             : #elif ROSE_ALLOC_MEMSET == 2
  138484             :         memset(alloc, 0x00, SgMembershipOp::pool_size * sizeof(SgMembershipOp));
  138485             : #elif ROSE_ALLOC_MEMSET == 3
  138486             :         memset(alloc, 0xAA, SgMembershipOp::pool_size * sizeof(SgMembershipOp));
  138487             : #endif
  138488           0 :         for (unsigned i=0; i < SgMembershipOp::pool_size-1; i++) {
  138489           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
  138490             :         }
  138491           0 :         alloc[SgMembershipOp::pool_size-1].p_freepointer = nullptr;
  138492             : 
  138493           0 :         SgMembershipOp::pools.push_back ( (unsigned char *) alloc );
  138494           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgMembershipOp::pool_size * sizeof(SgMembershipOp), V_SgMembershipOp ) );
  138495           0 :         SgMembershipOp::next_node = alloc;
  138496             :     }
  138497           0 :     ROSE_ASSERT(SgMembershipOp::next_node != nullptr);
  138498             : 
  138499           0 :     SgMembershipOp * object = SgMembershipOp::next_node;
  138500           0 :     SgMembershipOp::next_node = (SgMembershipOp*)(object->p_freepointer);
  138501             : 
  138502             : #if ROSE_ALLOC_TRACE == 2
  138503             :     printf("SgMembershipOp::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgMembershipOp::next_node);
  138504             : #endif
  138505             : 
  138506           0 :     SgNode * fp = object->p_freepointer;
  138507             : #if ROSE_ALLOC_MEMSET == 1
  138508             : #elif ROSE_ALLOC_MEMSET == 2
  138509             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgMembershipOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  138510             : #elif ROSE_ALLOC_MEMSET == 3
  138511             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgMembershipOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  138512             : #endif
  138513           0 :     object->p_freepointer = fp;
  138514             : 
  138515             : #if ROSE_ALLOC_TRACE == 2
  138516             : //    printf("SgMembershipOp::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgMembershipOp::next_node);
  138517             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  138518             :     Rose::MemPool::snapshot(oss.str());
  138519             :     alloc_trace_cnt++;
  138520             : #endif
  138521             : 
  138522           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  138523             : 
  138524           0 :     ALLOC_MUTEX(SgMembershipOp, unlock);
  138525             : 
  138526             :     return object;
  138527             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  138528             : }
  138529             : 
  138530             : 
  138531             : 
  138532             : /*! \brief Delete operator for SgMembershipOp.
  138533             : 
  138534             :    This delete operator implements deallocation using memory pools to 
  138535             :    provide most efficent use of the heap within construction of large ASTs.
  138536             : 
  138537             : \internal The new and delete operators use the lower level C malloc/free
  138538             :    function calls for performance and to make sure that mixing of malloc/free
  138539             :    and new/delete by the used can be caught more readily.  This may change
  138540             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  138541             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  138542             :    deallocate memory allocated using ROSE_MALLOC.
  138543             : */
  138544           0 : void SgMembershipOp::operator delete(void *Pointer, size_t Size)
  138545             : {
  138546             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  138547             :      * or throwing an exception. */
  138548           0 :     ALLOC_MUTEX(SgMembershipOp, lock);
  138549             : 
  138550             : #if USE_CPP_NEW_DELETE_OPERATORS
  138551             :     ROSE_FREE(Pointer);
  138552             : #else
  138553             : #if ROSE_PEDANTIC_ALLOC
  138554             :     ROSE_ASSERT(Size == sizeof(SgMembershipOp));
  138555             : #else
  138556           0 :     if (Size != sizeof(SgMembershipOp)) {
  138557           0 :       ROSE_FREE(Pointer);
  138558           0 :       ALLOC_MUTEX(SgMembershipOp, unlock);
  138559             :       return;
  138560             :     }
  138561             : #endif
  138562             : 
  138563           0 :     SgMembershipOp * object = (SgMembershipOp*) Pointer;
  138564           0 :     ROSE_ASSERT(object != nullptr);
  138565             : 
  138566             : #if ROSE_ALLOC_TRACE == 2
  138567             : //  printf("SgMembershipOp::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgMembershipOp::next_node);
  138568             :     printf("SgMembershipOp::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgMembershipOp::next_node);
  138569             : #endif
  138570             : 
  138571             : #if ROSE_PEDANTIC_ALLOC
  138572             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  138573             : #endif
  138574             : 
  138575             : #if ROSE_ALLOC_MEMSET == 1
  138576             : #elif ROSE_ALLOC_MEMSET == 2
  138577             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgMembershipOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  138578             : #elif ROSE_ALLOC_MEMSET == 3
  138579             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgMembershipOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  138580             : #endif
  138581             : 
  138582             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  138583             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  138584             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  138585             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  138586             : #else
  138587           0 :     object->p_freepointer = SgMembershipOp::next_node;
  138588           0 :     SgMembershipOp::next_node = object;
  138589             : #endif
  138590             : 
  138591             : #if ROSE_ALLOC_TRACE == 2
  138592             : //  printf("SgMembershipOp::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgMembershipOp::next_node);
  138593             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  138594             :     Rose::MemPool::snapshot(oss.str());
  138595             :     alloc_trace_cnt++;
  138596             : #endif
  138597             : 
  138598             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  138599             : 
  138600           0 :     ALLOC_MUTEX(SgMembershipOp, unlock);
  138601             : }
  138602             : 
  138603             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  138604             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  138605             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  138606             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  138607             : // Also, note comment below from Robb (copied from the Common.code file).
  138608             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  138609             : //
  138610             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  138611             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  138612             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  138613             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  138614             : #if 0
  138615             : void SgMembershipOp::operator delete(void* pointer) { SgMembershipOp::operator delete (pointer, sizeof(SgMembershipOp)); };
  138616             : #endif
  138617             : /* #line 138618 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  138618             : 
  138619             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  138620             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  138621             : // obviously imply C++.
  138622             : 
  138623             : // This implements the support within ROSE for memory pools.  Memory pools
  138624             : // support the most condensed usage of memory within the construction of
  138625             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  138626             : // by a new operator written for each class.
  138627             : 
  138628             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  138629             :     // User wants multi-thread support and POSIX threads are available.
  138630             : #   include <pthread.h>
  138631             :     static pthread_mutex_t SgSpaceshipOp_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  138632             : #else
  138633             :      // Cause synchronization to be skipped.
  138634             : #    ifndef ALLOC_MUTEX
  138635             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  138636             : #    endif
  138637             : #    ifdef _REENTRANT
  138638             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  138639             : #       ifdef _MSC_VER
  138640             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  138641             : #       else
  138642             : #           warning "POSIX threads are not available; synchronization being skipped"
  138643             : #       endif
  138644             : #    endif
  138645             : #endif
  138646             : 
  138647             : #ifndef ROSE_ALLOC_TRACE
  138648             : #  define ROSE_ALLOC_TRACE 0
  138649             : #endif
  138650             : 
  138651             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  138652             : #define ROSE_ALLOC_TRACE_CNT
  138653             : #include "memory-pool-snapshot.h"
  138654             : unsigned long alloc_trace_cnt = 0;
  138655             : #endif
  138656             : 
  138657             : #if ROSE_ALLOC_TRACE
  138658             : const unsigned SgSpaceshipOp::pool_size = 5;
  138659             : #else
  138660             : const unsigned SgSpaceshipOp::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  138661             : #endif
  138662             : 
  138663             : #ifndef ROSE_ALLOC_MEMSET
  138664             : #  define ROSE_ALLOC_MEMSET 0
  138665             : #endif
  138666             : 
  138667             : #ifndef ROSE_PEDANTIC_ALLOC
  138668             : #  define ROSE_PEDANTIC_ALLOC 0
  138669             : #endif
  138670             : 
  138671             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  138672             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  138673             : #endif
  138674             : 
  138675             : #if !defined(SGNODE__ALL_POOLS)
  138676             : #define SGNODE__ALL_POOLS
  138677             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  138678             : #endif
  138679             : 
  138680             : SgSpaceshipOp* SgSpaceshipOp::next_node = nullptr;
  138681             : std::vector<unsigned char*> SgSpaceshipOp::pools;
  138682             : 
  138683             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  138684             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  138685             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  138686             : // around this macro definition rather than each use).
  138687             : #ifndef ALLOC_MUTEX
  138688             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  138689             :         do {                                                                     \
  138690             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  138691             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  138692             :                 abort();                                                         \
  138693             :             }                                                                    \
  138694             :         } while (0);
  138695             : #endif
  138696             : 
  138697             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  138698             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  138699             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  138700             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  138701             : 
  138702             : /*! \brief New operator for SgSpaceshipOp.
  138703             : 
  138704             :    This new operator implements memory pools to provide most efficent 
  138705             :    use of the heap within construction of large ASTs.
  138706             : 
  138707             : \internal The new and delete operators use the lower level C malloc/free
  138708             :    function calls for performance and to make sure that mixing of malloc/free
  138709             :    and new/delete by the used can be caught more readily.  This may change
  138710             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  138711             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  138712             :    deallocate memory allocated using ROSE_MALLOC.
  138713             : */
  138714           0 : void *SgSpaceshipOp::operator new ( size_t Size )
  138715             : {
  138716             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  138717             :      * returning or throwing an exception. */
  138718           0 :     ALLOC_MUTEX(SgSpaceshipOp, lock);
  138719             : 
  138720             : #if ROSE_ALLOC_TRACE == 2
  138721             : //    printf("SgSpaceshipOp::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgSpaceshipOp::next_node);
  138722             : #endif
  138723             : 
  138724             : #if USE_CPP_NEW_DELETE_OPERATORS
  138725             :     void *mem = ROSE_MALLOC(Size);
  138726             :     ALLOC_MUTEX(SgSpaceshipOp, unlock);
  138727             :     return mem;
  138728             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  138729             : #if ROSE_PEDANTIC_ALLOC
  138730             :     ROSE_ASSERT(Size == sizeof(SgSpaceshipOp));
  138731             : #else
  138732           0 :     if (Size != sizeof(SgSpaceshipOp)) {
  138733           0 :       void * object = ROSE_MALLOC(Size);
  138734           0 :       ALLOC_MUTEX(SgSpaceshipOp, unlock);
  138735             :       return object;
  138736             :     }
  138737             : #endif
  138738             : 
  138739           0 :     if (SgSpaceshipOp::next_node == nullptr) {
  138740           0 :         SgSpaceshipOp * alloc = (SgSpaceshipOp*) ROSE_MALLOC ( SgSpaceshipOp::pool_size * sizeof(SgSpaceshipOp) );
  138741           0 :         ROSE_ASSERT(alloc != nullptr);
  138742             : 
  138743             : #if ROSE_ALLOC_TRACE == 2
  138744             : //        printf("SgSpaceshipOp::alloc\n  block[%zi] = [ %p , %p [\n", SgSpaceshipOp::pools.size(), alloc, alloc + SgSpaceshipOp::pool_size);
  138745             : #endif
  138746             : 
  138747             : #if ROSE_ALLOC_MEMSET == 1
  138748             : #elif ROSE_ALLOC_MEMSET == 2
  138749             :         memset(alloc, 0x00, SgSpaceshipOp::pool_size * sizeof(SgSpaceshipOp));
  138750             : #elif ROSE_ALLOC_MEMSET == 3
  138751             :         memset(alloc, 0xAA, SgSpaceshipOp::pool_size * sizeof(SgSpaceshipOp));
  138752             : #endif
  138753           0 :         for (unsigned i=0; i < SgSpaceshipOp::pool_size-1; i++) {
  138754           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
  138755             :         }
  138756           0 :         alloc[SgSpaceshipOp::pool_size-1].p_freepointer = nullptr;
  138757             : 
  138758           0 :         SgSpaceshipOp::pools.push_back ( (unsigned char *) alloc );
  138759           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgSpaceshipOp::pool_size * sizeof(SgSpaceshipOp), V_SgSpaceshipOp ) );
  138760           0 :         SgSpaceshipOp::next_node = alloc;
  138761             :     }
  138762           0 :     ROSE_ASSERT(SgSpaceshipOp::next_node != nullptr);
  138763             : 
  138764           0 :     SgSpaceshipOp * object = SgSpaceshipOp::next_node;
  138765           0 :     SgSpaceshipOp::next_node = (SgSpaceshipOp*)(object->p_freepointer);
  138766             : 
  138767             : #if ROSE_ALLOC_TRACE == 2
  138768             :     printf("SgSpaceshipOp::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgSpaceshipOp::next_node);
  138769             : #endif
  138770             : 
  138771           0 :     SgNode * fp = object->p_freepointer;
  138772             : #if ROSE_ALLOC_MEMSET == 1
  138773             : #elif ROSE_ALLOC_MEMSET == 2
  138774             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgSpaceshipOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  138775             : #elif ROSE_ALLOC_MEMSET == 3
  138776             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgSpaceshipOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  138777             : #endif
  138778           0 :     object->p_freepointer = fp;
  138779             : 
  138780             : #if ROSE_ALLOC_TRACE == 2
  138781             : //    printf("SgSpaceshipOp::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgSpaceshipOp::next_node);
  138782             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  138783             :     Rose::MemPool::snapshot(oss.str());
  138784             :     alloc_trace_cnt++;
  138785             : #endif
  138786             : 
  138787           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  138788             : 
  138789           0 :     ALLOC_MUTEX(SgSpaceshipOp, unlock);
  138790             : 
  138791             :     return object;
  138792             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  138793             : }
  138794             : 
  138795             : 
  138796             : 
  138797             : /*! \brief Delete operator for SgSpaceshipOp.
  138798             : 
  138799             :    This delete operator implements deallocation using memory pools to 
  138800             :    provide most efficent use of the heap within construction of large ASTs.
  138801             : 
  138802             : \internal The new and delete operators use the lower level C malloc/free
  138803             :    function calls for performance and to make sure that mixing of malloc/free
  138804             :    and new/delete by the used can be caught more readily.  This may change
  138805             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  138806             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  138807             :    deallocate memory allocated using ROSE_MALLOC.
  138808             : */
  138809           0 : void SgSpaceshipOp::operator delete(void *Pointer, size_t Size)
  138810             : {
  138811             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  138812             :      * or throwing an exception. */
  138813           0 :     ALLOC_MUTEX(SgSpaceshipOp, lock);
  138814             : 
  138815             : #if USE_CPP_NEW_DELETE_OPERATORS
  138816             :     ROSE_FREE(Pointer);
  138817             : #else
  138818             : #if ROSE_PEDANTIC_ALLOC
  138819             :     ROSE_ASSERT(Size == sizeof(SgSpaceshipOp));
  138820             : #else
  138821           0 :     if (Size != sizeof(SgSpaceshipOp)) {
  138822           0 :       ROSE_FREE(Pointer);
  138823           0 :       ALLOC_MUTEX(SgSpaceshipOp, unlock);
  138824             :       return;
  138825             :     }
  138826             : #endif
  138827             : 
  138828           0 :     SgSpaceshipOp * object = (SgSpaceshipOp*) Pointer;
  138829           0 :     ROSE_ASSERT(object != nullptr);
  138830             : 
  138831             : #if ROSE_ALLOC_TRACE == 2
  138832             : //  printf("SgSpaceshipOp::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgSpaceshipOp::next_node);
  138833             :     printf("SgSpaceshipOp::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgSpaceshipOp::next_node);
  138834             : #endif
  138835             : 
  138836             : #if ROSE_PEDANTIC_ALLOC
  138837             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  138838             : #endif
  138839             : 
  138840             : #if ROSE_ALLOC_MEMSET == 1
  138841             : #elif ROSE_ALLOC_MEMSET == 2
  138842             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgSpaceshipOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  138843             : #elif ROSE_ALLOC_MEMSET == 3
  138844             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgSpaceshipOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  138845             : #endif
  138846             : 
  138847             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  138848             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  138849             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  138850             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  138851             : #else
  138852           0 :     object->p_freepointer = SgSpaceshipOp::next_node;
  138853           0 :     SgSpaceshipOp::next_node = object;
  138854             : #endif
  138855             : 
  138856             : #if ROSE_ALLOC_TRACE == 2
  138857             : //  printf("SgSpaceshipOp::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgSpaceshipOp::next_node);
  138858             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  138859             :     Rose::MemPool::snapshot(oss.str());
  138860             :     alloc_trace_cnt++;
  138861             : #endif
  138862             : 
  138863             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  138864             : 
  138865           0 :     ALLOC_MUTEX(SgSpaceshipOp, unlock);
  138866             : }
  138867             : 
  138868             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  138869             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  138870             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  138871             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  138872             : // Also, note comment below from Robb (copied from the Common.code file).
  138873             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  138874             : //
  138875             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  138876             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  138877             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  138878             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  138879             : #if 0
  138880             : void SgSpaceshipOp::operator delete(void* pointer) { SgSpaceshipOp::operator delete (pointer, sizeof(SgSpaceshipOp)); };
  138881             : #endif
  138882             : /* #line 138883 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  138883             : 
  138884             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  138885             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  138886             : // obviously imply C++.
  138887             : 
  138888             : // This implements the support within ROSE for memory pools.  Memory pools
  138889             : // support the most condensed usage of memory within the construction of
  138890             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  138891             : // by a new operator written for each class.
  138892             : 
  138893             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  138894             :     // User wants multi-thread support and POSIX threads are available.
  138895             : #   include <pthread.h>
  138896             :     static pthread_mutex_t SgNonMembershipOp_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  138897             : #else
  138898             :      // Cause synchronization to be skipped.
  138899             : #    ifndef ALLOC_MUTEX
  138900             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  138901             : #    endif
  138902             : #    ifdef _REENTRANT
  138903             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  138904             : #       ifdef _MSC_VER
  138905             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  138906             : #       else
  138907             : #           warning "POSIX threads are not available; synchronization being skipped"
  138908             : #       endif
  138909             : #    endif
  138910             : #endif
  138911             : 
  138912             : #ifndef ROSE_ALLOC_TRACE
  138913             : #  define ROSE_ALLOC_TRACE 0
  138914             : #endif
  138915             : 
  138916             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  138917             : #define ROSE_ALLOC_TRACE_CNT
  138918             : #include "memory-pool-snapshot.h"
  138919             : unsigned long alloc_trace_cnt = 0;
  138920             : #endif
  138921             : 
  138922             : #if ROSE_ALLOC_TRACE
  138923             : const unsigned SgNonMembershipOp::pool_size = 5;
  138924             : #else
  138925             : const unsigned SgNonMembershipOp::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  138926             : #endif
  138927             : 
  138928             : #ifndef ROSE_ALLOC_MEMSET
  138929             : #  define ROSE_ALLOC_MEMSET 0
  138930             : #endif
  138931             : 
  138932             : #ifndef ROSE_PEDANTIC_ALLOC
  138933             : #  define ROSE_PEDANTIC_ALLOC 0
  138934             : #endif
  138935             : 
  138936             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  138937             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  138938             : #endif
  138939             : 
  138940             : #if !defined(SGNODE__ALL_POOLS)
  138941             : #define SGNODE__ALL_POOLS
  138942             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  138943             : #endif
  138944             : 
  138945             : SgNonMembershipOp* SgNonMembershipOp::next_node = nullptr;
  138946             : std::vector<unsigned char*> SgNonMembershipOp::pools;
  138947             : 
  138948             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  138949             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  138950             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  138951             : // around this macro definition rather than each use).
  138952             : #ifndef ALLOC_MUTEX
  138953             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  138954             :         do {                                                                     \
  138955             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  138956             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  138957             :                 abort();                                                         \
  138958             :             }                                                                    \
  138959             :         } while (0);
  138960             : #endif
  138961             : 
  138962             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  138963             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  138964             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  138965             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  138966             : 
  138967             : /*! \brief New operator for SgNonMembershipOp.
  138968             : 
  138969             :    This new operator implements memory pools to provide most efficent 
  138970             :    use of the heap within construction of large ASTs.
  138971             : 
  138972             : \internal The new and delete operators use the lower level C malloc/free
  138973             :    function calls for performance and to make sure that mixing of malloc/free
  138974             :    and new/delete by the used can be caught more readily.  This may change
  138975             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  138976             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  138977             :    deallocate memory allocated using ROSE_MALLOC.
  138978             : */
  138979           0 : void *SgNonMembershipOp::operator new ( size_t Size )
  138980             : {
  138981             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  138982             :      * returning or throwing an exception. */
  138983           0 :     ALLOC_MUTEX(SgNonMembershipOp, lock);
  138984             : 
  138985             : #if ROSE_ALLOC_TRACE == 2
  138986             : //    printf("SgNonMembershipOp::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgNonMembershipOp::next_node);
  138987             : #endif
  138988             : 
  138989             : #if USE_CPP_NEW_DELETE_OPERATORS
  138990             :     void *mem = ROSE_MALLOC(Size);
  138991             :     ALLOC_MUTEX(SgNonMembershipOp, unlock);
  138992             :     return mem;
  138993             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  138994             : #if ROSE_PEDANTIC_ALLOC
  138995             :     ROSE_ASSERT(Size == sizeof(SgNonMembershipOp));
  138996             : #else
  138997           0 :     if (Size != sizeof(SgNonMembershipOp)) {
  138998           0 :       void * object = ROSE_MALLOC(Size);
  138999           0 :       ALLOC_MUTEX(SgNonMembershipOp, unlock);
  139000             :       return object;
  139001             :     }
  139002             : #endif
  139003             : 
  139004           0 :     if (SgNonMembershipOp::next_node == nullptr) {
  139005           0 :         SgNonMembershipOp * alloc = (SgNonMembershipOp*) ROSE_MALLOC ( SgNonMembershipOp::pool_size * sizeof(SgNonMembershipOp) );
  139006           0 :         ROSE_ASSERT(alloc != nullptr);
  139007             : 
  139008             : #if ROSE_ALLOC_TRACE == 2
  139009             : //        printf("SgNonMembershipOp::alloc\n  block[%zi] = [ %p , %p [\n", SgNonMembershipOp::pools.size(), alloc, alloc + SgNonMembershipOp::pool_size);
  139010             : #endif
  139011             : 
  139012             : #if ROSE_ALLOC_MEMSET == 1
  139013             : #elif ROSE_ALLOC_MEMSET == 2
  139014             :         memset(alloc, 0x00, SgNonMembershipOp::pool_size * sizeof(SgNonMembershipOp));
  139015             : #elif ROSE_ALLOC_MEMSET == 3
  139016             :         memset(alloc, 0xAA, SgNonMembershipOp::pool_size * sizeof(SgNonMembershipOp));
  139017             : #endif
  139018           0 :         for (unsigned i=0; i < SgNonMembershipOp::pool_size-1; i++) {
  139019           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
  139020             :         }
  139021           0 :         alloc[SgNonMembershipOp::pool_size-1].p_freepointer = nullptr;
  139022             : 
  139023           0 :         SgNonMembershipOp::pools.push_back ( (unsigned char *) alloc );
  139024           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgNonMembershipOp::pool_size * sizeof(SgNonMembershipOp), V_SgNonMembershipOp ) );
  139025           0 :         SgNonMembershipOp::next_node = alloc;
  139026             :     }
  139027           0 :     ROSE_ASSERT(SgNonMembershipOp::next_node != nullptr);
  139028             : 
  139029           0 :     SgNonMembershipOp * object = SgNonMembershipOp::next_node;
  139030           0 :     SgNonMembershipOp::next_node = (SgNonMembershipOp*)(object->p_freepointer);
  139031             : 
  139032             : #if ROSE_ALLOC_TRACE == 2
  139033             :     printf("SgNonMembershipOp::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgNonMembershipOp::next_node);
  139034             : #endif
  139035             : 
  139036           0 :     SgNode * fp = object->p_freepointer;
  139037             : #if ROSE_ALLOC_MEMSET == 1
  139038             : #elif ROSE_ALLOC_MEMSET == 2
  139039             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgNonMembershipOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  139040             : #elif ROSE_ALLOC_MEMSET == 3
  139041             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgNonMembershipOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  139042             : #endif
  139043           0 :     object->p_freepointer = fp;
  139044             : 
  139045             : #if ROSE_ALLOC_TRACE == 2
  139046             : //    printf("SgNonMembershipOp::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgNonMembershipOp::next_node);
  139047             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  139048             :     Rose::MemPool::snapshot(oss.str());
  139049             :     alloc_trace_cnt++;
  139050             : #endif
  139051             : 
  139052           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  139053             : 
  139054           0 :     ALLOC_MUTEX(SgNonMembershipOp, unlock);
  139055             : 
  139056             :     return object;
  139057             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  139058             : }
  139059             : 
  139060             : 
  139061             : 
  139062             : /*! \brief Delete operator for SgNonMembershipOp.
  139063             : 
  139064             :    This delete operator implements deallocation using memory pools to 
  139065             :    provide most efficent use of the heap within construction of large ASTs.
  139066             : 
  139067             : \internal The new and delete operators use the lower level C malloc/free
  139068             :    function calls for performance and to make sure that mixing of malloc/free
  139069             :    and new/delete by the used can be caught more readily.  This may change
  139070             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  139071             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  139072             :    deallocate memory allocated using ROSE_MALLOC.
  139073             : */
  139074           0 : void SgNonMembershipOp::operator delete(void *Pointer, size_t Size)
  139075             : {
  139076             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  139077             :      * or throwing an exception. */
  139078           0 :     ALLOC_MUTEX(SgNonMembershipOp, lock);
  139079             : 
  139080             : #if USE_CPP_NEW_DELETE_OPERATORS
  139081             :     ROSE_FREE(Pointer);
  139082             : #else
  139083             : #if ROSE_PEDANTIC_ALLOC
  139084             :     ROSE_ASSERT(Size == sizeof(SgNonMembershipOp));
  139085             : #else
  139086           0 :     if (Size != sizeof(SgNonMembershipOp)) {
  139087           0 :       ROSE_FREE(Pointer);
  139088           0 :       ALLOC_MUTEX(SgNonMembershipOp, unlock);
  139089             :       return;
  139090             :     }
  139091             : #endif
  139092             : 
  139093           0 :     SgNonMembershipOp * object = (SgNonMembershipOp*) Pointer;
  139094           0 :     ROSE_ASSERT(object != nullptr);
  139095             : 
  139096             : #if ROSE_ALLOC_TRACE == 2
  139097             : //  printf("SgNonMembershipOp::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgNonMembershipOp::next_node);
  139098             :     printf("SgNonMembershipOp::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgNonMembershipOp::next_node);
  139099             : #endif
  139100             : 
  139101             : #if ROSE_PEDANTIC_ALLOC
  139102             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  139103             : #endif
  139104             : 
  139105             : #if ROSE_ALLOC_MEMSET == 1
  139106             : #elif ROSE_ALLOC_MEMSET == 2
  139107             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgNonMembershipOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  139108             : #elif ROSE_ALLOC_MEMSET == 3
  139109             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgNonMembershipOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  139110             : #endif
  139111             : 
  139112             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  139113             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  139114             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  139115             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  139116             : #else
  139117           0 :     object->p_freepointer = SgNonMembershipOp::next_node;
  139118           0 :     SgNonMembershipOp::next_node = object;
  139119             : #endif
  139120             : 
  139121             : #if ROSE_ALLOC_TRACE == 2
  139122             : //  printf("SgNonMembershipOp::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgNonMembershipOp::next_node);
  139123             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  139124             :     Rose::MemPool::snapshot(oss.str());
  139125             :     alloc_trace_cnt++;
  139126             : #endif
  139127             : 
  139128             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  139129             : 
  139130           0 :     ALLOC_MUTEX(SgNonMembershipOp, unlock);
  139131             : }
  139132             : 
  139133             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  139134             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  139135             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  139136             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  139137             : // Also, note comment below from Robb (copied from the Common.code file).
  139138             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  139139             : //
  139140             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  139141             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  139142             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  139143             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  139144             : #if 0
  139145             : void SgNonMembershipOp::operator delete(void* pointer) { SgNonMembershipOp::operator delete (pointer, sizeof(SgNonMembershipOp)); };
  139146             : #endif
  139147             : /* #line 139148 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  139148             : 
  139149             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  139150             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  139151             : // obviously imply C++.
  139152             : 
  139153             : // This implements the support within ROSE for memory pools.  Memory pools
  139154             : // support the most condensed usage of memory within the construction of
  139155             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  139156             : // by a new operator written for each class.
  139157             : 
  139158             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  139159             :     // User wants multi-thread support and POSIX threads are available.
  139160             : #   include <pthread.h>
  139161             :     static pthread_mutex_t SgIsOp_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  139162             : #else
  139163             :      // Cause synchronization to be skipped.
  139164             : #    ifndef ALLOC_MUTEX
  139165             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  139166             : #    endif
  139167             : #    ifdef _REENTRANT
  139168             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  139169             : #       ifdef _MSC_VER
  139170             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  139171             : #       else
  139172             : #           warning "POSIX threads are not available; synchronization being skipped"
  139173             : #       endif
  139174             : #    endif
  139175             : #endif
  139176             : 
  139177             : #ifndef ROSE_ALLOC_TRACE
  139178             : #  define ROSE_ALLOC_TRACE 0
  139179             : #endif
  139180             : 
  139181             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  139182             : #define ROSE_ALLOC_TRACE_CNT
  139183             : #include "memory-pool-snapshot.h"
  139184             : unsigned long alloc_trace_cnt = 0;
  139185             : #endif
  139186             : 
  139187             : #if ROSE_ALLOC_TRACE
  139188             : const unsigned SgIsOp::pool_size = 5;
  139189             : #else
  139190             : const unsigned SgIsOp::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  139191             : #endif
  139192             : 
  139193             : #ifndef ROSE_ALLOC_MEMSET
  139194             : #  define ROSE_ALLOC_MEMSET 0
  139195             : #endif
  139196             : 
  139197             : #ifndef ROSE_PEDANTIC_ALLOC
  139198             : #  define ROSE_PEDANTIC_ALLOC 0
  139199             : #endif
  139200             : 
  139201             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  139202             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  139203             : #endif
  139204             : 
  139205             : #if !defined(SGNODE__ALL_POOLS)
  139206             : #define SGNODE__ALL_POOLS
  139207             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  139208             : #endif
  139209             : 
  139210             : SgIsOp* SgIsOp::next_node = nullptr;
  139211             : std::vector<unsigned char*> SgIsOp::pools;
  139212             : 
  139213             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  139214             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  139215             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  139216             : // around this macro definition rather than each use).
  139217             : #ifndef ALLOC_MUTEX
  139218             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  139219             :         do {                                                                     \
  139220             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  139221             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  139222             :                 abort();                                                         \
  139223             :             }                                                                    \
  139224             :         } while (0);
  139225             : #endif
  139226             : 
  139227             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  139228             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  139229             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  139230             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  139231             : 
  139232             : /*! \brief New operator for SgIsOp.
  139233             : 
  139234             :    This new operator implements memory pools to provide most efficent 
  139235             :    use of the heap within construction of large ASTs.
  139236             : 
  139237             : \internal The new and delete operators use the lower level C malloc/free
  139238             :    function calls for performance and to make sure that mixing of malloc/free
  139239             :    and new/delete by the used can be caught more readily.  This may change
  139240             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  139241             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  139242             :    deallocate memory allocated using ROSE_MALLOC.
  139243             : */
  139244           0 : void *SgIsOp::operator new ( size_t Size )
  139245             : {
  139246             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  139247             :      * returning or throwing an exception. */
  139248           0 :     ALLOC_MUTEX(SgIsOp, lock);
  139249             : 
  139250             : #if ROSE_ALLOC_TRACE == 2
  139251             : //    printf("SgIsOp::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgIsOp::next_node);
  139252             : #endif
  139253             : 
  139254             : #if USE_CPP_NEW_DELETE_OPERATORS
  139255             :     void *mem = ROSE_MALLOC(Size);
  139256             :     ALLOC_MUTEX(SgIsOp, unlock);
  139257             :     return mem;
  139258             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  139259             : #if ROSE_PEDANTIC_ALLOC
  139260             :     ROSE_ASSERT(Size == sizeof(SgIsOp));
  139261             : #else
  139262           0 :     if (Size != sizeof(SgIsOp)) {
  139263           0 :       void * object = ROSE_MALLOC(Size);
  139264           0 :       ALLOC_MUTEX(SgIsOp, unlock);
  139265             :       return object;
  139266             :     }
  139267             : #endif
  139268             : 
  139269           0 :     if (SgIsOp::next_node == nullptr) {
  139270           0 :         SgIsOp * alloc = (SgIsOp*) ROSE_MALLOC ( SgIsOp::pool_size * sizeof(SgIsOp) );
  139271           0 :         ROSE_ASSERT(alloc != nullptr);
  139272             : 
  139273             : #if ROSE_ALLOC_TRACE == 2
  139274             : //        printf("SgIsOp::alloc\n  block[%zi] = [ %p , %p [\n", SgIsOp::pools.size(), alloc, alloc + SgIsOp::pool_size);
  139275             : #endif
  139276             : 
  139277             : #if ROSE_ALLOC_MEMSET == 1
  139278             : #elif ROSE_ALLOC_MEMSET == 2
  139279             :         memset(alloc, 0x00, SgIsOp::pool_size * sizeof(SgIsOp));
  139280             : #elif ROSE_ALLOC_MEMSET == 3
  139281             :         memset(alloc, 0xAA, SgIsOp::pool_size * sizeof(SgIsOp));
  139282             : #endif
  139283           0 :         for (unsigned i=0; i < SgIsOp::pool_size-1; i++) {
  139284           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
  139285             :         }
  139286           0 :         alloc[SgIsOp::pool_size-1].p_freepointer = nullptr;
  139287             : 
  139288           0 :         SgIsOp::pools.push_back ( (unsigned char *) alloc );
  139289           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgIsOp::pool_size * sizeof(SgIsOp), V_SgIsOp ) );
  139290           0 :         SgIsOp::next_node = alloc;
  139291             :     }
  139292           0 :     ROSE_ASSERT(SgIsOp::next_node != nullptr);
  139293             : 
  139294           0 :     SgIsOp * object = SgIsOp::next_node;
  139295           0 :     SgIsOp::next_node = (SgIsOp*)(object->p_freepointer);
  139296             : 
  139297             : #if ROSE_ALLOC_TRACE == 2
  139298             :     printf("SgIsOp::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgIsOp::next_node);
  139299             : #endif
  139300             : 
  139301           0 :     SgNode * fp = object->p_freepointer;
  139302             : #if ROSE_ALLOC_MEMSET == 1
  139303             : #elif ROSE_ALLOC_MEMSET == 2
  139304             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgIsOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  139305             : #elif ROSE_ALLOC_MEMSET == 3
  139306             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgIsOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  139307             : #endif
  139308           0 :     object->p_freepointer = fp;
  139309             : 
  139310             : #if ROSE_ALLOC_TRACE == 2
  139311             : //    printf("SgIsOp::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgIsOp::next_node);
  139312             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  139313             :     Rose::MemPool::snapshot(oss.str());
  139314             :     alloc_trace_cnt++;
  139315             : #endif
  139316             : 
  139317           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  139318             : 
  139319           0 :     ALLOC_MUTEX(SgIsOp, unlock);
  139320             : 
  139321             :     return object;
  139322             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  139323             : }
  139324             : 
  139325             : 
  139326             : 
  139327             : /*! \brief Delete operator for SgIsOp.
  139328             : 
  139329             :    This delete operator implements deallocation using memory pools to 
  139330             :    provide most efficent use of the heap within construction of large ASTs.
  139331             : 
  139332             : \internal The new and delete operators use the lower level C malloc/free
  139333             :    function calls for performance and to make sure that mixing of malloc/free
  139334             :    and new/delete by the used can be caught more readily.  This may change
  139335             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  139336             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  139337             :    deallocate memory allocated using ROSE_MALLOC.
  139338             : */
  139339           0 : void SgIsOp::operator delete(void *Pointer, size_t Size)
  139340             : {
  139341             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  139342             :      * or throwing an exception. */
  139343           0 :     ALLOC_MUTEX(SgIsOp, lock);
  139344             : 
  139345             : #if USE_CPP_NEW_DELETE_OPERATORS
  139346             :     ROSE_FREE(Pointer);
  139347             : #else
  139348             : #if ROSE_PEDANTIC_ALLOC
  139349             :     ROSE_ASSERT(Size == sizeof(SgIsOp));
  139350             : #else
  139351           0 :     if (Size != sizeof(SgIsOp)) {
  139352           0 :       ROSE_FREE(Pointer);
  139353           0 :       ALLOC_MUTEX(SgIsOp, unlock);
  139354             :       return;
  139355             :     }
  139356             : #endif
  139357             : 
  139358           0 :     SgIsOp * object = (SgIsOp*) Pointer;
  139359           0 :     ROSE_ASSERT(object != nullptr);
  139360             : 
  139361             : #if ROSE_ALLOC_TRACE == 2
  139362             : //  printf("SgIsOp::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgIsOp::next_node);
  139363             :     printf("SgIsOp::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgIsOp::next_node);
  139364             : #endif
  139365             : 
  139366             : #if ROSE_PEDANTIC_ALLOC
  139367             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  139368             : #endif
  139369             : 
  139370             : #if ROSE_ALLOC_MEMSET == 1
  139371             : #elif ROSE_ALLOC_MEMSET == 2
  139372             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgIsOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  139373             : #elif ROSE_ALLOC_MEMSET == 3
  139374             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgIsOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  139375             : #endif
  139376             : 
  139377             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  139378             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  139379             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  139380             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  139381             : #else
  139382           0 :     object->p_freepointer = SgIsOp::next_node;
  139383           0 :     SgIsOp::next_node = object;
  139384             : #endif
  139385             : 
  139386             : #if ROSE_ALLOC_TRACE == 2
  139387             : //  printf("SgIsOp::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgIsOp::next_node);
  139388             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  139389             :     Rose::MemPool::snapshot(oss.str());
  139390             :     alloc_trace_cnt++;
  139391             : #endif
  139392             : 
  139393             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  139394             : 
  139395           0 :     ALLOC_MUTEX(SgIsOp, unlock);
  139396             : }
  139397             : 
  139398             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  139399             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  139400             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  139401             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  139402             : // Also, note comment below from Robb (copied from the Common.code file).
  139403             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  139404             : //
  139405             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  139406             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  139407             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  139408             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  139409             : #if 0
  139410             : void SgIsOp::operator delete(void* pointer) { SgIsOp::operator delete (pointer, sizeof(SgIsOp)); };
  139411             : #endif
  139412             : /* #line 139413 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  139413             : 
  139414             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  139415             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  139416             : // obviously imply C++.
  139417             : 
  139418             : // This implements the support within ROSE for memory pools.  Memory pools
  139419             : // support the most condensed usage of memory within the construction of
  139420             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  139421             : // by a new operator written for each class.
  139422             : 
  139423             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  139424             :     // User wants multi-thread support and POSIX threads are available.
  139425             : #   include <pthread.h>
  139426             :     static pthread_mutex_t SgIsNotOp_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  139427             : #else
  139428             :      // Cause synchronization to be skipped.
  139429             : #    ifndef ALLOC_MUTEX
  139430             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  139431             : #    endif
  139432             : #    ifdef _REENTRANT
  139433             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  139434             : #       ifdef _MSC_VER
  139435             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  139436             : #       else
  139437             : #           warning "POSIX threads are not available; synchronization being skipped"
  139438             : #       endif
  139439             : #    endif
  139440             : #endif
  139441             : 
  139442             : #ifndef ROSE_ALLOC_TRACE
  139443             : #  define ROSE_ALLOC_TRACE 0
  139444             : #endif
  139445             : 
  139446             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  139447             : #define ROSE_ALLOC_TRACE_CNT
  139448             : #include "memory-pool-snapshot.h"
  139449             : unsigned long alloc_trace_cnt = 0;
  139450             : #endif
  139451             : 
  139452             : #if ROSE_ALLOC_TRACE
  139453             : const unsigned SgIsNotOp::pool_size = 5;
  139454             : #else
  139455             : const unsigned SgIsNotOp::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  139456             : #endif
  139457             : 
  139458             : #ifndef ROSE_ALLOC_MEMSET
  139459             : #  define ROSE_ALLOC_MEMSET 0
  139460             : #endif
  139461             : 
  139462             : #ifndef ROSE_PEDANTIC_ALLOC
  139463             : #  define ROSE_PEDANTIC_ALLOC 0
  139464             : #endif
  139465             : 
  139466             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  139467             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  139468             : #endif
  139469             : 
  139470             : #if !defined(SGNODE__ALL_POOLS)
  139471             : #define SGNODE__ALL_POOLS
  139472             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  139473             : #endif
  139474             : 
  139475             : SgIsNotOp* SgIsNotOp::next_node = nullptr;
  139476             : std::vector<unsigned char*> SgIsNotOp::pools;
  139477             : 
  139478             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  139479             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  139480             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  139481             : // around this macro definition rather than each use).
  139482             : #ifndef ALLOC_MUTEX
  139483             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  139484             :         do {                                                                     \
  139485             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  139486             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  139487             :                 abort();                                                         \
  139488             :             }                                                                    \
  139489             :         } while (0);
  139490             : #endif
  139491             : 
  139492             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  139493             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  139494             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  139495             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  139496             : 
  139497             : /*! \brief New operator for SgIsNotOp.
  139498             : 
  139499             :    This new operator implements memory pools to provide most efficent 
  139500             :    use of the heap within construction of large ASTs.
  139501             : 
  139502             : \internal The new and delete operators use the lower level C malloc/free
  139503             :    function calls for performance and to make sure that mixing of malloc/free
  139504             :    and new/delete by the used can be caught more readily.  This may change
  139505             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  139506             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  139507             :    deallocate memory allocated using ROSE_MALLOC.
  139508             : */
  139509           0 : void *SgIsNotOp::operator new ( size_t Size )
  139510             : {
  139511             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  139512             :      * returning or throwing an exception. */
  139513           0 :     ALLOC_MUTEX(SgIsNotOp, lock);
  139514             : 
  139515             : #if ROSE_ALLOC_TRACE == 2
  139516             : //    printf("SgIsNotOp::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgIsNotOp::next_node);
  139517             : #endif
  139518             : 
  139519             : #if USE_CPP_NEW_DELETE_OPERATORS
  139520             :     void *mem = ROSE_MALLOC(Size);
  139521             :     ALLOC_MUTEX(SgIsNotOp, unlock);
  139522             :     return mem;
  139523             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  139524             : #if ROSE_PEDANTIC_ALLOC
  139525             :     ROSE_ASSERT(Size == sizeof(SgIsNotOp));
  139526             : #else
  139527           0 :     if (Size != sizeof(SgIsNotOp)) {
  139528           0 :       void * object = ROSE_MALLOC(Size);
  139529           0 :       ALLOC_MUTEX(SgIsNotOp, unlock);
  139530             :       return object;
  139531             :     }
  139532             : #endif
  139533             : 
  139534           0 :     if (SgIsNotOp::next_node == nullptr) {
  139535           0 :         SgIsNotOp * alloc = (SgIsNotOp*) ROSE_MALLOC ( SgIsNotOp::pool_size * sizeof(SgIsNotOp) );
  139536           0 :         ROSE_ASSERT(alloc != nullptr);
  139537             : 
  139538             : #if ROSE_ALLOC_TRACE == 2
  139539             : //        printf("SgIsNotOp::alloc\n  block[%zi] = [ %p , %p [\n", SgIsNotOp::pools.size(), alloc, alloc + SgIsNotOp::pool_size);
  139540             : #endif
  139541             : 
  139542             : #if ROSE_ALLOC_MEMSET == 1
  139543             : #elif ROSE_ALLOC_MEMSET == 2
  139544             :         memset(alloc, 0x00, SgIsNotOp::pool_size * sizeof(SgIsNotOp));
  139545             : #elif ROSE_ALLOC_MEMSET == 3
  139546             :         memset(alloc, 0xAA, SgIsNotOp::pool_size * sizeof(SgIsNotOp));
  139547             : #endif
  139548           0 :         for (unsigned i=0; i < SgIsNotOp::pool_size-1; i++) {
  139549           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
  139550             :         }
  139551           0 :         alloc[SgIsNotOp::pool_size-1].p_freepointer = nullptr;
  139552             : 
  139553           0 :         SgIsNotOp::pools.push_back ( (unsigned char *) alloc );
  139554           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgIsNotOp::pool_size * sizeof(SgIsNotOp), V_SgIsNotOp ) );
  139555           0 :         SgIsNotOp::next_node = alloc;
  139556             :     }
  139557           0 :     ROSE_ASSERT(SgIsNotOp::next_node != nullptr);
  139558             : 
  139559           0 :     SgIsNotOp * object = SgIsNotOp::next_node;
  139560           0 :     SgIsNotOp::next_node = (SgIsNotOp*)(object->p_freepointer);
  139561             : 
  139562             : #if ROSE_ALLOC_TRACE == 2
  139563             :     printf("SgIsNotOp::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgIsNotOp::next_node);
  139564             : #endif
  139565             : 
  139566           0 :     SgNode * fp = object->p_freepointer;
  139567             : #if ROSE_ALLOC_MEMSET == 1
  139568             : #elif ROSE_ALLOC_MEMSET == 2
  139569             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgIsNotOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  139570             : #elif ROSE_ALLOC_MEMSET == 3
  139571             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgIsNotOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  139572             : #endif
  139573           0 :     object->p_freepointer = fp;
  139574             : 
  139575             : #if ROSE_ALLOC_TRACE == 2
  139576             : //    printf("SgIsNotOp::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgIsNotOp::next_node);
  139577             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  139578             :     Rose::MemPool::snapshot(oss.str());
  139579             :     alloc_trace_cnt++;
  139580             : #endif
  139581             : 
  139582           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  139583             : 
  139584           0 :     ALLOC_MUTEX(SgIsNotOp, unlock);
  139585             : 
  139586             :     return object;
  139587             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  139588             : }
  139589             : 
  139590             : 
  139591             : 
  139592             : /*! \brief Delete operator for SgIsNotOp.
  139593             : 
  139594             :    This delete operator implements deallocation using memory pools to 
  139595             :    provide most efficent use of the heap within construction of large ASTs.
  139596             : 
  139597             : \internal The new and delete operators use the lower level C malloc/free
  139598             :    function calls for performance and to make sure that mixing of malloc/free
  139599             :    and new/delete by the used can be caught more readily.  This may change
  139600             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  139601             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  139602             :    deallocate memory allocated using ROSE_MALLOC.
  139603             : */
  139604           0 : void SgIsNotOp::operator delete(void *Pointer, size_t Size)
  139605             : {
  139606             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  139607             :      * or throwing an exception. */
  139608           0 :     ALLOC_MUTEX(SgIsNotOp, lock);
  139609             : 
  139610             : #if USE_CPP_NEW_DELETE_OPERATORS
  139611             :     ROSE_FREE(Pointer);
  139612             : #else
  139613             : #if ROSE_PEDANTIC_ALLOC
  139614             :     ROSE_ASSERT(Size == sizeof(SgIsNotOp));
  139615             : #else
  139616           0 :     if (Size != sizeof(SgIsNotOp)) {
  139617           0 :       ROSE_FREE(Pointer);
  139618           0 :       ALLOC_MUTEX(SgIsNotOp, unlock);
  139619             :       return;
  139620             :     }
  139621             : #endif
  139622             : 
  139623           0 :     SgIsNotOp * object = (SgIsNotOp*) Pointer;
  139624           0 :     ROSE_ASSERT(object != nullptr);
  139625             : 
  139626             : #if ROSE_ALLOC_TRACE == 2
  139627             : //  printf("SgIsNotOp::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgIsNotOp::next_node);
  139628             :     printf("SgIsNotOp::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgIsNotOp::next_node);
  139629             : #endif
  139630             : 
  139631             : #if ROSE_PEDANTIC_ALLOC
  139632             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  139633             : #endif
  139634             : 
  139635             : #if ROSE_ALLOC_MEMSET == 1
  139636             : #elif ROSE_ALLOC_MEMSET == 2
  139637             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgIsNotOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  139638             : #elif ROSE_ALLOC_MEMSET == 3
  139639             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgIsNotOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  139640             : #endif
  139641             : 
  139642             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  139643             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  139644             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  139645             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  139646             : #else
  139647           0 :     object->p_freepointer = SgIsNotOp::next_node;
  139648           0 :     SgIsNotOp::next_node = object;
  139649             : #endif
  139650             : 
  139651             : #if ROSE_ALLOC_TRACE == 2
  139652             : //  printf("SgIsNotOp::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgIsNotOp::next_node);
  139653             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  139654             :     Rose::MemPool::snapshot(oss.str());
  139655             :     alloc_trace_cnt++;
  139656             : #endif
  139657             : 
  139658             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  139659             : 
  139660           0 :     ALLOC_MUTEX(SgIsNotOp, unlock);
  139661             : }
  139662             : 
  139663             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  139664             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  139665             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  139666             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  139667             : // Also, note comment below from Robb (copied from the Common.code file).
  139668             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  139669             : //
  139670             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  139671             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  139672             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  139673             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  139674             : #if 0
  139675             : void SgIsNotOp::operator delete(void* pointer) { SgIsNotOp::operator delete (pointer, sizeof(SgIsNotOp)); };
  139676             : #endif
  139677             : /* #line 139678 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  139678             : 
  139679             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  139680             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  139681             : // obviously imply C++.
  139682             : 
  139683             : // This implements the support within ROSE for memory pools.  Memory pools
  139684             : // support the most condensed usage of memory within the construction of
  139685             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  139686             : // by a new operator written for each class.
  139687             : 
  139688             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  139689             :     // User wants multi-thread support and POSIX threads are available.
  139690             : #   include <pthread.h>
  139691             :     static pthread_mutex_t SgElementwiseOp_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  139692             : #else
  139693             :      // Cause synchronization to be skipped.
  139694             : #    ifndef ALLOC_MUTEX
  139695             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  139696             : #    endif
  139697             : #    ifdef _REENTRANT
  139698             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  139699             : #       ifdef _MSC_VER
  139700             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  139701             : #       else
  139702             : #           warning "POSIX threads are not available; synchronization being skipped"
  139703             : #       endif
  139704             : #    endif
  139705             : #endif
  139706             : 
  139707             : #ifndef ROSE_ALLOC_TRACE
  139708             : #  define ROSE_ALLOC_TRACE 0
  139709             : #endif
  139710             : 
  139711             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  139712             : #define ROSE_ALLOC_TRACE_CNT
  139713             : #include "memory-pool-snapshot.h"
  139714             : unsigned long alloc_trace_cnt = 0;
  139715             : #endif
  139716             : 
  139717             : #if ROSE_ALLOC_TRACE
  139718             : const unsigned SgElementwiseOp::pool_size = 5;
  139719             : #else
  139720             : const unsigned SgElementwiseOp::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  139721             : #endif
  139722             : 
  139723             : #ifndef ROSE_ALLOC_MEMSET
  139724             : #  define ROSE_ALLOC_MEMSET 0
  139725             : #endif
  139726             : 
  139727             : #ifndef ROSE_PEDANTIC_ALLOC
  139728             : #  define ROSE_PEDANTIC_ALLOC 0
  139729             : #endif
  139730             : 
  139731             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  139732             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  139733             : #endif
  139734             : 
  139735             : #if !defined(SGNODE__ALL_POOLS)
  139736             : #define SGNODE__ALL_POOLS
  139737             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  139738             : #endif
  139739             : 
  139740             : SgElementwiseOp* SgElementwiseOp::next_node = nullptr;
  139741             : std::vector<unsigned char*> SgElementwiseOp::pools;
  139742             : 
  139743             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  139744             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  139745             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  139746             : // around this macro definition rather than each use).
  139747             : #ifndef ALLOC_MUTEX
  139748             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  139749             :         do {                                                                     \
  139750             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  139751             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  139752             :                 abort();                                                         \
  139753             :             }                                                                    \
  139754             :         } while (0);
  139755             : #endif
  139756             : 
  139757             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  139758             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  139759             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  139760             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  139761             : 
  139762             : /*! \brief New operator for SgElementwiseOp.
  139763             : 
  139764             :    This new operator implements memory pools to provide most efficent 
  139765             :    use of the heap within construction of large ASTs.
  139766             : 
  139767             : \internal The new and delete operators use the lower level C malloc/free
  139768             :    function calls for performance and to make sure that mixing of malloc/free
  139769             :    and new/delete by the used can be caught more readily.  This may change
  139770             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  139771             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  139772             :    deallocate memory allocated using ROSE_MALLOC.
  139773             : */
  139774           0 : void *SgElementwiseOp::operator new ( size_t Size )
  139775             : {
  139776             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  139777             :      * returning or throwing an exception. */
  139778           0 :     ALLOC_MUTEX(SgElementwiseOp, lock);
  139779             : 
  139780             : #if ROSE_ALLOC_TRACE == 2
  139781             : //    printf("SgElementwiseOp::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgElementwiseOp::next_node);
  139782             : #endif
  139783             : 
  139784             : #if USE_CPP_NEW_DELETE_OPERATORS
  139785             :     void *mem = ROSE_MALLOC(Size);
  139786             :     ALLOC_MUTEX(SgElementwiseOp, unlock);
  139787             :     return mem;
  139788             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  139789             : #if ROSE_PEDANTIC_ALLOC
  139790             :     ROSE_ASSERT(Size == sizeof(SgElementwiseOp));
  139791             : #else
  139792           0 :     if (Size != sizeof(SgElementwiseOp)) {
  139793           0 :       void * object = ROSE_MALLOC(Size);
  139794           0 :       ALLOC_MUTEX(SgElementwiseOp, unlock);
  139795             :       return object;
  139796             :     }
  139797             : #endif
  139798             : 
  139799           0 :     if (SgElementwiseOp::next_node == nullptr) {
  139800           0 :         SgElementwiseOp * alloc = (SgElementwiseOp*) ROSE_MALLOC ( SgElementwiseOp::pool_size * sizeof(SgElementwiseOp) );
  139801           0 :         ROSE_ASSERT(alloc != nullptr);
  139802             : 
  139803             : #if ROSE_ALLOC_TRACE == 2
  139804             : //        printf("SgElementwiseOp::alloc\n  block[%zi] = [ %p , %p [\n", SgElementwiseOp::pools.size(), alloc, alloc + SgElementwiseOp::pool_size);
  139805             : #endif
  139806             : 
  139807             : #if ROSE_ALLOC_MEMSET == 1
  139808             : #elif ROSE_ALLOC_MEMSET == 2
  139809             :         memset(alloc, 0x00, SgElementwiseOp::pool_size * sizeof(SgElementwiseOp));
  139810             : #elif ROSE_ALLOC_MEMSET == 3
  139811             :         memset(alloc, 0xAA, SgElementwiseOp::pool_size * sizeof(SgElementwiseOp));
  139812             : #endif
  139813           0 :         for (unsigned i=0; i < SgElementwiseOp::pool_size-1; i++) {
  139814           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
  139815             :         }
  139816           0 :         alloc[SgElementwiseOp::pool_size-1].p_freepointer = nullptr;
  139817             : 
  139818           0 :         SgElementwiseOp::pools.push_back ( (unsigned char *) alloc );
  139819           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgElementwiseOp::pool_size * sizeof(SgElementwiseOp), V_SgElementwiseOp ) );
  139820           0 :         SgElementwiseOp::next_node = alloc;
  139821             :     }
  139822           0 :     ROSE_ASSERT(SgElementwiseOp::next_node != nullptr);
  139823             : 
  139824           0 :     SgElementwiseOp * object = SgElementwiseOp::next_node;
  139825           0 :     SgElementwiseOp::next_node = (SgElementwiseOp*)(object->p_freepointer);
  139826             : 
  139827             : #if ROSE_ALLOC_TRACE == 2
  139828             :     printf("SgElementwiseOp::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgElementwiseOp::next_node);
  139829             : #endif
  139830             : 
  139831           0 :     SgNode * fp = object->p_freepointer;
  139832             : #if ROSE_ALLOC_MEMSET == 1
  139833             : #elif ROSE_ALLOC_MEMSET == 2
  139834             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgElementwiseOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  139835             : #elif ROSE_ALLOC_MEMSET == 3
  139836             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgElementwiseOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  139837             : #endif
  139838           0 :     object->p_freepointer = fp;
  139839             : 
  139840             : #if ROSE_ALLOC_TRACE == 2
  139841             : //    printf("SgElementwiseOp::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgElementwiseOp::next_node);
  139842             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  139843             :     Rose::MemPool::snapshot(oss.str());
  139844             :     alloc_trace_cnt++;
  139845             : #endif
  139846             : 
  139847           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  139848             : 
  139849           0 :     ALLOC_MUTEX(SgElementwiseOp, unlock);
  139850             : 
  139851             :     return object;
  139852             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  139853             : }
  139854             : 
  139855             : 
  139856             : 
  139857             : /*! \brief Delete operator for SgElementwiseOp.
  139858             : 
  139859             :    This delete operator implements deallocation using memory pools to 
  139860             :    provide most efficent use of the heap within construction of large ASTs.
  139861             : 
  139862             : \internal The new and delete operators use the lower level C malloc/free
  139863             :    function calls for performance and to make sure that mixing of malloc/free
  139864             :    and new/delete by the used can be caught more readily.  This may change
  139865             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  139866             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  139867             :    deallocate memory allocated using ROSE_MALLOC.
  139868             : */
  139869           0 : void SgElementwiseOp::operator delete(void *Pointer, size_t Size)
  139870             : {
  139871             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  139872             :      * or throwing an exception. */
  139873           0 :     ALLOC_MUTEX(SgElementwiseOp, lock);
  139874             : 
  139875             : #if USE_CPP_NEW_DELETE_OPERATORS
  139876             :     ROSE_FREE(Pointer);
  139877             : #else
  139878             : #if ROSE_PEDANTIC_ALLOC
  139879             :     ROSE_ASSERT(Size == sizeof(SgElementwiseOp));
  139880             : #else
  139881           0 :     if (Size != sizeof(SgElementwiseOp)) {
  139882           0 :       ROSE_FREE(Pointer);
  139883           0 :       ALLOC_MUTEX(SgElementwiseOp, unlock);
  139884             :       return;
  139885             :     }
  139886             : #endif
  139887             : 
  139888           0 :     SgElementwiseOp * object = (SgElementwiseOp*) Pointer;
  139889           0 :     ROSE_ASSERT(object != nullptr);
  139890             : 
  139891             : #if ROSE_ALLOC_TRACE == 2
  139892             : //  printf("SgElementwiseOp::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgElementwiseOp::next_node);
  139893             :     printf("SgElementwiseOp::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgElementwiseOp::next_node);
  139894             : #endif
  139895             : 
  139896             : #if ROSE_PEDANTIC_ALLOC
  139897             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  139898             : #endif
  139899             : 
  139900             : #if ROSE_ALLOC_MEMSET == 1
  139901             : #elif ROSE_ALLOC_MEMSET == 2
  139902             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgElementwiseOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  139903             : #elif ROSE_ALLOC_MEMSET == 3
  139904             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgElementwiseOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  139905             : #endif
  139906             : 
  139907             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  139908             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  139909             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  139910             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  139911             : #else
  139912           0 :     object->p_freepointer = SgElementwiseOp::next_node;
  139913           0 :     SgElementwiseOp::next_node = object;
  139914             : #endif
  139915             : 
  139916             : #if ROSE_ALLOC_TRACE == 2
  139917             : //  printf("SgElementwiseOp::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgElementwiseOp::next_node);
  139918             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  139919             :     Rose::MemPool::snapshot(oss.str());
  139920             :     alloc_trace_cnt++;
  139921             : #endif
  139922             : 
  139923             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  139924             : 
  139925           0 :     ALLOC_MUTEX(SgElementwiseOp, unlock);
  139926             : }
  139927             : 
  139928             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  139929             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  139930             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  139931             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  139932             : // Also, note comment below from Robb (copied from the Common.code file).
  139933             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  139934             : //
  139935             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  139936             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  139937             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  139938             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  139939             : #if 0
  139940             : void SgElementwiseOp::operator delete(void* pointer) { SgElementwiseOp::operator delete (pointer, sizeof(SgElementwiseOp)); };
  139941             : #endif
  139942             : /* #line 139943 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  139943             : 
  139944             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  139945             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  139946             : // obviously imply C++.
  139947             : 
  139948             : // This implements the support within ROSE for memory pools.  Memory pools
  139949             : // support the most condensed usage of memory within the construction of
  139950             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  139951             : // by a new operator written for each class.
  139952             : 
  139953             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  139954             :     // User wants multi-thread support and POSIX threads are available.
  139955             : #   include <pthread.h>
  139956             :     static pthread_mutex_t SgElementwiseMultiplyOp_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  139957             : #else
  139958             :      // Cause synchronization to be skipped.
  139959             : #    ifndef ALLOC_MUTEX
  139960             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  139961             : #    endif
  139962             : #    ifdef _REENTRANT
  139963             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  139964             : #       ifdef _MSC_VER
  139965             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  139966             : #       else
  139967             : #           warning "POSIX threads are not available; synchronization being skipped"
  139968             : #       endif
  139969             : #    endif
  139970             : #endif
  139971             : 
  139972             : #ifndef ROSE_ALLOC_TRACE
  139973             : #  define ROSE_ALLOC_TRACE 0
  139974             : #endif
  139975             : 
  139976             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  139977             : #define ROSE_ALLOC_TRACE_CNT
  139978             : #include "memory-pool-snapshot.h"
  139979             : unsigned long alloc_trace_cnt = 0;
  139980             : #endif
  139981             : 
  139982             : #if ROSE_ALLOC_TRACE
  139983             : const unsigned SgElementwiseMultiplyOp::pool_size = 5;
  139984             : #else
  139985             : const unsigned SgElementwiseMultiplyOp::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  139986             : #endif
  139987             : 
  139988             : #ifndef ROSE_ALLOC_MEMSET
  139989             : #  define ROSE_ALLOC_MEMSET 0
  139990             : #endif
  139991             : 
  139992             : #ifndef ROSE_PEDANTIC_ALLOC
  139993             : #  define ROSE_PEDANTIC_ALLOC 0
  139994             : #endif
  139995             : 
  139996             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  139997             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  139998             : #endif
  139999             : 
  140000             : #if !defined(SGNODE__ALL_POOLS)
  140001             : #define SGNODE__ALL_POOLS
  140002             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  140003             : #endif
  140004             : 
  140005             : SgElementwiseMultiplyOp* SgElementwiseMultiplyOp::next_node = nullptr;
  140006             : std::vector<unsigned char*> SgElementwiseMultiplyOp::pools;
  140007             : 
  140008             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  140009             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  140010             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  140011             : // around this macro definition rather than each use).
  140012             : #ifndef ALLOC_MUTEX
  140013             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  140014             :         do {                                                                     \
  140015             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  140016             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  140017             :                 abort();                                                         \
  140018             :             }                                                                    \
  140019             :         } while (0);
  140020             : #endif
  140021             : 
  140022             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  140023             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  140024             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  140025             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  140026             : 
  140027             : /*! \brief New operator for SgElementwiseMultiplyOp.
  140028             : 
  140029             :    This new operator implements memory pools to provide most efficent 
  140030             :    use of the heap within construction of large ASTs.
  140031             : 
  140032             : \internal The new and delete operators use the lower level C malloc/free
  140033             :    function calls for performance and to make sure that mixing of malloc/free
  140034             :    and new/delete by the used can be caught more readily.  This may change
  140035             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  140036             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  140037             :    deallocate memory allocated using ROSE_MALLOC.
  140038             : */
  140039           0 : void *SgElementwiseMultiplyOp::operator new ( size_t Size )
  140040             : {
  140041             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  140042             :      * returning or throwing an exception. */
  140043           0 :     ALLOC_MUTEX(SgElementwiseMultiplyOp, lock);
  140044             : 
  140045             : #if ROSE_ALLOC_TRACE == 2
  140046             : //    printf("SgElementwiseMultiplyOp::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgElementwiseMultiplyOp::next_node);
  140047             : #endif
  140048             : 
  140049             : #if USE_CPP_NEW_DELETE_OPERATORS
  140050             :     void *mem = ROSE_MALLOC(Size);
  140051             :     ALLOC_MUTEX(SgElementwiseMultiplyOp, unlock);
  140052             :     return mem;
  140053             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  140054             : #if ROSE_PEDANTIC_ALLOC
  140055             :     ROSE_ASSERT(Size == sizeof(SgElementwiseMultiplyOp));
  140056             : #else
  140057           0 :     if (Size != sizeof(SgElementwiseMultiplyOp)) {
  140058           0 :       void * object = ROSE_MALLOC(Size);
  140059           0 :       ALLOC_MUTEX(SgElementwiseMultiplyOp, unlock);
  140060             :       return object;
  140061             :     }
  140062             : #endif
  140063             : 
  140064           0 :     if (SgElementwiseMultiplyOp::next_node == nullptr) {
  140065           0 :         SgElementwiseMultiplyOp * alloc = (SgElementwiseMultiplyOp*) ROSE_MALLOC ( SgElementwiseMultiplyOp::pool_size * sizeof(SgElementwiseMultiplyOp) );
  140066           0 :         ROSE_ASSERT(alloc != nullptr);
  140067             : 
  140068             : #if ROSE_ALLOC_TRACE == 2
  140069             : //        printf("SgElementwiseMultiplyOp::alloc\n  block[%zi] = [ %p , %p [\n", SgElementwiseMultiplyOp::pools.size(), alloc, alloc + SgElementwiseMultiplyOp::pool_size);
  140070             : #endif
  140071             : 
  140072             : #if ROSE_ALLOC_MEMSET == 1
  140073             : #elif ROSE_ALLOC_MEMSET == 2
  140074             :         memset(alloc, 0x00, SgElementwiseMultiplyOp::pool_size * sizeof(SgElementwiseMultiplyOp));
  140075             : #elif ROSE_ALLOC_MEMSET == 3
  140076             :         memset(alloc, 0xAA, SgElementwiseMultiplyOp::pool_size * sizeof(SgElementwiseMultiplyOp));
  140077             : #endif
  140078           0 :         for (unsigned i=0; i < SgElementwiseMultiplyOp::pool_size-1; i++) {
  140079           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
  140080             :         }
  140081           0 :         alloc[SgElementwiseMultiplyOp::pool_size-1].p_freepointer = nullptr;
  140082             : 
  140083           0 :         SgElementwiseMultiplyOp::pools.push_back ( (unsigned char *) alloc );
  140084           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgElementwiseMultiplyOp::pool_size * sizeof(SgElementwiseMultiplyOp), V_SgElementwiseMultiplyOp ) );
  140085           0 :         SgElementwiseMultiplyOp::next_node = alloc;
  140086             :     }
  140087           0 :     ROSE_ASSERT(SgElementwiseMultiplyOp::next_node != nullptr);
  140088             : 
  140089           0 :     SgElementwiseMultiplyOp * object = SgElementwiseMultiplyOp::next_node;
  140090           0 :     SgElementwiseMultiplyOp::next_node = (SgElementwiseMultiplyOp*)(object->p_freepointer);
  140091             : 
  140092             : #if ROSE_ALLOC_TRACE == 2
  140093             :     printf("SgElementwiseMultiplyOp::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgElementwiseMultiplyOp::next_node);
  140094             : #endif
  140095             : 
  140096           0 :     SgNode * fp = object->p_freepointer;
  140097             : #if ROSE_ALLOC_MEMSET == 1
  140098             : #elif ROSE_ALLOC_MEMSET == 2
  140099             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgElementwiseMultiplyOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  140100             : #elif ROSE_ALLOC_MEMSET == 3
  140101             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgElementwiseMultiplyOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  140102             : #endif
  140103           0 :     object->p_freepointer = fp;
  140104             : 
  140105             : #if ROSE_ALLOC_TRACE == 2
  140106             : //    printf("SgElementwiseMultiplyOp::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgElementwiseMultiplyOp::next_node);
  140107             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  140108             :     Rose::MemPool::snapshot(oss.str());
  140109             :     alloc_trace_cnt++;
  140110             : #endif
  140111             : 
  140112           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  140113             : 
  140114           0 :     ALLOC_MUTEX(SgElementwiseMultiplyOp, unlock);
  140115             : 
  140116             :     return object;
  140117             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  140118             : }
  140119             : 
  140120             : 
  140121             : 
  140122             : /*! \brief Delete operator for SgElementwiseMultiplyOp.
  140123             : 
  140124             :    This delete operator implements deallocation using memory pools to 
  140125             :    provide most efficent use of the heap within construction of large ASTs.
  140126             : 
  140127             : \internal The new and delete operators use the lower level C malloc/free
  140128             :    function calls for performance and to make sure that mixing of malloc/free
  140129             :    and new/delete by the used can be caught more readily.  This may change
  140130             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  140131             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  140132             :    deallocate memory allocated using ROSE_MALLOC.
  140133             : */
  140134           0 : void SgElementwiseMultiplyOp::operator delete(void *Pointer, size_t Size)
  140135             : {
  140136             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  140137             :      * or throwing an exception. */
  140138           0 :     ALLOC_MUTEX(SgElementwiseMultiplyOp, lock);
  140139             : 
  140140             : #if USE_CPP_NEW_DELETE_OPERATORS
  140141             :     ROSE_FREE(Pointer);
  140142             : #else
  140143             : #if ROSE_PEDANTIC_ALLOC
  140144             :     ROSE_ASSERT(Size == sizeof(SgElementwiseMultiplyOp));
  140145             : #else
  140146           0 :     if (Size != sizeof(SgElementwiseMultiplyOp)) {
  140147           0 :       ROSE_FREE(Pointer);
  140148           0 :       ALLOC_MUTEX(SgElementwiseMultiplyOp, unlock);
  140149             :       return;
  140150             :     }
  140151             : #endif
  140152             : 
  140153           0 :     SgElementwiseMultiplyOp * object = (SgElementwiseMultiplyOp*) Pointer;
  140154           0 :     ROSE_ASSERT(object != nullptr);
  140155             : 
  140156             : #if ROSE_ALLOC_TRACE == 2
  140157             : //  printf("SgElementwiseMultiplyOp::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgElementwiseMultiplyOp::next_node);
  140158             :     printf("SgElementwiseMultiplyOp::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgElementwiseMultiplyOp::next_node);
  140159             : #endif
  140160             : 
  140161             : #if ROSE_PEDANTIC_ALLOC
  140162             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  140163             : #endif
  140164             : 
  140165             : #if ROSE_ALLOC_MEMSET == 1
  140166             : #elif ROSE_ALLOC_MEMSET == 2
  140167             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgElementwiseMultiplyOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  140168             : #elif ROSE_ALLOC_MEMSET == 3
  140169             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgElementwiseMultiplyOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  140170             : #endif
  140171             : 
  140172             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  140173             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  140174             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  140175             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  140176             : #else
  140177           0 :     object->p_freepointer = SgElementwiseMultiplyOp::next_node;
  140178           0 :     SgElementwiseMultiplyOp::next_node = object;
  140179             : #endif
  140180             : 
  140181             : #if ROSE_ALLOC_TRACE == 2
  140182             : //  printf("SgElementwiseMultiplyOp::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgElementwiseMultiplyOp::next_node);
  140183             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  140184             :     Rose::MemPool::snapshot(oss.str());
  140185             :     alloc_trace_cnt++;
  140186             : #endif
  140187             : 
  140188             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  140189             : 
  140190           0 :     ALLOC_MUTEX(SgElementwiseMultiplyOp, unlock);
  140191             : }
  140192             : 
  140193             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  140194             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  140195             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  140196             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  140197             : // Also, note comment below from Robb (copied from the Common.code file).
  140198             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  140199             : //
  140200             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  140201             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  140202             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  140203             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  140204             : #if 0
  140205             : void SgElementwiseMultiplyOp::operator delete(void* pointer) { SgElementwiseMultiplyOp::operator delete (pointer, sizeof(SgElementwiseMultiplyOp)); };
  140206             : #endif
  140207             : /* #line 140208 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  140208             : 
  140209             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  140210             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  140211             : // obviously imply C++.
  140212             : 
  140213             : // This implements the support within ROSE for memory pools.  Memory pools
  140214             : // support the most condensed usage of memory within the construction of
  140215             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  140216             : // by a new operator written for each class.
  140217             : 
  140218             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  140219             :     // User wants multi-thread support and POSIX threads are available.
  140220             : #   include <pthread.h>
  140221             :     static pthread_mutex_t SgElementwisePowerOp_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  140222             : #else
  140223             :      // Cause synchronization to be skipped.
  140224             : #    ifndef ALLOC_MUTEX
  140225             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  140226             : #    endif
  140227             : #    ifdef _REENTRANT
  140228             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  140229             : #       ifdef _MSC_VER
  140230             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  140231             : #       else
  140232             : #           warning "POSIX threads are not available; synchronization being skipped"
  140233             : #       endif
  140234             : #    endif
  140235             : #endif
  140236             : 
  140237             : #ifndef ROSE_ALLOC_TRACE
  140238             : #  define ROSE_ALLOC_TRACE 0
  140239             : #endif
  140240             : 
  140241             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  140242             : #define ROSE_ALLOC_TRACE_CNT
  140243             : #include "memory-pool-snapshot.h"
  140244             : unsigned long alloc_trace_cnt = 0;
  140245             : #endif
  140246             : 
  140247             : #if ROSE_ALLOC_TRACE
  140248             : const unsigned SgElementwisePowerOp::pool_size = 5;
  140249             : #else
  140250             : const unsigned SgElementwisePowerOp::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  140251             : #endif
  140252             : 
  140253             : #ifndef ROSE_ALLOC_MEMSET
  140254             : #  define ROSE_ALLOC_MEMSET 0
  140255             : #endif
  140256             : 
  140257             : #ifndef ROSE_PEDANTIC_ALLOC
  140258             : #  define ROSE_PEDANTIC_ALLOC 0
  140259             : #endif
  140260             : 
  140261             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  140262             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  140263             : #endif
  140264             : 
  140265             : #if !defined(SGNODE__ALL_POOLS)
  140266             : #define SGNODE__ALL_POOLS
  140267             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  140268             : #endif
  140269             : 
  140270             : SgElementwisePowerOp* SgElementwisePowerOp::next_node = nullptr;
  140271             : std::vector<unsigned char*> SgElementwisePowerOp::pools;
  140272             : 
  140273             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  140274             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  140275             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  140276             : // around this macro definition rather than each use).
  140277             : #ifndef ALLOC_MUTEX
  140278             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  140279             :         do {                                                                     \
  140280             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  140281             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  140282             :                 abort();                                                         \
  140283             :             }                                                                    \
  140284             :         } while (0);
  140285             : #endif
  140286             : 
  140287             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  140288             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  140289             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  140290             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  140291             : 
  140292             : /*! \brief New operator for SgElementwisePowerOp.
  140293             : 
  140294             :    This new operator implements memory pools to provide most efficent 
  140295             :    use of the heap within construction of large ASTs.
  140296             : 
  140297             : \internal The new and delete operators use the lower level C malloc/free
  140298             :    function calls for performance and to make sure that mixing of malloc/free
  140299             :    and new/delete by the used can be caught more readily.  This may change
  140300             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  140301             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  140302             :    deallocate memory allocated using ROSE_MALLOC.
  140303             : */
  140304           0 : void *SgElementwisePowerOp::operator new ( size_t Size )
  140305             : {
  140306             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  140307             :      * returning or throwing an exception. */
  140308           0 :     ALLOC_MUTEX(SgElementwisePowerOp, lock);
  140309             : 
  140310             : #if ROSE_ALLOC_TRACE == 2
  140311             : //    printf("SgElementwisePowerOp::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgElementwisePowerOp::next_node);
  140312             : #endif
  140313             : 
  140314             : #if USE_CPP_NEW_DELETE_OPERATORS
  140315             :     void *mem = ROSE_MALLOC(Size);
  140316             :     ALLOC_MUTEX(SgElementwisePowerOp, unlock);
  140317             :     return mem;
  140318             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  140319             : #if ROSE_PEDANTIC_ALLOC
  140320             :     ROSE_ASSERT(Size == sizeof(SgElementwisePowerOp));
  140321             : #else
  140322           0 :     if (Size != sizeof(SgElementwisePowerOp)) {
  140323           0 :       void * object = ROSE_MALLOC(Size);
  140324           0 :       ALLOC_MUTEX(SgElementwisePowerOp, unlock);
  140325             :       return object;
  140326             :     }
  140327             : #endif
  140328             : 
  140329           0 :     if (SgElementwisePowerOp::next_node == nullptr) {
  140330           0 :         SgElementwisePowerOp * alloc = (SgElementwisePowerOp*) ROSE_MALLOC ( SgElementwisePowerOp::pool_size * sizeof(SgElementwisePowerOp) );
  140331           0 :         ROSE_ASSERT(alloc != nullptr);
  140332             : 
  140333             : #if ROSE_ALLOC_TRACE == 2
  140334             : //        printf("SgElementwisePowerOp::alloc\n  block[%zi] = [ %p , %p [\n", SgElementwisePowerOp::pools.size(), alloc, alloc + SgElementwisePowerOp::pool_size);
  140335             : #endif
  140336             : 
  140337             : #if ROSE_ALLOC_MEMSET == 1
  140338             : #elif ROSE_ALLOC_MEMSET == 2
  140339             :         memset(alloc, 0x00, SgElementwisePowerOp::pool_size * sizeof(SgElementwisePowerOp));
  140340             : #elif ROSE_ALLOC_MEMSET == 3
  140341             :         memset(alloc, 0xAA, SgElementwisePowerOp::pool_size * sizeof(SgElementwisePowerOp));
  140342             : #endif
  140343           0 :         for (unsigned i=0; i < SgElementwisePowerOp::pool_size-1; i++) {
  140344           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
  140345             :         }
  140346           0 :         alloc[SgElementwisePowerOp::pool_size-1].p_freepointer = nullptr;
  140347             : 
  140348           0 :         SgElementwisePowerOp::pools.push_back ( (unsigned char *) alloc );
  140349           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgElementwisePowerOp::pool_size * sizeof(SgElementwisePowerOp), V_SgElementwisePowerOp ) );
  140350           0 :         SgElementwisePowerOp::next_node = alloc;
  140351             :     }
  140352           0 :     ROSE_ASSERT(SgElementwisePowerOp::next_node != nullptr);
  140353             : 
  140354           0 :     SgElementwisePowerOp * object = SgElementwisePowerOp::next_node;
  140355           0 :     SgElementwisePowerOp::next_node = (SgElementwisePowerOp*)(object->p_freepointer);
  140356             : 
  140357             : #if ROSE_ALLOC_TRACE == 2
  140358             :     printf("SgElementwisePowerOp::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgElementwisePowerOp::next_node);
  140359             : #endif
  140360             : 
  140361           0 :     SgNode * fp = object->p_freepointer;
  140362             : #if ROSE_ALLOC_MEMSET == 1
  140363             : #elif ROSE_ALLOC_MEMSET == 2
  140364             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgElementwisePowerOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  140365             : #elif ROSE_ALLOC_MEMSET == 3
  140366             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgElementwisePowerOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  140367             : #endif
  140368           0 :     object->p_freepointer = fp;
  140369             : 
  140370             : #if ROSE_ALLOC_TRACE == 2
  140371             : //    printf("SgElementwisePowerOp::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgElementwisePowerOp::next_node);
  140372             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  140373             :     Rose::MemPool::snapshot(oss.str());
  140374             :     alloc_trace_cnt++;
  140375             : #endif
  140376             : 
  140377           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  140378             : 
  140379           0 :     ALLOC_MUTEX(SgElementwisePowerOp, unlock);
  140380             : 
  140381             :     return object;
  140382             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  140383             : }
  140384             : 
  140385             : 
  140386             : 
  140387             : /*! \brief Delete operator for SgElementwisePowerOp.
  140388             : 
  140389             :    This delete operator implements deallocation using memory pools to 
  140390             :    provide most efficent use of the heap within construction of large ASTs.
  140391             : 
  140392             : \internal The new and delete operators use the lower level C malloc/free
  140393             :    function calls for performance and to make sure that mixing of malloc/free
  140394             :    and new/delete by the used can be caught more readily.  This may change
  140395             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  140396             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  140397             :    deallocate memory allocated using ROSE_MALLOC.
  140398             : */
  140399           0 : void SgElementwisePowerOp::operator delete(void *Pointer, size_t Size)
  140400             : {
  140401             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  140402             :      * or throwing an exception. */
  140403           0 :     ALLOC_MUTEX(SgElementwisePowerOp, lock);
  140404             : 
  140405             : #if USE_CPP_NEW_DELETE_OPERATORS
  140406             :     ROSE_FREE(Pointer);
  140407             : #else
  140408             : #if ROSE_PEDANTIC_ALLOC
  140409             :     ROSE_ASSERT(Size == sizeof(SgElementwisePowerOp));
  140410             : #else
  140411           0 :     if (Size != sizeof(SgElementwisePowerOp)) {
  140412           0 :       ROSE_FREE(Pointer);
  140413           0 :       ALLOC_MUTEX(SgElementwisePowerOp, unlock);
  140414             :       return;
  140415             :     }
  140416             : #endif
  140417             : 
  140418           0 :     SgElementwisePowerOp * object = (SgElementwisePowerOp*) Pointer;
  140419           0 :     ROSE_ASSERT(object != nullptr);
  140420             : 
  140421             : #if ROSE_ALLOC_TRACE == 2
  140422             : //  printf("SgElementwisePowerOp::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgElementwisePowerOp::next_node);
  140423             :     printf("SgElementwisePowerOp::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgElementwisePowerOp::next_node);
  140424             : #endif
  140425             : 
  140426             : #if ROSE_PEDANTIC_ALLOC
  140427             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  140428             : #endif
  140429             : 
  140430             : #if ROSE_ALLOC_MEMSET == 1
  140431             : #elif ROSE_ALLOC_MEMSET == 2
  140432             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgElementwisePowerOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  140433             : #elif ROSE_ALLOC_MEMSET == 3
  140434             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgElementwisePowerOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  140435             : #endif
  140436             : 
  140437             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  140438             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  140439             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  140440             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  140441             : #else
  140442           0 :     object->p_freepointer = SgElementwisePowerOp::next_node;
  140443           0 :     SgElementwisePowerOp::next_node = object;
  140444             : #endif
  140445             : 
  140446             : #if ROSE_ALLOC_TRACE == 2
  140447             : //  printf("SgElementwisePowerOp::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgElementwisePowerOp::next_node);
  140448             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  140449             :     Rose::MemPool::snapshot(oss.str());
  140450             :     alloc_trace_cnt++;
  140451             : #endif
  140452             : 
  140453             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  140454             : 
  140455           0 :     ALLOC_MUTEX(SgElementwisePowerOp, unlock);
  140456             : }
  140457             : 
  140458             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  140459             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  140460             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  140461             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  140462             : // Also, note comment below from Robb (copied from the Common.code file).
  140463             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  140464             : //
  140465             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  140466             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  140467             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  140468             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  140469             : #if 0
  140470             : void SgElementwisePowerOp::operator delete(void* pointer) { SgElementwisePowerOp::operator delete (pointer, sizeof(SgElementwisePowerOp)); };
  140471             : #endif
  140472             : /* #line 140473 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  140473             : 
  140474             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  140475             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  140476             : // obviously imply C++.
  140477             : 
  140478             : // This implements the support within ROSE for memory pools.  Memory pools
  140479             : // support the most condensed usage of memory within the construction of
  140480             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  140481             : // by a new operator written for each class.
  140482             : 
  140483             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  140484             :     // User wants multi-thread support and POSIX threads are available.
  140485             : #   include <pthread.h>
  140486             :     static pthread_mutex_t SgElementwiseLeftDivideOp_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  140487             : #else
  140488             :      // Cause synchronization to be skipped.
  140489             : #    ifndef ALLOC_MUTEX
  140490             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  140491             : #    endif
  140492             : #    ifdef _REENTRANT
  140493             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  140494             : #       ifdef _MSC_VER
  140495             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  140496             : #       else
  140497             : #           warning "POSIX threads are not available; synchronization being skipped"
  140498             : #       endif
  140499             : #    endif
  140500             : #endif
  140501             : 
  140502             : #ifndef ROSE_ALLOC_TRACE
  140503             : #  define ROSE_ALLOC_TRACE 0
  140504             : #endif
  140505             : 
  140506             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  140507             : #define ROSE_ALLOC_TRACE_CNT
  140508             : #include "memory-pool-snapshot.h"
  140509             : unsigned long alloc_trace_cnt = 0;
  140510             : #endif
  140511             : 
  140512             : #if ROSE_ALLOC_TRACE
  140513             : const unsigned SgElementwiseLeftDivideOp::pool_size = 5;
  140514             : #else
  140515             : const unsigned SgElementwiseLeftDivideOp::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  140516             : #endif
  140517             : 
  140518             : #ifndef ROSE_ALLOC_MEMSET
  140519             : #  define ROSE_ALLOC_MEMSET 0
  140520             : #endif
  140521             : 
  140522             : #ifndef ROSE_PEDANTIC_ALLOC
  140523             : #  define ROSE_PEDANTIC_ALLOC 0
  140524             : #endif
  140525             : 
  140526             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  140527             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  140528             : #endif
  140529             : 
  140530             : #if !defined(SGNODE__ALL_POOLS)
  140531             : #define SGNODE__ALL_POOLS
  140532             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  140533             : #endif
  140534             : 
  140535             : SgElementwiseLeftDivideOp* SgElementwiseLeftDivideOp::next_node = nullptr;
  140536             : std::vector<unsigned char*> SgElementwiseLeftDivideOp::pools;
  140537             : 
  140538             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  140539             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  140540             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  140541             : // around this macro definition rather than each use).
  140542             : #ifndef ALLOC_MUTEX
  140543             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  140544             :         do {                                                                     \
  140545             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  140546             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  140547             :                 abort();                                                         \
  140548             :             }                                                                    \
  140549             :         } while (0);
  140550             : #endif
  140551             : 
  140552             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  140553             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  140554             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  140555             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  140556             : 
  140557             : /*! \brief New operator for SgElementwiseLeftDivideOp.
  140558             : 
  140559             :    This new operator implements memory pools to provide most efficent 
  140560             :    use of the heap within construction of large ASTs.
  140561             : 
  140562             : \internal The new and delete operators use the lower level C malloc/free
  140563             :    function calls for performance and to make sure that mixing of malloc/free
  140564             :    and new/delete by the used can be caught more readily.  This may change
  140565             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  140566             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  140567             :    deallocate memory allocated using ROSE_MALLOC.
  140568             : */
  140569           0 : void *SgElementwiseLeftDivideOp::operator new ( size_t Size )
  140570             : {
  140571             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  140572             :      * returning or throwing an exception. */
  140573           0 :     ALLOC_MUTEX(SgElementwiseLeftDivideOp, lock);
  140574             : 
  140575             : #if ROSE_ALLOC_TRACE == 2
  140576             : //    printf("SgElementwiseLeftDivideOp::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgElementwiseLeftDivideOp::next_node);
  140577             : #endif
  140578             : 
  140579             : #if USE_CPP_NEW_DELETE_OPERATORS
  140580             :     void *mem = ROSE_MALLOC(Size);
  140581             :     ALLOC_MUTEX(SgElementwiseLeftDivideOp, unlock);
  140582             :     return mem;
  140583             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  140584             : #if ROSE_PEDANTIC_ALLOC
  140585             :     ROSE_ASSERT(Size == sizeof(SgElementwiseLeftDivideOp));
  140586             : #else
  140587           0 :     if (Size != sizeof(SgElementwiseLeftDivideOp)) {
  140588           0 :       void * object = ROSE_MALLOC(Size);
  140589           0 :       ALLOC_MUTEX(SgElementwiseLeftDivideOp, unlock);
  140590             :       return object;
  140591             :     }
  140592             : #endif
  140593             : 
  140594           0 :     if (SgElementwiseLeftDivideOp::next_node == nullptr) {
  140595           0 :         SgElementwiseLeftDivideOp * alloc = (SgElementwiseLeftDivideOp*) ROSE_MALLOC ( SgElementwiseLeftDivideOp::pool_size * sizeof(SgElementwiseLeftDivideOp) );
  140596           0 :         ROSE_ASSERT(alloc != nullptr);
  140597             : 
  140598             : #if ROSE_ALLOC_TRACE == 2
  140599             : //        printf("SgElementwiseLeftDivideOp::alloc\n  block[%zi] = [ %p , %p [\n", SgElementwiseLeftDivideOp::pools.size(), alloc, alloc + SgElementwiseLeftDivideOp::pool_size);
  140600             : #endif
  140601             : 
  140602             : #if ROSE_ALLOC_MEMSET == 1
  140603             : #elif ROSE_ALLOC_MEMSET == 2
  140604             :         memset(alloc, 0x00, SgElementwiseLeftDivideOp::pool_size * sizeof(SgElementwiseLeftDivideOp));
  140605             : #elif ROSE_ALLOC_MEMSET == 3
  140606             :         memset(alloc, 0xAA, SgElementwiseLeftDivideOp::pool_size * sizeof(SgElementwiseLeftDivideOp));
  140607             : #endif
  140608           0 :         for (unsigned i=0; i < SgElementwiseLeftDivideOp::pool_size-1; i++) {
  140609           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
  140610             :         }
  140611           0 :         alloc[SgElementwiseLeftDivideOp::pool_size-1].p_freepointer = nullptr;
  140612             : 
  140613           0 :         SgElementwiseLeftDivideOp::pools.push_back ( (unsigned char *) alloc );
  140614           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgElementwiseLeftDivideOp::pool_size * sizeof(SgElementwiseLeftDivideOp), V_SgElementwiseLeftDivideOp ) );
  140615           0 :         SgElementwiseLeftDivideOp::next_node = alloc;
  140616             :     }
  140617           0 :     ROSE_ASSERT(SgElementwiseLeftDivideOp::next_node != nullptr);
  140618             : 
  140619           0 :     SgElementwiseLeftDivideOp * object = SgElementwiseLeftDivideOp::next_node;
  140620           0 :     SgElementwiseLeftDivideOp::next_node = (SgElementwiseLeftDivideOp*)(object->p_freepointer);
  140621             : 
  140622             : #if ROSE_ALLOC_TRACE == 2
  140623             :     printf("SgElementwiseLeftDivideOp::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgElementwiseLeftDivideOp::next_node);
  140624             : #endif
  140625             : 
  140626           0 :     SgNode * fp = object->p_freepointer;
  140627             : #if ROSE_ALLOC_MEMSET == 1
  140628             : #elif ROSE_ALLOC_MEMSET == 2
  140629             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgElementwiseLeftDivideOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  140630             : #elif ROSE_ALLOC_MEMSET == 3
  140631             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgElementwiseLeftDivideOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  140632             : #endif
  140633           0 :     object->p_freepointer = fp;
  140634             : 
  140635             : #if ROSE_ALLOC_TRACE == 2
  140636             : //    printf("SgElementwiseLeftDivideOp::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgElementwiseLeftDivideOp::next_node);
  140637             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  140638             :     Rose::MemPool::snapshot(oss.str());
  140639             :     alloc_trace_cnt++;
  140640             : #endif
  140641             : 
  140642           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  140643             : 
  140644           0 :     ALLOC_MUTEX(SgElementwiseLeftDivideOp, unlock);
  140645             : 
  140646             :     return object;
  140647             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  140648             : }
  140649             : 
  140650             : 
  140651             : 
  140652             : /*! \brief Delete operator for SgElementwiseLeftDivideOp.
  140653             : 
  140654             :    This delete operator implements deallocation using memory pools to 
  140655             :    provide most efficent use of the heap within construction of large ASTs.
  140656             : 
  140657             : \internal The new and delete operators use the lower level C malloc/free
  140658             :    function calls for performance and to make sure that mixing of malloc/free
  140659             :    and new/delete by the used can be caught more readily.  This may change
  140660             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  140661             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  140662             :    deallocate memory allocated using ROSE_MALLOC.
  140663             : */
  140664           0 : void SgElementwiseLeftDivideOp::operator delete(void *Pointer, size_t Size)
  140665             : {
  140666             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  140667             :      * or throwing an exception. */
  140668           0 :     ALLOC_MUTEX(SgElementwiseLeftDivideOp, lock);
  140669             : 
  140670             : #if USE_CPP_NEW_DELETE_OPERATORS
  140671             :     ROSE_FREE(Pointer);
  140672             : #else
  140673             : #if ROSE_PEDANTIC_ALLOC
  140674             :     ROSE_ASSERT(Size == sizeof(SgElementwiseLeftDivideOp));
  140675             : #else
  140676           0 :     if (Size != sizeof(SgElementwiseLeftDivideOp)) {
  140677           0 :       ROSE_FREE(Pointer);
  140678           0 :       ALLOC_MUTEX(SgElementwiseLeftDivideOp, unlock);
  140679             :       return;
  140680             :     }
  140681             : #endif
  140682             : 
  140683           0 :     SgElementwiseLeftDivideOp * object = (SgElementwiseLeftDivideOp*) Pointer;
  140684           0 :     ROSE_ASSERT(object != nullptr);
  140685             : 
  140686             : #if ROSE_ALLOC_TRACE == 2
  140687             : //  printf("SgElementwiseLeftDivideOp::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgElementwiseLeftDivideOp::next_node);
  140688             :     printf("SgElementwiseLeftDivideOp::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgElementwiseLeftDivideOp::next_node);
  140689             : #endif
  140690             : 
  140691             : #if ROSE_PEDANTIC_ALLOC
  140692             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  140693             : #endif
  140694             : 
  140695             : #if ROSE_ALLOC_MEMSET == 1
  140696             : #elif ROSE_ALLOC_MEMSET == 2
  140697             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgElementwiseLeftDivideOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  140698             : #elif ROSE_ALLOC_MEMSET == 3
  140699             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgElementwiseLeftDivideOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  140700             : #endif
  140701             : 
  140702             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  140703             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  140704             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  140705             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  140706             : #else
  140707           0 :     object->p_freepointer = SgElementwiseLeftDivideOp::next_node;
  140708           0 :     SgElementwiseLeftDivideOp::next_node = object;
  140709             : #endif
  140710             : 
  140711             : #if ROSE_ALLOC_TRACE == 2
  140712             : //  printf("SgElementwiseLeftDivideOp::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgElementwiseLeftDivideOp::next_node);
  140713             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  140714             :     Rose::MemPool::snapshot(oss.str());
  140715             :     alloc_trace_cnt++;
  140716             : #endif
  140717             : 
  140718             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  140719             : 
  140720           0 :     ALLOC_MUTEX(SgElementwiseLeftDivideOp, unlock);
  140721             : }
  140722             : 
  140723             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  140724             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  140725             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  140726             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  140727             : // Also, note comment below from Robb (copied from the Common.code file).
  140728             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  140729             : //
  140730             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  140731             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  140732             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  140733             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  140734             : #if 0
  140735             : void SgElementwiseLeftDivideOp::operator delete(void* pointer) { SgElementwiseLeftDivideOp::operator delete (pointer, sizeof(SgElementwiseLeftDivideOp)); };
  140736             : #endif
  140737             : /* #line 140738 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  140738             : 
  140739             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  140740             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  140741             : // obviously imply C++.
  140742             : 
  140743             : // This implements the support within ROSE for memory pools.  Memory pools
  140744             : // support the most condensed usage of memory within the construction of
  140745             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  140746             : // by a new operator written for each class.
  140747             : 
  140748             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  140749             :     // User wants multi-thread support and POSIX threads are available.
  140750             : #   include <pthread.h>
  140751             :     static pthread_mutex_t SgElementwiseDivideOp_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  140752             : #else
  140753             :      // Cause synchronization to be skipped.
  140754             : #    ifndef ALLOC_MUTEX
  140755             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  140756             : #    endif
  140757             : #    ifdef _REENTRANT
  140758             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  140759             : #       ifdef _MSC_VER
  140760             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  140761             : #       else
  140762             : #           warning "POSIX threads are not available; synchronization being skipped"
  140763             : #       endif
  140764             : #    endif
  140765             : #endif
  140766             : 
  140767             : #ifndef ROSE_ALLOC_TRACE
  140768             : #  define ROSE_ALLOC_TRACE 0
  140769             : #endif
  140770             : 
  140771             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  140772             : #define ROSE_ALLOC_TRACE_CNT
  140773             : #include "memory-pool-snapshot.h"
  140774             : unsigned long alloc_trace_cnt = 0;
  140775             : #endif
  140776             : 
  140777             : #if ROSE_ALLOC_TRACE
  140778             : const unsigned SgElementwiseDivideOp::pool_size = 5;
  140779             : #else
  140780             : const unsigned SgElementwiseDivideOp::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  140781             : #endif
  140782             : 
  140783             : #ifndef ROSE_ALLOC_MEMSET
  140784             : #  define ROSE_ALLOC_MEMSET 0
  140785             : #endif
  140786             : 
  140787             : #ifndef ROSE_PEDANTIC_ALLOC
  140788             : #  define ROSE_PEDANTIC_ALLOC 0
  140789             : #endif
  140790             : 
  140791             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  140792             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  140793             : #endif
  140794             : 
  140795             : #if !defined(SGNODE__ALL_POOLS)
  140796             : #define SGNODE__ALL_POOLS
  140797             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  140798             : #endif
  140799             : 
  140800             : SgElementwiseDivideOp* SgElementwiseDivideOp::next_node = nullptr;
  140801             : std::vector<unsigned char*> SgElementwiseDivideOp::pools;
  140802             : 
  140803             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  140804             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  140805             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  140806             : // around this macro definition rather than each use).
  140807             : #ifndef ALLOC_MUTEX
  140808             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  140809             :         do {                                                                     \
  140810             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  140811             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  140812             :                 abort();                                                         \
  140813             :             }                                                                    \
  140814             :         } while (0);
  140815             : #endif
  140816             : 
  140817             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  140818             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  140819             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  140820             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  140821             : 
  140822             : /*! \brief New operator for SgElementwiseDivideOp.
  140823             : 
  140824             :    This new operator implements memory pools to provide most efficent 
  140825             :    use of the heap within construction of large ASTs.
  140826             : 
  140827             : \internal The new and delete operators use the lower level C malloc/free
  140828             :    function calls for performance and to make sure that mixing of malloc/free
  140829             :    and new/delete by the used can be caught more readily.  This may change
  140830             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  140831             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  140832             :    deallocate memory allocated using ROSE_MALLOC.
  140833             : */
  140834           0 : void *SgElementwiseDivideOp::operator new ( size_t Size )
  140835             : {
  140836             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  140837             :      * returning or throwing an exception. */
  140838           0 :     ALLOC_MUTEX(SgElementwiseDivideOp, lock);
  140839             : 
  140840             : #if ROSE_ALLOC_TRACE == 2
  140841             : //    printf("SgElementwiseDivideOp::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgElementwiseDivideOp::next_node);
  140842             : #endif
  140843             : 
  140844             : #if USE_CPP_NEW_DELETE_OPERATORS
  140845             :     void *mem = ROSE_MALLOC(Size);
  140846             :     ALLOC_MUTEX(SgElementwiseDivideOp, unlock);
  140847             :     return mem;
  140848             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  140849             : #if ROSE_PEDANTIC_ALLOC
  140850             :     ROSE_ASSERT(Size == sizeof(SgElementwiseDivideOp));
  140851             : #else
  140852           0 :     if (Size != sizeof(SgElementwiseDivideOp)) {
  140853           0 :       void * object = ROSE_MALLOC(Size);
  140854           0 :       ALLOC_MUTEX(SgElementwiseDivideOp, unlock);
  140855             :       return object;
  140856             :     }
  140857             : #endif
  140858             : 
  140859           0 :     if (SgElementwiseDivideOp::next_node == nullptr) {
  140860           0 :         SgElementwiseDivideOp * alloc = (SgElementwiseDivideOp*) ROSE_MALLOC ( SgElementwiseDivideOp::pool_size * sizeof(SgElementwiseDivideOp) );
  140861           0 :         ROSE_ASSERT(alloc != nullptr);
  140862             : 
  140863             : #if ROSE_ALLOC_TRACE == 2
  140864             : //        printf("SgElementwiseDivideOp::alloc\n  block[%zi] = [ %p , %p [\n", SgElementwiseDivideOp::pools.size(), alloc, alloc + SgElementwiseDivideOp::pool_size);
  140865             : #endif
  140866             : 
  140867             : #if ROSE_ALLOC_MEMSET == 1
  140868             : #elif ROSE_ALLOC_MEMSET == 2
  140869             :         memset(alloc, 0x00, SgElementwiseDivideOp::pool_size * sizeof(SgElementwiseDivideOp));
  140870             : #elif ROSE_ALLOC_MEMSET == 3
  140871             :         memset(alloc, 0xAA, SgElementwiseDivideOp::pool_size * sizeof(SgElementwiseDivideOp));
  140872             : #endif
  140873           0 :         for (unsigned i=0; i < SgElementwiseDivideOp::pool_size-1; i++) {
  140874           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
  140875             :         }
  140876           0 :         alloc[SgElementwiseDivideOp::pool_size-1].p_freepointer = nullptr;
  140877             : 
  140878           0 :         SgElementwiseDivideOp::pools.push_back ( (unsigned char *) alloc );
  140879           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgElementwiseDivideOp::pool_size * sizeof(SgElementwiseDivideOp), V_SgElementwiseDivideOp ) );
  140880           0 :         SgElementwiseDivideOp::next_node = alloc;
  140881             :     }
  140882           0 :     ROSE_ASSERT(SgElementwiseDivideOp::next_node != nullptr);
  140883             : 
  140884           0 :     SgElementwiseDivideOp * object = SgElementwiseDivideOp::next_node;
  140885           0 :     SgElementwiseDivideOp::next_node = (SgElementwiseDivideOp*)(object->p_freepointer);
  140886             : 
  140887             : #if ROSE_ALLOC_TRACE == 2
  140888             :     printf("SgElementwiseDivideOp::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgElementwiseDivideOp::next_node);
  140889             : #endif
  140890             : 
  140891           0 :     SgNode * fp = object->p_freepointer;
  140892             : #if ROSE_ALLOC_MEMSET == 1
  140893             : #elif ROSE_ALLOC_MEMSET == 2
  140894             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgElementwiseDivideOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  140895             : #elif ROSE_ALLOC_MEMSET == 3
  140896             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgElementwiseDivideOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  140897             : #endif
  140898           0 :     object->p_freepointer = fp;
  140899             : 
  140900             : #if ROSE_ALLOC_TRACE == 2
  140901             : //    printf("SgElementwiseDivideOp::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgElementwiseDivideOp::next_node);
  140902             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  140903             :     Rose::MemPool::snapshot(oss.str());
  140904             :     alloc_trace_cnt++;
  140905             : #endif
  140906             : 
  140907           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  140908             : 
  140909           0 :     ALLOC_MUTEX(SgElementwiseDivideOp, unlock);
  140910             : 
  140911             :     return object;
  140912             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  140913             : }
  140914             : 
  140915             : 
  140916             : 
  140917             : /*! \brief Delete operator for SgElementwiseDivideOp.
  140918             : 
  140919             :    This delete operator implements deallocation using memory pools to 
  140920             :    provide most efficent use of the heap within construction of large ASTs.
  140921             : 
  140922             : \internal The new and delete operators use the lower level C malloc/free
  140923             :    function calls for performance and to make sure that mixing of malloc/free
  140924             :    and new/delete by the used can be caught more readily.  This may change
  140925             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  140926             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  140927             :    deallocate memory allocated using ROSE_MALLOC.
  140928             : */
  140929           0 : void SgElementwiseDivideOp::operator delete(void *Pointer, size_t Size)
  140930             : {
  140931             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  140932             :      * or throwing an exception. */
  140933           0 :     ALLOC_MUTEX(SgElementwiseDivideOp, lock);
  140934             : 
  140935             : #if USE_CPP_NEW_DELETE_OPERATORS
  140936             :     ROSE_FREE(Pointer);
  140937             : #else
  140938             : #if ROSE_PEDANTIC_ALLOC
  140939             :     ROSE_ASSERT(Size == sizeof(SgElementwiseDivideOp));
  140940             : #else
  140941           0 :     if (Size != sizeof(SgElementwiseDivideOp)) {
  140942           0 :       ROSE_FREE(Pointer);
  140943           0 :       ALLOC_MUTEX(SgElementwiseDivideOp, unlock);
  140944             :       return;
  140945             :     }
  140946             : #endif
  140947             : 
  140948           0 :     SgElementwiseDivideOp * object = (SgElementwiseDivideOp*) Pointer;
  140949           0 :     ROSE_ASSERT(object != nullptr);
  140950             : 
  140951             : #if ROSE_ALLOC_TRACE == 2
  140952             : //  printf("SgElementwiseDivideOp::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgElementwiseDivideOp::next_node);
  140953             :     printf("SgElementwiseDivideOp::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgElementwiseDivideOp::next_node);
  140954             : #endif
  140955             : 
  140956             : #if ROSE_PEDANTIC_ALLOC
  140957             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  140958             : #endif
  140959             : 
  140960             : #if ROSE_ALLOC_MEMSET == 1
  140961             : #elif ROSE_ALLOC_MEMSET == 2
  140962             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgElementwiseDivideOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  140963             : #elif ROSE_ALLOC_MEMSET == 3
  140964             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgElementwiseDivideOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  140965             : #endif
  140966             : 
  140967             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  140968             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  140969             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  140970             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  140971             : #else
  140972           0 :     object->p_freepointer = SgElementwiseDivideOp::next_node;
  140973           0 :     SgElementwiseDivideOp::next_node = object;
  140974             : #endif
  140975             : 
  140976             : #if ROSE_ALLOC_TRACE == 2
  140977             : //  printf("SgElementwiseDivideOp::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgElementwiseDivideOp::next_node);
  140978             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  140979             :     Rose::MemPool::snapshot(oss.str());
  140980             :     alloc_trace_cnt++;
  140981             : #endif
  140982             : 
  140983             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  140984             : 
  140985           0 :     ALLOC_MUTEX(SgElementwiseDivideOp, unlock);
  140986             : }
  140987             : 
  140988             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  140989             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  140990             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  140991             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  140992             : // Also, note comment below from Robb (copied from the Common.code file).
  140993             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  140994             : //
  140995             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  140996             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  140997             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  140998             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  140999             : #if 0
  141000             : void SgElementwiseDivideOp::operator delete(void* pointer) { SgElementwiseDivideOp::operator delete (pointer, sizeof(SgElementwiseDivideOp)); };
  141001             : #endif
  141002             : /* #line 141003 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  141003             : 
  141004             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  141005             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  141006             : // obviously imply C++.
  141007             : 
  141008             : // This implements the support within ROSE for memory pools.  Memory pools
  141009             : // support the most condensed usage of memory within the construction of
  141010             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  141011             : // by a new operator written for each class.
  141012             : 
  141013             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  141014             :     // User wants multi-thread support and POSIX threads are available.
  141015             : #   include <pthread.h>
  141016             :     static pthread_mutex_t SgElementwiseAddOp_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  141017             : #else
  141018             :      // Cause synchronization to be skipped.
  141019             : #    ifndef ALLOC_MUTEX
  141020             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  141021             : #    endif
  141022             : #    ifdef _REENTRANT
  141023             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  141024             : #       ifdef _MSC_VER
  141025             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  141026             : #       else
  141027             : #           warning "POSIX threads are not available; synchronization being skipped"
  141028             : #       endif
  141029             : #    endif
  141030             : #endif
  141031             : 
  141032             : #ifndef ROSE_ALLOC_TRACE
  141033             : #  define ROSE_ALLOC_TRACE 0
  141034             : #endif
  141035             : 
  141036             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  141037             : #define ROSE_ALLOC_TRACE_CNT
  141038             : #include "memory-pool-snapshot.h"
  141039             : unsigned long alloc_trace_cnt = 0;
  141040             : #endif
  141041             : 
  141042             : #if ROSE_ALLOC_TRACE
  141043             : const unsigned SgElementwiseAddOp::pool_size = 5;
  141044             : #else
  141045             : const unsigned SgElementwiseAddOp::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  141046             : #endif
  141047             : 
  141048             : #ifndef ROSE_ALLOC_MEMSET
  141049             : #  define ROSE_ALLOC_MEMSET 0
  141050             : #endif
  141051             : 
  141052             : #ifndef ROSE_PEDANTIC_ALLOC
  141053             : #  define ROSE_PEDANTIC_ALLOC 0
  141054             : #endif
  141055             : 
  141056             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  141057             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  141058             : #endif
  141059             : 
  141060             : #if !defined(SGNODE__ALL_POOLS)
  141061             : #define SGNODE__ALL_POOLS
  141062             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  141063             : #endif
  141064             : 
  141065             : SgElementwiseAddOp* SgElementwiseAddOp::next_node = nullptr;
  141066             : std::vector<unsigned char*> SgElementwiseAddOp::pools;
  141067             : 
  141068             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  141069             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  141070             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  141071             : // around this macro definition rather than each use).
  141072             : #ifndef ALLOC_MUTEX
  141073             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  141074             :         do {                                                                     \
  141075             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  141076             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  141077             :                 abort();                                                         \
  141078             :             }                                                                    \
  141079             :         } while (0);
  141080             : #endif
  141081             : 
  141082             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  141083             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  141084             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  141085             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  141086             : 
  141087             : /*! \brief New operator for SgElementwiseAddOp.
  141088             : 
  141089             :    This new operator implements memory pools to provide most efficent 
  141090             :    use of the heap within construction of large ASTs.
  141091             : 
  141092             : \internal The new and delete operators use the lower level C malloc/free
  141093             :    function calls for performance and to make sure that mixing of malloc/free
  141094             :    and new/delete by the used can be caught more readily.  This may change
  141095             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  141096             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  141097             :    deallocate memory allocated using ROSE_MALLOC.
  141098             : */
  141099           0 : void *SgElementwiseAddOp::operator new ( size_t Size )
  141100             : {
  141101             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  141102             :      * returning or throwing an exception. */
  141103           0 :     ALLOC_MUTEX(SgElementwiseAddOp, lock);
  141104             : 
  141105             : #if ROSE_ALLOC_TRACE == 2
  141106             : //    printf("SgElementwiseAddOp::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgElementwiseAddOp::next_node);
  141107             : #endif
  141108             : 
  141109             : #if USE_CPP_NEW_DELETE_OPERATORS
  141110             :     void *mem = ROSE_MALLOC(Size);
  141111             :     ALLOC_MUTEX(SgElementwiseAddOp, unlock);
  141112             :     return mem;
  141113             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  141114             : #if ROSE_PEDANTIC_ALLOC
  141115             :     ROSE_ASSERT(Size == sizeof(SgElementwiseAddOp));
  141116             : #else
  141117           0 :     if (Size != sizeof(SgElementwiseAddOp)) {
  141118           0 :       void * object = ROSE_MALLOC(Size);
  141119           0 :       ALLOC_MUTEX(SgElementwiseAddOp, unlock);
  141120             :       return object;
  141121             :     }
  141122             : #endif
  141123             : 
  141124           0 :     if (SgElementwiseAddOp::next_node == nullptr) {
  141125           0 :         SgElementwiseAddOp * alloc = (SgElementwiseAddOp*) ROSE_MALLOC ( SgElementwiseAddOp::pool_size * sizeof(SgElementwiseAddOp) );
  141126           0 :         ROSE_ASSERT(alloc != nullptr);
  141127             : 
  141128             : #if ROSE_ALLOC_TRACE == 2
  141129             : //        printf("SgElementwiseAddOp::alloc\n  block[%zi] = [ %p , %p [\n", SgElementwiseAddOp::pools.size(), alloc, alloc + SgElementwiseAddOp::pool_size);
  141130             : #endif
  141131             : 
  141132             : #if ROSE_ALLOC_MEMSET == 1
  141133             : #elif ROSE_ALLOC_MEMSET == 2
  141134             :         memset(alloc, 0x00, SgElementwiseAddOp::pool_size * sizeof(SgElementwiseAddOp));
  141135             : #elif ROSE_ALLOC_MEMSET == 3
  141136             :         memset(alloc, 0xAA, SgElementwiseAddOp::pool_size * sizeof(SgElementwiseAddOp));
  141137             : #endif
  141138           0 :         for (unsigned i=0; i < SgElementwiseAddOp::pool_size-1; i++) {
  141139           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
  141140             :         }
  141141           0 :         alloc[SgElementwiseAddOp::pool_size-1].p_freepointer = nullptr;
  141142             : 
  141143           0 :         SgElementwiseAddOp::pools.push_back ( (unsigned char *) alloc );
  141144           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgElementwiseAddOp::pool_size * sizeof(SgElementwiseAddOp), V_SgElementwiseAddOp ) );
  141145           0 :         SgElementwiseAddOp::next_node = alloc;
  141146             :     }
  141147           0 :     ROSE_ASSERT(SgElementwiseAddOp::next_node != nullptr);
  141148             : 
  141149           0 :     SgElementwiseAddOp * object = SgElementwiseAddOp::next_node;
  141150           0 :     SgElementwiseAddOp::next_node = (SgElementwiseAddOp*)(object->p_freepointer);
  141151             : 
  141152             : #if ROSE_ALLOC_TRACE == 2
  141153             :     printf("SgElementwiseAddOp::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgElementwiseAddOp::next_node);
  141154             : #endif
  141155             : 
  141156           0 :     SgNode * fp = object->p_freepointer;
  141157             : #if ROSE_ALLOC_MEMSET == 1
  141158             : #elif ROSE_ALLOC_MEMSET == 2
  141159             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgElementwiseAddOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  141160             : #elif ROSE_ALLOC_MEMSET == 3
  141161             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgElementwiseAddOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  141162             : #endif
  141163           0 :     object->p_freepointer = fp;
  141164             : 
  141165             : #if ROSE_ALLOC_TRACE == 2
  141166             : //    printf("SgElementwiseAddOp::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgElementwiseAddOp::next_node);
  141167             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  141168             :     Rose::MemPool::snapshot(oss.str());
  141169             :     alloc_trace_cnt++;
  141170             : #endif
  141171             : 
  141172           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  141173             : 
  141174           0 :     ALLOC_MUTEX(SgElementwiseAddOp, unlock);
  141175             : 
  141176             :     return object;
  141177             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  141178             : }
  141179             : 
  141180             : 
  141181             : 
  141182             : /*! \brief Delete operator for SgElementwiseAddOp.
  141183             : 
  141184             :    This delete operator implements deallocation using memory pools to 
  141185             :    provide most efficent use of the heap within construction of large ASTs.
  141186             : 
  141187             : \internal The new and delete operators use the lower level C malloc/free
  141188             :    function calls for performance and to make sure that mixing of malloc/free
  141189             :    and new/delete by the used can be caught more readily.  This may change
  141190             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  141191             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  141192             :    deallocate memory allocated using ROSE_MALLOC.
  141193             : */
  141194           0 : void SgElementwiseAddOp::operator delete(void *Pointer, size_t Size)
  141195             : {
  141196             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  141197             :      * or throwing an exception. */
  141198           0 :     ALLOC_MUTEX(SgElementwiseAddOp, lock);
  141199             : 
  141200             : #if USE_CPP_NEW_DELETE_OPERATORS
  141201             :     ROSE_FREE(Pointer);
  141202             : #else
  141203             : #if ROSE_PEDANTIC_ALLOC
  141204             :     ROSE_ASSERT(Size == sizeof(SgElementwiseAddOp));
  141205             : #else
  141206           0 :     if (Size != sizeof(SgElementwiseAddOp)) {
  141207           0 :       ROSE_FREE(Pointer);
  141208           0 :       ALLOC_MUTEX(SgElementwiseAddOp, unlock);
  141209             :       return;
  141210             :     }
  141211             : #endif
  141212             : 
  141213           0 :     SgElementwiseAddOp * object = (SgElementwiseAddOp*) Pointer;
  141214           0 :     ROSE_ASSERT(object != nullptr);
  141215             : 
  141216             : #if ROSE_ALLOC_TRACE == 2
  141217             : //  printf("SgElementwiseAddOp::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgElementwiseAddOp::next_node);
  141218             :     printf("SgElementwiseAddOp::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgElementwiseAddOp::next_node);
  141219             : #endif
  141220             : 
  141221             : #if ROSE_PEDANTIC_ALLOC
  141222             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  141223             : #endif
  141224             : 
  141225             : #if ROSE_ALLOC_MEMSET == 1
  141226             : #elif ROSE_ALLOC_MEMSET == 2
  141227             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgElementwiseAddOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  141228             : #elif ROSE_ALLOC_MEMSET == 3
  141229             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgElementwiseAddOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  141230             : #endif
  141231             : 
  141232             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  141233             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  141234             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  141235             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  141236             : #else
  141237           0 :     object->p_freepointer = SgElementwiseAddOp::next_node;
  141238           0 :     SgElementwiseAddOp::next_node = object;
  141239             : #endif
  141240             : 
  141241             : #if ROSE_ALLOC_TRACE == 2
  141242             : //  printf("SgElementwiseAddOp::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgElementwiseAddOp::next_node);
  141243             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  141244             :     Rose::MemPool::snapshot(oss.str());
  141245             :     alloc_trace_cnt++;
  141246             : #endif
  141247             : 
  141248             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  141249             : 
  141250           0 :     ALLOC_MUTEX(SgElementwiseAddOp, unlock);
  141251             : }
  141252             : 
  141253             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  141254             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  141255             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  141256             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  141257             : // Also, note comment below from Robb (copied from the Common.code file).
  141258             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  141259             : //
  141260             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  141261             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  141262             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  141263             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  141264             : #if 0
  141265             : void SgElementwiseAddOp::operator delete(void* pointer) { SgElementwiseAddOp::operator delete (pointer, sizeof(SgElementwiseAddOp)); };
  141266             : #endif
  141267             : /* #line 141268 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  141268             : 
  141269             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  141270             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  141271             : // obviously imply C++.
  141272             : 
  141273             : // This implements the support within ROSE for memory pools.  Memory pools
  141274             : // support the most condensed usage of memory within the construction of
  141275             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  141276             : // by a new operator written for each class.
  141277             : 
  141278             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  141279             :     // User wants multi-thread support and POSIX threads are available.
  141280             : #   include <pthread.h>
  141281             :     static pthread_mutex_t SgElementwiseSubtractOp_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  141282             : #else
  141283             :      // Cause synchronization to be skipped.
  141284             : #    ifndef ALLOC_MUTEX
  141285             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  141286             : #    endif
  141287             : #    ifdef _REENTRANT
  141288             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  141289             : #       ifdef _MSC_VER
  141290             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  141291             : #       else
  141292             : #           warning "POSIX threads are not available; synchronization being skipped"
  141293             : #       endif
  141294             : #    endif
  141295             : #endif
  141296             : 
  141297             : #ifndef ROSE_ALLOC_TRACE
  141298             : #  define ROSE_ALLOC_TRACE 0
  141299             : #endif
  141300             : 
  141301             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  141302             : #define ROSE_ALLOC_TRACE_CNT
  141303             : #include "memory-pool-snapshot.h"
  141304             : unsigned long alloc_trace_cnt = 0;
  141305             : #endif
  141306             : 
  141307             : #if ROSE_ALLOC_TRACE
  141308             : const unsigned SgElementwiseSubtractOp::pool_size = 5;
  141309             : #else
  141310             : const unsigned SgElementwiseSubtractOp::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  141311             : #endif
  141312             : 
  141313             : #ifndef ROSE_ALLOC_MEMSET
  141314             : #  define ROSE_ALLOC_MEMSET 0
  141315             : #endif
  141316             : 
  141317             : #ifndef ROSE_PEDANTIC_ALLOC
  141318             : #  define ROSE_PEDANTIC_ALLOC 0
  141319             : #endif
  141320             : 
  141321             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  141322             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  141323             : #endif
  141324             : 
  141325             : #if !defined(SGNODE__ALL_POOLS)
  141326             : #define SGNODE__ALL_POOLS
  141327             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  141328             : #endif
  141329             : 
  141330             : SgElementwiseSubtractOp* SgElementwiseSubtractOp::next_node = nullptr;
  141331             : std::vector<unsigned char*> SgElementwiseSubtractOp::pools;
  141332             : 
  141333             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  141334             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  141335             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  141336             : // around this macro definition rather than each use).
  141337             : #ifndef ALLOC_MUTEX
  141338             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  141339             :         do {                                                                     \
  141340             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  141341             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  141342             :                 abort();                                                         \
  141343             :             }                                                                    \
  141344             :         } while (0);
  141345             : #endif
  141346             : 
  141347             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  141348             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  141349             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  141350             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  141351             : 
  141352             : /*! \brief New operator for SgElementwiseSubtractOp.
  141353             : 
  141354             :    This new operator implements memory pools to provide most efficent 
  141355             :    use of the heap within construction of large ASTs.
  141356             : 
  141357             : \internal The new and delete operators use the lower level C malloc/free
  141358             :    function calls for performance and to make sure that mixing of malloc/free
  141359             :    and new/delete by the used can be caught more readily.  This may change
  141360             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  141361             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  141362             :    deallocate memory allocated using ROSE_MALLOC.
  141363             : */
  141364           0 : void *SgElementwiseSubtractOp::operator new ( size_t Size )
  141365             : {
  141366             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  141367             :      * returning or throwing an exception. */
  141368           0 :     ALLOC_MUTEX(SgElementwiseSubtractOp, lock);
  141369             : 
  141370             : #if ROSE_ALLOC_TRACE == 2
  141371             : //    printf("SgElementwiseSubtractOp::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgElementwiseSubtractOp::next_node);
  141372             : #endif
  141373             : 
  141374             : #if USE_CPP_NEW_DELETE_OPERATORS
  141375             :     void *mem = ROSE_MALLOC(Size);
  141376             :     ALLOC_MUTEX(SgElementwiseSubtractOp, unlock);
  141377             :     return mem;
  141378             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  141379             : #if ROSE_PEDANTIC_ALLOC
  141380             :     ROSE_ASSERT(Size == sizeof(SgElementwiseSubtractOp));
  141381             : #else
  141382           0 :     if (Size != sizeof(SgElementwiseSubtractOp)) {
  141383           0 :       void * object = ROSE_MALLOC(Size);
  141384           0 :       ALLOC_MUTEX(SgElementwiseSubtractOp, unlock);
  141385             :       return object;
  141386             :     }
  141387             : #endif
  141388             : 
  141389           0 :     if (SgElementwiseSubtractOp::next_node == nullptr) {
  141390           0 :         SgElementwiseSubtractOp * alloc = (SgElementwiseSubtractOp*) ROSE_MALLOC ( SgElementwiseSubtractOp::pool_size * sizeof(SgElementwiseSubtractOp) );
  141391           0 :         ROSE_ASSERT(alloc != nullptr);
  141392             : 
  141393             : #if ROSE_ALLOC_TRACE == 2
  141394             : //        printf("SgElementwiseSubtractOp::alloc\n  block[%zi] = [ %p , %p [\n", SgElementwiseSubtractOp::pools.size(), alloc, alloc + SgElementwiseSubtractOp::pool_size);
  141395             : #endif
  141396             : 
  141397             : #if ROSE_ALLOC_MEMSET == 1
  141398             : #elif ROSE_ALLOC_MEMSET == 2
  141399             :         memset(alloc, 0x00, SgElementwiseSubtractOp::pool_size * sizeof(SgElementwiseSubtractOp));
  141400             : #elif ROSE_ALLOC_MEMSET == 3
  141401             :         memset(alloc, 0xAA, SgElementwiseSubtractOp::pool_size * sizeof(SgElementwiseSubtractOp));
  141402             : #endif
  141403           0 :         for (unsigned i=0; i < SgElementwiseSubtractOp::pool_size-1; i++) {
  141404           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
  141405             :         }
  141406           0 :         alloc[SgElementwiseSubtractOp::pool_size-1].p_freepointer = nullptr;
  141407             : 
  141408           0 :         SgElementwiseSubtractOp::pools.push_back ( (unsigned char *) alloc );
  141409           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgElementwiseSubtractOp::pool_size * sizeof(SgElementwiseSubtractOp), V_SgElementwiseSubtractOp ) );
  141410           0 :         SgElementwiseSubtractOp::next_node = alloc;
  141411             :     }
  141412           0 :     ROSE_ASSERT(SgElementwiseSubtractOp::next_node != nullptr);
  141413             : 
  141414           0 :     SgElementwiseSubtractOp * object = SgElementwiseSubtractOp::next_node;
  141415           0 :     SgElementwiseSubtractOp::next_node = (SgElementwiseSubtractOp*)(object->p_freepointer);
  141416             : 
  141417             : #if ROSE_ALLOC_TRACE == 2
  141418             :     printf("SgElementwiseSubtractOp::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgElementwiseSubtractOp::next_node);
  141419             : #endif
  141420             : 
  141421           0 :     SgNode * fp = object->p_freepointer;
  141422             : #if ROSE_ALLOC_MEMSET == 1
  141423             : #elif ROSE_ALLOC_MEMSET == 2
  141424             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgElementwiseSubtractOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  141425             : #elif ROSE_ALLOC_MEMSET == 3
  141426             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgElementwiseSubtractOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  141427             : #endif
  141428           0 :     object->p_freepointer = fp;
  141429             : 
  141430             : #if ROSE_ALLOC_TRACE == 2
  141431             : //    printf("SgElementwiseSubtractOp::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgElementwiseSubtractOp::next_node);
  141432             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  141433             :     Rose::MemPool::snapshot(oss.str());
  141434             :     alloc_trace_cnt++;
  141435             : #endif
  141436             : 
  141437           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  141438             : 
  141439           0 :     ALLOC_MUTEX(SgElementwiseSubtractOp, unlock);
  141440             : 
  141441             :     return object;
  141442             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  141443             : }
  141444             : 
  141445             : 
  141446             : 
  141447             : /*! \brief Delete operator for SgElementwiseSubtractOp.
  141448             : 
  141449             :    This delete operator implements deallocation using memory pools to 
  141450             :    provide most efficent use of the heap within construction of large ASTs.
  141451             : 
  141452             : \internal The new and delete operators use the lower level C malloc/free
  141453             :    function calls for performance and to make sure that mixing of malloc/free
  141454             :    and new/delete by the used can be caught more readily.  This may change
  141455             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  141456             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  141457             :    deallocate memory allocated using ROSE_MALLOC.
  141458             : */
  141459           0 : void SgElementwiseSubtractOp::operator delete(void *Pointer, size_t Size)
  141460             : {
  141461             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  141462             :      * or throwing an exception. */
  141463           0 :     ALLOC_MUTEX(SgElementwiseSubtractOp, lock);
  141464             : 
  141465             : #if USE_CPP_NEW_DELETE_OPERATORS
  141466             :     ROSE_FREE(Pointer);
  141467             : #else
  141468             : #if ROSE_PEDANTIC_ALLOC
  141469             :     ROSE_ASSERT(Size == sizeof(SgElementwiseSubtractOp));
  141470             : #else
  141471           0 :     if (Size != sizeof(SgElementwiseSubtractOp)) {
  141472           0 :       ROSE_FREE(Pointer);
  141473           0 :       ALLOC_MUTEX(SgElementwiseSubtractOp, unlock);
  141474             :       return;
  141475             :     }
  141476             : #endif
  141477             : 
  141478           0 :     SgElementwiseSubtractOp * object = (SgElementwiseSubtractOp*) Pointer;
  141479           0 :     ROSE_ASSERT(object != nullptr);
  141480             : 
  141481             : #if ROSE_ALLOC_TRACE == 2
  141482             : //  printf("SgElementwiseSubtractOp::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgElementwiseSubtractOp::next_node);
  141483             :     printf("SgElementwiseSubtractOp::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgElementwiseSubtractOp::next_node);
  141484             : #endif
  141485             : 
  141486             : #if ROSE_PEDANTIC_ALLOC
  141487             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  141488             : #endif
  141489             : 
  141490             : #if ROSE_ALLOC_MEMSET == 1
  141491             : #elif ROSE_ALLOC_MEMSET == 2
  141492             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgElementwiseSubtractOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  141493             : #elif ROSE_ALLOC_MEMSET == 3
  141494             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgElementwiseSubtractOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  141495             : #endif
  141496             : 
  141497             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  141498             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  141499             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  141500             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  141501             : #else
  141502           0 :     object->p_freepointer = SgElementwiseSubtractOp::next_node;
  141503           0 :     SgElementwiseSubtractOp::next_node = object;
  141504             : #endif
  141505             : 
  141506             : #if ROSE_ALLOC_TRACE == 2
  141507             : //  printf("SgElementwiseSubtractOp::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgElementwiseSubtractOp::next_node);
  141508             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  141509             :     Rose::MemPool::snapshot(oss.str());
  141510             :     alloc_trace_cnt++;
  141511             : #endif
  141512             : 
  141513             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  141514             : 
  141515           0 :     ALLOC_MUTEX(SgElementwiseSubtractOp, unlock);
  141516             : }
  141517             : 
  141518             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  141519             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  141520             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  141521             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  141522             : // Also, note comment below from Robb (copied from the Common.code file).
  141523             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  141524             : //
  141525             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  141526             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  141527             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  141528             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  141529             : #if 0
  141530             : void SgElementwiseSubtractOp::operator delete(void* pointer) { SgElementwiseSubtractOp::operator delete (pointer, sizeof(SgElementwiseSubtractOp)); };
  141531             : #endif
  141532             : /* #line 141533 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  141533             : 
  141534             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  141535             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  141536             : // obviously imply C++.
  141537             : 
  141538             : // This implements the support within ROSE for memory pools.  Memory pools
  141539             : // support the most condensed usage of memory within the construction of
  141540             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  141541             : // by a new operator written for each class.
  141542             : 
  141543             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  141544             :     // User wants multi-thread support and POSIX threads are available.
  141545             : #   include <pthread.h>
  141546             :     static pthread_mutex_t SgPowerOp_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  141547             : #else
  141548             :      // Cause synchronization to be skipped.
  141549             : #    ifndef ALLOC_MUTEX
  141550             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  141551             : #    endif
  141552             : #    ifdef _REENTRANT
  141553             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  141554             : #       ifdef _MSC_VER
  141555             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  141556             : #       else
  141557             : #           warning "POSIX threads are not available; synchronization being skipped"
  141558             : #       endif
  141559             : #    endif
  141560             : #endif
  141561             : 
  141562             : #ifndef ROSE_ALLOC_TRACE
  141563             : #  define ROSE_ALLOC_TRACE 0
  141564             : #endif
  141565             : 
  141566             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  141567             : #define ROSE_ALLOC_TRACE_CNT
  141568             : #include "memory-pool-snapshot.h"
  141569             : unsigned long alloc_trace_cnt = 0;
  141570             : #endif
  141571             : 
  141572             : #if ROSE_ALLOC_TRACE
  141573             : const unsigned SgPowerOp::pool_size = 5;
  141574             : #else
  141575             : const unsigned SgPowerOp::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  141576             : #endif
  141577             : 
  141578             : #ifndef ROSE_ALLOC_MEMSET
  141579             : #  define ROSE_ALLOC_MEMSET 0
  141580             : #endif
  141581             : 
  141582             : #ifndef ROSE_PEDANTIC_ALLOC
  141583             : #  define ROSE_PEDANTIC_ALLOC 0
  141584             : #endif
  141585             : 
  141586             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  141587             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  141588             : #endif
  141589             : 
  141590             : #if !defined(SGNODE__ALL_POOLS)
  141591             : #define SGNODE__ALL_POOLS
  141592             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  141593             : #endif
  141594             : 
  141595             : SgPowerOp* SgPowerOp::next_node = nullptr;
  141596             : std::vector<unsigned char*> SgPowerOp::pools;
  141597             : 
  141598             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  141599             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  141600             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  141601             : // around this macro definition rather than each use).
  141602             : #ifndef ALLOC_MUTEX
  141603             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  141604             :         do {                                                                     \
  141605             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  141606             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  141607             :                 abort();                                                         \
  141608             :             }                                                                    \
  141609             :         } while (0);
  141610             : #endif
  141611             : 
  141612             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  141613             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  141614             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  141615             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  141616             : 
  141617             : /*! \brief New operator for SgPowerOp.
  141618             : 
  141619             :    This new operator implements memory pools to provide most efficent 
  141620             :    use of the heap within construction of large ASTs.
  141621             : 
  141622             : \internal The new and delete operators use the lower level C malloc/free
  141623             :    function calls for performance and to make sure that mixing of malloc/free
  141624             :    and new/delete by the used can be caught more readily.  This may change
  141625             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  141626             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  141627             :    deallocate memory allocated using ROSE_MALLOC.
  141628             : */
  141629           0 : void *SgPowerOp::operator new ( size_t Size )
  141630             : {
  141631             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  141632             :      * returning or throwing an exception. */
  141633           0 :     ALLOC_MUTEX(SgPowerOp, lock);
  141634             : 
  141635             : #if ROSE_ALLOC_TRACE == 2
  141636             : //    printf("SgPowerOp::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgPowerOp::next_node);
  141637             : #endif
  141638             : 
  141639             : #if USE_CPP_NEW_DELETE_OPERATORS
  141640             :     void *mem = ROSE_MALLOC(Size);
  141641             :     ALLOC_MUTEX(SgPowerOp, unlock);
  141642             :     return mem;
  141643             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  141644             : #if ROSE_PEDANTIC_ALLOC
  141645             :     ROSE_ASSERT(Size == sizeof(SgPowerOp));
  141646             : #else
  141647           0 :     if (Size != sizeof(SgPowerOp)) {
  141648           0 :       void * object = ROSE_MALLOC(Size);
  141649           0 :       ALLOC_MUTEX(SgPowerOp, unlock);
  141650             :       return object;
  141651             :     }
  141652             : #endif
  141653             : 
  141654           0 :     if (SgPowerOp::next_node == nullptr) {
  141655           0 :         SgPowerOp * alloc = (SgPowerOp*) ROSE_MALLOC ( SgPowerOp::pool_size * sizeof(SgPowerOp) );
  141656           0 :         ROSE_ASSERT(alloc != nullptr);
  141657             : 
  141658             : #if ROSE_ALLOC_TRACE == 2
  141659             : //        printf("SgPowerOp::alloc\n  block[%zi] = [ %p , %p [\n", SgPowerOp::pools.size(), alloc, alloc + SgPowerOp::pool_size);
  141660             : #endif
  141661             : 
  141662             : #if ROSE_ALLOC_MEMSET == 1
  141663             : #elif ROSE_ALLOC_MEMSET == 2
  141664             :         memset(alloc, 0x00, SgPowerOp::pool_size * sizeof(SgPowerOp));
  141665             : #elif ROSE_ALLOC_MEMSET == 3
  141666             :         memset(alloc, 0xAA, SgPowerOp::pool_size * sizeof(SgPowerOp));
  141667             : #endif
  141668           0 :         for (unsigned i=0; i < SgPowerOp::pool_size-1; i++) {
  141669           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
  141670             :         }
  141671           0 :         alloc[SgPowerOp::pool_size-1].p_freepointer = nullptr;
  141672             : 
  141673           0 :         SgPowerOp::pools.push_back ( (unsigned char *) alloc );
  141674           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgPowerOp::pool_size * sizeof(SgPowerOp), V_SgPowerOp ) );
  141675           0 :         SgPowerOp::next_node = alloc;
  141676             :     }
  141677           0 :     ROSE_ASSERT(SgPowerOp::next_node != nullptr);
  141678             : 
  141679           0 :     SgPowerOp * object = SgPowerOp::next_node;
  141680           0 :     SgPowerOp::next_node = (SgPowerOp*)(object->p_freepointer);
  141681             : 
  141682             : #if ROSE_ALLOC_TRACE == 2
  141683             :     printf("SgPowerOp::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgPowerOp::next_node);
  141684             : #endif
  141685             : 
  141686           0 :     SgNode * fp = object->p_freepointer;
  141687             : #if ROSE_ALLOC_MEMSET == 1
  141688             : #elif ROSE_ALLOC_MEMSET == 2
  141689             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgPowerOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  141690             : #elif ROSE_ALLOC_MEMSET == 3
  141691             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgPowerOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  141692             : #endif
  141693           0 :     object->p_freepointer = fp;
  141694             : 
  141695             : #if ROSE_ALLOC_TRACE == 2
  141696             : //    printf("SgPowerOp::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgPowerOp::next_node);
  141697             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  141698             :     Rose::MemPool::snapshot(oss.str());
  141699             :     alloc_trace_cnt++;
  141700             : #endif
  141701             : 
  141702           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  141703             : 
  141704           0 :     ALLOC_MUTEX(SgPowerOp, unlock);
  141705             : 
  141706             :     return object;
  141707             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  141708             : }
  141709             : 
  141710             : 
  141711             : 
  141712             : /*! \brief Delete operator for SgPowerOp.
  141713             : 
  141714             :    This delete operator implements deallocation using memory pools to 
  141715             :    provide most efficent use of the heap within construction of large ASTs.
  141716             : 
  141717             : \internal The new and delete operators use the lower level C malloc/free
  141718             :    function calls for performance and to make sure that mixing of malloc/free
  141719             :    and new/delete by the used can be caught more readily.  This may change
  141720             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  141721             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  141722             :    deallocate memory allocated using ROSE_MALLOC.
  141723             : */
  141724           0 : void SgPowerOp::operator delete(void *Pointer, size_t Size)
  141725             : {
  141726             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  141727             :      * or throwing an exception. */
  141728           0 :     ALLOC_MUTEX(SgPowerOp, lock);
  141729             : 
  141730             : #if USE_CPP_NEW_DELETE_OPERATORS
  141731             :     ROSE_FREE(Pointer);
  141732             : #else
  141733             : #if ROSE_PEDANTIC_ALLOC
  141734             :     ROSE_ASSERT(Size == sizeof(SgPowerOp));
  141735             : #else
  141736           0 :     if (Size != sizeof(SgPowerOp)) {
  141737           0 :       ROSE_FREE(Pointer);
  141738           0 :       ALLOC_MUTEX(SgPowerOp, unlock);
  141739             :       return;
  141740             :     }
  141741             : #endif
  141742             : 
  141743           0 :     SgPowerOp * object = (SgPowerOp*) Pointer;
  141744           0 :     ROSE_ASSERT(object != nullptr);
  141745             : 
  141746             : #if ROSE_ALLOC_TRACE == 2
  141747             : //  printf("SgPowerOp::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgPowerOp::next_node);
  141748             :     printf("SgPowerOp::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgPowerOp::next_node);
  141749             : #endif
  141750             : 
  141751             : #if ROSE_PEDANTIC_ALLOC
  141752             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  141753             : #endif
  141754             : 
  141755             : #if ROSE_ALLOC_MEMSET == 1
  141756             : #elif ROSE_ALLOC_MEMSET == 2
  141757             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgPowerOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  141758             : #elif ROSE_ALLOC_MEMSET == 3
  141759             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgPowerOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  141760             : #endif
  141761             : 
  141762             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  141763             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  141764             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  141765             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  141766             : #else
  141767           0 :     object->p_freepointer = SgPowerOp::next_node;
  141768           0 :     SgPowerOp::next_node = object;
  141769             : #endif
  141770             : 
  141771             : #if ROSE_ALLOC_TRACE == 2
  141772             : //  printf("SgPowerOp::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgPowerOp::next_node);
  141773             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  141774             :     Rose::MemPool::snapshot(oss.str());
  141775             :     alloc_trace_cnt++;
  141776             : #endif
  141777             : 
  141778             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  141779             : 
  141780           0 :     ALLOC_MUTEX(SgPowerOp, unlock);
  141781             : }
  141782             : 
  141783             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  141784             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  141785             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  141786             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  141787             : // Also, note comment below from Robb (copied from the Common.code file).
  141788             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  141789             : //
  141790             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  141791             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  141792             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  141793             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  141794             : #if 0
  141795             : void SgPowerOp::operator delete(void* pointer) { SgPowerOp::operator delete (pointer, sizeof(SgPowerOp)); };
  141796             : #endif
  141797             : /* #line 141798 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  141798             : 
  141799             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  141800             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  141801             : // obviously imply C++.
  141802             : 
  141803             : // This implements the support within ROSE for memory pools.  Memory pools
  141804             : // support the most condensed usage of memory within the construction of
  141805             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  141806             : // by a new operator written for each class.
  141807             : 
  141808             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  141809             :     // User wants multi-thread support and POSIX threads are available.
  141810             : #   include <pthread.h>
  141811             :     static pthread_mutex_t SgLeftDivideOp_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  141812             : #else
  141813             :      // Cause synchronization to be skipped.
  141814             : #    ifndef ALLOC_MUTEX
  141815             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  141816             : #    endif
  141817             : #    ifdef _REENTRANT
  141818             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  141819             : #       ifdef _MSC_VER
  141820             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  141821             : #       else
  141822             : #           warning "POSIX threads are not available; synchronization being skipped"
  141823             : #       endif
  141824             : #    endif
  141825             : #endif
  141826             : 
  141827             : #ifndef ROSE_ALLOC_TRACE
  141828             : #  define ROSE_ALLOC_TRACE 0
  141829             : #endif
  141830             : 
  141831             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  141832             : #define ROSE_ALLOC_TRACE_CNT
  141833             : #include "memory-pool-snapshot.h"
  141834             : unsigned long alloc_trace_cnt = 0;
  141835             : #endif
  141836             : 
  141837             : #if ROSE_ALLOC_TRACE
  141838             : const unsigned SgLeftDivideOp::pool_size = 5;
  141839             : #else
  141840             : const unsigned SgLeftDivideOp::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  141841             : #endif
  141842             : 
  141843             : #ifndef ROSE_ALLOC_MEMSET
  141844             : #  define ROSE_ALLOC_MEMSET 0
  141845             : #endif
  141846             : 
  141847             : #ifndef ROSE_PEDANTIC_ALLOC
  141848             : #  define ROSE_PEDANTIC_ALLOC 0
  141849             : #endif
  141850             : 
  141851             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  141852             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  141853             : #endif
  141854             : 
  141855             : #if !defined(SGNODE__ALL_POOLS)
  141856             : #define SGNODE__ALL_POOLS
  141857             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  141858             : #endif
  141859             : 
  141860             : SgLeftDivideOp* SgLeftDivideOp::next_node = nullptr;
  141861             : std::vector<unsigned char*> SgLeftDivideOp::pools;
  141862             : 
  141863             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  141864             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  141865             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  141866             : // around this macro definition rather than each use).
  141867             : #ifndef ALLOC_MUTEX
  141868             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  141869             :         do {                                                                     \
  141870             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  141871             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  141872             :                 abort();                                                         \
  141873             :             }                                                                    \
  141874             :         } while (0);
  141875             : #endif
  141876             : 
  141877             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  141878             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  141879             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  141880             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  141881             : 
  141882             : /*! \brief New operator for SgLeftDivideOp.
  141883             : 
  141884             :    This new operator implements memory pools to provide most efficent 
  141885             :    use of the heap within construction of large ASTs.
  141886             : 
  141887             : \internal The new and delete operators use the lower level C malloc/free
  141888             :    function calls for performance and to make sure that mixing of malloc/free
  141889             :    and new/delete by the used can be caught more readily.  This may change
  141890             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  141891             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  141892             :    deallocate memory allocated using ROSE_MALLOC.
  141893             : */
  141894           0 : void *SgLeftDivideOp::operator new ( size_t Size )
  141895             : {
  141896             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  141897             :      * returning or throwing an exception. */
  141898           0 :     ALLOC_MUTEX(SgLeftDivideOp, lock);
  141899             : 
  141900             : #if ROSE_ALLOC_TRACE == 2
  141901             : //    printf("SgLeftDivideOp::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgLeftDivideOp::next_node);
  141902             : #endif
  141903             : 
  141904             : #if USE_CPP_NEW_DELETE_OPERATORS
  141905             :     void *mem = ROSE_MALLOC(Size);
  141906             :     ALLOC_MUTEX(SgLeftDivideOp, unlock);
  141907             :     return mem;
  141908             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  141909             : #if ROSE_PEDANTIC_ALLOC
  141910             :     ROSE_ASSERT(Size == sizeof(SgLeftDivideOp));
  141911             : #else
  141912           0 :     if (Size != sizeof(SgLeftDivideOp)) {
  141913           0 :       void * object = ROSE_MALLOC(Size);
  141914           0 :       ALLOC_MUTEX(SgLeftDivideOp, unlock);
  141915             :       return object;
  141916             :     }
  141917             : #endif
  141918             : 
  141919           0 :     if (SgLeftDivideOp::next_node == nullptr) {
  141920           0 :         SgLeftDivideOp * alloc = (SgLeftDivideOp*) ROSE_MALLOC ( SgLeftDivideOp::pool_size * sizeof(SgLeftDivideOp) );
  141921           0 :         ROSE_ASSERT(alloc != nullptr);
  141922             : 
  141923             : #if ROSE_ALLOC_TRACE == 2
  141924             : //        printf("SgLeftDivideOp::alloc\n  block[%zi] = [ %p , %p [\n", SgLeftDivideOp::pools.size(), alloc, alloc + SgLeftDivideOp::pool_size);
  141925             : #endif
  141926             : 
  141927             : #if ROSE_ALLOC_MEMSET == 1
  141928             : #elif ROSE_ALLOC_MEMSET == 2
  141929             :         memset(alloc, 0x00, SgLeftDivideOp::pool_size * sizeof(SgLeftDivideOp));
  141930             : #elif ROSE_ALLOC_MEMSET == 3
  141931             :         memset(alloc, 0xAA, SgLeftDivideOp::pool_size * sizeof(SgLeftDivideOp));
  141932             : #endif
  141933           0 :         for (unsigned i=0; i < SgLeftDivideOp::pool_size-1; i++) {
  141934           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
  141935             :         }
  141936           0 :         alloc[SgLeftDivideOp::pool_size-1].p_freepointer = nullptr;
  141937             : 
  141938           0 :         SgLeftDivideOp::pools.push_back ( (unsigned char *) alloc );
  141939           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgLeftDivideOp::pool_size * sizeof(SgLeftDivideOp), V_SgLeftDivideOp ) );
  141940           0 :         SgLeftDivideOp::next_node = alloc;
  141941             :     }
  141942           0 :     ROSE_ASSERT(SgLeftDivideOp::next_node != nullptr);
  141943             : 
  141944           0 :     SgLeftDivideOp * object = SgLeftDivideOp::next_node;
  141945           0 :     SgLeftDivideOp::next_node = (SgLeftDivideOp*)(object->p_freepointer);
  141946             : 
  141947             : #if ROSE_ALLOC_TRACE == 2
  141948             :     printf("SgLeftDivideOp::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgLeftDivideOp::next_node);
  141949             : #endif
  141950             : 
  141951           0 :     SgNode * fp = object->p_freepointer;
  141952             : #if ROSE_ALLOC_MEMSET == 1
  141953             : #elif ROSE_ALLOC_MEMSET == 2
  141954             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgLeftDivideOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  141955             : #elif ROSE_ALLOC_MEMSET == 3
  141956             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgLeftDivideOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  141957             : #endif
  141958           0 :     object->p_freepointer = fp;
  141959             : 
  141960             : #if ROSE_ALLOC_TRACE == 2
  141961             : //    printf("SgLeftDivideOp::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgLeftDivideOp::next_node);
  141962             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  141963             :     Rose::MemPool::snapshot(oss.str());
  141964             :     alloc_trace_cnt++;
  141965             : #endif
  141966             : 
  141967           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  141968             : 
  141969           0 :     ALLOC_MUTEX(SgLeftDivideOp, unlock);
  141970             : 
  141971             :     return object;
  141972             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  141973             : }
  141974             : 
  141975             : 
  141976             : 
  141977             : /*! \brief Delete operator for SgLeftDivideOp.
  141978             : 
  141979             :    This delete operator implements deallocation using memory pools to 
  141980             :    provide most efficent use of the heap within construction of large ASTs.
  141981             : 
  141982             : \internal The new and delete operators use the lower level C malloc/free
  141983             :    function calls for performance and to make sure that mixing of malloc/free
  141984             :    and new/delete by the used can be caught more readily.  This may change
  141985             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  141986             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  141987             :    deallocate memory allocated using ROSE_MALLOC.
  141988             : */
  141989           0 : void SgLeftDivideOp::operator delete(void *Pointer, size_t Size)
  141990             : {
  141991             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  141992             :      * or throwing an exception. */
  141993           0 :     ALLOC_MUTEX(SgLeftDivideOp, lock);
  141994             : 
  141995             : #if USE_CPP_NEW_DELETE_OPERATORS
  141996             :     ROSE_FREE(Pointer);
  141997             : #else
  141998             : #if ROSE_PEDANTIC_ALLOC
  141999             :     ROSE_ASSERT(Size == sizeof(SgLeftDivideOp));
  142000             : #else
  142001           0 :     if (Size != sizeof(SgLeftDivideOp)) {
  142002           0 :       ROSE_FREE(Pointer);
  142003           0 :       ALLOC_MUTEX(SgLeftDivideOp, unlock);
  142004             :       return;
  142005             :     }
  142006             : #endif
  142007             : 
  142008           0 :     SgLeftDivideOp * object = (SgLeftDivideOp*) Pointer;
  142009           0 :     ROSE_ASSERT(object != nullptr);
  142010             : 
  142011             : #if ROSE_ALLOC_TRACE == 2
  142012             : //  printf("SgLeftDivideOp::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgLeftDivideOp::next_node);
  142013             :     printf("SgLeftDivideOp::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgLeftDivideOp::next_node);
  142014             : #endif
  142015             : 
  142016             : #if ROSE_PEDANTIC_ALLOC
  142017             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  142018             : #endif
  142019             : 
  142020             : #if ROSE_ALLOC_MEMSET == 1
  142021             : #elif ROSE_ALLOC_MEMSET == 2
  142022             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgLeftDivideOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  142023             : #elif ROSE_ALLOC_MEMSET == 3
  142024             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgLeftDivideOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  142025             : #endif
  142026             : 
  142027             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  142028             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  142029             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  142030             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  142031             : #else
  142032           0 :     object->p_freepointer = SgLeftDivideOp::next_node;
  142033           0 :     SgLeftDivideOp::next_node = object;
  142034             : #endif
  142035             : 
  142036             : #if ROSE_ALLOC_TRACE == 2
  142037             : //  printf("SgLeftDivideOp::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgLeftDivideOp::next_node);
  142038             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  142039             :     Rose::MemPool::snapshot(oss.str());
  142040             :     alloc_trace_cnt++;
  142041             : #endif
  142042             : 
  142043             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  142044             : 
  142045           0 :     ALLOC_MUTEX(SgLeftDivideOp, unlock);
  142046             : }
  142047             : 
  142048             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  142049             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  142050             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  142051             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  142052             : // Also, note comment below from Robb (copied from the Common.code file).
  142053             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  142054             : //
  142055             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  142056             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  142057             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  142058             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  142059             : #if 0
  142060             : void SgLeftDivideOp::operator delete(void* pointer) { SgLeftDivideOp::operator delete (pointer, sizeof(SgLeftDivideOp)); };
  142061             : #endif
  142062             : /* #line 142063 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  142063             : 
  142064             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  142065             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  142066             : // obviously imply C++.
  142067             : 
  142068             : // This implements the support within ROSE for memory pools.  Memory pools
  142069             : // support the most condensed usage of memory within the construction of
  142070             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  142071             : // by a new operator written for each class.
  142072             : 
  142073             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  142074             :     // User wants multi-thread support and POSIX threads are available.
  142075             : #   include <pthread.h>
  142076             :     static pthread_mutex_t SgSIMDBinaryOp_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  142077             : #else
  142078             :      // Cause synchronization to be skipped.
  142079             : #    ifndef ALLOC_MUTEX
  142080             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  142081             : #    endif
  142082             : #    ifdef _REENTRANT
  142083             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  142084             : #       ifdef _MSC_VER
  142085             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  142086             : #       else
  142087             : #           warning "POSIX threads are not available; synchronization being skipped"
  142088             : #       endif
  142089             : #    endif
  142090             : #endif
  142091             : 
  142092             : #ifndef ROSE_ALLOC_TRACE
  142093             : #  define ROSE_ALLOC_TRACE 0
  142094             : #endif
  142095             : 
  142096             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  142097             : #define ROSE_ALLOC_TRACE_CNT
  142098             : #include "memory-pool-snapshot.h"
  142099             : unsigned long alloc_trace_cnt = 0;
  142100             : #endif
  142101             : 
  142102             : #if ROSE_ALLOC_TRACE
  142103             : const unsigned SgSIMDBinaryOp::pool_size = 5;
  142104             : #else
  142105             : const unsigned SgSIMDBinaryOp::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  142106             : #endif
  142107             : 
  142108             : #ifndef ROSE_ALLOC_MEMSET
  142109             : #  define ROSE_ALLOC_MEMSET 0
  142110             : #endif
  142111             : 
  142112             : #ifndef ROSE_PEDANTIC_ALLOC
  142113             : #  define ROSE_PEDANTIC_ALLOC 0
  142114             : #endif
  142115             : 
  142116             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  142117             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  142118             : #endif
  142119             : 
  142120             : #if !defined(SGNODE__ALL_POOLS)
  142121             : #define SGNODE__ALL_POOLS
  142122             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  142123             : #endif
  142124             : 
  142125             : SgSIMDBinaryOp* SgSIMDBinaryOp::next_node = nullptr;
  142126             : std::vector<unsigned char*> SgSIMDBinaryOp::pools;
  142127             : 
  142128             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  142129             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  142130             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  142131             : // around this macro definition rather than each use).
  142132             : #ifndef ALLOC_MUTEX
  142133             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  142134             :         do {                                                                     \
  142135             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  142136             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  142137             :                 abort();                                                         \
  142138             :             }                                                                    \
  142139             :         } while (0);
  142140             : #endif
  142141             : 
  142142             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  142143             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  142144             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  142145             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  142146             : 
  142147             : /*! \brief New operator for SgSIMDBinaryOp.
  142148             : 
  142149             :    This new operator implements memory pools to provide most efficent 
  142150             :    use of the heap within construction of large ASTs.
  142151             : 
  142152             : \internal The new and delete operators use the lower level C malloc/free
  142153             :    function calls for performance and to make sure that mixing of malloc/free
  142154             :    and new/delete by the used can be caught more readily.  This may change
  142155             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  142156             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  142157             :    deallocate memory allocated using ROSE_MALLOC.
  142158             : */
  142159           0 : void *SgSIMDBinaryOp::operator new ( size_t Size )
  142160             : {
  142161             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  142162             :      * returning or throwing an exception. */
  142163           0 :     ALLOC_MUTEX(SgSIMDBinaryOp, lock);
  142164             : 
  142165             : #if ROSE_ALLOC_TRACE == 2
  142166             : //    printf("SgSIMDBinaryOp::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgSIMDBinaryOp::next_node);
  142167             : #endif
  142168             : 
  142169             : #if USE_CPP_NEW_DELETE_OPERATORS
  142170             :     void *mem = ROSE_MALLOC(Size);
  142171             :     ALLOC_MUTEX(SgSIMDBinaryOp, unlock);
  142172             :     return mem;
  142173             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  142174             : #if ROSE_PEDANTIC_ALLOC
  142175             :     ROSE_ASSERT(Size == sizeof(SgSIMDBinaryOp));
  142176             : #else
  142177           0 :     if (Size != sizeof(SgSIMDBinaryOp)) {
  142178           0 :       void * object = ROSE_MALLOC(Size);
  142179           0 :       ALLOC_MUTEX(SgSIMDBinaryOp, unlock);
  142180             :       return object;
  142181             :     }
  142182             : #endif
  142183             : 
  142184           0 :     if (SgSIMDBinaryOp::next_node == nullptr) {
  142185           0 :         SgSIMDBinaryOp * alloc = (SgSIMDBinaryOp*) ROSE_MALLOC ( SgSIMDBinaryOp::pool_size * sizeof(SgSIMDBinaryOp) );
  142186           0 :         ROSE_ASSERT(alloc != nullptr);
  142187             : 
  142188             : #if ROSE_ALLOC_TRACE == 2
  142189             : //        printf("SgSIMDBinaryOp::alloc\n  block[%zi] = [ %p , %p [\n", SgSIMDBinaryOp::pools.size(), alloc, alloc + SgSIMDBinaryOp::pool_size);
  142190             : #endif
  142191             : 
  142192             : #if ROSE_ALLOC_MEMSET == 1
  142193             : #elif ROSE_ALLOC_MEMSET == 2
  142194             :         memset(alloc, 0x00, SgSIMDBinaryOp::pool_size * sizeof(SgSIMDBinaryOp));
  142195             : #elif ROSE_ALLOC_MEMSET == 3
  142196             :         memset(alloc, 0xAA, SgSIMDBinaryOp::pool_size * sizeof(SgSIMDBinaryOp));
  142197             : #endif
  142198           0 :         for (unsigned i=0; i < SgSIMDBinaryOp::pool_size-1; i++) {
  142199           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
  142200             :         }
  142201           0 :         alloc[SgSIMDBinaryOp::pool_size-1].p_freepointer = nullptr;
  142202             : 
  142203           0 :         SgSIMDBinaryOp::pools.push_back ( (unsigned char *) alloc );
  142204           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgSIMDBinaryOp::pool_size * sizeof(SgSIMDBinaryOp), V_SgSIMDBinaryOp ) );
  142205           0 :         SgSIMDBinaryOp::next_node = alloc;
  142206             :     }
  142207           0 :     ROSE_ASSERT(SgSIMDBinaryOp::next_node != nullptr);
  142208             : 
  142209           0 :     SgSIMDBinaryOp * object = SgSIMDBinaryOp::next_node;
  142210           0 :     SgSIMDBinaryOp::next_node = (SgSIMDBinaryOp*)(object->p_freepointer);
  142211             : 
  142212             : #if ROSE_ALLOC_TRACE == 2
  142213             :     printf("SgSIMDBinaryOp::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgSIMDBinaryOp::next_node);
  142214             : #endif
  142215             : 
  142216           0 :     SgNode * fp = object->p_freepointer;
  142217             : #if ROSE_ALLOC_MEMSET == 1
  142218             : #elif ROSE_ALLOC_MEMSET == 2
  142219             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgSIMDBinaryOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  142220             : #elif ROSE_ALLOC_MEMSET == 3
  142221             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgSIMDBinaryOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  142222             : #endif
  142223           0 :     object->p_freepointer = fp;
  142224             : 
  142225             : #if ROSE_ALLOC_TRACE == 2
  142226             : //    printf("SgSIMDBinaryOp::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgSIMDBinaryOp::next_node);
  142227             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  142228             :     Rose::MemPool::snapshot(oss.str());
  142229             :     alloc_trace_cnt++;
  142230             : #endif
  142231             : 
  142232           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  142233             : 
  142234           0 :     ALLOC_MUTEX(SgSIMDBinaryOp, unlock);
  142235             : 
  142236             :     return object;
  142237             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  142238             : }
  142239             : 
  142240             : 
  142241             : 
  142242             : /*! \brief Delete operator for SgSIMDBinaryOp.
  142243             : 
  142244             :    This delete operator implements deallocation using memory pools to 
  142245             :    provide most efficent use of the heap within construction of large ASTs.
  142246             : 
  142247             : \internal The new and delete operators use the lower level C malloc/free
  142248             :    function calls for performance and to make sure that mixing of malloc/free
  142249             :    and new/delete by the used can be caught more readily.  This may change
  142250             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  142251             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  142252             :    deallocate memory allocated using ROSE_MALLOC.
  142253             : */
  142254           0 : void SgSIMDBinaryOp::operator delete(void *Pointer, size_t Size)
  142255             : {
  142256             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  142257             :      * or throwing an exception. */
  142258           0 :     ALLOC_MUTEX(SgSIMDBinaryOp, lock);
  142259             : 
  142260             : #if USE_CPP_NEW_DELETE_OPERATORS
  142261             :     ROSE_FREE(Pointer);
  142262             : #else
  142263             : #if ROSE_PEDANTIC_ALLOC
  142264             :     ROSE_ASSERT(Size == sizeof(SgSIMDBinaryOp));
  142265             : #else
  142266           0 :     if (Size != sizeof(SgSIMDBinaryOp)) {
  142267           0 :       ROSE_FREE(Pointer);
  142268           0 :       ALLOC_MUTEX(SgSIMDBinaryOp, unlock);
  142269             :       return;
  142270             :     }
  142271             : #endif
  142272             : 
  142273           0 :     SgSIMDBinaryOp * object = (SgSIMDBinaryOp*) Pointer;
  142274           0 :     ROSE_ASSERT(object != nullptr);
  142275             : 
  142276             : #if ROSE_ALLOC_TRACE == 2
  142277             : //  printf("SgSIMDBinaryOp::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgSIMDBinaryOp::next_node);
  142278             :     printf("SgSIMDBinaryOp::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgSIMDBinaryOp::next_node);
  142279             : #endif
  142280             : 
  142281             : #if ROSE_PEDANTIC_ALLOC
  142282             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  142283             : #endif
  142284             : 
  142285             : #if ROSE_ALLOC_MEMSET == 1
  142286             : #elif ROSE_ALLOC_MEMSET == 2
  142287             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgSIMDBinaryOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  142288             : #elif ROSE_ALLOC_MEMSET == 3
  142289             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgSIMDBinaryOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  142290             : #endif
  142291             : 
  142292             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  142293             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  142294             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  142295             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  142296             : #else
  142297           0 :     object->p_freepointer = SgSIMDBinaryOp::next_node;
  142298           0 :     SgSIMDBinaryOp::next_node = object;
  142299             : #endif
  142300             : 
  142301             : #if ROSE_ALLOC_TRACE == 2
  142302             : //  printf("SgSIMDBinaryOp::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgSIMDBinaryOp::next_node);
  142303             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  142304             :     Rose::MemPool::snapshot(oss.str());
  142305             :     alloc_trace_cnt++;
  142306             : #endif
  142307             : 
  142308             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  142309             : 
  142310           0 :     ALLOC_MUTEX(SgSIMDBinaryOp, unlock);
  142311             : }
  142312             : 
  142313             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  142314             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  142315             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  142316             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  142317             : // Also, note comment below from Robb (copied from the Common.code file).
  142318             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  142319             : //
  142320             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  142321             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  142322             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  142323             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  142324             : #if 0
  142325             : void SgSIMDBinaryOp::operator delete(void* pointer) { SgSIMDBinaryOp::operator delete (pointer, sizeof(SgSIMDBinaryOp)); };
  142326             : #endif
  142327             : /* #line 142328 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  142328             : 
  142329             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  142330             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  142331             : // obviously imply C++.
  142332             : 
  142333             : // This implements the support within ROSE for memory pools.  Memory pools
  142334             : // support the most condensed usage of memory within the construction of
  142335             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  142336             : // by a new operator written for each class.
  142337             : 
  142338             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  142339             :     // User wants multi-thread support and POSIX threads are available.
  142340             : #   include <pthread.h>
  142341             :     static pthread_mutex_t SgSIMDAddOp_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  142342             : #else
  142343             :      // Cause synchronization to be skipped.
  142344             : #    ifndef ALLOC_MUTEX
  142345             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  142346             : #    endif
  142347             : #    ifdef _REENTRANT
  142348             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  142349             : #       ifdef _MSC_VER
  142350             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  142351             : #       else
  142352             : #           warning "POSIX threads are not available; synchronization being skipped"
  142353             : #       endif
  142354             : #    endif
  142355             : #endif
  142356             : 
  142357             : #ifndef ROSE_ALLOC_TRACE
  142358             : #  define ROSE_ALLOC_TRACE 0
  142359             : #endif
  142360             : 
  142361             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  142362             : #define ROSE_ALLOC_TRACE_CNT
  142363             : #include "memory-pool-snapshot.h"
  142364             : unsigned long alloc_trace_cnt = 0;
  142365             : #endif
  142366             : 
  142367             : #if ROSE_ALLOC_TRACE
  142368             : const unsigned SgSIMDAddOp::pool_size = 5;
  142369             : #else
  142370             : const unsigned SgSIMDAddOp::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  142371             : #endif
  142372             : 
  142373             : #ifndef ROSE_ALLOC_MEMSET
  142374             : #  define ROSE_ALLOC_MEMSET 0
  142375             : #endif
  142376             : 
  142377             : #ifndef ROSE_PEDANTIC_ALLOC
  142378             : #  define ROSE_PEDANTIC_ALLOC 0
  142379             : #endif
  142380             : 
  142381             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  142382             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  142383             : #endif
  142384             : 
  142385             : #if !defined(SGNODE__ALL_POOLS)
  142386             : #define SGNODE__ALL_POOLS
  142387             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  142388             : #endif
  142389             : 
  142390             : SgSIMDAddOp* SgSIMDAddOp::next_node = nullptr;
  142391             : std::vector<unsigned char*> SgSIMDAddOp::pools;
  142392             : 
  142393             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  142394             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  142395             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  142396             : // around this macro definition rather than each use).
  142397             : #ifndef ALLOC_MUTEX
  142398             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  142399             :         do {                                                                     \
  142400             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  142401             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  142402             :                 abort();                                                         \
  142403             :             }                                                                    \
  142404             :         } while (0);
  142405             : #endif
  142406             : 
  142407             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  142408             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  142409             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  142410             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  142411             : 
  142412             : /*! \brief New operator for SgSIMDAddOp.
  142413             : 
  142414             :    This new operator implements memory pools to provide most efficent 
  142415             :    use of the heap within construction of large ASTs.
  142416             : 
  142417             : \internal The new and delete operators use the lower level C malloc/free
  142418             :    function calls for performance and to make sure that mixing of malloc/free
  142419             :    and new/delete by the used can be caught more readily.  This may change
  142420             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  142421             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  142422             :    deallocate memory allocated using ROSE_MALLOC.
  142423             : */
  142424           0 : void *SgSIMDAddOp::operator new ( size_t Size )
  142425             : {
  142426             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  142427             :      * returning or throwing an exception. */
  142428           0 :     ALLOC_MUTEX(SgSIMDAddOp, lock);
  142429             : 
  142430             : #if ROSE_ALLOC_TRACE == 2
  142431             : //    printf("SgSIMDAddOp::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgSIMDAddOp::next_node);
  142432             : #endif
  142433             : 
  142434             : #if USE_CPP_NEW_DELETE_OPERATORS
  142435             :     void *mem = ROSE_MALLOC(Size);
  142436             :     ALLOC_MUTEX(SgSIMDAddOp, unlock);
  142437             :     return mem;
  142438             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  142439             : #if ROSE_PEDANTIC_ALLOC
  142440             :     ROSE_ASSERT(Size == sizeof(SgSIMDAddOp));
  142441             : #else
  142442           0 :     if (Size != sizeof(SgSIMDAddOp)) {
  142443           0 :       void * object = ROSE_MALLOC(Size);
  142444           0 :       ALLOC_MUTEX(SgSIMDAddOp, unlock);
  142445             :       return object;
  142446             :     }
  142447             : #endif
  142448             : 
  142449           0 :     if (SgSIMDAddOp::next_node == nullptr) {
  142450           0 :         SgSIMDAddOp * alloc = (SgSIMDAddOp*) ROSE_MALLOC ( SgSIMDAddOp::pool_size * sizeof(SgSIMDAddOp) );
  142451           0 :         ROSE_ASSERT(alloc != nullptr);
  142452             : 
  142453             : #if ROSE_ALLOC_TRACE == 2
  142454             : //        printf("SgSIMDAddOp::alloc\n  block[%zi] = [ %p , %p [\n", SgSIMDAddOp::pools.size(), alloc, alloc + SgSIMDAddOp::pool_size);
  142455             : #endif
  142456             : 
  142457             : #if ROSE_ALLOC_MEMSET == 1
  142458             : #elif ROSE_ALLOC_MEMSET == 2
  142459             :         memset(alloc, 0x00, SgSIMDAddOp::pool_size * sizeof(SgSIMDAddOp));
  142460             : #elif ROSE_ALLOC_MEMSET == 3
  142461             :         memset(alloc, 0xAA, SgSIMDAddOp::pool_size * sizeof(SgSIMDAddOp));
  142462             : #endif
  142463           0 :         for (unsigned i=0; i < SgSIMDAddOp::pool_size-1; i++) {
  142464           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
  142465             :         }
  142466           0 :         alloc[SgSIMDAddOp::pool_size-1].p_freepointer = nullptr;
  142467             : 
  142468           0 :         SgSIMDAddOp::pools.push_back ( (unsigned char *) alloc );
  142469           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgSIMDAddOp::pool_size * sizeof(SgSIMDAddOp), V_SgSIMDAddOp ) );
  142470           0 :         SgSIMDAddOp::next_node = alloc;
  142471             :     }
  142472           0 :     ROSE_ASSERT(SgSIMDAddOp::next_node != nullptr);
  142473             : 
  142474           0 :     SgSIMDAddOp * object = SgSIMDAddOp::next_node;
  142475           0 :     SgSIMDAddOp::next_node = (SgSIMDAddOp*)(object->p_freepointer);
  142476             : 
  142477             : #if ROSE_ALLOC_TRACE == 2
  142478             :     printf("SgSIMDAddOp::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgSIMDAddOp::next_node);
  142479             : #endif
  142480             : 
  142481           0 :     SgNode * fp = object->p_freepointer;
  142482             : #if ROSE_ALLOC_MEMSET == 1
  142483             : #elif ROSE_ALLOC_MEMSET == 2
  142484             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgSIMDAddOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  142485             : #elif ROSE_ALLOC_MEMSET == 3
  142486             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgSIMDAddOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  142487             : #endif
  142488           0 :     object->p_freepointer = fp;
  142489             : 
  142490             : #if ROSE_ALLOC_TRACE == 2
  142491             : //    printf("SgSIMDAddOp::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgSIMDAddOp::next_node);
  142492             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  142493             :     Rose::MemPool::snapshot(oss.str());
  142494             :     alloc_trace_cnt++;
  142495             : #endif
  142496             : 
  142497           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  142498             : 
  142499           0 :     ALLOC_MUTEX(SgSIMDAddOp, unlock);
  142500             : 
  142501             :     return object;
  142502             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  142503             : }
  142504             : 
  142505             : 
  142506             : 
  142507             : /*! \brief Delete operator for SgSIMDAddOp.
  142508             : 
  142509             :    This delete operator implements deallocation using memory pools to 
  142510             :    provide most efficent use of the heap within construction of large ASTs.
  142511             : 
  142512             : \internal The new and delete operators use the lower level C malloc/free
  142513             :    function calls for performance and to make sure that mixing of malloc/free
  142514             :    and new/delete by the used can be caught more readily.  This may change
  142515             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  142516             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  142517             :    deallocate memory allocated using ROSE_MALLOC.
  142518             : */
  142519           0 : void SgSIMDAddOp::operator delete(void *Pointer, size_t Size)
  142520             : {
  142521             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  142522             :      * or throwing an exception. */
  142523           0 :     ALLOC_MUTEX(SgSIMDAddOp, lock);
  142524             : 
  142525             : #if USE_CPP_NEW_DELETE_OPERATORS
  142526             :     ROSE_FREE(Pointer);
  142527             : #else
  142528             : #if ROSE_PEDANTIC_ALLOC
  142529             :     ROSE_ASSERT(Size == sizeof(SgSIMDAddOp));
  142530             : #else
  142531           0 :     if (Size != sizeof(SgSIMDAddOp)) {
  142532           0 :       ROSE_FREE(Pointer);
  142533           0 :       ALLOC_MUTEX(SgSIMDAddOp, unlock);
  142534             :       return;
  142535             :     }
  142536             : #endif
  142537             : 
  142538           0 :     SgSIMDAddOp * object = (SgSIMDAddOp*) Pointer;
  142539           0 :     ROSE_ASSERT(object != nullptr);
  142540             : 
  142541             : #if ROSE_ALLOC_TRACE == 2
  142542             : //  printf("SgSIMDAddOp::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgSIMDAddOp::next_node);
  142543             :     printf("SgSIMDAddOp::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgSIMDAddOp::next_node);
  142544             : #endif
  142545             : 
  142546             : #if ROSE_PEDANTIC_ALLOC
  142547             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  142548             : #endif
  142549             : 
  142550             : #if ROSE_ALLOC_MEMSET == 1
  142551             : #elif ROSE_ALLOC_MEMSET == 2
  142552             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgSIMDAddOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  142553             : #elif ROSE_ALLOC_MEMSET == 3
  142554             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgSIMDAddOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  142555             : #endif
  142556             : 
  142557             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  142558             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  142559             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  142560             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  142561             : #else
  142562           0 :     object->p_freepointer = SgSIMDAddOp::next_node;
  142563           0 :     SgSIMDAddOp::next_node = object;
  142564             : #endif
  142565             : 
  142566             : #if ROSE_ALLOC_TRACE == 2
  142567             : //  printf("SgSIMDAddOp::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgSIMDAddOp::next_node);
  142568             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  142569             :     Rose::MemPool::snapshot(oss.str());
  142570             :     alloc_trace_cnt++;
  142571             : #endif
  142572             : 
  142573             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  142574             : 
  142575           0 :     ALLOC_MUTEX(SgSIMDAddOp, unlock);
  142576             : }
  142577             : 
  142578             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  142579             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  142580             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  142581             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  142582             : // Also, note comment below from Robb (copied from the Common.code file).
  142583             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  142584             : //
  142585             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  142586             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  142587             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  142588             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  142589             : #if 0
  142590             : void SgSIMDAddOp::operator delete(void* pointer) { SgSIMDAddOp::operator delete (pointer, sizeof(SgSIMDAddOp)); };
  142591             : #endif
  142592             : /* #line 142593 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  142593             : 
  142594             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  142595             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  142596             : // obviously imply C++.
  142597             : 
  142598             : // This implements the support within ROSE for memory pools.  Memory pools
  142599             : // support the most condensed usage of memory within the construction of
  142600             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  142601             : // by a new operator written for each class.
  142602             : 
  142603             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  142604             :     // User wants multi-thread support and POSIX threads are available.
  142605             : #   include <pthread.h>
  142606             :     static pthread_mutex_t SgSIMDSubOp_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  142607             : #else
  142608             :      // Cause synchronization to be skipped.
  142609             : #    ifndef ALLOC_MUTEX
  142610             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  142611             : #    endif
  142612             : #    ifdef _REENTRANT
  142613             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  142614             : #       ifdef _MSC_VER
  142615             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  142616             : #       else
  142617             : #           warning "POSIX threads are not available; synchronization being skipped"
  142618             : #       endif
  142619             : #    endif
  142620             : #endif
  142621             : 
  142622             : #ifndef ROSE_ALLOC_TRACE
  142623             : #  define ROSE_ALLOC_TRACE 0
  142624             : #endif
  142625             : 
  142626             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  142627             : #define ROSE_ALLOC_TRACE_CNT
  142628             : #include "memory-pool-snapshot.h"
  142629             : unsigned long alloc_trace_cnt = 0;
  142630             : #endif
  142631             : 
  142632             : #if ROSE_ALLOC_TRACE
  142633             : const unsigned SgSIMDSubOp::pool_size = 5;
  142634             : #else
  142635             : const unsigned SgSIMDSubOp::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  142636             : #endif
  142637             : 
  142638             : #ifndef ROSE_ALLOC_MEMSET
  142639             : #  define ROSE_ALLOC_MEMSET 0
  142640             : #endif
  142641             : 
  142642             : #ifndef ROSE_PEDANTIC_ALLOC
  142643             : #  define ROSE_PEDANTIC_ALLOC 0
  142644             : #endif
  142645             : 
  142646             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  142647             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  142648             : #endif
  142649             : 
  142650             : #if !defined(SGNODE__ALL_POOLS)
  142651             : #define SGNODE__ALL_POOLS
  142652             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  142653             : #endif
  142654             : 
  142655             : SgSIMDSubOp* SgSIMDSubOp::next_node = nullptr;
  142656             : std::vector<unsigned char*> SgSIMDSubOp::pools;
  142657             : 
  142658             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  142659             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  142660             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  142661             : // around this macro definition rather than each use).
  142662             : #ifndef ALLOC_MUTEX
  142663             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  142664             :         do {                                                                     \
  142665             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  142666             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  142667             :                 abort();                                                         \
  142668             :             }                                                                    \
  142669             :         } while (0);
  142670             : #endif
  142671             : 
  142672             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  142673             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  142674             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  142675             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  142676             : 
  142677             : /*! \brief New operator for SgSIMDSubOp.
  142678             : 
  142679             :    This new operator implements memory pools to provide most efficent 
  142680             :    use of the heap within construction of large ASTs.
  142681             : 
  142682             : \internal The new and delete operators use the lower level C malloc/free
  142683             :    function calls for performance and to make sure that mixing of malloc/free
  142684             :    and new/delete by the used can be caught more readily.  This may change
  142685             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  142686             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  142687             :    deallocate memory allocated using ROSE_MALLOC.
  142688             : */
  142689           0 : void *SgSIMDSubOp::operator new ( size_t Size )
  142690             : {
  142691             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  142692             :      * returning or throwing an exception. */
  142693           0 :     ALLOC_MUTEX(SgSIMDSubOp, lock);
  142694             : 
  142695             : #if ROSE_ALLOC_TRACE == 2
  142696             : //    printf("SgSIMDSubOp::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgSIMDSubOp::next_node);
  142697             : #endif
  142698             : 
  142699             : #if USE_CPP_NEW_DELETE_OPERATORS
  142700             :     void *mem = ROSE_MALLOC(Size);
  142701             :     ALLOC_MUTEX(SgSIMDSubOp, unlock);
  142702             :     return mem;
  142703             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  142704             : #if ROSE_PEDANTIC_ALLOC
  142705             :     ROSE_ASSERT(Size == sizeof(SgSIMDSubOp));
  142706             : #else
  142707           0 :     if (Size != sizeof(SgSIMDSubOp)) {
  142708           0 :       void * object = ROSE_MALLOC(Size);
  142709           0 :       ALLOC_MUTEX(SgSIMDSubOp, unlock);
  142710             :       return object;
  142711             :     }
  142712             : #endif
  142713             : 
  142714           0 :     if (SgSIMDSubOp::next_node == nullptr) {
  142715           0 :         SgSIMDSubOp * alloc = (SgSIMDSubOp*) ROSE_MALLOC ( SgSIMDSubOp::pool_size * sizeof(SgSIMDSubOp) );
  142716           0 :         ROSE_ASSERT(alloc != nullptr);
  142717             : 
  142718             : #if ROSE_ALLOC_TRACE == 2
  142719             : //        printf("SgSIMDSubOp::alloc\n  block[%zi] = [ %p , %p [\n", SgSIMDSubOp::pools.size(), alloc, alloc + SgSIMDSubOp::pool_size);
  142720             : #endif
  142721             : 
  142722             : #if ROSE_ALLOC_MEMSET == 1
  142723             : #elif ROSE_ALLOC_MEMSET == 2
  142724             :         memset(alloc, 0x00, SgSIMDSubOp::pool_size * sizeof(SgSIMDSubOp));
  142725             : #elif ROSE_ALLOC_MEMSET == 3
  142726             :         memset(alloc, 0xAA, SgSIMDSubOp::pool_size * sizeof(SgSIMDSubOp));
  142727             : #endif
  142728           0 :         for (unsigned i=0; i < SgSIMDSubOp::pool_size-1; i++) {
  142729           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
  142730             :         }
  142731           0 :         alloc[SgSIMDSubOp::pool_size-1].p_freepointer = nullptr;
  142732             : 
  142733           0 :         SgSIMDSubOp::pools.push_back ( (unsigned char *) alloc );
  142734           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgSIMDSubOp::pool_size * sizeof(SgSIMDSubOp), V_SgSIMDSubOp ) );
  142735           0 :         SgSIMDSubOp::next_node = alloc;
  142736             :     }
  142737           0 :     ROSE_ASSERT(SgSIMDSubOp::next_node != nullptr);
  142738             : 
  142739           0 :     SgSIMDSubOp * object = SgSIMDSubOp::next_node;
  142740           0 :     SgSIMDSubOp::next_node = (SgSIMDSubOp*)(object->p_freepointer);
  142741             : 
  142742             : #if ROSE_ALLOC_TRACE == 2
  142743             :     printf("SgSIMDSubOp::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgSIMDSubOp::next_node);
  142744             : #endif
  142745             : 
  142746           0 :     SgNode * fp = object->p_freepointer;
  142747             : #if ROSE_ALLOC_MEMSET == 1
  142748             : #elif ROSE_ALLOC_MEMSET == 2
  142749             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgSIMDSubOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  142750             : #elif ROSE_ALLOC_MEMSET == 3
  142751             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgSIMDSubOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  142752             : #endif
  142753           0 :     object->p_freepointer = fp;
  142754             : 
  142755             : #if ROSE_ALLOC_TRACE == 2
  142756             : //    printf("SgSIMDSubOp::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgSIMDSubOp::next_node);
  142757             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  142758             :     Rose::MemPool::snapshot(oss.str());
  142759             :     alloc_trace_cnt++;
  142760             : #endif
  142761             : 
  142762           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  142763             : 
  142764           0 :     ALLOC_MUTEX(SgSIMDSubOp, unlock);
  142765             : 
  142766             :     return object;
  142767             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  142768             : }
  142769             : 
  142770             : 
  142771             : 
  142772             : /*! \brief Delete operator for SgSIMDSubOp.
  142773             : 
  142774             :    This delete operator implements deallocation using memory pools to 
  142775             :    provide most efficent use of the heap within construction of large ASTs.
  142776             : 
  142777             : \internal The new and delete operators use the lower level C malloc/free
  142778             :    function calls for performance and to make sure that mixing of malloc/free
  142779             :    and new/delete by the used can be caught more readily.  This may change
  142780             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  142781             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  142782             :    deallocate memory allocated using ROSE_MALLOC.
  142783             : */
  142784           0 : void SgSIMDSubOp::operator delete(void *Pointer, size_t Size)
  142785             : {
  142786             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  142787             :      * or throwing an exception. */
  142788           0 :     ALLOC_MUTEX(SgSIMDSubOp, lock);
  142789             : 
  142790             : #if USE_CPP_NEW_DELETE_OPERATORS
  142791             :     ROSE_FREE(Pointer);
  142792             : #else
  142793             : #if ROSE_PEDANTIC_ALLOC
  142794             :     ROSE_ASSERT(Size == sizeof(SgSIMDSubOp));
  142795             : #else
  142796           0 :     if (Size != sizeof(SgSIMDSubOp)) {
  142797           0 :       ROSE_FREE(Pointer);
  142798           0 :       ALLOC_MUTEX(SgSIMDSubOp, unlock);
  142799             :       return;
  142800             :     }
  142801             : #endif
  142802             : 
  142803           0 :     SgSIMDSubOp * object = (SgSIMDSubOp*) Pointer;
  142804           0 :     ROSE_ASSERT(object != nullptr);
  142805             : 
  142806             : #if ROSE_ALLOC_TRACE == 2
  142807             : //  printf("SgSIMDSubOp::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgSIMDSubOp::next_node);
  142808             :     printf("SgSIMDSubOp::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgSIMDSubOp::next_node);
  142809             : #endif
  142810             : 
  142811             : #if ROSE_PEDANTIC_ALLOC
  142812             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  142813             : #endif
  142814             : 
  142815             : #if ROSE_ALLOC_MEMSET == 1
  142816             : #elif ROSE_ALLOC_MEMSET == 2
  142817             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgSIMDSubOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  142818             : #elif ROSE_ALLOC_MEMSET == 3
  142819             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgSIMDSubOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  142820             : #endif
  142821             : 
  142822             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  142823             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  142824             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  142825             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  142826             : #else
  142827           0 :     object->p_freepointer = SgSIMDSubOp::next_node;
  142828           0 :     SgSIMDSubOp::next_node = object;
  142829             : #endif
  142830             : 
  142831             : #if ROSE_ALLOC_TRACE == 2
  142832             : //  printf("SgSIMDSubOp::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgSIMDSubOp::next_node);
  142833             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  142834             :     Rose::MemPool::snapshot(oss.str());
  142835             :     alloc_trace_cnt++;
  142836             : #endif
  142837             : 
  142838             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  142839             : 
  142840           0 :     ALLOC_MUTEX(SgSIMDSubOp, unlock);
  142841             : }
  142842             : 
  142843             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  142844             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  142845             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  142846             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  142847             : // Also, note comment below from Robb (copied from the Common.code file).
  142848             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  142849             : //
  142850             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  142851             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  142852             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  142853             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  142854             : #if 0
  142855             : void SgSIMDSubOp::operator delete(void* pointer) { SgSIMDSubOp::operator delete (pointer, sizeof(SgSIMDSubOp)); };
  142856             : #endif
  142857             : /* #line 142858 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  142858             : 
  142859             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  142860             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  142861             : // obviously imply C++.
  142862             : 
  142863             : // This implements the support within ROSE for memory pools.  Memory pools
  142864             : // support the most condensed usage of memory within the construction of
  142865             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  142866             : // by a new operator written for each class.
  142867             : 
  142868             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  142869             :     // User wants multi-thread support and POSIX threads are available.
  142870             : #   include <pthread.h>
  142871             :     static pthread_mutex_t SgSIMDMulOp_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  142872             : #else
  142873             :      // Cause synchronization to be skipped.
  142874             : #    ifndef ALLOC_MUTEX
  142875             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  142876             : #    endif
  142877             : #    ifdef _REENTRANT
  142878             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  142879             : #       ifdef _MSC_VER
  142880             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  142881             : #       else
  142882             : #           warning "POSIX threads are not available; synchronization being skipped"
  142883             : #       endif
  142884             : #    endif
  142885             : #endif
  142886             : 
  142887             : #ifndef ROSE_ALLOC_TRACE
  142888             : #  define ROSE_ALLOC_TRACE 0
  142889             : #endif
  142890             : 
  142891             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  142892             : #define ROSE_ALLOC_TRACE_CNT
  142893             : #include "memory-pool-snapshot.h"
  142894             : unsigned long alloc_trace_cnt = 0;
  142895             : #endif
  142896             : 
  142897             : #if ROSE_ALLOC_TRACE
  142898             : const unsigned SgSIMDMulOp::pool_size = 5;
  142899             : #else
  142900             : const unsigned SgSIMDMulOp::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  142901             : #endif
  142902             : 
  142903             : #ifndef ROSE_ALLOC_MEMSET
  142904             : #  define ROSE_ALLOC_MEMSET 0
  142905             : #endif
  142906             : 
  142907             : #ifndef ROSE_PEDANTIC_ALLOC
  142908             : #  define ROSE_PEDANTIC_ALLOC 0
  142909             : #endif
  142910             : 
  142911             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  142912             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  142913             : #endif
  142914             : 
  142915             : #if !defined(SGNODE__ALL_POOLS)
  142916             : #define SGNODE__ALL_POOLS
  142917             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  142918             : #endif
  142919             : 
  142920             : SgSIMDMulOp* SgSIMDMulOp::next_node = nullptr;
  142921             : std::vector<unsigned char*> SgSIMDMulOp::pools;
  142922             : 
  142923             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  142924             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  142925             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  142926             : // around this macro definition rather than each use).
  142927             : #ifndef ALLOC_MUTEX
  142928             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  142929             :         do {                                                                     \
  142930             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  142931             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  142932             :                 abort();                                                         \
  142933             :             }                                                                    \
  142934             :         } while (0);
  142935             : #endif
  142936             : 
  142937             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  142938             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  142939             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  142940             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  142941             : 
  142942             : /*! \brief New operator for SgSIMDMulOp.
  142943             : 
  142944             :    This new operator implements memory pools to provide most efficent 
  142945             :    use of the heap within construction of large ASTs.
  142946             : 
  142947             : \internal The new and delete operators use the lower level C malloc/free
  142948             :    function calls for performance and to make sure that mixing of malloc/free
  142949             :    and new/delete by the used can be caught more readily.  This may change
  142950             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  142951             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  142952             :    deallocate memory allocated using ROSE_MALLOC.
  142953             : */
  142954           0 : void *SgSIMDMulOp::operator new ( size_t Size )
  142955             : {
  142956             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  142957             :      * returning or throwing an exception. */
  142958           0 :     ALLOC_MUTEX(SgSIMDMulOp, lock);
  142959             : 
  142960             : #if ROSE_ALLOC_TRACE == 2
  142961             : //    printf("SgSIMDMulOp::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgSIMDMulOp::next_node);
  142962             : #endif
  142963             : 
  142964             : #if USE_CPP_NEW_DELETE_OPERATORS
  142965             :     void *mem = ROSE_MALLOC(Size);
  142966             :     ALLOC_MUTEX(SgSIMDMulOp, unlock);
  142967             :     return mem;
  142968             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  142969             : #if ROSE_PEDANTIC_ALLOC
  142970             :     ROSE_ASSERT(Size == sizeof(SgSIMDMulOp));
  142971             : #else
  142972           0 :     if (Size != sizeof(SgSIMDMulOp)) {
  142973           0 :       void * object = ROSE_MALLOC(Size);
  142974           0 :       ALLOC_MUTEX(SgSIMDMulOp, unlock);
  142975             :       return object;
  142976             :     }
  142977             : #endif
  142978             : 
  142979           0 :     if (SgSIMDMulOp::next_node == nullptr) {
  142980           0 :         SgSIMDMulOp * alloc = (SgSIMDMulOp*) ROSE_MALLOC ( SgSIMDMulOp::pool_size * sizeof(SgSIMDMulOp) );
  142981           0 :         ROSE_ASSERT(alloc != nullptr);
  142982             : 
  142983             : #if ROSE_ALLOC_TRACE == 2
  142984             : //        printf("SgSIMDMulOp::alloc\n  block[%zi] = [ %p , %p [\n", SgSIMDMulOp::pools.size(), alloc, alloc + SgSIMDMulOp::pool_size);
  142985             : #endif
  142986             : 
  142987             : #if ROSE_ALLOC_MEMSET == 1
  142988             : #elif ROSE_ALLOC_MEMSET == 2
  142989             :         memset(alloc, 0x00, SgSIMDMulOp::pool_size * sizeof(SgSIMDMulOp));
  142990             : #elif ROSE_ALLOC_MEMSET == 3
  142991             :         memset(alloc, 0xAA, SgSIMDMulOp::pool_size * sizeof(SgSIMDMulOp));
  142992             : #endif
  142993           0 :         for (unsigned i=0; i < SgSIMDMulOp::pool_size-1; i++) {
  142994           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
  142995             :         }
  142996           0 :         alloc[SgSIMDMulOp::pool_size-1].p_freepointer = nullptr;
  142997             : 
  142998           0 :         SgSIMDMulOp::pools.push_back ( (unsigned char *) alloc );
  142999           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgSIMDMulOp::pool_size * sizeof(SgSIMDMulOp), V_SgSIMDMulOp ) );
  143000           0 :         SgSIMDMulOp::next_node = alloc;
  143001             :     }
  143002           0 :     ROSE_ASSERT(SgSIMDMulOp::next_node != nullptr);
  143003             : 
  143004           0 :     SgSIMDMulOp * object = SgSIMDMulOp::next_node;
  143005           0 :     SgSIMDMulOp::next_node = (SgSIMDMulOp*)(object->p_freepointer);
  143006             : 
  143007             : #if ROSE_ALLOC_TRACE == 2
  143008             :     printf("SgSIMDMulOp::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgSIMDMulOp::next_node);
  143009             : #endif
  143010             : 
  143011           0 :     SgNode * fp = object->p_freepointer;
  143012             : #if ROSE_ALLOC_MEMSET == 1
  143013             : #elif ROSE_ALLOC_MEMSET == 2
  143014             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgSIMDMulOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  143015             : #elif ROSE_ALLOC_MEMSET == 3
  143016             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgSIMDMulOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  143017             : #endif
  143018           0 :     object->p_freepointer = fp;
  143019             : 
  143020             : #if ROSE_ALLOC_TRACE == 2
  143021             : //    printf("SgSIMDMulOp::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgSIMDMulOp::next_node);
  143022             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  143023             :     Rose::MemPool::snapshot(oss.str());
  143024             :     alloc_trace_cnt++;
  143025             : #endif
  143026             : 
  143027           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  143028             : 
  143029           0 :     ALLOC_MUTEX(SgSIMDMulOp, unlock);
  143030             : 
  143031             :     return object;
  143032             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  143033             : }
  143034             : 
  143035             : 
  143036             : 
  143037             : /*! \brief Delete operator for SgSIMDMulOp.
  143038             : 
  143039             :    This delete operator implements deallocation using memory pools to 
  143040             :    provide most efficent use of the heap within construction of large ASTs.
  143041             : 
  143042             : \internal The new and delete operators use the lower level C malloc/free
  143043             :    function calls for performance and to make sure that mixing of malloc/free
  143044             :    and new/delete by the used can be caught more readily.  This may change
  143045             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  143046             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  143047             :    deallocate memory allocated using ROSE_MALLOC.
  143048             : */
  143049           0 : void SgSIMDMulOp::operator delete(void *Pointer, size_t Size)
  143050             : {
  143051             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  143052             :      * or throwing an exception. */
  143053           0 :     ALLOC_MUTEX(SgSIMDMulOp, lock);
  143054             : 
  143055             : #if USE_CPP_NEW_DELETE_OPERATORS
  143056             :     ROSE_FREE(Pointer);
  143057             : #else
  143058             : #if ROSE_PEDANTIC_ALLOC
  143059             :     ROSE_ASSERT(Size == sizeof(SgSIMDMulOp));
  143060             : #else
  143061           0 :     if (Size != sizeof(SgSIMDMulOp)) {
  143062           0 :       ROSE_FREE(Pointer);
  143063           0 :       ALLOC_MUTEX(SgSIMDMulOp, unlock);
  143064             :       return;
  143065             :     }
  143066             : #endif
  143067             : 
  143068           0 :     SgSIMDMulOp * object = (SgSIMDMulOp*) Pointer;
  143069           0 :     ROSE_ASSERT(object != nullptr);
  143070             : 
  143071             : #if ROSE_ALLOC_TRACE == 2
  143072             : //  printf("SgSIMDMulOp::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgSIMDMulOp::next_node);
  143073             :     printf("SgSIMDMulOp::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgSIMDMulOp::next_node);
  143074             : #endif
  143075             : 
  143076             : #if ROSE_PEDANTIC_ALLOC
  143077             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  143078             : #endif
  143079             : 
  143080             : #if ROSE_ALLOC_MEMSET == 1
  143081             : #elif ROSE_ALLOC_MEMSET == 2
  143082             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgSIMDMulOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  143083             : #elif ROSE_ALLOC_MEMSET == 3
  143084             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgSIMDMulOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  143085             : #endif
  143086             : 
  143087             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  143088             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  143089             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  143090             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  143091             : #else
  143092           0 :     object->p_freepointer = SgSIMDMulOp::next_node;
  143093           0 :     SgSIMDMulOp::next_node = object;
  143094             : #endif
  143095             : 
  143096             : #if ROSE_ALLOC_TRACE == 2
  143097             : //  printf("SgSIMDMulOp::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgSIMDMulOp::next_node);
  143098             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  143099             :     Rose::MemPool::snapshot(oss.str());
  143100             :     alloc_trace_cnt++;
  143101             : #endif
  143102             : 
  143103             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  143104             : 
  143105           0 :     ALLOC_MUTEX(SgSIMDMulOp, unlock);
  143106             : }
  143107             : 
  143108             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  143109             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  143110             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  143111             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  143112             : // Also, note comment below from Robb (copied from the Common.code file).
  143113             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  143114             : //
  143115             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  143116             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  143117             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  143118             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  143119             : #if 0
  143120             : void SgSIMDMulOp::operator delete(void* pointer) { SgSIMDMulOp::operator delete (pointer, sizeof(SgSIMDMulOp)); };
  143121             : #endif
  143122             : /* #line 143123 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  143123             : 
  143124             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  143125             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  143126             : // obviously imply C++.
  143127             : 
  143128             : // This implements the support within ROSE for memory pools.  Memory pools
  143129             : // support the most condensed usage of memory within the construction of
  143130             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  143131             : // by a new operator written for each class.
  143132             : 
  143133             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  143134             :     // User wants multi-thread support and POSIX threads are available.
  143135             : #   include <pthread.h>
  143136             :     static pthread_mutex_t SgSIMDDivOp_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  143137             : #else
  143138             :      // Cause synchronization to be skipped.
  143139             : #    ifndef ALLOC_MUTEX
  143140             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  143141             : #    endif
  143142             : #    ifdef _REENTRANT
  143143             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  143144             : #       ifdef _MSC_VER
  143145             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  143146             : #       else
  143147             : #           warning "POSIX threads are not available; synchronization being skipped"
  143148             : #       endif
  143149             : #    endif
  143150             : #endif
  143151             : 
  143152             : #ifndef ROSE_ALLOC_TRACE
  143153             : #  define ROSE_ALLOC_TRACE 0
  143154             : #endif
  143155             : 
  143156             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  143157             : #define ROSE_ALLOC_TRACE_CNT
  143158             : #include "memory-pool-snapshot.h"
  143159             : unsigned long alloc_trace_cnt = 0;
  143160             : #endif
  143161             : 
  143162             : #if ROSE_ALLOC_TRACE
  143163             : const unsigned SgSIMDDivOp::pool_size = 5;
  143164             : #else
  143165             : const unsigned SgSIMDDivOp::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  143166             : #endif
  143167             : 
  143168             : #ifndef ROSE_ALLOC_MEMSET
  143169             : #  define ROSE_ALLOC_MEMSET 0
  143170             : #endif
  143171             : 
  143172             : #ifndef ROSE_PEDANTIC_ALLOC
  143173             : #  define ROSE_PEDANTIC_ALLOC 0
  143174             : #endif
  143175             : 
  143176             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  143177             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  143178             : #endif
  143179             : 
  143180             : #if !defined(SGNODE__ALL_POOLS)
  143181             : #define SGNODE__ALL_POOLS
  143182             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  143183             : #endif
  143184             : 
  143185             : SgSIMDDivOp* SgSIMDDivOp::next_node = nullptr;
  143186             : std::vector<unsigned char*> SgSIMDDivOp::pools;
  143187             : 
  143188             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  143189             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  143190             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  143191             : // around this macro definition rather than each use).
  143192             : #ifndef ALLOC_MUTEX
  143193             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  143194             :         do {                                                                     \
  143195             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  143196             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  143197             :                 abort();                                                         \
  143198             :             }                                                                    \
  143199             :         } while (0);
  143200             : #endif
  143201             : 
  143202             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  143203             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  143204             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  143205             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  143206             : 
  143207             : /*! \brief New operator for SgSIMDDivOp.
  143208             : 
  143209             :    This new operator implements memory pools to provide most efficent 
  143210             :    use of the heap within construction of large ASTs.
  143211             : 
  143212             : \internal The new and delete operators use the lower level C malloc/free
  143213             :    function calls for performance and to make sure that mixing of malloc/free
  143214             :    and new/delete by the used can be caught more readily.  This may change
  143215             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  143216             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  143217             :    deallocate memory allocated using ROSE_MALLOC.
  143218             : */
  143219           0 : void *SgSIMDDivOp::operator new ( size_t Size )
  143220             : {
  143221             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  143222             :      * returning or throwing an exception. */
  143223           0 :     ALLOC_MUTEX(SgSIMDDivOp, lock);
  143224             : 
  143225             : #if ROSE_ALLOC_TRACE == 2
  143226             : //    printf("SgSIMDDivOp::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgSIMDDivOp::next_node);
  143227             : #endif
  143228             : 
  143229             : #if USE_CPP_NEW_DELETE_OPERATORS
  143230             :     void *mem = ROSE_MALLOC(Size);
  143231             :     ALLOC_MUTEX(SgSIMDDivOp, unlock);
  143232             :     return mem;
  143233             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  143234             : #if ROSE_PEDANTIC_ALLOC
  143235             :     ROSE_ASSERT(Size == sizeof(SgSIMDDivOp));
  143236             : #else
  143237           0 :     if (Size != sizeof(SgSIMDDivOp)) {
  143238           0 :       void * object = ROSE_MALLOC(Size);
  143239           0 :       ALLOC_MUTEX(SgSIMDDivOp, unlock);
  143240             :       return object;
  143241             :     }
  143242             : #endif
  143243             : 
  143244           0 :     if (SgSIMDDivOp::next_node == nullptr) {
  143245           0 :         SgSIMDDivOp * alloc = (SgSIMDDivOp*) ROSE_MALLOC ( SgSIMDDivOp::pool_size * sizeof(SgSIMDDivOp) );
  143246           0 :         ROSE_ASSERT(alloc != nullptr);
  143247             : 
  143248             : #if ROSE_ALLOC_TRACE == 2
  143249             : //        printf("SgSIMDDivOp::alloc\n  block[%zi] = [ %p , %p [\n", SgSIMDDivOp::pools.size(), alloc, alloc + SgSIMDDivOp::pool_size);
  143250             : #endif
  143251             : 
  143252             : #if ROSE_ALLOC_MEMSET == 1
  143253             : #elif ROSE_ALLOC_MEMSET == 2
  143254             :         memset(alloc, 0x00, SgSIMDDivOp::pool_size * sizeof(SgSIMDDivOp));
  143255             : #elif ROSE_ALLOC_MEMSET == 3
  143256             :         memset(alloc, 0xAA, SgSIMDDivOp::pool_size * sizeof(SgSIMDDivOp));
  143257             : #endif
  143258           0 :         for (unsigned i=0; i < SgSIMDDivOp::pool_size-1; i++) {
  143259           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
  143260             :         }
  143261           0 :         alloc[SgSIMDDivOp::pool_size-1].p_freepointer = nullptr;
  143262             : 
  143263           0 :         SgSIMDDivOp::pools.push_back ( (unsigned char *) alloc );
  143264           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgSIMDDivOp::pool_size * sizeof(SgSIMDDivOp), V_SgSIMDDivOp ) );
  143265           0 :         SgSIMDDivOp::next_node = alloc;
  143266             :     }
  143267           0 :     ROSE_ASSERT(SgSIMDDivOp::next_node != nullptr);
  143268             : 
  143269           0 :     SgSIMDDivOp * object = SgSIMDDivOp::next_node;
  143270           0 :     SgSIMDDivOp::next_node = (SgSIMDDivOp*)(object->p_freepointer);
  143271             : 
  143272             : #if ROSE_ALLOC_TRACE == 2
  143273             :     printf("SgSIMDDivOp::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgSIMDDivOp::next_node);
  143274             : #endif
  143275             : 
  143276           0 :     SgNode * fp = object->p_freepointer;
  143277             : #if ROSE_ALLOC_MEMSET == 1
  143278             : #elif ROSE_ALLOC_MEMSET == 2
  143279             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgSIMDDivOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  143280             : #elif ROSE_ALLOC_MEMSET == 3
  143281             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgSIMDDivOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  143282             : #endif
  143283           0 :     object->p_freepointer = fp;
  143284             : 
  143285             : #if ROSE_ALLOC_TRACE == 2
  143286             : //    printf("SgSIMDDivOp::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgSIMDDivOp::next_node);
  143287             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  143288             :     Rose::MemPool::snapshot(oss.str());
  143289             :     alloc_trace_cnt++;
  143290             : #endif
  143291             : 
  143292           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  143293             : 
  143294           0 :     ALLOC_MUTEX(SgSIMDDivOp, unlock);
  143295             : 
  143296             :     return object;
  143297             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  143298             : }
  143299             : 
  143300             : 
  143301             : 
  143302             : /*! \brief Delete operator for SgSIMDDivOp.
  143303             : 
  143304             :    This delete operator implements deallocation using memory pools to 
  143305             :    provide most efficent use of the heap within construction of large ASTs.
  143306             : 
  143307             : \internal The new and delete operators use the lower level C malloc/free
  143308             :    function calls for performance and to make sure that mixing of malloc/free
  143309             :    and new/delete by the used can be caught more readily.  This may change
  143310             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  143311             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  143312             :    deallocate memory allocated using ROSE_MALLOC.
  143313             : */
  143314           0 : void SgSIMDDivOp::operator delete(void *Pointer, size_t Size)
  143315             : {
  143316             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  143317             :      * or throwing an exception. */
  143318           0 :     ALLOC_MUTEX(SgSIMDDivOp, lock);
  143319             : 
  143320             : #if USE_CPP_NEW_DELETE_OPERATORS
  143321             :     ROSE_FREE(Pointer);
  143322             : #else
  143323             : #if ROSE_PEDANTIC_ALLOC
  143324             :     ROSE_ASSERT(Size == sizeof(SgSIMDDivOp));
  143325             : #else
  143326           0 :     if (Size != sizeof(SgSIMDDivOp)) {
  143327           0 :       ROSE_FREE(Pointer);
  143328           0 :       ALLOC_MUTEX(SgSIMDDivOp, unlock);
  143329             :       return;
  143330             :     }
  143331             : #endif
  143332             : 
  143333           0 :     SgSIMDDivOp * object = (SgSIMDDivOp*) Pointer;
  143334           0 :     ROSE_ASSERT(object != nullptr);
  143335             : 
  143336             : #if ROSE_ALLOC_TRACE == 2
  143337             : //  printf("SgSIMDDivOp::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgSIMDDivOp::next_node);
  143338             :     printf("SgSIMDDivOp::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgSIMDDivOp::next_node);
  143339             : #endif
  143340             : 
  143341             : #if ROSE_PEDANTIC_ALLOC
  143342             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  143343             : #endif
  143344             : 
  143345             : #if ROSE_ALLOC_MEMSET == 1
  143346             : #elif ROSE_ALLOC_MEMSET == 2
  143347             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgSIMDDivOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  143348             : #elif ROSE_ALLOC_MEMSET == 3
  143349             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgSIMDDivOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  143350             : #endif
  143351             : 
  143352             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  143353             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  143354             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  143355             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  143356             : #else
  143357           0 :     object->p_freepointer = SgSIMDDivOp::next_node;
  143358           0 :     SgSIMDDivOp::next_node = object;
  143359             : #endif
  143360             : 
  143361             : #if ROSE_ALLOC_TRACE == 2
  143362             : //  printf("SgSIMDDivOp::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgSIMDDivOp::next_node);
  143363             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  143364             :     Rose::MemPool::snapshot(oss.str());
  143365             :     alloc_trace_cnt++;
  143366             : #endif
  143367             : 
  143368             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  143369             : 
  143370           0 :     ALLOC_MUTEX(SgSIMDDivOp, unlock);
  143371             : }
  143372             : 
  143373             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  143374             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  143375             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  143376             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  143377             : // Also, note comment below from Robb (copied from the Common.code file).
  143378             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  143379             : //
  143380             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  143381             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  143382             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  143383             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  143384             : #if 0
  143385             : void SgSIMDDivOp::operator delete(void* pointer) { SgSIMDDivOp::operator delete (pointer, sizeof(SgSIMDDivOp)); };
  143386             : #endif
  143387             : /* #line 143388 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  143388             : 
  143389             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  143390             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  143391             : // obviously imply C++.
  143392             : 
  143393             : // This implements the support within ROSE for memory pools.  Memory pools
  143394             : // support the most condensed usage of memory within the construction of
  143395             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  143396             : // by a new operator written for each class.
  143397             : 
  143398             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  143399             :     // User wants multi-thread support and POSIX threads are available.
  143400             : #   include <pthread.h>
  143401             :     static pthread_mutex_t SgSIMDFmaOp_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  143402             : #else
  143403             :      // Cause synchronization to be skipped.
  143404             : #    ifndef ALLOC_MUTEX
  143405             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  143406             : #    endif
  143407             : #    ifdef _REENTRANT
  143408             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  143409             : #       ifdef _MSC_VER
  143410             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  143411             : #       else
  143412             : #           warning "POSIX threads are not available; synchronization being skipped"
  143413             : #       endif
  143414             : #    endif
  143415             : #endif
  143416             : 
  143417             : #ifndef ROSE_ALLOC_TRACE
  143418             : #  define ROSE_ALLOC_TRACE 0
  143419             : #endif
  143420             : 
  143421             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  143422             : #define ROSE_ALLOC_TRACE_CNT
  143423             : #include "memory-pool-snapshot.h"
  143424             : unsigned long alloc_trace_cnt = 0;
  143425             : #endif
  143426             : 
  143427             : #if ROSE_ALLOC_TRACE
  143428             : const unsigned SgSIMDFmaOp::pool_size = 5;
  143429             : #else
  143430             : const unsigned SgSIMDFmaOp::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  143431             : #endif
  143432             : 
  143433             : #ifndef ROSE_ALLOC_MEMSET
  143434             : #  define ROSE_ALLOC_MEMSET 0
  143435             : #endif
  143436             : 
  143437             : #ifndef ROSE_PEDANTIC_ALLOC
  143438             : #  define ROSE_PEDANTIC_ALLOC 0
  143439             : #endif
  143440             : 
  143441             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  143442             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  143443             : #endif
  143444             : 
  143445             : #if !defined(SGNODE__ALL_POOLS)
  143446             : #define SGNODE__ALL_POOLS
  143447             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  143448             : #endif
  143449             : 
  143450             : SgSIMDFmaOp* SgSIMDFmaOp::next_node = nullptr;
  143451             : std::vector<unsigned char*> SgSIMDFmaOp::pools;
  143452             : 
  143453             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  143454             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  143455             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  143456             : // around this macro definition rather than each use).
  143457             : #ifndef ALLOC_MUTEX
  143458             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  143459             :         do {                                                                     \
  143460             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  143461             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  143462             :                 abort();                                                         \
  143463             :             }                                                                    \
  143464             :         } while (0);
  143465             : #endif
  143466             : 
  143467             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  143468             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  143469             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  143470             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  143471             : 
  143472             : /*! \brief New operator for SgSIMDFmaOp.
  143473             : 
  143474             :    This new operator implements memory pools to provide most efficent 
  143475             :    use of the heap within construction of large ASTs.
  143476             : 
  143477             : \internal The new and delete operators use the lower level C malloc/free
  143478             :    function calls for performance and to make sure that mixing of malloc/free
  143479             :    and new/delete by the used can be caught more readily.  This may change
  143480             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  143481             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  143482             :    deallocate memory allocated using ROSE_MALLOC.
  143483             : */
  143484           0 : void *SgSIMDFmaOp::operator new ( size_t Size )
  143485             : {
  143486             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  143487             :      * returning or throwing an exception. */
  143488           0 :     ALLOC_MUTEX(SgSIMDFmaOp, lock);
  143489             : 
  143490             : #if ROSE_ALLOC_TRACE == 2
  143491             : //    printf("SgSIMDFmaOp::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgSIMDFmaOp::next_node);
  143492             : #endif
  143493             : 
  143494             : #if USE_CPP_NEW_DELETE_OPERATORS
  143495             :     void *mem = ROSE_MALLOC(Size);
  143496             :     ALLOC_MUTEX(SgSIMDFmaOp, unlock);
  143497             :     return mem;
  143498             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  143499             : #if ROSE_PEDANTIC_ALLOC
  143500             :     ROSE_ASSERT(Size == sizeof(SgSIMDFmaOp));
  143501             : #else
  143502           0 :     if (Size != sizeof(SgSIMDFmaOp)) {
  143503           0 :       void * object = ROSE_MALLOC(Size);
  143504           0 :       ALLOC_MUTEX(SgSIMDFmaOp, unlock);
  143505             :       return object;
  143506             :     }
  143507             : #endif
  143508             : 
  143509           0 :     if (SgSIMDFmaOp::next_node == nullptr) {
  143510           0 :         SgSIMDFmaOp * alloc = (SgSIMDFmaOp*) ROSE_MALLOC ( SgSIMDFmaOp::pool_size * sizeof(SgSIMDFmaOp) );
  143511           0 :         ROSE_ASSERT(alloc != nullptr);
  143512             : 
  143513             : #if ROSE_ALLOC_TRACE == 2
  143514             : //        printf("SgSIMDFmaOp::alloc\n  block[%zi] = [ %p , %p [\n", SgSIMDFmaOp::pools.size(), alloc, alloc + SgSIMDFmaOp::pool_size);
  143515             : #endif
  143516             : 
  143517             : #if ROSE_ALLOC_MEMSET == 1
  143518             : #elif ROSE_ALLOC_MEMSET == 2
  143519             :         memset(alloc, 0x00, SgSIMDFmaOp::pool_size * sizeof(SgSIMDFmaOp));
  143520             : #elif ROSE_ALLOC_MEMSET == 3
  143521             :         memset(alloc, 0xAA, SgSIMDFmaOp::pool_size * sizeof(SgSIMDFmaOp));
  143522             : #endif
  143523           0 :         for (unsigned i=0; i < SgSIMDFmaOp::pool_size-1; i++) {
  143524           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
  143525             :         }
  143526           0 :         alloc[SgSIMDFmaOp::pool_size-1].p_freepointer = nullptr;
  143527             : 
  143528           0 :         SgSIMDFmaOp::pools.push_back ( (unsigned char *) alloc );
  143529           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgSIMDFmaOp::pool_size * sizeof(SgSIMDFmaOp), V_SgSIMDFmaOp ) );
  143530           0 :         SgSIMDFmaOp::next_node = alloc;
  143531             :     }
  143532           0 :     ROSE_ASSERT(SgSIMDFmaOp::next_node != nullptr);
  143533             : 
  143534           0 :     SgSIMDFmaOp * object = SgSIMDFmaOp::next_node;
  143535           0 :     SgSIMDFmaOp::next_node = (SgSIMDFmaOp*)(object->p_freepointer);
  143536             : 
  143537             : #if ROSE_ALLOC_TRACE == 2
  143538             :     printf("SgSIMDFmaOp::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgSIMDFmaOp::next_node);
  143539             : #endif
  143540             : 
  143541           0 :     SgNode * fp = object->p_freepointer;
  143542             : #if ROSE_ALLOC_MEMSET == 1
  143543             : #elif ROSE_ALLOC_MEMSET == 2
  143544             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgSIMDFmaOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  143545             : #elif ROSE_ALLOC_MEMSET == 3
  143546             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgSIMDFmaOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  143547             : #endif
  143548           0 :     object->p_freepointer = fp;
  143549             : 
  143550             : #if ROSE_ALLOC_TRACE == 2
  143551             : //    printf("SgSIMDFmaOp::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgSIMDFmaOp::next_node);
  143552             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  143553             :     Rose::MemPool::snapshot(oss.str());
  143554             :     alloc_trace_cnt++;
  143555             : #endif
  143556             : 
  143557           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  143558             : 
  143559           0 :     ALLOC_MUTEX(SgSIMDFmaOp, unlock);
  143560             : 
  143561             :     return object;
  143562             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  143563             : }
  143564             : 
  143565             : 
  143566             : 
  143567             : /*! \brief Delete operator for SgSIMDFmaOp.
  143568             : 
  143569             :    This delete operator implements deallocation using memory pools to 
  143570             :    provide most efficent use of the heap within construction of large ASTs.
  143571             : 
  143572             : \internal The new and delete operators use the lower level C malloc/free
  143573             :    function calls for performance and to make sure that mixing of malloc/free
  143574             :    and new/delete by the used can be caught more readily.  This may change
  143575             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  143576             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  143577             :    deallocate memory allocated using ROSE_MALLOC.
  143578             : */
  143579           0 : void SgSIMDFmaOp::operator delete(void *Pointer, size_t Size)
  143580             : {
  143581             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  143582             :      * or throwing an exception. */
  143583           0 :     ALLOC_MUTEX(SgSIMDFmaOp, lock);
  143584             : 
  143585             : #if USE_CPP_NEW_DELETE_OPERATORS
  143586             :     ROSE_FREE(Pointer);
  143587             : #else
  143588             : #if ROSE_PEDANTIC_ALLOC
  143589             :     ROSE_ASSERT(Size == sizeof(SgSIMDFmaOp));
  143590             : #else
  143591           0 :     if (Size != sizeof(SgSIMDFmaOp)) {
  143592           0 :       ROSE_FREE(Pointer);
  143593           0 :       ALLOC_MUTEX(SgSIMDFmaOp, unlock);
  143594             :       return;
  143595             :     }
  143596             : #endif
  143597             : 
  143598           0 :     SgSIMDFmaOp * object = (SgSIMDFmaOp*) Pointer;
  143599           0 :     ROSE_ASSERT(object != nullptr);
  143600             : 
  143601             : #if ROSE_ALLOC_TRACE == 2
  143602             : //  printf("SgSIMDFmaOp::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgSIMDFmaOp::next_node);
  143603             :     printf("SgSIMDFmaOp::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgSIMDFmaOp::next_node);
  143604             : #endif
  143605             : 
  143606             : #if ROSE_PEDANTIC_ALLOC
  143607             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  143608             : #endif
  143609             : 
  143610             : #if ROSE_ALLOC_MEMSET == 1
  143611             : #elif ROSE_ALLOC_MEMSET == 2
  143612             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgSIMDFmaOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  143613             : #elif ROSE_ALLOC_MEMSET == 3
  143614             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgSIMDFmaOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  143615             : #endif
  143616             : 
  143617             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  143618             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  143619             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  143620             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  143621             : #else
  143622           0 :     object->p_freepointer = SgSIMDFmaOp::next_node;
  143623           0 :     SgSIMDFmaOp::next_node = object;
  143624             : #endif
  143625             : 
  143626             : #if ROSE_ALLOC_TRACE == 2
  143627             : //  printf("SgSIMDFmaOp::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgSIMDFmaOp::next_node);
  143628             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  143629             :     Rose::MemPool::snapshot(oss.str());
  143630             :     alloc_trace_cnt++;
  143631             : #endif
  143632             : 
  143633             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  143634             : 
  143635           0 :     ALLOC_MUTEX(SgSIMDFmaOp, unlock);
  143636             : }
  143637             : 
  143638             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  143639             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  143640             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  143641             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  143642             : // Also, note comment below from Robb (copied from the Common.code file).
  143643             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  143644             : //
  143645             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  143646             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  143647             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  143648             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  143649             : #if 0
  143650             : void SgSIMDFmaOp::operator delete(void* pointer) { SgSIMDFmaOp::operator delete (pointer, sizeof(SgSIMDFmaOp)); };
  143651             : #endif
  143652             : /* #line 143653 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  143653             : 
  143654             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  143655             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  143656             : // obviously imply C++.
  143657             : 
  143658             : // This implements the support within ROSE for memory pools.  Memory pools
  143659             : // support the most condensed usage of memory within the construction of
  143660             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  143661             : // by a new operator written for each class.
  143662             : 
  143663             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  143664             :     // User wants multi-thread support and POSIX threads are available.
  143665             : #   include <pthread.h>
  143666             :     static pthread_mutex_t SgSIMDLoad_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  143667             : #else
  143668             :      // Cause synchronization to be skipped.
  143669             : #    ifndef ALLOC_MUTEX
  143670             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  143671             : #    endif
  143672             : #    ifdef _REENTRANT
  143673             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  143674             : #       ifdef _MSC_VER
  143675             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  143676             : #       else
  143677             : #           warning "POSIX threads are not available; synchronization being skipped"
  143678             : #       endif
  143679             : #    endif
  143680             : #endif
  143681             : 
  143682             : #ifndef ROSE_ALLOC_TRACE
  143683             : #  define ROSE_ALLOC_TRACE 0
  143684             : #endif
  143685             : 
  143686             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  143687             : #define ROSE_ALLOC_TRACE_CNT
  143688             : #include "memory-pool-snapshot.h"
  143689             : unsigned long alloc_trace_cnt = 0;
  143690             : #endif
  143691             : 
  143692             : #if ROSE_ALLOC_TRACE
  143693             : const unsigned SgSIMDLoad::pool_size = 5;
  143694             : #else
  143695             : const unsigned SgSIMDLoad::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  143696             : #endif
  143697             : 
  143698             : #ifndef ROSE_ALLOC_MEMSET
  143699             : #  define ROSE_ALLOC_MEMSET 0
  143700             : #endif
  143701             : 
  143702             : #ifndef ROSE_PEDANTIC_ALLOC
  143703             : #  define ROSE_PEDANTIC_ALLOC 0
  143704             : #endif
  143705             : 
  143706             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  143707             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  143708             : #endif
  143709             : 
  143710             : #if !defined(SGNODE__ALL_POOLS)
  143711             : #define SGNODE__ALL_POOLS
  143712             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  143713             : #endif
  143714             : 
  143715             : SgSIMDLoad* SgSIMDLoad::next_node = nullptr;
  143716             : std::vector<unsigned char*> SgSIMDLoad::pools;
  143717             : 
  143718             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  143719             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  143720             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  143721             : // around this macro definition rather than each use).
  143722             : #ifndef ALLOC_MUTEX
  143723             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  143724             :         do {                                                                     \
  143725             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  143726             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  143727             :                 abort();                                                         \
  143728             :             }                                                                    \
  143729             :         } while (0);
  143730             : #endif
  143731             : 
  143732             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  143733             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  143734             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  143735             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  143736             : 
  143737             : /*! \brief New operator for SgSIMDLoad.
  143738             : 
  143739             :    This new operator implements memory pools to provide most efficent 
  143740             :    use of the heap within construction of large ASTs.
  143741             : 
  143742             : \internal The new and delete operators use the lower level C malloc/free
  143743             :    function calls for performance and to make sure that mixing of malloc/free
  143744             :    and new/delete by the used can be caught more readily.  This may change
  143745             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  143746             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  143747             :    deallocate memory allocated using ROSE_MALLOC.
  143748             : */
  143749           0 : void *SgSIMDLoad::operator new ( size_t Size )
  143750             : {
  143751             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  143752             :      * returning or throwing an exception. */
  143753           0 :     ALLOC_MUTEX(SgSIMDLoad, lock);
  143754             : 
  143755             : #if ROSE_ALLOC_TRACE == 2
  143756             : //    printf("SgSIMDLoad::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgSIMDLoad::next_node);
  143757             : #endif
  143758             : 
  143759             : #if USE_CPP_NEW_DELETE_OPERATORS
  143760             :     void *mem = ROSE_MALLOC(Size);
  143761             :     ALLOC_MUTEX(SgSIMDLoad, unlock);
  143762             :     return mem;
  143763             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  143764             : #if ROSE_PEDANTIC_ALLOC
  143765             :     ROSE_ASSERT(Size == sizeof(SgSIMDLoad));
  143766             : #else
  143767           0 :     if (Size != sizeof(SgSIMDLoad)) {
  143768           0 :       void * object = ROSE_MALLOC(Size);
  143769           0 :       ALLOC_MUTEX(SgSIMDLoad, unlock);
  143770             :       return object;
  143771             :     }
  143772             : #endif
  143773             : 
  143774           0 :     if (SgSIMDLoad::next_node == nullptr) {
  143775           0 :         SgSIMDLoad * alloc = (SgSIMDLoad*) ROSE_MALLOC ( SgSIMDLoad::pool_size * sizeof(SgSIMDLoad) );
  143776           0 :         ROSE_ASSERT(alloc != nullptr);
  143777             : 
  143778             : #if ROSE_ALLOC_TRACE == 2
  143779             : //        printf("SgSIMDLoad::alloc\n  block[%zi] = [ %p , %p [\n", SgSIMDLoad::pools.size(), alloc, alloc + SgSIMDLoad::pool_size);
  143780             : #endif
  143781             : 
  143782             : #if ROSE_ALLOC_MEMSET == 1
  143783             : #elif ROSE_ALLOC_MEMSET == 2
  143784             :         memset(alloc, 0x00, SgSIMDLoad::pool_size * sizeof(SgSIMDLoad));
  143785             : #elif ROSE_ALLOC_MEMSET == 3
  143786             :         memset(alloc, 0xAA, SgSIMDLoad::pool_size * sizeof(SgSIMDLoad));
  143787             : #endif
  143788           0 :         for (unsigned i=0; i < SgSIMDLoad::pool_size-1; i++) {
  143789           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
  143790             :         }
  143791           0 :         alloc[SgSIMDLoad::pool_size-1].p_freepointer = nullptr;
  143792             : 
  143793           0 :         SgSIMDLoad::pools.push_back ( (unsigned char *) alloc );
  143794           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgSIMDLoad::pool_size * sizeof(SgSIMDLoad), V_SgSIMDLoad ) );
  143795           0 :         SgSIMDLoad::next_node = alloc;
  143796             :     }
  143797           0 :     ROSE_ASSERT(SgSIMDLoad::next_node != nullptr);
  143798             : 
  143799           0 :     SgSIMDLoad * object = SgSIMDLoad::next_node;
  143800           0 :     SgSIMDLoad::next_node = (SgSIMDLoad*)(object->p_freepointer);
  143801             : 
  143802             : #if ROSE_ALLOC_TRACE == 2
  143803             :     printf("SgSIMDLoad::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgSIMDLoad::next_node);
  143804             : #endif
  143805             : 
  143806           0 :     SgNode * fp = object->p_freepointer;
  143807             : #if ROSE_ALLOC_MEMSET == 1
  143808             : #elif ROSE_ALLOC_MEMSET == 2
  143809             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgSIMDLoad) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  143810             : #elif ROSE_ALLOC_MEMSET == 3
  143811             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgSIMDLoad) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  143812             : #endif
  143813           0 :     object->p_freepointer = fp;
  143814             : 
  143815             : #if ROSE_ALLOC_TRACE == 2
  143816             : //    printf("SgSIMDLoad::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgSIMDLoad::next_node);
  143817             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  143818             :     Rose::MemPool::snapshot(oss.str());
  143819             :     alloc_trace_cnt++;
  143820             : #endif
  143821             : 
  143822           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  143823             : 
  143824           0 :     ALLOC_MUTEX(SgSIMDLoad, unlock);
  143825             : 
  143826             :     return object;
  143827             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  143828             : }
  143829             : 
  143830             : 
  143831             : 
  143832             : /*! \brief Delete operator for SgSIMDLoad.
  143833             : 
  143834             :    This delete operator implements deallocation using memory pools to 
  143835             :    provide most efficent use of the heap within construction of large ASTs.
  143836             : 
  143837             : \internal The new and delete operators use the lower level C malloc/free
  143838             :    function calls for performance and to make sure that mixing of malloc/free
  143839             :    and new/delete by the used can be caught more readily.  This may change
  143840             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  143841             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  143842             :    deallocate memory allocated using ROSE_MALLOC.
  143843             : */
  143844           0 : void SgSIMDLoad::operator delete(void *Pointer, size_t Size)
  143845             : {
  143846             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  143847             :      * or throwing an exception. */
  143848           0 :     ALLOC_MUTEX(SgSIMDLoad, lock);
  143849             : 
  143850             : #if USE_CPP_NEW_DELETE_OPERATORS
  143851             :     ROSE_FREE(Pointer);
  143852             : #else
  143853             : #if ROSE_PEDANTIC_ALLOC
  143854             :     ROSE_ASSERT(Size == sizeof(SgSIMDLoad));
  143855             : #else
  143856           0 :     if (Size != sizeof(SgSIMDLoad)) {
  143857           0 :       ROSE_FREE(Pointer);
  143858           0 :       ALLOC_MUTEX(SgSIMDLoad, unlock);
  143859             :       return;
  143860             :     }
  143861             : #endif
  143862             : 
  143863           0 :     SgSIMDLoad * object = (SgSIMDLoad*) Pointer;
  143864           0 :     ROSE_ASSERT(object != nullptr);
  143865             : 
  143866             : #if ROSE_ALLOC_TRACE == 2
  143867             : //  printf("SgSIMDLoad::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgSIMDLoad::next_node);
  143868             :     printf("SgSIMDLoad::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgSIMDLoad::next_node);
  143869             : #endif
  143870             : 
  143871             : #if ROSE_PEDANTIC_ALLOC
  143872             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  143873             : #endif
  143874             : 
  143875             : #if ROSE_ALLOC_MEMSET == 1
  143876             : #elif ROSE_ALLOC_MEMSET == 2
  143877             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgSIMDLoad) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  143878             : #elif ROSE_ALLOC_MEMSET == 3
  143879             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgSIMDLoad) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  143880             : #endif
  143881             : 
  143882             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  143883             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  143884             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  143885             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  143886             : #else
  143887           0 :     object->p_freepointer = SgSIMDLoad::next_node;
  143888           0 :     SgSIMDLoad::next_node = object;
  143889             : #endif
  143890             : 
  143891             : #if ROSE_ALLOC_TRACE == 2
  143892             : //  printf("SgSIMDLoad::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgSIMDLoad::next_node);
  143893             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  143894             :     Rose::MemPool::snapshot(oss.str());
  143895             :     alloc_trace_cnt++;
  143896             : #endif
  143897             : 
  143898             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  143899             : 
  143900           0 :     ALLOC_MUTEX(SgSIMDLoad, unlock);
  143901             : }
  143902             : 
  143903             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  143904             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  143905             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  143906             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  143907             : // Also, note comment below from Robb (copied from the Common.code file).
  143908             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  143909             : //
  143910             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  143911             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  143912             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  143913             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  143914             : #if 0
  143915             : void SgSIMDLoad::operator delete(void* pointer) { SgSIMDLoad::operator delete (pointer, sizeof(SgSIMDLoad)); };
  143916             : #endif
  143917             : /* #line 143918 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  143918             : 
  143919             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  143920             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  143921             : // obviously imply C++.
  143922             : 
  143923             : // This implements the support within ROSE for memory pools.  Memory pools
  143924             : // support the most condensed usage of memory within the construction of
  143925             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  143926             : // by a new operator written for each class.
  143927             : 
  143928             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  143929             :     // User wants multi-thread support and POSIX threads are available.
  143930             : #   include <pthread.h>
  143931             :     static pthread_mutex_t SgSIMDBroadcast_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  143932             : #else
  143933             :      // Cause synchronization to be skipped.
  143934             : #    ifndef ALLOC_MUTEX
  143935             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  143936             : #    endif
  143937             : #    ifdef _REENTRANT
  143938             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  143939             : #       ifdef _MSC_VER
  143940             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  143941             : #       else
  143942             : #           warning "POSIX threads are not available; synchronization being skipped"
  143943             : #       endif
  143944             : #    endif
  143945             : #endif
  143946             : 
  143947             : #ifndef ROSE_ALLOC_TRACE
  143948             : #  define ROSE_ALLOC_TRACE 0
  143949             : #endif
  143950             : 
  143951             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  143952             : #define ROSE_ALLOC_TRACE_CNT
  143953             : #include "memory-pool-snapshot.h"
  143954             : unsigned long alloc_trace_cnt = 0;
  143955             : #endif
  143956             : 
  143957             : #if ROSE_ALLOC_TRACE
  143958             : const unsigned SgSIMDBroadcast::pool_size = 5;
  143959             : #else
  143960             : const unsigned SgSIMDBroadcast::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  143961             : #endif
  143962             : 
  143963             : #ifndef ROSE_ALLOC_MEMSET
  143964             : #  define ROSE_ALLOC_MEMSET 0
  143965             : #endif
  143966             : 
  143967             : #ifndef ROSE_PEDANTIC_ALLOC
  143968             : #  define ROSE_PEDANTIC_ALLOC 0
  143969             : #endif
  143970             : 
  143971             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  143972             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  143973             : #endif
  143974             : 
  143975             : #if !defined(SGNODE__ALL_POOLS)
  143976             : #define SGNODE__ALL_POOLS
  143977             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  143978             : #endif
  143979             : 
  143980             : SgSIMDBroadcast* SgSIMDBroadcast::next_node = nullptr;
  143981             : std::vector<unsigned char*> SgSIMDBroadcast::pools;
  143982             : 
  143983             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  143984             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  143985             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  143986             : // around this macro definition rather than each use).
  143987             : #ifndef ALLOC_MUTEX
  143988             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  143989             :         do {                                                                     \
  143990             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  143991             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  143992             :                 abort();                                                         \
  143993             :             }                                                                    \
  143994             :         } while (0);
  143995             : #endif
  143996             : 
  143997             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  143998             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  143999             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  144000             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  144001             : 
  144002             : /*! \brief New operator for SgSIMDBroadcast.
  144003             : 
  144004             :    This new operator implements memory pools to provide most efficent 
  144005             :    use of the heap within construction of large ASTs.
  144006             : 
  144007             : \internal The new and delete operators use the lower level C malloc/free
  144008             :    function calls for performance and to make sure that mixing of malloc/free
  144009             :    and new/delete by the used can be caught more readily.  This may change
  144010             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  144011             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  144012             :    deallocate memory allocated using ROSE_MALLOC.
  144013             : */
  144014           0 : void *SgSIMDBroadcast::operator new ( size_t Size )
  144015             : {
  144016             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  144017             :      * returning or throwing an exception. */
  144018           0 :     ALLOC_MUTEX(SgSIMDBroadcast, lock);
  144019             : 
  144020             : #if ROSE_ALLOC_TRACE == 2
  144021             : //    printf("SgSIMDBroadcast::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgSIMDBroadcast::next_node);
  144022             : #endif
  144023             : 
  144024             : #if USE_CPP_NEW_DELETE_OPERATORS
  144025             :     void *mem = ROSE_MALLOC(Size);
  144026             :     ALLOC_MUTEX(SgSIMDBroadcast, unlock);
  144027             :     return mem;
  144028             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  144029             : #if ROSE_PEDANTIC_ALLOC
  144030             :     ROSE_ASSERT(Size == sizeof(SgSIMDBroadcast));
  144031             : #else
  144032           0 :     if (Size != sizeof(SgSIMDBroadcast)) {
  144033           0 :       void * object = ROSE_MALLOC(Size);
  144034           0 :       ALLOC_MUTEX(SgSIMDBroadcast, unlock);
  144035             :       return object;
  144036             :     }
  144037             : #endif
  144038             : 
  144039           0 :     if (SgSIMDBroadcast::next_node == nullptr) {
  144040           0 :         SgSIMDBroadcast * alloc = (SgSIMDBroadcast*) ROSE_MALLOC ( SgSIMDBroadcast::pool_size * sizeof(SgSIMDBroadcast) );
  144041           0 :         ROSE_ASSERT(alloc != nullptr);
  144042             : 
  144043             : #if ROSE_ALLOC_TRACE == 2
  144044             : //        printf("SgSIMDBroadcast::alloc\n  block[%zi] = [ %p , %p [\n", SgSIMDBroadcast::pools.size(), alloc, alloc + SgSIMDBroadcast::pool_size);
  144045             : #endif
  144046             : 
  144047             : #if ROSE_ALLOC_MEMSET == 1
  144048             : #elif ROSE_ALLOC_MEMSET == 2
  144049             :         memset(alloc, 0x00, SgSIMDBroadcast::pool_size * sizeof(SgSIMDBroadcast));
  144050             : #elif ROSE_ALLOC_MEMSET == 3
  144051             :         memset(alloc, 0xAA, SgSIMDBroadcast::pool_size * sizeof(SgSIMDBroadcast));
  144052             : #endif
  144053           0 :         for (unsigned i=0; i < SgSIMDBroadcast::pool_size-1; i++) {
  144054           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
  144055             :         }
  144056           0 :         alloc[SgSIMDBroadcast::pool_size-1].p_freepointer = nullptr;
  144057             : 
  144058           0 :         SgSIMDBroadcast::pools.push_back ( (unsigned char *) alloc );
  144059           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgSIMDBroadcast::pool_size * sizeof(SgSIMDBroadcast), V_SgSIMDBroadcast ) );
  144060           0 :         SgSIMDBroadcast::next_node = alloc;
  144061             :     }
  144062           0 :     ROSE_ASSERT(SgSIMDBroadcast::next_node != nullptr);
  144063             : 
  144064           0 :     SgSIMDBroadcast * object = SgSIMDBroadcast::next_node;
  144065           0 :     SgSIMDBroadcast::next_node = (SgSIMDBroadcast*)(object->p_freepointer);
  144066             : 
  144067             : #if ROSE_ALLOC_TRACE == 2
  144068             :     printf("SgSIMDBroadcast::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgSIMDBroadcast::next_node);
  144069             : #endif
  144070             : 
  144071           0 :     SgNode * fp = object->p_freepointer;
  144072             : #if ROSE_ALLOC_MEMSET == 1
  144073             : #elif ROSE_ALLOC_MEMSET == 2
  144074             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgSIMDBroadcast) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  144075             : #elif ROSE_ALLOC_MEMSET == 3
  144076             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgSIMDBroadcast) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  144077             : #endif
  144078           0 :     object->p_freepointer = fp;
  144079             : 
  144080             : #if ROSE_ALLOC_TRACE == 2
  144081             : //    printf("SgSIMDBroadcast::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgSIMDBroadcast::next_node);
  144082             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  144083             :     Rose::MemPool::snapshot(oss.str());
  144084             :     alloc_trace_cnt++;
  144085             : #endif
  144086             : 
  144087           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  144088             : 
  144089           0 :     ALLOC_MUTEX(SgSIMDBroadcast, unlock);
  144090             : 
  144091             :     return object;
  144092             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  144093             : }
  144094             : 
  144095             : 
  144096             : 
  144097             : /*! \brief Delete operator for SgSIMDBroadcast.
  144098             : 
  144099             :    This delete operator implements deallocation using memory pools to 
  144100             :    provide most efficent use of the heap within construction of large ASTs.
  144101             : 
  144102             : \internal The new and delete operators use the lower level C malloc/free
  144103             :    function calls for performance and to make sure that mixing of malloc/free
  144104             :    and new/delete by the used can be caught more readily.  This may change
  144105             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  144106             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  144107             :    deallocate memory allocated using ROSE_MALLOC.
  144108             : */
  144109           0 : void SgSIMDBroadcast::operator delete(void *Pointer, size_t Size)
  144110             : {
  144111             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  144112             :      * or throwing an exception. */
  144113           0 :     ALLOC_MUTEX(SgSIMDBroadcast, lock);
  144114             : 
  144115             : #if USE_CPP_NEW_DELETE_OPERATORS
  144116             :     ROSE_FREE(Pointer);
  144117             : #else
  144118             : #if ROSE_PEDANTIC_ALLOC
  144119             :     ROSE_ASSERT(Size == sizeof(SgSIMDBroadcast));
  144120             : #else
  144121           0 :     if (Size != sizeof(SgSIMDBroadcast)) {
  144122           0 :       ROSE_FREE(Pointer);
  144123           0 :       ALLOC_MUTEX(SgSIMDBroadcast, unlock);
  144124             :       return;
  144125             :     }
  144126             : #endif
  144127             : 
  144128           0 :     SgSIMDBroadcast * object = (SgSIMDBroadcast*) Pointer;
  144129           0 :     ROSE_ASSERT(object != nullptr);
  144130             : 
  144131             : #if ROSE_ALLOC_TRACE == 2
  144132             : //  printf("SgSIMDBroadcast::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgSIMDBroadcast::next_node);
  144133             :     printf("SgSIMDBroadcast::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgSIMDBroadcast::next_node);
  144134             : #endif
  144135             : 
  144136             : #if ROSE_PEDANTIC_ALLOC
  144137             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  144138             : #endif
  144139             : 
  144140             : #if ROSE_ALLOC_MEMSET == 1
  144141             : #elif ROSE_ALLOC_MEMSET == 2
  144142             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgSIMDBroadcast) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  144143             : #elif ROSE_ALLOC_MEMSET == 3
  144144             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgSIMDBroadcast) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  144145             : #endif
  144146             : 
  144147             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  144148             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  144149             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  144150             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  144151             : #else
  144152           0 :     object->p_freepointer = SgSIMDBroadcast::next_node;
  144153           0 :     SgSIMDBroadcast::next_node = object;
  144154             : #endif
  144155             : 
  144156             : #if ROSE_ALLOC_TRACE == 2
  144157             : //  printf("SgSIMDBroadcast::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgSIMDBroadcast::next_node);
  144158             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  144159             :     Rose::MemPool::snapshot(oss.str());
  144160             :     alloc_trace_cnt++;
  144161             : #endif
  144162             : 
  144163             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  144164             : 
  144165           0 :     ALLOC_MUTEX(SgSIMDBroadcast, unlock);
  144166             : }
  144167             : 
  144168             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  144169             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  144170             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  144171             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  144172             : // Also, note comment below from Robb (copied from the Common.code file).
  144173             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  144174             : //
  144175             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  144176             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  144177             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  144178             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  144179             : #if 0
  144180             : void SgSIMDBroadcast::operator delete(void* pointer) { SgSIMDBroadcast::operator delete (pointer, sizeof(SgSIMDBroadcast)); };
  144181             : #endif
  144182             : /* #line 144183 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  144183             : 
  144184             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  144185             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  144186             : // obviously imply C++.
  144187             : 
  144188             : // This implements the support within ROSE for memory pools.  Memory pools
  144189             : // support the most condensed usage of memory within the construction of
  144190             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  144191             : // by a new operator written for each class.
  144192             : 
  144193             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  144194             :     // User wants multi-thread support and POSIX threads are available.
  144195             : #   include <pthread.h>
  144196             :     static pthread_mutex_t SgSIMDStore_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  144197             : #else
  144198             :      // Cause synchronization to be skipped.
  144199             : #    ifndef ALLOC_MUTEX
  144200             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  144201             : #    endif
  144202             : #    ifdef _REENTRANT
  144203             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  144204             : #       ifdef _MSC_VER
  144205             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  144206             : #       else
  144207             : #           warning "POSIX threads are not available; synchronization being skipped"
  144208             : #       endif
  144209             : #    endif
  144210             : #endif
  144211             : 
  144212             : #ifndef ROSE_ALLOC_TRACE
  144213             : #  define ROSE_ALLOC_TRACE 0
  144214             : #endif
  144215             : 
  144216             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  144217             : #define ROSE_ALLOC_TRACE_CNT
  144218             : #include "memory-pool-snapshot.h"
  144219             : unsigned long alloc_trace_cnt = 0;
  144220             : #endif
  144221             : 
  144222             : #if ROSE_ALLOC_TRACE
  144223             : const unsigned SgSIMDStore::pool_size = 5;
  144224             : #else
  144225             : const unsigned SgSIMDStore::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  144226             : #endif
  144227             : 
  144228             : #ifndef ROSE_ALLOC_MEMSET
  144229             : #  define ROSE_ALLOC_MEMSET 0
  144230             : #endif
  144231             : 
  144232             : #ifndef ROSE_PEDANTIC_ALLOC
  144233             : #  define ROSE_PEDANTIC_ALLOC 0
  144234             : #endif
  144235             : 
  144236             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  144237             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  144238             : #endif
  144239             : 
  144240             : #if !defined(SGNODE__ALL_POOLS)
  144241             : #define SGNODE__ALL_POOLS
  144242             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  144243             : #endif
  144244             : 
  144245             : SgSIMDStore* SgSIMDStore::next_node = nullptr;
  144246             : std::vector<unsigned char*> SgSIMDStore::pools;
  144247             : 
  144248             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  144249             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  144250             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  144251             : // around this macro definition rather than each use).
  144252             : #ifndef ALLOC_MUTEX
  144253             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  144254             :         do {                                                                     \
  144255             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  144256             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  144257             :                 abort();                                                         \
  144258             :             }                                                                    \
  144259             :         } while (0);
  144260             : #endif
  144261             : 
  144262             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  144263             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  144264             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  144265             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  144266             : 
  144267             : /*! \brief New operator for SgSIMDStore.
  144268             : 
  144269             :    This new operator implements memory pools to provide most efficent 
  144270             :    use of the heap within construction of large ASTs.
  144271             : 
  144272             : \internal The new and delete operators use the lower level C malloc/free
  144273             :    function calls for performance and to make sure that mixing of malloc/free
  144274             :    and new/delete by the used can be caught more readily.  This may change
  144275             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  144276             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  144277             :    deallocate memory allocated using ROSE_MALLOC.
  144278             : */
  144279           0 : void *SgSIMDStore::operator new ( size_t Size )
  144280             : {
  144281             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  144282             :      * returning or throwing an exception. */
  144283           0 :     ALLOC_MUTEX(SgSIMDStore, lock);
  144284             : 
  144285             : #if ROSE_ALLOC_TRACE == 2
  144286             : //    printf("SgSIMDStore::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgSIMDStore::next_node);
  144287             : #endif
  144288             : 
  144289             : #if USE_CPP_NEW_DELETE_OPERATORS
  144290             :     void *mem = ROSE_MALLOC(Size);
  144291             :     ALLOC_MUTEX(SgSIMDStore, unlock);
  144292             :     return mem;
  144293             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  144294             : #if ROSE_PEDANTIC_ALLOC
  144295             :     ROSE_ASSERT(Size == sizeof(SgSIMDStore));
  144296             : #else
  144297           0 :     if (Size != sizeof(SgSIMDStore)) {
  144298           0 :       void * object = ROSE_MALLOC(Size);
  144299           0 :       ALLOC_MUTEX(SgSIMDStore, unlock);
  144300             :       return object;
  144301             :     }
  144302             : #endif
  144303             : 
  144304           0 :     if (SgSIMDStore::next_node == nullptr) {
  144305           0 :         SgSIMDStore * alloc = (SgSIMDStore*) ROSE_MALLOC ( SgSIMDStore::pool_size * sizeof(SgSIMDStore) );
  144306           0 :         ROSE_ASSERT(alloc != nullptr);
  144307             : 
  144308             : #if ROSE_ALLOC_TRACE == 2
  144309             : //        printf("SgSIMDStore::alloc\n  block[%zi] = [ %p , %p [\n", SgSIMDStore::pools.size(), alloc, alloc + SgSIMDStore::pool_size);
  144310             : #endif
  144311             : 
  144312             : #if ROSE_ALLOC_MEMSET == 1
  144313             : #elif ROSE_ALLOC_MEMSET == 2
  144314             :         memset(alloc, 0x00, SgSIMDStore::pool_size * sizeof(SgSIMDStore));
  144315             : #elif ROSE_ALLOC_MEMSET == 3
  144316             :         memset(alloc, 0xAA, SgSIMDStore::pool_size * sizeof(SgSIMDStore));
  144317             : #endif
  144318           0 :         for (unsigned i=0; i < SgSIMDStore::pool_size-1; i++) {
  144319           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
  144320             :         }
  144321           0 :         alloc[SgSIMDStore::pool_size-1].p_freepointer = nullptr;
  144322             : 
  144323           0 :         SgSIMDStore::pools.push_back ( (unsigned char *) alloc );
  144324           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgSIMDStore::pool_size * sizeof(SgSIMDStore), V_SgSIMDStore ) );
  144325           0 :         SgSIMDStore::next_node = alloc;
  144326             :     }
  144327           0 :     ROSE_ASSERT(SgSIMDStore::next_node != nullptr);
  144328             : 
  144329           0 :     SgSIMDStore * object = SgSIMDStore::next_node;
  144330           0 :     SgSIMDStore::next_node = (SgSIMDStore*)(object->p_freepointer);
  144331             : 
  144332             : #if ROSE_ALLOC_TRACE == 2
  144333             :     printf("SgSIMDStore::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgSIMDStore::next_node);
  144334             : #endif
  144335             : 
  144336           0 :     SgNode * fp = object->p_freepointer;
  144337             : #if ROSE_ALLOC_MEMSET == 1
  144338             : #elif ROSE_ALLOC_MEMSET == 2
  144339             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgSIMDStore) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  144340             : #elif ROSE_ALLOC_MEMSET == 3
  144341             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgSIMDStore) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  144342             : #endif
  144343           0 :     object->p_freepointer = fp;
  144344             : 
  144345             : #if ROSE_ALLOC_TRACE == 2
  144346             : //    printf("SgSIMDStore::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgSIMDStore::next_node);
  144347             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  144348             :     Rose::MemPool::snapshot(oss.str());
  144349             :     alloc_trace_cnt++;
  144350             : #endif
  144351             : 
  144352           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  144353             : 
  144354           0 :     ALLOC_MUTEX(SgSIMDStore, unlock);
  144355             : 
  144356             :     return object;
  144357             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  144358             : }
  144359             : 
  144360             : 
  144361             : 
  144362             : /*! \brief Delete operator for SgSIMDStore.
  144363             : 
  144364             :    This delete operator implements deallocation using memory pools to 
  144365             :    provide most efficent use of the heap within construction of large ASTs.
  144366             : 
  144367             : \internal The new and delete operators use the lower level C malloc/free
  144368             :    function calls for performance and to make sure that mixing of malloc/free
  144369             :    and new/delete by the used can be caught more readily.  This may change
  144370             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  144371             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  144372             :    deallocate memory allocated using ROSE_MALLOC.
  144373             : */
  144374           0 : void SgSIMDStore::operator delete(void *Pointer, size_t Size)
  144375             : {
  144376             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  144377             :      * or throwing an exception. */
  144378           0 :     ALLOC_MUTEX(SgSIMDStore, lock);
  144379             : 
  144380             : #if USE_CPP_NEW_DELETE_OPERATORS
  144381             :     ROSE_FREE(Pointer);
  144382             : #else
  144383             : #if ROSE_PEDANTIC_ALLOC
  144384             :     ROSE_ASSERT(Size == sizeof(SgSIMDStore));
  144385             : #else
  144386           0 :     if (Size != sizeof(SgSIMDStore)) {
  144387           0 :       ROSE_FREE(Pointer);
  144388           0 :       ALLOC_MUTEX(SgSIMDStore, unlock);
  144389             :       return;
  144390             :     }
  144391             : #endif
  144392             : 
  144393           0 :     SgSIMDStore * object = (SgSIMDStore*) Pointer;
  144394           0 :     ROSE_ASSERT(object != nullptr);
  144395             : 
  144396             : #if ROSE_ALLOC_TRACE == 2
  144397             : //  printf("SgSIMDStore::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgSIMDStore::next_node);
  144398             :     printf("SgSIMDStore::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgSIMDStore::next_node);
  144399             : #endif
  144400             : 
  144401             : #if ROSE_PEDANTIC_ALLOC
  144402             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  144403             : #endif
  144404             : 
  144405             : #if ROSE_ALLOC_MEMSET == 1
  144406             : #elif ROSE_ALLOC_MEMSET == 2
  144407             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgSIMDStore) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  144408             : #elif ROSE_ALLOC_MEMSET == 3
  144409             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgSIMDStore) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  144410             : #endif
  144411             : 
  144412             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  144413             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  144414             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  144415             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  144416             : #else
  144417           0 :     object->p_freepointer = SgSIMDStore::next_node;
  144418           0 :     SgSIMDStore::next_node = object;
  144419             : #endif
  144420             : 
  144421             : #if ROSE_ALLOC_TRACE == 2
  144422             : //  printf("SgSIMDStore::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgSIMDStore::next_node);
  144423             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  144424             :     Rose::MemPool::snapshot(oss.str());
  144425             :     alloc_trace_cnt++;
  144426             : #endif
  144427             : 
  144428             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  144429             : 
  144430           0 :     ALLOC_MUTEX(SgSIMDStore, unlock);
  144431             : }
  144432             : 
  144433             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  144434             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  144435             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  144436             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  144437             : // Also, note comment below from Robb (copied from the Common.code file).
  144438             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  144439             : //
  144440             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  144441             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  144442             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  144443             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  144444             : #if 0
  144445             : void SgSIMDStore::operator delete(void* pointer) { SgSIMDStore::operator delete (pointer, sizeof(SgSIMDStore)); };
  144446             : #endif
  144447             : /* #line 144448 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  144448             : 
  144449             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  144450             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  144451             : // obviously imply C++.
  144452             : 
  144453             : // This implements the support within ROSE for memory pools.  Memory pools
  144454             : // support the most condensed usage of memory within the construction of
  144455             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  144456             : // by a new operator written for each class.
  144457             : 
  144458             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  144459             :     // User wants multi-thread support and POSIX threads are available.
  144460             : #   include <pthread.h>
  144461             :     static pthread_mutex_t SgSIMDPartialStore_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  144462             : #else
  144463             :      // Cause synchronization to be skipped.
  144464             : #    ifndef ALLOC_MUTEX
  144465             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  144466             : #    endif
  144467             : #    ifdef _REENTRANT
  144468             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  144469             : #       ifdef _MSC_VER
  144470             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  144471             : #       else
  144472             : #           warning "POSIX threads are not available; synchronization being skipped"
  144473             : #       endif
  144474             : #    endif
  144475             : #endif
  144476             : 
  144477             : #ifndef ROSE_ALLOC_TRACE
  144478             : #  define ROSE_ALLOC_TRACE 0
  144479             : #endif
  144480             : 
  144481             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  144482             : #define ROSE_ALLOC_TRACE_CNT
  144483             : #include "memory-pool-snapshot.h"
  144484             : unsigned long alloc_trace_cnt = 0;
  144485             : #endif
  144486             : 
  144487             : #if ROSE_ALLOC_TRACE
  144488             : const unsigned SgSIMDPartialStore::pool_size = 5;
  144489             : #else
  144490             : const unsigned SgSIMDPartialStore::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  144491             : #endif
  144492             : 
  144493             : #ifndef ROSE_ALLOC_MEMSET
  144494             : #  define ROSE_ALLOC_MEMSET 0
  144495             : #endif
  144496             : 
  144497             : #ifndef ROSE_PEDANTIC_ALLOC
  144498             : #  define ROSE_PEDANTIC_ALLOC 0
  144499             : #endif
  144500             : 
  144501             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  144502             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  144503             : #endif
  144504             : 
  144505             : #if !defined(SGNODE__ALL_POOLS)
  144506             : #define SGNODE__ALL_POOLS
  144507             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  144508             : #endif
  144509             : 
  144510             : SgSIMDPartialStore* SgSIMDPartialStore::next_node = nullptr;
  144511             : std::vector<unsigned char*> SgSIMDPartialStore::pools;
  144512             : 
  144513             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  144514             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  144515             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  144516             : // around this macro definition rather than each use).
  144517             : #ifndef ALLOC_MUTEX
  144518             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  144519             :         do {                                                                     \
  144520             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  144521             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  144522             :                 abort();                                                         \
  144523             :             }                                                                    \
  144524             :         } while (0);
  144525             : #endif
  144526             : 
  144527             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  144528             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  144529             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  144530             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  144531             : 
  144532             : /*! \brief New operator for SgSIMDPartialStore.
  144533             : 
  144534             :    This new operator implements memory pools to provide most efficent 
  144535             :    use of the heap within construction of large ASTs.
  144536             : 
  144537             : \internal The new and delete operators use the lower level C malloc/free
  144538             :    function calls for performance and to make sure that mixing of malloc/free
  144539             :    and new/delete by the used can be caught more readily.  This may change
  144540             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  144541             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  144542             :    deallocate memory allocated using ROSE_MALLOC.
  144543             : */
  144544           0 : void *SgSIMDPartialStore::operator new ( size_t Size )
  144545             : {
  144546             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  144547             :      * returning or throwing an exception. */
  144548           0 :     ALLOC_MUTEX(SgSIMDPartialStore, lock);
  144549             : 
  144550             : #if ROSE_ALLOC_TRACE == 2
  144551             : //    printf("SgSIMDPartialStore::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgSIMDPartialStore::next_node);
  144552             : #endif
  144553             : 
  144554             : #if USE_CPP_NEW_DELETE_OPERATORS
  144555             :     void *mem = ROSE_MALLOC(Size);
  144556             :     ALLOC_MUTEX(SgSIMDPartialStore, unlock);
  144557             :     return mem;
  144558             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  144559             : #if ROSE_PEDANTIC_ALLOC
  144560             :     ROSE_ASSERT(Size == sizeof(SgSIMDPartialStore));
  144561             : #else
  144562           0 :     if (Size != sizeof(SgSIMDPartialStore)) {
  144563           0 :       void * object = ROSE_MALLOC(Size);
  144564           0 :       ALLOC_MUTEX(SgSIMDPartialStore, unlock);
  144565             :       return object;
  144566             :     }
  144567             : #endif
  144568             : 
  144569           0 :     if (SgSIMDPartialStore::next_node == nullptr) {
  144570           0 :         SgSIMDPartialStore * alloc = (SgSIMDPartialStore*) ROSE_MALLOC ( SgSIMDPartialStore::pool_size * sizeof(SgSIMDPartialStore) );
  144571           0 :         ROSE_ASSERT(alloc != nullptr);
  144572             : 
  144573             : #if ROSE_ALLOC_TRACE == 2
  144574             : //        printf("SgSIMDPartialStore::alloc\n  block[%zi] = [ %p , %p [\n", SgSIMDPartialStore::pools.size(), alloc, alloc + SgSIMDPartialStore::pool_size);
  144575             : #endif
  144576             : 
  144577             : #if ROSE_ALLOC_MEMSET == 1
  144578             : #elif ROSE_ALLOC_MEMSET == 2
  144579             :         memset(alloc, 0x00, SgSIMDPartialStore::pool_size * sizeof(SgSIMDPartialStore));
  144580             : #elif ROSE_ALLOC_MEMSET == 3
  144581             :         memset(alloc, 0xAA, SgSIMDPartialStore::pool_size * sizeof(SgSIMDPartialStore));
  144582             : #endif
  144583           0 :         for (unsigned i=0; i < SgSIMDPartialStore::pool_size-1; i++) {
  144584           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
  144585             :         }
  144586           0 :         alloc[SgSIMDPartialStore::pool_size-1].p_freepointer = nullptr;
  144587             : 
  144588           0 :         SgSIMDPartialStore::pools.push_back ( (unsigned char *) alloc );
  144589           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgSIMDPartialStore::pool_size * sizeof(SgSIMDPartialStore), V_SgSIMDPartialStore ) );
  144590           0 :         SgSIMDPartialStore::next_node = alloc;
  144591             :     }
  144592           0 :     ROSE_ASSERT(SgSIMDPartialStore::next_node != nullptr);
  144593             : 
  144594           0 :     SgSIMDPartialStore * object = SgSIMDPartialStore::next_node;
  144595           0 :     SgSIMDPartialStore::next_node = (SgSIMDPartialStore*)(object->p_freepointer);
  144596             : 
  144597             : #if ROSE_ALLOC_TRACE == 2
  144598             :     printf("SgSIMDPartialStore::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgSIMDPartialStore::next_node);
  144599             : #endif
  144600             : 
  144601           0 :     SgNode * fp = object->p_freepointer;
  144602             : #if ROSE_ALLOC_MEMSET == 1
  144603             : #elif ROSE_ALLOC_MEMSET == 2
  144604             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgSIMDPartialStore) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  144605             : #elif ROSE_ALLOC_MEMSET == 3
  144606             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgSIMDPartialStore) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  144607             : #endif
  144608           0 :     object->p_freepointer = fp;
  144609             : 
  144610             : #if ROSE_ALLOC_TRACE == 2
  144611             : //    printf("SgSIMDPartialStore::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgSIMDPartialStore::next_node);
  144612             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  144613             :     Rose::MemPool::snapshot(oss.str());
  144614             :     alloc_trace_cnt++;
  144615             : #endif
  144616             : 
  144617           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  144618             : 
  144619           0 :     ALLOC_MUTEX(SgSIMDPartialStore, unlock);
  144620             : 
  144621             :     return object;
  144622             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  144623             : }
  144624             : 
  144625             : 
  144626             : 
  144627             : /*! \brief Delete operator for SgSIMDPartialStore.
  144628             : 
  144629             :    This delete operator implements deallocation using memory pools to 
  144630             :    provide most efficent use of the heap within construction of large ASTs.
  144631             : 
  144632             : \internal The new and delete operators use the lower level C malloc/free
  144633             :    function calls for performance and to make sure that mixing of malloc/free
  144634             :    and new/delete by the used can be caught more readily.  This may change
  144635             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  144636             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  144637             :    deallocate memory allocated using ROSE_MALLOC.
  144638             : */
  144639           0 : void SgSIMDPartialStore::operator delete(void *Pointer, size_t Size)
  144640             : {
  144641             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  144642             :      * or throwing an exception. */
  144643           0 :     ALLOC_MUTEX(SgSIMDPartialStore, lock);
  144644             : 
  144645             : #if USE_CPP_NEW_DELETE_OPERATORS
  144646             :     ROSE_FREE(Pointer);
  144647             : #else
  144648             : #if ROSE_PEDANTIC_ALLOC
  144649             :     ROSE_ASSERT(Size == sizeof(SgSIMDPartialStore));
  144650             : #else
  144651           0 :     if (Size != sizeof(SgSIMDPartialStore)) {
  144652           0 :       ROSE_FREE(Pointer);
  144653           0 :       ALLOC_MUTEX(SgSIMDPartialStore, unlock);
  144654             :       return;
  144655             :     }
  144656             : #endif
  144657             : 
  144658           0 :     SgSIMDPartialStore * object = (SgSIMDPartialStore*) Pointer;
  144659           0 :     ROSE_ASSERT(object != nullptr);
  144660             : 
  144661             : #if ROSE_ALLOC_TRACE == 2
  144662             : //  printf("SgSIMDPartialStore::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgSIMDPartialStore::next_node);
  144663             :     printf("SgSIMDPartialStore::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgSIMDPartialStore::next_node);
  144664             : #endif
  144665             : 
  144666             : #if ROSE_PEDANTIC_ALLOC
  144667             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  144668             : #endif
  144669             : 
  144670             : #if ROSE_ALLOC_MEMSET == 1
  144671             : #elif ROSE_ALLOC_MEMSET == 2
  144672             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgSIMDPartialStore) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  144673             : #elif ROSE_ALLOC_MEMSET == 3
  144674             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgSIMDPartialStore) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  144675             : #endif
  144676             : 
  144677             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  144678             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  144679             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  144680             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  144681             : #else
  144682           0 :     object->p_freepointer = SgSIMDPartialStore::next_node;
  144683           0 :     SgSIMDPartialStore::next_node = object;
  144684             : #endif
  144685             : 
  144686             : #if ROSE_ALLOC_TRACE == 2
  144687             : //  printf("SgSIMDPartialStore::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgSIMDPartialStore::next_node);
  144688             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  144689             :     Rose::MemPool::snapshot(oss.str());
  144690             :     alloc_trace_cnt++;
  144691             : #endif
  144692             : 
  144693             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  144694             : 
  144695           0 :     ALLOC_MUTEX(SgSIMDPartialStore, unlock);
  144696             : }
  144697             : 
  144698             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  144699             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  144700             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  144701             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  144702             : // Also, note comment below from Robb (copied from the Common.code file).
  144703             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  144704             : //
  144705             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  144706             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  144707             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  144708             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  144709             : #if 0
  144710             : void SgSIMDPartialStore::operator delete(void* pointer) { SgSIMDPartialStore::operator delete (pointer, sizeof(SgSIMDPartialStore)); };
  144711             : #endif
  144712             : /* #line 144713 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  144713             : 
  144714             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  144715             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  144716             : // obviously imply C++.
  144717             : 
  144718             : // This implements the support within ROSE for memory pools.  Memory pools
  144719             : // support the most condensed usage of memory within the construction of
  144720             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  144721             : // by a new operator written for each class.
  144722             : 
  144723             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  144724             :     // User wants multi-thread support and POSIX threads are available.
  144725             : #   include <pthread.h>
  144726             :     static pthread_mutex_t SgSIMDScalarStore_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  144727             : #else
  144728             :      // Cause synchronization to be skipped.
  144729             : #    ifndef ALLOC_MUTEX
  144730             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  144731             : #    endif
  144732             : #    ifdef _REENTRANT
  144733             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  144734             : #       ifdef _MSC_VER
  144735             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  144736             : #       else
  144737             : #           warning "POSIX threads are not available; synchronization being skipped"
  144738             : #       endif
  144739             : #    endif
  144740             : #endif
  144741             : 
  144742             : #ifndef ROSE_ALLOC_TRACE
  144743             : #  define ROSE_ALLOC_TRACE 0
  144744             : #endif
  144745             : 
  144746             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  144747             : #define ROSE_ALLOC_TRACE_CNT
  144748             : #include "memory-pool-snapshot.h"
  144749             : unsigned long alloc_trace_cnt = 0;
  144750             : #endif
  144751             : 
  144752             : #if ROSE_ALLOC_TRACE
  144753             : const unsigned SgSIMDScalarStore::pool_size = 5;
  144754             : #else
  144755             : const unsigned SgSIMDScalarStore::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  144756             : #endif
  144757             : 
  144758             : #ifndef ROSE_ALLOC_MEMSET
  144759             : #  define ROSE_ALLOC_MEMSET 0
  144760             : #endif
  144761             : 
  144762             : #ifndef ROSE_PEDANTIC_ALLOC
  144763             : #  define ROSE_PEDANTIC_ALLOC 0
  144764             : #endif
  144765             : 
  144766             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  144767             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  144768             : #endif
  144769             : 
  144770             : #if !defined(SGNODE__ALL_POOLS)
  144771             : #define SGNODE__ALL_POOLS
  144772             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  144773             : #endif
  144774             : 
  144775             : SgSIMDScalarStore* SgSIMDScalarStore::next_node = nullptr;
  144776             : std::vector<unsigned char*> SgSIMDScalarStore::pools;
  144777             : 
  144778             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  144779             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  144780             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  144781             : // around this macro definition rather than each use).
  144782             : #ifndef ALLOC_MUTEX
  144783             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  144784             :         do {                                                                     \
  144785             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  144786             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  144787             :                 abort();                                                         \
  144788             :             }                                                                    \
  144789             :         } while (0);
  144790             : #endif
  144791             : 
  144792             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  144793             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  144794             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  144795             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  144796             : 
  144797             : /*! \brief New operator for SgSIMDScalarStore.
  144798             : 
  144799             :    This new operator implements memory pools to provide most efficent 
  144800             :    use of the heap within construction of large ASTs.
  144801             : 
  144802             : \internal The new and delete operators use the lower level C malloc/free
  144803             :    function calls for performance and to make sure that mixing of malloc/free
  144804             :    and new/delete by the used can be caught more readily.  This may change
  144805             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  144806             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  144807             :    deallocate memory allocated using ROSE_MALLOC.
  144808             : */
  144809           0 : void *SgSIMDScalarStore::operator new ( size_t Size )
  144810             : {
  144811             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  144812             :      * returning or throwing an exception. */
  144813           0 :     ALLOC_MUTEX(SgSIMDScalarStore, lock);
  144814             : 
  144815             : #if ROSE_ALLOC_TRACE == 2
  144816             : //    printf("SgSIMDScalarStore::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgSIMDScalarStore::next_node);
  144817             : #endif
  144818             : 
  144819             : #if USE_CPP_NEW_DELETE_OPERATORS
  144820             :     void *mem = ROSE_MALLOC(Size);
  144821             :     ALLOC_MUTEX(SgSIMDScalarStore, unlock);
  144822             :     return mem;
  144823             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  144824             : #if ROSE_PEDANTIC_ALLOC
  144825             :     ROSE_ASSERT(Size == sizeof(SgSIMDScalarStore));
  144826             : #else
  144827           0 :     if (Size != sizeof(SgSIMDScalarStore)) {
  144828           0 :       void * object = ROSE_MALLOC(Size);
  144829           0 :       ALLOC_MUTEX(SgSIMDScalarStore, unlock);
  144830             :       return object;
  144831             :     }
  144832             : #endif
  144833             : 
  144834           0 :     if (SgSIMDScalarStore::next_node == nullptr) {
  144835           0 :         SgSIMDScalarStore * alloc = (SgSIMDScalarStore*) ROSE_MALLOC ( SgSIMDScalarStore::pool_size * sizeof(SgSIMDScalarStore) );
  144836           0 :         ROSE_ASSERT(alloc != nullptr);
  144837             : 
  144838             : #if ROSE_ALLOC_TRACE == 2
  144839             : //        printf("SgSIMDScalarStore::alloc\n  block[%zi] = [ %p , %p [\n", SgSIMDScalarStore::pools.size(), alloc, alloc + SgSIMDScalarStore::pool_size);
  144840             : #endif
  144841             : 
  144842             : #if ROSE_ALLOC_MEMSET == 1
  144843             : #elif ROSE_ALLOC_MEMSET == 2
  144844             :         memset(alloc, 0x00, SgSIMDScalarStore::pool_size * sizeof(SgSIMDScalarStore));
  144845             : #elif ROSE_ALLOC_MEMSET == 3
  144846             :         memset(alloc, 0xAA, SgSIMDScalarStore::pool_size * sizeof(SgSIMDScalarStore));
  144847             : #endif
  144848           0 :         for (unsigned i=0; i < SgSIMDScalarStore::pool_size-1; i++) {
  144849           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
  144850             :         }
  144851           0 :         alloc[SgSIMDScalarStore::pool_size-1].p_freepointer = nullptr;
  144852             : 
  144853           0 :         SgSIMDScalarStore::pools.push_back ( (unsigned char *) alloc );
  144854           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgSIMDScalarStore::pool_size * sizeof(SgSIMDScalarStore), V_SgSIMDScalarStore ) );
  144855           0 :         SgSIMDScalarStore::next_node = alloc;
  144856             :     }
  144857           0 :     ROSE_ASSERT(SgSIMDScalarStore::next_node != nullptr);
  144858             : 
  144859           0 :     SgSIMDScalarStore * object = SgSIMDScalarStore::next_node;
  144860           0 :     SgSIMDScalarStore::next_node = (SgSIMDScalarStore*)(object->p_freepointer);
  144861             : 
  144862             : #if ROSE_ALLOC_TRACE == 2
  144863             :     printf("SgSIMDScalarStore::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgSIMDScalarStore::next_node);
  144864             : #endif
  144865             : 
  144866           0 :     SgNode * fp = object->p_freepointer;
  144867             : #if ROSE_ALLOC_MEMSET == 1
  144868             : #elif ROSE_ALLOC_MEMSET == 2
  144869             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgSIMDScalarStore) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  144870             : #elif ROSE_ALLOC_MEMSET == 3
  144871             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgSIMDScalarStore) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  144872             : #endif
  144873           0 :     object->p_freepointer = fp;
  144874             : 
  144875             : #if ROSE_ALLOC_TRACE == 2
  144876             : //    printf("SgSIMDScalarStore::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgSIMDScalarStore::next_node);
  144877             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  144878             :     Rose::MemPool::snapshot(oss.str());
  144879             :     alloc_trace_cnt++;
  144880             : #endif
  144881             : 
  144882           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  144883             : 
  144884           0 :     ALLOC_MUTEX(SgSIMDScalarStore, unlock);
  144885             : 
  144886             :     return object;
  144887             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  144888             : }
  144889             : 
  144890             : 
  144891             : 
  144892             : /*! \brief Delete operator for SgSIMDScalarStore.
  144893             : 
  144894             :    This delete operator implements deallocation using memory pools to 
  144895             :    provide most efficent use of the heap within construction of large ASTs.
  144896             : 
  144897             : \internal The new and delete operators use the lower level C malloc/free
  144898             :    function calls for performance and to make sure that mixing of malloc/free
  144899             :    and new/delete by the used can be caught more readily.  This may change
  144900             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  144901             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  144902             :    deallocate memory allocated using ROSE_MALLOC.
  144903             : */
  144904           0 : void SgSIMDScalarStore::operator delete(void *Pointer, size_t Size)
  144905             : {
  144906             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  144907             :      * or throwing an exception. */
  144908           0 :     ALLOC_MUTEX(SgSIMDScalarStore, lock);
  144909             : 
  144910             : #if USE_CPP_NEW_DELETE_OPERATORS
  144911             :     ROSE_FREE(Pointer);
  144912             : #else
  144913             : #if ROSE_PEDANTIC_ALLOC
  144914             :     ROSE_ASSERT(Size == sizeof(SgSIMDScalarStore));
  144915             : #else
  144916           0 :     if (Size != sizeof(SgSIMDScalarStore)) {
  144917           0 :       ROSE_FREE(Pointer);
  144918           0 :       ALLOC_MUTEX(SgSIMDScalarStore, unlock);
  144919             :       return;
  144920             :     }
  144921             : #endif
  144922             : 
  144923           0 :     SgSIMDScalarStore * object = (SgSIMDScalarStore*) Pointer;
  144924           0 :     ROSE_ASSERT(object != nullptr);
  144925             : 
  144926             : #if ROSE_ALLOC_TRACE == 2
  144927             : //  printf("SgSIMDScalarStore::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgSIMDScalarStore::next_node);
  144928             :     printf("SgSIMDScalarStore::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgSIMDScalarStore::next_node);
  144929             : #endif
  144930             : 
  144931             : #if ROSE_PEDANTIC_ALLOC
  144932             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  144933             : #endif
  144934             : 
  144935             : #if ROSE_ALLOC_MEMSET == 1
  144936             : #elif ROSE_ALLOC_MEMSET == 2
  144937             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgSIMDScalarStore) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  144938             : #elif ROSE_ALLOC_MEMSET == 3
  144939             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgSIMDScalarStore) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  144940             : #endif
  144941             : 
  144942             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  144943             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  144944             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  144945             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  144946             : #else
  144947           0 :     object->p_freepointer = SgSIMDScalarStore::next_node;
  144948           0 :     SgSIMDScalarStore::next_node = object;
  144949             : #endif
  144950             : 
  144951             : #if ROSE_ALLOC_TRACE == 2
  144952             : //  printf("SgSIMDScalarStore::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgSIMDScalarStore::next_node);
  144953             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  144954             :     Rose::MemPool::snapshot(oss.str());
  144955             :     alloc_trace_cnt++;
  144956             : #endif
  144957             : 
  144958             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  144959             : 
  144960           0 :     ALLOC_MUTEX(SgSIMDScalarStore, unlock);
  144961             : }
  144962             : 
  144963             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  144964             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  144965             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  144966             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  144967             : // Also, note comment below from Robb (copied from the Common.code file).
  144968             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  144969             : //
  144970             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  144971             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  144972             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  144973             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  144974             : #if 0
  144975             : void SgSIMDScalarStore::operator delete(void* pointer) { SgSIMDScalarStore::operator delete (pointer, sizeof(SgSIMDScalarStore)); };
  144976             : #endif
  144977             : /* #line 144978 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  144978             : 
  144979             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  144980             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  144981             : // obviously imply C++.
  144982             : 
  144983             : // This implements the support within ROSE for memory pools.  Memory pools
  144984             : // support the most condensed usage of memory within the construction of
  144985             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  144986             : // by a new operator written for each class.
  144987             : 
  144988             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  144989             :     // User wants multi-thread support and POSIX threads are available.
  144990             : #   include <pthread.h>
  144991             :     static pthread_mutex_t SgSIMDGather_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  144992             : #else
  144993             :      // Cause synchronization to be skipped.
  144994             : #    ifndef ALLOC_MUTEX
  144995             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  144996             : #    endif
  144997             : #    ifdef _REENTRANT
  144998             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  144999             : #       ifdef _MSC_VER
  145000             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  145001             : #       else
  145002             : #           warning "POSIX threads are not available; synchronization being skipped"
  145003             : #       endif
  145004             : #    endif
  145005             : #endif
  145006             : 
  145007             : #ifndef ROSE_ALLOC_TRACE
  145008             : #  define ROSE_ALLOC_TRACE 0
  145009             : #endif
  145010             : 
  145011             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  145012             : #define ROSE_ALLOC_TRACE_CNT
  145013             : #include "memory-pool-snapshot.h"
  145014             : unsigned long alloc_trace_cnt = 0;
  145015             : #endif
  145016             : 
  145017             : #if ROSE_ALLOC_TRACE
  145018             : const unsigned SgSIMDGather::pool_size = 5;
  145019             : #else
  145020             : const unsigned SgSIMDGather::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  145021             : #endif
  145022             : 
  145023             : #ifndef ROSE_ALLOC_MEMSET
  145024             : #  define ROSE_ALLOC_MEMSET 0
  145025             : #endif
  145026             : 
  145027             : #ifndef ROSE_PEDANTIC_ALLOC
  145028             : #  define ROSE_PEDANTIC_ALLOC 0
  145029             : #endif
  145030             : 
  145031             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  145032             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  145033             : #endif
  145034             : 
  145035             : #if !defined(SGNODE__ALL_POOLS)
  145036             : #define SGNODE__ALL_POOLS
  145037             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  145038             : #endif
  145039             : 
  145040             : SgSIMDGather* SgSIMDGather::next_node = nullptr;
  145041             : std::vector<unsigned char*> SgSIMDGather::pools;
  145042             : 
  145043             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  145044             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  145045             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  145046             : // around this macro definition rather than each use).
  145047             : #ifndef ALLOC_MUTEX
  145048             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  145049             :         do {                                                                     \
  145050             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  145051             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  145052             :                 abort();                                                         \
  145053             :             }                                                                    \
  145054             :         } while (0);
  145055             : #endif
  145056             : 
  145057             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  145058             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  145059             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  145060             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  145061             : 
  145062             : /*! \brief New operator for SgSIMDGather.
  145063             : 
  145064             :    This new operator implements memory pools to provide most efficent 
  145065             :    use of the heap within construction of large ASTs.
  145066             : 
  145067             : \internal The new and delete operators use the lower level C malloc/free
  145068             :    function calls for performance and to make sure that mixing of malloc/free
  145069             :    and new/delete by the used can be caught more readily.  This may change
  145070             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  145071             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  145072             :    deallocate memory allocated using ROSE_MALLOC.
  145073             : */
  145074           0 : void *SgSIMDGather::operator new ( size_t Size )
  145075             : {
  145076             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  145077             :      * returning or throwing an exception. */
  145078           0 :     ALLOC_MUTEX(SgSIMDGather, lock);
  145079             : 
  145080             : #if ROSE_ALLOC_TRACE == 2
  145081             : //    printf("SgSIMDGather::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgSIMDGather::next_node);
  145082             : #endif
  145083             : 
  145084             : #if USE_CPP_NEW_DELETE_OPERATORS
  145085             :     void *mem = ROSE_MALLOC(Size);
  145086             :     ALLOC_MUTEX(SgSIMDGather, unlock);
  145087             :     return mem;
  145088             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  145089             : #if ROSE_PEDANTIC_ALLOC
  145090             :     ROSE_ASSERT(Size == sizeof(SgSIMDGather));
  145091             : #else
  145092           0 :     if (Size != sizeof(SgSIMDGather)) {
  145093           0 :       void * object = ROSE_MALLOC(Size);
  145094           0 :       ALLOC_MUTEX(SgSIMDGather, unlock);
  145095             :       return object;
  145096             :     }
  145097             : #endif
  145098             : 
  145099           0 :     if (SgSIMDGather::next_node == nullptr) {
  145100           0 :         SgSIMDGather * alloc = (SgSIMDGather*) ROSE_MALLOC ( SgSIMDGather::pool_size * sizeof(SgSIMDGather) );
  145101           0 :         ROSE_ASSERT(alloc != nullptr);
  145102             : 
  145103             : #if ROSE_ALLOC_TRACE == 2
  145104             : //        printf("SgSIMDGather::alloc\n  block[%zi] = [ %p , %p [\n", SgSIMDGather::pools.size(), alloc, alloc + SgSIMDGather::pool_size);
  145105             : #endif
  145106             : 
  145107             : #if ROSE_ALLOC_MEMSET == 1
  145108             : #elif ROSE_ALLOC_MEMSET == 2
  145109             :         memset(alloc, 0x00, SgSIMDGather::pool_size * sizeof(SgSIMDGather));
  145110             : #elif ROSE_ALLOC_MEMSET == 3
  145111             :         memset(alloc, 0xAA, SgSIMDGather::pool_size * sizeof(SgSIMDGather));
  145112             : #endif
  145113           0 :         for (unsigned i=0; i < SgSIMDGather::pool_size-1; i++) {
  145114           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
  145115             :         }
  145116           0 :         alloc[SgSIMDGather::pool_size-1].p_freepointer = nullptr;
  145117             : 
  145118           0 :         SgSIMDGather::pools.push_back ( (unsigned char *) alloc );
  145119           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgSIMDGather::pool_size * sizeof(SgSIMDGather), V_SgSIMDGather ) );
  145120           0 :         SgSIMDGather::next_node = alloc;
  145121             :     }
  145122           0 :     ROSE_ASSERT(SgSIMDGather::next_node != nullptr);
  145123             : 
  145124           0 :     SgSIMDGather * object = SgSIMDGather::next_node;
  145125           0 :     SgSIMDGather::next_node = (SgSIMDGather*)(object->p_freepointer);
  145126             : 
  145127             : #if ROSE_ALLOC_TRACE == 2
  145128             :     printf("SgSIMDGather::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgSIMDGather::next_node);
  145129             : #endif
  145130             : 
  145131           0 :     SgNode * fp = object->p_freepointer;
  145132             : #if ROSE_ALLOC_MEMSET == 1
  145133             : #elif ROSE_ALLOC_MEMSET == 2
  145134             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgSIMDGather) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  145135             : #elif ROSE_ALLOC_MEMSET == 3
  145136             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgSIMDGather) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  145137             : #endif
  145138           0 :     object->p_freepointer = fp;
  145139             : 
  145140             : #if ROSE_ALLOC_TRACE == 2
  145141             : //    printf("SgSIMDGather::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgSIMDGather::next_node);
  145142             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  145143             :     Rose::MemPool::snapshot(oss.str());
  145144             :     alloc_trace_cnt++;
  145145             : #endif
  145146             : 
  145147           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  145148             : 
  145149           0 :     ALLOC_MUTEX(SgSIMDGather, unlock);
  145150             : 
  145151             :     return object;
  145152             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  145153             : }
  145154             : 
  145155             : 
  145156             : 
  145157             : /*! \brief Delete operator for SgSIMDGather.
  145158             : 
  145159             :    This delete operator implements deallocation using memory pools to 
  145160             :    provide most efficent use of the heap within construction of large ASTs.
  145161             : 
  145162             : \internal The new and delete operators use the lower level C malloc/free
  145163             :    function calls for performance and to make sure that mixing of malloc/free
  145164             :    and new/delete by the used can be caught more readily.  This may change
  145165             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  145166             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  145167             :    deallocate memory allocated using ROSE_MALLOC.
  145168             : */
  145169           0 : void SgSIMDGather::operator delete(void *Pointer, size_t Size)
  145170             : {
  145171             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  145172             :      * or throwing an exception. */
  145173           0 :     ALLOC_MUTEX(SgSIMDGather, lock);
  145174             : 
  145175             : #if USE_CPP_NEW_DELETE_OPERATORS
  145176             :     ROSE_FREE(Pointer);
  145177             : #else
  145178             : #if ROSE_PEDANTIC_ALLOC
  145179             :     ROSE_ASSERT(Size == sizeof(SgSIMDGather));
  145180             : #else
  145181           0 :     if (Size != sizeof(SgSIMDGather)) {
  145182           0 :       ROSE_FREE(Pointer);
  145183           0 :       ALLOC_MUTEX(SgSIMDGather, unlock);
  145184             :       return;
  145185             :     }
  145186             : #endif
  145187             : 
  145188           0 :     SgSIMDGather * object = (SgSIMDGather*) Pointer;
  145189           0 :     ROSE_ASSERT(object != nullptr);
  145190             : 
  145191             : #if ROSE_ALLOC_TRACE == 2
  145192             : //  printf("SgSIMDGather::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgSIMDGather::next_node);
  145193             :     printf("SgSIMDGather::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgSIMDGather::next_node);
  145194             : #endif
  145195             : 
  145196             : #if ROSE_PEDANTIC_ALLOC
  145197             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  145198             : #endif
  145199             : 
  145200             : #if ROSE_ALLOC_MEMSET == 1
  145201             : #elif ROSE_ALLOC_MEMSET == 2
  145202             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgSIMDGather) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  145203             : #elif ROSE_ALLOC_MEMSET == 3
  145204             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgSIMDGather) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  145205             : #endif
  145206             : 
  145207             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  145208             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  145209             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  145210             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  145211             : #else
  145212           0 :     object->p_freepointer = SgSIMDGather::next_node;
  145213           0 :     SgSIMDGather::next_node = object;
  145214             : #endif
  145215             : 
  145216             : #if ROSE_ALLOC_TRACE == 2
  145217             : //  printf("SgSIMDGather::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgSIMDGather::next_node);
  145218             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  145219             :     Rose::MemPool::snapshot(oss.str());
  145220             :     alloc_trace_cnt++;
  145221             : #endif
  145222             : 
  145223             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  145224             : 
  145225           0 :     ALLOC_MUTEX(SgSIMDGather, unlock);
  145226             : }
  145227             : 
  145228             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  145229             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  145230             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  145231             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  145232             : // Also, note comment below from Robb (copied from the Common.code file).
  145233             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  145234             : //
  145235             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  145236             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  145237             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  145238             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  145239             : #if 0
  145240             : void SgSIMDGather::operator delete(void* pointer) { SgSIMDGather::operator delete (pointer, sizeof(SgSIMDGather)); };
  145241             : #endif
  145242             : /* #line 145243 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  145243             : 
  145244             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  145245             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  145246             : // obviously imply C++.
  145247             : 
  145248             : // This implements the support within ROSE for memory pools.  Memory pools
  145249             : // support the most condensed usage of memory within the construction of
  145250             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  145251             : // by a new operator written for each class.
  145252             : 
  145253             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  145254             :     // User wants multi-thread support and POSIX threads are available.
  145255             : #   include <pthread.h>
  145256             :     static pthread_mutex_t SgSIMDExplicitGather_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  145257             : #else
  145258             :      // Cause synchronization to be skipped.
  145259             : #    ifndef ALLOC_MUTEX
  145260             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  145261             : #    endif
  145262             : #    ifdef _REENTRANT
  145263             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  145264             : #       ifdef _MSC_VER
  145265             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  145266             : #       else
  145267             : #           warning "POSIX threads are not available; synchronization being skipped"
  145268             : #       endif
  145269             : #    endif
  145270             : #endif
  145271             : 
  145272             : #ifndef ROSE_ALLOC_TRACE
  145273             : #  define ROSE_ALLOC_TRACE 0
  145274             : #endif
  145275             : 
  145276             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  145277             : #define ROSE_ALLOC_TRACE_CNT
  145278             : #include "memory-pool-snapshot.h"
  145279             : unsigned long alloc_trace_cnt = 0;
  145280             : #endif
  145281             : 
  145282             : #if ROSE_ALLOC_TRACE
  145283             : const unsigned SgSIMDExplicitGather::pool_size = 5;
  145284             : #else
  145285             : const unsigned SgSIMDExplicitGather::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  145286             : #endif
  145287             : 
  145288             : #ifndef ROSE_ALLOC_MEMSET
  145289             : #  define ROSE_ALLOC_MEMSET 0
  145290             : #endif
  145291             : 
  145292             : #ifndef ROSE_PEDANTIC_ALLOC
  145293             : #  define ROSE_PEDANTIC_ALLOC 0
  145294             : #endif
  145295             : 
  145296             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  145297             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  145298             : #endif
  145299             : 
  145300             : #if !defined(SGNODE__ALL_POOLS)
  145301             : #define SGNODE__ALL_POOLS
  145302             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  145303             : #endif
  145304             : 
  145305             : SgSIMDExplicitGather* SgSIMDExplicitGather::next_node = nullptr;
  145306             : std::vector<unsigned char*> SgSIMDExplicitGather::pools;
  145307             : 
  145308             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  145309             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  145310             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  145311             : // around this macro definition rather than each use).
  145312             : #ifndef ALLOC_MUTEX
  145313             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  145314             :         do {                                                                     \
  145315             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  145316             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  145317             :                 abort();                                                         \
  145318             :             }                                                                    \
  145319             :         } while (0);
  145320             : #endif
  145321             : 
  145322             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  145323             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  145324             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  145325             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  145326             : 
  145327             : /*! \brief New operator for SgSIMDExplicitGather.
  145328             : 
  145329             :    This new operator implements memory pools to provide most efficent 
  145330             :    use of the heap within construction of large ASTs.
  145331             : 
  145332             : \internal The new and delete operators use the lower level C malloc/free
  145333             :    function calls for performance and to make sure that mixing of malloc/free
  145334             :    and new/delete by the used can be caught more readily.  This may change
  145335             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  145336             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  145337             :    deallocate memory allocated using ROSE_MALLOC.
  145338             : */
  145339           0 : void *SgSIMDExplicitGather::operator new ( size_t Size )
  145340             : {
  145341             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  145342             :      * returning or throwing an exception. */
  145343           0 :     ALLOC_MUTEX(SgSIMDExplicitGather, lock);
  145344             : 
  145345             : #if ROSE_ALLOC_TRACE == 2
  145346             : //    printf("SgSIMDExplicitGather::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgSIMDExplicitGather::next_node);
  145347             : #endif
  145348             : 
  145349             : #if USE_CPP_NEW_DELETE_OPERATORS
  145350             :     void *mem = ROSE_MALLOC(Size);
  145351             :     ALLOC_MUTEX(SgSIMDExplicitGather, unlock);
  145352             :     return mem;
  145353             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  145354             : #if ROSE_PEDANTIC_ALLOC
  145355             :     ROSE_ASSERT(Size == sizeof(SgSIMDExplicitGather));
  145356             : #else
  145357           0 :     if (Size != sizeof(SgSIMDExplicitGather)) {
  145358           0 :       void * object = ROSE_MALLOC(Size);
  145359           0 :       ALLOC_MUTEX(SgSIMDExplicitGather, unlock);
  145360             :       return object;
  145361             :     }
  145362             : #endif
  145363             : 
  145364           0 :     if (SgSIMDExplicitGather::next_node == nullptr) {
  145365           0 :         SgSIMDExplicitGather * alloc = (SgSIMDExplicitGather*) ROSE_MALLOC ( SgSIMDExplicitGather::pool_size * sizeof(SgSIMDExplicitGather) );
  145366           0 :         ROSE_ASSERT(alloc != nullptr);
  145367             : 
  145368             : #if ROSE_ALLOC_TRACE == 2
  145369             : //        printf("SgSIMDExplicitGather::alloc\n  block[%zi] = [ %p , %p [\n", SgSIMDExplicitGather::pools.size(), alloc, alloc + SgSIMDExplicitGather::pool_size);
  145370             : #endif
  145371             : 
  145372             : #if ROSE_ALLOC_MEMSET == 1
  145373             : #elif ROSE_ALLOC_MEMSET == 2
  145374             :         memset(alloc, 0x00, SgSIMDExplicitGather::pool_size * sizeof(SgSIMDExplicitGather));
  145375             : #elif ROSE_ALLOC_MEMSET == 3
  145376             :         memset(alloc, 0xAA, SgSIMDExplicitGather::pool_size * sizeof(SgSIMDExplicitGather));
  145377             : #endif
  145378           0 :         for (unsigned i=0; i < SgSIMDExplicitGather::pool_size-1; i++) {
  145379           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
  145380             :         }
  145381           0 :         alloc[SgSIMDExplicitGather::pool_size-1].p_freepointer = nullptr;
  145382             : 
  145383           0 :         SgSIMDExplicitGather::pools.push_back ( (unsigned char *) alloc );
  145384           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgSIMDExplicitGather::pool_size * sizeof(SgSIMDExplicitGather), V_SgSIMDExplicitGather ) );
  145385           0 :         SgSIMDExplicitGather::next_node = alloc;
  145386             :     }
  145387           0 :     ROSE_ASSERT(SgSIMDExplicitGather::next_node != nullptr);
  145388             : 
  145389           0 :     SgSIMDExplicitGather * object = SgSIMDExplicitGather::next_node;
  145390           0 :     SgSIMDExplicitGather::next_node = (SgSIMDExplicitGather*)(object->p_freepointer);
  145391             : 
  145392             : #if ROSE_ALLOC_TRACE == 2
  145393             :     printf("SgSIMDExplicitGather::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgSIMDExplicitGather::next_node);
  145394             : #endif
  145395             : 
  145396           0 :     SgNode * fp = object->p_freepointer;
  145397             : #if ROSE_ALLOC_MEMSET == 1
  145398             : #elif ROSE_ALLOC_MEMSET == 2
  145399             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgSIMDExplicitGather) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  145400             : #elif ROSE_ALLOC_MEMSET == 3
  145401             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgSIMDExplicitGather) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  145402             : #endif
  145403           0 :     object->p_freepointer = fp;
  145404             : 
  145405             : #if ROSE_ALLOC_TRACE == 2
  145406             : //    printf("SgSIMDExplicitGather::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgSIMDExplicitGather::next_node);
  145407             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  145408             :     Rose::MemPool::snapshot(oss.str());
  145409             :     alloc_trace_cnt++;
  145410             : #endif
  145411             : 
  145412           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  145413             : 
  145414           0 :     ALLOC_MUTEX(SgSIMDExplicitGather, unlock);
  145415             : 
  145416             :     return object;
  145417             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  145418             : }
  145419             : 
  145420             : 
  145421             : 
  145422             : /*! \brief Delete operator for SgSIMDExplicitGather.
  145423             : 
  145424             :    This delete operator implements deallocation using memory pools to 
  145425             :    provide most efficent use of the heap within construction of large ASTs.
  145426             : 
  145427             : \internal The new and delete operators use the lower level C malloc/free
  145428             :    function calls for performance and to make sure that mixing of malloc/free
  145429             :    and new/delete by the used can be caught more readily.  This may change
  145430             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  145431             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  145432             :    deallocate memory allocated using ROSE_MALLOC.
  145433             : */
  145434           0 : void SgSIMDExplicitGather::operator delete(void *Pointer, size_t Size)
  145435             : {
  145436             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  145437             :      * or throwing an exception. */
  145438           0 :     ALLOC_MUTEX(SgSIMDExplicitGather, lock);
  145439             : 
  145440             : #if USE_CPP_NEW_DELETE_OPERATORS
  145441             :     ROSE_FREE(Pointer);
  145442             : #else
  145443             : #if ROSE_PEDANTIC_ALLOC
  145444             :     ROSE_ASSERT(Size == sizeof(SgSIMDExplicitGather));
  145445             : #else
  145446           0 :     if (Size != sizeof(SgSIMDExplicitGather)) {
  145447           0 :       ROSE_FREE(Pointer);
  145448           0 :       ALLOC_MUTEX(SgSIMDExplicitGather, unlock);
  145449             :       return;
  145450             :     }
  145451             : #endif
  145452             : 
  145453           0 :     SgSIMDExplicitGather * object = (SgSIMDExplicitGather*) Pointer;
  145454           0 :     ROSE_ASSERT(object != nullptr);
  145455             : 
  145456             : #if ROSE_ALLOC_TRACE == 2
  145457             : //  printf("SgSIMDExplicitGather::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgSIMDExplicitGather::next_node);
  145458             :     printf("SgSIMDExplicitGather::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgSIMDExplicitGather::next_node);
  145459             : #endif
  145460             : 
  145461             : #if ROSE_PEDANTIC_ALLOC
  145462             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  145463             : #endif
  145464             : 
  145465             : #if ROSE_ALLOC_MEMSET == 1
  145466             : #elif ROSE_ALLOC_MEMSET == 2
  145467             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgSIMDExplicitGather) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  145468             : #elif ROSE_ALLOC_MEMSET == 3
  145469             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgSIMDExplicitGather) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  145470             : #endif
  145471             : 
  145472             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  145473             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  145474             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  145475             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  145476             : #else
  145477           0 :     object->p_freepointer = SgSIMDExplicitGather::next_node;
  145478           0 :     SgSIMDExplicitGather::next_node = object;
  145479             : #endif
  145480             : 
  145481             : #if ROSE_ALLOC_TRACE == 2
  145482             : //  printf("SgSIMDExplicitGather::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgSIMDExplicitGather::next_node);
  145483             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  145484             :     Rose::MemPool::snapshot(oss.str());
  145485             :     alloc_trace_cnt++;
  145486             : #endif
  145487             : 
  145488             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  145489             : 
  145490           0 :     ALLOC_MUTEX(SgSIMDExplicitGather, unlock);
  145491             : }
  145492             : 
  145493             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  145494             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  145495             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  145496             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  145497             : // Also, note comment below from Robb (copied from the Common.code file).
  145498             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  145499             : //
  145500             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  145501             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  145502             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  145503             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  145504             : #if 0
  145505             : void SgSIMDExplicitGather::operator delete(void* pointer) { SgSIMDExplicitGather::operator delete (pointer, sizeof(SgSIMDExplicitGather)); };
  145506             : #endif
  145507             : /* #line 145508 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  145508             : 
  145509             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  145510             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  145511             : // obviously imply C++.
  145512             : 
  145513             : // This implements the support within ROSE for memory pools.  Memory pools
  145514             : // support the most condensed usage of memory within the construction of
  145515             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  145516             : // by a new operator written for each class.
  145517             : 
  145518             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  145519             :     // User wants multi-thread support and POSIX threads are available.
  145520             : #   include <pthread.h>
  145521             :     static pthread_mutex_t SgSIMDScatter_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  145522             : #else
  145523             :      // Cause synchronization to be skipped.
  145524             : #    ifndef ALLOC_MUTEX
  145525             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  145526             : #    endif
  145527             : #    ifdef _REENTRANT
  145528             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  145529             : #       ifdef _MSC_VER
  145530             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  145531             : #       else
  145532             : #           warning "POSIX threads are not available; synchronization being skipped"
  145533             : #       endif
  145534             : #    endif
  145535             : #endif
  145536             : 
  145537             : #ifndef ROSE_ALLOC_TRACE
  145538             : #  define ROSE_ALLOC_TRACE 0
  145539             : #endif
  145540             : 
  145541             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  145542             : #define ROSE_ALLOC_TRACE_CNT
  145543             : #include "memory-pool-snapshot.h"
  145544             : unsigned long alloc_trace_cnt = 0;
  145545             : #endif
  145546             : 
  145547             : #if ROSE_ALLOC_TRACE
  145548             : const unsigned SgSIMDScatter::pool_size = 5;
  145549             : #else
  145550             : const unsigned SgSIMDScatter::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  145551             : #endif
  145552             : 
  145553             : #ifndef ROSE_ALLOC_MEMSET
  145554             : #  define ROSE_ALLOC_MEMSET 0
  145555             : #endif
  145556             : 
  145557             : #ifndef ROSE_PEDANTIC_ALLOC
  145558             : #  define ROSE_PEDANTIC_ALLOC 0
  145559             : #endif
  145560             : 
  145561             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  145562             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  145563             : #endif
  145564             : 
  145565             : #if !defined(SGNODE__ALL_POOLS)
  145566             : #define SGNODE__ALL_POOLS
  145567             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  145568             : #endif
  145569             : 
  145570             : SgSIMDScatter* SgSIMDScatter::next_node = nullptr;
  145571             : std::vector<unsigned char*> SgSIMDScatter::pools;
  145572             : 
  145573             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  145574             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  145575             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  145576             : // around this macro definition rather than each use).
  145577             : #ifndef ALLOC_MUTEX
  145578             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  145579             :         do {                                                                     \
  145580             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  145581             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  145582             :                 abort();                                                         \
  145583             :             }                                                                    \
  145584             :         } while (0);
  145585             : #endif
  145586             : 
  145587             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  145588             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  145589             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  145590             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  145591             : 
  145592             : /*! \brief New operator for SgSIMDScatter.
  145593             : 
  145594             :    This new operator implements memory pools to provide most efficent 
  145595             :    use of the heap within construction of large ASTs.
  145596             : 
  145597             : \internal The new and delete operators use the lower level C malloc/free
  145598             :    function calls for performance and to make sure that mixing of malloc/free
  145599             :    and new/delete by the used can be caught more readily.  This may change
  145600             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  145601             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  145602             :    deallocate memory allocated using ROSE_MALLOC.
  145603             : */
  145604           0 : void *SgSIMDScatter::operator new ( size_t Size )
  145605             : {
  145606             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  145607             :      * returning or throwing an exception. */
  145608           0 :     ALLOC_MUTEX(SgSIMDScatter, lock);
  145609             : 
  145610             : #if ROSE_ALLOC_TRACE == 2
  145611             : //    printf("SgSIMDScatter::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgSIMDScatter::next_node);
  145612             : #endif
  145613             : 
  145614             : #if USE_CPP_NEW_DELETE_OPERATORS
  145615             :     void *mem = ROSE_MALLOC(Size);
  145616             :     ALLOC_MUTEX(SgSIMDScatter, unlock);
  145617             :     return mem;
  145618             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  145619             : #if ROSE_PEDANTIC_ALLOC
  145620             :     ROSE_ASSERT(Size == sizeof(SgSIMDScatter));
  145621             : #else
  145622           0 :     if (Size != sizeof(SgSIMDScatter)) {
  145623           0 :       void * object = ROSE_MALLOC(Size);
  145624           0 :       ALLOC_MUTEX(SgSIMDScatter, unlock);
  145625             :       return object;
  145626             :     }
  145627             : #endif
  145628             : 
  145629           0 :     if (SgSIMDScatter::next_node == nullptr) {
  145630           0 :         SgSIMDScatter * alloc = (SgSIMDScatter*) ROSE_MALLOC ( SgSIMDScatter::pool_size * sizeof(SgSIMDScatter) );
  145631           0 :         ROSE_ASSERT(alloc != nullptr);
  145632             : 
  145633             : #if ROSE_ALLOC_TRACE == 2
  145634             : //        printf("SgSIMDScatter::alloc\n  block[%zi] = [ %p , %p [\n", SgSIMDScatter::pools.size(), alloc, alloc + SgSIMDScatter::pool_size);
  145635             : #endif
  145636             : 
  145637             : #if ROSE_ALLOC_MEMSET == 1
  145638             : #elif ROSE_ALLOC_MEMSET == 2
  145639             :         memset(alloc, 0x00, SgSIMDScatter::pool_size * sizeof(SgSIMDScatter));
  145640             : #elif ROSE_ALLOC_MEMSET == 3
  145641             :         memset(alloc, 0xAA, SgSIMDScatter::pool_size * sizeof(SgSIMDScatter));
  145642             : #endif
  145643           0 :         for (unsigned i=0; i < SgSIMDScatter::pool_size-1; i++) {
  145644           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
  145645             :         }
  145646           0 :         alloc[SgSIMDScatter::pool_size-1].p_freepointer = nullptr;
  145647             : 
  145648           0 :         SgSIMDScatter::pools.push_back ( (unsigned char *) alloc );
  145649           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgSIMDScatter::pool_size * sizeof(SgSIMDScatter), V_SgSIMDScatter ) );
  145650           0 :         SgSIMDScatter::next_node = alloc;
  145651             :     }
  145652           0 :     ROSE_ASSERT(SgSIMDScatter::next_node != nullptr);
  145653             : 
  145654           0 :     SgSIMDScatter * object = SgSIMDScatter::next_node;
  145655           0 :     SgSIMDScatter::next_node = (SgSIMDScatter*)(object->p_freepointer);
  145656             : 
  145657             : #if ROSE_ALLOC_TRACE == 2
  145658             :     printf("SgSIMDScatter::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgSIMDScatter::next_node);
  145659             : #endif
  145660             : 
  145661           0 :     SgNode * fp = object->p_freepointer;
  145662             : #if ROSE_ALLOC_MEMSET == 1
  145663             : #elif ROSE_ALLOC_MEMSET == 2
  145664             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgSIMDScatter) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  145665             : #elif ROSE_ALLOC_MEMSET == 3
  145666             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgSIMDScatter) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  145667             : #endif
  145668           0 :     object->p_freepointer = fp;
  145669             : 
  145670             : #if ROSE_ALLOC_TRACE == 2
  145671             : //    printf("SgSIMDScatter::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgSIMDScatter::next_node);
  145672             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  145673             :     Rose::MemPool::snapshot(oss.str());
  145674             :     alloc_trace_cnt++;
  145675             : #endif
  145676             : 
  145677           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  145678             : 
  145679           0 :     ALLOC_MUTEX(SgSIMDScatter, unlock);
  145680             : 
  145681             :     return object;
  145682             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  145683             : }
  145684             : 
  145685             : 
  145686             : 
  145687             : /*! \brief Delete operator for SgSIMDScatter.
  145688             : 
  145689             :    This delete operator implements deallocation using memory pools to 
  145690             :    provide most efficent use of the heap within construction of large ASTs.
  145691             : 
  145692             : \internal The new and delete operators use the lower level C malloc/free
  145693             :    function calls for performance and to make sure that mixing of malloc/free
  145694             :    and new/delete by the used can be caught more readily.  This may change
  145695             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  145696             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  145697             :    deallocate memory allocated using ROSE_MALLOC.
  145698             : */
  145699           0 : void SgSIMDScatter::operator delete(void *Pointer, size_t Size)
  145700             : {
  145701             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  145702             :      * or throwing an exception. */
  145703           0 :     ALLOC_MUTEX(SgSIMDScatter, lock);
  145704             : 
  145705             : #if USE_CPP_NEW_DELETE_OPERATORS
  145706             :     ROSE_FREE(Pointer);
  145707             : #else
  145708             : #if ROSE_PEDANTIC_ALLOC
  145709             :     ROSE_ASSERT(Size == sizeof(SgSIMDScatter));
  145710             : #else
  145711           0 :     if (Size != sizeof(SgSIMDScatter)) {
  145712           0 :       ROSE_FREE(Pointer);
  145713           0 :       ALLOC_MUTEX(SgSIMDScatter, unlock);
  145714             :       return;
  145715             :     }
  145716             : #endif
  145717             : 
  145718           0 :     SgSIMDScatter * object = (SgSIMDScatter*) Pointer;
  145719           0 :     ROSE_ASSERT(object != nullptr);
  145720             : 
  145721             : #if ROSE_ALLOC_TRACE == 2
  145722             : //  printf("SgSIMDScatter::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgSIMDScatter::next_node);
  145723             :     printf("SgSIMDScatter::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgSIMDScatter::next_node);
  145724             : #endif
  145725             : 
  145726             : #if ROSE_PEDANTIC_ALLOC
  145727             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  145728             : #endif
  145729             : 
  145730             : #if ROSE_ALLOC_MEMSET == 1
  145731             : #elif ROSE_ALLOC_MEMSET == 2
  145732             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgSIMDScatter) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  145733             : #elif ROSE_ALLOC_MEMSET == 3
  145734             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgSIMDScatter) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  145735             : #endif
  145736             : 
  145737             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  145738             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  145739             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  145740             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  145741             : #else
  145742           0 :     object->p_freepointer = SgSIMDScatter::next_node;
  145743           0 :     SgSIMDScatter::next_node = object;
  145744             : #endif
  145745             : 
  145746             : #if ROSE_ALLOC_TRACE == 2
  145747             : //  printf("SgSIMDScatter::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgSIMDScatter::next_node);
  145748             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  145749             :     Rose::MemPool::snapshot(oss.str());
  145750             :     alloc_trace_cnt++;
  145751             : #endif
  145752             : 
  145753             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  145754             : 
  145755           0 :     ALLOC_MUTEX(SgSIMDScatter, unlock);
  145756             : }
  145757             : 
  145758             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  145759             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  145760             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  145761             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  145762             : // Also, note comment below from Robb (copied from the Common.code file).
  145763             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  145764             : //
  145765             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  145766             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  145767             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  145768             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  145769             : #if 0
  145770             : void SgSIMDScatter::operator delete(void* pointer) { SgSIMDScatter::operator delete (pointer, sizeof(SgSIMDScatter)); };
  145771             : #endif
  145772             : /* #line 145773 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  145773             : 
  145774             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  145775             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  145776             : // obviously imply C++.
  145777             : 
  145778             : // This implements the support within ROSE for memory pools.  Memory pools
  145779             : // support the most condensed usage of memory within the construction of
  145780             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  145781             : // by a new operator written for each class.
  145782             : 
  145783             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  145784             :     // User wants multi-thread support and POSIX threads are available.
  145785             : #   include <pthread.h>
  145786             :     static pthread_mutex_t SgExprListExp_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  145787             : #else
  145788             :      // Cause synchronization to be skipped.
  145789             : #    ifndef ALLOC_MUTEX
  145790             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  145791             : #    endif
  145792             : #    ifdef _REENTRANT
  145793             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  145794             : #       ifdef _MSC_VER
  145795             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  145796             : #       else
  145797             : #           warning "POSIX threads are not available; synchronization being skipped"
  145798             : #       endif
  145799             : #    endif
  145800             : #endif
  145801             : 
  145802             : #ifndef ROSE_ALLOC_TRACE
  145803             : #  define ROSE_ALLOC_TRACE 0
  145804             : #endif
  145805             : 
  145806             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  145807             : #define ROSE_ALLOC_TRACE_CNT
  145808             : #include "memory-pool-snapshot.h"
  145809             : unsigned long alloc_trace_cnt = 0;
  145810             : #endif
  145811             : 
  145812             : #if ROSE_ALLOC_TRACE
  145813             : const unsigned SgExprListExp::pool_size = 5;
  145814             : #else
  145815             : const unsigned SgExprListExp::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  145816             : #endif
  145817             : 
  145818             : #ifndef ROSE_ALLOC_MEMSET
  145819             : #  define ROSE_ALLOC_MEMSET 0
  145820             : #endif
  145821             : 
  145822             : #ifndef ROSE_PEDANTIC_ALLOC
  145823             : #  define ROSE_PEDANTIC_ALLOC 0
  145824             : #endif
  145825             : 
  145826             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  145827             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  145828             : #endif
  145829             : 
  145830             : #if !defined(SGNODE__ALL_POOLS)
  145831             : #define SGNODE__ALL_POOLS
  145832             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  145833             : #endif
  145834             : 
  145835             : SgExprListExp* SgExprListExp::next_node = nullptr;
  145836             : std::vector<unsigned char*> SgExprListExp::pools;
  145837             : 
  145838             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  145839             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  145840             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  145841             : // around this macro definition rather than each use).
  145842             : #ifndef ALLOC_MUTEX
  145843             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  145844             :         do {                                                                     \
  145845             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  145846             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  145847             :                 abort();                                                         \
  145848             :             }                                                                    \
  145849             :         } while (0);
  145850             : #endif
  145851             : 
  145852             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  145853             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  145854             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  145855             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  145856             : 
  145857             : /*! \brief New operator for SgExprListExp.
  145858             : 
  145859             :    This new operator implements memory pools to provide most efficent 
  145860             :    use of the heap within construction of large ASTs.
  145861             : 
  145862             : \internal The new and delete operators use the lower level C malloc/free
  145863             :    function calls for performance and to make sure that mixing of malloc/free
  145864             :    and new/delete by the used can be caught more readily.  This may change
  145865             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  145866             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  145867             :    deallocate memory allocated using ROSE_MALLOC.
  145868             : */
  145869       42610 : void *SgExprListExp::operator new ( size_t Size )
  145870             : {
  145871             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  145872             :      * returning or throwing an exception. */
  145873       42610 :     ALLOC_MUTEX(SgExprListExp, lock);
  145874             : 
  145875             : #if ROSE_ALLOC_TRACE == 2
  145876             : //    printf("SgExprListExp::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgExprListExp::next_node);
  145877             : #endif
  145878             : 
  145879             : #if USE_CPP_NEW_DELETE_OPERATORS
  145880             :     void *mem = ROSE_MALLOC(Size);
  145881             :     ALLOC_MUTEX(SgExprListExp, unlock);
  145882             :     return mem;
  145883             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  145884             : #if ROSE_PEDANTIC_ALLOC
  145885             :     ROSE_ASSERT(Size == sizeof(SgExprListExp));
  145886             : #else
  145887       42610 :     if (Size != sizeof(SgExprListExp)) {
  145888           0 :       void * object = ROSE_MALLOC(Size);
  145889           0 :       ALLOC_MUTEX(SgExprListExp, unlock);
  145890             :       return object;
  145891             :     }
  145892             : #endif
  145893             : 
  145894       42610 :     if (SgExprListExp::next_node == nullptr) {
  145895         286 :         SgExprListExp * alloc = (SgExprListExp*) ROSE_MALLOC ( SgExprListExp::pool_size * sizeof(SgExprListExp) );
  145896         286 :         ROSE_ASSERT(alloc != nullptr);
  145897             : 
  145898             : #if ROSE_ALLOC_TRACE == 2
  145899             : //        printf("SgExprListExp::alloc\n  block[%zi] = [ %p , %p [\n", SgExprListExp::pools.size(), alloc, alloc + SgExprListExp::pool_size);
  145900             : #endif
  145901             : 
  145902             : #if ROSE_ALLOC_MEMSET == 1
  145903             : #elif ROSE_ALLOC_MEMSET == 2
  145904             :         memset(alloc, 0x00, SgExprListExp::pool_size * sizeof(SgExprListExp));
  145905             : #elif ROSE_ALLOC_MEMSET == 3
  145906             :         memset(alloc, 0xAA, SgExprListExp::pool_size * sizeof(SgExprListExp));
  145907             : #endif
  145908      572000 :         for (unsigned i=0; i < SgExprListExp::pool_size-1; i++) {
  145909      571714 :           alloc[i].p_freepointer = &(alloc[i+1]);
  145910             :         }
  145911         286 :         alloc[SgExprListExp::pool_size-1].p_freepointer = nullptr;
  145912             : 
  145913         286 :         SgExprListExp::pools.push_back ( (unsigned char *) alloc );
  145914         286 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgExprListExp::pool_size * sizeof(SgExprListExp), V_SgExprListExp ) );
  145915         286 :         SgExprListExp::next_node = alloc;
  145916             :     }
  145917       42610 :     ROSE_ASSERT(SgExprListExp::next_node != nullptr);
  145918             : 
  145919       42610 :     SgExprListExp * object = SgExprListExp::next_node;
  145920       42610 :     SgExprListExp::next_node = (SgExprListExp*)(object->p_freepointer);
  145921             : 
  145922             : #if ROSE_ALLOC_TRACE == 2
  145923             :     printf("SgExprListExp::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgExprListExp::next_node);
  145924             : #endif
  145925             : 
  145926       42610 :     SgNode * fp = object->p_freepointer;
  145927             : #if ROSE_ALLOC_MEMSET == 1
  145928             : #elif ROSE_ALLOC_MEMSET == 2
  145929             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgExprListExp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  145930             : #elif ROSE_ALLOC_MEMSET == 3
  145931             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgExprListExp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  145932             : #endif
  145933       42610 :     object->p_freepointer = fp;
  145934             : 
  145935             : #if ROSE_ALLOC_TRACE == 2
  145936             : //    printf("SgExprListExp::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgExprListExp::next_node);
  145937             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  145938             :     Rose::MemPool::snapshot(oss.str());
  145939             :     alloc_trace_cnt++;
  145940             : #endif
  145941             : 
  145942       42610 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  145943             : 
  145944       42610 :     ALLOC_MUTEX(SgExprListExp, unlock);
  145945             : 
  145946             :     return object;
  145947             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  145948             : }
  145949             : 
  145950             : 
  145951             : 
  145952             : /*! \brief Delete operator for SgExprListExp.
  145953             : 
  145954             :    This delete operator implements deallocation using memory pools to 
  145955             :    provide most efficent use of the heap within construction of large ASTs.
  145956             : 
  145957             : \internal The new and delete operators use the lower level C malloc/free
  145958             :    function calls for performance and to make sure that mixing of malloc/free
  145959             :    and new/delete by the used can be caught more readily.  This may change
  145960             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  145961             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  145962             :    deallocate memory allocated using ROSE_MALLOC.
  145963             : */
  145964        8125 : void SgExprListExp::operator delete(void *Pointer, size_t Size)
  145965             : {
  145966             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  145967             :      * or throwing an exception. */
  145968        8125 :     ALLOC_MUTEX(SgExprListExp, lock);
  145969             : 
  145970             : #if USE_CPP_NEW_DELETE_OPERATORS
  145971             :     ROSE_FREE(Pointer);
  145972             : #else
  145973             : #if ROSE_PEDANTIC_ALLOC
  145974             :     ROSE_ASSERT(Size == sizeof(SgExprListExp));
  145975             : #else
  145976        8125 :     if (Size != sizeof(SgExprListExp)) {
  145977           0 :       ROSE_FREE(Pointer);
  145978           0 :       ALLOC_MUTEX(SgExprListExp, unlock);
  145979             :       return;
  145980             :     }
  145981             : #endif
  145982             : 
  145983        8125 :     SgExprListExp * object = (SgExprListExp*) Pointer;
  145984        8125 :     ROSE_ASSERT(object != nullptr);
  145985             : 
  145986             : #if ROSE_ALLOC_TRACE == 2
  145987             : //  printf("SgExprListExp::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgExprListExp::next_node);
  145988             :     printf("SgExprListExp::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgExprListExp::next_node);
  145989             : #endif
  145990             : 
  145991             : #if ROSE_PEDANTIC_ALLOC
  145992             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  145993             : #endif
  145994             : 
  145995             : #if ROSE_ALLOC_MEMSET == 1
  145996             : #elif ROSE_ALLOC_MEMSET == 2
  145997             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgExprListExp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  145998             : #elif ROSE_ALLOC_MEMSET == 3
  145999             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgExprListExp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  146000             : #endif
  146001             : 
  146002             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  146003             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  146004             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  146005             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  146006             : #else
  146007        8125 :     object->p_freepointer = SgExprListExp::next_node;
  146008        8125 :     SgExprListExp::next_node = object;
  146009             : #endif
  146010             : 
  146011             : #if ROSE_ALLOC_TRACE == 2
  146012             : //  printf("SgExprListExp::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgExprListExp::next_node);
  146013             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  146014             :     Rose::MemPool::snapshot(oss.str());
  146015             :     alloc_trace_cnt++;
  146016             : #endif
  146017             : 
  146018             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  146019             : 
  146020        8125 :     ALLOC_MUTEX(SgExprListExp, unlock);
  146021             : }
  146022             : 
  146023             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  146024             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  146025             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  146026             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  146027             : // Also, note comment below from Robb (copied from the Common.code file).
  146028             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  146029             : //
  146030             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  146031             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  146032             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  146033             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  146034             : #if 0
  146035             : void SgExprListExp::operator delete(void* pointer) { SgExprListExp::operator delete (pointer, sizeof(SgExprListExp)); };
  146036             : #endif
  146037             : /* #line 146038 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  146038             : 
  146039             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  146040             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  146041             : // obviously imply C++.
  146042             : 
  146043             : // This implements the support within ROSE for memory pools.  Memory pools
  146044             : // support the most condensed usage of memory within the construction of
  146045             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  146046             : // by a new operator written for each class.
  146047             : 
  146048             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  146049             :     // User wants multi-thread support and POSIX threads are available.
  146050             : #   include <pthread.h>
  146051             :     static pthread_mutex_t SgListExp_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  146052             : #else
  146053             :      // Cause synchronization to be skipped.
  146054             : #    ifndef ALLOC_MUTEX
  146055             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  146056             : #    endif
  146057             : #    ifdef _REENTRANT
  146058             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  146059             : #       ifdef _MSC_VER
  146060             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  146061             : #       else
  146062             : #           warning "POSIX threads are not available; synchronization being skipped"
  146063             : #       endif
  146064             : #    endif
  146065             : #endif
  146066             : 
  146067             : #ifndef ROSE_ALLOC_TRACE
  146068             : #  define ROSE_ALLOC_TRACE 0
  146069             : #endif
  146070             : 
  146071             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  146072             : #define ROSE_ALLOC_TRACE_CNT
  146073             : #include "memory-pool-snapshot.h"
  146074             : unsigned long alloc_trace_cnt = 0;
  146075             : #endif
  146076             : 
  146077             : #if ROSE_ALLOC_TRACE
  146078             : const unsigned SgListExp::pool_size = 5;
  146079             : #else
  146080             : const unsigned SgListExp::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  146081             : #endif
  146082             : 
  146083             : #ifndef ROSE_ALLOC_MEMSET
  146084             : #  define ROSE_ALLOC_MEMSET 0
  146085             : #endif
  146086             : 
  146087             : #ifndef ROSE_PEDANTIC_ALLOC
  146088             : #  define ROSE_PEDANTIC_ALLOC 0
  146089             : #endif
  146090             : 
  146091             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  146092             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  146093             : #endif
  146094             : 
  146095             : #if !defined(SGNODE__ALL_POOLS)
  146096             : #define SGNODE__ALL_POOLS
  146097             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  146098             : #endif
  146099             : 
  146100             : SgListExp* SgListExp::next_node = nullptr;
  146101             : std::vector<unsigned char*> SgListExp::pools;
  146102             : 
  146103             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  146104             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  146105             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  146106             : // around this macro definition rather than each use).
  146107             : #ifndef ALLOC_MUTEX
  146108             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  146109             :         do {                                                                     \
  146110             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  146111             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  146112             :                 abort();                                                         \
  146113             :             }                                                                    \
  146114             :         } while (0);
  146115             : #endif
  146116             : 
  146117             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  146118             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  146119             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  146120             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  146121             : 
  146122             : /*! \brief New operator for SgListExp.
  146123             : 
  146124             :    This new operator implements memory pools to provide most efficent 
  146125             :    use of the heap within construction of large ASTs.
  146126             : 
  146127             : \internal The new and delete operators use the lower level C malloc/free
  146128             :    function calls for performance and to make sure that mixing of malloc/free
  146129             :    and new/delete by the used can be caught more readily.  This may change
  146130             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  146131             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  146132             :    deallocate memory allocated using ROSE_MALLOC.
  146133             : */
  146134           0 : void *SgListExp::operator new ( size_t Size )
  146135             : {
  146136             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  146137             :      * returning or throwing an exception. */
  146138           0 :     ALLOC_MUTEX(SgListExp, lock);
  146139             : 
  146140             : #if ROSE_ALLOC_TRACE == 2
  146141             : //    printf("SgListExp::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgListExp::next_node);
  146142             : #endif
  146143             : 
  146144             : #if USE_CPP_NEW_DELETE_OPERATORS
  146145             :     void *mem = ROSE_MALLOC(Size);
  146146             :     ALLOC_MUTEX(SgListExp, unlock);
  146147             :     return mem;
  146148             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  146149             : #if ROSE_PEDANTIC_ALLOC
  146150             :     ROSE_ASSERT(Size == sizeof(SgListExp));
  146151             : #else
  146152           0 :     if (Size != sizeof(SgListExp)) {
  146153           0 :       void * object = ROSE_MALLOC(Size);
  146154           0 :       ALLOC_MUTEX(SgListExp, unlock);
  146155             :       return object;
  146156             :     }
  146157             : #endif
  146158             : 
  146159           0 :     if (SgListExp::next_node == nullptr) {
  146160           0 :         SgListExp * alloc = (SgListExp*) ROSE_MALLOC ( SgListExp::pool_size * sizeof(SgListExp) );
  146161           0 :         ROSE_ASSERT(alloc != nullptr);
  146162             : 
  146163             : #if ROSE_ALLOC_TRACE == 2
  146164             : //        printf("SgListExp::alloc\n  block[%zi] = [ %p , %p [\n", SgListExp::pools.size(), alloc, alloc + SgListExp::pool_size);
  146165             : #endif
  146166             : 
  146167             : #if ROSE_ALLOC_MEMSET == 1
  146168             : #elif ROSE_ALLOC_MEMSET == 2
  146169             :         memset(alloc, 0x00, SgListExp::pool_size * sizeof(SgListExp));
  146170             : #elif ROSE_ALLOC_MEMSET == 3
  146171             :         memset(alloc, 0xAA, SgListExp::pool_size * sizeof(SgListExp));
  146172             : #endif
  146173           0 :         for (unsigned i=0; i < SgListExp::pool_size-1; i++) {
  146174           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
  146175             :         }
  146176           0 :         alloc[SgListExp::pool_size-1].p_freepointer = nullptr;
  146177             : 
  146178           0 :         SgListExp::pools.push_back ( (unsigned char *) alloc );
  146179           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgListExp::pool_size * sizeof(SgListExp), V_SgListExp ) );
  146180           0 :         SgListExp::next_node = alloc;
  146181             :     }
  146182           0 :     ROSE_ASSERT(SgListExp::next_node != nullptr);
  146183             : 
  146184           0 :     SgListExp * object = SgListExp::next_node;
  146185           0 :     SgListExp::next_node = (SgListExp*)(object->p_freepointer);
  146186             : 
  146187             : #if ROSE_ALLOC_TRACE == 2
  146188             :     printf("SgListExp::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgListExp::next_node);
  146189             : #endif
  146190             : 
  146191           0 :     SgNode * fp = object->p_freepointer;
  146192             : #if ROSE_ALLOC_MEMSET == 1
  146193             : #elif ROSE_ALLOC_MEMSET == 2
  146194             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgListExp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  146195             : #elif ROSE_ALLOC_MEMSET == 3
  146196             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgListExp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  146197             : #endif
  146198           0 :     object->p_freepointer = fp;
  146199             : 
  146200             : #if ROSE_ALLOC_TRACE == 2
  146201             : //    printf("SgListExp::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgListExp::next_node);
  146202             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  146203             :     Rose::MemPool::snapshot(oss.str());
  146204             :     alloc_trace_cnt++;
  146205             : #endif
  146206             : 
  146207           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  146208             : 
  146209           0 :     ALLOC_MUTEX(SgListExp, unlock);
  146210             : 
  146211             :     return object;
  146212             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  146213             : }
  146214             : 
  146215             : 
  146216             : 
  146217             : /*! \brief Delete operator for SgListExp.
  146218             : 
  146219             :    This delete operator implements deallocation using memory pools to 
  146220             :    provide most efficent use of the heap within construction of large ASTs.
  146221             : 
  146222             : \internal The new and delete operators use the lower level C malloc/free
  146223             :    function calls for performance and to make sure that mixing of malloc/free
  146224             :    and new/delete by the used can be caught more readily.  This may change
  146225             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  146226             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  146227             :    deallocate memory allocated using ROSE_MALLOC.
  146228             : */
  146229           0 : void SgListExp::operator delete(void *Pointer, size_t Size)
  146230             : {
  146231             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  146232             :      * or throwing an exception. */
  146233           0 :     ALLOC_MUTEX(SgListExp, lock);
  146234             : 
  146235             : #if USE_CPP_NEW_DELETE_OPERATORS
  146236             :     ROSE_FREE(Pointer);
  146237             : #else
  146238             : #if ROSE_PEDANTIC_ALLOC
  146239             :     ROSE_ASSERT(Size == sizeof(SgListExp));
  146240             : #else
  146241           0 :     if (Size != sizeof(SgListExp)) {
  146242           0 :       ROSE_FREE(Pointer);
  146243           0 :       ALLOC_MUTEX(SgListExp, unlock);
  146244             :       return;
  146245             :     }
  146246             : #endif
  146247             : 
  146248           0 :     SgListExp * object = (SgListExp*) Pointer;
  146249           0 :     ROSE_ASSERT(object != nullptr);
  146250             : 
  146251             : #if ROSE_ALLOC_TRACE == 2
  146252             : //  printf("SgListExp::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgListExp::next_node);
  146253             :     printf("SgListExp::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgListExp::next_node);
  146254             : #endif
  146255             : 
  146256             : #if ROSE_PEDANTIC_ALLOC
  146257             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  146258             : #endif
  146259             : 
  146260             : #if ROSE_ALLOC_MEMSET == 1
  146261             : #elif ROSE_ALLOC_MEMSET == 2
  146262             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgListExp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  146263             : #elif ROSE_ALLOC_MEMSET == 3
  146264             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgListExp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  146265             : #endif
  146266             : 
  146267             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  146268             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  146269             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  146270             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  146271             : #else
  146272           0 :     object->p_freepointer = SgListExp::next_node;
  146273           0 :     SgListExp::next_node = object;
  146274             : #endif
  146275             : 
  146276             : #if ROSE_ALLOC_TRACE == 2
  146277             : //  printf("SgListExp::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgListExp::next_node);
  146278             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  146279             :     Rose::MemPool::snapshot(oss.str());
  146280             :     alloc_trace_cnt++;
  146281             : #endif
  146282             : 
  146283             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  146284             : 
  146285           0 :     ALLOC_MUTEX(SgListExp, unlock);
  146286             : }
  146287             : 
  146288             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  146289             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  146290             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  146291             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  146292             : // Also, note comment below from Robb (copied from the Common.code file).
  146293             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  146294             : //
  146295             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  146296             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  146297             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  146298             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  146299             : #if 0
  146300             : void SgListExp::operator delete(void* pointer) { SgListExp::operator delete (pointer, sizeof(SgListExp)); };
  146301             : #endif
  146302             : /* #line 146303 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  146303             : 
  146304             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  146305             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  146306             : // obviously imply C++.
  146307             : 
  146308             : // This implements the support within ROSE for memory pools.  Memory pools
  146309             : // support the most condensed usage of memory within the construction of
  146310             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  146311             : // by a new operator written for each class.
  146312             : 
  146313             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  146314             :     // User wants multi-thread support and POSIX threads are available.
  146315             : #   include <pthread.h>
  146316             :     static pthread_mutex_t SgTupleExp_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  146317             : #else
  146318             :      // Cause synchronization to be skipped.
  146319             : #    ifndef ALLOC_MUTEX
  146320             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  146321             : #    endif
  146322             : #    ifdef _REENTRANT
  146323             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  146324             : #       ifdef _MSC_VER
  146325             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  146326             : #       else
  146327             : #           warning "POSIX threads are not available; synchronization being skipped"
  146328             : #       endif
  146329             : #    endif
  146330             : #endif
  146331             : 
  146332             : #ifndef ROSE_ALLOC_TRACE
  146333             : #  define ROSE_ALLOC_TRACE 0
  146334             : #endif
  146335             : 
  146336             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  146337             : #define ROSE_ALLOC_TRACE_CNT
  146338             : #include "memory-pool-snapshot.h"
  146339             : unsigned long alloc_trace_cnt = 0;
  146340             : #endif
  146341             : 
  146342             : #if ROSE_ALLOC_TRACE
  146343             : const unsigned SgTupleExp::pool_size = 5;
  146344             : #else
  146345             : const unsigned SgTupleExp::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  146346             : #endif
  146347             : 
  146348             : #ifndef ROSE_ALLOC_MEMSET
  146349             : #  define ROSE_ALLOC_MEMSET 0
  146350             : #endif
  146351             : 
  146352             : #ifndef ROSE_PEDANTIC_ALLOC
  146353             : #  define ROSE_PEDANTIC_ALLOC 0
  146354             : #endif
  146355             : 
  146356             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  146357             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  146358             : #endif
  146359             : 
  146360             : #if !defined(SGNODE__ALL_POOLS)
  146361             : #define SGNODE__ALL_POOLS
  146362             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  146363             : #endif
  146364             : 
  146365             : SgTupleExp* SgTupleExp::next_node = nullptr;
  146366             : std::vector<unsigned char*> SgTupleExp::pools;
  146367             : 
  146368             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  146369             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  146370             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  146371             : // around this macro definition rather than each use).
  146372             : #ifndef ALLOC_MUTEX
  146373             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  146374             :         do {                                                                     \
  146375             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  146376             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  146377             :                 abort();                                                         \
  146378             :             }                                                                    \
  146379             :         } while (0);
  146380             : #endif
  146381             : 
  146382             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  146383             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  146384             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  146385             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  146386             : 
  146387             : /*! \brief New operator for SgTupleExp.
  146388             : 
  146389             :    This new operator implements memory pools to provide most efficent 
  146390             :    use of the heap within construction of large ASTs.
  146391             : 
  146392             : \internal The new and delete operators use the lower level C malloc/free
  146393             :    function calls for performance and to make sure that mixing of malloc/free
  146394             :    and new/delete by the used can be caught more readily.  This may change
  146395             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  146396             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  146397             :    deallocate memory allocated using ROSE_MALLOC.
  146398             : */
  146399           0 : void *SgTupleExp::operator new ( size_t Size )
  146400             : {
  146401             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  146402             :      * returning or throwing an exception. */
  146403           0 :     ALLOC_MUTEX(SgTupleExp, lock);
  146404             : 
  146405             : #if ROSE_ALLOC_TRACE == 2
  146406             : //    printf("SgTupleExp::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgTupleExp::next_node);
  146407             : #endif
  146408             : 
  146409             : #if USE_CPP_NEW_DELETE_OPERATORS
  146410             :     void *mem = ROSE_MALLOC(Size);
  146411             :     ALLOC_MUTEX(SgTupleExp, unlock);
  146412             :     return mem;
  146413             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  146414             : #if ROSE_PEDANTIC_ALLOC
  146415             :     ROSE_ASSERT(Size == sizeof(SgTupleExp));
  146416             : #else
  146417           0 :     if (Size != sizeof(SgTupleExp)) {
  146418           0 :       void * object = ROSE_MALLOC(Size);
  146419           0 :       ALLOC_MUTEX(SgTupleExp, unlock);
  146420             :       return object;
  146421             :     }
  146422             : #endif
  146423             : 
  146424           0 :     if (SgTupleExp::next_node == nullptr) {
  146425           0 :         SgTupleExp * alloc = (SgTupleExp*) ROSE_MALLOC ( SgTupleExp::pool_size * sizeof(SgTupleExp) );
  146426           0 :         ROSE_ASSERT(alloc != nullptr);
  146427             : 
  146428             : #if ROSE_ALLOC_TRACE == 2
  146429             : //        printf("SgTupleExp::alloc\n  block[%zi] = [ %p , %p [\n", SgTupleExp::pools.size(), alloc, alloc + SgTupleExp::pool_size);
  146430             : #endif
  146431             : 
  146432             : #if ROSE_ALLOC_MEMSET == 1
  146433             : #elif ROSE_ALLOC_MEMSET == 2
  146434             :         memset(alloc, 0x00, SgTupleExp::pool_size * sizeof(SgTupleExp));
  146435             : #elif ROSE_ALLOC_MEMSET == 3
  146436             :         memset(alloc, 0xAA, SgTupleExp::pool_size * sizeof(SgTupleExp));
  146437             : #endif
  146438           0 :         for (unsigned i=0; i < SgTupleExp::pool_size-1; i++) {
  146439           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
  146440             :         }
  146441           0 :         alloc[SgTupleExp::pool_size-1].p_freepointer = nullptr;
  146442             : 
  146443           0 :         SgTupleExp::pools.push_back ( (unsigned char *) alloc );
  146444           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgTupleExp::pool_size * sizeof(SgTupleExp), V_SgTupleExp ) );
  146445           0 :         SgTupleExp::next_node = alloc;
  146446             :     }
  146447           0 :     ROSE_ASSERT(SgTupleExp::next_node != nullptr);
  146448             : 
  146449           0 :     SgTupleExp * object = SgTupleExp::next_node;
  146450           0 :     SgTupleExp::next_node = (SgTupleExp*)(object->p_freepointer);
  146451             : 
  146452             : #if ROSE_ALLOC_TRACE == 2
  146453             :     printf("SgTupleExp::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTupleExp::next_node);
  146454             : #endif
  146455             : 
  146456           0 :     SgNode * fp = object->p_freepointer;
  146457             : #if ROSE_ALLOC_MEMSET == 1
  146458             : #elif ROSE_ALLOC_MEMSET == 2
  146459             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgTupleExp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  146460             : #elif ROSE_ALLOC_MEMSET == 3
  146461             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgTupleExp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  146462             : #endif
  146463           0 :     object->p_freepointer = fp;
  146464             : 
  146465             : #if ROSE_ALLOC_TRACE == 2
  146466             : //    printf("SgTupleExp::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTupleExp::next_node);
  146467             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  146468             :     Rose::MemPool::snapshot(oss.str());
  146469             :     alloc_trace_cnt++;
  146470             : #endif
  146471             : 
  146472           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  146473             : 
  146474           0 :     ALLOC_MUTEX(SgTupleExp, unlock);
  146475             : 
  146476             :     return object;
  146477             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  146478             : }
  146479             : 
  146480             : 
  146481             : 
  146482             : /*! \brief Delete operator for SgTupleExp.
  146483             : 
  146484             :    This delete operator implements deallocation using memory pools to 
  146485             :    provide most efficent use of the heap within construction of large ASTs.
  146486             : 
  146487             : \internal The new and delete operators use the lower level C malloc/free
  146488             :    function calls for performance and to make sure that mixing of malloc/free
  146489             :    and new/delete by the used can be caught more readily.  This may change
  146490             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  146491             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  146492             :    deallocate memory allocated using ROSE_MALLOC.
  146493             : */
  146494           0 : void SgTupleExp::operator delete(void *Pointer, size_t Size)
  146495             : {
  146496             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  146497             :      * or throwing an exception. */
  146498           0 :     ALLOC_MUTEX(SgTupleExp, lock);
  146499             : 
  146500             : #if USE_CPP_NEW_DELETE_OPERATORS
  146501             :     ROSE_FREE(Pointer);
  146502             : #else
  146503             : #if ROSE_PEDANTIC_ALLOC
  146504             :     ROSE_ASSERT(Size == sizeof(SgTupleExp));
  146505             : #else
  146506           0 :     if (Size != sizeof(SgTupleExp)) {
  146507           0 :       ROSE_FREE(Pointer);
  146508           0 :       ALLOC_MUTEX(SgTupleExp, unlock);
  146509             :       return;
  146510             :     }
  146511             : #endif
  146512             : 
  146513           0 :     SgTupleExp * object = (SgTupleExp*) Pointer;
  146514           0 :     ROSE_ASSERT(object != nullptr);
  146515             : 
  146516             : #if ROSE_ALLOC_TRACE == 2
  146517             : //  printf("SgTupleExp::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTupleExp::next_node);
  146518             :     printf("SgTupleExp::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTupleExp::next_node);
  146519             : #endif
  146520             : 
  146521             : #if ROSE_PEDANTIC_ALLOC
  146522             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  146523             : #endif
  146524             : 
  146525             : #if ROSE_ALLOC_MEMSET == 1
  146526             : #elif ROSE_ALLOC_MEMSET == 2
  146527             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgTupleExp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  146528             : #elif ROSE_ALLOC_MEMSET == 3
  146529             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgTupleExp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  146530             : #endif
  146531             : 
  146532             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  146533             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  146534             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  146535             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  146536             : #else
  146537           0 :     object->p_freepointer = SgTupleExp::next_node;
  146538           0 :     SgTupleExp::next_node = object;
  146539             : #endif
  146540             : 
  146541             : #if ROSE_ALLOC_TRACE == 2
  146542             : //  printf("SgTupleExp::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTupleExp::next_node);
  146543             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  146544             :     Rose::MemPool::snapshot(oss.str());
  146545             :     alloc_trace_cnt++;
  146546             : #endif
  146547             : 
  146548             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  146549             : 
  146550           0 :     ALLOC_MUTEX(SgTupleExp, unlock);
  146551             : }
  146552             : 
  146553             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  146554             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  146555             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  146556             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  146557             : // Also, note comment below from Robb (copied from the Common.code file).
  146558             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  146559             : //
  146560             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  146561             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  146562             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  146563             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  146564             : #if 0
  146565             : void SgTupleExp::operator delete(void* pointer) { SgTupleExp::operator delete (pointer, sizeof(SgTupleExp)); };
  146566             : #endif
  146567             : /* #line 146568 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  146568             : 
  146569             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  146570             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  146571             : // obviously imply C++.
  146572             : 
  146573             : // This implements the support within ROSE for memory pools.  Memory pools
  146574             : // support the most condensed usage of memory within the construction of
  146575             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  146576             : // by a new operator written for each class.
  146577             : 
  146578             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  146579             :     // User wants multi-thread support and POSIX threads are available.
  146580             : #   include <pthread.h>
  146581             :     static pthread_mutex_t SgMatrixExp_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  146582             : #else
  146583             :      // Cause synchronization to be skipped.
  146584             : #    ifndef ALLOC_MUTEX
  146585             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  146586             : #    endif
  146587             : #    ifdef _REENTRANT
  146588             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  146589             : #       ifdef _MSC_VER
  146590             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  146591             : #       else
  146592             : #           warning "POSIX threads are not available; synchronization being skipped"
  146593             : #       endif
  146594             : #    endif
  146595             : #endif
  146596             : 
  146597             : #ifndef ROSE_ALLOC_TRACE
  146598             : #  define ROSE_ALLOC_TRACE 0
  146599             : #endif
  146600             : 
  146601             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  146602             : #define ROSE_ALLOC_TRACE_CNT
  146603             : #include "memory-pool-snapshot.h"
  146604             : unsigned long alloc_trace_cnt = 0;
  146605             : #endif
  146606             : 
  146607             : #if ROSE_ALLOC_TRACE
  146608             : const unsigned SgMatrixExp::pool_size = 5;
  146609             : #else
  146610             : const unsigned SgMatrixExp::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  146611             : #endif
  146612             : 
  146613             : #ifndef ROSE_ALLOC_MEMSET
  146614             : #  define ROSE_ALLOC_MEMSET 0
  146615             : #endif
  146616             : 
  146617             : #ifndef ROSE_PEDANTIC_ALLOC
  146618             : #  define ROSE_PEDANTIC_ALLOC 0
  146619             : #endif
  146620             : 
  146621             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  146622             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  146623             : #endif
  146624             : 
  146625             : #if !defined(SGNODE__ALL_POOLS)
  146626             : #define SGNODE__ALL_POOLS
  146627             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  146628             : #endif
  146629             : 
  146630             : SgMatrixExp* SgMatrixExp::next_node = nullptr;
  146631             : std::vector<unsigned char*> SgMatrixExp::pools;
  146632             : 
  146633             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  146634             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  146635             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  146636             : // around this macro definition rather than each use).
  146637             : #ifndef ALLOC_MUTEX
  146638             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  146639             :         do {                                                                     \
  146640             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  146641             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  146642             :                 abort();                                                         \
  146643             :             }                                                                    \
  146644             :         } while (0);
  146645             : #endif
  146646             : 
  146647             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  146648             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  146649             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  146650             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  146651             : 
  146652             : /*! \brief New operator for SgMatrixExp.
  146653             : 
  146654             :    This new operator implements memory pools to provide most efficent 
  146655             :    use of the heap within construction of large ASTs.
  146656             : 
  146657             : \internal The new and delete operators use the lower level C malloc/free
  146658             :    function calls for performance and to make sure that mixing of malloc/free
  146659             :    and new/delete by the used can be caught more readily.  This may change
  146660             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  146661             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  146662             :    deallocate memory allocated using ROSE_MALLOC.
  146663             : */
  146664           0 : void *SgMatrixExp::operator new ( size_t Size )
  146665             : {
  146666             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  146667             :      * returning or throwing an exception. */
  146668           0 :     ALLOC_MUTEX(SgMatrixExp, lock);
  146669             : 
  146670             : #if ROSE_ALLOC_TRACE == 2
  146671             : //    printf("SgMatrixExp::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgMatrixExp::next_node);
  146672             : #endif
  146673             : 
  146674             : #if USE_CPP_NEW_DELETE_OPERATORS
  146675             :     void *mem = ROSE_MALLOC(Size);
  146676             :     ALLOC_MUTEX(SgMatrixExp, unlock);
  146677             :     return mem;
  146678             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  146679             : #if ROSE_PEDANTIC_ALLOC
  146680             :     ROSE_ASSERT(Size == sizeof(SgMatrixExp));
  146681             : #else
  146682           0 :     if (Size != sizeof(SgMatrixExp)) {
  146683           0 :       void * object = ROSE_MALLOC(Size);
  146684           0 :       ALLOC_MUTEX(SgMatrixExp, unlock);
  146685             :       return object;
  146686             :     }
  146687             : #endif
  146688             : 
  146689           0 :     if (SgMatrixExp::next_node == nullptr) {
  146690           0 :         SgMatrixExp * alloc = (SgMatrixExp*) ROSE_MALLOC ( SgMatrixExp::pool_size * sizeof(SgMatrixExp) );
  146691           0 :         ROSE_ASSERT(alloc != nullptr);
  146692             : 
  146693             : #if ROSE_ALLOC_TRACE == 2
  146694             : //        printf("SgMatrixExp::alloc\n  block[%zi] = [ %p , %p [\n", SgMatrixExp::pools.size(), alloc, alloc + SgMatrixExp::pool_size);
  146695             : #endif
  146696             : 
  146697             : #if ROSE_ALLOC_MEMSET == 1
  146698             : #elif ROSE_ALLOC_MEMSET == 2
  146699             :         memset(alloc, 0x00, SgMatrixExp::pool_size * sizeof(SgMatrixExp));
  146700             : #elif ROSE_ALLOC_MEMSET == 3
  146701             :         memset(alloc, 0xAA, SgMatrixExp::pool_size * sizeof(SgMatrixExp));
  146702             : #endif
  146703           0 :         for (unsigned i=0; i < SgMatrixExp::pool_size-1; i++) {
  146704           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
  146705             :         }
  146706           0 :         alloc[SgMatrixExp::pool_size-1].p_freepointer = nullptr;
  146707             : 
  146708           0 :         SgMatrixExp::pools.push_back ( (unsigned char *) alloc );
  146709           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgMatrixExp::pool_size * sizeof(SgMatrixExp), V_SgMatrixExp ) );
  146710           0 :         SgMatrixExp::next_node = alloc;
  146711             :     }
  146712           0 :     ROSE_ASSERT(SgMatrixExp::next_node != nullptr);
  146713             : 
  146714           0 :     SgMatrixExp * object = SgMatrixExp::next_node;
  146715           0 :     SgMatrixExp::next_node = (SgMatrixExp*)(object->p_freepointer);
  146716             : 
  146717             : #if ROSE_ALLOC_TRACE == 2
  146718             :     printf("SgMatrixExp::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgMatrixExp::next_node);
  146719             : #endif
  146720             : 
  146721           0 :     SgNode * fp = object->p_freepointer;
  146722             : #if ROSE_ALLOC_MEMSET == 1
  146723             : #elif ROSE_ALLOC_MEMSET == 2
  146724             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgMatrixExp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  146725             : #elif ROSE_ALLOC_MEMSET == 3
  146726             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgMatrixExp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  146727             : #endif
  146728           0 :     object->p_freepointer = fp;
  146729             : 
  146730             : #if ROSE_ALLOC_TRACE == 2
  146731             : //    printf("SgMatrixExp::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgMatrixExp::next_node);
  146732             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  146733             :     Rose::MemPool::snapshot(oss.str());
  146734             :     alloc_trace_cnt++;
  146735             : #endif
  146736             : 
  146737           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  146738             : 
  146739           0 :     ALLOC_MUTEX(SgMatrixExp, unlock);
  146740             : 
  146741             :     return object;
  146742             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  146743             : }
  146744             : 
  146745             : 
  146746             : 
  146747             : /*! \brief Delete operator for SgMatrixExp.
  146748             : 
  146749             :    This delete operator implements deallocation using memory pools to 
  146750             :    provide most efficent use of the heap within construction of large ASTs.
  146751             : 
  146752             : \internal The new and delete operators use the lower level C malloc/free
  146753             :    function calls for performance and to make sure that mixing of malloc/free
  146754             :    and new/delete by the used can be caught more readily.  This may change
  146755             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  146756             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  146757             :    deallocate memory allocated using ROSE_MALLOC.
  146758             : */
  146759           0 : void SgMatrixExp::operator delete(void *Pointer, size_t Size)
  146760             : {
  146761             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  146762             :      * or throwing an exception. */
  146763           0 :     ALLOC_MUTEX(SgMatrixExp, lock);
  146764             : 
  146765             : #if USE_CPP_NEW_DELETE_OPERATORS
  146766             :     ROSE_FREE(Pointer);
  146767             : #else
  146768             : #if ROSE_PEDANTIC_ALLOC
  146769             :     ROSE_ASSERT(Size == sizeof(SgMatrixExp));
  146770             : #else
  146771           0 :     if (Size != sizeof(SgMatrixExp)) {
  146772           0 :       ROSE_FREE(Pointer);
  146773           0 :       ALLOC_MUTEX(SgMatrixExp, unlock);
  146774             :       return;
  146775             :     }
  146776             : #endif
  146777             : 
  146778           0 :     SgMatrixExp * object = (SgMatrixExp*) Pointer;
  146779           0 :     ROSE_ASSERT(object != nullptr);
  146780             : 
  146781             : #if ROSE_ALLOC_TRACE == 2
  146782             : //  printf("SgMatrixExp::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgMatrixExp::next_node);
  146783             :     printf("SgMatrixExp::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgMatrixExp::next_node);
  146784             : #endif
  146785             : 
  146786             : #if ROSE_PEDANTIC_ALLOC
  146787             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  146788             : #endif
  146789             : 
  146790             : #if ROSE_ALLOC_MEMSET == 1
  146791             : #elif ROSE_ALLOC_MEMSET == 2
  146792             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgMatrixExp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  146793             : #elif ROSE_ALLOC_MEMSET == 3
  146794             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgMatrixExp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  146795             : #endif
  146796             : 
  146797             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  146798             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  146799             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  146800             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  146801             : #else
  146802           0 :     object->p_freepointer = SgMatrixExp::next_node;
  146803           0 :     SgMatrixExp::next_node = object;
  146804             : #endif
  146805             : 
  146806             : #if ROSE_ALLOC_TRACE == 2
  146807             : //  printf("SgMatrixExp::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgMatrixExp::next_node);
  146808             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  146809             :     Rose::MemPool::snapshot(oss.str());
  146810             :     alloc_trace_cnt++;
  146811             : #endif
  146812             : 
  146813             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  146814             : 
  146815           0 :     ALLOC_MUTEX(SgMatrixExp, unlock);
  146816             : }
  146817             : 
  146818             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  146819             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  146820             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  146821             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  146822             : // Also, note comment below from Robb (copied from the Common.code file).
  146823             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  146824             : //
  146825             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  146826             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  146827             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  146828             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  146829             : #if 0
  146830             : void SgMatrixExp::operator delete(void* pointer) { SgMatrixExp::operator delete (pointer, sizeof(SgMatrixExp)); };
  146831             : #endif
  146832             : /* #line 146833 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  146833             : 
  146834             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  146835             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  146836             : // obviously imply C++.
  146837             : 
  146838             : // This implements the support within ROSE for memory pools.  Memory pools
  146839             : // support the most condensed usage of memory within the construction of
  146840             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  146841             : // by a new operator written for each class.
  146842             : 
  146843             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  146844             :     // User wants multi-thread support and POSIX threads are available.
  146845             : #   include <pthread.h>
  146846             :     static pthread_mutex_t SgVarRefExp_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  146847             : #else
  146848             :      // Cause synchronization to be skipped.
  146849             : #    ifndef ALLOC_MUTEX
  146850             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  146851             : #    endif
  146852             : #    ifdef _REENTRANT
  146853             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  146854             : #       ifdef _MSC_VER
  146855             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  146856             : #       else
  146857             : #           warning "POSIX threads are not available; synchronization being skipped"
  146858             : #       endif
  146859             : #    endif
  146860             : #endif
  146861             : 
  146862             : #ifndef ROSE_ALLOC_TRACE
  146863             : #  define ROSE_ALLOC_TRACE 0
  146864             : #endif
  146865             : 
  146866             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  146867             : #define ROSE_ALLOC_TRACE_CNT
  146868             : #include "memory-pool-snapshot.h"
  146869             : unsigned long alloc_trace_cnt = 0;
  146870             : #endif
  146871             : 
  146872             : #if ROSE_ALLOC_TRACE
  146873             : const unsigned SgVarRefExp::pool_size = 5;
  146874             : #else
  146875             : const unsigned SgVarRefExp::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  146876             : #endif
  146877             : 
  146878             : #ifndef ROSE_ALLOC_MEMSET
  146879             : #  define ROSE_ALLOC_MEMSET 0
  146880             : #endif
  146881             : 
  146882             : #ifndef ROSE_PEDANTIC_ALLOC
  146883             : #  define ROSE_PEDANTIC_ALLOC 0
  146884             : #endif
  146885             : 
  146886             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  146887             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  146888             : #endif
  146889             : 
  146890             : #if !defined(SGNODE__ALL_POOLS)
  146891             : #define SGNODE__ALL_POOLS
  146892             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  146893             : #endif
  146894             : 
  146895             : SgVarRefExp* SgVarRefExp::next_node = nullptr;
  146896             : std::vector<unsigned char*> SgVarRefExp::pools;
  146897             : 
  146898             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  146899             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  146900             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  146901             : // around this macro definition rather than each use).
  146902             : #ifndef ALLOC_MUTEX
  146903             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  146904             :         do {                                                                     \
  146905             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  146906             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  146907             :                 abort();                                                         \
  146908             :             }                                                                    \
  146909             :         } while (0);
  146910             : #endif
  146911             : 
  146912             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  146913             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  146914             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  146915             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  146916             : 
  146917             : /*! \brief New operator for SgVarRefExp.
  146918             : 
  146919             :    This new operator implements memory pools to provide most efficent 
  146920             :    use of the heap within construction of large ASTs.
  146921             : 
  146922             : \internal The new and delete operators use the lower level C malloc/free
  146923             :    function calls for performance and to make sure that mixing of malloc/free
  146924             :    and new/delete by the used can be caught more readily.  This may change
  146925             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  146926             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  146927             :    deallocate memory allocated using ROSE_MALLOC.
  146928             : */
  146929       82556 : void *SgVarRefExp::operator new ( size_t Size )
  146930             : {
  146931             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  146932             :      * returning or throwing an exception. */
  146933       82556 :     ALLOC_MUTEX(SgVarRefExp, lock);
  146934             : 
  146935             : #if ROSE_ALLOC_TRACE == 2
  146936             : //    printf("SgVarRefExp::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgVarRefExp::next_node);
  146937             : #endif
  146938             : 
  146939             : #if USE_CPP_NEW_DELETE_OPERATORS
  146940             :     void *mem = ROSE_MALLOC(Size);
  146941             :     ALLOC_MUTEX(SgVarRefExp, unlock);
  146942             :     return mem;
  146943             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  146944             : #if ROSE_PEDANTIC_ALLOC
  146945             :     ROSE_ASSERT(Size == sizeof(SgVarRefExp));
  146946             : #else
  146947       82556 :     if (Size != sizeof(SgVarRefExp)) {
  146948           0 :       void * object = ROSE_MALLOC(Size);
  146949           0 :       ALLOC_MUTEX(SgVarRefExp, unlock);
  146950             :       return object;
  146951             :     }
  146952             : #endif
  146953             : 
  146954       82556 :     if (SgVarRefExp::next_node == nullptr) {
  146955         331 :         SgVarRefExp * alloc = (SgVarRefExp*) ROSE_MALLOC ( SgVarRefExp::pool_size * sizeof(SgVarRefExp) );
  146956         331 :         ROSE_ASSERT(alloc != nullptr);
  146957             : 
  146958             : #if ROSE_ALLOC_TRACE == 2
  146959             : //        printf("SgVarRefExp::alloc\n  block[%zi] = [ %p , %p [\n", SgVarRefExp::pools.size(), alloc, alloc + SgVarRefExp::pool_size);
  146960             : #endif
  146961             : 
  146962             : #if ROSE_ALLOC_MEMSET == 1
  146963             : #elif ROSE_ALLOC_MEMSET == 2
  146964             :         memset(alloc, 0x00, SgVarRefExp::pool_size * sizeof(SgVarRefExp));
  146965             : #elif ROSE_ALLOC_MEMSET == 3
  146966             :         memset(alloc, 0xAA, SgVarRefExp::pool_size * sizeof(SgVarRefExp));
  146967             : #endif
  146968      662000 :         for (unsigned i=0; i < SgVarRefExp::pool_size-1; i++) {
  146969      661669 :           alloc[i].p_freepointer = &(alloc[i+1]);
  146970             :         }
  146971         331 :         alloc[SgVarRefExp::pool_size-1].p_freepointer = nullptr;
  146972             : 
  146973         331 :         SgVarRefExp::pools.push_back ( (unsigned char *) alloc );
  146974         331 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgVarRefExp::pool_size * sizeof(SgVarRefExp), V_SgVarRefExp ) );
  146975         331 :         SgVarRefExp::next_node = alloc;
  146976             :     }
  146977       82556 :     ROSE_ASSERT(SgVarRefExp::next_node != nullptr);
  146978             : 
  146979       82556 :     SgVarRefExp * object = SgVarRefExp::next_node;
  146980       82556 :     SgVarRefExp::next_node = (SgVarRefExp*)(object->p_freepointer);
  146981             : 
  146982             : #if ROSE_ALLOC_TRACE == 2
  146983             :     printf("SgVarRefExp::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgVarRefExp::next_node);
  146984             : #endif
  146985             : 
  146986       82556 :     SgNode * fp = object->p_freepointer;
  146987             : #if ROSE_ALLOC_MEMSET == 1
  146988             : #elif ROSE_ALLOC_MEMSET == 2
  146989             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgVarRefExp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  146990             : #elif ROSE_ALLOC_MEMSET == 3
  146991             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgVarRefExp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  146992             : #endif
  146993       82556 :     object->p_freepointer = fp;
  146994             : 
  146995             : #if ROSE_ALLOC_TRACE == 2
  146996             : //    printf("SgVarRefExp::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgVarRefExp::next_node);
  146997             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  146998             :     Rose::MemPool::snapshot(oss.str());
  146999             :     alloc_trace_cnt++;
  147000             : #endif
  147001             : 
  147002       82556 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  147003             : 
  147004       82556 :     ALLOC_MUTEX(SgVarRefExp, unlock);
  147005             : 
  147006             :     return object;
  147007             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  147008             : }
  147009             : 
  147010             : 
  147011             : 
  147012             : /*! \brief Delete operator for SgVarRefExp.
  147013             : 
  147014             :    This delete operator implements deallocation using memory pools to 
  147015             :    provide most efficent use of the heap within construction of large ASTs.
  147016             : 
  147017             : \internal The new and delete operators use the lower level C malloc/free
  147018             :    function calls for performance and to make sure that mixing of malloc/free
  147019             :    and new/delete by the used can be caught more readily.  This may change
  147020             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  147021             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  147022             :    deallocate memory allocated using ROSE_MALLOC.
  147023             : */
  147024       16805 : void SgVarRefExp::operator delete(void *Pointer, size_t Size)
  147025             : {
  147026             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  147027             :      * or throwing an exception. */
  147028       16805 :     ALLOC_MUTEX(SgVarRefExp, lock);
  147029             : 
  147030             : #if USE_CPP_NEW_DELETE_OPERATORS
  147031             :     ROSE_FREE(Pointer);
  147032             : #else
  147033             : #if ROSE_PEDANTIC_ALLOC
  147034             :     ROSE_ASSERT(Size == sizeof(SgVarRefExp));
  147035             : #else
  147036       16805 :     if (Size != sizeof(SgVarRefExp)) {
  147037           0 :       ROSE_FREE(Pointer);
  147038           0 :       ALLOC_MUTEX(SgVarRefExp, unlock);
  147039             :       return;
  147040             :     }
  147041             : #endif
  147042             : 
  147043       16805 :     SgVarRefExp * object = (SgVarRefExp*) Pointer;
  147044       16805 :     ROSE_ASSERT(object != nullptr);
  147045             : 
  147046             : #if ROSE_ALLOC_TRACE == 2
  147047             : //  printf("SgVarRefExp::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgVarRefExp::next_node);
  147048             :     printf("SgVarRefExp::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgVarRefExp::next_node);
  147049             : #endif
  147050             : 
  147051             : #if ROSE_PEDANTIC_ALLOC
  147052             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  147053             : #endif
  147054             : 
  147055             : #if ROSE_ALLOC_MEMSET == 1
  147056             : #elif ROSE_ALLOC_MEMSET == 2
  147057             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgVarRefExp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  147058             : #elif ROSE_ALLOC_MEMSET == 3
  147059             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgVarRefExp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  147060             : #endif
  147061             : 
  147062             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  147063             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  147064             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  147065             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  147066             : #else
  147067       16805 :     object->p_freepointer = SgVarRefExp::next_node;
  147068       16805 :     SgVarRefExp::next_node = object;
  147069             : #endif
  147070             : 
  147071             : #if ROSE_ALLOC_TRACE == 2
  147072             : //  printf("SgVarRefExp::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgVarRefExp::next_node);
  147073             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  147074             :     Rose::MemPool::snapshot(oss.str());
  147075             :     alloc_trace_cnt++;
  147076             : #endif
  147077             : 
  147078             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  147079             : 
  147080       16805 :     ALLOC_MUTEX(SgVarRefExp, unlock);
  147081             : }
  147082             : 
  147083             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  147084             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  147085             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  147086             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  147087             : // Also, note comment below from Robb (copied from the Common.code file).
  147088             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  147089             : //
  147090             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  147091             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  147092             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  147093             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  147094             : #if 0
  147095             : void SgVarRefExp::operator delete(void* pointer) { SgVarRefExp::operator delete (pointer, sizeof(SgVarRefExp)); };
  147096             : #endif
  147097             : /* #line 147098 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  147098             : 
  147099             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  147100             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  147101             : // obviously imply C++.
  147102             : 
  147103             : // This implements the support within ROSE for memory pools.  Memory pools
  147104             : // support the most condensed usage of memory within the construction of
  147105             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  147106             : // by a new operator written for each class.
  147107             : 
  147108             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  147109             :     // User wants multi-thread support and POSIX threads are available.
  147110             : #   include <pthread.h>
  147111             :     static pthread_mutex_t SgClassNameRefExp_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  147112             : #else
  147113             :      // Cause synchronization to be skipped.
  147114             : #    ifndef ALLOC_MUTEX
  147115             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  147116             : #    endif
  147117             : #    ifdef _REENTRANT
  147118             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  147119             : #       ifdef _MSC_VER
  147120             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  147121             : #       else
  147122             : #           warning "POSIX threads are not available; synchronization being skipped"
  147123             : #       endif
  147124             : #    endif
  147125             : #endif
  147126             : 
  147127             : #ifndef ROSE_ALLOC_TRACE
  147128             : #  define ROSE_ALLOC_TRACE 0
  147129             : #endif
  147130             : 
  147131             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  147132             : #define ROSE_ALLOC_TRACE_CNT
  147133             : #include "memory-pool-snapshot.h"
  147134             : unsigned long alloc_trace_cnt = 0;
  147135             : #endif
  147136             : 
  147137             : #if ROSE_ALLOC_TRACE
  147138             : const unsigned SgClassNameRefExp::pool_size = 5;
  147139             : #else
  147140             : const unsigned SgClassNameRefExp::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  147141             : #endif
  147142             : 
  147143             : #ifndef ROSE_ALLOC_MEMSET
  147144             : #  define ROSE_ALLOC_MEMSET 0
  147145             : #endif
  147146             : 
  147147             : #ifndef ROSE_PEDANTIC_ALLOC
  147148             : #  define ROSE_PEDANTIC_ALLOC 0
  147149             : #endif
  147150             : 
  147151             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  147152             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  147153             : #endif
  147154             : 
  147155             : #if !defined(SGNODE__ALL_POOLS)
  147156             : #define SGNODE__ALL_POOLS
  147157             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  147158             : #endif
  147159             : 
  147160             : SgClassNameRefExp* SgClassNameRefExp::next_node = nullptr;
  147161             : std::vector<unsigned char*> SgClassNameRefExp::pools;
  147162             : 
  147163             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  147164             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  147165             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  147166             : // around this macro definition rather than each use).
  147167             : #ifndef ALLOC_MUTEX
  147168             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  147169             :         do {                                                                     \
  147170             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  147171             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  147172             :                 abort();                                                         \
  147173             :             }                                                                    \
  147174             :         } while (0);
  147175             : #endif
  147176             : 
  147177             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  147178             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  147179             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  147180             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  147181             : 
  147182             : /*! \brief New operator for SgClassNameRefExp.
  147183             : 
  147184             :    This new operator implements memory pools to provide most efficent 
  147185             :    use of the heap within construction of large ASTs.
  147186             : 
  147187             : \internal The new and delete operators use the lower level C malloc/free
  147188             :    function calls for performance and to make sure that mixing of malloc/free
  147189             :    and new/delete by the used can be caught more readily.  This may change
  147190             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  147191             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  147192             :    deallocate memory allocated using ROSE_MALLOC.
  147193             : */
  147194           0 : void *SgClassNameRefExp::operator new ( size_t Size )
  147195             : {
  147196             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  147197             :      * returning or throwing an exception. */
  147198           0 :     ALLOC_MUTEX(SgClassNameRefExp, lock);
  147199             : 
  147200             : #if ROSE_ALLOC_TRACE == 2
  147201             : //    printf("SgClassNameRefExp::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgClassNameRefExp::next_node);
  147202             : #endif
  147203             : 
  147204             : #if USE_CPP_NEW_DELETE_OPERATORS
  147205             :     void *mem = ROSE_MALLOC(Size);
  147206             :     ALLOC_MUTEX(SgClassNameRefExp, unlock);
  147207             :     return mem;
  147208             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  147209             : #if ROSE_PEDANTIC_ALLOC
  147210             :     ROSE_ASSERT(Size == sizeof(SgClassNameRefExp));
  147211             : #else
  147212           0 :     if (Size != sizeof(SgClassNameRefExp)) {
  147213           0 :       void * object = ROSE_MALLOC(Size);
  147214           0 :       ALLOC_MUTEX(SgClassNameRefExp, unlock);
  147215             :       return object;
  147216             :     }
  147217             : #endif
  147218             : 
  147219           0 :     if (SgClassNameRefExp::next_node == nullptr) {
  147220           0 :         SgClassNameRefExp * alloc = (SgClassNameRefExp*) ROSE_MALLOC ( SgClassNameRefExp::pool_size * sizeof(SgClassNameRefExp) );
  147221           0 :         ROSE_ASSERT(alloc != nullptr);
  147222             : 
  147223             : #if ROSE_ALLOC_TRACE == 2
  147224             : //        printf("SgClassNameRefExp::alloc\n  block[%zi] = [ %p , %p [\n", SgClassNameRefExp::pools.size(), alloc, alloc + SgClassNameRefExp::pool_size);
  147225             : #endif
  147226             : 
  147227             : #if ROSE_ALLOC_MEMSET == 1
  147228             : #elif ROSE_ALLOC_MEMSET == 2
  147229             :         memset(alloc, 0x00, SgClassNameRefExp::pool_size * sizeof(SgClassNameRefExp));
  147230             : #elif ROSE_ALLOC_MEMSET == 3
  147231             :         memset(alloc, 0xAA, SgClassNameRefExp::pool_size * sizeof(SgClassNameRefExp));
  147232             : #endif
  147233           0 :         for (unsigned i=0; i < SgClassNameRefExp::pool_size-1; i++) {
  147234           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
  147235             :         }
  147236           0 :         alloc[SgClassNameRefExp::pool_size-1].p_freepointer = nullptr;
  147237             : 
  147238           0 :         SgClassNameRefExp::pools.push_back ( (unsigned char *) alloc );
  147239           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgClassNameRefExp::pool_size * sizeof(SgClassNameRefExp), V_SgClassNameRefExp ) );
  147240           0 :         SgClassNameRefExp::next_node = alloc;
  147241             :     }
  147242           0 :     ROSE_ASSERT(SgClassNameRefExp::next_node != nullptr);
  147243             : 
  147244           0 :     SgClassNameRefExp * object = SgClassNameRefExp::next_node;
  147245           0 :     SgClassNameRefExp::next_node = (SgClassNameRefExp*)(object->p_freepointer);
  147246             : 
  147247             : #if ROSE_ALLOC_TRACE == 2
  147248             :     printf("SgClassNameRefExp::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgClassNameRefExp::next_node);
  147249             : #endif
  147250             : 
  147251           0 :     SgNode * fp = object->p_freepointer;
  147252             : #if ROSE_ALLOC_MEMSET == 1
  147253             : #elif ROSE_ALLOC_MEMSET == 2
  147254             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgClassNameRefExp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  147255             : #elif ROSE_ALLOC_MEMSET == 3
  147256             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgClassNameRefExp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  147257             : #endif
  147258           0 :     object->p_freepointer = fp;
  147259             : 
  147260             : #if ROSE_ALLOC_TRACE == 2
  147261             : //    printf("SgClassNameRefExp::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgClassNameRefExp::next_node);
  147262             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  147263             :     Rose::MemPool::snapshot(oss.str());
  147264             :     alloc_trace_cnt++;
  147265             : #endif
  147266             : 
  147267           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  147268             : 
  147269           0 :     ALLOC_MUTEX(SgClassNameRefExp, unlock);
  147270             : 
  147271             :     return object;
  147272             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  147273             : }
  147274             : 
  147275             : 
  147276             : 
  147277             : /*! \brief Delete operator for SgClassNameRefExp.
  147278             : 
  147279             :    This delete operator implements deallocation using memory pools to 
  147280             :    provide most efficent use of the heap within construction of large ASTs.
  147281             : 
  147282             : \internal The new and delete operators use the lower level C malloc/free
  147283             :    function calls for performance and to make sure that mixing of malloc/free
  147284             :    and new/delete by the used can be caught more readily.  This may change
  147285             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  147286             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  147287             :    deallocate memory allocated using ROSE_MALLOC.
  147288             : */
  147289           0 : void SgClassNameRefExp::operator delete(void *Pointer, size_t Size)
  147290             : {
  147291             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  147292             :      * or throwing an exception. */
  147293           0 :     ALLOC_MUTEX(SgClassNameRefExp, lock);
  147294             : 
  147295             : #if USE_CPP_NEW_DELETE_OPERATORS
  147296             :     ROSE_FREE(Pointer);
  147297             : #else
  147298             : #if ROSE_PEDANTIC_ALLOC
  147299             :     ROSE_ASSERT(Size == sizeof(SgClassNameRefExp));
  147300             : #else
  147301           0 :     if (Size != sizeof(SgClassNameRefExp)) {
  147302           0 :       ROSE_FREE(Pointer);
  147303           0 :       ALLOC_MUTEX(SgClassNameRefExp, unlock);
  147304             :       return;
  147305             :     }
  147306             : #endif
  147307             : 
  147308           0 :     SgClassNameRefExp * object = (SgClassNameRefExp*) Pointer;
  147309           0 :     ROSE_ASSERT(object != nullptr);
  147310             : 
  147311             : #if ROSE_ALLOC_TRACE == 2
  147312             : //  printf("SgClassNameRefExp::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgClassNameRefExp::next_node);
  147313             :     printf("SgClassNameRefExp::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgClassNameRefExp::next_node);
  147314             : #endif
  147315             : 
  147316             : #if ROSE_PEDANTIC_ALLOC
  147317             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  147318             : #endif
  147319             : 
  147320             : #if ROSE_ALLOC_MEMSET == 1
  147321             : #elif ROSE_ALLOC_MEMSET == 2
  147322             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgClassNameRefExp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  147323             : #elif ROSE_ALLOC_MEMSET == 3
  147324             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgClassNameRefExp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  147325             : #endif
  147326             : 
  147327             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  147328             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  147329             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  147330             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  147331             : #else
  147332           0 :     object->p_freepointer = SgClassNameRefExp::next_node;
  147333           0 :     SgClassNameRefExp::next_node = object;
  147334             : #endif
  147335             : 
  147336             : #if ROSE_ALLOC_TRACE == 2
  147337             : //  printf("SgClassNameRefExp::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgClassNameRefExp::next_node);
  147338             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  147339             :     Rose::MemPool::snapshot(oss.str());
  147340             :     alloc_trace_cnt++;
  147341             : #endif
  147342             : 
  147343             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  147344             : 
  147345           0 :     ALLOC_MUTEX(SgClassNameRefExp, unlock);
  147346             : }
  147347             : 
  147348             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  147349             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  147350             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  147351             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  147352             : // Also, note comment below from Robb (copied from the Common.code file).
  147353             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  147354             : //
  147355             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  147356             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  147357             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  147358             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  147359             : #if 0
  147360             : void SgClassNameRefExp::operator delete(void* pointer) { SgClassNameRefExp::operator delete (pointer, sizeof(SgClassNameRefExp)); };
  147361             : #endif
  147362             : /* #line 147363 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  147363             : 
  147364             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  147365             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  147366             : // obviously imply C++.
  147367             : 
  147368             : // This implements the support within ROSE for memory pools.  Memory pools
  147369             : // support the most condensed usage of memory within the construction of
  147370             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  147371             : // by a new operator written for each class.
  147372             : 
  147373             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  147374             :     // User wants multi-thread support and POSIX threads are available.
  147375             : #   include <pthread.h>
  147376             :     static pthread_mutex_t SgFunctionRefExp_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  147377             : #else
  147378             :      // Cause synchronization to be skipped.
  147379             : #    ifndef ALLOC_MUTEX
  147380             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  147381             : #    endif
  147382             : #    ifdef _REENTRANT
  147383             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  147384             : #       ifdef _MSC_VER
  147385             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  147386             : #       else
  147387             : #           warning "POSIX threads are not available; synchronization being skipped"
  147388             : #       endif
  147389             : #    endif
  147390             : #endif
  147391             : 
  147392             : #ifndef ROSE_ALLOC_TRACE
  147393             : #  define ROSE_ALLOC_TRACE 0
  147394             : #endif
  147395             : 
  147396             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  147397             : #define ROSE_ALLOC_TRACE_CNT
  147398             : #include "memory-pool-snapshot.h"
  147399             : unsigned long alloc_trace_cnt = 0;
  147400             : #endif
  147401             : 
  147402             : #if ROSE_ALLOC_TRACE
  147403             : const unsigned SgFunctionRefExp::pool_size = 5;
  147404             : #else
  147405             : const unsigned SgFunctionRefExp::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  147406             : #endif
  147407             : 
  147408             : #ifndef ROSE_ALLOC_MEMSET
  147409             : #  define ROSE_ALLOC_MEMSET 0
  147410             : #endif
  147411             : 
  147412             : #ifndef ROSE_PEDANTIC_ALLOC
  147413             : #  define ROSE_PEDANTIC_ALLOC 0
  147414             : #endif
  147415             : 
  147416             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  147417             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  147418             : #endif
  147419             : 
  147420             : #if !defined(SGNODE__ALL_POOLS)
  147421             : #define SGNODE__ALL_POOLS
  147422             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  147423             : #endif
  147424             : 
  147425             : SgFunctionRefExp* SgFunctionRefExp::next_node = nullptr;
  147426             : std::vector<unsigned char*> SgFunctionRefExp::pools;
  147427             : 
  147428             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  147429             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  147430             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  147431             : // around this macro definition rather than each use).
  147432             : #ifndef ALLOC_MUTEX
  147433             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  147434             :         do {                                                                     \
  147435             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  147436             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  147437             :                 abort();                                                         \
  147438             :             }                                                                    \
  147439             :         } while (0);
  147440             : #endif
  147441             : 
  147442             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  147443             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  147444             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  147445             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  147446             : 
  147447             : /*! \brief New operator for SgFunctionRefExp.
  147448             : 
  147449             :    This new operator implements memory pools to provide most efficent 
  147450             :    use of the heap within construction of large ASTs.
  147451             : 
  147452             : \internal The new and delete operators use the lower level C malloc/free
  147453             :    function calls for performance and to make sure that mixing of malloc/free
  147454             :    and new/delete by the used can be caught more readily.  This may change
  147455             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  147456             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  147457             :    deallocate memory allocated using ROSE_MALLOC.
  147458             : */
  147459        8590 : void *SgFunctionRefExp::operator new ( size_t Size )
  147460             : {
  147461             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  147462             :      * returning or throwing an exception. */
  147463        8590 :     ALLOC_MUTEX(SgFunctionRefExp, lock);
  147464             : 
  147465             : #if ROSE_ALLOC_TRACE == 2
  147466             : //    printf("SgFunctionRefExp::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgFunctionRefExp::next_node);
  147467             : #endif
  147468             : 
  147469             : #if USE_CPP_NEW_DELETE_OPERATORS
  147470             :     void *mem = ROSE_MALLOC(Size);
  147471             :     ALLOC_MUTEX(SgFunctionRefExp, unlock);
  147472             :     return mem;
  147473             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  147474             : #if ROSE_PEDANTIC_ALLOC
  147475             :     ROSE_ASSERT(Size == sizeof(SgFunctionRefExp));
  147476             : #else
  147477        8590 :     if (Size != sizeof(SgFunctionRefExp)) {
  147478           0 :       void * object = ROSE_MALLOC(Size);
  147479           0 :       ALLOC_MUTEX(SgFunctionRefExp, unlock);
  147480             :       return object;
  147481             :     }
  147482             : #endif
  147483             : 
  147484        8590 :     if (SgFunctionRefExp::next_node == nullptr) {
  147485         228 :         SgFunctionRefExp * alloc = (SgFunctionRefExp*) ROSE_MALLOC ( SgFunctionRefExp::pool_size * sizeof(SgFunctionRefExp) );
  147486         228 :         ROSE_ASSERT(alloc != nullptr);
  147487             : 
  147488             : #if ROSE_ALLOC_TRACE == 2
  147489             : //        printf("SgFunctionRefExp::alloc\n  block[%zi] = [ %p , %p [\n", SgFunctionRefExp::pools.size(), alloc, alloc + SgFunctionRefExp::pool_size);
  147490             : #endif
  147491             : 
  147492             : #if ROSE_ALLOC_MEMSET == 1
  147493             : #elif ROSE_ALLOC_MEMSET == 2
  147494             :         memset(alloc, 0x00, SgFunctionRefExp::pool_size * sizeof(SgFunctionRefExp));
  147495             : #elif ROSE_ALLOC_MEMSET == 3
  147496             :         memset(alloc, 0xAA, SgFunctionRefExp::pool_size * sizeof(SgFunctionRefExp));
  147497             : #endif
  147498      456000 :         for (unsigned i=0; i < SgFunctionRefExp::pool_size-1; i++) {
  147499      455772 :           alloc[i].p_freepointer = &(alloc[i+1]);
  147500             :         }
  147501         228 :         alloc[SgFunctionRefExp::pool_size-1].p_freepointer = nullptr;
  147502             : 
  147503         228 :         SgFunctionRefExp::pools.push_back ( (unsigned char *) alloc );
  147504         228 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgFunctionRefExp::pool_size * sizeof(SgFunctionRefExp), V_SgFunctionRefExp ) );
  147505         228 :         SgFunctionRefExp::next_node = alloc;
  147506             :     }
  147507        8590 :     ROSE_ASSERT(SgFunctionRefExp::next_node != nullptr);
  147508             : 
  147509        8590 :     SgFunctionRefExp * object = SgFunctionRefExp::next_node;
  147510        8590 :     SgFunctionRefExp::next_node = (SgFunctionRefExp*)(object->p_freepointer);
  147511             : 
  147512             : #if ROSE_ALLOC_TRACE == 2
  147513             :     printf("SgFunctionRefExp::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgFunctionRefExp::next_node);
  147514             : #endif
  147515             : 
  147516        8590 :     SgNode * fp = object->p_freepointer;
  147517             : #if ROSE_ALLOC_MEMSET == 1
  147518             : #elif ROSE_ALLOC_MEMSET == 2
  147519             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgFunctionRefExp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  147520             : #elif ROSE_ALLOC_MEMSET == 3
  147521             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgFunctionRefExp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  147522             : #endif
  147523        8590 :     object->p_freepointer = fp;
  147524             : 
  147525             : #if ROSE_ALLOC_TRACE == 2
  147526             : //    printf("SgFunctionRefExp::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgFunctionRefExp::next_node);
  147527             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  147528             :     Rose::MemPool::snapshot(oss.str());
  147529             :     alloc_trace_cnt++;
  147530             : #endif
  147531             : 
  147532        8590 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  147533             : 
  147534        8590 :     ALLOC_MUTEX(SgFunctionRefExp, unlock);
  147535             : 
  147536             :     return object;
  147537             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  147538             : }
  147539             : 
  147540             : 
  147541             : 
  147542             : /*! \brief Delete operator for SgFunctionRefExp.
  147543             : 
  147544             :    This delete operator implements deallocation using memory pools to 
  147545             :    provide most efficent use of the heap within construction of large ASTs.
  147546             : 
  147547             : \internal The new and delete operators use the lower level C malloc/free
  147548             :    function calls for performance and to make sure that mixing of malloc/free
  147549             :    and new/delete by the used can be caught more readily.  This may change
  147550             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  147551             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  147552             :    deallocate memory allocated using ROSE_MALLOC.
  147553             : */
  147554        1379 : void SgFunctionRefExp::operator delete(void *Pointer, size_t Size)
  147555             : {
  147556             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  147557             :      * or throwing an exception. */
  147558        1379 :     ALLOC_MUTEX(SgFunctionRefExp, lock);
  147559             : 
  147560             : #if USE_CPP_NEW_DELETE_OPERATORS
  147561             :     ROSE_FREE(Pointer);
  147562             : #else
  147563             : #if ROSE_PEDANTIC_ALLOC
  147564             :     ROSE_ASSERT(Size == sizeof(SgFunctionRefExp));
  147565             : #else
  147566        1379 :     if (Size != sizeof(SgFunctionRefExp)) {
  147567           0 :       ROSE_FREE(Pointer);
  147568           0 :       ALLOC_MUTEX(SgFunctionRefExp, unlock);
  147569             :       return;
  147570             :     }
  147571             : #endif
  147572             : 
  147573        1379 :     SgFunctionRefExp * object = (SgFunctionRefExp*) Pointer;
  147574        1379 :     ROSE_ASSERT(object != nullptr);
  147575             : 
  147576             : #if ROSE_ALLOC_TRACE == 2
  147577             : //  printf("SgFunctionRefExp::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgFunctionRefExp::next_node);
  147578             :     printf("SgFunctionRefExp::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgFunctionRefExp::next_node);
  147579             : #endif
  147580             : 
  147581             : #if ROSE_PEDANTIC_ALLOC
  147582             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  147583             : #endif
  147584             : 
  147585             : #if ROSE_ALLOC_MEMSET == 1
  147586             : #elif ROSE_ALLOC_MEMSET == 2
  147587             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgFunctionRefExp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  147588             : #elif ROSE_ALLOC_MEMSET == 3
  147589             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgFunctionRefExp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  147590             : #endif
  147591             : 
  147592             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  147593             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  147594             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  147595             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  147596             : #else
  147597        1379 :     object->p_freepointer = SgFunctionRefExp::next_node;
  147598        1379 :     SgFunctionRefExp::next_node = object;
  147599             : #endif
  147600             : 
  147601             : #if ROSE_ALLOC_TRACE == 2
  147602             : //  printf("SgFunctionRefExp::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgFunctionRefExp::next_node);
  147603             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  147604             :     Rose::MemPool::snapshot(oss.str());
  147605             :     alloc_trace_cnt++;
  147606             : #endif
  147607             : 
  147608             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  147609             : 
  147610        1379 :     ALLOC_MUTEX(SgFunctionRefExp, unlock);
  147611             : }
  147612             : 
  147613             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  147614             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  147615             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  147616             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  147617             : // Also, note comment below from Robb (copied from the Common.code file).
  147618             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  147619             : //
  147620             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  147621             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  147622             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  147623             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  147624             : #if 0
  147625             : void SgFunctionRefExp::operator delete(void* pointer) { SgFunctionRefExp::operator delete (pointer, sizeof(SgFunctionRefExp)); };
  147626             : #endif
  147627             : /* #line 147628 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  147628             : 
  147629             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  147630             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  147631             : // obviously imply C++.
  147632             : 
  147633             : // This implements the support within ROSE for memory pools.  Memory pools
  147634             : // support the most condensed usage of memory within the construction of
  147635             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  147636             : // by a new operator written for each class.
  147637             : 
  147638             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  147639             :     // User wants multi-thread support and POSIX threads are available.
  147640             : #   include <pthread.h>
  147641             :     static pthread_mutex_t SgMemberFunctionRefExp_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  147642             : #else
  147643             :      // Cause synchronization to be skipped.
  147644             : #    ifndef ALLOC_MUTEX
  147645             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  147646             : #    endif
  147647             : #    ifdef _REENTRANT
  147648             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  147649             : #       ifdef _MSC_VER
  147650             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  147651             : #       else
  147652             : #           warning "POSIX threads are not available; synchronization being skipped"
  147653             : #       endif
  147654             : #    endif
  147655             : #endif
  147656             : 
  147657             : #ifndef ROSE_ALLOC_TRACE
  147658             : #  define ROSE_ALLOC_TRACE 0
  147659             : #endif
  147660             : 
  147661             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  147662             : #define ROSE_ALLOC_TRACE_CNT
  147663             : #include "memory-pool-snapshot.h"
  147664             : unsigned long alloc_trace_cnt = 0;
  147665             : #endif
  147666             : 
  147667             : #if ROSE_ALLOC_TRACE
  147668             : const unsigned SgMemberFunctionRefExp::pool_size = 5;
  147669             : #else
  147670             : const unsigned SgMemberFunctionRefExp::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  147671             : #endif
  147672             : 
  147673             : #ifndef ROSE_ALLOC_MEMSET
  147674             : #  define ROSE_ALLOC_MEMSET 0
  147675             : #endif
  147676             : 
  147677             : #ifndef ROSE_PEDANTIC_ALLOC
  147678             : #  define ROSE_PEDANTIC_ALLOC 0
  147679             : #endif
  147680             : 
  147681             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  147682             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  147683             : #endif
  147684             : 
  147685             : #if !defined(SGNODE__ALL_POOLS)
  147686             : #define SGNODE__ALL_POOLS
  147687             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  147688             : #endif
  147689             : 
  147690             : SgMemberFunctionRefExp* SgMemberFunctionRefExp::next_node = nullptr;
  147691             : std::vector<unsigned char*> SgMemberFunctionRefExp::pools;
  147692             : 
  147693             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  147694             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  147695             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  147696             : // around this macro definition rather than each use).
  147697             : #ifndef ALLOC_MUTEX
  147698             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  147699             :         do {                                                                     \
  147700             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  147701             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  147702             :                 abort();                                                         \
  147703             :             }                                                                    \
  147704             :         } while (0);
  147705             : #endif
  147706             : 
  147707             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  147708             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  147709             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  147710             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  147711             : 
  147712             : /*! \brief New operator for SgMemberFunctionRefExp.
  147713             : 
  147714             :    This new operator implements memory pools to provide most efficent 
  147715             :    use of the heap within construction of large ASTs.
  147716             : 
  147717             : \internal The new and delete operators use the lower level C malloc/free
  147718             :    function calls for performance and to make sure that mixing of malloc/free
  147719             :    and new/delete by the used can be caught more readily.  This may change
  147720             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  147721             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  147722             :    deallocate memory allocated using ROSE_MALLOC.
  147723             : */
  147724        5299 : void *SgMemberFunctionRefExp::operator new ( size_t Size )
  147725             : {
  147726             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  147727             :      * returning or throwing an exception. */
  147728        5299 :     ALLOC_MUTEX(SgMemberFunctionRefExp, lock);
  147729             : 
  147730             : #if ROSE_ALLOC_TRACE == 2
  147731             : //    printf("SgMemberFunctionRefExp::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgMemberFunctionRefExp::next_node);
  147732             : #endif
  147733             : 
  147734             : #if USE_CPP_NEW_DELETE_OPERATORS
  147735             :     void *mem = ROSE_MALLOC(Size);
  147736             :     ALLOC_MUTEX(SgMemberFunctionRefExp, unlock);
  147737             :     return mem;
  147738             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  147739             : #if ROSE_PEDANTIC_ALLOC
  147740             :     ROSE_ASSERT(Size == sizeof(SgMemberFunctionRefExp));
  147741             : #else
  147742        5299 :     if (Size != sizeof(SgMemberFunctionRefExp)) {
  147743           0 :       void * object = ROSE_MALLOC(Size);
  147744           0 :       ALLOC_MUTEX(SgMemberFunctionRefExp, unlock);
  147745             :       return object;
  147746             :     }
  147747             : #endif
  147748             : 
  147749        5299 :     if (SgMemberFunctionRefExp::next_node == nullptr) {
  147750          13 :         SgMemberFunctionRefExp * alloc = (SgMemberFunctionRefExp*) ROSE_MALLOC ( SgMemberFunctionRefExp::pool_size * sizeof(SgMemberFunctionRefExp) );
  147751          13 :         ROSE_ASSERT(alloc != nullptr);
  147752             : 
  147753             : #if ROSE_ALLOC_TRACE == 2
  147754             : //        printf("SgMemberFunctionRefExp::alloc\n  block[%zi] = [ %p , %p [\n", SgMemberFunctionRefExp::pools.size(), alloc, alloc + SgMemberFunctionRefExp::pool_size);
  147755             : #endif
  147756             : 
  147757             : #if ROSE_ALLOC_MEMSET == 1
  147758             : #elif ROSE_ALLOC_MEMSET == 2
  147759             :         memset(alloc, 0x00, SgMemberFunctionRefExp::pool_size * sizeof(SgMemberFunctionRefExp));
  147760             : #elif ROSE_ALLOC_MEMSET == 3
  147761             :         memset(alloc, 0xAA, SgMemberFunctionRefExp::pool_size * sizeof(SgMemberFunctionRefExp));
  147762             : #endif
  147763       26000 :         for (unsigned i=0; i < SgMemberFunctionRefExp::pool_size-1; i++) {
  147764       25987 :           alloc[i].p_freepointer = &(alloc[i+1]);
  147765             :         }
  147766          13 :         alloc[SgMemberFunctionRefExp::pool_size-1].p_freepointer = nullptr;
  147767             : 
  147768          13 :         SgMemberFunctionRefExp::pools.push_back ( (unsigned char *) alloc );
  147769          13 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgMemberFunctionRefExp::pool_size * sizeof(SgMemberFunctionRefExp), V_SgMemberFunctionRefExp ) );
  147770          13 :         SgMemberFunctionRefExp::next_node = alloc;
  147771             :     }
  147772        5299 :     ROSE_ASSERT(SgMemberFunctionRefExp::next_node != nullptr);
  147773             : 
  147774        5299 :     SgMemberFunctionRefExp * object = SgMemberFunctionRefExp::next_node;
  147775        5299 :     SgMemberFunctionRefExp::next_node = (SgMemberFunctionRefExp*)(object->p_freepointer);
  147776             : 
  147777             : #if ROSE_ALLOC_TRACE == 2
  147778             :     printf("SgMemberFunctionRefExp::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgMemberFunctionRefExp::next_node);
  147779             : #endif
  147780             : 
  147781        5299 :     SgNode * fp = object->p_freepointer;
  147782             : #if ROSE_ALLOC_MEMSET == 1
  147783             : #elif ROSE_ALLOC_MEMSET == 2
  147784             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgMemberFunctionRefExp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  147785             : #elif ROSE_ALLOC_MEMSET == 3
  147786             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgMemberFunctionRefExp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  147787             : #endif
  147788        5299 :     object->p_freepointer = fp;
  147789             : 
  147790             : #if ROSE_ALLOC_TRACE == 2
  147791             : //    printf("SgMemberFunctionRefExp::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgMemberFunctionRefExp::next_node);
  147792             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  147793             :     Rose::MemPool::snapshot(oss.str());
  147794             :     alloc_trace_cnt++;
  147795             : #endif
  147796             : 
  147797        5299 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  147798             : 
  147799        5299 :     ALLOC_MUTEX(SgMemberFunctionRefExp, unlock);
  147800             : 
  147801             :     return object;
  147802             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  147803             : }
  147804             : 
  147805             : 
  147806             : 
  147807             : /*! \brief Delete operator for SgMemberFunctionRefExp.
  147808             : 
  147809             :    This delete operator implements deallocation using memory pools to 
  147810             :    provide most efficent use of the heap within construction of large ASTs.
  147811             : 
  147812             : \internal The new and delete operators use the lower level C malloc/free
  147813             :    function calls for performance and to make sure that mixing of malloc/free
  147814             :    and new/delete by the used can be caught more readily.  This may change
  147815             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  147816             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  147817             :    deallocate memory allocated using ROSE_MALLOC.
  147818             : */
  147819        1080 : void SgMemberFunctionRefExp::operator delete(void *Pointer, size_t Size)
  147820             : {
  147821             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  147822             :      * or throwing an exception. */
  147823        1080 :     ALLOC_MUTEX(SgMemberFunctionRefExp, lock);
  147824             : 
  147825             : #if USE_CPP_NEW_DELETE_OPERATORS
  147826             :     ROSE_FREE(Pointer);
  147827             : #else
  147828             : #if ROSE_PEDANTIC_ALLOC
  147829             :     ROSE_ASSERT(Size == sizeof(SgMemberFunctionRefExp));
  147830             : #else
  147831        1080 :     if (Size != sizeof(SgMemberFunctionRefExp)) {
  147832           0 :       ROSE_FREE(Pointer);
  147833           0 :       ALLOC_MUTEX(SgMemberFunctionRefExp, unlock);
  147834             :       return;
  147835             :     }
  147836             : #endif
  147837             : 
  147838        1080 :     SgMemberFunctionRefExp * object = (SgMemberFunctionRefExp*) Pointer;
  147839        1080 :     ROSE_ASSERT(object != nullptr);
  147840             : 
  147841             : #if ROSE_ALLOC_TRACE == 2
  147842             : //  printf("SgMemberFunctionRefExp::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgMemberFunctionRefExp::next_node);
  147843             :     printf("SgMemberFunctionRefExp::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgMemberFunctionRefExp::next_node);
  147844             : #endif
  147845             : 
  147846             : #if ROSE_PEDANTIC_ALLOC
  147847             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  147848             : #endif
  147849             : 
  147850             : #if ROSE_ALLOC_MEMSET == 1
  147851             : #elif ROSE_ALLOC_MEMSET == 2
  147852             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgMemberFunctionRefExp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  147853             : #elif ROSE_ALLOC_MEMSET == 3
  147854             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgMemberFunctionRefExp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  147855             : #endif
  147856             : 
  147857             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  147858             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  147859             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  147860             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  147861             : #else
  147862        1080 :     object->p_freepointer = SgMemberFunctionRefExp::next_node;
  147863        1080 :     SgMemberFunctionRefExp::next_node = object;
  147864             : #endif
  147865             : 
  147866             : #if ROSE_ALLOC_TRACE == 2
  147867             : //  printf("SgMemberFunctionRefExp::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgMemberFunctionRefExp::next_node);
  147868             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  147869             :     Rose::MemPool::snapshot(oss.str());
  147870             :     alloc_trace_cnt++;
  147871             : #endif
  147872             : 
  147873             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  147874             : 
  147875        1080 :     ALLOC_MUTEX(SgMemberFunctionRefExp, unlock);
  147876             : }
  147877             : 
  147878             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  147879             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  147880             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  147881             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  147882             : // Also, note comment below from Robb (copied from the Common.code file).
  147883             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  147884             : //
  147885             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  147886             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  147887             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  147888             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  147889             : #if 0
  147890             : void SgMemberFunctionRefExp::operator delete(void* pointer) { SgMemberFunctionRefExp::operator delete (pointer, sizeof(SgMemberFunctionRefExp)); };
  147891             : #endif
  147892             : /* #line 147893 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  147893             : 
  147894             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  147895             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  147896             : // obviously imply C++.
  147897             : 
  147898             : // This implements the support within ROSE for memory pools.  Memory pools
  147899             : // support the most condensed usage of memory within the construction of
  147900             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  147901             : // by a new operator written for each class.
  147902             : 
  147903             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  147904             :     // User wants multi-thread support and POSIX threads are available.
  147905             : #   include <pthread.h>
  147906             :     static pthread_mutex_t SgValueExp_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  147907             : #else
  147908             :      // Cause synchronization to be skipped.
  147909             : #    ifndef ALLOC_MUTEX
  147910             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  147911             : #    endif
  147912             : #    ifdef _REENTRANT
  147913             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  147914             : #       ifdef _MSC_VER
  147915             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  147916             : #       else
  147917             : #           warning "POSIX threads are not available; synchronization being skipped"
  147918             : #       endif
  147919             : #    endif
  147920             : #endif
  147921             : 
  147922             : #ifndef ROSE_ALLOC_TRACE
  147923             : #  define ROSE_ALLOC_TRACE 0
  147924             : #endif
  147925             : 
  147926             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  147927             : #define ROSE_ALLOC_TRACE_CNT
  147928             : #include "memory-pool-snapshot.h"
  147929             : unsigned long alloc_trace_cnt = 0;
  147930             : #endif
  147931             : 
  147932             : #if ROSE_ALLOC_TRACE
  147933             : const unsigned SgValueExp::pool_size = 5;
  147934             : #else
  147935             : const unsigned SgValueExp::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  147936             : #endif
  147937             : 
  147938             : #ifndef ROSE_ALLOC_MEMSET
  147939             : #  define ROSE_ALLOC_MEMSET 0
  147940             : #endif
  147941             : 
  147942             : #ifndef ROSE_PEDANTIC_ALLOC
  147943             : #  define ROSE_PEDANTIC_ALLOC 0
  147944             : #endif
  147945             : 
  147946             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  147947             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  147948             : #endif
  147949             : 
  147950             : #if !defined(SGNODE__ALL_POOLS)
  147951             : #define SGNODE__ALL_POOLS
  147952             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  147953             : #endif
  147954             : 
  147955             : SgValueExp* SgValueExp::next_node = nullptr;
  147956             : std::vector<unsigned char*> SgValueExp::pools;
  147957             : 
  147958             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  147959             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  147960             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  147961             : // around this macro definition rather than each use).
  147962             : #ifndef ALLOC_MUTEX
  147963             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  147964             :         do {                                                                     \
  147965             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  147966             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  147967             :                 abort();                                                         \
  147968             :             }                                                                    \
  147969             :         } while (0);
  147970             : #endif
  147971             : 
  147972             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  147973             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  147974             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  147975             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  147976             : 
  147977             : /*! \brief New operator for SgValueExp.
  147978             : 
  147979             :    This new operator implements memory pools to provide most efficent 
  147980             :    use of the heap within construction of large ASTs.
  147981             : 
  147982             : \internal The new and delete operators use the lower level C malloc/free
  147983             :    function calls for performance and to make sure that mixing of malloc/free
  147984             :    and new/delete by the used can be caught more readily.  This may change
  147985             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  147986             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  147987             :    deallocate memory allocated using ROSE_MALLOC.
  147988             : */
  147989           0 : void *SgValueExp::operator new ( size_t Size )
  147990             : {
  147991             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  147992             :      * returning or throwing an exception. */
  147993           0 :     ALLOC_MUTEX(SgValueExp, lock);
  147994             : 
  147995             : #if ROSE_ALLOC_TRACE == 2
  147996             : //    printf("SgValueExp::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgValueExp::next_node);
  147997             : #endif
  147998             : 
  147999             : #if USE_CPP_NEW_DELETE_OPERATORS
  148000             :     void *mem = ROSE_MALLOC(Size);
  148001             :     ALLOC_MUTEX(SgValueExp, unlock);
  148002             :     return mem;
  148003             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  148004             : #if ROSE_PEDANTIC_ALLOC
  148005             :     ROSE_ASSERT(Size == sizeof(SgValueExp));
  148006             : #else
  148007           0 :     if (Size != sizeof(SgValueExp)) {
  148008           0 :       void * object = ROSE_MALLOC(Size);
  148009           0 :       ALLOC_MUTEX(SgValueExp, unlock);
  148010             :       return object;
  148011             :     }
  148012             : #endif
  148013             : 
  148014           0 :     if (SgValueExp::next_node == nullptr) {
  148015           0 :         SgValueExp * alloc = (SgValueExp*) ROSE_MALLOC ( SgValueExp::pool_size * sizeof(SgValueExp) );
  148016           0 :         ROSE_ASSERT(alloc != nullptr);
  148017             : 
  148018             : #if ROSE_ALLOC_TRACE == 2
  148019             : //        printf("SgValueExp::alloc\n  block[%zi] = [ %p , %p [\n", SgValueExp::pools.size(), alloc, alloc + SgValueExp::pool_size);
  148020             : #endif
  148021             : 
  148022             : #if ROSE_ALLOC_MEMSET == 1
  148023             : #elif ROSE_ALLOC_MEMSET == 2
  148024             :         memset(alloc, 0x00, SgValueExp::pool_size * sizeof(SgValueExp));
  148025             : #elif ROSE_ALLOC_MEMSET == 3
  148026             :         memset(alloc, 0xAA, SgValueExp::pool_size * sizeof(SgValueExp));
  148027             : #endif
  148028           0 :         for (unsigned i=0; i < SgValueExp::pool_size-1; i++) {
  148029           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
  148030             :         }
  148031           0 :         alloc[SgValueExp::pool_size-1].p_freepointer = nullptr;
  148032             : 
  148033           0 :         SgValueExp::pools.push_back ( (unsigned char *) alloc );
  148034           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgValueExp::pool_size * sizeof(SgValueExp), V_SgValueExp ) );
  148035           0 :         SgValueExp::next_node = alloc;
  148036             :     }
  148037           0 :     ROSE_ASSERT(SgValueExp::next_node != nullptr);
  148038             : 
  148039           0 :     SgValueExp * object = SgValueExp::next_node;
  148040           0 :     SgValueExp::next_node = (SgValueExp*)(object->p_freepointer);
  148041             : 
  148042             : #if ROSE_ALLOC_TRACE == 2
  148043             :     printf("SgValueExp::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgValueExp::next_node);
  148044             : #endif
  148045             : 
  148046           0 :     SgNode * fp = object->p_freepointer;
  148047             : #if ROSE_ALLOC_MEMSET == 1
  148048             : #elif ROSE_ALLOC_MEMSET == 2
  148049             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgValueExp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  148050             : #elif ROSE_ALLOC_MEMSET == 3
  148051             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgValueExp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  148052             : #endif
  148053           0 :     object->p_freepointer = fp;
  148054             : 
  148055             : #if ROSE_ALLOC_TRACE == 2
  148056             : //    printf("SgValueExp::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgValueExp::next_node);
  148057             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  148058             :     Rose::MemPool::snapshot(oss.str());
  148059             :     alloc_trace_cnt++;
  148060             : #endif
  148061             : 
  148062           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  148063             : 
  148064           0 :     ALLOC_MUTEX(SgValueExp, unlock);
  148065             : 
  148066             :     return object;
  148067             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  148068             : }
  148069             : 
  148070             : 
  148071             : 
  148072             : /*! \brief Delete operator for SgValueExp.
  148073             : 
  148074             :    This delete operator implements deallocation using memory pools to 
  148075             :    provide most efficent use of the heap within construction of large ASTs.
  148076             : 
  148077             : \internal The new and delete operators use the lower level C malloc/free
  148078             :    function calls for performance and to make sure that mixing of malloc/free
  148079             :    and new/delete by the used can be caught more readily.  This may change
  148080             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  148081             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  148082             :    deallocate memory allocated using ROSE_MALLOC.
  148083             : */
  148084           0 : void SgValueExp::operator delete(void *Pointer, size_t Size)
  148085             : {
  148086             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  148087             :      * or throwing an exception. */
  148088           0 :     ALLOC_MUTEX(SgValueExp, lock);
  148089             : 
  148090             : #if USE_CPP_NEW_DELETE_OPERATORS
  148091             :     ROSE_FREE(Pointer);
  148092             : #else
  148093             : #if ROSE_PEDANTIC_ALLOC
  148094             :     ROSE_ASSERT(Size == sizeof(SgValueExp));
  148095             : #else
  148096           0 :     if (Size != sizeof(SgValueExp)) {
  148097           0 :       ROSE_FREE(Pointer);
  148098           0 :       ALLOC_MUTEX(SgValueExp, unlock);
  148099             :       return;
  148100             :     }
  148101             : #endif
  148102             : 
  148103           0 :     SgValueExp * object = (SgValueExp*) Pointer;
  148104           0 :     ROSE_ASSERT(object != nullptr);
  148105             : 
  148106             : #if ROSE_ALLOC_TRACE == 2
  148107             : //  printf("SgValueExp::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgValueExp::next_node);
  148108             :     printf("SgValueExp::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgValueExp::next_node);
  148109             : #endif
  148110             : 
  148111             : #if ROSE_PEDANTIC_ALLOC
  148112             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  148113             : #endif
  148114             : 
  148115             : #if ROSE_ALLOC_MEMSET == 1
  148116             : #elif ROSE_ALLOC_MEMSET == 2
  148117             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgValueExp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  148118             : #elif ROSE_ALLOC_MEMSET == 3
  148119             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgValueExp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  148120             : #endif
  148121             : 
  148122             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  148123             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  148124             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  148125             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  148126             : #else
  148127           0 :     object->p_freepointer = SgValueExp::next_node;
  148128           0 :     SgValueExp::next_node = object;
  148129             : #endif
  148130             : 
  148131             : #if ROSE_ALLOC_TRACE == 2
  148132             : //  printf("SgValueExp::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgValueExp::next_node);
  148133             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  148134             :     Rose::MemPool::snapshot(oss.str());
  148135             :     alloc_trace_cnt++;
  148136             : #endif
  148137             : 
  148138             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  148139             : 
  148140           0 :     ALLOC_MUTEX(SgValueExp, unlock);
  148141             : }
  148142             : 
  148143             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  148144             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  148145             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  148146             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  148147             : // Also, note comment below from Robb (copied from the Common.code file).
  148148             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  148149             : //
  148150             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  148151             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  148152             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  148153             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  148154             : #if 0
  148155             : void SgValueExp::operator delete(void* pointer) { SgValueExp::operator delete (pointer, sizeof(SgValueExp)); };
  148156             : #endif
  148157             : /* #line 148158 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  148158             : 
  148159             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  148160             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  148161             : // obviously imply C++.
  148162             : 
  148163             : // This implements the support within ROSE for memory pools.  Memory pools
  148164             : // support the most condensed usage of memory within the construction of
  148165             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  148166             : // by a new operator written for each class.
  148167             : 
  148168             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  148169             :     // User wants multi-thread support and POSIX threads are available.
  148170             : #   include <pthread.h>
  148171             :     static pthread_mutex_t SgBoolValExp_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  148172             : #else
  148173             :      // Cause synchronization to be skipped.
  148174             : #    ifndef ALLOC_MUTEX
  148175             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  148176             : #    endif
  148177             : #    ifdef _REENTRANT
  148178             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  148179             : #       ifdef _MSC_VER
  148180             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  148181             : #       else
  148182             : #           warning "POSIX threads are not available; synchronization being skipped"
  148183             : #       endif
  148184             : #    endif
  148185             : #endif
  148186             : 
  148187             : #ifndef ROSE_ALLOC_TRACE
  148188             : #  define ROSE_ALLOC_TRACE 0
  148189             : #endif
  148190             : 
  148191             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  148192             : #define ROSE_ALLOC_TRACE_CNT
  148193             : #include "memory-pool-snapshot.h"
  148194             : unsigned long alloc_trace_cnt = 0;
  148195             : #endif
  148196             : 
  148197             : #if ROSE_ALLOC_TRACE
  148198             : const unsigned SgBoolValExp::pool_size = 5;
  148199             : #else
  148200             : const unsigned SgBoolValExp::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  148201             : #endif
  148202             : 
  148203             : #ifndef ROSE_ALLOC_MEMSET
  148204             : #  define ROSE_ALLOC_MEMSET 0
  148205             : #endif
  148206             : 
  148207             : #ifndef ROSE_PEDANTIC_ALLOC
  148208             : #  define ROSE_PEDANTIC_ALLOC 0
  148209             : #endif
  148210             : 
  148211             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  148212             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  148213             : #endif
  148214             : 
  148215             : #if !defined(SGNODE__ALL_POOLS)
  148216             : #define SGNODE__ALL_POOLS
  148217             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  148218             : #endif
  148219             : 
  148220             : SgBoolValExp* SgBoolValExp::next_node = nullptr;
  148221             : std::vector<unsigned char*> SgBoolValExp::pools;
  148222             : 
  148223             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  148224             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  148225             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  148226             : // around this macro definition rather than each use).
  148227             : #ifndef ALLOC_MUTEX
  148228             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  148229             :         do {                                                                     \
  148230             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  148231             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  148232             :                 abort();                                                         \
  148233             :             }                                                                    \
  148234             :         } while (0);
  148235             : #endif
  148236             : 
  148237             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  148238             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  148239             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  148240             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  148241             : 
  148242             : /*! \brief New operator for SgBoolValExp.
  148243             : 
  148244             :    This new operator implements memory pools to provide most efficent 
  148245             :    use of the heap within construction of large ASTs.
  148246             : 
  148247             : \internal The new and delete operators use the lower level C malloc/free
  148248             :    function calls for performance and to make sure that mixing of malloc/free
  148249             :    and new/delete by the used can be caught more readily.  This may change
  148250             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  148251             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  148252             :    deallocate memory allocated using ROSE_MALLOC.
  148253             : */
  148254        5404 : void *SgBoolValExp::operator new ( size_t Size )
  148255             : {
  148256             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  148257             :      * returning or throwing an exception. */
  148258        5404 :     ALLOC_MUTEX(SgBoolValExp, lock);
  148259             : 
  148260             : #if ROSE_ALLOC_TRACE == 2
  148261             : //    printf("SgBoolValExp::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgBoolValExp::next_node);
  148262             : #endif
  148263             : 
  148264             : #if USE_CPP_NEW_DELETE_OPERATORS
  148265             :     void *mem = ROSE_MALLOC(Size);
  148266             :     ALLOC_MUTEX(SgBoolValExp, unlock);
  148267             :     return mem;
  148268             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  148269             : #if ROSE_PEDANTIC_ALLOC
  148270             :     ROSE_ASSERT(Size == sizeof(SgBoolValExp));
  148271             : #else
  148272        5404 :     if (Size != sizeof(SgBoolValExp)) {
  148273           0 :       void * object = ROSE_MALLOC(Size);
  148274           0 :       ALLOC_MUTEX(SgBoolValExp, unlock);
  148275             :       return object;
  148276             :     }
  148277             : #endif
  148278             : 
  148279        5404 :     if (SgBoolValExp::next_node == nullptr) {
  148280          11 :         SgBoolValExp * alloc = (SgBoolValExp*) ROSE_MALLOC ( SgBoolValExp::pool_size * sizeof(SgBoolValExp) );
  148281          11 :         ROSE_ASSERT(alloc != nullptr);
  148282             : 
  148283             : #if ROSE_ALLOC_TRACE == 2
  148284             : //        printf("SgBoolValExp::alloc\n  block[%zi] = [ %p , %p [\n", SgBoolValExp::pools.size(), alloc, alloc + SgBoolValExp::pool_size);
  148285             : #endif
  148286             : 
  148287             : #if ROSE_ALLOC_MEMSET == 1
  148288             : #elif ROSE_ALLOC_MEMSET == 2
  148289             :         memset(alloc, 0x00, SgBoolValExp::pool_size * sizeof(SgBoolValExp));
  148290             : #elif ROSE_ALLOC_MEMSET == 3
  148291             :         memset(alloc, 0xAA, SgBoolValExp::pool_size * sizeof(SgBoolValExp));
  148292             : #endif
  148293       22000 :         for (unsigned i=0; i < SgBoolValExp::pool_size-1; i++) {
  148294       21989 :           alloc[i].p_freepointer = &(alloc[i+1]);
  148295             :         }
  148296          11 :         alloc[SgBoolValExp::pool_size-1].p_freepointer = nullptr;
  148297             : 
  148298          11 :         SgBoolValExp::pools.push_back ( (unsigned char *) alloc );
  148299          11 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgBoolValExp::pool_size * sizeof(SgBoolValExp), V_SgBoolValExp ) );
  148300          11 :         SgBoolValExp::next_node = alloc;
  148301             :     }
  148302        5404 :     ROSE_ASSERT(SgBoolValExp::next_node != nullptr);
  148303             : 
  148304        5404 :     SgBoolValExp * object = SgBoolValExp::next_node;
  148305        5404 :     SgBoolValExp::next_node = (SgBoolValExp*)(object->p_freepointer);
  148306             : 
  148307             : #if ROSE_ALLOC_TRACE == 2
  148308             :     printf("SgBoolValExp::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgBoolValExp::next_node);
  148309             : #endif
  148310             : 
  148311        5404 :     SgNode * fp = object->p_freepointer;
  148312             : #if ROSE_ALLOC_MEMSET == 1
  148313             : #elif ROSE_ALLOC_MEMSET == 2
  148314             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgBoolValExp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  148315             : #elif ROSE_ALLOC_MEMSET == 3
  148316             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgBoolValExp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  148317             : #endif
  148318        5404 :     object->p_freepointer = fp;
  148319             : 
  148320             : #if ROSE_ALLOC_TRACE == 2
  148321             : //    printf("SgBoolValExp::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgBoolValExp::next_node);
  148322             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  148323             :     Rose::MemPool::snapshot(oss.str());
  148324             :     alloc_trace_cnt++;
  148325             : #endif
  148326             : 
  148327        5404 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  148328             : 
  148329        5404 :     ALLOC_MUTEX(SgBoolValExp, unlock);
  148330             : 
  148331             :     return object;
  148332             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  148333             : }
  148334             : 
  148335             : 
  148336             : 
  148337             : /*! \brief Delete operator for SgBoolValExp.
  148338             : 
  148339             :    This delete operator implements deallocation using memory pools to 
  148340             :    provide most efficent use of the heap within construction of large ASTs.
  148341             : 
  148342             : \internal The new and delete operators use the lower level C malloc/free
  148343             :    function calls for performance and to make sure that mixing of malloc/free
  148344             :    and new/delete by the used can be caught more readily.  This may change
  148345             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  148346             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  148347             :    deallocate memory allocated using ROSE_MALLOC.
  148348             : */
  148349        2068 : void SgBoolValExp::operator delete(void *Pointer, size_t Size)
  148350             : {
  148351             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  148352             :      * or throwing an exception. */
  148353        2068 :     ALLOC_MUTEX(SgBoolValExp, lock);
  148354             : 
  148355             : #if USE_CPP_NEW_DELETE_OPERATORS
  148356             :     ROSE_FREE(Pointer);
  148357             : #else
  148358             : #if ROSE_PEDANTIC_ALLOC
  148359             :     ROSE_ASSERT(Size == sizeof(SgBoolValExp));
  148360             : #else
  148361        2068 :     if (Size != sizeof(SgBoolValExp)) {
  148362           0 :       ROSE_FREE(Pointer);
  148363           0 :       ALLOC_MUTEX(SgBoolValExp, unlock);
  148364             :       return;
  148365             :     }
  148366             : #endif
  148367             : 
  148368        2068 :     SgBoolValExp * object = (SgBoolValExp*) Pointer;
  148369        2068 :     ROSE_ASSERT(object != nullptr);
  148370             : 
  148371             : #if ROSE_ALLOC_TRACE == 2
  148372             : //  printf("SgBoolValExp::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgBoolValExp::next_node);
  148373             :     printf("SgBoolValExp::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgBoolValExp::next_node);
  148374             : #endif
  148375             : 
  148376             : #if ROSE_PEDANTIC_ALLOC
  148377             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  148378             : #endif
  148379             : 
  148380             : #if ROSE_ALLOC_MEMSET == 1
  148381             : #elif ROSE_ALLOC_MEMSET == 2
  148382             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgBoolValExp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  148383             : #elif ROSE_ALLOC_MEMSET == 3
  148384             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgBoolValExp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  148385             : #endif
  148386             : 
  148387             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  148388             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  148389             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  148390             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  148391             : #else
  148392        2068 :     object->p_freepointer = SgBoolValExp::next_node;
  148393        2068 :     SgBoolValExp::next_node = object;
  148394             : #endif
  148395             : 
  148396             : #if ROSE_ALLOC_TRACE == 2
  148397             : //  printf("SgBoolValExp::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgBoolValExp::next_node);
  148398             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  148399             :     Rose::MemPool::snapshot(oss.str());
  148400             :     alloc_trace_cnt++;
  148401             : #endif
  148402             : 
  148403             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  148404             : 
  148405        2068 :     ALLOC_MUTEX(SgBoolValExp, unlock);
  148406             : }
  148407             : 
  148408             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  148409             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  148410             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  148411             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  148412             : // Also, note comment below from Robb (copied from the Common.code file).
  148413             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  148414             : //
  148415             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  148416             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  148417             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  148418             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  148419             : #if 0
  148420             : void SgBoolValExp::operator delete(void* pointer) { SgBoolValExp::operator delete (pointer, sizeof(SgBoolValExp)); };
  148421             : #endif
  148422             : /* #line 148423 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  148423             : 
  148424             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  148425             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  148426             : // obviously imply C++.
  148427             : 
  148428             : // This implements the support within ROSE for memory pools.  Memory pools
  148429             : // support the most condensed usage of memory within the construction of
  148430             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  148431             : // by a new operator written for each class.
  148432             : 
  148433             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  148434             :     // User wants multi-thread support and POSIX threads are available.
  148435             : #   include <pthread.h>
  148436             :     static pthread_mutex_t SgStringVal_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  148437             : #else
  148438             :      // Cause synchronization to be skipped.
  148439             : #    ifndef ALLOC_MUTEX
  148440             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  148441             : #    endif
  148442             : #    ifdef _REENTRANT
  148443             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  148444             : #       ifdef _MSC_VER
  148445             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  148446             : #       else
  148447             : #           warning "POSIX threads are not available; synchronization being skipped"
  148448             : #       endif
  148449             : #    endif
  148450             : #endif
  148451             : 
  148452             : #ifndef ROSE_ALLOC_TRACE
  148453             : #  define ROSE_ALLOC_TRACE 0
  148454             : #endif
  148455             : 
  148456             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  148457             : #define ROSE_ALLOC_TRACE_CNT
  148458             : #include "memory-pool-snapshot.h"
  148459             : unsigned long alloc_trace_cnt = 0;
  148460             : #endif
  148461             : 
  148462             : #if ROSE_ALLOC_TRACE
  148463             : const unsigned SgStringVal::pool_size = 5;
  148464             : #else
  148465             : const unsigned SgStringVal::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  148466             : #endif
  148467             : 
  148468             : #ifndef ROSE_ALLOC_MEMSET
  148469             : #  define ROSE_ALLOC_MEMSET 0
  148470             : #endif
  148471             : 
  148472             : #ifndef ROSE_PEDANTIC_ALLOC
  148473             : #  define ROSE_PEDANTIC_ALLOC 0
  148474             : #endif
  148475             : 
  148476             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  148477             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  148478             : #endif
  148479             : 
  148480             : #if !defined(SGNODE__ALL_POOLS)
  148481             : #define SGNODE__ALL_POOLS
  148482             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  148483             : #endif
  148484             : 
  148485             : SgStringVal* SgStringVal::next_node = nullptr;
  148486             : std::vector<unsigned char*> SgStringVal::pools;
  148487             : 
  148488             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  148489             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  148490             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  148491             : // around this macro definition rather than each use).
  148492             : #ifndef ALLOC_MUTEX
  148493             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  148494             :         do {                                                                     \
  148495             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  148496             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  148497             :                 abort();                                                         \
  148498             :             }                                                                    \
  148499             :         } while (0);
  148500             : #endif
  148501             : 
  148502             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  148503             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  148504             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  148505             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  148506             : 
  148507             : /*! \brief New operator for SgStringVal.
  148508             : 
  148509             :    This new operator implements memory pools to provide most efficent 
  148510             :    use of the heap within construction of large ASTs.
  148511             : 
  148512             : \internal The new and delete operators use the lower level C malloc/free
  148513             :    function calls for performance and to make sure that mixing of malloc/free
  148514             :    and new/delete by the used can be caught more readily.  This may change
  148515             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  148516             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  148517             :    deallocate memory allocated using ROSE_MALLOC.
  148518             : */
  148519        1682 : void *SgStringVal::operator new ( size_t Size )
  148520             : {
  148521             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  148522             :      * returning or throwing an exception. */
  148523        1682 :     ALLOC_MUTEX(SgStringVal, lock);
  148524             : 
  148525             : #if ROSE_ALLOC_TRACE == 2
  148526             : //    printf("SgStringVal::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgStringVal::next_node);
  148527             : #endif
  148528             : 
  148529             : #if USE_CPP_NEW_DELETE_OPERATORS
  148530             :     void *mem = ROSE_MALLOC(Size);
  148531             :     ALLOC_MUTEX(SgStringVal, unlock);
  148532             :     return mem;
  148533             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  148534             : #if ROSE_PEDANTIC_ALLOC
  148535             :     ROSE_ASSERT(Size == sizeof(SgStringVal));
  148536             : #else
  148537        1682 :     if (Size != sizeof(SgStringVal)) {
  148538           0 :       void * object = ROSE_MALLOC(Size);
  148539           0 :       ALLOC_MUTEX(SgStringVal, unlock);
  148540             :       return object;
  148541             :     }
  148542             : #endif
  148543             : 
  148544        1682 :     if (SgStringVal::next_node == nullptr) {
  148545         170 :         SgStringVal * alloc = (SgStringVal*) ROSE_MALLOC ( SgStringVal::pool_size * sizeof(SgStringVal) );
  148546         170 :         ROSE_ASSERT(alloc != nullptr);
  148547             : 
  148548             : #if ROSE_ALLOC_TRACE == 2
  148549             : //        printf("SgStringVal::alloc\n  block[%zi] = [ %p , %p [\n", SgStringVal::pools.size(), alloc, alloc + SgStringVal::pool_size);
  148550             : #endif
  148551             : 
  148552             : #if ROSE_ALLOC_MEMSET == 1
  148553             : #elif ROSE_ALLOC_MEMSET == 2
  148554             :         memset(alloc, 0x00, SgStringVal::pool_size * sizeof(SgStringVal));
  148555             : #elif ROSE_ALLOC_MEMSET == 3
  148556             :         memset(alloc, 0xAA, SgStringVal::pool_size * sizeof(SgStringVal));
  148557             : #endif
  148558      340000 :         for (unsigned i=0; i < SgStringVal::pool_size-1; i++) {
  148559      339830 :           alloc[i].p_freepointer = &(alloc[i+1]);
  148560             :         }
  148561         170 :         alloc[SgStringVal::pool_size-1].p_freepointer = nullptr;
  148562             : 
  148563         170 :         SgStringVal::pools.push_back ( (unsigned char *) alloc );
  148564         170 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgStringVal::pool_size * sizeof(SgStringVal), V_SgStringVal ) );
  148565         170 :         SgStringVal::next_node = alloc;
  148566             :     }
  148567        1682 :     ROSE_ASSERT(SgStringVal::next_node != nullptr);
  148568             : 
  148569        1682 :     SgStringVal * object = SgStringVal::next_node;
  148570        1682 :     SgStringVal::next_node = (SgStringVal*)(object->p_freepointer);
  148571             : 
  148572             : #if ROSE_ALLOC_TRACE == 2
  148573             :     printf("SgStringVal::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgStringVal::next_node);
  148574             : #endif
  148575             : 
  148576        1682 :     SgNode * fp = object->p_freepointer;
  148577             : #if ROSE_ALLOC_MEMSET == 1
  148578             : #elif ROSE_ALLOC_MEMSET == 2
  148579             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgStringVal) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  148580             : #elif ROSE_ALLOC_MEMSET == 3
  148581             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgStringVal) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  148582             : #endif
  148583        1682 :     object->p_freepointer = fp;
  148584             : 
  148585             : #if ROSE_ALLOC_TRACE == 2
  148586             : //    printf("SgStringVal::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgStringVal::next_node);
  148587             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  148588             :     Rose::MemPool::snapshot(oss.str());
  148589             :     alloc_trace_cnt++;
  148590             : #endif
  148591             : 
  148592        1682 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  148593             : 
  148594        1682 :     ALLOC_MUTEX(SgStringVal, unlock);
  148595             : 
  148596             :     return object;
  148597             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  148598             : }
  148599             : 
  148600             : 
  148601             : 
  148602             : /*! \brief Delete operator for SgStringVal.
  148603             : 
  148604             :    This delete operator implements deallocation using memory pools to 
  148605             :    provide most efficent use of the heap within construction of large ASTs.
  148606             : 
  148607             : \internal The new and delete operators use the lower level C malloc/free
  148608             :    function calls for performance and to make sure that mixing of malloc/free
  148609             :    and new/delete by the used can be caught more readily.  This may change
  148610             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  148611             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  148612             :    deallocate memory allocated using ROSE_MALLOC.
  148613             : */
  148614         368 : void SgStringVal::operator delete(void *Pointer, size_t Size)
  148615             : {
  148616             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  148617             :      * or throwing an exception. */
  148618         368 :     ALLOC_MUTEX(SgStringVal, lock);
  148619             : 
  148620             : #if USE_CPP_NEW_DELETE_OPERATORS
  148621             :     ROSE_FREE(Pointer);
  148622             : #else
  148623             : #if ROSE_PEDANTIC_ALLOC
  148624             :     ROSE_ASSERT(Size == sizeof(SgStringVal));
  148625             : #else
  148626         368 :     if (Size != sizeof(SgStringVal)) {
  148627           0 :       ROSE_FREE(Pointer);
  148628           0 :       ALLOC_MUTEX(SgStringVal, unlock);
  148629             :       return;
  148630             :     }
  148631             : #endif
  148632             : 
  148633         368 :     SgStringVal * object = (SgStringVal*) Pointer;
  148634         368 :     ROSE_ASSERT(object != nullptr);
  148635             : 
  148636             : #if ROSE_ALLOC_TRACE == 2
  148637             : //  printf("SgStringVal::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgStringVal::next_node);
  148638             :     printf("SgStringVal::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgStringVal::next_node);
  148639             : #endif
  148640             : 
  148641             : #if ROSE_PEDANTIC_ALLOC
  148642             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  148643             : #endif
  148644             : 
  148645             : #if ROSE_ALLOC_MEMSET == 1
  148646             : #elif ROSE_ALLOC_MEMSET == 2
  148647             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgStringVal) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  148648             : #elif ROSE_ALLOC_MEMSET == 3
  148649             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgStringVal) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  148650             : #endif
  148651             : 
  148652             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  148653             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  148654             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  148655             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  148656             : #else
  148657         368 :     object->p_freepointer = SgStringVal::next_node;
  148658         368 :     SgStringVal::next_node = object;
  148659             : #endif
  148660             : 
  148661             : #if ROSE_ALLOC_TRACE == 2
  148662             : //  printf("SgStringVal::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgStringVal::next_node);
  148663             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  148664             :     Rose::MemPool::snapshot(oss.str());
  148665             :     alloc_trace_cnt++;
  148666             : #endif
  148667             : 
  148668             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  148669             : 
  148670         368 :     ALLOC_MUTEX(SgStringVal, unlock);
  148671             : }
  148672             : 
  148673             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  148674             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  148675             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  148676             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  148677             : // Also, note comment below from Robb (copied from the Common.code file).
  148678             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  148679             : //
  148680             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  148681             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  148682             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  148683             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  148684             : #if 0
  148685             : void SgStringVal::operator delete(void* pointer) { SgStringVal::operator delete (pointer, sizeof(SgStringVal)); };
  148686             : #endif
  148687             : /* #line 148688 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  148688             : 
  148689             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  148690             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  148691             : // obviously imply C++.
  148692             : 
  148693             : // This implements the support within ROSE for memory pools.  Memory pools
  148694             : // support the most condensed usage of memory within the construction of
  148695             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  148696             : // by a new operator written for each class.
  148697             : 
  148698             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  148699             :     // User wants multi-thread support and POSIX threads are available.
  148700             : #   include <pthread.h>
  148701             :     static pthread_mutex_t SgShortVal_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  148702             : #else
  148703             :      // Cause synchronization to be skipped.
  148704             : #    ifndef ALLOC_MUTEX
  148705             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  148706             : #    endif
  148707             : #    ifdef _REENTRANT
  148708             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  148709             : #       ifdef _MSC_VER
  148710             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  148711             : #       else
  148712             : #           warning "POSIX threads are not available; synchronization being skipped"
  148713             : #       endif
  148714             : #    endif
  148715             : #endif
  148716             : 
  148717             : #ifndef ROSE_ALLOC_TRACE
  148718             : #  define ROSE_ALLOC_TRACE 0
  148719             : #endif
  148720             : 
  148721             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  148722             : #define ROSE_ALLOC_TRACE_CNT
  148723             : #include "memory-pool-snapshot.h"
  148724             : unsigned long alloc_trace_cnt = 0;
  148725             : #endif
  148726             : 
  148727             : #if ROSE_ALLOC_TRACE
  148728             : const unsigned SgShortVal::pool_size = 5;
  148729             : #else
  148730             : const unsigned SgShortVal::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  148731             : #endif
  148732             : 
  148733             : #ifndef ROSE_ALLOC_MEMSET
  148734             : #  define ROSE_ALLOC_MEMSET 0
  148735             : #endif
  148736             : 
  148737             : #ifndef ROSE_PEDANTIC_ALLOC
  148738             : #  define ROSE_PEDANTIC_ALLOC 0
  148739             : #endif
  148740             : 
  148741             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  148742             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  148743             : #endif
  148744             : 
  148745             : #if !defined(SGNODE__ALL_POOLS)
  148746             : #define SGNODE__ALL_POOLS
  148747             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  148748             : #endif
  148749             : 
  148750             : SgShortVal* SgShortVal::next_node = nullptr;
  148751             : std::vector<unsigned char*> SgShortVal::pools;
  148752             : 
  148753             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  148754             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  148755             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  148756             : // around this macro definition rather than each use).
  148757             : #ifndef ALLOC_MUTEX
  148758             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  148759             :         do {                                                                     \
  148760             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  148761             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  148762             :                 abort();                                                         \
  148763             :             }                                                                    \
  148764             :         } while (0);
  148765             : #endif
  148766             : 
  148767             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  148768             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  148769             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  148770             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  148771             : 
  148772             : /*! \brief New operator for SgShortVal.
  148773             : 
  148774             :    This new operator implements memory pools to provide most efficent 
  148775             :    use of the heap within construction of large ASTs.
  148776             : 
  148777             : \internal The new and delete operators use the lower level C malloc/free
  148778             :    function calls for performance and to make sure that mixing of malloc/free
  148779             :    and new/delete by the used can be caught more readily.  This may change
  148780             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  148781             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  148782             :    deallocate memory allocated using ROSE_MALLOC.
  148783             : */
  148784          35 : void *SgShortVal::operator new ( size_t Size )
  148785             : {
  148786             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  148787             :      * returning or throwing an exception. */
  148788          35 :     ALLOC_MUTEX(SgShortVal, lock);
  148789             : 
  148790             : #if ROSE_ALLOC_TRACE == 2
  148791             : //    printf("SgShortVal::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgShortVal::next_node);
  148792             : #endif
  148793             : 
  148794             : #if USE_CPP_NEW_DELETE_OPERATORS
  148795             :     void *mem = ROSE_MALLOC(Size);
  148796             :     ALLOC_MUTEX(SgShortVal, unlock);
  148797             :     return mem;
  148798             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  148799             : #if ROSE_PEDANTIC_ALLOC
  148800             :     ROSE_ASSERT(Size == sizeof(SgShortVal));
  148801             : #else
  148802          35 :     if (Size != sizeof(SgShortVal)) {
  148803           0 :       void * object = ROSE_MALLOC(Size);
  148804           0 :       ALLOC_MUTEX(SgShortVal, unlock);
  148805             :       return object;
  148806             :     }
  148807             : #endif
  148808             : 
  148809          35 :     if (SgShortVal::next_node == nullptr) {
  148810           9 :         SgShortVal * alloc = (SgShortVal*) ROSE_MALLOC ( SgShortVal::pool_size * sizeof(SgShortVal) );
  148811           9 :         ROSE_ASSERT(alloc != nullptr);
  148812             : 
  148813             : #if ROSE_ALLOC_TRACE == 2
  148814             : //        printf("SgShortVal::alloc\n  block[%zi] = [ %p , %p [\n", SgShortVal::pools.size(), alloc, alloc + SgShortVal::pool_size);
  148815             : #endif
  148816             : 
  148817             : #if ROSE_ALLOC_MEMSET == 1
  148818             : #elif ROSE_ALLOC_MEMSET == 2
  148819             :         memset(alloc, 0x00, SgShortVal::pool_size * sizeof(SgShortVal));
  148820             : #elif ROSE_ALLOC_MEMSET == 3
  148821             :         memset(alloc, 0xAA, SgShortVal::pool_size * sizeof(SgShortVal));
  148822             : #endif
  148823       18000 :         for (unsigned i=0; i < SgShortVal::pool_size-1; i++) {
  148824       17991 :           alloc[i].p_freepointer = &(alloc[i+1]);
  148825             :         }
  148826           9 :         alloc[SgShortVal::pool_size-1].p_freepointer = nullptr;
  148827             : 
  148828           9 :         SgShortVal::pools.push_back ( (unsigned char *) alloc );
  148829           9 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgShortVal::pool_size * sizeof(SgShortVal), V_SgShortVal ) );
  148830           9 :         SgShortVal::next_node = alloc;
  148831             :     }
  148832          35 :     ROSE_ASSERT(SgShortVal::next_node != nullptr);
  148833             : 
  148834          35 :     SgShortVal * object = SgShortVal::next_node;
  148835          35 :     SgShortVal::next_node = (SgShortVal*)(object->p_freepointer);
  148836             : 
  148837             : #if ROSE_ALLOC_TRACE == 2
  148838             :     printf("SgShortVal::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgShortVal::next_node);
  148839             : #endif
  148840             : 
  148841          35 :     SgNode * fp = object->p_freepointer;
  148842             : #if ROSE_ALLOC_MEMSET == 1
  148843             : #elif ROSE_ALLOC_MEMSET == 2
  148844             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgShortVal) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  148845             : #elif ROSE_ALLOC_MEMSET == 3
  148846             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgShortVal) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  148847             : #endif
  148848          35 :     object->p_freepointer = fp;
  148849             : 
  148850             : #if ROSE_ALLOC_TRACE == 2
  148851             : //    printf("SgShortVal::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgShortVal::next_node);
  148852             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  148853             :     Rose::MemPool::snapshot(oss.str());
  148854             :     alloc_trace_cnt++;
  148855             : #endif
  148856             : 
  148857          35 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  148858             : 
  148859          35 :     ALLOC_MUTEX(SgShortVal, unlock);
  148860             : 
  148861             :     return object;
  148862             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  148863             : }
  148864             : 
  148865             : 
  148866             : 
  148867             : /*! \brief Delete operator for SgShortVal.
  148868             : 
  148869             :    This delete operator implements deallocation using memory pools to 
  148870             :    provide most efficent use of the heap within construction of large ASTs.
  148871             : 
  148872             : \internal The new and delete operators use the lower level C malloc/free
  148873             :    function calls for performance and to make sure that mixing of malloc/free
  148874             :    and new/delete by the used can be caught more readily.  This may change
  148875             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  148876             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  148877             :    deallocate memory allocated using ROSE_MALLOC.
  148878             : */
  148879          33 : void SgShortVal::operator delete(void *Pointer, size_t Size)
  148880             : {
  148881             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  148882             :      * or throwing an exception. */
  148883          33 :     ALLOC_MUTEX(SgShortVal, lock);
  148884             : 
  148885             : #if USE_CPP_NEW_DELETE_OPERATORS
  148886             :     ROSE_FREE(Pointer);
  148887             : #else
  148888             : #if ROSE_PEDANTIC_ALLOC
  148889             :     ROSE_ASSERT(Size == sizeof(SgShortVal));
  148890             : #else
  148891          33 :     if (Size != sizeof(SgShortVal)) {
  148892           0 :       ROSE_FREE(Pointer);
  148893           0 :       ALLOC_MUTEX(SgShortVal, unlock);
  148894             :       return;
  148895             :     }
  148896             : #endif
  148897             : 
  148898          33 :     SgShortVal * object = (SgShortVal*) Pointer;
  148899          33 :     ROSE_ASSERT(object != nullptr);
  148900             : 
  148901             : #if ROSE_ALLOC_TRACE == 2
  148902             : //  printf("SgShortVal::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgShortVal::next_node);
  148903             :     printf("SgShortVal::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgShortVal::next_node);
  148904             : #endif
  148905             : 
  148906             : #if ROSE_PEDANTIC_ALLOC
  148907             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  148908             : #endif
  148909             : 
  148910             : #if ROSE_ALLOC_MEMSET == 1
  148911             : #elif ROSE_ALLOC_MEMSET == 2
  148912             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgShortVal) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  148913             : #elif ROSE_ALLOC_MEMSET == 3
  148914             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgShortVal) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  148915             : #endif
  148916             : 
  148917             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  148918             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  148919             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  148920             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  148921             : #else
  148922          33 :     object->p_freepointer = SgShortVal::next_node;
  148923          33 :     SgShortVal::next_node = object;
  148924             : #endif
  148925             : 
  148926             : #if ROSE_ALLOC_TRACE == 2
  148927             : //  printf("SgShortVal::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgShortVal::next_node);
  148928             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  148929             :     Rose::MemPool::snapshot(oss.str());
  148930             :     alloc_trace_cnt++;
  148931             : #endif
  148932             : 
  148933             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  148934             : 
  148935          33 :     ALLOC_MUTEX(SgShortVal, unlock);
  148936             : }
  148937             : 
  148938             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  148939             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  148940             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  148941             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  148942             : // Also, note comment below from Robb (copied from the Common.code file).
  148943             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  148944             : //
  148945             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  148946             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  148947             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  148948             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  148949             : #if 0
  148950             : void SgShortVal::operator delete(void* pointer) { SgShortVal::operator delete (pointer, sizeof(SgShortVal)); };
  148951             : #endif
  148952             : /* #line 148953 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  148953             : 
  148954             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  148955             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  148956             : // obviously imply C++.
  148957             : 
  148958             : // This implements the support within ROSE for memory pools.  Memory pools
  148959             : // support the most condensed usage of memory within the construction of
  148960             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  148961             : // by a new operator written for each class.
  148962             : 
  148963             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  148964             :     // User wants multi-thread support and POSIX threads are available.
  148965             : #   include <pthread.h>
  148966             :     static pthread_mutex_t SgCharVal_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  148967             : #else
  148968             :      // Cause synchronization to be skipped.
  148969             : #    ifndef ALLOC_MUTEX
  148970             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  148971             : #    endif
  148972             : #    ifdef _REENTRANT
  148973             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  148974             : #       ifdef _MSC_VER
  148975             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  148976             : #       else
  148977             : #           warning "POSIX threads are not available; synchronization being skipped"
  148978             : #       endif
  148979             : #    endif
  148980             : #endif
  148981             : 
  148982             : #ifndef ROSE_ALLOC_TRACE
  148983             : #  define ROSE_ALLOC_TRACE 0
  148984             : #endif
  148985             : 
  148986             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  148987             : #define ROSE_ALLOC_TRACE_CNT
  148988             : #include "memory-pool-snapshot.h"
  148989             : unsigned long alloc_trace_cnt = 0;
  148990             : #endif
  148991             : 
  148992             : #if ROSE_ALLOC_TRACE
  148993             : const unsigned SgCharVal::pool_size = 5;
  148994             : #else
  148995             : const unsigned SgCharVal::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  148996             : #endif
  148997             : 
  148998             : #ifndef ROSE_ALLOC_MEMSET
  148999             : #  define ROSE_ALLOC_MEMSET 0
  149000             : #endif
  149001             : 
  149002             : #ifndef ROSE_PEDANTIC_ALLOC
  149003             : #  define ROSE_PEDANTIC_ALLOC 0
  149004             : #endif
  149005             : 
  149006             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  149007             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  149008             : #endif
  149009             : 
  149010             : #if !defined(SGNODE__ALL_POOLS)
  149011             : #define SGNODE__ALL_POOLS
  149012             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  149013             : #endif
  149014             : 
  149015             : SgCharVal* SgCharVal::next_node = nullptr;
  149016             : std::vector<unsigned char*> SgCharVal::pools;
  149017             : 
  149018             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  149019             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  149020             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  149021             : // around this macro definition rather than each use).
  149022             : #ifndef ALLOC_MUTEX
  149023             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  149024             :         do {                                                                     \
  149025             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  149026             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  149027             :                 abort();                                                         \
  149028             :             }                                                                    \
  149029             :         } while (0);
  149030             : #endif
  149031             : 
  149032             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  149033             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  149034             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  149035             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  149036             : 
  149037             : /*! \brief New operator for SgCharVal.
  149038             : 
  149039             :    This new operator implements memory pools to provide most efficent 
  149040             :    use of the heap within construction of large ASTs.
  149041             : 
  149042             : \internal The new and delete operators use the lower level C malloc/free
  149043             :    function calls for performance and to make sure that mixing of malloc/free
  149044             :    and new/delete by the used can be caught more readily.  This may change
  149045             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  149046             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  149047             :    deallocate memory allocated using ROSE_MALLOC.
  149048             : */
  149049         491 : void *SgCharVal::operator new ( size_t Size )
  149050             : {
  149051             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  149052             :      * returning or throwing an exception. */
  149053         491 :     ALLOC_MUTEX(SgCharVal, lock);
  149054             : 
  149055             : #if ROSE_ALLOC_TRACE == 2
  149056             : //    printf("SgCharVal::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgCharVal::next_node);
  149057             : #endif
  149058             : 
  149059             : #if USE_CPP_NEW_DELETE_OPERATORS
  149060             :     void *mem = ROSE_MALLOC(Size);
  149061             :     ALLOC_MUTEX(SgCharVal, unlock);
  149062             :     return mem;
  149063             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  149064             : #if ROSE_PEDANTIC_ALLOC
  149065             :     ROSE_ASSERT(Size == sizeof(SgCharVal));
  149066             : #else
  149067         491 :     if (Size != sizeof(SgCharVal)) {
  149068           0 :       void * object = ROSE_MALLOC(Size);
  149069           0 :       ALLOC_MUTEX(SgCharVal, unlock);
  149070             :       return object;
  149071             :     }
  149072             : #endif
  149073             : 
  149074         491 :     if (SgCharVal::next_node == nullptr) {
  149075          11 :         SgCharVal * alloc = (SgCharVal*) ROSE_MALLOC ( SgCharVal::pool_size * sizeof(SgCharVal) );
  149076          11 :         ROSE_ASSERT(alloc != nullptr);
  149077             : 
  149078             : #if ROSE_ALLOC_TRACE == 2
  149079             : //        printf("SgCharVal::alloc\n  block[%zi] = [ %p , %p [\n", SgCharVal::pools.size(), alloc, alloc + SgCharVal::pool_size);
  149080             : #endif
  149081             : 
  149082             : #if ROSE_ALLOC_MEMSET == 1
  149083             : #elif ROSE_ALLOC_MEMSET == 2
  149084             :         memset(alloc, 0x00, SgCharVal::pool_size * sizeof(SgCharVal));
  149085             : #elif ROSE_ALLOC_MEMSET == 3
  149086             :         memset(alloc, 0xAA, SgCharVal::pool_size * sizeof(SgCharVal));
  149087             : #endif
  149088       22000 :         for (unsigned i=0; i < SgCharVal::pool_size-1; i++) {
  149089       21989 :           alloc[i].p_freepointer = &(alloc[i+1]);
  149090             :         }
  149091          11 :         alloc[SgCharVal::pool_size-1].p_freepointer = nullptr;
  149092             : 
  149093          11 :         SgCharVal::pools.push_back ( (unsigned char *) alloc );
  149094          11 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgCharVal::pool_size * sizeof(SgCharVal), V_SgCharVal ) );
  149095          11 :         SgCharVal::next_node = alloc;
  149096             :     }
  149097         491 :     ROSE_ASSERT(SgCharVal::next_node != nullptr);
  149098             : 
  149099         491 :     SgCharVal * object = SgCharVal::next_node;
  149100         491 :     SgCharVal::next_node = (SgCharVal*)(object->p_freepointer);
  149101             : 
  149102             : #if ROSE_ALLOC_TRACE == 2
  149103             :     printf("SgCharVal::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgCharVal::next_node);
  149104             : #endif
  149105             : 
  149106         491 :     SgNode * fp = object->p_freepointer;
  149107             : #if ROSE_ALLOC_MEMSET == 1
  149108             : #elif ROSE_ALLOC_MEMSET == 2
  149109             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgCharVal) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  149110             : #elif ROSE_ALLOC_MEMSET == 3
  149111             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgCharVal) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  149112             : #endif
  149113         491 :     object->p_freepointer = fp;
  149114             : 
  149115             : #if ROSE_ALLOC_TRACE == 2
  149116             : //    printf("SgCharVal::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgCharVal::next_node);
  149117             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  149118             :     Rose::MemPool::snapshot(oss.str());
  149119             :     alloc_trace_cnt++;
  149120             : #endif
  149121             : 
  149122         491 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  149123             : 
  149124         491 :     ALLOC_MUTEX(SgCharVal, unlock);
  149125             : 
  149126             :     return object;
  149127             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  149128             : }
  149129             : 
  149130             : 
  149131             : 
  149132             : /*! \brief Delete operator for SgCharVal.
  149133             : 
  149134             :    This delete operator implements deallocation using memory pools to 
  149135             :    provide most efficent use of the heap within construction of large ASTs.
  149136             : 
  149137             : \internal The new and delete operators use the lower level C malloc/free
  149138             :    function calls for performance and to make sure that mixing of malloc/free
  149139             :    and new/delete by the used can be caught more readily.  This may change
  149140             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  149141             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  149142             :    deallocate memory allocated using ROSE_MALLOC.
  149143             : */
  149144         121 : void SgCharVal::operator delete(void *Pointer, size_t Size)
  149145             : {
  149146             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  149147             :      * or throwing an exception. */
  149148         121 :     ALLOC_MUTEX(SgCharVal, lock);
  149149             : 
  149150             : #if USE_CPP_NEW_DELETE_OPERATORS
  149151             :     ROSE_FREE(Pointer);
  149152             : #else
  149153             : #if ROSE_PEDANTIC_ALLOC
  149154             :     ROSE_ASSERT(Size == sizeof(SgCharVal));
  149155             : #else
  149156         121 :     if (Size != sizeof(SgCharVal)) {
  149157           0 :       ROSE_FREE(Pointer);
  149158           0 :       ALLOC_MUTEX(SgCharVal, unlock);
  149159             :       return;
  149160             :     }
  149161             : #endif
  149162             : 
  149163         121 :     SgCharVal * object = (SgCharVal*) Pointer;
  149164         121 :     ROSE_ASSERT(object != nullptr);
  149165             : 
  149166             : #if ROSE_ALLOC_TRACE == 2
  149167             : //  printf("SgCharVal::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgCharVal::next_node);
  149168             :     printf("SgCharVal::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgCharVal::next_node);
  149169             : #endif
  149170             : 
  149171             : #if ROSE_PEDANTIC_ALLOC
  149172             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  149173             : #endif
  149174             : 
  149175             : #if ROSE_ALLOC_MEMSET == 1
  149176             : #elif ROSE_ALLOC_MEMSET == 2
  149177             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgCharVal) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  149178             : #elif ROSE_ALLOC_MEMSET == 3
  149179             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgCharVal) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  149180             : #endif
  149181             : 
  149182             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  149183             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  149184             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  149185             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  149186             : #else
  149187         121 :     object->p_freepointer = SgCharVal::next_node;
  149188         121 :     SgCharVal::next_node = object;
  149189             : #endif
  149190             : 
  149191             : #if ROSE_ALLOC_TRACE == 2
  149192             : //  printf("SgCharVal::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgCharVal::next_node);
  149193             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  149194             :     Rose::MemPool::snapshot(oss.str());
  149195             :     alloc_trace_cnt++;
  149196             : #endif
  149197             : 
  149198             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  149199             : 
  149200         121 :     ALLOC_MUTEX(SgCharVal, unlock);
  149201             : }
  149202             : 
  149203             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  149204             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  149205             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  149206             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  149207             : // Also, note comment below from Robb (copied from the Common.code file).
  149208             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  149209             : //
  149210             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  149211             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  149212             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  149213             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  149214             : #if 0
  149215             : void SgCharVal::operator delete(void* pointer) { SgCharVal::operator delete (pointer, sizeof(SgCharVal)); };
  149216             : #endif
  149217             : /* #line 149218 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  149218             : 
  149219             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  149220             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  149221             : // obviously imply C++.
  149222             : 
  149223             : // This implements the support within ROSE for memory pools.  Memory pools
  149224             : // support the most condensed usage of memory within the construction of
  149225             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  149226             : // by a new operator written for each class.
  149227             : 
  149228             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  149229             :     // User wants multi-thread support and POSIX threads are available.
  149230             : #   include <pthread.h>
  149231             :     static pthread_mutex_t SgUnsignedCharVal_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  149232             : #else
  149233             :      // Cause synchronization to be skipped.
  149234             : #    ifndef ALLOC_MUTEX
  149235             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  149236             : #    endif
  149237             : #    ifdef _REENTRANT
  149238             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  149239             : #       ifdef _MSC_VER
  149240             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  149241             : #       else
  149242             : #           warning "POSIX threads are not available; synchronization being skipped"
  149243             : #       endif
  149244             : #    endif
  149245             : #endif
  149246             : 
  149247             : #ifndef ROSE_ALLOC_TRACE
  149248             : #  define ROSE_ALLOC_TRACE 0
  149249             : #endif
  149250             : 
  149251             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  149252             : #define ROSE_ALLOC_TRACE_CNT
  149253             : #include "memory-pool-snapshot.h"
  149254             : unsigned long alloc_trace_cnt = 0;
  149255             : #endif
  149256             : 
  149257             : #if ROSE_ALLOC_TRACE
  149258             : const unsigned SgUnsignedCharVal::pool_size = 5;
  149259             : #else
  149260             : const unsigned SgUnsignedCharVal::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  149261             : #endif
  149262             : 
  149263             : #ifndef ROSE_ALLOC_MEMSET
  149264             : #  define ROSE_ALLOC_MEMSET 0
  149265             : #endif
  149266             : 
  149267             : #ifndef ROSE_PEDANTIC_ALLOC
  149268             : #  define ROSE_PEDANTIC_ALLOC 0
  149269             : #endif
  149270             : 
  149271             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  149272             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  149273             : #endif
  149274             : 
  149275             : #if !defined(SGNODE__ALL_POOLS)
  149276             : #define SGNODE__ALL_POOLS
  149277             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  149278             : #endif
  149279             : 
  149280             : SgUnsignedCharVal* SgUnsignedCharVal::next_node = nullptr;
  149281             : std::vector<unsigned char*> SgUnsignedCharVal::pools;
  149282             : 
  149283             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  149284             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  149285             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  149286             : // around this macro definition rather than each use).
  149287             : #ifndef ALLOC_MUTEX
  149288             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  149289             :         do {                                                                     \
  149290             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  149291             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  149292             :                 abort();                                                         \
  149293             :             }                                                                    \
  149294             :         } while (0);
  149295             : #endif
  149296             : 
  149297             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  149298             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  149299             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  149300             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  149301             : 
  149302             : /*! \brief New operator for SgUnsignedCharVal.
  149303             : 
  149304             :    This new operator implements memory pools to provide most efficent 
  149305             :    use of the heap within construction of large ASTs.
  149306             : 
  149307             : \internal The new and delete operators use the lower level C malloc/free
  149308             :    function calls for performance and to make sure that mixing of malloc/free
  149309             :    and new/delete by the used can be caught more readily.  This may change
  149310             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  149311             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  149312             :    deallocate memory allocated using ROSE_MALLOC.
  149313             : */
  149314           2 : void *SgUnsignedCharVal::operator new ( size_t Size )
  149315             : {
  149316             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  149317             :      * returning or throwing an exception. */
  149318           2 :     ALLOC_MUTEX(SgUnsignedCharVal, lock);
  149319             : 
  149320             : #if ROSE_ALLOC_TRACE == 2
  149321             : //    printf("SgUnsignedCharVal::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgUnsignedCharVal::next_node);
  149322             : #endif
  149323             : 
  149324             : #if USE_CPP_NEW_DELETE_OPERATORS
  149325             :     void *mem = ROSE_MALLOC(Size);
  149326             :     ALLOC_MUTEX(SgUnsignedCharVal, unlock);
  149327             :     return mem;
  149328             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  149329             : #if ROSE_PEDANTIC_ALLOC
  149330             :     ROSE_ASSERT(Size == sizeof(SgUnsignedCharVal));
  149331             : #else
  149332           2 :     if (Size != sizeof(SgUnsignedCharVal)) {
  149333           0 :       void * object = ROSE_MALLOC(Size);
  149334           0 :       ALLOC_MUTEX(SgUnsignedCharVal, unlock);
  149335             :       return object;
  149336             :     }
  149337             : #endif
  149338             : 
  149339           2 :     if (SgUnsignedCharVal::next_node == nullptr) {
  149340           1 :         SgUnsignedCharVal * alloc = (SgUnsignedCharVal*) ROSE_MALLOC ( SgUnsignedCharVal::pool_size * sizeof(SgUnsignedCharVal) );
  149341           1 :         ROSE_ASSERT(alloc != nullptr);
  149342             : 
  149343             : #if ROSE_ALLOC_TRACE == 2
  149344             : //        printf("SgUnsignedCharVal::alloc\n  block[%zi] = [ %p , %p [\n", SgUnsignedCharVal::pools.size(), alloc, alloc + SgUnsignedCharVal::pool_size);
  149345             : #endif
  149346             : 
  149347             : #if ROSE_ALLOC_MEMSET == 1
  149348             : #elif ROSE_ALLOC_MEMSET == 2
  149349             :         memset(alloc, 0x00, SgUnsignedCharVal::pool_size * sizeof(SgUnsignedCharVal));
  149350             : #elif ROSE_ALLOC_MEMSET == 3
  149351             :         memset(alloc, 0xAA, SgUnsignedCharVal::pool_size * sizeof(SgUnsignedCharVal));
  149352             : #endif
  149353        2000 :         for (unsigned i=0; i < SgUnsignedCharVal::pool_size-1; i++) {
  149354        1999 :           alloc[i].p_freepointer = &(alloc[i+1]);
  149355             :         }
  149356           1 :         alloc[SgUnsignedCharVal::pool_size-1].p_freepointer = nullptr;
  149357             : 
  149358           1 :         SgUnsignedCharVal::pools.push_back ( (unsigned char *) alloc );
  149359           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgUnsignedCharVal::pool_size * sizeof(SgUnsignedCharVal), V_SgUnsignedCharVal ) );
  149360           1 :         SgUnsignedCharVal::next_node = alloc;
  149361             :     }
  149362           2 :     ROSE_ASSERT(SgUnsignedCharVal::next_node != nullptr);
  149363             : 
  149364           2 :     SgUnsignedCharVal * object = SgUnsignedCharVal::next_node;
  149365           2 :     SgUnsignedCharVal::next_node = (SgUnsignedCharVal*)(object->p_freepointer);
  149366             : 
  149367             : #if ROSE_ALLOC_TRACE == 2
  149368             :     printf("SgUnsignedCharVal::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUnsignedCharVal::next_node);
  149369             : #endif
  149370             : 
  149371           2 :     SgNode * fp = object->p_freepointer;
  149372             : #if ROSE_ALLOC_MEMSET == 1
  149373             : #elif ROSE_ALLOC_MEMSET == 2
  149374             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgUnsignedCharVal) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  149375             : #elif ROSE_ALLOC_MEMSET == 3
  149376             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgUnsignedCharVal) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  149377             : #endif
  149378           2 :     object->p_freepointer = fp;
  149379             : 
  149380             : #if ROSE_ALLOC_TRACE == 2
  149381             : //    printf("SgUnsignedCharVal::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUnsignedCharVal::next_node);
  149382             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  149383             :     Rose::MemPool::snapshot(oss.str());
  149384             :     alloc_trace_cnt++;
  149385             : #endif
  149386             : 
  149387           2 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  149388             : 
  149389           2 :     ALLOC_MUTEX(SgUnsignedCharVal, unlock);
  149390             : 
  149391             :     return object;
  149392             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  149393             : }
  149394             : 
  149395             : 
  149396             : 
  149397             : /*! \brief Delete operator for SgUnsignedCharVal.
  149398             : 
  149399             :    This delete operator implements deallocation using memory pools to 
  149400             :    provide most efficent use of the heap within construction of large ASTs.
  149401             : 
  149402             : \internal The new and delete operators use the lower level C malloc/free
  149403             :    function calls for performance and to make sure that mixing of malloc/free
  149404             :    and new/delete by the used can be caught more readily.  This may change
  149405             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  149406             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  149407             :    deallocate memory allocated using ROSE_MALLOC.
  149408             : */
  149409           0 : void SgUnsignedCharVal::operator delete(void *Pointer, size_t Size)
  149410             : {
  149411             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  149412             :      * or throwing an exception. */
  149413           0 :     ALLOC_MUTEX(SgUnsignedCharVal, lock);
  149414             : 
  149415             : #if USE_CPP_NEW_DELETE_OPERATORS
  149416             :     ROSE_FREE(Pointer);
  149417             : #else
  149418             : #if ROSE_PEDANTIC_ALLOC
  149419             :     ROSE_ASSERT(Size == sizeof(SgUnsignedCharVal));
  149420             : #else
  149421           0 :     if (Size != sizeof(SgUnsignedCharVal)) {
  149422           0 :       ROSE_FREE(Pointer);
  149423           0 :       ALLOC_MUTEX(SgUnsignedCharVal, unlock);
  149424             :       return;
  149425             :     }
  149426             : #endif
  149427             : 
  149428           0 :     SgUnsignedCharVal * object = (SgUnsignedCharVal*) Pointer;
  149429           0 :     ROSE_ASSERT(object != nullptr);
  149430             : 
  149431             : #if ROSE_ALLOC_TRACE == 2
  149432             : //  printf("SgUnsignedCharVal::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUnsignedCharVal::next_node);
  149433             :     printf("SgUnsignedCharVal::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUnsignedCharVal::next_node);
  149434             : #endif
  149435             : 
  149436             : #if ROSE_PEDANTIC_ALLOC
  149437             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  149438             : #endif
  149439             : 
  149440             : #if ROSE_ALLOC_MEMSET == 1
  149441             : #elif ROSE_ALLOC_MEMSET == 2
  149442             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgUnsignedCharVal) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  149443             : #elif ROSE_ALLOC_MEMSET == 3
  149444             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgUnsignedCharVal) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  149445             : #endif
  149446             : 
  149447             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  149448             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  149449             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  149450             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  149451             : #else
  149452           0 :     object->p_freepointer = SgUnsignedCharVal::next_node;
  149453           0 :     SgUnsignedCharVal::next_node = object;
  149454             : #endif
  149455             : 
  149456             : #if ROSE_ALLOC_TRACE == 2
  149457             : //  printf("SgUnsignedCharVal::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUnsignedCharVal::next_node);
  149458             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  149459             :     Rose::MemPool::snapshot(oss.str());
  149460             :     alloc_trace_cnt++;
  149461             : #endif
  149462             : 
  149463             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  149464             : 
  149465           0 :     ALLOC_MUTEX(SgUnsignedCharVal, unlock);
  149466             : }
  149467             : 
  149468             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  149469             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  149470             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  149471             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  149472             : // Also, note comment below from Robb (copied from the Common.code file).
  149473             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  149474             : //
  149475             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  149476             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  149477             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  149478             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  149479             : #if 0
  149480             : void SgUnsignedCharVal::operator delete(void* pointer) { SgUnsignedCharVal::operator delete (pointer, sizeof(SgUnsignedCharVal)); };
  149481             : #endif
  149482             : /* #line 149483 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  149483             : 
  149484             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  149485             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  149486             : // obviously imply C++.
  149487             : 
  149488             : // This implements the support within ROSE for memory pools.  Memory pools
  149489             : // support the most condensed usage of memory within the construction of
  149490             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  149491             : // by a new operator written for each class.
  149492             : 
  149493             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  149494             :     // User wants multi-thread support and POSIX threads are available.
  149495             : #   include <pthread.h>
  149496             :     static pthread_mutex_t SgWcharVal_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  149497             : #else
  149498             :      // Cause synchronization to be skipped.
  149499             : #    ifndef ALLOC_MUTEX
  149500             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  149501             : #    endif
  149502             : #    ifdef _REENTRANT
  149503             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  149504             : #       ifdef _MSC_VER
  149505             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  149506             : #       else
  149507             : #           warning "POSIX threads are not available; synchronization being skipped"
  149508             : #       endif
  149509             : #    endif
  149510             : #endif
  149511             : 
  149512             : #ifndef ROSE_ALLOC_TRACE
  149513             : #  define ROSE_ALLOC_TRACE 0
  149514             : #endif
  149515             : 
  149516             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  149517             : #define ROSE_ALLOC_TRACE_CNT
  149518             : #include "memory-pool-snapshot.h"
  149519             : unsigned long alloc_trace_cnt = 0;
  149520             : #endif
  149521             : 
  149522             : #if ROSE_ALLOC_TRACE
  149523             : const unsigned SgWcharVal::pool_size = 5;
  149524             : #else
  149525             : const unsigned SgWcharVal::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  149526             : #endif
  149527             : 
  149528             : #ifndef ROSE_ALLOC_MEMSET
  149529             : #  define ROSE_ALLOC_MEMSET 0
  149530             : #endif
  149531             : 
  149532             : #ifndef ROSE_PEDANTIC_ALLOC
  149533             : #  define ROSE_PEDANTIC_ALLOC 0
  149534             : #endif
  149535             : 
  149536             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  149537             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  149538             : #endif
  149539             : 
  149540             : #if !defined(SGNODE__ALL_POOLS)
  149541             : #define SGNODE__ALL_POOLS
  149542             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  149543             : #endif
  149544             : 
  149545             : SgWcharVal* SgWcharVal::next_node = nullptr;
  149546             : std::vector<unsigned char*> SgWcharVal::pools;
  149547             : 
  149548             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  149549             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  149550             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  149551             : // around this macro definition rather than each use).
  149552             : #ifndef ALLOC_MUTEX
  149553             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  149554             :         do {                                                                     \
  149555             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  149556             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  149557             :                 abort();                                                         \
  149558             :             }                                                                    \
  149559             :         } while (0);
  149560             : #endif
  149561             : 
  149562             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  149563             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  149564             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  149565             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  149566             : 
  149567             : /*! \brief New operator for SgWcharVal.
  149568             : 
  149569             :    This new operator implements memory pools to provide most efficent 
  149570             :    use of the heap within construction of large ASTs.
  149571             : 
  149572             : \internal The new and delete operators use the lower level C malloc/free
  149573             :    function calls for performance and to make sure that mixing of malloc/free
  149574             :    and new/delete by the used can be caught more readily.  This may change
  149575             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  149576             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  149577             :    deallocate memory allocated using ROSE_MALLOC.
  149578             : */
  149579           9 : void *SgWcharVal::operator new ( size_t Size )
  149580             : {
  149581             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  149582             :      * returning or throwing an exception. */
  149583           9 :     ALLOC_MUTEX(SgWcharVal, lock);
  149584             : 
  149585             : #if ROSE_ALLOC_TRACE == 2
  149586             : //    printf("SgWcharVal::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgWcharVal::next_node);
  149587             : #endif
  149588             : 
  149589             : #if USE_CPP_NEW_DELETE_OPERATORS
  149590             :     void *mem = ROSE_MALLOC(Size);
  149591             :     ALLOC_MUTEX(SgWcharVal, unlock);
  149592             :     return mem;
  149593             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  149594             : #if ROSE_PEDANTIC_ALLOC
  149595             :     ROSE_ASSERT(Size == sizeof(SgWcharVal));
  149596             : #else
  149597           9 :     if (Size != sizeof(SgWcharVal)) {
  149598           0 :       void * object = ROSE_MALLOC(Size);
  149599           0 :       ALLOC_MUTEX(SgWcharVal, unlock);
  149600             :       return object;
  149601             :     }
  149602             : #endif
  149603             : 
  149604           9 :     if (SgWcharVal::next_node == nullptr) {
  149605           9 :         SgWcharVal * alloc = (SgWcharVal*) ROSE_MALLOC ( SgWcharVal::pool_size * sizeof(SgWcharVal) );
  149606           9 :         ROSE_ASSERT(alloc != nullptr);
  149607             : 
  149608             : #if ROSE_ALLOC_TRACE == 2
  149609             : //        printf("SgWcharVal::alloc\n  block[%zi] = [ %p , %p [\n", SgWcharVal::pools.size(), alloc, alloc + SgWcharVal::pool_size);
  149610             : #endif
  149611             : 
  149612             : #if ROSE_ALLOC_MEMSET == 1
  149613             : #elif ROSE_ALLOC_MEMSET == 2
  149614             :         memset(alloc, 0x00, SgWcharVal::pool_size * sizeof(SgWcharVal));
  149615             : #elif ROSE_ALLOC_MEMSET == 3
  149616             :         memset(alloc, 0xAA, SgWcharVal::pool_size * sizeof(SgWcharVal));
  149617             : #endif
  149618       18000 :         for (unsigned i=0; i < SgWcharVal::pool_size-1; i++) {
  149619       17991 :           alloc[i].p_freepointer = &(alloc[i+1]);
  149620             :         }
  149621           9 :         alloc[SgWcharVal::pool_size-1].p_freepointer = nullptr;
  149622             : 
  149623           9 :         SgWcharVal::pools.push_back ( (unsigned char *) alloc );
  149624           9 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgWcharVal::pool_size * sizeof(SgWcharVal), V_SgWcharVal ) );
  149625           9 :         SgWcharVal::next_node = alloc;
  149626             :     }
  149627           9 :     ROSE_ASSERT(SgWcharVal::next_node != nullptr);
  149628             : 
  149629           9 :     SgWcharVal * object = SgWcharVal::next_node;
  149630           9 :     SgWcharVal::next_node = (SgWcharVal*)(object->p_freepointer);
  149631             : 
  149632             : #if ROSE_ALLOC_TRACE == 2
  149633             :     printf("SgWcharVal::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgWcharVal::next_node);
  149634             : #endif
  149635             : 
  149636           9 :     SgNode * fp = object->p_freepointer;
  149637             : #if ROSE_ALLOC_MEMSET == 1
  149638             : #elif ROSE_ALLOC_MEMSET == 2
  149639             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgWcharVal) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  149640             : #elif ROSE_ALLOC_MEMSET == 3
  149641             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgWcharVal) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  149642             : #endif
  149643           9 :     object->p_freepointer = fp;
  149644             : 
  149645             : #if ROSE_ALLOC_TRACE == 2
  149646             : //    printf("SgWcharVal::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgWcharVal::next_node);
  149647             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  149648             :     Rose::MemPool::snapshot(oss.str());
  149649             :     alloc_trace_cnt++;
  149650             : #endif
  149651             : 
  149652           9 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  149653             : 
  149654           9 :     ALLOC_MUTEX(SgWcharVal, unlock);
  149655             : 
  149656             :     return object;
  149657             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  149658             : }
  149659             : 
  149660             : 
  149661             : 
  149662             : /*! \brief Delete operator for SgWcharVal.
  149663             : 
  149664             :    This delete operator implements deallocation using memory pools to 
  149665             :    provide most efficent use of the heap within construction of large ASTs.
  149666             : 
  149667             : \internal The new and delete operators use the lower level C malloc/free
  149668             :    function calls for performance and to make sure that mixing of malloc/free
  149669             :    and new/delete by the used can be caught more readily.  This may change
  149670             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  149671             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  149672             :    deallocate memory allocated using ROSE_MALLOC.
  149673             : */
  149674           8 : void SgWcharVal::operator delete(void *Pointer, size_t Size)
  149675             : {
  149676             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  149677             :      * or throwing an exception. */
  149678           8 :     ALLOC_MUTEX(SgWcharVal, lock);
  149679             : 
  149680             : #if USE_CPP_NEW_DELETE_OPERATORS
  149681             :     ROSE_FREE(Pointer);
  149682             : #else
  149683             : #if ROSE_PEDANTIC_ALLOC
  149684             :     ROSE_ASSERT(Size == sizeof(SgWcharVal));
  149685             : #else
  149686           8 :     if (Size != sizeof(SgWcharVal)) {
  149687           0 :       ROSE_FREE(Pointer);
  149688           0 :       ALLOC_MUTEX(SgWcharVal, unlock);
  149689             :       return;
  149690             :     }
  149691             : #endif
  149692             : 
  149693           8 :     SgWcharVal * object = (SgWcharVal*) Pointer;
  149694           8 :     ROSE_ASSERT(object != nullptr);
  149695             : 
  149696             : #if ROSE_ALLOC_TRACE == 2
  149697             : //  printf("SgWcharVal::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgWcharVal::next_node);
  149698             :     printf("SgWcharVal::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgWcharVal::next_node);
  149699             : #endif
  149700             : 
  149701             : #if ROSE_PEDANTIC_ALLOC
  149702             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  149703             : #endif
  149704             : 
  149705             : #if ROSE_ALLOC_MEMSET == 1
  149706             : #elif ROSE_ALLOC_MEMSET == 2
  149707             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgWcharVal) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  149708             : #elif ROSE_ALLOC_MEMSET == 3
  149709             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgWcharVal) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  149710             : #endif
  149711             : 
  149712             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  149713             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  149714             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  149715             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  149716             : #else
  149717           8 :     object->p_freepointer = SgWcharVal::next_node;
  149718           8 :     SgWcharVal::next_node = object;
  149719             : #endif
  149720             : 
  149721             : #if ROSE_ALLOC_TRACE == 2
  149722             : //  printf("SgWcharVal::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgWcharVal::next_node);
  149723             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  149724             :     Rose::MemPool::snapshot(oss.str());
  149725             :     alloc_trace_cnt++;
  149726             : #endif
  149727             : 
  149728             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  149729             : 
  149730           8 :     ALLOC_MUTEX(SgWcharVal, unlock);
  149731             : }
  149732             : 
  149733             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  149734             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  149735             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  149736             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  149737             : // Also, note comment below from Robb (copied from the Common.code file).
  149738             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  149739             : //
  149740             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  149741             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  149742             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  149743             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  149744             : #if 0
  149745             : void SgWcharVal::operator delete(void* pointer) { SgWcharVal::operator delete (pointer, sizeof(SgWcharVal)); };
  149746             : #endif
  149747             : /* #line 149748 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  149748             : 
  149749             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  149750             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  149751             : // obviously imply C++.
  149752             : 
  149753             : // This implements the support within ROSE for memory pools.  Memory pools
  149754             : // support the most condensed usage of memory within the construction of
  149755             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  149756             : // by a new operator written for each class.
  149757             : 
  149758             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  149759             :     // User wants multi-thread support and POSIX threads are available.
  149760             : #   include <pthread.h>
  149761             :     static pthread_mutex_t SgUnsignedShortVal_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  149762             : #else
  149763             :      // Cause synchronization to be skipped.
  149764             : #    ifndef ALLOC_MUTEX
  149765             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  149766             : #    endif
  149767             : #    ifdef _REENTRANT
  149768             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  149769             : #       ifdef _MSC_VER
  149770             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  149771             : #       else
  149772             : #           warning "POSIX threads are not available; synchronization being skipped"
  149773             : #       endif
  149774             : #    endif
  149775             : #endif
  149776             : 
  149777             : #ifndef ROSE_ALLOC_TRACE
  149778             : #  define ROSE_ALLOC_TRACE 0
  149779             : #endif
  149780             : 
  149781             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  149782             : #define ROSE_ALLOC_TRACE_CNT
  149783             : #include "memory-pool-snapshot.h"
  149784             : unsigned long alloc_trace_cnt = 0;
  149785             : #endif
  149786             : 
  149787             : #if ROSE_ALLOC_TRACE
  149788             : const unsigned SgUnsignedShortVal::pool_size = 5;
  149789             : #else
  149790             : const unsigned SgUnsignedShortVal::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  149791             : #endif
  149792             : 
  149793             : #ifndef ROSE_ALLOC_MEMSET
  149794             : #  define ROSE_ALLOC_MEMSET 0
  149795             : #endif
  149796             : 
  149797             : #ifndef ROSE_PEDANTIC_ALLOC
  149798             : #  define ROSE_PEDANTIC_ALLOC 0
  149799             : #endif
  149800             : 
  149801             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  149802             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  149803             : #endif
  149804             : 
  149805             : #if !defined(SGNODE__ALL_POOLS)
  149806             : #define SGNODE__ALL_POOLS
  149807             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  149808             : #endif
  149809             : 
  149810             : SgUnsignedShortVal* SgUnsignedShortVal::next_node = nullptr;
  149811             : std::vector<unsigned char*> SgUnsignedShortVal::pools;
  149812             : 
  149813             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  149814             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  149815             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  149816             : // around this macro definition rather than each use).
  149817             : #ifndef ALLOC_MUTEX
  149818             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  149819             :         do {                                                                     \
  149820             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  149821             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  149822             :                 abort();                                                         \
  149823             :             }                                                                    \
  149824             :         } while (0);
  149825             : #endif
  149826             : 
  149827             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  149828             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  149829             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  149830             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  149831             : 
  149832             : /*! \brief New operator for SgUnsignedShortVal.
  149833             : 
  149834             :    This new operator implements memory pools to provide most efficent 
  149835             :    use of the heap within construction of large ASTs.
  149836             : 
  149837             : \internal The new and delete operators use the lower level C malloc/free
  149838             :    function calls for performance and to make sure that mixing of malloc/free
  149839             :    and new/delete by the used can be caught more readily.  This may change
  149840             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  149841             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  149842             :    deallocate memory allocated using ROSE_MALLOC.
  149843             : */
  149844         219 : void *SgUnsignedShortVal::operator new ( size_t Size )
  149845             : {
  149846             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  149847             :      * returning or throwing an exception. */
  149848         219 :     ALLOC_MUTEX(SgUnsignedShortVal, lock);
  149849             : 
  149850             : #if ROSE_ALLOC_TRACE == 2
  149851             : //    printf("SgUnsignedShortVal::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgUnsignedShortVal::next_node);
  149852             : #endif
  149853             : 
  149854             : #if USE_CPP_NEW_DELETE_OPERATORS
  149855             :     void *mem = ROSE_MALLOC(Size);
  149856             :     ALLOC_MUTEX(SgUnsignedShortVal, unlock);
  149857             :     return mem;
  149858             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  149859             : #if ROSE_PEDANTIC_ALLOC
  149860             :     ROSE_ASSERT(Size == sizeof(SgUnsignedShortVal));
  149861             : #else
  149862         219 :     if (Size != sizeof(SgUnsignedShortVal)) {
  149863           0 :       void * object = ROSE_MALLOC(Size);
  149864           0 :       ALLOC_MUTEX(SgUnsignedShortVal, unlock);
  149865             :       return object;
  149866             :     }
  149867             : #endif
  149868             : 
  149869         219 :     if (SgUnsignedShortVal::next_node == nullptr) {
  149870           9 :         SgUnsignedShortVal * alloc = (SgUnsignedShortVal*) ROSE_MALLOC ( SgUnsignedShortVal::pool_size * sizeof(SgUnsignedShortVal) );
  149871           9 :         ROSE_ASSERT(alloc != nullptr);
  149872             : 
  149873             : #if ROSE_ALLOC_TRACE == 2
  149874             : //        printf("SgUnsignedShortVal::alloc\n  block[%zi] = [ %p , %p [\n", SgUnsignedShortVal::pools.size(), alloc, alloc + SgUnsignedShortVal::pool_size);
  149875             : #endif
  149876             : 
  149877             : #if ROSE_ALLOC_MEMSET == 1
  149878             : #elif ROSE_ALLOC_MEMSET == 2
  149879             :         memset(alloc, 0x00, SgUnsignedShortVal::pool_size * sizeof(SgUnsignedShortVal));
  149880             : #elif ROSE_ALLOC_MEMSET == 3
  149881             :         memset(alloc, 0xAA, SgUnsignedShortVal::pool_size * sizeof(SgUnsignedShortVal));
  149882             : #endif
  149883       18000 :         for (unsigned i=0; i < SgUnsignedShortVal::pool_size-1; i++) {
  149884       17991 :           alloc[i].p_freepointer = &(alloc[i+1]);
  149885             :         }
  149886           9 :         alloc[SgUnsignedShortVal::pool_size-1].p_freepointer = nullptr;
  149887             : 
  149888           9 :         SgUnsignedShortVal::pools.push_back ( (unsigned char *) alloc );
  149889           9 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgUnsignedShortVal::pool_size * sizeof(SgUnsignedShortVal), V_SgUnsignedShortVal ) );
  149890           9 :         SgUnsignedShortVal::next_node = alloc;
  149891             :     }
  149892         219 :     ROSE_ASSERT(SgUnsignedShortVal::next_node != nullptr);
  149893             : 
  149894         219 :     SgUnsignedShortVal * object = SgUnsignedShortVal::next_node;
  149895         219 :     SgUnsignedShortVal::next_node = (SgUnsignedShortVal*)(object->p_freepointer);
  149896             : 
  149897             : #if ROSE_ALLOC_TRACE == 2
  149898             :     printf("SgUnsignedShortVal::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUnsignedShortVal::next_node);
  149899             : #endif
  149900             : 
  149901         219 :     SgNode * fp = object->p_freepointer;
  149902             : #if ROSE_ALLOC_MEMSET == 1
  149903             : #elif ROSE_ALLOC_MEMSET == 2
  149904             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgUnsignedShortVal) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  149905             : #elif ROSE_ALLOC_MEMSET == 3
  149906             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgUnsignedShortVal) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  149907             : #endif
  149908         219 :     object->p_freepointer = fp;
  149909             : 
  149910             : #if ROSE_ALLOC_TRACE == 2
  149911             : //    printf("SgUnsignedShortVal::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUnsignedShortVal::next_node);
  149912             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  149913             :     Rose::MemPool::snapshot(oss.str());
  149914             :     alloc_trace_cnt++;
  149915             : #endif
  149916             : 
  149917         219 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  149918             : 
  149919         219 :     ALLOC_MUTEX(SgUnsignedShortVal, unlock);
  149920             : 
  149921             :     return object;
  149922             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  149923             : }
  149924             : 
  149925             : 
  149926             : 
  149927             : /*! \brief Delete operator for SgUnsignedShortVal.
  149928             : 
  149929             :    This delete operator implements deallocation using memory pools to 
  149930             :    provide most efficent use of the heap within construction of large ASTs.
  149931             : 
  149932             : \internal The new and delete operators use the lower level C malloc/free
  149933             :    function calls for performance and to make sure that mixing of malloc/free
  149934             :    and new/delete by the used can be caught more readily.  This may change
  149935             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  149936             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  149937             :    deallocate memory allocated using ROSE_MALLOC.
  149938             : */
  149939         217 : void SgUnsignedShortVal::operator delete(void *Pointer, size_t Size)
  149940             : {
  149941             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  149942             :      * or throwing an exception. */
  149943         217 :     ALLOC_MUTEX(SgUnsignedShortVal, lock);
  149944             : 
  149945             : #if USE_CPP_NEW_DELETE_OPERATORS
  149946             :     ROSE_FREE(Pointer);
  149947             : #else
  149948             : #if ROSE_PEDANTIC_ALLOC
  149949             :     ROSE_ASSERT(Size == sizeof(SgUnsignedShortVal));
  149950             : #else
  149951         217 :     if (Size != sizeof(SgUnsignedShortVal)) {
  149952           0 :       ROSE_FREE(Pointer);
  149953           0 :       ALLOC_MUTEX(SgUnsignedShortVal, unlock);
  149954             :       return;
  149955             :     }
  149956             : #endif
  149957             : 
  149958         217 :     SgUnsignedShortVal * object = (SgUnsignedShortVal*) Pointer;
  149959         217 :     ROSE_ASSERT(object != nullptr);
  149960             : 
  149961             : #if ROSE_ALLOC_TRACE == 2
  149962             : //  printf("SgUnsignedShortVal::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUnsignedShortVal::next_node);
  149963             :     printf("SgUnsignedShortVal::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUnsignedShortVal::next_node);
  149964             : #endif
  149965             : 
  149966             : #if ROSE_PEDANTIC_ALLOC
  149967             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  149968             : #endif
  149969             : 
  149970             : #if ROSE_ALLOC_MEMSET == 1
  149971             : #elif ROSE_ALLOC_MEMSET == 2
  149972             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgUnsignedShortVal) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  149973             : #elif ROSE_ALLOC_MEMSET == 3
  149974             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgUnsignedShortVal) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  149975             : #endif
  149976             : 
  149977             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  149978             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  149979             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  149980             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  149981             : #else
  149982         217 :     object->p_freepointer = SgUnsignedShortVal::next_node;
  149983         217 :     SgUnsignedShortVal::next_node = object;
  149984             : #endif
  149985             : 
  149986             : #if ROSE_ALLOC_TRACE == 2
  149987             : //  printf("SgUnsignedShortVal::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUnsignedShortVal::next_node);
  149988             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  149989             :     Rose::MemPool::snapshot(oss.str());
  149990             :     alloc_trace_cnt++;
  149991             : #endif
  149992             : 
  149993             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  149994             : 
  149995         217 :     ALLOC_MUTEX(SgUnsignedShortVal, unlock);
  149996             : }
  149997             : 
  149998             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  149999             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  150000             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  150001             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  150002             : // Also, note comment below from Robb (copied from the Common.code file).
  150003             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  150004             : //
  150005             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  150006             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  150007             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  150008             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  150009             : #if 0
  150010             : void SgUnsignedShortVal::operator delete(void* pointer) { SgUnsignedShortVal::operator delete (pointer, sizeof(SgUnsignedShortVal)); };
  150011             : #endif
  150012             : /* #line 150013 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  150013             : 
  150014             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  150015             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  150016             : // obviously imply C++.
  150017             : 
  150018             : // This implements the support within ROSE for memory pools.  Memory pools
  150019             : // support the most condensed usage of memory within the construction of
  150020             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  150021             : // by a new operator written for each class.
  150022             : 
  150023             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  150024             :     // User wants multi-thread support and POSIX threads are available.
  150025             : #   include <pthread.h>
  150026             :     static pthread_mutex_t SgIntVal_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  150027             : #else
  150028             :      // Cause synchronization to be skipped.
  150029             : #    ifndef ALLOC_MUTEX
  150030             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  150031             : #    endif
  150032             : #    ifdef _REENTRANT
  150033             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  150034             : #       ifdef _MSC_VER
  150035             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  150036             : #       else
  150037             : #           warning "POSIX threads are not available; synchronization being skipped"
  150038             : #       endif
  150039             : #    endif
  150040             : #endif
  150041             : 
  150042             : #ifndef ROSE_ALLOC_TRACE
  150043             : #  define ROSE_ALLOC_TRACE 0
  150044             : #endif
  150045             : 
  150046             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  150047             : #define ROSE_ALLOC_TRACE_CNT
  150048             : #include "memory-pool-snapshot.h"
  150049             : unsigned long alloc_trace_cnt = 0;
  150050             : #endif
  150051             : 
  150052             : #if ROSE_ALLOC_TRACE
  150053             : const unsigned SgIntVal::pool_size = 5;
  150054             : #else
  150055             : const unsigned SgIntVal::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  150056             : #endif
  150057             : 
  150058             : #ifndef ROSE_ALLOC_MEMSET
  150059             : #  define ROSE_ALLOC_MEMSET 0
  150060             : #endif
  150061             : 
  150062             : #ifndef ROSE_PEDANTIC_ALLOC
  150063             : #  define ROSE_PEDANTIC_ALLOC 0
  150064             : #endif
  150065             : 
  150066             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  150067             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  150068             : #endif
  150069             : 
  150070             : #if !defined(SGNODE__ALL_POOLS)
  150071             : #define SGNODE__ALL_POOLS
  150072             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  150073             : #endif
  150074             : 
  150075             : SgIntVal* SgIntVal::next_node = nullptr;
  150076             : std::vector<unsigned char*> SgIntVal::pools;
  150077             : 
  150078             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  150079             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  150080             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  150081             : // around this macro definition rather than each use).
  150082             : #ifndef ALLOC_MUTEX
  150083             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  150084             :         do {                                                                     \
  150085             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  150086             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  150087             :                 abort();                                                         \
  150088             :             }                                                                    \
  150089             :         } while (0);
  150090             : #endif
  150091             : 
  150092             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  150093             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  150094             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  150095             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  150096             : 
  150097             : /*! \brief New operator for SgIntVal.
  150098             : 
  150099             :    This new operator implements memory pools to provide most efficent 
  150100             :    use of the heap within construction of large ASTs.
  150101             : 
  150102             : \internal The new and delete operators use the lower level C malloc/free
  150103             :    function calls for performance and to make sure that mixing of malloc/free
  150104             :    and new/delete by the used can be caught more readily.  This may change
  150105             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  150106             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  150107             :    deallocate memory allocated using ROSE_MALLOC.
  150108             : */
  150109       30689 : void *SgIntVal::operator new ( size_t Size )
  150110             : {
  150111             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  150112             :      * returning or throwing an exception. */
  150113       30689 :     ALLOC_MUTEX(SgIntVal, lock);
  150114             : 
  150115             : #if ROSE_ALLOC_TRACE == 2
  150116             : //    printf("SgIntVal::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgIntVal::next_node);
  150117             : #endif
  150118             : 
  150119             : #if USE_CPP_NEW_DELETE_OPERATORS
  150120             :     void *mem = ROSE_MALLOC(Size);
  150121             :     ALLOC_MUTEX(SgIntVal, unlock);
  150122             :     return mem;
  150123             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  150124             : #if ROSE_PEDANTIC_ALLOC
  150125             :     ROSE_ASSERT(Size == sizeof(SgIntVal));
  150126             : #else
  150127       30689 :     if (Size != sizeof(SgIntVal)) {
  150128           0 :       void * object = ROSE_MALLOC(Size);
  150129           0 :       ALLOC_MUTEX(SgIntVal, unlock);
  150130             :       return object;
  150131             :     }
  150132             : #endif
  150133             : 
  150134       30689 :     if (SgIntVal::next_node == nullptr) {
  150135         316 :         SgIntVal * alloc = (SgIntVal*) ROSE_MALLOC ( SgIntVal::pool_size * sizeof(SgIntVal) );
  150136         316 :         ROSE_ASSERT(alloc != nullptr);
  150137             : 
  150138             : #if ROSE_ALLOC_TRACE == 2
  150139             : //        printf("SgIntVal::alloc\n  block[%zi] = [ %p , %p [\n", SgIntVal::pools.size(), alloc, alloc + SgIntVal::pool_size);
  150140             : #endif
  150141             : 
  150142             : #if ROSE_ALLOC_MEMSET == 1
  150143             : #elif ROSE_ALLOC_MEMSET == 2
  150144             :         memset(alloc, 0x00, SgIntVal::pool_size * sizeof(SgIntVal));
  150145             : #elif ROSE_ALLOC_MEMSET == 3
  150146             :         memset(alloc, 0xAA, SgIntVal::pool_size * sizeof(SgIntVal));
  150147             : #endif
  150148      632000 :         for (unsigned i=0; i < SgIntVal::pool_size-1; i++) {
  150149      631684 :           alloc[i].p_freepointer = &(alloc[i+1]);
  150150             :         }
  150151         316 :         alloc[SgIntVal::pool_size-1].p_freepointer = nullptr;
  150152             : 
  150153         316 :         SgIntVal::pools.push_back ( (unsigned char *) alloc );
  150154         316 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgIntVal::pool_size * sizeof(SgIntVal), V_SgIntVal ) );
  150155         316 :         SgIntVal::next_node = alloc;
  150156             :     }
  150157       30689 :     ROSE_ASSERT(SgIntVal::next_node != nullptr);
  150158             : 
  150159       30689 :     SgIntVal * object = SgIntVal::next_node;
  150160       30689 :     SgIntVal::next_node = (SgIntVal*)(object->p_freepointer);
  150161             : 
  150162             : #if ROSE_ALLOC_TRACE == 2
  150163             :     printf("SgIntVal::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgIntVal::next_node);
  150164             : #endif
  150165             : 
  150166       30689 :     SgNode * fp = object->p_freepointer;
  150167             : #if ROSE_ALLOC_MEMSET == 1
  150168             : #elif ROSE_ALLOC_MEMSET == 2
  150169             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgIntVal) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  150170             : #elif ROSE_ALLOC_MEMSET == 3
  150171             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgIntVal) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  150172             : #endif
  150173       30689 :     object->p_freepointer = fp;
  150174             : 
  150175             : #if ROSE_ALLOC_TRACE == 2
  150176             : //    printf("SgIntVal::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgIntVal::next_node);
  150177             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  150178             :     Rose::MemPool::snapshot(oss.str());
  150179             :     alloc_trace_cnt++;
  150180             : #endif
  150181             : 
  150182       30689 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  150183             : 
  150184       30689 :     ALLOC_MUTEX(SgIntVal, unlock);
  150185             : 
  150186             :     return object;
  150187             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  150188             : }
  150189             : 
  150190             : 
  150191             : 
  150192             : /*! \brief Delete operator for SgIntVal.
  150193             : 
  150194             :    This delete operator implements deallocation using memory pools to 
  150195             :    provide most efficent use of the heap within construction of large ASTs.
  150196             : 
  150197             : \internal The new and delete operators use the lower level C malloc/free
  150198             :    function calls for performance and to make sure that mixing of malloc/free
  150199             :    and new/delete by the used can be caught more readily.  This may change
  150200             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  150201             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  150202             :    deallocate memory allocated using ROSE_MALLOC.
  150203             : */
  150204       13280 : void SgIntVal::operator delete(void *Pointer, size_t Size)
  150205             : {
  150206             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  150207             :      * or throwing an exception. */
  150208       13280 :     ALLOC_MUTEX(SgIntVal, lock);
  150209             : 
  150210             : #if USE_CPP_NEW_DELETE_OPERATORS
  150211             :     ROSE_FREE(Pointer);
  150212             : #else
  150213             : #if ROSE_PEDANTIC_ALLOC
  150214             :     ROSE_ASSERT(Size == sizeof(SgIntVal));
  150215             : #else
  150216       13280 :     if (Size != sizeof(SgIntVal)) {
  150217           0 :       ROSE_FREE(Pointer);
  150218           0 :       ALLOC_MUTEX(SgIntVal, unlock);
  150219             :       return;
  150220             :     }
  150221             : #endif
  150222             : 
  150223       13280 :     SgIntVal * object = (SgIntVal*) Pointer;
  150224       13280 :     ROSE_ASSERT(object != nullptr);
  150225             : 
  150226             : #if ROSE_ALLOC_TRACE == 2
  150227             : //  printf("SgIntVal::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgIntVal::next_node);
  150228             :     printf("SgIntVal::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgIntVal::next_node);
  150229             : #endif
  150230             : 
  150231             : #if ROSE_PEDANTIC_ALLOC
  150232             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  150233             : #endif
  150234             : 
  150235             : #if ROSE_ALLOC_MEMSET == 1
  150236             : #elif ROSE_ALLOC_MEMSET == 2
  150237             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgIntVal) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  150238             : #elif ROSE_ALLOC_MEMSET == 3
  150239             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgIntVal) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  150240             : #endif
  150241             : 
  150242             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  150243             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  150244             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  150245             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  150246             : #else
  150247       13280 :     object->p_freepointer = SgIntVal::next_node;
  150248       13280 :     SgIntVal::next_node = object;
  150249             : #endif
  150250             : 
  150251             : #if ROSE_ALLOC_TRACE == 2
  150252             : //  printf("SgIntVal::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgIntVal::next_node);
  150253             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  150254             :     Rose::MemPool::snapshot(oss.str());
  150255             :     alloc_trace_cnt++;
  150256             : #endif
  150257             : 
  150258             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  150259             : 
  150260       13280 :     ALLOC_MUTEX(SgIntVal, unlock);
  150261             : }
  150262             : 
  150263             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  150264             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  150265             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  150266             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  150267             : // Also, note comment below from Robb (copied from the Common.code file).
  150268             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  150269             : //
  150270             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  150271             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  150272             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  150273             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  150274             : #if 0
  150275             : void SgIntVal::operator delete(void* pointer) { SgIntVal::operator delete (pointer, sizeof(SgIntVal)); };
  150276             : #endif
  150277             : /* #line 150278 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  150278             : 
  150279             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  150280             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  150281             : // obviously imply C++.
  150282             : 
  150283             : // This implements the support within ROSE for memory pools.  Memory pools
  150284             : // support the most condensed usage of memory within the construction of
  150285             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  150286             : // by a new operator written for each class.
  150287             : 
  150288             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  150289             :     // User wants multi-thread support and POSIX threads are available.
  150290             : #   include <pthread.h>
  150291             :     static pthread_mutex_t SgEnumVal_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  150292             : #else
  150293             :      // Cause synchronization to be skipped.
  150294             : #    ifndef ALLOC_MUTEX
  150295             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  150296             : #    endif
  150297             : #    ifdef _REENTRANT
  150298             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  150299             : #       ifdef _MSC_VER
  150300             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  150301             : #       else
  150302             : #           warning "POSIX threads are not available; synchronization being skipped"
  150303             : #       endif
  150304             : #    endif
  150305             : #endif
  150306             : 
  150307             : #ifndef ROSE_ALLOC_TRACE
  150308             : #  define ROSE_ALLOC_TRACE 0
  150309             : #endif
  150310             : 
  150311             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  150312             : #define ROSE_ALLOC_TRACE_CNT
  150313             : #include "memory-pool-snapshot.h"
  150314             : unsigned long alloc_trace_cnt = 0;
  150315             : #endif
  150316             : 
  150317             : #if ROSE_ALLOC_TRACE
  150318             : const unsigned SgEnumVal::pool_size = 5;
  150319             : #else
  150320             : const unsigned SgEnumVal::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  150321             : #endif
  150322             : 
  150323             : #ifndef ROSE_ALLOC_MEMSET
  150324             : #  define ROSE_ALLOC_MEMSET 0
  150325             : #endif
  150326             : 
  150327             : #ifndef ROSE_PEDANTIC_ALLOC
  150328             : #  define ROSE_PEDANTIC_ALLOC 0
  150329             : #endif
  150330             : 
  150331             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  150332             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  150333             : #endif
  150334             : 
  150335             : #if !defined(SGNODE__ALL_POOLS)
  150336             : #define SGNODE__ALL_POOLS
  150337             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  150338             : #endif
  150339             : 
  150340             : SgEnumVal* SgEnumVal::next_node = nullptr;
  150341             : std::vector<unsigned char*> SgEnumVal::pools;
  150342             : 
  150343             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  150344             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  150345             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  150346             : // around this macro definition rather than each use).
  150347             : #ifndef ALLOC_MUTEX
  150348             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  150349             :         do {                                                                     \
  150350             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  150351             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  150352             :                 abort();                                                         \
  150353             :             }                                                                    \
  150354             :         } while (0);
  150355             : #endif
  150356             : 
  150357             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  150358             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  150359             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  150360             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  150361             : 
  150362             : /*! \brief New operator for SgEnumVal.
  150363             : 
  150364             :    This new operator implements memory pools to provide most efficent 
  150365             :    use of the heap within construction of large ASTs.
  150366             : 
  150367             : \internal The new and delete operators use the lower level C malloc/free
  150368             :    function calls for performance and to make sure that mixing of malloc/free
  150369             :    and new/delete by the used can be caught more readily.  This may change
  150370             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  150371             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  150372             :    deallocate memory allocated using ROSE_MALLOC.
  150373             : */
  150374       12748 : void *SgEnumVal::operator new ( size_t Size )
  150375             : {
  150376             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  150377             :      * returning or throwing an exception. */
  150378       12748 :     ALLOC_MUTEX(SgEnumVal, lock);
  150379             : 
  150380             : #if ROSE_ALLOC_TRACE == 2
  150381             : //    printf("SgEnumVal::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgEnumVal::next_node);
  150382             : #endif
  150383             : 
  150384             : #if USE_CPP_NEW_DELETE_OPERATORS
  150385             :     void *mem = ROSE_MALLOC(Size);
  150386             :     ALLOC_MUTEX(SgEnumVal, unlock);
  150387             :     return mem;
  150388             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  150389             : #if ROSE_PEDANTIC_ALLOC
  150390             :     ROSE_ASSERT(Size == sizeof(SgEnumVal));
  150391             : #else
  150392       12748 :     if (Size != sizeof(SgEnumVal)) {
  150393           0 :       void * object = ROSE_MALLOC(Size);
  150394           0 :       ALLOC_MUTEX(SgEnumVal, unlock);
  150395             :       return object;
  150396             :     }
  150397             : #endif
  150398             : 
  150399       12748 :     if (SgEnumVal::next_node == nullptr) {
  150400         183 :         SgEnumVal * alloc = (SgEnumVal*) ROSE_MALLOC ( SgEnumVal::pool_size * sizeof(SgEnumVal) );
  150401         183 :         ROSE_ASSERT(alloc != nullptr);
  150402             : 
  150403             : #if ROSE_ALLOC_TRACE == 2
  150404             : //        printf("SgEnumVal::alloc\n  block[%zi] = [ %p , %p [\n", SgEnumVal::pools.size(), alloc, alloc + SgEnumVal::pool_size);
  150405             : #endif
  150406             : 
  150407             : #if ROSE_ALLOC_MEMSET == 1
  150408             : #elif ROSE_ALLOC_MEMSET == 2
  150409             :         memset(alloc, 0x00, SgEnumVal::pool_size * sizeof(SgEnumVal));
  150410             : #elif ROSE_ALLOC_MEMSET == 3
  150411             :         memset(alloc, 0xAA, SgEnumVal::pool_size * sizeof(SgEnumVal));
  150412             : #endif
  150413      366000 :         for (unsigned i=0; i < SgEnumVal::pool_size-1; i++) {
  150414      365817 :           alloc[i].p_freepointer = &(alloc[i+1]);
  150415             :         }
  150416         183 :         alloc[SgEnumVal::pool_size-1].p_freepointer = nullptr;
  150417             : 
  150418         183 :         SgEnumVal::pools.push_back ( (unsigned char *) alloc );
  150419         183 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgEnumVal::pool_size * sizeof(SgEnumVal), V_SgEnumVal ) );
  150420         183 :         SgEnumVal::next_node = alloc;
  150421             :     }
  150422       12748 :     ROSE_ASSERT(SgEnumVal::next_node != nullptr);
  150423             : 
  150424       12748 :     SgEnumVal * object = SgEnumVal::next_node;
  150425       12748 :     SgEnumVal::next_node = (SgEnumVal*)(object->p_freepointer);
  150426             : 
  150427             : #if ROSE_ALLOC_TRACE == 2
  150428             :     printf("SgEnumVal::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgEnumVal::next_node);
  150429             : #endif
  150430             : 
  150431       12748 :     SgNode * fp = object->p_freepointer;
  150432             : #if ROSE_ALLOC_MEMSET == 1
  150433             : #elif ROSE_ALLOC_MEMSET == 2
  150434             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgEnumVal) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  150435             : #elif ROSE_ALLOC_MEMSET == 3
  150436             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgEnumVal) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  150437             : #endif
  150438       12748 :     object->p_freepointer = fp;
  150439             : 
  150440             : #if ROSE_ALLOC_TRACE == 2
  150441             : //    printf("SgEnumVal::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgEnumVal::next_node);
  150442             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  150443             :     Rose::MemPool::snapshot(oss.str());
  150444             :     alloc_trace_cnt++;
  150445             : #endif
  150446             : 
  150447       12748 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  150448             : 
  150449       12748 :     ALLOC_MUTEX(SgEnumVal, unlock);
  150450             : 
  150451             :     return object;
  150452             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  150453             : }
  150454             : 
  150455             : 
  150456             : 
  150457             : /*! \brief Delete operator for SgEnumVal.
  150458             : 
  150459             :    This delete operator implements deallocation using memory pools to 
  150460             :    provide most efficent use of the heap within construction of large ASTs.
  150461             : 
  150462             : \internal The new and delete operators use the lower level C malloc/free
  150463             :    function calls for performance and to make sure that mixing of malloc/free
  150464             :    and new/delete by the used can be caught more readily.  This may change
  150465             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  150466             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  150467             :    deallocate memory allocated using ROSE_MALLOC.
  150468             : */
  150469        4013 : void SgEnumVal::operator delete(void *Pointer, size_t Size)
  150470             : {
  150471             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  150472             :      * or throwing an exception. */
  150473        4013 :     ALLOC_MUTEX(SgEnumVal, lock);
  150474             : 
  150475             : #if USE_CPP_NEW_DELETE_OPERATORS
  150476             :     ROSE_FREE(Pointer);
  150477             : #else
  150478             : #if ROSE_PEDANTIC_ALLOC
  150479             :     ROSE_ASSERT(Size == sizeof(SgEnumVal));
  150480             : #else
  150481        4013 :     if (Size != sizeof(SgEnumVal)) {
  150482           0 :       ROSE_FREE(Pointer);
  150483           0 :       ALLOC_MUTEX(SgEnumVal, unlock);
  150484             :       return;
  150485             :     }
  150486             : #endif
  150487             : 
  150488        4013 :     SgEnumVal * object = (SgEnumVal*) Pointer;
  150489        4013 :     ROSE_ASSERT(object != nullptr);
  150490             : 
  150491             : #if ROSE_ALLOC_TRACE == 2
  150492             : //  printf("SgEnumVal::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgEnumVal::next_node);
  150493             :     printf("SgEnumVal::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgEnumVal::next_node);
  150494             : #endif
  150495             : 
  150496             : #if ROSE_PEDANTIC_ALLOC
  150497             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  150498             : #endif
  150499             : 
  150500             : #if ROSE_ALLOC_MEMSET == 1
  150501             : #elif ROSE_ALLOC_MEMSET == 2
  150502             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgEnumVal) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  150503             : #elif ROSE_ALLOC_MEMSET == 3
  150504             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgEnumVal) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  150505             : #endif
  150506             : 
  150507             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  150508             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  150509             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  150510             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  150511             : #else
  150512        4013 :     object->p_freepointer = SgEnumVal::next_node;
  150513        4013 :     SgEnumVal::next_node = object;
  150514             : #endif
  150515             : 
  150516             : #if ROSE_ALLOC_TRACE == 2
  150517             : //  printf("SgEnumVal::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgEnumVal::next_node);
  150518             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  150519             :     Rose::MemPool::snapshot(oss.str());
  150520             :     alloc_trace_cnt++;
  150521             : #endif
  150522             : 
  150523             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  150524             : 
  150525        4013 :     ALLOC_MUTEX(SgEnumVal, unlock);
  150526             : }
  150527             : 
  150528             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  150529             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  150530             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  150531             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  150532             : // Also, note comment below from Robb (copied from the Common.code file).
  150533             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  150534             : //
  150535             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  150536             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  150537             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  150538             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  150539             : #if 0
  150540             : void SgEnumVal::operator delete(void* pointer) { SgEnumVal::operator delete (pointer, sizeof(SgEnumVal)); };
  150541             : #endif
  150542             : /* #line 150543 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  150543             : 
  150544             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  150545             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  150546             : // obviously imply C++.
  150547             : 
  150548             : // This implements the support within ROSE for memory pools.  Memory pools
  150549             : // support the most condensed usage of memory within the construction of
  150550             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  150551             : // by a new operator written for each class.
  150552             : 
  150553             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  150554             :     // User wants multi-thread support and POSIX threads are available.
  150555             : #   include <pthread.h>
  150556             :     static pthread_mutex_t SgUnsignedIntVal_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  150557             : #else
  150558             :      // Cause synchronization to be skipped.
  150559             : #    ifndef ALLOC_MUTEX
  150560             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  150561             : #    endif
  150562             : #    ifdef _REENTRANT
  150563             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  150564             : #       ifdef _MSC_VER
  150565             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  150566             : #       else
  150567             : #           warning "POSIX threads are not available; synchronization being skipped"
  150568             : #       endif
  150569             : #    endif
  150570             : #endif
  150571             : 
  150572             : #ifndef ROSE_ALLOC_TRACE
  150573             : #  define ROSE_ALLOC_TRACE 0
  150574             : #endif
  150575             : 
  150576             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  150577             : #define ROSE_ALLOC_TRACE_CNT
  150578             : #include "memory-pool-snapshot.h"
  150579             : unsigned long alloc_trace_cnt = 0;
  150580             : #endif
  150581             : 
  150582             : #if ROSE_ALLOC_TRACE
  150583             : const unsigned SgUnsignedIntVal::pool_size = 5;
  150584             : #else
  150585             : const unsigned SgUnsignedIntVal::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  150586             : #endif
  150587             : 
  150588             : #ifndef ROSE_ALLOC_MEMSET
  150589             : #  define ROSE_ALLOC_MEMSET 0
  150590             : #endif
  150591             : 
  150592             : #ifndef ROSE_PEDANTIC_ALLOC
  150593             : #  define ROSE_PEDANTIC_ALLOC 0
  150594             : #endif
  150595             : 
  150596             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  150597             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  150598             : #endif
  150599             : 
  150600             : #if !defined(SGNODE__ALL_POOLS)
  150601             : #define SGNODE__ALL_POOLS
  150602             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  150603             : #endif
  150604             : 
  150605             : SgUnsignedIntVal* SgUnsignedIntVal::next_node = nullptr;
  150606             : std::vector<unsigned char*> SgUnsignedIntVal::pools;
  150607             : 
  150608             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  150609             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  150610             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  150611             : // around this macro definition rather than each use).
  150612             : #ifndef ALLOC_MUTEX
  150613             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  150614             :         do {                                                                     \
  150615             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  150616             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  150617             :                 abort();                                                         \
  150618             :             }                                                                    \
  150619             :         } while (0);
  150620             : #endif
  150621             : 
  150622             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  150623             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  150624             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  150625             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  150626             : 
  150627             : /*! \brief New operator for SgUnsignedIntVal.
  150628             : 
  150629             :    This new operator implements memory pools to provide most efficent 
  150630             :    use of the heap within construction of large ASTs.
  150631             : 
  150632             : \internal The new and delete operators use the lower level C malloc/free
  150633             :    function calls for performance and to make sure that mixing of malloc/free
  150634             :    and new/delete by the used can be caught more readily.  This may change
  150635             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  150636             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  150637             :    deallocate memory allocated using ROSE_MALLOC.
  150638             : */
  150639         259 : void *SgUnsignedIntVal::operator new ( size_t Size )
  150640             : {
  150641             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  150642             :      * returning or throwing an exception. */
  150643         259 :     ALLOC_MUTEX(SgUnsignedIntVal, lock);
  150644             : 
  150645             : #if ROSE_ALLOC_TRACE == 2
  150646             : //    printf("SgUnsignedIntVal::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgUnsignedIntVal::next_node);
  150647             : #endif
  150648             : 
  150649             : #if USE_CPP_NEW_DELETE_OPERATORS
  150650             :     void *mem = ROSE_MALLOC(Size);
  150651             :     ALLOC_MUTEX(SgUnsignedIntVal, unlock);
  150652             :     return mem;
  150653             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  150654             : #if ROSE_PEDANTIC_ALLOC
  150655             :     ROSE_ASSERT(Size == sizeof(SgUnsignedIntVal));
  150656             : #else
  150657         259 :     if (Size != sizeof(SgUnsignedIntVal)) {
  150658           0 :       void * object = ROSE_MALLOC(Size);
  150659           0 :       ALLOC_MUTEX(SgUnsignedIntVal, unlock);
  150660             :       return object;
  150661             :     }
  150662             : #endif
  150663             : 
  150664         259 :     if (SgUnsignedIntVal::next_node == nullptr) {
  150665          43 :         SgUnsignedIntVal * alloc = (SgUnsignedIntVal*) ROSE_MALLOC ( SgUnsignedIntVal::pool_size * sizeof(SgUnsignedIntVal) );
  150666          43 :         ROSE_ASSERT(alloc != nullptr);
  150667             : 
  150668             : #if ROSE_ALLOC_TRACE == 2
  150669             : //        printf("SgUnsignedIntVal::alloc\n  block[%zi] = [ %p , %p [\n", SgUnsignedIntVal::pools.size(), alloc, alloc + SgUnsignedIntVal::pool_size);
  150670             : #endif
  150671             : 
  150672             : #if ROSE_ALLOC_MEMSET == 1
  150673             : #elif ROSE_ALLOC_MEMSET == 2
  150674             :         memset(alloc, 0x00, SgUnsignedIntVal::pool_size * sizeof(SgUnsignedIntVal));
  150675             : #elif ROSE_ALLOC_MEMSET == 3
  150676             :         memset(alloc, 0xAA, SgUnsignedIntVal::pool_size * sizeof(SgUnsignedIntVal));
  150677             : #endif
  150678       86000 :         for (unsigned i=0; i < SgUnsignedIntVal::pool_size-1; i++) {
  150679       85957 :           alloc[i].p_freepointer = &(alloc[i+1]);
  150680             :         }
  150681          43 :         alloc[SgUnsignedIntVal::pool_size-1].p_freepointer = nullptr;
  150682             : 
  150683          43 :         SgUnsignedIntVal::pools.push_back ( (unsigned char *) alloc );
  150684          43 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgUnsignedIntVal::pool_size * sizeof(SgUnsignedIntVal), V_SgUnsignedIntVal ) );
  150685          43 :         SgUnsignedIntVal::next_node = alloc;
  150686             :     }
  150687         259 :     ROSE_ASSERT(SgUnsignedIntVal::next_node != nullptr);
  150688             : 
  150689         259 :     SgUnsignedIntVal * object = SgUnsignedIntVal::next_node;
  150690         259 :     SgUnsignedIntVal::next_node = (SgUnsignedIntVal*)(object->p_freepointer);
  150691             : 
  150692             : #if ROSE_ALLOC_TRACE == 2
  150693             :     printf("SgUnsignedIntVal::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUnsignedIntVal::next_node);
  150694             : #endif
  150695             : 
  150696         259 :     SgNode * fp = object->p_freepointer;
  150697             : #if ROSE_ALLOC_MEMSET == 1
  150698             : #elif ROSE_ALLOC_MEMSET == 2
  150699             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgUnsignedIntVal) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  150700             : #elif ROSE_ALLOC_MEMSET == 3
  150701             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgUnsignedIntVal) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  150702             : #endif
  150703         259 :     object->p_freepointer = fp;
  150704             : 
  150705             : #if ROSE_ALLOC_TRACE == 2
  150706             : //    printf("SgUnsignedIntVal::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUnsignedIntVal::next_node);
  150707             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  150708             :     Rose::MemPool::snapshot(oss.str());
  150709             :     alloc_trace_cnt++;
  150710             : #endif
  150711             : 
  150712         259 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  150713             : 
  150714         259 :     ALLOC_MUTEX(SgUnsignedIntVal, unlock);
  150715             : 
  150716             :     return object;
  150717             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  150718             : }
  150719             : 
  150720             : 
  150721             : 
  150722             : /*! \brief Delete operator for SgUnsignedIntVal.
  150723             : 
  150724             :    This delete operator implements deallocation using memory pools to 
  150725             :    provide most efficent use of the heap within construction of large ASTs.
  150726             : 
  150727             : \internal The new and delete operators use the lower level C malloc/free
  150728             :    function calls for performance and to make sure that mixing of malloc/free
  150729             :    and new/delete by the used can be caught more readily.  This may change
  150730             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  150731             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  150732             :    deallocate memory allocated using ROSE_MALLOC.
  150733             : */
  150734         186 : void SgUnsignedIntVal::operator delete(void *Pointer, size_t Size)
  150735             : {
  150736             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  150737             :      * or throwing an exception. */
  150738         186 :     ALLOC_MUTEX(SgUnsignedIntVal, lock);
  150739             : 
  150740             : #if USE_CPP_NEW_DELETE_OPERATORS
  150741             :     ROSE_FREE(Pointer);
  150742             : #else
  150743             : #if ROSE_PEDANTIC_ALLOC
  150744             :     ROSE_ASSERT(Size == sizeof(SgUnsignedIntVal));
  150745             : #else
  150746         186 :     if (Size != sizeof(SgUnsignedIntVal)) {
  150747           0 :       ROSE_FREE(Pointer);
  150748           0 :       ALLOC_MUTEX(SgUnsignedIntVal, unlock);
  150749             :       return;
  150750             :     }
  150751             : #endif
  150752             : 
  150753         186 :     SgUnsignedIntVal * object = (SgUnsignedIntVal*) Pointer;
  150754         186 :     ROSE_ASSERT(object != nullptr);
  150755             : 
  150756             : #if ROSE_ALLOC_TRACE == 2
  150757             : //  printf("SgUnsignedIntVal::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUnsignedIntVal::next_node);
  150758             :     printf("SgUnsignedIntVal::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUnsignedIntVal::next_node);
  150759             : #endif
  150760             : 
  150761             : #if ROSE_PEDANTIC_ALLOC
  150762             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  150763             : #endif
  150764             : 
  150765             : #if ROSE_ALLOC_MEMSET == 1
  150766             : #elif ROSE_ALLOC_MEMSET == 2
  150767             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgUnsignedIntVal) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  150768             : #elif ROSE_ALLOC_MEMSET == 3
  150769             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgUnsignedIntVal) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  150770             : #endif
  150771             : 
  150772             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  150773             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  150774             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  150775             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  150776             : #else
  150777         186 :     object->p_freepointer = SgUnsignedIntVal::next_node;
  150778         186 :     SgUnsignedIntVal::next_node = object;
  150779             : #endif
  150780             : 
  150781             : #if ROSE_ALLOC_TRACE == 2
  150782             : //  printf("SgUnsignedIntVal::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUnsignedIntVal::next_node);
  150783             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  150784             :     Rose::MemPool::snapshot(oss.str());
  150785             :     alloc_trace_cnt++;
  150786             : #endif
  150787             : 
  150788             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  150789             : 
  150790         186 :     ALLOC_MUTEX(SgUnsignedIntVal, unlock);
  150791             : }
  150792             : 
  150793             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  150794             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  150795             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  150796             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  150797             : // Also, note comment below from Robb (copied from the Common.code file).
  150798             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  150799             : //
  150800             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  150801             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  150802             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  150803             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  150804             : #if 0
  150805             : void SgUnsignedIntVal::operator delete(void* pointer) { SgUnsignedIntVal::operator delete (pointer, sizeof(SgUnsignedIntVal)); };
  150806             : #endif
  150807             : /* #line 150808 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  150808             : 
  150809             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  150810             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  150811             : // obviously imply C++.
  150812             : 
  150813             : // This implements the support within ROSE for memory pools.  Memory pools
  150814             : // support the most condensed usage of memory within the construction of
  150815             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  150816             : // by a new operator written for each class.
  150817             : 
  150818             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  150819             :     // User wants multi-thread support and POSIX threads are available.
  150820             : #   include <pthread.h>
  150821             :     static pthread_mutex_t SgLongIntVal_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  150822             : #else
  150823             :      // Cause synchronization to be skipped.
  150824             : #    ifndef ALLOC_MUTEX
  150825             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  150826             : #    endif
  150827             : #    ifdef _REENTRANT
  150828             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  150829             : #       ifdef _MSC_VER
  150830             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  150831             : #       else
  150832             : #           warning "POSIX threads are not available; synchronization being skipped"
  150833             : #       endif
  150834             : #    endif
  150835             : #endif
  150836             : 
  150837             : #ifndef ROSE_ALLOC_TRACE
  150838             : #  define ROSE_ALLOC_TRACE 0
  150839             : #endif
  150840             : 
  150841             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  150842             : #define ROSE_ALLOC_TRACE_CNT
  150843             : #include "memory-pool-snapshot.h"
  150844             : unsigned long alloc_trace_cnt = 0;
  150845             : #endif
  150846             : 
  150847             : #if ROSE_ALLOC_TRACE
  150848             : const unsigned SgLongIntVal::pool_size = 5;
  150849             : #else
  150850             : const unsigned SgLongIntVal::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  150851             : #endif
  150852             : 
  150853             : #ifndef ROSE_ALLOC_MEMSET
  150854             : #  define ROSE_ALLOC_MEMSET 0
  150855             : #endif
  150856             : 
  150857             : #ifndef ROSE_PEDANTIC_ALLOC
  150858             : #  define ROSE_PEDANTIC_ALLOC 0
  150859             : #endif
  150860             : 
  150861             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  150862             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  150863             : #endif
  150864             : 
  150865             : #if !defined(SGNODE__ALL_POOLS)
  150866             : #define SGNODE__ALL_POOLS
  150867             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  150868             : #endif
  150869             : 
  150870             : SgLongIntVal* SgLongIntVal::next_node = nullptr;
  150871             : std::vector<unsigned char*> SgLongIntVal::pools;
  150872             : 
  150873             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  150874             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  150875             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  150876             : // around this macro definition rather than each use).
  150877             : #ifndef ALLOC_MUTEX
  150878             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  150879             :         do {                                                                     \
  150880             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  150881             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  150882             :                 abort();                                                         \
  150883             :             }                                                                    \
  150884             :         } while (0);
  150885             : #endif
  150886             : 
  150887             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  150888             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  150889             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  150890             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  150891             : 
  150892             : /*! \brief New operator for SgLongIntVal.
  150893             : 
  150894             :    This new operator implements memory pools to provide most efficent 
  150895             :    use of the heap within construction of large ASTs.
  150896             : 
  150897             : \internal The new and delete operators use the lower level C malloc/free
  150898             :    function calls for performance and to make sure that mixing of malloc/free
  150899             :    and new/delete by the used can be caught more readily.  This may change
  150900             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  150901             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  150902             :    deallocate memory allocated using ROSE_MALLOC.
  150903             : */
  150904        1940 : void *SgLongIntVal::operator new ( size_t Size )
  150905             : {
  150906             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  150907             :      * returning or throwing an exception. */
  150908        1940 :     ALLOC_MUTEX(SgLongIntVal, lock);
  150909             : 
  150910             : #if ROSE_ALLOC_TRACE == 2
  150911             : //    printf("SgLongIntVal::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgLongIntVal::next_node);
  150912             : #endif
  150913             : 
  150914             : #if USE_CPP_NEW_DELETE_OPERATORS
  150915             :     void *mem = ROSE_MALLOC(Size);
  150916             :     ALLOC_MUTEX(SgLongIntVal, unlock);
  150917             :     return mem;
  150918             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  150919             : #if ROSE_PEDANTIC_ALLOC
  150920             :     ROSE_ASSERT(Size == sizeof(SgLongIntVal));
  150921             : #else
  150922        1940 :     if (Size != sizeof(SgLongIntVal)) {
  150923           0 :       void * object = ROSE_MALLOC(Size);
  150924           0 :       ALLOC_MUTEX(SgLongIntVal, unlock);
  150925             :       return object;
  150926             :     }
  150927             : #endif
  150928             : 
  150929        1940 :     if (SgLongIntVal::next_node == nullptr) {
  150930          17 :         SgLongIntVal * alloc = (SgLongIntVal*) ROSE_MALLOC ( SgLongIntVal::pool_size * sizeof(SgLongIntVal) );
  150931          17 :         ROSE_ASSERT(alloc != nullptr);
  150932             : 
  150933             : #if ROSE_ALLOC_TRACE == 2
  150934             : //        printf("SgLongIntVal::alloc\n  block[%zi] = [ %p , %p [\n", SgLongIntVal::pools.size(), alloc, alloc + SgLongIntVal::pool_size);
  150935             : #endif
  150936             : 
  150937             : #if ROSE_ALLOC_MEMSET == 1
  150938             : #elif ROSE_ALLOC_MEMSET == 2
  150939             :         memset(alloc, 0x00, SgLongIntVal::pool_size * sizeof(SgLongIntVal));
  150940             : #elif ROSE_ALLOC_MEMSET == 3
  150941             :         memset(alloc, 0xAA, SgLongIntVal::pool_size * sizeof(SgLongIntVal));
  150942             : #endif
  150943       34000 :         for (unsigned i=0; i < SgLongIntVal::pool_size-1; i++) {
  150944       33983 :           alloc[i].p_freepointer = &(alloc[i+1]);
  150945             :         }
  150946          17 :         alloc[SgLongIntVal::pool_size-1].p_freepointer = nullptr;
  150947             : 
  150948          17 :         SgLongIntVal::pools.push_back ( (unsigned char *) alloc );
  150949          17 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgLongIntVal::pool_size * sizeof(SgLongIntVal), V_SgLongIntVal ) );
  150950          17 :         SgLongIntVal::next_node = alloc;
  150951             :     }
  150952        1940 :     ROSE_ASSERT(SgLongIntVal::next_node != nullptr);
  150953             : 
  150954        1940 :     SgLongIntVal * object = SgLongIntVal::next_node;
  150955        1940 :     SgLongIntVal::next_node = (SgLongIntVal*)(object->p_freepointer);
  150956             : 
  150957             : #if ROSE_ALLOC_TRACE == 2
  150958             :     printf("SgLongIntVal::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgLongIntVal::next_node);
  150959             : #endif
  150960             : 
  150961        1940 :     SgNode * fp = object->p_freepointer;
  150962             : #if ROSE_ALLOC_MEMSET == 1
  150963             : #elif ROSE_ALLOC_MEMSET == 2
  150964             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgLongIntVal) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  150965             : #elif ROSE_ALLOC_MEMSET == 3
  150966             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgLongIntVal) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  150967             : #endif
  150968        1940 :     object->p_freepointer = fp;
  150969             : 
  150970             : #if ROSE_ALLOC_TRACE == 2
  150971             : //    printf("SgLongIntVal::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgLongIntVal::next_node);
  150972             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  150973             :     Rose::MemPool::snapshot(oss.str());
  150974             :     alloc_trace_cnt++;
  150975             : #endif
  150976             : 
  150977        1940 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  150978             : 
  150979        1940 :     ALLOC_MUTEX(SgLongIntVal, unlock);
  150980             : 
  150981             :     return object;
  150982             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  150983             : }
  150984             : 
  150985             : 
  150986             : 
  150987             : /*! \brief Delete operator for SgLongIntVal.
  150988             : 
  150989             :    This delete operator implements deallocation using memory pools to 
  150990             :    provide most efficent use of the heap within construction of large ASTs.
  150991             : 
  150992             : \internal The new and delete operators use the lower level C malloc/free
  150993             :    function calls for performance and to make sure that mixing of malloc/free
  150994             :    and new/delete by the used can be caught more readily.  This may change
  150995             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  150996             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  150997             :    deallocate memory allocated using ROSE_MALLOC.
  150998             : */
  150999        1844 : void SgLongIntVal::operator delete(void *Pointer, size_t Size)
  151000             : {
  151001             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  151002             :      * or throwing an exception. */
  151003        1844 :     ALLOC_MUTEX(SgLongIntVal, lock);
  151004             : 
  151005             : #if USE_CPP_NEW_DELETE_OPERATORS
  151006             :     ROSE_FREE(Pointer);
  151007             : #else
  151008             : #if ROSE_PEDANTIC_ALLOC
  151009             :     ROSE_ASSERT(Size == sizeof(SgLongIntVal));
  151010             : #else
  151011        1844 :     if (Size != sizeof(SgLongIntVal)) {
  151012           0 :       ROSE_FREE(Pointer);
  151013           0 :       ALLOC_MUTEX(SgLongIntVal, unlock);
  151014             :       return;
  151015             :     }
  151016             : #endif
  151017             : 
  151018        1844 :     SgLongIntVal * object = (SgLongIntVal*) Pointer;
  151019        1844 :     ROSE_ASSERT(object != nullptr);
  151020             : 
  151021             : #if ROSE_ALLOC_TRACE == 2
  151022             : //  printf("SgLongIntVal::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgLongIntVal::next_node);
  151023             :     printf("SgLongIntVal::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgLongIntVal::next_node);
  151024             : #endif
  151025             : 
  151026             : #if ROSE_PEDANTIC_ALLOC
  151027             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  151028             : #endif
  151029             : 
  151030             : #if ROSE_ALLOC_MEMSET == 1
  151031             : #elif ROSE_ALLOC_MEMSET == 2
  151032             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgLongIntVal) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  151033             : #elif ROSE_ALLOC_MEMSET == 3
  151034             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgLongIntVal) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  151035             : #endif
  151036             : 
  151037             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  151038             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  151039             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  151040             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  151041             : #else
  151042        1844 :     object->p_freepointer = SgLongIntVal::next_node;
  151043        1844 :     SgLongIntVal::next_node = object;
  151044             : #endif
  151045             : 
  151046             : #if ROSE_ALLOC_TRACE == 2
  151047             : //  printf("SgLongIntVal::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgLongIntVal::next_node);
  151048             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  151049             :     Rose::MemPool::snapshot(oss.str());
  151050             :     alloc_trace_cnt++;
  151051             : #endif
  151052             : 
  151053             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  151054             : 
  151055        1844 :     ALLOC_MUTEX(SgLongIntVal, unlock);
  151056             : }
  151057             : 
  151058             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  151059             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  151060             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  151061             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  151062             : // Also, note comment below from Robb (copied from the Common.code file).
  151063             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  151064             : //
  151065             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  151066             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  151067             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  151068             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  151069             : #if 0
  151070             : void SgLongIntVal::operator delete(void* pointer) { SgLongIntVal::operator delete (pointer, sizeof(SgLongIntVal)); };
  151071             : #endif
  151072             : /* #line 151073 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  151073             : 
  151074             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  151075             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  151076             : // obviously imply C++.
  151077             : 
  151078             : // This implements the support within ROSE for memory pools.  Memory pools
  151079             : // support the most condensed usage of memory within the construction of
  151080             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  151081             : // by a new operator written for each class.
  151082             : 
  151083             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  151084             :     // User wants multi-thread support and POSIX threads are available.
  151085             : #   include <pthread.h>
  151086             :     static pthread_mutex_t SgLongLongIntVal_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  151087             : #else
  151088             :      // Cause synchronization to be skipped.
  151089             : #    ifndef ALLOC_MUTEX
  151090             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  151091             : #    endif
  151092             : #    ifdef _REENTRANT
  151093             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  151094             : #       ifdef _MSC_VER
  151095             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  151096             : #       else
  151097             : #           warning "POSIX threads are not available; synchronization being skipped"
  151098             : #       endif
  151099             : #    endif
  151100             : #endif
  151101             : 
  151102             : #ifndef ROSE_ALLOC_TRACE
  151103             : #  define ROSE_ALLOC_TRACE 0
  151104             : #endif
  151105             : 
  151106             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  151107             : #define ROSE_ALLOC_TRACE_CNT
  151108             : #include "memory-pool-snapshot.h"
  151109             : unsigned long alloc_trace_cnt = 0;
  151110             : #endif
  151111             : 
  151112             : #if ROSE_ALLOC_TRACE
  151113             : const unsigned SgLongLongIntVal::pool_size = 5;
  151114             : #else
  151115             : const unsigned SgLongLongIntVal::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  151116             : #endif
  151117             : 
  151118             : #ifndef ROSE_ALLOC_MEMSET
  151119             : #  define ROSE_ALLOC_MEMSET 0
  151120             : #endif
  151121             : 
  151122             : #ifndef ROSE_PEDANTIC_ALLOC
  151123             : #  define ROSE_PEDANTIC_ALLOC 0
  151124             : #endif
  151125             : 
  151126             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  151127             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  151128             : #endif
  151129             : 
  151130             : #if !defined(SGNODE__ALL_POOLS)
  151131             : #define SGNODE__ALL_POOLS
  151132             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  151133             : #endif
  151134             : 
  151135             : SgLongLongIntVal* SgLongLongIntVal::next_node = nullptr;
  151136             : std::vector<unsigned char*> SgLongLongIntVal::pools;
  151137             : 
  151138             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  151139             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  151140             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  151141             : // around this macro definition rather than each use).
  151142             : #ifndef ALLOC_MUTEX
  151143             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  151144             :         do {                                                                     \
  151145             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  151146             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  151147             :                 abort();                                                         \
  151148             :             }                                                                    \
  151149             :         } while (0);
  151150             : #endif
  151151             : 
  151152             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  151153             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  151154             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  151155             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  151156             : 
  151157             : /*! \brief New operator for SgLongLongIntVal.
  151158             : 
  151159             :    This new operator implements memory pools to provide most efficent 
  151160             :    use of the heap within construction of large ASTs.
  151161             : 
  151162             : \internal The new and delete operators use the lower level C malloc/free
  151163             :    function calls for performance and to make sure that mixing of malloc/free
  151164             :    and new/delete by the used can be caught more readily.  This may change
  151165             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  151166             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  151167             :    deallocate memory allocated using ROSE_MALLOC.
  151168             : */
  151169          47 : void *SgLongLongIntVal::operator new ( size_t Size )
  151170             : {
  151171             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  151172             :      * returning or throwing an exception. */
  151173          47 :     ALLOC_MUTEX(SgLongLongIntVal, lock);
  151174             : 
  151175             : #if ROSE_ALLOC_TRACE == 2
  151176             : //    printf("SgLongLongIntVal::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgLongLongIntVal::next_node);
  151177             : #endif
  151178             : 
  151179             : #if USE_CPP_NEW_DELETE_OPERATORS
  151180             :     void *mem = ROSE_MALLOC(Size);
  151181             :     ALLOC_MUTEX(SgLongLongIntVal, unlock);
  151182             :     return mem;
  151183             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  151184             : #if ROSE_PEDANTIC_ALLOC
  151185             :     ROSE_ASSERT(Size == sizeof(SgLongLongIntVal));
  151186             : #else
  151187          47 :     if (Size != sizeof(SgLongLongIntVal)) {
  151188           0 :       void * object = ROSE_MALLOC(Size);
  151189           0 :       ALLOC_MUTEX(SgLongLongIntVal, unlock);
  151190             :       return object;
  151191             :     }
  151192             : #endif
  151193             : 
  151194          47 :     if (SgLongLongIntVal::next_node == nullptr) {
  151195          14 :         SgLongLongIntVal * alloc = (SgLongLongIntVal*) ROSE_MALLOC ( SgLongLongIntVal::pool_size * sizeof(SgLongLongIntVal) );
  151196          14 :         ROSE_ASSERT(alloc != nullptr);
  151197             : 
  151198             : #if ROSE_ALLOC_TRACE == 2
  151199             : //        printf("SgLongLongIntVal::alloc\n  block[%zi] = [ %p , %p [\n", SgLongLongIntVal::pools.size(), alloc, alloc + SgLongLongIntVal::pool_size);
  151200             : #endif
  151201             : 
  151202             : #if ROSE_ALLOC_MEMSET == 1
  151203             : #elif ROSE_ALLOC_MEMSET == 2
  151204             :         memset(alloc, 0x00, SgLongLongIntVal::pool_size * sizeof(SgLongLongIntVal));
  151205             : #elif ROSE_ALLOC_MEMSET == 3
  151206             :         memset(alloc, 0xAA, SgLongLongIntVal::pool_size * sizeof(SgLongLongIntVal));
  151207             : #endif
  151208       28000 :         for (unsigned i=0; i < SgLongLongIntVal::pool_size-1; i++) {
  151209       27986 :           alloc[i].p_freepointer = &(alloc[i+1]);
  151210             :         }
  151211          14 :         alloc[SgLongLongIntVal::pool_size-1].p_freepointer = nullptr;
  151212             : 
  151213          14 :         SgLongLongIntVal::pools.push_back ( (unsigned char *) alloc );
  151214          14 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgLongLongIntVal::pool_size * sizeof(SgLongLongIntVal), V_SgLongLongIntVal ) );
  151215          14 :         SgLongLongIntVal::next_node = alloc;
  151216             :     }
  151217          47 :     ROSE_ASSERT(SgLongLongIntVal::next_node != nullptr);
  151218             : 
  151219          47 :     SgLongLongIntVal * object = SgLongLongIntVal::next_node;
  151220          47 :     SgLongLongIntVal::next_node = (SgLongLongIntVal*)(object->p_freepointer);
  151221             : 
  151222             : #if ROSE_ALLOC_TRACE == 2
  151223             :     printf("SgLongLongIntVal::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgLongLongIntVal::next_node);
  151224             : #endif
  151225             : 
  151226          47 :     SgNode * fp = object->p_freepointer;
  151227             : #if ROSE_ALLOC_MEMSET == 1
  151228             : #elif ROSE_ALLOC_MEMSET == 2
  151229             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgLongLongIntVal) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  151230             : #elif ROSE_ALLOC_MEMSET == 3
  151231             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgLongLongIntVal) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  151232             : #endif
  151233          47 :     object->p_freepointer = fp;
  151234             : 
  151235             : #if ROSE_ALLOC_TRACE == 2
  151236             : //    printf("SgLongLongIntVal::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgLongLongIntVal::next_node);
  151237             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  151238             :     Rose::MemPool::snapshot(oss.str());
  151239             :     alloc_trace_cnt++;
  151240             : #endif
  151241             : 
  151242          47 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  151243             : 
  151244          47 :     ALLOC_MUTEX(SgLongLongIntVal, unlock);
  151245             : 
  151246             :     return object;
  151247             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  151248             : }
  151249             : 
  151250             : 
  151251             : 
  151252             : /*! \brief Delete operator for SgLongLongIntVal.
  151253             : 
  151254             :    This delete operator implements deallocation using memory pools to 
  151255             :    provide most efficent use of the heap within construction of large ASTs.
  151256             : 
  151257             : \internal The new and delete operators use the lower level C malloc/free
  151258             :    function calls for performance and to make sure that mixing of malloc/free
  151259             :    and new/delete by the used can be caught more readily.  This may change
  151260             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  151261             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  151262             :    deallocate memory allocated using ROSE_MALLOC.
  151263             : */
  151264          46 : void SgLongLongIntVal::operator delete(void *Pointer, size_t Size)
  151265             : {
  151266             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  151267             :      * or throwing an exception. */
  151268          46 :     ALLOC_MUTEX(SgLongLongIntVal, lock);
  151269             : 
  151270             : #if USE_CPP_NEW_DELETE_OPERATORS
  151271             :     ROSE_FREE(Pointer);
  151272             : #else
  151273             : #if ROSE_PEDANTIC_ALLOC
  151274             :     ROSE_ASSERT(Size == sizeof(SgLongLongIntVal));
  151275             : #else
  151276          46 :     if (Size != sizeof(SgLongLongIntVal)) {
  151277           0 :       ROSE_FREE(Pointer);
  151278           0 :       ALLOC_MUTEX(SgLongLongIntVal, unlock);
  151279             :       return;
  151280             :     }
  151281             : #endif
  151282             : 
  151283          46 :     SgLongLongIntVal * object = (SgLongLongIntVal*) Pointer;
  151284          46 :     ROSE_ASSERT(object != nullptr);
  151285             : 
  151286             : #if ROSE_ALLOC_TRACE == 2
  151287             : //  printf("SgLongLongIntVal::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgLongLongIntVal::next_node);
  151288             :     printf("SgLongLongIntVal::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgLongLongIntVal::next_node);
  151289             : #endif
  151290             : 
  151291             : #if ROSE_PEDANTIC_ALLOC
  151292             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  151293             : #endif
  151294             : 
  151295             : #if ROSE_ALLOC_MEMSET == 1
  151296             : #elif ROSE_ALLOC_MEMSET == 2
  151297             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgLongLongIntVal) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  151298             : #elif ROSE_ALLOC_MEMSET == 3
  151299             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgLongLongIntVal) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  151300             : #endif
  151301             : 
  151302             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  151303             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  151304             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  151305             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  151306             : #else
  151307          46 :     object->p_freepointer = SgLongLongIntVal::next_node;
  151308          46 :     SgLongLongIntVal::next_node = object;
  151309             : #endif
  151310             : 
  151311             : #if ROSE_ALLOC_TRACE == 2
  151312             : //  printf("SgLongLongIntVal::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgLongLongIntVal::next_node);
  151313             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  151314             :     Rose::MemPool::snapshot(oss.str());
  151315             :     alloc_trace_cnt++;
  151316             : #endif
  151317             : 
  151318             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  151319             : 
  151320          46 :     ALLOC_MUTEX(SgLongLongIntVal, unlock);
  151321             : }
  151322             : 
  151323             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  151324             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  151325             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  151326             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  151327             : // Also, note comment below from Robb (copied from the Common.code file).
  151328             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  151329             : //
  151330             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  151331             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  151332             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  151333             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  151334             : #if 0
  151335             : void SgLongLongIntVal::operator delete(void* pointer) { SgLongLongIntVal::operator delete (pointer, sizeof(SgLongLongIntVal)); };
  151336             : #endif
  151337             : /* #line 151338 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  151338             : 
  151339             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  151340             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  151341             : // obviously imply C++.
  151342             : 
  151343             : // This implements the support within ROSE for memory pools.  Memory pools
  151344             : // support the most condensed usage of memory within the construction of
  151345             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  151346             : // by a new operator written for each class.
  151347             : 
  151348             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  151349             :     // User wants multi-thread support and POSIX threads are available.
  151350             : #   include <pthread.h>
  151351             :     static pthread_mutex_t SgUnsignedLongLongIntVal_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  151352             : #else
  151353             :      // Cause synchronization to be skipped.
  151354             : #    ifndef ALLOC_MUTEX
  151355             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  151356             : #    endif
  151357             : #    ifdef _REENTRANT
  151358             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  151359             : #       ifdef _MSC_VER
  151360             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  151361             : #       else
  151362             : #           warning "POSIX threads are not available; synchronization being skipped"
  151363             : #       endif
  151364             : #    endif
  151365             : #endif
  151366             : 
  151367             : #ifndef ROSE_ALLOC_TRACE
  151368             : #  define ROSE_ALLOC_TRACE 0
  151369             : #endif
  151370             : 
  151371             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  151372             : #define ROSE_ALLOC_TRACE_CNT
  151373             : #include "memory-pool-snapshot.h"
  151374             : unsigned long alloc_trace_cnt = 0;
  151375             : #endif
  151376             : 
  151377             : #if ROSE_ALLOC_TRACE
  151378             : const unsigned SgUnsignedLongLongIntVal::pool_size = 5;
  151379             : #else
  151380             : const unsigned SgUnsignedLongLongIntVal::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  151381             : #endif
  151382             : 
  151383             : #ifndef ROSE_ALLOC_MEMSET
  151384             : #  define ROSE_ALLOC_MEMSET 0
  151385             : #endif
  151386             : 
  151387             : #ifndef ROSE_PEDANTIC_ALLOC
  151388             : #  define ROSE_PEDANTIC_ALLOC 0
  151389             : #endif
  151390             : 
  151391             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  151392             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  151393             : #endif
  151394             : 
  151395             : #if !defined(SGNODE__ALL_POOLS)
  151396             : #define SGNODE__ALL_POOLS
  151397             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  151398             : #endif
  151399             : 
  151400             : SgUnsignedLongLongIntVal* SgUnsignedLongLongIntVal::next_node = nullptr;
  151401             : std::vector<unsigned char*> SgUnsignedLongLongIntVal::pools;
  151402             : 
  151403             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  151404             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  151405             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  151406             : // around this macro definition rather than each use).
  151407             : #ifndef ALLOC_MUTEX
  151408             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  151409             :         do {                                                                     \
  151410             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  151411             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  151412             :                 abort();                                                         \
  151413             :             }                                                                    \
  151414             :         } while (0);
  151415             : #endif
  151416             : 
  151417             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  151418             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  151419             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  151420             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  151421             : 
  151422             : /*! \brief New operator for SgUnsignedLongLongIntVal.
  151423             : 
  151424             :    This new operator implements memory pools to provide most efficent 
  151425             :    use of the heap within construction of large ASTs.
  151426             : 
  151427             : \internal The new and delete operators use the lower level C malloc/free
  151428             :    function calls for performance and to make sure that mixing of malloc/free
  151429             :    and new/delete by the used can be caught more readily.  This may change
  151430             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  151431             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  151432             :    deallocate memory allocated using ROSE_MALLOC.
  151433             : */
  151434          35 : void *SgUnsignedLongLongIntVal::operator new ( size_t Size )
  151435             : {
  151436             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  151437             :      * returning or throwing an exception. */
  151438          35 :     ALLOC_MUTEX(SgUnsignedLongLongIntVal, lock);
  151439             : 
  151440             : #if ROSE_ALLOC_TRACE == 2
  151441             : //    printf("SgUnsignedLongLongIntVal::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgUnsignedLongLongIntVal::next_node);
  151442             : #endif
  151443             : 
  151444             : #if USE_CPP_NEW_DELETE_OPERATORS
  151445             :     void *mem = ROSE_MALLOC(Size);
  151446             :     ALLOC_MUTEX(SgUnsignedLongLongIntVal, unlock);
  151447             :     return mem;
  151448             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  151449             : #if ROSE_PEDANTIC_ALLOC
  151450             :     ROSE_ASSERT(Size == sizeof(SgUnsignedLongLongIntVal));
  151451             : #else
  151452          35 :     if (Size != sizeof(SgUnsignedLongLongIntVal)) {
  151453           0 :       void * object = ROSE_MALLOC(Size);
  151454           0 :       ALLOC_MUTEX(SgUnsignedLongLongIntVal, unlock);
  151455             :       return object;
  151456             :     }
  151457             : #endif
  151458             : 
  151459          35 :     if (SgUnsignedLongLongIntVal::next_node == nullptr) {
  151460           9 :         SgUnsignedLongLongIntVal * alloc = (SgUnsignedLongLongIntVal*) ROSE_MALLOC ( SgUnsignedLongLongIntVal::pool_size * sizeof(SgUnsignedLongLongIntVal) );
  151461           9 :         ROSE_ASSERT(alloc != nullptr);
  151462             : 
  151463             : #if ROSE_ALLOC_TRACE == 2
  151464             : //        printf("SgUnsignedLongLongIntVal::alloc\n  block[%zi] = [ %p , %p [\n", SgUnsignedLongLongIntVal::pools.size(), alloc, alloc + SgUnsignedLongLongIntVal::pool_size);
  151465             : #endif
  151466             : 
  151467             : #if ROSE_ALLOC_MEMSET == 1
  151468             : #elif ROSE_ALLOC_MEMSET == 2
  151469             :         memset(alloc, 0x00, SgUnsignedLongLongIntVal::pool_size * sizeof(SgUnsignedLongLongIntVal));
  151470             : #elif ROSE_ALLOC_MEMSET == 3
  151471             :         memset(alloc, 0xAA, SgUnsignedLongLongIntVal::pool_size * sizeof(SgUnsignedLongLongIntVal));
  151472             : #endif
  151473       18000 :         for (unsigned i=0; i < SgUnsignedLongLongIntVal::pool_size-1; i++) {
  151474       17991 :           alloc[i].p_freepointer = &(alloc[i+1]);
  151475             :         }
  151476           9 :         alloc[SgUnsignedLongLongIntVal::pool_size-1].p_freepointer = nullptr;
  151477             : 
  151478           9 :         SgUnsignedLongLongIntVal::pools.push_back ( (unsigned char *) alloc );
  151479           9 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgUnsignedLongLongIntVal::pool_size * sizeof(SgUnsignedLongLongIntVal), V_SgUnsignedLongLongIntVal ) );
  151480           9 :         SgUnsignedLongLongIntVal::next_node = alloc;
  151481             :     }
  151482          35 :     ROSE_ASSERT(SgUnsignedLongLongIntVal::next_node != nullptr);
  151483             : 
  151484          35 :     SgUnsignedLongLongIntVal * object = SgUnsignedLongLongIntVal::next_node;
  151485          35 :     SgUnsignedLongLongIntVal::next_node = (SgUnsignedLongLongIntVal*)(object->p_freepointer);
  151486             : 
  151487             : #if ROSE_ALLOC_TRACE == 2
  151488             :     printf("SgUnsignedLongLongIntVal::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUnsignedLongLongIntVal::next_node);
  151489             : #endif
  151490             : 
  151491          35 :     SgNode * fp = object->p_freepointer;
  151492             : #if ROSE_ALLOC_MEMSET == 1
  151493             : #elif ROSE_ALLOC_MEMSET == 2
  151494             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgUnsignedLongLongIntVal) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  151495             : #elif ROSE_ALLOC_MEMSET == 3
  151496             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgUnsignedLongLongIntVal) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  151497             : #endif
  151498          35 :     object->p_freepointer = fp;
  151499             : 
  151500             : #if ROSE_ALLOC_TRACE == 2
  151501             : //    printf("SgUnsignedLongLongIntVal::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUnsignedLongLongIntVal::next_node);
  151502             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  151503             :     Rose::MemPool::snapshot(oss.str());
  151504             :     alloc_trace_cnt++;
  151505             : #endif
  151506             : 
  151507          35 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  151508             : 
  151509          35 :     ALLOC_MUTEX(SgUnsignedLongLongIntVal, unlock);
  151510             : 
  151511             :     return object;
  151512             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  151513             : }
  151514             : 
  151515             : 
  151516             : 
  151517             : /*! \brief Delete operator for SgUnsignedLongLongIntVal.
  151518             : 
  151519             :    This delete operator implements deallocation using memory pools to 
  151520             :    provide most efficent use of the heap within construction of large ASTs.
  151521             : 
  151522             : \internal The new and delete operators use the lower level C malloc/free
  151523             :    function calls for performance and to make sure that mixing of malloc/free
  151524             :    and new/delete by the used can be caught more readily.  This may change
  151525             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  151526             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  151527             :    deallocate memory allocated using ROSE_MALLOC.
  151528             : */
  151529          33 : void SgUnsignedLongLongIntVal::operator delete(void *Pointer, size_t Size)
  151530             : {
  151531             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  151532             :      * or throwing an exception. */
  151533          33 :     ALLOC_MUTEX(SgUnsignedLongLongIntVal, lock);
  151534             : 
  151535             : #if USE_CPP_NEW_DELETE_OPERATORS
  151536             :     ROSE_FREE(Pointer);
  151537             : #else
  151538             : #if ROSE_PEDANTIC_ALLOC
  151539             :     ROSE_ASSERT(Size == sizeof(SgUnsignedLongLongIntVal));
  151540             : #else
  151541          33 :     if (Size != sizeof(SgUnsignedLongLongIntVal)) {
  151542           0 :       ROSE_FREE(Pointer);
  151543           0 :       ALLOC_MUTEX(SgUnsignedLongLongIntVal, unlock);
  151544             :       return;
  151545             :     }
  151546             : #endif
  151547             : 
  151548          33 :     SgUnsignedLongLongIntVal * object = (SgUnsignedLongLongIntVal*) Pointer;
  151549          33 :     ROSE_ASSERT(object != nullptr);
  151550             : 
  151551             : #if ROSE_ALLOC_TRACE == 2
  151552             : //  printf("SgUnsignedLongLongIntVal::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUnsignedLongLongIntVal::next_node);
  151553             :     printf("SgUnsignedLongLongIntVal::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUnsignedLongLongIntVal::next_node);
  151554             : #endif
  151555             : 
  151556             : #if ROSE_PEDANTIC_ALLOC
  151557             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  151558             : #endif
  151559             : 
  151560             : #if ROSE_ALLOC_MEMSET == 1
  151561             : #elif ROSE_ALLOC_MEMSET == 2
  151562             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgUnsignedLongLongIntVal) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  151563             : #elif ROSE_ALLOC_MEMSET == 3
  151564             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgUnsignedLongLongIntVal) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  151565             : #endif
  151566             : 
  151567             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  151568             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  151569             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  151570             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  151571             : #else
  151572          33 :     object->p_freepointer = SgUnsignedLongLongIntVal::next_node;
  151573          33 :     SgUnsignedLongLongIntVal::next_node = object;
  151574             : #endif
  151575             : 
  151576             : #if ROSE_ALLOC_TRACE == 2
  151577             : //  printf("SgUnsignedLongLongIntVal::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUnsignedLongLongIntVal::next_node);
  151578             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  151579             :     Rose::MemPool::snapshot(oss.str());
  151580             :     alloc_trace_cnt++;
  151581             : #endif
  151582             : 
  151583             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  151584             : 
  151585          33 :     ALLOC_MUTEX(SgUnsignedLongLongIntVal, unlock);
  151586             : }
  151587             : 
  151588             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  151589             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  151590             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  151591             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  151592             : // Also, note comment below from Robb (copied from the Common.code file).
  151593             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  151594             : //
  151595             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  151596             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  151597             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  151598             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  151599             : #if 0
  151600             : void SgUnsignedLongLongIntVal::operator delete(void* pointer) { SgUnsignedLongLongIntVal::operator delete (pointer, sizeof(SgUnsignedLongLongIntVal)); };
  151601             : #endif
  151602             : /* #line 151603 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  151603             : 
  151604             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  151605             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  151606             : // obviously imply C++.
  151607             : 
  151608             : // This implements the support within ROSE for memory pools.  Memory pools
  151609             : // support the most condensed usage of memory within the construction of
  151610             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  151611             : // by a new operator written for each class.
  151612             : 
  151613             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  151614             :     // User wants multi-thread support and POSIX threads are available.
  151615             : #   include <pthread.h>
  151616             :     static pthread_mutex_t SgUnsignedLongVal_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  151617             : #else
  151618             :      // Cause synchronization to be skipped.
  151619             : #    ifndef ALLOC_MUTEX
  151620             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  151621             : #    endif
  151622             : #    ifdef _REENTRANT
  151623             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  151624             : #       ifdef _MSC_VER
  151625             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  151626             : #       else
  151627             : #           warning "POSIX threads are not available; synchronization being skipped"
  151628             : #       endif
  151629             : #    endif
  151630             : #endif
  151631             : 
  151632             : #ifndef ROSE_ALLOC_TRACE
  151633             : #  define ROSE_ALLOC_TRACE 0
  151634             : #endif
  151635             : 
  151636             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  151637             : #define ROSE_ALLOC_TRACE_CNT
  151638             : #include "memory-pool-snapshot.h"
  151639             : unsigned long alloc_trace_cnt = 0;
  151640             : #endif
  151641             : 
  151642             : #if ROSE_ALLOC_TRACE
  151643             : const unsigned SgUnsignedLongVal::pool_size = 5;
  151644             : #else
  151645             : const unsigned SgUnsignedLongVal::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  151646             : #endif
  151647             : 
  151648             : #ifndef ROSE_ALLOC_MEMSET
  151649             : #  define ROSE_ALLOC_MEMSET 0
  151650             : #endif
  151651             : 
  151652             : #ifndef ROSE_PEDANTIC_ALLOC
  151653             : #  define ROSE_PEDANTIC_ALLOC 0
  151654             : #endif
  151655             : 
  151656             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  151657             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  151658             : #endif
  151659             : 
  151660             : #if !defined(SGNODE__ALL_POOLS)
  151661             : #define SGNODE__ALL_POOLS
  151662             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  151663             : #endif
  151664             : 
  151665             : SgUnsignedLongVal* SgUnsignedLongVal::next_node = nullptr;
  151666             : std::vector<unsigned char*> SgUnsignedLongVal::pools;
  151667             : 
  151668             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  151669             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  151670             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  151671             : // around this macro definition rather than each use).
  151672             : #ifndef ALLOC_MUTEX
  151673             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  151674             :         do {                                                                     \
  151675             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  151676             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  151677             :                 abort();                                                         \
  151678             :             }                                                                    \
  151679             :         } while (0);
  151680             : #endif
  151681             : 
  151682             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  151683             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  151684             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  151685             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  151686             : 
  151687             : /*! \brief New operator for SgUnsignedLongVal.
  151688             : 
  151689             :    This new operator implements memory pools to provide most efficent 
  151690             :    use of the heap within construction of large ASTs.
  151691             : 
  151692             : \internal The new and delete operators use the lower level C malloc/free
  151693             :    function calls for performance and to make sure that mixing of malloc/free
  151694             :    and new/delete by the used can be caught more readily.  This may change
  151695             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  151696             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  151697             :    deallocate memory allocated using ROSE_MALLOC.
  151698             : */
  151699        7883 : void *SgUnsignedLongVal::operator new ( size_t Size )
  151700             : {
  151701             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  151702             :      * returning or throwing an exception. */
  151703        7883 :     ALLOC_MUTEX(SgUnsignedLongVal, lock);
  151704             : 
  151705             : #if ROSE_ALLOC_TRACE == 2
  151706             : //    printf("SgUnsignedLongVal::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgUnsignedLongVal::next_node);
  151707             : #endif
  151708             : 
  151709             : #if USE_CPP_NEW_DELETE_OPERATORS
  151710             :     void *mem = ROSE_MALLOC(Size);
  151711             :     ALLOC_MUTEX(SgUnsignedLongVal, unlock);
  151712             :     return mem;
  151713             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  151714             : #if ROSE_PEDANTIC_ALLOC
  151715             :     ROSE_ASSERT(Size == sizeof(SgUnsignedLongVal));
  151716             : #else
  151717        7883 :     if (Size != sizeof(SgUnsignedLongVal)) {
  151718           0 :       void * object = ROSE_MALLOC(Size);
  151719           0 :       ALLOC_MUTEX(SgUnsignedLongVal, unlock);
  151720             :       return object;
  151721             :     }
  151722             : #endif
  151723             : 
  151724        7883 :     if (SgUnsignedLongVal::next_node == nullptr) {
  151725         211 :         SgUnsignedLongVal * alloc = (SgUnsignedLongVal*) ROSE_MALLOC ( SgUnsignedLongVal::pool_size * sizeof(SgUnsignedLongVal) );
  151726         211 :         ROSE_ASSERT(alloc != nullptr);
  151727             : 
  151728             : #if ROSE_ALLOC_TRACE == 2
  151729             : //        printf("SgUnsignedLongVal::alloc\n  block[%zi] = [ %p , %p [\n", SgUnsignedLongVal::pools.size(), alloc, alloc + SgUnsignedLongVal::pool_size);
  151730             : #endif
  151731             : 
  151732             : #if ROSE_ALLOC_MEMSET == 1
  151733             : #elif ROSE_ALLOC_MEMSET == 2
  151734             :         memset(alloc, 0x00, SgUnsignedLongVal::pool_size * sizeof(SgUnsignedLongVal));
  151735             : #elif ROSE_ALLOC_MEMSET == 3
  151736             :         memset(alloc, 0xAA, SgUnsignedLongVal::pool_size * sizeof(SgUnsignedLongVal));
  151737             : #endif
  151738      422000 :         for (unsigned i=0; i < SgUnsignedLongVal::pool_size-1; i++) {
  151739      421789 :           alloc[i].p_freepointer = &(alloc[i+1]);
  151740             :         }
  151741         211 :         alloc[SgUnsignedLongVal::pool_size-1].p_freepointer = nullptr;
  151742             : 
  151743         211 :         SgUnsignedLongVal::pools.push_back ( (unsigned char *) alloc );
  151744         211 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgUnsignedLongVal::pool_size * sizeof(SgUnsignedLongVal), V_SgUnsignedLongVal ) );
  151745         211 :         SgUnsignedLongVal::next_node = alloc;
  151746             :     }
  151747        7883 :     ROSE_ASSERT(SgUnsignedLongVal::next_node != nullptr);
  151748             : 
  151749        7883 :     SgUnsignedLongVal * object = SgUnsignedLongVal::next_node;
  151750        7883 :     SgUnsignedLongVal::next_node = (SgUnsignedLongVal*)(object->p_freepointer);
  151751             : 
  151752             : #if ROSE_ALLOC_TRACE == 2
  151753             :     printf("SgUnsignedLongVal::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUnsignedLongVal::next_node);
  151754             : #endif
  151755             : 
  151756        7883 :     SgNode * fp = object->p_freepointer;
  151757             : #if ROSE_ALLOC_MEMSET == 1
  151758             : #elif ROSE_ALLOC_MEMSET == 2
  151759             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgUnsignedLongVal) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  151760             : #elif ROSE_ALLOC_MEMSET == 3
  151761             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgUnsignedLongVal) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  151762             : #endif
  151763        7883 :     object->p_freepointer = fp;
  151764             : 
  151765             : #if ROSE_ALLOC_TRACE == 2
  151766             : //    printf("SgUnsignedLongVal::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUnsignedLongVal::next_node);
  151767             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  151768             :     Rose::MemPool::snapshot(oss.str());
  151769             :     alloc_trace_cnt++;
  151770             : #endif
  151771             : 
  151772        7883 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  151773             : 
  151774        7883 :     ALLOC_MUTEX(SgUnsignedLongVal, unlock);
  151775             : 
  151776             :     return object;
  151777             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  151778             : }
  151779             : 
  151780             : 
  151781             : 
  151782             : /*! \brief Delete operator for SgUnsignedLongVal.
  151783             : 
  151784             :    This delete operator implements deallocation using memory pools to 
  151785             :    provide most efficent use of the heap within construction of large ASTs.
  151786             : 
  151787             : \internal The new and delete operators use the lower level C malloc/free
  151788             :    function calls for performance and to make sure that mixing of malloc/free
  151789             :    and new/delete by the used can be caught more readily.  This may change
  151790             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  151791             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  151792             :    deallocate memory allocated using ROSE_MALLOC.
  151793             : */
  151794        7698 : void SgUnsignedLongVal::operator delete(void *Pointer, size_t Size)
  151795             : {
  151796             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  151797             :      * or throwing an exception. */
  151798        7698 :     ALLOC_MUTEX(SgUnsignedLongVal, lock);
  151799             : 
  151800             : #if USE_CPP_NEW_DELETE_OPERATORS
  151801             :     ROSE_FREE(Pointer);
  151802             : #else
  151803             : #if ROSE_PEDANTIC_ALLOC
  151804             :     ROSE_ASSERT(Size == sizeof(SgUnsignedLongVal));
  151805             : #else
  151806        7698 :     if (Size != sizeof(SgUnsignedLongVal)) {
  151807           0 :       ROSE_FREE(Pointer);
  151808           0 :       ALLOC_MUTEX(SgUnsignedLongVal, unlock);
  151809             :       return;
  151810             :     }
  151811             : #endif
  151812             : 
  151813        7698 :     SgUnsignedLongVal * object = (SgUnsignedLongVal*) Pointer;
  151814        7698 :     ROSE_ASSERT(object != nullptr);
  151815             : 
  151816             : #if ROSE_ALLOC_TRACE == 2
  151817             : //  printf("SgUnsignedLongVal::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUnsignedLongVal::next_node);
  151818             :     printf("SgUnsignedLongVal::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUnsignedLongVal::next_node);
  151819             : #endif
  151820             : 
  151821             : #if ROSE_PEDANTIC_ALLOC
  151822             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  151823             : #endif
  151824             : 
  151825             : #if ROSE_ALLOC_MEMSET == 1
  151826             : #elif ROSE_ALLOC_MEMSET == 2
  151827             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgUnsignedLongVal) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  151828             : #elif ROSE_ALLOC_MEMSET == 3
  151829             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgUnsignedLongVal) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  151830             : #endif
  151831             : 
  151832             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  151833             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  151834             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  151835             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  151836             : #else
  151837        7698 :     object->p_freepointer = SgUnsignedLongVal::next_node;
  151838        7698 :     SgUnsignedLongVal::next_node = object;
  151839             : #endif
  151840             : 
  151841             : #if ROSE_ALLOC_TRACE == 2
  151842             : //  printf("SgUnsignedLongVal::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUnsignedLongVal::next_node);
  151843             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  151844             :     Rose::MemPool::snapshot(oss.str());
  151845             :     alloc_trace_cnt++;
  151846             : #endif
  151847             : 
  151848             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  151849             : 
  151850        7698 :     ALLOC_MUTEX(SgUnsignedLongVal, unlock);
  151851             : }
  151852             : 
  151853             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  151854             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  151855             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  151856             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  151857             : // Also, note comment below from Robb (copied from the Common.code file).
  151858             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  151859             : //
  151860             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  151861             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  151862             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  151863             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  151864             : #if 0
  151865             : void SgUnsignedLongVal::operator delete(void* pointer) { SgUnsignedLongVal::operator delete (pointer, sizeof(SgUnsignedLongVal)); };
  151866             : #endif
  151867             : /* #line 151868 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  151868             : 
  151869             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  151870             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  151871             : // obviously imply C++.
  151872             : 
  151873             : // This implements the support within ROSE for memory pools.  Memory pools
  151874             : // support the most condensed usage of memory within the construction of
  151875             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  151876             : // by a new operator written for each class.
  151877             : 
  151878             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  151879             :     // User wants multi-thread support and POSIX threads are available.
  151880             : #   include <pthread.h>
  151881             :     static pthread_mutex_t SgFloatVal_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  151882             : #else
  151883             :      // Cause synchronization to be skipped.
  151884             : #    ifndef ALLOC_MUTEX
  151885             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  151886             : #    endif
  151887             : #    ifdef _REENTRANT
  151888             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  151889             : #       ifdef _MSC_VER
  151890             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  151891             : #       else
  151892             : #           warning "POSIX threads are not available; synchronization being skipped"
  151893             : #       endif
  151894             : #    endif
  151895             : #endif
  151896             : 
  151897             : #ifndef ROSE_ALLOC_TRACE
  151898             : #  define ROSE_ALLOC_TRACE 0
  151899             : #endif
  151900             : 
  151901             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  151902             : #define ROSE_ALLOC_TRACE_CNT
  151903             : #include "memory-pool-snapshot.h"
  151904             : unsigned long alloc_trace_cnt = 0;
  151905             : #endif
  151906             : 
  151907             : #if ROSE_ALLOC_TRACE
  151908             : const unsigned SgFloatVal::pool_size = 5;
  151909             : #else
  151910             : const unsigned SgFloatVal::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  151911             : #endif
  151912             : 
  151913             : #ifndef ROSE_ALLOC_MEMSET
  151914             : #  define ROSE_ALLOC_MEMSET 0
  151915             : #endif
  151916             : 
  151917             : #ifndef ROSE_PEDANTIC_ALLOC
  151918             : #  define ROSE_PEDANTIC_ALLOC 0
  151919             : #endif
  151920             : 
  151921             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  151922             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  151923             : #endif
  151924             : 
  151925             : #if !defined(SGNODE__ALL_POOLS)
  151926             : #define SGNODE__ALL_POOLS
  151927             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  151928             : #endif
  151929             : 
  151930             : SgFloatVal* SgFloatVal::next_node = nullptr;
  151931             : std::vector<unsigned char*> SgFloatVal::pools;
  151932             : 
  151933             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  151934             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  151935             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  151936             : // around this macro definition rather than each use).
  151937             : #ifndef ALLOC_MUTEX
  151938             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  151939             :         do {                                                                     \
  151940             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  151941             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  151942             :                 abort();                                                         \
  151943             :             }                                                                    \
  151944             :         } while (0);
  151945             : #endif
  151946             : 
  151947             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  151948             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  151949             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  151950             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  151951             : 
  151952             : /*! \brief New operator for SgFloatVal.
  151953             : 
  151954             :    This new operator implements memory pools to provide most efficent 
  151955             :    use of the heap within construction of large ASTs.
  151956             : 
  151957             : \internal The new and delete operators use the lower level C malloc/free
  151958             :    function calls for performance and to make sure that mixing of malloc/free
  151959             :    and new/delete by the used can be caught more readily.  This may change
  151960             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  151961             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  151962             :    deallocate memory allocated using ROSE_MALLOC.
  151963             : */
  151964         122 : void *SgFloatVal::operator new ( size_t Size )
  151965             : {
  151966             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  151967             :      * returning or throwing an exception. */
  151968         122 :     ALLOC_MUTEX(SgFloatVal, lock);
  151969             : 
  151970             : #if ROSE_ALLOC_TRACE == 2
  151971             : //    printf("SgFloatVal::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgFloatVal::next_node);
  151972             : #endif
  151973             : 
  151974             : #if USE_CPP_NEW_DELETE_OPERATORS
  151975             :     void *mem = ROSE_MALLOC(Size);
  151976             :     ALLOC_MUTEX(SgFloatVal, unlock);
  151977             :     return mem;
  151978             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  151979             : #if ROSE_PEDANTIC_ALLOC
  151980             :     ROSE_ASSERT(Size == sizeof(SgFloatVal));
  151981             : #else
  151982         122 :     if (Size != sizeof(SgFloatVal)) {
  151983           0 :       void * object = ROSE_MALLOC(Size);
  151984           0 :       ALLOC_MUTEX(SgFloatVal, unlock);
  151985             :       return object;
  151986             :     }
  151987             : #endif
  151988             : 
  151989         122 :     if (SgFloatVal::next_node == nullptr) {
  151990          33 :         SgFloatVal * alloc = (SgFloatVal*) ROSE_MALLOC ( SgFloatVal::pool_size * sizeof(SgFloatVal) );
  151991          33 :         ROSE_ASSERT(alloc != nullptr);
  151992             : 
  151993             : #if ROSE_ALLOC_TRACE == 2
  151994             : //        printf("SgFloatVal::alloc\n  block[%zi] = [ %p , %p [\n", SgFloatVal::pools.size(), alloc, alloc + SgFloatVal::pool_size);
  151995             : #endif
  151996             : 
  151997             : #if ROSE_ALLOC_MEMSET == 1
  151998             : #elif ROSE_ALLOC_MEMSET == 2
  151999             :         memset(alloc, 0x00, SgFloatVal::pool_size * sizeof(SgFloatVal));
  152000             : #elif ROSE_ALLOC_MEMSET == 3
  152001             :         memset(alloc, 0xAA, SgFloatVal::pool_size * sizeof(SgFloatVal));
  152002             : #endif
  152003       66000 :         for (unsigned i=0; i < SgFloatVal::pool_size-1; i++) {
  152004       65967 :           alloc[i].p_freepointer = &(alloc[i+1]);
  152005             :         }
  152006          33 :         alloc[SgFloatVal::pool_size-1].p_freepointer = nullptr;
  152007             : 
  152008          33 :         SgFloatVal::pools.push_back ( (unsigned char *) alloc );
  152009          33 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgFloatVal::pool_size * sizeof(SgFloatVal), V_SgFloatVal ) );
  152010          33 :         SgFloatVal::next_node = alloc;
  152011             :     }
  152012         122 :     ROSE_ASSERT(SgFloatVal::next_node != nullptr);
  152013             : 
  152014         122 :     SgFloatVal * object = SgFloatVal::next_node;
  152015         122 :     SgFloatVal::next_node = (SgFloatVal*)(object->p_freepointer);
  152016             : 
  152017             : #if ROSE_ALLOC_TRACE == 2
  152018             :     printf("SgFloatVal::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgFloatVal::next_node);
  152019             : #endif
  152020             : 
  152021         122 :     SgNode * fp = object->p_freepointer;
  152022             : #if ROSE_ALLOC_MEMSET == 1
  152023             : #elif ROSE_ALLOC_MEMSET == 2
  152024             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgFloatVal) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  152025             : #elif ROSE_ALLOC_MEMSET == 3
  152026             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgFloatVal) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  152027             : #endif
  152028         122 :     object->p_freepointer = fp;
  152029             : 
  152030             : #if ROSE_ALLOC_TRACE == 2
  152031             : //    printf("SgFloatVal::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgFloatVal::next_node);
  152032             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  152033             :     Rose::MemPool::snapshot(oss.str());
  152034             :     alloc_trace_cnt++;
  152035             : #endif
  152036             : 
  152037         122 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  152038             : 
  152039         122 :     ALLOC_MUTEX(SgFloatVal, unlock);
  152040             : 
  152041             :     return object;
  152042             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  152043             : }
  152044             : 
  152045             : 
  152046             : 
  152047             : /*! \brief Delete operator for SgFloatVal.
  152048             : 
  152049             :    This delete operator implements deallocation using memory pools to 
  152050             :    provide most efficent use of the heap within construction of large ASTs.
  152051             : 
  152052             : \internal The new and delete operators use the lower level C malloc/free
  152053             :    function calls for performance and to make sure that mixing of malloc/free
  152054             :    and new/delete by the used can be caught more readily.  This may change
  152055             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  152056             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  152057             :    deallocate memory allocated using ROSE_MALLOC.
  152058             : */
  152059         105 : void SgFloatVal::operator delete(void *Pointer, size_t Size)
  152060             : {
  152061             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  152062             :      * or throwing an exception. */
  152063         105 :     ALLOC_MUTEX(SgFloatVal, lock);
  152064             : 
  152065             : #if USE_CPP_NEW_DELETE_OPERATORS
  152066             :     ROSE_FREE(Pointer);
  152067             : #else
  152068             : #if ROSE_PEDANTIC_ALLOC
  152069             :     ROSE_ASSERT(Size == sizeof(SgFloatVal));
  152070             : #else
  152071         105 :     if (Size != sizeof(SgFloatVal)) {
  152072           0 :       ROSE_FREE(Pointer);
  152073           0 :       ALLOC_MUTEX(SgFloatVal, unlock);
  152074             :       return;
  152075             :     }
  152076             : #endif
  152077             : 
  152078         105 :     SgFloatVal * object = (SgFloatVal*) Pointer;
  152079         105 :     ROSE_ASSERT(object != nullptr);
  152080             : 
  152081             : #if ROSE_ALLOC_TRACE == 2
  152082             : //  printf("SgFloatVal::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgFloatVal::next_node);
  152083             :     printf("SgFloatVal::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgFloatVal::next_node);
  152084             : #endif
  152085             : 
  152086             : #if ROSE_PEDANTIC_ALLOC
  152087             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  152088             : #endif
  152089             : 
  152090             : #if ROSE_ALLOC_MEMSET == 1
  152091             : #elif ROSE_ALLOC_MEMSET == 2
  152092             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgFloatVal) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  152093             : #elif ROSE_ALLOC_MEMSET == 3
  152094             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgFloatVal) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  152095             : #endif
  152096             : 
  152097             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  152098             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  152099             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  152100             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  152101             : #else
  152102         105 :     object->p_freepointer = SgFloatVal::next_node;
  152103         105 :     SgFloatVal::next_node = object;
  152104             : #endif
  152105             : 
  152106             : #if ROSE_ALLOC_TRACE == 2
  152107             : //  printf("SgFloatVal::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgFloatVal::next_node);
  152108             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  152109             :     Rose::MemPool::snapshot(oss.str());
  152110             :     alloc_trace_cnt++;
  152111             : #endif
  152112             : 
  152113             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  152114             : 
  152115         105 :     ALLOC_MUTEX(SgFloatVal, unlock);
  152116             : }
  152117             : 
  152118             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  152119             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  152120             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  152121             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  152122             : // Also, note comment below from Robb (copied from the Common.code file).
  152123             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  152124             : //
  152125             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  152126             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  152127             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  152128             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  152129             : #if 0
  152130             : void SgFloatVal::operator delete(void* pointer) { SgFloatVal::operator delete (pointer, sizeof(SgFloatVal)); };
  152131             : #endif
  152132             : /* #line 152133 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  152133             : 
  152134             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  152135             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  152136             : // obviously imply C++.
  152137             : 
  152138             : // This implements the support within ROSE for memory pools.  Memory pools
  152139             : // support the most condensed usage of memory within the construction of
  152140             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  152141             : // by a new operator written for each class.
  152142             : 
  152143             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  152144             :     // User wants multi-thread support and POSIX threads are available.
  152145             : #   include <pthread.h>
  152146             :     static pthread_mutex_t SgDoubleVal_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  152147             : #else
  152148             :      // Cause synchronization to be skipped.
  152149             : #    ifndef ALLOC_MUTEX
  152150             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  152151             : #    endif
  152152             : #    ifdef _REENTRANT
  152153             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  152154             : #       ifdef _MSC_VER
  152155             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  152156             : #       else
  152157             : #           warning "POSIX threads are not available; synchronization being skipped"
  152158             : #       endif
  152159             : #    endif
  152160             : #endif
  152161             : 
  152162             : #ifndef ROSE_ALLOC_TRACE
  152163             : #  define ROSE_ALLOC_TRACE 0
  152164             : #endif
  152165             : 
  152166             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  152167             : #define ROSE_ALLOC_TRACE_CNT
  152168             : #include "memory-pool-snapshot.h"
  152169             : unsigned long alloc_trace_cnt = 0;
  152170             : #endif
  152171             : 
  152172             : #if ROSE_ALLOC_TRACE
  152173             : const unsigned SgDoubleVal::pool_size = 5;
  152174             : #else
  152175             : const unsigned SgDoubleVal::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  152176             : #endif
  152177             : 
  152178             : #ifndef ROSE_ALLOC_MEMSET
  152179             : #  define ROSE_ALLOC_MEMSET 0
  152180             : #endif
  152181             : 
  152182             : #ifndef ROSE_PEDANTIC_ALLOC
  152183             : #  define ROSE_PEDANTIC_ALLOC 0
  152184             : #endif
  152185             : 
  152186             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  152187             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  152188             : #endif
  152189             : 
  152190             : #if !defined(SGNODE__ALL_POOLS)
  152191             : #define SGNODE__ALL_POOLS
  152192             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  152193             : #endif
  152194             : 
  152195             : SgDoubleVal* SgDoubleVal::next_node = nullptr;
  152196             : std::vector<unsigned char*> SgDoubleVal::pools;
  152197             : 
  152198             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  152199             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  152200             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  152201             : // around this macro definition rather than each use).
  152202             : #ifndef ALLOC_MUTEX
  152203             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  152204             :         do {                                                                     \
  152205             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  152206             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  152207             :                 abort();                                                         \
  152208             :             }                                                                    \
  152209             :         } while (0);
  152210             : #endif
  152211             : 
  152212             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  152213             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  152214             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  152215             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  152216             : 
  152217             : /*! \brief New operator for SgDoubleVal.
  152218             : 
  152219             :    This new operator implements memory pools to provide most efficent 
  152220             :    use of the heap within construction of large ASTs.
  152221             : 
  152222             : \internal The new and delete operators use the lower level C malloc/free
  152223             :    function calls for performance and to make sure that mixing of malloc/free
  152224             :    and new/delete by the used can be caught more readily.  This may change
  152225             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  152226             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  152227             :    deallocate memory allocated using ROSE_MALLOC.
  152228             : */
  152229         586 : void *SgDoubleVal::operator new ( size_t Size )
  152230             : {
  152231             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  152232             :      * returning or throwing an exception. */
  152233         586 :     ALLOC_MUTEX(SgDoubleVal, lock);
  152234             : 
  152235             : #if ROSE_ALLOC_TRACE == 2
  152236             : //    printf("SgDoubleVal::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgDoubleVal::next_node);
  152237             : #endif
  152238             : 
  152239             : #if USE_CPP_NEW_DELETE_OPERATORS
  152240             :     void *mem = ROSE_MALLOC(Size);
  152241             :     ALLOC_MUTEX(SgDoubleVal, unlock);
  152242             :     return mem;
  152243             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  152244             : #if ROSE_PEDANTIC_ALLOC
  152245             :     ROSE_ASSERT(Size == sizeof(SgDoubleVal));
  152246             : #else
  152247         586 :     if (Size != sizeof(SgDoubleVal)) {
  152248           0 :       void * object = ROSE_MALLOC(Size);
  152249           0 :       ALLOC_MUTEX(SgDoubleVal, unlock);
  152250             :       return object;
  152251             :     }
  152252             : #endif
  152253             : 
  152254         586 :     if (SgDoubleVal::next_node == nullptr) {
  152255          65 :         SgDoubleVal * alloc = (SgDoubleVal*) ROSE_MALLOC ( SgDoubleVal::pool_size * sizeof(SgDoubleVal) );
  152256          65 :         ROSE_ASSERT(alloc != nullptr);
  152257             : 
  152258             : #if ROSE_ALLOC_TRACE == 2
  152259             : //        printf("SgDoubleVal::alloc\n  block[%zi] = [ %p , %p [\n", SgDoubleVal::pools.size(), alloc, alloc + SgDoubleVal::pool_size);
  152260             : #endif
  152261             : 
  152262             : #if ROSE_ALLOC_MEMSET == 1
  152263             : #elif ROSE_ALLOC_MEMSET == 2
  152264             :         memset(alloc, 0x00, SgDoubleVal::pool_size * sizeof(SgDoubleVal));
  152265             : #elif ROSE_ALLOC_MEMSET == 3
  152266             :         memset(alloc, 0xAA, SgDoubleVal::pool_size * sizeof(SgDoubleVal));
  152267             : #endif
  152268      130000 :         for (unsigned i=0; i < SgDoubleVal::pool_size-1; i++) {
  152269      129935 :           alloc[i].p_freepointer = &(alloc[i+1]);
  152270             :         }
  152271          65 :         alloc[SgDoubleVal::pool_size-1].p_freepointer = nullptr;
  152272             : 
  152273          65 :         SgDoubleVal::pools.push_back ( (unsigned char *) alloc );
  152274          65 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgDoubleVal::pool_size * sizeof(SgDoubleVal), V_SgDoubleVal ) );
  152275          65 :         SgDoubleVal::next_node = alloc;
  152276             :     }
  152277         586 :     ROSE_ASSERT(SgDoubleVal::next_node != nullptr);
  152278             : 
  152279         586 :     SgDoubleVal * object = SgDoubleVal::next_node;
  152280         586 :     SgDoubleVal::next_node = (SgDoubleVal*)(object->p_freepointer);
  152281             : 
  152282             : #if ROSE_ALLOC_TRACE == 2
  152283             :     printf("SgDoubleVal::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgDoubleVal::next_node);
  152284             : #endif
  152285             : 
  152286         586 :     SgNode * fp = object->p_freepointer;
  152287             : #if ROSE_ALLOC_MEMSET == 1
  152288             : #elif ROSE_ALLOC_MEMSET == 2
  152289             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgDoubleVal) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  152290             : #elif ROSE_ALLOC_MEMSET == 3
  152291             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgDoubleVal) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  152292             : #endif
  152293         586 :     object->p_freepointer = fp;
  152294             : 
  152295             : #if ROSE_ALLOC_TRACE == 2
  152296             : //    printf("SgDoubleVal::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgDoubleVal::next_node);
  152297             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  152298             :     Rose::MemPool::snapshot(oss.str());
  152299             :     alloc_trace_cnt++;
  152300             : #endif
  152301             : 
  152302         586 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  152303             : 
  152304         586 :     ALLOC_MUTEX(SgDoubleVal, unlock);
  152305             : 
  152306             :     return object;
  152307             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  152308             : }
  152309             : 
  152310             : 
  152311             : 
  152312             : /*! \brief Delete operator for SgDoubleVal.
  152313             : 
  152314             :    This delete operator implements deallocation using memory pools to 
  152315             :    provide most efficent use of the heap within construction of large ASTs.
  152316             : 
  152317             : \internal The new and delete operators use the lower level C malloc/free
  152318             :    function calls for performance and to make sure that mixing of malloc/free
  152319             :    and new/delete by the used can be caught more readily.  This may change
  152320             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  152321             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  152322             :    deallocate memory allocated using ROSE_MALLOC.
  152323             : */
  152324         146 : void SgDoubleVal::operator delete(void *Pointer, size_t Size)
  152325             : {
  152326             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  152327             :      * or throwing an exception. */
  152328         146 :     ALLOC_MUTEX(SgDoubleVal, lock);
  152329             : 
  152330             : #if USE_CPP_NEW_DELETE_OPERATORS
  152331             :     ROSE_FREE(Pointer);
  152332             : #else
  152333             : #if ROSE_PEDANTIC_ALLOC
  152334             :     ROSE_ASSERT(Size == sizeof(SgDoubleVal));
  152335             : #else
  152336         146 :     if (Size != sizeof(SgDoubleVal)) {
  152337           0 :       ROSE_FREE(Pointer);
  152338           0 :       ALLOC_MUTEX(SgDoubleVal, unlock);
  152339             :       return;
  152340             :     }
  152341             : #endif
  152342             : 
  152343         146 :     SgDoubleVal * object = (SgDoubleVal*) Pointer;
  152344         146 :     ROSE_ASSERT(object != nullptr);
  152345             : 
  152346             : #if ROSE_ALLOC_TRACE == 2
  152347             : //  printf("SgDoubleVal::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgDoubleVal::next_node);
  152348             :     printf("SgDoubleVal::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgDoubleVal::next_node);
  152349             : #endif
  152350             : 
  152351             : #if ROSE_PEDANTIC_ALLOC
  152352             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  152353             : #endif
  152354             : 
  152355             : #if ROSE_ALLOC_MEMSET == 1
  152356             : #elif ROSE_ALLOC_MEMSET == 2
  152357             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgDoubleVal) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  152358             : #elif ROSE_ALLOC_MEMSET == 3
  152359             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgDoubleVal) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  152360             : #endif
  152361             : 
  152362             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  152363             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  152364             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  152365             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  152366             : #else
  152367         146 :     object->p_freepointer = SgDoubleVal::next_node;
  152368         146 :     SgDoubleVal::next_node = object;
  152369             : #endif
  152370             : 
  152371             : #if ROSE_ALLOC_TRACE == 2
  152372             : //  printf("SgDoubleVal::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgDoubleVal::next_node);
  152373             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  152374             :     Rose::MemPool::snapshot(oss.str());
  152375             :     alloc_trace_cnt++;
  152376             : #endif
  152377             : 
  152378             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  152379             : 
  152380         146 :     ALLOC_MUTEX(SgDoubleVal, unlock);
  152381             : }
  152382             : 
  152383             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  152384             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  152385             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  152386             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  152387             : // Also, note comment below from Robb (copied from the Common.code file).
  152388             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  152389             : //
  152390             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  152391             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  152392             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  152393             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  152394             : #if 0
  152395             : void SgDoubleVal::operator delete(void* pointer) { SgDoubleVal::operator delete (pointer, sizeof(SgDoubleVal)); };
  152396             : #endif
  152397             : /* #line 152398 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  152398             : 
  152399             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  152400             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  152401             : // obviously imply C++.
  152402             : 
  152403             : // This implements the support within ROSE for memory pools.  Memory pools
  152404             : // support the most condensed usage of memory within the construction of
  152405             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  152406             : // by a new operator written for each class.
  152407             : 
  152408             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  152409             :     // User wants multi-thread support and POSIX threads are available.
  152410             : #   include <pthread.h>
  152411             :     static pthread_mutex_t SgLongDoubleVal_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  152412             : #else
  152413             :      // Cause synchronization to be skipped.
  152414             : #    ifndef ALLOC_MUTEX
  152415             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  152416             : #    endif
  152417             : #    ifdef _REENTRANT
  152418             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  152419             : #       ifdef _MSC_VER
  152420             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  152421             : #       else
  152422             : #           warning "POSIX threads are not available; synchronization being skipped"
  152423             : #       endif
  152424             : #    endif
  152425             : #endif
  152426             : 
  152427             : #ifndef ROSE_ALLOC_TRACE
  152428             : #  define ROSE_ALLOC_TRACE 0
  152429             : #endif
  152430             : 
  152431             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  152432             : #define ROSE_ALLOC_TRACE_CNT
  152433             : #include "memory-pool-snapshot.h"
  152434             : unsigned long alloc_trace_cnt = 0;
  152435             : #endif
  152436             : 
  152437             : #if ROSE_ALLOC_TRACE
  152438             : const unsigned SgLongDoubleVal::pool_size = 5;
  152439             : #else
  152440             : const unsigned SgLongDoubleVal::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  152441             : #endif
  152442             : 
  152443             : #ifndef ROSE_ALLOC_MEMSET
  152444             : #  define ROSE_ALLOC_MEMSET 0
  152445             : #endif
  152446             : 
  152447             : #ifndef ROSE_PEDANTIC_ALLOC
  152448             : #  define ROSE_PEDANTIC_ALLOC 0
  152449             : #endif
  152450             : 
  152451             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  152452             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  152453             : #endif
  152454             : 
  152455             : #if !defined(SGNODE__ALL_POOLS)
  152456             : #define SGNODE__ALL_POOLS
  152457             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  152458             : #endif
  152459             : 
  152460             : SgLongDoubleVal* SgLongDoubleVal::next_node = nullptr;
  152461             : std::vector<unsigned char*> SgLongDoubleVal::pools;
  152462             : 
  152463             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  152464             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  152465             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  152466             : // around this macro definition rather than each use).
  152467             : #ifndef ALLOC_MUTEX
  152468             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  152469             :         do {                                                                     \
  152470             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  152471             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  152472             :                 abort();                                                         \
  152473             :             }                                                                    \
  152474             :         } while (0);
  152475             : #endif
  152476             : 
  152477             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  152478             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  152479             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  152480             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  152481             : 
  152482             : /*! \brief New operator for SgLongDoubleVal.
  152483             : 
  152484             :    This new operator implements memory pools to provide most efficent 
  152485             :    use of the heap within construction of large ASTs.
  152486             : 
  152487             : \internal The new and delete operators use the lower level C malloc/free
  152488             :    function calls for performance and to make sure that mixing of malloc/free
  152489             :    and new/delete by the used can be caught more readily.  This may change
  152490             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  152491             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  152492             :    deallocate memory allocated using ROSE_MALLOC.
  152493             : */
  152494          33 : void *SgLongDoubleVal::operator new ( size_t Size )
  152495             : {
  152496             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  152497             :      * returning or throwing an exception. */
  152498          33 :     ALLOC_MUTEX(SgLongDoubleVal, lock);
  152499             : 
  152500             : #if ROSE_ALLOC_TRACE == 2
  152501             : //    printf("SgLongDoubleVal::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgLongDoubleVal::next_node);
  152502             : #endif
  152503             : 
  152504             : #if USE_CPP_NEW_DELETE_OPERATORS
  152505             :     void *mem = ROSE_MALLOC(Size);
  152506             :     ALLOC_MUTEX(SgLongDoubleVal, unlock);
  152507             :     return mem;
  152508             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  152509             : #if ROSE_PEDANTIC_ALLOC
  152510             :     ROSE_ASSERT(Size == sizeof(SgLongDoubleVal));
  152511             : #else
  152512          33 :     if (Size != sizeof(SgLongDoubleVal)) {
  152513           0 :       void * object = ROSE_MALLOC(Size);
  152514           0 :       ALLOC_MUTEX(SgLongDoubleVal, unlock);
  152515             :       return object;
  152516             :     }
  152517             : #endif
  152518             : 
  152519          33 :     if (SgLongDoubleVal::next_node == nullptr) {
  152520           9 :         SgLongDoubleVal * alloc = (SgLongDoubleVal*) ROSE_MALLOC ( SgLongDoubleVal::pool_size * sizeof(SgLongDoubleVal) );
  152521           9 :         ROSE_ASSERT(alloc != nullptr);
  152522             : 
  152523             : #if ROSE_ALLOC_TRACE == 2
  152524             : //        printf("SgLongDoubleVal::alloc\n  block[%zi] = [ %p , %p [\n", SgLongDoubleVal::pools.size(), alloc, alloc + SgLongDoubleVal::pool_size);
  152525             : #endif
  152526             : 
  152527             : #if ROSE_ALLOC_MEMSET == 1
  152528             : #elif ROSE_ALLOC_MEMSET == 2
  152529             :         memset(alloc, 0x00, SgLongDoubleVal::pool_size * sizeof(SgLongDoubleVal));
  152530             : #elif ROSE_ALLOC_MEMSET == 3
  152531             :         memset(alloc, 0xAA, SgLongDoubleVal::pool_size * sizeof(SgLongDoubleVal));
  152532             : #endif
  152533       18000 :         for (unsigned i=0; i < SgLongDoubleVal::pool_size-1; i++) {
  152534       17991 :           alloc[i].p_freepointer = &(alloc[i+1]);
  152535             :         }
  152536           9 :         alloc[SgLongDoubleVal::pool_size-1].p_freepointer = nullptr;
  152537             : 
  152538           9 :         SgLongDoubleVal::pools.push_back ( (unsigned char *) alloc );
  152539           9 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgLongDoubleVal::pool_size * sizeof(SgLongDoubleVal), V_SgLongDoubleVal ) );
  152540           9 :         SgLongDoubleVal::next_node = alloc;
  152541             :     }
  152542          33 :     ROSE_ASSERT(SgLongDoubleVal::next_node != nullptr);
  152543             : 
  152544          33 :     SgLongDoubleVal * object = SgLongDoubleVal::next_node;
  152545          33 :     SgLongDoubleVal::next_node = (SgLongDoubleVal*)(object->p_freepointer);
  152546             : 
  152547             : #if ROSE_ALLOC_TRACE == 2
  152548             :     printf("SgLongDoubleVal::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgLongDoubleVal::next_node);
  152549             : #endif
  152550             : 
  152551          33 :     SgNode * fp = object->p_freepointer;
  152552             : #if ROSE_ALLOC_MEMSET == 1
  152553             : #elif ROSE_ALLOC_MEMSET == 2
  152554             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgLongDoubleVal) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  152555             : #elif ROSE_ALLOC_MEMSET == 3
  152556             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgLongDoubleVal) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  152557             : #endif
  152558          33 :     object->p_freepointer = fp;
  152559             : 
  152560             : #if ROSE_ALLOC_TRACE == 2
  152561             : //    printf("SgLongDoubleVal::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgLongDoubleVal::next_node);
  152562             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  152563             :     Rose::MemPool::snapshot(oss.str());
  152564             :     alloc_trace_cnt++;
  152565             : #endif
  152566             : 
  152567          33 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  152568             : 
  152569          33 :     ALLOC_MUTEX(SgLongDoubleVal, unlock);
  152570             : 
  152571             :     return object;
  152572             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  152573             : }
  152574             : 
  152575             : 
  152576             : 
  152577             : /*! \brief Delete operator for SgLongDoubleVal.
  152578             : 
  152579             :    This delete operator implements deallocation using memory pools to 
  152580             :    provide most efficent use of the heap within construction of large ASTs.
  152581             : 
  152582             : \internal The new and delete operators use the lower level C malloc/free
  152583             :    function calls for performance and to make sure that mixing of malloc/free
  152584             :    and new/delete by the used can be caught more readily.  This may change
  152585             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  152586             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  152587             :    deallocate memory allocated using ROSE_MALLOC.
  152588             : */
  152589          32 : void SgLongDoubleVal::operator delete(void *Pointer, size_t Size)
  152590             : {
  152591             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  152592             :      * or throwing an exception. */
  152593          32 :     ALLOC_MUTEX(SgLongDoubleVal, lock);
  152594             : 
  152595             : #if USE_CPP_NEW_DELETE_OPERATORS
  152596             :     ROSE_FREE(Pointer);
  152597             : #else
  152598             : #if ROSE_PEDANTIC_ALLOC
  152599             :     ROSE_ASSERT(Size == sizeof(SgLongDoubleVal));
  152600             : #else
  152601          32 :     if (Size != sizeof(SgLongDoubleVal)) {
  152602           0 :       ROSE_FREE(Pointer);
  152603           0 :       ALLOC_MUTEX(SgLongDoubleVal, unlock);
  152604             :       return;
  152605             :     }
  152606             : #endif
  152607             : 
  152608          32 :     SgLongDoubleVal * object = (SgLongDoubleVal*) Pointer;
  152609          32 :     ROSE_ASSERT(object != nullptr);
  152610             : 
  152611             : #if ROSE_ALLOC_TRACE == 2
  152612             : //  printf("SgLongDoubleVal::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgLongDoubleVal::next_node);
  152613             :     printf("SgLongDoubleVal::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgLongDoubleVal::next_node);
  152614             : #endif
  152615             : 
  152616             : #if ROSE_PEDANTIC_ALLOC
  152617             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  152618             : #endif
  152619             : 
  152620             : #if ROSE_ALLOC_MEMSET == 1
  152621             : #elif ROSE_ALLOC_MEMSET == 2
  152622             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgLongDoubleVal) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  152623             : #elif ROSE_ALLOC_MEMSET == 3
  152624             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgLongDoubleVal) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  152625             : #endif
  152626             : 
  152627             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  152628             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  152629             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  152630             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  152631             : #else
  152632          32 :     object->p_freepointer = SgLongDoubleVal::next_node;
  152633          32 :     SgLongDoubleVal::next_node = object;
  152634             : #endif
  152635             : 
  152636             : #if ROSE_ALLOC_TRACE == 2
  152637             : //  printf("SgLongDoubleVal::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgLongDoubleVal::next_node);
  152638             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  152639             :     Rose::MemPool::snapshot(oss.str());
  152640             :     alloc_trace_cnt++;
  152641             : #endif
  152642             : 
  152643             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  152644             : 
  152645          32 :     ALLOC_MUTEX(SgLongDoubleVal, unlock);
  152646             : }
  152647             : 
  152648             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  152649             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  152650             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  152651             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  152652             : // Also, note comment below from Robb (copied from the Common.code file).
  152653             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  152654             : //
  152655             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  152656             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  152657             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  152658             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  152659             : #if 0
  152660             : void SgLongDoubleVal::operator delete(void* pointer) { SgLongDoubleVal::operator delete (pointer, sizeof(SgLongDoubleVal)); };
  152661             : #endif
  152662             : /* #line 152663 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  152663             : 
  152664             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  152665             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  152666             : // obviously imply C++.
  152667             : 
  152668             : // This implements the support within ROSE for memory pools.  Memory pools
  152669             : // support the most condensed usage of memory within the construction of
  152670             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  152671             : // by a new operator written for each class.
  152672             : 
  152673             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  152674             :     // User wants multi-thread support and POSIX threads are available.
  152675             : #   include <pthread.h>
  152676             :     static pthread_mutex_t SgComplexVal_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  152677             : #else
  152678             :      // Cause synchronization to be skipped.
  152679             : #    ifndef ALLOC_MUTEX
  152680             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  152681             : #    endif
  152682             : #    ifdef _REENTRANT
  152683             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  152684             : #       ifdef _MSC_VER
  152685             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  152686             : #       else
  152687             : #           warning "POSIX threads are not available; synchronization being skipped"
  152688             : #       endif
  152689             : #    endif
  152690             : #endif
  152691             : 
  152692             : #ifndef ROSE_ALLOC_TRACE
  152693             : #  define ROSE_ALLOC_TRACE 0
  152694             : #endif
  152695             : 
  152696             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  152697             : #define ROSE_ALLOC_TRACE_CNT
  152698             : #include "memory-pool-snapshot.h"
  152699             : unsigned long alloc_trace_cnt = 0;
  152700             : #endif
  152701             : 
  152702             : #if ROSE_ALLOC_TRACE
  152703             : const unsigned SgComplexVal::pool_size = 5;
  152704             : #else
  152705             : const unsigned SgComplexVal::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  152706             : #endif
  152707             : 
  152708             : #ifndef ROSE_ALLOC_MEMSET
  152709             : #  define ROSE_ALLOC_MEMSET 0
  152710             : #endif
  152711             : 
  152712             : #ifndef ROSE_PEDANTIC_ALLOC
  152713             : #  define ROSE_PEDANTIC_ALLOC 0
  152714             : #endif
  152715             : 
  152716             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  152717             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  152718             : #endif
  152719             : 
  152720             : #if !defined(SGNODE__ALL_POOLS)
  152721             : #define SGNODE__ALL_POOLS
  152722             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  152723             : #endif
  152724             : 
  152725             : SgComplexVal* SgComplexVal::next_node = nullptr;
  152726             : std::vector<unsigned char*> SgComplexVal::pools;
  152727             : 
  152728             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  152729             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  152730             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  152731             : // around this macro definition rather than each use).
  152732             : #ifndef ALLOC_MUTEX
  152733             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  152734             :         do {                                                                     \
  152735             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  152736             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  152737             :                 abort();                                                         \
  152738             :             }                                                                    \
  152739             :         } while (0);
  152740             : #endif
  152741             : 
  152742             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  152743             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  152744             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  152745             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  152746             : 
  152747             : /*! \brief New operator for SgComplexVal.
  152748             : 
  152749             :    This new operator implements memory pools to provide most efficent 
  152750             :    use of the heap within construction of large ASTs.
  152751             : 
  152752             : \internal The new and delete operators use the lower level C malloc/free
  152753             :    function calls for performance and to make sure that mixing of malloc/free
  152754             :    and new/delete by the used can be caught more readily.  This may change
  152755             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  152756             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  152757             :    deallocate memory allocated using ROSE_MALLOC.
  152758             : */
  152759           4 : void *SgComplexVal::operator new ( size_t Size )
  152760             : {
  152761             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  152762             :      * returning or throwing an exception. */
  152763           4 :     ALLOC_MUTEX(SgComplexVal, lock);
  152764             : 
  152765             : #if ROSE_ALLOC_TRACE == 2
  152766             : //    printf("SgComplexVal::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgComplexVal::next_node);
  152767             : #endif
  152768             : 
  152769             : #if USE_CPP_NEW_DELETE_OPERATORS
  152770             :     void *mem = ROSE_MALLOC(Size);
  152771             :     ALLOC_MUTEX(SgComplexVal, unlock);
  152772             :     return mem;
  152773             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  152774             : #if ROSE_PEDANTIC_ALLOC
  152775             :     ROSE_ASSERT(Size == sizeof(SgComplexVal));
  152776             : #else
  152777           4 :     if (Size != sizeof(SgComplexVal)) {
  152778           0 :       void * object = ROSE_MALLOC(Size);
  152779           0 :       ALLOC_MUTEX(SgComplexVal, unlock);
  152780             :       return object;
  152781             :     }
  152782             : #endif
  152783             : 
  152784           4 :     if (SgComplexVal::next_node == nullptr) {
  152785           1 :         SgComplexVal * alloc = (SgComplexVal*) ROSE_MALLOC ( SgComplexVal::pool_size * sizeof(SgComplexVal) );
  152786           1 :         ROSE_ASSERT(alloc != nullptr);
  152787             : 
  152788             : #if ROSE_ALLOC_TRACE == 2
  152789             : //        printf("SgComplexVal::alloc\n  block[%zi] = [ %p , %p [\n", SgComplexVal::pools.size(), alloc, alloc + SgComplexVal::pool_size);
  152790             : #endif
  152791             : 
  152792             : #if ROSE_ALLOC_MEMSET == 1
  152793             : #elif ROSE_ALLOC_MEMSET == 2
  152794             :         memset(alloc, 0x00, SgComplexVal::pool_size * sizeof(SgComplexVal));
  152795             : #elif ROSE_ALLOC_MEMSET == 3
  152796             :         memset(alloc, 0xAA, SgComplexVal::pool_size * sizeof(SgComplexVal));
  152797             : #endif
  152798        2000 :         for (unsigned i=0; i < SgComplexVal::pool_size-1; i++) {
  152799        1999 :           alloc[i].p_freepointer = &(alloc[i+1]);
  152800             :         }
  152801           1 :         alloc[SgComplexVal::pool_size-1].p_freepointer = nullptr;
  152802             : 
  152803           1 :         SgComplexVal::pools.push_back ( (unsigned char *) alloc );
  152804           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgComplexVal::pool_size * sizeof(SgComplexVal), V_SgComplexVal ) );
  152805           1 :         SgComplexVal::next_node = alloc;
  152806             :     }
  152807           4 :     ROSE_ASSERT(SgComplexVal::next_node != nullptr);
  152808             : 
  152809           4 :     SgComplexVal * object = SgComplexVal::next_node;
  152810           4 :     SgComplexVal::next_node = (SgComplexVal*)(object->p_freepointer);
  152811             : 
  152812             : #if ROSE_ALLOC_TRACE == 2
  152813             :     printf("SgComplexVal::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgComplexVal::next_node);
  152814             : #endif
  152815             : 
  152816           4 :     SgNode * fp = object->p_freepointer;
  152817             : #if ROSE_ALLOC_MEMSET == 1
  152818             : #elif ROSE_ALLOC_MEMSET == 2
  152819             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgComplexVal) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  152820             : #elif ROSE_ALLOC_MEMSET == 3
  152821             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgComplexVal) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  152822             : #endif
  152823           4 :     object->p_freepointer = fp;
  152824             : 
  152825             : #if ROSE_ALLOC_TRACE == 2
  152826             : //    printf("SgComplexVal::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgComplexVal::next_node);
  152827             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  152828             :     Rose::MemPool::snapshot(oss.str());
  152829             :     alloc_trace_cnt++;
  152830             : #endif
  152831             : 
  152832           4 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  152833             : 
  152834           4 :     ALLOC_MUTEX(SgComplexVal, unlock);
  152835             : 
  152836             :     return object;
  152837             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  152838             : }
  152839             : 
  152840             : 
  152841             : 
  152842             : /*! \brief Delete operator for SgComplexVal.
  152843             : 
  152844             :    This delete operator implements deallocation using memory pools to 
  152845             :    provide most efficent use of the heap within construction of large ASTs.
  152846             : 
  152847             : \internal The new and delete operators use the lower level C malloc/free
  152848             :    function calls for performance and to make sure that mixing of malloc/free
  152849             :    and new/delete by the used can be caught more readily.  This may change
  152850             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  152851             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  152852             :    deallocate memory allocated using ROSE_MALLOC.
  152853             : */
  152854           0 : void SgComplexVal::operator delete(void *Pointer, size_t Size)
  152855             : {
  152856             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  152857             :      * or throwing an exception. */
  152858           0 :     ALLOC_MUTEX(SgComplexVal, lock);
  152859             : 
  152860             : #if USE_CPP_NEW_DELETE_OPERATORS
  152861             :     ROSE_FREE(Pointer);
  152862             : #else
  152863             : #if ROSE_PEDANTIC_ALLOC
  152864             :     ROSE_ASSERT(Size == sizeof(SgComplexVal));
  152865             : #else
  152866           0 :     if (Size != sizeof(SgComplexVal)) {
  152867           0 :       ROSE_FREE(Pointer);
  152868           0 :       ALLOC_MUTEX(SgComplexVal, unlock);
  152869             :       return;
  152870             :     }
  152871             : #endif
  152872             : 
  152873           0 :     SgComplexVal * object = (SgComplexVal*) Pointer;
  152874           0 :     ROSE_ASSERT(object != nullptr);
  152875             : 
  152876             : #if ROSE_ALLOC_TRACE == 2
  152877             : //  printf("SgComplexVal::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgComplexVal::next_node);
  152878             :     printf("SgComplexVal::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgComplexVal::next_node);
  152879             : #endif
  152880             : 
  152881             : #if ROSE_PEDANTIC_ALLOC
  152882             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  152883             : #endif
  152884             : 
  152885             : #if ROSE_ALLOC_MEMSET == 1
  152886             : #elif ROSE_ALLOC_MEMSET == 2
  152887             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgComplexVal) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  152888             : #elif ROSE_ALLOC_MEMSET == 3
  152889             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgComplexVal) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  152890             : #endif
  152891             : 
  152892             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  152893             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  152894             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  152895             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  152896             : #else
  152897           0 :     object->p_freepointer = SgComplexVal::next_node;
  152898           0 :     SgComplexVal::next_node = object;
  152899             : #endif
  152900             : 
  152901             : #if ROSE_ALLOC_TRACE == 2
  152902             : //  printf("SgComplexVal::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgComplexVal::next_node);
  152903             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  152904             :     Rose::MemPool::snapshot(oss.str());
  152905             :     alloc_trace_cnt++;
  152906             : #endif
  152907             : 
  152908             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  152909             : 
  152910           0 :     ALLOC_MUTEX(SgComplexVal, unlock);
  152911             : }
  152912             : 
  152913             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  152914             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  152915             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  152916             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  152917             : // Also, note comment below from Robb (copied from the Common.code file).
  152918             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  152919             : //
  152920             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  152921             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  152922             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  152923             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  152924             : #if 0
  152925             : void SgComplexVal::operator delete(void* pointer) { SgComplexVal::operator delete (pointer, sizeof(SgComplexVal)); };
  152926             : #endif
  152927             : /* #line 152928 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  152928             : 
  152929             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  152930             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  152931             : // obviously imply C++.
  152932             : 
  152933             : // This implements the support within ROSE for memory pools.  Memory pools
  152934             : // support the most condensed usage of memory within the construction of
  152935             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  152936             : // by a new operator written for each class.
  152937             : 
  152938             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  152939             :     // User wants multi-thread support and POSIX threads are available.
  152940             : #   include <pthread.h>
  152941             :     static pthread_mutex_t SgUpcThreads_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  152942             : #else
  152943             :      // Cause synchronization to be skipped.
  152944             : #    ifndef ALLOC_MUTEX
  152945             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  152946             : #    endif
  152947             : #    ifdef _REENTRANT
  152948             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  152949             : #       ifdef _MSC_VER
  152950             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  152951             : #       else
  152952             : #           warning "POSIX threads are not available; synchronization being skipped"
  152953             : #       endif
  152954             : #    endif
  152955             : #endif
  152956             : 
  152957             : #ifndef ROSE_ALLOC_TRACE
  152958             : #  define ROSE_ALLOC_TRACE 0
  152959             : #endif
  152960             : 
  152961             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  152962             : #define ROSE_ALLOC_TRACE_CNT
  152963             : #include "memory-pool-snapshot.h"
  152964             : unsigned long alloc_trace_cnt = 0;
  152965             : #endif
  152966             : 
  152967             : #if ROSE_ALLOC_TRACE
  152968             : const unsigned SgUpcThreads::pool_size = 5;
  152969             : #else
  152970             : const unsigned SgUpcThreads::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  152971             : #endif
  152972             : 
  152973             : #ifndef ROSE_ALLOC_MEMSET
  152974             : #  define ROSE_ALLOC_MEMSET 0
  152975             : #endif
  152976             : 
  152977             : #ifndef ROSE_PEDANTIC_ALLOC
  152978             : #  define ROSE_PEDANTIC_ALLOC 0
  152979             : #endif
  152980             : 
  152981             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  152982             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  152983             : #endif
  152984             : 
  152985             : #if !defined(SGNODE__ALL_POOLS)
  152986             : #define SGNODE__ALL_POOLS
  152987             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  152988             : #endif
  152989             : 
  152990             : SgUpcThreads* SgUpcThreads::next_node = nullptr;
  152991             : std::vector<unsigned char*> SgUpcThreads::pools;
  152992             : 
  152993             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  152994             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  152995             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  152996             : // around this macro definition rather than each use).
  152997             : #ifndef ALLOC_MUTEX
  152998             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  152999             :         do {                                                                     \
  153000             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  153001             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  153002             :                 abort();                                                         \
  153003             :             }                                                                    \
  153004             :         } while (0);
  153005             : #endif
  153006             : 
  153007             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  153008             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  153009             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  153010             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  153011             : 
  153012             : /*! \brief New operator for SgUpcThreads.
  153013             : 
  153014             :    This new operator implements memory pools to provide most efficent 
  153015             :    use of the heap within construction of large ASTs.
  153016             : 
  153017             : \internal The new and delete operators use the lower level C malloc/free
  153018             :    function calls for performance and to make sure that mixing of malloc/free
  153019             :    and new/delete by the used can be caught more readily.  This may change
  153020             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  153021             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  153022             :    deallocate memory allocated using ROSE_MALLOC.
  153023             : */
  153024           0 : void *SgUpcThreads::operator new ( size_t Size )
  153025             : {
  153026             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  153027             :      * returning or throwing an exception. */
  153028           0 :     ALLOC_MUTEX(SgUpcThreads, lock);
  153029             : 
  153030             : #if ROSE_ALLOC_TRACE == 2
  153031             : //    printf("SgUpcThreads::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgUpcThreads::next_node);
  153032             : #endif
  153033             : 
  153034             : #if USE_CPP_NEW_DELETE_OPERATORS
  153035             :     void *mem = ROSE_MALLOC(Size);
  153036             :     ALLOC_MUTEX(SgUpcThreads, unlock);
  153037             :     return mem;
  153038             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  153039             : #if ROSE_PEDANTIC_ALLOC
  153040             :     ROSE_ASSERT(Size == sizeof(SgUpcThreads));
  153041             : #else
  153042           0 :     if (Size != sizeof(SgUpcThreads)) {
  153043           0 :       void * object = ROSE_MALLOC(Size);
  153044           0 :       ALLOC_MUTEX(SgUpcThreads, unlock);
  153045             :       return object;
  153046             :     }
  153047             : #endif
  153048             : 
  153049           0 :     if (SgUpcThreads::next_node == nullptr) {
  153050           0 :         SgUpcThreads * alloc = (SgUpcThreads*) ROSE_MALLOC ( SgUpcThreads::pool_size * sizeof(SgUpcThreads) );
  153051           0 :         ROSE_ASSERT(alloc != nullptr);
  153052             : 
  153053             : #if ROSE_ALLOC_TRACE == 2
  153054             : //        printf("SgUpcThreads::alloc\n  block[%zi] = [ %p , %p [\n", SgUpcThreads::pools.size(), alloc, alloc + SgUpcThreads::pool_size);
  153055             : #endif
  153056             : 
  153057             : #if ROSE_ALLOC_MEMSET == 1
  153058             : #elif ROSE_ALLOC_MEMSET == 2
  153059             :         memset(alloc, 0x00, SgUpcThreads::pool_size * sizeof(SgUpcThreads));
  153060             : #elif ROSE_ALLOC_MEMSET == 3
  153061             :         memset(alloc, 0xAA, SgUpcThreads::pool_size * sizeof(SgUpcThreads));
  153062             : #endif
  153063           0 :         for (unsigned i=0; i < SgUpcThreads::pool_size-1; i++) {
  153064           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
  153065             :         }
  153066           0 :         alloc[SgUpcThreads::pool_size-1].p_freepointer = nullptr;
  153067             : 
  153068           0 :         SgUpcThreads::pools.push_back ( (unsigned char *) alloc );
  153069           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgUpcThreads::pool_size * sizeof(SgUpcThreads), V_SgUpcThreads ) );
  153070           0 :         SgUpcThreads::next_node = alloc;
  153071             :     }
  153072           0 :     ROSE_ASSERT(SgUpcThreads::next_node != nullptr);
  153073             : 
  153074           0 :     SgUpcThreads * object = SgUpcThreads::next_node;
  153075           0 :     SgUpcThreads::next_node = (SgUpcThreads*)(object->p_freepointer);
  153076             : 
  153077             : #if ROSE_ALLOC_TRACE == 2
  153078             :     printf("SgUpcThreads::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUpcThreads::next_node);
  153079             : #endif
  153080             : 
  153081           0 :     SgNode * fp = object->p_freepointer;
  153082             : #if ROSE_ALLOC_MEMSET == 1
  153083             : #elif ROSE_ALLOC_MEMSET == 2
  153084             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgUpcThreads) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  153085             : #elif ROSE_ALLOC_MEMSET == 3
  153086             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgUpcThreads) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  153087             : #endif
  153088           0 :     object->p_freepointer = fp;
  153089             : 
  153090             : #if ROSE_ALLOC_TRACE == 2
  153091             : //    printf("SgUpcThreads::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUpcThreads::next_node);
  153092             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  153093             :     Rose::MemPool::snapshot(oss.str());
  153094             :     alloc_trace_cnt++;
  153095             : #endif
  153096             : 
  153097           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  153098             : 
  153099           0 :     ALLOC_MUTEX(SgUpcThreads, unlock);
  153100             : 
  153101             :     return object;
  153102             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  153103             : }
  153104             : 
  153105             : 
  153106             : 
  153107             : /*! \brief Delete operator for SgUpcThreads.
  153108             : 
  153109             :    This delete operator implements deallocation using memory pools to 
  153110             :    provide most efficent use of the heap within construction of large ASTs.
  153111             : 
  153112             : \internal The new and delete operators use the lower level C malloc/free
  153113             :    function calls for performance and to make sure that mixing of malloc/free
  153114             :    and new/delete by the used can be caught more readily.  This may change
  153115             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  153116             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  153117             :    deallocate memory allocated using ROSE_MALLOC.
  153118             : */
  153119           0 : void SgUpcThreads::operator delete(void *Pointer, size_t Size)
  153120             : {
  153121             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  153122             :      * or throwing an exception. */
  153123           0 :     ALLOC_MUTEX(SgUpcThreads, lock);
  153124             : 
  153125             : #if USE_CPP_NEW_DELETE_OPERATORS
  153126             :     ROSE_FREE(Pointer);
  153127             : #else
  153128             : #if ROSE_PEDANTIC_ALLOC
  153129             :     ROSE_ASSERT(Size == sizeof(SgUpcThreads));
  153130             : #else
  153131           0 :     if (Size != sizeof(SgUpcThreads)) {
  153132           0 :       ROSE_FREE(Pointer);
  153133           0 :       ALLOC_MUTEX(SgUpcThreads, unlock);
  153134             :       return;
  153135             :     }
  153136             : #endif
  153137             : 
  153138           0 :     SgUpcThreads * object = (SgUpcThreads*) Pointer;
  153139           0 :     ROSE_ASSERT(object != nullptr);
  153140             : 
  153141             : #if ROSE_ALLOC_TRACE == 2
  153142             : //  printf("SgUpcThreads::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUpcThreads::next_node);
  153143             :     printf("SgUpcThreads::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUpcThreads::next_node);
  153144             : #endif
  153145             : 
  153146             : #if ROSE_PEDANTIC_ALLOC
  153147             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  153148             : #endif
  153149             : 
  153150             : #if ROSE_ALLOC_MEMSET == 1
  153151             : #elif ROSE_ALLOC_MEMSET == 2
  153152             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgUpcThreads) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  153153             : #elif ROSE_ALLOC_MEMSET == 3
  153154             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgUpcThreads) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  153155             : #endif
  153156             : 
  153157             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  153158             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  153159             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  153160             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  153161             : #else
  153162           0 :     object->p_freepointer = SgUpcThreads::next_node;
  153163           0 :     SgUpcThreads::next_node = object;
  153164             : #endif
  153165             : 
  153166             : #if ROSE_ALLOC_TRACE == 2
  153167             : //  printf("SgUpcThreads::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUpcThreads::next_node);
  153168             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  153169             :     Rose::MemPool::snapshot(oss.str());
  153170             :     alloc_trace_cnt++;
  153171             : #endif
  153172             : 
  153173             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  153174             : 
  153175           0 :     ALLOC_MUTEX(SgUpcThreads, unlock);
  153176             : }
  153177             : 
  153178             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  153179             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  153180             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  153181             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  153182             : // Also, note comment below from Robb (copied from the Common.code file).
  153183             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  153184             : //
  153185             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  153186             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  153187             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  153188             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  153189             : #if 0
  153190             : void SgUpcThreads::operator delete(void* pointer) { SgUpcThreads::operator delete (pointer, sizeof(SgUpcThreads)); };
  153191             : #endif
  153192             : /* #line 153193 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  153193             : 
  153194             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  153195             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  153196             : // obviously imply C++.
  153197             : 
  153198             : // This implements the support within ROSE for memory pools.  Memory pools
  153199             : // support the most condensed usage of memory within the construction of
  153200             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  153201             : // by a new operator written for each class.
  153202             : 
  153203             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  153204             :     // User wants multi-thread support and POSIX threads are available.
  153205             : #   include <pthread.h>
  153206             :     static pthread_mutex_t SgUpcMythread_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  153207             : #else
  153208             :      // Cause synchronization to be skipped.
  153209             : #    ifndef ALLOC_MUTEX
  153210             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  153211             : #    endif
  153212             : #    ifdef _REENTRANT
  153213             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  153214             : #       ifdef _MSC_VER
  153215             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  153216             : #       else
  153217             : #           warning "POSIX threads are not available; synchronization being skipped"
  153218             : #       endif
  153219             : #    endif
  153220             : #endif
  153221             : 
  153222             : #ifndef ROSE_ALLOC_TRACE
  153223             : #  define ROSE_ALLOC_TRACE 0
  153224             : #endif
  153225             : 
  153226             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  153227             : #define ROSE_ALLOC_TRACE_CNT
  153228             : #include "memory-pool-snapshot.h"
  153229             : unsigned long alloc_trace_cnt = 0;
  153230             : #endif
  153231             : 
  153232             : #if ROSE_ALLOC_TRACE
  153233             : const unsigned SgUpcMythread::pool_size = 5;
  153234             : #else
  153235             : const unsigned SgUpcMythread::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  153236             : #endif
  153237             : 
  153238             : #ifndef ROSE_ALLOC_MEMSET
  153239             : #  define ROSE_ALLOC_MEMSET 0
  153240             : #endif
  153241             : 
  153242             : #ifndef ROSE_PEDANTIC_ALLOC
  153243             : #  define ROSE_PEDANTIC_ALLOC 0
  153244             : #endif
  153245             : 
  153246             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  153247             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  153248             : #endif
  153249             : 
  153250             : #if !defined(SGNODE__ALL_POOLS)
  153251             : #define SGNODE__ALL_POOLS
  153252             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  153253             : #endif
  153254             : 
  153255             : SgUpcMythread* SgUpcMythread::next_node = nullptr;
  153256             : std::vector<unsigned char*> SgUpcMythread::pools;
  153257             : 
  153258             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  153259             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  153260             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  153261             : // around this macro definition rather than each use).
  153262             : #ifndef ALLOC_MUTEX
  153263             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  153264             :         do {                                                                     \
  153265             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  153266             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  153267             :                 abort();                                                         \
  153268             :             }                                                                    \
  153269             :         } while (0);
  153270             : #endif
  153271             : 
  153272             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  153273             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  153274             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  153275             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  153276             : 
  153277             : /*! \brief New operator for SgUpcMythread.
  153278             : 
  153279             :    This new operator implements memory pools to provide most efficent 
  153280             :    use of the heap within construction of large ASTs.
  153281             : 
  153282             : \internal The new and delete operators use the lower level C malloc/free
  153283             :    function calls for performance and to make sure that mixing of malloc/free
  153284             :    and new/delete by the used can be caught more readily.  This may change
  153285             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  153286             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  153287             :    deallocate memory allocated using ROSE_MALLOC.
  153288             : */
  153289           0 : void *SgUpcMythread::operator new ( size_t Size )
  153290             : {
  153291             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  153292             :      * returning or throwing an exception. */
  153293           0 :     ALLOC_MUTEX(SgUpcMythread, lock);
  153294             : 
  153295             : #if ROSE_ALLOC_TRACE == 2
  153296             : //    printf("SgUpcMythread::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgUpcMythread::next_node);
  153297             : #endif
  153298             : 
  153299             : #if USE_CPP_NEW_DELETE_OPERATORS
  153300             :     void *mem = ROSE_MALLOC(Size);
  153301             :     ALLOC_MUTEX(SgUpcMythread, unlock);
  153302             :     return mem;
  153303             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  153304             : #if ROSE_PEDANTIC_ALLOC
  153305             :     ROSE_ASSERT(Size == sizeof(SgUpcMythread));
  153306             : #else
  153307           0 :     if (Size != sizeof(SgUpcMythread)) {
  153308           0 :       void * object = ROSE_MALLOC(Size);
  153309           0 :       ALLOC_MUTEX(SgUpcMythread, unlock);
  153310             :       return object;
  153311             :     }
  153312             : #endif
  153313             : 
  153314           0 :     if (SgUpcMythread::next_node == nullptr) {
  153315           0 :         SgUpcMythread * alloc = (SgUpcMythread*) ROSE_MALLOC ( SgUpcMythread::pool_size * sizeof(SgUpcMythread) );
  153316           0 :         ROSE_ASSERT(alloc != nullptr);
  153317             : 
  153318             : #if ROSE_ALLOC_TRACE == 2
  153319             : //        printf("SgUpcMythread::alloc\n  block[%zi] = [ %p , %p [\n", SgUpcMythread::pools.size(), alloc, alloc + SgUpcMythread::pool_size);
  153320             : #endif
  153321             : 
  153322             : #if ROSE_ALLOC_MEMSET == 1
  153323             : #elif ROSE_ALLOC_MEMSET == 2
  153324             :         memset(alloc, 0x00, SgUpcMythread::pool_size * sizeof(SgUpcMythread));
  153325             : #elif ROSE_ALLOC_MEMSET == 3
  153326             :         memset(alloc, 0xAA, SgUpcMythread::pool_size * sizeof(SgUpcMythread));
  153327             : #endif
  153328           0 :         for (unsigned i=0; i < SgUpcMythread::pool_size-1; i++) {
  153329           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
  153330             :         }
  153331           0 :         alloc[SgUpcMythread::pool_size-1].p_freepointer = nullptr;
  153332             : 
  153333           0 :         SgUpcMythread::pools.push_back ( (unsigned char *) alloc );
  153334           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgUpcMythread::pool_size * sizeof(SgUpcMythread), V_SgUpcMythread ) );
  153335           0 :         SgUpcMythread::next_node = alloc;
  153336             :     }
  153337           0 :     ROSE_ASSERT(SgUpcMythread::next_node != nullptr);
  153338             : 
  153339           0 :     SgUpcMythread * object = SgUpcMythread::next_node;
  153340           0 :     SgUpcMythread::next_node = (SgUpcMythread*)(object->p_freepointer);
  153341             : 
  153342             : #if ROSE_ALLOC_TRACE == 2
  153343             :     printf("SgUpcMythread::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUpcMythread::next_node);
  153344             : #endif
  153345             : 
  153346           0 :     SgNode * fp = object->p_freepointer;
  153347             : #if ROSE_ALLOC_MEMSET == 1
  153348             : #elif ROSE_ALLOC_MEMSET == 2
  153349             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgUpcMythread) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  153350             : #elif ROSE_ALLOC_MEMSET == 3
  153351             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgUpcMythread) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  153352             : #endif
  153353           0 :     object->p_freepointer = fp;
  153354             : 
  153355             : #if ROSE_ALLOC_TRACE == 2
  153356             : //    printf("SgUpcMythread::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUpcMythread::next_node);
  153357             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  153358             :     Rose::MemPool::snapshot(oss.str());
  153359             :     alloc_trace_cnt++;
  153360             : #endif
  153361             : 
  153362           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  153363             : 
  153364           0 :     ALLOC_MUTEX(SgUpcMythread, unlock);
  153365             : 
  153366             :     return object;
  153367             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  153368             : }
  153369             : 
  153370             : 
  153371             : 
  153372             : /*! \brief Delete operator for SgUpcMythread.
  153373             : 
  153374             :    This delete operator implements deallocation using memory pools to 
  153375             :    provide most efficent use of the heap within construction of large ASTs.
  153376             : 
  153377             : \internal The new and delete operators use the lower level C malloc/free
  153378             :    function calls for performance and to make sure that mixing of malloc/free
  153379             :    and new/delete by the used can be caught more readily.  This may change
  153380             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  153381             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  153382             :    deallocate memory allocated using ROSE_MALLOC.
  153383             : */
  153384           0 : void SgUpcMythread::operator delete(void *Pointer, size_t Size)
  153385             : {
  153386             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  153387             :      * or throwing an exception. */
  153388           0 :     ALLOC_MUTEX(SgUpcMythread, lock);
  153389             : 
  153390             : #if USE_CPP_NEW_DELETE_OPERATORS
  153391             :     ROSE_FREE(Pointer);
  153392             : #else
  153393             : #if ROSE_PEDANTIC_ALLOC
  153394             :     ROSE_ASSERT(Size == sizeof(SgUpcMythread));
  153395             : #else
  153396           0 :     if (Size != sizeof(SgUpcMythread)) {
  153397           0 :       ROSE_FREE(Pointer);
  153398           0 :       ALLOC_MUTEX(SgUpcMythread, unlock);
  153399             :       return;
  153400             :     }
  153401             : #endif
  153402             : 
  153403           0 :     SgUpcMythread * object = (SgUpcMythread*) Pointer;
  153404           0 :     ROSE_ASSERT(object != nullptr);
  153405             : 
  153406             : #if ROSE_ALLOC_TRACE == 2
  153407             : //  printf("SgUpcMythread::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUpcMythread::next_node);
  153408             :     printf("SgUpcMythread::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUpcMythread::next_node);
  153409             : #endif
  153410             : 
  153411             : #if ROSE_PEDANTIC_ALLOC
  153412             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  153413             : #endif
  153414             : 
  153415             : #if ROSE_ALLOC_MEMSET == 1
  153416             : #elif ROSE_ALLOC_MEMSET == 2
  153417             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgUpcMythread) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  153418             : #elif ROSE_ALLOC_MEMSET == 3
  153419             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgUpcMythread) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  153420             : #endif
  153421             : 
  153422             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  153423             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  153424             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  153425             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  153426             : #else
  153427           0 :     object->p_freepointer = SgUpcMythread::next_node;
  153428           0 :     SgUpcMythread::next_node = object;
  153429             : #endif
  153430             : 
  153431             : #if ROSE_ALLOC_TRACE == 2
  153432             : //  printf("SgUpcMythread::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUpcMythread::next_node);
  153433             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  153434             :     Rose::MemPool::snapshot(oss.str());
  153435             :     alloc_trace_cnt++;
  153436             : #endif
  153437             : 
  153438             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  153439             : 
  153440           0 :     ALLOC_MUTEX(SgUpcMythread, unlock);
  153441             : }
  153442             : 
  153443             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  153444             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  153445             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  153446             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  153447             : // Also, note comment below from Robb (copied from the Common.code file).
  153448             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  153449             : //
  153450             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  153451             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  153452             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  153453             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  153454             : #if 0
  153455             : void SgUpcMythread::operator delete(void* pointer) { SgUpcMythread::operator delete (pointer, sizeof(SgUpcMythread)); };
  153456             : #endif
  153457             : /* #line 153458 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  153458             : 
  153459             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  153460             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  153461             : // obviously imply C++.
  153462             : 
  153463             : // This implements the support within ROSE for memory pools.  Memory pools
  153464             : // support the most condensed usage of memory within the construction of
  153465             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  153466             : // by a new operator written for each class.
  153467             : 
  153468             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  153469             :     // User wants multi-thread support and POSIX threads are available.
  153470             : #   include <pthread.h>
  153471             :     static pthread_mutex_t SgTemplateParameterVal_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  153472             : #else
  153473             :      // Cause synchronization to be skipped.
  153474             : #    ifndef ALLOC_MUTEX
  153475             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  153476             : #    endif
  153477             : #    ifdef _REENTRANT
  153478             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  153479             : #       ifdef _MSC_VER
  153480             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  153481             : #       else
  153482             : #           warning "POSIX threads are not available; synchronization being skipped"
  153483             : #       endif
  153484             : #    endif
  153485             : #endif
  153486             : 
  153487             : #ifndef ROSE_ALLOC_TRACE
  153488             : #  define ROSE_ALLOC_TRACE 0
  153489             : #endif
  153490             : 
  153491             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  153492             : #define ROSE_ALLOC_TRACE_CNT
  153493             : #include "memory-pool-snapshot.h"
  153494             : unsigned long alloc_trace_cnt = 0;
  153495             : #endif
  153496             : 
  153497             : #if ROSE_ALLOC_TRACE
  153498             : const unsigned SgTemplateParameterVal::pool_size = 5;
  153499             : #else
  153500             : const unsigned SgTemplateParameterVal::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  153501             : #endif
  153502             : 
  153503             : #ifndef ROSE_ALLOC_MEMSET
  153504             : #  define ROSE_ALLOC_MEMSET 0
  153505             : #endif
  153506             : 
  153507             : #ifndef ROSE_PEDANTIC_ALLOC
  153508             : #  define ROSE_PEDANTIC_ALLOC 0
  153509             : #endif
  153510             : 
  153511             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  153512             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  153513             : #endif
  153514             : 
  153515             : #if !defined(SGNODE__ALL_POOLS)
  153516             : #define SGNODE__ALL_POOLS
  153517             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  153518             : #endif
  153519             : 
  153520             : SgTemplateParameterVal* SgTemplateParameterVal::next_node = nullptr;
  153521             : std::vector<unsigned char*> SgTemplateParameterVal::pools;
  153522             : 
  153523             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  153524             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  153525             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  153526             : // around this macro definition rather than each use).
  153527             : #ifndef ALLOC_MUTEX
  153528             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  153529             :         do {                                                                     \
  153530             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  153531             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  153532             :                 abort();                                                         \
  153533             :             }                                                                    \
  153534             :         } while (0);
  153535             : #endif
  153536             : 
  153537             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  153538             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  153539             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  153540             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  153541             : 
  153542             : /*! \brief New operator for SgTemplateParameterVal.
  153543             : 
  153544             :    This new operator implements memory pools to provide most efficent 
  153545             :    use of the heap within construction of large ASTs.
  153546             : 
  153547             : \internal The new and delete operators use the lower level C malloc/free
  153548             :    function calls for performance and to make sure that mixing of malloc/free
  153549             :    and new/delete by the used can be caught more readily.  This may change
  153550             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  153551             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  153552             :    deallocate memory allocated using ROSE_MALLOC.
  153553             : */
  153554           0 : void *SgTemplateParameterVal::operator new ( size_t Size )
  153555             : {
  153556             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  153557             :      * returning or throwing an exception. */
  153558           0 :     ALLOC_MUTEX(SgTemplateParameterVal, lock);
  153559             : 
  153560             : #if ROSE_ALLOC_TRACE == 2
  153561             : //    printf("SgTemplateParameterVal::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgTemplateParameterVal::next_node);
  153562             : #endif
  153563             : 
  153564             : #if USE_CPP_NEW_DELETE_OPERATORS
  153565             :     void *mem = ROSE_MALLOC(Size);
  153566             :     ALLOC_MUTEX(SgTemplateParameterVal, unlock);
  153567             :     return mem;
  153568             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  153569             : #if ROSE_PEDANTIC_ALLOC
  153570             :     ROSE_ASSERT(Size == sizeof(SgTemplateParameterVal));
  153571             : #else
  153572           0 :     if (Size != sizeof(SgTemplateParameterVal)) {
  153573           0 :       void * object = ROSE_MALLOC(Size);
  153574           0 :       ALLOC_MUTEX(SgTemplateParameterVal, unlock);
  153575             :       return object;
  153576             :     }
  153577             : #endif
  153578             : 
  153579           0 :     if (SgTemplateParameterVal::next_node == nullptr) {
  153580           0 :         SgTemplateParameterVal * alloc = (SgTemplateParameterVal*) ROSE_MALLOC ( SgTemplateParameterVal::pool_size * sizeof(SgTemplateParameterVal) );
  153581           0 :         ROSE_ASSERT(alloc != nullptr);
  153582             : 
  153583             : #if ROSE_ALLOC_TRACE == 2
  153584             : //        printf("SgTemplateParameterVal::alloc\n  block[%zi] = [ %p , %p [\n", SgTemplateParameterVal::pools.size(), alloc, alloc + SgTemplateParameterVal::pool_size);
  153585             : #endif
  153586             : 
  153587             : #if ROSE_ALLOC_MEMSET == 1
  153588             : #elif ROSE_ALLOC_MEMSET == 2
  153589             :         memset(alloc, 0x00, SgTemplateParameterVal::pool_size * sizeof(SgTemplateParameterVal));
  153590             : #elif ROSE_ALLOC_MEMSET == 3
  153591             :         memset(alloc, 0xAA, SgTemplateParameterVal::pool_size * sizeof(SgTemplateParameterVal));
  153592             : #endif
  153593           0 :         for (unsigned i=0; i < SgTemplateParameterVal::pool_size-1; i++) {
  153594           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
  153595             :         }
  153596           0 :         alloc[SgTemplateParameterVal::pool_size-1].p_freepointer = nullptr;
  153597             : 
  153598           0 :         SgTemplateParameterVal::pools.push_back ( (unsigned char *) alloc );
  153599           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgTemplateParameterVal::pool_size * sizeof(SgTemplateParameterVal), V_SgTemplateParameterVal ) );
  153600           0 :         SgTemplateParameterVal::next_node = alloc;
  153601             :     }
  153602           0 :     ROSE_ASSERT(SgTemplateParameterVal::next_node != nullptr);
  153603             : 
  153604           0 :     SgTemplateParameterVal * object = SgTemplateParameterVal::next_node;
  153605           0 :     SgTemplateParameterVal::next_node = (SgTemplateParameterVal*)(object->p_freepointer);
  153606             : 
  153607             : #if ROSE_ALLOC_TRACE == 2
  153608             :     printf("SgTemplateParameterVal::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTemplateParameterVal::next_node);
  153609             : #endif
  153610             : 
  153611           0 :     SgNode * fp = object->p_freepointer;
  153612             : #if ROSE_ALLOC_MEMSET == 1
  153613             : #elif ROSE_ALLOC_MEMSET == 2
  153614             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgTemplateParameterVal) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  153615             : #elif ROSE_ALLOC_MEMSET == 3
  153616             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgTemplateParameterVal) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  153617             : #endif
  153618           0 :     object->p_freepointer = fp;
  153619             : 
  153620             : #if ROSE_ALLOC_TRACE == 2
  153621             : //    printf("SgTemplateParameterVal::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTemplateParameterVal::next_node);
  153622             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  153623             :     Rose::MemPool::snapshot(oss.str());
  153624             :     alloc_trace_cnt++;
  153625             : #endif
  153626             : 
  153627           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  153628             : 
  153629           0 :     ALLOC_MUTEX(SgTemplateParameterVal, unlock);
  153630             : 
  153631             :     return object;
  153632             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  153633             : }
  153634             : 
  153635             : 
  153636             : 
  153637             : /*! \brief Delete operator for SgTemplateParameterVal.
  153638             : 
  153639             :    This delete operator implements deallocation using memory pools to 
  153640             :    provide most efficent use of the heap within construction of large ASTs.
  153641             : 
  153642             : \internal The new and delete operators use the lower level C malloc/free
  153643             :    function calls for performance and to make sure that mixing of malloc/free
  153644             :    and new/delete by the used can be caught more readily.  This may change
  153645             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  153646             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  153647             :    deallocate memory allocated using ROSE_MALLOC.
  153648             : */
  153649           0 : void SgTemplateParameterVal::operator delete(void *Pointer, size_t Size)
  153650             : {
  153651             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  153652             :      * or throwing an exception. */
  153653           0 :     ALLOC_MUTEX(SgTemplateParameterVal, lock);
  153654             : 
  153655             : #if USE_CPP_NEW_DELETE_OPERATORS
  153656             :     ROSE_FREE(Pointer);
  153657             : #else
  153658             : #if ROSE_PEDANTIC_ALLOC
  153659             :     ROSE_ASSERT(Size == sizeof(SgTemplateParameterVal));
  153660             : #else
  153661           0 :     if (Size != sizeof(SgTemplateParameterVal)) {
  153662           0 :       ROSE_FREE(Pointer);
  153663           0 :       ALLOC_MUTEX(SgTemplateParameterVal, unlock);
  153664             :       return;
  153665             :     }
  153666             : #endif
  153667             : 
  153668           0 :     SgTemplateParameterVal * object = (SgTemplateParameterVal*) Pointer;
  153669           0 :     ROSE_ASSERT(object != nullptr);
  153670             : 
  153671             : #if ROSE_ALLOC_TRACE == 2
  153672             : //  printf("SgTemplateParameterVal::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTemplateParameterVal::next_node);
  153673             :     printf("SgTemplateParameterVal::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTemplateParameterVal::next_node);
  153674             : #endif
  153675             : 
  153676             : #if ROSE_PEDANTIC_ALLOC
  153677             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  153678             : #endif
  153679             : 
  153680             : #if ROSE_ALLOC_MEMSET == 1
  153681             : #elif ROSE_ALLOC_MEMSET == 2
  153682             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgTemplateParameterVal) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  153683             : #elif ROSE_ALLOC_MEMSET == 3
  153684             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgTemplateParameterVal) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  153685             : #endif
  153686             : 
  153687             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  153688             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  153689             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  153690             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  153691             : #else
  153692           0 :     object->p_freepointer = SgTemplateParameterVal::next_node;
  153693           0 :     SgTemplateParameterVal::next_node = object;
  153694             : #endif
  153695             : 
  153696             : #if ROSE_ALLOC_TRACE == 2
  153697             : //  printf("SgTemplateParameterVal::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTemplateParameterVal::next_node);
  153698             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  153699             :     Rose::MemPool::snapshot(oss.str());
  153700             :     alloc_trace_cnt++;
  153701             : #endif
  153702             : 
  153703             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  153704             : 
  153705           0 :     ALLOC_MUTEX(SgTemplateParameterVal, unlock);
  153706             : }
  153707             : 
  153708             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  153709             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  153710             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  153711             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  153712             : // Also, note comment below from Robb (copied from the Common.code file).
  153713             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  153714             : //
  153715             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  153716             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  153717             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  153718             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  153719             : #if 0
  153720             : void SgTemplateParameterVal::operator delete(void* pointer) { SgTemplateParameterVal::operator delete (pointer, sizeof(SgTemplateParameterVal)); };
  153721             : #endif
  153722             : /* #line 153723 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  153723             : 
  153724             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  153725             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  153726             : // obviously imply C++.
  153727             : 
  153728             : // This implements the support within ROSE for memory pools.  Memory pools
  153729             : // support the most condensed usage of memory within the construction of
  153730             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  153731             : // by a new operator written for each class.
  153732             : 
  153733             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  153734             :     // User wants multi-thread support and POSIX threads are available.
  153735             : #   include <pthread.h>
  153736             :     static pthread_mutex_t SgNullptrValExp_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  153737             : #else
  153738             :      // Cause synchronization to be skipped.
  153739             : #    ifndef ALLOC_MUTEX
  153740             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  153741             : #    endif
  153742             : #    ifdef _REENTRANT
  153743             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  153744             : #       ifdef _MSC_VER
  153745             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  153746             : #       else
  153747             : #           warning "POSIX threads are not available; synchronization being skipped"
  153748             : #       endif
  153749             : #    endif
  153750             : #endif
  153751             : 
  153752             : #ifndef ROSE_ALLOC_TRACE
  153753             : #  define ROSE_ALLOC_TRACE 0
  153754             : #endif
  153755             : 
  153756             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  153757             : #define ROSE_ALLOC_TRACE_CNT
  153758             : #include "memory-pool-snapshot.h"
  153759             : unsigned long alloc_trace_cnt = 0;
  153760             : #endif
  153761             : 
  153762             : #if ROSE_ALLOC_TRACE
  153763             : const unsigned SgNullptrValExp::pool_size = 5;
  153764             : #else
  153765             : const unsigned SgNullptrValExp::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  153766             : #endif
  153767             : 
  153768             : #ifndef ROSE_ALLOC_MEMSET
  153769             : #  define ROSE_ALLOC_MEMSET 0
  153770             : #endif
  153771             : 
  153772             : #ifndef ROSE_PEDANTIC_ALLOC
  153773             : #  define ROSE_PEDANTIC_ALLOC 0
  153774             : #endif
  153775             : 
  153776             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  153777             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  153778             : #endif
  153779             : 
  153780             : #if !defined(SGNODE__ALL_POOLS)
  153781             : #define SGNODE__ALL_POOLS
  153782             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  153783             : #endif
  153784             : 
  153785             : SgNullptrValExp* SgNullptrValExp::next_node = nullptr;
  153786             : std::vector<unsigned char*> SgNullptrValExp::pools;
  153787             : 
  153788             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  153789             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  153790             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  153791             : // around this macro definition rather than each use).
  153792             : #ifndef ALLOC_MUTEX
  153793             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  153794             :         do {                                                                     \
  153795             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  153796             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  153797             :                 abort();                                                         \
  153798             :             }                                                                    \
  153799             :         } while (0);
  153800             : #endif
  153801             : 
  153802             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  153803             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  153804             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  153805             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  153806             : 
  153807             : /*! \brief New operator for SgNullptrValExp.
  153808             : 
  153809             :    This new operator implements memory pools to provide most efficent 
  153810             :    use of the heap within construction of large ASTs.
  153811             : 
  153812             : \internal The new and delete operators use the lower level C malloc/free
  153813             :    function calls for performance and to make sure that mixing of malloc/free
  153814             :    and new/delete by the used can be caught more readily.  This may change
  153815             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  153816             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  153817             :    deallocate memory allocated using ROSE_MALLOC.
  153818             : */
  153819         131 : void *SgNullptrValExp::operator new ( size_t Size )
  153820             : {
  153821             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  153822             :      * returning or throwing an exception. */
  153823         131 :     ALLOC_MUTEX(SgNullptrValExp, lock);
  153824             : 
  153825             : #if ROSE_ALLOC_TRACE == 2
  153826             : //    printf("SgNullptrValExp::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgNullptrValExp::next_node);
  153827             : #endif
  153828             : 
  153829             : #if USE_CPP_NEW_DELETE_OPERATORS
  153830             :     void *mem = ROSE_MALLOC(Size);
  153831             :     ALLOC_MUTEX(SgNullptrValExp, unlock);
  153832             :     return mem;
  153833             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  153834             : #if ROSE_PEDANTIC_ALLOC
  153835             :     ROSE_ASSERT(Size == sizeof(SgNullptrValExp));
  153836             : #else
  153837         131 :     if (Size != sizeof(SgNullptrValExp)) {
  153838           0 :       void * object = ROSE_MALLOC(Size);
  153839           0 :       ALLOC_MUTEX(SgNullptrValExp, unlock);
  153840             :       return object;
  153841             :     }
  153842             : #endif
  153843             : 
  153844         131 :     if (SgNullptrValExp::next_node == nullptr) {
  153845          62 :         SgNullptrValExp * alloc = (SgNullptrValExp*) ROSE_MALLOC ( SgNullptrValExp::pool_size * sizeof(SgNullptrValExp) );
  153846          62 :         ROSE_ASSERT(alloc != nullptr);
  153847             : 
  153848             : #if ROSE_ALLOC_TRACE == 2
  153849             : //        printf("SgNullptrValExp::alloc\n  block[%zi] = [ %p , %p [\n", SgNullptrValExp::pools.size(), alloc, alloc + SgNullptrValExp::pool_size);
  153850             : #endif
  153851             : 
  153852             : #if ROSE_ALLOC_MEMSET == 1
  153853             : #elif ROSE_ALLOC_MEMSET == 2
  153854             :         memset(alloc, 0x00, SgNullptrValExp::pool_size * sizeof(SgNullptrValExp));
  153855             : #elif ROSE_ALLOC_MEMSET == 3
  153856             :         memset(alloc, 0xAA, SgNullptrValExp::pool_size * sizeof(SgNullptrValExp));
  153857             : #endif
  153858      124000 :         for (unsigned i=0; i < SgNullptrValExp::pool_size-1; i++) {
  153859      123938 :           alloc[i].p_freepointer = &(alloc[i+1]);
  153860             :         }
  153861          62 :         alloc[SgNullptrValExp::pool_size-1].p_freepointer = nullptr;
  153862             : 
  153863          62 :         SgNullptrValExp::pools.push_back ( (unsigned char *) alloc );
  153864          62 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgNullptrValExp::pool_size * sizeof(SgNullptrValExp), V_SgNullptrValExp ) );
  153865          62 :         SgNullptrValExp::next_node = alloc;
  153866             :     }
  153867         131 :     ROSE_ASSERT(SgNullptrValExp::next_node != nullptr);
  153868             : 
  153869         131 :     SgNullptrValExp * object = SgNullptrValExp::next_node;
  153870         131 :     SgNullptrValExp::next_node = (SgNullptrValExp*)(object->p_freepointer);
  153871             : 
  153872             : #if ROSE_ALLOC_TRACE == 2
  153873             :     printf("SgNullptrValExp::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgNullptrValExp::next_node);
  153874             : #endif
  153875             : 
  153876         131 :     SgNode * fp = object->p_freepointer;
  153877             : #if ROSE_ALLOC_MEMSET == 1
  153878             : #elif ROSE_ALLOC_MEMSET == 2
  153879             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgNullptrValExp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  153880             : #elif ROSE_ALLOC_MEMSET == 3
  153881             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgNullptrValExp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  153882             : #endif
  153883         131 :     object->p_freepointer = fp;
  153884             : 
  153885             : #if ROSE_ALLOC_TRACE == 2
  153886             : //    printf("SgNullptrValExp::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgNullptrValExp::next_node);
  153887             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  153888             :     Rose::MemPool::snapshot(oss.str());
  153889             :     alloc_trace_cnt++;
  153890             : #endif
  153891             : 
  153892         131 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  153893             : 
  153894         131 :     ALLOC_MUTEX(SgNullptrValExp, unlock);
  153895             : 
  153896             :     return object;
  153897             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  153898             : }
  153899             : 
  153900             : 
  153901             : 
  153902             : /*! \brief Delete operator for SgNullptrValExp.
  153903             : 
  153904             :    This delete operator implements deallocation using memory pools to 
  153905             :    provide most efficent use of the heap within construction of large ASTs.
  153906             : 
  153907             : \internal The new and delete operators use the lower level C malloc/free
  153908             :    function calls for performance and to make sure that mixing of malloc/free
  153909             :    and new/delete by the used can be caught more readily.  This may change
  153910             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  153911             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  153912             :    deallocate memory allocated using ROSE_MALLOC.
  153913             : */
  153914          12 : void SgNullptrValExp::operator delete(void *Pointer, size_t Size)
  153915             : {
  153916             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  153917             :      * or throwing an exception. */
  153918          12 :     ALLOC_MUTEX(SgNullptrValExp, lock);
  153919             : 
  153920             : #if USE_CPP_NEW_DELETE_OPERATORS
  153921             :     ROSE_FREE(Pointer);
  153922             : #else
  153923             : #if ROSE_PEDANTIC_ALLOC
  153924             :     ROSE_ASSERT(Size == sizeof(SgNullptrValExp));
  153925             : #else
  153926          12 :     if (Size != sizeof(SgNullptrValExp)) {
  153927           0 :       ROSE_FREE(Pointer);
  153928           0 :       ALLOC_MUTEX(SgNullptrValExp, unlock);
  153929             :       return;
  153930             :     }
  153931             : #endif
  153932             : 
  153933          12 :     SgNullptrValExp * object = (SgNullptrValExp*) Pointer;
  153934          12 :     ROSE_ASSERT(object != nullptr);
  153935             : 
  153936             : #if ROSE_ALLOC_TRACE == 2
  153937             : //  printf("SgNullptrValExp::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgNullptrValExp::next_node);
  153938             :     printf("SgNullptrValExp::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgNullptrValExp::next_node);
  153939             : #endif
  153940             : 
  153941             : #if ROSE_PEDANTIC_ALLOC
  153942             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  153943             : #endif
  153944             : 
  153945             : #if ROSE_ALLOC_MEMSET == 1
  153946             : #elif ROSE_ALLOC_MEMSET == 2
  153947             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgNullptrValExp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  153948             : #elif ROSE_ALLOC_MEMSET == 3
  153949             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgNullptrValExp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  153950             : #endif
  153951             : 
  153952             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  153953             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  153954             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  153955             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  153956             : #else
  153957          12 :     object->p_freepointer = SgNullptrValExp::next_node;
  153958          12 :     SgNullptrValExp::next_node = object;
  153959             : #endif
  153960             : 
  153961             : #if ROSE_ALLOC_TRACE == 2
  153962             : //  printf("SgNullptrValExp::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgNullptrValExp::next_node);
  153963             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  153964             :     Rose::MemPool::snapshot(oss.str());
  153965             :     alloc_trace_cnt++;
  153966             : #endif
  153967             : 
  153968             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  153969             : 
  153970          12 :     ALLOC_MUTEX(SgNullptrValExp, unlock);
  153971             : }
  153972             : 
  153973             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  153974             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  153975             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  153976             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  153977             : // Also, note comment below from Robb (copied from the Common.code file).
  153978             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  153979             : //
  153980             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  153981             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  153982             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  153983             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  153984             : #if 0
  153985             : void SgNullptrValExp::operator delete(void* pointer) { SgNullptrValExp::operator delete (pointer, sizeof(SgNullptrValExp)); };
  153986             : #endif
  153987             : /* #line 153988 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  153988             : 
  153989             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  153990             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  153991             : // obviously imply C++.
  153992             : 
  153993             : // This implements the support within ROSE for memory pools.  Memory pools
  153994             : // support the most condensed usage of memory within the construction of
  153995             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  153996             : // by a new operator written for each class.
  153997             : 
  153998             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  153999             :     // User wants multi-thread support and POSIX threads are available.
  154000             : #   include <pthread.h>
  154001             :     static pthread_mutex_t SgChar16Val_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  154002             : #else
  154003             :      // Cause synchronization to be skipped.
  154004             : #    ifndef ALLOC_MUTEX
  154005             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  154006             : #    endif
  154007             : #    ifdef _REENTRANT
  154008             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  154009             : #       ifdef _MSC_VER
  154010             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  154011             : #       else
  154012             : #           warning "POSIX threads are not available; synchronization being skipped"
  154013             : #       endif
  154014             : #    endif
  154015             : #endif
  154016             : 
  154017             : #ifndef ROSE_ALLOC_TRACE
  154018             : #  define ROSE_ALLOC_TRACE 0
  154019             : #endif
  154020             : 
  154021             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  154022             : #define ROSE_ALLOC_TRACE_CNT
  154023             : #include "memory-pool-snapshot.h"
  154024             : unsigned long alloc_trace_cnt = 0;
  154025             : #endif
  154026             : 
  154027             : #if ROSE_ALLOC_TRACE
  154028             : const unsigned SgChar16Val::pool_size = 5;
  154029             : #else
  154030             : const unsigned SgChar16Val::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  154031             : #endif
  154032             : 
  154033             : #ifndef ROSE_ALLOC_MEMSET
  154034             : #  define ROSE_ALLOC_MEMSET 0
  154035             : #endif
  154036             : 
  154037             : #ifndef ROSE_PEDANTIC_ALLOC
  154038             : #  define ROSE_PEDANTIC_ALLOC 0
  154039             : #endif
  154040             : 
  154041             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  154042             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  154043             : #endif
  154044             : 
  154045             : #if !defined(SGNODE__ALL_POOLS)
  154046             : #define SGNODE__ALL_POOLS
  154047             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  154048             : #endif
  154049             : 
  154050             : SgChar16Val* SgChar16Val::next_node = nullptr;
  154051             : std::vector<unsigned char*> SgChar16Val::pools;
  154052             : 
  154053             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  154054             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  154055             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  154056             : // around this macro definition rather than each use).
  154057             : #ifndef ALLOC_MUTEX
  154058             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  154059             :         do {                                                                     \
  154060             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  154061             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  154062             :                 abort();                                                         \
  154063             :             }                                                                    \
  154064             :         } while (0);
  154065             : #endif
  154066             : 
  154067             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  154068             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  154069             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  154070             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  154071             : 
  154072             : /*! \brief New operator for SgChar16Val.
  154073             : 
  154074             :    This new operator implements memory pools to provide most efficent 
  154075             :    use of the heap within construction of large ASTs.
  154076             : 
  154077             : \internal The new and delete operators use the lower level C malloc/free
  154078             :    function calls for performance and to make sure that mixing of malloc/free
  154079             :    and new/delete by the used can be caught more readily.  This may change
  154080             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  154081             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  154082             :    deallocate memory allocated using ROSE_MALLOC.
  154083             : */
  154084           0 : void *SgChar16Val::operator new ( size_t Size )
  154085             : {
  154086             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  154087             :      * returning or throwing an exception. */
  154088           0 :     ALLOC_MUTEX(SgChar16Val, lock);
  154089             : 
  154090             : #if ROSE_ALLOC_TRACE == 2
  154091             : //    printf("SgChar16Val::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgChar16Val::next_node);
  154092             : #endif
  154093             : 
  154094             : #if USE_CPP_NEW_DELETE_OPERATORS
  154095             :     void *mem = ROSE_MALLOC(Size);
  154096             :     ALLOC_MUTEX(SgChar16Val, unlock);
  154097             :     return mem;
  154098             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  154099             : #if ROSE_PEDANTIC_ALLOC
  154100             :     ROSE_ASSERT(Size == sizeof(SgChar16Val));
  154101             : #else
  154102           0 :     if (Size != sizeof(SgChar16Val)) {
  154103           0 :       void * object = ROSE_MALLOC(Size);
  154104           0 :       ALLOC_MUTEX(SgChar16Val, unlock);
  154105             :       return object;
  154106             :     }
  154107             : #endif
  154108             : 
  154109           0 :     if (SgChar16Val::next_node == nullptr) {
  154110           0 :         SgChar16Val * alloc = (SgChar16Val*) ROSE_MALLOC ( SgChar16Val::pool_size * sizeof(SgChar16Val) );
  154111           0 :         ROSE_ASSERT(alloc != nullptr);
  154112             : 
  154113             : #if ROSE_ALLOC_TRACE == 2
  154114             : //        printf("SgChar16Val::alloc\n  block[%zi] = [ %p , %p [\n", SgChar16Val::pools.size(), alloc, alloc + SgChar16Val::pool_size);
  154115             : #endif
  154116             : 
  154117             : #if ROSE_ALLOC_MEMSET == 1
  154118             : #elif ROSE_ALLOC_MEMSET == 2
  154119             :         memset(alloc, 0x00, SgChar16Val::pool_size * sizeof(SgChar16Val));
  154120             : #elif ROSE_ALLOC_MEMSET == 3
  154121             :         memset(alloc, 0xAA, SgChar16Val::pool_size * sizeof(SgChar16Val));
  154122             : #endif
  154123           0 :         for (unsigned i=0; i < SgChar16Val::pool_size-1; i++) {
  154124           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
  154125             :         }
  154126           0 :         alloc[SgChar16Val::pool_size-1].p_freepointer = nullptr;
  154127             : 
  154128           0 :         SgChar16Val::pools.push_back ( (unsigned char *) alloc );
  154129           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgChar16Val::pool_size * sizeof(SgChar16Val), V_SgChar16Val ) );
  154130           0 :         SgChar16Val::next_node = alloc;
  154131             :     }
  154132           0 :     ROSE_ASSERT(SgChar16Val::next_node != nullptr);
  154133             : 
  154134           0 :     SgChar16Val * object = SgChar16Val::next_node;
  154135           0 :     SgChar16Val::next_node = (SgChar16Val*)(object->p_freepointer);
  154136             : 
  154137             : #if ROSE_ALLOC_TRACE == 2
  154138             :     printf("SgChar16Val::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgChar16Val::next_node);
  154139             : #endif
  154140             : 
  154141           0 :     SgNode * fp = object->p_freepointer;
  154142             : #if ROSE_ALLOC_MEMSET == 1
  154143             : #elif ROSE_ALLOC_MEMSET == 2
  154144             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgChar16Val) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  154145             : #elif ROSE_ALLOC_MEMSET == 3
  154146             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgChar16Val) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  154147             : #endif
  154148           0 :     object->p_freepointer = fp;
  154149             : 
  154150             : #if ROSE_ALLOC_TRACE == 2
  154151             : //    printf("SgChar16Val::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgChar16Val::next_node);
  154152             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  154153             :     Rose::MemPool::snapshot(oss.str());
  154154             :     alloc_trace_cnt++;
  154155             : #endif
  154156             : 
  154157           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  154158             : 
  154159           0 :     ALLOC_MUTEX(SgChar16Val, unlock);
  154160             : 
  154161             :     return object;
  154162             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  154163             : }
  154164             : 
  154165             : 
  154166             : 
  154167             : /*! \brief Delete operator for SgChar16Val.
  154168             : 
  154169             :    This delete operator implements deallocation using memory pools to 
  154170             :    provide most efficent use of the heap within construction of large ASTs.
  154171             : 
  154172             : \internal The new and delete operators use the lower level C malloc/free
  154173             :    function calls for performance and to make sure that mixing of malloc/free
  154174             :    and new/delete by the used can be caught more readily.  This may change
  154175             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  154176             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  154177             :    deallocate memory allocated using ROSE_MALLOC.
  154178             : */
  154179           0 : void SgChar16Val::operator delete(void *Pointer, size_t Size)
  154180             : {
  154181             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  154182             :      * or throwing an exception. */
  154183           0 :     ALLOC_MUTEX(SgChar16Val, lock);
  154184             : 
  154185             : #if USE_CPP_NEW_DELETE_OPERATORS
  154186             :     ROSE_FREE(Pointer);
  154187             : #else
  154188             : #if ROSE_PEDANTIC_ALLOC
  154189             :     ROSE_ASSERT(Size == sizeof(SgChar16Val));
  154190             : #else
  154191           0 :     if (Size != sizeof(SgChar16Val)) {
  154192           0 :       ROSE_FREE(Pointer);
  154193           0 :       ALLOC_MUTEX(SgChar16Val, unlock);
  154194             :       return;
  154195             :     }
  154196             : #endif
  154197             : 
  154198           0 :     SgChar16Val * object = (SgChar16Val*) Pointer;
  154199           0 :     ROSE_ASSERT(object != nullptr);
  154200             : 
  154201             : #if ROSE_ALLOC_TRACE == 2
  154202             : //  printf("SgChar16Val::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgChar16Val::next_node);
  154203             :     printf("SgChar16Val::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgChar16Val::next_node);
  154204             : #endif
  154205             : 
  154206             : #if ROSE_PEDANTIC_ALLOC
  154207             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  154208             : #endif
  154209             : 
  154210             : #if ROSE_ALLOC_MEMSET == 1
  154211             : #elif ROSE_ALLOC_MEMSET == 2
  154212             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgChar16Val) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  154213             : #elif ROSE_ALLOC_MEMSET == 3
  154214             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgChar16Val) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  154215             : #endif
  154216             : 
  154217             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  154218             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  154219             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  154220             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  154221             : #else
  154222           0 :     object->p_freepointer = SgChar16Val::next_node;
  154223           0 :     SgChar16Val::next_node = object;
  154224             : #endif
  154225             : 
  154226             : #if ROSE_ALLOC_TRACE == 2
  154227             : //  printf("SgChar16Val::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgChar16Val::next_node);
  154228             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  154229             :     Rose::MemPool::snapshot(oss.str());
  154230             :     alloc_trace_cnt++;
  154231             : #endif
  154232             : 
  154233             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  154234             : 
  154235           0 :     ALLOC_MUTEX(SgChar16Val, unlock);
  154236             : }
  154237             : 
  154238             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  154239             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  154240             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  154241             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  154242             : // Also, note comment below from Robb (copied from the Common.code file).
  154243             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  154244             : //
  154245             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  154246             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  154247             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  154248             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  154249             : #if 0
  154250             : void SgChar16Val::operator delete(void* pointer) { SgChar16Val::operator delete (pointer, sizeof(SgChar16Val)); };
  154251             : #endif
  154252             : /* #line 154253 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  154253             : 
  154254             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  154255             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  154256             : // obviously imply C++.
  154257             : 
  154258             : // This implements the support within ROSE for memory pools.  Memory pools
  154259             : // support the most condensed usage of memory within the construction of
  154260             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  154261             : // by a new operator written for each class.
  154262             : 
  154263             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  154264             :     // User wants multi-thread support and POSIX threads are available.
  154265             : #   include <pthread.h>
  154266             :     static pthread_mutex_t SgChar32Val_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  154267             : #else
  154268             :      // Cause synchronization to be skipped.
  154269             : #    ifndef ALLOC_MUTEX
  154270             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  154271             : #    endif
  154272             : #    ifdef _REENTRANT
  154273             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  154274             : #       ifdef _MSC_VER
  154275             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  154276             : #       else
  154277             : #           warning "POSIX threads are not available; synchronization being skipped"
  154278             : #       endif
  154279             : #    endif
  154280             : #endif
  154281             : 
  154282             : #ifndef ROSE_ALLOC_TRACE
  154283             : #  define ROSE_ALLOC_TRACE 0
  154284             : #endif
  154285             : 
  154286             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  154287             : #define ROSE_ALLOC_TRACE_CNT
  154288             : #include "memory-pool-snapshot.h"
  154289             : unsigned long alloc_trace_cnt = 0;
  154290             : #endif
  154291             : 
  154292             : #if ROSE_ALLOC_TRACE
  154293             : const unsigned SgChar32Val::pool_size = 5;
  154294             : #else
  154295             : const unsigned SgChar32Val::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  154296             : #endif
  154297             : 
  154298             : #ifndef ROSE_ALLOC_MEMSET
  154299             : #  define ROSE_ALLOC_MEMSET 0
  154300             : #endif
  154301             : 
  154302             : #ifndef ROSE_PEDANTIC_ALLOC
  154303             : #  define ROSE_PEDANTIC_ALLOC 0
  154304             : #endif
  154305             : 
  154306             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  154307             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  154308             : #endif
  154309             : 
  154310             : #if !defined(SGNODE__ALL_POOLS)
  154311             : #define SGNODE__ALL_POOLS
  154312             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  154313             : #endif
  154314             : 
  154315             : SgChar32Val* SgChar32Val::next_node = nullptr;
  154316             : std::vector<unsigned char*> SgChar32Val::pools;
  154317             : 
  154318             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  154319             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  154320             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  154321             : // around this macro definition rather than each use).
  154322             : #ifndef ALLOC_MUTEX
  154323             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  154324             :         do {                                                                     \
  154325             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  154326             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  154327             :                 abort();                                                         \
  154328             :             }                                                                    \
  154329             :         } while (0);
  154330             : #endif
  154331             : 
  154332             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  154333             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  154334             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  154335             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  154336             : 
  154337             : /*! \brief New operator for SgChar32Val.
  154338             : 
  154339             :    This new operator implements memory pools to provide most efficent 
  154340             :    use of the heap within construction of large ASTs.
  154341             : 
  154342             : \internal The new and delete operators use the lower level C malloc/free
  154343             :    function calls for performance and to make sure that mixing of malloc/free
  154344             :    and new/delete by the used can be caught more readily.  This may change
  154345             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  154346             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  154347             :    deallocate memory allocated using ROSE_MALLOC.
  154348             : */
  154349           0 : void *SgChar32Val::operator new ( size_t Size )
  154350             : {
  154351             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  154352             :      * returning or throwing an exception. */
  154353           0 :     ALLOC_MUTEX(SgChar32Val, lock);
  154354             : 
  154355             : #if ROSE_ALLOC_TRACE == 2
  154356             : //    printf("SgChar32Val::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgChar32Val::next_node);
  154357             : #endif
  154358             : 
  154359             : #if USE_CPP_NEW_DELETE_OPERATORS
  154360             :     void *mem = ROSE_MALLOC(Size);
  154361             :     ALLOC_MUTEX(SgChar32Val, unlock);
  154362             :     return mem;
  154363             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  154364             : #if ROSE_PEDANTIC_ALLOC
  154365             :     ROSE_ASSERT(Size == sizeof(SgChar32Val));
  154366             : #else
  154367           0 :     if (Size != sizeof(SgChar32Val)) {
  154368           0 :       void * object = ROSE_MALLOC(Size);
  154369           0 :       ALLOC_MUTEX(SgChar32Val, unlock);
  154370             :       return object;
  154371             :     }
  154372             : #endif
  154373             : 
  154374           0 :     if (SgChar32Val::next_node == nullptr) {
  154375           0 :         SgChar32Val * alloc = (SgChar32Val*) ROSE_MALLOC ( SgChar32Val::pool_size * sizeof(SgChar32Val) );
  154376           0 :         ROSE_ASSERT(alloc != nullptr);
  154377             : 
  154378             : #if ROSE_ALLOC_TRACE == 2
  154379             : //        printf("SgChar32Val::alloc\n  block[%zi] = [ %p , %p [\n", SgChar32Val::pools.size(), alloc, alloc + SgChar32Val::pool_size);
  154380             : #endif
  154381             : 
  154382             : #if ROSE_ALLOC_MEMSET == 1
  154383             : #elif ROSE_ALLOC_MEMSET == 2
  154384             :         memset(alloc, 0x00, SgChar32Val::pool_size * sizeof(SgChar32Val));
  154385             : #elif ROSE_ALLOC_MEMSET == 3
  154386             :         memset(alloc, 0xAA, SgChar32Val::pool_size * sizeof(SgChar32Val));
  154387             : #endif
  154388           0 :         for (unsigned i=0; i < SgChar32Val::pool_size-1; i++) {
  154389           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
  154390             :         }
  154391           0 :         alloc[SgChar32Val::pool_size-1].p_freepointer = nullptr;
  154392             : 
  154393           0 :         SgChar32Val::pools.push_back ( (unsigned char *) alloc );
  154394           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgChar32Val::pool_size * sizeof(SgChar32Val), V_SgChar32Val ) );
  154395           0 :         SgChar32Val::next_node = alloc;
  154396             :     }
  154397           0 :     ROSE_ASSERT(SgChar32Val::next_node != nullptr);
  154398             : 
  154399           0 :     SgChar32Val * object = SgChar32Val::next_node;
  154400           0 :     SgChar32Val::next_node = (SgChar32Val*)(object->p_freepointer);
  154401             : 
  154402             : #if ROSE_ALLOC_TRACE == 2
  154403             :     printf("SgChar32Val::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgChar32Val::next_node);
  154404             : #endif
  154405             : 
  154406           0 :     SgNode * fp = object->p_freepointer;
  154407             : #if ROSE_ALLOC_MEMSET == 1
  154408             : #elif ROSE_ALLOC_MEMSET == 2
  154409             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgChar32Val) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  154410             : #elif ROSE_ALLOC_MEMSET == 3
  154411             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgChar32Val) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  154412             : #endif
  154413           0 :     object->p_freepointer = fp;
  154414             : 
  154415             : #if ROSE_ALLOC_TRACE == 2
  154416             : //    printf("SgChar32Val::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgChar32Val::next_node);
  154417             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  154418             :     Rose::MemPool::snapshot(oss.str());
  154419             :     alloc_trace_cnt++;
  154420             : #endif
  154421             : 
  154422           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  154423             : 
  154424           0 :     ALLOC_MUTEX(SgChar32Val, unlock);
  154425             : 
  154426             :     return object;
  154427             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  154428             : }
  154429             : 
  154430             : 
  154431             : 
  154432             : /*! \brief Delete operator for SgChar32Val.
  154433             : 
  154434             :    This delete operator implements deallocation using memory pools to 
  154435             :    provide most efficent use of the heap within construction of large ASTs.
  154436             : 
  154437             : \internal The new and delete operators use the lower level C malloc/free
  154438             :    function calls for performance and to make sure that mixing of malloc/free
  154439             :    and new/delete by the used can be caught more readily.  This may change
  154440             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  154441             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  154442             :    deallocate memory allocated using ROSE_MALLOC.
  154443             : */
  154444           0 : void SgChar32Val::operator delete(void *Pointer, size_t Size)
  154445             : {
  154446             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  154447             :      * or throwing an exception. */
  154448           0 :     ALLOC_MUTEX(SgChar32Val, lock);
  154449             : 
  154450             : #if USE_CPP_NEW_DELETE_OPERATORS
  154451             :     ROSE_FREE(Pointer);
  154452             : #else
  154453             : #if ROSE_PEDANTIC_ALLOC
  154454             :     ROSE_ASSERT(Size == sizeof(SgChar32Val));
  154455             : #else
  154456           0 :     if (Size != sizeof(SgChar32Val)) {
  154457           0 :       ROSE_FREE(Pointer);
  154458           0 :       ALLOC_MUTEX(SgChar32Val, unlock);
  154459             :       return;
  154460             :     }
  154461             : #endif
  154462             : 
  154463           0 :     SgChar32Val * object = (SgChar32Val*) Pointer;
  154464           0 :     ROSE_ASSERT(object != nullptr);
  154465             : 
  154466             : #if ROSE_ALLOC_TRACE == 2
  154467             : //  printf("SgChar32Val::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgChar32Val::next_node);
  154468             :     printf("SgChar32Val::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgChar32Val::next_node);
  154469             : #endif
  154470             : 
  154471             : #if ROSE_PEDANTIC_ALLOC
  154472             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  154473             : #endif
  154474             : 
  154475             : #if ROSE_ALLOC_MEMSET == 1
  154476             : #elif ROSE_ALLOC_MEMSET == 2
  154477             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgChar32Val) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  154478             : #elif ROSE_ALLOC_MEMSET == 3
  154479             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgChar32Val) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  154480             : #endif
  154481             : 
  154482             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  154483             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  154484             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  154485             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  154486             : #else
  154487           0 :     object->p_freepointer = SgChar32Val::next_node;
  154488           0 :     SgChar32Val::next_node = object;
  154489             : #endif
  154490             : 
  154491             : #if ROSE_ALLOC_TRACE == 2
  154492             : //  printf("SgChar32Val::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgChar32Val::next_node);
  154493             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  154494             :     Rose::MemPool::snapshot(oss.str());
  154495             :     alloc_trace_cnt++;
  154496             : #endif
  154497             : 
  154498             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  154499             : 
  154500           0 :     ALLOC_MUTEX(SgChar32Val, unlock);
  154501             : }
  154502             : 
  154503             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  154504             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  154505             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  154506             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  154507             : // Also, note comment below from Robb (copied from the Common.code file).
  154508             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  154509             : //
  154510             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  154511             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  154512             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  154513             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  154514             : #if 0
  154515             : void SgChar32Val::operator delete(void* pointer) { SgChar32Val::operator delete (pointer, sizeof(SgChar32Val)); };
  154516             : #endif
  154517             : /* #line 154518 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  154518             : 
  154519             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  154520             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  154521             : // obviously imply C++.
  154522             : 
  154523             : // This implements the support within ROSE for memory pools.  Memory pools
  154524             : // support the most condensed usage of memory within the construction of
  154525             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  154526             : // by a new operator written for each class.
  154527             : 
  154528             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  154529             :     // User wants multi-thread support and POSIX threads are available.
  154530             : #   include <pthread.h>
  154531             :     static pthread_mutex_t SgFloat80Val_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  154532             : #else
  154533             :      // Cause synchronization to be skipped.
  154534             : #    ifndef ALLOC_MUTEX
  154535             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  154536             : #    endif
  154537             : #    ifdef _REENTRANT
  154538             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  154539             : #       ifdef _MSC_VER
  154540             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  154541             : #       else
  154542             : #           warning "POSIX threads are not available; synchronization being skipped"
  154543             : #       endif
  154544             : #    endif
  154545             : #endif
  154546             : 
  154547             : #ifndef ROSE_ALLOC_TRACE
  154548             : #  define ROSE_ALLOC_TRACE 0
  154549             : #endif
  154550             : 
  154551             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  154552             : #define ROSE_ALLOC_TRACE_CNT
  154553             : #include "memory-pool-snapshot.h"
  154554             : unsigned long alloc_trace_cnt = 0;
  154555             : #endif
  154556             : 
  154557             : #if ROSE_ALLOC_TRACE
  154558             : const unsigned SgFloat80Val::pool_size = 5;
  154559             : #else
  154560             : const unsigned SgFloat80Val::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  154561             : #endif
  154562             : 
  154563             : #ifndef ROSE_ALLOC_MEMSET
  154564             : #  define ROSE_ALLOC_MEMSET 0
  154565             : #endif
  154566             : 
  154567             : #ifndef ROSE_PEDANTIC_ALLOC
  154568             : #  define ROSE_PEDANTIC_ALLOC 0
  154569             : #endif
  154570             : 
  154571             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  154572             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  154573             : #endif
  154574             : 
  154575             : #if !defined(SGNODE__ALL_POOLS)
  154576             : #define SGNODE__ALL_POOLS
  154577             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  154578             : #endif
  154579             : 
  154580             : SgFloat80Val* SgFloat80Val::next_node = nullptr;
  154581             : std::vector<unsigned char*> SgFloat80Val::pools;
  154582             : 
  154583             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  154584             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  154585             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  154586             : // around this macro definition rather than each use).
  154587             : #ifndef ALLOC_MUTEX
  154588             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  154589             :         do {                                                                     \
  154590             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  154591             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  154592             :                 abort();                                                         \
  154593             :             }                                                                    \
  154594             :         } while (0);
  154595             : #endif
  154596             : 
  154597             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  154598             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  154599             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  154600             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  154601             : 
  154602             : /*! \brief New operator for SgFloat80Val.
  154603             : 
  154604             :    This new operator implements memory pools to provide most efficent 
  154605             :    use of the heap within construction of large ASTs.
  154606             : 
  154607             : \internal The new and delete operators use the lower level C malloc/free
  154608             :    function calls for performance and to make sure that mixing of malloc/free
  154609             :    and new/delete by the used can be caught more readily.  This may change
  154610             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  154611             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  154612             :    deallocate memory allocated using ROSE_MALLOC.
  154613             : */
  154614           0 : void *SgFloat80Val::operator new ( size_t Size )
  154615             : {
  154616             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  154617             :      * returning or throwing an exception. */
  154618           0 :     ALLOC_MUTEX(SgFloat80Val, lock);
  154619             : 
  154620             : #if ROSE_ALLOC_TRACE == 2
  154621             : //    printf("SgFloat80Val::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgFloat80Val::next_node);
  154622             : #endif
  154623             : 
  154624             : #if USE_CPP_NEW_DELETE_OPERATORS
  154625             :     void *mem = ROSE_MALLOC(Size);
  154626             :     ALLOC_MUTEX(SgFloat80Val, unlock);
  154627             :     return mem;
  154628             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  154629             : #if ROSE_PEDANTIC_ALLOC
  154630             :     ROSE_ASSERT(Size == sizeof(SgFloat80Val));
  154631             : #else
  154632           0 :     if (Size != sizeof(SgFloat80Val)) {
  154633           0 :       void * object = ROSE_MALLOC(Size);
  154634           0 :       ALLOC_MUTEX(SgFloat80Val, unlock);
  154635             :       return object;
  154636             :     }
  154637             : #endif
  154638             : 
  154639           0 :     if (SgFloat80Val::next_node == nullptr) {
  154640           0 :         SgFloat80Val * alloc = (SgFloat80Val*) ROSE_MALLOC ( SgFloat80Val::pool_size * sizeof(SgFloat80Val) );
  154641           0 :         ROSE_ASSERT(alloc != nullptr);
  154642             : 
  154643             : #if ROSE_ALLOC_TRACE == 2
  154644             : //        printf("SgFloat80Val::alloc\n  block[%zi] = [ %p , %p [\n", SgFloat80Val::pools.size(), alloc, alloc + SgFloat80Val::pool_size);
  154645             : #endif
  154646             : 
  154647             : #if ROSE_ALLOC_MEMSET == 1
  154648             : #elif ROSE_ALLOC_MEMSET == 2
  154649             :         memset(alloc, 0x00, SgFloat80Val::pool_size * sizeof(SgFloat80Val));
  154650             : #elif ROSE_ALLOC_MEMSET == 3
  154651             :         memset(alloc, 0xAA, SgFloat80Val::pool_size * sizeof(SgFloat80Val));
  154652             : #endif
  154653           0 :         for (unsigned i=0; i < SgFloat80Val::pool_size-1; i++) {
  154654           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
  154655             :         }
  154656           0 :         alloc[SgFloat80Val::pool_size-1].p_freepointer = nullptr;
  154657             : 
  154658           0 :         SgFloat80Val::pools.push_back ( (unsigned char *) alloc );
  154659           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgFloat80Val::pool_size * sizeof(SgFloat80Val), V_SgFloat80Val ) );
  154660           0 :         SgFloat80Val::next_node = alloc;
  154661             :     }
  154662           0 :     ROSE_ASSERT(SgFloat80Val::next_node != nullptr);
  154663             : 
  154664           0 :     SgFloat80Val * object = SgFloat80Val::next_node;
  154665           0 :     SgFloat80Val::next_node = (SgFloat80Val*)(object->p_freepointer);
  154666             : 
  154667             : #if ROSE_ALLOC_TRACE == 2
  154668             :     printf("SgFloat80Val::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgFloat80Val::next_node);
  154669             : #endif
  154670             : 
  154671           0 :     SgNode * fp = object->p_freepointer;
  154672             : #if ROSE_ALLOC_MEMSET == 1
  154673             : #elif ROSE_ALLOC_MEMSET == 2
  154674             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgFloat80Val) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  154675             : #elif ROSE_ALLOC_MEMSET == 3
  154676             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgFloat80Val) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  154677             : #endif
  154678           0 :     object->p_freepointer = fp;
  154679             : 
  154680             : #if ROSE_ALLOC_TRACE == 2
  154681             : //    printf("SgFloat80Val::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgFloat80Val::next_node);
  154682             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  154683             :     Rose::MemPool::snapshot(oss.str());
  154684             :     alloc_trace_cnt++;
  154685             : #endif
  154686             : 
  154687           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  154688             : 
  154689           0 :     ALLOC_MUTEX(SgFloat80Val, unlock);
  154690             : 
  154691             :     return object;
  154692             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  154693             : }
  154694             : 
  154695             : 
  154696             : 
  154697             : /*! \brief Delete operator for SgFloat80Val.
  154698             : 
  154699             :    This delete operator implements deallocation using memory pools to 
  154700             :    provide most efficent use of the heap within construction of large ASTs.
  154701             : 
  154702             : \internal The new and delete operators use the lower level C malloc/free
  154703             :    function calls for performance and to make sure that mixing of malloc/free
  154704             :    and new/delete by the used can be caught more readily.  This may change
  154705             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  154706             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  154707             :    deallocate memory allocated using ROSE_MALLOC.
  154708             : */
  154709           0 : void SgFloat80Val::operator delete(void *Pointer, size_t Size)
  154710             : {
  154711             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  154712             :      * or throwing an exception. */
  154713           0 :     ALLOC_MUTEX(SgFloat80Val, lock);
  154714             : 
  154715             : #if USE_CPP_NEW_DELETE_OPERATORS
  154716             :     ROSE_FREE(Pointer);
  154717             : #else
  154718             : #if ROSE_PEDANTIC_ALLOC
  154719             :     ROSE_ASSERT(Size == sizeof(SgFloat80Val));
  154720             : #else
  154721           0 :     if (Size != sizeof(SgFloat80Val)) {
  154722           0 :       ROSE_FREE(Pointer);
  154723           0 :       ALLOC_MUTEX(SgFloat80Val, unlock);
  154724             :       return;
  154725             :     }
  154726             : #endif
  154727             : 
  154728           0 :     SgFloat80Val * object = (SgFloat80Val*) Pointer;
  154729           0 :     ROSE_ASSERT(object != nullptr);
  154730             : 
  154731             : #if ROSE_ALLOC_TRACE == 2
  154732             : //  printf("SgFloat80Val::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgFloat80Val::next_node);
  154733             :     printf("SgFloat80Val::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgFloat80Val::next_node);
  154734             : #endif
  154735             : 
  154736             : #if ROSE_PEDANTIC_ALLOC
  154737             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  154738             : #endif
  154739             : 
  154740             : #if ROSE_ALLOC_MEMSET == 1
  154741             : #elif ROSE_ALLOC_MEMSET == 2
  154742             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgFloat80Val) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  154743             : #elif ROSE_ALLOC_MEMSET == 3
  154744             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgFloat80Val) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  154745             : #endif
  154746             : 
  154747             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  154748             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  154749             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  154750             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  154751             : #else
  154752           0 :     object->p_freepointer = SgFloat80Val::next_node;
  154753           0 :     SgFloat80Val::next_node = object;
  154754             : #endif
  154755             : 
  154756             : #if ROSE_ALLOC_TRACE == 2
  154757             : //  printf("SgFloat80Val::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgFloat80Val::next_node);
  154758             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  154759             :     Rose::MemPool::snapshot(oss.str());
  154760             :     alloc_trace_cnt++;
  154761             : #endif
  154762             : 
  154763             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  154764             : 
  154765           0 :     ALLOC_MUTEX(SgFloat80Val, unlock);
  154766             : }
  154767             : 
  154768             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  154769             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  154770             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  154771             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  154772             : // Also, note comment below from Robb (copied from the Common.code file).
  154773             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  154774             : //
  154775             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  154776             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  154777             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  154778             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  154779             : #if 0
  154780             : void SgFloat80Val::operator delete(void* pointer) { SgFloat80Val::operator delete (pointer, sizeof(SgFloat80Val)); };
  154781             : #endif
  154782             : /* #line 154783 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  154783             : 
  154784             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  154785             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  154786             : // obviously imply C++.
  154787             : 
  154788             : // This implements the support within ROSE for memory pools.  Memory pools
  154789             : // support the most condensed usage of memory within the construction of
  154790             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  154791             : // by a new operator written for each class.
  154792             : 
  154793             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  154794             :     // User wants multi-thread support and POSIX threads are available.
  154795             : #   include <pthread.h>
  154796             :     static pthread_mutex_t SgFloat128Val_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  154797             : #else
  154798             :      // Cause synchronization to be skipped.
  154799             : #    ifndef ALLOC_MUTEX
  154800             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  154801             : #    endif
  154802             : #    ifdef _REENTRANT
  154803             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  154804             : #       ifdef _MSC_VER
  154805             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  154806             : #       else
  154807             : #           warning "POSIX threads are not available; synchronization being skipped"
  154808             : #       endif
  154809             : #    endif
  154810             : #endif
  154811             : 
  154812             : #ifndef ROSE_ALLOC_TRACE
  154813             : #  define ROSE_ALLOC_TRACE 0
  154814             : #endif
  154815             : 
  154816             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  154817             : #define ROSE_ALLOC_TRACE_CNT
  154818             : #include "memory-pool-snapshot.h"
  154819             : unsigned long alloc_trace_cnt = 0;
  154820             : #endif
  154821             : 
  154822             : #if ROSE_ALLOC_TRACE
  154823             : const unsigned SgFloat128Val::pool_size = 5;
  154824             : #else
  154825             : const unsigned SgFloat128Val::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  154826             : #endif
  154827             : 
  154828             : #ifndef ROSE_ALLOC_MEMSET
  154829             : #  define ROSE_ALLOC_MEMSET 0
  154830             : #endif
  154831             : 
  154832             : #ifndef ROSE_PEDANTIC_ALLOC
  154833             : #  define ROSE_PEDANTIC_ALLOC 0
  154834             : #endif
  154835             : 
  154836             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  154837             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  154838             : #endif
  154839             : 
  154840             : #if !defined(SGNODE__ALL_POOLS)
  154841             : #define SGNODE__ALL_POOLS
  154842             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  154843             : #endif
  154844             : 
  154845             : SgFloat128Val* SgFloat128Val::next_node = nullptr;
  154846             : std::vector<unsigned char*> SgFloat128Val::pools;
  154847             : 
  154848             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  154849             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  154850             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  154851             : // around this macro definition rather than each use).
  154852             : #ifndef ALLOC_MUTEX
  154853             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  154854             :         do {                                                                     \
  154855             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  154856             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  154857             :                 abort();                                                         \
  154858             :             }                                                                    \
  154859             :         } while (0);
  154860             : #endif
  154861             : 
  154862             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  154863             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  154864             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  154865             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  154866             : 
  154867             : /*! \brief New operator for SgFloat128Val.
  154868             : 
  154869             :    This new operator implements memory pools to provide most efficent 
  154870             :    use of the heap within construction of large ASTs.
  154871             : 
  154872             : \internal The new and delete operators use the lower level C malloc/free
  154873             :    function calls for performance and to make sure that mixing of malloc/free
  154874             :    and new/delete by the used can be caught more readily.  This may change
  154875             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  154876             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  154877             :    deallocate memory allocated using ROSE_MALLOC.
  154878             : */
  154879           0 : void *SgFloat128Val::operator new ( size_t Size )
  154880             : {
  154881             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  154882             :      * returning or throwing an exception. */
  154883           0 :     ALLOC_MUTEX(SgFloat128Val, lock);
  154884             : 
  154885             : #if ROSE_ALLOC_TRACE == 2
  154886             : //    printf("SgFloat128Val::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgFloat128Val::next_node);
  154887             : #endif
  154888             : 
  154889             : #if USE_CPP_NEW_DELETE_OPERATORS
  154890             :     void *mem = ROSE_MALLOC(Size);
  154891             :     ALLOC_MUTEX(SgFloat128Val, unlock);
  154892             :     return mem;
  154893             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  154894             : #if ROSE_PEDANTIC_ALLOC
  154895             :     ROSE_ASSERT(Size == sizeof(SgFloat128Val));
  154896             : #else
  154897           0 :     if (Size != sizeof(SgFloat128Val)) {
  154898           0 :       void * object = ROSE_MALLOC(Size);
  154899           0 :       ALLOC_MUTEX(SgFloat128Val, unlock);
  154900             :       return object;
  154901             :     }
  154902             : #endif
  154903             : 
  154904           0 :     if (SgFloat128Val::next_node == nullptr) {
  154905           0 :         SgFloat128Val * alloc = (SgFloat128Val*) ROSE_MALLOC ( SgFloat128Val::pool_size * sizeof(SgFloat128Val) );
  154906           0 :         ROSE_ASSERT(alloc != nullptr);
  154907             : 
  154908             : #if ROSE_ALLOC_TRACE == 2
  154909             : //        printf("SgFloat128Val::alloc\n  block[%zi] = [ %p , %p [\n", SgFloat128Val::pools.size(), alloc, alloc + SgFloat128Val::pool_size);
  154910             : #endif
  154911             : 
  154912             : #if ROSE_ALLOC_MEMSET == 1
  154913             : #elif ROSE_ALLOC_MEMSET == 2
  154914             :         memset(alloc, 0x00, SgFloat128Val::pool_size * sizeof(SgFloat128Val));
  154915             : #elif ROSE_ALLOC_MEMSET == 3
  154916             :         memset(alloc, 0xAA, SgFloat128Val::pool_size * sizeof(SgFloat128Val));
  154917             : #endif
  154918           0 :         for (unsigned i=0; i < SgFloat128Val::pool_size-1; i++) {
  154919           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
  154920             :         }
  154921           0 :         alloc[SgFloat128Val::pool_size-1].p_freepointer = nullptr;
  154922             : 
  154923           0 :         SgFloat128Val::pools.push_back ( (unsigned char *) alloc );
  154924           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgFloat128Val::pool_size * sizeof(SgFloat128Val), V_SgFloat128Val ) );
  154925           0 :         SgFloat128Val::next_node = alloc;
  154926             :     }
  154927           0 :     ROSE_ASSERT(SgFloat128Val::next_node != nullptr);
  154928             : 
  154929           0 :     SgFloat128Val * object = SgFloat128Val::next_node;
  154930           0 :     SgFloat128Val::next_node = (SgFloat128Val*)(object->p_freepointer);
  154931             : 
  154932             : #if ROSE_ALLOC_TRACE == 2
  154933             :     printf("SgFloat128Val::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgFloat128Val::next_node);
  154934             : #endif
  154935             : 
  154936           0 :     SgNode * fp = object->p_freepointer;
  154937             : #if ROSE_ALLOC_MEMSET == 1
  154938             : #elif ROSE_ALLOC_MEMSET == 2
  154939             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgFloat128Val) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  154940             : #elif ROSE_ALLOC_MEMSET == 3
  154941             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgFloat128Val) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  154942             : #endif
  154943           0 :     object->p_freepointer = fp;
  154944             : 
  154945             : #if ROSE_ALLOC_TRACE == 2
  154946             : //    printf("SgFloat128Val::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgFloat128Val::next_node);
  154947             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  154948             :     Rose::MemPool::snapshot(oss.str());
  154949             :     alloc_trace_cnt++;
  154950             : #endif
  154951             : 
  154952           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  154953             : 
  154954           0 :     ALLOC_MUTEX(SgFloat128Val, unlock);
  154955             : 
  154956             :     return object;
  154957             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  154958             : }
  154959             : 
  154960             : 
  154961             : 
  154962             : /*! \brief Delete operator for SgFloat128Val.
  154963             : 
  154964             :    This delete operator implements deallocation using memory pools to 
  154965             :    provide most efficent use of the heap within construction of large ASTs.
  154966             : 
  154967             : \internal The new and delete operators use the lower level C malloc/free
  154968             :    function calls for performance and to make sure that mixing of malloc/free
  154969             :    and new/delete by the used can be caught more readily.  This may change
  154970             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  154971             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  154972             :    deallocate memory allocated using ROSE_MALLOC.
  154973             : */
  154974           0 : void SgFloat128Val::operator delete(void *Pointer, size_t Size)
  154975             : {
  154976             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  154977             :      * or throwing an exception. */
  154978           0 :     ALLOC_MUTEX(SgFloat128Val, lock);
  154979             : 
  154980             : #if USE_CPP_NEW_DELETE_OPERATORS
  154981             :     ROSE_FREE(Pointer);
  154982             : #else
  154983             : #if ROSE_PEDANTIC_ALLOC
  154984             :     ROSE_ASSERT(Size == sizeof(SgFloat128Val));
  154985             : #else
  154986           0 :     if (Size != sizeof(SgFloat128Val)) {
  154987           0 :       ROSE_FREE(Pointer);
  154988           0 :       ALLOC_MUTEX(SgFloat128Val, unlock);
  154989             :       return;
  154990             :     }
  154991             : #endif
  154992             : 
  154993           0 :     SgFloat128Val * object = (SgFloat128Val*) Pointer;
  154994           0 :     ROSE_ASSERT(object != nullptr);
  154995             : 
  154996             : #if ROSE_ALLOC_TRACE == 2
  154997             : //  printf("SgFloat128Val::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgFloat128Val::next_node);
  154998             :     printf("SgFloat128Val::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgFloat128Val::next_node);
  154999             : #endif
  155000             : 
  155001             : #if ROSE_PEDANTIC_ALLOC
  155002             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  155003             : #endif
  155004             : 
  155005             : #if ROSE_ALLOC_MEMSET == 1
  155006             : #elif ROSE_ALLOC_MEMSET == 2
  155007             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgFloat128Val) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  155008             : #elif ROSE_ALLOC_MEMSET == 3
  155009             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgFloat128Val) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  155010             : #endif
  155011             : 
  155012             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  155013             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  155014             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  155015             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  155016             : #else
  155017           0 :     object->p_freepointer = SgFloat128Val::next_node;
  155018           0 :     SgFloat128Val::next_node = object;
  155019             : #endif
  155020             : 
  155021             : #if ROSE_ALLOC_TRACE == 2
  155022             : //  printf("SgFloat128Val::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgFloat128Val::next_node);
  155023             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  155024             :     Rose::MemPool::snapshot(oss.str());
  155025             :     alloc_trace_cnt++;
  155026             : #endif
  155027             : 
  155028             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  155029             : 
  155030           0 :     ALLOC_MUTEX(SgFloat128Val, unlock);
  155031             : }
  155032             : 
  155033             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  155034             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  155035             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  155036             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  155037             : // Also, note comment below from Robb (copied from the Common.code file).
  155038             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  155039             : //
  155040             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  155041             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  155042             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  155043             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  155044             : #if 0
  155045             : void SgFloat128Val::operator delete(void* pointer) { SgFloat128Val::operator delete (pointer, sizeof(SgFloat128Val)); };
  155046             : #endif
  155047             : /* #line 155048 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  155048             : 
  155049             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  155050             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  155051             : // obviously imply C++.
  155052             : 
  155053             : // This implements the support within ROSE for memory pools.  Memory pools
  155054             : // support the most condensed usage of memory within the construction of
  155055             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  155056             : // by a new operator written for each class.
  155057             : 
  155058             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  155059             :     // User wants multi-thread support and POSIX threads are available.
  155060             : #   include <pthread.h>
  155061             :     static pthread_mutex_t SgVoidVal_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  155062             : #else
  155063             :      // Cause synchronization to be skipped.
  155064             : #    ifndef ALLOC_MUTEX
  155065             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  155066             : #    endif
  155067             : #    ifdef _REENTRANT
  155068             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  155069             : #       ifdef _MSC_VER
  155070             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  155071             : #       else
  155072             : #           warning "POSIX threads are not available; synchronization being skipped"
  155073             : #       endif
  155074             : #    endif
  155075             : #endif
  155076             : 
  155077             : #ifndef ROSE_ALLOC_TRACE
  155078             : #  define ROSE_ALLOC_TRACE 0
  155079             : #endif
  155080             : 
  155081             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  155082             : #define ROSE_ALLOC_TRACE_CNT
  155083             : #include "memory-pool-snapshot.h"
  155084             : unsigned long alloc_trace_cnt = 0;
  155085             : #endif
  155086             : 
  155087             : #if ROSE_ALLOC_TRACE
  155088             : const unsigned SgVoidVal::pool_size = 5;
  155089             : #else
  155090             : const unsigned SgVoidVal::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  155091             : #endif
  155092             : 
  155093             : #ifndef ROSE_ALLOC_MEMSET
  155094             : #  define ROSE_ALLOC_MEMSET 0
  155095             : #endif
  155096             : 
  155097             : #ifndef ROSE_PEDANTIC_ALLOC
  155098             : #  define ROSE_PEDANTIC_ALLOC 0
  155099             : #endif
  155100             : 
  155101             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  155102             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  155103             : #endif
  155104             : 
  155105             : #if !defined(SGNODE__ALL_POOLS)
  155106             : #define SGNODE__ALL_POOLS
  155107             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  155108             : #endif
  155109             : 
  155110             : SgVoidVal* SgVoidVal::next_node = nullptr;
  155111             : std::vector<unsigned char*> SgVoidVal::pools;
  155112             : 
  155113             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  155114             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  155115             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  155116             : // around this macro definition rather than each use).
  155117             : #ifndef ALLOC_MUTEX
  155118             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  155119             :         do {                                                                     \
  155120             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  155121             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  155122             :                 abort();                                                         \
  155123             :             }                                                                    \
  155124             :         } while (0);
  155125             : #endif
  155126             : 
  155127             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  155128             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  155129             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  155130             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  155131             : 
  155132             : /*! \brief New operator for SgVoidVal.
  155133             : 
  155134             :    This new operator implements memory pools to provide most efficent 
  155135             :    use of the heap within construction of large ASTs.
  155136             : 
  155137             : \internal The new and delete operators use the lower level C malloc/free
  155138             :    function calls for performance and to make sure that mixing of malloc/free
  155139             :    and new/delete by the used can be caught more readily.  This may change
  155140             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  155141             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  155142             :    deallocate memory allocated using ROSE_MALLOC.
  155143             : */
  155144           0 : void *SgVoidVal::operator new ( size_t Size )
  155145             : {
  155146             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  155147             :      * returning or throwing an exception. */
  155148           0 :     ALLOC_MUTEX(SgVoidVal, lock);
  155149             : 
  155150             : #if ROSE_ALLOC_TRACE == 2
  155151             : //    printf("SgVoidVal::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgVoidVal::next_node);
  155152             : #endif
  155153             : 
  155154             : #if USE_CPP_NEW_DELETE_OPERATORS
  155155             :     void *mem = ROSE_MALLOC(Size);
  155156             :     ALLOC_MUTEX(SgVoidVal, unlock);
  155157             :     return mem;
  155158             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  155159             : #if ROSE_PEDANTIC_ALLOC
  155160             :     ROSE_ASSERT(Size == sizeof(SgVoidVal));
  155161             : #else
  155162           0 :     if (Size != sizeof(SgVoidVal)) {
  155163           0 :       void * object = ROSE_MALLOC(Size);
  155164           0 :       ALLOC_MUTEX(SgVoidVal, unlock);
  155165             :       return object;
  155166             :     }
  155167             : #endif
  155168             : 
  155169           0 :     if (SgVoidVal::next_node == nullptr) {
  155170           0 :         SgVoidVal * alloc = (SgVoidVal*) ROSE_MALLOC ( SgVoidVal::pool_size * sizeof(SgVoidVal) );
  155171           0 :         ROSE_ASSERT(alloc != nullptr);
  155172             : 
  155173             : #if ROSE_ALLOC_TRACE == 2
  155174             : //        printf("SgVoidVal::alloc\n  block[%zi] = [ %p , %p [\n", SgVoidVal::pools.size(), alloc, alloc + SgVoidVal::pool_size);
  155175             : #endif
  155176             : 
  155177             : #if ROSE_ALLOC_MEMSET == 1
  155178             : #elif ROSE_ALLOC_MEMSET == 2
  155179             :         memset(alloc, 0x00, SgVoidVal::pool_size * sizeof(SgVoidVal));
  155180             : #elif ROSE_ALLOC_MEMSET == 3
  155181             :         memset(alloc, 0xAA, SgVoidVal::pool_size * sizeof(SgVoidVal));
  155182             : #endif
  155183           0 :         for (unsigned i=0; i < SgVoidVal::pool_size-1; i++) {
  155184           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
  155185             :         }
  155186           0 :         alloc[SgVoidVal::pool_size-1].p_freepointer = nullptr;
  155187             : 
  155188           0 :         SgVoidVal::pools.push_back ( (unsigned char *) alloc );
  155189           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgVoidVal::pool_size * sizeof(SgVoidVal), V_SgVoidVal ) );
  155190           0 :         SgVoidVal::next_node = alloc;
  155191             :     }
  155192           0 :     ROSE_ASSERT(SgVoidVal::next_node != nullptr);
  155193             : 
  155194           0 :     SgVoidVal * object = SgVoidVal::next_node;
  155195           0 :     SgVoidVal::next_node = (SgVoidVal*)(object->p_freepointer);
  155196             : 
  155197             : #if ROSE_ALLOC_TRACE == 2
  155198             :     printf("SgVoidVal::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgVoidVal::next_node);
  155199             : #endif
  155200             : 
  155201           0 :     SgNode * fp = object->p_freepointer;
  155202             : #if ROSE_ALLOC_MEMSET == 1
  155203             : #elif ROSE_ALLOC_MEMSET == 2
  155204             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgVoidVal) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  155205             : #elif ROSE_ALLOC_MEMSET == 3
  155206             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgVoidVal) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  155207             : #endif
  155208           0 :     object->p_freepointer = fp;
  155209             : 
  155210             : #if ROSE_ALLOC_TRACE == 2
  155211             : //    printf("SgVoidVal::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgVoidVal::next_node);
  155212             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  155213             :     Rose::MemPool::snapshot(oss.str());
  155214             :     alloc_trace_cnt++;
  155215             : #endif
  155216             : 
  155217           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  155218             : 
  155219           0 :     ALLOC_MUTEX(SgVoidVal, unlock);
  155220             : 
  155221             :     return object;
  155222             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  155223             : }
  155224             : 
  155225             : 
  155226             : 
  155227             : /*! \brief Delete operator for SgVoidVal.
  155228             : 
  155229             :    This delete operator implements deallocation using memory pools to 
  155230             :    provide most efficent use of the heap within construction of large ASTs.
  155231             : 
  155232             : \internal The new and delete operators use the lower level C malloc/free
  155233             :    function calls for performance and to make sure that mixing of malloc/free
  155234             :    and new/delete by the used can be caught more readily.  This may change
  155235             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  155236             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  155237             :    deallocate memory allocated using ROSE_MALLOC.
  155238             : */
  155239           0 : void SgVoidVal::operator delete(void *Pointer, size_t Size)
  155240             : {
  155241             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  155242             :      * or throwing an exception. */
  155243           0 :     ALLOC_MUTEX(SgVoidVal, lock);
  155244             : 
  155245             : #if USE_CPP_NEW_DELETE_OPERATORS
  155246             :     ROSE_FREE(Pointer);
  155247             : #else
  155248             : #if ROSE_PEDANTIC_ALLOC
  155249             :     ROSE_ASSERT(Size == sizeof(SgVoidVal));
  155250             : #else
  155251           0 :     if (Size != sizeof(SgVoidVal)) {
  155252           0 :       ROSE_FREE(Pointer);
  155253           0 :       ALLOC_MUTEX(SgVoidVal, unlock);
  155254             :       return;
  155255             :     }
  155256             : #endif
  155257             : 
  155258           0 :     SgVoidVal * object = (SgVoidVal*) Pointer;
  155259           0 :     ROSE_ASSERT(object != nullptr);
  155260             : 
  155261             : #if ROSE_ALLOC_TRACE == 2
  155262             : //  printf("SgVoidVal::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgVoidVal::next_node);
  155263             :     printf("SgVoidVal::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgVoidVal::next_node);
  155264             : #endif
  155265             : 
  155266             : #if ROSE_PEDANTIC_ALLOC
  155267             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  155268             : #endif
  155269             : 
  155270             : #if ROSE_ALLOC_MEMSET == 1
  155271             : #elif ROSE_ALLOC_MEMSET == 2
  155272             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgVoidVal) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  155273             : #elif ROSE_ALLOC_MEMSET == 3
  155274             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgVoidVal) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  155275             : #endif
  155276             : 
  155277             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  155278             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  155279             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  155280             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  155281             : #else
  155282           0 :     object->p_freepointer = SgVoidVal::next_node;
  155283           0 :     SgVoidVal::next_node = object;
  155284             : #endif
  155285             : 
  155286             : #if ROSE_ALLOC_TRACE == 2
  155287             : //  printf("SgVoidVal::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgVoidVal::next_node);
  155288             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  155289             :     Rose::MemPool::snapshot(oss.str());
  155290             :     alloc_trace_cnt++;
  155291             : #endif
  155292             : 
  155293             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  155294             : 
  155295           0 :     ALLOC_MUTEX(SgVoidVal, unlock);
  155296             : }
  155297             : 
  155298             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  155299             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  155300             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  155301             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  155302             : // Also, note comment below from Robb (copied from the Common.code file).
  155303             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  155304             : //
  155305             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  155306             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  155307             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  155308             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  155309             : #if 0
  155310             : void SgVoidVal::operator delete(void* pointer) { SgVoidVal::operator delete (pointer, sizeof(SgVoidVal)); };
  155311             : #endif
  155312             : /* #line 155313 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  155313             : 
  155314             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  155315             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  155316             : // obviously imply C++.
  155317             : 
  155318             : // This implements the support within ROSE for memory pools.  Memory pools
  155319             : // support the most condensed usage of memory within the construction of
  155320             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  155321             : // by a new operator written for each class.
  155322             : 
  155323             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  155324             :     // User wants multi-thread support and POSIX threads are available.
  155325             : #   include <pthread.h>
  155326             :     static pthread_mutex_t SgCallExpression_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  155327             : #else
  155328             :      // Cause synchronization to be skipped.
  155329             : #    ifndef ALLOC_MUTEX
  155330             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  155331             : #    endif
  155332             : #    ifdef _REENTRANT
  155333             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  155334             : #       ifdef _MSC_VER
  155335             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  155336             : #       else
  155337             : #           warning "POSIX threads are not available; synchronization being skipped"
  155338             : #       endif
  155339             : #    endif
  155340             : #endif
  155341             : 
  155342             : #ifndef ROSE_ALLOC_TRACE
  155343             : #  define ROSE_ALLOC_TRACE 0
  155344             : #endif
  155345             : 
  155346             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  155347             : #define ROSE_ALLOC_TRACE_CNT
  155348             : #include "memory-pool-snapshot.h"
  155349             : unsigned long alloc_trace_cnt = 0;
  155350             : #endif
  155351             : 
  155352             : #if ROSE_ALLOC_TRACE
  155353             : const unsigned SgCallExpression::pool_size = 5;
  155354             : #else
  155355             : const unsigned SgCallExpression::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  155356             : #endif
  155357             : 
  155358             : #ifndef ROSE_ALLOC_MEMSET
  155359             : #  define ROSE_ALLOC_MEMSET 0
  155360             : #endif
  155361             : 
  155362             : #ifndef ROSE_PEDANTIC_ALLOC
  155363             : #  define ROSE_PEDANTIC_ALLOC 0
  155364             : #endif
  155365             : 
  155366             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  155367             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  155368             : #endif
  155369             : 
  155370             : #if !defined(SGNODE__ALL_POOLS)
  155371             : #define SGNODE__ALL_POOLS
  155372             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  155373             : #endif
  155374             : 
  155375             : SgCallExpression* SgCallExpression::next_node = nullptr;
  155376             : std::vector<unsigned char*> SgCallExpression::pools;
  155377             : 
  155378             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  155379             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  155380             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  155381             : // around this macro definition rather than each use).
  155382             : #ifndef ALLOC_MUTEX
  155383             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  155384             :         do {                                                                     \
  155385             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  155386             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  155387             :                 abort();                                                         \
  155388             :             }                                                                    \
  155389             :         } while (0);
  155390             : #endif
  155391             : 
  155392             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  155393             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  155394             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  155395             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  155396             : 
  155397             : /*! \brief New operator for SgCallExpression.
  155398             : 
  155399             :    This new operator implements memory pools to provide most efficent 
  155400             :    use of the heap within construction of large ASTs.
  155401             : 
  155402             : \internal The new and delete operators use the lower level C malloc/free
  155403             :    function calls for performance and to make sure that mixing of malloc/free
  155404             :    and new/delete by the used can be caught more readily.  This may change
  155405             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  155406             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  155407             :    deallocate memory allocated using ROSE_MALLOC.
  155408             : */
  155409           0 : void *SgCallExpression::operator new ( size_t Size )
  155410             : {
  155411             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  155412             :      * returning or throwing an exception. */
  155413           0 :     ALLOC_MUTEX(SgCallExpression, lock);
  155414             : 
  155415             : #if ROSE_ALLOC_TRACE == 2
  155416             : //    printf("SgCallExpression::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgCallExpression::next_node);
  155417             : #endif
  155418             : 
  155419             : #if USE_CPP_NEW_DELETE_OPERATORS
  155420             :     void *mem = ROSE_MALLOC(Size);
  155421             :     ALLOC_MUTEX(SgCallExpression, unlock);
  155422             :     return mem;
  155423             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  155424             : #if ROSE_PEDANTIC_ALLOC
  155425             :     ROSE_ASSERT(Size == sizeof(SgCallExpression));
  155426             : #else
  155427           0 :     if (Size != sizeof(SgCallExpression)) {
  155428           0 :       void * object = ROSE_MALLOC(Size);
  155429           0 :       ALLOC_MUTEX(SgCallExpression, unlock);
  155430             :       return object;
  155431             :     }
  155432             : #endif
  155433             : 
  155434           0 :     if (SgCallExpression::next_node == nullptr) {
  155435           0 :         SgCallExpression * alloc = (SgCallExpression*) ROSE_MALLOC ( SgCallExpression::pool_size * sizeof(SgCallExpression) );
  155436           0 :         ROSE_ASSERT(alloc != nullptr);
  155437             : 
  155438             : #if ROSE_ALLOC_TRACE == 2
  155439             : //        printf("SgCallExpression::alloc\n  block[%zi] = [ %p , %p [\n", SgCallExpression::pools.size(), alloc, alloc + SgCallExpression::pool_size);
  155440             : #endif
  155441             : 
  155442             : #if ROSE_ALLOC_MEMSET == 1
  155443             : #elif ROSE_ALLOC_MEMSET == 2
  155444             :         memset(alloc, 0x00, SgCallExpression::pool_size * sizeof(SgCallExpression));
  155445             : #elif ROSE_ALLOC_MEMSET == 3
  155446             :         memset(alloc, 0xAA, SgCallExpression::pool_size * sizeof(SgCallExpression));
  155447             : #endif
  155448           0 :         for (unsigned i=0; i < SgCallExpression::pool_size-1; i++) {
  155449           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
  155450             :         }
  155451           0 :         alloc[SgCallExpression::pool_size-1].p_freepointer = nullptr;
  155452             : 
  155453           0 :         SgCallExpression::pools.push_back ( (unsigned char *) alloc );
  155454           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgCallExpression::pool_size * sizeof(SgCallExpression), V_SgCallExpression ) );
  155455           0 :         SgCallExpression::next_node = alloc;
  155456             :     }
  155457           0 :     ROSE_ASSERT(SgCallExpression::next_node != nullptr);
  155458             : 
  155459           0 :     SgCallExpression * object = SgCallExpression::next_node;
  155460           0 :     SgCallExpression::next_node = (SgCallExpression*)(object->p_freepointer);
  155461             : 
  155462             : #if ROSE_ALLOC_TRACE == 2
  155463             :     printf("SgCallExpression::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgCallExpression::next_node);
  155464             : #endif
  155465             : 
  155466           0 :     SgNode * fp = object->p_freepointer;
  155467             : #if ROSE_ALLOC_MEMSET == 1
  155468             : #elif ROSE_ALLOC_MEMSET == 2
  155469             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgCallExpression) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  155470             : #elif ROSE_ALLOC_MEMSET == 3
  155471             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgCallExpression) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  155472             : #endif
  155473           0 :     object->p_freepointer = fp;
  155474             : 
  155475             : #if ROSE_ALLOC_TRACE == 2
  155476             : //    printf("SgCallExpression::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgCallExpression::next_node);
  155477             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  155478             :     Rose::MemPool::snapshot(oss.str());
  155479             :     alloc_trace_cnt++;
  155480             : #endif
  155481             : 
  155482           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  155483             : 
  155484           0 :     ALLOC_MUTEX(SgCallExpression, unlock);
  155485             : 
  155486             :     return object;
  155487             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  155488             : }
  155489             : 
  155490             : 
  155491             : 
  155492             : /*! \brief Delete operator for SgCallExpression.
  155493             : 
  155494             :    This delete operator implements deallocation using memory pools to 
  155495             :    provide most efficent use of the heap within construction of large ASTs.
  155496             : 
  155497             : \internal The new and delete operators use the lower level C malloc/free
  155498             :    function calls for performance and to make sure that mixing of malloc/free
  155499             :    and new/delete by the used can be caught more readily.  This may change
  155500             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  155501             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  155502             :    deallocate memory allocated using ROSE_MALLOC.
  155503             : */
  155504           0 : void SgCallExpression::operator delete(void *Pointer, size_t Size)
  155505             : {
  155506             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  155507             :      * or throwing an exception. */
  155508           0 :     ALLOC_MUTEX(SgCallExpression, lock);
  155509             : 
  155510             : #if USE_CPP_NEW_DELETE_OPERATORS
  155511             :     ROSE_FREE(Pointer);
  155512             : #else
  155513             : #if ROSE_PEDANTIC_ALLOC
  155514             :     ROSE_ASSERT(Size == sizeof(SgCallExpression));
  155515             : #else
  155516           0 :     if (Size != sizeof(SgCallExpression)) {
  155517           0 :       ROSE_FREE(Pointer);
  155518           0 :       ALLOC_MUTEX(SgCallExpression, unlock);
  155519             :       return;
  155520             :     }
  155521             : #endif
  155522             : 
  155523           0 :     SgCallExpression * object = (SgCallExpression*) Pointer;
  155524           0 :     ROSE_ASSERT(object != nullptr);
  155525             : 
  155526             : #if ROSE_ALLOC_TRACE == 2
  155527             : //  printf("SgCallExpression::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgCallExpression::next_node);
  155528             :     printf("SgCallExpression::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgCallExpression::next_node);
  155529             : #endif
  155530             : 
  155531             : #if ROSE_PEDANTIC_ALLOC
  155532             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  155533             : #endif
  155534             : 
  155535             : #if ROSE_ALLOC_MEMSET == 1
  155536             : #elif ROSE_ALLOC_MEMSET == 2
  155537             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgCallExpression) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  155538             : #elif ROSE_ALLOC_MEMSET == 3
  155539             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgCallExpression) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  155540             : #endif
  155541             : 
  155542             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  155543             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  155544             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  155545             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  155546             : #else
  155547           0 :     object->p_freepointer = SgCallExpression::next_node;
  155548           0 :     SgCallExpression::next_node = object;
  155549             : #endif
  155550             : 
  155551             : #if ROSE_ALLOC_TRACE == 2
  155552             : //  printf("SgCallExpression::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgCallExpression::next_node);
  155553             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  155554             :     Rose::MemPool::snapshot(oss.str());
  155555             :     alloc_trace_cnt++;
  155556             : #endif
  155557             : 
  155558             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  155559             : 
  155560           0 :     ALLOC_MUTEX(SgCallExpression, unlock);
  155561             : }
  155562             : 
  155563             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  155564             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  155565             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  155566             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  155567             : // Also, note comment below from Robb (copied from the Common.code file).
  155568             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  155569             : //
  155570             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  155571             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  155572             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  155573             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  155574             : #if 0
  155575             : void SgCallExpression::operator delete(void* pointer) { SgCallExpression::operator delete (pointer, sizeof(SgCallExpression)); };
  155576             : #endif
  155577             : /* #line 155578 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  155578             : 
  155579             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  155580             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  155581             : // obviously imply C++.
  155582             : 
  155583             : // This implements the support within ROSE for memory pools.  Memory pools
  155584             : // support the most condensed usage of memory within the construction of
  155585             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  155586             : // by a new operator written for each class.
  155587             : 
  155588             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  155589             :     // User wants multi-thread support and POSIX threads are available.
  155590             : #   include <pthread.h>
  155591             :     static pthread_mutex_t SgFunctionCallExp_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  155592             : #else
  155593             :      // Cause synchronization to be skipped.
  155594             : #    ifndef ALLOC_MUTEX
  155595             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  155596             : #    endif
  155597             : #    ifdef _REENTRANT
  155598             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  155599             : #       ifdef _MSC_VER
  155600             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  155601             : #       else
  155602             : #           warning "POSIX threads are not available; synchronization being skipped"
  155603             : #       endif
  155604             : #    endif
  155605             : #endif
  155606             : 
  155607             : #ifndef ROSE_ALLOC_TRACE
  155608             : #  define ROSE_ALLOC_TRACE 0
  155609             : #endif
  155610             : 
  155611             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  155612             : #define ROSE_ALLOC_TRACE_CNT
  155613             : #include "memory-pool-snapshot.h"
  155614             : unsigned long alloc_trace_cnt = 0;
  155615             : #endif
  155616             : 
  155617             : #if ROSE_ALLOC_TRACE
  155618             : const unsigned SgFunctionCallExp::pool_size = 5;
  155619             : #else
  155620             : const unsigned SgFunctionCallExp::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  155621             : #endif
  155622             : 
  155623             : #ifndef ROSE_ALLOC_MEMSET
  155624             : #  define ROSE_ALLOC_MEMSET 0
  155625             : #endif
  155626             : 
  155627             : #ifndef ROSE_PEDANTIC_ALLOC
  155628             : #  define ROSE_PEDANTIC_ALLOC 0
  155629             : #endif
  155630             : 
  155631             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  155632             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  155633             : #endif
  155634             : 
  155635             : #if !defined(SGNODE__ALL_POOLS)
  155636             : #define SGNODE__ALL_POOLS
  155637             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  155638             : #endif
  155639             : 
  155640             : SgFunctionCallExp* SgFunctionCallExp::next_node = nullptr;
  155641             : std::vector<unsigned char*> SgFunctionCallExp::pools;
  155642             : 
  155643             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  155644             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  155645             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  155646             : // around this macro definition rather than each use).
  155647             : #ifndef ALLOC_MUTEX
  155648             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  155649             :         do {                                                                     \
  155650             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  155651             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  155652             :                 abort();                                                         \
  155653             :             }                                                                    \
  155654             :         } while (0);
  155655             : #endif
  155656             : 
  155657             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  155658             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  155659             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  155660             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  155661             : 
  155662             : /*! \brief New operator for SgFunctionCallExp.
  155663             : 
  155664             :    This new operator implements memory pools to provide most efficent 
  155665             :    use of the heap within construction of large ASTs.
  155666             : 
  155667             : \internal The new and delete operators use the lower level C malloc/free
  155668             :    function calls for performance and to make sure that mixing of malloc/free
  155669             :    and new/delete by the used can be caught more readily.  This may change
  155670             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  155671             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  155672             :    deallocate memory allocated using ROSE_MALLOC.
  155673             : */
  155674       36148 : void *SgFunctionCallExp::operator new ( size_t Size )
  155675             : {
  155676             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  155677             :      * returning or throwing an exception. */
  155678       36148 :     ALLOC_MUTEX(SgFunctionCallExp, lock);
  155679             : 
  155680             : #if ROSE_ALLOC_TRACE == 2
  155681             : //    printf("SgFunctionCallExp::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgFunctionCallExp::next_node);
  155682             : #endif
  155683             : 
  155684             : #if USE_CPP_NEW_DELETE_OPERATORS
  155685             :     void *mem = ROSE_MALLOC(Size);
  155686             :     ALLOC_MUTEX(SgFunctionCallExp, unlock);
  155687             :     return mem;
  155688             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  155689             : #if ROSE_PEDANTIC_ALLOC
  155690             :     ROSE_ASSERT(Size == sizeof(SgFunctionCallExp));
  155691             : #else
  155692       36148 :     if (Size != sizeof(SgFunctionCallExp)) {
  155693           0 :       void * object = ROSE_MALLOC(Size);
  155694           0 :       ALLOC_MUTEX(SgFunctionCallExp, unlock);
  155695             :       return object;
  155696             :     }
  155697             : #endif
  155698             : 
  155699       36148 :     if (SgFunctionCallExp::next_node == nullptr) {
  155700         235 :         SgFunctionCallExp * alloc = (SgFunctionCallExp*) ROSE_MALLOC ( SgFunctionCallExp::pool_size * sizeof(SgFunctionCallExp) );
  155701         235 :         ROSE_ASSERT(alloc != nullptr);
  155702             : 
  155703             : #if ROSE_ALLOC_TRACE == 2
  155704             : //        printf("SgFunctionCallExp::alloc\n  block[%zi] = [ %p , %p [\n", SgFunctionCallExp::pools.size(), alloc, alloc + SgFunctionCallExp::pool_size);
  155705             : #endif
  155706             : 
  155707             : #if ROSE_ALLOC_MEMSET == 1
  155708             : #elif ROSE_ALLOC_MEMSET == 2
  155709             :         memset(alloc, 0x00, SgFunctionCallExp::pool_size * sizeof(SgFunctionCallExp));
  155710             : #elif ROSE_ALLOC_MEMSET == 3
  155711             :         memset(alloc, 0xAA, SgFunctionCallExp::pool_size * sizeof(SgFunctionCallExp));
  155712             : #endif
  155713      470000 :         for (unsigned i=0; i < SgFunctionCallExp::pool_size-1; i++) {
  155714      469765 :           alloc[i].p_freepointer = &(alloc[i+1]);
  155715             :         }
  155716         235 :         alloc[SgFunctionCallExp::pool_size-1].p_freepointer = nullptr;
  155717             : 
  155718         235 :         SgFunctionCallExp::pools.push_back ( (unsigned char *) alloc );
  155719         235 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgFunctionCallExp::pool_size * sizeof(SgFunctionCallExp), V_SgFunctionCallExp ) );
  155720         235 :         SgFunctionCallExp::next_node = alloc;
  155721             :     }
  155722       36148 :     ROSE_ASSERT(SgFunctionCallExp::next_node != nullptr);
  155723             : 
  155724       36148 :     SgFunctionCallExp * object = SgFunctionCallExp::next_node;
  155725       36148 :     SgFunctionCallExp::next_node = (SgFunctionCallExp*)(object->p_freepointer);
  155726             : 
  155727             : #if ROSE_ALLOC_TRACE == 2
  155728             :     printf("SgFunctionCallExp::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgFunctionCallExp::next_node);
  155729             : #endif
  155730             : 
  155731       36148 :     SgNode * fp = object->p_freepointer;
  155732             : #if ROSE_ALLOC_MEMSET == 1
  155733             : #elif ROSE_ALLOC_MEMSET == 2
  155734             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgFunctionCallExp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  155735             : #elif ROSE_ALLOC_MEMSET == 3
  155736             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgFunctionCallExp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  155737             : #endif
  155738       36148 :     object->p_freepointer = fp;
  155739             : 
  155740             : #if ROSE_ALLOC_TRACE == 2
  155741             : //    printf("SgFunctionCallExp::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgFunctionCallExp::next_node);
  155742             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  155743             :     Rose::MemPool::snapshot(oss.str());
  155744             :     alloc_trace_cnt++;
  155745             : #endif
  155746             : 
  155747       36148 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  155748             : 
  155749       36148 :     ALLOC_MUTEX(SgFunctionCallExp, unlock);
  155750             : 
  155751             :     return object;
  155752             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  155753             : }
  155754             : 
  155755             : 
  155756             : 
  155757             : /*! \brief Delete operator for SgFunctionCallExp.
  155758             : 
  155759             :    This delete operator implements deallocation using memory pools to 
  155760             :    provide most efficent use of the heap within construction of large ASTs.
  155761             : 
  155762             : \internal The new and delete operators use the lower level C malloc/free
  155763             :    function calls for performance and to make sure that mixing of malloc/free
  155764             :    and new/delete by the used can be caught more readily.  This may change
  155765             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  155766             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  155767             :    deallocate memory allocated using ROSE_MALLOC.
  155768             : */
  155769        6889 : void SgFunctionCallExp::operator delete(void *Pointer, size_t Size)
  155770             : {
  155771             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  155772             :      * or throwing an exception. */
  155773        6889 :     ALLOC_MUTEX(SgFunctionCallExp, lock);
  155774             : 
  155775             : #if USE_CPP_NEW_DELETE_OPERATORS
  155776             :     ROSE_FREE(Pointer);
  155777             : #else
  155778             : #if ROSE_PEDANTIC_ALLOC
  155779             :     ROSE_ASSERT(Size == sizeof(SgFunctionCallExp));
  155780             : #else
  155781        6889 :     if (Size != sizeof(SgFunctionCallExp)) {
  155782           0 :       ROSE_FREE(Pointer);
  155783           0 :       ALLOC_MUTEX(SgFunctionCallExp, unlock);
  155784             :       return;
  155785             :     }
  155786             : #endif
  155787             : 
  155788        6889 :     SgFunctionCallExp * object = (SgFunctionCallExp*) Pointer;
  155789        6889 :     ROSE_ASSERT(object != nullptr);
  155790             : 
  155791             : #if ROSE_ALLOC_TRACE == 2
  155792             : //  printf("SgFunctionCallExp::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgFunctionCallExp::next_node);
  155793             :     printf("SgFunctionCallExp::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgFunctionCallExp::next_node);
  155794             : #endif
  155795             : 
  155796             : #if ROSE_PEDANTIC_ALLOC
  155797             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  155798             : #endif
  155799             : 
  155800             : #if ROSE_ALLOC_MEMSET == 1
  155801             : #elif ROSE_ALLOC_MEMSET == 2
  155802             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgFunctionCallExp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  155803             : #elif ROSE_ALLOC_MEMSET == 3
  155804             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgFunctionCallExp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  155805             : #endif
  155806             : 
  155807             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  155808             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  155809             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  155810             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  155811             : #else
  155812        6889 :     object->p_freepointer = SgFunctionCallExp::next_node;
  155813        6889 :     SgFunctionCallExp::next_node = object;
  155814             : #endif
  155815             : 
  155816             : #if ROSE_ALLOC_TRACE == 2
  155817             : //  printf("SgFunctionCallExp::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgFunctionCallExp::next_node);
  155818             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  155819             :     Rose::MemPool::snapshot(oss.str());
  155820             :     alloc_trace_cnt++;
  155821             : #endif
  155822             : 
  155823             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  155824             : 
  155825        6889 :     ALLOC_MUTEX(SgFunctionCallExp, unlock);
  155826             : }
  155827             : 
  155828             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  155829             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  155830             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  155831             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  155832             : // Also, note comment below from Robb (copied from the Common.code file).
  155833             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  155834             : //
  155835             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  155836             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  155837             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  155838             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  155839             : #if 0
  155840             : void SgFunctionCallExp::operator delete(void* pointer) { SgFunctionCallExp::operator delete (pointer, sizeof(SgFunctionCallExp)); };
  155841             : #endif
  155842             : /* #line 155843 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  155843             : 
  155844             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  155845             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  155846             : // obviously imply C++.
  155847             : 
  155848             : // This implements the support within ROSE for memory pools.  Memory pools
  155849             : // support the most condensed usage of memory within the construction of
  155850             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  155851             : // by a new operator written for each class.
  155852             : 
  155853             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  155854             :     // User wants multi-thread support and POSIX threads are available.
  155855             : #   include <pthread.h>
  155856             :     static pthread_mutex_t SgCudaKernelCallExp_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  155857             : #else
  155858             :      // Cause synchronization to be skipped.
  155859             : #    ifndef ALLOC_MUTEX
  155860             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  155861             : #    endif
  155862             : #    ifdef _REENTRANT
  155863             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  155864             : #       ifdef _MSC_VER
  155865             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  155866             : #       else
  155867             : #           warning "POSIX threads are not available; synchronization being skipped"
  155868             : #       endif
  155869             : #    endif
  155870             : #endif
  155871             : 
  155872             : #ifndef ROSE_ALLOC_TRACE
  155873             : #  define ROSE_ALLOC_TRACE 0
  155874             : #endif
  155875             : 
  155876             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  155877             : #define ROSE_ALLOC_TRACE_CNT
  155878             : #include "memory-pool-snapshot.h"
  155879             : unsigned long alloc_trace_cnt = 0;
  155880             : #endif
  155881             : 
  155882             : #if ROSE_ALLOC_TRACE
  155883             : const unsigned SgCudaKernelCallExp::pool_size = 5;
  155884             : #else
  155885             : const unsigned SgCudaKernelCallExp::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  155886             : #endif
  155887             : 
  155888             : #ifndef ROSE_ALLOC_MEMSET
  155889             : #  define ROSE_ALLOC_MEMSET 0
  155890             : #endif
  155891             : 
  155892             : #ifndef ROSE_PEDANTIC_ALLOC
  155893             : #  define ROSE_PEDANTIC_ALLOC 0
  155894             : #endif
  155895             : 
  155896             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  155897             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  155898             : #endif
  155899             : 
  155900             : #if !defined(SGNODE__ALL_POOLS)
  155901             : #define SGNODE__ALL_POOLS
  155902             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  155903             : #endif
  155904             : 
  155905             : SgCudaKernelCallExp* SgCudaKernelCallExp::next_node = nullptr;
  155906             : std::vector<unsigned char*> SgCudaKernelCallExp::pools;
  155907             : 
  155908             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  155909             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  155910             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  155911             : // around this macro definition rather than each use).
  155912             : #ifndef ALLOC_MUTEX
  155913             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  155914             :         do {                                                                     \
  155915             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  155916             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  155917             :                 abort();                                                         \
  155918             :             }                                                                    \
  155919             :         } while (0);
  155920             : #endif
  155921             : 
  155922             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  155923             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  155924             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  155925             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  155926             : 
  155927             : /*! \brief New operator for SgCudaKernelCallExp.
  155928             : 
  155929             :    This new operator implements memory pools to provide most efficent 
  155930             :    use of the heap within construction of large ASTs.
  155931             : 
  155932             : \internal The new and delete operators use the lower level C malloc/free
  155933             :    function calls for performance and to make sure that mixing of malloc/free
  155934             :    and new/delete by the used can be caught more readily.  This may change
  155935             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  155936             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  155937             :    deallocate memory allocated using ROSE_MALLOC.
  155938             : */
  155939           0 : void *SgCudaKernelCallExp::operator new ( size_t Size )
  155940             : {
  155941             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  155942             :      * returning or throwing an exception. */
  155943           0 :     ALLOC_MUTEX(SgCudaKernelCallExp, lock);
  155944             : 
  155945             : #if ROSE_ALLOC_TRACE == 2
  155946             : //    printf("SgCudaKernelCallExp::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgCudaKernelCallExp::next_node);
  155947             : #endif
  155948             : 
  155949             : #if USE_CPP_NEW_DELETE_OPERATORS
  155950             :     void *mem = ROSE_MALLOC(Size);
  155951             :     ALLOC_MUTEX(SgCudaKernelCallExp, unlock);
  155952             :     return mem;
  155953             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  155954             : #if ROSE_PEDANTIC_ALLOC
  155955             :     ROSE_ASSERT(Size == sizeof(SgCudaKernelCallExp));
  155956             : #else
  155957           0 :     if (Size != sizeof(SgCudaKernelCallExp)) {
  155958           0 :       void * object = ROSE_MALLOC(Size);
  155959           0 :       ALLOC_MUTEX(SgCudaKernelCallExp, unlock);
  155960             :       return object;
  155961             :     }
  155962             : #endif
  155963             : 
  155964           0 :     if (SgCudaKernelCallExp::next_node == nullptr) {
  155965           0 :         SgCudaKernelCallExp * alloc = (SgCudaKernelCallExp*) ROSE_MALLOC ( SgCudaKernelCallExp::pool_size * sizeof(SgCudaKernelCallExp) );
  155966           0 :         ROSE_ASSERT(alloc != nullptr);
  155967             : 
  155968             : #if ROSE_ALLOC_TRACE == 2
  155969             : //        printf("SgCudaKernelCallExp::alloc\n  block[%zi] = [ %p , %p [\n", SgCudaKernelCallExp::pools.size(), alloc, alloc + SgCudaKernelCallExp::pool_size);
  155970             : #endif
  155971             : 
  155972             : #if ROSE_ALLOC_MEMSET == 1
  155973             : #elif ROSE_ALLOC_MEMSET == 2
  155974             :         memset(alloc, 0x00, SgCudaKernelCallExp::pool_size * sizeof(SgCudaKernelCallExp));
  155975             : #elif ROSE_ALLOC_MEMSET == 3
  155976             :         memset(alloc, 0xAA, SgCudaKernelCallExp::pool_size * sizeof(SgCudaKernelCallExp));
  155977             : #endif
  155978           0 :         for (unsigned i=0; i < SgCudaKernelCallExp::pool_size-1; i++) {
  155979           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
  155980             :         }
  155981           0 :         alloc[SgCudaKernelCallExp::pool_size-1].p_freepointer = nullptr;
  155982             : 
  155983           0 :         SgCudaKernelCallExp::pools.push_back ( (unsigned char *) alloc );
  155984           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgCudaKernelCallExp::pool_size * sizeof(SgCudaKernelCallExp), V_SgCudaKernelCallExp ) );
  155985           0 :         SgCudaKernelCallExp::next_node = alloc;
  155986             :     }
  155987           0 :     ROSE_ASSERT(SgCudaKernelCallExp::next_node != nullptr);
  155988             : 
  155989           0 :     SgCudaKernelCallExp * object = SgCudaKernelCallExp::next_node;
  155990           0 :     SgCudaKernelCallExp::next_node = (SgCudaKernelCallExp*)(object->p_freepointer);
  155991             : 
  155992             : #if ROSE_ALLOC_TRACE == 2
  155993             :     printf("SgCudaKernelCallExp::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgCudaKernelCallExp::next_node);
  155994             : #endif
  155995             : 
  155996           0 :     SgNode * fp = object->p_freepointer;
  155997             : #if ROSE_ALLOC_MEMSET == 1
  155998             : #elif ROSE_ALLOC_MEMSET == 2
  155999             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgCudaKernelCallExp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  156000             : #elif ROSE_ALLOC_MEMSET == 3
  156001             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgCudaKernelCallExp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  156002             : #endif
  156003           0 :     object->p_freepointer = fp;
  156004             : 
  156005             : #if ROSE_ALLOC_TRACE == 2
  156006             : //    printf("SgCudaKernelCallExp::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgCudaKernelCallExp::next_node);
  156007             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  156008             :     Rose::MemPool::snapshot(oss.str());
  156009             :     alloc_trace_cnt++;
  156010             : #endif
  156011             : 
  156012           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  156013             : 
  156014           0 :     ALLOC_MUTEX(SgCudaKernelCallExp, unlock);
  156015             : 
  156016             :     return object;
  156017             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  156018             : }
  156019             : 
  156020             : 
  156021             : 
  156022             : /*! \brief Delete operator for SgCudaKernelCallExp.
  156023             : 
  156024             :    This delete operator implements deallocation using memory pools to 
  156025             :    provide most efficent use of the heap within construction of large ASTs.
  156026             : 
  156027             : \internal The new and delete operators use the lower level C malloc/free
  156028             :    function calls for performance and to make sure that mixing of malloc/free
  156029             :    and new/delete by the used can be caught more readily.  This may change
  156030             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  156031             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  156032             :    deallocate memory allocated using ROSE_MALLOC.
  156033             : */
  156034           0 : void SgCudaKernelCallExp::operator delete(void *Pointer, size_t Size)
  156035             : {
  156036             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  156037             :      * or throwing an exception. */
  156038           0 :     ALLOC_MUTEX(SgCudaKernelCallExp, lock);
  156039             : 
  156040             : #if USE_CPP_NEW_DELETE_OPERATORS
  156041             :     ROSE_FREE(Pointer);
  156042             : #else
  156043             : #if ROSE_PEDANTIC_ALLOC
  156044             :     ROSE_ASSERT(Size == sizeof(SgCudaKernelCallExp));
  156045             : #else
  156046           0 :     if (Size != sizeof(SgCudaKernelCallExp)) {
  156047           0 :       ROSE_FREE(Pointer);
  156048           0 :       ALLOC_MUTEX(SgCudaKernelCallExp, unlock);
  156049             :       return;
  156050             :     }
  156051             : #endif
  156052             : 
  156053           0 :     SgCudaKernelCallExp * object = (SgCudaKernelCallExp*) Pointer;
  156054           0 :     ROSE_ASSERT(object != nullptr);
  156055             : 
  156056             : #if ROSE_ALLOC_TRACE == 2
  156057             : //  printf("SgCudaKernelCallExp::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgCudaKernelCallExp::next_node);
  156058             :     printf("SgCudaKernelCallExp::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgCudaKernelCallExp::next_node);
  156059             : #endif
  156060             : 
  156061             : #if ROSE_PEDANTIC_ALLOC
  156062             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  156063             : #endif
  156064             : 
  156065             : #if ROSE_ALLOC_MEMSET == 1
  156066             : #elif ROSE_ALLOC_MEMSET == 2
  156067             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgCudaKernelCallExp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  156068             : #elif ROSE_ALLOC_MEMSET == 3
  156069             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgCudaKernelCallExp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  156070             : #endif
  156071             : 
  156072             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  156073             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  156074             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  156075             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  156076             : #else
  156077           0 :     object->p_freepointer = SgCudaKernelCallExp::next_node;
  156078           0 :     SgCudaKernelCallExp::next_node = object;
  156079             : #endif
  156080             : 
  156081             : #if ROSE_ALLOC_TRACE == 2
  156082             : //  printf("SgCudaKernelCallExp::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgCudaKernelCallExp::next_node);
  156083             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  156084             :     Rose::MemPool::snapshot(oss.str());
  156085             :     alloc_trace_cnt++;
  156086             : #endif
  156087             : 
  156088             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  156089             : 
  156090           0 :     ALLOC_MUTEX(SgCudaKernelCallExp, unlock);
  156091             : }
  156092             : 
  156093             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  156094             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  156095             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  156096             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  156097             : // Also, note comment below from Robb (copied from the Common.code file).
  156098             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  156099             : //
  156100             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  156101             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  156102             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  156103             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  156104             : #if 0
  156105             : void SgCudaKernelCallExp::operator delete(void* pointer) { SgCudaKernelCallExp::operator delete (pointer, sizeof(SgCudaKernelCallExp)); };
  156106             : #endif
  156107             : /* #line 156108 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  156108             : 
  156109             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  156110             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  156111             : // obviously imply C++.
  156112             : 
  156113             : // This implements the support within ROSE for memory pools.  Memory pools
  156114             : // support the most condensed usage of memory within the construction of
  156115             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  156116             : // by a new operator written for each class.
  156117             : 
  156118             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  156119             :     // User wants multi-thread support and POSIX threads are available.
  156120             : #   include <pthread.h>
  156121             :     static pthread_mutex_t SgSizeOfOp_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  156122             : #else
  156123             :      // Cause synchronization to be skipped.
  156124             : #    ifndef ALLOC_MUTEX
  156125             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  156126             : #    endif
  156127             : #    ifdef _REENTRANT
  156128             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  156129             : #       ifdef _MSC_VER
  156130             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  156131             : #       else
  156132             : #           warning "POSIX threads are not available; synchronization being skipped"
  156133             : #       endif
  156134             : #    endif
  156135             : #endif
  156136             : 
  156137             : #ifndef ROSE_ALLOC_TRACE
  156138             : #  define ROSE_ALLOC_TRACE 0
  156139             : #endif
  156140             : 
  156141             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  156142             : #define ROSE_ALLOC_TRACE_CNT
  156143             : #include "memory-pool-snapshot.h"
  156144             : unsigned long alloc_trace_cnt = 0;
  156145             : #endif
  156146             : 
  156147             : #if ROSE_ALLOC_TRACE
  156148             : const unsigned SgSizeOfOp::pool_size = 5;
  156149             : #else
  156150             : const unsigned SgSizeOfOp::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  156151             : #endif
  156152             : 
  156153             : #ifndef ROSE_ALLOC_MEMSET
  156154             : #  define ROSE_ALLOC_MEMSET 0
  156155             : #endif
  156156             : 
  156157             : #ifndef ROSE_PEDANTIC_ALLOC
  156158             : #  define ROSE_PEDANTIC_ALLOC 0
  156159             : #endif
  156160             : 
  156161             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  156162             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  156163             : #endif
  156164             : 
  156165             : #if !defined(SGNODE__ALL_POOLS)
  156166             : #define SGNODE__ALL_POOLS
  156167             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  156168             : #endif
  156169             : 
  156170             : SgSizeOfOp* SgSizeOfOp::next_node = nullptr;
  156171             : std::vector<unsigned char*> SgSizeOfOp::pools;
  156172             : 
  156173             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  156174             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  156175             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  156176             : // around this macro definition rather than each use).
  156177             : #ifndef ALLOC_MUTEX
  156178             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  156179             :         do {                                                                     \
  156180             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  156181             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  156182             :                 abort();                                                         \
  156183             :             }                                                                    \
  156184             :         } while (0);
  156185             : #endif
  156186             : 
  156187             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  156188             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  156189             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  156190             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  156191             : 
  156192             : /*! \brief New operator for SgSizeOfOp.
  156193             : 
  156194             :    This new operator implements memory pools to provide most efficent 
  156195             :    use of the heap within construction of large ASTs.
  156196             : 
  156197             : \internal The new and delete operators use the lower level C malloc/free
  156198             :    function calls for performance and to make sure that mixing of malloc/free
  156199             :    and new/delete by the used can be caught more readily.  This may change
  156200             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  156201             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  156202             :    deallocate memory allocated using ROSE_MALLOC.
  156203             : */
  156204        2280 : void *SgSizeOfOp::operator new ( size_t Size )
  156205             : {
  156206             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  156207             :      * returning or throwing an exception. */
  156208        2280 :     ALLOC_MUTEX(SgSizeOfOp, lock);
  156209             : 
  156210             : #if ROSE_ALLOC_TRACE == 2
  156211             : //    printf("SgSizeOfOp::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgSizeOfOp::next_node);
  156212             : #endif
  156213             : 
  156214             : #if USE_CPP_NEW_DELETE_OPERATORS
  156215             :     void *mem = ROSE_MALLOC(Size);
  156216             :     ALLOC_MUTEX(SgSizeOfOp, unlock);
  156217             :     return mem;
  156218             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  156219             : #if ROSE_PEDANTIC_ALLOC
  156220             :     ROSE_ASSERT(Size == sizeof(SgSizeOfOp));
  156221             : #else
  156222        2280 :     if (Size != sizeof(SgSizeOfOp)) {
  156223           0 :       void * object = ROSE_MALLOC(Size);
  156224           0 :       ALLOC_MUTEX(SgSizeOfOp, unlock);
  156225             :       return object;
  156226             :     }
  156227             : #endif
  156228             : 
  156229        2280 :     if (SgSizeOfOp::next_node == nullptr) {
  156230         198 :         SgSizeOfOp * alloc = (SgSizeOfOp*) ROSE_MALLOC ( SgSizeOfOp::pool_size * sizeof(SgSizeOfOp) );
  156231         198 :         ROSE_ASSERT(alloc != nullptr);
  156232             : 
  156233             : #if ROSE_ALLOC_TRACE == 2
  156234             : //        printf("SgSizeOfOp::alloc\n  block[%zi] = [ %p , %p [\n", SgSizeOfOp::pools.size(), alloc, alloc + SgSizeOfOp::pool_size);
  156235             : #endif
  156236             : 
  156237             : #if ROSE_ALLOC_MEMSET == 1
  156238             : #elif ROSE_ALLOC_MEMSET == 2
  156239             :         memset(alloc, 0x00, SgSizeOfOp::pool_size * sizeof(SgSizeOfOp));
  156240             : #elif ROSE_ALLOC_MEMSET == 3
  156241             :         memset(alloc, 0xAA, SgSizeOfOp::pool_size * sizeof(SgSizeOfOp));
  156242             : #endif
  156243      396000 :         for (unsigned i=0; i < SgSizeOfOp::pool_size-1; i++) {
  156244      395802 :           alloc[i].p_freepointer = &(alloc[i+1]);
  156245             :         }
  156246         198 :         alloc[SgSizeOfOp::pool_size-1].p_freepointer = nullptr;
  156247             : 
  156248         198 :         SgSizeOfOp::pools.push_back ( (unsigned char *) alloc );
  156249         198 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgSizeOfOp::pool_size * sizeof(SgSizeOfOp), V_SgSizeOfOp ) );
  156250         198 :         SgSizeOfOp::next_node = alloc;
  156251             :     }
  156252        2280 :     ROSE_ASSERT(SgSizeOfOp::next_node != nullptr);
  156253             : 
  156254        2280 :     SgSizeOfOp * object = SgSizeOfOp::next_node;
  156255        2280 :     SgSizeOfOp::next_node = (SgSizeOfOp*)(object->p_freepointer);
  156256             : 
  156257             : #if ROSE_ALLOC_TRACE == 2
  156258             :     printf("SgSizeOfOp::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgSizeOfOp::next_node);
  156259             : #endif
  156260             : 
  156261        2280 :     SgNode * fp = object->p_freepointer;
  156262             : #if ROSE_ALLOC_MEMSET == 1
  156263             : #elif ROSE_ALLOC_MEMSET == 2
  156264             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgSizeOfOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  156265             : #elif ROSE_ALLOC_MEMSET == 3
  156266             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgSizeOfOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  156267             : #endif
  156268        2280 :     object->p_freepointer = fp;
  156269             : 
  156270             : #if ROSE_ALLOC_TRACE == 2
  156271             : //    printf("SgSizeOfOp::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgSizeOfOp::next_node);
  156272             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  156273             :     Rose::MemPool::snapshot(oss.str());
  156274             :     alloc_trace_cnt++;
  156275             : #endif
  156276             : 
  156277        2280 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  156278             : 
  156279        2280 :     ALLOC_MUTEX(SgSizeOfOp, unlock);
  156280             : 
  156281             :     return object;
  156282             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  156283             : }
  156284             : 
  156285             : 
  156286             : 
  156287             : /*! \brief Delete operator for SgSizeOfOp.
  156288             : 
  156289             :    This delete operator implements deallocation using memory pools to 
  156290             :    provide most efficent use of the heap within construction of large ASTs.
  156291             : 
  156292             : \internal The new and delete operators use the lower level C malloc/free
  156293             :    function calls for performance and to make sure that mixing of malloc/free
  156294             :    and new/delete by the used can be caught more readily.  This may change
  156295             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  156296             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  156297             :    deallocate memory allocated using ROSE_MALLOC.
  156298             : */
  156299         629 : void SgSizeOfOp::operator delete(void *Pointer, size_t Size)
  156300             : {
  156301             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  156302             :      * or throwing an exception. */
  156303         629 :     ALLOC_MUTEX(SgSizeOfOp, lock);
  156304             : 
  156305             : #if USE_CPP_NEW_DELETE_OPERATORS
  156306             :     ROSE_FREE(Pointer);
  156307             : #else
  156308             : #if ROSE_PEDANTIC_ALLOC
  156309             :     ROSE_ASSERT(Size == sizeof(SgSizeOfOp));
  156310             : #else
  156311         629 :     if (Size != sizeof(SgSizeOfOp)) {
  156312           0 :       ROSE_FREE(Pointer);
  156313           0 :       ALLOC_MUTEX(SgSizeOfOp, unlock);
  156314             :       return;
  156315             :     }
  156316             : #endif
  156317             : 
  156318         629 :     SgSizeOfOp * object = (SgSizeOfOp*) Pointer;
  156319         629 :     ROSE_ASSERT(object != nullptr);
  156320             : 
  156321             : #if ROSE_ALLOC_TRACE == 2
  156322             : //  printf("SgSizeOfOp::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgSizeOfOp::next_node);
  156323             :     printf("SgSizeOfOp::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgSizeOfOp::next_node);
  156324             : #endif
  156325             : 
  156326             : #if ROSE_PEDANTIC_ALLOC
  156327             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  156328             : #endif
  156329             : 
  156330             : #if ROSE_ALLOC_MEMSET == 1
  156331             : #elif ROSE_ALLOC_MEMSET == 2
  156332             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgSizeOfOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  156333             : #elif ROSE_ALLOC_MEMSET == 3
  156334             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgSizeOfOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  156335             : #endif
  156336             : 
  156337             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  156338             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  156339             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  156340             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  156341             : #else
  156342         629 :     object->p_freepointer = SgSizeOfOp::next_node;
  156343         629 :     SgSizeOfOp::next_node = object;
  156344             : #endif
  156345             : 
  156346             : #if ROSE_ALLOC_TRACE == 2
  156347             : //  printf("SgSizeOfOp::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgSizeOfOp::next_node);
  156348             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  156349             :     Rose::MemPool::snapshot(oss.str());
  156350             :     alloc_trace_cnt++;
  156351             : #endif
  156352             : 
  156353             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  156354             : 
  156355         629 :     ALLOC_MUTEX(SgSizeOfOp, unlock);
  156356             : }
  156357             : 
  156358             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  156359             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  156360             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  156361             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  156362             : // Also, note comment below from Robb (copied from the Common.code file).
  156363             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  156364             : //
  156365             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  156366             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  156367             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  156368             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  156369             : #if 0
  156370             : void SgSizeOfOp::operator delete(void* pointer) { SgSizeOfOp::operator delete (pointer, sizeof(SgSizeOfOp)); };
  156371             : #endif
  156372             : /* #line 156373 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  156373             : 
  156374             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  156375             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  156376             : // obviously imply C++.
  156377             : 
  156378             : // This implements the support within ROSE for memory pools.  Memory pools
  156379             : // support the most condensed usage of memory within the construction of
  156380             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  156381             : // by a new operator written for each class.
  156382             : 
  156383             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  156384             :     // User wants multi-thread support and POSIX threads are available.
  156385             : #   include <pthread.h>
  156386             :     static pthread_mutex_t SgUpcLocalsizeofExpression_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  156387             : #else
  156388             :      // Cause synchronization to be skipped.
  156389             : #    ifndef ALLOC_MUTEX
  156390             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  156391             : #    endif
  156392             : #    ifdef _REENTRANT
  156393             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  156394             : #       ifdef _MSC_VER
  156395             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  156396             : #       else
  156397             : #           warning "POSIX threads are not available; synchronization being skipped"
  156398             : #       endif
  156399             : #    endif
  156400             : #endif
  156401             : 
  156402             : #ifndef ROSE_ALLOC_TRACE
  156403             : #  define ROSE_ALLOC_TRACE 0
  156404             : #endif
  156405             : 
  156406             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  156407             : #define ROSE_ALLOC_TRACE_CNT
  156408             : #include "memory-pool-snapshot.h"
  156409             : unsigned long alloc_trace_cnt = 0;
  156410             : #endif
  156411             : 
  156412             : #if ROSE_ALLOC_TRACE
  156413             : const unsigned SgUpcLocalsizeofExpression::pool_size = 5;
  156414             : #else
  156415             : const unsigned SgUpcLocalsizeofExpression::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  156416             : #endif
  156417             : 
  156418             : #ifndef ROSE_ALLOC_MEMSET
  156419             : #  define ROSE_ALLOC_MEMSET 0
  156420             : #endif
  156421             : 
  156422             : #ifndef ROSE_PEDANTIC_ALLOC
  156423             : #  define ROSE_PEDANTIC_ALLOC 0
  156424             : #endif
  156425             : 
  156426             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  156427             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  156428             : #endif
  156429             : 
  156430             : #if !defined(SGNODE__ALL_POOLS)
  156431             : #define SGNODE__ALL_POOLS
  156432             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  156433             : #endif
  156434             : 
  156435             : SgUpcLocalsizeofExpression* SgUpcLocalsizeofExpression::next_node = nullptr;
  156436             : std::vector<unsigned char*> SgUpcLocalsizeofExpression::pools;
  156437             : 
  156438             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  156439             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  156440             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  156441             : // around this macro definition rather than each use).
  156442             : #ifndef ALLOC_MUTEX
  156443             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  156444             :         do {                                                                     \
  156445             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  156446             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  156447             :                 abort();                                                         \
  156448             :             }                                                                    \
  156449             :         } while (0);
  156450             : #endif
  156451             : 
  156452             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  156453             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  156454             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  156455             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  156456             : 
  156457             : /*! \brief New operator for SgUpcLocalsizeofExpression.
  156458             : 
  156459             :    This new operator implements memory pools to provide most efficent 
  156460             :    use of the heap within construction of large ASTs.
  156461             : 
  156462             : \internal The new and delete operators use the lower level C malloc/free
  156463             :    function calls for performance and to make sure that mixing of malloc/free
  156464             :    and new/delete by the used can be caught more readily.  This may change
  156465             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  156466             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  156467             :    deallocate memory allocated using ROSE_MALLOC.
  156468             : */
  156469           0 : void *SgUpcLocalsizeofExpression::operator new ( size_t Size )
  156470             : {
  156471             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  156472             :      * returning or throwing an exception. */
  156473           0 :     ALLOC_MUTEX(SgUpcLocalsizeofExpression, lock);
  156474             : 
  156475             : #if ROSE_ALLOC_TRACE == 2
  156476             : //    printf("SgUpcLocalsizeofExpression::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgUpcLocalsizeofExpression::next_node);
  156477             : #endif
  156478             : 
  156479             : #if USE_CPP_NEW_DELETE_OPERATORS
  156480             :     void *mem = ROSE_MALLOC(Size);
  156481             :     ALLOC_MUTEX(SgUpcLocalsizeofExpression, unlock);
  156482             :     return mem;
  156483             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  156484             : #if ROSE_PEDANTIC_ALLOC
  156485             :     ROSE_ASSERT(Size == sizeof(SgUpcLocalsizeofExpression));
  156486             : #else
  156487           0 :     if (Size != sizeof(SgUpcLocalsizeofExpression)) {
  156488           0 :       void * object = ROSE_MALLOC(Size);
  156489           0 :       ALLOC_MUTEX(SgUpcLocalsizeofExpression, unlock);
  156490             :       return object;
  156491             :     }
  156492             : #endif
  156493             : 
  156494           0 :     if (SgUpcLocalsizeofExpression::next_node == nullptr) {
  156495           0 :         SgUpcLocalsizeofExpression * alloc = (SgUpcLocalsizeofExpression*) ROSE_MALLOC ( SgUpcLocalsizeofExpression::pool_size * sizeof(SgUpcLocalsizeofExpression) );
  156496           0 :         ROSE_ASSERT(alloc != nullptr);
  156497             : 
  156498             : #if ROSE_ALLOC_TRACE == 2
  156499             : //        printf("SgUpcLocalsizeofExpression::alloc\n  block[%zi] = [ %p , %p [\n", SgUpcLocalsizeofExpression::pools.size(), alloc, alloc + SgUpcLocalsizeofExpression::pool_size);
  156500             : #endif
  156501             : 
  156502             : #if ROSE_ALLOC_MEMSET == 1
  156503             : #elif ROSE_ALLOC_MEMSET == 2
  156504             :         memset(alloc, 0x00, SgUpcLocalsizeofExpression::pool_size * sizeof(SgUpcLocalsizeofExpression));
  156505             : #elif ROSE_ALLOC_MEMSET == 3
  156506             :         memset(alloc, 0xAA, SgUpcLocalsizeofExpression::pool_size * sizeof(SgUpcLocalsizeofExpression));
  156507             : #endif
  156508           0 :         for (unsigned i=0; i < SgUpcLocalsizeofExpression::pool_size-1; i++) {
  156509           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
  156510             :         }
  156511           0 :         alloc[SgUpcLocalsizeofExpression::pool_size-1].p_freepointer = nullptr;
  156512             : 
  156513           0 :         SgUpcLocalsizeofExpression::pools.push_back ( (unsigned char *) alloc );
  156514           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgUpcLocalsizeofExpression::pool_size * sizeof(SgUpcLocalsizeofExpression), V_SgUpcLocalsizeofExpression ) );
  156515           0 :         SgUpcLocalsizeofExpression::next_node = alloc;
  156516             :     }
  156517           0 :     ROSE_ASSERT(SgUpcLocalsizeofExpression::next_node != nullptr);
  156518             : 
  156519           0 :     SgUpcLocalsizeofExpression * object = SgUpcLocalsizeofExpression::next_node;
  156520           0 :     SgUpcLocalsizeofExpression::next_node = (SgUpcLocalsizeofExpression*)(object->p_freepointer);
  156521             : 
  156522             : #if ROSE_ALLOC_TRACE == 2
  156523             :     printf("SgUpcLocalsizeofExpression::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUpcLocalsizeofExpression::next_node);
  156524             : #endif
  156525             : 
  156526           0 :     SgNode * fp = object->p_freepointer;
  156527             : #if ROSE_ALLOC_MEMSET == 1
  156528             : #elif ROSE_ALLOC_MEMSET == 2
  156529             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgUpcLocalsizeofExpression) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  156530             : #elif ROSE_ALLOC_MEMSET == 3
  156531             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgUpcLocalsizeofExpression) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  156532             : #endif
  156533           0 :     object->p_freepointer = fp;
  156534             : 
  156535             : #if ROSE_ALLOC_TRACE == 2
  156536             : //    printf("SgUpcLocalsizeofExpression::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUpcLocalsizeofExpression::next_node);
  156537             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  156538             :     Rose::MemPool::snapshot(oss.str());
  156539             :     alloc_trace_cnt++;
  156540             : #endif
  156541             : 
  156542           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  156543             : 
  156544           0 :     ALLOC_MUTEX(SgUpcLocalsizeofExpression, unlock);
  156545             : 
  156546             :     return object;
  156547             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  156548             : }
  156549             : 
  156550             : 
  156551             : 
  156552             : /*! \brief Delete operator for SgUpcLocalsizeofExpression.
  156553             : 
  156554             :    This delete operator implements deallocation using memory pools to 
  156555             :    provide most efficent use of the heap within construction of large ASTs.
  156556             : 
  156557             : \internal The new and delete operators use the lower level C malloc/free
  156558             :    function calls for performance and to make sure that mixing of malloc/free
  156559             :    and new/delete by the used can be caught more readily.  This may change
  156560             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  156561             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  156562             :    deallocate memory allocated using ROSE_MALLOC.
  156563             : */
  156564           0 : void SgUpcLocalsizeofExpression::operator delete(void *Pointer, size_t Size)
  156565             : {
  156566             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  156567             :      * or throwing an exception. */
  156568           0 :     ALLOC_MUTEX(SgUpcLocalsizeofExpression, lock);
  156569             : 
  156570             : #if USE_CPP_NEW_DELETE_OPERATORS
  156571             :     ROSE_FREE(Pointer);
  156572             : #else
  156573             : #if ROSE_PEDANTIC_ALLOC
  156574             :     ROSE_ASSERT(Size == sizeof(SgUpcLocalsizeofExpression));
  156575             : #else
  156576           0 :     if (Size != sizeof(SgUpcLocalsizeofExpression)) {
  156577           0 :       ROSE_FREE(Pointer);
  156578           0 :       ALLOC_MUTEX(SgUpcLocalsizeofExpression, unlock);
  156579             :       return;
  156580             :     }
  156581             : #endif
  156582             : 
  156583           0 :     SgUpcLocalsizeofExpression * object = (SgUpcLocalsizeofExpression*) Pointer;
  156584           0 :     ROSE_ASSERT(object != nullptr);
  156585             : 
  156586             : #if ROSE_ALLOC_TRACE == 2
  156587             : //  printf("SgUpcLocalsizeofExpression::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUpcLocalsizeofExpression::next_node);
  156588             :     printf("SgUpcLocalsizeofExpression::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUpcLocalsizeofExpression::next_node);
  156589             : #endif
  156590             : 
  156591             : #if ROSE_PEDANTIC_ALLOC
  156592             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  156593             : #endif
  156594             : 
  156595             : #if ROSE_ALLOC_MEMSET == 1
  156596             : #elif ROSE_ALLOC_MEMSET == 2
  156597             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgUpcLocalsizeofExpression) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  156598             : #elif ROSE_ALLOC_MEMSET == 3
  156599             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgUpcLocalsizeofExpression) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  156600             : #endif
  156601             : 
  156602             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  156603             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  156604             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  156605             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  156606             : #else
  156607           0 :     object->p_freepointer = SgUpcLocalsizeofExpression::next_node;
  156608           0 :     SgUpcLocalsizeofExpression::next_node = object;
  156609             : #endif
  156610             : 
  156611             : #if ROSE_ALLOC_TRACE == 2
  156612             : //  printf("SgUpcLocalsizeofExpression::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUpcLocalsizeofExpression::next_node);
  156613             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  156614             :     Rose::MemPool::snapshot(oss.str());
  156615             :     alloc_trace_cnt++;
  156616             : #endif
  156617             : 
  156618             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  156619             : 
  156620           0 :     ALLOC_MUTEX(SgUpcLocalsizeofExpression, unlock);
  156621             : }
  156622             : 
  156623             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  156624             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  156625             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  156626             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  156627             : // Also, note comment below from Robb (copied from the Common.code file).
  156628             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  156629             : //
  156630             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  156631             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  156632             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  156633             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  156634             : #if 0
  156635             : void SgUpcLocalsizeofExpression::operator delete(void* pointer) { SgUpcLocalsizeofExpression::operator delete (pointer, sizeof(SgUpcLocalsizeofExpression)); };
  156636             : #endif
  156637             : /* #line 156638 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  156638             : 
  156639             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  156640             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  156641             : // obviously imply C++.
  156642             : 
  156643             : // This implements the support within ROSE for memory pools.  Memory pools
  156644             : // support the most condensed usage of memory within the construction of
  156645             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  156646             : // by a new operator written for each class.
  156647             : 
  156648             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  156649             :     // User wants multi-thread support and POSIX threads are available.
  156650             : #   include <pthread.h>
  156651             :     static pthread_mutex_t SgUpcBlocksizeofExpression_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  156652             : #else
  156653             :      // Cause synchronization to be skipped.
  156654             : #    ifndef ALLOC_MUTEX
  156655             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  156656             : #    endif
  156657             : #    ifdef _REENTRANT
  156658             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  156659             : #       ifdef _MSC_VER
  156660             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  156661             : #       else
  156662             : #           warning "POSIX threads are not available; synchronization being skipped"
  156663             : #       endif
  156664             : #    endif
  156665             : #endif
  156666             : 
  156667             : #ifndef ROSE_ALLOC_TRACE
  156668             : #  define ROSE_ALLOC_TRACE 0
  156669             : #endif
  156670             : 
  156671             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  156672             : #define ROSE_ALLOC_TRACE_CNT
  156673             : #include "memory-pool-snapshot.h"
  156674             : unsigned long alloc_trace_cnt = 0;
  156675             : #endif
  156676             : 
  156677             : #if ROSE_ALLOC_TRACE
  156678             : const unsigned SgUpcBlocksizeofExpression::pool_size = 5;
  156679             : #else
  156680             : const unsigned SgUpcBlocksizeofExpression::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  156681             : #endif
  156682             : 
  156683             : #ifndef ROSE_ALLOC_MEMSET
  156684             : #  define ROSE_ALLOC_MEMSET 0
  156685             : #endif
  156686             : 
  156687             : #ifndef ROSE_PEDANTIC_ALLOC
  156688             : #  define ROSE_PEDANTIC_ALLOC 0
  156689             : #endif
  156690             : 
  156691             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  156692             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  156693             : #endif
  156694             : 
  156695             : #if !defined(SGNODE__ALL_POOLS)
  156696             : #define SGNODE__ALL_POOLS
  156697             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  156698             : #endif
  156699             : 
  156700             : SgUpcBlocksizeofExpression* SgUpcBlocksizeofExpression::next_node = nullptr;
  156701             : std::vector<unsigned char*> SgUpcBlocksizeofExpression::pools;
  156702             : 
  156703             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  156704             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  156705             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  156706             : // around this macro definition rather than each use).
  156707             : #ifndef ALLOC_MUTEX
  156708             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  156709             :         do {                                                                     \
  156710             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  156711             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  156712             :                 abort();                                                         \
  156713             :             }                                                                    \
  156714             :         } while (0);
  156715             : #endif
  156716             : 
  156717             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  156718             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  156719             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  156720             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  156721             : 
  156722             : /*! \brief New operator for SgUpcBlocksizeofExpression.
  156723             : 
  156724             :    This new operator implements memory pools to provide most efficent 
  156725             :    use of the heap within construction of large ASTs.
  156726             : 
  156727             : \internal The new and delete operators use the lower level C malloc/free
  156728             :    function calls for performance and to make sure that mixing of malloc/free
  156729             :    and new/delete by the used can be caught more readily.  This may change
  156730             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  156731             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  156732             :    deallocate memory allocated using ROSE_MALLOC.
  156733             : */
  156734           0 : void *SgUpcBlocksizeofExpression::operator new ( size_t Size )
  156735             : {
  156736             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  156737             :      * returning or throwing an exception. */
  156738           0 :     ALLOC_MUTEX(SgUpcBlocksizeofExpression, lock);
  156739             : 
  156740             : #if ROSE_ALLOC_TRACE == 2
  156741             : //    printf("SgUpcBlocksizeofExpression::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgUpcBlocksizeofExpression::next_node);
  156742             : #endif
  156743             : 
  156744             : #if USE_CPP_NEW_DELETE_OPERATORS
  156745             :     void *mem = ROSE_MALLOC(Size);
  156746             :     ALLOC_MUTEX(SgUpcBlocksizeofExpression, unlock);
  156747             :     return mem;
  156748             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  156749             : #if ROSE_PEDANTIC_ALLOC
  156750             :     ROSE_ASSERT(Size == sizeof(SgUpcBlocksizeofExpression));
  156751             : #else
  156752           0 :     if (Size != sizeof(SgUpcBlocksizeofExpression)) {
  156753           0 :       void * object = ROSE_MALLOC(Size);
  156754           0 :       ALLOC_MUTEX(SgUpcBlocksizeofExpression, unlock);
  156755             :       return object;
  156756             :     }
  156757             : #endif
  156758             : 
  156759           0 :     if (SgUpcBlocksizeofExpression::next_node == nullptr) {
  156760           0 :         SgUpcBlocksizeofExpression * alloc = (SgUpcBlocksizeofExpression*) ROSE_MALLOC ( SgUpcBlocksizeofExpression::pool_size * sizeof(SgUpcBlocksizeofExpression) );
  156761           0 :         ROSE_ASSERT(alloc != nullptr);
  156762             : 
  156763             : #if ROSE_ALLOC_TRACE == 2
  156764             : //        printf("SgUpcBlocksizeofExpression::alloc\n  block[%zi] = [ %p , %p [\n", SgUpcBlocksizeofExpression::pools.size(), alloc, alloc + SgUpcBlocksizeofExpression::pool_size);
  156765             : #endif
  156766             : 
  156767             : #if ROSE_ALLOC_MEMSET == 1
  156768             : #elif ROSE_ALLOC_MEMSET == 2
  156769             :         memset(alloc, 0x00, SgUpcBlocksizeofExpression::pool_size * sizeof(SgUpcBlocksizeofExpression));
  156770             : #elif ROSE_ALLOC_MEMSET == 3
  156771             :         memset(alloc, 0xAA, SgUpcBlocksizeofExpression::pool_size * sizeof(SgUpcBlocksizeofExpression));
  156772             : #endif
  156773           0 :         for (unsigned i=0; i < SgUpcBlocksizeofExpression::pool_size-1; i++) {
  156774           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
  156775             :         }
  156776           0 :         alloc[SgUpcBlocksizeofExpression::pool_size-1].p_freepointer = nullptr;
  156777             : 
  156778           0 :         SgUpcBlocksizeofExpression::pools.push_back ( (unsigned char *) alloc );
  156779           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgUpcBlocksizeofExpression::pool_size * sizeof(SgUpcBlocksizeofExpression), V_SgUpcBlocksizeofExpression ) );
  156780           0 :         SgUpcBlocksizeofExpression::next_node = alloc;
  156781             :     }
  156782           0 :     ROSE_ASSERT(SgUpcBlocksizeofExpression::next_node != nullptr);
  156783             : 
  156784           0 :     SgUpcBlocksizeofExpression * object = SgUpcBlocksizeofExpression::next_node;
  156785           0 :     SgUpcBlocksizeofExpression::next_node = (SgUpcBlocksizeofExpression*)(object->p_freepointer);
  156786             : 
  156787             : #if ROSE_ALLOC_TRACE == 2
  156788             :     printf("SgUpcBlocksizeofExpression::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUpcBlocksizeofExpression::next_node);
  156789             : #endif
  156790             : 
  156791           0 :     SgNode * fp = object->p_freepointer;
  156792             : #if ROSE_ALLOC_MEMSET == 1
  156793             : #elif ROSE_ALLOC_MEMSET == 2
  156794             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgUpcBlocksizeofExpression) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  156795             : #elif ROSE_ALLOC_MEMSET == 3
  156796             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgUpcBlocksizeofExpression) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  156797             : #endif
  156798           0 :     object->p_freepointer = fp;
  156799             : 
  156800             : #if ROSE_ALLOC_TRACE == 2
  156801             : //    printf("SgUpcBlocksizeofExpression::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUpcBlocksizeofExpression::next_node);
  156802             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  156803             :     Rose::MemPool::snapshot(oss.str());
  156804             :     alloc_trace_cnt++;
  156805             : #endif
  156806             : 
  156807           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  156808             : 
  156809           0 :     ALLOC_MUTEX(SgUpcBlocksizeofExpression, unlock);
  156810             : 
  156811             :     return object;
  156812             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  156813             : }
  156814             : 
  156815             : 
  156816             : 
  156817             : /*! \brief Delete operator for SgUpcBlocksizeofExpression.
  156818             : 
  156819             :    This delete operator implements deallocation using memory pools to 
  156820             :    provide most efficent use of the heap within construction of large ASTs.
  156821             : 
  156822             : \internal The new and delete operators use the lower level C malloc/free
  156823             :    function calls for performance and to make sure that mixing of malloc/free
  156824             :    and new/delete by the used can be caught more readily.  This may change
  156825             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  156826             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  156827             :    deallocate memory allocated using ROSE_MALLOC.
  156828             : */
  156829           0 : void SgUpcBlocksizeofExpression::operator delete(void *Pointer, size_t Size)
  156830             : {
  156831             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  156832             :      * or throwing an exception. */
  156833           0 :     ALLOC_MUTEX(SgUpcBlocksizeofExpression, lock);
  156834             : 
  156835             : #if USE_CPP_NEW_DELETE_OPERATORS
  156836             :     ROSE_FREE(Pointer);
  156837             : #else
  156838             : #if ROSE_PEDANTIC_ALLOC
  156839             :     ROSE_ASSERT(Size == sizeof(SgUpcBlocksizeofExpression));
  156840             : #else
  156841           0 :     if (Size != sizeof(SgUpcBlocksizeofExpression)) {
  156842           0 :       ROSE_FREE(Pointer);
  156843           0 :       ALLOC_MUTEX(SgUpcBlocksizeofExpression, unlock);
  156844             :       return;
  156845             :     }
  156846             : #endif
  156847             : 
  156848           0 :     SgUpcBlocksizeofExpression * object = (SgUpcBlocksizeofExpression*) Pointer;
  156849           0 :     ROSE_ASSERT(object != nullptr);
  156850             : 
  156851             : #if ROSE_ALLOC_TRACE == 2
  156852             : //  printf("SgUpcBlocksizeofExpression::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUpcBlocksizeofExpression::next_node);
  156853             :     printf("SgUpcBlocksizeofExpression::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUpcBlocksizeofExpression::next_node);
  156854             : #endif
  156855             : 
  156856             : #if ROSE_PEDANTIC_ALLOC
  156857             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  156858             : #endif
  156859             : 
  156860             : #if ROSE_ALLOC_MEMSET == 1
  156861             : #elif ROSE_ALLOC_MEMSET == 2
  156862             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgUpcBlocksizeofExpression) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  156863             : #elif ROSE_ALLOC_MEMSET == 3
  156864             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgUpcBlocksizeofExpression) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  156865             : #endif
  156866             : 
  156867             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  156868             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  156869             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  156870             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  156871             : #else
  156872           0 :     object->p_freepointer = SgUpcBlocksizeofExpression::next_node;
  156873           0 :     SgUpcBlocksizeofExpression::next_node = object;
  156874             : #endif
  156875             : 
  156876             : #if ROSE_ALLOC_TRACE == 2
  156877             : //  printf("SgUpcBlocksizeofExpression::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUpcBlocksizeofExpression::next_node);
  156878             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  156879             :     Rose::MemPool::snapshot(oss.str());
  156880             :     alloc_trace_cnt++;
  156881             : #endif
  156882             : 
  156883             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  156884             : 
  156885           0 :     ALLOC_MUTEX(SgUpcBlocksizeofExpression, unlock);
  156886             : }
  156887             : 
  156888             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  156889             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  156890             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  156891             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  156892             : // Also, note comment below from Robb (copied from the Common.code file).
  156893             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  156894             : //
  156895             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  156896             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  156897             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  156898             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  156899             : #if 0
  156900             : void SgUpcBlocksizeofExpression::operator delete(void* pointer) { SgUpcBlocksizeofExpression::operator delete (pointer, sizeof(SgUpcBlocksizeofExpression)); };
  156901             : #endif
  156902             : /* #line 156903 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  156903             : 
  156904             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  156905             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  156906             : // obviously imply C++.
  156907             : 
  156908             : // This implements the support within ROSE for memory pools.  Memory pools
  156909             : // support the most condensed usage of memory within the construction of
  156910             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  156911             : // by a new operator written for each class.
  156912             : 
  156913             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  156914             :     // User wants multi-thread support and POSIX threads are available.
  156915             : #   include <pthread.h>
  156916             :     static pthread_mutex_t SgUpcElemsizeofExpression_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  156917             : #else
  156918             :      // Cause synchronization to be skipped.
  156919             : #    ifndef ALLOC_MUTEX
  156920             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  156921             : #    endif
  156922             : #    ifdef _REENTRANT
  156923             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  156924             : #       ifdef _MSC_VER
  156925             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  156926             : #       else
  156927             : #           warning "POSIX threads are not available; synchronization being skipped"
  156928             : #       endif
  156929             : #    endif
  156930             : #endif
  156931             : 
  156932             : #ifndef ROSE_ALLOC_TRACE
  156933             : #  define ROSE_ALLOC_TRACE 0
  156934             : #endif
  156935             : 
  156936             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  156937             : #define ROSE_ALLOC_TRACE_CNT
  156938             : #include "memory-pool-snapshot.h"
  156939             : unsigned long alloc_trace_cnt = 0;
  156940             : #endif
  156941             : 
  156942             : #if ROSE_ALLOC_TRACE
  156943             : const unsigned SgUpcElemsizeofExpression::pool_size = 5;
  156944             : #else
  156945             : const unsigned SgUpcElemsizeofExpression::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  156946             : #endif
  156947             : 
  156948             : #ifndef ROSE_ALLOC_MEMSET
  156949             : #  define ROSE_ALLOC_MEMSET 0
  156950             : #endif
  156951             : 
  156952             : #ifndef ROSE_PEDANTIC_ALLOC
  156953             : #  define ROSE_PEDANTIC_ALLOC 0
  156954             : #endif
  156955             : 
  156956             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  156957             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  156958             : #endif
  156959             : 
  156960             : #if !defined(SGNODE__ALL_POOLS)
  156961             : #define SGNODE__ALL_POOLS
  156962             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  156963             : #endif
  156964             : 
  156965             : SgUpcElemsizeofExpression* SgUpcElemsizeofExpression::next_node = nullptr;
  156966             : std::vector<unsigned char*> SgUpcElemsizeofExpression::pools;
  156967             : 
  156968             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  156969             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  156970             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  156971             : // around this macro definition rather than each use).
  156972             : #ifndef ALLOC_MUTEX
  156973             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  156974             :         do {                                                                     \
  156975             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  156976             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  156977             :                 abort();                                                         \
  156978             :             }                                                                    \
  156979             :         } while (0);
  156980             : #endif
  156981             : 
  156982             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  156983             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  156984             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  156985             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  156986             : 
  156987             : /*! \brief New operator for SgUpcElemsizeofExpression.
  156988             : 
  156989             :    This new operator implements memory pools to provide most efficent 
  156990             :    use of the heap within construction of large ASTs.
  156991             : 
  156992             : \internal The new and delete operators use the lower level C malloc/free
  156993             :    function calls for performance and to make sure that mixing of malloc/free
  156994             :    and new/delete by the used can be caught more readily.  This may change
  156995             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  156996             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  156997             :    deallocate memory allocated using ROSE_MALLOC.
  156998             : */
  156999           0 : void *SgUpcElemsizeofExpression::operator new ( size_t Size )
  157000             : {
  157001             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  157002             :      * returning or throwing an exception. */
  157003           0 :     ALLOC_MUTEX(SgUpcElemsizeofExpression, lock);
  157004             : 
  157005             : #if ROSE_ALLOC_TRACE == 2
  157006             : //    printf("SgUpcElemsizeofExpression::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgUpcElemsizeofExpression::next_node);
  157007             : #endif
  157008             : 
  157009             : #if USE_CPP_NEW_DELETE_OPERATORS
  157010             :     void *mem = ROSE_MALLOC(Size);
  157011             :     ALLOC_MUTEX(SgUpcElemsizeofExpression, unlock);
  157012             :     return mem;
  157013             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  157014             : #if ROSE_PEDANTIC_ALLOC
  157015             :     ROSE_ASSERT(Size == sizeof(SgUpcElemsizeofExpression));
  157016             : #else
  157017           0 :     if (Size != sizeof(SgUpcElemsizeofExpression)) {
  157018           0 :       void * object = ROSE_MALLOC(Size);
  157019           0 :       ALLOC_MUTEX(SgUpcElemsizeofExpression, unlock);
  157020             :       return object;
  157021             :     }
  157022             : #endif
  157023             : 
  157024           0 :     if (SgUpcElemsizeofExpression::next_node == nullptr) {
  157025           0 :         SgUpcElemsizeofExpression * alloc = (SgUpcElemsizeofExpression*) ROSE_MALLOC ( SgUpcElemsizeofExpression::pool_size * sizeof(SgUpcElemsizeofExpression) );
  157026           0 :         ROSE_ASSERT(alloc != nullptr);
  157027             : 
  157028             : #if ROSE_ALLOC_TRACE == 2
  157029             : //        printf("SgUpcElemsizeofExpression::alloc\n  block[%zi] = [ %p , %p [\n", SgUpcElemsizeofExpression::pools.size(), alloc, alloc + SgUpcElemsizeofExpression::pool_size);
  157030             : #endif
  157031             : 
  157032             : #if ROSE_ALLOC_MEMSET == 1
  157033             : #elif ROSE_ALLOC_MEMSET == 2
  157034             :         memset(alloc, 0x00, SgUpcElemsizeofExpression::pool_size * sizeof(SgUpcElemsizeofExpression));
  157035             : #elif ROSE_ALLOC_MEMSET == 3
  157036             :         memset(alloc, 0xAA, SgUpcElemsizeofExpression::pool_size * sizeof(SgUpcElemsizeofExpression));
  157037             : #endif
  157038           0 :         for (unsigned i=0; i < SgUpcElemsizeofExpression::pool_size-1; i++) {
  157039           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
  157040             :         }
  157041           0 :         alloc[SgUpcElemsizeofExpression::pool_size-1].p_freepointer = nullptr;
  157042             : 
  157043           0 :         SgUpcElemsizeofExpression::pools.push_back ( (unsigned char *) alloc );
  157044           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgUpcElemsizeofExpression::pool_size * sizeof(SgUpcElemsizeofExpression), V_SgUpcElemsizeofExpression ) );
  157045           0 :         SgUpcElemsizeofExpression::next_node = alloc;
  157046             :     }
  157047           0 :     ROSE_ASSERT(SgUpcElemsizeofExpression::next_node != nullptr);
  157048             : 
  157049           0 :     SgUpcElemsizeofExpression * object = SgUpcElemsizeofExpression::next_node;
  157050           0 :     SgUpcElemsizeofExpression::next_node = (SgUpcElemsizeofExpression*)(object->p_freepointer);
  157051             : 
  157052             : #if ROSE_ALLOC_TRACE == 2
  157053             :     printf("SgUpcElemsizeofExpression::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUpcElemsizeofExpression::next_node);
  157054             : #endif
  157055             : 
  157056           0 :     SgNode * fp = object->p_freepointer;
  157057             : #if ROSE_ALLOC_MEMSET == 1
  157058             : #elif ROSE_ALLOC_MEMSET == 2
  157059             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgUpcElemsizeofExpression) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  157060             : #elif ROSE_ALLOC_MEMSET == 3
  157061             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgUpcElemsizeofExpression) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  157062             : #endif
  157063           0 :     object->p_freepointer = fp;
  157064             : 
  157065             : #if ROSE_ALLOC_TRACE == 2
  157066             : //    printf("SgUpcElemsizeofExpression::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUpcElemsizeofExpression::next_node);
  157067             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  157068             :     Rose::MemPool::snapshot(oss.str());
  157069             :     alloc_trace_cnt++;
  157070             : #endif
  157071             : 
  157072           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  157073             : 
  157074           0 :     ALLOC_MUTEX(SgUpcElemsizeofExpression, unlock);
  157075             : 
  157076             :     return object;
  157077             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  157078             : }
  157079             : 
  157080             : 
  157081             : 
  157082             : /*! \brief Delete operator for SgUpcElemsizeofExpression.
  157083             : 
  157084             :    This delete operator implements deallocation using memory pools to 
  157085             :    provide most efficent use of the heap within construction of large ASTs.
  157086             : 
  157087             : \internal The new and delete operators use the lower level C malloc/free
  157088             :    function calls for performance and to make sure that mixing of malloc/free
  157089             :    and new/delete by the used can be caught more readily.  This may change
  157090             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  157091             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  157092             :    deallocate memory allocated using ROSE_MALLOC.
  157093             : */
  157094           0 : void SgUpcElemsizeofExpression::operator delete(void *Pointer, size_t Size)
  157095             : {
  157096             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  157097             :      * or throwing an exception. */
  157098           0 :     ALLOC_MUTEX(SgUpcElemsizeofExpression, lock);
  157099             : 
  157100             : #if USE_CPP_NEW_DELETE_OPERATORS
  157101             :     ROSE_FREE(Pointer);
  157102             : #else
  157103             : #if ROSE_PEDANTIC_ALLOC
  157104             :     ROSE_ASSERT(Size == sizeof(SgUpcElemsizeofExpression));
  157105             : #else
  157106           0 :     if (Size != sizeof(SgUpcElemsizeofExpression)) {
  157107           0 :       ROSE_FREE(Pointer);
  157108           0 :       ALLOC_MUTEX(SgUpcElemsizeofExpression, unlock);
  157109             :       return;
  157110             :     }
  157111             : #endif
  157112             : 
  157113           0 :     SgUpcElemsizeofExpression * object = (SgUpcElemsizeofExpression*) Pointer;
  157114           0 :     ROSE_ASSERT(object != nullptr);
  157115             : 
  157116             : #if ROSE_ALLOC_TRACE == 2
  157117             : //  printf("SgUpcElemsizeofExpression::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUpcElemsizeofExpression::next_node);
  157118             :     printf("SgUpcElemsizeofExpression::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUpcElemsizeofExpression::next_node);
  157119             : #endif
  157120             : 
  157121             : #if ROSE_PEDANTIC_ALLOC
  157122             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  157123             : #endif
  157124             : 
  157125             : #if ROSE_ALLOC_MEMSET == 1
  157126             : #elif ROSE_ALLOC_MEMSET == 2
  157127             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgUpcElemsizeofExpression) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  157128             : #elif ROSE_ALLOC_MEMSET == 3
  157129             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgUpcElemsizeofExpression) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  157130             : #endif
  157131             : 
  157132             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  157133             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  157134             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  157135             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  157136             : #else
  157137           0 :     object->p_freepointer = SgUpcElemsizeofExpression::next_node;
  157138           0 :     SgUpcElemsizeofExpression::next_node = object;
  157139             : #endif
  157140             : 
  157141             : #if ROSE_ALLOC_TRACE == 2
  157142             : //  printf("SgUpcElemsizeofExpression::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUpcElemsizeofExpression::next_node);
  157143             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  157144             :     Rose::MemPool::snapshot(oss.str());
  157145             :     alloc_trace_cnt++;
  157146             : #endif
  157147             : 
  157148             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  157149             : 
  157150           0 :     ALLOC_MUTEX(SgUpcElemsizeofExpression, unlock);
  157151             : }
  157152             : 
  157153             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  157154             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  157155             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  157156             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  157157             : // Also, note comment below from Robb (copied from the Common.code file).
  157158             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  157159             : //
  157160             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  157161             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  157162             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  157163             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  157164             : #if 0
  157165             : void SgUpcElemsizeofExpression::operator delete(void* pointer) { SgUpcElemsizeofExpression::operator delete (pointer, sizeof(SgUpcElemsizeofExpression)); };
  157166             : #endif
  157167             : /* #line 157168 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  157168             : 
  157169             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  157170             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  157171             : // obviously imply C++.
  157172             : 
  157173             : // This implements the support within ROSE for memory pools.  Memory pools
  157174             : // support the most condensed usage of memory within the construction of
  157175             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  157176             : // by a new operator written for each class.
  157177             : 
  157178             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  157179             :     // User wants multi-thread support and POSIX threads are available.
  157180             : #   include <pthread.h>
  157181             :     static pthread_mutex_t SgSuperExp_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  157182             : #else
  157183             :      // Cause synchronization to be skipped.
  157184             : #    ifndef ALLOC_MUTEX
  157185             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  157186             : #    endif
  157187             : #    ifdef _REENTRANT
  157188             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  157189             : #       ifdef _MSC_VER
  157190             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  157191             : #       else
  157192             : #           warning "POSIX threads are not available; synchronization being skipped"
  157193             : #       endif
  157194             : #    endif
  157195             : #endif
  157196             : 
  157197             : #ifndef ROSE_ALLOC_TRACE
  157198             : #  define ROSE_ALLOC_TRACE 0
  157199             : #endif
  157200             : 
  157201             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  157202             : #define ROSE_ALLOC_TRACE_CNT
  157203             : #include "memory-pool-snapshot.h"
  157204             : unsigned long alloc_trace_cnt = 0;
  157205             : #endif
  157206             : 
  157207             : #if ROSE_ALLOC_TRACE
  157208             : const unsigned SgSuperExp::pool_size = 5;
  157209             : #else
  157210             : const unsigned SgSuperExp::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  157211             : #endif
  157212             : 
  157213             : #ifndef ROSE_ALLOC_MEMSET
  157214             : #  define ROSE_ALLOC_MEMSET 0
  157215             : #endif
  157216             : 
  157217             : #ifndef ROSE_PEDANTIC_ALLOC
  157218             : #  define ROSE_PEDANTIC_ALLOC 0
  157219             : #endif
  157220             : 
  157221             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  157222             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  157223             : #endif
  157224             : 
  157225             : #if !defined(SGNODE__ALL_POOLS)
  157226             : #define SGNODE__ALL_POOLS
  157227             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  157228             : #endif
  157229             : 
  157230             : SgSuperExp* SgSuperExp::next_node = nullptr;
  157231             : std::vector<unsigned char*> SgSuperExp::pools;
  157232             : 
  157233             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  157234             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  157235             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  157236             : // around this macro definition rather than each use).
  157237             : #ifndef ALLOC_MUTEX
  157238             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  157239             :         do {                                                                     \
  157240             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  157241             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  157242             :                 abort();                                                         \
  157243             :             }                                                                    \
  157244             :         } while (0);
  157245             : #endif
  157246             : 
  157247             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  157248             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  157249             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  157250             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  157251             : 
  157252             : /*! \brief New operator for SgSuperExp.
  157253             : 
  157254             :    This new operator implements memory pools to provide most efficent 
  157255             :    use of the heap within construction of large ASTs.
  157256             : 
  157257             : \internal The new and delete operators use the lower level C malloc/free
  157258             :    function calls for performance and to make sure that mixing of malloc/free
  157259             :    and new/delete by the used can be caught more readily.  This may change
  157260             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  157261             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  157262             :    deallocate memory allocated using ROSE_MALLOC.
  157263             : */
  157264           0 : void *SgSuperExp::operator new ( size_t Size )
  157265             : {
  157266             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  157267             :      * returning or throwing an exception. */
  157268           0 :     ALLOC_MUTEX(SgSuperExp, lock);
  157269             : 
  157270             : #if ROSE_ALLOC_TRACE == 2
  157271             : //    printf("SgSuperExp::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgSuperExp::next_node);
  157272             : #endif
  157273             : 
  157274             : #if USE_CPP_NEW_DELETE_OPERATORS
  157275             :     void *mem = ROSE_MALLOC(Size);
  157276             :     ALLOC_MUTEX(SgSuperExp, unlock);
  157277             :     return mem;
  157278             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  157279             : #if ROSE_PEDANTIC_ALLOC
  157280             :     ROSE_ASSERT(Size == sizeof(SgSuperExp));
  157281             : #else
  157282           0 :     if (Size != sizeof(SgSuperExp)) {
  157283           0 :       void * object = ROSE_MALLOC(Size);
  157284           0 :       ALLOC_MUTEX(SgSuperExp, unlock);
  157285             :       return object;
  157286             :     }
  157287             : #endif
  157288             : 
  157289           0 :     if (SgSuperExp::next_node == nullptr) {
  157290           0 :         SgSuperExp * alloc = (SgSuperExp*) ROSE_MALLOC ( SgSuperExp::pool_size * sizeof(SgSuperExp) );
  157291           0 :         ROSE_ASSERT(alloc != nullptr);
  157292             : 
  157293             : #if ROSE_ALLOC_TRACE == 2
  157294             : //        printf("SgSuperExp::alloc\n  block[%zi] = [ %p , %p [\n", SgSuperExp::pools.size(), alloc, alloc + SgSuperExp::pool_size);
  157295             : #endif
  157296             : 
  157297             : #if ROSE_ALLOC_MEMSET == 1
  157298             : #elif ROSE_ALLOC_MEMSET == 2
  157299             :         memset(alloc, 0x00, SgSuperExp::pool_size * sizeof(SgSuperExp));
  157300             : #elif ROSE_ALLOC_MEMSET == 3
  157301             :         memset(alloc, 0xAA, SgSuperExp::pool_size * sizeof(SgSuperExp));
  157302             : #endif
  157303           0 :         for (unsigned i=0; i < SgSuperExp::pool_size-1; i++) {
  157304           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
  157305             :         }
  157306           0 :         alloc[SgSuperExp::pool_size-1].p_freepointer = nullptr;
  157307             : 
  157308           0 :         SgSuperExp::pools.push_back ( (unsigned char *) alloc );
  157309           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgSuperExp::pool_size * sizeof(SgSuperExp), V_SgSuperExp ) );
  157310           0 :         SgSuperExp::next_node = alloc;
  157311             :     }
  157312           0 :     ROSE_ASSERT(SgSuperExp::next_node != nullptr);
  157313             : 
  157314           0 :     SgSuperExp * object = SgSuperExp::next_node;
  157315           0 :     SgSuperExp::next_node = (SgSuperExp*)(object->p_freepointer);
  157316             : 
  157317             : #if ROSE_ALLOC_TRACE == 2
  157318             :     printf("SgSuperExp::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgSuperExp::next_node);
  157319             : #endif
  157320             : 
  157321           0 :     SgNode * fp = object->p_freepointer;
  157322             : #if ROSE_ALLOC_MEMSET == 1
  157323             : #elif ROSE_ALLOC_MEMSET == 2
  157324             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgSuperExp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  157325             : #elif ROSE_ALLOC_MEMSET == 3
  157326             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgSuperExp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  157327             : #endif
  157328           0 :     object->p_freepointer = fp;
  157329             : 
  157330             : #if ROSE_ALLOC_TRACE == 2
  157331             : //    printf("SgSuperExp::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgSuperExp::next_node);
  157332             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  157333             :     Rose::MemPool::snapshot(oss.str());
  157334             :     alloc_trace_cnt++;
  157335             : #endif
  157336             : 
  157337           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  157338             : 
  157339           0 :     ALLOC_MUTEX(SgSuperExp, unlock);
  157340             : 
  157341             :     return object;
  157342             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  157343             : }
  157344             : 
  157345             : 
  157346             : 
  157347             : /*! \brief Delete operator for SgSuperExp.
  157348             : 
  157349             :    This delete operator implements deallocation using memory pools to 
  157350             :    provide most efficent use of the heap within construction of large ASTs.
  157351             : 
  157352             : \internal The new and delete operators use the lower level C malloc/free
  157353             :    function calls for performance and to make sure that mixing of malloc/free
  157354             :    and new/delete by the used can be caught more readily.  This may change
  157355             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  157356             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  157357             :    deallocate memory allocated using ROSE_MALLOC.
  157358             : */
  157359           0 : void SgSuperExp::operator delete(void *Pointer, size_t Size)
  157360             : {
  157361             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  157362             :      * or throwing an exception. */
  157363           0 :     ALLOC_MUTEX(SgSuperExp, lock);
  157364             : 
  157365             : #if USE_CPP_NEW_DELETE_OPERATORS
  157366             :     ROSE_FREE(Pointer);
  157367             : #else
  157368             : #if ROSE_PEDANTIC_ALLOC
  157369             :     ROSE_ASSERT(Size == sizeof(SgSuperExp));
  157370             : #else
  157371           0 :     if (Size != sizeof(SgSuperExp)) {
  157372           0 :       ROSE_FREE(Pointer);
  157373           0 :       ALLOC_MUTEX(SgSuperExp, unlock);
  157374             :       return;
  157375             :     }
  157376             : #endif
  157377             : 
  157378           0 :     SgSuperExp * object = (SgSuperExp*) Pointer;
  157379           0 :     ROSE_ASSERT(object != nullptr);
  157380             : 
  157381             : #if ROSE_ALLOC_TRACE == 2
  157382             : //  printf("SgSuperExp::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgSuperExp::next_node);
  157383             :     printf("SgSuperExp::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgSuperExp::next_node);
  157384             : #endif
  157385             : 
  157386             : #if ROSE_PEDANTIC_ALLOC
  157387             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  157388             : #endif
  157389             : 
  157390             : #if ROSE_ALLOC_MEMSET == 1
  157391             : #elif ROSE_ALLOC_MEMSET == 2
  157392             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgSuperExp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  157393             : #elif ROSE_ALLOC_MEMSET == 3
  157394             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgSuperExp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  157395             : #endif
  157396             : 
  157397             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  157398             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  157399             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  157400             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  157401             : #else
  157402           0 :     object->p_freepointer = SgSuperExp::next_node;
  157403           0 :     SgSuperExp::next_node = object;
  157404             : #endif
  157405             : 
  157406             : #if ROSE_ALLOC_TRACE == 2
  157407             : //  printf("SgSuperExp::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgSuperExp::next_node);
  157408             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  157409             :     Rose::MemPool::snapshot(oss.str());
  157410             :     alloc_trace_cnt++;
  157411             : #endif
  157412             : 
  157413             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  157414             : 
  157415           0 :     ALLOC_MUTEX(SgSuperExp, unlock);
  157416             : }
  157417             : 
  157418             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  157419             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  157420             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  157421             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  157422             : // Also, note comment below from Robb (copied from the Common.code file).
  157423             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  157424             : //
  157425             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  157426             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  157427             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  157428             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  157429             : #if 0
  157430             : void SgSuperExp::operator delete(void* pointer) { SgSuperExp::operator delete (pointer, sizeof(SgSuperExp)); };
  157431             : #endif
  157432             : /* #line 157433 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  157433             : 
  157434             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  157435             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  157436             : // obviously imply C++.
  157437             : 
  157438             : // This implements the support within ROSE for memory pools.  Memory pools
  157439             : // support the most condensed usage of memory within the construction of
  157440             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  157441             : // by a new operator written for each class.
  157442             : 
  157443             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  157444             :     // User wants multi-thread support and POSIX threads are available.
  157445             : #   include <pthread.h>
  157446             :     static pthread_mutex_t SgTypeIdOp_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  157447             : #else
  157448             :      // Cause synchronization to be skipped.
  157449             : #    ifndef ALLOC_MUTEX
  157450             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  157451             : #    endif
  157452             : #    ifdef _REENTRANT
  157453             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  157454             : #       ifdef _MSC_VER
  157455             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  157456             : #       else
  157457             : #           warning "POSIX threads are not available; synchronization being skipped"
  157458             : #       endif
  157459             : #    endif
  157460             : #endif
  157461             : 
  157462             : #ifndef ROSE_ALLOC_TRACE
  157463             : #  define ROSE_ALLOC_TRACE 0
  157464             : #endif
  157465             : 
  157466             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  157467             : #define ROSE_ALLOC_TRACE_CNT
  157468             : #include "memory-pool-snapshot.h"
  157469             : unsigned long alloc_trace_cnt = 0;
  157470             : #endif
  157471             : 
  157472             : #if ROSE_ALLOC_TRACE
  157473             : const unsigned SgTypeIdOp::pool_size = 5;
  157474             : #else
  157475             : const unsigned SgTypeIdOp::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  157476             : #endif
  157477             : 
  157478             : #ifndef ROSE_ALLOC_MEMSET
  157479             : #  define ROSE_ALLOC_MEMSET 0
  157480             : #endif
  157481             : 
  157482             : #ifndef ROSE_PEDANTIC_ALLOC
  157483             : #  define ROSE_PEDANTIC_ALLOC 0
  157484             : #endif
  157485             : 
  157486             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  157487             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  157488             : #endif
  157489             : 
  157490             : #if !defined(SGNODE__ALL_POOLS)
  157491             : #define SGNODE__ALL_POOLS
  157492             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  157493             : #endif
  157494             : 
  157495             : SgTypeIdOp* SgTypeIdOp::next_node = nullptr;
  157496             : std::vector<unsigned char*> SgTypeIdOp::pools;
  157497             : 
  157498             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  157499             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  157500             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  157501             : // around this macro definition rather than each use).
  157502             : #ifndef ALLOC_MUTEX
  157503             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  157504             :         do {                                                                     \
  157505             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  157506             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  157507             :                 abort();                                                         \
  157508             :             }                                                                    \
  157509             :         } while (0);
  157510             : #endif
  157511             : 
  157512             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  157513             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  157514             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  157515             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  157516             : 
  157517             : /*! \brief New operator for SgTypeIdOp.
  157518             : 
  157519             :    This new operator implements memory pools to provide most efficent 
  157520             :    use of the heap within construction of large ASTs.
  157521             : 
  157522             : \internal The new and delete operators use the lower level C malloc/free
  157523             :    function calls for performance and to make sure that mixing of malloc/free
  157524             :    and new/delete by the used can be caught more readily.  This may change
  157525             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  157526             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  157527             :    deallocate memory allocated using ROSE_MALLOC.
  157528             : */
  157529          11 : void *SgTypeIdOp::operator new ( size_t Size )
  157530             : {
  157531             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  157532             :      * returning or throwing an exception. */
  157533          11 :     ALLOC_MUTEX(SgTypeIdOp, lock);
  157534             : 
  157535             : #if ROSE_ALLOC_TRACE == 2
  157536             : //    printf("SgTypeIdOp::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgTypeIdOp::next_node);
  157537             : #endif
  157538             : 
  157539             : #if USE_CPP_NEW_DELETE_OPERATORS
  157540             :     void *mem = ROSE_MALLOC(Size);
  157541             :     ALLOC_MUTEX(SgTypeIdOp, unlock);
  157542             :     return mem;
  157543             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  157544             : #if ROSE_PEDANTIC_ALLOC
  157545             :     ROSE_ASSERT(Size == sizeof(SgTypeIdOp));
  157546             : #else
  157547          11 :     if (Size != sizeof(SgTypeIdOp)) {
  157548           0 :       void * object = ROSE_MALLOC(Size);
  157549           0 :       ALLOC_MUTEX(SgTypeIdOp, unlock);
  157550             :       return object;
  157551             :     }
  157552             : #endif
  157553             : 
  157554          11 :     if (SgTypeIdOp::next_node == nullptr) {
  157555          10 :         SgTypeIdOp * alloc = (SgTypeIdOp*) ROSE_MALLOC ( SgTypeIdOp::pool_size * sizeof(SgTypeIdOp) );
  157556          10 :         ROSE_ASSERT(alloc != nullptr);
  157557             : 
  157558             : #if ROSE_ALLOC_TRACE == 2
  157559             : //        printf("SgTypeIdOp::alloc\n  block[%zi] = [ %p , %p [\n", SgTypeIdOp::pools.size(), alloc, alloc + SgTypeIdOp::pool_size);
  157560             : #endif
  157561             : 
  157562             : #if ROSE_ALLOC_MEMSET == 1
  157563             : #elif ROSE_ALLOC_MEMSET == 2
  157564             :         memset(alloc, 0x00, SgTypeIdOp::pool_size * sizeof(SgTypeIdOp));
  157565             : #elif ROSE_ALLOC_MEMSET == 3
  157566             :         memset(alloc, 0xAA, SgTypeIdOp::pool_size * sizeof(SgTypeIdOp));
  157567             : #endif
  157568       20000 :         for (unsigned i=0; i < SgTypeIdOp::pool_size-1; i++) {
  157569       19990 :           alloc[i].p_freepointer = &(alloc[i+1]);
  157570             :         }
  157571          10 :         alloc[SgTypeIdOp::pool_size-1].p_freepointer = nullptr;
  157572             : 
  157573          10 :         SgTypeIdOp::pools.push_back ( (unsigned char *) alloc );
  157574          10 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgTypeIdOp::pool_size * sizeof(SgTypeIdOp), V_SgTypeIdOp ) );
  157575          10 :         SgTypeIdOp::next_node = alloc;
  157576             :     }
  157577          11 :     ROSE_ASSERT(SgTypeIdOp::next_node != nullptr);
  157578             : 
  157579          11 :     SgTypeIdOp * object = SgTypeIdOp::next_node;
  157580          11 :     SgTypeIdOp::next_node = (SgTypeIdOp*)(object->p_freepointer);
  157581             : 
  157582             : #if ROSE_ALLOC_TRACE == 2
  157583             :     printf("SgTypeIdOp::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeIdOp::next_node);
  157584             : #endif
  157585             : 
  157586          11 :     SgNode * fp = object->p_freepointer;
  157587             : #if ROSE_ALLOC_MEMSET == 1
  157588             : #elif ROSE_ALLOC_MEMSET == 2
  157589             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgTypeIdOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  157590             : #elif ROSE_ALLOC_MEMSET == 3
  157591             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgTypeIdOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  157592             : #endif
  157593          11 :     object->p_freepointer = fp;
  157594             : 
  157595             : #if ROSE_ALLOC_TRACE == 2
  157596             : //    printf("SgTypeIdOp::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeIdOp::next_node);
  157597             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  157598             :     Rose::MemPool::snapshot(oss.str());
  157599             :     alloc_trace_cnt++;
  157600             : #endif
  157601             : 
  157602          11 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  157603             : 
  157604          11 :     ALLOC_MUTEX(SgTypeIdOp, unlock);
  157605             : 
  157606             :     return object;
  157607             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  157608             : }
  157609             : 
  157610             : 
  157611             : 
  157612             : /*! \brief Delete operator for SgTypeIdOp.
  157613             : 
  157614             :    This delete operator implements deallocation using memory pools to 
  157615             :    provide most efficent use of the heap within construction of large ASTs.
  157616             : 
  157617             : \internal The new and delete operators use the lower level C malloc/free
  157618             :    function calls for performance and to make sure that mixing of malloc/free
  157619             :    and new/delete by the used can be caught more readily.  This may change
  157620             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  157621             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  157622             :    deallocate memory allocated using ROSE_MALLOC.
  157623             : */
  157624           2 : void SgTypeIdOp::operator delete(void *Pointer, size_t Size)
  157625             : {
  157626             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  157627             :      * or throwing an exception. */
  157628           2 :     ALLOC_MUTEX(SgTypeIdOp, lock);
  157629             : 
  157630             : #if USE_CPP_NEW_DELETE_OPERATORS
  157631             :     ROSE_FREE(Pointer);
  157632             : #else
  157633             : #if ROSE_PEDANTIC_ALLOC
  157634             :     ROSE_ASSERT(Size == sizeof(SgTypeIdOp));
  157635             : #else
  157636           2 :     if (Size != sizeof(SgTypeIdOp)) {
  157637           0 :       ROSE_FREE(Pointer);
  157638           0 :       ALLOC_MUTEX(SgTypeIdOp, unlock);
  157639             :       return;
  157640             :     }
  157641             : #endif
  157642             : 
  157643           2 :     SgTypeIdOp * object = (SgTypeIdOp*) Pointer;
  157644           2 :     ROSE_ASSERT(object != nullptr);
  157645             : 
  157646             : #if ROSE_ALLOC_TRACE == 2
  157647             : //  printf("SgTypeIdOp::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeIdOp::next_node);
  157648             :     printf("SgTypeIdOp::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeIdOp::next_node);
  157649             : #endif
  157650             : 
  157651             : #if ROSE_PEDANTIC_ALLOC
  157652             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  157653             : #endif
  157654             : 
  157655             : #if ROSE_ALLOC_MEMSET == 1
  157656             : #elif ROSE_ALLOC_MEMSET == 2
  157657             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgTypeIdOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  157658             : #elif ROSE_ALLOC_MEMSET == 3
  157659             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgTypeIdOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  157660             : #endif
  157661             : 
  157662             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  157663             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  157664             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  157665             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  157666             : #else
  157667           2 :     object->p_freepointer = SgTypeIdOp::next_node;
  157668           2 :     SgTypeIdOp::next_node = object;
  157669             : #endif
  157670             : 
  157671             : #if ROSE_ALLOC_TRACE == 2
  157672             : //  printf("SgTypeIdOp::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeIdOp::next_node);
  157673             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  157674             :     Rose::MemPool::snapshot(oss.str());
  157675             :     alloc_trace_cnt++;
  157676             : #endif
  157677             : 
  157678             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  157679             : 
  157680           2 :     ALLOC_MUTEX(SgTypeIdOp, unlock);
  157681             : }
  157682             : 
  157683             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  157684             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  157685             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  157686             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  157687             : // Also, note comment below from Robb (copied from the Common.code file).
  157688             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  157689             : //
  157690             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  157691             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  157692             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  157693             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  157694             : #if 0
  157695             : void SgTypeIdOp::operator delete(void* pointer) { SgTypeIdOp::operator delete (pointer, sizeof(SgTypeIdOp)); };
  157696             : #endif
  157697             : /* #line 157698 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  157698             : 
  157699             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  157700             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  157701             : // obviously imply C++.
  157702             : 
  157703             : // This implements the support within ROSE for memory pools.  Memory pools
  157704             : // support the most condensed usage of memory within the construction of
  157705             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  157706             : // by a new operator written for each class.
  157707             : 
  157708             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  157709             :     // User wants multi-thread support and POSIX threads are available.
  157710             : #   include <pthread.h>
  157711             :     static pthread_mutex_t SgConditionalExp_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  157712             : #else
  157713             :      // Cause synchronization to be skipped.
  157714             : #    ifndef ALLOC_MUTEX
  157715             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  157716             : #    endif
  157717             : #    ifdef _REENTRANT
  157718             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  157719             : #       ifdef _MSC_VER
  157720             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  157721             : #       else
  157722             : #           warning "POSIX threads are not available; synchronization being skipped"
  157723             : #       endif
  157724             : #    endif
  157725             : #endif
  157726             : 
  157727             : #ifndef ROSE_ALLOC_TRACE
  157728             : #  define ROSE_ALLOC_TRACE 0
  157729             : #endif
  157730             : 
  157731             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  157732             : #define ROSE_ALLOC_TRACE_CNT
  157733             : #include "memory-pool-snapshot.h"
  157734             : unsigned long alloc_trace_cnt = 0;
  157735             : #endif
  157736             : 
  157737             : #if ROSE_ALLOC_TRACE
  157738             : const unsigned SgConditionalExp::pool_size = 5;
  157739             : #else
  157740             : const unsigned SgConditionalExp::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  157741             : #endif
  157742             : 
  157743             : #ifndef ROSE_ALLOC_MEMSET
  157744             : #  define ROSE_ALLOC_MEMSET 0
  157745             : #endif
  157746             : 
  157747             : #ifndef ROSE_PEDANTIC_ALLOC
  157748             : #  define ROSE_PEDANTIC_ALLOC 0
  157749             : #endif
  157750             : 
  157751             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  157752             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  157753             : #endif
  157754             : 
  157755             : #if !defined(SGNODE__ALL_POOLS)
  157756             : #define SGNODE__ALL_POOLS
  157757             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  157758             : #endif
  157759             : 
  157760             : SgConditionalExp* SgConditionalExp::next_node = nullptr;
  157761             : std::vector<unsigned char*> SgConditionalExp::pools;
  157762             : 
  157763             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  157764             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  157765             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  157766             : // around this macro definition rather than each use).
  157767             : #ifndef ALLOC_MUTEX
  157768             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  157769             :         do {                                                                     \
  157770             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  157771             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  157772             :                 abort();                                                         \
  157773             :             }                                                                    \
  157774             :         } while (0);
  157775             : #endif
  157776             : 
  157777             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  157778             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  157779             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  157780             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  157781             : 
  157782             : /*! \brief New operator for SgConditionalExp.
  157783             : 
  157784             :    This new operator implements memory pools to provide most efficent 
  157785             :    use of the heap within construction of large ASTs.
  157786             : 
  157787             : \internal The new and delete operators use the lower level C malloc/free
  157788             :    function calls for performance and to make sure that mixing of malloc/free
  157789             :    and new/delete by the used can be caught more readily.  This may change
  157790             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  157791             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  157792             :    deallocate memory allocated using ROSE_MALLOC.
  157793             : */
  157794        1886 : void *SgConditionalExp::operator new ( size_t Size )
  157795             : {
  157796             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  157797             :      * returning or throwing an exception. */
  157798        1886 :     ALLOC_MUTEX(SgConditionalExp, lock);
  157799             : 
  157800             : #if ROSE_ALLOC_TRACE == 2
  157801             : //    printf("SgConditionalExp::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgConditionalExp::next_node);
  157802             : #endif
  157803             : 
  157804             : #if USE_CPP_NEW_DELETE_OPERATORS
  157805             :     void *mem = ROSE_MALLOC(Size);
  157806             :     ALLOC_MUTEX(SgConditionalExp, unlock);
  157807             :     return mem;
  157808             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  157809             : #if ROSE_PEDANTIC_ALLOC
  157810             :     ROSE_ASSERT(Size == sizeof(SgConditionalExp));
  157811             : #else
  157812        1886 :     if (Size != sizeof(SgConditionalExp)) {
  157813           0 :       void * object = ROSE_MALLOC(Size);
  157814           0 :       ALLOC_MUTEX(SgConditionalExp, unlock);
  157815             :       return object;
  157816             :     }
  157817             : #endif
  157818             : 
  157819        1886 :     if (SgConditionalExp::next_node == nullptr) {
  157820          53 :         SgConditionalExp * alloc = (SgConditionalExp*) ROSE_MALLOC ( SgConditionalExp::pool_size * sizeof(SgConditionalExp) );
  157821          53 :         ROSE_ASSERT(alloc != nullptr);
  157822             : 
  157823             : #if ROSE_ALLOC_TRACE == 2
  157824             : //        printf("SgConditionalExp::alloc\n  block[%zi] = [ %p , %p [\n", SgConditionalExp::pools.size(), alloc, alloc + SgConditionalExp::pool_size);
  157825             : #endif
  157826             : 
  157827             : #if ROSE_ALLOC_MEMSET == 1
  157828             : #elif ROSE_ALLOC_MEMSET == 2
  157829             :         memset(alloc, 0x00, SgConditionalExp::pool_size * sizeof(SgConditionalExp));
  157830             : #elif ROSE_ALLOC_MEMSET == 3
  157831             :         memset(alloc, 0xAA, SgConditionalExp::pool_size * sizeof(SgConditionalExp));
  157832             : #endif
  157833      106000 :         for (unsigned i=0; i < SgConditionalExp::pool_size-1; i++) {
  157834      105947 :           alloc[i].p_freepointer = &(alloc[i+1]);
  157835             :         }
  157836          53 :         alloc[SgConditionalExp::pool_size-1].p_freepointer = nullptr;
  157837             : 
  157838          53 :         SgConditionalExp::pools.push_back ( (unsigned char *) alloc );
  157839          53 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgConditionalExp::pool_size * sizeof(SgConditionalExp), V_SgConditionalExp ) );
  157840          53 :         SgConditionalExp::next_node = alloc;
  157841             :     }
  157842        1886 :     ROSE_ASSERT(SgConditionalExp::next_node != nullptr);
  157843             : 
  157844        1886 :     SgConditionalExp * object = SgConditionalExp::next_node;
  157845        1886 :     SgConditionalExp::next_node = (SgConditionalExp*)(object->p_freepointer);
  157846             : 
  157847             : #if ROSE_ALLOC_TRACE == 2
  157848             :     printf("SgConditionalExp::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgConditionalExp::next_node);
  157849             : #endif
  157850             : 
  157851        1886 :     SgNode * fp = object->p_freepointer;
  157852             : #if ROSE_ALLOC_MEMSET == 1
  157853             : #elif ROSE_ALLOC_MEMSET == 2
  157854             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgConditionalExp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  157855             : #elif ROSE_ALLOC_MEMSET == 3
  157856             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgConditionalExp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  157857             : #endif
  157858        1886 :     object->p_freepointer = fp;
  157859             : 
  157860             : #if ROSE_ALLOC_TRACE == 2
  157861             : //    printf("SgConditionalExp::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgConditionalExp::next_node);
  157862             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  157863             :     Rose::MemPool::snapshot(oss.str());
  157864             :     alloc_trace_cnt++;
  157865             : #endif
  157866             : 
  157867        1886 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  157868             : 
  157869        1886 :     ALLOC_MUTEX(SgConditionalExp, unlock);
  157870             : 
  157871             :     return object;
  157872             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  157873             : }
  157874             : 
  157875             : 
  157876             : 
  157877             : /*! \brief Delete operator for SgConditionalExp.
  157878             : 
  157879             :    This delete operator implements deallocation using memory pools to 
  157880             :    provide most efficent use of the heap within construction of large ASTs.
  157881             : 
  157882             : \internal The new and delete operators use the lower level C malloc/free
  157883             :    function calls for performance and to make sure that mixing of malloc/free
  157884             :    and new/delete by the used can be caught more readily.  This may change
  157885             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  157886             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  157887             :    deallocate memory allocated using ROSE_MALLOC.
  157888             : */
  157889        1216 : void SgConditionalExp::operator delete(void *Pointer, size_t Size)
  157890             : {
  157891             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  157892             :      * or throwing an exception. */
  157893        1216 :     ALLOC_MUTEX(SgConditionalExp, lock);
  157894             : 
  157895             : #if USE_CPP_NEW_DELETE_OPERATORS
  157896             :     ROSE_FREE(Pointer);
  157897             : #else
  157898             : #if ROSE_PEDANTIC_ALLOC
  157899             :     ROSE_ASSERT(Size == sizeof(SgConditionalExp));
  157900             : #else
  157901        1216 :     if (Size != sizeof(SgConditionalExp)) {
  157902           0 :       ROSE_FREE(Pointer);
  157903           0 :       ALLOC_MUTEX(SgConditionalExp, unlock);
  157904             :       return;
  157905             :     }
  157906             : #endif
  157907             : 
  157908        1216 :     SgConditionalExp * object = (SgConditionalExp*) Pointer;
  157909        1216 :     ROSE_ASSERT(object != nullptr);
  157910             : 
  157911             : #if ROSE_ALLOC_TRACE == 2
  157912             : //  printf("SgConditionalExp::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgConditionalExp::next_node);
  157913             :     printf("SgConditionalExp::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgConditionalExp::next_node);
  157914             : #endif
  157915             : 
  157916             : #if ROSE_PEDANTIC_ALLOC
  157917             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  157918             : #endif
  157919             : 
  157920             : #if ROSE_ALLOC_MEMSET == 1
  157921             : #elif ROSE_ALLOC_MEMSET == 2
  157922             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgConditionalExp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  157923             : #elif ROSE_ALLOC_MEMSET == 3
  157924             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgConditionalExp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  157925             : #endif
  157926             : 
  157927             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  157928             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  157929             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  157930             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  157931             : #else
  157932        1216 :     object->p_freepointer = SgConditionalExp::next_node;
  157933        1216 :     SgConditionalExp::next_node = object;
  157934             : #endif
  157935             : 
  157936             : #if ROSE_ALLOC_TRACE == 2
  157937             : //  printf("SgConditionalExp::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgConditionalExp::next_node);
  157938             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  157939             :     Rose::MemPool::snapshot(oss.str());
  157940             :     alloc_trace_cnt++;
  157941             : #endif
  157942             : 
  157943             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  157944             : 
  157945        1216 :     ALLOC_MUTEX(SgConditionalExp, unlock);
  157946             : }
  157947             : 
  157948             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  157949             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  157950             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  157951             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  157952             : // Also, note comment below from Robb (copied from the Common.code file).
  157953             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  157954             : //
  157955             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  157956             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  157957             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  157958             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  157959             : #if 0
  157960             : void SgConditionalExp::operator delete(void* pointer) { SgConditionalExp::operator delete (pointer, sizeof(SgConditionalExp)); };
  157961             : #endif
  157962             : /* #line 157963 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  157963             : 
  157964             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  157965             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  157966             : // obviously imply C++.
  157967             : 
  157968             : // This implements the support within ROSE for memory pools.  Memory pools
  157969             : // support the most condensed usage of memory within the construction of
  157970             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  157971             : // by a new operator written for each class.
  157972             : 
  157973             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  157974             :     // User wants multi-thread support and POSIX threads are available.
  157975             : #   include <pthread.h>
  157976             :     static pthread_mutex_t SgNewExp_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  157977             : #else
  157978             :      // Cause synchronization to be skipped.
  157979             : #    ifndef ALLOC_MUTEX
  157980             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  157981             : #    endif
  157982             : #    ifdef _REENTRANT
  157983             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  157984             : #       ifdef _MSC_VER
  157985             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  157986             : #       else
  157987             : #           warning "POSIX threads are not available; synchronization being skipped"
  157988             : #       endif
  157989             : #    endif
  157990             : #endif
  157991             : 
  157992             : #ifndef ROSE_ALLOC_TRACE
  157993             : #  define ROSE_ALLOC_TRACE 0
  157994             : #endif
  157995             : 
  157996             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  157997             : #define ROSE_ALLOC_TRACE_CNT
  157998             : #include "memory-pool-snapshot.h"
  157999             : unsigned long alloc_trace_cnt = 0;
  158000             : #endif
  158001             : 
  158002             : #if ROSE_ALLOC_TRACE
  158003             : const unsigned SgNewExp::pool_size = 5;
  158004             : #else
  158005             : const unsigned SgNewExp::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  158006             : #endif
  158007             : 
  158008             : #ifndef ROSE_ALLOC_MEMSET
  158009             : #  define ROSE_ALLOC_MEMSET 0
  158010             : #endif
  158011             : 
  158012             : #ifndef ROSE_PEDANTIC_ALLOC
  158013             : #  define ROSE_PEDANTIC_ALLOC 0
  158014             : #endif
  158015             : 
  158016             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  158017             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  158018             : #endif
  158019             : 
  158020             : #if !defined(SGNODE__ALL_POOLS)
  158021             : #define SGNODE__ALL_POOLS
  158022             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  158023             : #endif
  158024             : 
  158025             : SgNewExp* SgNewExp::next_node = nullptr;
  158026             : std::vector<unsigned char*> SgNewExp::pools;
  158027             : 
  158028             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  158029             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  158030             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  158031             : // around this macro definition rather than each use).
  158032             : #ifndef ALLOC_MUTEX
  158033             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  158034             :         do {                                                                     \
  158035             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  158036             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  158037             :                 abort();                                                         \
  158038             :             }                                                                    \
  158039             :         } while (0);
  158040             : #endif
  158041             : 
  158042             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  158043             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  158044             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  158045             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  158046             : 
  158047             : /*! \brief New operator for SgNewExp.
  158048             : 
  158049             :    This new operator implements memory pools to provide most efficent 
  158050             :    use of the heap within construction of large ASTs.
  158051             : 
  158052             : \internal The new and delete operators use the lower level C malloc/free
  158053             :    function calls for performance and to make sure that mixing of malloc/free
  158054             :    and new/delete by the used can be caught more readily.  This may change
  158055             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  158056             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  158057             :    deallocate memory allocated using ROSE_MALLOC.
  158058             : */
  158059         143 : void *SgNewExp::operator new ( size_t Size )
  158060             : {
  158061             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  158062             :      * returning or throwing an exception. */
  158063         143 :     ALLOC_MUTEX(SgNewExp, lock);
  158064             : 
  158065             : #if ROSE_ALLOC_TRACE == 2
  158066             : //    printf("SgNewExp::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgNewExp::next_node);
  158067             : #endif
  158068             : 
  158069             : #if USE_CPP_NEW_DELETE_OPERATORS
  158070             :     void *mem = ROSE_MALLOC(Size);
  158071             :     ALLOC_MUTEX(SgNewExp, unlock);
  158072             :     return mem;
  158073             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  158074             : #if ROSE_PEDANTIC_ALLOC
  158075             :     ROSE_ASSERT(Size == sizeof(SgNewExp));
  158076             : #else
  158077         143 :     if (Size != sizeof(SgNewExp)) {
  158078           0 :       void * object = ROSE_MALLOC(Size);
  158079           0 :       ALLOC_MUTEX(SgNewExp, unlock);
  158080             :       return object;
  158081             :     }
  158082             : #endif
  158083             : 
  158084         143 :     if (SgNewExp::next_node == nullptr) {
  158085          11 :         SgNewExp * alloc = (SgNewExp*) ROSE_MALLOC ( SgNewExp::pool_size * sizeof(SgNewExp) );
  158086          11 :         ROSE_ASSERT(alloc != nullptr);
  158087             : 
  158088             : #if ROSE_ALLOC_TRACE == 2
  158089             : //        printf("SgNewExp::alloc\n  block[%zi] = [ %p , %p [\n", SgNewExp::pools.size(), alloc, alloc + SgNewExp::pool_size);
  158090             : #endif
  158091             : 
  158092             : #if ROSE_ALLOC_MEMSET == 1
  158093             : #elif ROSE_ALLOC_MEMSET == 2
  158094             :         memset(alloc, 0x00, SgNewExp::pool_size * sizeof(SgNewExp));
  158095             : #elif ROSE_ALLOC_MEMSET == 3
  158096             :         memset(alloc, 0xAA, SgNewExp::pool_size * sizeof(SgNewExp));
  158097             : #endif
  158098       22000 :         for (unsigned i=0; i < SgNewExp::pool_size-1; i++) {
  158099       21989 :           alloc[i].p_freepointer = &(alloc[i+1]);
  158100             :         }
  158101          11 :         alloc[SgNewExp::pool_size-1].p_freepointer = nullptr;
  158102             : 
  158103          11 :         SgNewExp::pools.push_back ( (unsigned char *) alloc );
  158104          11 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgNewExp::pool_size * sizeof(SgNewExp), V_SgNewExp ) );
  158105          11 :         SgNewExp::next_node = alloc;
  158106             :     }
  158107         143 :     ROSE_ASSERT(SgNewExp::next_node != nullptr);
  158108             : 
  158109         143 :     SgNewExp * object = SgNewExp::next_node;
  158110         143 :     SgNewExp::next_node = (SgNewExp*)(object->p_freepointer);
  158111             : 
  158112             : #if ROSE_ALLOC_TRACE == 2
  158113             :     printf("SgNewExp::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgNewExp::next_node);
  158114             : #endif
  158115             : 
  158116         143 :     SgNode * fp = object->p_freepointer;
  158117             : #if ROSE_ALLOC_MEMSET == 1
  158118             : #elif ROSE_ALLOC_MEMSET == 2
  158119             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgNewExp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  158120             : #elif ROSE_ALLOC_MEMSET == 3
  158121             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgNewExp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  158122             : #endif
  158123         143 :     object->p_freepointer = fp;
  158124             : 
  158125             : #if ROSE_ALLOC_TRACE == 2
  158126             : //    printf("SgNewExp::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgNewExp::next_node);
  158127             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  158128             :     Rose::MemPool::snapshot(oss.str());
  158129             :     alloc_trace_cnt++;
  158130             : #endif
  158131             : 
  158132         143 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  158133             : 
  158134         143 :     ALLOC_MUTEX(SgNewExp, unlock);
  158135             : 
  158136             :     return object;
  158137             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  158138             : }
  158139             : 
  158140             : 
  158141             : 
  158142             : /*! \brief Delete operator for SgNewExp.
  158143             : 
  158144             :    This delete operator implements deallocation using memory pools to 
  158145             :    provide most efficent use of the heap within construction of large ASTs.
  158146             : 
  158147             : \internal The new and delete operators use the lower level C malloc/free
  158148             :    function calls for performance and to make sure that mixing of malloc/free
  158149             :    and new/delete by the used can be caught more readily.  This may change
  158150             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  158151             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  158152             :    deallocate memory allocated using ROSE_MALLOC.
  158153             : */
  158154          28 : void SgNewExp::operator delete(void *Pointer, size_t Size)
  158155             : {
  158156             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  158157             :      * or throwing an exception. */
  158158          28 :     ALLOC_MUTEX(SgNewExp, lock);
  158159             : 
  158160             : #if USE_CPP_NEW_DELETE_OPERATORS
  158161             :     ROSE_FREE(Pointer);
  158162             : #else
  158163             : #if ROSE_PEDANTIC_ALLOC
  158164             :     ROSE_ASSERT(Size == sizeof(SgNewExp));
  158165             : #else
  158166          28 :     if (Size != sizeof(SgNewExp)) {
  158167           0 :       ROSE_FREE(Pointer);
  158168           0 :       ALLOC_MUTEX(SgNewExp, unlock);
  158169             :       return;
  158170             :     }
  158171             : #endif
  158172             : 
  158173          28 :     SgNewExp * object = (SgNewExp*) Pointer;
  158174          28 :     ROSE_ASSERT(object != nullptr);
  158175             : 
  158176             : #if ROSE_ALLOC_TRACE == 2
  158177             : //  printf("SgNewExp::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgNewExp::next_node);
  158178             :     printf("SgNewExp::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgNewExp::next_node);
  158179             : #endif
  158180             : 
  158181             : #if ROSE_PEDANTIC_ALLOC
  158182             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  158183             : #endif
  158184             : 
  158185             : #if ROSE_ALLOC_MEMSET == 1
  158186             : #elif ROSE_ALLOC_MEMSET == 2
  158187             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgNewExp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  158188             : #elif ROSE_ALLOC_MEMSET == 3
  158189             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgNewExp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  158190             : #endif
  158191             : 
  158192             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  158193             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  158194             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  158195             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  158196             : #else
  158197          28 :     object->p_freepointer = SgNewExp::next_node;
  158198          28 :     SgNewExp::next_node = object;
  158199             : #endif
  158200             : 
  158201             : #if ROSE_ALLOC_TRACE == 2
  158202             : //  printf("SgNewExp::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgNewExp::next_node);
  158203             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  158204             :     Rose::MemPool::snapshot(oss.str());
  158205             :     alloc_trace_cnt++;
  158206             : #endif
  158207             : 
  158208             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  158209             : 
  158210          28 :     ALLOC_MUTEX(SgNewExp, unlock);
  158211             : }
  158212             : 
  158213             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  158214             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  158215             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  158216             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  158217             : // Also, note comment below from Robb (copied from the Common.code file).
  158218             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  158219             : //
  158220             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  158221             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  158222             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  158223             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  158224             : #if 0
  158225             : void SgNewExp::operator delete(void* pointer) { SgNewExp::operator delete (pointer, sizeof(SgNewExp)); };
  158226             : #endif
  158227             : /* #line 158228 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  158228             : 
  158229             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  158230             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  158231             : // obviously imply C++.
  158232             : 
  158233             : // This implements the support within ROSE for memory pools.  Memory pools
  158234             : // support the most condensed usage of memory within the construction of
  158235             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  158236             : // by a new operator written for each class.
  158237             : 
  158238             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  158239             :     // User wants multi-thread support and POSIX threads are available.
  158240             : #   include <pthread.h>
  158241             :     static pthread_mutex_t SgDeleteExp_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  158242             : #else
  158243             :      // Cause synchronization to be skipped.
  158244             : #    ifndef ALLOC_MUTEX
  158245             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  158246             : #    endif
  158247             : #    ifdef _REENTRANT
  158248             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  158249             : #       ifdef _MSC_VER
  158250             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  158251             : #       else
  158252             : #           warning "POSIX threads are not available; synchronization being skipped"
  158253             : #       endif
  158254             : #    endif
  158255             : #endif
  158256             : 
  158257             : #ifndef ROSE_ALLOC_TRACE
  158258             : #  define ROSE_ALLOC_TRACE 0
  158259             : #endif
  158260             : 
  158261             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  158262             : #define ROSE_ALLOC_TRACE_CNT
  158263             : #include "memory-pool-snapshot.h"
  158264             : unsigned long alloc_trace_cnt = 0;
  158265             : #endif
  158266             : 
  158267             : #if ROSE_ALLOC_TRACE
  158268             : const unsigned SgDeleteExp::pool_size = 5;
  158269             : #else
  158270             : const unsigned SgDeleteExp::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  158271             : #endif
  158272             : 
  158273             : #ifndef ROSE_ALLOC_MEMSET
  158274             : #  define ROSE_ALLOC_MEMSET 0
  158275             : #endif
  158276             : 
  158277             : #ifndef ROSE_PEDANTIC_ALLOC
  158278             : #  define ROSE_PEDANTIC_ALLOC 0
  158279             : #endif
  158280             : 
  158281             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  158282             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  158283             : #endif
  158284             : 
  158285             : #if !defined(SGNODE__ALL_POOLS)
  158286             : #define SGNODE__ALL_POOLS
  158287             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  158288             : #endif
  158289             : 
  158290             : SgDeleteExp* SgDeleteExp::next_node = nullptr;
  158291             : std::vector<unsigned char*> SgDeleteExp::pools;
  158292             : 
  158293             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  158294             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  158295             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  158296             : // around this macro definition rather than each use).
  158297             : #ifndef ALLOC_MUTEX
  158298             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  158299             :         do {                                                                     \
  158300             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  158301             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  158302             :                 abort();                                                         \
  158303             :             }                                                                    \
  158304             :         } while (0);
  158305             : #endif
  158306             : 
  158307             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  158308             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  158309             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  158310             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  158311             : 
  158312             : /*! \brief New operator for SgDeleteExp.
  158313             : 
  158314             :    This new operator implements memory pools to provide most efficent 
  158315             :    use of the heap within construction of large ASTs.
  158316             : 
  158317             : \internal The new and delete operators use the lower level C malloc/free
  158318             :    function calls for performance and to make sure that mixing of malloc/free
  158319             :    and new/delete by the used can be caught more readily.  This may change
  158320             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  158321             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  158322             :    deallocate memory allocated using ROSE_MALLOC.
  158323             : */
  158324         135 : void *SgDeleteExp::operator new ( size_t Size )
  158325             : {
  158326             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  158327             :      * returning or throwing an exception. */
  158328         135 :     ALLOC_MUTEX(SgDeleteExp, lock);
  158329             : 
  158330             : #if ROSE_ALLOC_TRACE == 2
  158331             : //    printf("SgDeleteExp::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgDeleteExp::next_node);
  158332             : #endif
  158333             : 
  158334             : #if USE_CPP_NEW_DELETE_OPERATORS
  158335             :     void *mem = ROSE_MALLOC(Size);
  158336             :     ALLOC_MUTEX(SgDeleteExp, unlock);
  158337             :     return mem;
  158338             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  158339             : #if ROSE_PEDANTIC_ALLOC
  158340             :     ROSE_ASSERT(Size == sizeof(SgDeleteExp));
  158341             : #else
  158342         135 :     if (Size != sizeof(SgDeleteExp)) {
  158343           0 :       void * object = ROSE_MALLOC(Size);
  158344           0 :       ALLOC_MUTEX(SgDeleteExp, unlock);
  158345             :       return object;
  158346             :     }
  158347             : #endif
  158348             : 
  158349         135 :     if (SgDeleteExp::next_node == nullptr) {
  158350           8 :         SgDeleteExp * alloc = (SgDeleteExp*) ROSE_MALLOC ( SgDeleteExp::pool_size * sizeof(SgDeleteExp) );
  158351           8 :         ROSE_ASSERT(alloc != nullptr);
  158352             : 
  158353             : #if ROSE_ALLOC_TRACE == 2
  158354             : //        printf("SgDeleteExp::alloc\n  block[%zi] = [ %p , %p [\n", SgDeleteExp::pools.size(), alloc, alloc + SgDeleteExp::pool_size);
  158355             : #endif
  158356             : 
  158357             : #if ROSE_ALLOC_MEMSET == 1
  158358             : #elif ROSE_ALLOC_MEMSET == 2
  158359             :         memset(alloc, 0x00, SgDeleteExp::pool_size * sizeof(SgDeleteExp));
  158360             : #elif ROSE_ALLOC_MEMSET == 3
  158361             :         memset(alloc, 0xAA, SgDeleteExp::pool_size * sizeof(SgDeleteExp));
  158362             : #endif
  158363       16000 :         for (unsigned i=0; i < SgDeleteExp::pool_size-1; i++) {
  158364       15992 :           alloc[i].p_freepointer = &(alloc[i+1]);
  158365             :         }
  158366           8 :         alloc[SgDeleteExp::pool_size-1].p_freepointer = nullptr;
  158367             : 
  158368           8 :         SgDeleteExp::pools.push_back ( (unsigned char *) alloc );
  158369           8 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgDeleteExp::pool_size * sizeof(SgDeleteExp), V_SgDeleteExp ) );
  158370           8 :         SgDeleteExp::next_node = alloc;
  158371             :     }
  158372         135 :     ROSE_ASSERT(SgDeleteExp::next_node != nullptr);
  158373             : 
  158374         135 :     SgDeleteExp * object = SgDeleteExp::next_node;
  158375         135 :     SgDeleteExp::next_node = (SgDeleteExp*)(object->p_freepointer);
  158376             : 
  158377             : #if ROSE_ALLOC_TRACE == 2
  158378             :     printf("SgDeleteExp::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgDeleteExp::next_node);
  158379             : #endif
  158380             : 
  158381         135 :     SgNode * fp = object->p_freepointer;
  158382             : #if ROSE_ALLOC_MEMSET == 1
  158383             : #elif ROSE_ALLOC_MEMSET == 2
  158384             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgDeleteExp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  158385             : #elif ROSE_ALLOC_MEMSET == 3
  158386             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgDeleteExp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  158387             : #endif
  158388         135 :     object->p_freepointer = fp;
  158389             : 
  158390             : #if ROSE_ALLOC_TRACE == 2
  158391             : //    printf("SgDeleteExp::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgDeleteExp::next_node);
  158392             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  158393             :     Rose::MemPool::snapshot(oss.str());
  158394             :     alloc_trace_cnt++;
  158395             : #endif
  158396             : 
  158397         135 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  158398             : 
  158399         135 :     ALLOC_MUTEX(SgDeleteExp, unlock);
  158400             : 
  158401             :     return object;
  158402             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  158403             : }
  158404             : 
  158405             : 
  158406             : 
  158407             : /*! \brief Delete operator for SgDeleteExp.
  158408             : 
  158409             :    This delete operator implements deallocation using memory pools to 
  158410             :    provide most efficent use of the heap within construction of large ASTs.
  158411             : 
  158412             : \internal The new and delete operators use the lower level C malloc/free
  158413             :    function calls for performance and to make sure that mixing of malloc/free
  158414             :    and new/delete by the used can be caught more readily.  This may change
  158415             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  158416             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  158417             :    deallocate memory allocated using ROSE_MALLOC.
  158418             : */
  158419          30 : void SgDeleteExp::operator delete(void *Pointer, size_t Size)
  158420             : {
  158421             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  158422             :      * or throwing an exception. */
  158423          30 :     ALLOC_MUTEX(SgDeleteExp, lock);
  158424             : 
  158425             : #if USE_CPP_NEW_DELETE_OPERATORS
  158426             :     ROSE_FREE(Pointer);
  158427             : #else
  158428             : #if ROSE_PEDANTIC_ALLOC
  158429             :     ROSE_ASSERT(Size == sizeof(SgDeleteExp));
  158430             : #else
  158431          30 :     if (Size != sizeof(SgDeleteExp)) {
  158432           0 :       ROSE_FREE(Pointer);
  158433           0 :       ALLOC_MUTEX(SgDeleteExp, unlock);
  158434             :       return;
  158435             :     }
  158436             : #endif
  158437             : 
  158438          30 :     SgDeleteExp * object = (SgDeleteExp*) Pointer;
  158439          30 :     ROSE_ASSERT(object != nullptr);
  158440             : 
  158441             : #if ROSE_ALLOC_TRACE == 2
  158442             : //  printf("SgDeleteExp::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgDeleteExp::next_node);
  158443             :     printf("SgDeleteExp::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgDeleteExp::next_node);
  158444             : #endif
  158445             : 
  158446             : #if ROSE_PEDANTIC_ALLOC
  158447             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  158448             : #endif
  158449             : 
  158450             : #if ROSE_ALLOC_MEMSET == 1
  158451             : #elif ROSE_ALLOC_MEMSET == 2
  158452             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgDeleteExp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  158453             : #elif ROSE_ALLOC_MEMSET == 3
  158454             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgDeleteExp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  158455             : #endif
  158456             : 
  158457             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  158458             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  158459             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  158460             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  158461             : #else
  158462          30 :     object->p_freepointer = SgDeleteExp::next_node;
  158463          30 :     SgDeleteExp::next_node = object;
  158464             : #endif
  158465             : 
  158466             : #if ROSE_ALLOC_TRACE == 2
  158467             : //  printf("SgDeleteExp::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgDeleteExp::next_node);
  158468             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  158469             :     Rose::MemPool::snapshot(oss.str());
  158470             :     alloc_trace_cnt++;
  158471             : #endif
  158472             : 
  158473             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  158474             : 
  158475          30 :     ALLOC_MUTEX(SgDeleteExp, unlock);
  158476             : }
  158477             : 
  158478             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  158479             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  158480             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  158481             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  158482             : // Also, note comment below from Robb (copied from the Common.code file).
  158483             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  158484             : //
  158485             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  158486             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  158487             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  158488             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  158489             : #if 0
  158490             : void SgDeleteExp::operator delete(void* pointer) { SgDeleteExp::operator delete (pointer, sizeof(SgDeleteExp)); };
  158491             : #endif
  158492             : /* #line 158493 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  158493             : 
  158494             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  158495             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  158496             : // obviously imply C++.
  158497             : 
  158498             : // This implements the support within ROSE for memory pools.  Memory pools
  158499             : // support the most condensed usage of memory within the construction of
  158500             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  158501             : // by a new operator written for each class.
  158502             : 
  158503             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  158504             :     // User wants multi-thread support and POSIX threads are available.
  158505             : #   include <pthread.h>
  158506             :     static pthread_mutex_t SgThisExp_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  158507             : #else
  158508             :      // Cause synchronization to be skipped.
  158509             : #    ifndef ALLOC_MUTEX
  158510             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  158511             : #    endif
  158512             : #    ifdef _REENTRANT
  158513             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  158514             : #       ifdef _MSC_VER
  158515             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  158516             : #       else
  158517             : #           warning "POSIX threads are not available; synchronization being skipped"
  158518             : #       endif
  158519             : #    endif
  158520             : #endif
  158521             : 
  158522             : #ifndef ROSE_ALLOC_TRACE
  158523             : #  define ROSE_ALLOC_TRACE 0
  158524             : #endif
  158525             : 
  158526             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  158527             : #define ROSE_ALLOC_TRACE_CNT
  158528             : #include "memory-pool-snapshot.h"
  158529             : unsigned long alloc_trace_cnt = 0;
  158530             : #endif
  158531             : 
  158532             : #if ROSE_ALLOC_TRACE
  158533             : const unsigned SgThisExp::pool_size = 5;
  158534             : #else
  158535             : const unsigned SgThisExp::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  158536             : #endif
  158537             : 
  158538             : #ifndef ROSE_ALLOC_MEMSET
  158539             : #  define ROSE_ALLOC_MEMSET 0
  158540             : #endif
  158541             : 
  158542             : #ifndef ROSE_PEDANTIC_ALLOC
  158543             : #  define ROSE_PEDANTIC_ALLOC 0
  158544             : #endif
  158545             : 
  158546             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  158547             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  158548             : #endif
  158549             : 
  158550             : #if !defined(SGNODE__ALL_POOLS)
  158551             : #define SGNODE__ALL_POOLS
  158552             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  158553             : #endif
  158554             : 
  158555             : SgThisExp* SgThisExp::next_node = nullptr;
  158556             : std::vector<unsigned char*> SgThisExp::pools;
  158557             : 
  158558             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  158559             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  158560             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  158561             : // around this macro definition rather than each use).
  158562             : #ifndef ALLOC_MUTEX
  158563             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  158564             :         do {                                                                     \
  158565             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  158566             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  158567             :                 abort();                                                         \
  158568             :             }                                                                    \
  158569             :         } while (0);
  158570             : #endif
  158571             : 
  158572             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  158573             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  158574             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  158575             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  158576             : 
  158577             : /*! \brief New operator for SgThisExp.
  158578             : 
  158579             :    This new operator implements memory pools to provide most efficent 
  158580             :    use of the heap within construction of large ASTs.
  158581             : 
  158582             : \internal The new and delete operators use the lower level C malloc/free
  158583             :    function calls for performance and to make sure that mixing of malloc/free
  158584             :    and new/delete by the used can be caught more readily.  This may change
  158585             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  158586             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  158587             :    deallocate memory allocated using ROSE_MALLOC.
  158588             : */
  158589       13291 : void *SgThisExp::operator new ( size_t Size )
  158590             : {
  158591             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  158592             :      * returning or throwing an exception. */
  158593       13291 :     ALLOC_MUTEX(SgThisExp, lock);
  158594             : 
  158595             : #if ROSE_ALLOC_TRACE == 2
  158596             : //    printf("SgThisExp::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgThisExp::next_node);
  158597             : #endif
  158598             : 
  158599             : #if USE_CPP_NEW_DELETE_OPERATORS
  158600             :     void *mem = ROSE_MALLOC(Size);
  158601             :     ALLOC_MUTEX(SgThisExp, unlock);
  158602             :     return mem;
  158603             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  158604             : #if ROSE_PEDANTIC_ALLOC
  158605             :     ROSE_ASSERT(Size == sizeof(SgThisExp));
  158606             : #else
  158607       13291 :     if (Size != sizeof(SgThisExp)) {
  158608           0 :       void * object = ROSE_MALLOC(Size);
  158609           0 :       ALLOC_MUTEX(SgThisExp, unlock);
  158610             :       return object;
  158611             :     }
  158612             : #endif
  158613             : 
  158614       13291 :     if (SgThisExp::next_node == nullptr) {
  158615          15 :         SgThisExp * alloc = (SgThisExp*) ROSE_MALLOC ( SgThisExp::pool_size * sizeof(SgThisExp) );
  158616          15 :         ROSE_ASSERT(alloc != nullptr);
  158617             : 
  158618             : #if ROSE_ALLOC_TRACE == 2
  158619             : //        printf("SgThisExp::alloc\n  block[%zi] = [ %p , %p [\n", SgThisExp::pools.size(), alloc, alloc + SgThisExp::pool_size);
  158620             : #endif
  158621             : 
  158622             : #if ROSE_ALLOC_MEMSET == 1
  158623             : #elif ROSE_ALLOC_MEMSET == 2
  158624             :         memset(alloc, 0x00, SgThisExp::pool_size * sizeof(SgThisExp));
  158625             : #elif ROSE_ALLOC_MEMSET == 3
  158626             :         memset(alloc, 0xAA, SgThisExp::pool_size * sizeof(SgThisExp));
  158627             : #endif
  158628       30000 :         for (unsigned i=0; i < SgThisExp::pool_size-1; i++) {
  158629       29985 :           alloc[i].p_freepointer = &(alloc[i+1]);
  158630             :         }
  158631          15 :         alloc[SgThisExp::pool_size-1].p_freepointer = nullptr;
  158632             : 
  158633          15 :         SgThisExp::pools.push_back ( (unsigned char *) alloc );
  158634          15 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgThisExp::pool_size * sizeof(SgThisExp), V_SgThisExp ) );
  158635          15 :         SgThisExp::next_node = alloc;
  158636             :     }
  158637       13291 :     ROSE_ASSERT(SgThisExp::next_node != nullptr);
  158638             : 
  158639       13291 :     SgThisExp * object = SgThisExp::next_node;
  158640       13291 :     SgThisExp::next_node = (SgThisExp*)(object->p_freepointer);
  158641             : 
  158642             : #if ROSE_ALLOC_TRACE == 2
  158643             :     printf("SgThisExp::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgThisExp::next_node);
  158644             : #endif
  158645             : 
  158646       13291 :     SgNode * fp = object->p_freepointer;
  158647             : #if ROSE_ALLOC_MEMSET == 1
  158648             : #elif ROSE_ALLOC_MEMSET == 2
  158649             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgThisExp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  158650             : #elif ROSE_ALLOC_MEMSET == 3
  158651             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgThisExp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  158652             : #endif
  158653       13291 :     object->p_freepointer = fp;
  158654             : 
  158655             : #if ROSE_ALLOC_TRACE == 2
  158656             : //    printf("SgThisExp::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgThisExp::next_node);
  158657             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  158658             :     Rose::MemPool::snapshot(oss.str());
  158659             :     alloc_trace_cnt++;
  158660             : #endif
  158661             : 
  158662       13291 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  158663             : 
  158664       13291 :     ALLOC_MUTEX(SgThisExp, unlock);
  158665             : 
  158666             :     return object;
  158667             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  158668             : }
  158669             : 
  158670             : 
  158671             : 
  158672             : /*! \brief Delete operator for SgThisExp.
  158673             : 
  158674             :    This delete operator implements deallocation using memory pools to 
  158675             :    provide most efficent use of the heap within construction of large ASTs.
  158676             : 
  158677             : \internal The new and delete operators use the lower level C malloc/free
  158678             :    function calls for performance and to make sure that mixing of malloc/free
  158679             :    and new/delete by the used can be caught more readily.  This may change
  158680             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  158681             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  158682             :    deallocate memory allocated using ROSE_MALLOC.
  158683             : */
  158684        2550 : void SgThisExp::operator delete(void *Pointer, size_t Size)
  158685             : {
  158686             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  158687             :      * or throwing an exception. */
  158688        2550 :     ALLOC_MUTEX(SgThisExp, lock);
  158689             : 
  158690             : #if USE_CPP_NEW_DELETE_OPERATORS
  158691             :     ROSE_FREE(Pointer);
  158692             : #else
  158693             : #if ROSE_PEDANTIC_ALLOC
  158694             :     ROSE_ASSERT(Size == sizeof(SgThisExp));
  158695             : #else
  158696        2550 :     if (Size != sizeof(SgThisExp)) {
  158697           0 :       ROSE_FREE(Pointer);
  158698           0 :       ALLOC_MUTEX(SgThisExp, unlock);
  158699             :       return;
  158700             :     }
  158701             : #endif
  158702             : 
  158703        2550 :     SgThisExp * object = (SgThisExp*) Pointer;
  158704        2550 :     ROSE_ASSERT(object != nullptr);
  158705             : 
  158706             : #if ROSE_ALLOC_TRACE == 2
  158707             : //  printf("SgThisExp::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgThisExp::next_node);
  158708             :     printf("SgThisExp::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgThisExp::next_node);
  158709             : #endif
  158710             : 
  158711             : #if ROSE_PEDANTIC_ALLOC
  158712             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  158713             : #endif
  158714             : 
  158715             : #if ROSE_ALLOC_MEMSET == 1
  158716             : #elif ROSE_ALLOC_MEMSET == 2
  158717             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgThisExp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  158718             : #elif ROSE_ALLOC_MEMSET == 3
  158719             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgThisExp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  158720             : #endif
  158721             : 
  158722             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  158723             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  158724             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  158725             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  158726             : #else
  158727        2550 :     object->p_freepointer = SgThisExp::next_node;
  158728        2550 :     SgThisExp::next_node = object;
  158729             : #endif
  158730             : 
  158731             : #if ROSE_ALLOC_TRACE == 2
  158732             : //  printf("SgThisExp::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgThisExp::next_node);
  158733             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  158734             :     Rose::MemPool::snapshot(oss.str());
  158735             :     alloc_trace_cnt++;
  158736             : #endif
  158737             : 
  158738             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  158739             : 
  158740        2550 :     ALLOC_MUTEX(SgThisExp, unlock);
  158741             : }
  158742             : 
  158743             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  158744             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  158745             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  158746             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  158747             : // Also, note comment below from Robb (copied from the Common.code file).
  158748             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  158749             : //
  158750             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  158751             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  158752             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  158753             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  158754             : #if 0
  158755             : void SgThisExp::operator delete(void* pointer) { SgThisExp::operator delete (pointer, sizeof(SgThisExp)); };
  158756             : #endif
  158757             : /* #line 158758 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  158758             : 
  158759             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  158760             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  158761             : // obviously imply C++.
  158762             : 
  158763             : // This implements the support within ROSE for memory pools.  Memory pools
  158764             : // support the most condensed usage of memory within the construction of
  158765             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  158766             : // by a new operator written for each class.
  158767             : 
  158768             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  158769             :     // User wants multi-thread support and POSIX threads are available.
  158770             : #   include <pthread.h>
  158771             :     static pthread_mutex_t SgRefExp_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  158772             : #else
  158773             :      // Cause synchronization to be skipped.
  158774             : #    ifndef ALLOC_MUTEX
  158775             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  158776             : #    endif
  158777             : #    ifdef _REENTRANT
  158778             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  158779             : #       ifdef _MSC_VER
  158780             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  158781             : #       else
  158782             : #           warning "POSIX threads are not available; synchronization being skipped"
  158783             : #       endif
  158784             : #    endif
  158785             : #endif
  158786             : 
  158787             : #ifndef ROSE_ALLOC_TRACE
  158788             : #  define ROSE_ALLOC_TRACE 0
  158789             : #endif
  158790             : 
  158791             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  158792             : #define ROSE_ALLOC_TRACE_CNT
  158793             : #include "memory-pool-snapshot.h"
  158794             : unsigned long alloc_trace_cnt = 0;
  158795             : #endif
  158796             : 
  158797             : #if ROSE_ALLOC_TRACE
  158798             : const unsigned SgRefExp::pool_size = 5;
  158799             : #else
  158800             : const unsigned SgRefExp::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  158801             : #endif
  158802             : 
  158803             : #ifndef ROSE_ALLOC_MEMSET
  158804             : #  define ROSE_ALLOC_MEMSET 0
  158805             : #endif
  158806             : 
  158807             : #ifndef ROSE_PEDANTIC_ALLOC
  158808             : #  define ROSE_PEDANTIC_ALLOC 0
  158809             : #endif
  158810             : 
  158811             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  158812             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  158813             : #endif
  158814             : 
  158815             : #if !defined(SGNODE__ALL_POOLS)
  158816             : #define SGNODE__ALL_POOLS
  158817             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  158818             : #endif
  158819             : 
  158820             : SgRefExp* SgRefExp::next_node = nullptr;
  158821             : std::vector<unsigned char*> SgRefExp::pools;
  158822             : 
  158823             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  158824             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  158825             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  158826             : // around this macro definition rather than each use).
  158827             : #ifndef ALLOC_MUTEX
  158828             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  158829             :         do {                                                                     \
  158830             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  158831             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  158832             :                 abort();                                                         \
  158833             :             }                                                                    \
  158834             :         } while (0);
  158835             : #endif
  158836             : 
  158837             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  158838             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  158839             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  158840             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  158841             : 
  158842             : /*! \brief New operator for SgRefExp.
  158843             : 
  158844             :    This new operator implements memory pools to provide most efficent 
  158845             :    use of the heap within construction of large ASTs.
  158846             : 
  158847             : \internal The new and delete operators use the lower level C malloc/free
  158848             :    function calls for performance and to make sure that mixing of malloc/free
  158849             :    and new/delete by the used can be caught more readily.  This may change
  158850             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  158851             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  158852             :    deallocate memory allocated using ROSE_MALLOC.
  158853             : */
  158854           0 : void *SgRefExp::operator new ( size_t Size )
  158855             : {
  158856             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  158857             :      * returning or throwing an exception. */
  158858           0 :     ALLOC_MUTEX(SgRefExp, lock);
  158859             : 
  158860             : #if ROSE_ALLOC_TRACE == 2
  158861             : //    printf("SgRefExp::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgRefExp::next_node);
  158862             : #endif
  158863             : 
  158864             : #if USE_CPP_NEW_DELETE_OPERATORS
  158865             :     void *mem = ROSE_MALLOC(Size);
  158866             :     ALLOC_MUTEX(SgRefExp, unlock);
  158867             :     return mem;
  158868             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  158869             : #if ROSE_PEDANTIC_ALLOC
  158870             :     ROSE_ASSERT(Size == sizeof(SgRefExp));
  158871             : #else
  158872           0 :     if (Size != sizeof(SgRefExp)) {
  158873           0 :       void * object = ROSE_MALLOC(Size);
  158874           0 :       ALLOC_MUTEX(SgRefExp, unlock);
  158875             :       return object;
  158876             :     }
  158877             : #endif
  158878             : 
  158879           0 :     if (SgRefExp::next_node == nullptr) {
  158880           0 :         SgRefExp * alloc = (SgRefExp*) ROSE_MALLOC ( SgRefExp::pool_size * sizeof(SgRefExp) );
  158881           0 :         ROSE_ASSERT(alloc != nullptr);
  158882             : 
  158883             : #if ROSE_ALLOC_TRACE == 2
  158884             : //        printf("SgRefExp::alloc\n  block[%zi] = [ %p , %p [\n", SgRefExp::pools.size(), alloc, alloc + SgRefExp::pool_size);
  158885             : #endif
  158886             : 
  158887             : #if ROSE_ALLOC_MEMSET == 1
  158888             : #elif ROSE_ALLOC_MEMSET == 2
  158889             :         memset(alloc, 0x00, SgRefExp::pool_size * sizeof(SgRefExp));
  158890             : #elif ROSE_ALLOC_MEMSET == 3
  158891             :         memset(alloc, 0xAA, SgRefExp::pool_size * sizeof(SgRefExp));
  158892             : #endif
  158893           0 :         for (unsigned i=0; i < SgRefExp::pool_size-1; i++) {
  158894           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
  158895             :         }
  158896           0 :         alloc[SgRefExp::pool_size-1].p_freepointer = nullptr;
  158897             : 
  158898           0 :         SgRefExp::pools.push_back ( (unsigned char *) alloc );
  158899           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgRefExp::pool_size * sizeof(SgRefExp), V_SgRefExp ) );
  158900           0 :         SgRefExp::next_node = alloc;
  158901             :     }
  158902           0 :     ROSE_ASSERT(SgRefExp::next_node != nullptr);
  158903             : 
  158904           0 :     SgRefExp * object = SgRefExp::next_node;
  158905           0 :     SgRefExp::next_node = (SgRefExp*)(object->p_freepointer);
  158906             : 
  158907             : #if ROSE_ALLOC_TRACE == 2
  158908             :     printf("SgRefExp::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgRefExp::next_node);
  158909             : #endif
  158910             : 
  158911           0 :     SgNode * fp = object->p_freepointer;
  158912             : #if ROSE_ALLOC_MEMSET == 1
  158913             : #elif ROSE_ALLOC_MEMSET == 2
  158914             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgRefExp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  158915             : #elif ROSE_ALLOC_MEMSET == 3
  158916             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgRefExp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  158917             : #endif
  158918           0 :     object->p_freepointer = fp;
  158919             : 
  158920             : #if ROSE_ALLOC_TRACE == 2
  158921             : //    printf("SgRefExp::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgRefExp::next_node);
  158922             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  158923             :     Rose::MemPool::snapshot(oss.str());
  158924             :     alloc_trace_cnt++;
  158925             : #endif
  158926             : 
  158927           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  158928             : 
  158929           0 :     ALLOC_MUTEX(SgRefExp, unlock);
  158930             : 
  158931             :     return object;
  158932             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  158933             : }
  158934             : 
  158935             : 
  158936             : 
  158937             : /*! \brief Delete operator for SgRefExp.
  158938             : 
  158939             :    This delete operator implements deallocation using memory pools to 
  158940             :    provide most efficent use of the heap within construction of large ASTs.
  158941             : 
  158942             : \internal The new and delete operators use the lower level C malloc/free
  158943             :    function calls for performance and to make sure that mixing of malloc/free
  158944             :    and new/delete by the used can be caught more readily.  This may change
  158945             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  158946             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  158947             :    deallocate memory allocated using ROSE_MALLOC.
  158948             : */
  158949           0 : void SgRefExp::operator delete(void *Pointer, size_t Size)
  158950             : {
  158951             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  158952             :      * or throwing an exception. */
  158953           0 :     ALLOC_MUTEX(SgRefExp, lock);
  158954             : 
  158955             : #if USE_CPP_NEW_DELETE_OPERATORS
  158956             :     ROSE_FREE(Pointer);
  158957             : #else
  158958             : #if ROSE_PEDANTIC_ALLOC
  158959             :     ROSE_ASSERT(Size == sizeof(SgRefExp));
  158960             : #else
  158961           0 :     if (Size != sizeof(SgRefExp)) {
  158962           0 :       ROSE_FREE(Pointer);
  158963           0 :       ALLOC_MUTEX(SgRefExp, unlock);
  158964             :       return;
  158965             :     }
  158966             : #endif
  158967             : 
  158968           0 :     SgRefExp * object = (SgRefExp*) Pointer;
  158969           0 :     ROSE_ASSERT(object != nullptr);
  158970             : 
  158971             : #if ROSE_ALLOC_TRACE == 2
  158972             : //  printf("SgRefExp::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgRefExp::next_node);
  158973             :     printf("SgRefExp::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgRefExp::next_node);
  158974             : #endif
  158975             : 
  158976             : #if ROSE_PEDANTIC_ALLOC
  158977             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  158978             : #endif
  158979             : 
  158980             : #if ROSE_ALLOC_MEMSET == 1
  158981             : #elif ROSE_ALLOC_MEMSET == 2
  158982             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgRefExp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  158983             : #elif ROSE_ALLOC_MEMSET == 3
  158984             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgRefExp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  158985             : #endif
  158986             : 
  158987             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  158988             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  158989             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  158990             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  158991             : #else
  158992           0 :     object->p_freepointer = SgRefExp::next_node;
  158993           0 :     SgRefExp::next_node = object;
  158994             : #endif
  158995             : 
  158996             : #if ROSE_ALLOC_TRACE == 2
  158997             : //  printf("SgRefExp::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgRefExp::next_node);
  158998             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  158999             :     Rose::MemPool::snapshot(oss.str());
  159000             :     alloc_trace_cnt++;
  159001             : #endif
  159002             : 
  159003             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  159004             : 
  159005           0 :     ALLOC_MUTEX(SgRefExp, unlock);
  159006             : }
  159007             : 
  159008             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  159009             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  159010             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  159011             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  159012             : // Also, note comment below from Robb (copied from the Common.code file).
  159013             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  159014             : //
  159015             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  159016             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  159017             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  159018             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  159019             : #if 0
  159020             : void SgRefExp::operator delete(void* pointer) { SgRefExp::operator delete (pointer, sizeof(SgRefExp)); };
  159021             : #endif
  159022             : /* #line 159023 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  159023             : 
  159024             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  159025             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  159026             : // obviously imply C++.
  159027             : 
  159028             : // This implements the support within ROSE for memory pools.  Memory pools
  159029             : // support the most condensed usage of memory within the construction of
  159030             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  159031             : // by a new operator written for each class.
  159032             : 
  159033             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  159034             :     // User wants multi-thread support and POSIX threads are available.
  159035             : #   include <pthread.h>
  159036             :     static pthread_mutex_t SgInitializer_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  159037             : #else
  159038             :      // Cause synchronization to be skipped.
  159039             : #    ifndef ALLOC_MUTEX
  159040             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  159041             : #    endif
  159042             : #    ifdef _REENTRANT
  159043             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  159044             : #       ifdef _MSC_VER
  159045             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  159046             : #       else
  159047             : #           warning "POSIX threads are not available; synchronization being skipped"
  159048             : #       endif
  159049             : #    endif
  159050             : #endif
  159051             : 
  159052             : #ifndef ROSE_ALLOC_TRACE
  159053             : #  define ROSE_ALLOC_TRACE 0
  159054             : #endif
  159055             : 
  159056             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  159057             : #define ROSE_ALLOC_TRACE_CNT
  159058             : #include "memory-pool-snapshot.h"
  159059             : unsigned long alloc_trace_cnt = 0;
  159060             : #endif
  159061             : 
  159062             : #if ROSE_ALLOC_TRACE
  159063             : const unsigned SgInitializer::pool_size = 5;
  159064             : #else
  159065             : const unsigned SgInitializer::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  159066             : #endif
  159067             : 
  159068             : #ifndef ROSE_ALLOC_MEMSET
  159069             : #  define ROSE_ALLOC_MEMSET 0
  159070             : #endif
  159071             : 
  159072             : #ifndef ROSE_PEDANTIC_ALLOC
  159073             : #  define ROSE_PEDANTIC_ALLOC 0
  159074             : #endif
  159075             : 
  159076             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  159077             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  159078             : #endif
  159079             : 
  159080             : #if !defined(SGNODE__ALL_POOLS)
  159081             : #define SGNODE__ALL_POOLS
  159082             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  159083             : #endif
  159084             : 
  159085             : SgInitializer* SgInitializer::next_node = nullptr;
  159086             : std::vector<unsigned char*> SgInitializer::pools;
  159087             : 
  159088             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  159089             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  159090             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  159091             : // around this macro definition rather than each use).
  159092             : #ifndef ALLOC_MUTEX
  159093             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  159094             :         do {                                                                     \
  159095             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  159096             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  159097             :                 abort();                                                         \
  159098             :             }                                                                    \
  159099             :         } while (0);
  159100             : #endif
  159101             : 
  159102             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  159103             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  159104             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  159105             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  159106             : 
  159107             : /*! \brief New operator for SgInitializer.
  159108             : 
  159109             :    This new operator implements memory pools to provide most efficent 
  159110             :    use of the heap within construction of large ASTs.
  159111             : 
  159112             : \internal The new and delete operators use the lower level C malloc/free
  159113             :    function calls for performance and to make sure that mixing of malloc/free
  159114             :    and new/delete by the used can be caught more readily.  This may change
  159115             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  159116             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  159117             :    deallocate memory allocated using ROSE_MALLOC.
  159118             : */
  159119           0 : void *SgInitializer::operator new ( size_t Size )
  159120             : {
  159121             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  159122             :      * returning or throwing an exception. */
  159123           0 :     ALLOC_MUTEX(SgInitializer, lock);
  159124             : 
  159125             : #if ROSE_ALLOC_TRACE == 2
  159126             : //    printf("SgInitializer::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgInitializer::next_node);
  159127             : #endif
  159128             : 
  159129             : #if USE_CPP_NEW_DELETE_OPERATORS
  159130             :     void *mem = ROSE_MALLOC(Size);
  159131             :     ALLOC_MUTEX(SgInitializer, unlock);
  159132             :     return mem;
  159133             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  159134             : #if ROSE_PEDANTIC_ALLOC
  159135             :     ROSE_ASSERT(Size == sizeof(SgInitializer));
  159136             : #else
  159137           0 :     if (Size != sizeof(SgInitializer)) {
  159138           0 :       void * object = ROSE_MALLOC(Size);
  159139           0 :       ALLOC_MUTEX(SgInitializer, unlock);
  159140             :       return object;
  159141             :     }
  159142             : #endif
  159143             : 
  159144           0 :     if (SgInitializer::next_node == nullptr) {
  159145           0 :         SgInitializer * alloc = (SgInitializer*) ROSE_MALLOC ( SgInitializer::pool_size * sizeof(SgInitializer) );
  159146           0 :         ROSE_ASSERT(alloc != nullptr);
  159147             : 
  159148             : #if ROSE_ALLOC_TRACE == 2
  159149             : //        printf("SgInitializer::alloc\n  block[%zi] = [ %p , %p [\n", SgInitializer::pools.size(), alloc, alloc + SgInitializer::pool_size);
  159150             : #endif
  159151             : 
  159152             : #if ROSE_ALLOC_MEMSET == 1
  159153             : #elif ROSE_ALLOC_MEMSET == 2
  159154             :         memset(alloc, 0x00, SgInitializer::pool_size * sizeof(SgInitializer));
  159155             : #elif ROSE_ALLOC_MEMSET == 3
  159156             :         memset(alloc, 0xAA, SgInitializer::pool_size * sizeof(SgInitializer));
  159157             : #endif
  159158           0 :         for (unsigned i=0; i < SgInitializer::pool_size-1; i++) {
  159159           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
  159160             :         }
  159161           0 :         alloc[SgInitializer::pool_size-1].p_freepointer = nullptr;
  159162             : 
  159163           0 :         SgInitializer::pools.push_back ( (unsigned char *) alloc );
  159164           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgInitializer::pool_size * sizeof(SgInitializer), V_SgInitializer ) );
  159165           0 :         SgInitializer::next_node = alloc;
  159166             :     }
  159167           0 :     ROSE_ASSERT(SgInitializer::next_node != nullptr);
  159168             : 
  159169           0 :     SgInitializer * object = SgInitializer::next_node;
  159170           0 :     SgInitializer::next_node = (SgInitializer*)(object->p_freepointer);
  159171             : 
  159172             : #if ROSE_ALLOC_TRACE == 2
  159173             :     printf("SgInitializer::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgInitializer::next_node);
  159174             : #endif
  159175             : 
  159176           0 :     SgNode * fp = object->p_freepointer;
  159177             : #if ROSE_ALLOC_MEMSET == 1
  159178             : #elif ROSE_ALLOC_MEMSET == 2
  159179             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgInitializer) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  159180             : #elif ROSE_ALLOC_MEMSET == 3
  159181             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgInitializer) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  159182             : #endif
  159183           0 :     object->p_freepointer = fp;
  159184             : 
  159185             : #if ROSE_ALLOC_TRACE == 2
  159186             : //    printf("SgInitializer::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgInitializer::next_node);
  159187             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  159188             :     Rose::MemPool::snapshot(oss.str());
  159189             :     alloc_trace_cnt++;
  159190             : #endif
  159191             : 
  159192           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  159193             : 
  159194           0 :     ALLOC_MUTEX(SgInitializer, unlock);
  159195             : 
  159196             :     return object;
  159197             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  159198             : }
  159199             : 
  159200             : 
  159201             : 
  159202             : /*! \brief Delete operator for SgInitializer.
  159203             : 
  159204             :    This delete operator implements deallocation using memory pools to 
  159205             :    provide most efficent use of the heap within construction of large ASTs.
  159206             : 
  159207             : \internal The new and delete operators use the lower level C malloc/free
  159208             :    function calls for performance and to make sure that mixing of malloc/free
  159209             :    and new/delete by the used can be caught more readily.  This may change
  159210             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  159211             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  159212             :    deallocate memory allocated using ROSE_MALLOC.
  159213             : */
  159214           0 : void SgInitializer::operator delete(void *Pointer, size_t Size)
  159215             : {
  159216             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  159217             :      * or throwing an exception. */
  159218           0 :     ALLOC_MUTEX(SgInitializer, lock);
  159219             : 
  159220             : #if USE_CPP_NEW_DELETE_OPERATORS
  159221             :     ROSE_FREE(Pointer);
  159222             : #else
  159223             : #if ROSE_PEDANTIC_ALLOC
  159224             :     ROSE_ASSERT(Size == sizeof(SgInitializer));
  159225             : #else
  159226           0 :     if (Size != sizeof(SgInitializer)) {
  159227           0 :       ROSE_FREE(Pointer);
  159228           0 :       ALLOC_MUTEX(SgInitializer, unlock);
  159229             :       return;
  159230             :     }
  159231             : #endif
  159232             : 
  159233           0 :     SgInitializer * object = (SgInitializer*) Pointer;
  159234           0 :     ROSE_ASSERT(object != nullptr);
  159235             : 
  159236             : #if ROSE_ALLOC_TRACE == 2
  159237             : //  printf("SgInitializer::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgInitializer::next_node);
  159238             :     printf("SgInitializer::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgInitializer::next_node);
  159239             : #endif
  159240             : 
  159241             : #if ROSE_PEDANTIC_ALLOC
  159242             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  159243             : #endif
  159244             : 
  159245             : #if ROSE_ALLOC_MEMSET == 1
  159246             : #elif ROSE_ALLOC_MEMSET == 2
  159247             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgInitializer) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  159248             : #elif ROSE_ALLOC_MEMSET == 3
  159249             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgInitializer) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  159250             : #endif
  159251             : 
  159252             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  159253             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  159254             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  159255             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  159256             : #else
  159257           0 :     object->p_freepointer = SgInitializer::next_node;
  159258           0 :     SgInitializer::next_node = object;
  159259             : #endif
  159260             : 
  159261             : #if ROSE_ALLOC_TRACE == 2
  159262             : //  printf("SgInitializer::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgInitializer::next_node);
  159263             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  159264             :     Rose::MemPool::snapshot(oss.str());
  159265             :     alloc_trace_cnt++;
  159266             : #endif
  159267             : 
  159268             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  159269             : 
  159270           0 :     ALLOC_MUTEX(SgInitializer, unlock);
  159271             : }
  159272             : 
  159273             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  159274             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  159275             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  159276             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  159277             : // Also, note comment below from Robb (copied from the Common.code file).
  159278             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  159279             : //
  159280             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  159281             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  159282             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  159283             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  159284             : #if 0
  159285             : void SgInitializer::operator delete(void* pointer) { SgInitializer::operator delete (pointer, sizeof(SgInitializer)); };
  159286             : #endif
  159287             : /* #line 159288 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  159288             : 
  159289             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  159290             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  159291             : // obviously imply C++.
  159292             : 
  159293             : // This implements the support within ROSE for memory pools.  Memory pools
  159294             : // support the most condensed usage of memory within the construction of
  159295             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  159296             : // by a new operator written for each class.
  159297             : 
  159298             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  159299             :     // User wants multi-thread support and POSIX threads are available.
  159300             : #   include <pthread.h>
  159301             :     static pthread_mutex_t SgAggregateInitializer_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  159302             : #else
  159303             :      // Cause synchronization to be skipped.
  159304             : #    ifndef ALLOC_MUTEX
  159305             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  159306             : #    endif
  159307             : #    ifdef _REENTRANT
  159308             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  159309             : #       ifdef _MSC_VER
  159310             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  159311             : #       else
  159312             : #           warning "POSIX threads are not available; synchronization being skipped"
  159313             : #       endif
  159314             : #    endif
  159315             : #endif
  159316             : 
  159317             : #ifndef ROSE_ALLOC_TRACE
  159318             : #  define ROSE_ALLOC_TRACE 0
  159319             : #endif
  159320             : 
  159321             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  159322             : #define ROSE_ALLOC_TRACE_CNT
  159323             : #include "memory-pool-snapshot.h"
  159324             : unsigned long alloc_trace_cnt = 0;
  159325             : #endif
  159326             : 
  159327             : #if ROSE_ALLOC_TRACE
  159328             : const unsigned SgAggregateInitializer::pool_size = 5;
  159329             : #else
  159330             : const unsigned SgAggregateInitializer::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  159331             : #endif
  159332             : 
  159333             : #ifndef ROSE_ALLOC_MEMSET
  159334             : #  define ROSE_ALLOC_MEMSET 0
  159335             : #endif
  159336             : 
  159337             : #ifndef ROSE_PEDANTIC_ALLOC
  159338             : #  define ROSE_PEDANTIC_ALLOC 0
  159339             : #endif
  159340             : 
  159341             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  159342             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  159343             : #endif
  159344             : 
  159345             : #if !defined(SGNODE__ALL_POOLS)
  159346             : #define SGNODE__ALL_POOLS
  159347             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  159348             : #endif
  159349             : 
  159350             : SgAggregateInitializer* SgAggregateInitializer::next_node = nullptr;
  159351             : std::vector<unsigned char*> SgAggregateInitializer::pools;
  159352             : 
  159353             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  159354             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  159355             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  159356             : // around this macro definition rather than each use).
  159357             : #ifndef ALLOC_MUTEX
  159358             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  159359             :         do {                                                                     \
  159360             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  159361             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  159362             :                 abort();                                                         \
  159363             :             }                                                                    \
  159364             :         } while (0);
  159365             : #endif
  159366             : 
  159367             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  159368             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  159369             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  159370             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  159371             : 
  159372             : /*! \brief New operator for SgAggregateInitializer.
  159373             : 
  159374             :    This new operator implements memory pools to provide most efficent 
  159375             :    use of the heap within construction of large ASTs.
  159376             : 
  159377             : \internal The new and delete operators use the lower level C malloc/free
  159378             :    function calls for performance and to make sure that mixing of malloc/free
  159379             :    and new/delete by the used can be caught more readily.  This may change
  159380             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  159381             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  159382             :    deallocate memory allocated using ROSE_MALLOC.
  159383             : */
  159384         275 : void *SgAggregateInitializer::operator new ( size_t Size )
  159385             : {
  159386             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  159387             :      * returning or throwing an exception. */
  159388         275 :     ALLOC_MUTEX(SgAggregateInitializer, lock);
  159389             : 
  159390             : #if ROSE_ALLOC_TRACE == 2
  159391             : //    printf("SgAggregateInitializer::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgAggregateInitializer::next_node);
  159392             : #endif
  159393             : 
  159394             : #if USE_CPP_NEW_DELETE_OPERATORS
  159395             :     void *mem = ROSE_MALLOC(Size);
  159396             :     ALLOC_MUTEX(SgAggregateInitializer, unlock);
  159397             :     return mem;
  159398             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  159399             : #if ROSE_PEDANTIC_ALLOC
  159400             :     ROSE_ASSERT(Size == sizeof(SgAggregateInitializer));
  159401             : #else
  159402         275 :     if (Size != sizeof(SgAggregateInitializer)) {
  159403           0 :       void * object = ROSE_MALLOC(Size);
  159404           0 :       ALLOC_MUTEX(SgAggregateInitializer, unlock);
  159405             :       return object;
  159406             :     }
  159407             : #endif
  159408             : 
  159409         275 :     if (SgAggregateInitializer::next_node == nullptr) {
  159410          15 :         SgAggregateInitializer * alloc = (SgAggregateInitializer*) ROSE_MALLOC ( SgAggregateInitializer::pool_size * sizeof(SgAggregateInitializer) );
  159411          15 :         ROSE_ASSERT(alloc != nullptr);
  159412             : 
  159413             : #if ROSE_ALLOC_TRACE == 2
  159414             : //        printf("SgAggregateInitializer::alloc\n  block[%zi] = [ %p , %p [\n", SgAggregateInitializer::pools.size(), alloc, alloc + SgAggregateInitializer::pool_size);
  159415             : #endif
  159416             : 
  159417             : #if ROSE_ALLOC_MEMSET == 1
  159418             : #elif ROSE_ALLOC_MEMSET == 2
  159419             :         memset(alloc, 0x00, SgAggregateInitializer::pool_size * sizeof(SgAggregateInitializer));
  159420             : #elif ROSE_ALLOC_MEMSET == 3
  159421             :         memset(alloc, 0xAA, SgAggregateInitializer::pool_size * sizeof(SgAggregateInitializer));
  159422             : #endif
  159423       30000 :         for (unsigned i=0; i < SgAggregateInitializer::pool_size-1; i++) {
  159424       29985 :           alloc[i].p_freepointer = &(alloc[i+1]);
  159425             :         }
  159426          15 :         alloc[SgAggregateInitializer::pool_size-1].p_freepointer = nullptr;
  159427             : 
  159428          15 :         SgAggregateInitializer::pools.push_back ( (unsigned char *) alloc );
  159429          15 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgAggregateInitializer::pool_size * sizeof(SgAggregateInitializer), V_SgAggregateInitializer ) );
  159430          15 :         SgAggregateInitializer::next_node = alloc;
  159431             :     }
  159432         275 :     ROSE_ASSERT(SgAggregateInitializer::next_node != nullptr);
  159433             : 
  159434         275 :     SgAggregateInitializer * object = SgAggregateInitializer::next_node;
  159435         275 :     SgAggregateInitializer::next_node = (SgAggregateInitializer*)(object->p_freepointer);
  159436             : 
  159437             : #if ROSE_ALLOC_TRACE == 2
  159438             :     printf("SgAggregateInitializer::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgAggregateInitializer::next_node);
  159439             : #endif
  159440             : 
  159441         275 :     SgNode * fp = object->p_freepointer;
  159442             : #if ROSE_ALLOC_MEMSET == 1
  159443             : #elif ROSE_ALLOC_MEMSET == 2
  159444             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgAggregateInitializer) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  159445             : #elif ROSE_ALLOC_MEMSET == 3
  159446             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgAggregateInitializer) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  159447             : #endif
  159448         275 :     object->p_freepointer = fp;
  159449             : 
  159450             : #if ROSE_ALLOC_TRACE == 2
  159451             : //    printf("SgAggregateInitializer::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgAggregateInitializer::next_node);
  159452             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  159453             :     Rose::MemPool::snapshot(oss.str());
  159454             :     alloc_trace_cnt++;
  159455             : #endif
  159456             : 
  159457         275 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  159458             : 
  159459         275 :     ALLOC_MUTEX(SgAggregateInitializer, unlock);
  159460             : 
  159461             :     return object;
  159462             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  159463             : }
  159464             : 
  159465             : 
  159466             : 
  159467             : /*! \brief Delete operator for SgAggregateInitializer.
  159468             : 
  159469             :    This delete operator implements deallocation using memory pools to 
  159470             :    provide most efficent use of the heap within construction of large ASTs.
  159471             : 
  159472             : \internal The new and delete operators use the lower level C malloc/free
  159473             :    function calls for performance and to make sure that mixing of malloc/free
  159474             :    and new/delete by the used can be caught more readily.  This may change
  159475             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  159476             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  159477             :    deallocate memory allocated using ROSE_MALLOC.
  159478             : */
  159479         198 : void SgAggregateInitializer::operator delete(void *Pointer, size_t Size)
  159480             : {
  159481             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  159482             :      * or throwing an exception. */
  159483         198 :     ALLOC_MUTEX(SgAggregateInitializer, lock);
  159484             : 
  159485             : #if USE_CPP_NEW_DELETE_OPERATORS
  159486             :     ROSE_FREE(Pointer);
  159487             : #else
  159488             : #if ROSE_PEDANTIC_ALLOC
  159489             :     ROSE_ASSERT(Size == sizeof(SgAggregateInitializer));
  159490             : #else
  159491         198 :     if (Size != sizeof(SgAggregateInitializer)) {
  159492           0 :       ROSE_FREE(Pointer);
  159493           0 :       ALLOC_MUTEX(SgAggregateInitializer, unlock);
  159494             :       return;
  159495             :     }
  159496             : #endif
  159497             : 
  159498         198 :     SgAggregateInitializer * object = (SgAggregateInitializer*) Pointer;
  159499         198 :     ROSE_ASSERT(object != nullptr);
  159500             : 
  159501             : #if ROSE_ALLOC_TRACE == 2
  159502             : //  printf("SgAggregateInitializer::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgAggregateInitializer::next_node);
  159503             :     printf("SgAggregateInitializer::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgAggregateInitializer::next_node);
  159504             : #endif
  159505             : 
  159506             : #if ROSE_PEDANTIC_ALLOC
  159507             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  159508             : #endif
  159509             : 
  159510             : #if ROSE_ALLOC_MEMSET == 1
  159511             : #elif ROSE_ALLOC_MEMSET == 2
  159512             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgAggregateInitializer) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  159513             : #elif ROSE_ALLOC_MEMSET == 3
  159514             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgAggregateInitializer) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  159515             : #endif
  159516             : 
  159517             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  159518             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  159519             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  159520             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  159521             : #else
  159522         198 :     object->p_freepointer = SgAggregateInitializer::next_node;
  159523         198 :     SgAggregateInitializer::next_node = object;
  159524             : #endif
  159525             : 
  159526             : #if ROSE_ALLOC_TRACE == 2
  159527             : //  printf("SgAggregateInitializer::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgAggregateInitializer::next_node);
  159528             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  159529             :     Rose::MemPool::snapshot(oss.str());
  159530             :     alloc_trace_cnt++;
  159531             : #endif
  159532             : 
  159533             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  159534             : 
  159535         198 :     ALLOC_MUTEX(SgAggregateInitializer, unlock);
  159536             : }
  159537             : 
  159538             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  159539             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  159540             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  159541             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  159542             : // Also, note comment below from Robb (copied from the Common.code file).
  159543             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  159544             : //
  159545             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  159546             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  159547             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  159548             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  159549             : #if 0
  159550             : void SgAggregateInitializer::operator delete(void* pointer) { SgAggregateInitializer::operator delete (pointer, sizeof(SgAggregateInitializer)); };
  159551             : #endif
  159552             : /* #line 159553 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  159553             : 
  159554             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  159555             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  159556             : // obviously imply C++.
  159557             : 
  159558             : // This implements the support within ROSE for memory pools.  Memory pools
  159559             : // support the most condensed usage of memory within the construction of
  159560             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  159561             : // by a new operator written for each class.
  159562             : 
  159563             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  159564             :     // User wants multi-thread support and POSIX threads are available.
  159565             : #   include <pthread.h>
  159566             :     static pthread_mutex_t SgCompoundInitializer_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  159567             : #else
  159568             :      // Cause synchronization to be skipped.
  159569             : #    ifndef ALLOC_MUTEX
  159570             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  159571             : #    endif
  159572             : #    ifdef _REENTRANT
  159573             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  159574             : #       ifdef _MSC_VER
  159575             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  159576             : #       else
  159577             : #           warning "POSIX threads are not available; synchronization being skipped"
  159578             : #       endif
  159579             : #    endif
  159580             : #endif
  159581             : 
  159582             : #ifndef ROSE_ALLOC_TRACE
  159583             : #  define ROSE_ALLOC_TRACE 0
  159584             : #endif
  159585             : 
  159586             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  159587             : #define ROSE_ALLOC_TRACE_CNT
  159588             : #include "memory-pool-snapshot.h"
  159589             : unsigned long alloc_trace_cnt = 0;
  159590             : #endif
  159591             : 
  159592             : #if ROSE_ALLOC_TRACE
  159593             : const unsigned SgCompoundInitializer::pool_size = 5;
  159594             : #else
  159595             : const unsigned SgCompoundInitializer::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  159596             : #endif
  159597             : 
  159598             : #ifndef ROSE_ALLOC_MEMSET
  159599             : #  define ROSE_ALLOC_MEMSET 0
  159600             : #endif
  159601             : 
  159602             : #ifndef ROSE_PEDANTIC_ALLOC
  159603             : #  define ROSE_PEDANTIC_ALLOC 0
  159604             : #endif
  159605             : 
  159606             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  159607             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  159608             : #endif
  159609             : 
  159610             : #if !defined(SGNODE__ALL_POOLS)
  159611             : #define SGNODE__ALL_POOLS
  159612             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  159613             : #endif
  159614             : 
  159615             : SgCompoundInitializer* SgCompoundInitializer::next_node = nullptr;
  159616             : std::vector<unsigned char*> SgCompoundInitializer::pools;
  159617             : 
  159618             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  159619             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  159620             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  159621             : // around this macro definition rather than each use).
  159622             : #ifndef ALLOC_MUTEX
  159623             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  159624             :         do {                                                                     \
  159625             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  159626             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  159627             :                 abort();                                                         \
  159628             :             }                                                                    \
  159629             :         } while (0);
  159630             : #endif
  159631             : 
  159632             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  159633             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  159634             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  159635             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  159636             : 
  159637             : /*! \brief New operator for SgCompoundInitializer.
  159638             : 
  159639             :    This new operator implements memory pools to provide most efficent 
  159640             :    use of the heap within construction of large ASTs.
  159641             : 
  159642             : \internal The new and delete operators use the lower level C malloc/free
  159643             :    function calls for performance and to make sure that mixing of malloc/free
  159644             :    and new/delete by the used can be caught more readily.  This may change
  159645             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  159646             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  159647             :    deallocate memory allocated using ROSE_MALLOC.
  159648             : */
  159649           0 : void *SgCompoundInitializer::operator new ( size_t Size )
  159650             : {
  159651             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  159652             :      * returning or throwing an exception. */
  159653           0 :     ALLOC_MUTEX(SgCompoundInitializer, lock);
  159654             : 
  159655             : #if ROSE_ALLOC_TRACE == 2
  159656             : //    printf("SgCompoundInitializer::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgCompoundInitializer::next_node);
  159657             : #endif
  159658             : 
  159659             : #if USE_CPP_NEW_DELETE_OPERATORS
  159660             :     void *mem = ROSE_MALLOC(Size);
  159661             :     ALLOC_MUTEX(SgCompoundInitializer, unlock);
  159662             :     return mem;
  159663             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  159664             : #if ROSE_PEDANTIC_ALLOC
  159665             :     ROSE_ASSERT(Size == sizeof(SgCompoundInitializer));
  159666             : #else
  159667           0 :     if (Size != sizeof(SgCompoundInitializer)) {
  159668           0 :       void * object = ROSE_MALLOC(Size);
  159669           0 :       ALLOC_MUTEX(SgCompoundInitializer, unlock);
  159670             :       return object;
  159671             :     }
  159672             : #endif
  159673             : 
  159674           0 :     if (SgCompoundInitializer::next_node == nullptr) {
  159675           0 :         SgCompoundInitializer * alloc = (SgCompoundInitializer*) ROSE_MALLOC ( SgCompoundInitializer::pool_size * sizeof(SgCompoundInitializer) );
  159676           0 :         ROSE_ASSERT(alloc != nullptr);
  159677             : 
  159678             : #if ROSE_ALLOC_TRACE == 2
  159679             : //        printf("SgCompoundInitializer::alloc\n  block[%zi] = [ %p , %p [\n", SgCompoundInitializer::pools.size(), alloc, alloc + SgCompoundInitializer::pool_size);
  159680             : #endif
  159681             : 
  159682             : #if ROSE_ALLOC_MEMSET == 1
  159683             : #elif ROSE_ALLOC_MEMSET == 2
  159684             :         memset(alloc, 0x00, SgCompoundInitializer::pool_size * sizeof(SgCompoundInitializer));
  159685             : #elif ROSE_ALLOC_MEMSET == 3
  159686             :         memset(alloc, 0xAA, SgCompoundInitializer::pool_size * sizeof(SgCompoundInitializer));
  159687             : #endif
  159688           0 :         for (unsigned i=0; i < SgCompoundInitializer::pool_size-1; i++) {
  159689           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
  159690             :         }
  159691           0 :         alloc[SgCompoundInitializer::pool_size-1].p_freepointer = nullptr;
  159692             : 
  159693           0 :         SgCompoundInitializer::pools.push_back ( (unsigned char *) alloc );
  159694           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgCompoundInitializer::pool_size * sizeof(SgCompoundInitializer), V_SgCompoundInitializer ) );
  159695           0 :         SgCompoundInitializer::next_node = alloc;
  159696             :     }
  159697           0 :     ROSE_ASSERT(SgCompoundInitializer::next_node != nullptr);
  159698             : 
  159699           0 :     SgCompoundInitializer * object = SgCompoundInitializer::next_node;
  159700           0 :     SgCompoundInitializer::next_node = (SgCompoundInitializer*)(object->p_freepointer);
  159701             : 
  159702             : #if ROSE_ALLOC_TRACE == 2
  159703             :     printf("SgCompoundInitializer::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgCompoundInitializer::next_node);
  159704             : #endif
  159705             : 
  159706           0 :     SgNode * fp = object->p_freepointer;
  159707             : #if ROSE_ALLOC_MEMSET == 1
  159708             : #elif ROSE_ALLOC_MEMSET == 2
  159709             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgCompoundInitializer) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  159710             : #elif ROSE_ALLOC_MEMSET == 3
  159711             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgCompoundInitializer) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  159712             : #endif
  159713           0 :     object->p_freepointer = fp;
  159714             : 
  159715             : #if ROSE_ALLOC_TRACE == 2
  159716             : //    printf("SgCompoundInitializer::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgCompoundInitializer::next_node);
  159717             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  159718             :     Rose::MemPool::snapshot(oss.str());
  159719             :     alloc_trace_cnt++;
  159720             : #endif
  159721             : 
  159722           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  159723             : 
  159724           0 :     ALLOC_MUTEX(SgCompoundInitializer, unlock);
  159725             : 
  159726             :     return object;
  159727             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  159728             : }
  159729             : 
  159730             : 
  159731             : 
  159732             : /*! \brief Delete operator for SgCompoundInitializer.
  159733             : 
  159734             :    This delete operator implements deallocation using memory pools to 
  159735             :    provide most efficent use of the heap within construction of large ASTs.
  159736             : 
  159737             : \internal The new and delete operators use the lower level C malloc/free
  159738             :    function calls for performance and to make sure that mixing of malloc/free
  159739             :    and new/delete by the used can be caught more readily.  This may change
  159740             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  159741             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  159742             :    deallocate memory allocated using ROSE_MALLOC.
  159743             : */
  159744           0 : void SgCompoundInitializer::operator delete(void *Pointer, size_t Size)
  159745             : {
  159746             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  159747             :      * or throwing an exception. */
  159748           0 :     ALLOC_MUTEX(SgCompoundInitializer, lock);
  159749             : 
  159750             : #if USE_CPP_NEW_DELETE_OPERATORS
  159751             :     ROSE_FREE(Pointer);
  159752             : #else
  159753             : #if ROSE_PEDANTIC_ALLOC
  159754             :     ROSE_ASSERT(Size == sizeof(SgCompoundInitializer));
  159755             : #else
  159756           0 :     if (Size != sizeof(SgCompoundInitializer)) {
  159757           0 :       ROSE_FREE(Pointer);
  159758           0 :       ALLOC_MUTEX(SgCompoundInitializer, unlock);
  159759             :       return;
  159760             :     }
  159761             : #endif
  159762             : 
  159763           0 :     SgCompoundInitializer * object = (SgCompoundInitializer*) Pointer;
  159764           0 :     ROSE_ASSERT(object != nullptr);
  159765             : 
  159766             : #if ROSE_ALLOC_TRACE == 2
  159767             : //  printf("SgCompoundInitializer::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgCompoundInitializer::next_node);
  159768             :     printf("SgCompoundInitializer::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgCompoundInitializer::next_node);
  159769             : #endif
  159770             : 
  159771             : #if ROSE_PEDANTIC_ALLOC
  159772             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  159773             : #endif
  159774             : 
  159775             : #if ROSE_ALLOC_MEMSET == 1
  159776             : #elif ROSE_ALLOC_MEMSET == 2
  159777             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgCompoundInitializer) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  159778             : #elif ROSE_ALLOC_MEMSET == 3
  159779             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgCompoundInitializer) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  159780             : #endif
  159781             : 
  159782             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  159783             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  159784             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  159785             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  159786             : #else
  159787           0 :     object->p_freepointer = SgCompoundInitializer::next_node;
  159788           0 :     SgCompoundInitializer::next_node = object;
  159789             : #endif
  159790             : 
  159791             : #if ROSE_ALLOC_TRACE == 2
  159792             : //  printf("SgCompoundInitializer::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgCompoundInitializer::next_node);
  159793             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  159794             :     Rose::MemPool::snapshot(oss.str());
  159795             :     alloc_trace_cnt++;
  159796             : #endif
  159797             : 
  159798             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  159799             : 
  159800           0 :     ALLOC_MUTEX(SgCompoundInitializer, unlock);
  159801             : }
  159802             : 
  159803             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  159804             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  159805             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  159806             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  159807             : // Also, note comment below from Robb (copied from the Common.code file).
  159808             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  159809             : //
  159810             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  159811             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  159812             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  159813             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  159814             : #if 0
  159815             : void SgCompoundInitializer::operator delete(void* pointer) { SgCompoundInitializer::operator delete (pointer, sizeof(SgCompoundInitializer)); };
  159816             : #endif
  159817             : /* #line 159818 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  159818             : 
  159819             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  159820             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  159821             : // obviously imply C++.
  159822             : 
  159823             : // This implements the support within ROSE for memory pools.  Memory pools
  159824             : // support the most condensed usage of memory within the construction of
  159825             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  159826             : // by a new operator written for each class.
  159827             : 
  159828             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  159829             :     // User wants multi-thread support and POSIX threads are available.
  159830             : #   include <pthread.h>
  159831             :     static pthread_mutex_t SgConstructorInitializer_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  159832             : #else
  159833             :      // Cause synchronization to be skipped.
  159834             : #    ifndef ALLOC_MUTEX
  159835             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  159836             : #    endif
  159837             : #    ifdef _REENTRANT
  159838             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  159839             : #       ifdef _MSC_VER
  159840             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  159841             : #       else
  159842             : #           warning "POSIX threads are not available; synchronization being skipped"
  159843             : #       endif
  159844             : #    endif
  159845             : #endif
  159846             : 
  159847             : #ifndef ROSE_ALLOC_TRACE
  159848             : #  define ROSE_ALLOC_TRACE 0
  159849             : #endif
  159850             : 
  159851             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  159852             : #define ROSE_ALLOC_TRACE_CNT
  159853             : #include "memory-pool-snapshot.h"
  159854             : unsigned long alloc_trace_cnt = 0;
  159855             : #endif
  159856             : 
  159857             : #if ROSE_ALLOC_TRACE
  159858             : const unsigned SgConstructorInitializer::pool_size = 5;
  159859             : #else
  159860             : const unsigned SgConstructorInitializer::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  159861             : #endif
  159862             : 
  159863             : #ifndef ROSE_ALLOC_MEMSET
  159864             : #  define ROSE_ALLOC_MEMSET 0
  159865             : #endif
  159866             : 
  159867             : #ifndef ROSE_PEDANTIC_ALLOC
  159868             : #  define ROSE_PEDANTIC_ALLOC 0
  159869             : #endif
  159870             : 
  159871             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  159872             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  159873             : #endif
  159874             : 
  159875             : #if !defined(SGNODE__ALL_POOLS)
  159876             : #define SGNODE__ALL_POOLS
  159877             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  159878             : #endif
  159879             : 
  159880             : SgConstructorInitializer* SgConstructorInitializer::next_node = nullptr;
  159881             : std::vector<unsigned char*> SgConstructorInitializer::pools;
  159882             : 
  159883             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  159884             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  159885             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  159886             : // around this macro definition rather than each use).
  159887             : #ifndef ALLOC_MUTEX
  159888             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  159889             :         do {                                                                     \
  159890             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  159891             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  159892             :                 abort();                                                         \
  159893             :             }                                                                    \
  159894             :         } while (0);
  159895             : #endif
  159896             : 
  159897             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  159898             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  159899             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  159900             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  159901             : 
  159902             : /*! \brief New operator for SgConstructorInitializer.
  159903             : 
  159904             :    This new operator implements memory pools to provide most efficent 
  159905             :    use of the heap within construction of large ASTs.
  159906             : 
  159907             : \internal The new and delete operators use the lower level C malloc/free
  159908             :    function calls for performance and to make sure that mixing of malloc/free
  159909             :    and new/delete by the used can be caught more readily.  This may change
  159910             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  159911             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  159912             :    deallocate memory allocated using ROSE_MALLOC.
  159913             : */
  159914        5047 : void *SgConstructorInitializer::operator new ( size_t Size )
  159915             : {
  159916             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  159917             :      * returning or throwing an exception. */
  159918        5047 :     ALLOC_MUTEX(SgConstructorInitializer, lock);
  159919             : 
  159920             : #if ROSE_ALLOC_TRACE == 2
  159921             : //    printf("SgConstructorInitializer::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgConstructorInitializer::next_node);
  159922             : #endif
  159923             : 
  159924             : #if USE_CPP_NEW_DELETE_OPERATORS
  159925             :     void *mem = ROSE_MALLOC(Size);
  159926             :     ALLOC_MUTEX(SgConstructorInitializer, unlock);
  159927             :     return mem;
  159928             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  159929             : #if ROSE_PEDANTIC_ALLOC
  159930             :     ROSE_ASSERT(Size == sizeof(SgConstructorInitializer));
  159931             : #else
  159932        5047 :     if (Size != sizeof(SgConstructorInitializer)) {
  159933           0 :       void * object = ROSE_MALLOC(Size);
  159934           0 :       ALLOC_MUTEX(SgConstructorInitializer, unlock);
  159935             :       return object;
  159936             :     }
  159937             : #endif
  159938             : 
  159939        5047 :     if (SgConstructorInitializer::next_node == nullptr) {
  159940          14 :         SgConstructorInitializer * alloc = (SgConstructorInitializer*) ROSE_MALLOC ( SgConstructorInitializer::pool_size * sizeof(SgConstructorInitializer) );
  159941          14 :         ROSE_ASSERT(alloc != nullptr);
  159942             : 
  159943             : #if ROSE_ALLOC_TRACE == 2
  159944             : //        printf("SgConstructorInitializer::alloc\n  block[%zi] = [ %p , %p [\n", SgConstructorInitializer::pools.size(), alloc, alloc + SgConstructorInitializer::pool_size);
  159945             : #endif
  159946             : 
  159947             : #if ROSE_ALLOC_MEMSET == 1
  159948             : #elif ROSE_ALLOC_MEMSET == 2
  159949             :         memset(alloc, 0x00, SgConstructorInitializer::pool_size * sizeof(SgConstructorInitializer));
  159950             : #elif ROSE_ALLOC_MEMSET == 3
  159951             :         memset(alloc, 0xAA, SgConstructorInitializer::pool_size * sizeof(SgConstructorInitializer));
  159952             : #endif
  159953       28000 :         for (unsigned i=0; i < SgConstructorInitializer::pool_size-1; i++) {
  159954       27986 :           alloc[i].p_freepointer = &(alloc[i+1]);
  159955             :         }
  159956          14 :         alloc[SgConstructorInitializer::pool_size-1].p_freepointer = nullptr;
  159957             : 
  159958          14 :         SgConstructorInitializer::pools.push_back ( (unsigned char *) alloc );
  159959          14 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgConstructorInitializer::pool_size * sizeof(SgConstructorInitializer), V_SgConstructorInitializer ) );
  159960          14 :         SgConstructorInitializer::next_node = alloc;
  159961             :     }
  159962        5047 :     ROSE_ASSERT(SgConstructorInitializer::next_node != nullptr);
  159963             : 
  159964        5047 :     SgConstructorInitializer * object = SgConstructorInitializer::next_node;
  159965        5047 :     SgConstructorInitializer::next_node = (SgConstructorInitializer*)(object->p_freepointer);
  159966             : 
  159967             : #if ROSE_ALLOC_TRACE == 2
  159968             :     printf("SgConstructorInitializer::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgConstructorInitializer::next_node);
  159969             : #endif
  159970             : 
  159971        5047 :     SgNode * fp = object->p_freepointer;
  159972             : #if ROSE_ALLOC_MEMSET == 1
  159973             : #elif ROSE_ALLOC_MEMSET == 2
  159974             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgConstructorInitializer) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  159975             : #elif ROSE_ALLOC_MEMSET == 3
  159976             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgConstructorInitializer) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  159977             : #endif
  159978        5047 :     object->p_freepointer = fp;
  159979             : 
  159980             : #if ROSE_ALLOC_TRACE == 2
  159981             : //    printf("SgConstructorInitializer::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgConstructorInitializer::next_node);
  159982             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  159983             :     Rose::MemPool::snapshot(oss.str());
  159984             :     alloc_trace_cnt++;
  159985             : #endif
  159986             : 
  159987        5047 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  159988             : 
  159989        5047 :     ALLOC_MUTEX(SgConstructorInitializer, unlock);
  159990             : 
  159991             :     return object;
  159992             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  159993             : }
  159994             : 
  159995             : 
  159996             : 
  159997             : /*! \brief Delete operator for SgConstructorInitializer.
  159998             : 
  159999             :    This delete operator implements deallocation using memory pools to 
  160000             :    provide most efficent use of the heap within construction of large ASTs.
  160001             : 
  160002             : \internal The new and delete operators use the lower level C malloc/free
  160003             :    function calls for performance and to make sure that mixing of malloc/free
  160004             :    and new/delete by the used can be caught more readily.  This may change
  160005             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  160006             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  160007             :    deallocate memory allocated using ROSE_MALLOC.
  160008             : */
  160009        1027 : void SgConstructorInitializer::operator delete(void *Pointer, size_t Size)
  160010             : {
  160011             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  160012             :      * or throwing an exception. */
  160013        1027 :     ALLOC_MUTEX(SgConstructorInitializer, lock);
  160014             : 
  160015             : #if USE_CPP_NEW_DELETE_OPERATORS
  160016             :     ROSE_FREE(Pointer);
  160017             : #else
  160018             : #if ROSE_PEDANTIC_ALLOC
  160019             :     ROSE_ASSERT(Size == sizeof(SgConstructorInitializer));
  160020             : #else
  160021        1027 :     if (Size != sizeof(SgConstructorInitializer)) {
  160022           0 :       ROSE_FREE(Pointer);
  160023           0 :       ALLOC_MUTEX(SgConstructorInitializer, unlock);
  160024             :       return;
  160025             :     }
  160026             : #endif
  160027             : 
  160028        1027 :     SgConstructorInitializer * object = (SgConstructorInitializer*) Pointer;
  160029        1027 :     ROSE_ASSERT(object != nullptr);
  160030             : 
  160031             : #if ROSE_ALLOC_TRACE == 2
  160032             : //  printf("SgConstructorInitializer::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgConstructorInitializer::next_node);
  160033             :     printf("SgConstructorInitializer::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgConstructorInitializer::next_node);
  160034             : #endif
  160035             : 
  160036             : #if ROSE_PEDANTIC_ALLOC
  160037             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  160038             : #endif
  160039             : 
  160040             : #if ROSE_ALLOC_MEMSET == 1
  160041             : #elif ROSE_ALLOC_MEMSET == 2
  160042             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgConstructorInitializer) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  160043             : #elif ROSE_ALLOC_MEMSET == 3
  160044             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgConstructorInitializer) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  160045             : #endif
  160046             : 
  160047             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  160048             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  160049             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  160050             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  160051             : #else
  160052        1027 :     object->p_freepointer = SgConstructorInitializer::next_node;
  160053        1027 :     SgConstructorInitializer::next_node = object;
  160054             : #endif
  160055             : 
  160056             : #if ROSE_ALLOC_TRACE == 2
  160057             : //  printf("SgConstructorInitializer::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgConstructorInitializer::next_node);
  160058             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  160059             :     Rose::MemPool::snapshot(oss.str());
  160060             :     alloc_trace_cnt++;
  160061             : #endif
  160062             : 
  160063             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  160064             : 
  160065        1027 :     ALLOC_MUTEX(SgConstructorInitializer, unlock);
  160066             : }
  160067             : 
  160068             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  160069             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  160070             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  160071             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  160072             : // Also, note comment below from Robb (copied from the Common.code file).
  160073             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  160074             : //
  160075             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  160076             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  160077             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  160078             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  160079             : #if 0
  160080             : void SgConstructorInitializer::operator delete(void* pointer) { SgConstructorInitializer::operator delete (pointer, sizeof(SgConstructorInitializer)); };
  160081             : #endif
  160082             : /* #line 160083 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  160083             : 
  160084             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  160085             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  160086             : // obviously imply C++.
  160087             : 
  160088             : // This implements the support within ROSE for memory pools.  Memory pools
  160089             : // support the most condensed usage of memory within the construction of
  160090             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  160091             : // by a new operator written for each class.
  160092             : 
  160093             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  160094             :     // User wants multi-thread support and POSIX threads are available.
  160095             : #   include <pthread.h>
  160096             :     static pthread_mutex_t SgAssignInitializer_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  160097             : #else
  160098             :      // Cause synchronization to be skipped.
  160099             : #    ifndef ALLOC_MUTEX
  160100             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  160101             : #    endif
  160102             : #    ifdef _REENTRANT
  160103             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  160104             : #       ifdef _MSC_VER
  160105             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  160106             : #       else
  160107             : #           warning "POSIX threads are not available; synchronization being skipped"
  160108             : #       endif
  160109             : #    endif
  160110             : #endif
  160111             : 
  160112             : #ifndef ROSE_ALLOC_TRACE
  160113             : #  define ROSE_ALLOC_TRACE 0
  160114             : #endif
  160115             : 
  160116             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  160117             : #define ROSE_ALLOC_TRACE_CNT
  160118             : #include "memory-pool-snapshot.h"
  160119             : unsigned long alloc_trace_cnt = 0;
  160120             : #endif
  160121             : 
  160122             : #if ROSE_ALLOC_TRACE
  160123             : const unsigned SgAssignInitializer::pool_size = 5;
  160124             : #else
  160125             : const unsigned SgAssignInitializer::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  160126             : #endif
  160127             : 
  160128             : #ifndef ROSE_ALLOC_MEMSET
  160129             : #  define ROSE_ALLOC_MEMSET 0
  160130             : #endif
  160131             : 
  160132             : #ifndef ROSE_PEDANTIC_ALLOC
  160133             : #  define ROSE_PEDANTIC_ALLOC 0
  160134             : #endif
  160135             : 
  160136             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  160137             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  160138             : #endif
  160139             : 
  160140             : #if !defined(SGNODE__ALL_POOLS)
  160141             : #define SGNODE__ALL_POOLS
  160142             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  160143             : #endif
  160144             : 
  160145             : SgAssignInitializer* SgAssignInitializer::next_node = nullptr;
  160146             : std::vector<unsigned char*> SgAssignInitializer::pools;
  160147             : 
  160148             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  160149             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  160150             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  160151             : // around this macro definition rather than each use).
  160152             : #ifndef ALLOC_MUTEX
  160153             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  160154             :         do {                                                                     \
  160155             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  160156             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  160157             :                 abort();                                                         \
  160158             :             }                                                                    \
  160159             :         } while (0);
  160160             : #endif
  160161             : 
  160162             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  160163             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  160164             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  160165             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  160166             : 
  160167             : /*! \brief New operator for SgAssignInitializer.
  160168             : 
  160169             :    This new operator implements memory pools to provide most efficent 
  160170             :    use of the heap within construction of large ASTs.
  160171             : 
  160172             : \internal The new and delete operators use the lower level C malloc/free
  160173             :    function calls for performance and to make sure that mixing of malloc/free
  160174             :    and new/delete by the used can be caught more readily.  This may change
  160175             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  160176             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  160177             :    deallocate memory allocated using ROSE_MALLOC.
  160178             : */
  160179       18139 : void *SgAssignInitializer::operator new ( size_t Size )
  160180             : {
  160181             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  160182             :      * returning or throwing an exception. */
  160183       18139 :     ALLOC_MUTEX(SgAssignInitializer, lock);
  160184             : 
  160185             : #if ROSE_ALLOC_TRACE == 2
  160186             : //    printf("SgAssignInitializer::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgAssignInitializer::next_node);
  160187             : #endif
  160188             : 
  160189             : #if USE_CPP_NEW_DELETE_OPERATORS
  160190             :     void *mem = ROSE_MALLOC(Size);
  160191             :     ALLOC_MUTEX(SgAssignInitializer, unlock);
  160192             :     return mem;
  160193             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  160194             : #if ROSE_PEDANTIC_ALLOC
  160195             :     ROSE_ASSERT(Size == sizeof(SgAssignInitializer));
  160196             : #else
  160197       18139 :     if (Size != sizeof(SgAssignInitializer)) {
  160198           0 :       void * object = ROSE_MALLOC(Size);
  160199           0 :       ALLOC_MUTEX(SgAssignInitializer, unlock);
  160200             :       return object;
  160201             :     }
  160202             : #endif
  160203             : 
  160204       18139 :     if (SgAssignInitializer::next_node == nullptr) {
  160205         242 :         SgAssignInitializer * alloc = (SgAssignInitializer*) ROSE_MALLOC ( SgAssignInitializer::pool_size * sizeof(SgAssignInitializer) );
  160206         242 :         ROSE_ASSERT(alloc != nullptr);
  160207             : 
  160208             : #if ROSE_ALLOC_TRACE == 2
  160209             : //        printf("SgAssignInitializer::alloc\n  block[%zi] = [ %p , %p [\n", SgAssignInitializer::pools.size(), alloc, alloc + SgAssignInitializer::pool_size);
  160210             : #endif
  160211             : 
  160212             : #if ROSE_ALLOC_MEMSET == 1
  160213             : #elif ROSE_ALLOC_MEMSET == 2
  160214             :         memset(alloc, 0x00, SgAssignInitializer::pool_size * sizeof(SgAssignInitializer));
  160215             : #elif ROSE_ALLOC_MEMSET == 3
  160216             :         memset(alloc, 0xAA, SgAssignInitializer::pool_size * sizeof(SgAssignInitializer));
  160217             : #endif
  160218      484000 :         for (unsigned i=0; i < SgAssignInitializer::pool_size-1; i++) {
  160219      483758 :           alloc[i].p_freepointer = &(alloc[i+1]);
  160220             :         }
  160221         242 :         alloc[SgAssignInitializer::pool_size-1].p_freepointer = nullptr;
  160222             : 
  160223         242 :         SgAssignInitializer::pools.push_back ( (unsigned char *) alloc );
  160224         242 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgAssignInitializer::pool_size * sizeof(SgAssignInitializer), V_SgAssignInitializer ) );
  160225         242 :         SgAssignInitializer::next_node = alloc;
  160226             :     }
  160227       18139 :     ROSE_ASSERT(SgAssignInitializer::next_node != nullptr);
  160228             : 
  160229       18139 :     SgAssignInitializer * object = SgAssignInitializer::next_node;
  160230       18139 :     SgAssignInitializer::next_node = (SgAssignInitializer*)(object->p_freepointer);
  160231             : 
  160232             : #if ROSE_ALLOC_TRACE == 2
  160233             :     printf("SgAssignInitializer::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgAssignInitializer::next_node);
  160234             : #endif
  160235             : 
  160236       18139 :     SgNode * fp = object->p_freepointer;
  160237             : #if ROSE_ALLOC_MEMSET == 1
  160238             : #elif ROSE_ALLOC_MEMSET == 2
  160239             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgAssignInitializer) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  160240             : #elif ROSE_ALLOC_MEMSET == 3
  160241             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgAssignInitializer) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  160242             : #endif
  160243       18139 :     object->p_freepointer = fp;
  160244             : 
  160245             : #if ROSE_ALLOC_TRACE == 2
  160246             : //    printf("SgAssignInitializer::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgAssignInitializer::next_node);
  160247             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  160248             :     Rose::MemPool::snapshot(oss.str());
  160249             :     alloc_trace_cnt++;
  160250             : #endif
  160251             : 
  160252       18139 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  160253             : 
  160254       18139 :     ALLOC_MUTEX(SgAssignInitializer, unlock);
  160255             : 
  160256             :     return object;
  160257             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  160258             : }
  160259             : 
  160260             : 
  160261             : 
  160262             : /*! \brief Delete operator for SgAssignInitializer.
  160263             : 
  160264             :    This delete operator implements deallocation using memory pools to 
  160265             :    provide most efficent use of the heap within construction of large ASTs.
  160266             : 
  160267             : \internal The new and delete operators use the lower level C malloc/free
  160268             :    function calls for performance and to make sure that mixing of malloc/free
  160269             :    and new/delete by the used can be caught more readily.  This may change
  160270             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  160271             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  160272             :    deallocate memory allocated using ROSE_MALLOC.
  160273             : */
  160274        2917 : void SgAssignInitializer::operator delete(void *Pointer, size_t Size)
  160275             : {
  160276             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  160277             :      * or throwing an exception. */
  160278        2917 :     ALLOC_MUTEX(SgAssignInitializer, lock);
  160279             : 
  160280             : #if USE_CPP_NEW_DELETE_OPERATORS
  160281             :     ROSE_FREE(Pointer);
  160282             : #else
  160283             : #if ROSE_PEDANTIC_ALLOC
  160284             :     ROSE_ASSERT(Size == sizeof(SgAssignInitializer));
  160285             : #else
  160286        2917 :     if (Size != sizeof(SgAssignInitializer)) {
  160287           0 :       ROSE_FREE(Pointer);
  160288           0 :       ALLOC_MUTEX(SgAssignInitializer, unlock);
  160289             :       return;
  160290             :     }
  160291             : #endif
  160292             : 
  160293        2917 :     SgAssignInitializer * object = (SgAssignInitializer*) Pointer;
  160294        2917 :     ROSE_ASSERT(object != nullptr);
  160295             : 
  160296             : #if ROSE_ALLOC_TRACE == 2
  160297             : //  printf("SgAssignInitializer::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgAssignInitializer::next_node);
  160298             :     printf("SgAssignInitializer::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgAssignInitializer::next_node);
  160299             : #endif
  160300             : 
  160301             : #if ROSE_PEDANTIC_ALLOC
  160302             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  160303             : #endif
  160304             : 
  160305             : #if ROSE_ALLOC_MEMSET == 1
  160306             : #elif ROSE_ALLOC_MEMSET == 2
  160307             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgAssignInitializer) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  160308             : #elif ROSE_ALLOC_MEMSET == 3
  160309             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgAssignInitializer) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  160310             : #endif
  160311             : 
  160312             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  160313             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  160314             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  160315             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  160316             : #else
  160317        2917 :     object->p_freepointer = SgAssignInitializer::next_node;
  160318        2917 :     SgAssignInitializer::next_node = object;
  160319             : #endif
  160320             : 
  160321             : #if ROSE_ALLOC_TRACE == 2
  160322             : //  printf("SgAssignInitializer::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgAssignInitializer::next_node);
  160323             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  160324             :     Rose::MemPool::snapshot(oss.str());
  160325             :     alloc_trace_cnt++;
  160326             : #endif
  160327             : 
  160328             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  160329             : 
  160330        2917 :     ALLOC_MUTEX(SgAssignInitializer, unlock);
  160331             : }
  160332             : 
  160333             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  160334             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  160335             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  160336             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  160337             : // Also, note comment below from Robb (copied from the Common.code file).
  160338             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  160339             : //
  160340             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  160341             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  160342             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  160343             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  160344             : #if 0
  160345             : void SgAssignInitializer::operator delete(void* pointer) { SgAssignInitializer::operator delete (pointer, sizeof(SgAssignInitializer)); };
  160346             : #endif
  160347             : /* #line 160348 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  160348             : 
  160349             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  160350             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  160351             : // obviously imply C++.
  160352             : 
  160353             : // This implements the support within ROSE for memory pools.  Memory pools
  160354             : // support the most condensed usage of memory within the construction of
  160355             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  160356             : // by a new operator written for each class.
  160357             : 
  160358             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  160359             :     // User wants multi-thread support and POSIX threads are available.
  160360             : #   include <pthread.h>
  160361             :     static pthread_mutex_t SgDesignatedInitializer_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  160362             : #else
  160363             :      // Cause synchronization to be skipped.
  160364             : #    ifndef ALLOC_MUTEX
  160365             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  160366             : #    endif
  160367             : #    ifdef _REENTRANT
  160368             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  160369             : #       ifdef _MSC_VER
  160370             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  160371             : #       else
  160372             : #           warning "POSIX threads are not available; synchronization being skipped"
  160373             : #       endif
  160374             : #    endif
  160375             : #endif
  160376             : 
  160377             : #ifndef ROSE_ALLOC_TRACE
  160378             : #  define ROSE_ALLOC_TRACE 0
  160379             : #endif
  160380             : 
  160381             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  160382             : #define ROSE_ALLOC_TRACE_CNT
  160383             : #include "memory-pool-snapshot.h"
  160384             : unsigned long alloc_trace_cnt = 0;
  160385             : #endif
  160386             : 
  160387             : #if ROSE_ALLOC_TRACE
  160388             : const unsigned SgDesignatedInitializer::pool_size = 5;
  160389             : #else
  160390             : const unsigned SgDesignatedInitializer::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  160391             : #endif
  160392             : 
  160393             : #ifndef ROSE_ALLOC_MEMSET
  160394             : #  define ROSE_ALLOC_MEMSET 0
  160395             : #endif
  160396             : 
  160397             : #ifndef ROSE_PEDANTIC_ALLOC
  160398             : #  define ROSE_PEDANTIC_ALLOC 0
  160399             : #endif
  160400             : 
  160401             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  160402             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  160403             : #endif
  160404             : 
  160405             : #if !defined(SGNODE__ALL_POOLS)
  160406             : #define SGNODE__ALL_POOLS
  160407             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  160408             : #endif
  160409             : 
  160410             : SgDesignatedInitializer* SgDesignatedInitializer::next_node = nullptr;
  160411             : std::vector<unsigned char*> SgDesignatedInitializer::pools;
  160412             : 
  160413             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  160414             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  160415             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  160416             : // around this macro definition rather than each use).
  160417             : #ifndef ALLOC_MUTEX
  160418             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  160419             :         do {                                                                     \
  160420             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  160421             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  160422             :                 abort();                                                         \
  160423             :             }                                                                    \
  160424             :         } while (0);
  160425             : #endif
  160426             : 
  160427             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  160428             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  160429             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  160430             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  160431             : 
  160432             : /*! \brief New operator for SgDesignatedInitializer.
  160433             : 
  160434             :    This new operator implements memory pools to provide most efficent 
  160435             :    use of the heap within construction of large ASTs.
  160436             : 
  160437             : \internal The new and delete operators use the lower level C malloc/free
  160438             :    function calls for performance and to make sure that mixing of malloc/free
  160439             :    and new/delete by the used can be caught more readily.  This may change
  160440             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  160441             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  160442             :    deallocate memory allocated using ROSE_MALLOC.
  160443             : */
  160444           0 : void *SgDesignatedInitializer::operator new ( size_t Size )
  160445             : {
  160446             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  160447             :      * returning or throwing an exception. */
  160448           0 :     ALLOC_MUTEX(SgDesignatedInitializer, lock);
  160449             : 
  160450             : #if ROSE_ALLOC_TRACE == 2
  160451             : //    printf("SgDesignatedInitializer::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgDesignatedInitializer::next_node);
  160452             : #endif
  160453             : 
  160454             : #if USE_CPP_NEW_DELETE_OPERATORS
  160455             :     void *mem = ROSE_MALLOC(Size);
  160456             :     ALLOC_MUTEX(SgDesignatedInitializer, unlock);
  160457             :     return mem;
  160458             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  160459             : #if ROSE_PEDANTIC_ALLOC
  160460             :     ROSE_ASSERT(Size == sizeof(SgDesignatedInitializer));
  160461             : #else
  160462           0 :     if (Size != sizeof(SgDesignatedInitializer)) {
  160463           0 :       void * object = ROSE_MALLOC(Size);
  160464           0 :       ALLOC_MUTEX(SgDesignatedInitializer, unlock);
  160465             :       return object;
  160466             :     }
  160467             : #endif
  160468             : 
  160469           0 :     if (SgDesignatedInitializer::next_node == nullptr) {
  160470           0 :         SgDesignatedInitializer * alloc = (SgDesignatedInitializer*) ROSE_MALLOC ( SgDesignatedInitializer::pool_size * sizeof(SgDesignatedInitializer) );
  160471           0 :         ROSE_ASSERT(alloc != nullptr);
  160472             : 
  160473             : #if ROSE_ALLOC_TRACE == 2
  160474             : //        printf("SgDesignatedInitializer::alloc\n  block[%zi] = [ %p , %p [\n", SgDesignatedInitializer::pools.size(), alloc, alloc + SgDesignatedInitializer::pool_size);
  160475             : #endif
  160476             : 
  160477             : #if ROSE_ALLOC_MEMSET == 1
  160478             : #elif ROSE_ALLOC_MEMSET == 2
  160479             :         memset(alloc, 0x00, SgDesignatedInitializer::pool_size * sizeof(SgDesignatedInitializer));
  160480             : #elif ROSE_ALLOC_MEMSET == 3
  160481             :         memset(alloc, 0xAA, SgDesignatedInitializer::pool_size * sizeof(SgDesignatedInitializer));
  160482             : #endif
  160483           0 :         for (unsigned i=0; i < SgDesignatedInitializer::pool_size-1; i++) {
  160484           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
  160485             :         }
  160486           0 :         alloc[SgDesignatedInitializer::pool_size-1].p_freepointer = nullptr;
  160487             : 
  160488           0 :         SgDesignatedInitializer::pools.push_back ( (unsigned char *) alloc );
  160489           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgDesignatedInitializer::pool_size * sizeof(SgDesignatedInitializer), V_SgDesignatedInitializer ) );
  160490           0 :         SgDesignatedInitializer::next_node = alloc;
  160491             :     }
  160492           0 :     ROSE_ASSERT(SgDesignatedInitializer::next_node != nullptr);
  160493             : 
  160494           0 :     SgDesignatedInitializer * object = SgDesignatedInitializer::next_node;
  160495           0 :     SgDesignatedInitializer::next_node = (SgDesignatedInitializer*)(object->p_freepointer);
  160496             : 
  160497             : #if ROSE_ALLOC_TRACE == 2
  160498             :     printf("SgDesignatedInitializer::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgDesignatedInitializer::next_node);
  160499             : #endif
  160500             : 
  160501           0 :     SgNode * fp = object->p_freepointer;
  160502             : #if ROSE_ALLOC_MEMSET == 1
  160503             : #elif ROSE_ALLOC_MEMSET == 2
  160504             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgDesignatedInitializer) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  160505             : #elif ROSE_ALLOC_MEMSET == 3
  160506             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgDesignatedInitializer) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  160507             : #endif
  160508           0 :     object->p_freepointer = fp;
  160509             : 
  160510             : #if ROSE_ALLOC_TRACE == 2
  160511             : //    printf("SgDesignatedInitializer::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgDesignatedInitializer::next_node);
  160512             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  160513             :     Rose::MemPool::snapshot(oss.str());
  160514             :     alloc_trace_cnt++;
  160515             : #endif
  160516             : 
  160517           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  160518             : 
  160519           0 :     ALLOC_MUTEX(SgDesignatedInitializer, unlock);
  160520             : 
  160521             :     return object;
  160522             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  160523             : }
  160524             : 
  160525             : 
  160526             : 
  160527             : /*! \brief Delete operator for SgDesignatedInitializer.
  160528             : 
  160529             :    This delete operator implements deallocation using memory pools to 
  160530             :    provide most efficent use of the heap within construction of large ASTs.
  160531             : 
  160532             : \internal The new and delete operators use the lower level C malloc/free
  160533             :    function calls for performance and to make sure that mixing of malloc/free
  160534             :    and new/delete by the used can be caught more readily.  This may change
  160535             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  160536             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  160537             :    deallocate memory allocated using ROSE_MALLOC.
  160538             : */
  160539           0 : void SgDesignatedInitializer::operator delete(void *Pointer, size_t Size)
  160540             : {
  160541             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  160542             :      * or throwing an exception. */
  160543           0 :     ALLOC_MUTEX(SgDesignatedInitializer, lock);
  160544             : 
  160545             : #if USE_CPP_NEW_DELETE_OPERATORS
  160546             :     ROSE_FREE(Pointer);
  160547             : #else
  160548             : #if ROSE_PEDANTIC_ALLOC
  160549             :     ROSE_ASSERT(Size == sizeof(SgDesignatedInitializer));
  160550             : #else
  160551           0 :     if (Size != sizeof(SgDesignatedInitializer)) {
  160552           0 :       ROSE_FREE(Pointer);
  160553           0 :       ALLOC_MUTEX(SgDesignatedInitializer, unlock);
  160554             :       return;
  160555             :     }
  160556             : #endif
  160557             : 
  160558           0 :     SgDesignatedInitializer * object = (SgDesignatedInitializer*) Pointer;
  160559           0 :     ROSE_ASSERT(object != nullptr);
  160560             : 
  160561             : #if ROSE_ALLOC_TRACE == 2
  160562             : //  printf("SgDesignatedInitializer::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgDesignatedInitializer::next_node);
  160563             :     printf("SgDesignatedInitializer::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgDesignatedInitializer::next_node);
  160564             : #endif
  160565             : 
  160566             : #if ROSE_PEDANTIC_ALLOC
  160567             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  160568             : #endif
  160569             : 
  160570             : #if ROSE_ALLOC_MEMSET == 1
  160571             : #elif ROSE_ALLOC_MEMSET == 2
  160572             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgDesignatedInitializer) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  160573             : #elif ROSE_ALLOC_MEMSET == 3
  160574             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgDesignatedInitializer) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  160575             : #endif
  160576             : 
  160577             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  160578             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  160579             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  160580             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  160581             : #else
  160582           0 :     object->p_freepointer = SgDesignatedInitializer::next_node;
  160583           0 :     SgDesignatedInitializer::next_node = object;
  160584             : #endif
  160585             : 
  160586             : #if ROSE_ALLOC_TRACE == 2
  160587             : //  printf("SgDesignatedInitializer::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgDesignatedInitializer::next_node);
  160588             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  160589             :     Rose::MemPool::snapshot(oss.str());
  160590             :     alloc_trace_cnt++;
  160591             : #endif
  160592             : 
  160593             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  160594             : 
  160595           0 :     ALLOC_MUTEX(SgDesignatedInitializer, unlock);
  160596             : }
  160597             : 
  160598             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  160599             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  160600             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  160601             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  160602             : // Also, note comment below from Robb (copied from the Common.code file).
  160603             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  160604             : //
  160605             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  160606             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  160607             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  160608             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  160609             : #if 0
  160610             : void SgDesignatedInitializer::operator delete(void* pointer) { SgDesignatedInitializer::operator delete (pointer, sizeof(SgDesignatedInitializer)); };
  160611             : #endif
  160612             : /* #line 160613 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  160613             : 
  160614             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  160615             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  160616             : // obviously imply C++.
  160617             : 
  160618             : // This implements the support within ROSE for memory pools.  Memory pools
  160619             : // support the most condensed usage of memory within the construction of
  160620             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  160621             : // by a new operator written for each class.
  160622             : 
  160623             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  160624             :     // User wants multi-thread support and POSIX threads are available.
  160625             : #   include <pthread.h>
  160626             :     static pthread_mutex_t SgBracedInitializer_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  160627             : #else
  160628             :      // Cause synchronization to be skipped.
  160629             : #    ifndef ALLOC_MUTEX
  160630             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  160631             : #    endif
  160632             : #    ifdef _REENTRANT
  160633             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  160634             : #       ifdef _MSC_VER
  160635             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  160636             : #       else
  160637             : #           warning "POSIX threads are not available; synchronization being skipped"
  160638             : #       endif
  160639             : #    endif
  160640             : #endif
  160641             : 
  160642             : #ifndef ROSE_ALLOC_TRACE
  160643             : #  define ROSE_ALLOC_TRACE 0
  160644             : #endif
  160645             : 
  160646             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  160647             : #define ROSE_ALLOC_TRACE_CNT
  160648             : #include "memory-pool-snapshot.h"
  160649             : unsigned long alloc_trace_cnt = 0;
  160650             : #endif
  160651             : 
  160652             : #if ROSE_ALLOC_TRACE
  160653             : const unsigned SgBracedInitializer::pool_size = 5;
  160654             : #else
  160655             : const unsigned SgBracedInitializer::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  160656             : #endif
  160657             : 
  160658             : #ifndef ROSE_ALLOC_MEMSET
  160659             : #  define ROSE_ALLOC_MEMSET 0
  160660             : #endif
  160661             : 
  160662             : #ifndef ROSE_PEDANTIC_ALLOC
  160663             : #  define ROSE_PEDANTIC_ALLOC 0
  160664             : #endif
  160665             : 
  160666             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  160667             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  160668             : #endif
  160669             : 
  160670             : #if !defined(SGNODE__ALL_POOLS)
  160671             : #define SGNODE__ALL_POOLS
  160672             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  160673             : #endif
  160674             : 
  160675             : SgBracedInitializer* SgBracedInitializer::next_node = nullptr;
  160676             : std::vector<unsigned char*> SgBracedInitializer::pools;
  160677             : 
  160678             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  160679             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  160680             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  160681             : // around this macro definition rather than each use).
  160682             : #ifndef ALLOC_MUTEX
  160683             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  160684             :         do {                                                                     \
  160685             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  160686             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  160687             :                 abort();                                                         \
  160688             :             }                                                                    \
  160689             :         } while (0);
  160690             : #endif
  160691             : 
  160692             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  160693             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  160694             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  160695             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  160696             : 
  160697             : /*! \brief New operator for SgBracedInitializer.
  160698             : 
  160699             :    This new operator implements memory pools to provide most efficent 
  160700             :    use of the heap within construction of large ASTs.
  160701             : 
  160702             : \internal The new and delete operators use the lower level C malloc/free
  160703             :    function calls for performance and to make sure that mixing of malloc/free
  160704             :    and new/delete by the used can be caught more readily.  This may change
  160705             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  160706             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  160707             :    deallocate memory allocated using ROSE_MALLOC.
  160708             : */
  160709          11 : void *SgBracedInitializer::operator new ( size_t Size )
  160710             : {
  160711             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  160712             :      * returning or throwing an exception. */
  160713          11 :     ALLOC_MUTEX(SgBracedInitializer, lock);
  160714             : 
  160715             : #if ROSE_ALLOC_TRACE == 2
  160716             : //    printf("SgBracedInitializer::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgBracedInitializer::next_node);
  160717             : #endif
  160718             : 
  160719             : #if USE_CPP_NEW_DELETE_OPERATORS
  160720             :     void *mem = ROSE_MALLOC(Size);
  160721             :     ALLOC_MUTEX(SgBracedInitializer, unlock);
  160722             :     return mem;
  160723             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  160724             : #if ROSE_PEDANTIC_ALLOC
  160725             :     ROSE_ASSERT(Size == sizeof(SgBracedInitializer));
  160726             : #else
  160727          11 :     if (Size != sizeof(SgBracedInitializer)) {
  160728           0 :       void * object = ROSE_MALLOC(Size);
  160729           0 :       ALLOC_MUTEX(SgBracedInitializer, unlock);
  160730             :       return object;
  160731             :     }
  160732             : #endif
  160733             : 
  160734          11 :     if (SgBracedInitializer::next_node == nullptr) {
  160735          10 :         SgBracedInitializer * alloc = (SgBracedInitializer*) ROSE_MALLOC ( SgBracedInitializer::pool_size * sizeof(SgBracedInitializer) );
  160736          10 :         ROSE_ASSERT(alloc != nullptr);
  160737             : 
  160738             : #if ROSE_ALLOC_TRACE == 2
  160739             : //        printf("SgBracedInitializer::alloc\n  block[%zi] = [ %p , %p [\n", SgBracedInitializer::pools.size(), alloc, alloc + SgBracedInitializer::pool_size);
  160740             : #endif
  160741             : 
  160742             : #if ROSE_ALLOC_MEMSET == 1
  160743             : #elif ROSE_ALLOC_MEMSET == 2
  160744             :         memset(alloc, 0x00, SgBracedInitializer::pool_size * sizeof(SgBracedInitializer));
  160745             : #elif ROSE_ALLOC_MEMSET == 3
  160746             :         memset(alloc, 0xAA, SgBracedInitializer::pool_size * sizeof(SgBracedInitializer));
  160747             : #endif
  160748       20000 :         for (unsigned i=0; i < SgBracedInitializer::pool_size-1; i++) {
  160749       19990 :           alloc[i].p_freepointer = &(alloc[i+1]);
  160750             :         }
  160751          10 :         alloc[SgBracedInitializer::pool_size-1].p_freepointer = nullptr;
  160752             : 
  160753          10 :         SgBracedInitializer::pools.push_back ( (unsigned char *) alloc );
  160754          10 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgBracedInitializer::pool_size * sizeof(SgBracedInitializer), V_SgBracedInitializer ) );
  160755          10 :         SgBracedInitializer::next_node = alloc;
  160756             :     }
  160757          11 :     ROSE_ASSERT(SgBracedInitializer::next_node != nullptr);
  160758             : 
  160759          11 :     SgBracedInitializer * object = SgBracedInitializer::next_node;
  160760          11 :     SgBracedInitializer::next_node = (SgBracedInitializer*)(object->p_freepointer);
  160761             : 
  160762             : #if ROSE_ALLOC_TRACE == 2
  160763             :     printf("SgBracedInitializer::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgBracedInitializer::next_node);
  160764             : #endif
  160765             : 
  160766          11 :     SgNode * fp = object->p_freepointer;
  160767             : #if ROSE_ALLOC_MEMSET == 1
  160768             : #elif ROSE_ALLOC_MEMSET == 2
  160769             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgBracedInitializer) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  160770             : #elif ROSE_ALLOC_MEMSET == 3
  160771             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgBracedInitializer) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  160772             : #endif
  160773          11 :     object->p_freepointer = fp;
  160774             : 
  160775             : #if ROSE_ALLOC_TRACE == 2
  160776             : //    printf("SgBracedInitializer::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgBracedInitializer::next_node);
  160777             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  160778             :     Rose::MemPool::snapshot(oss.str());
  160779             :     alloc_trace_cnt++;
  160780             : #endif
  160781             : 
  160782          11 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  160783             : 
  160784          11 :     ALLOC_MUTEX(SgBracedInitializer, unlock);
  160785             : 
  160786             :     return object;
  160787             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  160788             : }
  160789             : 
  160790             : 
  160791             : 
  160792             : /*! \brief Delete operator for SgBracedInitializer.
  160793             : 
  160794             :    This delete operator implements deallocation using memory pools to 
  160795             :    provide most efficent use of the heap within construction of large ASTs.
  160796             : 
  160797             : \internal The new and delete operators use the lower level C malloc/free
  160798             :    function calls for performance and to make sure that mixing of malloc/free
  160799             :    and new/delete by the used can be caught more readily.  This may change
  160800             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  160801             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  160802             :    deallocate memory allocated using ROSE_MALLOC.
  160803             : */
  160804           2 : void SgBracedInitializer::operator delete(void *Pointer, size_t Size)
  160805             : {
  160806             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  160807             :      * or throwing an exception. */
  160808           2 :     ALLOC_MUTEX(SgBracedInitializer, lock);
  160809             : 
  160810             : #if USE_CPP_NEW_DELETE_OPERATORS
  160811             :     ROSE_FREE(Pointer);
  160812             : #else
  160813             : #if ROSE_PEDANTIC_ALLOC
  160814             :     ROSE_ASSERT(Size == sizeof(SgBracedInitializer));
  160815             : #else
  160816           2 :     if (Size != sizeof(SgBracedInitializer)) {
  160817           0 :       ROSE_FREE(Pointer);
  160818           0 :       ALLOC_MUTEX(SgBracedInitializer, unlock);
  160819             :       return;
  160820             :     }
  160821             : #endif
  160822             : 
  160823           2 :     SgBracedInitializer * object = (SgBracedInitializer*) Pointer;
  160824           2 :     ROSE_ASSERT(object != nullptr);
  160825             : 
  160826             : #if ROSE_ALLOC_TRACE == 2
  160827             : //  printf("SgBracedInitializer::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgBracedInitializer::next_node);
  160828             :     printf("SgBracedInitializer::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgBracedInitializer::next_node);
  160829             : #endif
  160830             : 
  160831             : #if ROSE_PEDANTIC_ALLOC
  160832             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  160833             : #endif
  160834             : 
  160835             : #if ROSE_ALLOC_MEMSET == 1
  160836             : #elif ROSE_ALLOC_MEMSET == 2
  160837             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgBracedInitializer) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  160838             : #elif ROSE_ALLOC_MEMSET == 3
  160839             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgBracedInitializer) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  160840             : #endif
  160841             : 
  160842             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  160843             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  160844             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  160845             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  160846             : #else
  160847           2 :     object->p_freepointer = SgBracedInitializer::next_node;
  160848           2 :     SgBracedInitializer::next_node = object;
  160849             : #endif
  160850             : 
  160851             : #if ROSE_ALLOC_TRACE == 2
  160852             : //  printf("SgBracedInitializer::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgBracedInitializer::next_node);
  160853             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  160854             :     Rose::MemPool::snapshot(oss.str());
  160855             :     alloc_trace_cnt++;
  160856             : #endif
  160857             : 
  160858             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  160859             : 
  160860           2 :     ALLOC_MUTEX(SgBracedInitializer, unlock);
  160861             : }
  160862             : 
  160863             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  160864             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  160865             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  160866             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  160867             : // Also, note comment below from Robb (copied from the Common.code file).
  160868             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  160869             : //
  160870             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  160871             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  160872             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  160873             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  160874             : #if 0
  160875             : void SgBracedInitializer::operator delete(void* pointer) { SgBracedInitializer::operator delete (pointer, sizeof(SgBracedInitializer)); };
  160876             : #endif
  160877             : /* #line 160878 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  160878             : 
  160879             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  160880             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  160881             : // obviously imply C++.
  160882             : 
  160883             : // This implements the support within ROSE for memory pools.  Memory pools
  160884             : // support the most condensed usage of memory within the construction of
  160885             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  160886             : // by a new operator written for each class.
  160887             : 
  160888             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  160889             :     // User wants multi-thread support and POSIX threads are available.
  160890             : #   include <pthread.h>
  160891             :     static pthread_mutex_t SgVarArgStartOp_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  160892             : #else
  160893             :      // Cause synchronization to be skipped.
  160894             : #    ifndef ALLOC_MUTEX
  160895             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  160896             : #    endif
  160897             : #    ifdef _REENTRANT
  160898             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  160899             : #       ifdef _MSC_VER
  160900             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  160901             : #       else
  160902             : #           warning "POSIX threads are not available; synchronization being skipped"
  160903             : #       endif
  160904             : #    endif
  160905             : #endif
  160906             : 
  160907             : #ifndef ROSE_ALLOC_TRACE
  160908             : #  define ROSE_ALLOC_TRACE 0
  160909             : #endif
  160910             : 
  160911             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  160912             : #define ROSE_ALLOC_TRACE_CNT
  160913             : #include "memory-pool-snapshot.h"
  160914             : unsigned long alloc_trace_cnt = 0;
  160915             : #endif
  160916             : 
  160917             : #if ROSE_ALLOC_TRACE
  160918             : const unsigned SgVarArgStartOp::pool_size = 5;
  160919             : #else
  160920             : const unsigned SgVarArgStartOp::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  160921             : #endif
  160922             : 
  160923             : #ifndef ROSE_ALLOC_MEMSET
  160924             : #  define ROSE_ALLOC_MEMSET 0
  160925             : #endif
  160926             : 
  160927             : #ifndef ROSE_PEDANTIC_ALLOC
  160928             : #  define ROSE_PEDANTIC_ALLOC 0
  160929             : #endif
  160930             : 
  160931             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  160932             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  160933             : #endif
  160934             : 
  160935             : #if !defined(SGNODE__ALL_POOLS)
  160936             : #define SGNODE__ALL_POOLS
  160937             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  160938             : #endif
  160939             : 
  160940             : SgVarArgStartOp* SgVarArgStartOp::next_node = nullptr;
  160941             : std::vector<unsigned char*> SgVarArgStartOp::pools;
  160942             : 
  160943             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  160944             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  160945             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  160946             : // around this macro definition rather than each use).
  160947             : #ifndef ALLOC_MUTEX
  160948             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  160949             :         do {                                                                     \
  160950             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  160951             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  160952             :                 abort();                                                         \
  160953             :             }                                                                    \
  160954             :         } while (0);
  160955             : #endif
  160956             : 
  160957             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  160958             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  160959             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  160960             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  160961             : 
  160962             : /*! \brief New operator for SgVarArgStartOp.
  160963             : 
  160964             :    This new operator implements memory pools to provide most efficent 
  160965             :    use of the heap within construction of large ASTs.
  160966             : 
  160967             : \internal The new and delete operators use the lower level C malloc/free
  160968             :    function calls for performance and to make sure that mixing of malloc/free
  160969             :    and new/delete by the used can be caught more readily.  This may change
  160970             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  160971             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  160972             :    deallocate memory allocated using ROSE_MALLOC.
  160973             : */
  160974           0 : void *SgVarArgStartOp::operator new ( size_t Size )
  160975             : {
  160976             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  160977             :      * returning or throwing an exception. */
  160978           0 :     ALLOC_MUTEX(SgVarArgStartOp, lock);
  160979             : 
  160980             : #if ROSE_ALLOC_TRACE == 2
  160981             : //    printf("SgVarArgStartOp::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgVarArgStartOp::next_node);
  160982             : #endif
  160983             : 
  160984             : #if USE_CPP_NEW_DELETE_OPERATORS
  160985             :     void *mem = ROSE_MALLOC(Size);
  160986             :     ALLOC_MUTEX(SgVarArgStartOp, unlock);
  160987             :     return mem;
  160988             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  160989             : #if ROSE_PEDANTIC_ALLOC
  160990             :     ROSE_ASSERT(Size == sizeof(SgVarArgStartOp));
  160991             : #else
  160992           0 :     if (Size != sizeof(SgVarArgStartOp)) {
  160993           0 :       void * object = ROSE_MALLOC(Size);
  160994           0 :       ALLOC_MUTEX(SgVarArgStartOp, unlock);
  160995             :       return object;
  160996             :     }
  160997             : #endif
  160998             : 
  160999           0 :     if (SgVarArgStartOp::next_node == nullptr) {
  161000           0 :         SgVarArgStartOp * alloc = (SgVarArgStartOp*) ROSE_MALLOC ( SgVarArgStartOp::pool_size * sizeof(SgVarArgStartOp) );
  161001           0 :         ROSE_ASSERT(alloc != nullptr);
  161002             : 
  161003             : #if ROSE_ALLOC_TRACE == 2
  161004             : //        printf("SgVarArgStartOp::alloc\n  block[%zi] = [ %p , %p [\n", SgVarArgStartOp::pools.size(), alloc, alloc + SgVarArgStartOp::pool_size);
  161005             : #endif
  161006             : 
  161007             : #if ROSE_ALLOC_MEMSET == 1
  161008             : #elif ROSE_ALLOC_MEMSET == 2
  161009             :         memset(alloc, 0x00, SgVarArgStartOp::pool_size * sizeof(SgVarArgStartOp));
  161010             : #elif ROSE_ALLOC_MEMSET == 3
  161011             :         memset(alloc, 0xAA, SgVarArgStartOp::pool_size * sizeof(SgVarArgStartOp));
  161012             : #endif
  161013           0 :         for (unsigned i=0; i < SgVarArgStartOp::pool_size-1; i++) {
  161014           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
  161015             :         }
  161016           0 :         alloc[SgVarArgStartOp::pool_size-1].p_freepointer = nullptr;
  161017             : 
  161018           0 :         SgVarArgStartOp::pools.push_back ( (unsigned char *) alloc );
  161019           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgVarArgStartOp::pool_size * sizeof(SgVarArgStartOp), V_SgVarArgStartOp ) );
  161020           0 :         SgVarArgStartOp::next_node = alloc;
  161021             :     }
  161022           0 :     ROSE_ASSERT(SgVarArgStartOp::next_node != nullptr);
  161023             : 
  161024           0 :     SgVarArgStartOp * object = SgVarArgStartOp::next_node;
  161025           0 :     SgVarArgStartOp::next_node = (SgVarArgStartOp*)(object->p_freepointer);
  161026             : 
  161027             : #if ROSE_ALLOC_TRACE == 2
  161028             :     printf("SgVarArgStartOp::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgVarArgStartOp::next_node);
  161029             : #endif
  161030             : 
  161031           0 :     SgNode * fp = object->p_freepointer;
  161032             : #if ROSE_ALLOC_MEMSET == 1
  161033             : #elif ROSE_ALLOC_MEMSET == 2
  161034             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgVarArgStartOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  161035             : #elif ROSE_ALLOC_MEMSET == 3
  161036             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgVarArgStartOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  161037             : #endif
  161038           0 :     object->p_freepointer = fp;
  161039             : 
  161040             : #if ROSE_ALLOC_TRACE == 2
  161041             : //    printf("SgVarArgStartOp::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgVarArgStartOp::next_node);
  161042             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  161043             :     Rose::MemPool::snapshot(oss.str());
  161044             :     alloc_trace_cnt++;
  161045             : #endif
  161046             : 
  161047           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  161048             : 
  161049           0 :     ALLOC_MUTEX(SgVarArgStartOp, unlock);
  161050             : 
  161051             :     return object;
  161052             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  161053             : }
  161054             : 
  161055             : 
  161056             : 
  161057             : /*! \brief Delete operator for SgVarArgStartOp.
  161058             : 
  161059             :    This delete operator implements deallocation using memory pools to 
  161060             :    provide most efficent use of the heap within construction of large ASTs.
  161061             : 
  161062             : \internal The new and delete operators use the lower level C malloc/free
  161063             :    function calls for performance and to make sure that mixing of malloc/free
  161064             :    and new/delete by the used can be caught more readily.  This may change
  161065             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  161066             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  161067             :    deallocate memory allocated using ROSE_MALLOC.
  161068             : */
  161069           0 : void SgVarArgStartOp::operator delete(void *Pointer, size_t Size)
  161070             : {
  161071             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  161072             :      * or throwing an exception. */
  161073           0 :     ALLOC_MUTEX(SgVarArgStartOp, lock);
  161074             : 
  161075             : #if USE_CPP_NEW_DELETE_OPERATORS
  161076             :     ROSE_FREE(Pointer);
  161077             : #else
  161078             : #if ROSE_PEDANTIC_ALLOC
  161079             :     ROSE_ASSERT(Size == sizeof(SgVarArgStartOp));
  161080             : #else
  161081           0 :     if (Size != sizeof(SgVarArgStartOp)) {
  161082           0 :       ROSE_FREE(Pointer);
  161083           0 :       ALLOC_MUTEX(SgVarArgStartOp, unlock);
  161084             :       return;
  161085             :     }
  161086             : #endif
  161087             : 
  161088           0 :     SgVarArgStartOp * object = (SgVarArgStartOp*) Pointer;
  161089           0 :     ROSE_ASSERT(object != nullptr);
  161090             : 
  161091             : #if ROSE_ALLOC_TRACE == 2
  161092             : //  printf("SgVarArgStartOp::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgVarArgStartOp::next_node);
  161093             :     printf("SgVarArgStartOp::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgVarArgStartOp::next_node);
  161094             : #endif
  161095             : 
  161096             : #if ROSE_PEDANTIC_ALLOC
  161097             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  161098             : #endif
  161099             : 
  161100             : #if ROSE_ALLOC_MEMSET == 1
  161101             : #elif ROSE_ALLOC_MEMSET == 2
  161102             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgVarArgStartOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  161103             : #elif ROSE_ALLOC_MEMSET == 3
  161104             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgVarArgStartOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  161105             : #endif
  161106             : 
  161107             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  161108             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  161109             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  161110             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  161111             : #else
  161112           0 :     object->p_freepointer = SgVarArgStartOp::next_node;
  161113           0 :     SgVarArgStartOp::next_node = object;
  161114             : #endif
  161115             : 
  161116             : #if ROSE_ALLOC_TRACE == 2
  161117             : //  printf("SgVarArgStartOp::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgVarArgStartOp::next_node);
  161118             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  161119             :     Rose::MemPool::snapshot(oss.str());
  161120             :     alloc_trace_cnt++;
  161121             : #endif
  161122             : 
  161123             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  161124             : 
  161125           0 :     ALLOC_MUTEX(SgVarArgStartOp, unlock);
  161126             : }
  161127             : 
  161128             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  161129             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  161130             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  161131             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  161132             : // Also, note comment below from Robb (copied from the Common.code file).
  161133             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  161134             : //
  161135             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  161136             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  161137             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  161138             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  161139             : #if 0
  161140             : void SgVarArgStartOp::operator delete(void* pointer) { SgVarArgStartOp::operator delete (pointer, sizeof(SgVarArgStartOp)); };
  161141             : #endif
  161142             : /* #line 161143 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  161143             : 
  161144             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  161145             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  161146             : // obviously imply C++.
  161147             : 
  161148             : // This implements the support within ROSE for memory pools.  Memory pools
  161149             : // support the most condensed usage of memory within the construction of
  161150             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  161151             : // by a new operator written for each class.
  161152             : 
  161153             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  161154             :     // User wants multi-thread support and POSIX threads are available.
  161155             : #   include <pthread.h>
  161156             :     static pthread_mutex_t SgVarArgOp_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  161157             : #else
  161158             :      // Cause synchronization to be skipped.
  161159             : #    ifndef ALLOC_MUTEX
  161160             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  161161             : #    endif
  161162             : #    ifdef _REENTRANT
  161163             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  161164             : #       ifdef _MSC_VER
  161165             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  161166             : #       else
  161167             : #           warning "POSIX threads are not available; synchronization being skipped"
  161168             : #       endif
  161169             : #    endif
  161170             : #endif
  161171             : 
  161172             : #ifndef ROSE_ALLOC_TRACE
  161173             : #  define ROSE_ALLOC_TRACE 0
  161174             : #endif
  161175             : 
  161176             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  161177             : #define ROSE_ALLOC_TRACE_CNT
  161178             : #include "memory-pool-snapshot.h"
  161179             : unsigned long alloc_trace_cnt = 0;
  161180             : #endif
  161181             : 
  161182             : #if ROSE_ALLOC_TRACE
  161183             : const unsigned SgVarArgOp::pool_size = 5;
  161184             : #else
  161185             : const unsigned SgVarArgOp::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  161186             : #endif
  161187             : 
  161188             : #ifndef ROSE_ALLOC_MEMSET
  161189             : #  define ROSE_ALLOC_MEMSET 0
  161190             : #endif
  161191             : 
  161192             : #ifndef ROSE_PEDANTIC_ALLOC
  161193             : #  define ROSE_PEDANTIC_ALLOC 0
  161194             : #endif
  161195             : 
  161196             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  161197             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  161198             : #endif
  161199             : 
  161200             : #if !defined(SGNODE__ALL_POOLS)
  161201             : #define SGNODE__ALL_POOLS
  161202             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  161203             : #endif
  161204             : 
  161205             : SgVarArgOp* SgVarArgOp::next_node = nullptr;
  161206             : std::vector<unsigned char*> SgVarArgOp::pools;
  161207             : 
  161208             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  161209             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  161210             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  161211             : // around this macro definition rather than each use).
  161212             : #ifndef ALLOC_MUTEX
  161213             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  161214             :         do {                                                                     \
  161215             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  161216             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  161217             :                 abort();                                                         \
  161218             :             }                                                                    \
  161219             :         } while (0);
  161220             : #endif
  161221             : 
  161222             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  161223             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  161224             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  161225             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  161226             : 
  161227             : /*! \brief New operator for SgVarArgOp.
  161228             : 
  161229             :    This new operator implements memory pools to provide most efficent 
  161230             :    use of the heap within construction of large ASTs.
  161231             : 
  161232             : \internal The new and delete operators use the lower level C malloc/free
  161233             :    function calls for performance and to make sure that mixing of malloc/free
  161234             :    and new/delete by the used can be caught more readily.  This may change
  161235             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  161236             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  161237             :    deallocate memory allocated using ROSE_MALLOC.
  161238             : */
  161239           0 : void *SgVarArgOp::operator new ( size_t Size )
  161240             : {
  161241             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  161242             :      * returning or throwing an exception. */
  161243           0 :     ALLOC_MUTEX(SgVarArgOp, lock);
  161244             : 
  161245             : #if ROSE_ALLOC_TRACE == 2
  161246             : //    printf("SgVarArgOp::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgVarArgOp::next_node);
  161247             : #endif
  161248             : 
  161249             : #if USE_CPP_NEW_DELETE_OPERATORS
  161250             :     void *mem = ROSE_MALLOC(Size);
  161251             :     ALLOC_MUTEX(SgVarArgOp, unlock);
  161252             :     return mem;
  161253             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  161254             : #if ROSE_PEDANTIC_ALLOC
  161255             :     ROSE_ASSERT(Size == sizeof(SgVarArgOp));
  161256             : #else
  161257           0 :     if (Size != sizeof(SgVarArgOp)) {
  161258           0 :       void * object = ROSE_MALLOC(Size);
  161259           0 :       ALLOC_MUTEX(SgVarArgOp, unlock);
  161260             :       return object;
  161261             :     }
  161262             : #endif
  161263             : 
  161264           0 :     if (SgVarArgOp::next_node == nullptr) {
  161265           0 :         SgVarArgOp * alloc = (SgVarArgOp*) ROSE_MALLOC ( SgVarArgOp::pool_size * sizeof(SgVarArgOp) );
  161266           0 :         ROSE_ASSERT(alloc != nullptr);
  161267             : 
  161268             : #if ROSE_ALLOC_TRACE == 2
  161269             : //        printf("SgVarArgOp::alloc\n  block[%zi] = [ %p , %p [\n", SgVarArgOp::pools.size(), alloc, alloc + SgVarArgOp::pool_size);
  161270             : #endif
  161271             : 
  161272             : #if ROSE_ALLOC_MEMSET == 1
  161273             : #elif ROSE_ALLOC_MEMSET == 2
  161274             :         memset(alloc, 0x00, SgVarArgOp::pool_size * sizeof(SgVarArgOp));
  161275             : #elif ROSE_ALLOC_MEMSET == 3
  161276             :         memset(alloc, 0xAA, SgVarArgOp::pool_size * sizeof(SgVarArgOp));
  161277             : #endif
  161278           0 :         for (unsigned i=0; i < SgVarArgOp::pool_size-1; i++) {
  161279           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
  161280             :         }
  161281           0 :         alloc[SgVarArgOp::pool_size-1].p_freepointer = nullptr;
  161282             : 
  161283           0 :         SgVarArgOp::pools.push_back ( (unsigned char *) alloc );
  161284           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgVarArgOp::pool_size * sizeof(SgVarArgOp), V_SgVarArgOp ) );
  161285           0 :         SgVarArgOp::next_node = alloc;
  161286             :     }
  161287           0 :     ROSE_ASSERT(SgVarArgOp::next_node != nullptr);
  161288             : 
  161289           0 :     SgVarArgOp * object = SgVarArgOp::next_node;
  161290           0 :     SgVarArgOp::next_node = (SgVarArgOp*)(object->p_freepointer);
  161291             : 
  161292             : #if ROSE_ALLOC_TRACE == 2
  161293             :     printf("SgVarArgOp::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgVarArgOp::next_node);
  161294             : #endif
  161295             : 
  161296           0 :     SgNode * fp = object->p_freepointer;
  161297             : #if ROSE_ALLOC_MEMSET == 1
  161298             : #elif ROSE_ALLOC_MEMSET == 2
  161299             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgVarArgOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  161300             : #elif ROSE_ALLOC_MEMSET == 3
  161301             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgVarArgOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  161302             : #endif
  161303           0 :     object->p_freepointer = fp;
  161304             : 
  161305             : #if ROSE_ALLOC_TRACE == 2
  161306             : //    printf("SgVarArgOp::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgVarArgOp::next_node);
  161307             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  161308             :     Rose::MemPool::snapshot(oss.str());
  161309             :     alloc_trace_cnt++;
  161310             : #endif
  161311             : 
  161312           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  161313             : 
  161314           0 :     ALLOC_MUTEX(SgVarArgOp, unlock);
  161315             : 
  161316             :     return object;
  161317             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  161318             : }
  161319             : 
  161320             : 
  161321             : 
  161322             : /*! \brief Delete operator for SgVarArgOp.
  161323             : 
  161324             :    This delete operator implements deallocation using memory pools to 
  161325             :    provide most efficent use of the heap within construction of large ASTs.
  161326             : 
  161327             : \internal The new and delete operators use the lower level C malloc/free
  161328             :    function calls for performance and to make sure that mixing of malloc/free
  161329             :    and new/delete by the used can be caught more readily.  This may change
  161330             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  161331             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  161332             :    deallocate memory allocated using ROSE_MALLOC.
  161333             : */
  161334           0 : void SgVarArgOp::operator delete(void *Pointer, size_t Size)
  161335             : {
  161336             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  161337             :      * or throwing an exception. */
  161338           0 :     ALLOC_MUTEX(SgVarArgOp, lock);
  161339             : 
  161340             : #if USE_CPP_NEW_DELETE_OPERATORS
  161341             :     ROSE_FREE(Pointer);
  161342             : #else
  161343             : #if ROSE_PEDANTIC_ALLOC
  161344             :     ROSE_ASSERT(Size == sizeof(SgVarArgOp));
  161345             : #else
  161346           0 :     if (Size != sizeof(SgVarArgOp)) {
  161347           0 :       ROSE_FREE(Pointer);
  161348           0 :       ALLOC_MUTEX(SgVarArgOp, unlock);
  161349             :       return;
  161350             :     }
  161351             : #endif
  161352             : 
  161353           0 :     SgVarArgOp * object = (SgVarArgOp*) Pointer;
  161354           0 :     ROSE_ASSERT(object != nullptr);
  161355             : 
  161356             : #if ROSE_ALLOC_TRACE == 2
  161357             : //  printf("SgVarArgOp::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgVarArgOp::next_node);
  161358             :     printf("SgVarArgOp::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgVarArgOp::next_node);
  161359             : #endif
  161360             : 
  161361             : #if ROSE_PEDANTIC_ALLOC
  161362             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  161363             : #endif
  161364             : 
  161365             : #if ROSE_ALLOC_MEMSET == 1
  161366             : #elif ROSE_ALLOC_MEMSET == 2
  161367             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgVarArgOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  161368             : #elif ROSE_ALLOC_MEMSET == 3
  161369             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgVarArgOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  161370             : #endif
  161371             : 
  161372             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  161373             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  161374             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  161375             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  161376             : #else
  161377           0 :     object->p_freepointer = SgVarArgOp::next_node;
  161378           0 :     SgVarArgOp::next_node = object;
  161379             : #endif
  161380             : 
  161381             : #if ROSE_ALLOC_TRACE == 2
  161382             : //  printf("SgVarArgOp::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgVarArgOp::next_node);
  161383             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  161384             :     Rose::MemPool::snapshot(oss.str());
  161385             :     alloc_trace_cnt++;
  161386             : #endif
  161387             : 
  161388             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  161389             : 
  161390           0 :     ALLOC_MUTEX(SgVarArgOp, unlock);
  161391             : }
  161392             : 
  161393             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  161394             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  161395             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  161396             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  161397             : // Also, note comment below from Robb (copied from the Common.code file).
  161398             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  161399             : //
  161400             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  161401             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  161402             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  161403             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  161404             : #if 0
  161405             : void SgVarArgOp::operator delete(void* pointer) { SgVarArgOp::operator delete (pointer, sizeof(SgVarArgOp)); };
  161406             : #endif
  161407             : /* #line 161408 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  161408             : 
  161409             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  161410             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  161411             : // obviously imply C++.
  161412             : 
  161413             : // This implements the support within ROSE for memory pools.  Memory pools
  161414             : // support the most condensed usage of memory within the construction of
  161415             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  161416             : // by a new operator written for each class.
  161417             : 
  161418             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  161419             :     // User wants multi-thread support and POSIX threads are available.
  161420             : #   include <pthread.h>
  161421             :     static pthread_mutex_t SgVarArgEndOp_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  161422             : #else
  161423             :      // Cause synchronization to be skipped.
  161424             : #    ifndef ALLOC_MUTEX
  161425             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  161426             : #    endif
  161427             : #    ifdef _REENTRANT
  161428             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  161429             : #       ifdef _MSC_VER
  161430             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  161431             : #       else
  161432             : #           warning "POSIX threads are not available; synchronization being skipped"
  161433             : #       endif
  161434             : #    endif
  161435             : #endif
  161436             : 
  161437             : #ifndef ROSE_ALLOC_TRACE
  161438             : #  define ROSE_ALLOC_TRACE 0
  161439             : #endif
  161440             : 
  161441             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  161442             : #define ROSE_ALLOC_TRACE_CNT
  161443             : #include "memory-pool-snapshot.h"
  161444             : unsigned long alloc_trace_cnt = 0;
  161445             : #endif
  161446             : 
  161447             : #if ROSE_ALLOC_TRACE
  161448             : const unsigned SgVarArgEndOp::pool_size = 5;
  161449             : #else
  161450             : const unsigned SgVarArgEndOp::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  161451             : #endif
  161452             : 
  161453             : #ifndef ROSE_ALLOC_MEMSET
  161454             : #  define ROSE_ALLOC_MEMSET 0
  161455             : #endif
  161456             : 
  161457             : #ifndef ROSE_PEDANTIC_ALLOC
  161458             : #  define ROSE_PEDANTIC_ALLOC 0
  161459             : #endif
  161460             : 
  161461             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  161462             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  161463             : #endif
  161464             : 
  161465             : #if !defined(SGNODE__ALL_POOLS)
  161466             : #define SGNODE__ALL_POOLS
  161467             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  161468             : #endif
  161469             : 
  161470             : SgVarArgEndOp* SgVarArgEndOp::next_node = nullptr;
  161471             : std::vector<unsigned char*> SgVarArgEndOp::pools;
  161472             : 
  161473             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  161474             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  161475             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  161476             : // around this macro definition rather than each use).
  161477             : #ifndef ALLOC_MUTEX
  161478             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  161479             :         do {                                                                     \
  161480             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  161481             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  161482             :                 abort();                                                         \
  161483             :             }                                                                    \
  161484             :         } while (0);
  161485             : #endif
  161486             : 
  161487             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  161488             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  161489             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  161490             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  161491             : 
  161492             : /*! \brief New operator for SgVarArgEndOp.
  161493             : 
  161494             :    This new operator implements memory pools to provide most efficent 
  161495             :    use of the heap within construction of large ASTs.
  161496             : 
  161497             : \internal The new and delete operators use the lower level C malloc/free
  161498             :    function calls for performance and to make sure that mixing of malloc/free
  161499             :    and new/delete by the used can be caught more readily.  This may change
  161500             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  161501             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  161502             :    deallocate memory allocated using ROSE_MALLOC.
  161503             : */
  161504           0 : void *SgVarArgEndOp::operator new ( size_t Size )
  161505             : {
  161506             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  161507             :      * returning or throwing an exception. */
  161508           0 :     ALLOC_MUTEX(SgVarArgEndOp, lock);
  161509             : 
  161510             : #if ROSE_ALLOC_TRACE == 2
  161511             : //    printf("SgVarArgEndOp::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgVarArgEndOp::next_node);
  161512             : #endif
  161513             : 
  161514             : #if USE_CPP_NEW_DELETE_OPERATORS
  161515             :     void *mem = ROSE_MALLOC(Size);
  161516             :     ALLOC_MUTEX(SgVarArgEndOp, unlock);
  161517             :     return mem;
  161518             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  161519             : #if ROSE_PEDANTIC_ALLOC
  161520             :     ROSE_ASSERT(Size == sizeof(SgVarArgEndOp));
  161521             : #else
  161522           0 :     if (Size != sizeof(SgVarArgEndOp)) {
  161523           0 :       void * object = ROSE_MALLOC(Size);
  161524           0 :       ALLOC_MUTEX(SgVarArgEndOp, unlock);
  161525             :       return object;
  161526             :     }
  161527             : #endif
  161528             : 
  161529           0 :     if (SgVarArgEndOp::next_node == nullptr) {
  161530           0 :         SgVarArgEndOp * alloc = (SgVarArgEndOp*) ROSE_MALLOC ( SgVarArgEndOp::pool_size * sizeof(SgVarArgEndOp) );
  161531           0 :         ROSE_ASSERT(alloc != nullptr);
  161532             : 
  161533             : #if ROSE_ALLOC_TRACE == 2
  161534             : //        printf("SgVarArgEndOp::alloc\n  block[%zi] = [ %p , %p [\n", SgVarArgEndOp::pools.size(), alloc, alloc + SgVarArgEndOp::pool_size);
  161535             : #endif
  161536             : 
  161537             : #if ROSE_ALLOC_MEMSET == 1
  161538             : #elif ROSE_ALLOC_MEMSET == 2
  161539             :         memset(alloc, 0x00, SgVarArgEndOp::pool_size * sizeof(SgVarArgEndOp));
  161540             : #elif ROSE_ALLOC_MEMSET == 3
  161541             :         memset(alloc, 0xAA, SgVarArgEndOp::pool_size * sizeof(SgVarArgEndOp));
  161542             : #endif
  161543           0 :         for (unsigned i=0; i < SgVarArgEndOp::pool_size-1; i++) {
  161544           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
  161545             :         }
  161546           0 :         alloc[SgVarArgEndOp::pool_size-1].p_freepointer = nullptr;
  161547             : 
  161548           0 :         SgVarArgEndOp::pools.push_back ( (unsigned char *) alloc );
  161549           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgVarArgEndOp::pool_size * sizeof(SgVarArgEndOp), V_SgVarArgEndOp ) );
  161550           0 :         SgVarArgEndOp::next_node = alloc;
  161551             :     }
  161552           0 :     ROSE_ASSERT(SgVarArgEndOp::next_node != nullptr);
  161553             : 
  161554           0 :     SgVarArgEndOp * object = SgVarArgEndOp::next_node;
  161555           0 :     SgVarArgEndOp::next_node = (SgVarArgEndOp*)(object->p_freepointer);
  161556             : 
  161557             : #if ROSE_ALLOC_TRACE == 2
  161558             :     printf("SgVarArgEndOp::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgVarArgEndOp::next_node);
  161559             : #endif
  161560             : 
  161561           0 :     SgNode * fp = object->p_freepointer;
  161562             : #if ROSE_ALLOC_MEMSET == 1
  161563             : #elif ROSE_ALLOC_MEMSET == 2
  161564             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgVarArgEndOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  161565             : #elif ROSE_ALLOC_MEMSET == 3
  161566             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgVarArgEndOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  161567             : #endif
  161568           0 :     object->p_freepointer = fp;
  161569             : 
  161570             : #if ROSE_ALLOC_TRACE == 2
  161571             : //    printf("SgVarArgEndOp::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgVarArgEndOp::next_node);
  161572             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  161573             :     Rose::MemPool::snapshot(oss.str());
  161574             :     alloc_trace_cnt++;
  161575             : #endif
  161576             : 
  161577           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  161578             : 
  161579           0 :     ALLOC_MUTEX(SgVarArgEndOp, unlock);
  161580             : 
  161581             :     return object;
  161582             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  161583             : }
  161584             : 
  161585             : 
  161586             : 
  161587             : /*! \brief Delete operator for SgVarArgEndOp.
  161588             : 
  161589             :    This delete operator implements deallocation using memory pools to 
  161590             :    provide most efficent use of the heap within construction of large ASTs.
  161591             : 
  161592             : \internal The new and delete operators use the lower level C malloc/free
  161593             :    function calls for performance and to make sure that mixing of malloc/free
  161594             :    and new/delete by the used can be caught more readily.  This may change
  161595             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  161596             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  161597             :    deallocate memory allocated using ROSE_MALLOC.
  161598             : */
  161599           0 : void SgVarArgEndOp::operator delete(void *Pointer, size_t Size)
  161600             : {
  161601             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  161602             :      * or throwing an exception. */
  161603           0 :     ALLOC_MUTEX(SgVarArgEndOp, lock);
  161604             : 
  161605             : #if USE_CPP_NEW_DELETE_OPERATORS
  161606             :     ROSE_FREE(Pointer);
  161607             : #else
  161608             : #if ROSE_PEDANTIC_ALLOC
  161609             :     ROSE_ASSERT(Size == sizeof(SgVarArgEndOp));
  161610             : #else
  161611           0 :     if (Size != sizeof(SgVarArgEndOp)) {
  161612           0 :       ROSE_FREE(Pointer);
  161613           0 :       ALLOC_MUTEX(SgVarArgEndOp, unlock);
  161614             :       return;
  161615             :     }
  161616             : #endif
  161617             : 
  161618           0 :     SgVarArgEndOp * object = (SgVarArgEndOp*) Pointer;
  161619           0 :     ROSE_ASSERT(object != nullptr);
  161620             : 
  161621             : #if ROSE_ALLOC_TRACE == 2
  161622             : //  printf("SgVarArgEndOp::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgVarArgEndOp::next_node);
  161623             :     printf("SgVarArgEndOp::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgVarArgEndOp::next_node);
  161624             : #endif
  161625             : 
  161626             : #if ROSE_PEDANTIC_ALLOC
  161627             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  161628             : #endif
  161629             : 
  161630             : #if ROSE_ALLOC_MEMSET == 1
  161631             : #elif ROSE_ALLOC_MEMSET == 2
  161632             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgVarArgEndOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  161633             : #elif ROSE_ALLOC_MEMSET == 3
  161634             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgVarArgEndOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  161635             : #endif
  161636             : 
  161637             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  161638             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  161639             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  161640             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  161641             : #else
  161642           0 :     object->p_freepointer = SgVarArgEndOp::next_node;
  161643           0 :     SgVarArgEndOp::next_node = object;
  161644             : #endif
  161645             : 
  161646             : #if ROSE_ALLOC_TRACE == 2
  161647             : //  printf("SgVarArgEndOp::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgVarArgEndOp::next_node);
  161648             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  161649             :     Rose::MemPool::snapshot(oss.str());
  161650             :     alloc_trace_cnt++;
  161651             : #endif
  161652             : 
  161653             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  161654             : 
  161655           0 :     ALLOC_MUTEX(SgVarArgEndOp, unlock);
  161656             : }
  161657             : 
  161658             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  161659             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  161660             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  161661             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  161662             : // Also, note comment below from Robb (copied from the Common.code file).
  161663             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  161664             : //
  161665             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  161666             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  161667             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  161668             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  161669             : #if 0
  161670             : void SgVarArgEndOp::operator delete(void* pointer) { SgVarArgEndOp::operator delete (pointer, sizeof(SgVarArgEndOp)); };
  161671             : #endif
  161672             : /* #line 161673 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  161673             : 
  161674             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  161675             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  161676             : // obviously imply C++.
  161677             : 
  161678             : // This implements the support within ROSE for memory pools.  Memory pools
  161679             : // support the most condensed usage of memory within the construction of
  161680             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  161681             : // by a new operator written for each class.
  161682             : 
  161683             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  161684             :     // User wants multi-thread support and POSIX threads are available.
  161685             : #   include <pthread.h>
  161686             :     static pthread_mutex_t SgVarArgCopyOp_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  161687             : #else
  161688             :      // Cause synchronization to be skipped.
  161689             : #    ifndef ALLOC_MUTEX
  161690             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  161691             : #    endif
  161692             : #    ifdef _REENTRANT
  161693             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  161694             : #       ifdef _MSC_VER
  161695             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  161696             : #       else
  161697             : #           warning "POSIX threads are not available; synchronization being skipped"
  161698             : #       endif
  161699             : #    endif
  161700             : #endif
  161701             : 
  161702             : #ifndef ROSE_ALLOC_TRACE
  161703             : #  define ROSE_ALLOC_TRACE 0
  161704             : #endif
  161705             : 
  161706             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  161707             : #define ROSE_ALLOC_TRACE_CNT
  161708             : #include "memory-pool-snapshot.h"
  161709             : unsigned long alloc_trace_cnt = 0;
  161710             : #endif
  161711             : 
  161712             : #if ROSE_ALLOC_TRACE
  161713             : const unsigned SgVarArgCopyOp::pool_size = 5;
  161714             : #else
  161715             : const unsigned SgVarArgCopyOp::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  161716             : #endif
  161717             : 
  161718             : #ifndef ROSE_ALLOC_MEMSET
  161719             : #  define ROSE_ALLOC_MEMSET 0
  161720             : #endif
  161721             : 
  161722             : #ifndef ROSE_PEDANTIC_ALLOC
  161723             : #  define ROSE_PEDANTIC_ALLOC 0
  161724             : #endif
  161725             : 
  161726             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  161727             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  161728             : #endif
  161729             : 
  161730             : #if !defined(SGNODE__ALL_POOLS)
  161731             : #define SGNODE__ALL_POOLS
  161732             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  161733             : #endif
  161734             : 
  161735             : SgVarArgCopyOp* SgVarArgCopyOp::next_node = nullptr;
  161736             : std::vector<unsigned char*> SgVarArgCopyOp::pools;
  161737             : 
  161738             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  161739             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  161740             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  161741             : // around this macro definition rather than each use).
  161742             : #ifndef ALLOC_MUTEX
  161743             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  161744             :         do {                                                                     \
  161745             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  161746             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  161747             :                 abort();                                                         \
  161748             :             }                                                                    \
  161749             :         } while (0);
  161750             : #endif
  161751             : 
  161752             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  161753             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  161754             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  161755             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  161756             : 
  161757             : /*! \brief New operator for SgVarArgCopyOp.
  161758             : 
  161759             :    This new operator implements memory pools to provide most efficent 
  161760             :    use of the heap within construction of large ASTs.
  161761             : 
  161762             : \internal The new and delete operators use the lower level C malloc/free
  161763             :    function calls for performance and to make sure that mixing of malloc/free
  161764             :    and new/delete by the used can be caught more readily.  This may change
  161765             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  161766             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  161767             :    deallocate memory allocated using ROSE_MALLOC.
  161768             : */
  161769           0 : void *SgVarArgCopyOp::operator new ( size_t Size )
  161770             : {
  161771             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  161772             :      * returning or throwing an exception. */
  161773           0 :     ALLOC_MUTEX(SgVarArgCopyOp, lock);
  161774             : 
  161775             : #if ROSE_ALLOC_TRACE == 2
  161776             : //    printf("SgVarArgCopyOp::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgVarArgCopyOp::next_node);
  161777             : #endif
  161778             : 
  161779             : #if USE_CPP_NEW_DELETE_OPERATORS
  161780             :     void *mem = ROSE_MALLOC(Size);
  161781             :     ALLOC_MUTEX(SgVarArgCopyOp, unlock);
  161782             :     return mem;
  161783             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  161784             : #if ROSE_PEDANTIC_ALLOC
  161785             :     ROSE_ASSERT(Size == sizeof(SgVarArgCopyOp));
  161786             : #else
  161787           0 :     if (Size != sizeof(SgVarArgCopyOp)) {
  161788           0 :       void * object = ROSE_MALLOC(Size);
  161789           0 :       ALLOC_MUTEX(SgVarArgCopyOp, unlock);
  161790             :       return object;
  161791             :     }
  161792             : #endif
  161793             : 
  161794           0 :     if (SgVarArgCopyOp::next_node == nullptr) {
  161795           0 :         SgVarArgCopyOp * alloc = (SgVarArgCopyOp*) ROSE_MALLOC ( SgVarArgCopyOp::pool_size * sizeof(SgVarArgCopyOp) );
  161796           0 :         ROSE_ASSERT(alloc != nullptr);
  161797             : 
  161798             : #if ROSE_ALLOC_TRACE == 2
  161799             : //        printf("SgVarArgCopyOp::alloc\n  block[%zi] = [ %p , %p [\n", SgVarArgCopyOp::pools.size(), alloc, alloc + SgVarArgCopyOp::pool_size);
  161800             : #endif
  161801             : 
  161802             : #if ROSE_ALLOC_MEMSET == 1
  161803             : #elif ROSE_ALLOC_MEMSET == 2
  161804             :         memset(alloc, 0x00, SgVarArgCopyOp::pool_size * sizeof(SgVarArgCopyOp));
  161805             : #elif ROSE_ALLOC_MEMSET == 3
  161806             :         memset(alloc, 0xAA, SgVarArgCopyOp::pool_size * sizeof(SgVarArgCopyOp));
  161807             : #endif
  161808           0 :         for (unsigned i=0; i < SgVarArgCopyOp::pool_size-1; i++) {
  161809           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
  161810             :         }
  161811           0 :         alloc[SgVarArgCopyOp::pool_size-1].p_freepointer = nullptr;
  161812             : 
  161813           0 :         SgVarArgCopyOp::pools.push_back ( (unsigned char *) alloc );
  161814           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgVarArgCopyOp::pool_size * sizeof(SgVarArgCopyOp), V_SgVarArgCopyOp ) );
  161815           0 :         SgVarArgCopyOp::next_node = alloc;
  161816             :     }
  161817           0 :     ROSE_ASSERT(SgVarArgCopyOp::next_node != nullptr);
  161818             : 
  161819           0 :     SgVarArgCopyOp * object = SgVarArgCopyOp::next_node;
  161820           0 :     SgVarArgCopyOp::next_node = (SgVarArgCopyOp*)(object->p_freepointer);
  161821             : 
  161822             : #if ROSE_ALLOC_TRACE == 2
  161823             :     printf("SgVarArgCopyOp::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgVarArgCopyOp::next_node);
  161824             : #endif
  161825             : 
  161826           0 :     SgNode * fp = object->p_freepointer;
  161827             : #if ROSE_ALLOC_MEMSET == 1
  161828             : #elif ROSE_ALLOC_MEMSET == 2
  161829             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgVarArgCopyOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  161830             : #elif ROSE_ALLOC_MEMSET == 3
  161831             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgVarArgCopyOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  161832             : #endif
  161833           0 :     object->p_freepointer = fp;
  161834             : 
  161835             : #if ROSE_ALLOC_TRACE == 2
  161836             : //    printf("SgVarArgCopyOp::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgVarArgCopyOp::next_node);
  161837             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  161838             :     Rose::MemPool::snapshot(oss.str());
  161839             :     alloc_trace_cnt++;
  161840             : #endif
  161841             : 
  161842           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  161843             : 
  161844           0 :     ALLOC_MUTEX(SgVarArgCopyOp, unlock);
  161845             : 
  161846             :     return object;
  161847             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  161848             : }
  161849             : 
  161850             : 
  161851             : 
  161852             : /*! \brief Delete operator for SgVarArgCopyOp.
  161853             : 
  161854             :    This delete operator implements deallocation using memory pools to 
  161855             :    provide most efficent use of the heap within construction of large ASTs.
  161856             : 
  161857             : \internal The new and delete operators use the lower level C malloc/free
  161858             :    function calls for performance and to make sure that mixing of malloc/free
  161859             :    and new/delete by the used can be caught more readily.  This may change
  161860             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  161861             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  161862             :    deallocate memory allocated using ROSE_MALLOC.
  161863             : */
  161864           0 : void SgVarArgCopyOp::operator delete(void *Pointer, size_t Size)
  161865             : {
  161866             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  161867             :      * or throwing an exception. */
  161868           0 :     ALLOC_MUTEX(SgVarArgCopyOp, lock);
  161869             : 
  161870             : #if USE_CPP_NEW_DELETE_OPERATORS
  161871             :     ROSE_FREE(Pointer);
  161872             : #else
  161873             : #if ROSE_PEDANTIC_ALLOC
  161874             :     ROSE_ASSERT(Size == sizeof(SgVarArgCopyOp));
  161875             : #else
  161876           0 :     if (Size != sizeof(SgVarArgCopyOp)) {
  161877           0 :       ROSE_FREE(Pointer);
  161878           0 :       ALLOC_MUTEX(SgVarArgCopyOp, unlock);
  161879             :       return;
  161880             :     }
  161881             : #endif
  161882             : 
  161883           0 :     SgVarArgCopyOp * object = (SgVarArgCopyOp*) Pointer;
  161884           0 :     ROSE_ASSERT(object != nullptr);
  161885             : 
  161886             : #if ROSE_ALLOC_TRACE == 2
  161887             : //  printf("SgVarArgCopyOp::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgVarArgCopyOp::next_node);
  161888             :     printf("SgVarArgCopyOp::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgVarArgCopyOp::next_node);
  161889             : #endif
  161890             : 
  161891             : #if ROSE_PEDANTIC_ALLOC
  161892             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  161893             : #endif
  161894             : 
  161895             : #if ROSE_ALLOC_MEMSET == 1
  161896             : #elif ROSE_ALLOC_MEMSET == 2
  161897             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgVarArgCopyOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  161898             : #elif ROSE_ALLOC_MEMSET == 3
  161899             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgVarArgCopyOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  161900             : #endif
  161901             : 
  161902             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  161903             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  161904             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  161905             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  161906             : #else
  161907           0 :     object->p_freepointer = SgVarArgCopyOp::next_node;
  161908           0 :     SgVarArgCopyOp::next_node = object;
  161909             : #endif
  161910             : 
  161911             : #if ROSE_ALLOC_TRACE == 2
  161912             : //  printf("SgVarArgCopyOp::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgVarArgCopyOp::next_node);
  161913             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  161914             :     Rose::MemPool::snapshot(oss.str());
  161915             :     alloc_trace_cnt++;
  161916             : #endif
  161917             : 
  161918             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  161919             : 
  161920           0 :     ALLOC_MUTEX(SgVarArgCopyOp, unlock);
  161921             : }
  161922             : 
  161923             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  161924             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  161925             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  161926             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  161927             : // Also, note comment below from Robb (copied from the Common.code file).
  161928             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  161929             : //
  161930             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  161931             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  161932             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  161933             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  161934             : #if 0
  161935             : void SgVarArgCopyOp::operator delete(void* pointer) { SgVarArgCopyOp::operator delete (pointer, sizeof(SgVarArgCopyOp)); };
  161936             : #endif
  161937             : /* #line 161938 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  161938             : 
  161939             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  161940             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  161941             : // obviously imply C++.
  161942             : 
  161943             : // This implements the support within ROSE for memory pools.  Memory pools
  161944             : // support the most condensed usage of memory within the construction of
  161945             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  161946             : // by a new operator written for each class.
  161947             : 
  161948             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  161949             :     // User wants multi-thread support and POSIX threads are available.
  161950             : #   include <pthread.h>
  161951             :     static pthread_mutex_t SgVarArgStartOneOperandOp_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  161952             : #else
  161953             :      // Cause synchronization to be skipped.
  161954             : #    ifndef ALLOC_MUTEX
  161955             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  161956             : #    endif
  161957             : #    ifdef _REENTRANT
  161958             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  161959             : #       ifdef _MSC_VER
  161960             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  161961             : #       else
  161962             : #           warning "POSIX threads are not available; synchronization being skipped"
  161963             : #       endif
  161964             : #    endif
  161965             : #endif
  161966             : 
  161967             : #ifndef ROSE_ALLOC_TRACE
  161968             : #  define ROSE_ALLOC_TRACE 0
  161969             : #endif
  161970             : 
  161971             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  161972             : #define ROSE_ALLOC_TRACE_CNT
  161973             : #include "memory-pool-snapshot.h"
  161974             : unsigned long alloc_trace_cnt = 0;
  161975             : #endif
  161976             : 
  161977             : #if ROSE_ALLOC_TRACE
  161978             : const unsigned SgVarArgStartOneOperandOp::pool_size = 5;
  161979             : #else
  161980             : const unsigned SgVarArgStartOneOperandOp::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  161981             : #endif
  161982             : 
  161983             : #ifndef ROSE_ALLOC_MEMSET
  161984             : #  define ROSE_ALLOC_MEMSET 0
  161985             : #endif
  161986             : 
  161987             : #ifndef ROSE_PEDANTIC_ALLOC
  161988             : #  define ROSE_PEDANTIC_ALLOC 0
  161989             : #endif
  161990             : 
  161991             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  161992             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  161993             : #endif
  161994             : 
  161995             : #if !defined(SGNODE__ALL_POOLS)
  161996             : #define SGNODE__ALL_POOLS
  161997             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  161998             : #endif
  161999             : 
  162000             : SgVarArgStartOneOperandOp* SgVarArgStartOneOperandOp::next_node = nullptr;
  162001             : std::vector<unsigned char*> SgVarArgStartOneOperandOp::pools;
  162002             : 
  162003             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  162004             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  162005             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  162006             : // around this macro definition rather than each use).
  162007             : #ifndef ALLOC_MUTEX
  162008             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  162009             :         do {                                                                     \
  162010             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  162011             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  162012             :                 abort();                                                         \
  162013             :             }                                                                    \
  162014             :         } while (0);
  162015             : #endif
  162016             : 
  162017             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  162018             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  162019             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  162020             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  162021             : 
  162022             : /*! \brief New operator for SgVarArgStartOneOperandOp.
  162023             : 
  162024             :    This new operator implements memory pools to provide most efficent 
  162025             :    use of the heap within construction of large ASTs.
  162026             : 
  162027             : \internal The new and delete operators use the lower level C malloc/free
  162028             :    function calls for performance and to make sure that mixing of malloc/free
  162029             :    and new/delete by the used can be caught more readily.  This may change
  162030             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  162031             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  162032             :    deallocate memory allocated using ROSE_MALLOC.
  162033             : */
  162034           0 : void *SgVarArgStartOneOperandOp::operator new ( size_t Size )
  162035             : {
  162036             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  162037             :      * returning or throwing an exception. */
  162038           0 :     ALLOC_MUTEX(SgVarArgStartOneOperandOp, lock);
  162039             : 
  162040             : #if ROSE_ALLOC_TRACE == 2
  162041             : //    printf("SgVarArgStartOneOperandOp::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgVarArgStartOneOperandOp::next_node);
  162042             : #endif
  162043             : 
  162044             : #if USE_CPP_NEW_DELETE_OPERATORS
  162045             :     void *mem = ROSE_MALLOC(Size);
  162046             :     ALLOC_MUTEX(SgVarArgStartOneOperandOp, unlock);
  162047             :     return mem;
  162048             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  162049             : #if ROSE_PEDANTIC_ALLOC
  162050             :     ROSE_ASSERT(Size == sizeof(SgVarArgStartOneOperandOp));
  162051             : #else
  162052           0 :     if (Size != sizeof(SgVarArgStartOneOperandOp)) {
  162053           0 :       void * object = ROSE_MALLOC(Size);
  162054           0 :       ALLOC_MUTEX(SgVarArgStartOneOperandOp, unlock);
  162055             :       return object;
  162056             :     }
  162057             : #endif
  162058             : 
  162059           0 :     if (SgVarArgStartOneOperandOp::next_node == nullptr) {
  162060           0 :         SgVarArgStartOneOperandOp * alloc = (SgVarArgStartOneOperandOp*) ROSE_MALLOC ( SgVarArgStartOneOperandOp::pool_size * sizeof(SgVarArgStartOneOperandOp) );
  162061           0 :         ROSE_ASSERT(alloc != nullptr);
  162062             : 
  162063             : #if ROSE_ALLOC_TRACE == 2
  162064             : //        printf("SgVarArgStartOneOperandOp::alloc\n  block[%zi] = [ %p , %p [\n", SgVarArgStartOneOperandOp::pools.size(), alloc, alloc + SgVarArgStartOneOperandOp::pool_size);
  162065             : #endif
  162066             : 
  162067             : #if ROSE_ALLOC_MEMSET == 1
  162068             : #elif ROSE_ALLOC_MEMSET == 2
  162069             :         memset(alloc, 0x00, SgVarArgStartOneOperandOp::pool_size * sizeof(SgVarArgStartOneOperandOp));
  162070             : #elif ROSE_ALLOC_MEMSET == 3
  162071             :         memset(alloc, 0xAA, SgVarArgStartOneOperandOp::pool_size * sizeof(SgVarArgStartOneOperandOp));
  162072             : #endif
  162073           0 :         for (unsigned i=0; i < SgVarArgStartOneOperandOp::pool_size-1; i++) {
  162074           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
  162075             :         }
  162076           0 :         alloc[SgVarArgStartOneOperandOp::pool_size-1].p_freepointer = nullptr;
  162077             : 
  162078           0 :         SgVarArgStartOneOperandOp::pools.push_back ( (unsigned char *) alloc );
  162079           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgVarArgStartOneOperandOp::pool_size * sizeof(SgVarArgStartOneOperandOp), V_SgVarArgStartOneOperandOp ) );
  162080           0 :         SgVarArgStartOneOperandOp::next_node = alloc;
  162081             :     }
  162082           0 :     ROSE_ASSERT(SgVarArgStartOneOperandOp::next_node != nullptr);
  162083             : 
  162084           0 :     SgVarArgStartOneOperandOp * object = SgVarArgStartOneOperandOp::next_node;
  162085           0 :     SgVarArgStartOneOperandOp::next_node = (SgVarArgStartOneOperandOp*)(object->p_freepointer);
  162086             : 
  162087             : #if ROSE_ALLOC_TRACE == 2
  162088             :     printf("SgVarArgStartOneOperandOp::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgVarArgStartOneOperandOp::next_node);
  162089             : #endif
  162090             : 
  162091           0 :     SgNode * fp = object->p_freepointer;
  162092             : #if ROSE_ALLOC_MEMSET == 1
  162093             : #elif ROSE_ALLOC_MEMSET == 2
  162094             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgVarArgStartOneOperandOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  162095             : #elif ROSE_ALLOC_MEMSET == 3
  162096             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgVarArgStartOneOperandOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  162097             : #endif
  162098           0 :     object->p_freepointer = fp;
  162099             : 
  162100             : #if ROSE_ALLOC_TRACE == 2
  162101             : //    printf("SgVarArgStartOneOperandOp::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgVarArgStartOneOperandOp::next_node);
  162102             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  162103             :     Rose::MemPool::snapshot(oss.str());
  162104             :     alloc_trace_cnt++;
  162105             : #endif
  162106             : 
  162107           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  162108             : 
  162109           0 :     ALLOC_MUTEX(SgVarArgStartOneOperandOp, unlock);
  162110             : 
  162111             :     return object;
  162112             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  162113             : }
  162114             : 
  162115             : 
  162116             : 
  162117             : /*! \brief Delete operator for SgVarArgStartOneOperandOp.
  162118             : 
  162119             :    This delete operator implements deallocation using memory pools to 
  162120             :    provide most efficent use of the heap within construction of large ASTs.
  162121             : 
  162122             : \internal The new and delete operators use the lower level C malloc/free
  162123             :    function calls for performance and to make sure that mixing of malloc/free
  162124             :    and new/delete by the used can be caught more readily.  This may change
  162125             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  162126             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  162127             :    deallocate memory allocated using ROSE_MALLOC.
  162128             : */
  162129           0 : void SgVarArgStartOneOperandOp::operator delete(void *Pointer, size_t Size)
  162130             : {
  162131             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  162132             :      * or throwing an exception. */
  162133           0 :     ALLOC_MUTEX(SgVarArgStartOneOperandOp, lock);
  162134             : 
  162135             : #if USE_CPP_NEW_DELETE_OPERATORS
  162136             :     ROSE_FREE(Pointer);
  162137             : #else
  162138             : #if ROSE_PEDANTIC_ALLOC
  162139             :     ROSE_ASSERT(Size == sizeof(SgVarArgStartOneOperandOp));
  162140             : #else
  162141           0 :     if (Size != sizeof(SgVarArgStartOneOperandOp)) {
  162142           0 :       ROSE_FREE(Pointer);
  162143           0 :       ALLOC_MUTEX(SgVarArgStartOneOperandOp, unlock);
  162144             :       return;
  162145             :     }
  162146             : #endif
  162147             : 
  162148           0 :     SgVarArgStartOneOperandOp * object = (SgVarArgStartOneOperandOp*) Pointer;
  162149           0 :     ROSE_ASSERT(object != nullptr);
  162150             : 
  162151             : #if ROSE_ALLOC_TRACE == 2
  162152             : //  printf("SgVarArgStartOneOperandOp::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgVarArgStartOneOperandOp::next_node);
  162153             :     printf("SgVarArgStartOneOperandOp::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgVarArgStartOneOperandOp::next_node);
  162154             : #endif
  162155             : 
  162156             : #if ROSE_PEDANTIC_ALLOC
  162157             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  162158             : #endif
  162159             : 
  162160             : #if ROSE_ALLOC_MEMSET == 1
  162161             : #elif ROSE_ALLOC_MEMSET == 2
  162162             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgVarArgStartOneOperandOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  162163             : #elif ROSE_ALLOC_MEMSET == 3
  162164             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgVarArgStartOneOperandOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  162165             : #endif
  162166             : 
  162167             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  162168             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  162169             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  162170             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  162171             : #else
  162172           0 :     object->p_freepointer = SgVarArgStartOneOperandOp::next_node;
  162173           0 :     SgVarArgStartOneOperandOp::next_node = object;
  162174             : #endif
  162175             : 
  162176             : #if ROSE_ALLOC_TRACE == 2
  162177             : //  printf("SgVarArgStartOneOperandOp::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgVarArgStartOneOperandOp::next_node);
  162178             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  162179             :     Rose::MemPool::snapshot(oss.str());
  162180             :     alloc_trace_cnt++;
  162181             : #endif
  162182             : 
  162183             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  162184             : 
  162185           0 :     ALLOC_MUTEX(SgVarArgStartOneOperandOp, unlock);
  162186             : }
  162187             : 
  162188             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  162189             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  162190             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  162191             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  162192             : // Also, note comment below from Robb (copied from the Common.code file).
  162193             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  162194             : //
  162195             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  162196             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  162197             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  162198             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  162199             : #if 0
  162200             : void SgVarArgStartOneOperandOp::operator delete(void* pointer) { SgVarArgStartOneOperandOp::operator delete (pointer, sizeof(SgVarArgStartOneOperandOp)); };
  162201             : #endif
  162202             : /* #line 162203 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  162203             : 
  162204             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  162205             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  162206             : // obviously imply C++.
  162207             : 
  162208             : // This implements the support within ROSE for memory pools.  Memory pools
  162209             : // support the most condensed usage of memory within the construction of
  162210             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  162211             : // by a new operator written for each class.
  162212             : 
  162213             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  162214             :     // User wants multi-thread support and POSIX threads are available.
  162215             : #   include <pthread.h>
  162216             :     static pthread_mutex_t SgNullExpression_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  162217             : #else
  162218             :      // Cause synchronization to be skipped.
  162219             : #    ifndef ALLOC_MUTEX
  162220             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  162221             : #    endif
  162222             : #    ifdef _REENTRANT
  162223             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  162224             : #       ifdef _MSC_VER
  162225             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  162226             : #       else
  162227             : #           warning "POSIX threads are not available; synchronization being skipped"
  162228             : #       endif
  162229             : #    endif
  162230             : #endif
  162231             : 
  162232             : #ifndef ROSE_ALLOC_TRACE
  162233             : #  define ROSE_ALLOC_TRACE 0
  162234             : #endif
  162235             : 
  162236             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  162237             : #define ROSE_ALLOC_TRACE_CNT
  162238             : #include "memory-pool-snapshot.h"
  162239             : unsigned long alloc_trace_cnt = 0;
  162240             : #endif
  162241             : 
  162242             : #if ROSE_ALLOC_TRACE
  162243             : const unsigned SgNullExpression::pool_size = 5;
  162244             : #else
  162245             : const unsigned SgNullExpression::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  162246             : #endif
  162247             : 
  162248             : #ifndef ROSE_ALLOC_MEMSET
  162249             : #  define ROSE_ALLOC_MEMSET 0
  162250             : #endif
  162251             : 
  162252             : #ifndef ROSE_PEDANTIC_ALLOC
  162253             : #  define ROSE_PEDANTIC_ALLOC 0
  162254             : #endif
  162255             : 
  162256             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  162257             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  162258             : #endif
  162259             : 
  162260             : #if !defined(SGNODE__ALL_POOLS)
  162261             : #define SGNODE__ALL_POOLS
  162262             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  162263             : #endif
  162264             : 
  162265             : SgNullExpression* SgNullExpression::next_node = nullptr;
  162266             : std::vector<unsigned char*> SgNullExpression::pools;
  162267             : 
  162268             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  162269             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  162270             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  162271             : // around this macro definition rather than each use).
  162272             : #ifndef ALLOC_MUTEX
  162273             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  162274             :         do {                                                                     \
  162275             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  162276             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  162277             :                 abort();                                                         \
  162278             :             }                                                                    \
  162279             :         } while (0);
  162280             : #endif
  162281             : 
  162282             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  162283             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  162284             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  162285             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  162286             : 
  162287             : /*! \brief New operator for SgNullExpression.
  162288             : 
  162289             :    This new operator implements memory pools to provide most efficent 
  162290             :    use of the heap within construction of large ASTs.
  162291             : 
  162292             : \internal The new and delete operators use the lower level C malloc/free
  162293             :    function calls for performance and to make sure that mixing of malloc/free
  162294             :    and new/delete by the used can be caught more readily.  This may change
  162295             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  162296             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  162297             :    deallocate memory allocated using ROSE_MALLOC.
  162298             : */
  162299        1820 : void *SgNullExpression::operator new ( size_t Size )
  162300             : {
  162301             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  162302             :      * returning or throwing an exception. */
  162303        1820 :     ALLOC_MUTEX(SgNullExpression, lock);
  162304             : 
  162305             : #if ROSE_ALLOC_TRACE == 2
  162306             : //    printf("SgNullExpression::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgNullExpression::next_node);
  162307             : #endif
  162308             : 
  162309             : #if USE_CPP_NEW_DELETE_OPERATORS
  162310             :     void *mem = ROSE_MALLOC(Size);
  162311             :     ALLOC_MUTEX(SgNullExpression, unlock);
  162312             :     return mem;
  162313             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  162314             : #if ROSE_PEDANTIC_ALLOC
  162315             :     ROSE_ASSERT(Size == sizeof(SgNullExpression));
  162316             : #else
  162317        1820 :     if (Size != sizeof(SgNullExpression)) {
  162318           0 :       void * object = ROSE_MALLOC(Size);
  162319           0 :       ALLOC_MUTEX(SgNullExpression, unlock);
  162320             :       return object;
  162321             :     }
  162322             : #endif
  162323             : 
  162324        1820 :     if (SgNullExpression::next_node == nullptr) {
  162325         226 :         SgNullExpression * alloc = (SgNullExpression*) ROSE_MALLOC ( SgNullExpression::pool_size * sizeof(SgNullExpression) );
  162326         226 :         ROSE_ASSERT(alloc != nullptr);
  162327             : 
  162328             : #if ROSE_ALLOC_TRACE == 2
  162329             : //        printf("SgNullExpression::alloc\n  block[%zi] = [ %p , %p [\n", SgNullExpression::pools.size(), alloc, alloc + SgNullExpression::pool_size);
  162330             : #endif
  162331             : 
  162332             : #if ROSE_ALLOC_MEMSET == 1
  162333             : #elif ROSE_ALLOC_MEMSET == 2
  162334             :         memset(alloc, 0x00, SgNullExpression::pool_size * sizeof(SgNullExpression));
  162335             : #elif ROSE_ALLOC_MEMSET == 3
  162336             :         memset(alloc, 0xAA, SgNullExpression::pool_size * sizeof(SgNullExpression));
  162337             : #endif
  162338      452000 :         for (unsigned i=0; i < SgNullExpression::pool_size-1; i++) {
  162339      451774 :           alloc[i].p_freepointer = &(alloc[i+1]);
  162340             :         }
  162341         226 :         alloc[SgNullExpression::pool_size-1].p_freepointer = nullptr;
  162342             : 
  162343         226 :         SgNullExpression::pools.push_back ( (unsigned char *) alloc );
  162344         226 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgNullExpression::pool_size * sizeof(SgNullExpression), V_SgNullExpression ) );
  162345         226 :         SgNullExpression::next_node = alloc;
  162346             :     }
  162347        1820 :     ROSE_ASSERT(SgNullExpression::next_node != nullptr);
  162348             : 
  162349        1820 :     SgNullExpression * object = SgNullExpression::next_node;
  162350        1820 :     SgNullExpression::next_node = (SgNullExpression*)(object->p_freepointer);
  162351             : 
  162352             : #if ROSE_ALLOC_TRACE == 2
  162353             :     printf("SgNullExpression::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgNullExpression::next_node);
  162354             : #endif
  162355             : 
  162356        1820 :     SgNode * fp = object->p_freepointer;
  162357             : #if ROSE_ALLOC_MEMSET == 1
  162358             : #elif ROSE_ALLOC_MEMSET == 2
  162359             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgNullExpression) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  162360             : #elif ROSE_ALLOC_MEMSET == 3
  162361             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgNullExpression) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  162362             : #endif
  162363        1820 :     object->p_freepointer = fp;
  162364             : 
  162365             : #if ROSE_ALLOC_TRACE == 2
  162366             : //    printf("SgNullExpression::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgNullExpression::next_node);
  162367             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  162368             :     Rose::MemPool::snapshot(oss.str());
  162369             :     alloc_trace_cnt++;
  162370             : #endif
  162371             : 
  162372        1820 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  162373             : 
  162374        1820 :     ALLOC_MUTEX(SgNullExpression, unlock);
  162375             : 
  162376             :     return object;
  162377             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  162378             : }
  162379             : 
  162380             : 
  162381             : 
  162382             : /*! \brief Delete operator for SgNullExpression.
  162383             : 
  162384             :    This delete operator implements deallocation using memory pools to 
  162385             :    provide most efficent use of the heap within construction of large ASTs.
  162386             : 
  162387             : \internal The new and delete operators use the lower level C malloc/free
  162388             :    function calls for performance and to make sure that mixing of malloc/free
  162389             :    and new/delete by the used can be caught more readily.  This may change
  162390             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  162391             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  162392             :    deallocate memory allocated using ROSE_MALLOC.
  162393             : */
  162394         244 : void SgNullExpression::operator delete(void *Pointer, size_t Size)
  162395             : {
  162396             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  162397             :      * or throwing an exception. */
  162398         244 :     ALLOC_MUTEX(SgNullExpression, lock);
  162399             : 
  162400             : #if USE_CPP_NEW_DELETE_OPERATORS
  162401             :     ROSE_FREE(Pointer);
  162402             : #else
  162403             : #if ROSE_PEDANTIC_ALLOC
  162404             :     ROSE_ASSERT(Size == sizeof(SgNullExpression));
  162405             : #else
  162406         244 :     if (Size != sizeof(SgNullExpression)) {
  162407           0 :       ROSE_FREE(Pointer);
  162408           0 :       ALLOC_MUTEX(SgNullExpression, unlock);
  162409             :       return;
  162410             :     }
  162411             : #endif
  162412             : 
  162413         244 :     SgNullExpression * object = (SgNullExpression*) Pointer;
  162414         244 :     ROSE_ASSERT(object != nullptr);
  162415             : 
  162416             : #if ROSE_ALLOC_TRACE == 2
  162417             : //  printf("SgNullExpression::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgNullExpression::next_node);
  162418             :     printf("SgNullExpression::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgNullExpression::next_node);
  162419             : #endif
  162420             : 
  162421             : #if ROSE_PEDANTIC_ALLOC
  162422             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  162423             : #endif
  162424             : 
  162425             : #if ROSE_ALLOC_MEMSET == 1
  162426             : #elif ROSE_ALLOC_MEMSET == 2
  162427             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgNullExpression) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  162428             : #elif ROSE_ALLOC_MEMSET == 3
  162429             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgNullExpression) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  162430             : #endif
  162431             : 
  162432             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  162433             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  162434             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  162435             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  162436             : #else
  162437         244 :     object->p_freepointer = SgNullExpression::next_node;
  162438         244 :     SgNullExpression::next_node = object;
  162439             : #endif
  162440             : 
  162441             : #if ROSE_ALLOC_TRACE == 2
  162442             : //  printf("SgNullExpression::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgNullExpression::next_node);
  162443             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  162444             :     Rose::MemPool::snapshot(oss.str());
  162445             :     alloc_trace_cnt++;
  162446             : #endif
  162447             : 
  162448             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  162449             : 
  162450         244 :     ALLOC_MUTEX(SgNullExpression, unlock);
  162451             : }
  162452             : 
  162453             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  162454             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  162455             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  162456             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  162457             : // Also, note comment below from Robb (copied from the Common.code file).
  162458             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  162459             : //
  162460             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  162461             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  162462             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  162463             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  162464             : #if 0
  162465             : void SgNullExpression::operator delete(void* pointer) { SgNullExpression::operator delete (pointer, sizeof(SgNullExpression)); };
  162466             : #endif
  162467             : /* #line 162468 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  162468             : 
  162469             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  162470             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  162471             : // obviously imply C++.
  162472             : 
  162473             : // This implements the support within ROSE for memory pools.  Memory pools
  162474             : // support the most condensed usage of memory within the construction of
  162475             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  162476             : // by a new operator written for each class.
  162477             : 
  162478             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  162479             :     // User wants multi-thread support and POSIX threads are available.
  162480             : #   include <pthread.h>
  162481             :     static pthread_mutex_t SgVariantExpression_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  162482             : #else
  162483             :      // Cause synchronization to be skipped.
  162484             : #    ifndef ALLOC_MUTEX
  162485             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  162486             : #    endif
  162487             : #    ifdef _REENTRANT
  162488             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  162489             : #       ifdef _MSC_VER
  162490             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  162491             : #       else
  162492             : #           warning "POSIX threads are not available; synchronization being skipped"
  162493             : #       endif
  162494             : #    endif
  162495             : #endif
  162496             : 
  162497             : #ifndef ROSE_ALLOC_TRACE
  162498             : #  define ROSE_ALLOC_TRACE 0
  162499             : #endif
  162500             : 
  162501             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  162502             : #define ROSE_ALLOC_TRACE_CNT
  162503             : #include "memory-pool-snapshot.h"
  162504             : unsigned long alloc_trace_cnt = 0;
  162505             : #endif
  162506             : 
  162507             : #if ROSE_ALLOC_TRACE
  162508             : const unsigned SgVariantExpression::pool_size = 5;
  162509             : #else
  162510             : const unsigned SgVariantExpression::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  162511             : #endif
  162512             : 
  162513             : #ifndef ROSE_ALLOC_MEMSET
  162514             : #  define ROSE_ALLOC_MEMSET 0
  162515             : #endif
  162516             : 
  162517             : #ifndef ROSE_PEDANTIC_ALLOC
  162518             : #  define ROSE_PEDANTIC_ALLOC 0
  162519             : #endif
  162520             : 
  162521             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  162522             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  162523             : #endif
  162524             : 
  162525             : #if !defined(SGNODE__ALL_POOLS)
  162526             : #define SGNODE__ALL_POOLS
  162527             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  162528             : #endif
  162529             : 
  162530             : SgVariantExpression* SgVariantExpression::next_node = nullptr;
  162531             : std::vector<unsigned char*> SgVariantExpression::pools;
  162532             : 
  162533             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  162534             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  162535             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  162536             : // around this macro definition rather than each use).
  162537             : #ifndef ALLOC_MUTEX
  162538             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  162539             :         do {                                                                     \
  162540             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  162541             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  162542             :                 abort();                                                         \
  162543             :             }                                                                    \
  162544             :         } while (0);
  162545             : #endif
  162546             : 
  162547             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  162548             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  162549             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  162550             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  162551             : 
  162552             : /*! \brief New operator for SgVariantExpression.
  162553             : 
  162554             :    This new operator implements memory pools to provide most efficent 
  162555             :    use of the heap within construction of large ASTs.
  162556             : 
  162557             : \internal The new and delete operators use the lower level C malloc/free
  162558             :    function calls for performance and to make sure that mixing of malloc/free
  162559             :    and new/delete by the used can be caught more readily.  This may change
  162560             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  162561             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  162562             :    deallocate memory allocated using ROSE_MALLOC.
  162563             : */
  162564           1 : void *SgVariantExpression::operator new ( size_t Size )
  162565             : {
  162566             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  162567             :      * returning or throwing an exception. */
  162568           1 :     ALLOC_MUTEX(SgVariantExpression, lock);
  162569             : 
  162570             : #if ROSE_ALLOC_TRACE == 2
  162571             : //    printf("SgVariantExpression::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgVariantExpression::next_node);
  162572             : #endif
  162573             : 
  162574             : #if USE_CPP_NEW_DELETE_OPERATORS
  162575             :     void *mem = ROSE_MALLOC(Size);
  162576             :     ALLOC_MUTEX(SgVariantExpression, unlock);
  162577             :     return mem;
  162578             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  162579             : #if ROSE_PEDANTIC_ALLOC
  162580             :     ROSE_ASSERT(Size == sizeof(SgVariantExpression));
  162581             : #else
  162582           1 :     if (Size != sizeof(SgVariantExpression)) {
  162583           0 :       void * object = ROSE_MALLOC(Size);
  162584           0 :       ALLOC_MUTEX(SgVariantExpression, unlock);
  162585             :       return object;
  162586             :     }
  162587             : #endif
  162588             : 
  162589           1 :     if (SgVariantExpression::next_node == nullptr) {
  162590           1 :         SgVariantExpression * alloc = (SgVariantExpression*) ROSE_MALLOC ( SgVariantExpression::pool_size * sizeof(SgVariantExpression) );
  162591           1 :         ROSE_ASSERT(alloc != nullptr);
  162592             : 
  162593             : #if ROSE_ALLOC_TRACE == 2
  162594             : //        printf("SgVariantExpression::alloc\n  block[%zi] = [ %p , %p [\n", SgVariantExpression::pools.size(), alloc, alloc + SgVariantExpression::pool_size);
  162595             : #endif
  162596             : 
  162597             : #if ROSE_ALLOC_MEMSET == 1
  162598             : #elif ROSE_ALLOC_MEMSET == 2
  162599             :         memset(alloc, 0x00, SgVariantExpression::pool_size * sizeof(SgVariantExpression));
  162600             : #elif ROSE_ALLOC_MEMSET == 3
  162601             :         memset(alloc, 0xAA, SgVariantExpression::pool_size * sizeof(SgVariantExpression));
  162602             : #endif
  162603        2000 :         for (unsigned i=0; i < SgVariantExpression::pool_size-1; i++) {
  162604        1999 :           alloc[i].p_freepointer = &(alloc[i+1]);
  162605             :         }
  162606           1 :         alloc[SgVariantExpression::pool_size-1].p_freepointer = nullptr;
  162607             : 
  162608           1 :         SgVariantExpression::pools.push_back ( (unsigned char *) alloc );
  162609           1 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgVariantExpression::pool_size * sizeof(SgVariantExpression), V_SgVariantExpression ) );
  162610           1 :         SgVariantExpression::next_node = alloc;
  162611             :     }
  162612           1 :     ROSE_ASSERT(SgVariantExpression::next_node != nullptr);
  162613             : 
  162614           1 :     SgVariantExpression * object = SgVariantExpression::next_node;
  162615           1 :     SgVariantExpression::next_node = (SgVariantExpression*)(object->p_freepointer);
  162616             : 
  162617             : #if ROSE_ALLOC_TRACE == 2
  162618             :     printf("SgVariantExpression::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgVariantExpression::next_node);
  162619             : #endif
  162620             : 
  162621           1 :     SgNode * fp = object->p_freepointer;
  162622             : #if ROSE_ALLOC_MEMSET == 1
  162623             : #elif ROSE_ALLOC_MEMSET == 2
  162624             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgVariantExpression) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  162625             : #elif ROSE_ALLOC_MEMSET == 3
  162626             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgVariantExpression) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  162627             : #endif
  162628           1 :     object->p_freepointer = fp;
  162629             : 
  162630             : #if ROSE_ALLOC_TRACE == 2
  162631             : //    printf("SgVariantExpression::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgVariantExpression::next_node);
  162632             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  162633             :     Rose::MemPool::snapshot(oss.str());
  162634             :     alloc_trace_cnt++;
  162635             : #endif
  162636             : 
  162637           1 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  162638             : 
  162639           1 :     ALLOC_MUTEX(SgVariantExpression, unlock);
  162640             : 
  162641             :     return object;
  162642             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  162643             : }
  162644             : 
  162645             : 
  162646             : 
  162647             : /*! \brief Delete operator for SgVariantExpression.
  162648             : 
  162649             :    This delete operator implements deallocation using memory pools to 
  162650             :    provide most efficent use of the heap within construction of large ASTs.
  162651             : 
  162652             : \internal The new and delete operators use the lower level C malloc/free
  162653             :    function calls for performance and to make sure that mixing of malloc/free
  162654             :    and new/delete by the used can be caught more readily.  This may change
  162655             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  162656             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  162657             :    deallocate memory allocated using ROSE_MALLOC.
  162658             : */
  162659           1 : void SgVariantExpression::operator delete(void *Pointer, size_t Size)
  162660             : {
  162661             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  162662             :      * or throwing an exception. */
  162663           1 :     ALLOC_MUTEX(SgVariantExpression, lock);
  162664             : 
  162665             : #if USE_CPP_NEW_DELETE_OPERATORS
  162666             :     ROSE_FREE(Pointer);
  162667             : #else
  162668             : #if ROSE_PEDANTIC_ALLOC
  162669             :     ROSE_ASSERT(Size == sizeof(SgVariantExpression));
  162670             : #else
  162671           1 :     if (Size != sizeof(SgVariantExpression)) {
  162672           0 :       ROSE_FREE(Pointer);
  162673           0 :       ALLOC_MUTEX(SgVariantExpression, unlock);
  162674             :       return;
  162675             :     }
  162676             : #endif
  162677             : 
  162678           1 :     SgVariantExpression * object = (SgVariantExpression*) Pointer;
  162679           1 :     ROSE_ASSERT(object != nullptr);
  162680             : 
  162681             : #if ROSE_ALLOC_TRACE == 2
  162682             : //  printf("SgVariantExpression::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgVariantExpression::next_node);
  162683             :     printf("SgVariantExpression::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgVariantExpression::next_node);
  162684             : #endif
  162685             : 
  162686             : #if ROSE_PEDANTIC_ALLOC
  162687             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  162688             : #endif
  162689             : 
  162690             : #if ROSE_ALLOC_MEMSET == 1
  162691             : #elif ROSE_ALLOC_MEMSET == 2
  162692             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgVariantExpression) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  162693             : #elif ROSE_ALLOC_MEMSET == 3
  162694             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgVariantExpression) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  162695             : #endif
  162696             : 
  162697             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  162698             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  162699             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  162700             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  162701             : #else
  162702           1 :     object->p_freepointer = SgVariantExpression::next_node;
  162703           1 :     SgVariantExpression::next_node = object;
  162704             : #endif
  162705             : 
  162706             : #if ROSE_ALLOC_TRACE == 2
  162707             : //  printf("SgVariantExpression::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgVariantExpression::next_node);
  162708             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  162709             :     Rose::MemPool::snapshot(oss.str());
  162710             :     alloc_trace_cnt++;
  162711             : #endif
  162712             : 
  162713             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  162714             : 
  162715           1 :     ALLOC_MUTEX(SgVariantExpression, unlock);
  162716             : }
  162717             : 
  162718             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  162719             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  162720             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  162721             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  162722             : // Also, note comment below from Robb (copied from the Common.code file).
  162723             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  162724             : //
  162725             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  162726             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  162727             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  162728             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  162729             : #if 0
  162730             : void SgVariantExpression::operator delete(void* pointer) { SgVariantExpression::operator delete (pointer, sizeof(SgVariantExpression)); };
  162731             : #endif
  162732             : /* #line 162733 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  162733             : 
  162734             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  162735             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  162736             : // obviously imply C++.
  162737             : 
  162738             : // This implements the support within ROSE for memory pools.  Memory pools
  162739             : // support the most condensed usage of memory within the construction of
  162740             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  162741             : // by a new operator written for each class.
  162742             : 
  162743             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  162744             :     // User wants multi-thread support and POSIX threads are available.
  162745             : #   include <pthread.h>
  162746             :     static pthread_mutex_t SgSubscriptExpression_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  162747             : #else
  162748             :      // Cause synchronization to be skipped.
  162749             : #    ifndef ALLOC_MUTEX
  162750             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  162751             : #    endif
  162752             : #    ifdef _REENTRANT
  162753             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  162754             : #       ifdef _MSC_VER
  162755             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  162756             : #       else
  162757             : #           warning "POSIX threads are not available; synchronization being skipped"
  162758             : #       endif
  162759             : #    endif
  162760             : #endif
  162761             : 
  162762             : #ifndef ROSE_ALLOC_TRACE
  162763             : #  define ROSE_ALLOC_TRACE 0
  162764             : #endif
  162765             : 
  162766             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  162767             : #define ROSE_ALLOC_TRACE_CNT
  162768             : #include "memory-pool-snapshot.h"
  162769             : unsigned long alloc_trace_cnt = 0;
  162770             : #endif
  162771             : 
  162772             : #if ROSE_ALLOC_TRACE
  162773             : const unsigned SgSubscriptExpression::pool_size = 5;
  162774             : #else
  162775             : const unsigned SgSubscriptExpression::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  162776             : #endif
  162777             : 
  162778             : #ifndef ROSE_ALLOC_MEMSET
  162779             : #  define ROSE_ALLOC_MEMSET 0
  162780             : #endif
  162781             : 
  162782             : #ifndef ROSE_PEDANTIC_ALLOC
  162783             : #  define ROSE_PEDANTIC_ALLOC 0
  162784             : #endif
  162785             : 
  162786             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  162787             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  162788             : #endif
  162789             : 
  162790             : #if !defined(SGNODE__ALL_POOLS)
  162791             : #define SGNODE__ALL_POOLS
  162792             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  162793             : #endif
  162794             : 
  162795             : SgSubscriptExpression* SgSubscriptExpression::next_node = nullptr;
  162796             : std::vector<unsigned char*> SgSubscriptExpression::pools;
  162797             : 
  162798             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  162799             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  162800             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  162801             : // around this macro definition rather than each use).
  162802             : #ifndef ALLOC_MUTEX
  162803             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  162804             :         do {                                                                     \
  162805             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  162806             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  162807             :                 abort();                                                         \
  162808             :             }                                                                    \
  162809             :         } while (0);
  162810             : #endif
  162811             : 
  162812             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  162813             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  162814             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  162815             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  162816             : 
  162817             : /*! \brief New operator for SgSubscriptExpression.
  162818             : 
  162819             :    This new operator implements memory pools to provide most efficent 
  162820             :    use of the heap within construction of large ASTs.
  162821             : 
  162822             : \internal The new and delete operators use the lower level C malloc/free
  162823             :    function calls for performance and to make sure that mixing of malloc/free
  162824             :    and new/delete by the used can be caught more readily.  This may change
  162825             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  162826             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  162827             :    deallocate memory allocated using ROSE_MALLOC.
  162828             : */
  162829           0 : void *SgSubscriptExpression::operator new ( size_t Size )
  162830             : {
  162831             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  162832             :      * returning or throwing an exception. */
  162833           0 :     ALLOC_MUTEX(SgSubscriptExpression, lock);
  162834             : 
  162835             : #if ROSE_ALLOC_TRACE == 2
  162836             : //    printf("SgSubscriptExpression::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgSubscriptExpression::next_node);
  162837             : #endif
  162838             : 
  162839             : #if USE_CPP_NEW_DELETE_OPERATORS
  162840             :     void *mem = ROSE_MALLOC(Size);
  162841             :     ALLOC_MUTEX(SgSubscriptExpression, unlock);
  162842             :     return mem;
  162843             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  162844             : #if ROSE_PEDANTIC_ALLOC
  162845             :     ROSE_ASSERT(Size == sizeof(SgSubscriptExpression));
  162846             : #else
  162847           0 :     if (Size != sizeof(SgSubscriptExpression)) {
  162848           0 :       void * object = ROSE_MALLOC(Size);
  162849           0 :       ALLOC_MUTEX(SgSubscriptExpression, unlock);
  162850             :       return object;
  162851             :     }
  162852             : #endif
  162853             : 
  162854           0 :     if (SgSubscriptExpression::next_node == nullptr) {
  162855           0 :         SgSubscriptExpression * alloc = (SgSubscriptExpression*) ROSE_MALLOC ( SgSubscriptExpression::pool_size * sizeof(SgSubscriptExpression) );
  162856           0 :         ROSE_ASSERT(alloc != nullptr);
  162857             : 
  162858             : #if ROSE_ALLOC_TRACE == 2
  162859             : //        printf("SgSubscriptExpression::alloc\n  block[%zi] = [ %p , %p [\n", SgSubscriptExpression::pools.size(), alloc, alloc + SgSubscriptExpression::pool_size);
  162860             : #endif
  162861             : 
  162862             : #if ROSE_ALLOC_MEMSET == 1
  162863             : #elif ROSE_ALLOC_MEMSET == 2
  162864             :         memset(alloc, 0x00, SgSubscriptExpression::pool_size * sizeof(SgSubscriptExpression));
  162865             : #elif ROSE_ALLOC_MEMSET == 3
  162866             :         memset(alloc, 0xAA, SgSubscriptExpression::pool_size * sizeof(SgSubscriptExpression));
  162867             : #endif
  162868           0 :         for (unsigned i=0; i < SgSubscriptExpression::pool_size-1; i++) {
  162869           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
  162870             :         }
  162871           0 :         alloc[SgSubscriptExpression::pool_size-1].p_freepointer = nullptr;
  162872             : 
  162873           0 :         SgSubscriptExpression::pools.push_back ( (unsigned char *) alloc );
  162874           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgSubscriptExpression::pool_size * sizeof(SgSubscriptExpression), V_SgSubscriptExpression ) );
  162875           0 :         SgSubscriptExpression::next_node = alloc;
  162876             :     }
  162877           0 :     ROSE_ASSERT(SgSubscriptExpression::next_node != nullptr);
  162878             : 
  162879           0 :     SgSubscriptExpression * object = SgSubscriptExpression::next_node;
  162880           0 :     SgSubscriptExpression::next_node = (SgSubscriptExpression*)(object->p_freepointer);
  162881             : 
  162882             : #if ROSE_ALLOC_TRACE == 2
  162883             :     printf("SgSubscriptExpression::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgSubscriptExpression::next_node);
  162884             : #endif
  162885             : 
  162886           0 :     SgNode * fp = object->p_freepointer;
  162887             : #if ROSE_ALLOC_MEMSET == 1
  162888             : #elif ROSE_ALLOC_MEMSET == 2
  162889             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgSubscriptExpression) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  162890             : #elif ROSE_ALLOC_MEMSET == 3
  162891             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgSubscriptExpression) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  162892             : #endif
  162893           0 :     object->p_freepointer = fp;
  162894             : 
  162895             : #if ROSE_ALLOC_TRACE == 2
  162896             : //    printf("SgSubscriptExpression::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgSubscriptExpression::next_node);
  162897             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  162898             :     Rose::MemPool::snapshot(oss.str());
  162899             :     alloc_trace_cnt++;
  162900             : #endif
  162901             : 
  162902           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  162903             : 
  162904           0 :     ALLOC_MUTEX(SgSubscriptExpression, unlock);
  162905             : 
  162906             :     return object;
  162907             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  162908             : }
  162909             : 
  162910             : 
  162911             : 
  162912             : /*! \brief Delete operator for SgSubscriptExpression.
  162913             : 
  162914             :    This delete operator implements deallocation using memory pools to 
  162915             :    provide most efficent use of the heap within construction of large ASTs.
  162916             : 
  162917             : \internal The new and delete operators use the lower level C malloc/free
  162918             :    function calls for performance and to make sure that mixing of malloc/free
  162919             :    and new/delete by the used can be caught more readily.  This may change
  162920             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  162921             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  162922             :    deallocate memory allocated using ROSE_MALLOC.
  162923             : */
  162924           0 : void SgSubscriptExpression::operator delete(void *Pointer, size_t Size)
  162925             : {
  162926             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  162927             :      * or throwing an exception. */
  162928           0 :     ALLOC_MUTEX(SgSubscriptExpression, lock);
  162929             : 
  162930             : #if USE_CPP_NEW_DELETE_OPERATORS
  162931             :     ROSE_FREE(Pointer);
  162932             : #else
  162933             : #if ROSE_PEDANTIC_ALLOC
  162934             :     ROSE_ASSERT(Size == sizeof(SgSubscriptExpression));
  162935             : #else
  162936           0 :     if (Size != sizeof(SgSubscriptExpression)) {
  162937           0 :       ROSE_FREE(Pointer);
  162938           0 :       ALLOC_MUTEX(SgSubscriptExpression, unlock);
  162939             :       return;
  162940             :     }
  162941             : #endif
  162942             : 
  162943           0 :     SgSubscriptExpression * object = (SgSubscriptExpression*) Pointer;
  162944           0 :     ROSE_ASSERT(object != nullptr);
  162945             : 
  162946             : #if ROSE_ALLOC_TRACE == 2
  162947             : //  printf("SgSubscriptExpression::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgSubscriptExpression::next_node);
  162948             :     printf("SgSubscriptExpression::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgSubscriptExpression::next_node);
  162949             : #endif
  162950             : 
  162951             : #if ROSE_PEDANTIC_ALLOC
  162952             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  162953             : #endif
  162954             : 
  162955             : #if ROSE_ALLOC_MEMSET == 1
  162956             : #elif ROSE_ALLOC_MEMSET == 2
  162957             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgSubscriptExpression) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  162958             : #elif ROSE_ALLOC_MEMSET == 3
  162959             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgSubscriptExpression) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  162960             : #endif
  162961             : 
  162962             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  162963             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  162964             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  162965             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  162966             : #else
  162967           0 :     object->p_freepointer = SgSubscriptExpression::next_node;
  162968           0 :     SgSubscriptExpression::next_node = object;
  162969             : #endif
  162970             : 
  162971             : #if ROSE_ALLOC_TRACE == 2
  162972             : //  printf("SgSubscriptExpression::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgSubscriptExpression::next_node);
  162973             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  162974             :     Rose::MemPool::snapshot(oss.str());
  162975             :     alloc_trace_cnt++;
  162976             : #endif
  162977             : 
  162978             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  162979             : 
  162980           0 :     ALLOC_MUTEX(SgSubscriptExpression, unlock);
  162981             : }
  162982             : 
  162983             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  162984             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  162985             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  162986             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  162987             : // Also, note comment below from Robb (copied from the Common.code file).
  162988             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  162989             : //
  162990             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  162991             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  162992             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  162993             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  162994             : #if 0
  162995             : void SgSubscriptExpression::operator delete(void* pointer) { SgSubscriptExpression::operator delete (pointer, sizeof(SgSubscriptExpression)); };
  162996             : #endif
  162997             : /* #line 162998 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  162998             : 
  162999             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  163000             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  163001             : // obviously imply C++.
  163002             : 
  163003             : // This implements the support within ROSE for memory pools.  Memory pools
  163004             : // support the most condensed usage of memory within the construction of
  163005             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  163006             : // by a new operator written for each class.
  163007             : 
  163008             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  163009             :     // User wants multi-thread support and POSIX threads are available.
  163010             : #   include <pthread.h>
  163011             :     static pthread_mutex_t SgColonShapeExp_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  163012             : #else
  163013             :      // Cause synchronization to be skipped.
  163014             : #    ifndef ALLOC_MUTEX
  163015             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  163016             : #    endif
  163017             : #    ifdef _REENTRANT
  163018             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  163019             : #       ifdef _MSC_VER
  163020             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  163021             : #       else
  163022             : #           warning "POSIX threads are not available; synchronization being skipped"
  163023             : #       endif
  163024             : #    endif
  163025             : #endif
  163026             : 
  163027             : #ifndef ROSE_ALLOC_TRACE
  163028             : #  define ROSE_ALLOC_TRACE 0
  163029             : #endif
  163030             : 
  163031             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  163032             : #define ROSE_ALLOC_TRACE_CNT
  163033             : #include "memory-pool-snapshot.h"
  163034             : unsigned long alloc_trace_cnt = 0;
  163035             : #endif
  163036             : 
  163037             : #if ROSE_ALLOC_TRACE
  163038             : const unsigned SgColonShapeExp::pool_size = 5;
  163039             : #else
  163040             : const unsigned SgColonShapeExp::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  163041             : #endif
  163042             : 
  163043             : #ifndef ROSE_ALLOC_MEMSET
  163044             : #  define ROSE_ALLOC_MEMSET 0
  163045             : #endif
  163046             : 
  163047             : #ifndef ROSE_PEDANTIC_ALLOC
  163048             : #  define ROSE_PEDANTIC_ALLOC 0
  163049             : #endif
  163050             : 
  163051             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  163052             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  163053             : #endif
  163054             : 
  163055             : #if !defined(SGNODE__ALL_POOLS)
  163056             : #define SGNODE__ALL_POOLS
  163057             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  163058             : #endif
  163059             : 
  163060             : SgColonShapeExp* SgColonShapeExp::next_node = nullptr;
  163061             : std::vector<unsigned char*> SgColonShapeExp::pools;
  163062             : 
  163063             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  163064             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  163065             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  163066             : // around this macro definition rather than each use).
  163067             : #ifndef ALLOC_MUTEX
  163068             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  163069             :         do {                                                                     \
  163070             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  163071             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  163072             :                 abort();                                                         \
  163073             :             }                                                                    \
  163074             :         } while (0);
  163075             : #endif
  163076             : 
  163077             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  163078             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  163079             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  163080             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  163081             : 
  163082             : /*! \brief New operator for SgColonShapeExp.
  163083             : 
  163084             :    This new operator implements memory pools to provide most efficent 
  163085             :    use of the heap within construction of large ASTs.
  163086             : 
  163087             : \internal The new and delete operators use the lower level C malloc/free
  163088             :    function calls for performance and to make sure that mixing of malloc/free
  163089             :    and new/delete by the used can be caught more readily.  This may change
  163090             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  163091             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  163092             :    deallocate memory allocated using ROSE_MALLOC.
  163093             : */
  163094           0 : void *SgColonShapeExp::operator new ( size_t Size )
  163095             : {
  163096             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  163097             :      * returning or throwing an exception. */
  163098           0 :     ALLOC_MUTEX(SgColonShapeExp, lock);
  163099             : 
  163100             : #if ROSE_ALLOC_TRACE == 2
  163101             : //    printf("SgColonShapeExp::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgColonShapeExp::next_node);
  163102             : #endif
  163103             : 
  163104             : #if USE_CPP_NEW_DELETE_OPERATORS
  163105             :     void *mem = ROSE_MALLOC(Size);
  163106             :     ALLOC_MUTEX(SgColonShapeExp, unlock);
  163107             :     return mem;
  163108             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  163109             : #if ROSE_PEDANTIC_ALLOC
  163110             :     ROSE_ASSERT(Size == sizeof(SgColonShapeExp));
  163111             : #else
  163112           0 :     if (Size != sizeof(SgColonShapeExp)) {
  163113           0 :       void * object = ROSE_MALLOC(Size);
  163114           0 :       ALLOC_MUTEX(SgColonShapeExp, unlock);
  163115             :       return object;
  163116             :     }
  163117             : #endif
  163118             : 
  163119           0 :     if (SgColonShapeExp::next_node == nullptr) {
  163120           0 :         SgColonShapeExp * alloc = (SgColonShapeExp*) ROSE_MALLOC ( SgColonShapeExp::pool_size * sizeof(SgColonShapeExp) );
  163121           0 :         ROSE_ASSERT(alloc != nullptr);
  163122             : 
  163123             : #if ROSE_ALLOC_TRACE == 2
  163124             : //        printf("SgColonShapeExp::alloc\n  block[%zi] = [ %p , %p [\n", SgColonShapeExp::pools.size(), alloc, alloc + SgColonShapeExp::pool_size);
  163125             : #endif
  163126             : 
  163127             : #if ROSE_ALLOC_MEMSET == 1
  163128             : #elif ROSE_ALLOC_MEMSET == 2
  163129             :         memset(alloc, 0x00, SgColonShapeExp::pool_size * sizeof(SgColonShapeExp));
  163130             : #elif ROSE_ALLOC_MEMSET == 3
  163131             :         memset(alloc, 0xAA, SgColonShapeExp::pool_size * sizeof(SgColonShapeExp));
  163132             : #endif
  163133           0 :         for (unsigned i=0; i < SgColonShapeExp::pool_size-1; i++) {
  163134           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
  163135             :         }
  163136           0 :         alloc[SgColonShapeExp::pool_size-1].p_freepointer = nullptr;
  163137             : 
  163138           0 :         SgColonShapeExp::pools.push_back ( (unsigned char *) alloc );
  163139           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgColonShapeExp::pool_size * sizeof(SgColonShapeExp), V_SgColonShapeExp ) );
  163140           0 :         SgColonShapeExp::next_node = alloc;
  163141             :     }
  163142           0 :     ROSE_ASSERT(SgColonShapeExp::next_node != nullptr);
  163143             : 
  163144           0 :     SgColonShapeExp * object = SgColonShapeExp::next_node;
  163145           0 :     SgColonShapeExp::next_node = (SgColonShapeExp*)(object->p_freepointer);
  163146             : 
  163147             : #if ROSE_ALLOC_TRACE == 2
  163148             :     printf("SgColonShapeExp::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgColonShapeExp::next_node);
  163149             : #endif
  163150             : 
  163151           0 :     SgNode * fp = object->p_freepointer;
  163152             : #if ROSE_ALLOC_MEMSET == 1
  163153             : #elif ROSE_ALLOC_MEMSET == 2
  163154             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgColonShapeExp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  163155             : #elif ROSE_ALLOC_MEMSET == 3
  163156             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgColonShapeExp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  163157             : #endif
  163158           0 :     object->p_freepointer = fp;
  163159             : 
  163160             : #if ROSE_ALLOC_TRACE == 2
  163161             : //    printf("SgColonShapeExp::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgColonShapeExp::next_node);
  163162             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  163163             :     Rose::MemPool::snapshot(oss.str());
  163164             :     alloc_trace_cnt++;
  163165             : #endif
  163166             : 
  163167           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  163168             : 
  163169           0 :     ALLOC_MUTEX(SgColonShapeExp, unlock);
  163170             : 
  163171             :     return object;
  163172             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  163173             : }
  163174             : 
  163175             : 
  163176             : 
  163177             : /*! \brief Delete operator for SgColonShapeExp.
  163178             : 
  163179             :    This delete operator implements deallocation using memory pools to 
  163180             :    provide most efficent use of the heap within construction of large ASTs.
  163181             : 
  163182             : \internal The new and delete operators use the lower level C malloc/free
  163183             :    function calls for performance and to make sure that mixing of malloc/free
  163184             :    and new/delete by the used can be caught more readily.  This may change
  163185             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  163186             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  163187             :    deallocate memory allocated using ROSE_MALLOC.
  163188             : */
  163189           0 : void SgColonShapeExp::operator delete(void *Pointer, size_t Size)
  163190             : {
  163191             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  163192             :      * or throwing an exception. */
  163193           0 :     ALLOC_MUTEX(SgColonShapeExp, lock);
  163194             : 
  163195             : #if USE_CPP_NEW_DELETE_OPERATORS
  163196             :     ROSE_FREE(Pointer);
  163197             : #else
  163198             : #if ROSE_PEDANTIC_ALLOC
  163199             :     ROSE_ASSERT(Size == sizeof(SgColonShapeExp));
  163200             : #else
  163201           0 :     if (Size != sizeof(SgColonShapeExp)) {
  163202           0 :       ROSE_FREE(Pointer);
  163203           0 :       ALLOC_MUTEX(SgColonShapeExp, unlock);
  163204             :       return;
  163205             :     }
  163206             : #endif
  163207             : 
  163208           0 :     SgColonShapeExp * object = (SgColonShapeExp*) Pointer;
  163209           0 :     ROSE_ASSERT(object != nullptr);
  163210             : 
  163211             : #if ROSE_ALLOC_TRACE == 2
  163212             : //  printf("SgColonShapeExp::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgColonShapeExp::next_node);
  163213             :     printf("SgColonShapeExp::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgColonShapeExp::next_node);
  163214             : #endif
  163215             : 
  163216             : #if ROSE_PEDANTIC_ALLOC
  163217             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  163218             : #endif
  163219             : 
  163220             : #if ROSE_ALLOC_MEMSET == 1
  163221             : #elif ROSE_ALLOC_MEMSET == 2
  163222             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgColonShapeExp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  163223             : #elif ROSE_ALLOC_MEMSET == 3
  163224             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgColonShapeExp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  163225             : #endif
  163226             : 
  163227             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  163228             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  163229             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  163230             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  163231             : #else
  163232           0 :     object->p_freepointer = SgColonShapeExp::next_node;
  163233           0 :     SgColonShapeExp::next_node = object;
  163234             : #endif
  163235             : 
  163236             : #if ROSE_ALLOC_TRACE == 2
  163237             : //  printf("SgColonShapeExp::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgColonShapeExp::next_node);
  163238             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  163239             :     Rose::MemPool::snapshot(oss.str());
  163240             :     alloc_trace_cnt++;
  163241             : #endif
  163242             : 
  163243             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  163244             : 
  163245           0 :     ALLOC_MUTEX(SgColonShapeExp, unlock);
  163246             : }
  163247             : 
  163248             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  163249             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  163250             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  163251             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  163252             : // Also, note comment below from Robb (copied from the Common.code file).
  163253             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  163254             : //
  163255             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  163256             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  163257             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  163258             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  163259             : #if 0
  163260             : void SgColonShapeExp::operator delete(void* pointer) { SgColonShapeExp::operator delete (pointer, sizeof(SgColonShapeExp)); };
  163261             : #endif
  163262             : /* #line 163263 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  163263             : 
  163264             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  163265             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  163266             : // obviously imply C++.
  163267             : 
  163268             : // This implements the support within ROSE for memory pools.  Memory pools
  163269             : // support the most condensed usage of memory within the construction of
  163270             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  163271             : // by a new operator written for each class.
  163272             : 
  163273             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  163274             :     // User wants multi-thread support and POSIX threads are available.
  163275             : #   include <pthread.h>
  163276             :     static pthread_mutex_t SgAsteriskShapeExp_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  163277             : #else
  163278             :      // Cause synchronization to be skipped.
  163279             : #    ifndef ALLOC_MUTEX
  163280             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  163281             : #    endif
  163282             : #    ifdef _REENTRANT
  163283             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  163284             : #       ifdef _MSC_VER
  163285             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  163286             : #       else
  163287             : #           warning "POSIX threads are not available; synchronization being skipped"
  163288             : #       endif
  163289             : #    endif
  163290             : #endif
  163291             : 
  163292             : #ifndef ROSE_ALLOC_TRACE
  163293             : #  define ROSE_ALLOC_TRACE 0
  163294             : #endif
  163295             : 
  163296             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  163297             : #define ROSE_ALLOC_TRACE_CNT
  163298             : #include "memory-pool-snapshot.h"
  163299             : unsigned long alloc_trace_cnt = 0;
  163300             : #endif
  163301             : 
  163302             : #if ROSE_ALLOC_TRACE
  163303             : const unsigned SgAsteriskShapeExp::pool_size = 5;
  163304             : #else
  163305             : const unsigned SgAsteriskShapeExp::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  163306             : #endif
  163307             : 
  163308             : #ifndef ROSE_ALLOC_MEMSET
  163309             : #  define ROSE_ALLOC_MEMSET 0
  163310             : #endif
  163311             : 
  163312             : #ifndef ROSE_PEDANTIC_ALLOC
  163313             : #  define ROSE_PEDANTIC_ALLOC 0
  163314             : #endif
  163315             : 
  163316             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  163317             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  163318             : #endif
  163319             : 
  163320             : #if !defined(SGNODE__ALL_POOLS)
  163321             : #define SGNODE__ALL_POOLS
  163322             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  163323             : #endif
  163324             : 
  163325             : SgAsteriskShapeExp* SgAsteriskShapeExp::next_node = nullptr;
  163326             : std::vector<unsigned char*> SgAsteriskShapeExp::pools;
  163327             : 
  163328             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  163329             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  163330             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  163331             : // around this macro definition rather than each use).
  163332             : #ifndef ALLOC_MUTEX
  163333             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  163334             :         do {                                                                     \
  163335             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  163336             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  163337             :                 abort();                                                         \
  163338             :             }                                                                    \
  163339             :         } while (0);
  163340             : #endif
  163341             : 
  163342             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  163343             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  163344             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  163345             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  163346             : 
  163347             : /*! \brief New operator for SgAsteriskShapeExp.
  163348             : 
  163349             :    This new operator implements memory pools to provide most efficent 
  163350             :    use of the heap within construction of large ASTs.
  163351             : 
  163352             : \internal The new and delete operators use the lower level C malloc/free
  163353             :    function calls for performance and to make sure that mixing of malloc/free
  163354             :    and new/delete by the used can be caught more readily.  This may change
  163355             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  163356             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  163357             :    deallocate memory allocated using ROSE_MALLOC.
  163358             : */
  163359          69 : void *SgAsteriskShapeExp::operator new ( size_t Size )
  163360             : {
  163361             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  163362             :      * returning or throwing an exception. */
  163363          69 :     ALLOC_MUTEX(SgAsteriskShapeExp, lock);
  163364             : 
  163365             : #if ROSE_ALLOC_TRACE == 2
  163366             : //    printf("SgAsteriskShapeExp::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgAsteriskShapeExp::next_node);
  163367             : #endif
  163368             : 
  163369             : #if USE_CPP_NEW_DELETE_OPERATORS
  163370             :     void *mem = ROSE_MALLOC(Size);
  163371             :     ALLOC_MUTEX(SgAsteriskShapeExp, unlock);
  163372             :     return mem;
  163373             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  163374             : #if ROSE_PEDANTIC_ALLOC
  163375             :     ROSE_ASSERT(Size == sizeof(SgAsteriskShapeExp));
  163376             : #else
  163377          69 :     if (Size != sizeof(SgAsteriskShapeExp)) {
  163378           0 :       void * object = ROSE_MALLOC(Size);
  163379           0 :       ALLOC_MUTEX(SgAsteriskShapeExp, unlock);
  163380             :       return object;
  163381             :     }
  163382             : #endif
  163383             : 
  163384          69 :     if (SgAsteriskShapeExp::next_node == nullptr) {
  163385          29 :         SgAsteriskShapeExp * alloc = (SgAsteriskShapeExp*) ROSE_MALLOC ( SgAsteriskShapeExp::pool_size * sizeof(SgAsteriskShapeExp) );
  163386          29 :         ROSE_ASSERT(alloc != nullptr);
  163387             : 
  163388             : #if ROSE_ALLOC_TRACE == 2
  163389             : //        printf("SgAsteriskShapeExp::alloc\n  block[%zi] = [ %p , %p [\n", SgAsteriskShapeExp::pools.size(), alloc, alloc + SgAsteriskShapeExp::pool_size);
  163390             : #endif
  163391             : 
  163392             : #if ROSE_ALLOC_MEMSET == 1
  163393             : #elif ROSE_ALLOC_MEMSET == 2
  163394             :         memset(alloc, 0x00, SgAsteriskShapeExp::pool_size * sizeof(SgAsteriskShapeExp));
  163395             : #elif ROSE_ALLOC_MEMSET == 3
  163396             :         memset(alloc, 0xAA, SgAsteriskShapeExp::pool_size * sizeof(SgAsteriskShapeExp));
  163397             : #endif
  163398       58000 :         for (unsigned i=0; i < SgAsteriskShapeExp::pool_size-1; i++) {
  163399       57971 :           alloc[i].p_freepointer = &(alloc[i+1]);
  163400             :         }
  163401          29 :         alloc[SgAsteriskShapeExp::pool_size-1].p_freepointer = nullptr;
  163402             : 
  163403          29 :         SgAsteriskShapeExp::pools.push_back ( (unsigned char *) alloc );
  163404          29 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgAsteriskShapeExp::pool_size * sizeof(SgAsteriskShapeExp), V_SgAsteriskShapeExp ) );
  163405          29 :         SgAsteriskShapeExp::next_node = alloc;
  163406             :     }
  163407          69 :     ROSE_ASSERT(SgAsteriskShapeExp::next_node != nullptr);
  163408             : 
  163409          69 :     SgAsteriskShapeExp * object = SgAsteriskShapeExp::next_node;
  163410          69 :     SgAsteriskShapeExp::next_node = (SgAsteriskShapeExp*)(object->p_freepointer);
  163411             : 
  163412             : #if ROSE_ALLOC_TRACE == 2
  163413             :     printf("SgAsteriskShapeExp::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgAsteriskShapeExp::next_node);
  163414             : #endif
  163415             : 
  163416          69 :     SgNode * fp = object->p_freepointer;
  163417             : #if ROSE_ALLOC_MEMSET == 1
  163418             : #elif ROSE_ALLOC_MEMSET == 2
  163419             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgAsteriskShapeExp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  163420             : #elif ROSE_ALLOC_MEMSET == 3
  163421             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgAsteriskShapeExp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  163422             : #endif
  163423          69 :     object->p_freepointer = fp;
  163424             : 
  163425             : #if ROSE_ALLOC_TRACE == 2
  163426             : //    printf("SgAsteriskShapeExp::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgAsteriskShapeExp::next_node);
  163427             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  163428             :     Rose::MemPool::snapshot(oss.str());
  163429             :     alloc_trace_cnt++;
  163430             : #endif
  163431             : 
  163432          69 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  163433             : 
  163434          69 :     ALLOC_MUTEX(SgAsteriskShapeExp, unlock);
  163435             : 
  163436             :     return object;
  163437             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  163438             : }
  163439             : 
  163440             : 
  163441             : 
  163442             : /*! \brief Delete operator for SgAsteriskShapeExp.
  163443             : 
  163444             :    This delete operator implements deallocation using memory pools to 
  163445             :    provide most efficent use of the heap within construction of large ASTs.
  163446             : 
  163447             : \internal The new and delete operators use the lower level C malloc/free
  163448             :    function calls for performance and to make sure that mixing of malloc/free
  163449             :    and new/delete by the used can be caught more readily.  This may change
  163450             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  163451             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  163452             :    deallocate memory allocated using ROSE_MALLOC.
  163453             : */
  163454           1 : void SgAsteriskShapeExp::operator delete(void *Pointer, size_t Size)
  163455             : {
  163456             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  163457             :      * or throwing an exception. */
  163458           1 :     ALLOC_MUTEX(SgAsteriskShapeExp, lock);
  163459             : 
  163460             : #if USE_CPP_NEW_DELETE_OPERATORS
  163461             :     ROSE_FREE(Pointer);
  163462             : #else
  163463             : #if ROSE_PEDANTIC_ALLOC
  163464             :     ROSE_ASSERT(Size == sizeof(SgAsteriskShapeExp));
  163465             : #else
  163466           1 :     if (Size != sizeof(SgAsteriskShapeExp)) {
  163467           0 :       ROSE_FREE(Pointer);
  163468           0 :       ALLOC_MUTEX(SgAsteriskShapeExp, unlock);
  163469             :       return;
  163470             :     }
  163471             : #endif
  163472             : 
  163473           1 :     SgAsteriskShapeExp * object = (SgAsteriskShapeExp*) Pointer;
  163474           1 :     ROSE_ASSERT(object != nullptr);
  163475             : 
  163476             : #if ROSE_ALLOC_TRACE == 2
  163477             : //  printf("SgAsteriskShapeExp::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgAsteriskShapeExp::next_node);
  163478             :     printf("SgAsteriskShapeExp::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgAsteriskShapeExp::next_node);
  163479             : #endif
  163480             : 
  163481             : #if ROSE_PEDANTIC_ALLOC
  163482             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  163483             : #endif
  163484             : 
  163485             : #if ROSE_ALLOC_MEMSET == 1
  163486             : #elif ROSE_ALLOC_MEMSET == 2
  163487             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgAsteriskShapeExp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  163488             : #elif ROSE_ALLOC_MEMSET == 3
  163489             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgAsteriskShapeExp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  163490             : #endif
  163491             : 
  163492             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  163493             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  163494             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  163495             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  163496             : #else
  163497           1 :     object->p_freepointer = SgAsteriskShapeExp::next_node;
  163498           1 :     SgAsteriskShapeExp::next_node = object;
  163499             : #endif
  163500             : 
  163501             : #if ROSE_ALLOC_TRACE == 2
  163502             : //  printf("SgAsteriskShapeExp::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgAsteriskShapeExp::next_node);
  163503             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  163504             :     Rose::MemPool::snapshot(oss.str());
  163505             :     alloc_trace_cnt++;
  163506             : #endif
  163507             : 
  163508             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  163509             : 
  163510           1 :     ALLOC_MUTEX(SgAsteriskShapeExp, unlock);
  163511             : }
  163512             : 
  163513             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  163514             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  163515             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  163516             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  163517             : // Also, note comment below from Robb (copied from the Common.code file).
  163518             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  163519             : //
  163520             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  163521             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  163522             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  163523             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  163524             : #if 0
  163525             : void SgAsteriskShapeExp::operator delete(void* pointer) { SgAsteriskShapeExp::operator delete (pointer, sizeof(SgAsteriskShapeExp)); };
  163526             : #endif
  163527             : /* #line 163528 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  163528             : 
  163529             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  163530             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  163531             : // obviously imply C++.
  163532             : 
  163533             : // This implements the support within ROSE for memory pools.  Memory pools
  163534             : // support the most condensed usage of memory within the construction of
  163535             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  163536             : // by a new operator written for each class.
  163537             : 
  163538             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  163539             :     // User wants multi-thread support and POSIX threads are available.
  163540             : #   include <pthread.h>
  163541             :     static pthread_mutex_t SgImpliedDo_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  163542             : #else
  163543             :      // Cause synchronization to be skipped.
  163544             : #    ifndef ALLOC_MUTEX
  163545             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  163546             : #    endif
  163547             : #    ifdef _REENTRANT
  163548             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  163549             : #       ifdef _MSC_VER
  163550             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  163551             : #       else
  163552             : #           warning "POSIX threads are not available; synchronization being skipped"
  163553             : #       endif
  163554             : #    endif
  163555             : #endif
  163556             : 
  163557             : #ifndef ROSE_ALLOC_TRACE
  163558             : #  define ROSE_ALLOC_TRACE 0
  163559             : #endif
  163560             : 
  163561             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  163562             : #define ROSE_ALLOC_TRACE_CNT
  163563             : #include "memory-pool-snapshot.h"
  163564             : unsigned long alloc_trace_cnt = 0;
  163565             : #endif
  163566             : 
  163567             : #if ROSE_ALLOC_TRACE
  163568             : const unsigned SgImpliedDo::pool_size = 5;
  163569             : #else
  163570             : const unsigned SgImpliedDo::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  163571             : #endif
  163572             : 
  163573             : #ifndef ROSE_ALLOC_MEMSET
  163574             : #  define ROSE_ALLOC_MEMSET 0
  163575             : #endif
  163576             : 
  163577             : #ifndef ROSE_PEDANTIC_ALLOC
  163578             : #  define ROSE_PEDANTIC_ALLOC 0
  163579             : #endif
  163580             : 
  163581             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  163582             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  163583             : #endif
  163584             : 
  163585             : #if !defined(SGNODE__ALL_POOLS)
  163586             : #define SGNODE__ALL_POOLS
  163587             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  163588             : #endif
  163589             : 
  163590             : SgImpliedDo* SgImpliedDo::next_node = nullptr;
  163591             : std::vector<unsigned char*> SgImpliedDo::pools;
  163592             : 
  163593             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  163594             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  163595             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  163596             : // around this macro definition rather than each use).
  163597             : #ifndef ALLOC_MUTEX
  163598             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  163599             :         do {                                                                     \
  163600             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  163601             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  163602             :                 abort();                                                         \
  163603             :             }                                                                    \
  163604             :         } while (0);
  163605             : #endif
  163606             : 
  163607             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  163608             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  163609             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  163610             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  163611             : 
  163612             : /*! \brief New operator for SgImpliedDo.
  163613             : 
  163614             :    This new operator implements memory pools to provide most efficent 
  163615             :    use of the heap within construction of large ASTs.
  163616             : 
  163617             : \internal The new and delete operators use the lower level C malloc/free
  163618             :    function calls for performance and to make sure that mixing of malloc/free
  163619             :    and new/delete by the used can be caught more readily.  This may change
  163620             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  163621             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  163622             :    deallocate memory allocated using ROSE_MALLOC.
  163623             : */
  163624           0 : void *SgImpliedDo::operator new ( size_t Size )
  163625             : {
  163626             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  163627             :      * returning or throwing an exception. */
  163628           0 :     ALLOC_MUTEX(SgImpliedDo, lock);
  163629             : 
  163630             : #if ROSE_ALLOC_TRACE == 2
  163631             : //    printf("SgImpliedDo::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgImpliedDo::next_node);
  163632             : #endif
  163633             : 
  163634             : #if USE_CPP_NEW_DELETE_OPERATORS
  163635             :     void *mem = ROSE_MALLOC(Size);
  163636             :     ALLOC_MUTEX(SgImpliedDo, unlock);
  163637             :     return mem;
  163638             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  163639             : #if ROSE_PEDANTIC_ALLOC
  163640             :     ROSE_ASSERT(Size == sizeof(SgImpliedDo));
  163641             : #else
  163642           0 :     if (Size != sizeof(SgImpliedDo)) {
  163643           0 :       void * object = ROSE_MALLOC(Size);
  163644           0 :       ALLOC_MUTEX(SgImpliedDo, unlock);
  163645             :       return object;
  163646             :     }
  163647             : #endif
  163648             : 
  163649           0 :     if (SgImpliedDo::next_node == nullptr) {
  163650           0 :         SgImpliedDo * alloc = (SgImpliedDo*) ROSE_MALLOC ( SgImpliedDo::pool_size * sizeof(SgImpliedDo) );
  163651           0 :         ROSE_ASSERT(alloc != nullptr);
  163652             : 
  163653             : #if ROSE_ALLOC_TRACE == 2
  163654             : //        printf("SgImpliedDo::alloc\n  block[%zi] = [ %p , %p [\n", SgImpliedDo::pools.size(), alloc, alloc + SgImpliedDo::pool_size);
  163655             : #endif
  163656             : 
  163657             : #if ROSE_ALLOC_MEMSET == 1
  163658             : #elif ROSE_ALLOC_MEMSET == 2
  163659             :         memset(alloc, 0x00, SgImpliedDo::pool_size * sizeof(SgImpliedDo));
  163660             : #elif ROSE_ALLOC_MEMSET == 3
  163661             :         memset(alloc, 0xAA, SgImpliedDo::pool_size * sizeof(SgImpliedDo));
  163662             : #endif
  163663           0 :         for (unsigned i=0; i < SgImpliedDo::pool_size-1; i++) {
  163664           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
  163665             :         }
  163666           0 :         alloc[SgImpliedDo::pool_size-1].p_freepointer = nullptr;
  163667             : 
  163668           0 :         SgImpliedDo::pools.push_back ( (unsigned char *) alloc );
  163669           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgImpliedDo::pool_size * sizeof(SgImpliedDo), V_SgImpliedDo ) );
  163670           0 :         SgImpliedDo::next_node = alloc;
  163671             :     }
  163672           0 :     ROSE_ASSERT(SgImpliedDo::next_node != nullptr);
  163673             : 
  163674           0 :     SgImpliedDo * object = SgImpliedDo::next_node;
  163675           0 :     SgImpliedDo::next_node = (SgImpliedDo*)(object->p_freepointer);
  163676             : 
  163677             : #if ROSE_ALLOC_TRACE == 2
  163678             :     printf("SgImpliedDo::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgImpliedDo::next_node);
  163679             : #endif
  163680             : 
  163681           0 :     SgNode * fp = object->p_freepointer;
  163682             : #if ROSE_ALLOC_MEMSET == 1
  163683             : #elif ROSE_ALLOC_MEMSET == 2
  163684             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgImpliedDo) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  163685             : #elif ROSE_ALLOC_MEMSET == 3
  163686             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgImpliedDo) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  163687             : #endif
  163688           0 :     object->p_freepointer = fp;
  163689             : 
  163690             : #if ROSE_ALLOC_TRACE == 2
  163691             : //    printf("SgImpliedDo::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgImpliedDo::next_node);
  163692             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  163693             :     Rose::MemPool::snapshot(oss.str());
  163694             :     alloc_trace_cnt++;
  163695             : #endif
  163696             : 
  163697           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  163698             : 
  163699           0 :     ALLOC_MUTEX(SgImpliedDo, unlock);
  163700             : 
  163701             :     return object;
  163702             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  163703             : }
  163704             : 
  163705             : 
  163706             : 
  163707             : /*! \brief Delete operator for SgImpliedDo.
  163708             : 
  163709             :    This delete operator implements deallocation using memory pools to 
  163710             :    provide most efficent use of the heap within construction of large ASTs.
  163711             : 
  163712             : \internal The new and delete operators use the lower level C malloc/free
  163713             :    function calls for performance and to make sure that mixing of malloc/free
  163714             :    and new/delete by the used can be caught more readily.  This may change
  163715             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  163716             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  163717             :    deallocate memory allocated using ROSE_MALLOC.
  163718             : */
  163719           0 : void SgImpliedDo::operator delete(void *Pointer, size_t Size)
  163720             : {
  163721             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  163722             :      * or throwing an exception. */
  163723           0 :     ALLOC_MUTEX(SgImpliedDo, lock);
  163724             : 
  163725             : #if USE_CPP_NEW_DELETE_OPERATORS
  163726             :     ROSE_FREE(Pointer);
  163727             : #else
  163728             : #if ROSE_PEDANTIC_ALLOC
  163729             :     ROSE_ASSERT(Size == sizeof(SgImpliedDo));
  163730             : #else
  163731           0 :     if (Size != sizeof(SgImpliedDo)) {
  163732           0 :       ROSE_FREE(Pointer);
  163733           0 :       ALLOC_MUTEX(SgImpliedDo, unlock);
  163734             :       return;
  163735             :     }
  163736             : #endif
  163737             : 
  163738           0 :     SgImpliedDo * object = (SgImpliedDo*) Pointer;
  163739           0 :     ROSE_ASSERT(object != nullptr);
  163740             : 
  163741             : #if ROSE_ALLOC_TRACE == 2
  163742             : //  printf("SgImpliedDo::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgImpliedDo::next_node);
  163743             :     printf("SgImpliedDo::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgImpliedDo::next_node);
  163744             : #endif
  163745             : 
  163746             : #if ROSE_PEDANTIC_ALLOC
  163747             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  163748             : #endif
  163749             : 
  163750             : #if ROSE_ALLOC_MEMSET == 1
  163751             : #elif ROSE_ALLOC_MEMSET == 2
  163752             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgImpliedDo) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  163753             : #elif ROSE_ALLOC_MEMSET == 3
  163754             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgImpliedDo) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  163755             : #endif
  163756             : 
  163757             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  163758             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  163759             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  163760             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  163761             : #else
  163762           0 :     object->p_freepointer = SgImpliedDo::next_node;
  163763           0 :     SgImpliedDo::next_node = object;
  163764             : #endif
  163765             : 
  163766             : #if ROSE_ALLOC_TRACE == 2
  163767             : //  printf("SgImpliedDo::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgImpliedDo::next_node);
  163768             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  163769             :     Rose::MemPool::snapshot(oss.str());
  163770             :     alloc_trace_cnt++;
  163771             : #endif
  163772             : 
  163773             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  163774             : 
  163775           0 :     ALLOC_MUTEX(SgImpliedDo, unlock);
  163776             : }
  163777             : 
  163778             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  163779             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  163780             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  163781             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  163782             : // Also, note comment below from Robb (copied from the Common.code file).
  163783             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  163784             : //
  163785             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  163786             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  163787             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  163788             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  163789             : #if 0
  163790             : void SgImpliedDo::operator delete(void* pointer) { SgImpliedDo::operator delete (pointer, sizeof(SgImpliedDo)); };
  163791             : #endif
  163792             : /* #line 163793 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  163793             : 
  163794             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  163795             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  163796             : // obviously imply C++.
  163797             : 
  163798             : // This implements the support within ROSE for memory pools.  Memory pools
  163799             : // support the most condensed usage of memory within the construction of
  163800             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  163801             : // by a new operator written for each class.
  163802             : 
  163803             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  163804             :     // User wants multi-thread support and POSIX threads are available.
  163805             : #   include <pthread.h>
  163806             :     static pthread_mutex_t SgIOItemExpression_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  163807             : #else
  163808             :      // Cause synchronization to be skipped.
  163809             : #    ifndef ALLOC_MUTEX
  163810             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  163811             : #    endif
  163812             : #    ifdef _REENTRANT
  163813             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  163814             : #       ifdef _MSC_VER
  163815             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  163816             : #       else
  163817             : #           warning "POSIX threads are not available; synchronization being skipped"
  163818             : #       endif
  163819             : #    endif
  163820             : #endif
  163821             : 
  163822             : #ifndef ROSE_ALLOC_TRACE
  163823             : #  define ROSE_ALLOC_TRACE 0
  163824             : #endif
  163825             : 
  163826             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  163827             : #define ROSE_ALLOC_TRACE_CNT
  163828             : #include "memory-pool-snapshot.h"
  163829             : unsigned long alloc_trace_cnt = 0;
  163830             : #endif
  163831             : 
  163832             : #if ROSE_ALLOC_TRACE
  163833             : const unsigned SgIOItemExpression::pool_size = 5;
  163834             : #else
  163835             : const unsigned SgIOItemExpression::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  163836             : #endif
  163837             : 
  163838             : #ifndef ROSE_ALLOC_MEMSET
  163839             : #  define ROSE_ALLOC_MEMSET 0
  163840             : #endif
  163841             : 
  163842             : #ifndef ROSE_PEDANTIC_ALLOC
  163843             : #  define ROSE_PEDANTIC_ALLOC 0
  163844             : #endif
  163845             : 
  163846             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  163847             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  163848             : #endif
  163849             : 
  163850             : #if !defined(SGNODE__ALL_POOLS)
  163851             : #define SGNODE__ALL_POOLS
  163852             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  163853             : #endif
  163854             : 
  163855             : SgIOItemExpression* SgIOItemExpression::next_node = nullptr;
  163856             : std::vector<unsigned char*> SgIOItemExpression::pools;
  163857             : 
  163858             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  163859             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  163860             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  163861             : // around this macro definition rather than each use).
  163862             : #ifndef ALLOC_MUTEX
  163863             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  163864             :         do {                                                                     \
  163865             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  163866             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  163867             :                 abort();                                                         \
  163868             :             }                                                                    \
  163869             :         } while (0);
  163870             : #endif
  163871             : 
  163872             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  163873             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  163874             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  163875             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  163876             : 
  163877             : /*! \brief New operator for SgIOItemExpression.
  163878             : 
  163879             :    This new operator implements memory pools to provide most efficent 
  163880             :    use of the heap within construction of large ASTs.
  163881             : 
  163882             : \internal The new and delete operators use the lower level C malloc/free
  163883             :    function calls for performance and to make sure that mixing of malloc/free
  163884             :    and new/delete by the used can be caught more readily.  This may change
  163885             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  163886             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  163887             :    deallocate memory allocated using ROSE_MALLOC.
  163888             : */
  163889           0 : void *SgIOItemExpression::operator new ( size_t Size )
  163890             : {
  163891             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  163892             :      * returning or throwing an exception. */
  163893           0 :     ALLOC_MUTEX(SgIOItemExpression, lock);
  163894             : 
  163895             : #if ROSE_ALLOC_TRACE == 2
  163896             : //    printf("SgIOItemExpression::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgIOItemExpression::next_node);
  163897             : #endif
  163898             : 
  163899             : #if USE_CPP_NEW_DELETE_OPERATORS
  163900             :     void *mem = ROSE_MALLOC(Size);
  163901             :     ALLOC_MUTEX(SgIOItemExpression, unlock);
  163902             :     return mem;
  163903             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  163904             : #if ROSE_PEDANTIC_ALLOC
  163905             :     ROSE_ASSERT(Size == sizeof(SgIOItemExpression));
  163906             : #else
  163907           0 :     if (Size != sizeof(SgIOItemExpression)) {
  163908           0 :       void * object = ROSE_MALLOC(Size);
  163909           0 :       ALLOC_MUTEX(SgIOItemExpression, unlock);
  163910             :       return object;
  163911             :     }
  163912             : #endif
  163913             : 
  163914           0 :     if (SgIOItemExpression::next_node == nullptr) {
  163915           0 :         SgIOItemExpression * alloc = (SgIOItemExpression*) ROSE_MALLOC ( SgIOItemExpression::pool_size * sizeof(SgIOItemExpression) );
  163916           0 :         ROSE_ASSERT(alloc != nullptr);
  163917             : 
  163918             : #if ROSE_ALLOC_TRACE == 2
  163919             : //        printf("SgIOItemExpression::alloc\n  block[%zi] = [ %p , %p [\n", SgIOItemExpression::pools.size(), alloc, alloc + SgIOItemExpression::pool_size);
  163920             : #endif
  163921             : 
  163922             : #if ROSE_ALLOC_MEMSET == 1
  163923             : #elif ROSE_ALLOC_MEMSET == 2
  163924             :         memset(alloc, 0x00, SgIOItemExpression::pool_size * sizeof(SgIOItemExpression));
  163925             : #elif ROSE_ALLOC_MEMSET == 3
  163926             :         memset(alloc, 0xAA, SgIOItemExpression::pool_size * sizeof(SgIOItemExpression));
  163927             : #endif
  163928           0 :         for (unsigned i=0; i < SgIOItemExpression::pool_size-1; i++) {
  163929           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
  163930             :         }
  163931           0 :         alloc[SgIOItemExpression::pool_size-1].p_freepointer = nullptr;
  163932             : 
  163933           0 :         SgIOItemExpression::pools.push_back ( (unsigned char *) alloc );
  163934           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgIOItemExpression::pool_size * sizeof(SgIOItemExpression), V_SgIOItemExpression ) );
  163935           0 :         SgIOItemExpression::next_node = alloc;
  163936             :     }
  163937           0 :     ROSE_ASSERT(SgIOItemExpression::next_node != nullptr);
  163938             : 
  163939           0 :     SgIOItemExpression * object = SgIOItemExpression::next_node;
  163940           0 :     SgIOItemExpression::next_node = (SgIOItemExpression*)(object->p_freepointer);
  163941             : 
  163942             : #if ROSE_ALLOC_TRACE == 2
  163943             :     printf("SgIOItemExpression::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgIOItemExpression::next_node);
  163944             : #endif
  163945             : 
  163946           0 :     SgNode * fp = object->p_freepointer;
  163947             : #if ROSE_ALLOC_MEMSET == 1
  163948             : #elif ROSE_ALLOC_MEMSET == 2
  163949             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgIOItemExpression) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  163950             : #elif ROSE_ALLOC_MEMSET == 3
  163951             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgIOItemExpression) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  163952             : #endif
  163953           0 :     object->p_freepointer = fp;
  163954             : 
  163955             : #if ROSE_ALLOC_TRACE == 2
  163956             : //    printf("SgIOItemExpression::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgIOItemExpression::next_node);
  163957             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  163958             :     Rose::MemPool::snapshot(oss.str());
  163959             :     alloc_trace_cnt++;
  163960             : #endif
  163961             : 
  163962           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  163963             : 
  163964           0 :     ALLOC_MUTEX(SgIOItemExpression, unlock);
  163965             : 
  163966             :     return object;
  163967             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  163968             : }
  163969             : 
  163970             : 
  163971             : 
  163972             : /*! \brief Delete operator for SgIOItemExpression.
  163973             : 
  163974             :    This delete operator implements deallocation using memory pools to 
  163975             :    provide most efficent use of the heap within construction of large ASTs.
  163976             : 
  163977             : \internal The new and delete operators use the lower level C malloc/free
  163978             :    function calls for performance and to make sure that mixing of malloc/free
  163979             :    and new/delete by the used can be caught more readily.  This may change
  163980             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  163981             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  163982             :    deallocate memory allocated using ROSE_MALLOC.
  163983             : */
  163984           0 : void SgIOItemExpression::operator delete(void *Pointer, size_t Size)
  163985             : {
  163986             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  163987             :      * or throwing an exception. */
  163988           0 :     ALLOC_MUTEX(SgIOItemExpression, lock);
  163989             : 
  163990             : #if USE_CPP_NEW_DELETE_OPERATORS
  163991             :     ROSE_FREE(Pointer);
  163992             : #else
  163993             : #if ROSE_PEDANTIC_ALLOC
  163994             :     ROSE_ASSERT(Size == sizeof(SgIOItemExpression));
  163995             : #else
  163996           0 :     if (Size != sizeof(SgIOItemExpression)) {
  163997           0 :       ROSE_FREE(Pointer);
  163998           0 :       ALLOC_MUTEX(SgIOItemExpression, unlock);
  163999             :       return;
  164000             :     }
  164001             : #endif
  164002             : 
  164003           0 :     SgIOItemExpression * object = (SgIOItemExpression*) Pointer;
  164004           0 :     ROSE_ASSERT(object != nullptr);
  164005             : 
  164006             : #if ROSE_ALLOC_TRACE == 2
  164007             : //  printf("SgIOItemExpression::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgIOItemExpression::next_node);
  164008             :     printf("SgIOItemExpression::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgIOItemExpression::next_node);
  164009             : #endif
  164010             : 
  164011             : #if ROSE_PEDANTIC_ALLOC
  164012             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  164013             : #endif
  164014             : 
  164015             : #if ROSE_ALLOC_MEMSET == 1
  164016             : #elif ROSE_ALLOC_MEMSET == 2
  164017             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgIOItemExpression) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  164018             : #elif ROSE_ALLOC_MEMSET == 3
  164019             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgIOItemExpression) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  164020             : #endif
  164021             : 
  164022             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  164023             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  164024             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  164025             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  164026             : #else
  164027           0 :     object->p_freepointer = SgIOItemExpression::next_node;
  164028           0 :     SgIOItemExpression::next_node = object;
  164029             : #endif
  164030             : 
  164031             : #if ROSE_ALLOC_TRACE == 2
  164032             : //  printf("SgIOItemExpression::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgIOItemExpression::next_node);
  164033             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  164034             :     Rose::MemPool::snapshot(oss.str());
  164035             :     alloc_trace_cnt++;
  164036             : #endif
  164037             : 
  164038             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  164039             : 
  164040           0 :     ALLOC_MUTEX(SgIOItemExpression, unlock);
  164041             : }
  164042             : 
  164043             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  164044             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  164045             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  164046             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  164047             : // Also, note comment below from Robb (copied from the Common.code file).
  164048             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  164049             : //
  164050             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  164051             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  164052             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  164053             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  164054             : #if 0
  164055             : void SgIOItemExpression::operator delete(void* pointer) { SgIOItemExpression::operator delete (pointer, sizeof(SgIOItemExpression)); };
  164056             : #endif
  164057             : /* #line 164058 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  164058             : 
  164059             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  164060             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  164061             : // obviously imply C++.
  164062             : 
  164063             : // This implements the support within ROSE for memory pools.  Memory pools
  164064             : // support the most condensed usage of memory within the construction of
  164065             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  164066             : // by a new operator written for each class.
  164067             : 
  164068             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  164069             :     // User wants multi-thread support and POSIX threads are available.
  164070             : #   include <pthread.h>
  164071             :     static pthread_mutex_t SgStatementExpression_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  164072             : #else
  164073             :      // Cause synchronization to be skipped.
  164074             : #    ifndef ALLOC_MUTEX
  164075             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  164076             : #    endif
  164077             : #    ifdef _REENTRANT
  164078             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  164079             : #       ifdef _MSC_VER
  164080             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  164081             : #       else
  164082             : #           warning "POSIX threads are not available; synchronization being skipped"
  164083             : #       endif
  164084             : #    endif
  164085             : #endif
  164086             : 
  164087             : #ifndef ROSE_ALLOC_TRACE
  164088             : #  define ROSE_ALLOC_TRACE 0
  164089             : #endif
  164090             : 
  164091             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  164092             : #define ROSE_ALLOC_TRACE_CNT
  164093             : #include "memory-pool-snapshot.h"
  164094             : unsigned long alloc_trace_cnt = 0;
  164095             : #endif
  164096             : 
  164097             : #if ROSE_ALLOC_TRACE
  164098             : const unsigned SgStatementExpression::pool_size = 5;
  164099             : #else
  164100             : const unsigned SgStatementExpression::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  164101             : #endif
  164102             : 
  164103             : #ifndef ROSE_ALLOC_MEMSET
  164104             : #  define ROSE_ALLOC_MEMSET 0
  164105             : #endif
  164106             : 
  164107             : #ifndef ROSE_PEDANTIC_ALLOC
  164108             : #  define ROSE_PEDANTIC_ALLOC 0
  164109             : #endif
  164110             : 
  164111             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  164112             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  164113             : #endif
  164114             : 
  164115             : #if !defined(SGNODE__ALL_POOLS)
  164116             : #define SGNODE__ALL_POOLS
  164117             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  164118             : #endif
  164119             : 
  164120             : SgStatementExpression* SgStatementExpression::next_node = nullptr;
  164121             : std::vector<unsigned char*> SgStatementExpression::pools;
  164122             : 
  164123             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  164124             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  164125             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  164126             : // around this macro definition rather than each use).
  164127             : #ifndef ALLOC_MUTEX
  164128             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  164129             :         do {                                                                     \
  164130             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  164131             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  164132             :                 abort();                                                         \
  164133             :             }                                                                    \
  164134             :         } while (0);
  164135             : #endif
  164136             : 
  164137             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  164138             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  164139             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  164140             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  164141             : 
  164142             : /*! \brief New operator for SgStatementExpression.
  164143             : 
  164144             :    This new operator implements memory pools to provide most efficent 
  164145             :    use of the heap within construction of large ASTs.
  164146             : 
  164147             : \internal The new and delete operators use the lower level C malloc/free
  164148             :    function calls for performance and to make sure that mixing of malloc/free
  164149             :    and new/delete by the used can be caught more readily.  This may change
  164150             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  164151             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  164152             :    deallocate memory allocated using ROSE_MALLOC.
  164153             : */
  164154          59 : void *SgStatementExpression::operator new ( size_t Size )
  164155             : {
  164156             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  164157             :      * returning or throwing an exception. */
  164158          59 :     ALLOC_MUTEX(SgStatementExpression, lock);
  164159             : 
  164160             : #if ROSE_ALLOC_TRACE == 2
  164161             : //    printf("SgStatementExpression::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgStatementExpression::next_node);
  164162             : #endif
  164163             : 
  164164             : #if USE_CPP_NEW_DELETE_OPERATORS
  164165             :     void *mem = ROSE_MALLOC(Size);
  164166             :     ALLOC_MUTEX(SgStatementExpression, unlock);
  164167             :     return mem;
  164168             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  164169             : #if ROSE_PEDANTIC_ALLOC
  164170             :     ROSE_ASSERT(Size == sizeof(SgStatementExpression));
  164171             : #else
  164172          59 :     if (Size != sizeof(SgStatementExpression)) {
  164173           0 :       void * object = ROSE_MALLOC(Size);
  164174           0 :       ALLOC_MUTEX(SgStatementExpression, unlock);
  164175             :       return object;
  164176             :     }
  164177             : #endif
  164178             : 
  164179          59 :     if (SgStatementExpression::next_node == nullptr) {
  164180          28 :         SgStatementExpression * alloc = (SgStatementExpression*) ROSE_MALLOC ( SgStatementExpression::pool_size * sizeof(SgStatementExpression) );
  164181          28 :         ROSE_ASSERT(alloc != nullptr);
  164182             : 
  164183             : #if ROSE_ALLOC_TRACE == 2
  164184             : //        printf("SgStatementExpression::alloc\n  block[%zi] = [ %p , %p [\n", SgStatementExpression::pools.size(), alloc, alloc + SgStatementExpression::pool_size);
  164185             : #endif
  164186             : 
  164187             : #if ROSE_ALLOC_MEMSET == 1
  164188             : #elif ROSE_ALLOC_MEMSET == 2
  164189             :         memset(alloc, 0x00, SgStatementExpression::pool_size * sizeof(SgStatementExpression));
  164190             : #elif ROSE_ALLOC_MEMSET == 3
  164191             :         memset(alloc, 0xAA, SgStatementExpression::pool_size * sizeof(SgStatementExpression));
  164192             : #endif
  164193       56000 :         for (unsigned i=0; i < SgStatementExpression::pool_size-1; i++) {
  164194       55972 :           alloc[i].p_freepointer = &(alloc[i+1]);
  164195             :         }
  164196          28 :         alloc[SgStatementExpression::pool_size-1].p_freepointer = nullptr;
  164197             : 
  164198          28 :         SgStatementExpression::pools.push_back ( (unsigned char *) alloc );
  164199          28 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgStatementExpression::pool_size * sizeof(SgStatementExpression), V_SgStatementExpression ) );
  164200          28 :         SgStatementExpression::next_node = alloc;
  164201             :     }
  164202          59 :     ROSE_ASSERT(SgStatementExpression::next_node != nullptr);
  164203             : 
  164204          59 :     SgStatementExpression * object = SgStatementExpression::next_node;
  164205          59 :     SgStatementExpression::next_node = (SgStatementExpression*)(object->p_freepointer);
  164206             : 
  164207             : #if ROSE_ALLOC_TRACE == 2
  164208             :     printf("SgStatementExpression::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgStatementExpression::next_node);
  164209             : #endif
  164210             : 
  164211          59 :     SgNode * fp = object->p_freepointer;
  164212             : #if ROSE_ALLOC_MEMSET == 1
  164213             : #elif ROSE_ALLOC_MEMSET == 2
  164214             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgStatementExpression) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  164215             : #elif ROSE_ALLOC_MEMSET == 3
  164216             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgStatementExpression) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  164217             : #endif
  164218          59 :     object->p_freepointer = fp;
  164219             : 
  164220             : #if ROSE_ALLOC_TRACE == 2
  164221             : //    printf("SgStatementExpression::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgStatementExpression::next_node);
  164222             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  164223             :     Rose::MemPool::snapshot(oss.str());
  164224             :     alloc_trace_cnt++;
  164225             : #endif
  164226             : 
  164227          59 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  164228             : 
  164229          59 :     ALLOC_MUTEX(SgStatementExpression, unlock);
  164230             : 
  164231             :     return object;
  164232             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  164233             : }
  164234             : 
  164235             : 
  164236             : 
  164237             : /*! \brief Delete operator for SgStatementExpression.
  164238             : 
  164239             :    This delete operator implements deallocation using memory pools to 
  164240             :    provide most efficent use of the heap within construction of large ASTs.
  164241             : 
  164242             : \internal The new and delete operators use the lower level C malloc/free
  164243             :    function calls for performance and to make sure that mixing of malloc/free
  164244             :    and new/delete by the used can be caught more readily.  This may change
  164245             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  164246             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  164247             :    deallocate memory allocated using ROSE_MALLOC.
  164248             : */
  164249           0 : void SgStatementExpression::operator delete(void *Pointer, size_t Size)
  164250             : {
  164251             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  164252             :      * or throwing an exception. */
  164253           0 :     ALLOC_MUTEX(SgStatementExpression, lock);
  164254             : 
  164255             : #if USE_CPP_NEW_DELETE_OPERATORS
  164256             :     ROSE_FREE(Pointer);
  164257             : #else
  164258             : #if ROSE_PEDANTIC_ALLOC
  164259             :     ROSE_ASSERT(Size == sizeof(SgStatementExpression));
  164260             : #else
  164261           0 :     if (Size != sizeof(SgStatementExpression)) {
  164262           0 :       ROSE_FREE(Pointer);
  164263           0 :       ALLOC_MUTEX(SgStatementExpression, unlock);
  164264             :       return;
  164265             :     }
  164266             : #endif
  164267             : 
  164268           0 :     SgStatementExpression * object = (SgStatementExpression*) Pointer;
  164269           0 :     ROSE_ASSERT(object != nullptr);
  164270             : 
  164271             : #if ROSE_ALLOC_TRACE == 2
  164272             : //  printf("SgStatementExpression::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgStatementExpression::next_node);
  164273             :     printf("SgStatementExpression::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgStatementExpression::next_node);
  164274             : #endif
  164275             : 
  164276             : #if ROSE_PEDANTIC_ALLOC
  164277             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  164278             : #endif
  164279             : 
  164280             : #if ROSE_ALLOC_MEMSET == 1
  164281             : #elif ROSE_ALLOC_MEMSET == 2
  164282             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgStatementExpression) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  164283             : #elif ROSE_ALLOC_MEMSET == 3
  164284             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgStatementExpression) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  164285             : #endif
  164286             : 
  164287             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  164288             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  164289             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  164290             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  164291             : #else
  164292           0 :     object->p_freepointer = SgStatementExpression::next_node;
  164293           0 :     SgStatementExpression::next_node = object;
  164294             : #endif
  164295             : 
  164296             : #if ROSE_ALLOC_TRACE == 2
  164297             : //  printf("SgStatementExpression::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgStatementExpression::next_node);
  164298             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  164299             :     Rose::MemPool::snapshot(oss.str());
  164300             :     alloc_trace_cnt++;
  164301             : #endif
  164302             : 
  164303             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  164304             : 
  164305           0 :     ALLOC_MUTEX(SgStatementExpression, unlock);
  164306             : }
  164307             : 
  164308             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  164309             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  164310             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  164311             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  164312             : // Also, note comment below from Robb (copied from the Common.code file).
  164313             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  164314             : //
  164315             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  164316             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  164317             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  164318             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  164319             : #if 0
  164320             : void SgStatementExpression::operator delete(void* pointer) { SgStatementExpression::operator delete (pointer, sizeof(SgStatementExpression)); };
  164321             : #endif
  164322             : /* #line 164323 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  164323             : 
  164324             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  164325             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  164326             : // obviously imply C++.
  164327             : 
  164328             : // This implements the support within ROSE for memory pools.  Memory pools
  164329             : // support the most condensed usage of memory within the construction of
  164330             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  164331             : // by a new operator written for each class.
  164332             : 
  164333             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  164334             :     // User wants multi-thread support and POSIX threads are available.
  164335             : #   include <pthread.h>
  164336             :     static pthread_mutex_t SgAsmOp_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  164337             : #else
  164338             :      // Cause synchronization to be skipped.
  164339             : #    ifndef ALLOC_MUTEX
  164340             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  164341             : #    endif
  164342             : #    ifdef _REENTRANT
  164343             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  164344             : #       ifdef _MSC_VER
  164345             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  164346             : #       else
  164347             : #           warning "POSIX threads are not available; synchronization being skipped"
  164348             : #       endif
  164349             : #    endif
  164350             : #endif
  164351             : 
  164352             : #ifndef ROSE_ALLOC_TRACE
  164353             : #  define ROSE_ALLOC_TRACE 0
  164354             : #endif
  164355             : 
  164356             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  164357             : #define ROSE_ALLOC_TRACE_CNT
  164358             : #include "memory-pool-snapshot.h"
  164359             : unsigned long alloc_trace_cnt = 0;
  164360             : #endif
  164361             : 
  164362             : #if ROSE_ALLOC_TRACE
  164363             : const unsigned SgAsmOp::pool_size = 5;
  164364             : #else
  164365             : const unsigned SgAsmOp::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  164366             : #endif
  164367             : 
  164368             : #ifndef ROSE_ALLOC_MEMSET
  164369             : #  define ROSE_ALLOC_MEMSET 0
  164370             : #endif
  164371             : 
  164372             : #ifndef ROSE_PEDANTIC_ALLOC
  164373             : #  define ROSE_PEDANTIC_ALLOC 0
  164374             : #endif
  164375             : 
  164376             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  164377             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  164378             : #endif
  164379             : 
  164380             : #if !defined(SGNODE__ALL_POOLS)
  164381             : #define SGNODE__ALL_POOLS
  164382             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  164383             : #endif
  164384             : 
  164385             : SgAsmOp* SgAsmOp::next_node = nullptr;
  164386             : std::vector<unsigned char*> SgAsmOp::pools;
  164387             : 
  164388             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  164389             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  164390             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  164391             : // around this macro definition rather than each use).
  164392             : #ifndef ALLOC_MUTEX
  164393             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  164394             :         do {                                                                     \
  164395             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  164396             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  164397             :                 abort();                                                         \
  164398             :             }                                                                    \
  164399             :         } while (0);
  164400             : #endif
  164401             : 
  164402             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  164403             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  164404             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  164405             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  164406             : 
  164407             : /*! \brief New operator for SgAsmOp.
  164408             : 
  164409             :    This new operator implements memory pools to provide most efficent 
  164410             :    use of the heap within construction of large ASTs.
  164411             : 
  164412             : \internal The new and delete operators use the lower level C malloc/free
  164413             :    function calls for performance and to make sure that mixing of malloc/free
  164414             :    and new/delete by the used can be caught more readily.  This may change
  164415             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  164416             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  164417             :    deallocate memory allocated using ROSE_MALLOC.
  164418             : */
  164419           0 : void *SgAsmOp::operator new ( size_t Size )
  164420             : {
  164421             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  164422             :      * returning or throwing an exception. */
  164423           0 :     ALLOC_MUTEX(SgAsmOp, lock);
  164424             : 
  164425             : #if ROSE_ALLOC_TRACE == 2
  164426             : //    printf("SgAsmOp::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgAsmOp::next_node);
  164427             : #endif
  164428             : 
  164429             : #if USE_CPP_NEW_DELETE_OPERATORS
  164430             :     void *mem = ROSE_MALLOC(Size);
  164431             :     ALLOC_MUTEX(SgAsmOp, unlock);
  164432             :     return mem;
  164433             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  164434             : #if ROSE_PEDANTIC_ALLOC
  164435             :     ROSE_ASSERT(Size == sizeof(SgAsmOp));
  164436             : #else
  164437           0 :     if (Size != sizeof(SgAsmOp)) {
  164438           0 :       void * object = ROSE_MALLOC(Size);
  164439           0 :       ALLOC_MUTEX(SgAsmOp, unlock);
  164440             :       return object;
  164441             :     }
  164442             : #endif
  164443             : 
  164444           0 :     if (SgAsmOp::next_node == nullptr) {
  164445           0 :         SgAsmOp * alloc = (SgAsmOp*) ROSE_MALLOC ( SgAsmOp::pool_size * sizeof(SgAsmOp) );
  164446           0 :         ROSE_ASSERT(alloc != nullptr);
  164447             : 
  164448             : #if ROSE_ALLOC_TRACE == 2
  164449             : //        printf("SgAsmOp::alloc\n  block[%zi] = [ %p , %p [\n", SgAsmOp::pools.size(), alloc, alloc + SgAsmOp::pool_size);
  164450             : #endif
  164451             : 
  164452             : #if ROSE_ALLOC_MEMSET == 1
  164453             : #elif ROSE_ALLOC_MEMSET == 2
  164454             :         memset(alloc, 0x00, SgAsmOp::pool_size * sizeof(SgAsmOp));
  164455             : #elif ROSE_ALLOC_MEMSET == 3
  164456             :         memset(alloc, 0xAA, SgAsmOp::pool_size * sizeof(SgAsmOp));
  164457             : #endif
  164458           0 :         for (unsigned i=0; i < SgAsmOp::pool_size-1; i++) {
  164459           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
  164460             :         }
  164461           0 :         alloc[SgAsmOp::pool_size-1].p_freepointer = nullptr;
  164462             : 
  164463           0 :         SgAsmOp::pools.push_back ( (unsigned char *) alloc );
  164464           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgAsmOp::pool_size * sizeof(SgAsmOp), V_SgAsmOp ) );
  164465           0 :         SgAsmOp::next_node = alloc;
  164466             :     }
  164467           0 :     ROSE_ASSERT(SgAsmOp::next_node != nullptr);
  164468             : 
  164469           0 :     SgAsmOp * object = SgAsmOp::next_node;
  164470           0 :     SgAsmOp::next_node = (SgAsmOp*)(object->p_freepointer);
  164471             : 
  164472             : #if ROSE_ALLOC_TRACE == 2
  164473             :     printf("SgAsmOp::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgAsmOp::next_node);
  164474             : #endif
  164475             : 
  164476           0 :     SgNode * fp = object->p_freepointer;
  164477             : #if ROSE_ALLOC_MEMSET == 1
  164478             : #elif ROSE_ALLOC_MEMSET == 2
  164479             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgAsmOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  164480             : #elif ROSE_ALLOC_MEMSET == 3
  164481             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgAsmOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  164482             : #endif
  164483           0 :     object->p_freepointer = fp;
  164484             : 
  164485             : #if ROSE_ALLOC_TRACE == 2
  164486             : //    printf("SgAsmOp::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgAsmOp::next_node);
  164487             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  164488             :     Rose::MemPool::snapshot(oss.str());
  164489             :     alloc_trace_cnt++;
  164490             : #endif
  164491             : 
  164492           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  164493             : 
  164494           0 :     ALLOC_MUTEX(SgAsmOp, unlock);
  164495             : 
  164496             :     return object;
  164497             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  164498             : }
  164499             : 
  164500             : 
  164501             : 
  164502             : /*! \brief Delete operator for SgAsmOp.
  164503             : 
  164504             :    This delete operator implements deallocation using memory pools to 
  164505             :    provide most efficent use of the heap within construction of large ASTs.
  164506             : 
  164507             : \internal The new and delete operators use the lower level C malloc/free
  164508             :    function calls for performance and to make sure that mixing of malloc/free
  164509             :    and new/delete by the used can be caught more readily.  This may change
  164510             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  164511             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  164512             :    deallocate memory allocated using ROSE_MALLOC.
  164513             : */
  164514           0 : void SgAsmOp::operator delete(void *Pointer, size_t Size)
  164515             : {
  164516             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  164517             :      * or throwing an exception. */
  164518           0 :     ALLOC_MUTEX(SgAsmOp, lock);
  164519             : 
  164520             : #if USE_CPP_NEW_DELETE_OPERATORS
  164521             :     ROSE_FREE(Pointer);
  164522             : #else
  164523             : #if ROSE_PEDANTIC_ALLOC
  164524             :     ROSE_ASSERT(Size == sizeof(SgAsmOp));
  164525             : #else
  164526           0 :     if (Size != sizeof(SgAsmOp)) {
  164527           0 :       ROSE_FREE(Pointer);
  164528           0 :       ALLOC_MUTEX(SgAsmOp, unlock);
  164529             :       return;
  164530             :     }
  164531             : #endif
  164532             : 
  164533           0 :     SgAsmOp * object = (SgAsmOp*) Pointer;
  164534           0 :     ROSE_ASSERT(object != nullptr);
  164535             : 
  164536             : #if ROSE_ALLOC_TRACE == 2
  164537             : //  printf("SgAsmOp::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgAsmOp::next_node);
  164538             :     printf("SgAsmOp::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgAsmOp::next_node);
  164539             : #endif
  164540             : 
  164541             : #if ROSE_PEDANTIC_ALLOC
  164542             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  164543             : #endif
  164544             : 
  164545             : #if ROSE_ALLOC_MEMSET == 1
  164546             : #elif ROSE_ALLOC_MEMSET == 2
  164547             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgAsmOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  164548             : #elif ROSE_ALLOC_MEMSET == 3
  164549             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgAsmOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  164550             : #endif
  164551             : 
  164552             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  164553             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  164554             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  164555             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  164556             : #else
  164557           0 :     object->p_freepointer = SgAsmOp::next_node;
  164558           0 :     SgAsmOp::next_node = object;
  164559             : #endif
  164560             : 
  164561             : #if ROSE_ALLOC_TRACE == 2
  164562             : //  printf("SgAsmOp::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgAsmOp::next_node);
  164563             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  164564             :     Rose::MemPool::snapshot(oss.str());
  164565             :     alloc_trace_cnt++;
  164566             : #endif
  164567             : 
  164568             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  164569             : 
  164570           0 :     ALLOC_MUTEX(SgAsmOp, unlock);
  164571             : }
  164572             : 
  164573             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  164574             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  164575             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  164576             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  164577             : // Also, note comment below from Robb (copied from the Common.code file).
  164578             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  164579             : //
  164580             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  164581             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  164582             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  164583             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  164584             : #if 0
  164585             : void SgAsmOp::operator delete(void* pointer) { SgAsmOp::operator delete (pointer, sizeof(SgAsmOp)); };
  164586             : #endif
  164587             : /* #line 164588 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  164588             : 
  164589             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  164590             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  164591             : // obviously imply C++.
  164592             : 
  164593             : // This implements the support within ROSE for memory pools.  Memory pools
  164594             : // support the most condensed usage of memory within the construction of
  164595             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  164596             : // by a new operator written for each class.
  164597             : 
  164598             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  164599             :     // User wants multi-thread support and POSIX threads are available.
  164600             : #   include <pthread.h>
  164601             :     static pthread_mutex_t SgLabelRefExp_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  164602             : #else
  164603             :      // Cause synchronization to be skipped.
  164604             : #    ifndef ALLOC_MUTEX
  164605             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  164606             : #    endif
  164607             : #    ifdef _REENTRANT
  164608             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  164609             : #       ifdef _MSC_VER
  164610             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  164611             : #       else
  164612             : #           warning "POSIX threads are not available; synchronization being skipped"
  164613             : #       endif
  164614             : #    endif
  164615             : #endif
  164616             : 
  164617             : #ifndef ROSE_ALLOC_TRACE
  164618             : #  define ROSE_ALLOC_TRACE 0
  164619             : #endif
  164620             : 
  164621             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  164622             : #define ROSE_ALLOC_TRACE_CNT
  164623             : #include "memory-pool-snapshot.h"
  164624             : unsigned long alloc_trace_cnt = 0;
  164625             : #endif
  164626             : 
  164627             : #if ROSE_ALLOC_TRACE
  164628             : const unsigned SgLabelRefExp::pool_size = 5;
  164629             : #else
  164630             : const unsigned SgLabelRefExp::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  164631             : #endif
  164632             : 
  164633             : #ifndef ROSE_ALLOC_MEMSET
  164634             : #  define ROSE_ALLOC_MEMSET 0
  164635             : #endif
  164636             : 
  164637             : #ifndef ROSE_PEDANTIC_ALLOC
  164638             : #  define ROSE_PEDANTIC_ALLOC 0
  164639             : #endif
  164640             : 
  164641             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  164642             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  164643             : #endif
  164644             : 
  164645             : #if !defined(SGNODE__ALL_POOLS)
  164646             : #define SGNODE__ALL_POOLS
  164647             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  164648             : #endif
  164649             : 
  164650             : SgLabelRefExp* SgLabelRefExp::next_node = nullptr;
  164651             : std::vector<unsigned char*> SgLabelRefExp::pools;
  164652             : 
  164653             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  164654             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  164655             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  164656             : // around this macro definition rather than each use).
  164657             : #ifndef ALLOC_MUTEX
  164658             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  164659             :         do {                                                                     \
  164660             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  164661             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  164662             :                 abort();                                                         \
  164663             :             }                                                                    \
  164664             :         } while (0);
  164665             : #endif
  164666             : 
  164667             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  164668             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  164669             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  164670             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  164671             : 
  164672             : /*! \brief New operator for SgLabelRefExp.
  164673             : 
  164674             :    This new operator implements memory pools to provide most efficent 
  164675             :    use of the heap within construction of large ASTs.
  164676             : 
  164677             : \internal The new and delete operators use the lower level C malloc/free
  164678             :    function calls for performance and to make sure that mixing of malloc/free
  164679             :    and new/delete by the used can be caught more readily.  This may change
  164680             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  164681             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  164682             :    deallocate memory allocated using ROSE_MALLOC.
  164683             : */
  164684           9 : void *SgLabelRefExp::operator new ( size_t Size )
  164685             : {
  164686             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  164687             :      * returning or throwing an exception. */
  164688           9 :     ALLOC_MUTEX(SgLabelRefExp, lock);
  164689             : 
  164690             : #if ROSE_ALLOC_TRACE == 2
  164691             : //    printf("SgLabelRefExp::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgLabelRefExp::next_node);
  164692             : #endif
  164693             : 
  164694             : #if USE_CPP_NEW_DELETE_OPERATORS
  164695             :     void *mem = ROSE_MALLOC(Size);
  164696             :     ALLOC_MUTEX(SgLabelRefExp, unlock);
  164697             :     return mem;
  164698             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  164699             : #if ROSE_PEDANTIC_ALLOC
  164700             :     ROSE_ASSERT(Size == sizeof(SgLabelRefExp));
  164701             : #else
  164702           9 :     if (Size != sizeof(SgLabelRefExp)) {
  164703           0 :       void * object = ROSE_MALLOC(Size);
  164704           0 :       ALLOC_MUTEX(SgLabelRefExp, unlock);
  164705             :       return object;
  164706             :     }
  164707             : #endif
  164708             : 
  164709           9 :     if (SgLabelRefExp::next_node == nullptr) {
  164710           2 :         SgLabelRefExp * alloc = (SgLabelRefExp*) ROSE_MALLOC ( SgLabelRefExp::pool_size * sizeof(SgLabelRefExp) );
  164711           2 :         ROSE_ASSERT(alloc != nullptr);
  164712             : 
  164713             : #if ROSE_ALLOC_TRACE == 2
  164714             : //        printf("SgLabelRefExp::alloc\n  block[%zi] = [ %p , %p [\n", SgLabelRefExp::pools.size(), alloc, alloc + SgLabelRefExp::pool_size);
  164715             : #endif
  164716             : 
  164717             : #if ROSE_ALLOC_MEMSET == 1
  164718             : #elif ROSE_ALLOC_MEMSET == 2
  164719             :         memset(alloc, 0x00, SgLabelRefExp::pool_size * sizeof(SgLabelRefExp));
  164720             : #elif ROSE_ALLOC_MEMSET == 3
  164721             :         memset(alloc, 0xAA, SgLabelRefExp::pool_size * sizeof(SgLabelRefExp));
  164722             : #endif
  164723        4000 :         for (unsigned i=0; i < SgLabelRefExp::pool_size-1; i++) {
  164724        3998 :           alloc[i].p_freepointer = &(alloc[i+1]);
  164725             :         }
  164726           2 :         alloc[SgLabelRefExp::pool_size-1].p_freepointer = nullptr;
  164727             : 
  164728           2 :         SgLabelRefExp::pools.push_back ( (unsigned char *) alloc );
  164729           2 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgLabelRefExp::pool_size * sizeof(SgLabelRefExp), V_SgLabelRefExp ) );
  164730           2 :         SgLabelRefExp::next_node = alloc;
  164731             :     }
  164732           9 :     ROSE_ASSERT(SgLabelRefExp::next_node != nullptr);
  164733             : 
  164734           9 :     SgLabelRefExp * object = SgLabelRefExp::next_node;
  164735           9 :     SgLabelRefExp::next_node = (SgLabelRefExp*)(object->p_freepointer);
  164736             : 
  164737             : #if ROSE_ALLOC_TRACE == 2
  164738             :     printf("SgLabelRefExp::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgLabelRefExp::next_node);
  164739             : #endif
  164740             : 
  164741           9 :     SgNode * fp = object->p_freepointer;
  164742             : #if ROSE_ALLOC_MEMSET == 1
  164743             : #elif ROSE_ALLOC_MEMSET == 2
  164744             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgLabelRefExp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  164745             : #elif ROSE_ALLOC_MEMSET == 3
  164746             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgLabelRefExp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  164747             : #endif
  164748           9 :     object->p_freepointer = fp;
  164749             : 
  164750             : #if ROSE_ALLOC_TRACE == 2
  164751             : //    printf("SgLabelRefExp::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgLabelRefExp::next_node);
  164752             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  164753             :     Rose::MemPool::snapshot(oss.str());
  164754             :     alloc_trace_cnt++;
  164755             : #endif
  164756             : 
  164757           9 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  164758             : 
  164759           9 :     ALLOC_MUTEX(SgLabelRefExp, unlock);
  164760             : 
  164761             :     return object;
  164762             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  164763             : }
  164764             : 
  164765             : 
  164766             : 
  164767             : /*! \brief Delete operator for SgLabelRefExp.
  164768             : 
  164769             :    This delete operator implements deallocation using memory pools to 
  164770             :    provide most efficent use of the heap within construction of large ASTs.
  164771             : 
  164772             : \internal The new and delete operators use the lower level C malloc/free
  164773             :    function calls for performance and to make sure that mixing of malloc/free
  164774             :    and new/delete by the used can be caught more readily.  This may change
  164775             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  164776             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  164777             :    deallocate memory allocated using ROSE_MALLOC.
  164778             : */
  164779           0 : void SgLabelRefExp::operator delete(void *Pointer, size_t Size)
  164780             : {
  164781             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  164782             :      * or throwing an exception. */
  164783           0 :     ALLOC_MUTEX(SgLabelRefExp, lock);
  164784             : 
  164785             : #if USE_CPP_NEW_DELETE_OPERATORS
  164786             :     ROSE_FREE(Pointer);
  164787             : #else
  164788             : #if ROSE_PEDANTIC_ALLOC
  164789             :     ROSE_ASSERT(Size == sizeof(SgLabelRefExp));
  164790             : #else
  164791           0 :     if (Size != sizeof(SgLabelRefExp)) {
  164792           0 :       ROSE_FREE(Pointer);
  164793           0 :       ALLOC_MUTEX(SgLabelRefExp, unlock);
  164794             :       return;
  164795             :     }
  164796             : #endif
  164797             : 
  164798           0 :     SgLabelRefExp * object = (SgLabelRefExp*) Pointer;
  164799           0 :     ROSE_ASSERT(object != nullptr);
  164800             : 
  164801             : #if ROSE_ALLOC_TRACE == 2
  164802             : //  printf("SgLabelRefExp::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgLabelRefExp::next_node);
  164803             :     printf("SgLabelRefExp::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgLabelRefExp::next_node);
  164804             : #endif
  164805             : 
  164806             : #if ROSE_PEDANTIC_ALLOC
  164807             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  164808             : #endif
  164809             : 
  164810             : #if ROSE_ALLOC_MEMSET == 1
  164811             : #elif ROSE_ALLOC_MEMSET == 2
  164812             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgLabelRefExp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  164813             : #elif ROSE_ALLOC_MEMSET == 3
  164814             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgLabelRefExp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  164815             : #endif
  164816             : 
  164817             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  164818             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  164819             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  164820             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  164821             : #else
  164822           0 :     object->p_freepointer = SgLabelRefExp::next_node;
  164823           0 :     SgLabelRefExp::next_node = object;
  164824             : #endif
  164825             : 
  164826             : #if ROSE_ALLOC_TRACE == 2
  164827             : //  printf("SgLabelRefExp::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgLabelRefExp::next_node);
  164828             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  164829             :     Rose::MemPool::snapshot(oss.str());
  164830             :     alloc_trace_cnt++;
  164831             : #endif
  164832             : 
  164833             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  164834             : 
  164835           0 :     ALLOC_MUTEX(SgLabelRefExp, unlock);
  164836             : }
  164837             : 
  164838             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  164839             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  164840             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  164841             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  164842             : // Also, note comment below from Robb (copied from the Common.code file).
  164843             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  164844             : //
  164845             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  164846             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  164847             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  164848             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  164849             : #if 0
  164850             : void SgLabelRefExp::operator delete(void* pointer) { SgLabelRefExp::operator delete (pointer, sizeof(SgLabelRefExp)); };
  164851             : #endif
  164852             : /* #line 164853 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  164853             : 
  164854             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  164855             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  164856             : // obviously imply C++.
  164857             : 
  164858             : // This implements the support within ROSE for memory pools.  Memory pools
  164859             : // support the most condensed usage of memory within the construction of
  164860             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  164861             : // by a new operator written for each class.
  164862             : 
  164863             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  164864             :     // User wants multi-thread support and POSIX threads are available.
  164865             : #   include <pthread.h>
  164866             :     static pthread_mutex_t SgActualArgumentExpression_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  164867             : #else
  164868             :      // Cause synchronization to be skipped.
  164869             : #    ifndef ALLOC_MUTEX
  164870             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  164871             : #    endif
  164872             : #    ifdef _REENTRANT
  164873             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  164874             : #       ifdef _MSC_VER
  164875             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  164876             : #       else
  164877             : #           warning "POSIX threads are not available; synchronization being skipped"
  164878             : #       endif
  164879             : #    endif
  164880             : #endif
  164881             : 
  164882             : #ifndef ROSE_ALLOC_TRACE
  164883             : #  define ROSE_ALLOC_TRACE 0
  164884             : #endif
  164885             : 
  164886             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  164887             : #define ROSE_ALLOC_TRACE_CNT
  164888             : #include "memory-pool-snapshot.h"
  164889             : unsigned long alloc_trace_cnt = 0;
  164890             : #endif
  164891             : 
  164892             : #if ROSE_ALLOC_TRACE
  164893             : const unsigned SgActualArgumentExpression::pool_size = 5;
  164894             : #else
  164895             : const unsigned SgActualArgumentExpression::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  164896             : #endif
  164897             : 
  164898             : #ifndef ROSE_ALLOC_MEMSET
  164899             : #  define ROSE_ALLOC_MEMSET 0
  164900             : #endif
  164901             : 
  164902             : #ifndef ROSE_PEDANTIC_ALLOC
  164903             : #  define ROSE_PEDANTIC_ALLOC 0
  164904             : #endif
  164905             : 
  164906             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  164907             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  164908             : #endif
  164909             : 
  164910             : #if !defined(SGNODE__ALL_POOLS)
  164911             : #define SGNODE__ALL_POOLS
  164912             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  164913             : #endif
  164914             : 
  164915             : SgActualArgumentExpression* SgActualArgumentExpression::next_node = nullptr;
  164916             : std::vector<unsigned char*> SgActualArgumentExpression::pools;
  164917             : 
  164918             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  164919             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  164920             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  164921             : // around this macro definition rather than each use).
  164922             : #ifndef ALLOC_MUTEX
  164923             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  164924             :         do {                                                                     \
  164925             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  164926             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  164927             :                 abort();                                                         \
  164928             :             }                                                                    \
  164929             :         } while (0);
  164930             : #endif
  164931             : 
  164932             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  164933             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  164934             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  164935             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  164936             : 
  164937             : /*! \brief New operator for SgActualArgumentExpression.
  164938             : 
  164939             :    This new operator implements memory pools to provide most efficent 
  164940             :    use of the heap within construction of large ASTs.
  164941             : 
  164942             : \internal The new and delete operators use the lower level C malloc/free
  164943             :    function calls for performance and to make sure that mixing of malloc/free
  164944             :    and new/delete by the used can be caught more readily.  This may change
  164945             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  164946             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  164947             :    deallocate memory allocated using ROSE_MALLOC.
  164948             : */
  164949           0 : void *SgActualArgumentExpression::operator new ( size_t Size )
  164950             : {
  164951             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  164952             :      * returning or throwing an exception. */
  164953           0 :     ALLOC_MUTEX(SgActualArgumentExpression, lock);
  164954             : 
  164955             : #if ROSE_ALLOC_TRACE == 2
  164956             : //    printf("SgActualArgumentExpression::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgActualArgumentExpression::next_node);
  164957             : #endif
  164958             : 
  164959             : #if USE_CPP_NEW_DELETE_OPERATORS
  164960             :     void *mem = ROSE_MALLOC(Size);
  164961             :     ALLOC_MUTEX(SgActualArgumentExpression, unlock);
  164962             :     return mem;
  164963             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  164964             : #if ROSE_PEDANTIC_ALLOC
  164965             :     ROSE_ASSERT(Size == sizeof(SgActualArgumentExpression));
  164966             : #else
  164967           0 :     if (Size != sizeof(SgActualArgumentExpression)) {
  164968           0 :       void * object = ROSE_MALLOC(Size);
  164969           0 :       ALLOC_MUTEX(SgActualArgumentExpression, unlock);
  164970             :       return object;
  164971             :     }
  164972             : #endif
  164973             : 
  164974           0 :     if (SgActualArgumentExpression::next_node == nullptr) {
  164975           0 :         SgActualArgumentExpression * alloc = (SgActualArgumentExpression*) ROSE_MALLOC ( SgActualArgumentExpression::pool_size * sizeof(SgActualArgumentExpression) );
  164976           0 :         ROSE_ASSERT(alloc != nullptr);
  164977             : 
  164978             : #if ROSE_ALLOC_TRACE == 2
  164979             : //        printf("SgActualArgumentExpression::alloc\n  block[%zi] = [ %p , %p [\n", SgActualArgumentExpression::pools.size(), alloc, alloc + SgActualArgumentExpression::pool_size);
  164980             : #endif
  164981             : 
  164982             : #if ROSE_ALLOC_MEMSET == 1
  164983             : #elif ROSE_ALLOC_MEMSET == 2
  164984             :         memset(alloc, 0x00, SgActualArgumentExpression::pool_size * sizeof(SgActualArgumentExpression));
  164985             : #elif ROSE_ALLOC_MEMSET == 3
  164986             :         memset(alloc, 0xAA, SgActualArgumentExpression::pool_size * sizeof(SgActualArgumentExpression));
  164987             : #endif
  164988           0 :         for (unsigned i=0; i < SgActualArgumentExpression::pool_size-1; i++) {
  164989           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
  164990             :         }
  164991           0 :         alloc[SgActualArgumentExpression::pool_size-1].p_freepointer = nullptr;
  164992             : 
  164993           0 :         SgActualArgumentExpression::pools.push_back ( (unsigned char *) alloc );
  164994           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgActualArgumentExpression::pool_size * sizeof(SgActualArgumentExpression), V_SgActualArgumentExpression ) );
  164995           0 :         SgActualArgumentExpression::next_node = alloc;
  164996             :     }
  164997           0 :     ROSE_ASSERT(SgActualArgumentExpression::next_node != nullptr);
  164998             : 
  164999           0 :     SgActualArgumentExpression * object = SgActualArgumentExpression::next_node;
  165000           0 :     SgActualArgumentExpression::next_node = (SgActualArgumentExpression*)(object->p_freepointer);
  165001             : 
  165002             : #if ROSE_ALLOC_TRACE == 2
  165003             :     printf("SgActualArgumentExpression::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgActualArgumentExpression::next_node);
  165004             : #endif
  165005             : 
  165006           0 :     SgNode * fp = object->p_freepointer;
  165007             : #if ROSE_ALLOC_MEMSET == 1
  165008             : #elif ROSE_ALLOC_MEMSET == 2
  165009             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgActualArgumentExpression) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  165010             : #elif ROSE_ALLOC_MEMSET == 3
  165011             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgActualArgumentExpression) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  165012             : #endif
  165013           0 :     object->p_freepointer = fp;
  165014             : 
  165015             : #if ROSE_ALLOC_TRACE == 2
  165016             : //    printf("SgActualArgumentExpression::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgActualArgumentExpression::next_node);
  165017             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  165018             :     Rose::MemPool::snapshot(oss.str());
  165019             :     alloc_trace_cnt++;
  165020             : #endif
  165021             : 
  165022           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  165023             : 
  165024           0 :     ALLOC_MUTEX(SgActualArgumentExpression, unlock);
  165025             : 
  165026             :     return object;
  165027             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  165028             : }
  165029             : 
  165030             : 
  165031             : 
  165032             : /*! \brief Delete operator for SgActualArgumentExpression.
  165033             : 
  165034             :    This delete operator implements deallocation using memory pools to 
  165035             :    provide most efficent use of the heap within construction of large ASTs.
  165036             : 
  165037             : \internal The new and delete operators use the lower level C malloc/free
  165038             :    function calls for performance and to make sure that mixing of malloc/free
  165039             :    and new/delete by the used can be caught more readily.  This may change
  165040             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  165041             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  165042             :    deallocate memory allocated using ROSE_MALLOC.
  165043             : */
  165044           0 : void SgActualArgumentExpression::operator delete(void *Pointer, size_t Size)
  165045             : {
  165046             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  165047             :      * or throwing an exception. */
  165048           0 :     ALLOC_MUTEX(SgActualArgumentExpression, lock);
  165049             : 
  165050             : #if USE_CPP_NEW_DELETE_OPERATORS
  165051             :     ROSE_FREE(Pointer);
  165052             : #else
  165053             : #if ROSE_PEDANTIC_ALLOC
  165054             :     ROSE_ASSERT(Size == sizeof(SgActualArgumentExpression));
  165055             : #else
  165056           0 :     if (Size != sizeof(SgActualArgumentExpression)) {
  165057           0 :       ROSE_FREE(Pointer);
  165058           0 :       ALLOC_MUTEX(SgActualArgumentExpression, unlock);
  165059             :       return;
  165060             :     }
  165061             : #endif
  165062             : 
  165063           0 :     SgActualArgumentExpression * object = (SgActualArgumentExpression*) Pointer;
  165064           0 :     ROSE_ASSERT(object != nullptr);
  165065             : 
  165066             : #if ROSE_ALLOC_TRACE == 2
  165067             : //  printf("SgActualArgumentExpression::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgActualArgumentExpression::next_node);
  165068             :     printf("SgActualArgumentExpression::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgActualArgumentExpression::next_node);
  165069             : #endif
  165070             : 
  165071             : #if ROSE_PEDANTIC_ALLOC
  165072             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  165073             : #endif
  165074             : 
  165075             : #if ROSE_ALLOC_MEMSET == 1
  165076             : #elif ROSE_ALLOC_MEMSET == 2
  165077             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgActualArgumentExpression) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  165078             : #elif ROSE_ALLOC_MEMSET == 3
  165079             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgActualArgumentExpression) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  165080             : #endif
  165081             : 
  165082             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  165083             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  165084             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  165085             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  165086             : #else
  165087           0 :     object->p_freepointer = SgActualArgumentExpression::next_node;
  165088           0 :     SgActualArgumentExpression::next_node = object;
  165089             : #endif
  165090             : 
  165091             : #if ROSE_ALLOC_TRACE == 2
  165092             : //  printf("SgActualArgumentExpression::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgActualArgumentExpression::next_node);
  165093             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  165094             :     Rose::MemPool::snapshot(oss.str());
  165095             :     alloc_trace_cnt++;
  165096             : #endif
  165097             : 
  165098             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  165099             : 
  165100           0 :     ALLOC_MUTEX(SgActualArgumentExpression, unlock);
  165101             : }
  165102             : 
  165103             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  165104             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  165105             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  165106             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  165107             : // Also, note comment below from Robb (copied from the Common.code file).
  165108             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  165109             : //
  165110             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  165111             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  165112             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  165113             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  165114             : #if 0
  165115             : void SgActualArgumentExpression::operator delete(void* pointer) { SgActualArgumentExpression::operator delete (pointer, sizeof(SgActualArgumentExpression)); };
  165116             : #endif
  165117             : /* #line 165118 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  165118             : 
  165119             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  165120             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  165121             : // obviously imply C++.
  165122             : 
  165123             : // This implements the support within ROSE for memory pools.  Memory pools
  165124             : // support the most condensed usage of memory within the construction of
  165125             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  165126             : // by a new operator written for each class.
  165127             : 
  165128             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  165129             :     // User wants multi-thread support and POSIX threads are available.
  165130             : #   include <pthread.h>
  165131             :     static pthread_mutex_t SgUnknownArrayOrFunctionReference_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  165132             : #else
  165133             :      // Cause synchronization to be skipped.
  165134             : #    ifndef ALLOC_MUTEX
  165135             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  165136             : #    endif
  165137             : #    ifdef _REENTRANT
  165138             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  165139             : #       ifdef _MSC_VER
  165140             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  165141             : #       else
  165142             : #           warning "POSIX threads are not available; synchronization being skipped"
  165143             : #       endif
  165144             : #    endif
  165145             : #endif
  165146             : 
  165147             : #ifndef ROSE_ALLOC_TRACE
  165148             : #  define ROSE_ALLOC_TRACE 0
  165149             : #endif
  165150             : 
  165151             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  165152             : #define ROSE_ALLOC_TRACE_CNT
  165153             : #include "memory-pool-snapshot.h"
  165154             : unsigned long alloc_trace_cnt = 0;
  165155             : #endif
  165156             : 
  165157             : #if ROSE_ALLOC_TRACE
  165158             : const unsigned SgUnknownArrayOrFunctionReference::pool_size = 5;
  165159             : #else
  165160             : const unsigned SgUnknownArrayOrFunctionReference::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  165161             : #endif
  165162             : 
  165163             : #ifndef ROSE_ALLOC_MEMSET
  165164             : #  define ROSE_ALLOC_MEMSET 0
  165165             : #endif
  165166             : 
  165167             : #ifndef ROSE_PEDANTIC_ALLOC
  165168             : #  define ROSE_PEDANTIC_ALLOC 0
  165169             : #endif
  165170             : 
  165171             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  165172             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  165173             : #endif
  165174             : 
  165175             : #if !defined(SGNODE__ALL_POOLS)
  165176             : #define SGNODE__ALL_POOLS
  165177             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  165178             : #endif
  165179             : 
  165180             : SgUnknownArrayOrFunctionReference* SgUnknownArrayOrFunctionReference::next_node = nullptr;
  165181             : std::vector<unsigned char*> SgUnknownArrayOrFunctionReference::pools;
  165182             : 
  165183             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  165184             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  165185             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  165186             : // around this macro definition rather than each use).
  165187             : #ifndef ALLOC_MUTEX
  165188             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  165189             :         do {                                                                     \
  165190             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  165191             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  165192             :                 abort();                                                         \
  165193             :             }                                                                    \
  165194             :         } while (0);
  165195             : #endif
  165196             : 
  165197             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  165198             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  165199             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  165200             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  165201             : 
  165202             : /*! \brief New operator for SgUnknownArrayOrFunctionReference.
  165203             : 
  165204             :    This new operator implements memory pools to provide most efficent 
  165205             :    use of the heap within construction of large ASTs.
  165206             : 
  165207             : \internal The new and delete operators use the lower level C malloc/free
  165208             :    function calls for performance and to make sure that mixing of malloc/free
  165209             :    and new/delete by the used can be caught more readily.  This may change
  165210             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  165211             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  165212             :    deallocate memory allocated using ROSE_MALLOC.
  165213             : */
  165214           0 : void *SgUnknownArrayOrFunctionReference::operator new ( size_t Size )
  165215             : {
  165216             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  165217             :      * returning or throwing an exception. */
  165218           0 :     ALLOC_MUTEX(SgUnknownArrayOrFunctionReference, lock);
  165219             : 
  165220             : #if ROSE_ALLOC_TRACE == 2
  165221             : //    printf("SgUnknownArrayOrFunctionReference::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgUnknownArrayOrFunctionReference::next_node);
  165222             : #endif
  165223             : 
  165224             : #if USE_CPP_NEW_DELETE_OPERATORS
  165225             :     void *mem = ROSE_MALLOC(Size);
  165226             :     ALLOC_MUTEX(SgUnknownArrayOrFunctionReference, unlock);
  165227             :     return mem;
  165228             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  165229             : #if ROSE_PEDANTIC_ALLOC
  165230             :     ROSE_ASSERT(Size == sizeof(SgUnknownArrayOrFunctionReference));
  165231             : #else
  165232           0 :     if (Size != sizeof(SgUnknownArrayOrFunctionReference)) {
  165233           0 :       void * object = ROSE_MALLOC(Size);
  165234           0 :       ALLOC_MUTEX(SgUnknownArrayOrFunctionReference, unlock);
  165235             :       return object;
  165236             :     }
  165237             : #endif
  165238             : 
  165239           0 :     if (SgUnknownArrayOrFunctionReference::next_node == nullptr) {
  165240           0 :         SgUnknownArrayOrFunctionReference * alloc = (SgUnknownArrayOrFunctionReference*) ROSE_MALLOC ( SgUnknownArrayOrFunctionReference::pool_size * sizeof(SgUnknownArrayOrFunctionReference) );
  165241           0 :         ROSE_ASSERT(alloc != nullptr);
  165242             : 
  165243             : #if ROSE_ALLOC_TRACE == 2
  165244             : //        printf("SgUnknownArrayOrFunctionReference::alloc\n  block[%zi] = [ %p , %p [\n", SgUnknownArrayOrFunctionReference::pools.size(), alloc, alloc + SgUnknownArrayOrFunctionReference::pool_size);
  165245             : #endif
  165246             : 
  165247             : #if ROSE_ALLOC_MEMSET == 1
  165248             : #elif ROSE_ALLOC_MEMSET == 2
  165249             :         memset(alloc, 0x00, SgUnknownArrayOrFunctionReference::pool_size * sizeof(SgUnknownArrayOrFunctionReference));
  165250             : #elif ROSE_ALLOC_MEMSET == 3
  165251             :         memset(alloc, 0xAA, SgUnknownArrayOrFunctionReference::pool_size * sizeof(SgUnknownArrayOrFunctionReference));
  165252             : #endif
  165253           0 :         for (unsigned i=0; i < SgUnknownArrayOrFunctionReference::pool_size-1; i++) {
  165254           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
  165255             :         }
  165256           0 :         alloc[SgUnknownArrayOrFunctionReference::pool_size-1].p_freepointer = nullptr;
  165257             : 
  165258           0 :         SgUnknownArrayOrFunctionReference::pools.push_back ( (unsigned char *) alloc );
  165259           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgUnknownArrayOrFunctionReference::pool_size * sizeof(SgUnknownArrayOrFunctionReference), V_SgUnknownArrayOrFunctionReference ) );
  165260           0 :         SgUnknownArrayOrFunctionReference::next_node = alloc;
  165261             :     }
  165262           0 :     ROSE_ASSERT(SgUnknownArrayOrFunctionReference::next_node != nullptr);
  165263             : 
  165264           0 :     SgUnknownArrayOrFunctionReference * object = SgUnknownArrayOrFunctionReference::next_node;
  165265           0 :     SgUnknownArrayOrFunctionReference::next_node = (SgUnknownArrayOrFunctionReference*)(object->p_freepointer);
  165266             : 
  165267             : #if ROSE_ALLOC_TRACE == 2
  165268             :     printf("SgUnknownArrayOrFunctionReference::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUnknownArrayOrFunctionReference::next_node);
  165269             : #endif
  165270             : 
  165271           0 :     SgNode * fp = object->p_freepointer;
  165272             : #if ROSE_ALLOC_MEMSET == 1
  165273             : #elif ROSE_ALLOC_MEMSET == 2
  165274             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgUnknownArrayOrFunctionReference) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  165275             : #elif ROSE_ALLOC_MEMSET == 3
  165276             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgUnknownArrayOrFunctionReference) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  165277             : #endif
  165278           0 :     object->p_freepointer = fp;
  165279             : 
  165280             : #if ROSE_ALLOC_TRACE == 2
  165281             : //    printf("SgUnknownArrayOrFunctionReference::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUnknownArrayOrFunctionReference::next_node);
  165282             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  165283             :     Rose::MemPool::snapshot(oss.str());
  165284             :     alloc_trace_cnt++;
  165285             : #endif
  165286             : 
  165287           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  165288             : 
  165289           0 :     ALLOC_MUTEX(SgUnknownArrayOrFunctionReference, unlock);
  165290             : 
  165291             :     return object;
  165292             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  165293             : }
  165294             : 
  165295             : 
  165296             : 
  165297             : /*! \brief Delete operator for SgUnknownArrayOrFunctionReference.
  165298             : 
  165299             :    This delete operator implements deallocation using memory pools to 
  165300             :    provide most efficent use of the heap within construction of large ASTs.
  165301             : 
  165302             : \internal The new and delete operators use the lower level C malloc/free
  165303             :    function calls for performance and to make sure that mixing of malloc/free
  165304             :    and new/delete by the used can be caught more readily.  This may change
  165305             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  165306             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  165307             :    deallocate memory allocated using ROSE_MALLOC.
  165308             : */
  165309           0 : void SgUnknownArrayOrFunctionReference::operator delete(void *Pointer, size_t Size)
  165310             : {
  165311             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  165312             :      * or throwing an exception. */
  165313           0 :     ALLOC_MUTEX(SgUnknownArrayOrFunctionReference, lock);
  165314             : 
  165315             : #if USE_CPP_NEW_DELETE_OPERATORS
  165316             :     ROSE_FREE(Pointer);
  165317             : #else
  165318             : #if ROSE_PEDANTIC_ALLOC
  165319             :     ROSE_ASSERT(Size == sizeof(SgUnknownArrayOrFunctionReference));
  165320             : #else
  165321           0 :     if (Size != sizeof(SgUnknownArrayOrFunctionReference)) {
  165322           0 :       ROSE_FREE(Pointer);
  165323           0 :       ALLOC_MUTEX(SgUnknownArrayOrFunctionReference, unlock);
  165324             :       return;
  165325             :     }
  165326             : #endif
  165327             : 
  165328           0 :     SgUnknownArrayOrFunctionReference * object = (SgUnknownArrayOrFunctionReference*) Pointer;
  165329           0 :     ROSE_ASSERT(object != nullptr);
  165330             : 
  165331             : #if ROSE_ALLOC_TRACE == 2
  165332             : //  printf("SgUnknownArrayOrFunctionReference::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUnknownArrayOrFunctionReference::next_node);
  165333             :     printf("SgUnknownArrayOrFunctionReference::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUnknownArrayOrFunctionReference::next_node);
  165334             : #endif
  165335             : 
  165336             : #if ROSE_PEDANTIC_ALLOC
  165337             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  165338             : #endif
  165339             : 
  165340             : #if ROSE_ALLOC_MEMSET == 1
  165341             : #elif ROSE_ALLOC_MEMSET == 2
  165342             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgUnknownArrayOrFunctionReference) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  165343             : #elif ROSE_ALLOC_MEMSET == 3
  165344             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgUnknownArrayOrFunctionReference) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  165345             : #endif
  165346             : 
  165347             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  165348             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  165349             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  165350             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  165351             : #else
  165352           0 :     object->p_freepointer = SgUnknownArrayOrFunctionReference::next_node;
  165353           0 :     SgUnknownArrayOrFunctionReference::next_node = object;
  165354             : #endif
  165355             : 
  165356             : #if ROSE_ALLOC_TRACE == 2
  165357             : //  printf("SgUnknownArrayOrFunctionReference::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgUnknownArrayOrFunctionReference::next_node);
  165358             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  165359             :     Rose::MemPool::snapshot(oss.str());
  165360             :     alloc_trace_cnt++;
  165361             : #endif
  165362             : 
  165363             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  165364             : 
  165365           0 :     ALLOC_MUTEX(SgUnknownArrayOrFunctionReference, unlock);
  165366             : }
  165367             : 
  165368             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  165369             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  165370             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  165371             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  165372             : // Also, note comment below from Robb (copied from the Common.code file).
  165373             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  165374             : //
  165375             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  165376             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  165377             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  165378             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  165379             : #if 0
  165380             : void SgUnknownArrayOrFunctionReference::operator delete(void* pointer) { SgUnknownArrayOrFunctionReference::operator delete (pointer, sizeof(SgUnknownArrayOrFunctionReference)); };
  165381             : #endif
  165382             : /* #line 165383 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  165383             : 
  165384             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  165385             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  165386             : // obviously imply C++.
  165387             : 
  165388             : // This implements the support within ROSE for memory pools.  Memory pools
  165389             : // support the most condensed usage of memory within the construction of
  165390             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  165391             : // by a new operator written for each class.
  165392             : 
  165393             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  165394             :     // User wants multi-thread support and POSIX threads are available.
  165395             : #   include <pthread.h>
  165396             :     static pthread_mutex_t SgPseudoDestructorRefExp_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  165397             : #else
  165398             :      // Cause synchronization to be skipped.
  165399             : #    ifndef ALLOC_MUTEX
  165400             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  165401             : #    endif
  165402             : #    ifdef _REENTRANT
  165403             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  165404             : #       ifdef _MSC_VER
  165405             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  165406             : #       else
  165407             : #           warning "POSIX threads are not available; synchronization being skipped"
  165408             : #       endif
  165409             : #    endif
  165410             : #endif
  165411             : 
  165412             : #ifndef ROSE_ALLOC_TRACE
  165413             : #  define ROSE_ALLOC_TRACE 0
  165414             : #endif
  165415             : 
  165416             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  165417             : #define ROSE_ALLOC_TRACE_CNT
  165418             : #include "memory-pool-snapshot.h"
  165419             : unsigned long alloc_trace_cnt = 0;
  165420             : #endif
  165421             : 
  165422             : #if ROSE_ALLOC_TRACE
  165423             : const unsigned SgPseudoDestructorRefExp::pool_size = 5;
  165424             : #else
  165425             : const unsigned SgPseudoDestructorRefExp::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  165426             : #endif
  165427             : 
  165428             : #ifndef ROSE_ALLOC_MEMSET
  165429             : #  define ROSE_ALLOC_MEMSET 0
  165430             : #endif
  165431             : 
  165432             : #ifndef ROSE_PEDANTIC_ALLOC
  165433             : #  define ROSE_PEDANTIC_ALLOC 0
  165434             : #endif
  165435             : 
  165436             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  165437             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  165438             : #endif
  165439             : 
  165440             : #if !defined(SGNODE__ALL_POOLS)
  165441             : #define SGNODE__ALL_POOLS
  165442             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  165443             : #endif
  165444             : 
  165445             : SgPseudoDestructorRefExp* SgPseudoDestructorRefExp::next_node = nullptr;
  165446             : std::vector<unsigned char*> SgPseudoDestructorRefExp::pools;
  165447             : 
  165448             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  165449             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  165450             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  165451             : // around this macro definition rather than each use).
  165452             : #ifndef ALLOC_MUTEX
  165453             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  165454             :         do {                                                                     \
  165455             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  165456             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  165457             :                 abort();                                                         \
  165458             :             }                                                                    \
  165459             :         } while (0);
  165460             : #endif
  165461             : 
  165462             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  165463             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  165464             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  165465             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  165466             : 
  165467             : /*! \brief New operator for SgPseudoDestructorRefExp.
  165468             : 
  165469             :    This new operator implements memory pools to provide most efficent 
  165470             :    use of the heap within construction of large ASTs.
  165471             : 
  165472             : \internal The new and delete operators use the lower level C malloc/free
  165473             :    function calls for performance and to make sure that mixing of malloc/free
  165474             :    and new/delete by the used can be caught more readily.  This may change
  165475             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  165476             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  165477             :    deallocate memory allocated using ROSE_MALLOC.
  165478             : */
  165479           0 : void *SgPseudoDestructorRefExp::operator new ( size_t Size )
  165480             : {
  165481             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  165482             :      * returning or throwing an exception. */
  165483           0 :     ALLOC_MUTEX(SgPseudoDestructorRefExp, lock);
  165484             : 
  165485             : #if ROSE_ALLOC_TRACE == 2
  165486             : //    printf("SgPseudoDestructorRefExp::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgPseudoDestructorRefExp::next_node);
  165487             : #endif
  165488             : 
  165489             : #if USE_CPP_NEW_DELETE_OPERATORS
  165490             :     void *mem = ROSE_MALLOC(Size);
  165491             :     ALLOC_MUTEX(SgPseudoDestructorRefExp, unlock);
  165492             :     return mem;
  165493             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  165494             : #if ROSE_PEDANTIC_ALLOC
  165495             :     ROSE_ASSERT(Size == sizeof(SgPseudoDestructorRefExp));
  165496             : #else
  165497           0 :     if (Size != sizeof(SgPseudoDestructorRefExp)) {
  165498           0 :       void * object = ROSE_MALLOC(Size);
  165499           0 :       ALLOC_MUTEX(SgPseudoDestructorRefExp, unlock);
  165500             :       return object;
  165501             :     }
  165502             : #endif
  165503             : 
  165504           0 :     if (SgPseudoDestructorRefExp::next_node == nullptr) {
  165505           0 :         SgPseudoDestructorRefExp * alloc = (SgPseudoDestructorRefExp*) ROSE_MALLOC ( SgPseudoDestructorRefExp::pool_size * sizeof(SgPseudoDestructorRefExp) );
  165506           0 :         ROSE_ASSERT(alloc != nullptr);
  165507             : 
  165508             : #if ROSE_ALLOC_TRACE == 2
  165509             : //        printf("SgPseudoDestructorRefExp::alloc\n  block[%zi] = [ %p , %p [\n", SgPseudoDestructorRefExp::pools.size(), alloc, alloc + SgPseudoDestructorRefExp::pool_size);
  165510             : #endif
  165511             : 
  165512             : #if ROSE_ALLOC_MEMSET == 1
  165513             : #elif ROSE_ALLOC_MEMSET == 2
  165514             :         memset(alloc, 0x00, SgPseudoDestructorRefExp::pool_size * sizeof(SgPseudoDestructorRefExp));
  165515             : #elif ROSE_ALLOC_MEMSET == 3
  165516             :         memset(alloc, 0xAA, SgPseudoDestructorRefExp::pool_size * sizeof(SgPseudoDestructorRefExp));
  165517             : #endif
  165518           0 :         for (unsigned i=0; i < SgPseudoDestructorRefExp::pool_size-1; i++) {
  165519           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
  165520             :         }
  165521           0 :         alloc[SgPseudoDestructorRefExp::pool_size-1].p_freepointer = nullptr;
  165522             : 
  165523           0 :         SgPseudoDestructorRefExp::pools.push_back ( (unsigned char *) alloc );
  165524           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgPseudoDestructorRefExp::pool_size * sizeof(SgPseudoDestructorRefExp), V_SgPseudoDestructorRefExp ) );
  165525           0 :         SgPseudoDestructorRefExp::next_node = alloc;
  165526             :     }
  165527           0 :     ROSE_ASSERT(SgPseudoDestructorRefExp::next_node != nullptr);
  165528             : 
  165529           0 :     SgPseudoDestructorRefExp * object = SgPseudoDestructorRefExp::next_node;
  165530           0 :     SgPseudoDestructorRefExp::next_node = (SgPseudoDestructorRefExp*)(object->p_freepointer);
  165531             : 
  165532             : #if ROSE_ALLOC_TRACE == 2
  165533             :     printf("SgPseudoDestructorRefExp::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgPseudoDestructorRefExp::next_node);
  165534             : #endif
  165535             : 
  165536           0 :     SgNode * fp = object->p_freepointer;
  165537             : #if ROSE_ALLOC_MEMSET == 1
  165538             : #elif ROSE_ALLOC_MEMSET == 2
  165539             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgPseudoDestructorRefExp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  165540             : #elif ROSE_ALLOC_MEMSET == 3
  165541             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgPseudoDestructorRefExp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  165542             : #endif
  165543           0 :     object->p_freepointer = fp;
  165544             : 
  165545             : #if ROSE_ALLOC_TRACE == 2
  165546             : //    printf("SgPseudoDestructorRefExp::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgPseudoDestructorRefExp::next_node);
  165547             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  165548             :     Rose::MemPool::snapshot(oss.str());
  165549             :     alloc_trace_cnt++;
  165550             : #endif
  165551             : 
  165552           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  165553             : 
  165554           0 :     ALLOC_MUTEX(SgPseudoDestructorRefExp, unlock);
  165555             : 
  165556             :     return object;
  165557             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  165558             : }
  165559             : 
  165560             : 
  165561             : 
  165562             : /*! \brief Delete operator for SgPseudoDestructorRefExp.
  165563             : 
  165564             :    This delete operator implements deallocation using memory pools to 
  165565             :    provide most efficent use of the heap within construction of large ASTs.
  165566             : 
  165567             : \internal The new and delete operators use the lower level C malloc/free
  165568             :    function calls for performance and to make sure that mixing of malloc/free
  165569             :    and new/delete by the used can be caught more readily.  This may change
  165570             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  165571             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  165572             :    deallocate memory allocated using ROSE_MALLOC.
  165573             : */
  165574           0 : void SgPseudoDestructorRefExp::operator delete(void *Pointer, size_t Size)
  165575             : {
  165576             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  165577             :      * or throwing an exception. */
  165578           0 :     ALLOC_MUTEX(SgPseudoDestructorRefExp, lock);
  165579             : 
  165580             : #if USE_CPP_NEW_DELETE_OPERATORS
  165581             :     ROSE_FREE(Pointer);
  165582             : #else
  165583             : #if ROSE_PEDANTIC_ALLOC
  165584             :     ROSE_ASSERT(Size == sizeof(SgPseudoDestructorRefExp));
  165585             : #else
  165586           0 :     if (Size != sizeof(SgPseudoDestructorRefExp)) {
  165587           0 :       ROSE_FREE(Pointer);
  165588           0 :       ALLOC_MUTEX(SgPseudoDestructorRefExp, unlock);
  165589             :       return;
  165590             :     }
  165591             : #endif
  165592             : 
  165593           0 :     SgPseudoDestructorRefExp * object = (SgPseudoDestructorRefExp*) Pointer;
  165594           0 :     ROSE_ASSERT(object != nullptr);
  165595             : 
  165596             : #if ROSE_ALLOC_TRACE == 2
  165597             : //  printf("SgPseudoDestructorRefExp::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgPseudoDestructorRefExp::next_node);
  165598             :     printf("SgPseudoDestructorRefExp::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgPseudoDestructorRefExp::next_node);
  165599             : #endif
  165600             : 
  165601             : #if ROSE_PEDANTIC_ALLOC
  165602             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  165603             : #endif
  165604             : 
  165605             : #if ROSE_ALLOC_MEMSET == 1
  165606             : #elif ROSE_ALLOC_MEMSET == 2
  165607             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgPseudoDestructorRefExp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  165608             : #elif ROSE_ALLOC_MEMSET == 3
  165609             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgPseudoDestructorRefExp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  165610             : #endif
  165611             : 
  165612             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  165613             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  165614             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  165615             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  165616             : #else
  165617           0 :     object->p_freepointer = SgPseudoDestructorRefExp::next_node;
  165618           0 :     SgPseudoDestructorRefExp::next_node = object;
  165619             : #endif
  165620             : 
  165621             : #if ROSE_ALLOC_TRACE == 2
  165622             : //  printf("SgPseudoDestructorRefExp::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgPseudoDestructorRefExp::next_node);
  165623             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  165624             :     Rose::MemPool::snapshot(oss.str());
  165625             :     alloc_trace_cnt++;
  165626             : #endif
  165627             : 
  165628             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  165629             : 
  165630           0 :     ALLOC_MUTEX(SgPseudoDestructorRefExp, unlock);
  165631             : }
  165632             : 
  165633             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  165634             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  165635             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  165636             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  165637             : // Also, note comment below from Robb (copied from the Common.code file).
  165638             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  165639             : //
  165640             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  165641             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  165642             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  165643             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  165644             : #if 0
  165645             : void SgPseudoDestructorRefExp::operator delete(void* pointer) { SgPseudoDestructorRefExp::operator delete (pointer, sizeof(SgPseudoDestructorRefExp)); };
  165646             : #endif
  165647             : /* #line 165648 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  165648             : 
  165649             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  165650             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  165651             : // obviously imply C++.
  165652             : 
  165653             : // This implements the support within ROSE for memory pools.  Memory pools
  165654             : // support the most condensed usage of memory within the construction of
  165655             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  165656             : // by a new operator written for each class.
  165657             : 
  165658             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  165659             :     // User wants multi-thread support and POSIX threads are available.
  165660             : #   include <pthread.h>
  165661             :     static pthread_mutex_t SgCAFCoExpression_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  165662             : #else
  165663             :      // Cause synchronization to be skipped.
  165664             : #    ifndef ALLOC_MUTEX
  165665             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  165666             : #    endif
  165667             : #    ifdef _REENTRANT
  165668             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  165669             : #       ifdef _MSC_VER
  165670             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  165671             : #       else
  165672             : #           warning "POSIX threads are not available; synchronization being skipped"
  165673             : #       endif
  165674             : #    endif
  165675             : #endif
  165676             : 
  165677             : #ifndef ROSE_ALLOC_TRACE
  165678             : #  define ROSE_ALLOC_TRACE 0
  165679             : #endif
  165680             : 
  165681             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  165682             : #define ROSE_ALLOC_TRACE_CNT
  165683             : #include "memory-pool-snapshot.h"
  165684             : unsigned long alloc_trace_cnt = 0;
  165685             : #endif
  165686             : 
  165687             : #if ROSE_ALLOC_TRACE
  165688             : const unsigned SgCAFCoExpression::pool_size = 5;
  165689             : #else
  165690             : const unsigned SgCAFCoExpression::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  165691             : #endif
  165692             : 
  165693             : #ifndef ROSE_ALLOC_MEMSET
  165694             : #  define ROSE_ALLOC_MEMSET 0
  165695             : #endif
  165696             : 
  165697             : #ifndef ROSE_PEDANTIC_ALLOC
  165698             : #  define ROSE_PEDANTIC_ALLOC 0
  165699             : #endif
  165700             : 
  165701             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  165702             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  165703             : #endif
  165704             : 
  165705             : #if !defined(SGNODE__ALL_POOLS)
  165706             : #define SGNODE__ALL_POOLS
  165707             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  165708             : #endif
  165709             : 
  165710             : SgCAFCoExpression* SgCAFCoExpression::next_node = nullptr;
  165711             : std::vector<unsigned char*> SgCAFCoExpression::pools;
  165712             : 
  165713             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  165714             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  165715             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  165716             : // around this macro definition rather than each use).
  165717             : #ifndef ALLOC_MUTEX
  165718             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  165719             :         do {                                                                     \
  165720             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  165721             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  165722             :                 abort();                                                         \
  165723             :             }                                                                    \
  165724             :         } while (0);
  165725             : #endif
  165726             : 
  165727             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  165728             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  165729             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  165730             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  165731             : 
  165732             : /*! \brief New operator for SgCAFCoExpression.
  165733             : 
  165734             :    This new operator implements memory pools to provide most efficent 
  165735             :    use of the heap within construction of large ASTs.
  165736             : 
  165737             : \internal The new and delete operators use the lower level C malloc/free
  165738             :    function calls for performance and to make sure that mixing of malloc/free
  165739             :    and new/delete by the used can be caught more readily.  This may change
  165740             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  165741             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  165742             :    deallocate memory allocated using ROSE_MALLOC.
  165743             : */
  165744           0 : void *SgCAFCoExpression::operator new ( size_t Size )
  165745             : {
  165746             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  165747             :      * returning or throwing an exception. */
  165748           0 :     ALLOC_MUTEX(SgCAFCoExpression, lock);
  165749             : 
  165750             : #if ROSE_ALLOC_TRACE == 2
  165751             : //    printf("SgCAFCoExpression::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgCAFCoExpression::next_node);
  165752             : #endif
  165753             : 
  165754             : #if USE_CPP_NEW_DELETE_OPERATORS
  165755             :     void *mem = ROSE_MALLOC(Size);
  165756             :     ALLOC_MUTEX(SgCAFCoExpression, unlock);
  165757             :     return mem;
  165758             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  165759             : #if ROSE_PEDANTIC_ALLOC
  165760             :     ROSE_ASSERT(Size == sizeof(SgCAFCoExpression));
  165761             : #else
  165762           0 :     if (Size != sizeof(SgCAFCoExpression)) {
  165763           0 :       void * object = ROSE_MALLOC(Size);
  165764           0 :       ALLOC_MUTEX(SgCAFCoExpression, unlock);
  165765             :       return object;
  165766             :     }
  165767             : #endif
  165768             : 
  165769           0 :     if (SgCAFCoExpression::next_node == nullptr) {
  165770           0 :         SgCAFCoExpression * alloc = (SgCAFCoExpression*) ROSE_MALLOC ( SgCAFCoExpression::pool_size * sizeof(SgCAFCoExpression) );
  165771           0 :         ROSE_ASSERT(alloc != nullptr);
  165772             : 
  165773             : #if ROSE_ALLOC_TRACE == 2
  165774             : //        printf("SgCAFCoExpression::alloc\n  block[%zi] = [ %p , %p [\n", SgCAFCoExpression::pools.size(), alloc, alloc + SgCAFCoExpression::pool_size);
  165775             : #endif
  165776             : 
  165777             : #if ROSE_ALLOC_MEMSET == 1
  165778             : #elif ROSE_ALLOC_MEMSET == 2
  165779             :         memset(alloc, 0x00, SgCAFCoExpression::pool_size * sizeof(SgCAFCoExpression));
  165780             : #elif ROSE_ALLOC_MEMSET == 3
  165781             :         memset(alloc, 0xAA, SgCAFCoExpression::pool_size * sizeof(SgCAFCoExpression));
  165782             : #endif
  165783           0 :         for (unsigned i=0; i < SgCAFCoExpression::pool_size-1; i++) {
  165784           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
  165785             :         }
  165786           0 :         alloc[SgCAFCoExpression::pool_size-1].p_freepointer = nullptr;
  165787             : 
  165788           0 :         SgCAFCoExpression::pools.push_back ( (unsigned char *) alloc );
  165789           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgCAFCoExpression::pool_size * sizeof(SgCAFCoExpression), V_SgCAFCoExpression ) );
  165790           0 :         SgCAFCoExpression::next_node = alloc;
  165791             :     }
  165792           0 :     ROSE_ASSERT(SgCAFCoExpression::next_node != nullptr);
  165793             : 
  165794           0 :     SgCAFCoExpression * object = SgCAFCoExpression::next_node;
  165795           0 :     SgCAFCoExpression::next_node = (SgCAFCoExpression*)(object->p_freepointer);
  165796             : 
  165797             : #if ROSE_ALLOC_TRACE == 2
  165798             :     printf("SgCAFCoExpression::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgCAFCoExpression::next_node);
  165799             : #endif
  165800             : 
  165801           0 :     SgNode * fp = object->p_freepointer;
  165802             : #if ROSE_ALLOC_MEMSET == 1
  165803             : #elif ROSE_ALLOC_MEMSET == 2
  165804             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgCAFCoExpression) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  165805             : #elif ROSE_ALLOC_MEMSET == 3
  165806             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgCAFCoExpression) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  165807             : #endif
  165808           0 :     object->p_freepointer = fp;
  165809             : 
  165810             : #if ROSE_ALLOC_TRACE == 2
  165811             : //    printf("SgCAFCoExpression::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgCAFCoExpression::next_node);
  165812             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  165813             :     Rose::MemPool::snapshot(oss.str());
  165814             :     alloc_trace_cnt++;
  165815             : #endif
  165816             : 
  165817           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  165818             : 
  165819           0 :     ALLOC_MUTEX(SgCAFCoExpression, unlock);
  165820             : 
  165821             :     return object;
  165822             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  165823             : }
  165824             : 
  165825             : 
  165826             : 
  165827             : /*! \brief Delete operator for SgCAFCoExpression.
  165828             : 
  165829             :    This delete operator implements deallocation using memory pools to 
  165830             :    provide most efficent use of the heap within construction of large ASTs.
  165831             : 
  165832             : \internal The new and delete operators use the lower level C malloc/free
  165833             :    function calls for performance and to make sure that mixing of malloc/free
  165834             :    and new/delete by the used can be caught more readily.  This may change
  165835             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  165836             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  165837             :    deallocate memory allocated using ROSE_MALLOC.
  165838             : */
  165839           0 : void SgCAFCoExpression::operator delete(void *Pointer, size_t Size)
  165840             : {
  165841             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  165842             :      * or throwing an exception. */
  165843           0 :     ALLOC_MUTEX(SgCAFCoExpression, lock);
  165844             : 
  165845             : #if USE_CPP_NEW_DELETE_OPERATORS
  165846             :     ROSE_FREE(Pointer);
  165847             : #else
  165848             : #if ROSE_PEDANTIC_ALLOC
  165849             :     ROSE_ASSERT(Size == sizeof(SgCAFCoExpression));
  165850             : #else
  165851           0 :     if (Size != sizeof(SgCAFCoExpression)) {
  165852           0 :       ROSE_FREE(Pointer);
  165853           0 :       ALLOC_MUTEX(SgCAFCoExpression, unlock);
  165854             :       return;
  165855             :     }
  165856             : #endif
  165857             : 
  165858           0 :     SgCAFCoExpression * object = (SgCAFCoExpression*) Pointer;
  165859           0 :     ROSE_ASSERT(object != nullptr);
  165860             : 
  165861             : #if ROSE_ALLOC_TRACE == 2
  165862             : //  printf("SgCAFCoExpression::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgCAFCoExpression::next_node);
  165863             :     printf("SgCAFCoExpression::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgCAFCoExpression::next_node);
  165864             : #endif
  165865             : 
  165866             : #if ROSE_PEDANTIC_ALLOC
  165867             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  165868             : #endif
  165869             : 
  165870             : #if ROSE_ALLOC_MEMSET == 1
  165871             : #elif ROSE_ALLOC_MEMSET == 2
  165872             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgCAFCoExpression) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  165873             : #elif ROSE_ALLOC_MEMSET == 3
  165874             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgCAFCoExpression) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  165875             : #endif
  165876             : 
  165877             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  165878             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  165879             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  165880             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  165881             : #else
  165882           0 :     object->p_freepointer = SgCAFCoExpression::next_node;
  165883           0 :     SgCAFCoExpression::next_node = object;
  165884             : #endif
  165885             : 
  165886             : #if ROSE_ALLOC_TRACE == 2
  165887             : //  printf("SgCAFCoExpression::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgCAFCoExpression::next_node);
  165888             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  165889             :     Rose::MemPool::snapshot(oss.str());
  165890             :     alloc_trace_cnt++;
  165891             : #endif
  165892             : 
  165893             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  165894             : 
  165895           0 :     ALLOC_MUTEX(SgCAFCoExpression, unlock);
  165896             : }
  165897             : 
  165898             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  165899             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  165900             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  165901             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  165902             : // Also, note comment below from Robb (copied from the Common.code file).
  165903             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  165904             : //
  165905             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  165906             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  165907             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  165908             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  165909             : #if 0
  165910             : void SgCAFCoExpression::operator delete(void* pointer) { SgCAFCoExpression::operator delete (pointer, sizeof(SgCAFCoExpression)); };
  165911             : #endif
  165912             : /* #line 165913 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  165913             : 
  165914             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  165915             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  165916             : // obviously imply C++.
  165917             : 
  165918             : // This implements the support within ROSE for memory pools.  Memory pools
  165919             : // support the most condensed usage of memory within the construction of
  165920             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  165921             : // by a new operator written for each class.
  165922             : 
  165923             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  165924             :     // User wants multi-thread support and POSIX threads are available.
  165925             : #   include <pthread.h>
  165926             :     static pthread_mutex_t SgCudaKernelExecConfig_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  165927             : #else
  165928             :      // Cause synchronization to be skipped.
  165929             : #    ifndef ALLOC_MUTEX
  165930             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  165931             : #    endif
  165932             : #    ifdef _REENTRANT
  165933             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  165934             : #       ifdef _MSC_VER
  165935             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  165936             : #       else
  165937             : #           warning "POSIX threads are not available; synchronization being skipped"
  165938             : #       endif
  165939             : #    endif
  165940             : #endif
  165941             : 
  165942             : #ifndef ROSE_ALLOC_TRACE
  165943             : #  define ROSE_ALLOC_TRACE 0
  165944             : #endif
  165945             : 
  165946             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  165947             : #define ROSE_ALLOC_TRACE_CNT
  165948             : #include "memory-pool-snapshot.h"
  165949             : unsigned long alloc_trace_cnt = 0;
  165950             : #endif
  165951             : 
  165952             : #if ROSE_ALLOC_TRACE
  165953             : const unsigned SgCudaKernelExecConfig::pool_size = 5;
  165954             : #else
  165955             : const unsigned SgCudaKernelExecConfig::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  165956             : #endif
  165957             : 
  165958             : #ifndef ROSE_ALLOC_MEMSET
  165959             : #  define ROSE_ALLOC_MEMSET 0
  165960             : #endif
  165961             : 
  165962             : #ifndef ROSE_PEDANTIC_ALLOC
  165963             : #  define ROSE_PEDANTIC_ALLOC 0
  165964             : #endif
  165965             : 
  165966             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  165967             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  165968             : #endif
  165969             : 
  165970             : #if !defined(SGNODE__ALL_POOLS)
  165971             : #define SGNODE__ALL_POOLS
  165972             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  165973             : #endif
  165974             : 
  165975             : SgCudaKernelExecConfig* SgCudaKernelExecConfig::next_node = nullptr;
  165976             : std::vector<unsigned char*> SgCudaKernelExecConfig::pools;
  165977             : 
  165978             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  165979             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  165980             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  165981             : // around this macro definition rather than each use).
  165982             : #ifndef ALLOC_MUTEX
  165983             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  165984             :         do {                                                                     \
  165985             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  165986             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  165987             :                 abort();                                                         \
  165988             :             }                                                                    \
  165989             :         } while (0);
  165990             : #endif
  165991             : 
  165992             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  165993             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  165994             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  165995             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  165996             : 
  165997             : /*! \brief New operator for SgCudaKernelExecConfig.
  165998             : 
  165999             :    This new operator implements memory pools to provide most efficent 
  166000             :    use of the heap within construction of large ASTs.
  166001             : 
  166002             : \internal The new and delete operators use the lower level C malloc/free
  166003             :    function calls for performance and to make sure that mixing of malloc/free
  166004             :    and new/delete by the used can be caught more readily.  This may change
  166005             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  166006             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  166007             :    deallocate memory allocated using ROSE_MALLOC.
  166008             : */
  166009           0 : void *SgCudaKernelExecConfig::operator new ( size_t Size )
  166010             : {
  166011             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  166012             :      * returning or throwing an exception. */
  166013           0 :     ALLOC_MUTEX(SgCudaKernelExecConfig, lock);
  166014             : 
  166015             : #if ROSE_ALLOC_TRACE == 2
  166016             : //    printf("SgCudaKernelExecConfig::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgCudaKernelExecConfig::next_node);
  166017             : #endif
  166018             : 
  166019             : #if USE_CPP_NEW_DELETE_OPERATORS
  166020             :     void *mem = ROSE_MALLOC(Size);
  166021             :     ALLOC_MUTEX(SgCudaKernelExecConfig, unlock);
  166022             :     return mem;
  166023             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  166024             : #if ROSE_PEDANTIC_ALLOC
  166025             :     ROSE_ASSERT(Size == sizeof(SgCudaKernelExecConfig));
  166026             : #else
  166027           0 :     if (Size != sizeof(SgCudaKernelExecConfig)) {
  166028           0 :       void * object = ROSE_MALLOC(Size);
  166029           0 :       ALLOC_MUTEX(SgCudaKernelExecConfig, unlock);
  166030             :       return object;
  166031             :     }
  166032             : #endif
  166033             : 
  166034           0 :     if (SgCudaKernelExecConfig::next_node == nullptr) {
  166035           0 :         SgCudaKernelExecConfig * alloc = (SgCudaKernelExecConfig*) ROSE_MALLOC ( SgCudaKernelExecConfig::pool_size * sizeof(SgCudaKernelExecConfig) );
  166036           0 :         ROSE_ASSERT(alloc != nullptr);
  166037             : 
  166038             : #if ROSE_ALLOC_TRACE == 2
  166039             : //        printf("SgCudaKernelExecConfig::alloc\n  block[%zi] = [ %p , %p [\n", SgCudaKernelExecConfig::pools.size(), alloc, alloc + SgCudaKernelExecConfig::pool_size);
  166040             : #endif
  166041             : 
  166042             : #if ROSE_ALLOC_MEMSET == 1
  166043             : #elif ROSE_ALLOC_MEMSET == 2
  166044             :         memset(alloc, 0x00, SgCudaKernelExecConfig::pool_size * sizeof(SgCudaKernelExecConfig));
  166045             : #elif ROSE_ALLOC_MEMSET == 3
  166046             :         memset(alloc, 0xAA, SgCudaKernelExecConfig::pool_size * sizeof(SgCudaKernelExecConfig));
  166047             : #endif
  166048           0 :         for (unsigned i=0; i < SgCudaKernelExecConfig::pool_size-1; i++) {
  166049           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
  166050             :         }
  166051           0 :         alloc[SgCudaKernelExecConfig::pool_size-1].p_freepointer = nullptr;
  166052             : 
  166053           0 :         SgCudaKernelExecConfig::pools.push_back ( (unsigned char *) alloc );
  166054           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgCudaKernelExecConfig::pool_size * sizeof(SgCudaKernelExecConfig), V_SgCudaKernelExecConfig ) );
  166055           0 :         SgCudaKernelExecConfig::next_node = alloc;
  166056             :     }
  166057           0 :     ROSE_ASSERT(SgCudaKernelExecConfig::next_node != nullptr);
  166058             : 
  166059           0 :     SgCudaKernelExecConfig * object = SgCudaKernelExecConfig::next_node;
  166060           0 :     SgCudaKernelExecConfig::next_node = (SgCudaKernelExecConfig*)(object->p_freepointer);
  166061             : 
  166062             : #if ROSE_ALLOC_TRACE == 2
  166063             :     printf("SgCudaKernelExecConfig::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgCudaKernelExecConfig::next_node);
  166064             : #endif
  166065             : 
  166066           0 :     SgNode * fp = object->p_freepointer;
  166067             : #if ROSE_ALLOC_MEMSET == 1
  166068             : #elif ROSE_ALLOC_MEMSET == 2
  166069             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgCudaKernelExecConfig) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  166070             : #elif ROSE_ALLOC_MEMSET == 3
  166071             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgCudaKernelExecConfig) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  166072             : #endif
  166073           0 :     object->p_freepointer = fp;
  166074             : 
  166075             : #if ROSE_ALLOC_TRACE == 2
  166076             : //    printf("SgCudaKernelExecConfig::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgCudaKernelExecConfig::next_node);
  166077             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  166078             :     Rose::MemPool::snapshot(oss.str());
  166079             :     alloc_trace_cnt++;
  166080             : #endif
  166081             : 
  166082           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  166083             : 
  166084           0 :     ALLOC_MUTEX(SgCudaKernelExecConfig, unlock);
  166085             : 
  166086             :     return object;
  166087             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  166088             : }
  166089             : 
  166090             : 
  166091             : 
  166092             : /*! \brief Delete operator for SgCudaKernelExecConfig.
  166093             : 
  166094             :    This delete operator implements deallocation using memory pools to 
  166095             :    provide most efficent use of the heap within construction of large ASTs.
  166096             : 
  166097             : \internal The new and delete operators use the lower level C malloc/free
  166098             :    function calls for performance and to make sure that mixing of malloc/free
  166099             :    and new/delete by the used can be caught more readily.  This may change
  166100             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  166101             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  166102             :    deallocate memory allocated using ROSE_MALLOC.
  166103             : */
  166104           0 : void SgCudaKernelExecConfig::operator delete(void *Pointer, size_t Size)
  166105             : {
  166106             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  166107             :      * or throwing an exception. */
  166108           0 :     ALLOC_MUTEX(SgCudaKernelExecConfig, lock);
  166109             : 
  166110             : #if USE_CPP_NEW_DELETE_OPERATORS
  166111             :     ROSE_FREE(Pointer);
  166112             : #else
  166113             : #if ROSE_PEDANTIC_ALLOC
  166114             :     ROSE_ASSERT(Size == sizeof(SgCudaKernelExecConfig));
  166115             : #else
  166116           0 :     if (Size != sizeof(SgCudaKernelExecConfig)) {
  166117           0 :       ROSE_FREE(Pointer);
  166118           0 :       ALLOC_MUTEX(SgCudaKernelExecConfig, unlock);
  166119             :       return;
  166120             :     }
  166121             : #endif
  166122             : 
  166123           0 :     SgCudaKernelExecConfig * object = (SgCudaKernelExecConfig*) Pointer;
  166124           0 :     ROSE_ASSERT(object != nullptr);
  166125             : 
  166126             : #if ROSE_ALLOC_TRACE == 2
  166127             : //  printf("SgCudaKernelExecConfig::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgCudaKernelExecConfig::next_node);
  166128             :     printf("SgCudaKernelExecConfig::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgCudaKernelExecConfig::next_node);
  166129             : #endif
  166130             : 
  166131             : #if ROSE_PEDANTIC_ALLOC
  166132             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  166133             : #endif
  166134             : 
  166135             : #if ROSE_ALLOC_MEMSET == 1
  166136             : #elif ROSE_ALLOC_MEMSET == 2
  166137             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgCudaKernelExecConfig) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  166138             : #elif ROSE_ALLOC_MEMSET == 3
  166139             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgCudaKernelExecConfig) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  166140             : #endif
  166141             : 
  166142             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  166143             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  166144             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  166145             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  166146             : #else
  166147           0 :     object->p_freepointer = SgCudaKernelExecConfig::next_node;
  166148           0 :     SgCudaKernelExecConfig::next_node = object;
  166149             : #endif
  166150             : 
  166151             : #if ROSE_ALLOC_TRACE == 2
  166152             : //  printf("SgCudaKernelExecConfig::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgCudaKernelExecConfig::next_node);
  166153             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  166154             :     Rose::MemPool::snapshot(oss.str());
  166155             :     alloc_trace_cnt++;
  166156             : #endif
  166157             : 
  166158             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  166159             : 
  166160           0 :     ALLOC_MUTEX(SgCudaKernelExecConfig, unlock);
  166161             : }
  166162             : 
  166163             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  166164             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  166165             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  166166             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  166167             : // Also, note comment below from Robb (copied from the Common.code file).
  166168             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  166169             : //
  166170             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  166171             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  166172             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  166173             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  166174             : #if 0
  166175             : void SgCudaKernelExecConfig::operator delete(void* pointer) { SgCudaKernelExecConfig::operator delete (pointer, sizeof(SgCudaKernelExecConfig)); };
  166176             : #endif
  166177             : /* #line 166178 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  166178             : 
  166179             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  166180             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  166181             : // obviously imply C++.
  166182             : 
  166183             : // This implements the support within ROSE for memory pools.  Memory pools
  166184             : // support the most condensed usage of memory within the construction of
  166185             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  166186             : // by a new operator written for each class.
  166187             : 
  166188             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  166189             :     // User wants multi-thread support and POSIX threads are available.
  166190             : #   include <pthread.h>
  166191             :     static pthread_mutex_t SgLambdaRefExp_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  166192             : #else
  166193             :      // Cause synchronization to be skipped.
  166194             : #    ifndef ALLOC_MUTEX
  166195             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  166196             : #    endif
  166197             : #    ifdef _REENTRANT
  166198             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  166199             : #       ifdef _MSC_VER
  166200             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  166201             : #       else
  166202             : #           warning "POSIX threads are not available; synchronization being skipped"
  166203             : #       endif
  166204             : #    endif
  166205             : #endif
  166206             : 
  166207             : #ifndef ROSE_ALLOC_TRACE
  166208             : #  define ROSE_ALLOC_TRACE 0
  166209             : #endif
  166210             : 
  166211             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  166212             : #define ROSE_ALLOC_TRACE_CNT
  166213             : #include "memory-pool-snapshot.h"
  166214             : unsigned long alloc_trace_cnt = 0;
  166215             : #endif
  166216             : 
  166217             : #if ROSE_ALLOC_TRACE
  166218             : const unsigned SgLambdaRefExp::pool_size = 5;
  166219             : #else
  166220             : const unsigned SgLambdaRefExp::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  166221             : #endif
  166222             : 
  166223             : #ifndef ROSE_ALLOC_MEMSET
  166224             : #  define ROSE_ALLOC_MEMSET 0
  166225             : #endif
  166226             : 
  166227             : #ifndef ROSE_PEDANTIC_ALLOC
  166228             : #  define ROSE_PEDANTIC_ALLOC 0
  166229             : #endif
  166230             : 
  166231             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  166232             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  166233             : #endif
  166234             : 
  166235             : #if !defined(SGNODE__ALL_POOLS)
  166236             : #define SGNODE__ALL_POOLS
  166237             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  166238             : #endif
  166239             : 
  166240             : SgLambdaRefExp* SgLambdaRefExp::next_node = nullptr;
  166241             : std::vector<unsigned char*> SgLambdaRefExp::pools;
  166242             : 
  166243             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  166244             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  166245             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  166246             : // around this macro definition rather than each use).
  166247             : #ifndef ALLOC_MUTEX
  166248             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  166249             :         do {                                                                     \
  166250             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  166251             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  166252             :                 abort();                                                         \
  166253             :             }                                                                    \
  166254             :         } while (0);
  166255             : #endif
  166256             : 
  166257             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  166258             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  166259             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  166260             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  166261             : 
  166262             : /*! \brief New operator for SgLambdaRefExp.
  166263             : 
  166264             :    This new operator implements memory pools to provide most efficent 
  166265             :    use of the heap within construction of large ASTs.
  166266             : 
  166267             : \internal The new and delete operators use the lower level C malloc/free
  166268             :    function calls for performance and to make sure that mixing of malloc/free
  166269             :    and new/delete by the used can be caught more readily.  This may change
  166270             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  166271             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  166272             :    deallocate memory allocated using ROSE_MALLOC.
  166273             : */
  166274           0 : void *SgLambdaRefExp::operator new ( size_t Size )
  166275             : {
  166276             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  166277             :      * returning or throwing an exception. */
  166278           0 :     ALLOC_MUTEX(SgLambdaRefExp, lock);
  166279             : 
  166280             : #if ROSE_ALLOC_TRACE == 2
  166281             : //    printf("SgLambdaRefExp::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgLambdaRefExp::next_node);
  166282             : #endif
  166283             : 
  166284             : #if USE_CPP_NEW_DELETE_OPERATORS
  166285             :     void *mem = ROSE_MALLOC(Size);
  166286             :     ALLOC_MUTEX(SgLambdaRefExp, unlock);
  166287             :     return mem;
  166288             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  166289             : #if ROSE_PEDANTIC_ALLOC
  166290             :     ROSE_ASSERT(Size == sizeof(SgLambdaRefExp));
  166291             : #else
  166292           0 :     if (Size != sizeof(SgLambdaRefExp)) {
  166293           0 :       void * object = ROSE_MALLOC(Size);
  166294           0 :       ALLOC_MUTEX(SgLambdaRefExp, unlock);
  166295             :       return object;
  166296             :     }
  166297             : #endif
  166298             : 
  166299           0 :     if (SgLambdaRefExp::next_node == nullptr) {
  166300           0 :         SgLambdaRefExp * alloc = (SgLambdaRefExp*) ROSE_MALLOC ( SgLambdaRefExp::pool_size * sizeof(SgLambdaRefExp) );
  166301           0 :         ROSE_ASSERT(alloc != nullptr);
  166302             : 
  166303             : #if ROSE_ALLOC_TRACE == 2
  166304             : //        printf("SgLambdaRefExp::alloc\n  block[%zi] = [ %p , %p [\n", SgLambdaRefExp::pools.size(), alloc, alloc + SgLambdaRefExp::pool_size);
  166305             : #endif
  166306             : 
  166307             : #if ROSE_ALLOC_MEMSET == 1
  166308             : #elif ROSE_ALLOC_MEMSET == 2
  166309             :         memset(alloc, 0x00, SgLambdaRefExp::pool_size * sizeof(SgLambdaRefExp));
  166310             : #elif ROSE_ALLOC_MEMSET == 3
  166311             :         memset(alloc, 0xAA, SgLambdaRefExp::pool_size * sizeof(SgLambdaRefExp));
  166312             : #endif
  166313           0 :         for (unsigned i=0; i < SgLambdaRefExp::pool_size-1; i++) {
  166314           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
  166315             :         }
  166316           0 :         alloc[SgLambdaRefExp::pool_size-1].p_freepointer = nullptr;
  166317             : 
  166318           0 :         SgLambdaRefExp::pools.push_back ( (unsigned char *) alloc );
  166319           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgLambdaRefExp::pool_size * sizeof(SgLambdaRefExp), V_SgLambdaRefExp ) );
  166320           0 :         SgLambdaRefExp::next_node = alloc;
  166321             :     }
  166322           0 :     ROSE_ASSERT(SgLambdaRefExp::next_node != nullptr);
  166323             : 
  166324           0 :     SgLambdaRefExp * object = SgLambdaRefExp::next_node;
  166325           0 :     SgLambdaRefExp::next_node = (SgLambdaRefExp*)(object->p_freepointer);
  166326             : 
  166327             : #if ROSE_ALLOC_TRACE == 2
  166328             :     printf("SgLambdaRefExp::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgLambdaRefExp::next_node);
  166329             : #endif
  166330             : 
  166331           0 :     SgNode * fp = object->p_freepointer;
  166332             : #if ROSE_ALLOC_MEMSET == 1
  166333             : #elif ROSE_ALLOC_MEMSET == 2
  166334             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgLambdaRefExp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  166335             : #elif ROSE_ALLOC_MEMSET == 3
  166336             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgLambdaRefExp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  166337             : #endif
  166338           0 :     object->p_freepointer = fp;
  166339             : 
  166340             : #if ROSE_ALLOC_TRACE == 2
  166341             : //    printf("SgLambdaRefExp::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgLambdaRefExp::next_node);
  166342             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  166343             :     Rose::MemPool::snapshot(oss.str());
  166344             :     alloc_trace_cnt++;
  166345             : #endif
  166346             : 
  166347           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  166348             : 
  166349           0 :     ALLOC_MUTEX(SgLambdaRefExp, unlock);
  166350             : 
  166351             :     return object;
  166352             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  166353             : }
  166354             : 
  166355             : 
  166356             : 
  166357             : /*! \brief Delete operator for SgLambdaRefExp.
  166358             : 
  166359             :    This delete operator implements deallocation using memory pools to 
  166360             :    provide most efficent use of the heap within construction of large ASTs.
  166361             : 
  166362             : \internal The new and delete operators use the lower level C malloc/free
  166363             :    function calls for performance and to make sure that mixing of malloc/free
  166364             :    and new/delete by the used can be caught more readily.  This may change
  166365             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  166366             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  166367             :    deallocate memory allocated using ROSE_MALLOC.
  166368             : */
  166369           0 : void SgLambdaRefExp::operator delete(void *Pointer, size_t Size)
  166370             : {
  166371             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  166372             :      * or throwing an exception. */
  166373           0 :     ALLOC_MUTEX(SgLambdaRefExp, lock);
  166374             : 
  166375             : #if USE_CPP_NEW_DELETE_OPERATORS
  166376             :     ROSE_FREE(Pointer);
  166377             : #else
  166378             : #if ROSE_PEDANTIC_ALLOC
  166379             :     ROSE_ASSERT(Size == sizeof(SgLambdaRefExp));
  166380             : #else
  166381           0 :     if (Size != sizeof(SgLambdaRefExp)) {
  166382           0 :       ROSE_FREE(Pointer);
  166383           0 :       ALLOC_MUTEX(SgLambdaRefExp, unlock);
  166384             :       return;
  166385             :     }
  166386             : #endif
  166387             : 
  166388           0 :     SgLambdaRefExp * object = (SgLambdaRefExp*) Pointer;
  166389           0 :     ROSE_ASSERT(object != nullptr);
  166390             : 
  166391             : #if ROSE_ALLOC_TRACE == 2
  166392             : //  printf("SgLambdaRefExp::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgLambdaRefExp::next_node);
  166393             :     printf("SgLambdaRefExp::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgLambdaRefExp::next_node);
  166394             : #endif
  166395             : 
  166396             : #if ROSE_PEDANTIC_ALLOC
  166397             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  166398             : #endif
  166399             : 
  166400             : #if ROSE_ALLOC_MEMSET == 1
  166401             : #elif ROSE_ALLOC_MEMSET == 2
  166402             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgLambdaRefExp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  166403             : #elif ROSE_ALLOC_MEMSET == 3
  166404             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgLambdaRefExp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  166405             : #endif
  166406             : 
  166407             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  166408             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  166409             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  166410             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  166411             : #else
  166412           0 :     object->p_freepointer = SgLambdaRefExp::next_node;
  166413           0 :     SgLambdaRefExp::next_node = object;
  166414             : #endif
  166415             : 
  166416             : #if ROSE_ALLOC_TRACE == 2
  166417             : //  printf("SgLambdaRefExp::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgLambdaRefExp::next_node);
  166418             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  166419             :     Rose::MemPool::snapshot(oss.str());
  166420             :     alloc_trace_cnt++;
  166421             : #endif
  166422             : 
  166423             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  166424             : 
  166425           0 :     ALLOC_MUTEX(SgLambdaRefExp, unlock);
  166426             : }
  166427             : 
  166428             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  166429             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  166430             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  166431             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  166432             : // Also, note comment below from Robb (copied from the Common.code file).
  166433             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  166434             : //
  166435             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  166436             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  166437             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  166438             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  166439             : #if 0
  166440             : void SgLambdaRefExp::operator delete(void* pointer) { SgLambdaRefExp::operator delete (pointer, sizeof(SgLambdaRefExp)); };
  166441             : #endif
  166442             : /* #line 166443 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  166443             : 
  166444             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  166445             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  166446             : // obviously imply C++.
  166447             : 
  166448             : // This implements the support within ROSE for memory pools.  Memory pools
  166449             : // support the most condensed usage of memory within the construction of
  166450             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  166451             : // by a new operator written for each class.
  166452             : 
  166453             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  166454             :     // User wants multi-thread support and POSIX threads are available.
  166455             : #   include <pthread.h>
  166456             :     static pthread_mutex_t SgDictionaryExp_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  166457             : #else
  166458             :      // Cause synchronization to be skipped.
  166459             : #    ifndef ALLOC_MUTEX
  166460             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  166461             : #    endif
  166462             : #    ifdef _REENTRANT
  166463             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  166464             : #       ifdef _MSC_VER
  166465             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  166466             : #       else
  166467             : #           warning "POSIX threads are not available; synchronization being skipped"
  166468             : #       endif
  166469             : #    endif
  166470             : #endif
  166471             : 
  166472             : #ifndef ROSE_ALLOC_TRACE
  166473             : #  define ROSE_ALLOC_TRACE 0
  166474             : #endif
  166475             : 
  166476             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  166477             : #define ROSE_ALLOC_TRACE_CNT
  166478             : #include "memory-pool-snapshot.h"
  166479             : unsigned long alloc_trace_cnt = 0;
  166480             : #endif
  166481             : 
  166482             : #if ROSE_ALLOC_TRACE
  166483             : const unsigned SgDictionaryExp::pool_size = 5;
  166484             : #else
  166485             : const unsigned SgDictionaryExp::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  166486             : #endif
  166487             : 
  166488             : #ifndef ROSE_ALLOC_MEMSET
  166489             : #  define ROSE_ALLOC_MEMSET 0
  166490             : #endif
  166491             : 
  166492             : #ifndef ROSE_PEDANTIC_ALLOC
  166493             : #  define ROSE_PEDANTIC_ALLOC 0
  166494             : #endif
  166495             : 
  166496             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  166497             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  166498             : #endif
  166499             : 
  166500             : #if !defined(SGNODE__ALL_POOLS)
  166501             : #define SGNODE__ALL_POOLS
  166502             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  166503             : #endif
  166504             : 
  166505             : SgDictionaryExp* SgDictionaryExp::next_node = nullptr;
  166506             : std::vector<unsigned char*> SgDictionaryExp::pools;
  166507             : 
  166508             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  166509             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  166510             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  166511             : // around this macro definition rather than each use).
  166512             : #ifndef ALLOC_MUTEX
  166513             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  166514             :         do {                                                                     \
  166515             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  166516             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  166517             :                 abort();                                                         \
  166518             :             }                                                                    \
  166519             :         } while (0);
  166520             : #endif
  166521             : 
  166522             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  166523             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  166524             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  166525             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  166526             : 
  166527             : /*! \brief New operator for SgDictionaryExp.
  166528             : 
  166529             :    This new operator implements memory pools to provide most efficent 
  166530             :    use of the heap within construction of large ASTs.
  166531             : 
  166532             : \internal The new and delete operators use the lower level C malloc/free
  166533             :    function calls for performance and to make sure that mixing of malloc/free
  166534             :    and new/delete by the used can be caught more readily.  This may change
  166535             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  166536             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  166537             :    deallocate memory allocated using ROSE_MALLOC.
  166538             : */
  166539           0 : void *SgDictionaryExp::operator new ( size_t Size )
  166540             : {
  166541             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  166542             :      * returning or throwing an exception. */
  166543           0 :     ALLOC_MUTEX(SgDictionaryExp, lock);
  166544             : 
  166545             : #if ROSE_ALLOC_TRACE == 2
  166546             : //    printf("SgDictionaryExp::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgDictionaryExp::next_node);
  166547             : #endif
  166548             : 
  166549             : #if USE_CPP_NEW_DELETE_OPERATORS
  166550             :     void *mem = ROSE_MALLOC(Size);
  166551             :     ALLOC_MUTEX(SgDictionaryExp, unlock);
  166552             :     return mem;
  166553             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  166554             : #if ROSE_PEDANTIC_ALLOC
  166555             :     ROSE_ASSERT(Size == sizeof(SgDictionaryExp));
  166556             : #else
  166557           0 :     if (Size != sizeof(SgDictionaryExp)) {
  166558           0 :       void * object = ROSE_MALLOC(Size);
  166559           0 :       ALLOC_MUTEX(SgDictionaryExp, unlock);
  166560             :       return object;
  166561             :     }
  166562             : #endif
  166563             : 
  166564           0 :     if (SgDictionaryExp::next_node == nullptr) {
  166565           0 :         SgDictionaryExp * alloc = (SgDictionaryExp*) ROSE_MALLOC ( SgDictionaryExp::pool_size * sizeof(SgDictionaryExp) );
  166566           0 :         ROSE_ASSERT(alloc != nullptr);
  166567             : 
  166568             : #if ROSE_ALLOC_TRACE == 2
  166569             : //        printf("SgDictionaryExp::alloc\n  block[%zi] = [ %p , %p [\n", SgDictionaryExp::pools.size(), alloc, alloc + SgDictionaryExp::pool_size);
  166570             : #endif
  166571             : 
  166572             : #if ROSE_ALLOC_MEMSET == 1
  166573             : #elif ROSE_ALLOC_MEMSET == 2
  166574             :         memset(alloc, 0x00, SgDictionaryExp::pool_size * sizeof(SgDictionaryExp));
  166575             : #elif ROSE_ALLOC_MEMSET == 3
  166576             :         memset(alloc, 0xAA, SgDictionaryExp::pool_size * sizeof(SgDictionaryExp));
  166577             : #endif
  166578           0 :         for (unsigned i=0; i < SgDictionaryExp::pool_size-1; i++) {
  166579           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
  166580             :         }
  166581           0 :         alloc[SgDictionaryExp::pool_size-1].p_freepointer = nullptr;
  166582             : 
  166583           0 :         SgDictionaryExp::pools.push_back ( (unsigned char *) alloc );
  166584           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgDictionaryExp::pool_size * sizeof(SgDictionaryExp), V_SgDictionaryExp ) );
  166585           0 :         SgDictionaryExp::next_node = alloc;
  166586             :     }
  166587           0 :     ROSE_ASSERT(SgDictionaryExp::next_node != nullptr);
  166588             : 
  166589           0 :     SgDictionaryExp * object = SgDictionaryExp::next_node;
  166590           0 :     SgDictionaryExp::next_node = (SgDictionaryExp*)(object->p_freepointer);
  166591             : 
  166592             : #if ROSE_ALLOC_TRACE == 2
  166593             :     printf("SgDictionaryExp::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgDictionaryExp::next_node);
  166594             : #endif
  166595             : 
  166596           0 :     SgNode * fp = object->p_freepointer;
  166597             : #if ROSE_ALLOC_MEMSET == 1
  166598             : #elif ROSE_ALLOC_MEMSET == 2
  166599             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgDictionaryExp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  166600             : #elif ROSE_ALLOC_MEMSET == 3
  166601             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgDictionaryExp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  166602             : #endif
  166603           0 :     object->p_freepointer = fp;
  166604             : 
  166605             : #if ROSE_ALLOC_TRACE == 2
  166606             : //    printf("SgDictionaryExp::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgDictionaryExp::next_node);
  166607             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  166608             :     Rose::MemPool::snapshot(oss.str());
  166609             :     alloc_trace_cnt++;
  166610             : #endif
  166611             : 
  166612           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  166613             : 
  166614           0 :     ALLOC_MUTEX(SgDictionaryExp, unlock);
  166615             : 
  166616             :     return object;
  166617             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  166618             : }
  166619             : 
  166620             : 
  166621             : 
  166622             : /*! \brief Delete operator for SgDictionaryExp.
  166623             : 
  166624             :    This delete operator implements deallocation using memory pools to 
  166625             :    provide most efficent use of the heap within construction of large ASTs.
  166626             : 
  166627             : \internal The new and delete operators use the lower level C malloc/free
  166628             :    function calls for performance and to make sure that mixing of malloc/free
  166629             :    and new/delete by the used can be caught more readily.  This may change
  166630             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  166631             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  166632             :    deallocate memory allocated using ROSE_MALLOC.
  166633             : */
  166634           0 : void SgDictionaryExp::operator delete(void *Pointer, size_t Size)
  166635             : {
  166636             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  166637             :      * or throwing an exception. */
  166638           0 :     ALLOC_MUTEX(SgDictionaryExp, lock);
  166639             : 
  166640             : #if USE_CPP_NEW_DELETE_OPERATORS
  166641             :     ROSE_FREE(Pointer);
  166642             : #else
  166643             : #if ROSE_PEDANTIC_ALLOC
  166644             :     ROSE_ASSERT(Size == sizeof(SgDictionaryExp));
  166645             : #else
  166646           0 :     if (Size != sizeof(SgDictionaryExp)) {
  166647           0 :       ROSE_FREE(Pointer);
  166648           0 :       ALLOC_MUTEX(SgDictionaryExp, unlock);
  166649             :       return;
  166650             :     }
  166651             : #endif
  166652             : 
  166653           0 :     SgDictionaryExp * object = (SgDictionaryExp*) Pointer;
  166654           0 :     ROSE_ASSERT(object != nullptr);
  166655             : 
  166656             : #if ROSE_ALLOC_TRACE == 2
  166657             : //  printf("SgDictionaryExp::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgDictionaryExp::next_node);
  166658             :     printf("SgDictionaryExp::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgDictionaryExp::next_node);
  166659             : #endif
  166660             : 
  166661             : #if ROSE_PEDANTIC_ALLOC
  166662             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  166663             : #endif
  166664             : 
  166665             : #if ROSE_ALLOC_MEMSET == 1
  166666             : #elif ROSE_ALLOC_MEMSET == 2
  166667             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgDictionaryExp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  166668             : #elif ROSE_ALLOC_MEMSET == 3
  166669             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgDictionaryExp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  166670             : #endif
  166671             : 
  166672             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  166673             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  166674             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  166675             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  166676             : #else
  166677           0 :     object->p_freepointer = SgDictionaryExp::next_node;
  166678           0 :     SgDictionaryExp::next_node = object;
  166679             : #endif
  166680             : 
  166681             : #if ROSE_ALLOC_TRACE == 2
  166682             : //  printf("SgDictionaryExp::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgDictionaryExp::next_node);
  166683             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  166684             :     Rose::MemPool::snapshot(oss.str());
  166685             :     alloc_trace_cnt++;
  166686             : #endif
  166687             : 
  166688             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  166689             : 
  166690           0 :     ALLOC_MUTEX(SgDictionaryExp, unlock);
  166691             : }
  166692             : 
  166693             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  166694             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  166695             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  166696             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  166697             : // Also, note comment below from Robb (copied from the Common.code file).
  166698             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  166699             : //
  166700             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  166701             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  166702             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  166703             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  166704             : #if 0
  166705             : void SgDictionaryExp::operator delete(void* pointer) { SgDictionaryExp::operator delete (pointer, sizeof(SgDictionaryExp)); };
  166706             : #endif
  166707             : /* #line 166708 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  166708             : 
  166709             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  166710             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  166711             : // obviously imply C++.
  166712             : 
  166713             : // This implements the support within ROSE for memory pools.  Memory pools
  166714             : // support the most condensed usage of memory within the construction of
  166715             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  166716             : // by a new operator written for each class.
  166717             : 
  166718             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  166719             :     // User wants multi-thread support and POSIX threads are available.
  166720             : #   include <pthread.h>
  166721             :     static pthread_mutex_t SgKeyDatumPair_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  166722             : #else
  166723             :      // Cause synchronization to be skipped.
  166724             : #    ifndef ALLOC_MUTEX
  166725             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  166726             : #    endif
  166727             : #    ifdef _REENTRANT
  166728             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  166729             : #       ifdef _MSC_VER
  166730             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  166731             : #       else
  166732             : #           warning "POSIX threads are not available; synchronization being skipped"
  166733             : #       endif
  166734             : #    endif
  166735             : #endif
  166736             : 
  166737             : #ifndef ROSE_ALLOC_TRACE
  166738             : #  define ROSE_ALLOC_TRACE 0
  166739             : #endif
  166740             : 
  166741             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  166742             : #define ROSE_ALLOC_TRACE_CNT
  166743             : #include "memory-pool-snapshot.h"
  166744             : unsigned long alloc_trace_cnt = 0;
  166745             : #endif
  166746             : 
  166747             : #if ROSE_ALLOC_TRACE
  166748             : const unsigned SgKeyDatumPair::pool_size = 5;
  166749             : #else
  166750             : const unsigned SgKeyDatumPair::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  166751             : #endif
  166752             : 
  166753             : #ifndef ROSE_ALLOC_MEMSET
  166754             : #  define ROSE_ALLOC_MEMSET 0
  166755             : #endif
  166756             : 
  166757             : #ifndef ROSE_PEDANTIC_ALLOC
  166758             : #  define ROSE_PEDANTIC_ALLOC 0
  166759             : #endif
  166760             : 
  166761             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  166762             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  166763             : #endif
  166764             : 
  166765             : #if !defined(SGNODE__ALL_POOLS)
  166766             : #define SGNODE__ALL_POOLS
  166767             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  166768             : #endif
  166769             : 
  166770             : SgKeyDatumPair* SgKeyDatumPair::next_node = nullptr;
  166771             : std::vector<unsigned char*> SgKeyDatumPair::pools;
  166772             : 
  166773             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  166774             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  166775             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  166776             : // around this macro definition rather than each use).
  166777             : #ifndef ALLOC_MUTEX
  166778             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  166779             :         do {                                                                     \
  166780             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  166781             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  166782             :                 abort();                                                         \
  166783             :             }                                                                    \
  166784             :         } while (0);
  166785             : #endif
  166786             : 
  166787             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  166788             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  166789             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  166790             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  166791             : 
  166792             : /*! \brief New operator for SgKeyDatumPair.
  166793             : 
  166794             :    This new operator implements memory pools to provide most efficent 
  166795             :    use of the heap within construction of large ASTs.
  166796             : 
  166797             : \internal The new and delete operators use the lower level C malloc/free
  166798             :    function calls for performance and to make sure that mixing of malloc/free
  166799             :    and new/delete by the used can be caught more readily.  This may change
  166800             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  166801             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  166802             :    deallocate memory allocated using ROSE_MALLOC.
  166803             : */
  166804           0 : void *SgKeyDatumPair::operator new ( size_t Size )
  166805             : {
  166806             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  166807             :      * returning or throwing an exception. */
  166808           0 :     ALLOC_MUTEX(SgKeyDatumPair, lock);
  166809             : 
  166810             : #if ROSE_ALLOC_TRACE == 2
  166811             : //    printf("SgKeyDatumPair::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgKeyDatumPair::next_node);
  166812             : #endif
  166813             : 
  166814             : #if USE_CPP_NEW_DELETE_OPERATORS
  166815             :     void *mem = ROSE_MALLOC(Size);
  166816             :     ALLOC_MUTEX(SgKeyDatumPair, unlock);
  166817             :     return mem;
  166818             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  166819             : #if ROSE_PEDANTIC_ALLOC
  166820             :     ROSE_ASSERT(Size == sizeof(SgKeyDatumPair));
  166821             : #else
  166822           0 :     if (Size != sizeof(SgKeyDatumPair)) {
  166823           0 :       void * object = ROSE_MALLOC(Size);
  166824           0 :       ALLOC_MUTEX(SgKeyDatumPair, unlock);
  166825             :       return object;
  166826             :     }
  166827             : #endif
  166828             : 
  166829           0 :     if (SgKeyDatumPair::next_node == nullptr) {
  166830           0 :         SgKeyDatumPair * alloc = (SgKeyDatumPair*) ROSE_MALLOC ( SgKeyDatumPair::pool_size * sizeof(SgKeyDatumPair) );
  166831           0 :         ROSE_ASSERT(alloc != nullptr);
  166832             : 
  166833             : #if ROSE_ALLOC_TRACE == 2
  166834             : //        printf("SgKeyDatumPair::alloc\n  block[%zi] = [ %p , %p [\n", SgKeyDatumPair::pools.size(), alloc, alloc + SgKeyDatumPair::pool_size);
  166835             : #endif
  166836             : 
  166837             : #if ROSE_ALLOC_MEMSET == 1
  166838             : #elif ROSE_ALLOC_MEMSET == 2
  166839             :         memset(alloc, 0x00, SgKeyDatumPair::pool_size * sizeof(SgKeyDatumPair));
  166840             : #elif ROSE_ALLOC_MEMSET == 3
  166841             :         memset(alloc, 0xAA, SgKeyDatumPair::pool_size * sizeof(SgKeyDatumPair));
  166842             : #endif
  166843           0 :         for (unsigned i=0; i < SgKeyDatumPair::pool_size-1; i++) {
  166844           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
  166845             :         }
  166846           0 :         alloc[SgKeyDatumPair::pool_size-1].p_freepointer = nullptr;
  166847             : 
  166848           0 :         SgKeyDatumPair::pools.push_back ( (unsigned char *) alloc );
  166849           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgKeyDatumPair::pool_size * sizeof(SgKeyDatumPair), V_SgKeyDatumPair ) );
  166850           0 :         SgKeyDatumPair::next_node = alloc;
  166851             :     }
  166852           0 :     ROSE_ASSERT(SgKeyDatumPair::next_node != nullptr);
  166853             : 
  166854           0 :     SgKeyDatumPair * object = SgKeyDatumPair::next_node;
  166855           0 :     SgKeyDatumPair::next_node = (SgKeyDatumPair*)(object->p_freepointer);
  166856             : 
  166857             : #if ROSE_ALLOC_TRACE == 2
  166858             :     printf("SgKeyDatumPair::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgKeyDatumPair::next_node);
  166859             : #endif
  166860             : 
  166861           0 :     SgNode * fp = object->p_freepointer;
  166862             : #if ROSE_ALLOC_MEMSET == 1
  166863             : #elif ROSE_ALLOC_MEMSET == 2
  166864             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgKeyDatumPair) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  166865             : #elif ROSE_ALLOC_MEMSET == 3
  166866             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgKeyDatumPair) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  166867             : #endif
  166868           0 :     object->p_freepointer = fp;
  166869             : 
  166870             : #if ROSE_ALLOC_TRACE == 2
  166871             : //    printf("SgKeyDatumPair::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgKeyDatumPair::next_node);
  166872             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  166873             :     Rose::MemPool::snapshot(oss.str());
  166874             :     alloc_trace_cnt++;
  166875             : #endif
  166876             : 
  166877           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  166878             : 
  166879           0 :     ALLOC_MUTEX(SgKeyDatumPair, unlock);
  166880             : 
  166881             :     return object;
  166882             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  166883             : }
  166884             : 
  166885             : 
  166886             : 
  166887             : /*! \brief Delete operator for SgKeyDatumPair.
  166888             : 
  166889             :    This delete operator implements deallocation using memory pools to 
  166890             :    provide most efficent use of the heap within construction of large ASTs.
  166891             : 
  166892             : \internal The new and delete operators use the lower level C malloc/free
  166893             :    function calls for performance and to make sure that mixing of malloc/free
  166894             :    and new/delete by the used can be caught more readily.  This may change
  166895             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  166896             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  166897             :    deallocate memory allocated using ROSE_MALLOC.
  166898             : */
  166899           0 : void SgKeyDatumPair::operator delete(void *Pointer, size_t Size)
  166900             : {
  166901             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  166902             :      * or throwing an exception. */
  166903           0 :     ALLOC_MUTEX(SgKeyDatumPair, lock);
  166904             : 
  166905             : #if USE_CPP_NEW_DELETE_OPERATORS
  166906             :     ROSE_FREE(Pointer);
  166907             : #else
  166908             : #if ROSE_PEDANTIC_ALLOC
  166909             :     ROSE_ASSERT(Size == sizeof(SgKeyDatumPair));
  166910             : #else
  166911           0 :     if (Size != sizeof(SgKeyDatumPair)) {
  166912           0 :       ROSE_FREE(Pointer);
  166913           0 :       ALLOC_MUTEX(SgKeyDatumPair, unlock);
  166914             :       return;
  166915             :     }
  166916             : #endif
  166917             : 
  166918           0 :     SgKeyDatumPair * object = (SgKeyDatumPair*) Pointer;
  166919           0 :     ROSE_ASSERT(object != nullptr);
  166920             : 
  166921             : #if ROSE_ALLOC_TRACE == 2
  166922             : //  printf("SgKeyDatumPair::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgKeyDatumPair::next_node);
  166923             :     printf("SgKeyDatumPair::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgKeyDatumPair::next_node);
  166924             : #endif
  166925             : 
  166926             : #if ROSE_PEDANTIC_ALLOC
  166927             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  166928             : #endif
  166929             : 
  166930             : #if ROSE_ALLOC_MEMSET == 1
  166931             : #elif ROSE_ALLOC_MEMSET == 2
  166932             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgKeyDatumPair) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  166933             : #elif ROSE_ALLOC_MEMSET == 3
  166934             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgKeyDatumPair) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  166935             : #endif
  166936             : 
  166937             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  166938             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  166939             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  166940             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  166941             : #else
  166942           0 :     object->p_freepointer = SgKeyDatumPair::next_node;
  166943           0 :     SgKeyDatumPair::next_node = object;
  166944             : #endif
  166945             : 
  166946             : #if ROSE_ALLOC_TRACE == 2
  166947             : //  printf("SgKeyDatumPair::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgKeyDatumPair::next_node);
  166948             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  166949             :     Rose::MemPool::snapshot(oss.str());
  166950             :     alloc_trace_cnt++;
  166951             : #endif
  166952             : 
  166953             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  166954             : 
  166955           0 :     ALLOC_MUTEX(SgKeyDatumPair, unlock);
  166956             : }
  166957             : 
  166958             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  166959             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  166960             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  166961             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  166962             : // Also, note comment below from Robb (copied from the Common.code file).
  166963             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  166964             : //
  166965             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  166966             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  166967             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  166968             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  166969             : #if 0
  166970             : void SgKeyDatumPair::operator delete(void* pointer) { SgKeyDatumPair::operator delete (pointer, sizeof(SgKeyDatumPair)); };
  166971             : #endif
  166972             : /* #line 166973 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  166973             : 
  166974             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  166975             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  166976             : // obviously imply C++.
  166977             : 
  166978             : // This implements the support within ROSE for memory pools.  Memory pools
  166979             : // support the most condensed usage of memory within the construction of
  166980             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  166981             : // by a new operator written for each class.
  166982             : 
  166983             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  166984             :     // User wants multi-thread support and POSIX threads are available.
  166985             : #   include <pthread.h>
  166986             :     static pthread_mutex_t SgComprehension_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  166987             : #else
  166988             :      // Cause synchronization to be skipped.
  166989             : #    ifndef ALLOC_MUTEX
  166990             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  166991             : #    endif
  166992             : #    ifdef _REENTRANT
  166993             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  166994             : #       ifdef _MSC_VER
  166995             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  166996             : #       else
  166997             : #           warning "POSIX threads are not available; synchronization being skipped"
  166998             : #       endif
  166999             : #    endif
  167000             : #endif
  167001             : 
  167002             : #ifndef ROSE_ALLOC_TRACE
  167003             : #  define ROSE_ALLOC_TRACE 0
  167004             : #endif
  167005             : 
  167006             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  167007             : #define ROSE_ALLOC_TRACE_CNT
  167008             : #include "memory-pool-snapshot.h"
  167009             : unsigned long alloc_trace_cnt = 0;
  167010             : #endif
  167011             : 
  167012             : #if ROSE_ALLOC_TRACE
  167013             : const unsigned SgComprehension::pool_size = 5;
  167014             : #else
  167015             : const unsigned SgComprehension::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  167016             : #endif
  167017             : 
  167018             : #ifndef ROSE_ALLOC_MEMSET
  167019             : #  define ROSE_ALLOC_MEMSET 0
  167020             : #endif
  167021             : 
  167022             : #ifndef ROSE_PEDANTIC_ALLOC
  167023             : #  define ROSE_PEDANTIC_ALLOC 0
  167024             : #endif
  167025             : 
  167026             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  167027             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  167028             : #endif
  167029             : 
  167030             : #if !defined(SGNODE__ALL_POOLS)
  167031             : #define SGNODE__ALL_POOLS
  167032             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  167033             : #endif
  167034             : 
  167035             : SgComprehension* SgComprehension::next_node = nullptr;
  167036             : std::vector<unsigned char*> SgComprehension::pools;
  167037             : 
  167038             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  167039             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  167040             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  167041             : // around this macro definition rather than each use).
  167042             : #ifndef ALLOC_MUTEX
  167043             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  167044             :         do {                                                                     \
  167045             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  167046             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  167047             :                 abort();                                                         \
  167048             :             }                                                                    \
  167049             :         } while (0);
  167050             : #endif
  167051             : 
  167052             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  167053             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  167054             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  167055             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  167056             : 
  167057             : /*! \brief New operator for SgComprehension.
  167058             : 
  167059             :    This new operator implements memory pools to provide most efficent 
  167060             :    use of the heap within construction of large ASTs.
  167061             : 
  167062             : \internal The new and delete operators use the lower level C malloc/free
  167063             :    function calls for performance and to make sure that mixing of malloc/free
  167064             :    and new/delete by the used can be caught more readily.  This may change
  167065             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  167066             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  167067             :    deallocate memory allocated using ROSE_MALLOC.
  167068             : */
  167069           0 : void *SgComprehension::operator new ( size_t Size )
  167070             : {
  167071             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  167072             :      * returning or throwing an exception. */
  167073           0 :     ALLOC_MUTEX(SgComprehension, lock);
  167074             : 
  167075             : #if ROSE_ALLOC_TRACE == 2
  167076             : //    printf("SgComprehension::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgComprehension::next_node);
  167077             : #endif
  167078             : 
  167079             : #if USE_CPP_NEW_DELETE_OPERATORS
  167080             :     void *mem = ROSE_MALLOC(Size);
  167081             :     ALLOC_MUTEX(SgComprehension, unlock);
  167082             :     return mem;
  167083             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  167084             : #if ROSE_PEDANTIC_ALLOC
  167085             :     ROSE_ASSERT(Size == sizeof(SgComprehension));
  167086             : #else
  167087           0 :     if (Size != sizeof(SgComprehension)) {
  167088           0 :       void * object = ROSE_MALLOC(Size);
  167089           0 :       ALLOC_MUTEX(SgComprehension, unlock);
  167090             :       return object;
  167091             :     }
  167092             : #endif
  167093             : 
  167094           0 :     if (SgComprehension::next_node == nullptr) {
  167095           0 :         SgComprehension * alloc = (SgComprehension*) ROSE_MALLOC ( SgComprehension::pool_size * sizeof(SgComprehension) );
  167096           0 :         ROSE_ASSERT(alloc != nullptr);
  167097             : 
  167098             : #if ROSE_ALLOC_TRACE == 2
  167099             : //        printf("SgComprehension::alloc\n  block[%zi] = [ %p , %p [\n", SgComprehension::pools.size(), alloc, alloc + SgComprehension::pool_size);
  167100             : #endif
  167101             : 
  167102             : #if ROSE_ALLOC_MEMSET == 1
  167103             : #elif ROSE_ALLOC_MEMSET == 2
  167104             :         memset(alloc, 0x00, SgComprehension::pool_size * sizeof(SgComprehension));
  167105             : #elif ROSE_ALLOC_MEMSET == 3
  167106             :         memset(alloc, 0xAA, SgComprehension::pool_size * sizeof(SgComprehension));
  167107             : #endif
  167108           0 :         for (unsigned i=0; i < SgComprehension::pool_size-1; i++) {
  167109           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
  167110             :         }
  167111           0 :         alloc[SgComprehension::pool_size-1].p_freepointer = nullptr;
  167112             : 
  167113           0 :         SgComprehension::pools.push_back ( (unsigned char *) alloc );
  167114           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgComprehension::pool_size * sizeof(SgComprehension), V_SgComprehension ) );
  167115           0 :         SgComprehension::next_node = alloc;
  167116             :     }
  167117           0 :     ROSE_ASSERT(SgComprehension::next_node != nullptr);
  167118             : 
  167119           0 :     SgComprehension * object = SgComprehension::next_node;
  167120           0 :     SgComprehension::next_node = (SgComprehension*)(object->p_freepointer);
  167121             : 
  167122             : #if ROSE_ALLOC_TRACE == 2
  167123             :     printf("SgComprehension::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgComprehension::next_node);
  167124             : #endif
  167125             : 
  167126           0 :     SgNode * fp = object->p_freepointer;
  167127             : #if ROSE_ALLOC_MEMSET == 1
  167128             : #elif ROSE_ALLOC_MEMSET == 2
  167129             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgComprehension) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  167130             : #elif ROSE_ALLOC_MEMSET == 3
  167131             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgComprehension) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  167132             : #endif
  167133           0 :     object->p_freepointer = fp;
  167134             : 
  167135             : #if ROSE_ALLOC_TRACE == 2
  167136             : //    printf("SgComprehension::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgComprehension::next_node);
  167137             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  167138             :     Rose::MemPool::snapshot(oss.str());
  167139             :     alloc_trace_cnt++;
  167140             : #endif
  167141             : 
  167142           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  167143             : 
  167144           0 :     ALLOC_MUTEX(SgComprehension, unlock);
  167145             : 
  167146             :     return object;
  167147             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  167148             : }
  167149             : 
  167150             : 
  167151             : 
  167152             : /*! \brief Delete operator for SgComprehension.
  167153             : 
  167154             :    This delete operator implements deallocation using memory pools to 
  167155             :    provide most efficent use of the heap within construction of large ASTs.
  167156             : 
  167157             : \internal The new and delete operators use the lower level C malloc/free
  167158             :    function calls for performance and to make sure that mixing of malloc/free
  167159             :    and new/delete by the used can be caught more readily.  This may change
  167160             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  167161             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  167162             :    deallocate memory allocated using ROSE_MALLOC.
  167163             : */
  167164           0 : void SgComprehension::operator delete(void *Pointer, size_t Size)
  167165             : {
  167166             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  167167             :      * or throwing an exception. */
  167168           0 :     ALLOC_MUTEX(SgComprehension, lock);
  167169             : 
  167170             : #if USE_CPP_NEW_DELETE_OPERATORS
  167171             :     ROSE_FREE(Pointer);
  167172             : #else
  167173             : #if ROSE_PEDANTIC_ALLOC
  167174             :     ROSE_ASSERT(Size == sizeof(SgComprehension));
  167175             : #else
  167176           0 :     if (Size != sizeof(SgComprehension)) {
  167177           0 :       ROSE_FREE(Pointer);
  167178           0 :       ALLOC_MUTEX(SgComprehension, unlock);
  167179             :       return;
  167180             :     }
  167181             : #endif
  167182             : 
  167183           0 :     SgComprehension * object = (SgComprehension*) Pointer;
  167184           0 :     ROSE_ASSERT(object != nullptr);
  167185             : 
  167186             : #if ROSE_ALLOC_TRACE == 2
  167187             : //  printf("SgComprehension::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgComprehension::next_node);
  167188             :     printf("SgComprehension::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgComprehension::next_node);
  167189             : #endif
  167190             : 
  167191             : #if ROSE_PEDANTIC_ALLOC
  167192             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  167193             : #endif
  167194             : 
  167195             : #if ROSE_ALLOC_MEMSET == 1
  167196             : #elif ROSE_ALLOC_MEMSET == 2
  167197             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgComprehension) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  167198             : #elif ROSE_ALLOC_MEMSET == 3
  167199             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgComprehension) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  167200             : #endif
  167201             : 
  167202             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  167203             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  167204             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  167205             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  167206             : #else
  167207           0 :     object->p_freepointer = SgComprehension::next_node;
  167208           0 :     SgComprehension::next_node = object;
  167209             : #endif
  167210             : 
  167211             : #if ROSE_ALLOC_TRACE == 2
  167212             : //  printf("SgComprehension::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgComprehension::next_node);
  167213             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  167214             :     Rose::MemPool::snapshot(oss.str());
  167215             :     alloc_trace_cnt++;
  167216             : #endif
  167217             : 
  167218             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  167219             : 
  167220           0 :     ALLOC_MUTEX(SgComprehension, unlock);
  167221             : }
  167222             : 
  167223             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  167224             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  167225             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  167226             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  167227             : // Also, note comment below from Robb (copied from the Common.code file).
  167228             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  167229             : //
  167230             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  167231             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  167232             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  167233             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  167234             : #if 0
  167235             : void SgComprehension::operator delete(void* pointer) { SgComprehension::operator delete (pointer, sizeof(SgComprehension)); };
  167236             : #endif
  167237             : /* #line 167238 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  167238             : 
  167239             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  167240             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  167241             : // obviously imply C++.
  167242             : 
  167243             : // This implements the support within ROSE for memory pools.  Memory pools
  167244             : // support the most condensed usage of memory within the construction of
  167245             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  167246             : // by a new operator written for each class.
  167247             : 
  167248             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  167249             :     // User wants multi-thread support and POSIX threads are available.
  167250             : #   include <pthread.h>
  167251             :     static pthread_mutex_t SgListComprehension_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  167252             : #else
  167253             :      // Cause synchronization to be skipped.
  167254             : #    ifndef ALLOC_MUTEX
  167255             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  167256             : #    endif
  167257             : #    ifdef _REENTRANT
  167258             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  167259             : #       ifdef _MSC_VER
  167260             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  167261             : #       else
  167262             : #           warning "POSIX threads are not available; synchronization being skipped"
  167263             : #       endif
  167264             : #    endif
  167265             : #endif
  167266             : 
  167267             : #ifndef ROSE_ALLOC_TRACE
  167268             : #  define ROSE_ALLOC_TRACE 0
  167269             : #endif
  167270             : 
  167271             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  167272             : #define ROSE_ALLOC_TRACE_CNT
  167273             : #include "memory-pool-snapshot.h"
  167274             : unsigned long alloc_trace_cnt = 0;
  167275             : #endif
  167276             : 
  167277             : #if ROSE_ALLOC_TRACE
  167278             : const unsigned SgListComprehension::pool_size = 5;
  167279             : #else
  167280             : const unsigned SgListComprehension::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  167281             : #endif
  167282             : 
  167283             : #ifndef ROSE_ALLOC_MEMSET
  167284             : #  define ROSE_ALLOC_MEMSET 0
  167285             : #endif
  167286             : 
  167287             : #ifndef ROSE_PEDANTIC_ALLOC
  167288             : #  define ROSE_PEDANTIC_ALLOC 0
  167289             : #endif
  167290             : 
  167291             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  167292             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  167293             : #endif
  167294             : 
  167295             : #if !defined(SGNODE__ALL_POOLS)
  167296             : #define SGNODE__ALL_POOLS
  167297             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  167298             : #endif
  167299             : 
  167300             : SgListComprehension* SgListComprehension::next_node = nullptr;
  167301             : std::vector<unsigned char*> SgListComprehension::pools;
  167302             : 
  167303             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  167304             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  167305             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  167306             : // around this macro definition rather than each use).
  167307             : #ifndef ALLOC_MUTEX
  167308             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  167309             :         do {                                                                     \
  167310             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  167311             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  167312             :                 abort();                                                         \
  167313             :             }                                                                    \
  167314             :         } while (0);
  167315             : #endif
  167316             : 
  167317             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  167318             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  167319             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  167320             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  167321             : 
  167322             : /*! \brief New operator for SgListComprehension.
  167323             : 
  167324             :    This new operator implements memory pools to provide most efficent 
  167325             :    use of the heap within construction of large ASTs.
  167326             : 
  167327             : \internal The new and delete operators use the lower level C malloc/free
  167328             :    function calls for performance and to make sure that mixing of malloc/free
  167329             :    and new/delete by the used can be caught more readily.  This may change
  167330             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  167331             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  167332             :    deallocate memory allocated using ROSE_MALLOC.
  167333             : */
  167334           0 : void *SgListComprehension::operator new ( size_t Size )
  167335             : {
  167336             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  167337             :      * returning or throwing an exception. */
  167338           0 :     ALLOC_MUTEX(SgListComprehension, lock);
  167339             : 
  167340             : #if ROSE_ALLOC_TRACE == 2
  167341             : //    printf("SgListComprehension::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgListComprehension::next_node);
  167342             : #endif
  167343             : 
  167344             : #if USE_CPP_NEW_DELETE_OPERATORS
  167345             :     void *mem = ROSE_MALLOC(Size);
  167346             :     ALLOC_MUTEX(SgListComprehension, unlock);
  167347             :     return mem;
  167348             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  167349             : #if ROSE_PEDANTIC_ALLOC
  167350             :     ROSE_ASSERT(Size == sizeof(SgListComprehension));
  167351             : #else
  167352           0 :     if (Size != sizeof(SgListComprehension)) {
  167353           0 :       void * object = ROSE_MALLOC(Size);
  167354           0 :       ALLOC_MUTEX(SgListComprehension, unlock);
  167355             :       return object;
  167356             :     }
  167357             : #endif
  167358             : 
  167359           0 :     if (SgListComprehension::next_node == nullptr) {
  167360           0 :         SgListComprehension * alloc = (SgListComprehension*) ROSE_MALLOC ( SgListComprehension::pool_size * sizeof(SgListComprehension) );
  167361           0 :         ROSE_ASSERT(alloc != nullptr);
  167362             : 
  167363             : #if ROSE_ALLOC_TRACE == 2
  167364             : //        printf("SgListComprehension::alloc\n  block[%zi] = [ %p , %p [\n", SgListComprehension::pools.size(), alloc, alloc + SgListComprehension::pool_size);
  167365             : #endif
  167366             : 
  167367             : #if ROSE_ALLOC_MEMSET == 1
  167368             : #elif ROSE_ALLOC_MEMSET == 2
  167369             :         memset(alloc, 0x00, SgListComprehension::pool_size * sizeof(SgListComprehension));
  167370             : #elif ROSE_ALLOC_MEMSET == 3
  167371             :         memset(alloc, 0xAA, SgListComprehension::pool_size * sizeof(SgListComprehension));
  167372             : #endif
  167373           0 :         for (unsigned i=0; i < SgListComprehension::pool_size-1; i++) {
  167374           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
  167375             :         }
  167376           0 :         alloc[SgListComprehension::pool_size-1].p_freepointer = nullptr;
  167377             : 
  167378           0 :         SgListComprehension::pools.push_back ( (unsigned char *) alloc );
  167379           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgListComprehension::pool_size * sizeof(SgListComprehension), V_SgListComprehension ) );
  167380           0 :         SgListComprehension::next_node = alloc;
  167381             :     }
  167382           0 :     ROSE_ASSERT(SgListComprehension::next_node != nullptr);
  167383             : 
  167384           0 :     SgListComprehension * object = SgListComprehension::next_node;
  167385           0 :     SgListComprehension::next_node = (SgListComprehension*)(object->p_freepointer);
  167386             : 
  167387             : #if ROSE_ALLOC_TRACE == 2
  167388             :     printf("SgListComprehension::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgListComprehension::next_node);
  167389             : #endif
  167390             : 
  167391           0 :     SgNode * fp = object->p_freepointer;
  167392             : #if ROSE_ALLOC_MEMSET == 1
  167393             : #elif ROSE_ALLOC_MEMSET == 2
  167394             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgListComprehension) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  167395             : #elif ROSE_ALLOC_MEMSET == 3
  167396             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgListComprehension) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  167397             : #endif
  167398           0 :     object->p_freepointer = fp;
  167399             : 
  167400             : #if ROSE_ALLOC_TRACE == 2
  167401             : //    printf("SgListComprehension::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgListComprehension::next_node);
  167402             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  167403             :     Rose::MemPool::snapshot(oss.str());
  167404             :     alloc_trace_cnt++;
  167405             : #endif
  167406             : 
  167407           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  167408             : 
  167409           0 :     ALLOC_MUTEX(SgListComprehension, unlock);
  167410             : 
  167411             :     return object;
  167412             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  167413             : }
  167414             : 
  167415             : 
  167416             : 
  167417             : /*! \brief Delete operator for SgListComprehension.
  167418             : 
  167419             :    This delete operator implements deallocation using memory pools to 
  167420             :    provide most efficent use of the heap within construction of large ASTs.
  167421             : 
  167422             : \internal The new and delete operators use the lower level C malloc/free
  167423             :    function calls for performance and to make sure that mixing of malloc/free
  167424             :    and new/delete by the used can be caught more readily.  This may change
  167425             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  167426             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  167427             :    deallocate memory allocated using ROSE_MALLOC.
  167428             : */
  167429           0 : void SgListComprehension::operator delete(void *Pointer, size_t Size)
  167430             : {
  167431             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  167432             :      * or throwing an exception. */
  167433           0 :     ALLOC_MUTEX(SgListComprehension, lock);
  167434             : 
  167435             : #if USE_CPP_NEW_DELETE_OPERATORS
  167436             :     ROSE_FREE(Pointer);
  167437             : #else
  167438             : #if ROSE_PEDANTIC_ALLOC
  167439             :     ROSE_ASSERT(Size == sizeof(SgListComprehension));
  167440             : #else
  167441           0 :     if (Size != sizeof(SgListComprehension)) {
  167442           0 :       ROSE_FREE(Pointer);
  167443           0 :       ALLOC_MUTEX(SgListComprehension, unlock);
  167444             :       return;
  167445             :     }
  167446             : #endif
  167447             : 
  167448           0 :     SgListComprehension * object = (SgListComprehension*) Pointer;
  167449           0 :     ROSE_ASSERT(object != nullptr);
  167450             : 
  167451             : #if ROSE_ALLOC_TRACE == 2
  167452             : //  printf("SgListComprehension::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgListComprehension::next_node);
  167453             :     printf("SgListComprehension::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgListComprehension::next_node);
  167454             : #endif
  167455             : 
  167456             : #if ROSE_PEDANTIC_ALLOC
  167457             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  167458             : #endif
  167459             : 
  167460             : #if ROSE_ALLOC_MEMSET == 1
  167461             : #elif ROSE_ALLOC_MEMSET == 2
  167462             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgListComprehension) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  167463             : #elif ROSE_ALLOC_MEMSET == 3
  167464             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgListComprehension) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  167465             : #endif
  167466             : 
  167467             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  167468             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  167469             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  167470             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  167471             : #else
  167472           0 :     object->p_freepointer = SgListComprehension::next_node;
  167473           0 :     SgListComprehension::next_node = object;
  167474             : #endif
  167475             : 
  167476             : #if ROSE_ALLOC_TRACE == 2
  167477             : //  printf("SgListComprehension::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgListComprehension::next_node);
  167478             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  167479             :     Rose::MemPool::snapshot(oss.str());
  167480             :     alloc_trace_cnt++;
  167481             : #endif
  167482             : 
  167483             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  167484             : 
  167485           0 :     ALLOC_MUTEX(SgListComprehension, unlock);
  167486             : }
  167487             : 
  167488             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  167489             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  167490             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  167491             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  167492             : // Also, note comment below from Robb (copied from the Common.code file).
  167493             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  167494             : //
  167495             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  167496             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  167497             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  167498             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  167499             : #if 0
  167500             : void SgListComprehension::operator delete(void* pointer) { SgListComprehension::operator delete (pointer, sizeof(SgListComprehension)); };
  167501             : #endif
  167502             : /* #line 167503 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  167503             : 
  167504             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  167505             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  167506             : // obviously imply C++.
  167507             : 
  167508             : // This implements the support within ROSE for memory pools.  Memory pools
  167509             : // support the most condensed usage of memory within the construction of
  167510             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  167511             : // by a new operator written for each class.
  167512             : 
  167513             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  167514             :     // User wants multi-thread support and POSIX threads are available.
  167515             : #   include <pthread.h>
  167516             :     static pthread_mutex_t SgSetComprehension_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  167517             : #else
  167518             :      // Cause synchronization to be skipped.
  167519             : #    ifndef ALLOC_MUTEX
  167520             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  167521             : #    endif
  167522             : #    ifdef _REENTRANT
  167523             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  167524             : #       ifdef _MSC_VER
  167525             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  167526             : #       else
  167527             : #           warning "POSIX threads are not available; synchronization being skipped"
  167528             : #       endif
  167529             : #    endif
  167530             : #endif
  167531             : 
  167532             : #ifndef ROSE_ALLOC_TRACE
  167533             : #  define ROSE_ALLOC_TRACE 0
  167534             : #endif
  167535             : 
  167536             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  167537             : #define ROSE_ALLOC_TRACE_CNT
  167538             : #include "memory-pool-snapshot.h"
  167539             : unsigned long alloc_trace_cnt = 0;
  167540             : #endif
  167541             : 
  167542             : #if ROSE_ALLOC_TRACE
  167543             : const unsigned SgSetComprehension::pool_size = 5;
  167544             : #else
  167545             : const unsigned SgSetComprehension::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  167546             : #endif
  167547             : 
  167548             : #ifndef ROSE_ALLOC_MEMSET
  167549             : #  define ROSE_ALLOC_MEMSET 0
  167550             : #endif
  167551             : 
  167552             : #ifndef ROSE_PEDANTIC_ALLOC
  167553             : #  define ROSE_PEDANTIC_ALLOC 0
  167554             : #endif
  167555             : 
  167556             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  167557             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  167558             : #endif
  167559             : 
  167560             : #if !defined(SGNODE__ALL_POOLS)
  167561             : #define SGNODE__ALL_POOLS
  167562             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  167563             : #endif
  167564             : 
  167565             : SgSetComprehension* SgSetComprehension::next_node = nullptr;
  167566             : std::vector<unsigned char*> SgSetComprehension::pools;
  167567             : 
  167568             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  167569             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  167570             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  167571             : // around this macro definition rather than each use).
  167572             : #ifndef ALLOC_MUTEX
  167573             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  167574             :         do {                                                                     \
  167575             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  167576             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  167577             :                 abort();                                                         \
  167578             :             }                                                                    \
  167579             :         } while (0);
  167580             : #endif
  167581             : 
  167582             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  167583             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  167584             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  167585             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  167586             : 
  167587             : /*! \brief New operator for SgSetComprehension.
  167588             : 
  167589             :    This new operator implements memory pools to provide most efficent 
  167590             :    use of the heap within construction of large ASTs.
  167591             : 
  167592             : \internal The new and delete operators use the lower level C malloc/free
  167593             :    function calls for performance and to make sure that mixing of malloc/free
  167594             :    and new/delete by the used can be caught more readily.  This may change
  167595             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  167596             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  167597             :    deallocate memory allocated using ROSE_MALLOC.
  167598             : */
  167599           0 : void *SgSetComprehension::operator new ( size_t Size )
  167600             : {
  167601             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  167602             :      * returning or throwing an exception. */
  167603           0 :     ALLOC_MUTEX(SgSetComprehension, lock);
  167604             : 
  167605             : #if ROSE_ALLOC_TRACE == 2
  167606             : //    printf("SgSetComprehension::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgSetComprehension::next_node);
  167607             : #endif
  167608             : 
  167609             : #if USE_CPP_NEW_DELETE_OPERATORS
  167610             :     void *mem = ROSE_MALLOC(Size);
  167611             :     ALLOC_MUTEX(SgSetComprehension, unlock);
  167612             :     return mem;
  167613             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  167614             : #if ROSE_PEDANTIC_ALLOC
  167615             :     ROSE_ASSERT(Size == sizeof(SgSetComprehension));
  167616             : #else
  167617           0 :     if (Size != sizeof(SgSetComprehension)) {
  167618           0 :       void * object = ROSE_MALLOC(Size);
  167619           0 :       ALLOC_MUTEX(SgSetComprehension, unlock);
  167620             :       return object;
  167621             :     }
  167622             : #endif
  167623             : 
  167624           0 :     if (SgSetComprehension::next_node == nullptr) {
  167625           0 :         SgSetComprehension * alloc = (SgSetComprehension*) ROSE_MALLOC ( SgSetComprehension::pool_size * sizeof(SgSetComprehension) );
  167626           0 :         ROSE_ASSERT(alloc != nullptr);
  167627             : 
  167628             : #if ROSE_ALLOC_TRACE == 2
  167629             : //        printf("SgSetComprehension::alloc\n  block[%zi] = [ %p , %p [\n", SgSetComprehension::pools.size(), alloc, alloc + SgSetComprehension::pool_size);
  167630             : #endif
  167631             : 
  167632             : #if ROSE_ALLOC_MEMSET == 1
  167633             : #elif ROSE_ALLOC_MEMSET == 2
  167634             :         memset(alloc, 0x00, SgSetComprehension::pool_size * sizeof(SgSetComprehension));
  167635             : #elif ROSE_ALLOC_MEMSET == 3
  167636             :         memset(alloc, 0xAA, SgSetComprehension::pool_size * sizeof(SgSetComprehension));
  167637             : #endif
  167638           0 :         for (unsigned i=0; i < SgSetComprehension::pool_size-1; i++) {
  167639           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
  167640             :         }
  167641           0 :         alloc[SgSetComprehension::pool_size-1].p_freepointer = nullptr;
  167642             : 
  167643           0 :         SgSetComprehension::pools.push_back ( (unsigned char *) alloc );
  167644           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgSetComprehension::pool_size * sizeof(SgSetComprehension), V_SgSetComprehension ) );
  167645           0 :         SgSetComprehension::next_node = alloc;
  167646             :     }
  167647           0 :     ROSE_ASSERT(SgSetComprehension::next_node != nullptr);
  167648             : 
  167649           0 :     SgSetComprehension * object = SgSetComprehension::next_node;
  167650           0 :     SgSetComprehension::next_node = (SgSetComprehension*)(object->p_freepointer);
  167651             : 
  167652             : #if ROSE_ALLOC_TRACE == 2
  167653             :     printf("SgSetComprehension::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgSetComprehension::next_node);
  167654             : #endif
  167655             : 
  167656           0 :     SgNode * fp = object->p_freepointer;
  167657             : #if ROSE_ALLOC_MEMSET == 1
  167658             : #elif ROSE_ALLOC_MEMSET == 2
  167659             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgSetComprehension) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  167660             : #elif ROSE_ALLOC_MEMSET == 3
  167661             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgSetComprehension) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  167662             : #endif
  167663           0 :     object->p_freepointer = fp;
  167664             : 
  167665             : #if ROSE_ALLOC_TRACE == 2
  167666             : //    printf("SgSetComprehension::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgSetComprehension::next_node);
  167667             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  167668             :     Rose::MemPool::snapshot(oss.str());
  167669             :     alloc_trace_cnt++;
  167670             : #endif
  167671             : 
  167672           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  167673             : 
  167674           0 :     ALLOC_MUTEX(SgSetComprehension, unlock);
  167675             : 
  167676             :     return object;
  167677             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  167678             : }
  167679             : 
  167680             : 
  167681             : 
  167682             : /*! \brief Delete operator for SgSetComprehension.
  167683             : 
  167684             :    This delete operator implements deallocation using memory pools to 
  167685             :    provide most efficent use of the heap within construction of large ASTs.
  167686             : 
  167687             : \internal The new and delete operators use the lower level C malloc/free
  167688             :    function calls for performance and to make sure that mixing of malloc/free
  167689             :    and new/delete by the used can be caught more readily.  This may change
  167690             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  167691             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  167692             :    deallocate memory allocated using ROSE_MALLOC.
  167693             : */
  167694           0 : void SgSetComprehension::operator delete(void *Pointer, size_t Size)
  167695             : {
  167696             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  167697             :      * or throwing an exception. */
  167698           0 :     ALLOC_MUTEX(SgSetComprehension, lock);
  167699             : 
  167700             : #if USE_CPP_NEW_DELETE_OPERATORS
  167701             :     ROSE_FREE(Pointer);
  167702             : #else
  167703             : #if ROSE_PEDANTIC_ALLOC
  167704             :     ROSE_ASSERT(Size == sizeof(SgSetComprehension));
  167705             : #else
  167706           0 :     if (Size != sizeof(SgSetComprehension)) {
  167707           0 :       ROSE_FREE(Pointer);
  167708           0 :       ALLOC_MUTEX(SgSetComprehension, unlock);
  167709             :       return;
  167710             :     }
  167711             : #endif
  167712             : 
  167713           0 :     SgSetComprehension * object = (SgSetComprehension*) Pointer;
  167714           0 :     ROSE_ASSERT(object != nullptr);
  167715             : 
  167716             : #if ROSE_ALLOC_TRACE == 2
  167717             : //  printf("SgSetComprehension::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgSetComprehension::next_node);
  167718             :     printf("SgSetComprehension::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgSetComprehension::next_node);
  167719             : #endif
  167720             : 
  167721             : #if ROSE_PEDANTIC_ALLOC
  167722             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  167723             : #endif
  167724             : 
  167725             : #if ROSE_ALLOC_MEMSET == 1
  167726             : #elif ROSE_ALLOC_MEMSET == 2
  167727             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgSetComprehension) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  167728             : #elif ROSE_ALLOC_MEMSET == 3
  167729             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgSetComprehension) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  167730             : #endif
  167731             : 
  167732             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  167733             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  167734             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  167735             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  167736             : #else
  167737           0 :     object->p_freepointer = SgSetComprehension::next_node;
  167738           0 :     SgSetComprehension::next_node = object;
  167739             : #endif
  167740             : 
  167741             : #if ROSE_ALLOC_TRACE == 2
  167742             : //  printf("SgSetComprehension::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgSetComprehension::next_node);
  167743             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  167744             :     Rose::MemPool::snapshot(oss.str());
  167745             :     alloc_trace_cnt++;
  167746             : #endif
  167747             : 
  167748             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  167749             : 
  167750           0 :     ALLOC_MUTEX(SgSetComprehension, unlock);
  167751             : }
  167752             : 
  167753             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  167754             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  167755             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  167756             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  167757             : // Also, note comment below from Robb (copied from the Common.code file).
  167758             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  167759             : //
  167760             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  167761             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  167762             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  167763             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  167764             : #if 0
  167765             : void SgSetComprehension::operator delete(void* pointer) { SgSetComprehension::operator delete (pointer, sizeof(SgSetComprehension)); };
  167766             : #endif
  167767             : /* #line 167768 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  167768             : 
  167769             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  167770             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  167771             : // obviously imply C++.
  167772             : 
  167773             : // This implements the support within ROSE for memory pools.  Memory pools
  167774             : // support the most condensed usage of memory within the construction of
  167775             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  167776             : // by a new operator written for each class.
  167777             : 
  167778             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  167779             :     // User wants multi-thread support and POSIX threads are available.
  167780             : #   include <pthread.h>
  167781             :     static pthread_mutex_t SgDictionaryComprehension_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  167782             : #else
  167783             :      // Cause synchronization to be skipped.
  167784             : #    ifndef ALLOC_MUTEX
  167785             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  167786             : #    endif
  167787             : #    ifdef _REENTRANT
  167788             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  167789             : #       ifdef _MSC_VER
  167790             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  167791             : #       else
  167792             : #           warning "POSIX threads are not available; synchronization being skipped"
  167793             : #       endif
  167794             : #    endif
  167795             : #endif
  167796             : 
  167797             : #ifndef ROSE_ALLOC_TRACE
  167798             : #  define ROSE_ALLOC_TRACE 0
  167799             : #endif
  167800             : 
  167801             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  167802             : #define ROSE_ALLOC_TRACE_CNT
  167803             : #include "memory-pool-snapshot.h"
  167804             : unsigned long alloc_trace_cnt = 0;
  167805             : #endif
  167806             : 
  167807             : #if ROSE_ALLOC_TRACE
  167808             : const unsigned SgDictionaryComprehension::pool_size = 5;
  167809             : #else
  167810             : const unsigned SgDictionaryComprehension::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  167811             : #endif
  167812             : 
  167813             : #ifndef ROSE_ALLOC_MEMSET
  167814             : #  define ROSE_ALLOC_MEMSET 0
  167815             : #endif
  167816             : 
  167817             : #ifndef ROSE_PEDANTIC_ALLOC
  167818             : #  define ROSE_PEDANTIC_ALLOC 0
  167819             : #endif
  167820             : 
  167821             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  167822             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  167823             : #endif
  167824             : 
  167825             : #if !defined(SGNODE__ALL_POOLS)
  167826             : #define SGNODE__ALL_POOLS
  167827             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  167828             : #endif
  167829             : 
  167830             : SgDictionaryComprehension* SgDictionaryComprehension::next_node = nullptr;
  167831             : std::vector<unsigned char*> SgDictionaryComprehension::pools;
  167832             : 
  167833             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  167834             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  167835             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  167836             : // around this macro definition rather than each use).
  167837             : #ifndef ALLOC_MUTEX
  167838             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  167839             :         do {                                                                     \
  167840             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  167841             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  167842             :                 abort();                                                         \
  167843             :             }                                                                    \
  167844             :         } while (0);
  167845             : #endif
  167846             : 
  167847             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  167848             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  167849             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  167850             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  167851             : 
  167852             : /*! \brief New operator for SgDictionaryComprehension.
  167853             : 
  167854             :    This new operator implements memory pools to provide most efficent 
  167855             :    use of the heap within construction of large ASTs.
  167856             : 
  167857             : \internal The new and delete operators use the lower level C malloc/free
  167858             :    function calls for performance and to make sure that mixing of malloc/free
  167859             :    and new/delete by the used can be caught more readily.  This may change
  167860             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  167861             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  167862             :    deallocate memory allocated using ROSE_MALLOC.
  167863             : */
  167864           0 : void *SgDictionaryComprehension::operator new ( size_t Size )
  167865             : {
  167866             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  167867             :      * returning or throwing an exception. */
  167868           0 :     ALLOC_MUTEX(SgDictionaryComprehension, lock);
  167869             : 
  167870             : #if ROSE_ALLOC_TRACE == 2
  167871             : //    printf("SgDictionaryComprehension::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgDictionaryComprehension::next_node);
  167872             : #endif
  167873             : 
  167874             : #if USE_CPP_NEW_DELETE_OPERATORS
  167875             :     void *mem = ROSE_MALLOC(Size);
  167876             :     ALLOC_MUTEX(SgDictionaryComprehension, unlock);
  167877             :     return mem;
  167878             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  167879             : #if ROSE_PEDANTIC_ALLOC
  167880             :     ROSE_ASSERT(Size == sizeof(SgDictionaryComprehension));
  167881             : #else
  167882           0 :     if (Size != sizeof(SgDictionaryComprehension)) {
  167883           0 :       void * object = ROSE_MALLOC(Size);
  167884           0 :       ALLOC_MUTEX(SgDictionaryComprehension, unlock);
  167885             :       return object;
  167886             :     }
  167887             : #endif
  167888             : 
  167889           0 :     if (SgDictionaryComprehension::next_node == nullptr) {
  167890           0 :         SgDictionaryComprehension * alloc = (SgDictionaryComprehension*) ROSE_MALLOC ( SgDictionaryComprehension::pool_size * sizeof(SgDictionaryComprehension) );
  167891           0 :         ROSE_ASSERT(alloc != nullptr);
  167892             : 
  167893             : #if ROSE_ALLOC_TRACE == 2
  167894             : //        printf("SgDictionaryComprehension::alloc\n  block[%zi] = [ %p , %p [\n", SgDictionaryComprehension::pools.size(), alloc, alloc + SgDictionaryComprehension::pool_size);
  167895             : #endif
  167896             : 
  167897             : #if ROSE_ALLOC_MEMSET == 1
  167898             : #elif ROSE_ALLOC_MEMSET == 2
  167899             :         memset(alloc, 0x00, SgDictionaryComprehension::pool_size * sizeof(SgDictionaryComprehension));
  167900             : #elif ROSE_ALLOC_MEMSET == 3
  167901             :         memset(alloc, 0xAA, SgDictionaryComprehension::pool_size * sizeof(SgDictionaryComprehension));
  167902             : #endif
  167903           0 :         for (unsigned i=0; i < SgDictionaryComprehension::pool_size-1; i++) {
  167904           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
  167905             :         }
  167906           0 :         alloc[SgDictionaryComprehension::pool_size-1].p_freepointer = nullptr;
  167907             : 
  167908           0 :         SgDictionaryComprehension::pools.push_back ( (unsigned char *) alloc );
  167909           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgDictionaryComprehension::pool_size * sizeof(SgDictionaryComprehension), V_SgDictionaryComprehension ) );
  167910           0 :         SgDictionaryComprehension::next_node = alloc;
  167911             :     }
  167912           0 :     ROSE_ASSERT(SgDictionaryComprehension::next_node != nullptr);
  167913             : 
  167914           0 :     SgDictionaryComprehension * object = SgDictionaryComprehension::next_node;
  167915           0 :     SgDictionaryComprehension::next_node = (SgDictionaryComprehension*)(object->p_freepointer);
  167916             : 
  167917             : #if ROSE_ALLOC_TRACE == 2
  167918             :     printf("SgDictionaryComprehension::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgDictionaryComprehension::next_node);
  167919             : #endif
  167920             : 
  167921           0 :     SgNode * fp = object->p_freepointer;
  167922             : #if ROSE_ALLOC_MEMSET == 1
  167923             : #elif ROSE_ALLOC_MEMSET == 2
  167924             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgDictionaryComprehension) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  167925             : #elif ROSE_ALLOC_MEMSET == 3
  167926             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgDictionaryComprehension) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  167927             : #endif
  167928           0 :     object->p_freepointer = fp;
  167929             : 
  167930             : #if ROSE_ALLOC_TRACE == 2
  167931             : //    printf("SgDictionaryComprehension::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgDictionaryComprehension::next_node);
  167932             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  167933             :     Rose::MemPool::snapshot(oss.str());
  167934             :     alloc_trace_cnt++;
  167935             : #endif
  167936             : 
  167937           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  167938             : 
  167939           0 :     ALLOC_MUTEX(SgDictionaryComprehension, unlock);
  167940             : 
  167941             :     return object;
  167942             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  167943             : }
  167944             : 
  167945             : 
  167946             : 
  167947             : /*! \brief Delete operator for SgDictionaryComprehension.
  167948             : 
  167949             :    This delete operator implements deallocation using memory pools to 
  167950             :    provide most efficent use of the heap within construction of large ASTs.
  167951             : 
  167952             : \internal The new and delete operators use the lower level C malloc/free
  167953             :    function calls for performance and to make sure that mixing of malloc/free
  167954             :    and new/delete by the used can be caught more readily.  This may change
  167955             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  167956             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  167957             :    deallocate memory allocated using ROSE_MALLOC.
  167958             : */
  167959           0 : void SgDictionaryComprehension::operator delete(void *Pointer, size_t Size)
  167960             : {
  167961             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  167962             :      * or throwing an exception. */
  167963           0 :     ALLOC_MUTEX(SgDictionaryComprehension, lock);
  167964             : 
  167965             : #if USE_CPP_NEW_DELETE_OPERATORS
  167966             :     ROSE_FREE(Pointer);
  167967             : #else
  167968             : #if ROSE_PEDANTIC_ALLOC
  167969             :     ROSE_ASSERT(Size == sizeof(SgDictionaryComprehension));
  167970             : #else
  167971           0 :     if (Size != sizeof(SgDictionaryComprehension)) {
  167972           0 :       ROSE_FREE(Pointer);
  167973           0 :       ALLOC_MUTEX(SgDictionaryComprehension, unlock);
  167974             :       return;
  167975             :     }
  167976             : #endif
  167977             : 
  167978           0 :     SgDictionaryComprehension * object = (SgDictionaryComprehension*) Pointer;
  167979           0 :     ROSE_ASSERT(object != nullptr);
  167980             : 
  167981             : #if ROSE_ALLOC_TRACE == 2
  167982             : //  printf("SgDictionaryComprehension::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgDictionaryComprehension::next_node);
  167983             :     printf("SgDictionaryComprehension::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgDictionaryComprehension::next_node);
  167984             : #endif
  167985             : 
  167986             : #if ROSE_PEDANTIC_ALLOC
  167987             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  167988             : #endif
  167989             : 
  167990             : #if ROSE_ALLOC_MEMSET == 1
  167991             : #elif ROSE_ALLOC_MEMSET == 2
  167992             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgDictionaryComprehension) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  167993             : #elif ROSE_ALLOC_MEMSET == 3
  167994             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgDictionaryComprehension) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  167995             : #endif
  167996             : 
  167997             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  167998             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  167999             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  168000             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  168001             : #else
  168002           0 :     object->p_freepointer = SgDictionaryComprehension::next_node;
  168003           0 :     SgDictionaryComprehension::next_node = object;
  168004             : #endif
  168005             : 
  168006             : #if ROSE_ALLOC_TRACE == 2
  168007             : //  printf("SgDictionaryComprehension::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgDictionaryComprehension::next_node);
  168008             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  168009             :     Rose::MemPool::snapshot(oss.str());
  168010             :     alloc_trace_cnt++;
  168011             : #endif
  168012             : 
  168013             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  168014             : 
  168015           0 :     ALLOC_MUTEX(SgDictionaryComprehension, unlock);
  168016             : }
  168017             : 
  168018             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  168019             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  168020             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  168021             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  168022             : // Also, note comment below from Robb (copied from the Common.code file).
  168023             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  168024             : //
  168025             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  168026             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  168027             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  168028             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  168029             : #if 0
  168030             : void SgDictionaryComprehension::operator delete(void* pointer) { SgDictionaryComprehension::operator delete (pointer, sizeof(SgDictionaryComprehension)); };
  168031             : #endif
  168032             : /* #line 168033 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  168033             : 
  168034             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  168035             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  168036             : // obviously imply C++.
  168037             : 
  168038             : // This implements the support within ROSE for memory pools.  Memory pools
  168039             : // support the most condensed usage of memory within the construction of
  168040             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  168041             : // by a new operator written for each class.
  168042             : 
  168043             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  168044             :     // User wants multi-thread support and POSIX threads are available.
  168045             : #   include <pthread.h>
  168046             :     static pthread_mutex_t SgNaryOp_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  168047             : #else
  168048             :      // Cause synchronization to be skipped.
  168049             : #    ifndef ALLOC_MUTEX
  168050             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  168051             : #    endif
  168052             : #    ifdef _REENTRANT
  168053             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  168054             : #       ifdef _MSC_VER
  168055             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  168056             : #       else
  168057             : #           warning "POSIX threads are not available; synchronization being skipped"
  168058             : #       endif
  168059             : #    endif
  168060             : #endif
  168061             : 
  168062             : #ifndef ROSE_ALLOC_TRACE
  168063             : #  define ROSE_ALLOC_TRACE 0
  168064             : #endif
  168065             : 
  168066             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  168067             : #define ROSE_ALLOC_TRACE_CNT
  168068             : #include "memory-pool-snapshot.h"
  168069             : unsigned long alloc_trace_cnt = 0;
  168070             : #endif
  168071             : 
  168072             : #if ROSE_ALLOC_TRACE
  168073             : const unsigned SgNaryOp::pool_size = 5;
  168074             : #else
  168075             : const unsigned SgNaryOp::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  168076             : #endif
  168077             : 
  168078             : #ifndef ROSE_ALLOC_MEMSET
  168079             : #  define ROSE_ALLOC_MEMSET 0
  168080             : #endif
  168081             : 
  168082             : #ifndef ROSE_PEDANTIC_ALLOC
  168083             : #  define ROSE_PEDANTIC_ALLOC 0
  168084             : #endif
  168085             : 
  168086             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  168087             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  168088             : #endif
  168089             : 
  168090             : #if !defined(SGNODE__ALL_POOLS)
  168091             : #define SGNODE__ALL_POOLS
  168092             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  168093             : #endif
  168094             : 
  168095             : SgNaryOp* SgNaryOp::next_node = nullptr;
  168096             : std::vector<unsigned char*> SgNaryOp::pools;
  168097             : 
  168098             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  168099             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  168100             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  168101             : // around this macro definition rather than each use).
  168102             : #ifndef ALLOC_MUTEX
  168103             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  168104             :         do {                                                                     \
  168105             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  168106             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  168107             :                 abort();                                                         \
  168108             :             }                                                                    \
  168109             :         } while (0);
  168110             : #endif
  168111             : 
  168112             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  168113             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  168114             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  168115             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  168116             : 
  168117             : /*! \brief New operator for SgNaryOp.
  168118             : 
  168119             :    This new operator implements memory pools to provide most efficent 
  168120             :    use of the heap within construction of large ASTs.
  168121             : 
  168122             : \internal The new and delete operators use the lower level C malloc/free
  168123             :    function calls for performance and to make sure that mixing of malloc/free
  168124             :    and new/delete by the used can be caught more readily.  This may change
  168125             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  168126             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  168127             :    deallocate memory allocated using ROSE_MALLOC.
  168128             : */
  168129           0 : void *SgNaryOp::operator new ( size_t Size )
  168130             : {
  168131             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  168132             :      * returning or throwing an exception. */
  168133           0 :     ALLOC_MUTEX(SgNaryOp, lock);
  168134             : 
  168135             : #if ROSE_ALLOC_TRACE == 2
  168136             : //    printf("SgNaryOp::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgNaryOp::next_node);
  168137             : #endif
  168138             : 
  168139             : #if USE_CPP_NEW_DELETE_OPERATORS
  168140             :     void *mem = ROSE_MALLOC(Size);
  168141             :     ALLOC_MUTEX(SgNaryOp, unlock);
  168142             :     return mem;
  168143             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  168144             : #if ROSE_PEDANTIC_ALLOC
  168145             :     ROSE_ASSERT(Size == sizeof(SgNaryOp));
  168146             : #else
  168147           0 :     if (Size != sizeof(SgNaryOp)) {
  168148           0 :       void * object = ROSE_MALLOC(Size);
  168149           0 :       ALLOC_MUTEX(SgNaryOp, unlock);
  168150             :       return object;
  168151             :     }
  168152             : #endif
  168153             : 
  168154           0 :     if (SgNaryOp::next_node == nullptr) {
  168155           0 :         SgNaryOp * alloc = (SgNaryOp*) ROSE_MALLOC ( SgNaryOp::pool_size * sizeof(SgNaryOp) );
  168156           0 :         ROSE_ASSERT(alloc != nullptr);
  168157             : 
  168158             : #if ROSE_ALLOC_TRACE == 2
  168159             : //        printf("SgNaryOp::alloc\n  block[%zi] = [ %p , %p [\n", SgNaryOp::pools.size(), alloc, alloc + SgNaryOp::pool_size);
  168160             : #endif
  168161             : 
  168162             : #if ROSE_ALLOC_MEMSET == 1
  168163             : #elif ROSE_ALLOC_MEMSET == 2
  168164             :         memset(alloc, 0x00, SgNaryOp::pool_size * sizeof(SgNaryOp));
  168165             : #elif ROSE_ALLOC_MEMSET == 3
  168166             :         memset(alloc, 0xAA, SgNaryOp::pool_size * sizeof(SgNaryOp));
  168167             : #endif
  168168           0 :         for (unsigned i=0; i < SgNaryOp::pool_size-1; i++) {
  168169           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
  168170             :         }
  168171           0 :         alloc[SgNaryOp::pool_size-1].p_freepointer = nullptr;
  168172             : 
  168173           0 :         SgNaryOp::pools.push_back ( (unsigned char *) alloc );
  168174           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgNaryOp::pool_size * sizeof(SgNaryOp), V_SgNaryOp ) );
  168175           0 :         SgNaryOp::next_node = alloc;
  168176             :     }
  168177           0 :     ROSE_ASSERT(SgNaryOp::next_node != nullptr);
  168178             : 
  168179           0 :     SgNaryOp * object = SgNaryOp::next_node;
  168180           0 :     SgNaryOp::next_node = (SgNaryOp*)(object->p_freepointer);
  168181             : 
  168182             : #if ROSE_ALLOC_TRACE == 2
  168183             :     printf("SgNaryOp::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgNaryOp::next_node);
  168184             : #endif
  168185             : 
  168186           0 :     SgNode * fp = object->p_freepointer;
  168187             : #if ROSE_ALLOC_MEMSET == 1
  168188             : #elif ROSE_ALLOC_MEMSET == 2
  168189             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgNaryOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  168190             : #elif ROSE_ALLOC_MEMSET == 3
  168191             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgNaryOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  168192             : #endif
  168193           0 :     object->p_freepointer = fp;
  168194             : 
  168195             : #if ROSE_ALLOC_TRACE == 2
  168196             : //    printf("SgNaryOp::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgNaryOp::next_node);
  168197             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  168198             :     Rose::MemPool::snapshot(oss.str());
  168199             :     alloc_trace_cnt++;
  168200             : #endif
  168201             : 
  168202           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  168203             : 
  168204           0 :     ALLOC_MUTEX(SgNaryOp, unlock);
  168205             : 
  168206             :     return object;
  168207             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  168208             : }
  168209             : 
  168210             : 
  168211             : 
  168212             : /*! \brief Delete operator for SgNaryOp.
  168213             : 
  168214             :    This delete operator implements deallocation using memory pools to 
  168215             :    provide most efficent use of the heap within construction of large ASTs.
  168216             : 
  168217             : \internal The new and delete operators use the lower level C malloc/free
  168218             :    function calls for performance and to make sure that mixing of malloc/free
  168219             :    and new/delete by the used can be caught more readily.  This may change
  168220             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  168221             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  168222             :    deallocate memory allocated using ROSE_MALLOC.
  168223             : */
  168224           0 : void SgNaryOp::operator delete(void *Pointer, size_t Size)
  168225             : {
  168226             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  168227             :      * or throwing an exception. */
  168228           0 :     ALLOC_MUTEX(SgNaryOp, lock);
  168229             : 
  168230             : #if USE_CPP_NEW_DELETE_OPERATORS
  168231             :     ROSE_FREE(Pointer);
  168232             : #else
  168233             : #if ROSE_PEDANTIC_ALLOC
  168234             :     ROSE_ASSERT(Size == sizeof(SgNaryOp));
  168235             : #else
  168236           0 :     if (Size != sizeof(SgNaryOp)) {
  168237           0 :       ROSE_FREE(Pointer);
  168238           0 :       ALLOC_MUTEX(SgNaryOp, unlock);
  168239             :       return;
  168240             :     }
  168241             : #endif
  168242             : 
  168243           0 :     SgNaryOp * object = (SgNaryOp*) Pointer;
  168244           0 :     ROSE_ASSERT(object != nullptr);
  168245             : 
  168246             : #if ROSE_ALLOC_TRACE == 2
  168247             : //  printf("SgNaryOp::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgNaryOp::next_node);
  168248             :     printf("SgNaryOp::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgNaryOp::next_node);
  168249             : #endif
  168250             : 
  168251             : #if ROSE_PEDANTIC_ALLOC
  168252             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  168253             : #endif
  168254             : 
  168255             : #if ROSE_ALLOC_MEMSET == 1
  168256             : #elif ROSE_ALLOC_MEMSET == 2
  168257             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgNaryOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  168258             : #elif ROSE_ALLOC_MEMSET == 3
  168259             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgNaryOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  168260             : #endif
  168261             : 
  168262             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  168263             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  168264             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  168265             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  168266             : #else
  168267           0 :     object->p_freepointer = SgNaryOp::next_node;
  168268           0 :     SgNaryOp::next_node = object;
  168269             : #endif
  168270             : 
  168271             : #if ROSE_ALLOC_TRACE == 2
  168272             : //  printf("SgNaryOp::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgNaryOp::next_node);
  168273             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  168274             :     Rose::MemPool::snapshot(oss.str());
  168275             :     alloc_trace_cnt++;
  168276             : #endif
  168277             : 
  168278             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  168279             : 
  168280           0 :     ALLOC_MUTEX(SgNaryOp, unlock);
  168281             : }
  168282             : 
  168283             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  168284             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  168285             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  168286             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  168287             : // Also, note comment below from Robb (copied from the Common.code file).
  168288             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  168289             : //
  168290             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  168291             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  168292             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  168293             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  168294             : #if 0
  168295             : void SgNaryOp::operator delete(void* pointer) { SgNaryOp::operator delete (pointer, sizeof(SgNaryOp)); };
  168296             : #endif
  168297             : /* #line 168298 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  168298             : 
  168299             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  168300             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  168301             : // obviously imply C++.
  168302             : 
  168303             : // This implements the support within ROSE for memory pools.  Memory pools
  168304             : // support the most condensed usage of memory within the construction of
  168305             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  168306             : // by a new operator written for each class.
  168307             : 
  168308             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  168309             :     // User wants multi-thread support and POSIX threads are available.
  168310             : #   include <pthread.h>
  168311             :     static pthread_mutex_t SgNaryBooleanOp_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  168312             : #else
  168313             :      // Cause synchronization to be skipped.
  168314             : #    ifndef ALLOC_MUTEX
  168315             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  168316             : #    endif
  168317             : #    ifdef _REENTRANT
  168318             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  168319             : #       ifdef _MSC_VER
  168320             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  168321             : #       else
  168322             : #           warning "POSIX threads are not available; synchronization being skipped"
  168323             : #       endif
  168324             : #    endif
  168325             : #endif
  168326             : 
  168327             : #ifndef ROSE_ALLOC_TRACE
  168328             : #  define ROSE_ALLOC_TRACE 0
  168329             : #endif
  168330             : 
  168331             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  168332             : #define ROSE_ALLOC_TRACE_CNT
  168333             : #include "memory-pool-snapshot.h"
  168334             : unsigned long alloc_trace_cnt = 0;
  168335             : #endif
  168336             : 
  168337             : #if ROSE_ALLOC_TRACE
  168338             : const unsigned SgNaryBooleanOp::pool_size = 5;
  168339             : #else
  168340             : const unsigned SgNaryBooleanOp::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  168341             : #endif
  168342             : 
  168343             : #ifndef ROSE_ALLOC_MEMSET
  168344             : #  define ROSE_ALLOC_MEMSET 0
  168345             : #endif
  168346             : 
  168347             : #ifndef ROSE_PEDANTIC_ALLOC
  168348             : #  define ROSE_PEDANTIC_ALLOC 0
  168349             : #endif
  168350             : 
  168351             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  168352             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  168353             : #endif
  168354             : 
  168355             : #if !defined(SGNODE__ALL_POOLS)
  168356             : #define SGNODE__ALL_POOLS
  168357             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  168358             : #endif
  168359             : 
  168360             : SgNaryBooleanOp* SgNaryBooleanOp::next_node = nullptr;
  168361             : std::vector<unsigned char*> SgNaryBooleanOp::pools;
  168362             : 
  168363             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  168364             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  168365             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  168366             : // around this macro definition rather than each use).
  168367             : #ifndef ALLOC_MUTEX
  168368             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  168369             :         do {                                                                     \
  168370             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  168371             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  168372             :                 abort();                                                         \
  168373             :             }                                                                    \
  168374             :         } while (0);
  168375             : #endif
  168376             : 
  168377             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  168378             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  168379             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  168380             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  168381             : 
  168382             : /*! \brief New operator for SgNaryBooleanOp.
  168383             : 
  168384             :    This new operator implements memory pools to provide most efficent 
  168385             :    use of the heap within construction of large ASTs.
  168386             : 
  168387             : \internal The new and delete operators use the lower level C malloc/free
  168388             :    function calls for performance and to make sure that mixing of malloc/free
  168389             :    and new/delete by the used can be caught more readily.  This may change
  168390             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  168391             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  168392             :    deallocate memory allocated using ROSE_MALLOC.
  168393             : */
  168394           0 : void *SgNaryBooleanOp::operator new ( size_t Size )
  168395             : {
  168396             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  168397             :      * returning or throwing an exception. */
  168398           0 :     ALLOC_MUTEX(SgNaryBooleanOp, lock);
  168399             : 
  168400             : #if ROSE_ALLOC_TRACE == 2
  168401             : //    printf("SgNaryBooleanOp::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgNaryBooleanOp::next_node);
  168402             : #endif
  168403             : 
  168404             : #if USE_CPP_NEW_DELETE_OPERATORS
  168405             :     void *mem = ROSE_MALLOC(Size);
  168406             :     ALLOC_MUTEX(SgNaryBooleanOp, unlock);
  168407             :     return mem;
  168408             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  168409             : #if ROSE_PEDANTIC_ALLOC
  168410             :     ROSE_ASSERT(Size == sizeof(SgNaryBooleanOp));
  168411             : #else
  168412           0 :     if (Size != sizeof(SgNaryBooleanOp)) {
  168413           0 :       void * object = ROSE_MALLOC(Size);
  168414           0 :       ALLOC_MUTEX(SgNaryBooleanOp, unlock);
  168415             :       return object;
  168416             :     }
  168417             : #endif
  168418             : 
  168419           0 :     if (SgNaryBooleanOp::next_node == nullptr) {
  168420           0 :         SgNaryBooleanOp * alloc = (SgNaryBooleanOp*) ROSE_MALLOC ( SgNaryBooleanOp::pool_size * sizeof(SgNaryBooleanOp) );
  168421           0 :         ROSE_ASSERT(alloc != nullptr);
  168422             : 
  168423             : #if ROSE_ALLOC_TRACE == 2
  168424             : //        printf("SgNaryBooleanOp::alloc\n  block[%zi] = [ %p , %p [\n", SgNaryBooleanOp::pools.size(), alloc, alloc + SgNaryBooleanOp::pool_size);
  168425             : #endif
  168426             : 
  168427             : #if ROSE_ALLOC_MEMSET == 1
  168428             : #elif ROSE_ALLOC_MEMSET == 2
  168429             :         memset(alloc, 0x00, SgNaryBooleanOp::pool_size * sizeof(SgNaryBooleanOp));
  168430             : #elif ROSE_ALLOC_MEMSET == 3
  168431             :         memset(alloc, 0xAA, SgNaryBooleanOp::pool_size * sizeof(SgNaryBooleanOp));
  168432             : #endif
  168433           0 :         for (unsigned i=0; i < SgNaryBooleanOp::pool_size-1; i++) {
  168434           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
  168435             :         }
  168436           0 :         alloc[SgNaryBooleanOp::pool_size-1].p_freepointer = nullptr;
  168437             : 
  168438           0 :         SgNaryBooleanOp::pools.push_back ( (unsigned char *) alloc );
  168439           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgNaryBooleanOp::pool_size * sizeof(SgNaryBooleanOp), V_SgNaryBooleanOp ) );
  168440           0 :         SgNaryBooleanOp::next_node = alloc;
  168441             :     }
  168442           0 :     ROSE_ASSERT(SgNaryBooleanOp::next_node != nullptr);
  168443             : 
  168444           0 :     SgNaryBooleanOp * object = SgNaryBooleanOp::next_node;
  168445           0 :     SgNaryBooleanOp::next_node = (SgNaryBooleanOp*)(object->p_freepointer);
  168446             : 
  168447             : #if ROSE_ALLOC_TRACE == 2
  168448             :     printf("SgNaryBooleanOp::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgNaryBooleanOp::next_node);
  168449             : #endif
  168450             : 
  168451           0 :     SgNode * fp = object->p_freepointer;
  168452             : #if ROSE_ALLOC_MEMSET == 1
  168453             : #elif ROSE_ALLOC_MEMSET == 2
  168454             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgNaryBooleanOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  168455             : #elif ROSE_ALLOC_MEMSET == 3
  168456             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgNaryBooleanOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  168457             : #endif
  168458           0 :     object->p_freepointer = fp;
  168459             : 
  168460             : #if ROSE_ALLOC_TRACE == 2
  168461             : //    printf("SgNaryBooleanOp::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgNaryBooleanOp::next_node);
  168462             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  168463             :     Rose::MemPool::snapshot(oss.str());
  168464             :     alloc_trace_cnt++;
  168465             : #endif
  168466             : 
  168467           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  168468             : 
  168469           0 :     ALLOC_MUTEX(SgNaryBooleanOp, unlock);
  168470             : 
  168471             :     return object;
  168472             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  168473             : }
  168474             : 
  168475             : 
  168476             : 
  168477             : /*! \brief Delete operator for SgNaryBooleanOp.
  168478             : 
  168479             :    This delete operator implements deallocation using memory pools to 
  168480             :    provide most efficent use of the heap within construction of large ASTs.
  168481             : 
  168482             : \internal The new and delete operators use the lower level C malloc/free
  168483             :    function calls for performance and to make sure that mixing of malloc/free
  168484             :    and new/delete by the used can be caught more readily.  This may change
  168485             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  168486             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  168487             :    deallocate memory allocated using ROSE_MALLOC.
  168488             : */
  168489           0 : void SgNaryBooleanOp::operator delete(void *Pointer, size_t Size)
  168490             : {
  168491             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  168492             :      * or throwing an exception. */
  168493           0 :     ALLOC_MUTEX(SgNaryBooleanOp, lock);
  168494             : 
  168495             : #if USE_CPP_NEW_DELETE_OPERATORS
  168496             :     ROSE_FREE(Pointer);
  168497             : #else
  168498             : #if ROSE_PEDANTIC_ALLOC
  168499             :     ROSE_ASSERT(Size == sizeof(SgNaryBooleanOp));
  168500             : #else
  168501           0 :     if (Size != sizeof(SgNaryBooleanOp)) {
  168502           0 :       ROSE_FREE(Pointer);
  168503           0 :       ALLOC_MUTEX(SgNaryBooleanOp, unlock);
  168504             :       return;
  168505             :     }
  168506             : #endif
  168507             : 
  168508           0 :     SgNaryBooleanOp * object = (SgNaryBooleanOp*) Pointer;
  168509           0 :     ROSE_ASSERT(object != nullptr);
  168510             : 
  168511             : #if ROSE_ALLOC_TRACE == 2
  168512             : //  printf("SgNaryBooleanOp::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgNaryBooleanOp::next_node);
  168513             :     printf("SgNaryBooleanOp::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgNaryBooleanOp::next_node);
  168514             : #endif
  168515             : 
  168516             : #if ROSE_PEDANTIC_ALLOC
  168517             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  168518             : #endif
  168519             : 
  168520             : #if ROSE_ALLOC_MEMSET == 1
  168521             : #elif ROSE_ALLOC_MEMSET == 2
  168522             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgNaryBooleanOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  168523             : #elif ROSE_ALLOC_MEMSET == 3
  168524             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgNaryBooleanOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  168525             : #endif
  168526             : 
  168527             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  168528             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  168529             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  168530             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  168531             : #else
  168532           0 :     object->p_freepointer = SgNaryBooleanOp::next_node;
  168533           0 :     SgNaryBooleanOp::next_node = object;
  168534             : #endif
  168535             : 
  168536             : #if ROSE_ALLOC_TRACE == 2
  168537             : //  printf("SgNaryBooleanOp::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgNaryBooleanOp::next_node);
  168538             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  168539             :     Rose::MemPool::snapshot(oss.str());
  168540             :     alloc_trace_cnt++;
  168541             : #endif
  168542             : 
  168543             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  168544             : 
  168545           0 :     ALLOC_MUTEX(SgNaryBooleanOp, unlock);
  168546             : }
  168547             : 
  168548             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  168549             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  168550             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  168551             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  168552             : // Also, note comment below from Robb (copied from the Common.code file).
  168553             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  168554             : //
  168555             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  168556             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  168557             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  168558             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  168559             : #if 0
  168560             : void SgNaryBooleanOp::operator delete(void* pointer) { SgNaryBooleanOp::operator delete (pointer, sizeof(SgNaryBooleanOp)); };
  168561             : #endif
  168562             : /* #line 168563 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  168563             : 
  168564             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  168565             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  168566             : // obviously imply C++.
  168567             : 
  168568             : // This implements the support within ROSE for memory pools.  Memory pools
  168569             : // support the most condensed usage of memory within the construction of
  168570             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  168571             : // by a new operator written for each class.
  168572             : 
  168573             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  168574             :     // User wants multi-thread support and POSIX threads are available.
  168575             : #   include <pthread.h>
  168576             :     static pthread_mutex_t SgNaryComparisonOp_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  168577             : #else
  168578             :      // Cause synchronization to be skipped.
  168579             : #    ifndef ALLOC_MUTEX
  168580             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  168581             : #    endif
  168582             : #    ifdef _REENTRANT
  168583             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  168584             : #       ifdef _MSC_VER
  168585             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  168586             : #       else
  168587             : #           warning "POSIX threads are not available; synchronization being skipped"
  168588             : #       endif
  168589             : #    endif
  168590             : #endif
  168591             : 
  168592             : #ifndef ROSE_ALLOC_TRACE
  168593             : #  define ROSE_ALLOC_TRACE 0
  168594             : #endif
  168595             : 
  168596             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  168597             : #define ROSE_ALLOC_TRACE_CNT
  168598             : #include "memory-pool-snapshot.h"
  168599             : unsigned long alloc_trace_cnt = 0;
  168600             : #endif
  168601             : 
  168602             : #if ROSE_ALLOC_TRACE
  168603             : const unsigned SgNaryComparisonOp::pool_size = 5;
  168604             : #else
  168605             : const unsigned SgNaryComparisonOp::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  168606             : #endif
  168607             : 
  168608             : #ifndef ROSE_ALLOC_MEMSET
  168609             : #  define ROSE_ALLOC_MEMSET 0
  168610             : #endif
  168611             : 
  168612             : #ifndef ROSE_PEDANTIC_ALLOC
  168613             : #  define ROSE_PEDANTIC_ALLOC 0
  168614             : #endif
  168615             : 
  168616             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  168617             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  168618             : #endif
  168619             : 
  168620             : #if !defined(SGNODE__ALL_POOLS)
  168621             : #define SGNODE__ALL_POOLS
  168622             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  168623             : #endif
  168624             : 
  168625             : SgNaryComparisonOp* SgNaryComparisonOp::next_node = nullptr;
  168626             : std::vector<unsigned char*> SgNaryComparisonOp::pools;
  168627             : 
  168628             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  168629             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  168630             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  168631             : // around this macro definition rather than each use).
  168632             : #ifndef ALLOC_MUTEX
  168633             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  168634             :         do {                                                                     \
  168635             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  168636             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  168637             :                 abort();                                                         \
  168638             :             }                                                                    \
  168639             :         } while (0);
  168640             : #endif
  168641             : 
  168642             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  168643             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  168644             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  168645             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  168646             : 
  168647             : /*! \brief New operator for SgNaryComparisonOp.
  168648             : 
  168649             :    This new operator implements memory pools to provide most efficent 
  168650             :    use of the heap within construction of large ASTs.
  168651             : 
  168652             : \internal The new and delete operators use the lower level C malloc/free
  168653             :    function calls for performance and to make sure that mixing of malloc/free
  168654             :    and new/delete by the used can be caught more readily.  This may change
  168655             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  168656             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  168657             :    deallocate memory allocated using ROSE_MALLOC.
  168658             : */
  168659           0 : void *SgNaryComparisonOp::operator new ( size_t Size )
  168660             : {
  168661             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  168662             :      * returning or throwing an exception. */
  168663           0 :     ALLOC_MUTEX(SgNaryComparisonOp, lock);
  168664             : 
  168665             : #if ROSE_ALLOC_TRACE == 2
  168666             : //    printf("SgNaryComparisonOp::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgNaryComparisonOp::next_node);
  168667             : #endif
  168668             : 
  168669             : #if USE_CPP_NEW_DELETE_OPERATORS
  168670             :     void *mem = ROSE_MALLOC(Size);
  168671             :     ALLOC_MUTEX(SgNaryComparisonOp, unlock);
  168672             :     return mem;
  168673             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  168674             : #if ROSE_PEDANTIC_ALLOC
  168675             :     ROSE_ASSERT(Size == sizeof(SgNaryComparisonOp));
  168676             : #else
  168677           0 :     if (Size != sizeof(SgNaryComparisonOp)) {
  168678           0 :       void * object = ROSE_MALLOC(Size);
  168679           0 :       ALLOC_MUTEX(SgNaryComparisonOp, unlock);
  168680             :       return object;
  168681             :     }
  168682             : #endif
  168683             : 
  168684           0 :     if (SgNaryComparisonOp::next_node == nullptr) {
  168685           0 :         SgNaryComparisonOp * alloc = (SgNaryComparisonOp*) ROSE_MALLOC ( SgNaryComparisonOp::pool_size * sizeof(SgNaryComparisonOp) );
  168686           0 :         ROSE_ASSERT(alloc != nullptr);
  168687             : 
  168688             : #if ROSE_ALLOC_TRACE == 2
  168689             : //        printf("SgNaryComparisonOp::alloc\n  block[%zi] = [ %p , %p [\n", SgNaryComparisonOp::pools.size(), alloc, alloc + SgNaryComparisonOp::pool_size);
  168690             : #endif
  168691             : 
  168692             : #if ROSE_ALLOC_MEMSET == 1
  168693             : #elif ROSE_ALLOC_MEMSET == 2
  168694             :         memset(alloc, 0x00, SgNaryComparisonOp::pool_size * sizeof(SgNaryComparisonOp));
  168695             : #elif ROSE_ALLOC_MEMSET == 3
  168696             :         memset(alloc, 0xAA, SgNaryComparisonOp::pool_size * sizeof(SgNaryComparisonOp));
  168697             : #endif
  168698           0 :         for (unsigned i=0; i < SgNaryComparisonOp::pool_size-1; i++) {
  168699           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
  168700             :         }
  168701           0 :         alloc[SgNaryComparisonOp::pool_size-1].p_freepointer = nullptr;
  168702             : 
  168703           0 :         SgNaryComparisonOp::pools.push_back ( (unsigned char *) alloc );
  168704           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgNaryComparisonOp::pool_size * sizeof(SgNaryComparisonOp), V_SgNaryComparisonOp ) );
  168705           0 :         SgNaryComparisonOp::next_node = alloc;
  168706             :     }
  168707           0 :     ROSE_ASSERT(SgNaryComparisonOp::next_node != nullptr);
  168708             : 
  168709           0 :     SgNaryComparisonOp * object = SgNaryComparisonOp::next_node;
  168710           0 :     SgNaryComparisonOp::next_node = (SgNaryComparisonOp*)(object->p_freepointer);
  168711             : 
  168712             : #if ROSE_ALLOC_TRACE == 2
  168713             :     printf("SgNaryComparisonOp::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgNaryComparisonOp::next_node);
  168714             : #endif
  168715             : 
  168716           0 :     SgNode * fp = object->p_freepointer;
  168717             : #if ROSE_ALLOC_MEMSET == 1
  168718             : #elif ROSE_ALLOC_MEMSET == 2
  168719             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgNaryComparisonOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  168720             : #elif ROSE_ALLOC_MEMSET == 3
  168721             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgNaryComparisonOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  168722             : #endif
  168723           0 :     object->p_freepointer = fp;
  168724             : 
  168725             : #if ROSE_ALLOC_TRACE == 2
  168726             : //    printf("SgNaryComparisonOp::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgNaryComparisonOp::next_node);
  168727             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  168728             :     Rose::MemPool::snapshot(oss.str());
  168729             :     alloc_trace_cnt++;
  168730             : #endif
  168731             : 
  168732           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  168733             : 
  168734           0 :     ALLOC_MUTEX(SgNaryComparisonOp, unlock);
  168735             : 
  168736             :     return object;
  168737             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  168738             : }
  168739             : 
  168740             : 
  168741             : 
  168742             : /*! \brief Delete operator for SgNaryComparisonOp.
  168743             : 
  168744             :    This delete operator implements deallocation using memory pools to 
  168745             :    provide most efficent use of the heap within construction of large ASTs.
  168746             : 
  168747             : \internal The new and delete operators use the lower level C malloc/free
  168748             :    function calls for performance and to make sure that mixing of malloc/free
  168749             :    and new/delete by the used can be caught more readily.  This may change
  168750             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  168751             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  168752             :    deallocate memory allocated using ROSE_MALLOC.
  168753             : */
  168754           0 : void SgNaryComparisonOp::operator delete(void *Pointer, size_t Size)
  168755             : {
  168756             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  168757             :      * or throwing an exception. */
  168758           0 :     ALLOC_MUTEX(SgNaryComparisonOp, lock);
  168759             : 
  168760             : #if USE_CPP_NEW_DELETE_OPERATORS
  168761             :     ROSE_FREE(Pointer);
  168762             : #else
  168763             : #if ROSE_PEDANTIC_ALLOC
  168764             :     ROSE_ASSERT(Size == sizeof(SgNaryComparisonOp));
  168765             : #else
  168766           0 :     if (Size != sizeof(SgNaryComparisonOp)) {
  168767           0 :       ROSE_FREE(Pointer);
  168768           0 :       ALLOC_MUTEX(SgNaryComparisonOp, unlock);
  168769             :       return;
  168770             :     }
  168771             : #endif
  168772             : 
  168773           0 :     SgNaryComparisonOp * object = (SgNaryComparisonOp*) Pointer;
  168774           0 :     ROSE_ASSERT(object != nullptr);
  168775             : 
  168776             : #if ROSE_ALLOC_TRACE == 2
  168777             : //  printf("SgNaryComparisonOp::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgNaryComparisonOp::next_node);
  168778             :     printf("SgNaryComparisonOp::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgNaryComparisonOp::next_node);
  168779             : #endif
  168780             : 
  168781             : #if ROSE_PEDANTIC_ALLOC
  168782             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  168783             : #endif
  168784             : 
  168785             : #if ROSE_ALLOC_MEMSET == 1
  168786             : #elif ROSE_ALLOC_MEMSET == 2
  168787             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgNaryComparisonOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  168788             : #elif ROSE_ALLOC_MEMSET == 3
  168789             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgNaryComparisonOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  168790             : #endif
  168791             : 
  168792             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  168793             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  168794             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  168795             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  168796             : #else
  168797           0 :     object->p_freepointer = SgNaryComparisonOp::next_node;
  168798           0 :     SgNaryComparisonOp::next_node = object;
  168799             : #endif
  168800             : 
  168801             : #if ROSE_ALLOC_TRACE == 2
  168802             : //  printf("SgNaryComparisonOp::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgNaryComparisonOp::next_node);
  168803             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  168804             :     Rose::MemPool::snapshot(oss.str());
  168805             :     alloc_trace_cnt++;
  168806             : #endif
  168807             : 
  168808             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  168809             : 
  168810           0 :     ALLOC_MUTEX(SgNaryComparisonOp, unlock);
  168811             : }
  168812             : 
  168813             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  168814             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  168815             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  168816             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  168817             : // Also, note comment below from Robb (copied from the Common.code file).
  168818             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  168819             : //
  168820             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  168821             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  168822             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  168823             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  168824             : #if 0
  168825             : void SgNaryComparisonOp::operator delete(void* pointer) { SgNaryComparisonOp::operator delete (pointer, sizeof(SgNaryComparisonOp)); };
  168826             : #endif
  168827             : /* #line 168828 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  168828             : 
  168829             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  168830             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  168831             : // obviously imply C++.
  168832             : 
  168833             : // This implements the support within ROSE for memory pools.  Memory pools
  168834             : // support the most condensed usage of memory within the construction of
  168835             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  168836             : // by a new operator written for each class.
  168837             : 
  168838             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  168839             :     // User wants multi-thread support and POSIX threads are available.
  168840             : #   include <pthread.h>
  168841             :     static pthread_mutex_t SgStringConversion_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  168842             : #else
  168843             :      // Cause synchronization to be skipped.
  168844             : #    ifndef ALLOC_MUTEX
  168845             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  168846             : #    endif
  168847             : #    ifdef _REENTRANT
  168848             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  168849             : #       ifdef _MSC_VER
  168850             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  168851             : #       else
  168852             : #           warning "POSIX threads are not available; synchronization being skipped"
  168853             : #       endif
  168854             : #    endif
  168855             : #endif
  168856             : 
  168857             : #ifndef ROSE_ALLOC_TRACE
  168858             : #  define ROSE_ALLOC_TRACE 0
  168859             : #endif
  168860             : 
  168861             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  168862             : #define ROSE_ALLOC_TRACE_CNT
  168863             : #include "memory-pool-snapshot.h"
  168864             : unsigned long alloc_trace_cnt = 0;
  168865             : #endif
  168866             : 
  168867             : #if ROSE_ALLOC_TRACE
  168868             : const unsigned SgStringConversion::pool_size = 5;
  168869             : #else
  168870             : const unsigned SgStringConversion::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  168871             : #endif
  168872             : 
  168873             : #ifndef ROSE_ALLOC_MEMSET
  168874             : #  define ROSE_ALLOC_MEMSET 0
  168875             : #endif
  168876             : 
  168877             : #ifndef ROSE_PEDANTIC_ALLOC
  168878             : #  define ROSE_PEDANTIC_ALLOC 0
  168879             : #endif
  168880             : 
  168881             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  168882             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  168883             : #endif
  168884             : 
  168885             : #if !defined(SGNODE__ALL_POOLS)
  168886             : #define SGNODE__ALL_POOLS
  168887             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  168888             : #endif
  168889             : 
  168890             : SgStringConversion* SgStringConversion::next_node = nullptr;
  168891             : std::vector<unsigned char*> SgStringConversion::pools;
  168892             : 
  168893             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  168894             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  168895             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  168896             : // around this macro definition rather than each use).
  168897             : #ifndef ALLOC_MUTEX
  168898             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  168899             :         do {                                                                     \
  168900             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  168901             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  168902             :                 abort();                                                         \
  168903             :             }                                                                    \
  168904             :         } while (0);
  168905             : #endif
  168906             : 
  168907             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  168908             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  168909             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  168910             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  168911             : 
  168912             : /*! \brief New operator for SgStringConversion.
  168913             : 
  168914             :    This new operator implements memory pools to provide most efficent 
  168915             :    use of the heap within construction of large ASTs.
  168916             : 
  168917             : \internal The new and delete operators use the lower level C malloc/free
  168918             :    function calls for performance and to make sure that mixing of malloc/free
  168919             :    and new/delete by the used can be caught more readily.  This may change
  168920             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  168921             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  168922             :    deallocate memory allocated using ROSE_MALLOC.
  168923             : */
  168924           0 : void *SgStringConversion::operator new ( size_t Size )
  168925             : {
  168926             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  168927             :      * returning or throwing an exception. */
  168928           0 :     ALLOC_MUTEX(SgStringConversion, lock);
  168929             : 
  168930             : #if ROSE_ALLOC_TRACE == 2
  168931             : //    printf("SgStringConversion::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgStringConversion::next_node);
  168932             : #endif
  168933             : 
  168934             : #if USE_CPP_NEW_DELETE_OPERATORS
  168935             :     void *mem = ROSE_MALLOC(Size);
  168936             :     ALLOC_MUTEX(SgStringConversion, unlock);
  168937             :     return mem;
  168938             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  168939             : #if ROSE_PEDANTIC_ALLOC
  168940             :     ROSE_ASSERT(Size == sizeof(SgStringConversion));
  168941             : #else
  168942           0 :     if (Size != sizeof(SgStringConversion)) {
  168943           0 :       void * object = ROSE_MALLOC(Size);
  168944           0 :       ALLOC_MUTEX(SgStringConversion, unlock);
  168945             :       return object;
  168946             :     }
  168947             : #endif
  168948             : 
  168949           0 :     if (SgStringConversion::next_node == nullptr) {
  168950           0 :         SgStringConversion * alloc = (SgStringConversion*) ROSE_MALLOC ( SgStringConversion::pool_size * sizeof(SgStringConversion) );
  168951           0 :         ROSE_ASSERT(alloc != nullptr);
  168952             : 
  168953             : #if ROSE_ALLOC_TRACE == 2
  168954             : //        printf("SgStringConversion::alloc\n  block[%zi] = [ %p , %p [\n", SgStringConversion::pools.size(), alloc, alloc + SgStringConversion::pool_size);
  168955             : #endif
  168956             : 
  168957             : #if ROSE_ALLOC_MEMSET == 1
  168958             : #elif ROSE_ALLOC_MEMSET == 2
  168959             :         memset(alloc, 0x00, SgStringConversion::pool_size * sizeof(SgStringConversion));
  168960             : #elif ROSE_ALLOC_MEMSET == 3
  168961             :         memset(alloc, 0xAA, SgStringConversion::pool_size * sizeof(SgStringConversion));
  168962             : #endif
  168963           0 :         for (unsigned i=0; i < SgStringConversion::pool_size-1; i++) {
  168964           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
  168965             :         }
  168966           0 :         alloc[SgStringConversion::pool_size-1].p_freepointer = nullptr;
  168967             : 
  168968           0 :         SgStringConversion::pools.push_back ( (unsigned char *) alloc );
  168969           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgStringConversion::pool_size * sizeof(SgStringConversion), V_SgStringConversion ) );
  168970           0 :         SgStringConversion::next_node = alloc;
  168971             :     }
  168972           0 :     ROSE_ASSERT(SgStringConversion::next_node != nullptr);
  168973             : 
  168974           0 :     SgStringConversion * object = SgStringConversion::next_node;
  168975           0 :     SgStringConversion::next_node = (SgStringConversion*)(object->p_freepointer);
  168976             : 
  168977             : #if ROSE_ALLOC_TRACE == 2
  168978             :     printf("SgStringConversion::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgStringConversion::next_node);
  168979             : #endif
  168980             : 
  168981           0 :     SgNode * fp = object->p_freepointer;
  168982             : #if ROSE_ALLOC_MEMSET == 1
  168983             : #elif ROSE_ALLOC_MEMSET == 2
  168984             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgStringConversion) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  168985             : #elif ROSE_ALLOC_MEMSET == 3
  168986             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgStringConversion) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  168987             : #endif
  168988           0 :     object->p_freepointer = fp;
  168989             : 
  168990             : #if ROSE_ALLOC_TRACE == 2
  168991             : //    printf("SgStringConversion::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgStringConversion::next_node);
  168992             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  168993             :     Rose::MemPool::snapshot(oss.str());
  168994             :     alloc_trace_cnt++;
  168995             : #endif
  168996             : 
  168997           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  168998             : 
  168999           0 :     ALLOC_MUTEX(SgStringConversion, unlock);
  169000             : 
  169001             :     return object;
  169002             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  169003             : }
  169004             : 
  169005             : 
  169006             : 
  169007             : /*! \brief Delete operator for SgStringConversion.
  169008             : 
  169009             :    This delete operator implements deallocation using memory pools to 
  169010             :    provide most efficent use of the heap within construction of large ASTs.
  169011             : 
  169012             : \internal The new and delete operators use the lower level C malloc/free
  169013             :    function calls for performance and to make sure that mixing of malloc/free
  169014             :    and new/delete by the used can be caught more readily.  This may change
  169015             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  169016             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  169017             :    deallocate memory allocated using ROSE_MALLOC.
  169018             : */
  169019           0 : void SgStringConversion::operator delete(void *Pointer, size_t Size)
  169020             : {
  169021             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  169022             :      * or throwing an exception. */
  169023           0 :     ALLOC_MUTEX(SgStringConversion, lock);
  169024             : 
  169025             : #if USE_CPP_NEW_DELETE_OPERATORS
  169026             :     ROSE_FREE(Pointer);
  169027             : #else
  169028             : #if ROSE_PEDANTIC_ALLOC
  169029             :     ROSE_ASSERT(Size == sizeof(SgStringConversion));
  169030             : #else
  169031           0 :     if (Size != sizeof(SgStringConversion)) {
  169032           0 :       ROSE_FREE(Pointer);
  169033           0 :       ALLOC_MUTEX(SgStringConversion, unlock);
  169034             :       return;
  169035             :     }
  169036             : #endif
  169037             : 
  169038           0 :     SgStringConversion * object = (SgStringConversion*) Pointer;
  169039           0 :     ROSE_ASSERT(object != nullptr);
  169040             : 
  169041             : #if ROSE_ALLOC_TRACE == 2
  169042             : //  printf("SgStringConversion::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgStringConversion::next_node);
  169043             :     printf("SgStringConversion::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgStringConversion::next_node);
  169044             : #endif
  169045             : 
  169046             : #if ROSE_PEDANTIC_ALLOC
  169047             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  169048             : #endif
  169049             : 
  169050             : #if ROSE_ALLOC_MEMSET == 1
  169051             : #elif ROSE_ALLOC_MEMSET == 2
  169052             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgStringConversion) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  169053             : #elif ROSE_ALLOC_MEMSET == 3
  169054             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgStringConversion) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  169055             : #endif
  169056             : 
  169057             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  169058             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  169059             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  169060             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  169061             : #else
  169062           0 :     object->p_freepointer = SgStringConversion::next_node;
  169063           0 :     SgStringConversion::next_node = object;
  169064             : #endif
  169065             : 
  169066             : #if ROSE_ALLOC_TRACE == 2
  169067             : //  printf("SgStringConversion::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgStringConversion::next_node);
  169068             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  169069             :     Rose::MemPool::snapshot(oss.str());
  169070             :     alloc_trace_cnt++;
  169071             : #endif
  169072             : 
  169073             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  169074             : 
  169075           0 :     ALLOC_MUTEX(SgStringConversion, unlock);
  169076             : }
  169077             : 
  169078             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  169079             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  169080             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  169081             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  169082             : // Also, note comment below from Robb (copied from the Common.code file).
  169083             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  169084             : //
  169085             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  169086             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  169087             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  169088             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  169089             : #if 0
  169090             : void SgStringConversion::operator delete(void* pointer) { SgStringConversion::operator delete (pointer, sizeof(SgStringConversion)); };
  169091             : #endif
  169092             : /* #line 169093 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  169093             : 
  169094             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  169095             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  169096             : // obviously imply C++.
  169097             : 
  169098             : // This implements the support within ROSE for memory pools.  Memory pools
  169099             : // support the most condensed usage of memory within the construction of
  169100             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  169101             : // by a new operator written for each class.
  169102             : 
  169103             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  169104             :     // User wants multi-thread support and POSIX threads are available.
  169105             : #   include <pthread.h>
  169106             :     static pthread_mutex_t SgYieldExpression_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  169107             : #else
  169108             :      // Cause synchronization to be skipped.
  169109             : #    ifndef ALLOC_MUTEX
  169110             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  169111             : #    endif
  169112             : #    ifdef _REENTRANT
  169113             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  169114             : #       ifdef _MSC_VER
  169115             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  169116             : #       else
  169117             : #           warning "POSIX threads are not available; synchronization being skipped"
  169118             : #       endif
  169119             : #    endif
  169120             : #endif
  169121             : 
  169122             : #ifndef ROSE_ALLOC_TRACE
  169123             : #  define ROSE_ALLOC_TRACE 0
  169124             : #endif
  169125             : 
  169126             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  169127             : #define ROSE_ALLOC_TRACE_CNT
  169128             : #include "memory-pool-snapshot.h"
  169129             : unsigned long alloc_trace_cnt = 0;
  169130             : #endif
  169131             : 
  169132             : #if ROSE_ALLOC_TRACE
  169133             : const unsigned SgYieldExpression::pool_size = 5;
  169134             : #else
  169135             : const unsigned SgYieldExpression::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  169136             : #endif
  169137             : 
  169138             : #ifndef ROSE_ALLOC_MEMSET
  169139             : #  define ROSE_ALLOC_MEMSET 0
  169140             : #endif
  169141             : 
  169142             : #ifndef ROSE_PEDANTIC_ALLOC
  169143             : #  define ROSE_PEDANTIC_ALLOC 0
  169144             : #endif
  169145             : 
  169146             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  169147             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  169148             : #endif
  169149             : 
  169150             : #if !defined(SGNODE__ALL_POOLS)
  169151             : #define SGNODE__ALL_POOLS
  169152             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  169153             : #endif
  169154             : 
  169155             : SgYieldExpression* SgYieldExpression::next_node = nullptr;
  169156             : std::vector<unsigned char*> SgYieldExpression::pools;
  169157             : 
  169158             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  169159             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  169160             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  169161             : // around this macro definition rather than each use).
  169162             : #ifndef ALLOC_MUTEX
  169163             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  169164             :         do {                                                                     \
  169165             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  169166             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  169167             :                 abort();                                                         \
  169168             :             }                                                                    \
  169169             :         } while (0);
  169170             : #endif
  169171             : 
  169172             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  169173             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  169174             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  169175             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  169176             : 
  169177             : /*! \brief New operator for SgYieldExpression.
  169178             : 
  169179             :    This new operator implements memory pools to provide most efficent 
  169180             :    use of the heap within construction of large ASTs.
  169181             : 
  169182             : \internal The new and delete operators use the lower level C malloc/free
  169183             :    function calls for performance and to make sure that mixing of malloc/free
  169184             :    and new/delete by the used can be caught more readily.  This may change
  169185             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  169186             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  169187             :    deallocate memory allocated using ROSE_MALLOC.
  169188             : */
  169189           0 : void *SgYieldExpression::operator new ( size_t Size )
  169190             : {
  169191             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  169192             :      * returning or throwing an exception. */
  169193           0 :     ALLOC_MUTEX(SgYieldExpression, lock);
  169194             : 
  169195             : #if ROSE_ALLOC_TRACE == 2
  169196             : //    printf("SgYieldExpression::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgYieldExpression::next_node);
  169197             : #endif
  169198             : 
  169199             : #if USE_CPP_NEW_DELETE_OPERATORS
  169200             :     void *mem = ROSE_MALLOC(Size);
  169201             :     ALLOC_MUTEX(SgYieldExpression, unlock);
  169202             :     return mem;
  169203             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  169204             : #if ROSE_PEDANTIC_ALLOC
  169205             :     ROSE_ASSERT(Size == sizeof(SgYieldExpression));
  169206             : #else
  169207           0 :     if (Size != sizeof(SgYieldExpression)) {
  169208           0 :       void * object = ROSE_MALLOC(Size);
  169209           0 :       ALLOC_MUTEX(SgYieldExpression, unlock);
  169210             :       return object;
  169211             :     }
  169212             : #endif
  169213             : 
  169214           0 :     if (SgYieldExpression::next_node == nullptr) {
  169215           0 :         SgYieldExpression * alloc = (SgYieldExpression*) ROSE_MALLOC ( SgYieldExpression::pool_size * sizeof(SgYieldExpression) );
  169216           0 :         ROSE_ASSERT(alloc != nullptr);
  169217             : 
  169218             : #if ROSE_ALLOC_TRACE == 2
  169219             : //        printf("SgYieldExpression::alloc\n  block[%zi] = [ %p , %p [\n", SgYieldExpression::pools.size(), alloc, alloc + SgYieldExpression::pool_size);
  169220             : #endif
  169221             : 
  169222             : #if ROSE_ALLOC_MEMSET == 1
  169223             : #elif ROSE_ALLOC_MEMSET == 2
  169224             :         memset(alloc, 0x00, SgYieldExpression::pool_size * sizeof(SgYieldExpression));
  169225             : #elif ROSE_ALLOC_MEMSET == 3
  169226             :         memset(alloc, 0xAA, SgYieldExpression::pool_size * sizeof(SgYieldExpression));
  169227             : #endif
  169228           0 :         for (unsigned i=0; i < SgYieldExpression::pool_size-1; i++) {
  169229           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
  169230             :         }
  169231           0 :         alloc[SgYieldExpression::pool_size-1].p_freepointer = nullptr;
  169232             : 
  169233           0 :         SgYieldExpression::pools.push_back ( (unsigned char *) alloc );
  169234           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgYieldExpression::pool_size * sizeof(SgYieldExpression), V_SgYieldExpression ) );
  169235           0 :         SgYieldExpression::next_node = alloc;
  169236             :     }
  169237           0 :     ROSE_ASSERT(SgYieldExpression::next_node != nullptr);
  169238             : 
  169239           0 :     SgYieldExpression * object = SgYieldExpression::next_node;
  169240           0 :     SgYieldExpression::next_node = (SgYieldExpression*)(object->p_freepointer);
  169241             : 
  169242             : #if ROSE_ALLOC_TRACE == 2
  169243             :     printf("SgYieldExpression::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgYieldExpression::next_node);
  169244             : #endif
  169245             : 
  169246           0 :     SgNode * fp = object->p_freepointer;
  169247             : #if ROSE_ALLOC_MEMSET == 1
  169248             : #elif ROSE_ALLOC_MEMSET == 2
  169249             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgYieldExpression) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  169250             : #elif ROSE_ALLOC_MEMSET == 3
  169251             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgYieldExpression) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  169252             : #endif
  169253           0 :     object->p_freepointer = fp;
  169254             : 
  169255             : #if ROSE_ALLOC_TRACE == 2
  169256             : //    printf("SgYieldExpression::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgYieldExpression::next_node);
  169257             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  169258             :     Rose::MemPool::snapshot(oss.str());
  169259             :     alloc_trace_cnt++;
  169260             : #endif
  169261             : 
  169262           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  169263             : 
  169264           0 :     ALLOC_MUTEX(SgYieldExpression, unlock);
  169265             : 
  169266             :     return object;
  169267             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  169268             : }
  169269             : 
  169270             : 
  169271             : 
  169272             : /*! \brief Delete operator for SgYieldExpression.
  169273             : 
  169274             :    This delete operator implements deallocation using memory pools to 
  169275             :    provide most efficent use of the heap within construction of large ASTs.
  169276             : 
  169277             : \internal The new and delete operators use the lower level C malloc/free
  169278             :    function calls for performance and to make sure that mixing of malloc/free
  169279             :    and new/delete by the used can be caught more readily.  This may change
  169280             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  169281             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  169282             :    deallocate memory allocated using ROSE_MALLOC.
  169283             : */
  169284           0 : void SgYieldExpression::operator delete(void *Pointer, size_t Size)
  169285             : {
  169286             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  169287             :      * or throwing an exception. */
  169288           0 :     ALLOC_MUTEX(SgYieldExpression, lock);
  169289             : 
  169290             : #if USE_CPP_NEW_DELETE_OPERATORS
  169291             :     ROSE_FREE(Pointer);
  169292             : #else
  169293             : #if ROSE_PEDANTIC_ALLOC
  169294             :     ROSE_ASSERT(Size == sizeof(SgYieldExpression));
  169295             : #else
  169296           0 :     if (Size != sizeof(SgYieldExpression)) {
  169297           0 :       ROSE_FREE(Pointer);
  169298           0 :       ALLOC_MUTEX(SgYieldExpression, unlock);
  169299             :       return;
  169300             :     }
  169301             : #endif
  169302             : 
  169303           0 :     SgYieldExpression * object = (SgYieldExpression*) Pointer;
  169304           0 :     ROSE_ASSERT(object != nullptr);
  169305             : 
  169306             : #if ROSE_ALLOC_TRACE == 2
  169307             : //  printf("SgYieldExpression::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgYieldExpression::next_node);
  169308             :     printf("SgYieldExpression::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgYieldExpression::next_node);
  169309             : #endif
  169310             : 
  169311             : #if ROSE_PEDANTIC_ALLOC
  169312             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  169313             : #endif
  169314             : 
  169315             : #if ROSE_ALLOC_MEMSET == 1
  169316             : #elif ROSE_ALLOC_MEMSET == 2
  169317             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgYieldExpression) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  169318             : #elif ROSE_ALLOC_MEMSET == 3
  169319             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgYieldExpression) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  169320             : #endif
  169321             : 
  169322             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  169323             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  169324             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  169325             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  169326             : #else
  169327           0 :     object->p_freepointer = SgYieldExpression::next_node;
  169328           0 :     SgYieldExpression::next_node = object;
  169329             : #endif
  169330             : 
  169331             : #if ROSE_ALLOC_TRACE == 2
  169332             : //  printf("SgYieldExpression::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgYieldExpression::next_node);
  169333             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  169334             :     Rose::MemPool::snapshot(oss.str());
  169335             :     alloc_trace_cnt++;
  169336             : #endif
  169337             : 
  169338             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  169339             : 
  169340           0 :     ALLOC_MUTEX(SgYieldExpression, unlock);
  169341             : }
  169342             : 
  169343             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  169344             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  169345             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  169346             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  169347             : // Also, note comment below from Robb (copied from the Common.code file).
  169348             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  169349             : //
  169350             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  169351             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  169352             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  169353             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  169354             : #if 0
  169355             : void SgYieldExpression::operator delete(void* pointer) { SgYieldExpression::operator delete (pointer, sizeof(SgYieldExpression)); };
  169356             : #endif
  169357             : /* #line 169358 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  169358             : 
  169359             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  169360             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  169361             : // obviously imply C++.
  169362             : 
  169363             : // This implements the support within ROSE for memory pools.  Memory pools
  169364             : // support the most condensed usage of memory within the construction of
  169365             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  169366             : // by a new operator written for each class.
  169367             : 
  169368             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  169369             :     // User wants multi-thread support and POSIX threads are available.
  169370             : #   include <pthread.h>
  169371             :     static pthread_mutex_t SgTemplateFunctionRefExp_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  169372             : #else
  169373             :      // Cause synchronization to be skipped.
  169374             : #    ifndef ALLOC_MUTEX
  169375             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  169376             : #    endif
  169377             : #    ifdef _REENTRANT
  169378             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  169379             : #       ifdef _MSC_VER
  169380             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  169381             : #       else
  169382             : #           warning "POSIX threads are not available; synchronization being skipped"
  169383             : #       endif
  169384             : #    endif
  169385             : #endif
  169386             : 
  169387             : #ifndef ROSE_ALLOC_TRACE
  169388             : #  define ROSE_ALLOC_TRACE 0
  169389             : #endif
  169390             : 
  169391             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  169392             : #define ROSE_ALLOC_TRACE_CNT
  169393             : #include "memory-pool-snapshot.h"
  169394             : unsigned long alloc_trace_cnt = 0;
  169395             : #endif
  169396             : 
  169397             : #if ROSE_ALLOC_TRACE
  169398             : const unsigned SgTemplateFunctionRefExp::pool_size = 5;
  169399             : #else
  169400             : const unsigned SgTemplateFunctionRefExp::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  169401             : #endif
  169402             : 
  169403             : #ifndef ROSE_ALLOC_MEMSET
  169404             : #  define ROSE_ALLOC_MEMSET 0
  169405             : #endif
  169406             : 
  169407             : #ifndef ROSE_PEDANTIC_ALLOC
  169408             : #  define ROSE_PEDANTIC_ALLOC 0
  169409             : #endif
  169410             : 
  169411             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  169412             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  169413             : #endif
  169414             : 
  169415             : #if !defined(SGNODE__ALL_POOLS)
  169416             : #define SGNODE__ALL_POOLS
  169417             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  169418             : #endif
  169419             : 
  169420             : SgTemplateFunctionRefExp* SgTemplateFunctionRefExp::next_node = nullptr;
  169421             : std::vector<unsigned char*> SgTemplateFunctionRefExp::pools;
  169422             : 
  169423             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  169424             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  169425             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  169426             : // around this macro definition rather than each use).
  169427             : #ifndef ALLOC_MUTEX
  169428             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  169429             :         do {                                                                     \
  169430             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  169431             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  169432             :                 abort();                                                         \
  169433             :             }                                                                    \
  169434             :         } while (0);
  169435             : #endif
  169436             : 
  169437             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  169438             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  169439             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  169440             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  169441             : 
  169442             : /*! \brief New operator for SgTemplateFunctionRefExp.
  169443             : 
  169444             :    This new operator implements memory pools to provide most efficent 
  169445             :    use of the heap within construction of large ASTs.
  169446             : 
  169447             : \internal The new and delete operators use the lower level C malloc/free
  169448             :    function calls for performance and to make sure that mixing of malloc/free
  169449             :    and new/delete by the used can be caught more readily.  This may change
  169450             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  169451             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  169452             :    deallocate memory allocated using ROSE_MALLOC.
  169453             : */
  169454        3017 : void *SgTemplateFunctionRefExp::operator new ( size_t Size )
  169455             : {
  169456             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  169457             :      * returning or throwing an exception. */
  169458        3017 :     ALLOC_MUTEX(SgTemplateFunctionRefExp, lock);
  169459             : 
  169460             : #if ROSE_ALLOC_TRACE == 2
  169461             : //    printf("SgTemplateFunctionRefExp::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgTemplateFunctionRefExp::next_node);
  169462             : #endif
  169463             : 
  169464             : #if USE_CPP_NEW_DELETE_OPERATORS
  169465             :     void *mem = ROSE_MALLOC(Size);
  169466             :     ALLOC_MUTEX(SgTemplateFunctionRefExp, unlock);
  169467             :     return mem;
  169468             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  169469             : #if ROSE_PEDANTIC_ALLOC
  169470             :     ROSE_ASSERT(Size == sizeof(SgTemplateFunctionRefExp));
  169471             : #else
  169472        3017 :     if (Size != sizeof(SgTemplateFunctionRefExp)) {
  169473           0 :       void * object = ROSE_MALLOC(Size);
  169474           0 :       ALLOC_MUTEX(SgTemplateFunctionRefExp, unlock);
  169475             :       return object;
  169476             :     }
  169477             : #endif
  169478             : 
  169479        3017 :     if (SgTemplateFunctionRefExp::next_node == nullptr) {
  169480          10 :         SgTemplateFunctionRefExp * alloc = (SgTemplateFunctionRefExp*) ROSE_MALLOC ( SgTemplateFunctionRefExp::pool_size * sizeof(SgTemplateFunctionRefExp) );
  169481          10 :         ROSE_ASSERT(alloc != nullptr);
  169482             : 
  169483             : #if ROSE_ALLOC_TRACE == 2
  169484             : //        printf("SgTemplateFunctionRefExp::alloc\n  block[%zi] = [ %p , %p [\n", SgTemplateFunctionRefExp::pools.size(), alloc, alloc + SgTemplateFunctionRefExp::pool_size);
  169485             : #endif
  169486             : 
  169487             : #if ROSE_ALLOC_MEMSET == 1
  169488             : #elif ROSE_ALLOC_MEMSET == 2
  169489             :         memset(alloc, 0x00, SgTemplateFunctionRefExp::pool_size * sizeof(SgTemplateFunctionRefExp));
  169490             : #elif ROSE_ALLOC_MEMSET == 3
  169491             :         memset(alloc, 0xAA, SgTemplateFunctionRefExp::pool_size * sizeof(SgTemplateFunctionRefExp));
  169492             : #endif
  169493       20000 :         for (unsigned i=0; i < SgTemplateFunctionRefExp::pool_size-1; i++) {
  169494       19990 :           alloc[i].p_freepointer = &(alloc[i+1]);
  169495             :         }
  169496          10 :         alloc[SgTemplateFunctionRefExp::pool_size-1].p_freepointer = nullptr;
  169497             : 
  169498          10 :         SgTemplateFunctionRefExp::pools.push_back ( (unsigned char *) alloc );
  169499          10 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgTemplateFunctionRefExp::pool_size * sizeof(SgTemplateFunctionRefExp), V_SgTemplateFunctionRefExp ) );
  169500          10 :         SgTemplateFunctionRefExp::next_node = alloc;
  169501             :     }
  169502        3017 :     ROSE_ASSERT(SgTemplateFunctionRefExp::next_node != nullptr);
  169503             : 
  169504        3017 :     SgTemplateFunctionRefExp * object = SgTemplateFunctionRefExp::next_node;
  169505        3017 :     SgTemplateFunctionRefExp::next_node = (SgTemplateFunctionRefExp*)(object->p_freepointer);
  169506             : 
  169507             : #if ROSE_ALLOC_TRACE == 2
  169508             :     printf("SgTemplateFunctionRefExp::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTemplateFunctionRefExp::next_node);
  169509             : #endif
  169510             : 
  169511        3017 :     SgNode * fp = object->p_freepointer;
  169512             : #if ROSE_ALLOC_MEMSET == 1
  169513             : #elif ROSE_ALLOC_MEMSET == 2
  169514             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgTemplateFunctionRefExp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  169515             : #elif ROSE_ALLOC_MEMSET == 3
  169516             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgTemplateFunctionRefExp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  169517             : #endif
  169518        3017 :     object->p_freepointer = fp;
  169519             : 
  169520             : #if ROSE_ALLOC_TRACE == 2
  169521             : //    printf("SgTemplateFunctionRefExp::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTemplateFunctionRefExp::next_node);
  169522             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  169523             :     Rose::MemPool::snapshot(oss.str());
  169524             :     alloc_trace_cnt++;
  169525             : #endif
  169526             : 
  169527        3017 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  169528             : 
  169529        3017 :     ALLOC_MUTEX(SgTemplateFunctionRefExp, unlock);
  169530             : 
  169531             :     return object;
  169532             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  169533             : }
  169534             : 
  169535             : 
  169536             : 
  169537             : /*! \brief Delete operator for SgTemplateFunctionRefExp.
  169538             : 
  169539             :    This delete operator implements deallocation using memory pools to 
  169540             :    provide most efficent use of the heap within construction of large ASTs.
  169541             : 
  169542             : \internal The new and delete operators use the lower level C malloc/free
  169543             :    function calls for performance and to make sure that mixing of malloc/free
  169544             :    and new/delete by the used can be caught more readily.  This may change
  169545             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  169546             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  169547             :    deallocate memory allocated using ROSE_MALLOC.
  169548             : */
  169549         466 : void SgTemplateFunctionRefExp::operator delete(void *Pointer, size_t Size)
  169550             : {
  169551             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  169552             :      * or throwing an exception. */
  169553         466 :     ALLOC_MUTEX(SgTemplateFunctionRefExp, lock);
  169554             : 
  169555             : #if USE_CPP_NEW_DELETE_OPERATORS
  169556             :     ROSE_FREE(Pointer);
  169557             : #else
  169558             : #if ROSE_PEDANTIC_ALLOC
  169559             :     ROSE_ASSERT(Size == sizeof(SgTemplateFunctionRefExp));
  169560             : #else
  169561         466 :     if (Size != sizeof(SgTemplateFunctionRefExp)) {
  169562           0 :       ROSE_FREE(Pointer);
  169563           0 :       ALLOC_MUTEX(SgTemplateFunctionRefExp, unlock);
  169564             :       return;
  169565             :     }
  169566             : #endif
  169567             : 
  169568         466 :     SgTemplateFunctionRefExp * object = (SgTemplateFunctionRefExp*) Pointer;
  169569         466 :     ROSE_ASSERT(object != nullptr);
  169570             : 
  169571             : #if ROSE_ALLOC_TRACE == 2
  169572             : //  printf("SgTemplateFunctionRefExp::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTemplateFunctionRefExp::next_node);
  169573             :     printf("SgTemplateFunctionRefExp::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTemplateFunctionRefExp::next_node);
  169574             : #endif
  169575             : 
  169576             : #if ROSE_PEDANTIC_ALLOC
  169577             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  169578             : #endif
  169579             : 
  169580             : #if ROSE_ALLOC_MEMSET == 1
  169581             : #elif ROSE_ALLOC_MEMSET == 2
  169582             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgTemplateFunctionRefExp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  169583             : #elif ROSE_ALLOC_MEMSET == 3
  169584             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgTemplateFunctionRefExp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  169585             : #endif
  169586             : 
  169587             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  169588             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  169589             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  169590             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  169591             : #else
  169592         466 :     object->p_freepointer = SgTemplateFunctionRefExp::next_node;
  169593         466 :     SgTemplateFunctionRefExp::next_node = object;
  169594             : #endif
  169595             : 
  169596             : #if ROSE_ALLOC_TRACE == 2
  169597             : //  printf("SgTemplateFunctionRefExp::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTemplateFunctionRefExp::next_node);
  169598             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  169599             :     Rose::MemPool::snapshot(oss.str());
  169600             :     alloc_trace_cnt++;
  169601             : #endif
  169602             : 
  169603             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  169604             : 
  169605         466 :     ALLOC_MUTEX(SgTemplateFunctionRefExp, unlock);
  169606             : }
  169607             : 
  169608             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  169609             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  169610             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  169611             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  169612             : // Also, note comment below from Robb (copied from the Common.code file).
  169613             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  169614             : //
  169615             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  169616             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  169617             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  169618             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  169619             : #if 0
  169620             : void SgTemplateFunctionRefExp::operator delete(void* pointer) { SgTemplateFunctionRefExp::operator delete (pointer, sizeof(SgTemplateFunctionRefExp)); };
  169621             : #endif
  169622             : /* #line 169623 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  169623             : 
  169624             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  169625             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  169626             : // obviously imply C++.
  169627             : 
  169628             : // This implements the support within ROSE for memory pools.  Memory pools
  169629             : // support the most condensed usage of memory within the construction of
  169630             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  169631             : // by a new operator written for each class.
  169632             : 
  169633             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  169634             :     // User wants multi-thread support and POSIX threads are available.
  169635             : #   include <pthread.h>
  169636             :     static pthread_mutex_t SgTemplateMemberFunctionRefExp_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  169637             : #else
  169638             :      // Cause synchronization to be skipped.
  169639             : #    ifndef ALLOC_MUTEX
  169640             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  169641             : #    endif
  169642             : #    ifdef _REENTRANT
  169643             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  169644             : #       ifdef _MSC_VER
  169645             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  169646             : #       else
  169647             : #           warning "POSIX threads are not available; synchronization being skipped"
  169648             : #       endif
  169649             : #    endif
  169650             : #endif
  169651             : 
  169652             : #ifndef ROSE_ALLOC_TRACE
  169653             : #  define ROSE_ALLOC_TRACE 0
  169654             : #endif
  169655             : 
  169656             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  169657             : #define ROSE_ALLOC_TRACE_CNT
  169658             : #include "memory-pool-snapshot.h"
  169659             : unsigned long alloc_trace_cnt = 0;
  169660             : #endif
  169661             : 
  169662             : #if ROSE_ALLOC_TRACE
  169663             : const unsigned SgTemplateMemberFunctionRefExp::pool_size = 5;
  169664             : #else
  169665             : const unsigned SgTemplateMemberFunctionRefExp::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  169666             : #endif
  169667             : 
  169668             : #ifndef ROSE_ALLOC_MEMSET
  169669             : #  define ROSE_ALLOC_MEMSET 0
  169670             : #endif
  169671             : 
  169672             : #ifndef ROSE_PEDANTIC_ALLOC
  169673             : #  define ROSE_PEDANTIC_ALLOC 0
  169674             : #endif
  169675             : 
  169676             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  169677             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  169678             : #endif
  169679             : 
  169680             : #if !defined(SGNODE__ALL_POOLS)
  169681             : #define SGNODE__ALL_POOLS
  169682             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  169683             : #endif
  169684             : 
  169685             : SgTemplateMemberFunctionRefExp* SgTemplateMemberFunctionRefExp::next_node = nullptr;
  169686             : std::vector<unsigned char*> SgTemplateMemberFunctionRefExp::pools;
  169687             : 
  169688             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  169689             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  169690             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  169691             : // around this macro definition rather than each use).
  169692             : #ifndef ALLOC_MUTEX
  169693             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  169694             :         do {                                                                     \
  169695             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  169696             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  169697             :                 abort();                                                         \
  169698             :             }                                                                    \
  169699             :         } while (0);
  169700             : #endif
  169701             : 
  169702             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  169703             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  169704             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  169705             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  169706             : 
  169707             : /*! \brief New operator for SgTemplateMemberFunctionRefExp.
  169708             : 
  169709             :    This new operator implements memory pools to provide most efficent 
  169710             :    use of the heap within construction of large ASTs.
  169711             : 
  169712             : \internal The new and delete operators use the lower level C malloc/free
  169713             :    function calls for performance and to make sure that mixing of malloc/free
  169714             :    and new/delete by the used can be caught more readily.  This may change
  169715             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  169716             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  169717             :    deallocate memory allocated using ROSE_MALLOC.
  169718             : */
  169719        8042 : void *SgTemplateMemberFunctionRefExp::operator new ( size_t Size )
  169720             : {
  169721             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  169722             :      * returning or throwing an exception. */
  169723        8042 :     ALLOC_MUTEX(SgTemplateMemberFunctionRefExp, lock);
  169724             : 
  169725             : #if ROSE_ALLOC_TRACE == 2
  169726             : //    printf("SgTemplateMemberFunctionRefExp::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgTemplateMemberFunctionRefExp::next_node);
  169727             : #endif
  169728             : 
  169729             : #if USE_CPP_NEW_DELETE_OPERATORS
  169730             :     void *mem = ROSE_MALLOC(Size);
  169731             :     ALLOC_MUTEX(SgTemplateMemberFunctionRefExp, unlock);
  169732             :     return mem;
  169733             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  169734             : #if ROSE_PEDANTIC_ALLOC
  169735             :     ROSE_ASSERT(Size == sizeof(SgTemplateMemberFunctionRefExp));
  169736             : #else
  169737        8042 :     if (Size != sizeof(SgTemplateMemberFunctionRefExp)) {
  169738           0 :       void * object = ROSE_MALLOC(Size);
  169739           0 :       ALLOC_MUTEX(SgTemplateMemberFunctionRefExp, unlock);
  169740             :       return object;
  169741             :     }
  169742             : #endif
  169743             : 
  169744        8042 :     if (SgTemplateMemberFunctionRefExp::next_node == nullptr) {
  169745          10 :         SgTemplateMemberFunctionRefExp * alloc = (SgTemplateMemberFunctionRefExp*) ROSE_MALLOC ( SgTemplateMemberFunctionRefExp::pool_size * sizeof(SgTemplateMemberFunctionRefExp) );
  169746          10 :         ROSE_ASSERT(alloc != nullptr);
  169747             : 
  169748             : #if ROSE_ALLOC_TRACE == 2
  169749             : //        printf("SgTemplateMemberFunctionRefExp::alloc\n  block[%zi] = [ %p , %p [\n", SgTemplateMemberFunctionRefExp::pools.size(), alloc, alloc + SgTemplateMemberFunctionRefExp::pool_size);
  169750             : #endif
  169751             : 
  169752             : #if ROSE_ALLOC_MEMSET == 1
  169753             : #elif ROSE_ALLOC_MEMSET == 2
  169754             :         memset(alloc, 0x00, SgTemplateMemberFunctionRefExp::pool_size * sizeof(SgTemplateMemberFunctionRefExp));
  169755             : #elif ROSE_ALLOC_MEMSET == 3
  169756             :         memset(alloc, 0xAA, SgTemplateMemberFunctionRefExp::pool_size * sizeof(SgTemplateMemberFunctionRefExp));
  169757             : #endif
  169758       20000 :         for (unsigned i=0; i < SgTemplateMemberFunctionRefExp::pool_size-1; i++) {
  169759       19990 :           alloc[i].p_freepointer = &(alloc[i+1]);
  169760             :         }
  169761          10 :         alloc[SgTemplateMemberFunctionRefExp::pool_size-1].p_freepointer = nullptr;
  169762             : 
  169763          10 :         SgTemplateMemberFunctionRefExp::pools.push_back ( (unsigned char *) alloc );
  169764          10 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgTemplateMemberFunctionRefExp::pool_size * sizeof(SgTemplateMemberFunctionRefExp), V_SgTemplateMemberFunctionRefExp ) );
  169765          10 :         SgTemplateMemberFunctionRefExp::next_node = alloc;
  169766             :     }
  169767        8042 :     ROSE_ASSERT(SgTemplateMemberFunctionRefExp::next_node != nullptr);
  169768             : 
  169769        8042 :     SgTemplateMemberFunctionRefExp * object = SgTemplateMemberFunctionRefExp::next_node;
  169770        8042 :     SgTemplateMemberFunctionRefExp::next_node = (SgTemplateMemberFunctionRefExp*)(object->p_freepointer);
  169771             : 
  169772             : #if ROSE_ALLOC_TRACE == 2
  169773             :     printf("SgTemplateMemberFunctionRefExp::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTemplateMemberFunctionRefExp::next_node);
  169774             : #endif
  169775             : 
  169776        8042 :     SgNode * fp = object->p_freepointer;
  169777             : #if ROSE_ALLOC_MEMSET == 1
  169778             : #elif ROSE_ALLOC_MEMSET == 2
  169779             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgTemplateMemberFunctionRefExp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  169780             : #elif ROSE_ALLOC_MEMSET == 3
  169781             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgTemplateMemberFunctionRefExp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  169782             : #endif
  169783        8042 :     object->p_freepointer = fp;
  169784             : 
  169785             : #if ROSE_ALLOC_TRACE == 2
  169786             : //    printf("SgTemplateMemberFunctionRefExp::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTemplateMemberFunctionRefExp::next_node);
  169787             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  169788             :     Rose::MemPool::snapshot(oss.str());
  169789             :     alloc_trace_cnt++;
  169790             : #endif
  169791             : 
  169792        8042 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  169793             : 
  169794        8042 :     ALLOC_MUTEX(SgTemplateMemberFunctionRefExp, unlock);
  169795             : 
  169796             :     return object;
  169797             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  169798             : }
  169799             : 
  169800             : 
  169801             : 
  169802             : /*! \brief Delete operator for SgTemplateMemberFunctionRefExp.
  169803             : 
  169804             :    This delete operator implements deallocation using memory pools to 
  169805             :    provide most efficent use of the heap within construction of large ASTs.
  169806             : 
  169807             : \internal The new and delete operators use the lower level C malloc/free
  169808             :    function calls for performance and to make sure that mixing of malloc/free
  169809             :    and new/delete by the used can be caught more readily.  This may change
  169810             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  169811             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  169812             :    deallocate memory allocated using ROSE_MALLOC.
  169813             : */
  169814        1556 : void SgTemplateMemberFunctionRefExp::operator delete(void *Pointer, size_t Size)
  169815             : {
  169816             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  169817             :      * or throwing an exception. */
  169818        1556 :     ALLOC_MUTEX(SgTemplateMemberFunctionRefExp, lock);
  169819             : 
  169820             : #if USE_CPP_NEW_DELETE_OPERATORS
  169821             :     ROSE_FREE(Pointer);
  169822             : #else
  169823             : #if ROSE_PEDANTIC_ALLOC
  169824             :     ROSE_ASSERT(Size == sizeof(SgTemplateMemberFunctionRefExp));
  169825             : #else
  169826        1556 :     if (Size != sizeof(SgTemplateMemberFunctionRefExp)) {
  169827           0 :       ROSE_FREE(Pointer);
  169828           0 :       ALLOC_MUTEX(SgTemplateMemberFunctionRefExp, unlock);
  169829             :       return;
  169830             :     }
  169831             : #endif
  169832             : 
  169833        1556 :     SgTemplateMemberFunctionRefExp * object = (SgTemplateMemberFunctionRefExp*) Pointer;
  169834        1556 :     ROSE_ASSERT(object != nullptr);
  169835             : 
  169836             : #if ROSE_ALLOC_TRACE == 2
  169837             : //  printf("SgTemplateMemberFunctionRefExp::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTemplateMemberFunctionRefExp::next_node);
  169838             :     printf("SgTemplateMemberFunctionRefExp::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTemplateMemberFunctionRefExp::next_node);
  169839             : #endif
  169840             : 
  169841             : #if ROSE_PEDANTIC_ALLOC
  169842             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  169843             : #endif
  169844             : 
  169845             : #if ROSE_ALLOC_MEMSET == 1
  169846             : #elif ROSE_ALLOC_MEMSET == 2
  169847             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgTemplateMemberFunctionRefExp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  169848             : #elif ROSE_ALLOC_MEMSET == 3
  169849             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgTemplateMemberFunctionRefExp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  169850             : #endif
  169851             : 
  169852             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  169853             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  169854             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  169855             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  169856             : #else
  169857        1556 :     object->p_freepointer = SgTemplateMemberFunctionRefExp::next_node;
  169858        1556 :     SgTemplateMemberFunctionRefExp::next_node = object;
  169859             : #endif
  169860             : 
  169861             : #if ROSE_ALLOC_TRACE == 2
  169862             : //  printf("SgTemplateMemberFunctionRefExp::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTemplateMemberFunctionRefExp::next_node);
  169863             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  169864             :     Rose::MemPool::snapshot(oss.str());
  169865             :     alloc_trace_cnt++;
  169866             : #endif
  169867             : 
  169868             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  169869             : 
  169870        1556 :     ALLOC_MUTEX(SgTemplateMemberFunctionRefExp, unlock);
  169871             : }
  169872             : 
  169873             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  169874             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  169875             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  169876             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  169877             : // Also, note comment below from Robb (copied from the Common.code file).
  169878             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  169879             : //
  169880             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  169881             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  169882             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  169883             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  169884             : #if 0
  169885             : void SgTemplateMemberFunctionRefExp::operator delete(void* pointer) { SgTemplateMemberFunctionRefExp::operator delete (pointer, sizeof(SgTemplateMemberFunctionRefExp)); };
  169886             : #endif
  169887             : /* #line 169888 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  169888             : 
  169889             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  169890             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  169891             : // obviously imply C++.
  169892             : 
  169893             : // This implements the support within ROSE for memory pools.  Memory pools
  169894             : // support the most condensed usage of memory within the construction of
  169895             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  169896             : // by a new operator written for each class.
  169897             : 
  169898             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  169899             :     // User wants multi-thread support and POSIX threads are available.
  169900             : #   include <pthread.h>
  169901             :     static pthread_mutex_t SgAlignOfOp_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  169902             : #else
  169903             :      // Cause synchronization to be skipped.
  169904             : #    ifndef ALLOC_MUTEX
  169905             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  169906             : #    endif
  169907             : #    ifdef _REENTRANT
  169908             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  169909             : #       ifdef _MSC_VER
  169910             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  169911             : #       else
  169912             : #           warning "POSIX threads are not available; synchronization being skipped"
  169913             : #       endif
  169914             : #    endif
  169915             : #endif
  169916             : 
  169917             : #ifndef ROSE_ALLOC_TRACE
  169918             : #  define ROSE_ALLOC_TRACE 0
  169919             : #endif
  169920             : 
  169921             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  169922             : #define ROSE_ALLOC_TRACE_CNT
  169923             : #include "memory-pool-snapshot.h"
  169924             : unsigned long alloc_trace_cnt = 0;
  169925             : #endif
  169926             : 
  169927             : #if ROSE_ALLOC_TRACE
  169928             : const unsigned SgAlignOfOp::pool_size = 5;
  169929             : #else
  169930             : const unsigned SgAlignOfOp::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  169931             : #endif
  169932             : 
  169933             : #ifndef ROSE_ALLOC_MEMSET
  169934             : #  define ROSE_ALLOC_MEMSET 0
  169935             : #endif
  169936             : 
  169937             : #ifndef ROSE_PEDANTIC_ALLOC
  169938             : #  define ROSE_PEDANTIC_ALLOC 0
  169939             : #endif
  169940             : 
  169941             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  169942             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  169943             : #endif
  169944             : 
  169945             : #if !defined(SGNODE__ALL_POOLS)
  169946             : #define SGNODE__ALL_POOLS
  169947             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  169948             : #endif
  169949             : 
  169950             : SgAlignOfOp* SgAlignOfOp::next_node = nullptr;
  169951             : std::vector<unsigned char*> SgAlignOfOp::pools;
  169952             : 
  169953             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  169954             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  169955             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  169956             : // around this macro definition rather than each use).
  169957             : #ifndef ALLOC_MUTEX
  169958             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  169959             :         do {                                                                     \
  169960             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  169961             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  169962             :                 abort();                                                         \
  169963             :             }                                                                    \
  169964             :         } while (0);
  169965             : #endif
  169966             : 
  169967             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  169968             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  169969             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  169970             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  169971             : 
  169972             : /*! \brief New operator for SgAlignOfOp.
  169973             : 
  169974             :    This new operator implements memory pools to provide most efficent 
  169975             :    use of the heap within construction of large ASTs.
  169976             : 
  169977             : \internal The new and delete operators use the lower level C malloc/free
  169978             :    function calls for performance and to make sure that mixing of malloc/free
  169979             :    and new/delete by the used can be caught more readily.  This may change
  169980             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  169981             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  169982             :    deallocate memory allocated using ROSE_MALLOC.
  169983             : */
  169984          58 : void *SgAlignOfOp::operator new ( size_t Size )
  169985             : {
  169986             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  169987             :      * returning or throwing an exception. */
  169988          58 :     ALLOC_MUTEX(SgAlignOfOp, lock);
  169989             : 
  169990             : #if ROSE_ALLOC_TRACE == 2
  169991             : //    printf("SgAlignOfOp::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgAlignOfOp::next_node);
  169992             : #endif
  169993             : 
  169994             : #if USE_CPP_NEW_DELETE_OPERATORS
  169995             :     void *mem = ROSE_MALLOC(Size);
  169996             :     ALLOC_MUTEX(SgAlignOfOp, unlock);
  169997             :     return mem;
  169998             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  169999             : #if ROSE_PEDANTIC_ALLOC
  170000             :     ROSE_ASSERT(Size == sizeof(SgAlignOfOp));
  170001             : #else
  170002          58 :     if (Size != sizeof(SgAlignOfOp)) {
  170003           0 :       void * object = ROSE_MALLOC(Size);
  170004           0 :       ALLOC_MUTEX(SgAlignOfOp, unlock);
  170005             :       return object;
  170006             :     }
  170007             : #endif
  170008             : 
  170009          58 :     if (SgAlignOfOp::next_node == nullptr) {
  170010          10 :         SgAlignOfOp * alloc = (SgAlignOfOp*) ROSE_MALLOC ( SgAlignOfOp::pool_size * sizeof(SgAlignOfOp) );
  170011          10 :         ROSE_ASSERT(alloc != nullptr);
  170012             : 
  170013             : #if ROSE_ALLOC_TRACE == 2
  170014             : //        printf("SgAlignOfOp::alloc\n  block[%zi] = [ %p , %p [\n", SgAlignOfOp::pools.size(), alloc, alloc + SgAlignOfOp::pool_size);
  170015             : #endif
  170016             : 
  170017             : #if ROSE_ALLOC_MEMSET == 1
  170018             : #elif ROSE_ALLOC_MEMSET == 2
  170019             :         memset(alloc, 0x00, SgAlignOfOp::pool_size * sizeof(SgAlignOfOp));
  170020             : #elif ROSE_ALLOC_MEMSET == 3
  170021             :         memset(alloc, 0xAA, SgAlignOfOp::pool_size * sizeof(SgAlignOfOp));
  170022             : #endif
  170023       20000 :         for (unsigned i=0; i < SgAlignOfOp::pool_size-1; i++) {
  170024       19990 :           alloc[i].p_freepointer = &(alloc[i+1]);
  170025             :         }
  170026          10 :         alloc[SgAlignOfOp::pool_size-1].p_freepointer = nullptr;
  170027             : 
  170028          10 :         SgAlignOfOp::pools.push_back ( (unsigned char *) alloc );
  170029          10 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgAlignOfOp::pool_size * sizeof(SgAlignOfOp), V_SgAlignOfOp ) );
  170030          10 :         SgAlignOfOp::next_node = alloc;
  170031             :     }
  170032          58 :     ROSE_ASSERT(SgAlignOfOp::next_node != nullptr);
  170033             : 
  170034          58 :     SgAlignOfOp * object = SgAlignOfOp::next_node;
  170035          58 :     SgAlignOfOp::next_node = (SgAlignOfOp*)(object->p_freepointer);
  170036             : 
  170037             : #if ROSE_ALLOC_TRACE == 2
  170038             :     printf("SgAlignOfOp::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgAlignOfOp::next_node);
  170039             : #endif
  170040             : 
  170041          58 :     SgNode * fp = object->p_freepointer;
  170042             : #if ROSE_ALLOC_MEMSET == 1
  170043             : #elif ROSE_ALLOC_MEMSET == 2
  170044             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgAlignOfOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  170045             : #elif ROSE_ALLOC_MEMSET == 3
  170046             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgAlignOfOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  170047             : #endif
  170048          58 :     object->p_freepointer = fp;
  170049             : 
  170050             : #if ROSE_ALLOC_TRACE == 2
  170051             : //    printf("SgAlignOfOp::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgAlignOfOp::next_node);
  170052             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  170053             :     Rose::MemPool::snapshot(oss.str());
  170054             :     alloc_trace_cnt++;
  170055             : #endif
  170056             : 
  170057          58 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  170058             : 
  170059          58 :     ALLOC_MUTEX(SgAlignOfOp, unlock);
  170060             : 
  170061             :     return object;
  170062             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  170063             : }
  170064             : 
  170065             : 
  170066             : 
  170067             : /*! \brief Delete operator for SgAlignOfOp.
  170068             : 
  170069             :    This delete operator implements deallocation using memory pools to 
  170070             :    provide most efficent use of the heap within construction of large ASTs.
  170071             : 
  170072             : \internal The new and delete operators use the lower level C malloc/free
  170073             :    function calls for performance and to make sure that mixing of malloc/free
  170074             :    and new/delete by the used can be caught more readily.  This may change
  170075             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  170076             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  170077             :    deallocate memory allocated using ROSE_MALLOC.
  170078             : */
  170079          10 : void SgAlignOfOp::operator delete(void *Pointer, size_t Size)
  170080             : {
  170081             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  170082             :      * or throwing an exception. */
  170083          10 :     ALLOC_MUTEX(SgAlignOfOp, lock);
  170084             : 
  170085             : #if USE_CPP_NEW_DELETE_OPERATORS
  170086             :     ROSE_FREE(Pointer);
  170087             : #else
  170088             : #if ROSE_PEDANTIC_ALLOC
  170089             :     ROSE_ASSERT(Size == sizeof(SgAlignOfOp));
  170090             : #else
  170091          10 :     if (Size != sizeof(SgAlignOfOp)) {
  170092           0 :       ROSE_FREE(Pointer);
  170093           0 :       ALLOC_MUTEX(SgAlignOfOp, unlock);
  170094             :       return;
  170095             :     }
  170096             : #endif
  170097             : 
  170098          10 :     SgAlignOfOp * object = (SgAlignOfOp*) Pointer;
  170099          10 :     ROSE_ASSERT(object != nullptr);
  170100             : 
  170101             : #if ROSE_ALLOC_TRACE == 2
  170102             : //  printf("SgAlignOfOp::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgAlignOfOp::next_node);
  170103             :     printf("SgAlignOfOp::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgAlignOfOp::next_node);
  170104             : #endif
  170105             : 
  170106             : #if ROSE_PEDANTIC_ALLOC
  170107             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  170108             : #endif
  170109             : 
  170110             : #if ROSE_ALLOC_MEMSET == 1
  170111             : #elif ROSE_ALLOC_MEMSET == 2
  170112             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgAlignOfOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  170113             : #elif ROSE_ALLOC_MEMSET == 3
  170114             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgAlignOfOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  170115             : #endif
  170116             : 
  170117             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  170118             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  170119             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  170120             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  170121             : #else
  170122          10 :     object->p_freepointer = SgAlignOfOp::next_node;
  170123          10 :     SgAlignOfOp::next_node = object;
  170124             : #endif
  170125             : 
  170126             : #if ROSE_ALLOC_TRACE == 2
  170127             : //  printf("SgAlignOfOp::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgAlignOfOp::next_node);
  170128             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  170129             :     Rose::MemPool::snapshot(oss.str());
  170130             :     alloc_trace_cnt++;
  170131             : #endif
  170132             : 
  170133             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  170134             : 
  170135          10 :     ALLOC_MUTEX(SgAlignOfOp, unlock);
  170136             : }
  170137             : 
  170138             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  170139             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  170140             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  170141             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  170142             : // Also, note comment below from Robb (copied from the Common.code file).
  170143             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  170144             : //
  170145             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  170146             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  170147             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  170148             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  170149             : #if 0
  170150             : void SgAlignOfOp::operator delete(void* pointer) { SgAlignOfOp::operator delete (pointer, sizeof(SgAlignOfOp)); };
  170151             : #endif
  170152             : /* #line 170153 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  170153             : 
  170154             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  170155             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  170156             : // obviously imply C++.
  170157             : 
  170158             : // This implements the support within ROSE for memory pools.  Memory pools
  170159             : // support the most condensed usage of memory within the construction of
  170160             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  170161             : // by a new operator written for each class.
  170162             : 
  170163             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  170164             :     // User wants multi-thread support and POSIX threads are available.
  170165             : #   include <pthread.h>
  170166             :     static pthread_mutex_t SgRangeExp_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  170167             : #else
  170168             :      // Cause synchronization to be skipped.
  170169             : #    ifndef ALLOC_MUTEX
  170170             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  170171             : #    endif
  170172             : #    ifdef _REENTRANT
  170173             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  170174             : #       ifdef _MSC_VER
  170175             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  170176             : #       else
  170177             : #           warning "POSIX threads are not available; synchronization being skipped"
  170178             : #       endif
  170179             : #    endif
  170180             : #endif
  170181             : 
  170182             : #ifndef ROSE_ALLOC_TRACE
  170183             : #  define ROSE_ALLOC_TRACE 0
  170184             : #endif
  170185             : 
  170186             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  170187             : #define ROSE_ALLOC_TRACE_CNT
  170188             : #include "memory-pool-snapshot.h"
  170189             : unsigned long alloc_trace_cnt = 0;
  170190             : #endif
  170191             : 
  170192             : #if ROSE_ALLOC_TRACE
  170193             : const unsigned SgRangeExp::pool_size = 5;
  170194             : #else
  170195             : const unsigned SgRangeExp::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  170196             : #endif
  170197             : 
  170198             : #ifndef ROSE_ALLOC_MEMSET
  170199             : #  define ROSE_ALLOC_MEMSET 0
  170200             : #endif
  170201             : 
  170202             : #ifndef ROSE_PEDANTIC_ALLOC
  170203             : #  define ROSE_PEDANTIC_ALLOC 0
  170204             : #endif
  170205             : 
  170206             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  170207             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  170208             : #endif
  170209             : 
  170210             : #if !defined(SGNODE__ALL_POOLS)
  170211             : #define SGNODE__ALL_POOLS
  170212             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  170213             : #endif
  170214             : 
  170215             : SgRangeExp* SgRangeExp::next_node = nullptr;
  170216             : std::vector<unsigned char*> SgRangeExp::pools;
  170217             : 
  170218             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  170219             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  170220             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  170221             : // around this macro definition rather than each use).
  170222             : #ifndef ALLOC_MUTEX
  170223             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  170224             :         do {                                                                     \
  170225             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  170226             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  170227             :                 abort();                                                         \
  170228             :             }                                                                    \
  170229             :         } while (0);
  170230             : #endif
  170231             : 
  170232             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  170233             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  170234             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  170235             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  170236             : 
  170237             : /*! \brief New operator for SgRangeExp.
  170238             : 
  170239             :    This new operator implements memory pools to provide most efficent 
  170240             :    use of the heap within construction of large ASTs.
  170241             : 
  170242             : \internal The new and delete operators use the lower level C malloc/free
  170243             :    function calls for performance and to make sure that mixing of malloc/free
  170244             :    and new/delete by the used can be caught more readily.  This may change
  170245             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  170246             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  170247             :    deallocate memory allocated using ROSE_MALLOC.
  170248             : */
  170249           0 : void *SgRangeExp::operator new ( size_t Size )
  170250             : {
  170251             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  170252             :      * returning or throwing an exception. */
  170253           0 :     ALLOC_MUTEX(SgRangeExp, lock);
  170254             : 
  170255             : #if ROSE_ALLOC_TRACE == 2
  170256             : //    printf("SgRangeExp::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgRangeExp::next_node);
  170257             : #endif
  170258             : 
  170259             : #if USE_CPP_NEW_DELETE_OPERATORS
  170260             :     void *mem = ROSE_MALLOC(Size);
  170261             :     ALLOC_MUTEX(SgRangeExp, unlock);
  170262             :     return mem;
  170263             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  170264             : #if ROSE_PEDANTIC_ALLOC
  170265             :     ROSE_ASSERT(Size == sizeof(SgRangeExp));
  170266             : #else
  170267           0 :     if (Size != sizeof(SgRangeExp)) {
  170268           0 :       void * object = ROSE_MALLOC(Size);
  170269           0 :       ALLOC_MUTEX(SgRangeExp, unlock);
  170270             :       return object;
  170271             :     }
  170272             : #endif
  170273             : 
  170274           0 :     if (SgRangeExp::next_node == nullptr) {
  170275           0 :         SgRangeExp * alloc = (SgRangeExp*) ROSE_MALLOC ( SgRangeExp::pool_size * sizeof(SgRangeExp) );
  170276           0 :         ROSE_ASSERT(alloc != nullptr);
  170277             : 
  170278             : #if ROSE_ALLOC_TRACE == 2
  170279             : //        printf("SgRangeExp::alloc\n  block[%zi] = [ %p , %p [\n", SgRangeExp::pools.size(), alloc, alloc + SgRangeExp::pool_size);
  170280             : #endif
  170281             : 
  170282             : #if ROSE_ALLOC_MEMSET == 1
  170283             : #elif ROSE_ALLOC_MEMSET == 2
  170284             :         memset(alloc, 0x00, SgRangeExp::pool_size * sizeof(SgRangeExp));
  170285             : #elif ROSE_ALLOC_MEMSET == 3
  170286             :         memset(alloc, 0xAA, SgRangeExp::pool_size * sizeof(SgRangeExp));
  170287             : #endif
  170288           0 :         for (unsigned i=0; i < SgRangeExp::pool_size-1; i++) {
  170289           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
  170290             :         }
  170291           0 :         alloc[SgRangeExp::pool_size-1].p_freepointer = nullptr;
  170292             : 
  170293           0 :         SgRangeExp::pools.push_back ( (unsigned char *) alloc );
  170294           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgRangeExp::pool_size * sizeof(SgRangeExp), V_SgRangeExp ) );
  170295           0 :         SgRangeExp::next_node = alloc;
  170296             :     }
  170297           0 :     ROSE_ASSERT(SgRangeExp::next_node != nullptr);
  170298             : 
  170299           0 :     SgRangeExp * object = SgRangeExp::next_node;
  170300           0 :     SgRangeExp::next_node = (SgRangeExp*)(object->p_freepointer);
  170301             : 
  170302             : #if ROSE_ALLOC_TRACE == 2
  170303             :     printf("SgRangeExp::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgRangeExp::next_node);
  170304             : #endif
  170305             : 
  170306           0 :     SgNode * fp = object->p_freepointer;
  170307             : #if ROSE_ALLOC_MEMSET == 1
  170308             : #elif ROSE_ALLOC_MEMSET == 2
  170309             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgRangeExp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  170310             : #elif ROSE_ALLOC_MEMSET == 3
  170311             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgRangeExp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  170312             : #endif
  170313           0 :     object->p_freepointer = fp;
  170314             : 
  170315             : #if ROSE_ALLOC_TRACE == 2
  170316             : //    printf("SgRangeExp::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgRangeExp::next_node);
  170317             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  170318             :     Rose::MemPool::snapshot(oss.str());
  170319             :     alloc_trace_cnt++;
  170320             : #endif
  170321             : 
  170322           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  170323             : 
  170324           0 :     ALLOC_MUTEX(SgRangeExp, unlock);
  170325             : 
  170326             :     return object;
  170327             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  170328             : }
  170329             : 
  170330             : 
  170331             : 
  170332             : /*! \brief Delete operator for SgRangeExp.
  170333             : 
  170334             :    This delete operator implements deallocation using memory pools to 
  170335             :    provide most efficent use of the heap within construction of large ASTs.
  170336             : 
  170337             : \internal The new and delete operators use the lower level C malloc/free
  170338             :    function calls for performance and to make sure that mixing of malloc/free
  170339             :    and new/delete by the used can be caught more readily.  This may change
  170340             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  170341             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  170342             :    deallocate memory allocated using ROSE_MALLOC.
  170343             : */
  170344           0 : void SgRangeExp::operator delete(void *Pointer, size_t Size)
  170345             : {
  170346             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  170347             :      * or throwing an exception. */
  170348           0 :     ALLOC_MUTEX(SgRangeExp, lock);
  170349             : 
  170350             : #if USE_CPP_NEW_DELETE_OPERATORS
  170351             :     ROSE_FREE(Pointer);
  170352             : #else
  170353             : #if ROSE_PEDANTIC_ALLOC
  170354             :     ROSE_ASSERT(Size == sizeof(SgRangeExp));
  170355             : #else
  170356           0 :     if (Size != sizeof(SgRangeExp)) {
  170357           0 :       ROSE_FREE(Pointer);
  170358           0 :       ALLOC_MUTEX(SgRangeExp, unlock);
  170359             :       return;
  170360             :     }
  170361             : #endif
  170362             : 
  170363           0 :     SgRangeExp * object = (SgRangeExp*) Pointer;
  170364           0 :     ROSE_ASSERT(object != nullptr);
  170365             : 
  170366             : #if ROSE_ALLOC_TRACE == 2
  170367             : //  printf("SgRangeExp::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgRangeExp::next_node);
  170368             :     printf("SgRangeExp::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgRangeExp::next_node);
  170369             : #endif
  170370             : 
  170371             : #if ROSE_PEDANTIC_ALLOC
  170372             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  170373             : #endif
  170374             : 
  170375             : #if ROSE_ALLOC_MEMSET == 1
  170376             : #elif ROSE_ALLOC_MEMSET == 2
  170377             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgRangeExp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  170378             : #elif ROSE_ALLOC_MEMSET == 3
  170379             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgRangeExp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  170380             : #endif
  170381             : 
  170382             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  170383             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  170384             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  170385             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  170386             : #else
  170387           0 :     object->p_freepointer = SgRangeExp::next_node;
  170388           0 :     SgRangeExp::next_node = object;
  170389             : #endif
  170390             : 
  170391             : #if ROSE_ALLOC_TRACE == 2
  170392             : //  printf("SgRangeExp::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgRangeExp::next_node);
  170393             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  170394             :     Rose::MemPool::snapshot(oss.str());
  170395             :     alloc_trace_cnt++;
  170396             : #endif
  170397             : 
  170398             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  170399             : 
  170400           0 :     ALLOC_MUTEX(SgRangeExp, unlock);
  170401             : }
  170402             : 
  170403             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  170404             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  170405             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  170406             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  170407             : // Also, note comment below from Robb (copied from the Common.code file).
  170408             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  170409             : //
  170410             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  170411             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  170412             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  170413             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  170414             : #if 0
  170415             : void SgRangeExp::operator delete(void* pointer) { SgRangeExp::operator delete (pointer, sizeof(SgRangeExp)); };
  170416             : #endif
  170417             : /* #line 170418 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  170418             : 
  170419             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  170420             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  170421             : // obviously imply C++.
  170422             : 
  170423             : // This implements the support within ROSE for memory pools.  Memory pools
  170424             : // support the most condensed usage of memory within the construction of
  170425             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  170426             : // by a new operator written for each class.
  170427             : 
  170428             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  170429             :     // User wants multi-thread support and POSIX threads are available.
  170430             : #   include <pthread.h>
  170431             :     static pthread_mutex_t SgMagicColonExp_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  170432             : #else
  170433             :      // Cause synchronization to be skipped.
  170434             : #    ifndef ALLOC_MUTEX
  170435             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  170436             : #    endif
  170437             : #    ifdef _REENTRANT
  170438             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  170439             : #       ifdef _MSC_VER
  170440             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  170441             : #       else
  170442             : #           warning "POSIX threads are not available; synchronization being skipped"
  170443             : #       endif
  170444             : #    endif
  170445             : #endif
  170446             : 
  170447             : #ifndef ROSE_ALLOC_TRACE
  170448             : #  define ROSE_ALLOC_TRACE 0
  170449             : #endif
  170450             : 
  170451             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  170452             : #define ROSE_ALLOC_TRACE_CNT
  170453             : #include "memory-pool-snapshot.h"
  170454             : unsigned long alloc_trace_cnt = 0;
  170455             : #endif
  170456             : 
  170457             : #if ROSE_ALLOC_TRACE
  170458             : const unsigned SgMagicColonExp::pool_size = 5;
  170459             : #else
  170460             : const unsigned SgMagicColonExp::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  170461             : #endif
  170462             : 
  170463             : #ifndef ROSE_ALLOC_MEMSET
  170464             : #  define ROSE_ALLOC_MEMSET 0
  170465             : #endif
  170466             : 
  170467             : #ifndef ROSE_PEDANTIC_ALLOC
  170468             : #  define ROSE_PEDANTIC_ALLOC 0
  170469             : #endif
  170470             : 
  170471             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  170472             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  170473             : #endif
  170474             : 
  170475             : #if !defined(SGNODE__ALL_POOLS)
  170476             : #define SGNODE__ALL_POOLS
  170477             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  170478             : #endif
  170479             : 
  170480             : SgMagicColonExp* SgMagicColonExp::next_node = nullptr;
  170481             : std::vector<unsigned char*> SgMagicColonExp::pools;
  170482             : 
  170483             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  170484             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  170485             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  170486             : // around this macro definition rather than each use).
  170487             : #ifndef ALLOC_MUTEX
  170488             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  170489             :         do {                                                                     \
  170490             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  170491             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  170492             :                 abort();                                                         \
  170493             :             }                                                                    \
  170494             :         } while (0);
  170495             : #endif
  170496             : 
  170497             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  170498             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  170499             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  170500             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  170501             : 
  170502             : /*! \brief New operator for SgMagicColonExp.
  170503             : 
  170504             :    This new operator implements memory pools to provide most efficent 
  170505             :    use of the heap within construction of large ASTs.
  170506             : 
  170507             : \internal The new and delete operators use the lower level C malloc/free
  170508             :    function calls for performance and to make sure that mixing of malloc/free
  170509             :    and new/delete by the used can be caught more readily.  This may change
  170510             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  170511             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  170512             :    deallocate memory allocated using ROSE_MALLOC.
  170513             : */
  170514           0 : void *SgMagicColonExp::operator new ( size_t Size )
  170515             : {
  170516             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  170517             :      * returning or throwing an exception. */
  170518           0 :     ALLOC_MUTEX(SgMagicColonExp, lock);
  170519             : 
  170520             : #if ROSE_ALLOC_TRACE == 2
  170521             : //    printf("SgMagicColonExp::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgMagicColonExp::next_node);
  170522             : #endif
  170523             : 
  170524             : #if USE_CPP_NEW_DELETE_OPERATORS
  170525             :     void *mem = ROSE_MALLOC(Size);
  170526             :     ALLOC_MUTEX(SgMagicColonExp, unlock);
  170527             :     return mem;
  170528             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  170529             : #if ROSE_PEDANTIC_ALLOC
  170530             :     ROSE_ASSERT(Size == sizeof(SgMagicColonExp));
  170531             : #else
  170532           0 :     if (Size != sizeof(SgMagicColonExp)) {
  170533           0 :       void * object = ROSE_MALLOC(Size);
  170534           0 :       ALLOC_MUTEX(SgMagicColonExp, unlock);
  170535             :       return object;
  170536             :     }
  170537             : #endif
  170538             : 
  170539           0 :     if (SgMagicColonExp::next_node == nullptr) {
  170540           0 :         SgMagicColonExp * alloc = (SgMagicColonExp*) ROSE_MALLOC ( SgMagicColonExp::pool_size * sizeof(SgMagicColonExp) );
  170541           0 :         ROSE_ASSERT(alloc != nullptr);
  170542             : 
  170543             : #if ROSE_ALLOC_TRACE == 2
  170544             : //        printf("SgMagicColonExp::alloc\n  block[%zi] = [ %p , %p [\n", SgMagicColonExp::pools.size(), alloc, alloc + SgMagicColonExp::pool_size);
  170545             : #endif
  170546             : 
  170547             : #if ROSE_ALLOC_MEMSET == 1
  170548             : #elif ROSE_ALLOC_MEMSET == 2
  170549             :         memset(alloc, 0x00, SgMagicColonExp::pool_size * sizeof(SgMagicColonExp));
  170550             : #elif ROSE_ALLOC_MEMSET == 3
  170551             :         memset(alloc, 0xAA, SgMagicColonExp::pool_size * sizeof(SgMagicColonExp));
  170552             : #endif
  170553           0 :         for (unsigned i=0; i < SgMagicColonExp::pool_size-1; i++) {
  170554           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
  170555             :         }
  170556           0 :         alloc[SgMagicColonExp::pool_size-1].p_freepointer = nullptr;
  170557             : 
  170558           0 :         SgMagicColonExp::pools.push_back ( (unsigned char *) alloc );
  170559           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgMagicColonExp::pool_size * sizeof(SgMagicColonExp), V_SgMagicColonExp ) );
  170560           0 :         SgMagicColonExp::next_node = alloc;
  170561             :     }
  170562           0 :     ROSE_ASSERT(SgMagicColonExp::next_node != nullptr);
  170563             : 
  170564           0 :     SgMagicColonExp * object = SgMagicColonExp::next_node;
  170565           0 :     SgMagicColonExp::next_node = (SgMagicColonExp*)(object->p_freepointer);
  170566             : 
  170567             : #if ROSE_ALLOC_TRACE == 2
  170568             :     printf("SgMagicColonExp::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgMagicColonExp::next_node);
  170569             : #endif
  170570             : 
  170571           0 :     SgNode * fp = object->p_freepointer;
  170572             : #if ROSE_ALLOC_MEMSET == 1
  170573             : #elif ROSE_ALLOC_MEMSET == 2
  170574             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgMagicColonExp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  170575             : #elif ROSE_ALLOC_MEMSET == 3
  170576             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgMagicColonExp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  170577             : #endif
  170578           0 :     object->p_freepointer = fp;
  170579             : 
  170580             : #if ROSE_ALLOC_TRACE == 2
  170581             : //    printf("SgMagicColonExp::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgMagicColonExp::next_node);
  170582             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  170583             :     Rose::MemPool::snapshot(oss.str());
  170584             :     alloc_trace_cnt++;
  170585             : #endif
  170586             : 
  170587           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  170588             : 
  170589           0 :     ALLOC_MUTEX(SgMagicColonExp, unlock);
  170590             : 
  170591             :     return object;
  170592             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  170593             : }
  170594             : 
  170595             : 
  170596             : 
  170597             : /*! \brief Delete operator for SgMagicColonExp.
  170598             : 
  170599             :    This delete operator implements deallocation using memory pools to 
  170600             :    provide most efficent use of the heap within construction of large ASTs.
  170601             : 
  170602             : \internal The new and delete operators use the lower level C malloc/free
  170603             :    function calls for performance and to make sure that mixing of malloc/free
  170604             :    and new/delete by the used can be caught more readily.  This may change
  170605             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  170606             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  170607             :    deallocate memory allocated using ROSE_MALLOC.
  170608             : */
  170609           0 : void SgMagicColonExp::operator delete(void *Pointer, size_t Size)
  170610             : {
  170611             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  170612             :      * or throwing an exception. */
  170613           0 :     ALLOC_MUTEX(SgMagicColonExp, lock);
  170614             : 
  170615             : #if USE_CPP_NEW_DELETE_OPERATORS
  170616             :     ROSE_FREE(Pointer);
  170617             : #else
  170618             : #if ROSE_PEDANTIC_ALLOC
  170619             :     ROSE_ASSERT(Size == sizeof(SgMagicColonExp));
  170620             : #else
  170621           0 :     if (Size != sizeof(SgMagicColonExp)) {
  170622           0 :       ROSE_FREE(Pointer);
  170623           0 :       ALLOC_MUTEX(SgMagicColonExp, unlock);
  170624             :       return;
  170625             :     }
  170626             : #endif
  170627             : 
  170628           0 :     SgMagicColonExp * object = (SgMagicColonExp*) Pointer;
  170629           0 :     ROSE_ASSERT(object != nullptr);
  170630             : 
  170631             : #if ROSE_ALLOC_TRACE == 2
  170632             : //  printf("SgMagicColonExp::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgMagicColonExp::next_node);
  170633             :     printf("SgMagicColonExp::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgMagicColonExp::next_node);
  170634             : #endif
  170635             : 
  170636             : #if ROSE_PEDANTIC_ALLOC
  170637             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  170638             : #endif
  170639             : 
  170640             : #if ROSE_ALLOC_MEMSET == 1
  170641             : #elif ROSE_ALLOC_MEMSET == 2
  170642             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgMagicColonExp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  170643             : #elif ROSE_ALLOC_MEMSET == 3
  170644             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgMagicColonExp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  170645             : #endif
  170646             : 
  170647             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  170648             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  170649             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  170650             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  170651             : #else
  170652           0 :     object->p_freepointer = SgMagicColonExp::next_node;
  170653           0 :     SgMagicColonExp::next_node = object;
  170654             : #endif
  170655             : 
  170656             : #if ROSE_ALLOC_TRACE == 2
  170657             : //  printf("SgMagicColonExp::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgMagicColonExp::next_node);
  170658             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  170659             :     Rose::MemPool::snapshot(oss.str());
  170660             :     alloc_trace_cnt++;
  170661             : #endif
  170662             : 
  170663             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  170664             : 
  170665           0 :     ALLOC_MUTEX(SgMagicColonExp, unlock);
  170666             : }
  170667             : 
  170668             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  170669             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  170670             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  170671             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  170672             : // Also, note comment below from Robb (copied from the Common.code file).
  170673             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  170674             : //
  170675             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  170676             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  170677             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  170678             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  170679             : #if 0
  170680             : void SgMagicColonExp::operator delete(void* pointer) { SgMagicColonExp::operator delete (pointer, sizeof(SgMagicColonExp)); };
  170681             : #endif
  170682             : /* #line 170683 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  170683             : 
  170684             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  170685             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  170686             : // obviously imply C++.
  170687             : 
  170688             : // This implements the support within ROSE for memory pools.  Memory pools
  170689             : // support the most condensed usage of memory within the construction of
  170690             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  170691             : // by a new operator written for each class.
  170692             : 
  170693             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  170694             :     // User wants multi-thread support and POSIX threads are available.
  170695             : #   include <pthread.h>
  170696             :     static pthread_mutex_t SgTypeTraitBuiltinOperator_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  170697             : #else
  170698             :      // Cause synchronization to be skipped.
  170699             : #    ifndef ALLOC_MUTEX
  170700             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  170701             : #    endif
  170702             : #    ifdef _REENTRANT
  170703             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  170704             : #       ifdef _MSC_VER
  170705             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  170706             : #       else
  170707             : #           warning "POSIX threads are not available; synchronization being skipped"
  170708             : #       endif
  170709             : #    endif
  170710             : #endif
  170711             : 
  170712             : #ifndef ROSE_ALLOC_TRACE
  170713             : #  define ROSE_ALLOC_TRACE 0
  170714             : #endif
  170715             : 
  170716             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  170717             : #define ROSE_ALLOC_TRACE_CNT
  170718             : #include "memory-pool-snapshot.h"
  170719             : unsigned long alloc_trace_cnt = 0;
  170720             : #endif
  170721             : 
  170722             : #if ROSE_ALLOC_TRACE
  170723             : const unsigned SgTypeTraitBuiltinOperator::pool_size = 5;
  170724             : #else
  170725             : const unsigned SgTypeTraitBuiltinOperator::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  170726             : #endif
  170727             : 
  170728             : #ifndef ROSE_ALLOC_MEMSET
  170729             : #  define ROSE_ALLOC_MEMSET 0
  170730             : #endif
  170731             : 
  170732             : #ifndef ROSE_PEDANTIC_ALLOC
  170733             : #  define ROSE_PEDANTIC_ALLOC 0
  170734             : #endif
  170735             : 
  170736             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  170737             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  170738             : #endif
  170739             : 
  170740             : #if !defined(SGNODE__ALL_POOLS)
  170741             : #define SGNODE__ALL_POOLS
  170742             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  170743             : #endif
  170744             : 
  170745             : SgTypeTraitBuiltinOperator* SgTypeTraitBuiltinOperator::next_node = nullptr;
  170746             : std::vector<unsigned char*> SgTypeTraitBuiltinOperator::pools;
  170747             : 
  170748             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  170749             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  170750             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  170751             : // around this macro definition rather than each use).
  170752             : #ifndef ALLOC_MUTEX
  170753             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  170754             :         do {                                                                     \
  170755             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  170756             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  170757             :                 abort();                                                         \
  170758             :             }                                                                    \
  170759             :         } while (0);
  170760             : #endif
  170761             : 
  170762             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  170763             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  170764             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  170765             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  170766             : 
  170767             : /*! \brief New operator for SgTypeTraitBuiltinOperator.
  170768             : 
  170769             :    This new operator implements memory pools to provide most efficent 
  170770             :    use of the heap within construction of large ASTs.
  170771             : 
  170772             : \internal The new and delete operators use the lower level C malloc/free
  170773             :    function calls for performance and to make sure that mixing of malloc/free
  170774             :    and new/delete by the used can be caught more readily.  This may change
  170775             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  170776             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  170777             :    deallocate memory allocated using ROSE_MALLOC.
  170778             : */
  170779         470 : void *SgTypeTraitBuiltinOperator::operator new ( size_t Size )
  170780             : {
  170781             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  170782             :      * returning or throwing an exception. */
  170783         470 :     ALLOC_MUTEX(SgTypeTraitBuiltinOperator, lock);
  170784             : 
  170785             : #if ROSE_ALLOC_TRACE == 2
  170786             : //    printf("SgTypeTraitBuiltinOperator::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgTypeTraitBuiltinOperator::next_node);
  170787             : #endif
  170788             : 
  170789             : #if USE_CPP_NEW_DELETE_OPERATORS
  170790             :     void *mem = ROSE_MALLOC(Size);
  170791             :     ALLOC_MUTEX(SgTypeTraitBuiltinOperator, unlock);
  170792             :     return mem;
  170793             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  170794             : #if ROSE_PEDANTIC_ALLOC
  170795             :     ROSE_ASSERT(Size == sizeof(SgTypeTraitBuiltinOperator));
  170796             : #else
  170797         470 :     if (Size != sizeof(SgTypeTraitBuiltinOperator)) {
  170798           0 :       void * object = ROSE_MALLOC(Size);
  170799           0 :       ALLOC_MUTEX(SgTypeTraitBuiltinOperator, unlock);
  170800             :       return object;
  170801             :     }
  170802             : #endif
  170803             : 
  170804         470 :     if (SgTypeTraitBuiltinOperator::next_node == nullptr) {
  170805          10 :         SgTypeTraitBuiltinOperator * alloc = (SgTypeTraitBuiltinOperator*) ROSE_MALLOC ( SgTypeTraitBuiltinOperator::pool_size * sizeof(SgTypeTraitBuiltinOperator) );
  170806          10 :         ROSE_ASSERT(alloc != nullptr);
  170807             : 
  170808             : #if ROSE_ALLOC_TRACE == 2
  170809             : //        printf("SgTypeTraitBuiltinOperator::alloc\n  block[%zi] = [ %p , %p [\n", SgTypeTraitBuiltinOperator::pools.size(), alloc, alloc + SgTypeTraitBuiltinOperator::pool_size);
  170810             : #endif
  170811             : 
  170812             : #if ROSE_ALLOC_MEMSET == 1
  170813             : #elif ROSE_ALLOC_MEMSET == 2
  170814             :         memset(alloc, 0x00, SgTypeTraitBuiltinOperator::pool_size * sizeof(SgTypeTraitBuiltinOperator));
  170815             : #elif ROSE_ALLOC_MEMSET == 3
  170816             :         memset(alloc, 0xAA, SgTypeTraitBuiltinOperator::pool_size * sizeof(SgTypeTraitBuiltinOperator));
  170817             : #endif
  170818       20000 :         for (unsigned i=0; i < SgTypeTraitBuiltinOperator::pool_size-1; i++) {
  170819       19990 :           alloc[i].p_freepointer = &(alloc[i+1]);
  170820             :         }
  170821          10 :         alloc[SgTypeTraitBuiltinOperator::pool_size-1].p_freepointer = nullptr;
  170822             : 
  170823          10 :         SgTypeTraitBuiltinOperator::pools.push_back ( (unsigned char *) alloc );
  170824          10 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgTypeTraitBuiltinOperator::pool_size * sizeof(SgTypeTraitBuiltinOperator), V_SgTypeTraitBuiltinOperator ) );
  170825          10 :         SgTypeTraitBuiltinOperator::next_node = alloc;
  170826             :     }
  170827         470 :     ROSE_ASSERT(SgTypeTraitBuiltinOperator::next_node != nullptr);
  170828             : 
  170829         470 :     SgTypeTraitBuiltinOperator * object = SgTypeTraitBuiltinOperator::next_node;
  170830         470 :     SgTypeTraitBuiltinOperator::next_node = (SgTypeTraitBuiltinOperator*)(object->p_freepointer);
  170831             : 
  170832             : #if ROSE_ALLOC_TRACE == 2
  170833             :     printf("SgTypeTraitBuiltinOperator::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeTraitBuiltinOperator::next_node);
  170834             : #endif
  170835             : 
  170836         470 :     SgNode * fp = object->p_freepointer;
  170837             : #if ROSE_ALLOC_MEMSET == 1
  170838             : #elif ROSE_ALLOC_MEMSET == 2
  170839             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgTypeTraitBuiltinOperator) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  170840             : #elif ROSE_ALLOC_MEMSET == 3
  170841             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgTypeTraitBuiltinOperator) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  170842             : #endif
  170843         470 :     object->p_freepointer = fp;
  170844             : 
  170845             : #if ROSE_ALLOC_TRACE == 2
  170846             : //    printf("SgTypeTraitBuiltinOperator::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeTraitBuiltinOperator::next_node);
  170847             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  170848             :     Rose::MemPool::snapshot(oss.str());
  170849             :     alloc_trace_cnt++;
  170850             : #endif
  170851             : 
  170852         470 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  170853             : 
  170854         470 :     ALLOC_MUTEX(SgTypeTraitBuiltinOperator, unlock);
  170855             : 
  170856             :     return object;
  170857             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  170858             : }
  170859             : 
  170860             : 
  170861             : 
  170862             : /*! \brief Delete operator for SgTypeTraitBuiltinOperator.
  170863             : 
  170864             :    This delete operator implements deallocation using memory pools to 
  170865             :    provide most efficent use of the heap within construction of large ASTs.
  170866             : 
  170867             : \internal The new and delete operators use the lower level C malloc/free
  170868             :    function calls for performance and to make sure that mixing of malloc/free
  170869             :    and new/delete by the used can be caught more readily.  This may change
  170870             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  170871             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  170872             :    deallocate memory allocated using ROSE_MALLOC.
  170873             : */
  170874          84 : void SgTypeTraitBuiltinOperator::operator delete(void *Pointer, size_t Size)
  170875             : {
  170876             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  170877             :      * or throwing an exception. */
  170878          84 :     ALLOC_MUTEX(SgTypeTraitBuiltinOperator, lock);
  170879             : 
  170880             : #if USE_CPP_NEW_DELETE_OPERATORS
  170881             :     ROSE_FREE(Pointer);
  170882             : #else
  170883             : #if ROSE_PEDANTIC_ALLOC
  170884             :     ROSE_ASSERT(Size == sizeof(SgTypeTraitBuiltinOperator));
  170885             : #else
  170886          84 :     if (Size != sizeof(SgTypeTraitBuiltinOperator)) {
  170887           0 :       ROSE_FREE(Pointer);
  170888           0 :       ALLOC_MUTEX(SgTypeTraitBuiltinOperator, unlock);
  170889             :       return;
  170890             :     }
  170891             : #endif
  170892             : 
  170893          84 :     SgTypeTraitBuiltinOperator * object = (SgTypeTraitBuiltinOperator*) Pointer;
  170894          84 :     ROSE_ASSERT(object != nullptr);
  170895             : 
  170896             : #if ROSE_ALLOC_TRACE == 2
  170897             : //  printf("SgTypeTraitBuiltinOperator::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeTraitBuiltinOperator::next_node);
  170898             :     printf("SgTypeTraitBuiltinOperator::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeTraitBuiltinOperator::next_node);
  170899             : #endif
  170900             : 
  170901             : #if ROSE_PEDANTIC_ALLOC
  170902             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  170903             : #endif
  170904             : 
  170905             : #if ROSE_ALLOC_MEMSET == 1
  170906             : #elif ROSE_ALLOC_MEMSET == 2
  170907             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgTypeTraitBuiltinOperator) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  170908             : #elif ROSE_ALLOC_MEMSET == 3
  170909             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgTypeTraitBuiltinOperator) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  170910             : #endif
  170911             : 
  170912             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  170913             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  170914             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  170915             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  170916             : #else
  170917          84 :     object->p_freepointer = SgTypeTraitBuiltinOperator::next_node;
  170918          84 :     SgTypeTraitBuiltinOperator::next_node = object;
  170919             : #endif
  170920             : 
  170921             : #if ROSE_ALLOC_TRACE == 2
  170922             : //  printf("SgTypeTraitBuiltinOperator::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeTraitBuiltinOperator::next_node);
  170923             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  170924             :     Rose::MemPool::snapshot(oss.str());
  170925             :     alloc_trace_cnt++;
  170926             : #endif
  170927             : 
  170928             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  170929             : 
  170930          84 :     ALLOC_MUTEX(SgTypeTraitBuiltinOperator, unlock);
  170931             : }
  170932             : 
  170933             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  170934             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  170935             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  170936             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  170937             : // Also, note comment below from Robb (copied from the Common.code file).
  170938             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  170939             : //
  170940             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  170941             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  170942             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  170943             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  170944             : #if 0
  170945             : void SgTypeTraitBuiltinOperator::operator delete(void* pointer) { SgTypeTraitBuiltinOperator::operator delete (pointer, sizeof(SgTypeTraitBuiltinOperator)); };
  170946             : #endif
  170947             : /* #line 170948 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  170948             : 
  170949             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  170950             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  170951             : // obviously imply C++.
  170952             : 
  170953             : // This implements the support within ROSE for memory pools.  Memory pools
  170954             : // support the most condensed usage of memory within the construction of
  170955             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  170956             : // by a new operator written for each class.
  170957             : 
  170958             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  170959             :     // User wants multi-thread support and POSIX threads are available.
  170960             : #   include <pthread.h>
  170961             :     static pthread_mutex_t SgCompoundLiteralExp_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  170962             : #else
  170963             :      // Cause synchronization to be skipped.
  170964             : #    ifndef ALLOC_MUTEX
  170965             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  170966             : #    endif
  170967             : #    ifdef _REENTRANT
  170968             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  170969             : #       ifdef _MSC_VER
  170970             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  170971             : #       else
  170972             : #           warning "POSIX threads are not available; synchronization being skipped"
  170973             : #       endif
  170974             : #    endif
  170975             : #endif
  170976             : 
  170977             : #ifndef ROSE_ALLOC_TRACE
  170978             : #  define ROSE_ALLOC_TRACE 0
  170979             : #endif
  170980             : 
  170981             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  170982             : #define ROSE_ALLOC_TRACE_CNT
  170983             : #include "memory-pool-snapshot.h"
  170984             : unsigned long alloc_trace_cnt = 0;
  170985             : #endif
  170986             : 
  170987             : #if ROSE_ALLOC_TRACE
  170988             : const unsigned SgCompoundLiteralExp::pool_size = 5;
  170989             : #else
  170990             : const unsigned SgCompoundLiteralExp::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  170991             : #endif
  170992             : 
  170993             : #ifndef ROSE_ALLOC_MEMSET
  170994             : #  define ROSE_ALLOC_MEMSET 0
  170995             : #endif
  170996             : 
  170997             : #ifndef ROSE_PEDANTIC_ALLOC
  170998             : #  define ROSE_PEDANTIC_ALLOC 0
  170999             : #endif
  171000             : 
  171001             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  171002             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  171003             : #endif
  171004             : 
  171005             : #if !defined(SGNODE__ALL_POOLS)
  171006             : #define SGNODE__ALL_POOLS
  171007             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  171008             : #endif
  171009             : 
  171010             : SgCompoundLiteralExp* SgCompoundLiteralExp::next_node = nullptr;
  171011             : std::vector<unsigned char*> SgCompoundLiteralExp::pools;
  171012             : 
  171013             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  171014             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  171015             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  171016             : // around this macro definition rather than each use).
  171017             : #ifndef ALLOC_MUTEX
  171018             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  171019             :         do {                                                                     \
  171020             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  171021             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  171022             :                 abort();                                                         \
  171023             :             }                                                                    \
  171024             :         } while (0);
  171025             : #endif
  171026             : 
  171027             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  171028             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  171029             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  171030             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  171031             : 
  171032             : /*! \brief New operator for SgCompoundLiteralExp.
  171033             : 
  171034             :    This new operator implements memory pools to provide most efficent 
  171035             :    use of the heap within construction of large ASTs.
  171036             : 
  171037             : \internal The new and delete operators use the lower level C malloc/free
  171038             :    function calls for performance and to make sure that mixing of malloc/free
  171039             :    and new/delete by the used can be caught more readily.  This may change
  171040             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  171041             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  171042             :    deallocate memory allocated using ROSE_MALLOC.
  171043             : */
  171044           0 : void *SgCompoundLiteralExp::operator new ( size_t Size )
  171045             : {
  171046             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  171047             :      * returning or throwing an exception. */
  171048           0 :     ALLOC_MUTEX(SgCompoundLiteralExp, lock);
  171049             : 
  171050             : #if ROSE_ALLOC_TRACE == 2
  171051             : //    printf("SgCompoundLiteralExp::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgCompoundLiteralExp::next_node);
  171052             : #endif
  171053             : 
  171054             : #if USE_CPP_NEW_DELETE_OPERATORS
  171055             :     void *mem = ROSE_MALLOC(Size);
  171056             :     ALLOC_MUTEX(SgCompoundLiteralExp, unlock);
  171057             :     return mem;
  171058             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  171059             : #if ROSE_PEDANTIC_ALLOC
  171060             :     ROSE_ASSERT(Size == sizeof(SgCompoundLiteralExp));
  171061             : #else
  171062           0 :     if (Size != sizeof(SgCompoundLiteralExp)) {
  171063           0 :       void * object = ROSE_MALLOC(Size);
  171064           0 :       ALLOC_MUTEX(SgCompoundLiteralExp, unlock);
  171065             :       return object;
  171066             :     }
  171067             : #endif
  171068             : 
  171069           0 :     if (SgCompoundLiteralExp::next_node == nullptr) {
  171070           0 :         SgCompoundLiteralExp * alloc = (SgCompoundLiteralExp*) ROSE_MALLOC ( SgCompoundLiteralExp::pool_size * sizeof(SgCompoundLiteralExp) );
  171071           0 :         ROSE_ASSERT(alloc != nullptr);
  171072             : 
  171073             : #if ROSE_ALLOC_TRACE == 2
  171074             : //        printf("SgCompoundLiteralExp::alloc\n  block[%zi] = [ %p , %p [\n", SgCompoundLiteralExp::pools.size(), alloc, alloc + SgCompoundLiteralExp::pool_size);
  171075             : #endif
  171076             : 
  171077             : #if ROSE_ALLOC_MEMSET == 1
  171078             : #elif ROSE_ALLOC_MEMSET == 2
  171079             :         memset(alloc, 0x00, SgCompoundLiteralExp::pool_size * sizeof(SgCompoundLiteralExp));
  171080             : #elif ROSE_ALLOC_MEMSET == 3
  171081             :         memset(alloc, 0xAA, SgCompoundLiteralExp::pool_size * sizeof(SgCompoundLiteralExp));
  171082             : #endif
  171083           0 :         for (unsigned i=0; i < SgCompoundLiteralExp::pool_size-1; i++) {
  171084           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
  171085             :         }
  171086           0 :         alloc[SgCompoundLiteralExp::pool_size-1].p_freepointer = nullptr;
  171087             : 
  171088           0 :         SgCompoundLiteralExp::pools.push_back ( (unsigned char *) alloc );
  171089           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgCompoundLiteralExp::pool_size * sizeof(SgCompoundLiteralExp), V_SgCompoundLiteralExp ) );
  171090           0 :         SgCompoundLiteralExp::next_node = alloc;
  171091             :     }
  171092           0 :     ROSE_ASSERT(SgCompoundLiteralExp::next_node != nullptr);
  171093             : 
  171094           0 :     SgCompoundLiteralExp * object = SgCompoundLiteralExp::next_node;
  171095           0 :     SgCompoundLiteralExp::next_node = (SgCompoundLiteralExp*)(object->p_freepointer);
  171096             : 
  171097             : #if ROSE_ALLOC_TRACE == 2
  171098             :     printf("SgCompoundLiteralExp::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgCompoundLiteralExp::next_node);
  171099             : #endif
  171100             : 
  171101           0 :     SgNode * fp = object->p_freepointer;
  171102             : #if ROSE_ALLOC_MEMSET == 1
  171103             : #elif ROSE_ALLOC_MEMSET == 2
  171104             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgCompoundLiteralExp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  171105             : #elif ROSE_ALLOC_MEMSET == 3
  171106             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgCompoundLiteralExp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  171107             : #endif
  171108           0 :     object->p_freepointer = fp;
  171109             : 
  171110             : #if ROSE_ALLOC_TRACE == 2
  171111             : //    printf("SgCompoundLiteralExp::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgCompoundLiteralExp::next_node);
  171112             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  171113             :     Rose::MemPool::snapshot(oss.str());
  171114             :     alloc_trace_cnt++;
  171115             : #endif
  171116             : 
  171117           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  171118             : 
  171119           0 :     ALLOC_MUTEX(SgCompoundLiteralExp, unlock);
  171120             : 
  171121             :     return object;
  171122             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  171123             : }
  171124             : 
  171125             : 
  171126             : 
  171127             : /*! \brief Delete operator for SgCompoundLiteralExp.
  171128             : 
  171129             :    This delete operator implements deallocation using memory pools to 
  171130             :    provide most efficent use of the heap within construction of large ASTs.
  171131             : 
  171132             : \internal The new and delete operators use the lower level C malloc/free
  171133             :    function calls for performance and to make sure that mixing of malloc/free
  171134             :    and new/delete by the used can be caught more readily.  This may change
  171135             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  171136             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  171137             :    deallocate memory allocated using ROSE_MALLOC.
  171138             : */
  171139           0 : void SgCompoundLiteralExp::operator delete(void *Pointer, size_t Size)
  171140             : {
  171141             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  171142             :      * or throwing an exception. */
  171143           0 :     ALLOC_MUTEX(SgCompoundLiteralExp, lock);
  171144             : 
  171145             : #if USE_CPP_NEW_DELETE_OPERATORS
  171146             :     ROSE_FREE(Pointer);
  171147             : #else
  171148             : #if ROSE_PEDANTIC_ALLOC
  171149             :     ROSE_ASSERT(Size == sizeof(SgCompoundLiteralExp));
  171150             : #else
  171151           0 :     if (Size != sizeof(SgCompoundLiteralExp)) {
  171152           0 :       ROSE_FREE(Pointer);
  171153           0 :       ALLOC_MUTEX(SgCompoundLiteralExp, unlock);
  171154             :       return;
  171155             :     }
  171156             : #endif
  171157             : 
  171158           0 :     SgCompoundLiteralExp * object = (SgCompoundLiteralExp*) Pointer;
  171159           0 :     ROSE_ASSERT(object != nullptr);
  171160             : 
  171161             : #if ROSE_ALLOC_TRACE == 2
  171162             : //  printf("SgCompoundLiteralExp::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgCompoundLiteralExp::next_node);
  171163             :     printf("SgCompoundLiteralExp::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgCompoundLiteralExp::next_node);
  171164             : #endif
  171165             : 
  171166             : #if ROSE_PEDANTIC_ALLOC
  171167             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  171168             : #endif
  171169             : 
  171170             : #if ROSE_ALLOC_MEMSET == 1
  171171             : #elif ROSE_ALLOC_MEMSET == 2
  171172             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgCompoundLiteralExp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  171173             : #elif ROSE_ALLOC_MEMSET == 3
  171174             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgCompoundLiteralExp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  171175             : #endif
  171176             : 
  171177             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  171178             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  171179             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  171180             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  171181             : #else
  171182           0 :     object->p_freepointer = SgCompoundLiteralExp::next_node;
  171183           0 :     SgCompoundLiteralExp::next_node = object;
  171184             : #endif
  171185             : 
  171186             : #if ROSE_ALLOC_TRACE == 2
  171187             : //  printf("SgCompoundLiteralExp::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgCompoundLiteralExp::next_node);
  171188             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  171189             :     Rose::MemPool::snapshot(oss.str());
  171190             :     alloc_trace_cnt++;
  171191             : #endif
  171192             : 
  171193             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  171194             : 
  171195           0 :     ALLOC_MUTEX(SgCompoundLiteralExp, unlock);
  171196             : }
  171197             : 
  171198             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  171199             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  171200             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  171201             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  171202             : // Also, note comment below from Robb (copied from the Common.code file).
  171203             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  171204             : //
  171205             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  171206             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  171207             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  171208             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  171209             : #if 0
  171210             : void SgCompoundLiteralExp::operator delete(void* pointer) { SgCompoundLiteralExp::operator delete (pointer, sizeof(SgCompoundLiteralExp)); };
  171211             : #endif
  171212             : /* #line 171213 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  171213             : 
  171214             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  171215             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  171216             : // obviously imply C++.
  171217             : 
  171218             : // This implements the support within ROSE for memory pools.  Memory pools
  171219             : // support the most condensed usage of memory within the construction of
  171220             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  171221             : // by a new operator written for each class.
  171222             : 
  171223             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  171224             :     // User wants multi-thread support and POSIX threads are available.
  171225             : #   include <pthread.h>
  171226             :     static pthread_mutex_t SgTypeExpression_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  171227             : #else
  171228             :      // Cause synchronization to be skipped.
  171229             : #    ifndef ALLOC_MUTEX
  171230             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  171231             : #    endif
  171232             : #    ifdef _REENTRANT
  171233             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  171234             : #       ifdef _MSC_VER
  171235             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  171236             : #       else
  171237             : #           warning "POSIX threads are not available; synchronization being skipped"
  171238             : #       endif
  171239             : #    endif
  171240             : #endif
  171241             : 
  171242             : #ifndef ROSE_ALLOC_TRACE
  171243             : #  define ROSE_ALLOC_TRACE 0
  171244             : #endif
  171245             : 
  171246             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  171247             : #define ROSE_ALLOC_TRACE_CNT
  171248             : #include "memory-pool-snapshot.h"
  171249             : unsigned long alloc_trace_cnt = 0;
  171250             : #endif
  171251             : 
  171252             : #if ROSE_ALLOC_TRACE
  171253             : const unsigned SgTypeExpression::pool_size = 5;
  171254             : #else
  171255             : const unsigned SgTypeExpression::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  171256             : #endif
  171257             : 
  171258             : #ifndef ROSE_ALLOC_MEMSET
  171259             : #  define ROSE_ALLOC_MEMSET 0
  171260             : #endif
  171261             : 
  171262             : #ifndef ROSE_PEDANTIC_ALLOC
  171263             : #  define ROSE_PEDANTIC_ALLOC 0
  171264             : #endif
  171265             : 
  171266             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  171267             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  171268             : #endif
  171269             : 
  171270             : #if !defined(SGNODE__ALL_POOLS)
  171271             : #define SGNODE__ALL_POOLS
  171272             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  171273             : #endif
  171274             : 
  171275             : SgTypeExpression* SgTypeExpression::next_node = nullptr;
  171276             : std::vector<unsigned char*> SgTypeExpression::pools;
  171277             : 
  171278             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  171279             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  171280             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  171281             : // around this macro definition rather than each use).
  171282             : #ifndef ALLOC_MUTEX
  171283             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  171284             :         do {                                                                     \
  171285             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  171286             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  171287             :                 abort();                                                         \
  171288             :             }                                                                    \
  171289             :         } while (0);
  171290             : #endif
  171291             : 
  171292             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  171293             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  171294             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  171295             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  171296             : 
  171297             : /*! \brief New operator for SgTypeExpression.
  171298             : 
  171299             :    This new operator implements memory pools to provide most efficent 
  171300             :    use of the heap within construction of large ASTs.
  171301             : 
  171302             : \internal The new and delete operators use the lower level C malloc/free
  171303             :    function calls for performance and to make sure that mixing of malloc/free
  171304             :    and new/delete by the used can be caught more readily.  This may change
  171305             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  171306             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  171307             :    deallocate memory allocated using ROSE_MALLOC.
  171308             : */
  171309           0 : void *SgTypeExpression::operator new ( size_t Size )
  171310             : {
  171311             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  171312             :      * returning or throwing an exception. */
  171313           0 :     ALLOC_MUTEX(SgTypeExpression, lock);
  171314             : 
  171315             : #if ROSE_ALLOC_TRACE == 2
  171316             : //    printf("SgTypeExpression::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgTypeExpression::next_node);
  171317             : #endif
  171318             : 
  171319             : #if USE_CPP_NEW_DELETE_OPERATORS
  171320             :     void *mem = ROSE_MALLOC(Size);
  171321             :     ALLOC_MUTEX(SgTypeExpression, unlock);
  171322             :     return mem;
  171323             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  171324             : #if ROSE_PEDANTIC_ALLOC
  171325             :     ROSE_ASSERT(Size == sizeof(SgTypeExpression));
  171326             : #else
  171327           0 :     if (Size != sizeof(SgTypeExpression)) {
  171328           0 :       void * object = ROSE_MALLOC(Size);
  171329           0 :       ALLOC_MUTEX(SgTypeExpression, unlock);
  171330             :       return object;
  171331             :     }
  171332             : #endif
  171333             : 
  171334           0 :     if (SgTypeExpression::next_node == nullptr) {
  171335           0 :         SgTypeExpression * alloc = (SgTypeExpression*) ROSE_MALLOC ( SgTypeExpression::pool_size * sizeof(SgTypeExpression) );
  171336           0 :         ROSE_ASSERT(alloc != nullptr);
  171337             : 
  171338             : #if ROSE_ALLOC_TRACE == 2
  171339             : //        printf("SgTypeExpression::alloc\n  block[%zi] = [ %p , %p [\n", SgTypeExpression::pools.size(), alloc, alloc + SgTypeExpression::pool_size);
  171340             : #endif
  171341             : 
  171342             : #if ROSE_ALLOC_MEMSET == 1
  171343             : #elif ROSE_ALLOC_MEMSET == 2
  171344             :         memset(alloc, 0x00, SgTypeExpression::pool_size * sizeof(SgTypeExpression));
  171345             : #elif ROSE_ALLOC_MEMSET == 3
  171346             :         memset(alloc, 0xAA, SgTypeExpression::pool_size * sizeof(SgTypeExpression));
  171347             : #endif
  171348           0 :         for (unsigned i=0; i < SgTypeExpression::pool_size-1; i++) {
  171349           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
  171350             :         }
  171351           0 :         alloc[SgTypeExpression::pool_size-1].p_freepointer = nullptr;
  171352             : 
  171353           0 :         SgTypeExpression::pools.push_back ( (unsigned char *) alloc );
  171354           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgTypeExpression::pool_size * sizeof(SgTypeExpression), V_SgTypeExpression ) );
  171355           0 :         SgTypeExpression::next_node = alloc;
  171356             :     }
  171357           0 :     ROSE_ASSERT(SgTypeExpression::next_node != nullptr);
  171358             : 
  171359           0 :     SgTypeExpression * object = SgTypeExpression::next_node;
  171360           0 :     SgTypeExpression::next_node = (SgTypeExpression*)(object->p_freepointer);
  171361             : 
  171362             : #if ROSE_ALLOC_TRACE == 2
  171363             :     printf("SgTypeExpression::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeExpression::next_node);
  171364             : #endif
  171365             : 
  171366           0 :     SgNode * fp = object->p_freepointer;
  171367             : #if ROSE_ALLOC_MEMSET == 1
  171368             : #elif ROSE_ALLOC_MEMSET == 2
  171369             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgTypeExpression) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  171370             : #elif ROSE_ALLOC_MEMSET == 3
  171371             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgTypeExpression) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  171372             : #endif
  171373           0 :     object->p_freepointer = fp;
  171374             : 
  171375             : #if ROSE_ALLOC_TRACE == 2
  171376             : //    printf("SgTypeExpression::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeExpression::next_node);
  171377             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  171378             :     Rose::MemPool::snapshot(oss.str());
  171379             :     alloc_trace_cnt++;
  171380             : #endif
  171381             : 
  171382           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  171383             : 
  171384           0 :     ALLOC_MUTEX(SgTypeExpression, unlock);
  171385             : 
  171386             :     return object;
  171387             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  171388             : }
  171389             : 
  171390             : 
  171391             : 
  171392             : /*! \brief Delete operator for SgTypeExpression.
  171393             : 
  171394             :    This delete operator implements deallocation using memory pools to 
  171395             :    provide most efficent use of the heap within construction of large ASTs.
  171396             : 
  171397             : \internal The new and delete operators use the lower level C malloc/free
  171398             :    function calls for performance and to make sure that mixing of malloc/free
  171399             :    and new/delete by the used can be caught more readily.  This may change
  171400             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  171401             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  171402             :    deallocate memory allocated using ROSE_MALLOC.
  171403             : */
  171404           0 : void SgTypeExpression::operator delete(void *Pointer, size_t Size)
  171405             : {
  171406             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  171407             :      * or throwing an exception. */
  171408           0 :     ALLOC_MUTEX(SgTypeExpression, lock);
  171409             : 
  171410             : #if USE_CPP_NEW_DELETE_OPERATORS
  171411             :     ROSE_FREE(Pointer);
  171412             : #else
  171413             : #if ROSE_PEDANTIC_ALLOC
  171414             :     ROSE_ASSERT(Size == sizeof(SgTypeExpression));
  171415             : #else
  171416           0 :     if (Size != sizeof(SgTypeExpression)) {
  171417           0 :       ROSE_FREE(Pointer);
  171418           0 :       ALLOC_MUTEX(SgTypeExpression, unlock);
  171419             :       return;
  171420             :     }
  171421             : #endif
  171422             : 
  171423           0 :     SgTypeExpression * object = (SgTypeExpression*) Pointer;
  171424           0 :     ROSE_ASSERT(object != nullptr);
  171425             : 
  171426             : #if ROSE_ALLOC_TRACE == 2
  171427             : //  printf("SgTypeExpression::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeExpression::next_node);
  171428             :     printf("SgTypeExpression::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeExpression::next_node);
  171429             : #endif
  171430             : 
  171431             : #if ROSE_PEDANTIC_ALLOC
  171432             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  171433             : #endif
  171434             : 
  171435             : #if ROSE_ALLOC_MEMSET == 1
  171436             : #elif ROSE_ALLOC_MEMSET == 2
  171437             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgTypeExpression) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  171438             : #elif ROSE_ALLOC_MEMSET == 3
  171439             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgTypeExpression) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  171440             : #endif
  171441             : 
  171442             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  171443             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  171444             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  171445             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  171446             : #else
  171447           0 :     object->p_freepointer = SgTypeExpression::next_node;
  171448           0 :     SgTypeExpression::next_node = object;
  171449             : #endif
  171450             : 
  171451             : #if ROSE_ALLOC_TRACE == 2
  171452             : //  printf("SgTypeExpression::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypeExpression::next_node);
  171453             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  171454             :     Rose::MemPool::snapshot(oss.str());
  171455             :     alloc_trace_cnt++;
  171456             : #endif
  171457             : 
  171458             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  171459             : 
  171460           0 :     ALLOC_MUTEX(SgTypeExpression, unlock);
  171461             : }
  171462             : 
  171463             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  171464             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  171465             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  171466             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  171467             : // Also, note comment below from Robb (copied from the Common.code file).
  171468             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  171469             : //
  171470             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  171471             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  171472             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  171473             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  171474             : #if 0
  171475             : void SgTypeExpression::operator delete(void* pointer) { SgTypeExpression::operator delete (pointer, sizeof(SgTypeExpression)); };
  171476             : #endif
  171477             : /* #line 171478 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  171478             : 
  171479             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  171480             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  171481             : // obviously imply C++.
  171482             : 
  171483             : // This implements the support within ROSE for memory pools.  Memory pools
  171484             : // support the most condensed usage of memory within the construction of
  171485             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  171486             : // by a new operator written for each class.
  171487             : 
  171488             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  171489             :     // User wants multi-thread support and POSIX threads are available.
  171490             : #   include <pthread.h>
  171491             :     static pthread_mutex_t SgClassExp_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  171492             : #else
  171493             :      // Cause synchronization to be skipped.
  171494             : #    ifndef ALLOC_MUTEX
  171495             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  171496             : #    endif
  171497             : #    ifdef _REENTRANT
  171498             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  171499             : #       ifdef _MSC_VER
  171500             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  171501             : #       else
  171502             : #           warning "POSIX threads are not available; synchronization being skipped"
  171503             : #       endif
  171504             : #    endif
  171505             : #endif
  171506             : 
  171507             : #ifndef ROSE_ALLOC_TRACE
  171508             : #  define ROSE_ALLOC_TRACE 0
  171509             : #endif
  171510             : 
  171511             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  171512             : #define ROSE_ALLOC_TRACE_CNT
  171513             : #include "memory-pool-snapshot.h"
  171514             : unsigned long alloc_trace_cnt = 0;
  171515             : #endif
  171516             : 
  171517             : #if ROSE_ALLOC_TRACE
  171518             : const unsigned SgClassExp::pool_size = 5;
  171519             : #else
  171520             : const unsigned SgClassExp::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  171521             : #endif
  171522             : 
  171523             : #ifndef ROSE_ALLOC_MEMSET
  171524             : #  define ROSE_ALLOC_MEMSET 0
  171525             : #endif
  171526             : 
  171527             : #ifndef ROSE_PEDANTIC_ALLOC
  171528             : #  define ROSE_PEDANTIC_ALLOC 0
  171529             : #endif
  171530             : 
  171531             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  171532             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  171533             : #endif
  171534             : 
  171535             : #if !defined(SGNODE__ALL_POOLS)
  171536             : #define SGNODE__ALL_POOLS
  171537             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  171538             : #endif
  171539             : 
  171540             : SgClassExp* SgClassExp::next_node = nullptr;
  171541             : std::vector<unsigned char*> SgClassExp::pools;
  171542             : 
  171543             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  171544             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  171545             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  171546             : // around this macro definition rather than each use).
  171547             : #ifndef ALLOC_MUTEX
  171548             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  171549             :         do {                                                                     \
  171550             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  171551             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  171552             :                 abort();                                                         \
  171553             :             }                                                                    \
  171554             :         } while (0);
  171555             : #endif
  171556             : 
  171557             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  171558             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  171559             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  171560             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  171561             : 
  171562             : /*! \brief New operator for SgClassExp.
  171563             : 
  171564             :    This new operator implements memory pools to provide most efficent 
  171565             :    use of the heap within construction of large ASTs.
  171566             : 
  171567             : \internal The new and delete operators use the lower level C malloc/free
  171568             :    function calls for performance and to make sure that mixing of malloc/free
  171569             :    and new/delete by the used can be caught more readily.  This may change
  171570             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  171571             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  171572             :    deallocate memory allocated using ROSE_MALLOC.
  171573             : */
  171574           0 : void *SgClassExp::operator new ( size_t Size )
  171575             : {
  171576             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  171577             :      * returning or throwing an exception. */
  171578           0 :     ALLOC_MUTEX(SgClassExp, lock);
  171579             : 
  171580             : #if ROSE_ALLOC_TRACE == 2
  171581             : //    printf("SgClassExp::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgClassExp::next_node);
  171582             : #endif
  171583             : 
  171584             : #if USE_CPP_NEW_DELETE_OPERATORS
  171585             :     void *mem = ROSE_MALLOC(Size);
  171586             :     ALLOC_MUTEX(SgClassExp, unlock);
  171587             :     return mem;
  171588             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  171589             : #if ROSE_PEDANTIC_ALLOC
  171590             :     ROSE_ASSERT(Size == sizeof(SgClassExp));
  171591             : #else
  171592           0 :     if (Size != sizeof(SgClassExp)) {
  171593           0 :       void * object = ROSE_MALLOC(Size);
  171594           0 :       ALLOC_MUTEX(SgClassExp, unlock);
  171595             :       return object;
  171596             :     }
  171597             : #endif
  171598             : 
  171599           0 :     if (SgClassExp::next_node == nullptr) {
  171600           0 :         SgClassExp * alloc = (SgClassExp*) ROSE_MALLOC ( SgClassExp::pool_size * sizeof(SgClassExp) );
  171601           0 :         ROSE_ASSERT(alloc != nullptr);
  171602             : 
  171603             : #if ROSE_ALLOC_TRACE == 2
  171604             : //        printf("SgClassExp::alloc\n  block[%zi] = [ %p , %p [\n", SgClassExp::pools.size(), alloc, alloc + SgClassExp::pool_size);
  171605             : #endif
  171606             : 
  171607             : #if ROSE_ALLOC_MEMSET == 1
  171608             : #elif ROSE_ALLOC_MEMSET == 2
  171609             :         memset(alloc, 0x00, SgClassExp::pool_size * sizeof(SgClassExp));
  171610             : #elif ROSE_ALLOC_MEMSET == 3
  171611             :         memset(alloc, 0xAA, SgClassExp::pool_size * sizeof(SgClassExp));
  171612             : #endif
  171613           0 :         for (unsigned i=0; i < SgClassExp::pool_size-1; i++) {
  171614           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
  171615             :         }
  171616           0 :         alloc[SgClassExp::pool_size-1].p_freepointer = nullptr;
  171617             : 
  171618           0 :         SgClassExp::pools.push_back ( (unsigned char *) alloc );
  171619           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgClassExp::pool_size * sizeof(SgClassExp), V_SgClassExp ) );
  171620           0 :         SgClassExp::next_node = alloc;
  171621             :     }
  171622           0 :     ROSE_ASSERT(SgClassExp::next_node != nullptr);
  171623             : 
  171624           0 :     SgClassExp * object = SgClassExp::next_node;
  171625           0 :     SgClassExp::next_node = (SgClassExp*)(object->p_freepointer);
  171626             : 
  171627             : #if ROSE_ALLOC_TRACE == 2
  171628             :     printf("SgClassExp::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgClassExp::next_node);
  171629             : #endif
  171630             : 
  171631           0 :     SgNode * fp = object->p_freepointer;
  171632             : #if ROSE_ALLOC_MEMSET == 1
  171633             : #elif ROSE_ALLOC_MEMSET == 2
  171634             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgClassExp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  171635             : #elif ROSE_ALLOC_MEMSET == 3
  171636             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgClassExp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  171637             : #endif
  171638           0 :     object->p_freepointer = fp;
  171639             : 
  171640             : #if ROSE_ALLOC_TRACE == 2
  171641             : //    printf("SgClassExp::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgClassExp::next_node);
  171642             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  171643             :     Rose::MemPool::snapshot(oss.str());
  171644             :     alloc_trace_cnt++;
  171645             : #endif
  171646             : 
  171647           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  171648             : 
  171649           0 :     ALLOC_MUTEX(SgClassExp, unlock);
  171650             : 
  171651             :     return object;
  171652             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  171653             : }
  171654             : 
  171655             : 
  171656             : 
  171657             : /*! \brief Delete operator for SgClassExp.
  171658             : 
  171659             :    This delete operator implements deallocation using memory pools to 
  171660             :    provide most efficent use of the heap within construction of large ASTs.
  171661             : 
  171662             : \internal The new and delete operators use the lower level C malloc/free
  171663             :    function calls for performance and to make sure that mixing of malloc/free
  171664             :    and new/delete by the used can be caught more readily.  This may change
  171665             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  171666             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  171667             :    deallocate memory allocated using ROSE_MALLOC.
  171668             : */
  171669           0 : void SgClassExp::operator delete(void *Pointer, size_t Size)
  171670             : {
  171671             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  171672             :      * or throwing an exception. */
  171673           0 :     ALLOC_MUTEX(SgClassExp, lock);
  171674             : 
  171675             : #if USE_CPP_NEW_DELETE_OPERATORS
  171676             :     ROSE_FREE(Pointer);
  171677             : #else
  171678             : #if ROSE_PEDANTIC_ALLOC
  171679             :     ROSE_ASSERT(Size == sizeof(SgClassExp));
  171680             : #else
  171681           0 :     if (Size != sizeof(SgClassExp)) {
  171682           0 :       ROSE_FREE(Pointer);
  171683           0 :       ALLOC_MUTEX(SgClassExp, unlock);
  171684             :       return;
  171685             :     }
  171686             : #endif
  171687             : 
  171688           0 :     SgClassExp * object = (SgClassExp*) Pointer;
  171689           0 :     ROSE_ASSERT(object != nullptr);
  171690             : 
  171691             : #if ROSE_ALLOC_TRACE == 2
  171692             : //  printf("SgClassExp::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgClassExp::next_node);
  171693             :     printf("SgClassExp::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgClassExp::next_node);
  171694             : #endif
  171695             : 
  171696             : #if ROSE_PEDANTIC_ALLOC
  171697             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  171698             : #endif
  171699             : 
  171700             : #if ROSE_ALLOC_MEMSET == 1
  171701             : #elif ROSE_ALLOC_MEMSET == 2
  171702             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgClassExp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  171703             : #elif ROSE_ALLOC_MEMSET == 3
  171704             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgClassExp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  171705             : #endif
  171706             : 
  171707             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  171708             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  171709             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  171710             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  171711             : #else
  171712           0 :     object->p_freepointer = SgClassExp::next_node;
  171713           0 :     SgClassExp::next_node = object;
  171714             : #endif
  171715             : 
  171716             : #if ROSE_ALLOC_TRACE == 2
  171717             : //  printf("SgClassExp::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgClassExp::next_node);
  171718             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  171719             :     Rose::MemPool::snapshot(oss.str());
  171720             :     alloc_trace_cnt++;
  171721             : #endif
  171722             : 
  171723             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  171724             : 
  171725           0 :     ALLOC_MUTEX(SgClassExp, unlock);
  171726             : }
  171727             : 
  171728             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  171729             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  171730             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  171731             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  171732             : // Also, note comment below from Robb (copied from the Common.code file).
  171733             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  171734             : //
  171735             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  171736             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  171737             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  171738             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  171739             : #if 0
  171740             : void SgClassExp::operator delete(void* pointer) { SgClassExp::operator delete (pointer, sizeof(SgClassExp)); };
  171741             : #endif
  171742             : /* #line 171743 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  171743             : 
  171744             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  171745             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  171746             : // obviously imply C++.
  171747             : 
  171748             : // This implements the support within ROSE for memory pools.  Memory pools
  171749             : // support the most condensed usage of memory within the construction of
  171750             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  171751             : // by a new operator written for each class.
  171752             : 
  171753             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  171754             :     // User wants multi-thread support and POSIX threads are available.
  171755             : #   include <pthread.h>
  171756             :     static pthread_mutex_t SgFunctionParameterRefExp_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  171757             : #else
  171758             :      // Cause synchronization to be skipped.
  171759             : #    ifndef ALLOC_MUTEX
  171760             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  171761             : #    endif
  171762             : #    ifdef _REENTRANT
  171763             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  171764             : #       ifdef _MSC_VER
  171765             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  171766             : #       else
  171767             : #           warning "POSIX threads are not available; synchronization being skipped"
  171768             : #       endif
  171769             : #    endif
  171770             : #endif
  171771             : 
  171772             : #ifndef ROSE_ALLOC_TRACE
  171773             : #  define ROSE_ALLOC_TRACE 0
  171774             : #endif
  171775             : 
  171776             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  171777             : #define ROSE_ALLOC_TRACE_CNT
  171778             : #include "memory-pool-snapshot.h"
  171779             : unsigned long alloc_trace_cnt = 0;
  171780             : #endif
  171781             : 
  171782             : #if ROSE_ALLOC_TRACE
  171783             : const unsigned SgFunctionParameterRefExp::pool_size = 5;
  171784             : #else
  171785             : const unsigned SgFunctionParameterRefExp::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  171786             : #endif
  171787             : 
  171788             : #ifndef ROSE_ALLOC_MEMSET
  171789             : #  define ROSE_ALLOC_MEMSET 0
  171790             : #endif
  171791             : 
  171792             : #ifndef ROSE_PEDANTIC_ALLOC
  171793             : #  define ROSE_PEDANTIC_ALLOC 0
  171794             : #endif
  171795             : 
  171796             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  171797             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  171798             : #endif
  171799             : 
  171800             : #if !defined(SGNODE__ALL_POOLS)
  171801             : #define SGNODE__ALL_POOLS
  171802             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  171803             : #endif
  171804             : 
  171805             : SgFunctionParameterRefExp* SgFunctionParameterRefExp::next_node = nullptr;
  171806             : std::vector<unsigned char*> SgFunctionParameterRefExp::pools;
  171807             : 
  171808             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  171809             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  171810             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  171811             : // around this macro definition rather than each use).
  171812             : #ifndef ALLOC_MUTEX
  171813             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  171814             :         do {                                                                     \
  171815             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  171816             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  171817             :                 abort();                                                         \
  171818             :             }                                                                    \
  171819             :         } while (0);
  171820             : #endif
  171821             : 
  171822             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  171823             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  171824             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  171825             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  171826             : 
  171827             : /*! \brief New operator for SgFunctionParameterRefExp.
  171828             : 
  171829             :    This new operator implements memory pools to provide most efficent 
  171830             :    use of the heap within construction of large ASTs.
  171831             : 
  171832             : \internal The new and delete operators use the lower level C malloc/free
  171833             :    function calls for performance and to make sure that mixing of malloc/free
  171834             :    and new/delete by the used can be caught more readily.  This may change
  171835             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  171836             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  171837             :    deallocate memory allocated using ROSE_MALLOC.
  171838             : */
  171839         667 : void *SgFunctionParameterRefExp::operator new ( size_t Size )
  171840             : {
  171841             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  171842             :      * returning or throwing an exception. */
  171843         667 :     ALLOC_MUTEX(SgFunctionParameterRefExp, lock);
  171844             : 
  171845             : #if ROSE_ALLOC_TRACE == 2
  171846             : //    printf("SgFunctionParameterRefExp::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgFunctionParameterRefExp::next_node);
  171847             : #endif
  171848             : 
  171849             : #if USE_CPP_NEW_DELETE_OPERATORS
  171850             :     void *mem = ROSE_MALLOC(Size);
  171851             :     ALLOC_MUTEX(SgFunctionParameterRefExp, unlock);
  171852             :     return mem;
  171853             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  171854             : #if ROSE_PEDANTIC_ALLOC
  171855             :     ROSE_ASSERT(Size == sizeof(SgFunctionParameterRefExp));
  171856             : #else
  171857         667 :     if (Size != sizeof(SgFunctionParameterRefExp)) {
  171858           0 :       void * object = ROSE_MALLOC(Size);
  171859           0 :       ALLOC_MUTEX(SgFunctionParameterRefExp, unlock);
  171860             :       return object;
  171861             :     }
  171862             : #endif
  171863             : 
  171864         667 :     if (SgFunctionParameterRefExp::next_node == nullptr) {
  171865          10 :         SgFunctionParameterRefExp * alloc = (SgFunctionParameterRefExp*) ROSE_MALLOC ( SgFunctionParameterRefExp::pool_size * sizeof(SgFunctionParameterRefExp) );
  171866          10 :         ROSE_ASSERT(alloc != nullptr);
  171867             : 
  171868             : #if ROSE_ALLOC_TRACE == 2
  171869             : //        printf("SgFunctionParameterRefExp::alloc\n  block[%zi] = [ %p , %p [\n", SgFunctionParameterRefExp::pools.size(), alloc, alloc + SgFunctionParameterRefExp::pool_size);
  171870             : #endif
  171871             : 
  171872             : #if ROSE_ALLOC_MEMSET == 1
  171873             : #elif ROSE_ALLOC_MEMSET == 2
  171874             :         memset(alloc, 0x00, SgFunctionParameterRefExp::pool_size * sizeof(SgFunctionParameterRefExp));
  171875             : #elif ROSE_ALLOC_MEMSET == 3
  171876             :         memset(alloc, 0xAA, SgFunctionParameterRefExp::pool_size * sizeof(SgFunctionParameterRefExp));
  171877             : #endif
  171878       20000 :         for (unsigned i=0; i < SgFunctionParameterRefExp::pool_size-1; i++) {
  171879       19990 :           alloc[i].p_freepointer = &(alloc[i+1]);
  171880             :         }
  171881          10 :         alloc[SgFunctionParameterRefExp::pool_size-1].p_freepointer = nullptr;
  171882             : 
  171883          10 :         SgFunctionParameterRefExp::pools.push_back ( (unsigned char *) alloc );
  171884          10 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgFunctionParameterRefExp::pool_size * sizeof(SgFunctionParameterRefExp), V_SgFunctionParameterRefExp ) );
  171885          10 :         SgFunctionParameterRefExp::next_node = alloc;
  171886             :     }
  171887         667 :     ROSE_ASSERT(SgFunctionParameterRefExp::next_node != nullptr);
  171888             : 
  171889         667 :     SgFunctionParameterRefExp * object = SgFunctionParameterRefExp::next_node;
  171890         667 :     SgFunctionParameterRefExp::next_node = (SgFunctionParameterRefExp*)(object->p_freepointer);
  171891             : 
  171892             : #if ROSE_ALLOC_TRACE == 2
  171893             :     printf("SgFunctionParameterRefExp::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgFunctionParameterRefExp::next_node);
  171894             : #endif
  171895             : 
  171896         667 :     SgNode * fp = object->p_freepointer;
  171897             : #if ROSE_ALLOC_MEMSET == 1
  171898             : #elif ROSE_ALLOC_MEMSET == 2
  171899             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgFunctionParameterRefExp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  171900             : #elif ROSE_ALLOC_MEMSET == 3
  171901             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgFunctionParameterRefExp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  171902             : #endif
  171903         667 :     object->p_freepointer = fp;
  171904             : 
  171905             : #if ROSE_ALLOC_TRACE == 2
  171906             : //    printf("SgFunctionParameterRefExp::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgFunctionParameterRefExp::next_node);
  171907             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  171908             :     Rose::MemPool::snapshot(oss.str());
  171909             :     alloc_trace_cnt++;
  171910             : #endif
  171911             : 
  171912         667 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  171913             : 
  171914         667 :     ALLOC_MUTEX(SgFunctionParameterRefExp, unlock);
  171915             : 
  171916             :     return object;
  171917             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  171918             : }
  171919             : 
  171920             : 
  171921             : 
  171922             : /*! \brief Delete operator for SgFunctionParameterRefExp.
  171923             : 
  171924             :    This delete operator implements deallocation using memory pools to 
  171925             :    provide most efficent use of the heap within construction of large ASTs.
  171926             : 
  171927             : \internal The new and delete operators use the lower level C malloc/free
  171928             :    function calls for performance and to make sure that mixing of malloc/free
  171929             :    and new/delete by the used can be caught more readily.  This may change
  171930             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  171931             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  171932             :    deallocate memory allocated using ROSE_MALLOC.
  171933             : */
  171934         134 : void SgFunctionParameterRefExp::operator delete(void *Pointer, size_t Size)
  171935             : {
  171936             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  171937             :      * or throwing an exception. */
  171938         134 :     ALLOC_MUTEX(SgFunctionParameterRefExp, lock);
  171939             : 
  171940             : #if USE_CPP_NEW_DELETE_OPERATORS
  171941             :     ROSE_FREE(Pointer);
  171942             : #else
  171943             : #if ROSE_PEDANTIC_ALLOC
  171944             :     ROSE_ASSERT(Size == sizeof(SgFunctionParameterRefExp));
  171945             : #else
  171946         134 :     if (Size != sizeof(SgFunctionParameterRefExp)) {
  171947           0 :       ROSE_FREE(Pointer);
  171948           0 :       ALLOC_MUTEX(SgFunctionParameterRefExp, unlock);
  171949             :       return;
  171950             :     }
  171951             : #endif
  171952             : 
  171953         134 :     SgFunctionParameterRefExp * object = (SgFunctionParameterRefExp*) Pointer;
  171954         134 :     ROSE_ASSERT(object != nullptr);
  171955             : 
  171956             : #if ROSE_ALLOC_TRACE == 2
  171957             : //  printf("SgFunctionParameterRefExp::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgFunctionParameterRefExp::next_node);
  171958             :     printf("SgFunctionParameterRefExp::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgFunctionParameterRefExp::next_node);
  171959             : #endif
  171960             : 
  171961             : #if ROSE_PEDANTIC_ALLOC
  171962             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  171963             : #endif
  171964             : 
  171965             : #if ROSE_ALLOC_MEMSET == 1
  171966             : #elif ROSE_ALLOC_MEMSET == 2
  171967             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgFunctionParameterRefExp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  171968             : #elif ROSE_ALLOC_MEMSET == 3
  171969             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgFunctionParameterRefExp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  171970             : #endif
  171971             : 
  171972             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  171973             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  171974             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  171975             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  171976             : #else
  171977         134 :     object->p_freepointer = SgFunctionParameterRefExp::next_node;
  171978         134 :     SgFunctionParameterRefExp::next_node = object;
  171979             : #endif
  171980             : 
  171981             : #if ROSE_ALLOC_TRACE == 2
  171982             : //  printf("SgFunctionParameterRefExp::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgFunctionParameterRefExp::next_node);
  171983             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  171984             :     Rose::MemPool::snapshot(oss.str());
  171985             :     alloc_trace_cnt++;
  171986             : #endif
  171987             : 
  171988             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  171989             : 
  171990         134 :     ALLOC_MUTEX(SgFunctionParameterRefExp, unlock);
  171991             : }
  171992             : 
  171993             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  171994             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  171995             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  171996             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  171997             : // Also, note comment below from Robb (copied from the Common.code file).
  171998             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  171999             : //
  172000             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  172001             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  172002             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  172003             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  172004             : #if 0
  172005             : void SgFunctionParameterRefExp::operator delete(void* pointer) { SgFunctionParameterRefExp::operator delete (pointer, sizeof(SgFunctionParameterRefExp)); };
  172006             : #endif
  172007             : /* #line 172008 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  172008             : 
  172009             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  172010             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  172011             : // obviously imply C++.
  172012             : 
  172013             : // This implements the support within ROSE for memory pools.  Memory pools
  172014             : // support the most condensed usage of memory within the construction of
  172015             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  172016             : // by a new operator written for each class.
  172017             : 
  172018             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  172019             :     // User wants multi-thread support and POSIX threads are available.
  172020             : #   include <pthread.h>
  172021             :     static pthread_mutex_t SgLambdaExp_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  172022             : #else
  172023             :      // Cause synchronization to be skipped.
  172024             : #    ifndef ALLOC_MUTEX
  172025             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  172026             : #    endif
  172027             : #    ifdef _REENTRANT
  172028             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  172029             : #       ifdef _MSC_VER
  172030             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  172031             : #       else
  172032             : #           warning "POSIX threads are not available; synchronization being skipped"
  172033             : #       endif
  172034             : #    endif
  172035             : #endif
  172036             : 
  172037             : #ifndef ROSE_ALLOC_TRACE
  172038             : #  define ROSE_ALLOC_TRACE 0
  172039             : #endif
  172040             : 
  172041             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  172042             : #define ROSE_ALLOC_TRACE_CNT
  172043             : #include "memory-pool-snapshot.h"
  172044             : unsigned long alloc_trace_cnt = 0;
  172045             : #endif
  172046             : 
  172047             : #if ROSE_ALLOC_TRACE
  172048             : const unsigned SgLambdaExp::pool_size = 5;
  172049             : #else
  172050             : const unsigned SgLambdaExp::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  172051             : #endif
  172052             : 
  172053             : #ifndef ROSE_ALLOC_MEMSET
  172054             : #  define ROSE_ALLOC_MEMSET 0
  172055             : #endif
  172056             : 
  172057             : #ifndef ROSE_PEDANTIC_ALLOC
  172058             : #  define ROSE_PEDANTIC_ALLOC 0
  172059             : #endif
  172060             : 
  172061             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  172062             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  172063             : #endif
  172064             : 
  172065             : #if !defined(SGNODE__ALL_POOLS)
  172066             : #define SGNODE__ALL_POOLS
  172067             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  172068             : #endif
  172069             : 
  172070             : SgLambdaExp* SgLambdaExp::next_node = nullptr;
  172071             : std::vector<unsigned char*> SgLambdaExp::pools;
  172072             : 
  172073             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  172074             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  172075             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  172076             : // around this macro definition rather than each use).
  172077             : #ifndef ALLOC_MUTEX
  172078             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  172079             :         do {                                                                     \
  172080             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  172081             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  172082             :                 abort();                                                         \
  172083             :             }                                                                    \
  172084             :         } while (0);
  172085             : #endif
  172086             : 
  172087             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  172088             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  172089             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  172090             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  172091             : 
  172092             : /*! \brief New operator for SgLambdaExp.
  172093             : 
  172094             :    This new operator implements memory pools to provide most efficent 
  172095             :    use of the heap within construction of large ASTs.
  172096             : 
  172097             : \internal The new and delete operators use the lower level C malloc/free
  172098             :    function calls for performance and to make sure that mixing of malloc/free
  172099             :    and new/delete by the used can be caught more readily.  This may change
  172100             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  172101             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  172102             :    deallocate memory allocated using ROSE_MALLOC.
  172103             : */
  172104           0 : void *SgLambdaExp::operator new ( size_t Size )
  172105             : {
  172106             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  172107             :      * returning or throwing an exception. */
  172108           0 :     ALLOC_MUTEX(SgLambdaExp, lock);
  172109             : 
  172110             : #if ROSE_ALLOC_TRACE == 2
  172111             : //    printf("SgLambdaExp::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgLambdaExp::next_node);
  172112             : #endif
  172113             : 
  172114             : #if USE_CPP_NEW_DELETE_OPERATORS
  172115             :     void *mem = ROSE_MALLOC(Size);
  172116             :     ALLOC_MUTEX(SgLambdaExp, unlock);
  172117             :     return mem;
  172118             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  172119             : #if ROSE_PEDANTIC_ALLOC
  172120             :     ROSE_ASSERT(Size == sizeof(SgLambdaExp));
  172121             : #else
  172122           0 :     if (Size != sizeof(SgLambdaExp)) {
  172123           0 :       void * object = ROSE_MALLOC(Size);
  172124           0 :       ALLOC_MUTEX(SgLambdaExp, unlock);
  172125             :       return object;
  172126             :     }
  172127             : #endif
  172128             : 
  172129           0 :     if (SgLambdaExp::next_node == nullptr) {
  172130           0 :         SgLambdaExp * alloc = (SgLambdaExp*) ROSE_MALLOC ( SgLambdaExp::pool_size * sizeof(SgLambdaExp) );
  172131           0 :         ROSE_ASSERT(alloc != nullptr);
  172132             : 
  172133             : #if ROSE_ALLOC_TRACE == 2
  172134             : //        printf("SgLambdaExp::alloc\n  block[%zi] = [ %p , %p [\n", SgLambdaExp::pools.size(), alloc, alloc + SgLambdaExp::pool_size);
  172135             : #endif
  172136             : 
  172137             : #if ROSE_ALLOC_MEMSET == 1
  172138             : #elif ROSE_ALLOC_MEMSET == 2
  172139             :         memset(alloc, 0x00, SgLambdaExp::pool_size * sizeof(SgLambdaExp));
  172140             : #elif ROSE_ALLOC_MEMSET == 3
  172141             :         memset(alloc, 0xAA, SgLambdaExp::pool_size * sizeof(SgLambdaExp));
  172142             : #endif
  172143           0 :         for (unsigned i=0; i < SgLambdaExp::pool_size-1; i++) {
  172144           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
  172145             :         }
  172146           0 :         alloc[SgLambdaExp::pool_size-1].p_freepointer = nullptr;
  172147             : 
  172148           0 :         SgLambdaExp::pools.push_back ( (unsigned char *) alloc );
  172149           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgLambdaExp::pool_size * sizeof(SgLambdaExp), V_SgLambdaExp ) );
  172150           0 :         SgLambdaExp::next_node = alloc;
  172151             :     }
  172152           0 :     ROSE_ASSERT(SgLambdaExp::next_node != nullptr);
  172153             : 
  172154           0 :     SgLambdaExp * object = SgLambdaExp::next_node;
  172155           0 :     SgLambdaExp::next_node = (SgLambdaExp*)(object->p_freepointer);
  172156             : 
  172157             : #if ROSE_ALLOC_TRACE == 2
  172158             :     printf("SgLambdaExp::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgLambdaExp::next_node);
  172159             : #endif
  172160             : 
  172161           0 :     SgNode * fp = object->p_freepointer;
  172162             : #if ROSE_ALLOC_MEMSET == 1
  172163             : #elif ROSE_ALLOC_MEMSET == 2
  172164             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgLambdaExp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  172165             : #elif ROSE_ALLOC_MEMSET == 3
  172166             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgLambdaExp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  172167             : #endif
  172168           0 :     object->p_freepointer = fp;
  172169             : 
  172170             : #if ROSE_ALLOC_TRACE == 2
  172171             : //    printf("SgLambdaExp::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgLambdaExp::next_node);
  172172             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  172173             :     Rose::MemPool::snapshot(oss.str());
  172174             :     alloc_trace_cnt++;
  172175             : #endif
  172176             : 
  172177           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  172178             : 
  172179           0 :     ALLOC_MUTEX(SgLambdaExp, unlock);
  172180             : 
  172181             :     return object;
  172182             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  172183             : }
  172184             : 
  172185             : 
  172186             : 
  172187             : /*! \brief Delete operator for SgLambdaExp.
  172188             : 
  172189             :    This delete operator implements deallocation using memory pools to 
  172190             :    provide most efficent use of the heap within construction of large ASTs.
  172191             : 
  172192             : \internal The new and delete operators use the lower level C malloc/free
  172193             :    function calls for performance and to make sure that mixing of malloc/free
  172194             :    and new/delete by the used can be caught more readily.  This may change
  172195             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  172196             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  172197             :    deallocate memory allocated using ROSE_MALLOC.
  172198             : */
  172199           0 : void SgLambdaExp::operator delete(void *Pointer, size_t Size)
  172200             : {
  172201             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  172202             :      * or throwing an exception. */
  172203           0 :     ALLOC_MUTEX(SgLambdaExp, lock);
  172204             : 
  172205             : #if USE_CPP_NEW_DELETE_OPERATORS
  172206             :     ROSE_FREE(Pointer);
  172207             : #else
  172208             : #if ROSE_PEDANTIC_ALLOC
  172209             :     ROSE_ASSERT(Size == sizeof(SgLambdaExp));
  172210             : #else
  172211           0 :     if (Size != sizeof(SgLambdaExp)) {
  172212           0 :       ROSE_FREE(Pointer);
  172213           0 :       ALLOC_MUTEX(SgLambdaExp, unlock);
  172214             :       return;
  172215             :     }
  172216             : #endif
  172217             : 
  172218           0 :     SgLambdaExp * object = (SgLambdaExp*) Pointer;
  172219           0 :     ROSE_ASSERT(object != nullptr);
  172220             : 
  172221             : #if ROSE_ALLOC_TRACE == 2
  172222             : //  printf("SgLambdaExp::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgLambdaExp::next_node);
  172223             :     printf("SgLambdaExp::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgLambdaExp::next_node);
  172224             : #endif
  172225             : 
  172226             : #if ROSE_PEDANTIC_ALLOC
  172227             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  172228             : #endif
  172229             : 
  172230             : #if ROSE_ALLOC_MEMSET == 1
  172231             : #elif ROSE_ALLOC_MEMSET == 2
  172232             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgLambdaExp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  172233             : #elif ROSE_ALLOC_MEMSET == 3
  172234             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgLambdaExp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  172235             : #endif
  172236             : 
  172237             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  172238             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  172239             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  172240             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  172241             : #else
  172242           0 :     object->p_freepointer = SgLambdaExp::next_node;
  172243           0 :     SgLambdaExp::next_node = object;
  172244             : #endif
  172245             : 
  172246             : #if ROSE_ALLOC_TRACE == 2
  172247             : //  printf("SgLambdaExp::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgLambdaExp::next_node);
  172248             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  172249             :     Rose::MemPool::snapshot(oss.str());
  172250             :     alloc_trace_cnt++;
  172251             : #endif
  172252             : 
  172253             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  172254             : 
  172255           0 :     ALLOC_MUTEX(SgLambdaExp, unlock);
  172256             : }
  172257             : 
  172258             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  172259             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  172260             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  172261             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  172262             : // Also, note comment below from Robb (copied from the Common.code file).
  172263             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  172264             : //
  172265             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  172266             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  172267             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  172268             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  172269             : #if 0
  172270             : void SgLambdaExp::operator delete(void* pointer) { SgLambdaExp::operator delete (pointer, sizeof(SgLambdaExp)); };
  172271             : #endif
  172272             : /* #line 172273 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  172273             : 
  172274             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  172275             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  172276             : // obviously imply C++.
  172277             : 
  172278             : // This implements the support within ROSE for memory pools.  Memory pools
  172279             : // support the most condensed usage of memory within the construction of
  172280             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  172281             : // by a new operator written for each class.
  172282             : 
  172283             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  172284             :     // User wants multi-thread support and POSIX threads are available.
  172285             : #   include <pthread.h>
  172286             :     static pthread_mutex_t SgNoexceptOp_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  172287             : #else
  172288             :      // Cause synchronization to be skipped.
  172289             : #    ifndef ALLOC_MUTEX
  172290             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  172291             : #    endif
  172292             : #    ifdef _REENTRANT
  172293             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  172294             : #       ifdef _MSC_VER
  172295             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  172296             : #       else
  172297             : #           warning "POSIX threads are not available; synchronization being skipped"
  172298             : #       endif
  172299             : #    endif
  172300             : #endif
  172301             : 
  172302             : #ifndef ROSE_ALLOC_TRACE
  172303             : #  define ROSE_ALLOC_TRACE 0
  172304             : #endif
  172305             : 
  172306             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  172307             : #define ROSE_ALLOC_TRACE_CNT
  172308             : #include "memory-pool-snapshot.h"
  172309             : unsigned long alloc_trace_cnt = 0;
  172310             : #endif
  172311             : 
  172312             : #if ROSE_ALLOC_TRACE
  172313             : const unsigned SgNoexceptOp::pool_size = 5;
  172314             : #else
  172315             : const unsigned SgNoexceptOp::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  172316             : #endif
  172317             : 
  172318             : #ifndef ROSE_ALLOC_MEMSET
  172319             : #  define ROSE_ALLOC_MEMSET 0
  172320             : #endif
  172321             : 
  172322             : #ifndef ROSE_PEDANTIC_ALLOC
  172323             : #  define ROSE_PEDANTIC_ALLOC 0
  172324             : #endif
  172325             : 
  172326             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  172327             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  172328             : #endif
  172329             : 
  172330             : #if !defined(SGNODE__ALL_POOLS)
  172331             : #define SGNODE__ALL_POOLS
  172332             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  172333             : #endif
  172334             : 
  172335             : SgNoexceptOp* SgNoexceptOp::next_node = nullptr;
  172336             : std::vector<unsigned char*> SgNoexceptOp::pools;
  172337             : 
  172338             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  172339             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  172340             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  172341             : // around this macro definition rather than each use).
  172342             : #ifndef ALLOC_MUTEX
  172343             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  172344             :         do {                                                                     \
  172345             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  172346             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  172347             :                 abort();                                                         \
  172348             :             }                                                                    \
  172349             :         } while (0);
  172350             : #endif
  172351             : 
  172352             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  172353             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  172354             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  172355             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  172356             : 
  172357             : /*! \brief New operator for SgNoexceptOp.
  172358             : 
  172359             :    This new operator implements memory pools to provide most efficent 
  172360             :    use of the heap within construction of large ASTs.
  172361             : 
  172362             : \internal The new and delete operators use the lower level C malloc/free
  172363             :    function calls for performance and to make sure that mixing of malloc/free
  172364             :    and new/delete by the used can be caught more readily.  This may change
  172365             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  172366             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  172367             :    deallocate memory allocated using ROSE_MALLOC.
  172368             : */
  172369         201 : void *SgNoexceptOp::operator new ( size_t Size )
  172370             : {
  172371             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  172372             :      * returning or throwing an exception. */
  172373         201 :     ALLOC_MUTEX(SgNoexceptOp, lock);
  172374             : 
  172375             : #if ROSE_ALLOC_TRACE == 2
  172376             : //    printf("SgNoexceptOp::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgNoexceptOp::next_node);
  172377             : #endif
  172378             : 
  172379             : #if USE_CPP_NEW_DELETE_OPERATORS
  172380             :     void *mem = ROSE_MALLOC(Size);
  172381             :     ALLOC_MUTEX(SgNoexceptOp, unlock);
  172382             :     return mem;
  172383             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  172384             : #if ROSE_PEDANTIC_ALLOC
  172385             :     ROSE_ASSERT(Size == sizeof(SgNoexceptOp));
  172386             : #else
  172387         201 :     if (Size != sizeof(SgNoexceptOp)) {
  172388           0 :       void * object = ROSE_MALLOC(Size);
  172389           0 :       ALLOC_MUTEX(SgNoexceptOp, unlock);
  172390             :       return object;
  172391             :     }
  172392             : #endif
  172393             : 
  172394         201 :     if (SgNoexceptOp::next_node == nullptr) {
  172395          10 :         SgNoexceptOp * alloc = (SgNoexceptOp*) ROSE_MALLOC ( SgNoexceptOp::pool_size * sizeof(SgNoexceptOp) );
  172396          10 :         ROSE_ASSERT(alloc != nullptr);
  172397             : 
  172398             : #if ROSE_ALLOC_TRACE == 2
  172399             : //        printf("SgNoexceptOp::alloc\n  block[%zi] = [ %p , %p [\n", SgNoexceptOp::pools.size(), alloc, alloc + SgNoexceptOp::pool_size);
  172400             : #endif
  172401             : 
  172402             : #if ROSE_ALLOC_MEMSET == 1
  172403             : #elif ROSE_ALLOC_MEMSET == 2
  172404             :         memset(alloc, 0x00, SgNoexceptOp::pool_size * sizeof(SgNoexceptOp));
  172405             : #elif ROSE_ALLOC_MEMSET == 3
  172406             :         memset(alloc, 0xAA, SgNoexceptOp::pool_size * sizeof(SgNoexceptOp));
  172407             : #endif
  172408       20000 :         for (unsigned i=0; i < SgNoexceptOp::pool_size-1; i++) {
  172409       19990 :           alloc[i].p_freepointer = &(alloc[i+1]);
  172410             :         }
  172411          10 :         alloc[SgNoexceptOp::pool_size-1].p_freepointer = nullptr;
  172412             : 
  172413          10 :         SgNoexceptOp::pools.push_back ( (unsigned char *) alloc );
  172414          10 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgNoexceptOp::pool_size * sizeof(SgNoexceptOp), V_SgNoexceptOp ) );
  172415          10 :         SgNoexceptOp::next_node = alloc;
  172416             :     }
  172417         201 :     ROSE_ASSERT(SgNoexceptOp::next_node != nullptr);
  172418             : 
  172419         201 :     SgNoexceptOp * object = SgNoexceptOp::next_node;
  172420         201 :     SgNoexceptOp::next_node = (SgNoexceptOp*)(object->p_freepointer);
  172421             : 
  172422             : #if ROSE_ALLOC_TRACE == 2
  172423             :     printf("SgNoexceptOp::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgNoexceptOp::next_node);
  172424             : #endif
  172425             : 
  172426         201 :     SgNode * fp = object->p_freepointer;
  172427             : #if ROSE_ALLOC_MEMSET == 1
  172428             : #elif ROSE_ALLOC_MEMSET == 2
  172429             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgNoexceptOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  172430             : #elif ROSE_ALLOC_MEMSET == 3
  172431             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgNoexceptOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  172432             : #endif
  172433         201 :     object->p_freepointer = fp;
  172434             : 
  172435             : #if ROSE_ALLOC_TRACE == 2
  172436             : //    printf("SgNoexceptOp::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgNoexceptOp::next_node);
  172437             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  172438             :     Rose::MemPool::snapshot(oss.str());
  172439             :     alloc_trace_cnt++;
  172440             : #endif
  172441             : 
  172442         201 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  172443             : 
  172444         201 :     ALLOC_MUTEX(SgNoexceptOp, unlock);
  172445             : 
  172446             :     return object;
  172447             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  172448             : }
  172449             : 
  172450             : 
  172451             : 
  172452             : /*! \brief Delete operator for SgNoexceptOp.
  172453             : 
  172454             :    This delete operator implements deallocation using memory pools to 
  172455             :    provide most efficent use of the heap within construction of large ASTs.
  172456             : 
  172457             : \internal The new and delete operators use the lower level C malloc/free
  172458             :    function calls for performance and to make sure that mixing of malloc/free
  172459             :    and new/delete by the used can be caught more readily.  This may change
  172460             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  172461             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  172462             :    deallocate memory allocated using ROSE_MALLOC.
  172463             : */
  172464          36 : void SgNoexceptOp::operator delete(void *Pointer, size_t Size)
  172465             : {
  172466             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  172467             :      * or throwing an exception. */
  172468          36 :     ALLOC_MUTEX(SgNoexceptOp, lock);
  172469             : 
  172470             : #if USE_CPP_NEW_DELETE_OPERATORS
  172471             :     ROSE_FREE(Pointer);
  172472             : #else
  172473             : #if ROSE_PEDANTIC_ALLOC
  172474             :     ROSE_ASSERT(Size == sizeof(SgNoexceptOp));
  172475             : #else
  172476          36 :     if (Size != sizeof(SgNoexceptOp)) {
  172477           0 :       ROSE_FREE(Pointer);
  172478           0 :       ALLOC_MUTEX(SgNoexceptOp, unlock);
  172479             :       return;
  172480             :     }
  172481             : #endif
  172482             : 
  172483          36 :     SgNoexceptOp * object = (SgNoexceptOp*) Pointer;
  172484          36 :     ROSE_ASSERT(object != nullptr);
  172485             : 
  172486             : #if ROSE_ALLOC_TRACE == 2
  172487             : //  printf("SgNoexceptOp::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgNoexceptOp::next_node);
  172488             :     printf("SgNoexceptOp::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgNoexceptOp::next_node);
  172489             : #endif
  172490             : 
  172491             : #if ROSE_PEDANTIC_ALLOC
  172492             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  172493             : #endif
  172494             : 
  172495             : #if ROSE_ALLOC_MEMSET == 1
  172496             : #elif ROSE_ALLOC_MEMSET == 2
  172497             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgNoexceptOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  172498             : #elif ROSE_ALLOC_MEMSET == 3
  172499             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgNoexceptOp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  172500             : #endif
  172501             : 
  172502             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  172503             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  172504             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  172505             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  172506             : #else
  172507          36 :     object->p_freepointer = SgNoexceptOp::next_node;
  172508          36 :     SgNoexceptOp::next_node = object;
  172509             : #endif
  172510             : 
  172511             : #if ROSE_ALLOC_TRACE == 2
  172512             : //  printf("SgNoexceptOp::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgNoexceptOp::next_node);
  172513             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  172514             :     Rose::MemPool::snapshot(oss.str());
  172515             :     alloc_trace_cnt++;
  172516             : #endif
  172517             : 
  172518             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  172519             : 
  172520          36 :     ALLOC_MUTEX(SgNoexceptOp, unlock);
  172521             : }
  172522             : 
  172523             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  172524             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  172525             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  172526             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  172527             : // Also, note comment below from Robb (copied from the Common.code file).
  172528             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  172529             : //
  172530             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  172531             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  172532             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  172533             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  172534             : #if 0
  172535             : void SgNoexceptOp::operator delete(void* pointer) { SgNoexceptOp::operator delete (pointer, sizeof(SgNoexceptOp)); };
  172536             : #endif
  172537             : /* #line 172538 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  172538             : 
  172539             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  172540             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  172541             : // obviously imply C++.
  172542             : 
  172543             : // This implements the support within ROSE for memory pools.  Memory pools
  172544             : // support the most condensed usage of memory within the construction of
  172545             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  172546             : // by a new operator written for each class.
  172547             : 
  172548             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  172549             :     // User wants multi-thread support and POSIX threads are available.
  172550             : #   include <pthread.h>
  172551             :     static pthread_mutex_t SgNonrealRefExp_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  172552             : #else
  172553             :      // Cause synchronization to be skipped.
  172554             : #    ifndef ALLOC_MUTEX
  172555             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  172556             : #    endif
  172557             : #    ifdef _REENTRANT
  172558             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  172559             : #       ifdef _MSC_VER
  172560             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  172561             : #       else
  172562             : #           warning "POSIX threads are not available; synchronization being skipped"
  172563             : #       endif
  172564             : #    endif
  172565             : #endif
  172566             : 
  172567             : #ifndef ROSE_ALLOC_TRACE
  172568             : #  define ROSE_ALLOC_TRACE 0
  172569             : #endif
  172570             : 
  172571             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  172572             : #define ROSE_ALLOC_TRACE_CNT
  172573             : #include "memory-pool-snapshot.h"
  172574             : unsigned long alloc_trace_cnt = 0;
  172575             : #endif
  172576             : 
  172577             : #if ROSE_ALLOC_TRACE
  172578             : const unsigned SgNonrealRefExp::pool_size = 5;
  172579             : #else
  172580             : const unsigned SgNonrealRefExp::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  172581             : #endif
  172582             : 
  172583             : #ifndef ROSE_ALLOC_MEMSET
  172584             : #  define ROSE_ALLOC_MEMSET 0
  172585             : #endif
  172586             : 
  172587             : #ifndef ROSE_PEDANTIC_ALLOC
  172588             : #  define ROSE_PEDANTIC_ALLOC 0
  172589             : #endif
  172590             : 
  172591             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  172592             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  172593             : #endif
  172594             : 
  172595             : #if !defined(SGNODE__ALL_POOLS)
  172596             : #define SGNODE__ALL_POOLS
  172597             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  172598             : #endif
  172599             : 
  172600             : SgNonrealRefExp* SgNonrealRefExp::next_node = nullptr;
  172601             : std::vector<unsigned char*> SgNonrealRefExp::pools;
  172602             : 
  172603             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  172604             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  172605             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  172606             : // around this macro definition rather than each use).
  172607             : #ifndef ALLOC_MUTEX
  172608             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  172609             :         do {                                                                     \
  172610             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  172611             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  172612             :                 abort();                                                         \
  172613             :             }                                                                    \
  172614             :         } while (0);
  172615             : #endif
  172616             : 
  172617             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  172618             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  172619             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  172620             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  172621             : 
  172622             : /*! \brief New operator for SgNonrealRefExp.
  172623             : 
  172624             :    This new operator implements memory pools to provide most efficent 
  172625             :    use of the heap within construction of large ASTs.
  172626             : 
  172627             : \internal The new and delete operators use the lower level C malloc/free
  172628             :    function calls for performance and to make sure that mixing of malloc/free
  172629             :    and new/delete by the used can be caught more readily.  This may change
  172630             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  172631             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  172632             :    deallocate memory allocated using ROSE_MALLOC.
  172633             : */
  172634       18085 : void *SgNonrealRefExp::operator new ( size_t Size )
  172635             : {
  172636             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  172637             :      * returning or throwing an exception. */
  172638       18085 :     ALLOC_MUTEX(SgNonrealRefExp, lock);
  172639             : 
  172640             : #if ROSE_ALLOC_TRACE == 2
  172641             : //    printf("SgNonrealRefExp::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgNonrealRefExp::next_node);
  172642             : #endif
  172643             : 
  172644             : #if USE_CPP_NEW_DELETE_OPERATORS
  172645             :     void *mem = ROSE_MALLOC(Size);
  172646             :     ALLOC_MUTEX(SgNonrealRefExp, unlock);
  172647             :     return mem;
  172648             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  172649             : #if ROSE_PEDANTIC_ALLOC
  172650             :     ROSE_ASSERT(Size == sizeof(SgNonrealRefExp));
  172651             : #else
  172652       18085 :     if (Size != sizeof(SgNonrealRefExp)) {
  172653           0 :       void * object = ROSE_MALLOC(Size);
  172654           0 :       ALLOC_MUTEX(SgNonrealRefExp, unlock);
  172655             :       return object;
  172656             :     }
  172657             : #endif
  172658             : 
  172659       18085 :     if (SgNonrealRefExp::next_node == nullptr) {
  172660          11 :         SgNonrealRefExp * alloc = (SgNonrealRefExp*) ROSE_MALLOC ( SgNonrealRefExp::pool_size * sizeof(SgNonrealRefExp) );
  172661          11 :         ROSE_ASSERT(alloc != nullptr);
  172662             : 
  172663             : #if ROSE_ALLOC_TRACE == 2
  172664             : //        printf("SgNonrealRefExp::alloc\n  block[%zi] = [ %p , %p [\n", SgNonrealRefExp::pools.size(), alloc, alloc + SgNonrealRefExp::pool_size);
  172665             : #endif
  172666             : 
  172667             : #if ROSE_ALLOC_MEMSET == 1
  172668             : #elif ROSE_ALLOC_MEMSET == 2
  172669             :         memset(alloc, 0x00, SgNonrealRefExp::pool_size * sizeof(SgNonrealRefExp));
  172670             : #elif ROSE_ALLOC_MEMSET == 3
  172671             :         memset(alloc, 0xAA, SgNonrealRefExp::pool_size * sizeof(SgNonrealRefExp));
  172672             : #endif
  172673       22000 :         for (unsigned i=0; i < SgNonrealRefExp::pool_size-1; i++) {
  172674       21989 :           alloc[i].p_freepointer = &(alloc[i+1]);
  172675             :         }
  172676          11 :         alloc[SgNonrealRefExp::pool_size-1].p_freepointer = nullptr;
  172677             : 
  172678          11 :         SgNonrealRefExp::pools.push_back ( (unsigned char *) alloc );
  172679          11 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgNonrealRefExp::pool_size * sizeof(SgNonrealRefExp), V_SgNonrealRefExp ) );
  172680          11 :         SgNonrealRefExp::next_node = alloc;
  172681             :     }
  172682       18085 :     ROSE_ASSERT(SgNonrealRefExp::next_node != nullptr);
  172683             : 
  172684       18085 :     SgNonrealRefExp * object = SgNonrealRefExp::next_node;
  172685       18085 :     SgNonrealRefExp::next_node = (SgNonrealRefExp*)(object->p_freepointer);
  172686             : 
  172687             : #if ROSE_ALLOC_TRACE == 2
  172688             :     printf("SgNonrealRefExp::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgNonrealRefExp::next_node);
  172689             : #endif
  172690             : 
  172691       18085 :     SgNode * fp = object->p_freepointer;
  172692             : #if ROSE_ALLOC_MEMSET == 1
  172693             : #elif ROSE_ALLOC_MEMSET == 2
  172694             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgNonrealRefExp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  172695             : #elif ROSE_ALLOC_MEMSET == 3
  172696             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgNonrealRefExp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  172697             : #endif
  172698       18085 :     object->p_freepointer = fp;
  172699             : 
  172700             : #if ROSE_ALLOC_TRACE == 2
  172701             : //    printf("SgNonrealRefExp::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgNonrealRefExp::next_node);
  172702             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  172703             :     Rose::MemPool::snapshot(oss.str());
  172704             :     alloc_trace_cnt++;
  172705             : #endif
  172706             : 
  172707       18085 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  172708             : 
  172709       18085 :     ALLOC_MUTEX(SgNonrealRefExp, unlock);
  172710             : 
  172711             :     return object;
  172712             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  172713             : }
  172714             : 
  172715             : 
  172716             : 
  172717             : /*! \brief Delete operator for SgNonrealRefExp.
  172718             : 
  172719             :    This delete operator implements deallocation using memory pools to 
  172720             :    provide most efficent use of the heap within construction of large ASTs.
  172721             : 
  172722             : \internal The new and delete operators use the lower level C malloc/free
  172723             :    function calls for performance and to make sure that mixing of malloc/free
  172724             :    and new/delete by the used can be caught more readily.  This may change
  172725             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  172726             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  172727             :    deallocate memory allocated using ROSE_MALLOC.
  172728             : */
  172729        3584 : void SgNonrealRefExp::operator delete(void *Pointer, size_t Size)
  172730             : {
  172731             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  172732             :      * or throwing an exception. */
  172733        3584 :     ALLOC_MUTEX(SgNonrealRefExp, lock);
  172734             : 
  172735             : #if USE_CPP_NEW_DELETE_OPERATORS
  172736             :     ROSE_FREE(Pointer);
  172737             : #else
  172738             : #if ROSE_PEDANTIC_ALLOC
  172739             :     ROSE_ASSERT(Size == sizeof(SgNonrealRefExp));
  172740             : #else
  172741        3584 :     if (Size != sizeof(SgNonrealRefExp)) {
  172742           0 :       ROSE_FREE(Pointer);
  172743           0 :       ALLOC_MUTEX(SgNonrealRefExp, unlock);
  172744             :       return;
  172745             :     }
  172746             : #endif
  172747             : 
  172748        3584 :     SgNonrealRefExp * object = (SgNonrealRefExp*) Pointer;
  172749        3584 :     ROSE_ASSERT(object != nullptr);
  172750             : 
  172751             : #if ROSE_ALLOC_TRACE == 2
  172752             : //  printf("SgNonrealRefExp::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgNonrealRefExp::next_node);
  172753             :     printf("SgNonrealRefExp::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgNonrealRefExp::next_node);
  172754             : #endif
  172755             : 
  172756             : #if ROSE_PEDANTIC_ALLOC
  172757             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  172758             : #endif
  172759             : 
  172760             : #if ROSE_ALLOC_MEMSET == 1
  172761             : #elif ROSE_ALLOC_MEMSET == 2
  172762             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgNonrealRefExp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  172763             : #elif ROSE_ALLOC_MEMSET == 3
  172764             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgNonrealRefExp) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  172765             : #endif
  172766             : 
  172767             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  172768             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  172769             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  172770             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  172771             : #else
  172772        3584 :     object->p_freepointer = SgNonrealRefExp::next_node;
  172773        3584 :     SgNonrealRefExp::next_node = object;
  172774             : #endif
  172775             : 
  172776             : #if ROSE_ALLOC_TRACE == 2
  172777             : //  printf("SgNonrealRefExp::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgNonrealRefExp::next_node);
  172778             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  172779             :     Rose::MemPool::snapshot(oss.str());
  172780             :     alloc_trace_cnt++;
  172781             : #endif
  172782             : 
  172783             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  172784             : 
  172785        3584 :     ALLOC_MUTEX(SgNonrealRefExp, unlock);
  172786             : }
  172787             : 
  172788             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  172789             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  172790             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  172791             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  172792             : // Also, note comment below from Robb (copied from the Common.code file).
  172793             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  172794             : //
  172795             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  172796             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  172797             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  172798             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  172799             : #if 0
  172800             : void SgNonrealRefExp::operator delete(void* pointer) { SgNonrealRefExp::operator delete (pointer, sizeof(SgNonrealRefExp)); };
  172801             : #endif
  172802             : /* #line 172803 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  172803             : 
  172804             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  172805             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  172806             : // obviously imply C++.
  172807             : 
  172808             : // This implements the support within ROSE for memory pools.  Memory pools
  172809             : // support the most condensed usage of memory within the construction of
  172810             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  172811             : // by a new operator written for each class.
  172812             : 
  172813             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  172814             :     // User wants multi-thread support and POSIX threads are available.
  172815             : #   include <pthread.h>
  172816             :     static pthread_mutex_t SgFoldExpression_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  172817             : #else
  172818             :      // Cause synchronization to be skipped.
  172819             : #    ifndef ALLOC_MUTEX
  172820             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  172821             : #    endif
  172822             : #    ifdef _REENTRANT
  172823             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  172824             : #       ifdef _MSC_VER
  172825             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  172826             : #       else
  172827             : #           warning "POSIX threads are not available; synchronization being skipped"
  172828             : #       endif
  172829             : #    endif
  172830             : #endif
  172831             : 
  172832             : #ifndef ROSE_ALLOC_TRACE
  172833             : #  define ROSE_ALLOC_TRACE 0
  172834             : #endif
  172835             : 
  172836             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  172837             : #define ROSE_ALLOC_TRACE_CNT
  172838             : #include "memory-pool-snapshot.h"
  172839             : unsigned long alloc_trace_cnt = 0;
  172840             : #endif
  172841             : 
  172842             : #if ROSE_ALLOC_TRACE
  172843             : const unsigned SgFoldExpression::pool_size = 5;
  172844             : #else
  172845             : const unsigned SgFoldExpression::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  172846             : #endif
  172847             : 
  172848             : #ifndef ROSE_ALLOC_MEMSET
  172849             : #  define ROSE_ALLOC_MEMSET 0
  172850             : #endif
  172851             : 
  172852             : #ifndef ROSE_PEDANTIC_ALLOC
  172853             : #  define ROSE_PEDANTIC_ALLOC 0
  172854             : #endif
  172855             : 
  172856             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  172857             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  172858             : #endif
  172859             : 
  172860             : #if !defined(SGNODE__ALL_POOLS)
  172861             : #define SGNODE__ALL_POOLS
  172862             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  172863             : #endif
  172864             : 
  172865             : SgFoldExpression* SgFoldExpression::next_node = nullptr;
  172866             : std::vector<unsigned char*> SgFoldExpression::pools;
  172867             : 
  172868             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  172869             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  172870             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  172871             : // around this macro definition rather than each use).
  172872             : #ifndef ALLOC_MUTEX
  172873             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  172874             :         do {                                                                     \
  172875             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  172876             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  172877             :                 abort();                                                         \
  172878             :             }                                                                    \
  172879             :         } while (0);
  172880             : #endif
  172881             : 
  172882             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  172883             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  172884             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  172885             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  172886             : 
  172887             : /*! \brief New operator for SgFoldExpression.
  172888             : 
  172889             :    This new operator implements memory pools to provide most efficent 
  172890             :    use of the heap within construction of large ASTs.
  172891             : 
  172892             : \internal The new and delete operators use the lower level C malloc/free
  172893             :    function calls for performance and to make sure that mixing of malloc/free
  172894             :    and new/delete by the used can be caught more readily.  This may change
  172895             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  172896             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  172897             :    deallocate memory allocated using ROSE_MALLOC.
  172898             : */
  172899           0 : void *SgFoldExpression::operator new ( size_t Size )
  172900             : {
  172901             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  172902             :      * returning or throwing an exception. */
  172903           0 :     ALLOC_MUTEX(SgFoldExpression, lock);
  172904             : 
  172905             : #if ROSE_ALLOC_TRACE == 2
  172906             : //    printf("SgFoldExpression::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgFoldExpression::next_node);
  172907             : #endif
  172908             : 
  172909             : #if USE_CPP_NEW_DELETE_OPERATORS
  172910             :     void *mem = ROSE_MALLOC(Size);
  172911             :     ALLOC_MUTEX(SgFoldExpression, unlock);
  172912             :     return mem;
  172913             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  172914             : #if ROSE_PEDANTIC_ALLOC
  172915             :     ROSE_ASSERT(Size == sizeof(SgFoldExpression));
  172916             : #else
  172917           0 :     if (Size != sizeof(SgFoldExpression)) {
  172918           0 :       void * object = ROSE_MALLOC(Size);
  172919           0 :       ALLOC_MUTEX(SgFoldExpression, unlock);
  172920             :       return object;
  172921             :     }
  172922             : #endif
  172923             : 
  172924           0 :     if (SgFoldExpression::next_node == nullptr) {
  172925           0 :         SgFoldExpression * alloc = (SgFoldExpression*) ROSE_MALLOC ( SgFoldExpression::pool_size * sizeof(SgFoldExpression) );
  172926           0 :         ROSE_ASSERT(alloc != nullptr);
  172927             : 
  172928             : #if ROSE_ALLOC_TRACE == 2
  172929             : //        printf("SgFoldExpression::alloc\n  block[%zi] = [ %p , %p [\n", SgFoldExpression::pools.size(), alloc, alloc + SgFoldExpression::pool_size);
  172930             : #endif
  172931             : 
  172932             : #if ROSE_ALLOC_MEMSET == 1
  172933             : #elif ROSE_ALLOC_MEMSET == 2
  172934             :         memset(alloc, 0x00, SgFoldExpression::pool_size * sizeof(SgFoldExpression));
  172935             : #elif ROSE_ALLOC_MEMSET == 3
  172936             :         memset(alloc, 0xAA, SgFoldExpression::pool_size * sizeof(SgFoldExpression));
  172937             : #endif
  172938           0 :         for (unsigned i=0; i < SgFoldExpression::pool_size-1; i++) {
  172939           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
  172940             :         }
  172941           0 :         alloc[SgFoldExpression::pool_size-1].p_freepointer = nullptr;
  172942             : 
  172943           0 :         SgFoldExpression::pools.push_back ( (unsigned char *) alloc );
  172944           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgFoldExpression::pool_size * sizeof(SgFoldExpression), V_SgFoldExpression ) );
  172945           0 :         SgFoldExpression::next_node = alloc;
  172946             :     }
  172947           0 :     ROSE_ASSERT(SgFoldExpression::next_node != nullptr);
  172948             : 
  172949           0 :     SgFoldExpression * object = SgFoldExpression::next_node;
  172950           0 :     SgFoldExpression::next_node = (SgFoldExpression*)(object->p_freepointer);
  172951             : 
  172952             : #if ROSE_ALLOC_TRACE == 2
  172953             :     printf("SgFoldExpression::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgFoldExpression::next_node);
  172954             : #endif
  172955             : 
  172956           0 :     SgNode * fp = object->p_freepointer;
  172957             : #if ROSE_ALLOC_MEMSET == 1
  172958             : #elif ROSE_ALLOC_MEMSET == 2
  172959             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgFoldExpression) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  172960             : #elif ROSE_ALLOC_MEMSET == 3
  172961             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgFoldExpression) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  172962             : #endif
  172963           0 :     object->p_freepointer = fp;
  172964             : 
  172965             : #if ROSE_ALLOC_TRACE == 2
  172966             : //    printf("SgFoldExpression::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgFoldExpression::next_node);
  172967             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  172968             :     Rose::MemPool::snapshot(oss.str());
  172969             :     alloc_trace_cnt++;
  172970             : #endif
  172971             : 
  172972           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  172973             : 
  172974           0 :     ALLOC_MUTEX(SgFoldExpression, unlock);
  172975             : 
  172976             :     return object;
  172977             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  172978             : }
  172979             : 
  172980             : 
  172981             : 
  172982             : /*! \brief Delete operator for SgFoldExpression.
  172983             : 
  172984             :    This delete operator implements deallocation using memory pools to 
  172985             :    provide most efficent use of the heap within construction of large ASTs.
  172986             : 
  172987             : \internal The new and delete operators use the lower level C malloc/free
  172988             :    function calls for performance and to make sure that mixing of malloc/free
  172989             :    and new/delete by the used can be caught more readily.  This may change
  172990             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  172991             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  172992             :    deallocate memory allocated using ROSE_MALLOC.
  172993             : */
  172994           0 : void SgFoldExpression::operator delete(void *Pointer, size_t Size)
  172995             : {
  172996             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  172997             :      * or throwing an exception. */
  172998           0 :     ALLOC_MUTEX(SgFoldExpression, lock);
  172999             : 
  173000             : #if USE_CPP_NEW_DELETE_OPERATORS
  173001             :     ROSE_FREE(Pointer);
  173002             : #else
  173003             : #if ROSE_PEDANTIC_ALLOC
  173004             :     ROSE_ASSERT(Size == sizeof(SgFoldExpression));
  173005             : #else
  173006           0 :     if (Size != sizeof(SgFoldExpression)) {
  173007           0 :       ROSE_FREE(Pointer);
  173008           0 :       ALLOC_MUTEX(SgFoldExpression, unlock);
  173009             :       return;
  173010             :     }
  173011             : #endif
  173012             : 
  173013           0 :     SgFoldExpression * object = (SgFoldExpression*) Pointer;
  173014           0 :     ROSE_ASSERT(object != nullptr);
  173015             : 
  173016             : #if ROSE_ALLOC_TRACE == 2
  173017             : //  printf("SgFoldExpression::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgFoldExpression::next_node);
  173018             :     printf("SgFoldExpression::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgFoldExpression::next_node);
  173019             : #endif
  173020             : 
  173021             : #if ROSE_PEDANTIC_ALLOC
  173022             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  173023             : #endif
  173024             : 
  173025             : #if ROSE_ALLOC_MEMSET == 1
  173026             : #elif ROSE_ALLOC_MEMSET == 2
  173027             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgFoldExpression) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  173028             : #elif ROSE_ALLOC_MEMSET == 3
  173029             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgFoldExpression) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  173030             : #endif
  173031             : 
  173032             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  173033             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  173034             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  173035             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  173036             : #else
  173037           0 :     object->p_freepointer = SgFoldExpression::next_node;
  173038           0 :     SgFoldExpression::next_node = object;
  173039             : #endif
  173040             : 
  173041             : #if ROSE_ALLOC_TRACE == 2
  173042             : //  printf("SgFoldExpression::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgFoldExpression::next_node);
  173043             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  173044             :     Rose::MemPool::snapshot(oss.str());
  173045             :     alloc_trace_cnt++;
  173046             : #endif
  173047             : 
  173048             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  173049             : 
  173050           0 :     ALLOC_MUTEX(SgFoldExpression, unlock);
  173051             : }
  173052             : 
  173053             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  173054             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  173055             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  173056             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  173057             : // Also, note comment below from Robb (copied from the Common.code file).
  173058             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  173059             : //
  173060             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  173061             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  173062             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  173063             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  173064             : #if 0
  173065             : void SgFoldExpression::operator delete(void* pointer) { SgFoldExpression::operator delete (pointer, sizeof(SgFoldExpression)); };
  173066             : #endif
  173067             : /* #line 173068 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  173068             : 
  173069             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  173070             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  173071             : // obviously imply C++.
  173072             : 
  173073             : // This implements the support within ROSE for memory pools.  Memory pools
  173074             : // support the most condensed usage of memory within the construction of
  173075             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  173076             : // by a new operator written for each class.
  173077             : 
  173078             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  173079             :     // User wants multi-thread support and POSIX threads are available.
  173080             : #   include <pthread.h>
  173081             :     static pthread_mutex_t SgAwaitExpression_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  173082             : #else
  173083             :      // Cause synchronization to be skipped.
  173084             : #    ifndef ALLOC_MUTEX
  173085             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  173086             : #    endif
  173087             : #    ifdef _REENTRANT
  173088             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  173089             : #       ifdef _MSC_VER
  173090             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  173091             : #       else
  173092             : #           warning "POSIX threads are not available; synchronization being skipped"
  173093             : #       endif
  173094             : #    endif
  173095             : #endif
  173096             : 
  173097             : #ifndef ROSE_ALLOC_TRACE
  173098             : #  define ROSE_ALLOC_TRACE 0
  173099             : #endif
  173100             : 
  173101             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  173102             : #define ROSE_ALLOC_TRACE_CNT
  173103             : #include "memory-pool-snapshot.h"
  173104             : unsigned long alloc_trace_cnt = 0;
  173105             : #endif
  173106             : 
  173107             : #if ROSE_ALLOC_TRACE
  173108             : const unsigned SgAwaitExpression::pool_size = 5;
  173109             : #else
  173110             : const unsigned SgAwaitExpression::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  173111             : #endif
  173112             : 
  173113             : #ifndef ROSE_ALLOC_MEMSET
  173114             : #  define ROSE_ALLOC_MEMSET 0
  173115             : #endif
  173116             : 
  173117             : #ifndef ROSE_PEDANTIC_ALLOC
  173118             : #  define ROSE_PEDANTIC_ALLOC 0
  173119             : #endif
  173120             : 
  173121             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  173122             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  173123             : #endif
  173124             : 
  173125             : #if !defined(SGNODE__ALL_POOLS)
  173126             : #define SGNODE__ALL_POOLS
  173127             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  173128             : #endif
  173129             : 
  173130             : SgAwaitExpression* SgAwaitExpression::next_node = nullptr;
  173131             : std::vector<unsigned char*> SgAwaitExpression::pools;
  173132             : 
  173133             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  173134             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  173135             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  173136             : // around this macro definition rather than each use).
  173137             : #ifndef ALLOC_MUTEX
  173138             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  173139             :         do {                                                                     \
  173140             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  173141             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  173142             :                 abort();                                                         \
  173143             :             }                                                                    \
  173144             :         } while (0);
  173145             : #endif
  173146             : 
  173147             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  173148             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  173149             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  173150             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  173151             : 
  173152             : /*! \brief New operator for SgAwaitExpression.
  173153             : 
  173154             :    This new operator implements memory pools to provide most efficent 
  173155             :    use of the heap within construction of large ASTs.
  173156             : 
  173157             : \internal The new and delete operators use the lower level C malloc/free
  173158             :    function calls for performance and to make sure that mixing of malloc/free
  173159             :    and new/delete by the used can be caught more readily.  This may change
  173160             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  173161             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  173162             :    deallocate memory allocated using ROSE_MALLOC.
  173163             : */
  173164           0 : void *SgAwaitExpression::operator new ( size_t Size )
  173165             : {
  173166             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  173167             :      * returning or throwing an exception. */
  173168           0 :     ALLOC_MUTEX(SgAwaitExpression, lock);
  173169             : 
  173170             : #if ROSE_ALLOC_TRACE == 2
  173171             : //    printf("SgAwaitExpression::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgAwaitExpression::next_node);
  173172             : #endif
  173173             : 
  173174             : #if USE_CPP_NEW_DELETE_OPERATORS
  173175             :     void *mem = ROSE_MALLOC(Size);
  173176             :     ALLOC_MUTEX(SgAwaitExpression, unlock);
  173177             :     return mem;
  173178             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  173179             : #if ROSE_PEDANTIC_ALLOC
  173180             :     ROSE_ASSERT(Size == sizeof(SgAwaitExpression));
  173181             : #else
  173182           0 :     if (Size != sizeof(SgAwaitExpression)) {
  173183           0 :       void * object = ROSE_MALLOC(Size);
  173184           0 :       ALLOC_MUTEX(SgAwaitExpression, unlock);
  173185             :       return object;
  173186             :     }
  173187             : #endif
  173188             : 
  173189           0 :     if (SgAwaitExpression::next_node == nullptr) {
  173190           0 :         SgAwaitExpression * alloc = (SgAwaitExpression*) ROSE_MALLOC ( SgAwaitExpression::pool_size * sizeof(SgAwaitExpression) );
  173191           0 :         ROSE_ASSERT(alloc != nullptr);
  173192             : 
  173193             : #if ROSE_ALLOC_TRACE == 2
  173194             : //        printf("SgAwaitExpression::alloc\n  block[%zi] = [ %p , %p [\n", SgAwaitExpression::pools.size(), alloc, alloc + SgAwaitExpression::pool_size);
  173195             : #endif
  173196             : 
  173197             : #if ROSE_ALLOC_MEMSET == 1
  173198             : #elif ROSE_ALLOC_MEMSET == 2
  173199             :         memset(alloc, 0x00, SgAwaitExpression::pool_size * sizeof(SgAwaitExpression));
  173200             : #elif ROSE_ALLOC_MEMSET == 3
  173201             :         memset(alloc, 0xAA, SgAwaitExpression::pool_size * sizeof(SgAwaitExpression));
  173202             : #endif
  173203           0 :         for (unsigned i=0; i < SgAwaitExpression::pool_size-1; i++) {
  173204           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
  173205             :         }
  173206           0 :         alloc[SgAwaitExpression::pool_size-1].p_freepointer = nullptr;
  173207             : 
  173208           0 :         SgAwaitExpression::pools.push_back ( (unsigned char *) alloc );
  173209           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgAwaitExpression::pool_size * sizeof(SgAwaitExpression), V_SgAwaitExpression ) );
  173210           0 :         SgAwaitExpression::next_node = alloc;
  173211             :     }
  173212           0 :     ROSE_ASSERT(SgAwaitExpression::next_node != nullptr);
  173213             : 
  173214           0 :     SgAwaitExpression * object = SgAwaitExpression::next_node;
  173215           0 :     SgAwaitExpression::next_node = (SgAwaitExpression*)(object->p_freepointer);
  173216             : 
  173217             : #if ROSE_ALLOC_TRACE == 2
  173218             :     printf("SgAwaitExpression::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgAwaitExpression::next_node);
  173219             : #endif
  173220             : 
  173221           0 :     SgNode * fp = object->p_freepointer;
  173222             : #if ROSE_ALLOC_MEMSET == 1
  173223             : #elif ROSE_ALLOC_MEMSET == 2
  173224             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgAwaitExpression) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  173225             : #elif ROSE_ALLOC_MEMSET == 3
  173226             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgAwaitExpression) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  173227             : #endif
  173228           0 :     object->p_freepointer = fp;
  173229             : 
  173230             : #if ROSE_ALLOC_TRACE == 2
  173231             : //    printf("SgAwaitExpression::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgAwaitExpression::next_node);
  173232             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  173233             :     Rose::MemPool::snapshot(oss.str());
  173234             :     alloc_trace_cnt++;
  173235             : #endif
  173236             : 
  173237           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  173238             : 
  173239           0 :     ALLOC_MUTEX(SgAwaitExpression, unlock);
  173240             : 
  173241             :     return object;
  173242             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  173243             : }
  173244             : 
  173245             : 
  173246             : 
  173247             : /*! \brief Delete operator for SgAwaitExpression.
  173248             : 
  173249             :    This delete operator implements deallocation using memory pools to 
  173250             :    provide most efficent use of the heap within construction of large ASTs.
  173251             : 
  173252             : \internal The new and delete operators use the lower level C malloc/free
  173253             :    function calls for performance and to make sure that mixing of malloc/free
  173254             :    and new/delete by the used can be caught more readily.  This may change
  173255             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  173256             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  173257             :    deallocate memory allocated using ROSE_MALLOC.
  173258             : */
  173259           0 : void SgAwaitExpression::operator delete(void *Pointer, size_t Size)
  173260             : {
  173261             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  173262             :      * or throwing an exception. */
  173263           0 :     ALLOC_MUTEX(SgAwaitExpression, lock);
  173264             : 
  173265             : #if USE_CPP_NEW_DELETE_OPERATORS
  173266             :     ROSE_FREE(Pointer);
  173267             : #else
  173268             : #if ROSE_PEDANTIC_ALLOC
  173269             :     ROSE_ASSERT(Size == sizeof(SgAwaitExpression));
  173270             : #else
  173271           0 :     if (Size != sizeof(SgAwaitExpression)) {
  173272           0 :       ROSE_FREE(Pointer);
  173273           0 :       ALLOC_MUTEX(SgAwaitExpression, unlock);
  173274             :       return;
  173275             :     }
  173276             : #endif
  173277             : 
  173278           0 :     SgAwaitExpression * object = (SgAwaitExpression*) Pointer;
  173279           0 :     ROSE_ASSERT(object != nullptr);
  173280             : 
  173281             : #if ROSE_ALLOC_TRACE == 2
  173282             : //  printf("SgAwaitExpression::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgAwaitExpression::next_node);
  173283             :     printf("SgAwaitExpression::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgAwaitExpression::next_node);
  173284             : #endif
  173285             : 
  173286             : #if ROSE_PEDANTIC_ALLOC
  173287             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  173288             : #endif
  173289             : 
  173290             : #if ROSE_ALLOC_MEMSET == 1
  173291             : #elif ROSE_ALLOC_MEMSET == 2
  173292             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgAwaitExpression) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  173293             : #elif ROSE_ALLOC_MEMSET == 3
  173294             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgAwaitExpression) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  173295             : #endif
  173296             : 
  173297             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  173298             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  173299             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  173300             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  173301             : #else
  173302           0 :     object->p_freepointer = SgAwaitExpression::next_node;
  173303           0 :     SgAwaitExpression::next_node = object;
  173304             : #endif
  173305             : 
  173306             : #if ROSE_ALLOC_TRACE == 2
  173307             : //  printf("SgAwaitExpression::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgAwaitExpression::next_node);
  173308             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  173309             :     Rose::MemPool::snapshot(oss.str());
  173310             :     alloc_trace_cnt++;
  173311             : #endif
  173312             : 
  173313             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  173314             : 
  173315           0 :     ALLOC_MUTEX(SgAwaitExpression, unlock);
  173316             : }
  173317             : 
  173318             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  173319             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  173320             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  173321             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  173322             : // Also, note comment below from Robb (copied from the Common.code file).
  173323             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  173324             : //
  173325             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  173326             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  173327             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  173328             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  173329             : #if 0
  173330             : void SgAwaitExpression::operator delete(void* pointer) { SgAwaitExpression::operator delete (pointer, sizeof(SgAwaitExpression)); };
  173331             : #endif
  173332             : /* #line 173333 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  173333             : 
  173334             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  173335             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  173336             : // obviously imply C++.
  173337             : 
  173338             : // This implements the support within ROSE for memory pools.  Memory pools
  173339             : // support the most condensed usage of memory within the construction of
  173340             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  173341             : // by a new operator written for each class.
  173342             : 
  173343             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  173344             :     // User wants multi-thread support and POSIX threads are available.
  173345             : #   include <pthread.h>
  173346             :     static pthread_mutex_t SgChooseExpression_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  173347             : #else
  173348             :      // Cause synchronization to be skipped.
  173349             : #    ifndef ALLOC_MUTEX
  173350             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  173351             : #    endif
  173352             : #    ifdef _REENTRANT
  173353             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  173354             : #       ifdef _MSC_VER
  173355             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  173356             : #       else
  173357             : #           warning "POSIX threads are not available; synchronization being skipped"
  173358             : #       endif
  173359             : #    endif
  173360             : #endif
  173361             : 
  173362             : #ifndef ROSE_ALLOC_TRACE
  173363             : #  define ROSE_ALLOC_TRACE 0
  173364             : #endif
  173365             : 
  173366             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  173367             : #define ROSE_ALLOC_TRACE_CNT
  173368             : #include "memory-pool-snapshot.h"
  173369             : unsigned long alloc_trace_cnt = 0;
  173370             : #endif
  173371             : 
  173372             : #if ROSE_ALLOC_TRACE
  173373             : const unsigned SgChooseExpression::pool_size = 5;
  173374             : #else
  173375             : const unsigned SgChooseExpression::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  173376             : #endif
  173377             : 
  173378             : #ifndef ROSE_ALLOC_MEMSET
  173379             : #  define ROSE_ALLOC_MEMSET 0
  173380             : #endif
  173381             : 
  173382             : #ifndef ROSE_PEDANTIC_ALLOC
  173383             : #  define ROSE_PEDANTIC_ALLOC 0
  173384             : #endif
  173385             : 
  173386             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  173387             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  173388             : #endif
  173389             : 
  173390             : #if !defined(SGNODE__ALL_POOLS)
  173391             : #define SGNODE__ALL_POOLS
  173392             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  173393             : #endif
  173394             : 
  173395             : SgChooseExpression* SgChooseExpression::next_node = nullptr;
  173396             : std::vector<unsigned char*> SgChooseExpression::pools;
  173397             : 
  173398             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  173399             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  173400             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  173401             : // around this macro definition rather than each use).
  173402             : #ifndef ALLOC_MUTEX
  173403             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  173404             :         do {                                                                     \
  173405             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  173406             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  173407             :                 abort();                                                         \
  173408             :             }                                                                    \
  173409             :         } while (0);
  173410             : #endif
  173411             : 
  173412             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  173413             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  173414             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  173415             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  173416             : 
  173417             : /*! \brief New operator for SgChooseExpression.
  173418             : 
  173419             :    This new operator implements memory pools to provide most efficent 
  173420             :    use of the heap within construction of large ASTs.
  173421             : 
  173422             : \internal The new and delete operators use the lower level C malloc/free
  173423             :    function calls for performance and to make sure that mixing of malloc/free
  173424             :    and new/delete by the used can be caught more readily.  This may change
  173425             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  173426             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  173427             :    deallocate memory allocated using ROSE_MALLOC.
  173428             : */
  173429           0 : void *SgChooseExpression::operator new ( size_t Size )
  173430             : {
  173431             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  173432             :      * returning or throwing an exception. */
  173433           0 :     ALLOC_MUTEX(SgChooseExpression, lock);
  173434             : 
  173435             : #if ROSE_ALLOC_TRACE == 2
  173436             : //    printf("SgChooseExpression::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgChooseExpression::next_node);
  173437             : #endif
  173438             : 
  173439             : #if USE_CPP_NEW_DELETE_OPERATORS
  173440             :     void *mem = ROSE_MALLOC(Size);
  173441             :     ALLOC_MUTEX(SgChooseExpression, unlock);
  173442             :     return mem;
  173443             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  173444             : #if ROSE_PEDANTIC_ALLOC
  173445             :     ROSE_ASSERT(Size == sizeof(SgChooseExpression));
  173446             : #else
  173447           0 :     if (Size != sizeof(SgChooseExpression)) {
  173448           0 :       void * object = ROSE_MALLOC(Size);
  173449           0 :       ALLOC_MUTEX(SgChooseExpression, unlock);
  173450             :       return object;
  173451             :     }
  173452             : #endif
  173453             : 
  173454           0 :     if (SgChooseExpression::next_node == nullptr) {
  173455           0 :         SgChooseExpression * alloc = (SgChooseExpression*) ROSE_MALLOC ( SgChooseExpression::pool_size * sizeof(SgChooseExpression) );
  173456           0 :         ROSE_ASSERT(alloc != nullptr);
  173457             : 
  173458             : #if ROSE_ALLOC_TRACE == 2
  173459             : //        printf("SgChooseExpression::alloc\n  block[%zi] = [ %p , %p [\n", SgChooseExpression::pools.size(), alloc, alloc + SgChooseExpression::pool_size);
  173460             : #endif
  173461             : 
  173462             : #if ROSE_ALLOC_MEMSET == 1
  173463             : #elif ROSE_ALLOC_MEMSET == 2
  173464             :         memset(alloc, 0x00, SgChooseExpression::pool_size * sizeof(SgChooseExpression));
  173465             : #elif ROSE_ALLOC_MEMSET == 3
  173466             :         memset(alloc, 0xAA, SgChooseExpression::pool_size * sizeof(SgChooseExpression));
  173467             : #endif
  173468           0 :         for (unsigned i=0; i < SgChooseExpression::pool_size-1; i++) {
  173469           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
  173470             :         }
  173471           0 :         alloc[SgChooseExpression::pool_size-1].p_freepointer = nullptr;
  173472             : 
  173473           0 :         SgChooseExpression::pools.push_back ( (unsigned char *) alloc );
  173474           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgChooseExpression::pool_size * sizeof(SgChooseExpression), V_SgChooseExpression ) );
  173475           0 :         SgChooseExpression::next_node = alloc;
  173476             :     }
  173477           0 :     ROSE_ASSERT(SgChooseExpression::next_node != nullptr);
  173478             : 
  173479           0 :     SgChooseExpression * object = SgChooseExpression::next_node;
  173480           0 :     SgChooseExpression::next_node = (SgChooseExpression*)(object->p_freepointer);
  173481             : 
  173482             : #if ROSE_ALLOC_TRACE == 2
  173483             :     printf("SgChooseExpression::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgChooseExpression::next_node);
  173484             : #endif
  173485             : 
  173486           0 :     SgNode * fp = object->p_freepointer;
  173487             : #if ROSE_ALLOC_MEMSET == 1
  173488             : #elif ROSE_ALLOC_MEMSET == 2
  173489             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgChooseExpression) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  173490             : #elif ROSE_ALLOC_MEMSET == 3
  173491             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgChooseExpression) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  173492             : #endif
  173493           0 :     object->p_freepointer = fp;
  173494             : 
  173495             : #if ROSE_ALLOC_TRACE == 2
  173496             : //    printf("SgChooseExpression::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgChooseExpression::next_node);
  173497             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  173498             :     Rose::MemPool::snapshot(oss.str());
  173499             :     alloc_trace_cnt++;
  173500             : #endif
  173501             : 
  173502           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  173503             : 
  173504           0 :     ALLOC_MUTEX(SgChooseExpression, unlock);
  173505             : 
  173506             :     return object;
  173507             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  173508             : }
  173509             : 
  173510             : 
  173511             : 
  173512             : /*! \brief Delete operator for SgChooseExpression.
  173513             : 
  173514             :    This delete operator implements deallocation using memory pools to 
  173515             :    provide most efficent use of the heap within construction of large ASTs.
  173516             : 
  173517             : \internal The new and delete operators use the lower level C malloc/free
  173518             :    function calls for performance and to make sure that mixing of malloc/free
  173519             :    and new/delete by the used can be caught more readily.  This may change
  173520             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  173521             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  173522             :    deallocate memory allocated using ROSE_MALLOC.
  173523             : */
  173524           0 : void SgChooseExpression::operator delete(void *Pointer, size_t Size)
  173525             : {
  173526             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  173527             :      * or throwing an exception. */
  173528           0 :     ALLOC_MUTEX(SgChooseExpression, lock);
  173529             : 
  173530             : #if USE_CPP_NEW_DELETE_OPERATORS
  173531             :     ROSE_FREE(Pointer);
  173532             : #else
  173533             : #if ROSE_PEDANTIC_ALLOC
  173534             :     ROSE_ASSERT(Size == sizeof(SgChooseExpression));
  173535             : #else
  173536           0 :     if (Size != sizeof(SgChooseExpression)) {
  173537           0 :       ROSE_FREE(Pointer);
  173538           0 :       ALLOC_MUTEX(SgChooseExpression, unlock);
  173539             :       return;
  173540             :     }
  173541             : #endif
  173542             : 
  173543           0 :     SgChooseExpression * object = (SgChooseExpression*) Pointer;
  173544           0 :     ROSE_ASSERT(object != nullptr);
  173545             : 
  173546             : #if ROSE_ALLOC_TRACE == 2
  173547             : //  printf("SgChooseExpression::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgChooseExpression::next_node);
  173548             :     printf("SgChooseExpression::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgChooseExpression::next_node);
  173549             : #endif
  173550             : 
  173551             : #if ROSE_PEDANTIC_ALLOC
  173552             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  173553             : #endif
  173554             : 
  173555             : #if ROSE_ALLOC_MEMSET == 1
  173556             : #elif ROSE_ALLOC_MEMSET == 2
  173557             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgChooseExpression) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  173558             : #elif ROSE_ALLOC_MEMSET == 3
  173559             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgChooseExpression) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  173560             : #endif
  173561             : 
  173562             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  173563             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  173564             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  173565             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  173566             : #else
  173567           0 :     object->p_freepointer = SgChooseExpression::next_node;
  173568           0 :     SgChooseExpression::next_node = object;
  173569             : #endif
  173570             : 
  173571             : #if ROSE_ALLOC_TRACE == 2
  173572             : //  printf("SgChooseExpression::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgChooseExpression::next_node);
  173573             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  173574             :     Rose::MemPool::snapshot(oss.str());
  173575             :     alloc_trace_cnt++;
  173576             : #endif
  173577             : 
  173578             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  173579             : 
  173580           0 :     ALLOC_MUTEX(SgChooseExpression, unlock);
  173581             : }
  173582             : 
  173583             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  173584             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  173585             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  173586             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  173587             : // Also, note comment below from Robb (copied from the Common.code file).
  173588             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  173589             : //
  173590             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  173591             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  173592             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  173593             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  173594             : #if 0
  173595             : void SgChooseExpression::operator delete(void* pointer) { SgChooseExpression::operator delete (pointer, sizeof(SgChooseExpression)); };
  173596             : #endif
  173597             : /* #line 173598 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  173598             : 
  173599             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  173600             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  173601             : // obviously imply C++.
  173602             : 
  173603             : // This implements the support within ROSE for memory pools.  Memory pools
  173604             : // support the most condensed usage of memory within the construction of
  173605             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  173606             : // by a new operator written for each class.
  173607             : 
  173608             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  173609             :     // User wants multi-thread support and POSIX threads are available.
  173610             : #   include <pthread.h>
  173611             :     static pthread_mutex_t SgSymbol_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  173612             : #else
  173613             :      // Cause synchronization to be skipped.
  173614             : #    ifndef ALLOC_MUTEX
  173615             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  173616             : #    endif
  173617             : #    ifdef _REENTRANT
  173618             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  173619             : #       ifdef _MSC_VER
  173620             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  173621             : #       else
  173622             : #           warning "POSIX threads are not available; synchronization being skipped"
  173623             : #       endif
  173624             : #    endif
  173625             : #endif
  173626             : 
  173627             : #ifndef ROSE_ALLOC_TRACE
  173628             : #  define ROSE_ALLOC_TRACE 0
  173629             : #endif
  173630             : 
  173631             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  173632             : #define ROSE_ALLOC_TRACE_CNT
  173633             : #include "memory-pool-snapshot.h"
  173634             : unsigned long alloc_trace_cnt = 0;
  173635             : #endif
  173636             : 
  173637             : #if ROSE_ALLOC_TRACE
  173638             : const unsigned SgSymbol::pool_size = 5;
  173639             : #else
  173640             : const unsigned SgSymbol::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  173641             : #endif
  173642             : 
  173643             : #ifndef ROSE_ALLOC_MEMSET
  173644             : #  define ROSE_ALLOC_MEMSET 0
  173645             : #endif
  173646             : 
  173647             : #ifndef ROSE_PEDANTIC_ALLOC
  173648             : #  define ROSE_PEDANTIC_ALLOC 0
  173649             : #endif
  173650             : 
  173651             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  173652             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  173653             : #endif
  173654             : 
  173655             : #if !defined(SGNODE__ALL_POOLS)
  173656             : #define SGNODE__ALL_POOLS
  173657             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  173658             : #endif
  173659             : 
  173660             : SgSymbol* SgSymbol::next_node = nullptr;
  173661             : std::vector<unsigned char*> SgSymbol::pools;
  173662             : 
  173663             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  173664             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  173665             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  173666             : // around this macro definition rather than each use).
  173667             : #ifndef ALLOC_MUTEX
  173668             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  173669             :         do {                                                                     \
  173670             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  173671             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  173672             :                 abort();                                                         \
  173673             :             }                                                                    \
  173674             :         } while (0);
  173675             : #endif
  173676             : 
  173677             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  173678             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  173679             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  173680             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  173681             : 
  173682             : /*! \brief New operator for SgSymbol.
  173683             : 
  173684             :    This new operator implements memory pools to provide most efficent 
  173685             :    use of the heap within construction of large ASTs.
  173686             : 
  173687             : \internal The new and delete operators use the lower level C malloc/free
  173688             :    function calls for performance and to make sure that mixing of malloc/free
  173689             :    and new/delete by the used can be caught more readily.  This may change
  173690             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  173691             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  173692             :    deallocate memory allocated using ROSE_MALLOC.
  173693             : */
  173694           0 : void *SgSymbol::operator new ( size_t Size )
  173695             : {
  173696             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  173697             :      * returning or throwing an exception. */
  173698           0 :     ALLOC_MUTEX(SgSymbol, lock);
  173699             : 
  173700             : #if ROSE_ALLOC_TRACE == 2
  173701             : //    printf("SgSymbol::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgSymbol::next_node);
  173702             : #endif
  173703             : 
  173704             : #if USE_CPP_NEW_DELETE_OPERATORS
  173705             :     void *mem = ROSE_MALLOC(Size);
  173706             :     ALLOC_MUTEX(SgSymbol, unlock);
  173707             :     return mem;
  173708             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  173709             : #if ROSE_PEDANTIC_ALLOC
  173710             :     ROSE_ASSERT(Size == sizeof(SgSymbol));
  173711             : #else
  173712           0 :     if (Size != sizeof(SgSymbol)) {
  173713           0 :       void * object = ROSE_MALLOC(Size);
  173714           0 :       ALLOC_MUTEX(SgSymbol, unlock);
  173715             :       return object;
  173716             :     }
  173717             : #endif
  173718             : 
  173719           0 :     if (SgSymbol::next_node == nullptr) {
  173720           0 :         SgSymbol * alloc = (SgSymbol*) ROSE_MALLOC ( SgSymbol::pool_size * sizeof(SgSymbol) );
  173721           0 :         ROSE_ASSERT(alloc != nullptr);
  173722             : 
  173723             : #if ROSE_ALLOC_TRACE == 2
  173724             : //        printf("SgSymbol::alloc\n  block[%zi] = [ %p , %p [\n", SgSymbol::pools.size(), alloc, alloc + SgSymbol::pool_size);
  173725             : #endif
  173726             : 
  173727             : #if ROSE_ALLOC_MEMSET == 1
  173728             : #elif ROSE_ALLOC_MEMSET == 2
  173729             :         memset(alloc, 0x00, SgSymbol::pool_size * sizeof(SgSymbol));
  173730             : #elif ROSE_ALLOC_MEMSET == 3
  173731             :         memset(alloc, 0xAA, SgSymbol::pool_size * sizeof(SgSymbol));
  173732             : #endif
  173733           0 :         for (unsigned i=0; i < SgSymbol::pool_size-1; i++) {
  173734           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
  173735             :         }
  173736           0 :         alloc[SgSymbol::pool_size-1].p_freepointer = nullptr;
  173737             : 
  173738           0 :         SgSymbol::pools.push_back ( (unsigned char *) alloc );
  173739           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgSymbol::pool_size * sizeof(SgSymbol), V_SgSymbol ) );
  173740           0 :         SgSymbol::next_node = alloc;
  173741             :     }
  173742           0 :     ROSE_ASSERT(SgSymbol::next_node != nullptr);
  173743             : 
  173744           0 :     SgSymbol * object = SgSymbol::next_node;
  173745           0 :     SgSymbol::next_node = (SgSymbol*)(object->p_freepointer);
  173746             : 
  173747             : #if ROSE_ALLOC_TRACE == 2
  173748             :     printf("SgSymbol::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgSymbol::next_node);
  173749             : #endif
  173750             : 
  173751           0 :     SgNode * fp = object->p_freepointer;
  173752             : #if ROSE_ALLOC_MEMSET == 1
  173753             : #elif ROSE_ALLOC_MEMSET == 2
  173754             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgSymbol) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  173755             : #elif ROSE_ALLOC_MEMSET == 3
  173756             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgSymbol) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  173757             : #endif
  173758           0 :     object->p_freepointer = fp;
  173759             : 
  173760             : #if ROSE_ALLOC_TRACE == 2
  173761             : //    printf("SgSymbol::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgSymbol::next_node);
  173762             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  173763             :     Rose::MemPool::snapshot(oss.str());
  173764             :     alloc_trace_cnt++;
  173765             : #endif
  173766             : 
  173767           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  173768             : 
  173769           0 :     ALLOC_MUTEX(SgSymbol, unlock);
  173770             : 
  173771             :     return object;
  173772             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  173773             : }
  173774             : 
  173775             : 
  173776             : 
  173777             : /*! \brief Delete operator for SgSymbol.
  173778             : 
  173779             :    This delete operator implements deallocation using memory pools to 
  173780             :    provide most efficent use of the heap within construction of large ASTs.
  173781             : 
  173782             : \internal The new and delete operators use the lower level C malloc/free
  173783             :    function calls for performance and to make sure that mixing of malloc/free
  173784             :    and new/delete by the used can be caught more readily.  This may change
  173785             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  173786             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  173787             :    deallocate memory allocated using ROSE_MALLOC.
  173788             : */
  173789           0 : void SgSymbol::operator delete(void *Pointer, size_t Size)
  173790             : {
  173791             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  173792             :      * or throwing an exception. */
  173793           0 :     ALLOC_MUTEX(SgSymbol, lock);
  173794             : 
  173795             : #if USE_CPP_NEW_DELETE_OPERATORS
  173796             :     ROSE_FREE(Pointer);
  173797             : #else
  173798             : #if ROSE_PEDANTIC_ALLOC
  173799             :     ROSE_ASSERT(Size == sizeof(SgSymbol));
  173800             : #else
  173801           0 :     if (Size != sizeof(SgSymbol)) {
  173802           0 :       ROSE_FREE(Pointer);
  173803           0 :       ALLOC_MUTEX(SgSymbol, unlock);
  173804             :       return;
  173805             :     }
  173806             : #endif
  173807             : 
  173808           0 :     SgSymbol * object = (SgSymbol*) Pointer;
  173809           0 :     ROSE_ASSERT(object != nullptr);
  173810             : 
  173811             : #if ROSE_ALLOC_TRACE == 2
  173812             : //  printf("SgSymbol::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgSymbol::next_node);
  173813             :     printf("SgSymbol::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgSymbol::next_node);
  173814             : #endif
  173815             : 
  173816             : #if ROSE_PEDANTIC_ALLOC
  173817             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  173818             : #endif
  173819             : 
  173820             : #if ROSE_ALLOC_MEMSET == 1
  173821             : #elif ROSE_ALLOC_MEMSET == 2
  173822             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgSymbol) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  173823             : #elif ROSE_ALLOC_MEMSET == 3
  173824             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgSymbol) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  173825             : #endif
  173826             : 
  173827             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  173828             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  173829             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  173830             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  173831             : #else
  173832           0 :     object->p_freepointer = SgSymbol::next_node;
  173833           0 :     SgSymbol::next_node = object;
  173834             : #endif
  173835             : 
  173836             : #if ROSE_ALLOC_TRACE == 2
  173837             : //  printf("SgSymbol::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgSymbol::next_node);
  173838             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  173839             :     Rose::MemPool::snapshot(oss.str());
  173840             :     alloc_trace_cnt++;
  173841             : #endif
  173842             : 
  173843             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  173844             : 
  173845           0 :     ALLOC_MUTEX(SgSymbol, unlock);
  173846             : }
  173847             : 
  173848             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  173849             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  173850             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  173851             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  173852             : // Also, note comment below from Robb (copied from the Common.code file).
  173853             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  173854             : //
  173855             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  173856             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  173857             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  173858             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  173859             : #if 0
  173860             : void SgSymbol::operator delete(void* pointer) { SgSymbol::operator delete (pointer, sizeof(SgSymbol)); };
  173861             : #endif
  173862             : /* #line 173863 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  173863             : 
  173864             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  173865             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  173866             : // obviously imply C++.
  173867             : 
  173868             : // This implements the support within ROSE for memory pools.  Memory pools
  173869             : // support the most condensed usage of memory within the construction of
  173870             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  173871             : // by a new operator written for each class.
  173872             : 
  173873             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  173874             :     // User wants multi-thread support and POSIX threads are available.
  173875             : #   include <pthread.h>
  173876             :     static pthread_mutex_t SgVariableSymbol_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  173877             : #else
  173878             :      // Cause synchronization to be skipped.
  173879             : #    ifndef ALLOC_MUTEX
  173880             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  173881             : #    endif
  173882             : #    ifdef _REENTRANT
  173883             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  173884             : #       ifdef _MSC_VER
  173885             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  173886             : #       else
  173887             : #           warning "POSIX threads are not available; synchronization being skipped"
  173888             : #       endif
  173889             : #    endif
  173890             : #endif
  173891             : 
  173892             : #ifndef ROSE_ALLOC_TRACE
  173893             : #  define ROSE_ALLOC_TRACE 0
  173894             : #endif
  173895             : 
  173896             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  173897             : #define ROSE_ALLOC_TRACE_CNT
  173898             : #include "memory-pool-snapshot.h"
  173899             : unsigned long alloc_trace_cnt = 0;
  173900             : #endif
  173901             : 
  173902             : #if ROSE_ALLOC_TRACE
  173903             : const unsigned SgVariableSymbol::pool_size = 5;
  173904             : #else
  173905             : const unsigned SgVariableSymbol::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  173906             : #endif
  173907             : 
  173908             : #ifndef ROSE_ALLOC_MEMSET
  173909             : #  define ROSE_ALLOC_MEMSET 0
  173910             : #endif
  173911             : 
  173912             : #ifndef ROSE_PEDANTIC_ALLOC
  173913             : #  define ROSE_PEDANTIC_ALLOC 0
  173914             : #endif
  173915             : 
  173916             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  173917             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  173918             : #endif
  173919             : 
  173920             : #if !defined(SGNODE__ALL_POOLS)
  173921             : #define SGNODE__ALL_POOLS
  173922             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  173923             : #endif
  173924             : 
  173925             : SgVariableSymbol* SgVariableSymbol::next_node = nullptr;
  173926             : std::vector<unsigned char*> SgVariableSymbol::pools;
  173927             : 
  173928             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  173929             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  173930             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  173931             : // around this macro definition rather than each use).
  173932             : #ifndef ALLOC_MUTEX
  173933             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  173934             :         do {                                                                     \
  173935             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  173936             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  173937             :                 abort();                                                         \
  173938             :             }                                                                    \
  173939             :         } while (0);
  173940             : #endif
  173941             : 
  173942             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  173943             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  173944             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  173945             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  173946             : 
  173947             : /*! \brief New operator for SgVariableSymbol.
  173948             : 
  173949             :    This new operator implements memory pools to provide most efficent 
  173950             :    use of the heap within construction of large ASTs.
  173951             : 
  173952             : \internal The new and delete operators use the lower level C malloc/free
  173953             :    function calls for performance and to make sure that mixing of malloc/free
  173954             :    and new/delete by the used can be caught more readily.  This may change
  173955             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  173956             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  173957             :    deallocate memory allocated using ROSE_MALLOC.
  173958             : */
  173959       66646 : void *SgVariableSymbol::operator new ( size_t Size )
  173960             : {
  173961             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  173962             :      * returning or throwing an exception. */
  173963       66646 :     ALLOC_MUTEX(SgVariableSymbol, lock);
  173964             : 
  173965             : #if ROSE_ALLOC_TRACE == 2
  173966             : //    printf("SgVariableSymbol::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgVariableSymbol::next_node);
  173967             : #endif
  173968             : 
  173969             : #if USE_CPP_NEW_DELETE_OPERATORS
  173970             :     void *mem = ROSE_MALLOC(Size);
  173971             :     ALLOC_MUTEX(SgVariableSymbol, unlock);
  173972             :     return mem;
  173973             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  173974             : #if ROSE_PEDANTIC_ALLOC
  173975             :     ROSE_ASSERT(Size == sizeof(SgVariableSymbol));
  173976             : #else
  173977       66646 :     if (Size != sizeof(SgVariableSymbol)) {
  173978           0 :       void * object = ROSE_MALLOC(Size);
  173979           0 :       ALLOC_MUTEX(SgVariableSymbol, unlock);
  173980             :       return object;
  173981             :     }
  173982             : #endif
  173983             : 
  173984       66646 :     if (SgVariableSymbol::next_node == nullptr) {
  173985         342 :         SgVariableSymbol * alloc = (SgVariableSymbol*) ROSE_MALLOC ( SgVariableSymbol::pool_size * sizeof(SgVariableSymbol) );
  173986         342 :         ROSE_ASSERT(alloc != nullptr);
  173987             : 
  173988             : #if ROSE_ALLOC_TRACE == 2
  173989             : //        printf("SgVariableSymbol::alloc\n  block[%zi] = [ %p , %p [\n", SgVariableSymbol::pools.size(), alloc, alloc + SgVariableSymbol::pool_size);
  173990             : #endif
  173991             : 
  173992             : #if ROSE_ALLOC_MEMSET == 1
  173993             : #elif ROSE_ALLOC_MEMSET == 2
  173994             :         memset(alloc, 0x00, SgVariableSymbol::pool_size * sizeof(SgVariableSymbol));
  173995             : #elif ROSE_ALLOC_MEMSET == 3
  173996             :         memset(alloc, 0xAA, SgVariableSymbol::pool_size * sizeof(SgVariableSymbol));
  173997             : #endif
  173998      684000 :         for (unsigned i=0; i < SgVariableSymbol::pool_size-1; i++) {
  173999      683658 :           alloc[i].p_freepointer = &(alloc[i+1]);
  174000             :         }
  174001         342 :         alloc[SgVariableSymbol::pool_size-1].p_freepointer = nullptr;
  174002             : 
  174003         342 :         SgVariableSymbol::pools.push_back ( (unsigned char *) alloc );
  174004         342 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgVariableSymbol::pool_size * sizeof(SgVariableSymbol), V_SgVariableSymbol ) );
  174005         342 :         SgVariableSymbol::next_node = alloc;
  174006             :     }
  174007       66646 :     ROSE_ASSERT(SgVariableSymbol::next_node != nullptr);
  174008             : 
  174009       66646 :     SgVariableSymbol * object = SgVariableSymbol::next_node;
  174010       66646 :     SgVariableSymbol::next_node = (SgVariableSymbol*)(object->p_freepointer);
  174011             : 
  174012             : #if ROSE_ALLOC_TRACE == 2
  174013             :     printf("SgVariableSymbol::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgVariableSymbol::next_node);
  174014             : #endif
  174015             : 
  174016       66646 :     SgNode * fp = object->p_freepointer;
  174017             : #if ROSE_ALLOC_MEMSET == 1
  174018             : #elif ROSE_ALLOC_MEMSET == 2
  174019             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgVariableSymbol) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  174020             : #elif ROSE_ALLOC_MEMSET == 3
  174021             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgVariableSymbol) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  174022             : #endif
  174023       66646 :     object->p_freepointer = fp;
  174024             : 
  174025             : #if ROSE_ALLOC_TRACE == 2
  174026             : //    printf("SgVariableSymbol::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgVariableSymbol::next_node);
  174027             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  174028             :     Rose::MemPool::snapshot(oss.str());
  174029             :     alloc_trace_cnt++;
  174030             : #endif
  174031             : 
  174032       66646 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  174033             : 
  174034       66646 :     ALLOC_MUTEX(SgVariableSymbol, unlock);
  174035             : 
  174036             :     return object;
  174037             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  174038             : }
  174039             : 
  174040             : 
  174041             : 
  174042             : /*! \brief Delete operator for SgVariableSymbol.
  174043             : 
  174044             :    This delete operator implements deallocation using memory pools to 
  174045             :    provide most efficent use of the heap within construction of large ASTs.
  174046             : 
  174047             : \internal The new and delete operators use the lower level C malloc/free
  174048             :    function calls for performance and to make sure that mixing of malloc/free
  174049             :    and new/delete by the used can be caught more readily.  This may change
  174050             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  174051             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  174052             :    deallocate memory allocated using ROSE_MALLOC.
  174053             : */
  174054        8461 : void SgVariableSymbol::operator delete(void *Pointer, size_t Size)
  174055             : {
  174056             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  174057             :      * or throwing an exception. */
  174058        8461 :     ALLOC_MUTEX(SgVariableSymbol, lock);
  174059             : 
  174060             : #if USE_CPP_NEW_DELETE_OPERATORS
  174061             :     ROSE_FREE(Pointer);
  174062             : #else
  174063             : #if ROSE_PEDANTIC_ALLOC
  174064             :     ROSE_ASSERT(Size == sizeof(SgVariableSymbol));
  174065             : #else
  174066        8461 :     if (Size != sizeof(SgVariableSymbol)) {
  174067           0 :       ROSE_FREE(Pointer);
  174068           0 :       ALLOC_MUTEX(SgVariableSymbol, unlock);
  174069             :       return;
  174070             :     }
  174071             : #endif
  174072             : 
  174073        8461 :     SgVariableSymbol * object = (SgVariableSymbol*) Pointer;
  174074        8461 :     ROSE_ASSERT(object != nullptr);
  174075             : 
  174076             : #if ROSE_ALLOC_TRACE == 2
  174077             : //  printf("SgVariableSymbol::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgVariableSymbol::next_node);
  174078             :     printf("SgVariableSymbol::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgVariableSymbol::next_node);
  174079             : #endif
  174080             : 
  174081             : #if ROSE_PEDANTIC_ALLOC
  174082             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  174083             : #endif
  174084             : 
  174085             : #if ROSE_ALLOC_MEMSET == 1
  174086             : #elif ROSE_ALLOC_MEMSET == 2
  174087             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgVariableSymbol) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  174088             : #elif ROSE_ALLOC_MEMSET == 3
  174089             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgVariableSymbol) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  174090             : #endif
  174091             : 
  174092             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  174093             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  174094             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  174095             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  174096             : #else
  174097        8461 :     object->p_freepointer = SgVariableSymbol::next_node;
  174098        8461 :     SgVariableSymbol::next_node = object;
  174099             : #endif
  174100             : 
  174101             : #if ROSE_ALLOC_TRACE == 2
  174102             : //  printf("SgVariableSymbol::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgVariableSymbol::next_node);
  174103             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  174104             :     Rose::MemPool::snapshot(oss.str());
  174105             :     alloc_trace_cnt++;
  174106             : #endif
  174107             : 
  174108             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  174109             : 
  174110        8461 :     ALLOC_MUTEX(SgVariableSymbol, unlock);
  174111             : }
  174112             : 
  174113             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  174114             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  174115             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  174116             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  174117             : // Also, note comment below from Robb (copied from the Common.code file).
  174118             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  174119             : //
  174120             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  174121             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  174122             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  174123             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  174124             : #if 0
  174125             : void SgVariableSymbol::operator delete(void* pointer) { SgVariableSymbol::operator delete (pointer, sizeof(SgVariableSymbol)); };
  174126             : #endif
  174127             : /* #line 174128 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  174128             : 
  174129             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  174130             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  174131             : // obviously imply C++.
  174132             : 
  174133             : // This implements the support within ROSE for memory pools.  Memory pools
  174134             : // support the most condensed usage of memory within the construction of
  174135             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  174136             : // by a new operator written for each class.
  174137             : 
  174138             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  174139             :     // User wants multi-thread support and POSIX threads are available.
  174140             : #   include <pthread.h>
  174141             :     static pthread_mutex_t SgTemplateVariableSymbol_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  174142             : #else
  174143             :      // Cause synchronization to be skipped.
  174144             : #    ifndef ALLOC_MUTEX
  174145             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  174146             : #    endif
  174147             : #    ifdef _REENTRANT
  174148             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  174149             : #       ifdef _MSC_VER
  174150             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  174151             : #       else
  174152             : #           warning "POSIX threads are not available; synchronization being skipped"
  174153             : #       endif
  174154             : #    endif
  174155             : #endif
  174156             : 
  174157             : #ifndef ROSE_ALLOC_TRACE
  174158             : #  define ROSE_ALLOC_TRACE 0
  174159             : #endif
  174160             : 
  174161             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  174162             : #define ROSE_ALLOC_TRACE_CNT
  174163             : #include "memory-pool-snapshot.h"
  174164             : unsigned long alloc_trace_cnt = 0;
  174165             : #endif
  174166             : 
  174167             : #if ROSE_ALLOC_TRACE
  174168             : const unsigned SgTemplateVariableSymbol::pool_size = 5;
  174169             : #else
  174170             : const unsigned SgTemplateVariableSymbol::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  174171             : #endif
  174172             : 
  174173             : #ifndef ROSE_ALLOC_MEMSET
  174174             : #  define ROSE_ALLOC_MEMSET 0
  174175             : #endif
  174176             : 
  174177             : #ifndef ROSE_PEDANTIC_ALLOC
  174178             : #  define ROSE_PEDANTIC_ALLOC 0
  174179             : #endif
  174180             : 
  174181             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  174182             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  174183             : #endif
  174184             : 
  174185             : #if !defined(SGNODE__ALL_POOLS)
  174186             : #define SGNODE__ALL_POOLS
  174187             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  174188             : #endif
  174189             : 
  174190             : SgTemplateVariableSymbol* SgTemplateVariableSymbol::next_node = nullptr;
  174191             : std::vector<unsigned char*> SgTemplateVariableSymbol::pools;
  174192             : 
  174193             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  174194             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  174195             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  174196             : // around this macro definition rather than each use).
  174197             : #ifndef ALLOC_MUTEX
  174198             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  174199             :         do {                                                                     \
  174200             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  174201             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  174202             :                 abort();                                                         \
  174203             :             }                                                                    \
  174204             :         } while (0);
  174205             : #endif
  174206             : 
  174207             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  174208             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  174209             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  174210             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  174211             : 
  174212             : /*! \brief New operator for SgTemplateVariableSymbol.
  174213             : 
  174214             :    This new operator implements memory pools to provide most efficent 
  174215             :    use of the heap within construction of large ASTs.
  174216             : 
  174217             : \internal The new and delete operators use the lower level C malloc/free
  174218             :    function calls for performance and to make sure that mixing of malloc/free
  174219             :    and new/delete by the used can be caught more readily.  This may change
  174220             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  174221             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  174222             :    deallocate memory allocated using ROSE_MALLOC.
  174223             : */
  174224         845 : void *SgTemplateVariableSymbol::operator new ( size_t Size )
  174225             : {
  174226             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  174227             :      * returning or throwing an exception. */
  174228         845 :     ALLOC_MUTEX(SgTemplateVariableSymbol, lock);
  174229             : 
  174230             : #if ROSE_ALLOC_TRACE == 2
  174231             : //    printf("SgTemplateVariableSymbol::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgTemplateVariableSymbol::next_node);
  174232             : #endif
  174233             : 
  174234             : #if USE_CPP_NEW_DELETE_OPERATORS
  174235             :     void *mem = ROSE_MALLOC(Size);
  174236             :     ALLOC_MUTEX(SgTemplateVariableSymbol, unlock);
  174237             :     return mem;
  174238             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  174239             : #if ROSE_PEDANTIC_ALLOC
  174240             :     ROSE_ASSERT(Size == sizeof(SgTemplateVariableSymbol));
  174241             : #else
  174242         845 :     if (Size != sizeof(SgTemplateVariableSymbol)) {
  174243           0 :       void * object = ROSE_MALLOC(Size);
  174244           0 :       ALLOC_MUTEX(SgTemplateVariableSymbol, unlock);
  174245             :       return object;
  174246             :     }
  174247             : #endif
  174248             : 
  174249         845 :     if (SgTemplateVariableSymbol::next_node == nullptr) {
  174250          11 :         SgTemplateVariableSymbol * alloc = (SgTemplateVariableSymbol*) ROSE_MALLOC ( SgTemplateVariableSymbol::pool_size * sizeof(SgTemplateVariableSymbol) );
  174251          11 :         ROSE_ASSERT(alloc != nullptr);
  174252             : 
  174253             : #if ROSE_ALLOC_TRACE == 2
  174254             : //        printf("SgTemplateVariableSymbol::alloc\n  block[%zi] = [ %p , %p [\n", SgTemplateVariableSymbol::pools.size(), alloc, alloc + SgTemplateVariableSymbol::pool_size);
  174255             : #endif
  174256             : 
  174257             : #if ROSE_ALLOC_MEMSET == 1
  174258             : #elif ROSE_ALLOC_MEMSET == 2
  174259             :         memset(alloc, 0x00, SgTemplateVariableSymbol::pool_size * sizeof(SgTemplateVariableSymbol));
  174260             : #elif ROSE_ALLOC_MEMSET == 3
  174261             :         memset(alloc, 0xAA, SgTemplateVariableSymbol::pool_size * sizeof(SgTemplateVariableSymbol));
  174262             : #endif
  174263       22000 :         for (unsigned i=0; i < SgTemplateVariableSymbol::pool_size-1; i++) {
  174264       21989 :           alloc[i].p_freepointer = &(alloc[i+1]);
  174265             :         }
  174266          11 :         alloc[SgTemplateVariableSymbol::pool_size-1].p_freepointer = nullptr;
  174267             : 
  174268          11 :         SgTemplateVariableSymbol::pools.push_back ( (unsigned char *) alloc );
  174269          11 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgTemplateVariableSymbol::pool_size * sizeof(SgTemplateVariableSymbol), V_SgTemplateVariableSymbol ) );
  174270          11 :         SgTemplateVariableSymbol::next_node = alloc;
  174271             :     }
  174272         845 :     ROSE_ASSERT(SgTemplateVariableSymbol::next_node != nullptr);
  174273             : 
  174274         845 :     SgTemplateVariableSymbol * object = SgTemplateVariableSymbol::next_node;
  174275         845 :     SgTemplateVariableSymbol::next_node = (SgTemplateVariableSymbol*)(object->p_freepointer);
  174276             : 
  174277             : #if ROSE_ALLOC_TRACE == 2
  174278             :     printf("SgTemplateVariableSymbol::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTemplateVariableSymbol::next_node);
  174279             : #endif
  174280             : 
  174281         845 :     SgNode * fp = object->p_freepointer;
  174282             : #if ROSE_ALLOC_MEMSET == 1
  174283             : #elif ROSE_ALLOC_MEMSET == 2
  174284             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgTemplateVariableSymbol) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  174285             : #elif ROSE_ALLOC_MEMSET == 3
  174286             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgTemplateVariableSymbol) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  174287             : #endif
  174288         845 :     object->p_freepointer = fp;
  174289             : 
  174290             : #if ROSE_ALLOC_TRACE == 2
  174291             : //    printf("SgTemplateVariableSymbol::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTemplateVariableSymbol::next_node);
  174292             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  174293             :     Rose::MemPool::snapshot(oss.str());
  174294             :     alloc_trace_cnt++;
  174295             : #endif
  174296             : 
  174297         845 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  174298             : 
  174299         845 :     ALLOC_MUTEX(SgTemplateVariableSymbol, unlock);
  174300             : 
  174301             :     return object;
  174302             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  174303             : }
  174304             : 
  174305             : 
  174306             : 
  174307             : /*! \brief Delete operator for SgTemplateVariableSymbol.
  174308             : 
  174309             :    This delete operator implements deallocation using memory pools to 
  174310             :    provide most efficent use of the heap within construction of large ASTs.
  174311             : 
  174312             : \internal The new and delete operators use the lower level C malloc/free
  174313             :    function calls for performance and to make sure that mixing of malloc/free
  174314             :    and new/delete by the used can be caught more readily.  This may change
  174315             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  174316             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  174317             :    deallocate memory allocated using ROSE_MALLOC.
  174318             : */
  174319         172 : void SgTemplateVariableSymbol::operator delete(void *Pointer, size_t Size)
  174320             : {
  174321             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  174322             :      * or throwing an exception. */
  174323         172 :     ALLOC_MUTEX(SgTemplateVariableSymbol, lock);
  174324             : 
  174325             : #if USE_CPP_NEW_DELETE_OPERATORS
  174326             :     ROSE_FREE(Pointer);
  174327             : #else
  174328             : #if ROSE_PEDANTIC_ALLOC
  174329             :     ROSE_ASSERT(Size == sizeof(SgTemplateVariableSymbol));
  174330             : #else
  174331         172 :     if (Size != sizeof(SgTemplateVariableSymbol)) {
  174332           0 :       ROSE_FREE(Pointer);
  174333           0 :       ALLOC_MUTEX(SgTemplateVariableSymbol, unlock);
  174334             :       return;
  174335             :     }
  174336             : #endif
  174337             : 
  174338         172 :     SgTemplateVariableSymbol * object = (SgTemplateVariableSymbol*) Pointer;
  174339         172 :     ROSE_ASSERT(object != nullptr);
  174340             : 
  174341             : #if ROSE_ALLOC_TRACE == 2
  174342             : //  printf("SgTemplateVariableSymbol::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTemplateVariableSymbol::next_node);
  174343             :     printf("SgTemplateVariableSymbol::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTemplateVariableSymbol::next_node);
  174344             : #endif
  174345             : 
  174346             : #if ROSE_PEDANTIC_ALLOC
  174347             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  174348             : #endif
  174349             : 
  174350             : #if ROSE_ALLOC_MEMSET == 1
  174351             : #elif ROSE_ALLOC_MEMSET == 2
  174352             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgTemplateVariableSymbol) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  174353             : #elif ROSE_ALLOC_MEMSET == 3
  174354             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgTemplateVariableSymbol) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  174355             : #endif
  174356             : 
  174357             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  174358             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  174359             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  174360             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  174361             : #else
  174362         172 :     object->p_freepointer = SgTemplateVariableSymbol::next_node;
  174363         172 :     SgTemplateVariableSymbol::next_node = object;
  174364             : #endif
  174365             : 
  174366             : #if ROSE_ALLOC_TRACE == 2
  174367             : //  printf("SgTemplateVariableSymbol::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTemplateVariableSymbol::next_node);
  174368             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  174369             :     Rose::MemPool::snapshot(oss.str());
  174370             :     alloc_trace_cnt++;
  174371             : #endif
  174372             : 
  174373             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  174374             : 
  174375         172 :     ALLOC_MUTEX(SgTemplateVariableSymbol, unlock);
  174376             : }
  174377             : 
  174378             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  174379             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  174380             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  174381             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  174382             : // Also, note comment below from Robb (copied from the Common.code file).
  174383             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  174384             : //
  174385             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  174386             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  174387             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  174388             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  174389             : #if 0
  174390             : void SgTemplateVariableSymbol::operator delete(void* pointer) { SgTemplateVariableSymbol::operator delete (pointer, sizeof(SgTemplateVariableSymbol)); };
  174391             : #endif
  174392             : /* #line 174393 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  174393             : 
  174394             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  174395             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  174396             : // obviously imply C++.
  174397             : 
  174398             : // This implements the support within ROSE for memory pools.  Memory pools
  174399             : // support the most condensed usage of memory within the construction of
  174400             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  174401             : // by a new operator written for each class.
  174402             : 
  174403             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  174404             :     // User wants multi-thread support and POSIX threads are available.
  174405             : #   include <pthread.h>
  174406             :     static pthread_mutex_t SgNonrealSymbol_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  174407             : #else
  174408             :      // Cause synchronization to be skipped.
  174409             : #    ifndef ALLOC_MUTEX
  174410             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  174411             : #    endif
  174412             : #    ifdef _REENTRANT
  174413             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  174414             : #       ifdef _MSC_VER
  174415             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  174416             : #       else
  174417             : #           warning "POSIX threads are not available; synchronization being skipped"
  174418             : #       endif
  174419             : #    endif
  174420             : #endif
  174421             : 
  174422             : #ifndef ROSE_ALLOC_TRACE
  174423             : #  define ROSE_ALLOC_TRACE 0
  174424             : #endif
  174425             : 
  174426             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  174427             : #define ROSE_ALLOC_TRACE_CNT
  174428             : #include "memory-pool-snapshot.h"
  174429             : unsigned long alloc_trace_cnt = 0;
  174430             : #endif
  174431             : 
  174432             : #if ROSE_ALLOC_TRACE
  174433             : const unsigned SgNonrealSymbol::pool_size = 5;
  174434             : #else
  174435             : const unsigned SgNonrealSymbol::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  174436             : #endif
  174437             : 
  174438             : #ifndef ROSE_ALLOC_MEMSET
  174439             : #  define ROSE_ALLOC_MEMSET 0
  174440             : #endif
  174441             : 
  174442             : #ifndef ROSE_PEDANTIC_ALLOC
  174443             : #  define ROSE_PEDANTIC_ALLOC 0
  174444             : #endif
  174445             : 
  174446             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  174447             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  174448             : #endif
  174449             : 
  174450             : #if !defined(SGNODE__ALL_POOLS)
  174451             : #define SGNODE__ALL_POOLS
  174452             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  174453             : #endif
  174454             : 
  174455             : SgNonrealSymbol* SgNonrealSymbol::next_node = nullptr;
  174456             : std::vector<unsigned char*> SgNonrealSymbol::pools;
  174457             : 
  174458             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  174459             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  174460             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  174461             : // around this macro definition rather than each use).
  174462             : #ifndef ALLOC_MUTEX
  174463             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  174464             :         do {                                                                     \
  174465             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  174466             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  174467             :                 abort();                                                         \
  174468             :             }                                                                    \
  174469             :         } while (0);
  174470             : #endif
  174471             : 
  174472             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  174473             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  174474             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  174475             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  174476             : 
  174477             : /*! \brief New operator for SgNonrealSymbol.
  174478             : 
  174479             :    This new operator implements memory pools to provide most efficent 
  174480             :    use of the heap within construction of large ASTs.
  174481             : 
  174482             : \internal The new and delete operators use the lower level C malloc/free
  174483             :    function calls for performance and to make sure that mixing of malloc/free
  174484             :    and new/delete by the used can be caught more readily.  This may change
  174485             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  174486             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  174487             :    deallocate memory allocated using ROSE_MALLOC.
  174488             : */
  174489       54405 : void *SgNonrealSymbol::operator new ( size_t Size )
  174490             : {
  174491             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  174492             :      * returning or throwing an exception. */
  174493       54405 :     ALLOC_MUTEX(SgNonrealSymbol, lock);
  174494             : 
  174495             : #if ROSE_ALLOC_TRACE == 2
  174496             : //    printf("SgNonrealSymbol::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgNonrealSymbol::next_node);
  174497             : #endif
  174498             : 
  174499             : #if USE_CPP_NEW_DELETE_OPERATORS
  174500             :     void *mem = ROSE_MALLOC(Size);
  174501             :     ALLOC_MUTEX(SgNonrealSymbol, unlock);
  174502             :     return mem;
  174503             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  174504             : #if ROSE_PEDANTIC_ALLOC
  174505             :     ROSE_ASSERT(Size == sizeof(SgNonrealSymbol));
  174506             : #else
  174507       54405 :     if (Size != sizeof(SgNonrealSymbol)) {
  174508           0 :       void * object = ROSE_MALLOC(Size);
  174509           0 :       ALLOC_MUTEX(SgNonrealSymbol, unlock);
  174510             :       return object;
  174511             :     }
  174512             : #endif
  174513             : 
  174514       54405 :     if (SgNonrealSymbol::next_node == nullptr) {
  174515          31 :         SgNonrealSymbol * alloc = (SgNonrealSymbol*) ROSE_MALLOC ( SgNonrealSymbol::pool_size * sizeof(SgNonrealSymbol) );
  174516          31 :         ROSE_ASSERT(alloc != nullptr);
  174517             : 
  174518             : #if ROSE_ALLOC_TRACE == 2
  174519             : //        printf("SgNonrealSymbol::alloc\n  block[%zi] = [ %p , %p [\n", SgNonrealSymbol::pools.size(), alloc, alloc + SgNonrealSymbol::pool_size);
  174520             : #endif
  174521             : 
  174522             : #if ROSE_ALLOC_MEMSET == 1
  174523             : #elif ROSE_ALLOC_MEMSET == 2
  174524             :         memset(alloc, 0x00, SgNonrealSymbol::pool_size * sizeof(SgNonrealSymbol));
  174525             : #elif ROSE_ALLOC_MEMSET == 3
  174526             :         memset(alloc, 0xAA, SgNonrealSymbol::pool_size * sizeof(SgNonrealSymbol));
  174527             : #endif
  174528       62000 :         for (unsigned i=0; i < SgNonrealSymbol::pool_size-1; i++) {
  174529       61969 :           alloc[i].p_freepointer = &(alloc[i+1]);
  174530             :         }
  174531          31 :         alloc[SgNonrealSymbol::pool_size-1].p_freepointer = nullptr;
  174532             : 
  174533          31 :         SgNonrealSymbol::pools.push_back ( (unsigned char *) alloc );
  174534          31 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgNonrealSymbol::pool_size * sizeof(SgNonrealSymbol), V_SgNonrealSymbol ) );
  174535          31 :         SgNonrealSymbol::next_node = alloc;
  174536             :     }
  174537       54405 :     ROSE_ASSERT(SgNonrealSymbol::next_node != nullptr);
  174538             : 
  174539       54405 :     SgNonrealSymbol * object = SgNonrealSymbol::next_node;
  174540       54405 :     SgNonrealSymbol::next_node = (SgNonrealSymbol*)(object->p_freepointer);
  174541             : 
  174542             : #if ROSE_ALLOC_TRACE == 2
  174543             :     printf("SgNonrealSymbol::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgNonrealSymbol::next_node);
  174544             : #endif
  174545             : 
  174546       54405 :     SgNode * fp = object->p_freepointer;
  174547             : #if ROSE_ALLOC_MEMSET == 1
  174548             : #elif ROSE_ALLOC_MEMSET == 2
  174549             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgNonrealSymbol) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  174550             : #elif ROSE_ALLOC_MEMSET == 3
  174551             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgNonrealSymbol) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  174552             : #endif
  174553       54405 :     object->p_freepointer = fp;
  174554             : 
  174555             : #if ROSE_ALLOC_TRACE == 2
  174556             : //    printf("SgNonrealSymbol::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgNonrealSymbol::next_node);
  174557             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  174558             :     Rose::MemPool::snapshot(oss.str());
  174559             :     alloc_trace_cnt++;
  174560             : #endif
  174561             : 
  174562       54405 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  174563             : 
  174564       54405 :     ALLOC_MUTEX(SgNonrealSymbol, unlock);
  174565             : 
  174566             :     return object;
  174567             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  174568             : }
  174569             : 
  174570             : 
  174571             : 
  174572             : /*! \brief Delete operator for SgNonrealSymbol.
  174573             : 
  174574             :    This delete operator implements deallocation using memory pools to 
  174575             :    provide most efficent use of the heap within construction of large ASTs.
  174576             : 
  174577             : \internal The new and delete operators use the lower level C malloc/free
  174578             :    function calls for performance and to make sure that mixing of malloc/free
  174579             :    and new/delete by the used can be caught more readily.  This may change
  174580             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  174581             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  174582             :    deallocate memory allocated using ROSE_MALLOC.
  174583             : */
  174584       10160 : void SgNonrealSymbol::operator delete(void *Pointer, size_t Size)
  174585             : {
  174586             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  174587             :      * or throwing an exception. */
  174588       10160 :     ALLOC_MUTEX(SgNonrealSymbol, lock);
  174589             : 
  174590             : #if USE_CPP_NEW_DELETE_OPERATORS
  174591             :     ROSE_FREE(Pointer);
  174592             : #else
  174593             : #if ROSE_PEDANTIC_ALLOC
  174594             :     ROSE_ASSERT(Size == sizeof(SgNonrealSymbol));
  174595             : #else
  174596       10160 :     if (Size != sizeof(SgNonrealSymbol)) {
  174597           0 :       ROSE_FREE(Pointer);
  174598           0 :       ALLOC_MUTEX(SgNonrealSymbol, unlock);
  174599             :       return;
  174600             :     }
  174601             : #endif
  174602             : 
  174603       10160 :     SgNonrealSymbol * object = (SgNonrealSymbol*) Pointer;
  174604       10160 :     ROSE_ASSERT(object != nullptr);
  174605             : 
  174606             : #if ROSE_ALLOC_TRACE == 2
  174607             : //  printf("SgNonrealSymbol::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgNonrealSymbol::next_node);
  174608             :     printf("SgNonrealSymbol::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgNonrealSymbol::next_node);
  174609             : #endif
  174610             : 
  174611             : #if ROSE_PEDANTIC_ALLOC
  174612             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  174613             : #endif
  174614             : 
  174615             : #if ROSE_ALLOC_MEMSET == 1
  174616             : #elif ROSE_ALLOC_MEMSET == 2
  174617             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgNonrealSymbol) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  174618             : #elif ROSE_ALLOC_MEMSET == 3
  174619             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgNonrealSymbol) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  174620             : #endif
  174621             : 
  174622             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  174623             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  174624             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  174625             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  174626             : #else
  174627       10160 :     object->p_freepointer = SgNonrealSymbol::next_node;
  174628       10160 :     SgNonrealSymbol::next_node = object;
  174629             : #endif
  174630             : 
  174631             : #if ROSE_ALLOC_TRACE == 2
  174632             : //  printf("SgNonrealSymbol::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgNonrealSymbol::next_node);
  174633             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  174634             :     Rose::MemPool::snapshot(oss.str());
  174635             :     alloc_trace_cnt++;
  174636             : #endif
  174637             : 
  174638             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  174639             : 
  174640       10160 :     ALLOC_MUTEX(SgNonrealSymbol, unlock);
  174641             : }
  174642             : 
  174643             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  174644             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  174645             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  174646             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  174647             : // Also, note comment below from Robb (copied from the Common.code file).
  174648             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  174649             : //
  174650             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  174651             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  174652             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  174653             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  174654             : #if 0
  174655             : void SgNonrealSymbol::operator delete(void* pointer) { SgNonrealSymbol::operator delete (pointer, sizeof(SgNonrealSymbol)); };
  174656             : #endif
  174657             : /* #line 174658 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  174658             : 
  174659             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  174660             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  174661             : // obviously imply C++.
  174662             : 
  174663             : // This implements the support within ROSE for memory pools.  Memory pools
  174664             : // support the most condensed usage of memory within the construction of
  174665             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  174666             : // by a new operator written for each class.
  174667             : 
  174668             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  174669             :     // User wants multi-thread support and POSIX threads are available.
  174670             : #   include <pthread.h>
  174671             :     static pthread_mutex_t SgFunctionSymbol_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  174672             : #else
  174673             :      // Cause synchronization to be skipped.
  174674             : #    ifndef ALLOC_MUTEX
  174675             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  174676             : #    endif
  174677             : #    ifdef _REENTRANT
  174678             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  174679             : #       ifdef _MSC_VER
  174680             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  174681             : #       else
  174682             : #           warning "POSIX threads are not available; synchronization being skipped"
  174683             : #       endif
  174684             : #    endif
  174685             : #endif
  174686             : 
  174687             : #ifndef ROSE_ALLOC_TRACE
  174688             : #  define ROSE_ALLOC_TRACE 0
  174689             : #endif
  174690             : 
  174691             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  174692             : #define ROSE_ALLOC_TRACE_CNT
  174693             : #include "memory-pool-snapshot.h"
  174694             : unsigned long alloc_trace_cnt = 0;
  174695             : #endif
  174696             : 
  174697             : #if ROSE_ALLOC_TRACE
  174698             : const unsigned SgFunctionSymbol::pool_size = 5;
  174699             : #else
  174700             : const unsigned SgFunctionSymbol::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  174701             : #endif
  174702             : 
  174703             : #ifndef ROSE_ALLOC_MEMSET
  174704             : #  define ROSE_ALLOC_MEMSET 0
  174705             : #endif
  174706             : 
  174707             : #ifndef ROSE_PEDANTIC_ALLOC
  174708             : #  define ROSE_PEDANTIC_ALLOC 0
  174709             : #endif
  174710             : 
  174711             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  174712             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  174713             : #endif
  174714             : 
  174715             : #if !defined(SGNODE__ALL_POOLS)
  174716             : #define SGNODE__ALL_POOLS
  174717             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  174718             : #endif
  174719             : 
  174720             : SgFunctionSymbol* SgFunctionSymbol::next_node = nullptr;
  174721             : std::vector<unsigned char*> SgFunctionSymbol::pools;
  174722             : 
  174723             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  174724             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  174725             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  174726             : // around this macro definition rather than each use).
  174727             : #ifndef ALLOC_MUTEX
  174728             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  174729             :         do {                                                                     \
  174730             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  174731             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  174732             :                 abort();                                                         \
  174733             :             }                                                                    \
  174734             :         } while (0);
  174735             : #endif
  174736             : 
  174737             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  174738             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  174739             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  174740             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  174741             : 
  174742             : /*! \brief New operator for SgFunctionSymbol.
  174743             : 
  174744             :    This new operator implements memory pools to provide most efficent 
  174745             :    use of the heap within construction of large ASTs.
  174746             : 
  174747             : \internal The new and delete operators use the lower level C malloc/free
  174748             :    function calls for performance and to make sure that mixing of malloc/free
  174749             :    and new/delete by the used can be caught more readily.  This may change
  174750             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  174751             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  174752             :    deallocate memory allocated using ROSE_MALLOC.
  174753             : */
  174754      827508 : void *SgFunctionSymbol::operator new ( size_t Size )
  174755             : {
  174756             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  174757             :      * returning or throwing an exception. */
  174758      827508 :     ALLOC_MUTEX(SgFunctionSymbol, lock);
  174759             : 
  174760             : #if ROSE_ALLOC_TRACE == 2
  174761             : //    printf("SgFunctionSymbol::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgFunctionSymbol::next_node);
  174762             : #endif
  174763             : 
  174764             : #if USE_CPP_NEW_DELETE_OPERATORS
  174765             :     void *mem = ROSE_MALLOC(Size);
  174766             :     ALLOC_MUTEX(SgFunctionSymbol, unlock);
  174767             :     return mem;
  174768             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  174769             : #if ROSE_PEDANTIC_ALLOC
  174770             :     ROSE_ASSERT(Size == sizeof(SgFunctionSymbol));
  174771             : #else
  174772      827508 :     if (Size != sizeof(SgFunctionSymbol)) {
  174773           0 :       void * object = ROSE_MALLOC(Size);
  174774           0 :       ALLOC_MUTEX(SgFunctionSymbol, unlock);
  174775             :       return object;
  174776             :     }
  174777             : #endif
  174778             : 
  174779      827508 :     if (SgFunctionSymbol::next_node == nullptr) {
  174780         671 :         SgFunctionSymbol * alloc = (SgFunctionSymbol*) ROSE_MALLOC ( SgFunctionSymbol::pool_size * sizeof(SgFunctionSymbol) );
  174781         671 :         ROSE_ASSERT(alloc != nullptr);
  174782             : 
  174783             : #if ROSE_ALLOC_TRACE == 2
  174784             : //        printf("SgFunctionSymbol::alloc\n  block[%zi] = [ %p , %p [\n", SgFunctionSymbol::pools.size(), alloc, alloc + SgFunctionSymbol::pool_size);
  174785             : #endif
  174786             : 
  174787             : #if ROSE_ALLOC_MEMSET == 1
  174788             : #elif ROSE_ALLOC_MEMSET == 2
  174789             :         memset(alloc, 0x00, SgFunctionSymbol::pool_size * sizeof(SgFunctionSymbol));
  174790             : #elif ROSE_ALLOC_MEMSET == 3
  174791             :         memset(alloc, 0xAA, SgFunctionSymbol::pool_size * sizeof(SgFunctionSymbol));
  174792             : #endif
  174793     1342000 :         for (unsigned i=0; i < SgFunctionSymbol::pool_size-1; i++) {
  174794     1341330 :           alloc[i].p_freepointer = &(alloc[i+1]);
  174795             :         }
  174796         671 :         alloc[SgFunctionSymbol::pool_size-1].p_freepointer = nullptr;
  174797             : 
  174798         671 :         SgFunctionSymbol::pools.push_back ( (unsigned char *) alloc );
  174799         671 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgFunctionSymbol::pool_size * sizeof(SgFunctionSymbol), V_SgFunctionSymbol ) );
  174800         671 :         SgFunctionSymbol::next_node = alloc;
  174801             :     }
  174802      827508 :     ROSE_ASSERT(SgFunctionSymbol::next_node != nullptr);
  174803             : 
  174804      827508 :     SgFunctionSymbol * object = SgFunctionSymbol::next_node;
  174805      827508 :     SgFunctionSymbol::next_node = (SgFunctionSymbol*)(object->p_freepointer);
  174806             : 
  174807             : #if ROSE_ALLOC_TRACE == 2
  174808             :     printf("SgFunctionSymbol::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgFunctionSymbol::next_node);
  174809             : #endif
  174810             : 
  174811      827508 :     SgNode * fp = object->p_freepointer;
  174812             : #if ROSE_ALLOC_MEMSET == 1
  174813             : #elif ROSE_ALLOC_MEMSET == 2
  174814             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgFunctionSymbol) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  174815             : #elif ROSE_ALLOC_MEMSET == 3
  174816             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgFunctionSymbol) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  174817             : #endif
  174818      827508 :     object->p_freepointer = fp;
  174819             : 
  174820             : #if ROSE_ALLOC_TRACE == 2
  174821             : //    printf("SgFunctionSymbol::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgFunctionSymbol::next_node);
  174822             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  174823             :     Rose::MemPool::snapshot(oss.str());
  174824             :     alloc_trace_cnt++;
  174825             : #endif
  174826             : 
  174827      827508 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  174828             : 
  174829      827508 :     ALLOC_MUTEX(SgFunctionSymbol, unlock);
  174830             : 
  174831             :     return object;
  174832             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  174833             : }
  174834             : 
  174835             : 
  174836             : 
  174837             : /*! \brief Delete operator for SgFunctionSymbol.
  174838             : 
  174839             :    This delete operator implements deallocation using memory pools to 
  174840             :    provide most efficent use of the heap within construction of large ASTs.
  174841             : 
  174842             : \internal The new and delete operators use the lower level C malloc/free
  174843             :    function calls for performance and to make sure that mixing of malloc/free
  174844             :    and new/delete by the used can be caught more readily.  This may change
  174845             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  174846             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  174847             :    deallocate memory allocated using ROSE_MALLOC.
  174848             : */
  174849       11911 : void SgFunctionSymbol::operator delete(void *Pointer, size_t Size)
  174850             : {
  174851             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  174852             :      * or throwing an exception. */
  174853       11911 :     ALLOC_MUTEX(SgFunctionSymbol, lock);
  174854             : 
  174855             : #if USE_CPP_NEW_DELETE_OPERATORS
  174856             :     ROSE_FREE(Pointer);
  174857             : #else
  174858             : #if ROSE_PEDANTIC_ALLOC
  174859             :     ROSE_ASSERT(Size == sizeof(SgFunctionSymbol));
  174860             : #else
  174861       11911 :     if (Size != sizeof(SgFunctionSymbol)) {
  174862           0 :       ROSE_FREE(Pointer);
  174863           0 :       ALLOC_MUTEX(SgFunctionSymbol, unlock);
  174864             :       return;
  174865             :     }
  174866             : #endif
  174867             : 
  174868       11911 :     SgFunctionSymbol * object = (SgFunctionSymbol*) Pointer;
  174869       11911 :     ROSE_ASSERT(object != nullptr);
  174870             : 
  174871             : #if ROSE_ALLOC_TRACE == 2
  174872             : //  printf("SgFunctionSymbol::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgFunctionSymbol::next_node);
  174873             :     printf("SgFunctionSymbol::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgFunctionSymbol::next_node);
  174874             : #endif
  174875             : 
  174876             : #if ROSE_PEDANTIC_ALLOC
  174877             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  174878             : #endif
  174879             : 
  174880             : #if ROSE_ALLOC_MEMSET == 1
  174881             : #elif ROSE_ALLOC_MEMSET == 2
  174882             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgFunctionSymbol) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  174883             : #elif ROSE_ALLOC_MEMSET == 3
  174884             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgFunctionSymbol) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  174885             : #endif
  174886             : 
  174887             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  174888             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  174889             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  174890             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  174891             : #else
  174892       11911 :     object->p_freepointer = SgFunctionSymbol::next_node;
  174893       11911 :     SgFunctionSymbol::next_node = object;
  174894             : #endif
  174895             : 
  174896             : #if ROSE_ALLOC_TRACE == 2
  174897             : //  printf("SgFunctionSymbol::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgFunctionSymbol::next_node);
  174898             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  174899             :     Rose::MemPool::snapshot(oss.str());
  174900             :     alloc_trace_cnt++;
  174901             : #endif
  174902             : 
  174903             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  174904             : 
  174905       11911 :     ALLOC_MUTEX(SgFunctionSymbol, unlock);
  174906             : }
  174907             : 
  174908             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  174909             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  174910             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  174911             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  174912             : // Also, note comment below from Robb (copied from the Common.code file).
  174913             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  174914             : //
  174915             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  174916             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  174917             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  174918             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  174919             : #if 0
  174920             : void SgFunctionSymbol::operator delete(void* pointer) { SgFunctionSymbol::operator delete (pointer, sizeof(SgFunctionSymbol)); };
  174921             : #endif
  174922             : /* #line 174923 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  174923             : 
  174924             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  174925             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  174926             : // obviously imply C++.
  174927             : 
  174928             : // This implements the support within ROSE for memory pools.  Memory pools
  174929             : // support the most condensed usage of memory within the construction of
  174930             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  174931             : // by a new operator written for each class.
  174932             : 
  174933             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  174934             :     // User wants multi-thread support and POSIX threads are available.
  174935             : #   include <pthread.h>
  174936             :     static pthread_mutex_t SgMemberFunctionSymbol_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  174937             : #else
  174938             :      // Cause synchronization to be skipped.
  174939             : #    ifndef ALLOC_MUTEX
  174940             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  174941             : #    endif
  174942             : #    ifdef _REENTRANT
  174943             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  174944             : #       ifdef _MSC_VER
  174945             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  174946             : #       else
  174947             : #           warning "POSIX threads are not available; synchronization being skipped"
  174948             : #       endif
  174949             : #    endif
  174950             : #endif
  174951             : 
  174952             : #ifndef ROSE_ALLOC_TRACE
  174953             : #  define ROSE_ALLOC_TRACE 0
  174954             : #endif
  174955             : 
  174956             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  174957             : #define ROSE_ALLOC_TRACE_CNT
  174958             : #include "memory-pool-snapshot.h"
  174959             : unsigned long alloc_trace_cnt = 0;
  174960             : #endif
  174961             : 
  174962             : #if ROSE_ALLOC_TRACE
  174963             : const unsigned SgMemberFunctionSymbol::pool_size = 5;
  174964             : #else
  174965             : const unsigned SgMemberFunctionSymbol::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  174966             : #endif
  174967             : 
  174968             : #ifndef ROSE_ALLOC_MEMSET
  174969             : #  define ROSE_ALLOC_MEMSET 0
  174970             : #endif
  174971             : 
  174972             : #ifndef ROSE_PEDANTIC_ALLOC
  174973             : #  define ROSE_PEDANTIC_ALLOC 0
  174974             : #endif
  174975             : 
  174976             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  174977             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  174978             : #endif
  174979             : 
  174980             : #if !defined(SGNODE__ALL_POOLS)
  174981             : #define SGNODE__ALL_POOLS
  174982             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  174983             : #endif
  174984             : 
  174985             : SgMemberFunctionSymbol* SgMemberFunctionSymbol::next_node = nullptr;
  174986             : std::vector<unsigned char*> SgMemberFunctionSymbol::pools;
  174987             : 
  174988             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  174989             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  174990             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  174991             : // around this macro definition rather than each use).
  174992             : #ifndef ALLOC_MUTEX
  174993             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  174994             :         do {                                                                     \
  174995             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  174996             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  174997             :                 abort();                                                         \
  174998             :             }                                                                    \
  174999             :         } while (0);
  175000             : #endif
  175001             : 
  175002             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  175003             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  175004             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  175005             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  175006             : 
  175007             : /*! \brief New operator for SgMemberFunctionSymbol.
  175008             : 
  175009             :    This new operator implements memory pools to provide most efficent 
  175010             :    use of the heap within construction of large ASTs.
  175011             : 
  175012             : \internal The new and delete operators use the lower level C malloc/free
  175013             :    function calls for performance and to make sure that mixing of malloc/free
  175014             :    and new/delete by the used can be caught more readily.  This may change
  175015             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  175016             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  175017             :    deallocate memory allocated using ROSE_MALLOC.
  175018             : */
  175019       18381 : void *SgMemberFunctionSymbol::operator new ( size_t Size )
  175020             : {
  175021             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  175022             :      * returning or throwing an exception. */
  175023       18381 :     ALLOC_MUTEX(SgMemberFunctionSymbol, lock);
  175024             : 
  175025             : #if ROSE_ALLOC_TRACE == 2
  175026             : //    printf("SgMemberFunctionSymbol::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgMemberFunctionSymbol::next_node);
  175027             : #endif
  175028             : 
  175029             : #if USE_CPP_NEW_DELETE_OPERATORS
  175030             :     void *mem = ROSE_MALLOC(Size);
  175031             :     ALLOC_MUTEX(SgMemberFunctionSymbol, unlock);
  175032             :     return mem;
  175033             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  175034             : #if ROSE_PEDANTIC_ALLOC
  175035             :     ROSE_ASSERT(Size == sizeof(SgMemberFunctionSymbol));
  175036             : #else
  175037       18381 :     if (Size != sizeof(SgMemberFunctionSymbol)) {
  175038           0 :       void * object = ROSE_MALLOC(Size);
  175039           0 :       ALLOC_MUTEX(SgMemberFunctionSymbol, unlock);
  175040             :       return object;
  175041             :     }
  175042             : #endif
  175043             : 
  175044       18381 :     if (SgMemberFunctionSymbol::next_node == nullptr) {
  175045          17 :         SgMemberFunctionSymbol * alloc = (SgMemberFunctionSymbol*) ROSE_MALLOC ( SgMemberFunctionSymbol::pool_size * sizeof(SgMemberFunctionSymbol) );
  175046          17 :         ROSE_ASSERT(alloc != nullptr);
  175047             : 
  175048             : #if ROSE_ALLOC_TRACE == 2
  175049             : //        printf("SgMemberFunctionSymbol::alloc\n  block[%zi] = [ %p , %p [\n", SgMemberFunctionSymbol::pools.size(), alloc, alloc + SgMemberFunctionSymbol::pool_size);
  175050             : #endif
  175051             : 
  175052             : #if ROSE_ALLOC_MEMSET == 1
  175053             : #elif ROSE_ALLOC_MEMSET == 2
  175054             :         memset(alloc, 0x00, SgMemberFunctionSymbol::pool_size * sizeof(SgMemberFunctionSymbol));
  175055             : #elif ROSE_ALLOC_MEMSET == 3
  175056             :         memset(alloc, 0xAA, SgMemberFunctionSymbol::pool_size * sizeof(SgMemberFunctionSymbol));
  175057             : #endif
  175058       34000 :         for (unsigned i=0; i < SgMemberFunctionSymbol::pool_size-1; i++) {
  175059       33983 :           alloc[i].p_freepointer = &(alloc[i+1]);
  175060             :         }
  175061          17 :         alloc[SgMemberFunctionSymbol::pool_size-1].p_freepointer = nullptr;
  175062             : 
  175063          17 :         SgMemberFunctionSymbol::pools.push_back ( (unsigned char *) alloc );
  175064          17 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgMemberFunctionSymbol::pool_size * sizeof(SgMemberFunctionSymbol), V_SgMemberFunctionSymbol ) );
  175065          17 :         SgMemberFunctionSymbol::next_node = alloc;
  175066             :     }
  175067       18381 :     ROSE_ASSERT(SgMemberFunctionSymbol::next_node != nullptr);
  175068             : 
  175069       18381 :     SgMemberFunctionSymbol * object = SgMemberFunctionSymbol::next_node;
  175070       18381 :     SgMemberFunctionSymbol::next_node = (SgMemberFunctionSymbol*)(object->p_freepointer);
  175071             : 
  175072             : #if ROSE_ALLOC_TRACE == 2
  175073             :     printf("SgMemberFunctionSymbol::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgMemberFunctionSymbol::next_node);
  175074             : #endif
  175075             : 
  175076       18381 :     SgNode * fp = object->p_freepointer;
  175077             : #if ROSE_ALLOC_MEMSET == 1
  175078             : #elif ROSE_ALLOC_MEMSET == 2
  175079             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgMemberFunctionSymbol) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  175080             : #elif ROSE_ALLOC_MEMSET == 3
  175081             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgMemberFunctionSymbol) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  175082             : #endif
  175083       18381 :     object->p_freepointer = fp;
  175084             : 
  175085             : #if ROSE_ALLOC_TRACE == 2
  175086             : //    printf("SgMemberFunctionSymbol::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgMemberFunctionSymbol::next_node);
  175087             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  175088             :     Rose::MemPool::snapshot(oss.str());
  175089             :     alloc_trace_cnt++;
  175090             : #endif
  175091             : 
  175092       18381 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  175093             : 
  175094       18381 :     ALLOC_MUTEX(SgMemberFunctionSymbol, unlock);
  175095             : 
  175096             :     return object;
  175097             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  175098             : }
  175099             : 
  175100             : 
  175101             : 
  175102             : /*! \brief Delete operator for SgMemberFunctionSymbol.
  175103             : 
  175104             :    This delete operator implements deallocation using memory pools to 
  175105             :    provide most efficent use of the heap within construction of large ASTs.
  175106             : 
  175107             : \internal The new and delete operators use the lower level C malloc/free
  175108             :    function calls for performance and to make sure that mixing of malloc/free
  175109             :    and new/delete by the used can be caught more readily.  This may change
  175110             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  175111             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  175112             :    deallocate memory allocated using ROSE_MALLOC.
  175113             : */
  175114        3906 : void SgMemberFunctionSymbol::operator delete(void *Pointer, size_t Size)
  175115             : {
  175116             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  175117             :      * or throwing an exception. */
  175118        3906 :     ALLOC_MUTEX(SgMemberFunctionSymbol, lock);
  175119             : 
  175120             : #if USE_CPP_NEW_DELETE_OPERATORS
  175121             :     ROSE_FREE(Pointer);
  175122             : #else
  175123             : #if ROSE_PEDANTIC_ALLOC
  175124             :     ROSE_ASSERT(Size == sizeof(SgMemberFunctionSymbol));
  175125             : #else
  175126        3906 :     if (Size != sizeof(SgMemberFunctionSymbol)) {
  175127           0 :       ROSE_FREE(Pointer);
  175128           0 :       ALLOC_MUTEX(SgMemberFunctionSymbol, unlock);
  175129             :       return;
  175130             :     }
  175131             : #endif
  175132             : 
  175133        3906 :     SgMemberFunctionSymbol * object = (SgMemberFunctionSymbol*) Pointer;
  175134        3906 :     ROSE_ASSERT(object != nullptr);
  175135             : 
  175136             : #if ROSE_ALLOC_TRACE == 2
  175137             : //  printf("SgMemberFunctionSymbol::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgMemberFunctionSymbol::next_node);
  175138             :     printf("SgMemberFunctionSymbol::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgMemberFunctionSymbol::next_node);
  175139             : #endif
  175140             : 
  175141             : #if ROSE_PEDANTIC_ALLOC
  175142             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  175143             : #endif
  175144             : 
  175145             : #if ROSE_ALLOC_MEMSET == 1
  175146             : #elif ROSE_ALLOC_MEMSET == 2
  175147             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgMemberFunctionSymbol) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  175148             : #elif ROSE_ALLOC_MEMSET == 3
  175149             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgMemberFunctionSymbol) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  175150             : #endif
  175151             : 
  175152             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  175153             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  175154             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  175155             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  175156             : #else
  175157        3906 :     object->p_freepointer = SgMemberFunctionSymbol::next_node;
  175158        3906 :     SgMemberFunctionSymbol::next_node = object;
  175159             : #endif
  175160             : 
  175161             : #if ROSE_ALLOC_TRACE == 2
  175162             : //  printf("SgMemberFunctionSymbol::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgMemberFunctionSymbol::next_node);
  175163             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  175164             :     Rose::MemPool::snapshot(oss.str());
  175165             :     alloc_trace_cnt++;
  175166             : #endif
  175167             : 
  175168             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  175169             : 
  175170        3906 :     ALLOC_MUTEX(SgMemberFunctionSymbol, unlock);
  175171             : }
  175172             : 
  175173             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  175174             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  175175             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  175176             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  175177             : // Also, note comment below from Robb (copied from the Common.code file).
  175178             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  175179             : //
  175180             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  175181             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  175182             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  175183             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  175184             : #if 0
  175185             : void SgMemberFunctionSymbol::operator delete(void* pointer) { SgMemberFunctionSymbol::operator delete (pointer, sizeof(SgMemberFunctionSymbol)); };
  175186             : #endif
  175187             : /* #line 175188 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  175188             : 
  175189             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  175190             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  175191             : // obviously imply C++.
  175192             : 
  175193             : // This implements the support within ROSE for memory pools.  Memory pools
  175194             : // support the most condensed usage of memory within the construction of
  175195             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  175196             : // by a new operator written for each class.
  175197             : 
  175198             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  175199             :     // User wants multi-thread support and POSIX threads are available.
  175200             : #   include <pthread.h>
  175201             :     static pthread_mutex_t SgTemplateMemberFunctionSymbol_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  175202             : #else
  175203             :      // Cause synchronization to be skipped.
  175204             : #    ifndef ALLOC_MUTEX
  175205             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  175206             : #    endif
  175207             : #    ifdef _REENTRANT
  175208             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  175209             : #       ifdef _MSC_VER
  175210             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  175211             : #       else
  175212             : #           warning "POSIX threads are not available; synchronization being skipped"
  175213             : #       endif
  175214             : #    endif
  175215             : #endif
  175216             : 
  175217             : #ifndef ROSE_ALLOC_TRACE
  175218             : #  define ROSE_ALLOC_TRACE 0
  175219             : #endif
  175220             : 
  175221             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  175222             : #define ROSE_ALLOC_TRACE_CNT
  175223             : #include "memory-pool-snapshot.h"
  175224             : unsigned long alloc_trace_cnt = 0;
  175225             : #endif
  175226             : 
  175227             : #if ROSE_ALLOC_TRACE
  175228             : const unsigned SgTemplateMemberFunctionSymbol::pool_size = 5;
  175229             : #else
  175230             : const unsigned SgTemplateMemberFunctionSymbol::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  175231             : #endif
  175232             : 
  175233             : #ifndef ROSE_ALLOC_MEMSET
  175234             : #  define ROSE_ALLOC_MEMSET 0
  175235             : #endif
  175236             : 
  175237             : #ifndef ROSE_PEDANTIC_ALLOC
  175238             : #  define ROSE_PEDANTIC_ALLOC 0
  175239             : #endif
  175240             : 
  175241             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  175242             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  175243             : #endif
  175244             : 
  175245             : #if !defined(SGNODE__ALL_POOLS)
  175246             : #define SGNODE__ALL_POOLS
  175247             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  175248             : #endif
  175249             : 
  175250             : SgTemplateMemberFunctionSymbol* SgTemplateMemberFunctionSymbol::next_node = nullptr;
  175251             : std::vector<unsigned char*> SgTemplateMemberFunctionSymbol::pools;
  175252             : 
  175253             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  175254             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  175255             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  175256             : // around this macro definition rather than each use).
  175257             : #ifndef ALLOC_MUTEX
  175258             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  175259             :         do {                                                                     \
  175260             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  175261             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  175262             :                 abort();                                                         \
  175263             :             }                                                                    \
  175264             :         } while (0);
  175265             : #endif
  175266             : 
  175267             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  175268             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  175269             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  175270             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  175271             : 
  175272             : /*! \brief New operator for SgTemplateMemberFunctionSymbol.
  175273             : 
  175274             :    This new operator implements memory pools to provide most efficent 
  175275             :    use of the heap within construction of large ASTs.
  175276             : 
  175277             : \internal The new and delete operators use the lower level C malloc/free
  175278             :    function calls for performance and to make sure that mixing of malloc/free
  175279             :    and new/delete by the used can be caught more readily.  This may change
  175280             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  175281             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  175282             :    deallocate memory allocated using ROSE_MALLOC.
  175283             : */
  175284       10877 : void *SgTemplateMemberFunctionSymbol::operator new ( size_t Size )
  175285             : {
  175286             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  175287             :      * returning or throwing an exception. */
  175288       10877 :     ALLOC_MUTEX(SgTemplateMemberFunctionSymbol, lock);
  175289             : 
  175290             : #if ROSE_ALLOC_TRACE == 2
  175291             : //    printf("SgTemplateMemberFunctionSymbol::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgTemplateMemberFunctionSymbol::next_node);
  175292             : #endif
  175293             : 
  175294             : #if USE_CPP_NEW_DELETE_OPERATORS
  175295             :     void *mem = ROSE_MALLOC(Size);
  175296             :     ALLOC_MUTEX(SgTemplateMemberFunctionSymbol, unlock);
  175297             :     return mem;
  175298             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  175299             : #if ROSE_PEDANTIC_ALLOC
  175300             :     ROSE_ASSERT(Size == sizeof(SgTemplateMemberFunctionSymbol));
  175301             : #else
  175302       10877 :     if (Size != sizeof(SgTemplateMemberFunctionSymbol)) {
  175303           0 :       void * object = ROSE_MALLOC(Size);
  175304           0 :       ALLOC_MUTEX(SgTemplateMemberFunctionSymbol, unlock);
  175305             :       return object;
  175306             :     }
  175307             : #endif
  175308             : 
  175309       10877 :     if (SgTemplateMemberFunctionSymbol::next_node == nullptr) {
  175310          11 :         SgTemplateMemberFunctionSymbol * alloc = (SgTemplateMemberFunctionSymbol*) ROSE_MALLOC ( SgTemplateMemberFunctionSymbol::pool_size * sizeof(SgTemplateMemberFunctionSymbol) );
  175311          11 :         ROSE_ASSERT(alloc != nullptr);
  175312             : 
  175313             : #if ROSE_ALLOC_TRACE == 2
  175314             : //        printf("SgTemplateMemberFunctionSymbol::alloc\n  block[%zi] = [ %p , %p [\n", SgTemplateMemberFunctionSymbol::pools.size(), alloc, alloc + SgTemplateMemberFunctionSymbol::pool_size);
  175315             : #endif
  175316             : 
  175317             : #if ROSE_ALLOC_MEMSET == 1
  175318             : #elif ROSE_ALLOC_MEMSET == 2
  175319             :         memset(alloc, 0x00, SgTemplateMemberFunctionSymbol::pool_size * sizeof(SgTemplateMemberFunctionSymbol));
  175320             : #elif ROSE_ALLOC_MEMSET == 3
  175321             :         memset(alloc, 0xAA, SgTemplateMemberFunctionSymbol::pool_size * sizeof(SgTemplateMemberFunctionSymbol));
  175322             : #endif
  175323       22000 :         for (unsigned i=0; i < SgTemplateMemberFunctionSymbol::pool_size-1; i++) {
  175324       21989 :           alloc[i].p_freepointer = &(alloc[i+1]);
  175325             :         }
  175326          11 :         alloc[SgTemplateMemberFunctionSymbol::pool_size-1].p_freepointer = nullptr;
  175327             : 
  175328          11 :         SgTemplateMemberFunctionSymbol::pools.push_back ( (unsigned char *) alloc );
  175329          11 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgTemplateMemberFunctionSymbol::pool_size * sizeof(SgTemplateMemberFunctionSymbol), V_SgTemplateMemberFunctionSymbol ) );
  175330          11 :         SgTemplateMemberFunctionSymbol::next_node = alloc;
  175331             :     }
  175332       10877 :     ROSE_ASSERT(SgTemplateMemberFunctionSymbol::next_node != nullptr);
  175333             : 
  175334       10877 :     SgTemplateMemberFunctionSymbol * object = SgTemplateMemberFunctionSymbol::next_node;
  175335       10877 :     SgTemplateMemberFunctionSymbol::next_node = (SgTemplateMemberFunctionSymbol*)(object->p_freepointer);
  175336             : 
  175337             : #if ROSE_ALLOC_TRACE == 2
  175338             :     printf("SgTemplateMemberFunctionSymbol::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTemplateMemberFunctionSymbol::next_node);
  175339             : #endif
  175340             : 
  175341       10877 :     SgNode * fp = object->p_freepointer;
  175342             : #if ROSE_ALLOC_MEMSET == 1
  175343             : #elif ROSE_ALLOC_MEMSET == 2
  175344             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgTemplateMemberFunctionSymbol) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  175345             : #elif ROSE_ALLOC_MEMSET == 3
  175346             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgTemplateMemberFunctionSymbol) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  175347             : #endif
  175348       10877 :     object->p_freepointer = fp;
  175349             : 
  175350             : #if ROSE_ALLOC_TRACE == 2
  175351             : //    printf("SgTemplateMemberFunctionSymbol::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTemplateMemberFunctionSymbol::next_node);
  175352             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  175353             :     Rose::MemPool::snapshot(oss.str());
  175354             :     alloc_trace_cnt++;
  175355             : #endif
  175356             : 
  175357       10877 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  175358             : 
  175359       10877 :     ALLOC_MUTEX(SgTemplateMemberFunctionSymbol, unlock);
  175360             : 
  175361             :     return object;
  175362             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  175363             : }
  175364             : 
  175365             : 
  175366             : 
  175367             : /*! \brief Delete operator for SgTemplateMemberFunctionSymbol.
  175368             : 
  175369             :    This delete operator implements deallocation using memory pools to 
  175370             :    provide most efficent use of the heap within construction of large ASTs.
  175371             : 
  175372             : \internal The new and delete operators use the lower level C malloc/free
  175373             :    function calls for performance and to make sure that mixing of malloc/free
  175374             :    and new/delete by the used can be caught more readily.  This may change
  175375             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  175376             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  175377             :    deallocate memory allocated using ROSE_MALLOC.
  175378             : */
  175379        2094 : void SgTemplateMemberFunctionSymbol::operator delete(void *Pointer, size_t Size)
  175380             : {
  175381             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  175382             :      * or throwing an exception. */
  175383        2094 :     ALLOC_MUTEX(SgTemplateMemberFunctionSymbol, lock);
  175384             : 
  175385             : #if USE_CPP_NEW_DELETE_OPERATORS
  175386             :     ROSE_FREE(Pointer);
  175387             : #else
  175388             : #if ROSE_PEDANTIC_ALLOC
  175389             :     ROSE_ASSERT(Size == sizeof(SgTemplateMemberFunctionSymbol));
  175390             : #else
  175391        2094 :     if (Size != sizeof(SgTemplateMemberFunctionSymbol)) {
  175392           0 :       ROSE_FREE(Pointer);
  175393           0 :       ALLOC_MUTEX(SgTemplateMemberFunctionSymbol, unlock);
  175394             :       return;
  175395             :     }
  175396             : #endif
  175397             : 
  175398        2094 :     SgTemplateMemberFunctionSymbol * object = (SgTemplateMemberFunctionSymbol*) Pointer;
  175399        2094 :     ROSE_ASSERT(object != nullptr);
  175400             : 
  175401             : #if ROSE_ALLOC_TRACE == 2
  175402             : //  printf("SgTemplateMemberFunctionSymbol::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTemplateMemberFunctionSymbol::next_node);
  175403             :     printf("SgTemplateMemberFunctionSymbol::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTemplateMemberFunctionSymbol::next_node);
  175404             : #endif
  175405             : 
  175406             : #if ROSE_PEDANTIC_ALLOC
  175407             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  175408             : #endif
  175409             : 
  175410             : #if ROSE_ALLOC_MEMSET == 1
  175411             : #elif ROSE_ALLOC_MEMSET == 2
  175412             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgTemplateMemberFunctionSymbol) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  175413             : #elif ROSE_ALLOC_MEMSET == 3
  175414             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgTemplateMemberFunctionSymbol) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  175415             : #endif
  175416             : 
  175417             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  175418             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  175419             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  175420             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  175421             : #else
  175422        2094 :     object->p_freepointer = SgTemplateMemberFunctionSymbol::next_node;
  175423        2094 :     SgTemplateMemberFunctionSymbol::next_node = object;
  175424             : #endif
  175425             : 
  175426             : #if ROSE_ALLOC_TRACE == 2
  175427             : //  printf("SgTemplateMemberFunctionSymbol::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTemplateMemberFunctionSymbol::next_node);
  175428             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  175429             :     Rose::MemPool::snapshot(oss.str());
  175430             :     alloc_trace_cnt++;
  175431             : #endif
  175432             : 
  175433             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  175434             : 
  175435        2094 :     ALLOC_MUTEX(SgTemplateMemberFunctionSymbol, unlock);
  175436             : }
  175437             : 
  175438             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  175439             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  175440             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  175441             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  175442             : // Also, note comment below from Robb (copied from the Common.code file).
  175443             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  175444             : //
  175445             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  175446             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  175447             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  175448             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  175449             : #if 0
  175450             : void SgTemplateMemberFunctionSymbol::operator delete(void* pointer) { SgTemplateMemberFunctionSymbol::operator delete (pointer, sizeof(SgTemplateMemberFunctionSymbol)); };
  175451             : #endif
  175452             : /* #line 175453 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  175453             : 
  175454             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  175455             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  175456             : // obviously imply C++.
  175457             : 
  175458             : // This implements the support within ROSE for memory pools.  Memory pools
  175459             : // support the most condensed usage of memory within the construction of
  175460             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  175461             : // by a new operator written for each class.
  175462             : 
  175463             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  175464             :     // User wants multi-thread support and POSIX threads are available.
  175465             : #   include <pthread.h>
  175466             :     static pthread_mutex_t SgTemplateFunctionSymbol_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  175467             : #else
  175468             :      // Cause synchronization to be skipped.
  175469             : #    ifndef ALLOC_MUTEX
  175470             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  175471             : #    endif
  175472             : #    ifdef _REENTRANT
  175473             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  175474             : #       ifdef _MSC_VER
  175475             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  175476             : #       else
  175477             : #           warning "POSIX threads are not available; synchronization being skipped"
  175478             : #       endif
  175479             : #    endif
  175480             : #endif
  175481             : 
  175482             : #ifndef ROSE_ALLOC_TRACE
  175483             : #  define ROSE_ALLOC_TRACE 0
  175484             : #endif
  175485             : 
  175486             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  175487             : #define ROSE_ALLOC_TRACE_CNT
  175488             : #include "memory-pool-snapshot.h"
  175489             : unsigned long alloc_trace_cnt = 0;
  175490             : #endif
  175491             : 
  175492             : #if ROSE_ALLOC_TRACE
  175493             : const unsigned SgTemplateFunctionSymbol::pool_size = 5;
  175494             : #else
  175495             : const unsigned SgTemplateFunctionSymbol::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  175496             : #endif
  175497             : 
  175498             : #ifndef ROSE_ALLOC_MEMSET
  175499             : #  define ROSE_ALLOC_MEMSET 0
  175500             : #endif
  175501             : 
  175502             : #ifndef ROSE_PEDANTIC_ALLOC
  175503             : #  define ROSE_PEDANTIC_ALLOC 0
  175504             : #endif
  175505             : 
  175506             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  175507             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  175508             : #endif
  175509             : 
  175510             : #if !defined(SGNODE__ALL_POOLS)
  175511             : #define SGNODE__ALL_POOLS
  175512             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  175513             : #endif
  175514             : 
  175515             : SgTemplateFunctionSymbol* SgTemplateFunctionSymbol::next_node = nullptr;
  175516             : std::vector<unsigned char*> SgTemplateFunctionSymbol::pools;
  175517             : 
  175518             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  175519             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  175520             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  175521             : // around this macro definition rather than each use).
  175522             : #ifndef ALLOC_MUTEX
  175523             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  175524             :         do {                                                                     \
  175525             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  175526             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  175527             :                 abort();                                                         \
  175528             :             }                                                                    \
  175529             :         } while (0);
  175530             : #endif
  175531             : 
  175532             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  175533             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  175534             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  175535             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  175536             : 
  175537             : /*! \brief New operator for SgTemplateFunctionSymbol.
  175538             : 
  175539             :    This new operator implements memory pools to provide most efficent 
  175540             :    use of the heap within construction of large ASTs.
  175541             : 
  175542             : \internal The new and delete operators use the lower level C malloc/free
  175543             :    function calls for performance and to make sure that mixing of malloc/free
  175544             :    and new/delete by the used can be caught more readily.  This may change
  175545             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  175546             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  175547             :    deallocate memory allocated using ROSE_MALLOC.
  175548             : */
  175549        3763 : void *SgTemplateFunctionSymbol::operator new ( size_t Size )
  175550             : {
  175551             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  175552             :      * returning or throwing an exception. */
  175553        3763 :     ALLOC_MUTEX(SgTemplateFunctionSymbol, lock);
  175554             : 
  175555             : #if ROSE_ALLOC_TRACE == 2
  175556             : //    printf("SgTemplateFunctionSymbol::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgTemplateFunctionSymbol::next_node);
  175557             : #endif
  175558             : 
  175559             : #if USE_CPP_NEW_DELETE_OPERATORS
  175560             :     void *mem = ROSE_MALLOC(Size);
  175561             :     ALLOC_MUTEX(SgTemplateFunctionSymbol, unlock);
  175562             :     return mem;
  175563             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  175564             : #if ROSE_PEDANTIC_ALLOC
  175565             :     ROSE_ASSERT(Size == sizeof(SgTemplateFunctionSymbol));
  175566             : #else
  175567        3763 :     if (Size != sizeof(SgTemplateFunctionSymbol)) {
  175568           0 :       void * object = ROSE_MALLOC(Size);
  175569           0 :       ALLOC_MUTEX(SgTemplateFunctionSymbol, unlock);
  175570             :       return object;
  175571             :     }
  175572             : #endif
  175573             : 
  175574        3763 :     if (SgTemplateFunctionSymbol::next_node == nullptr) {
  175575          10 :         SgTemplateFunctionSymbol * alloc = (SgTemplateFunctionSymbol*) ROSE_MALLOC ( SgTemplateFunctionSymbol::pool_size * sizeof(SgTemplateFunctionSymbol) );
  175576          10 :         ROSE_ASSERT(alloc != nullptr);
  175577             : 
  175578             : #if ROSE_ALLOC_TRACE == 2
  175579             : //        printf("SgTemplateFunctionSymbol::alloc\n  block[%zi] = [ %p , %p [\n", SgTemplateFunctionSymbol::pools.size(), alloc, alloc + SgTemplateFunctionSymbol::pool_size);
  175580             : #endif
  175581             : 
  175582             : #if ROSE_ALLOC_MEMSET == 1
  175583             : #elif ROSE_ALLOC_MEMSET == 2
  175584             :         memset(alloc, 0x00, SgTemplateFunctionSymbol::pool_size * sizeof(SgTemplateFunctionSymbol));
  175585             : #elif ROSE_ALLOC_MEMSET == 3
  175586             :         memset(alloc, 0xAA, SgTemplateFunctionSymbol::pool_size * sizeof(SgTemplateFunctionSymbol));
  175587             : #endif
  175588       20000 :         for (unsigned i=0; i < SgTemplateFunctionSymbol::pool_size-1; i++) {
  175589       19990 :           alloc[i].p_freepointer = &(alloc[i+1]);
  175590             :         }
  175591          10 :         alloc[SgTemplateFunctionSymbol::pool_size-1].p_freepointer = nullptr;
  175592             : 
  175593          10 :         SgTemplateFunctionSymbol::pools.push_back ( (unsigned char *) alloc );
  175594          10 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgTemplateFunctionSymbol::pool_size * sizeof(SgTemplateFunctionSymbol), V_SgTemplateFunctionSymbol ) );
  175595          10 :         SgTemplateFunctionSymbol::next_node = alloc;
  175596             :     }
  175597        3763 :     ROSE_ASSERT(SgTemplateFunctionSymbol::next_node != nullptr);
  175598             : 
  175599        3763 :     SgTemplateFunctionSymbol * object = SgTemplateFunctionSymbol::next_node;
  175600        3763 :     SgTemplateFunctionSymbol::next_node = (SgTemplateFunctionSymbol*)(object->p_freepointer);
  175601             : 
  175602             : #if ROSE_ALLOC_TRACE == 2
  175603             :     printf("SgTemplateFunctionSymbol::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTemplateFunctionSymbol::next_node);
  175604             : #endif
  175605             : 
  175606        3763 :     SgNode * fp = object->p_freepointer;
  175607             : #if ROSE_ALLOC_MEMSET == 1
  175608             : #elif ROSE_ALLOC_MEMSET == 2
  175609             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgTemplateFunctionSymbol) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  175610             : #elif ROSE_ALLOC_MEMSET == 3
  175611             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgTemplateFunctionSymbol) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  175612             : #endif
  175613        3763 :     object->p_freepointer = fp;
  175614             : 
  175615             : #if ROSE_ALLOC_TRACE == 2
  175616             : //    printf("SgTemplateFunctionSymbol::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTemplateFunctionSymbol::next_node);
  175617             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  175618             :     Rose::MemPool::snapshot(oss.str());
  175619             :     alloc_trace_cnt++;
  175620             : #endif
  175621             : 
  175622        3763 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  175623             : 
  175624        3763 :     ALLOC_MUTEX(SgTemplateFunctionSymbol, unlock);
  175625             : 
  175626             :     return object;
  175627             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  175628             : }
  175629             : 
  175630             : 
  175631             : 
  175632             : /*! \brief Delete operator for SgTemplateFunctionSymbol.
  175633             : 
  175634             :    This delete operator implements deallocation using memory pools to 
  175635             :    provide most efficent use of the heap within construction of large ASTs.
  175636             : 
  175637             : \internal The new and delete operators use the lower level C malloc/free
  175638             :    function calls for performance and to make sure that mixing of malloc/free
  175639             :    and new/delete by the used can be caught more readily.  This may change
  175640             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  175641             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  175642             :    deallocate memory allocated using ROSE_MALLOC.
  175643             : */
  175644         680 : void SgTemplateFunctionSymbol::operator delete(void *Pointer, size_t Size)
  175645             : {
  175646             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  175647             :      * or throwing an exception. */
  175648         680 :     ALLOC_MUTEX(SgTemplateFunctionSymbol, lock);
  175649             : 
  175650             : #if USE_CPP_NEW_DELETE_OPERATORS
  175651             :     ROSE_FREE(Pointer);
  175652             : #else
  175653             : #if ROSE_PEDANTIC_ALLOC
  175654             :     ROSE_ASSERT(Size == sizeof(SgTemplateFunctionSymbol));
  175655             : #else
  175656         680 :     if (Size != sizeof(SgTemplateFunctionSymbol)) {
  175657           0 :       ROSE_FREE(Pointer);
  175658           0 :       ALLOC_MUTEX(SgTemplateFunctionSymbol, unlock);
  175659             :       return;
  175660             :     }
  175661             : #endif
  175662             : 
  175663         680 :     SgTemplateFunctionSymbol * object = (SgTemplateFunctionSymbol*) Pointer;
  175664         680 :     ROSE_ASSERT(object != nullptr);
  175665             : 
  175666             : #if ROSE_ALLOC_TRACE == 2
  175667             : //  printf("SgTemplateFunctionSymbol::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTemplateFunctionSymbol::next_node);
  175668             :     printf("SgTemplateFunctionSymbol::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTemplateFunctionSymbol::next_node);
  175669             : #endif
  175670             : 
  175671             : #if ROSE_PEDANTIC_ALLOC
  175672             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  175673             : #endif
  175674             : 
  175675             : #if ROSE_ALLOC_MEMSET == 1
  175676             : #elif ROSE_ALLOC_MEMSET == 2
  175677             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgTemplateFunctionSymbol) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  175678             : #elif ROSE_ALLOC_MEMSET == 3
  175679             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgTemplateFunctionSymbol) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  175680             : #endif
  175681             : 
  175682             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  175683             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  175684             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  175685             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  175686             : #else
  175687         680 :     object->p_freepointer = SgTemplateFunctionSymbol::next_node;
  175688         680 :     SgTemplateFunctionSymbol::next_node = object;
  175689             : #endif
  175690             : 
  175691             : #if ROSE_ALLOC_TRACE == 2
  175692             : //  printf("SgTemplateFunctionSymbol::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTemplateFunctionSymbol::next_node);
  175693             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  175694             :     Rose::MemPool::snapshot(oss.str());
  175695             :     alloc_trace_cnt++;
  175696             : #endif
  175697             : 
  175698             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  175699             : 
  175700         680 :     ALLOC_MUTEX(SgTemplateFunctionSymbol, unlock);
  175701             : }
  175702             : 
  175703             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  175704             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  175705             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  175706             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  175707             : // Also, note comment below from Robb (copied from the Common.code file).
  175708             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  175709             : //
  175710             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  175711             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  175712             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  175713             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  175714             : #if 0
  175715             : void SgTemplateFunctionSymbol::operator delete(void* pointer) { SgTemplateFunctionSymbol::operator delete (pointer, sizeof(SgTemplateFunctionSymbol)); };
  175716             : #endif
  175717             : /* #line 175718 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  175718             : 
  175719             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  175720             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  175721             : // obviously imply C++.
  175722             : 
  175723             : // This implements the support within ROSE for memory pools.  Memory pools
  175724             : // support the most condensed usage of memory within the construction of
  175725             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  175726             : // by a new operator written for each class.
  175727             : 
  175728             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  175729             :     // User wants multi-thread support and POSIX threads are available.
  175730             : #   include <pthread.h>
  175731             :     static pthread_mutex_t SgRenameSymbol_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  175732             : #else
  175733             :      // Cause synchronization to be skipped.
  175734             : #    ifndef ALLOC_MUTEX
  175735             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  175736             : #    endif
  175737             : #    ifdef _REENTRANT
  175738             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  175739             : #       ifdef _MSC_VER
  175740             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  175741             : #       else
  175742             : #           warning "POSIX threads are not available; synchronization being skipped"
  175743             : #       endif
  175744             : #    endif
  175745             : #endif
  175746             : 
  175747             : #ifndef ROSE_ALLOC_TRACE
  175748             : #  define ROSE_ALLOC_TRACE 0
  175749             : #endif
  175750             : 
  175751             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  175752             : #define ROSE_ALLOC_TRACE_CNT
  175753             : #include "memory-pool-snapshot.h"
  175754             : unsigned long alloc_trace_cnt = 0;
  175755             : #endif
  175756             : 
  175757             : #if ROSE_ALLOC_TRACE
  175758             : const unsigned SgRenameSymbol::pool_size = 5;
  175759             : #else
  175760             : const unsigned SgRenameSymbol::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  175761             : #endif
  175762             : 
  175763             : #ifndef ROSE_ALLOC_MEMSET
  175764             : #  define ROSE_ALLOC_MEMSET 0
  175765             : #endif
  175766             : 
  175767             : #ifndef ROSE_PEDANTIC_ALLOC
  175768             : #  define ROSE_PEDANTIC_ALLOC 0
  175769             : #endif
  175770             : 
  175771             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  175772             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  175773             : #endif
  175774             : 
  175775             : #if !defined(SGNODE__ALL_POOLS)
  175776             : #define SGNODE__ALL_POOLS
  175777             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  175778             : #endif
  175779             : 
  175780             : SgRenameSymbol* SgRenameSymbol::next_node = nullptr;
  175781             : std::vector<unsigned char*> SgRenameSymbol::pools;
  175782             : 
  175783             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  175784             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  175785             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  175786             : // around this macro definition rather than each use).
  175787             : #ifndef ALLOC_MUTEX
  175788             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  175789             :         do {                                                                     \
  175790             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  175791             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  175792             :                 abort();                                                         \
  175793             :             }                                                                    \
  175794             :         } while (0);
  175795             : #endif
  175796             : 
  175797             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  175798             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  175799             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  175800             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  175801             : 
  175802             : /*! \brief New operator for SgRenameSymbol.
  175803             : 
  175804             :    This new operator implements memory pools to provide most efficent 
  175805             :    use of the heap within construction of large ASTs.
  175806             : 
  175807             : \internal The new and delete operators use the lower level C malloc/free
  175808             :    function calls for performance and to make sure that mixing of malloc/free
  175809             :    and new/delete by the used can be caught more readily.  This may change
  175810             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  175811             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  175812             :    deallocate memory allocated using ROSE_MALLOC.
  175813             : */
  175814           0 : void *SgRenameSymbol::operator new ( size_t Size )
  175815             : {
  175816             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  175817             :      * returning or throwing an exception. */
  175818           0 :     ALLOC_MUTEX(SgRenameSymbol, lock);
  175819             : 
  175820             : #if ROSE_ALLOC_TRACE == 2
  175821             : //    printf("SgRenameSymbol::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgRenameSymbol::next_node);
  175822             : #endif
  175823             : 
  175824             : #if USE_CPP_NEW_DELETE_OPERATORS
  175825             :     void *mem = ROSE_MALLOC(Size);
  175826             :     ALLOC_MUTEX(SgRenameSymbol, unlock);
  175827             :     return mem;
  175828             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  175829             : #if ROSE_PEDANTIC_ALLOC
  175830             :     ROSE_ASSERT(Size == sizeof(SgRenameSymbol));
  175831             : #else
  175832           0 :     if (Size != sizeof(SgRenameSymbol)) {
  175833           0 :       void * object = ROSE_MALLOC(Size);
  175834           0 :       ALLOC_MUTEX(SgRenameSymbol, unlock);
  175835             :       return object;
  175836             :     }
  175837             : #endif
  175838             : 
  175839           0 :     if (SgRenameSymbol::next_node == nullptr) {
  175840           0 :         SgRenameSymbol * alloc = (SgRenameSymbol*) ROSE_MALLOC ( SgRenameSymbol::pool_size * sizeof(SgRenameSymbol) );
  175841           0 :         ROSE_ASSERT(alloc != nullptr);
  175842             : 
  175843             : #if ROSE_ALLOC_TRACE == 2
  175844             : //        printf("SgRenameSymbol::alloc\n  block[%zi] = [ %p , %p [\n", SgRenameSymbol::pools.size(), alloc, alloc + SgRenameSymbol::pool_size);
  175845             : #endif
  175846             : 
  175847             : #if ROSE_ALLOC_MEMSET == 1
  175848             : #elif ROSE_ALLOC_MEMSET == 2
  175849             :         memset(alloc, 0x00, SgRenameSymbol::pool_size * sizeof(SgRenameSymbol));
  175850             : #elif ROSE_ALLOC_MEMSET == 3
  175851             :         memset(alloc, 0xAA, SgRenameSymbol::pool_size * sizeof(SgRenameSymbol));
  175852             : #endif
  175853           0 :         for (unsigned i=0; i < SgRenameSymbol::pool_size-1; i++) {
  175854           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
  175855             :         }
  175856           0 :         alloc[SgRenameSymbol::pool_size-1].p_freepointer = nullptr;
  175857             : 
  175858           0 :         SgRenameSymbol::pools.push_back ( (unsigned char *) alloc );
  175859           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgRenameSymbol::pool_size * sizeof(SgRenameSymbol), V_SgRenameSymbol ) );
  175860           0 :         SgRenameSymbol::next_node = alloc;
  175861             :     }
  175862           0 :     ROSE_ASSERT(SgRenameSymbol::next_node != nullptr);
  175863             : 
  175864           0 :     SgRenameSymbol * object = SgRenameSymbol::next_node;
  175865           0 :     SgRenameSymbol::next_node = (SgRenameSymbol*)(object->p_freepointer);
  175866             : 
  175867             : #if ROSE_ALLOC_TRACE == 2
  175868             :     printf("SgRenameSymbol::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgRenameSymbol::next_node);
  175869             : #endif
  175870             : 
  175871           0 :     SgNode * fp = object->p_freepointer;
  175872             : #if ROSE_ALLOC_MEMSET == 1
  175873             : #elif ROSE_ALLOC_MEMSET == 2
  175874             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgRenameSymbol) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  175875             : #elif ROSE_ALLOC_MEMSET == 3
  175876             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgRenameSymbol) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  175877             : #endif
  175878           0 :     object->p_freepointer = fp;
  175879             : 
  175880             : #if ROSE_ALLOC_TRACE == 2
  175881             : //    printf("SgRenameSymbol::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgRenameSymbol::next_node);
  175882             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  175883             :     Rose::MemPool::snapshot(oss.str());
  175884             :     alloc_trace_cnt++;
  175885             : #endif
  175886             : 
  175887           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  175888             : 
  175889           0 :     ALLOC_MUTEX(SgRenameSymbol, unlock);
  175890             : 
  175891             :     return object;
  175892             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  175893             : }
  175894             : 
  175895             : 
  175896             : 
  175897             : /*! \brief Delete operator for SgRenameSymbol.
  175898             : 
  175899             :    This delete operator implements deallocation using memory pools to 
  175900             :    provide most efficent use of the heap within construction of large ASTs.
  175901             : 
  175902             : \internal The new and delete operators use the lower level C malloc/free
  175903             :    function calls for performance and to make sure that mixing of malloc/free
  175904             :    and new/delete by the used can be caught more readily.  This may change
  175905             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  175906             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  175907             :    deallocate memory allocated using ROSE_MALLOC.
  175908             : */
  175909           0 : void SgRenameSymbol::operator delete(void *Pointer, size_t Size)
  175910             : {
  175911             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  175912             :      * or throwing an exception. */
  175913           0 :     ALLOC_MUTEX(SgRenameSymbol, lock);
  175914             : 
  175915             : #if USE_CPP_NEW_DELETE_OPERATORS
  175916             :     ROSE_FREE(Pointer);
  175917             : #else
  175918             : #if ROSE_PEDANTIC_ALLOC
  175919             :     ROSE_ASSERT(Size == sizeof(SgRenameSymbol));
  175920             : #else
  175921           0 :     if (Size != sizeof(SgRenameSymbol)) {
  175922           0 :       ROSE_FREE(Pointer);
  175923           0 :       ALLOC_MUTEX(SgRenameSymbol, unlock);
  175924             :       return;
  175925             :     }
  175926             : #endif
  175927             : 
  175928           0 :     SgRenameSymbol * object = (SgRenameSymbol*) Pointer;
  175929           0 :     ROSE_ASSERT(object != nullptr);
  175930             : 
  175931             : #if ROSE_ALLOC_TRACE == 2
  175932             : //  printf("SgRenameSymbol::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgRenameSymbol::next_node);
  175933             :     printf("SgRenameSymbol::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgRenameSymbol::next_node);
  175934             : #endif
  175935             : 
  175936             : #if ROSE_PEDANTIC_ALLOC
  175937             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  175938             : #endif
  175939             : 
  175940             : #if ROSE_ALLOC_MEMSET == 1
  175941             : #elif ROSE_ALLOC_MEMSET == 2
  175942             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgRenameSymbol) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  175943             : #elif ROSE_ALLOC_MEMSET == 3
  175944             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgRenameSymbol) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  175945             : #endif
  175946             : 
  175947             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  175948             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  175949             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  175950             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  175951             : #else
  175952           0 :     object->p_freepointer = SgRenameSymbol::next_node;
  175953           0 :     SgRenameSymbol::next_node = object;
  175954             : #endif
  175955             : 
  175956             : #if ROSE_ALLOC_TRACE == 2
  175957             : //  printf("SgRenameSymbol::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgRenameSymbol::next_node);
  175958             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  175959             :     Rose::MemPool::snapshot(oss.str());
  175960             :     alloc_trace_cnt++;
  175961             : #endif
  175962             : 
  175963             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  175964             : 
  175965           0 :     ALLOC_MUTEX(SgRenameSymbol, unlock);
  175966             : }
  175967             : 
  175968             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  175969             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  175970             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  175971             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  175972             : // Also, note comment below from Robb (copied from the Common.code file).
  175973             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  175974             : //
  175975             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  175976             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  175977             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  175978             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  175979             : #if 0
  175980             : void SgRenameSymbol::operator delete(void* pointer) { SgRenameSymbol::operator delete (pointer, sizeof(SgRenameSymbol)); };
  175981             : #endif
  175982             : /* #line 175983 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  175983             : 
  175984             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  175985             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  175986             : // obviously imply C++.
  175987             : 
  175988             : // This implements the support within ROSE for memory pools.  Memory pools
  175989             : // support the most condensed usage of memory within the construction of
  175990             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  175991             : // by a new operator written for each class.
  175992             : 
  175993             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  175994             :     // User wants multi-thread support and POSIX threads are available.
  175995             : #   include <pthread.h>
  175996             :     static pthread_mutex_t SgFunctionTypeSymbol_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  175997             : #else
  175998             :      // Cause synchronization to be skipped.
  175999             : #    ifndef ALLOC_MUTEX
  176000             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  176001             : #    endif
  176002             : #    ifdef _REENTRANT
  176003             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  176004             : #       ifdef _MSC_VER
  176005             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  176006             : #       else
  176007             : #           warning "POSIX threads are not available; synchronization being skipped"
  176008             : #       endif
  176009             : #    endif
  176010             : #endif
  176011             : 
  176012             : #ifndef ROSE_ALLOC_TRACE
  176013             : #  define ROSE_ALLOC_TRACE 0
  176014             : #endif
  176015             : 
  176016             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  176017             : #define ROSE_ALLOC_TRACE_CNT
  176018             : #include "memory-pool-snapshot.h"
  176019             : unsigned long alloc_trace_cnt = 0;
  176020             : #endif
  176021             : 
  176022             : #if ROSE_ALLOC_TRACE
  176023             : const unsigned SgFunctionTypeSymbol::pool_size = 5;
  176024             : #else
  176025             : const unsigned SgFunctionTypeSymbol::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  176026             : #endif
  176027             : 
  176028             : #ifndef ROSE_ALLOC_MEMSET
  176029             : #  define ROSE_ALLOC_MEMSET 0
  176030             : #endif
  176031             : 
  176032             : #ifndef ROSE_PEDANTIC_ALLOC
  176033             : #  define ROSE_PEDANTIC_ALLOC 0
  176034             : #endif
  176035             : 
  176036             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  176037             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  176038             : #endif
  176039             : 
  176040             : #if !defined(SGNODE__ALL_POOLS)
  176041             : #define SGNODE__ALL_POOLS
  176042             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  176043             : #endif
  176044             : 
  176045             : SgFunctionTypeSymbol* SgFunctionTypeSymbol::next_node = nullptr;
  176046             : std::vector<unsigned char*> SgFunctionTypeSymbol::pools;
  176047             : 
  176048             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  176049             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  176050             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  176051             : // around this macro definition rather than each use).
  176052             : #ifndef ALLOC_MUTEX
  176053             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  176054             :         do {                                                                     \
  176055             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  176056             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  176057             :                 abort();                                                         \
  176058             :             }                                                                    \
  176059             :         } while (0);
  176060             : #endif
  176061             : 
  176062             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  176063             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  176064             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  176065             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  176066             : 
  176067             : /*! \brief New operator for SgFunctionTypeSymbol.
  176068             : 
  176069             :    This new operator implements memory pools to provide most efficent 
  176070             :    use of the heap within construction of large ASTs.
  176071             : 
  176072             : \internal The new and delete operators use the lower level C malloc/free
  176073             :    function calls for performance and to make sure that mixing of malloc/free
  176074             :    and new/delete by the used can be caught more readily.  This may change
  176075             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  176076             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  176077             :    deallocate memory allocated using ROSE_MALLOC.
  176078             : */
  176079      363788 : void *SgFunctionTypeSymbol::operator new ( size_t Size )
  176080             : {
  176081             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  176082             :      * returning or throwing an exception. */
  176083      363788 :     ALLOC_MUTEX(SgFunctionTypeSymbol, lock);
  176084             : 
  176085             : #if ROSE_ALLOC_TRACE == 2
  176086             : //    printf("SgFunctionTypeSymbol::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgFunctionTypeSymbol::next_node);
  176087             : #endif
  176088             : 
  176089             : #if USE_CPP_NEW_DELETE_OPERATORS
  176090             :     void *mem = ROSE_MALLOC(Size);
  176091             :     ALLOC_MUTEX(SgFunctionTypeSymbol, unlock);
  176092             :     return mem;
  176093             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  176094             : #if ROSE_PEDANTIC_ALLOC
  176095             :     ROSE_ASSERT(Size == sizeof(SgFunctionTypeSymbol));
  176096             : #else
  176097      363788 :     if (Size != sizeof(SgFunctionTypeSymbol)) {
  176098           0 :       void * object = ROSE_MALLOC(Size);
  176099           0 :       ALLOC_MUTEX(SgFunctionTypeSymbol, unlock);
  176100             :       return object;
  176101             :     }
  176102             : #endif
  176103             : 
  176104      363788 :     if (SgFunctionTypeSymbol::next_node == nullptr) {
  176105         388 :         SgFunctionTypeSymbol * alloc = (SgFunctionTypeSymbol*) ROSE_MALLOC ( SgFunctionTypeSymbol::pool_size * sizeof(SgFunctionTypeSymbol) );
  176106         388 :         ROSE_ASSERT(alloc != nullptr);
  176107             : 
  176108             : #if ROSE_ALLOC_TRACE == 2
  176109             : //        printf("SgFunctionTypeSymbol::alloc\n  block[%zi] = [ %p , %p [\n", SgFunctionTypeSymbol::pools.size(), alloc, alloc + SgFunctionTypeSymbol::pool_size);
  176110             : #endif
  176111             : 
  176112             : #if ROSE_ALLOC_MEMSET == 1
  176113             : #elif ROSE_ALLOC_MEMSET == 2
  176114             :         memset(alloc, 0x00, SgFunctionTypeSymbol::pool_size * sizeof(SgFunctionTypeSymbol));
  176115             : #elif ROSE_ALLOC_MEMSET == 3
  176116             :         memset(alloc, 0xAA, SgFunctionTypeSymbol::pool_size * sizeof(SgFunctionTypeSymbol));
  176117             : #endif
  176118      776000 :         for (unsigned i=0; i < SgFunctionTypeSymbol::pool_size-1; i++) {
  176119      775612 :           alloc[i].p_freepointer = &(alloc[i+1]);
  176120             :         }
  176121         388 :         alloc[SgFunctionTypeSymbol::pool_size-1].p_freepointer = nullptr;
  176122             : 
  176123         388 :         SgFunctionTypeSymbol::pools.push_back ( (unsigned char *) alloc );
  176124         388 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgFunctionTypeSymbol::pool_size * sizeof(SgFunctionTypeSymbol), V_SgFunctionTypeSymbol ) );
  176125         388 :         SgFunctionTypeSymbol::next_node = alloc;
  176126             :     }
  176127      363788 :     ROSE_ASSERT(SgFunctionTypeSymbol::next_node != nullptr);
  176128             : 
  176129      363788 :     SgFunctionTypeSymbol * object = SgFunctionTypeSymbol::next_node;
  176130      363788 :     SgFunctionTypeSymbol::next_node = (SgFunctionTypeSymbol*)(object->p_freepointer);
  176131             : 
  176132             : #if ROSE_ALLOC_TRACE == 2
  176133             :     printf("SgFunctionTypeSymbol::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgFunctionTypeSymbol::next_node);
  176134             : #endif
  176135             : 
  176136      363788 :     SgNode * fp = object->p_freepointer;
  176137             : #if ROSE_ALLOC_MEMSET == 1
  176138             : #elif ROSE_ALLOC_MEMSET == 2
  176139             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgFunctionTypeSymbol) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  176140             : #elif ROSE_ALLOC_MEMSET == 3
  176141             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgFunctionTypeSymbol) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  176142             : #endif
  176143      363788 :     object->p_freepointer = fp;
  176144             : 
  176145             : #if ROSE_ALLOC_TRACE == 2
  176146             : //    printf("SgFunctionTypeSymbol::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgFunctionTypeSymbol::next_node);
  176147             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  176148             :     Rose::MemPool::snapshot(oss.str());
  176149             :     alloc_trace_cnt++;
  176150             : #endif
  176151             : 
  176152      363788 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  176153             : 
  176154      363788 :     ALLOC_MUTEX(SgFunctionTypeSymbol, unlock);
  176155             : 
  176156             :     return object;
  176157             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  176158             : }
  176159             : 
  176160             : 
  176161             : 
  176162             : /*! \brief Delete operator for SgFunctionTypeSymbol.
  176163             : 
  176164             :    This delete operator implements deallocation using memory pools to 
  176165             :    provide most efficent use of the heap within construction of large ASTs.
  176166             : 
  176167             : \internal The new and delete operators use the lower level C malloc/free
  176168             :    function calls for performance and to make sure that mixing of malloc/free
  176169             :    and new/delete by the used can be caught more readily.  This may change
  176170             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  176171             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  176172             :    deallocate memory allocated using ROSE_MALLOC.
  176173             : */
  176174       18364 : void SgFunctionTypeSymbol::operator delete(void *Pointer, size_t Size)
  176175             : {
  176176             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  176177             :      * or throwing an exception. */
  176178       18364 :     ALLOC_MUTEX(SgFunctionTypeSymbol, lock);
  176179             : 
  176180             : #if USE_CPP_NEW_DELETE_OPERATORS
  176181             :     ROSE_FREE(Pointer);
  176182             : #else
  176183             : #if ROSE_PEDANTIC_ALLOC
  176184             :     ROSE_ASSERT(Size == sizeof(SgFunctionTypeSymbol));
  176185             : #else
  176186       18364 :     if (Size != sizeof(SgFunctionTypeSymbol)) {
  176187           0 :       ROSE_FREE(Pointer);
  176188           0 :       ALLOC_MUTEX(SgFunctionTypeSymbol, unlock);
  176189             :       return;
  176190             :     }
  176191             : #endif
  176192             : 
  176193       18364 :     SgFunctionTypeSymbol * object = (SgFunctionTypeSymbol*) Pointer;
  176194       18364 :     ROSE_ASSERT(object != nullptr);
  176195             : 
  176196             : #if ROSE_ALLOC_TRACE == 2
  176197             : //  printf("SgFunctionTypeSymbol::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgFunctionTypeSymbol::next_node);
  176198             :     printf("SgFunctionTypeSymbol::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgFunctionTypeSymbol::next_node);
  176199             : #endif
  176200             : 
  176201             : #if ROSE_PEDANTIC_ALLOC
  176202             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  176203             : #endif
  176204             : 
  176205             : #if ROSE_ALLOC_MEMSET == 1
  176206             : #elif ROSE_ALLOC_MEMSET == 2
  176207             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgFunctionTypeSymbol) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  176208             : #elif ROSE_ALLOC_MEMSET == 3
  176209             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgFunctionTypeSymbol) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  176210             : #endif
  176211             : 
  176212             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  176213             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  176214             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  176215             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  176216             : #else
  176217       18364 :     object->p_freepointer = SgFunctionTypeSymbol::next_node;
  176218       18364 :     SgFunctionTypeSymbol::next_node = object;
  176219             : #endif
  176220             : 
  176221             : #if ROSE_ALLOC_TRACE == 2
  176222             : //  printf("SgFunctionTypeSymbol::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgFunctionTypeSymbol::next_node);
  176223             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  176224             :     Rose::MemPool::snapshot(oss.str());
  176225             :     alloc_trace_cnt++;
  176226             : #endif
  176227             : 
  176228             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  176229             : 
  176230       18364 :     ALLOC_MUTEX(SgFunctionTypeSymbol, unlock);
  176231             : }
  176232             : 
  176233             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  176234             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  176235             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  176236             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  176237             : // Also, note comment below from Robb (copied from the Common.code file).
  176238             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  176239             : //
  176240             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  176241             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  176242             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  176243             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  176244             : #if 0
  176245             : void SgFunctionTypeSymbol::operator delete(void* pointer) { SgFunctionTypeSymbol::operator delete (pointer, sizeof(SgFunctionTypeSymbol)); };
  176246             : #endif
  176247             : /* #line 176248 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  176248             : 
  176249             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  176250             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  176251             : // obviously imply C++.
  176252             : 
  176253             : // This implements the support within ROSE for memory pools.  Memory pools
  176254             : // support the most condensed usage of memory within the construction of
  176255             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  176256             : // by a new operator written for each class.
  176257             : 
  176258             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  176259             :     // User wants multi-thread support and POSIX threads are available.
  176260             : #   include <pthread.h>
  176261             :     static pthread_mutex_t SgClassSymbol_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  176262             : #else
  176263             :      // Cause synchronization to be skipped.
  176264             : #    ifndef ALLOC_MUTEX
  176265             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  176266             : #    endif
  176267             : #    ifdef _REENTRANT
  176268             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  176269             : #       ifdef _MSC_VER
  176270             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  176271             : #       else
  176272             : #           warning "POSIX threads are not available; synchronization being skipped"
  176273             : #       endif
  176274             : #    endif
  176275             : #endif
  176276             : 
  176277             : #ifndef ROSE_ALLOC_TRACE
  176278             : #  define ROSE_ALLOC_TRACE 0
  176279             : #endif
  176280             : 
  176281             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  176282             : #define ROSE_ALLOC_TRACE_CNT
  176283             : #include "memory-pool-snapshot.h"
  176284             : unsigned long alloc_trace_cnt = 0;
  176285             : #endif
  176286             : 
  176287             : #if ROSE_ALLOC_TRACE
  176288             : const unsigned SgClassSymbol::pool_size = 5;
  176289             : #else
  176290             : const unsigned SgClassSymbol::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  176291             : #endif
  176292             : 
  176293             : #ifndef ROSE_ALLOC_MEMSET
  176294             : #  define ROSE_ALLOC_MEMSET 0
  176295             : #endif
  176296             : 
  176297             : #ifndef ROSE_PEDANTIC_ALLOC
  176298             : #  define ROSE_PEDANTIC_ALLOC 0
  176299             : #endif
  176300             : 
  176301             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  176302             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  176303             : #endif
  176304             : 
  176305             : #if !defined(SGNODE__ALL_POOLS)
  176306             : #define SGNODE__ALL_POOLS
  176307             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  176308             : #endif
  176309             : 
  176310             : SgClassSymbol* SgClassSymbol::next_node = nullptr;
  176311             : std::vector<unsigned char*> SgClassSymbol::pools;
  176312             : 
  176313             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  176314             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  176315             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  176316             : // around this macro definition rather than each use).
  176317             : #ifndef ALLOC_MUTEX
  176318             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  176319             :         do {                                                                     \
  176320             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  176321             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  176322             :                 abort();                                                         \
  176323             :             }                                                                    \
  176324             :         } while (0);
  176325             : #endif
  176326             : 
  176327             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  176328             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  176329             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  176330             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  176331             : 
  176332             : /*! \brief New operator for SgClassSymbol.
  176333             : 
  176334             :    This new operator implements memory pools to provide most efficent 
  176335             :    use of the heap within construction of large ASTs.
  176336             : 
  176337             : \internal The new and delete operators use the lower level C malloc/free
  176338             :    function calls for performance and to make sure that mixing of malloc/free
  176339             :    and new/delete by the used can be caught more readily.  This may change
  176340             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  176341             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  176342             :    deallocate memory allocated using ROSE_MALLOC.
  176343             : */
  176344       14388 : void *SgClassSymbol::operator new ( size_t Size )
  176345             : {
  176346             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  176347             :      * returning or throwing an exception. */
  176348       14388 :     ALLOC_MUTEX(SgClassSymbol, lock);
  176349             : 
  176350             : #if ROSE_ALLOC_TRACE == 2
  176351             : //    printf("SgClassSymbol::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgClassSymbol::next_node);
  176352             : #endif
  176353             : 
  176354             : #if USE_CPP_NEW_DELETE_OPERATORS
  176355             :     void *mem = ROSE_MALLOC(Size);
  176356             :     ALLOC_MUTEX(SgClassSymbol, unlock);
  176357             :     return mem;
  176358             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  176359             : #if ROSE_PEDANTIC_ALLOC
  176360             :     ROSE_ASSERT(Size == sizeof(SgClassSymbol));
  176361             : #else
  176362       14388 :     if (Size != sizeof(SgClassSymbol)) {
  176363           0 :       void * object = ROSE_MALLOC(Size);
  176364           0 :       ALLOC_MUTEX(SgClassSymbol, unlock);
  176365             :       return object;
  176366             :     }
  176367             : #endif
  176368             : 
  176369       14388 :     if (SgClassSymbol::next_node == nullptr) {
  176370         212 :         SgClassSymbol * alloc = (SgClassSymbol*) ROSE_MALLOC ( SgClassSymbol::pool_size * sizeof(SgClassSymbol) );
  176371         212 :         ROSE_ASSERT(alloc != nullptr);
  176372             : 
  176373             : #if ROSE_ALLOC_TRACE == 2
  176374             : //        printf("SgClassSymbol::alloc\n  block[%zi] = [ %p , %p [\n", SgClassSymbol::pools.size(), alloc, alloc + SgClassSymbol::pool_size);
  176375             : #endif
  176376             : 
  176377             : #if ROSE_ALLOC_MEMSET == 1
  176378             : #elif ROSE_ALLOC_MEMSET == 2
  176379             :         memset(alloc, 0x00, SgClassSymbol::pool_size * sizeof(SgClassSymbol));
  176380             : #elif ROSE_ALLOC_MEMSET == 3
  176381             :         memset(alloc, 0xAA, SgClassSymbol::pool_size * sizeof(SgClassSymbol));
  176382             : #endif
  176383      424000 :         for (unsigned i=0; i < SgClassSymbol::pool_size-1; i++) {
  176384      423788 :           alloc[i].p_freepointer = &(alloc[i+1]);
  176385             :         }
  176386         212 :         alloc[SgClassSymbol::pool_size-1].p_freepointer = nullptr;
  176387             : 
  176388         212 :         SgClassSymbol::pools.push_back ( (unsigned char *) alloc );
  176389         212 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgClassSymbol::pool_size * sizeof(SgClassSymbol), V_SgClassSymbol ) );
  176390         212 :         SgClassSymbol::next_node = alloc;
  176391             :     }
  176392       14388 :     ROSE_ASSERT(SgClassSymbol::next_node != nullptr);
  176393             : 
  176394       14388 :     SgClassSymbol * object = SgClassSymbol::next_node;
  176395       14388 :     SgClassSymbol::next_node = (SgClassSymbol*)(object->p_freepointer);
  176396             : 
  176397             : #if ROSE_ALLOC_TRACE == 2
  176398             :     printf("SgClassSymbol::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgClassSymbol::next_node);
  176399             : #endif
  176400             : 
  176401       14388 :     SgNode * fp = object->p_freepointer;
  176402             : #if ROSE_ALLOC_MEMSET == 1
  176403             : #elif ROSE_ALLOC_MEMSET == 2
  176404             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgClassSymbol) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  176405             : #elif ROSE_ALLOC_MEMSET == 3
  176406             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgClassSymbol) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  176407             : #endif
  176408       14388 :     object->p_freepointer = fp;
  176409             : 
  176410             : #if ROSE_ALLOC_TRACE == 2
  176411             : //    printf("SgClassSymbol::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgClassSymbol::next_node);
  176412             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  176413             :     Rose::MemPool::snapshot(oss.str());
  176414             :     alloc_trace_cnt++;
  176415             : #endif
  176416             : 
  176417       14388 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  176418             : 
  176419       14388 :     ALLOC_MUTEX(SgClassSymbol, unlock);
  176420             : 
  176421             :     return object;
  176422             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  176423             : }
  176424             : 
  176425             : 
  176426             : 
  176427             : /*! \brief Delete operator for SgClassSymbol.
  176428             : 
  176429             :    This delete operator implements deallocation using memory pools to 
  176430             :    provide most efficent use of the heap within construction of large ASTs.
  176431             : 
  176432             : \internal The new and delete operators use the lower level C malloc/free
  176433             :    function calls for performance and to make sure that mixing of malloc/free
  176434             :    and new/delete by the used can be caught more readily.  This may change
  176435             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  176436             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  176437             :    deallocate memory allocated using ROSE_MALLOC.
  176438             : */
  176439        1704 : void SgClassSymbol::operator delete(void *Pointer, size_t Size)
  176440             : {
  176441             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  176442             :      * or throwing an exception. */
  176443        1704 :     ALLOC_MUTEX(SgClassSymbol, lock);
  176444             : 
  176445             : #if USE_CPP_NEW_DELETE_OPERATORS
  176446             :     ROSE_FREE(Pointer);
  176447             : #else
  176448             : #if ROSE_PEDANTIC_ALLOC
  176449             :     ROSE_ASSERT(Size == sizeof(SgClassSymbol));
  176450             : #else
  176451        1704 :     if (Size != sizeof(SgClassSymbol)) {
  176452           0 :       ROSE_FREE(Pointer);
  176453           0 :       ALLOC_MUTEX(SgClassSymbol, unlock);
  176454             :       return;
  176455             :     }
  176456             : #endif
  176457             : 
  176458        1704 :     SgClassSymbol * object = (SgClassSymbol*) Pointer;
  176459        1704 :     ROSE_ASSERT(object != nullptr);
  176460             : 
  176461             : #if ROSE_ALLOC_TRACE == 2
  176462             : //  printf("SgClassSymbol::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgClassSymbol::next_node);
  176463             :     printf("SgClassSymbol::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgClassSymbol::next_node);
  176464             : #endif
  176465             : 
  176466             : #if ROSE_PEDANTIC_ALLOC
  176467             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  176468             : #endif
  176469             : 
  176470             : #if ROSE_ALLOC_MEMSET == 1
  176471             : #elif ROSE_ALLOC_MEMSET == 2
  176472             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgClassSymbol) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  176473             : #elif ROSE_ALLOC_MEMSET == 3
  176474             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgClassSymbol) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  176475             : #endif
  176476             : 
  176477             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  176478             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  176479             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  176480             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  176481             : #else
  176482        1704 :     object->p_freepointer = SgClassSymbol::next_node;
  176483        1704 :     SgClassSymbol::next_node = object;
  176484             : #endif
  176485             : 
  176486             : #if ROSE_ALLOC_TRACE == 2
  176487             : //  printf("SgClassSymbol::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgClassSymbol::next_node);
  176488             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  176489             :     Rose::MemPool::snapshot(oss.str());
  176490             :     alloc_trace_cnt++;
  176491             : #endif
  176492             : 
  176493             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  176494             : 
  176495        1704 :     ALLOC_MUTEX(SgClassSymbol, unlock);
  176496             : }
  176497             : 
  176498             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  176499             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  176500             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  176501             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  176502             : // Also, note comment below from Robb (copied from the Common.code file).
  176503             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  176504             : //
  176505             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  176506             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  176507             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  176508             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  176509             : #if 0
  176510             : void SgClassSymbol::operator delete(void* pointer) { SgClassSymbol::operator delete (pointer, sizeof(SgClassSymbol)); };
  176511             : #endif
  176512             : /* #line 176513 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  176513             : 
  176514             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  176515             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  176516             : // obviously imply C++.
  176517             : 
  176518             : // This implements the support within ROSE for memory pools.  Memory pools
  176519             : // support the most condensed usage of memory within the construction of
  176520             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  176521             : // by a new operator written for each class.
  176522             : 
  176523             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  176524             :     // User wants multi-thread support and POSIX threads are available.
  176525             : #   include <pthread.h>
  176526             :     static pthread_mutex_t SgTemplateClassSymbol_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  176527             : #else
  176528             :      // Cause synchronization to be skipped.
  176529             : #    ifndef ALLOC_MUTEX
  176530             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  176531             : #    endif
  176532             : #    ifdef _REENTRANT
  176533             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  176534             : #       ifdef _MSC_VER
  176535             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  176536             : #       else
  176537             : #           warning "POSIX threads are not available; synchronization being skipped"
  176538             : #       endif
  176539             : #    endif
  176540             : #endif
  176541             : 
  176542             : #ifndef ROSE_ALLOC_TRACE
  176543             : #  define ROSE_ALLOC_TRACE 0
  176544             : #endif
  176545             : 
  176546             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  176547             : #define ROSE_ALLOC_TRACE_CNT
  176548             : #include "memory-pool-snapshot.h"
  176549             : unsigned long alloc_trace_cnt = 0;
  176550             : #endif
  176551             : 
  176552             : #if ROSE_ALLOC_TRACE
  176553             : const unsigned SgTemplateClassSymbol::pool_size = 5;
  176554             : #else
  176555             : const unsigned SgTemplateClassSymbol::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  176556             : #endif
  176557             : 
  176558             : #ifndef ROSE_ALLOC_MEMSET
  176559             : #  define ROSE_ALLOC_MEMSET 0
  176560             : #endif
  176561             : 
  176562             : #ifndef ROSE_PEDANTIC_ALLOC
  176563             : #  define ROSE_PEDANTIC_ALLOC 0
  176564             : #endif
  176565             : 
  176566             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  176567             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  176568             : #endif
  176569             : 
  176570             : #if !defined(SGNODE__ALL_POOLS)
  176571             : #define SGNODE__ALL_POOLS
  176572             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  176573             : #endif
  176574             : 
  176575             : SgTemplateClassSymbol* SgTemplateClassSymbol::next_node = nullptr;
  176576             : std::vector<unsigned char*> SgTemplateClassSymbol::pools;
  176577             : 
  176578             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  176579             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  176580             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  176581             : // around this macro definition rather than each use).
  176582             : #ifndef ALLOC_MUTEX
  176583             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  176584             :         do {                                                                     \
  176585             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  176586             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  176587             :                 abort();                                                         \
  176588             :             }                                                                    \
  176589             :         } while (0);
  176590             : #endif
  176591             : 
  176592             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  176593             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  176594             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  176595             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  176596             : 
  176597             : /*! \brief New operator for SgTemplateClassSymbol.
  176598             : 
  176599             :    This new operator implements memory pools to provide most efficent 
  176600             :    use of the heap within construction of large ASTs.
  176601             : 
  176602             : \internal The new and delete operators use the lower level C malloc/free
  176603             :    function calls for performance and to make sure that mixing of malloc/free
  176604             :    and new/delete by the used can be caught more readily.  This may change
  176605             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  176606             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  176607             :    deallocate memory allocated using ROSE_MALLOC.
  176608             : */
  176609        6110 : void *SgTemplateClassSymbol::operator new ( size_t Size )
  176610             : {
  176611             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  176612             :      * returning or throwing an exception. */
  176613        6110 :     ALLOC_MUTEX(SgTemplateClassSymbol, lock);
  176614             : 
  176615             : #if ROSE_ALLOC_TRACE == 2
  176616             : //    printf("SgTemplateClassSymbol::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgTemplateClassSymbol::next_node);
  176617             : #endif
  176618             : 
  176619             : #if USE_CPP_NEW_DELETE_OPERATORS
  176620             :     void *mem = ROSE_MALLOC(Size);
  176621             :     ALLOC_MUTEX(SgTemplateClassSymbol, unlock);
  176622             :     return mem;
  176623             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  176624             : #if ROSE_PEDANTIC_ALLOC
  176625             :     ROSE_ASSERT(Size == sizeof(SgTemplateClassSymbol));
  176626             : #else
  176627        6110 :     if (Size != sizeof(SgTemplateClassSymbol)) {
  176628           0 :       void * object = ROSE_MALLOC(Size);
  176629           0 :       ALLOC_MUTEX(SgTemplateClassSymbol, unlock);
  176630             :       return object;
  176631             :     }
  176632             : #endif
  176633             : 
  176634        6110 :     if (SgTemplateClassSymbol::next_node == nullptr) {
  176635          11 :         SgTemplateClassSymbol * alloc = (SgTemplateClassSymbol*) ROSE_MALLOC ( SgTemplateClassSymbol::pool_size * sizeof(SgTemplateClassSymbol) );
  176636          11 :         ROSE_ASSERT(alloc != nullptr);
  176637             : 
  176638             : #if ROSE_ALLOC_TRACE == 2
  176639             : //        printf("SgTemplateClassSymbol::alloc\n  block[%zi] = [ %p , %p [\n", SgTemplateClassSymbol::pools.size(), alloc, alloc + SgTemplateClassSymbol::pool_size);
  176640             : #endif
  176641             : 
  176642             : #if ROSE_ALLOC_MEMSET == 1
  176643             : #elif ROSE_ALLOC_MEMSET == 2
  176644             :         memset(alloc, 0x00, SgTemplateClassSymbol::pool_size * sizeof(SgTemplateClassSymbol));
  176645             : #elif ROSE_ALLOC_MEMSET == 3
  176646             :         memset(alloc, 0xAA, SgTemplateClassSymbol::pool_size * sizeof(SgTemplateClassSymbol));
  176647             : #endif
  176648       22000 :         for (unsigned i=0; i < SgTemplateClassSymbol::pool_size-1; i++) {
  176649       21989 :           alloc[i].p_freepointer = &(alloc[i+1]);
  176650             :         }
  176651          11 :         alloc[SgTemplateClassSymbol::pool_size-1].p_freepointer = nullptr;
  176652             : 
  176653          11 :         SgTemplateClassSymbol::pools.push_back ( (unsigned char *) alloc );
  176654          11 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgTemplateClassSymbol::pool_size * sizeof(SgTemplateClassSymbol), V_SgTemplateClassSymbol ) );
  176655          11 :         SgTemplateClassSymbol::next_node = alloc;
  176656             :     }
  176657        6110 :     ROSE_ASSERT(SgTemplateClassSymbol::next_node != nullptr);
  176658             : 
  176659        6110 :     SgTemplateClassSymbol * object = SgTemplateClassSymbol::next_node;
  176660        6110 :     SgTemplateClassSymbol::next_node = (SgTemplateClassSymbol*)(object->p_freepointer);
  176661             : 
  176662             : #if ROSE_ALLOC_TRACE == 2
  176663             :     printf("SgTemplateClassSymbol::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTemplateClassSymbol::next_node);
  176664             : #endif
  176665             : 
  176666        6110 :     SgNode * fp = object->p_freepointer;
  176667             : #if ROSE_ALLOC_MEMSET == 1
  176668             : #elif ROSE_ALLOC_MEMSET == 2
  176669             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgTemplateClassSymbol) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  176670             : #elif ROSE_ALLOC_MEMSET == 3
  176671             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgTemplateClassSymbol) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  176672             : #endif
  176673        6110 :     object->p_freepointer = fp;
  176674             : 
  176675             : #if ROSE_ALLOC_TRACE == 2
  176676             : //    printf("SgTemplateClassSymbol::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTemplateClassSymbol::next_node);
  176677             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  176678             :     Rose::MemPool::snapshot(oss.str());
  176679             :     alloc_trace_cnt++;
  176680             : #endif
  176681             : 
  176682        6110 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  176683             : 
  176684        6110 :     ALLOC_MUTEX(SgTemplateClassSymbol, unlock);
  176685             : 
  176686             :     return object;
  176687             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  176688             : }
  176689             : 
  176690             : 
  176691             : 
  176692             : /*! \brief Delete operator for SgTemplateClassSymbol.
  176693             : 
  176694             :    This delete operator implements deallocation using memory pools to 
  176695             :    provide most efficent use of the heap within construction of large ASTs.
  176696             : 
  176697             : \internal The new and delete operators use the lower level C malloc/free
  176698             :    function calls for performance and to make sure that mixing of malloc/free
  176699             :    and new/delete by the used can be caught more readily.  This may change
  176700             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  176701             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  176702             :    deallocate memory allocated using ROSE_MALLOC.
  176703             : */
  176704        1144 : void SgTemplateClassSymbol::operator delete(void *Pointer, size_t Size)
  176705             : {
  176706             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  176707             :      * or throwing an exception. */
  176708        1144 :     ALLOC_MUTEX(SgTemplateClassSymbol, lock);
  176709             : 
  176710             : #if USE_CPP_NEW_DELETE_OPERATORS
  176711             :     ROSE_FREE(Pointer);
  176712             : #else
  176713             : #if ROSE_PEDANTIC_ALLOC
  176714             :     ROSE_ASSERT(Size == sizeof(SgTemplateClassSymbol));
  176715             : #else
  176716        1144 :     if (Size != sizeof(SgTemplateClassSymbol)) {
  176717           0 :       ROSE_FREE(Pointer);
  176718           0 :       ALLOC_MUTEX(SgTemplateClassSymbol, unlock);
  176719             :       return;
  176720             :     }
  176721             : #endif
  176722             : 
  176723        1144 :     SgTemplateClassSymbol * object = (SgTemplateClassSymbol*) Pointer;
  176724        1144 :     ROSE_ASSERT(object != nullptr);
  176725             : 
  176726             : #if ROSE_ALLOC_TRACE == 2
  176727             : //  printf("SgTemplateClassSymbol::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTemplateClassSymbol::next_node);
  176728             :     printf("SgTemplateClassSymbol::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTemplateClassSymbol::next_node);
  176729             : #endif
  176730             : 
  176731             : #if ROSE_PEDANTIC_ALLOC
  176732             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  176733             : #endif
  176734             : 
  176735             : #if ROSE_ALLOC_MEMSET == 1
  176736             : #elif ROSE_ALLOC_MEMSET == 2
  176737             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgTemplateClassSymbol) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  176738             : #elif ROSE_ALLOC_MEMSET == 3
  176739             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgTemplateClassSymbol) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  176740             : #endif
  176741             : 
  176742             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  176743             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  176744             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  176745             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  176746             : #else
  176747        1144 :     object->p_freepointer = SgTemplateClassSymbol::next_node;
  176748        1144 :     SgTemplateClassSymbol::next_node = object;
  176749             : #endif
  176750             : 
  176751             : #if ROSE_ALLOC_TRACE == 2
  176752             : //  printf("SgTemplateClassSymbol::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTemplateClassSymbol::next_node);
  176753             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  176754             :     Rose::MemPool::snapshot(oss.str());
  176755             :     alloc_trace_cnt++;
  176756             : #endif
  176757             : 
  176758             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  176759             : 
  176760        1144 :     ALLOC_MUTEX(SgTemplateClassSymbol, unlock);
  176761             : }
  176762             : 
  176763             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  176764             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  176765             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  176766             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  176767             : // Also, note comment below from Robb (copied from the Common.code file).
  176768             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  176769             : //
  176770             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  176771             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  176772             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  176773             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  176774             : #if 0
  176775             : void SgTemplateClassSymbol::operator delete(void* pointer) { SgTemplateClassSymbol::operator delete (pointer, sizeof(SgTemplateClassSymbol)); };
  176776             : #endif
  176777             : /* #line 176778 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  176778             : 
  176779             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  176780             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  176781             : // obviously imply C++.
  176782             : 
  176783             : // This implements the support within ROSE for memory pools.  Memory pools
  176784             : // support the most condensed usage of memory within the construction of
  176785             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  176786             : // by a new operator written for each class.
  176787             : 
  176788             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  176789             :     // User wants multi-thread support and POSIX threads are available.
  176790             : #   include <pthread.h>
  176791             :     static pthread_mutex_t SgTemplateSymbol_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  176792             : #else
  176793             :      // Cause synchronization to be skipped.
  176794             : #    ifndef ALLOC_MUTEX
  176795             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  176796             : #    endif
  176797             : #    ifdef _REENTRANT
  176798             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  176799             : #       ifdef _MSC_VER
  176800             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  176801             : #       else
  176802             : #           warning "POSIX threads are not available; synchronization being skipped"
  176803             : #       endif
  176804             : #    endif
  176805             : #endif
  176806             : 
  176807             : #ifndef ROSE_ALLOC_TRACE
  176808             : #  define ROSE_ALLOC_TRACE 0
  176809             : #endif
  176810             : 
  176811             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  176812             : #define ROSE_ALLOC_TRACE_CNT
  176813             : #include "memory-pool-snapshot.h"
  176814             : unsigned long alloc_trace_cnt = 0;
  176815             : #endif
  176816             : 
  176817             : #if ROSE_ALLOC_TRACE
  176818             : const unsigned SgTemplateSymbol::pool_size = 5;
  176819             : #else
  176820             : const unsigned SgTemplateSymbol::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  176821             : #endif
  176822             : 
  176823             : #ifndef ROSE_ALLOC_MEMSET
  176824             : #  define ROSE_ALLOC_MEMSET 0
  176825             : #endif
  176826             : 
  176827             : #ifndef ROSE_PEDANTIC_ALLOC
  176828             : #  define ROSE_PEDANTIC_ALLOC 0
  176829             : #endif
  176830             : 
  176831             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  176832             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  176833             : #endif
  176834             : 
  176835             : #if !defined(SGNODE__ALL_POOLS)
  176836             : #define SGNODE__ALL_POOLS
  176837             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  176838             : #endif
  176839             : 
  176840             : SgTemplateSymbol* SgTemplateSymbol::next_node = nullptr;
  176841             : std::vector<unsigned char*> SgTemplateSymbol::pools;
  176842             : 
  176843             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  176844             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  176845             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  176846             : // around this macro definition rather than each use).
  176847             : #ifndef ALLOC_MUTEX
  176848             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  176849             :         do {                                                                     \
  176850             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  176851             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  176852             :                 abort();                                                         \
  176853             :             }                                                                    \
  176854             :         } while (0);
  176855             : #endif
  176856             : 
  176857             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  176858             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  176859             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  176860             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  176861             : 
  176862             : /*! \brief New operator for SgTemplateSymbol.
  176863             : 
  176864             :    This new operator implements memory pools to provide most efficent 
  176865             :    use of the heap within construction of large ASTs.
  176866             : 
  176867             : \internal The new and delete operators use the lower level C malloc/free
  176868             :    function calls for performance and to make sure that mixing of malloc/free
  176869             :    and new/delete by the used can be caught more readily.  This may change
  176870             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  176871             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  176872             :    deallocate memory allocated using ROSE_MALLOC.
  176873             : */
  176874           0 : void *SgTemplateSymbol::operator new ( size_t Size )
  176875             : {
  176876             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  176877             :      * returning or throwing an exception. */
  176878           0 :     ALLOC_MUTEX(SgTemplateSymbol, lock);
  176879             : 
  176880             : #if ROSE_ALLOC_TRACE == 2
  176881             : //    printf("SgTemplateSymbol::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgTemplateSymbol::next_node);
  176882             : #endif
  176883             : 
  176884             : #if USE_CPP_NEW_DELETE_OPERATORS
  176885             :     void *mem = ROSE_MALLOC(Size);
  176886             :     ALLOC_MUTEX(SgTemplateSymbol, unlock);
  176887             :     return mem;
  176888             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  176889             : #if ROSE_PEDANTIC_ALLOC
  176890             :     ROSE_ASSERT(Size == sizeof(SgTemplateSymbol));
  176891             : #else
  176892           0 :     if (Size != sizeof(SgTemplateSymbol)) {
  176893           0 :       void * object = ROSE_MALLOC(Size);
  176894           0 :       ALLOC_MUTEX(SgTemplateSymbol, unlock);
  176895             :       return object;
  176896             :     }
  176897             : #endif
  176898             : 
  176899           0 :     if (SgTemplateSymbol::next_node == nullptr) {
  176900           0 :         SgTemplateSymbol * alloc = (SgTemplateSymbol*) ROSE_MALLOC ( SgTemplateSymbol::pool_size * sizeof(SgTemplateSymbol) );
  176901           0 :         ROSE_ASSERT(alloc != nullptr);
  176902             : 
  176903             : #if ROSE_ALLOC_TRACE == 2
  176904             : //        printf("SgTemplateSymbol::alloc\n  block[%zi] = [ %p , %p [\n", SgTemplateSymbol::pools.size(), alloc, alloc + SgTemplateSymbol::pool_size);
  176905             : #endif
  176906             : 
  176907             : #if ROSE_ALLOC_MEMSET == 1
  176908             : #elif ROSE_ALLOC_MEMSET == 2
  176909             :         memset(alloc, 0x00, SgTemplateSymbol::pool_size * sizeof(SgTemplateSymbol));
  176910             : #elif ROSE_ALLOC_MEMSET == 3
  176911             :         memset(alloc, 0xAA, SgTemplateSymbol::pool_size * sizeof(SgTemplateSymbol));
  176912             : #endif
  176913           0 :         for (unsigned i=0; i < SgTemplateSymbol::pool_size-1; i++) {
  176914           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
  176915             :         }
  176916           0 :         alloc[SgTemplateSymbol::pool_size-1].p_freepointer = nullptr;
  176917             : 
  176918           0 :         SgTemplateSymbol::pools.push_back ( (unsigned char *) alloc );
  176919           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgTemplateSymbol::pool_size * sizeof(SgTemplateSymbol), V_SgTemplateSymbol ) );
  176920           0 :         SgTemplateSymbol::next_node = alloc;
  176921             :     }
  176922           0 :     ROSE_ASSERT(SgTemplateSymbol::next_node != nullptr);
  176923             : 
  176924           0 :     SgTemplateSymbol * object = SgTemplateSymbol::next_node;
  176925           0 :     SgTemplateSymbol::next_node = (SgTemplateSymbol*)(object->p_freepointer);
  176926             : 
  176927             : #if ROSE_ALLOC_TRACE == 2
  176928             :     printf("SgTemplateSymbol::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTemplateSymbol::next_node);
  176929             : #endif
  176930             : 
  176931           0 :     SgNode * fp = object->p_freepointer;
  176932             : #if ROSE_ALLOC_MEMSET == 1
  176933             : #elif ROSE_ALLOC_MEMSET == 2
  176934             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgTemplateSymbol) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  176935             : #elif ROSE_ALLOC_MEMSET == 3
  176936             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgTemplateSymbol) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  176937             : #endif
  176938           0 :     object->p_freepointer = fp;
  176939             : 
  176940             : #if ROSE_ALLOC_TRACE == 2
  176941             : //    printf("SgTemplateSymbol::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTemplateSymbol::next_node);
  176942             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  176943             :     Rose::MemPool::snapshot(oss.str());
  176944             :     alloc_trace_cnt++;
  176945             : #endif
  176946             : 
  176947           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  176948             : 
  176949           0 :     ALLOC_MUTEX(SgTemplateSymbol, unlock);
  176950             : 
  176951             :     return object;
  176952             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  176953             : }
  176954             : 
  176955             : 
  176956             : 
  176957             : /*! \brief Delete operator for SgTemplateSymbol.
  176958             : 
  176959             :    This delete operator implements deallocation using memory pools to 
  176960             :    provide most efficent use of the heap within construction of large ASTs.
  176961             : 
  176962             : \internal The new and delete operators use the lower level C malloc/free
  176963             :    function calls for performance and to make sure that mixing of malloc/free
  176964             :    and new/delete by the used can be caught more readily.  This may change
  176965             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  176966             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  176967             :    deallocate memory allocated using ROSE_MALLOC.
  176968             : */
  176969           0 : void SgTemplateSymbol::operator delete(void *Pointer, size_t Size)
  176970             : {
  176971             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  176972             :      * or throwing an exception. */
  176973           0 :     ALLOC_MUTEX(SgTemplateSymbol, lock);
  176974             : 
  176975             : #if USE_CPP_NEW_DELETE_OPERATORS
  176976             :     ROSE_FREE(Pointer);
  176977             : #else
  176978             : #if ROSE_PEDANTIC_ALLOC
  176979             :     ROSE_ASSERT(Size == sizeof(SgTemplateSymbol));
  176980             : #else
  176981           0 :     if (Size != sizeof(SgTemplateSymbol)) {
  176982           0 :       ROSE_FREE(Pointer);
  176983           0 :       ALLOC_MUTEX(SgTemplateSymbol, unlock);
  176984             :       return;
  176985             :     }
  176986             : #endif
  176987             : 
  176988           0 :     SgTemplateSymbol * object = (SgTemplateSymbol*) Pointer;
  176989           0 :     ROSE_ASSERT(object != nullptr);
  176990             : 
  176991             : #if ROSE_ALLOC_TRACE == 2
  176992             : //  printf("SgTemplateSymbol::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTemplateSymbol::next_node);
  176993             :     printf("SgTemplateSymbol::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTemplateSymbol::next_node);
  176994             : #endif
  176995             : 
  176996             : #if ROSE_PEDANTIC_ALLOC
  176997             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  176998             : #endif
  176999             : 
  177000             : #if ROSE_ALLOC_MEMSET == 1
  177001             : #elif ROSE_ALLOC_MEMSET == 2
  177002             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgTemplateSymbol) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  177003             : #elif ROSE_ALLOC_MEMSET == 3
  177004             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgTemplateSymbol) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  177005             : #endif
  177006             : 
  177007             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  177008             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  177009             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  177010             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  177011             : #else
  177012           0 :     object->p_freepointer = SgTemplateSymbol::next_node;
  177013           0 :     SgTemplateSymbol::next_node = object;
  177014             : #endif
  177015             : 
  177016             : #if ROSE_ALLOC_TRACE == 2
  177017             : //  printf("SgTemplateSymbol::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTemplateSymbol::next_node);
  177018             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  177019             :     Rose::MemPool::snapshot(oss.str());
  177020             :     alloc_trace_cnt++;
  177021             : #endif
  177022             : 
  177023             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  177024             : 
  177025           0 :     ALLOC_MUTEX(SgTemplateSymbol, unlock);
  177026             : }
  177027             : 
  177028             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  177029             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  177030             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  177031             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  177032             : // Also, note comment below from Robb (copied from the Common.code file).
  177033             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  177034             : //
  177035             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  177036             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  177037             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  177038             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  177039             : #if 0
  177040             : void SgTemplateSymbol::operator delete(void* pointer) { SgTemplateSymbol::operator delete (pointer, sizeof(SgTemplateSymbol)); };
  177041             : #endif
  177042             : /* #line 177043 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  177043             : 
  177044             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  177045             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  177046             : // obviously imply C++.
  177047             : 
  177048             : // This implements the support within ROSE for memory pools.  Memory pools
  177049             : // support the most condensed usage of memory within the construction of
  177050             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  177051             : // by a new operator written for each class.
  177052             : 
  177053             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  177054             :     // User wants multi-thread support and POSIX threads are available.
  177055             : #   include <pthread.h>
  177056             :     static pthread_mutex_t SgEnumSymbol_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  177057             : #else
  177058             :      // Cause synchronization to be skipped.
  177059             : #    ifndef ALLOC_MUTEX
  177060             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  177061             : #    endif
  177062             : #    ifdef _REENTRANT
  177063             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  177064             : #       ifdef _MSC_VER
  177065             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  177066             : #       else
  177067             : #           warning "POSIX threads are not available; synchronization being skipped"
  177068             : #       endif
  177069             : #    endif
  177070             : #endif
  177071             : 
  177072             : #ifndef ROSE_ALLOC_TRACE
  177073             : #  define ROSE_ALLOC_TRACE 0
  177074             : #endif
  177075             : 
  177076             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  177077             : #define ROSE_ALLOC_TRACE_CNT
  177078             : #include "memory-pool-snapshot.h"
  177079             : unsigned long alloc_trace_cnt = 0;
  177080             : #endif
  177081             : 
  177082             : #if ROSE_ALLOC_TRACE
  177083             : const unsigned SgEnumSymbol::pool_size = 5;
  177084             : #else
  177085             : const unsigned SgEnumSymbol::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  177086             : #endif
  177087             : 
  177088             : #ifndef ROSE_ALLOC_MEMSET
  177089             : #  define ROSE_ALLOC_MEMSET 0
  177090             : #endif
  177091             : 
  177092             : #ifndef ROSE_PEDANTIC_ALLOC
  177093             : #  define ROSE_PEDANTIC_ALLOC 0
  177094             : #endif
  177095             : 
  177096             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  177097             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  177098             : #endif
  177099             : 
  177100             : #if !defined(SGNODE__ALL_POOLS)
  177101             : #define SGNODE__ALL_POOLS
  177102             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  177103             : #endif
  177104             : 
  177105             : SgEnumSymbol* SgEnumSymbol::next_node = nullptr;
  177106             : std::vector<unsigned char*> SgEnumSymbol::pools;
  177107             : 
  177108             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  177109             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  177110             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  177111             : // around this macro definition rather than each use).
  177112             : #ifndef ALLOC_MUTEX
  177113             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  177114             :         do {                                                                     \
  177115             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  177116             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  177117             :                 abort();                                                         \
  177118             :             }                                                                    \
  177119             :         } while (0);
  177120             : #endif
  177121             : 
  177122             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  177123             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  177124             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  177125             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  177126             : 
  177127             : /*! \brief New operator for SgEnumSymbol.
  177128             : 
  177129             :    This new operator implements memory pools to provide most efficent 
  177130             :    use of the heap within construction of large ASTs.
  177131             : 
  177132             : \internal The new and delete operators use the lower level C malloc/free
  177133             :    function calls for performance and to make sure that mixing of malloc/free
  177134             :    and new/delete by the used can be caught more readily.  This may change
  177135             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  177136             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  177137             :    deallocate memory allocated using ROSE_MALLOC.
  177138             : */
  177139        1578 : void *SgEnumSymbol::operator new ( size_t Size )
  177140             : {
  177141             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  177142             :      * returning or throwing an exception. */
  177143        1578 :     ALLOC_MUTEX(SgEnumSymbol, lock);
  177144             : 
  177145             : #if ROSE_ALLOC_TRACE == 2
  177146             : //    printf("SgEnumSymbol::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgEnumSymbol::next_node);
  177147             : #endif
  177148             : 
  177149             : #if USE_CPP_NEW_DELETE_OPERATORS
  177150             :     void *mem = ROSE_MALLOC(Size);
  177151             :     ALLOC_MUTEX(SgEnumSymbol, unlock);
  177152             :     return mem;
  177153             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  177154             : #if ROSE_PEDANTIC_ALLOC
  177155             :     ROSE_ASSERT(Size == sizeof(SgEnumSymbol));
  177156             : #else
  177157        1578 :     if (Size != sizeof(SgEnumSymbol)) {
  177158           0 :       void * object = ROSE_MALLOC(Size);
  177159           0 :       ALLOC_MUTEX(SgEnumSymbol, unlock);
  177160             :       return object;
  177161             :     }
  177162             : #endif
  177163             : 
  177164        1578 :     if (SgEnumSymbol::next_node == nullptr) {
  177165         183 :         SgEnumSymbol * alloc = (SgEnumSymbol*) ROSE_MALLOC ( SgEnumSymbol::pool_size * sizeof(SgEnumSymbol) );
  177166         183 :         ROSE_ASSERT(alloc != nullptr);
  177167             : 
  177168             : #if ROSE_ALLOC_TRACE == 2
  177169             : //        printf("SgEnumSymbol::alloc\n  block[%zi] = [ %p , %p [\n", SgEnumSymbol::pools.size(), alloc, alloc + SgEnumSymbol::pool_size);
  177170             : #endif
  177171             : 
  177172             : #if ROSE_ALLOC_MEMSET == 1
  177173             : #elif ROSE_ALLOC_MEMSET == 2
  177174             :         memset(alloc, 0x00, SgEnumSymbol::pool_size * sizeof(SgEnumSymbol));
  177175             : #elif ROSE_ALLOC_MEMSET == 3
  177176             :         memset(alloc, 0xAA, SgEnumSymbol::pool_size * sizeof(SgEnumSymbol));
  177177             : #endif
  177178      366000 :         for (unsigned i=0; i < SgEnumSymbol::pool_size-1; i++) {
  177179      365817 :           alloc[i].p_freepointer = &(alloc[i+1]);
  177180             :         }
  177181         183 :         alloc[SgEnumSymbol::pool_size-1].p_freepointer = nullptr;
  177182             : 
  177183         183 :         SgEnumSymbol::pools.push_back ( (unsigned char *) alloc );
  177184         183 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgEnumSymbol::pool_size * sizeof(SgEnumSymbol), V_SgEnumSymbol ) );
  177185         183 :         SgEnumSymbol::next_node = alloc;
  177186             :     }
  177187        1578 :     ROSE_ASSERT(SgEnumSymbol::next_node != nullptr);
  177188             : 
  177189        1578 :     SgEnumSymbol * object = SgEnumSymbol::next_node;
  177190        1578 :     SgEnumSymbol::next_node = (SgEnumSymbol*)(object->p_freepointer);
  177191             : 
  177192             : #if ROSE_ALLOC_TRACE == 2
  177193             :     printf("SgEnumSymbol::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgEnumSymbol::next_node);
  177194             : #endif
  177195             : 
  177196        1578 :     SgNode * fp = object->p_freepointer;
  177197             : #if ROSE_ALLOC_MEMSET == 1
  177198             : #elif ROSE_ALLOC_MEMSET == 2
  177199             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgEnumSymbol) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  177200             : #elif ROSE_ALLOC_MEMSET == 3
  177201             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgEnumSymbol) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  177202             : #endif
  177203        1578 :     object->p_freepointer = fp;
  177204             : 
  177205             : #if ROSE_ALLOC_TRACE == 2
  177206             : //    printf("SgEnumSymbol::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgEnumSymbol::next_node);
  177207             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  177208             :     Rose::MemPool::snapshot(oss.str());
  177209             :     alloc_trace_cnt++;
  177210             : #endif
  177211             : 
  177212        1578 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  177213             : 
  177214        1578 :     ALLOC_MUTEX(SgEnumSymbol, unlock);
  177215             : 
  177216             :     return object;
  177217             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  177218             : }
  177219             : 
  177220             : 
  177221             : 
  177222             : /*! \brief Delete operator for SgEnumSymbol.
  177223             : 
  177224             :    This delete operator implements deallocation using memory pools to 
  177225             :    provide most efficent use of the heap within construction of large ASTs.
  177226             : 
  177227             : \internal The new and delete operators use the lower level C malloc/free
  177228             :    function calls for performance and to make sure that mixing of malloc/free
  177229             :    and new/delete by the used can be caught more readily.  This may change
  177230             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  177231             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  177232             :    deallocate memory allocated using ROSE_MALLOC.
  177233             : */
  177234         176 : void SgEnumSymbol::operator delete(void *Pointer, size_t Size)
  177235             : {
  177236             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  177237             :      * or throwing an exception. */
  177238         176 :     ALLOC_MUTEX(SgEnumSymbol, lock);
  177239             : 
  177240             : #if USE_CPP_NEW_DELETE_OPERATORS
  177241             :     ROSE_FREE(Pointer);
  177242             : #else
  177243             : #if ROSE_PEDANTIC_ALLOC
  177244             :     ROSE_ASSERT(Size == sizeof(SgEnumSymbol));
  177245             : #else
  177246         176 :     if (Size != sizeof(SgEnumSymbol)) {
  177247           0 :       ROSE_FREE(Pointer);
  177248           0 :       ALLOC_MUTEX(SgEnumSymbol, unlock);
  177249             :       return;
  177250             :     }
  177251             : #endif
  177252             : 
  177253         176 :     SgEnumSymbol * object = (SgEnumSymbol*) Pointer;
  177254         176 :     ROSE_ASSERT(object != nullptr);
  177255             : 
  177256             : #if ROSE_ALLOC_TRACE == 2
  177257             : //  printf("SgEnumSymbol::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgEnumSymbol::next_node);
  177258             :     printf("SgEnumSymbol::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgEnumSymbol::next_node);
  177259             : #endif
  177260             : 
  177261             : #if ROSE_PEDANTIC_ALLOC
  177262             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  177263             : #endif
  177264             : 
  177265             : #if ROSE_ALLOC_MEMSET == 1
  177266             : #elif ROSE_ALLOC_MEMSET == 2
  177267             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgEnumSymbol) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  177268             : #elif ROSE_ALLOC_MEMSET == 3
  177269             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgEnumSymbol) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  177270             : #endif
  177271             : 
  177272             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  177273             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  177274             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  177275             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  177276             : #else
  177277         176 :     object->p_freepointer = SgEnumSymbol::next_node;
  177278         176 :     SgEnumSymbol::next_node = object;
  177279             : #endif
  177280             : 
  177281             : #if ROSE_ALLOC_TRACE == 2
  177282             : //  printf("SgEnumSymbol::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgEnumSymbol::next_node);
  177283             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  177284             :     Rose::MemPool::snapshot(oss.str());
  177285             :     alloc_trace_cnt++;
  177286             : #endif
  177287             : 
  177288             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  177289             : 
  177290         176 :     ALLOC_MUTEX(SgEnumSymbol, unlock);
  177291             : }
  177292             : 
  177293             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  177294             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  177295             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  177296             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  177297             : // Also, note comment below from Robb (copied from the Common.code file).
  177298             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  177299             : //
  177300             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  177301             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  177302             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  177303             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  177304             : #if 0
  177305             : void SgEnumSymbol::operator delete(void* pointer) { SgEnumSymbol::operator delete (pointer, sizeof(SgEnumSymbol)); };
  177306             : #endif
  177307             : /* #line 177308 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  177308             : 
  177309             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  177310             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  177311             : // obviously imply C++.
  177312             : 
  177313             : // This implements the support within ROSE for memory pools.  Memory pools
  177314             : // support the most condensed usage of memory within the construction of
  177315             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  177316             : // by a new operator written for each class.
  177317             : 
  177318             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  177319             :     // User wants multi-thread support and POSIX threads are available.
  177320             : #   include <pthread.h>
  177321             :     static pthread_mutex_t SgEnumFieldSymbol_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  177322             : #else
  177323             :      // Cause synchronization to be skipped.
  177324             : #    ifndef ALLOC_MUTEX
  177325             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  177326             : #    endif
  177327             : #    ifdef _REENTRANT
  177328             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  177329             : #       ifdef _MSC_VER
  177330             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  177331             : #       else
  177332             : #           warning "POSIX threads are not available; synchronization being skipped"
  177333             : #       endif
  177334             : #    endif
  177335             : #endif
  177336             : 
  177337             : #ifndef ROSE_ALLOC_TRACE
  177338             : #  define ROSE_ALLOC_TRACE 0
  177339             : #endif
  177340             : 
  177341             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  177342             : #define ROSE_ALLOC_TRACE_CNT
  177343             : #include "memory-pool-snapshot.h"
  177344             : unsigned long alloc_trace_cnt = 0;
  177345             : #endif
  177346             : 
  177347             : #if ROSE_ALLOC_TRACE
  177348             : const unsigned SgEnumFieldSymbol::pool_size = 5;
  177349             : #else
  177350             : const unsigned SgEnumFieldSymbol::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  177351             : #endif
  177352             : 
  177353             : #ifndef ROSE_ALLOC_MEMSET
  177354             : #  define ROSE_ALLOC_MEMSET 0
  177355             : #endif
  177356             : 
  177357             : #ifndef ROSE_PEDANTIC_ALLOC
  177358             : #  define ROSE_PEDANTIC_ALLOC 0
  177359             : #endif
  177360             : 
  177361             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  177362             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  177363             : #endif
  177364             : 
  177365             : #if !defined(SGNODE__ALL_POOLS)
  177366             : #define SGNODE__ALL_POOLS
  177367             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  177368             : #endif
  177369             : 
  177370             : SgEnumFieldSymbol* SgEnumFieldSymbol::next_node = nullptr;
  177371             : std::vector<unsigned char*> SgEnumFieldSymbol::pools;
  177372             : 
  177373             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  177374             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  177375             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  177376             : // around this macro definition rather than each use).
  177377             : #ifndef ALLOC_MUTEX
  177378             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  177379             :         do {                                                                     \
  177380             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  177381             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  177382             :                 abort();                                                         \
  177383             :             }                                                                    \
  177384             :         } while (0);
  177385             : #endif
  177386             : 
  177387             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  177388             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  177389             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  177390             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  177391             : 
  177392             : /*! \brief New operator for SgEnumFieldSymbol.
  177393             : 
  177394             :    This new operator implements memory pools to provide most efficent 
  177395             :    use of the heap within construction of large ASTs.
  177396             : 
  177397             : \internal The new and delete operators use the lower level C malloc/free
  177398             :    function calls for performance and to make sure that mixing of malloc/free
  177399             :    and new/delete by the used can be caught more readily.  This may change
  177400             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  177401             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  177402             :    deallocate memory allocated using ROSE_MALLOC.
  177403             : */
  177404        7285 : void *SgEnumFieldSymbol::operator new ( size_t Size )
  177405             : {
  177406             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  177407             :      * returning or throwing an exception. */
  177408        7285 :     ALLOC_MUTEX(SgEnumFieldSymbol, lock);
  177409             : 
  177410             : #if ROSE_ALLOC_TRACE == 2
  177411             : //    printf("SgEnumFieldSymbol::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgEnumFieldSymbol::next_node);
  177412             : #endif
  177413             : 
  177414             : #if USE_CPP_NEW_DELETE_OPERATORS
  177415             :     void *mem = ROSE_MALLOC(Size);
  177416             :     ALLOC_MUTEX(SgEnumFieldSymbol, unlock);
  177417             :     return mem;
  177418             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  177419             : #if ROSE_PEDANTIC_ALLOC
  177420             :     ROSE_ASSERT(Size == sizeof(SgEnumFieldSymbol));
  177421             : #else
  177422        7285 :     if (Size != sizeof(SgEnumFieldSymbol)) {
  177423           0 :       void * object = ROSE_MALLOC(Size);
  177424           0 :       ALLOC_MUTEX(SgEnumFieldSymbol, unlock);
  177425             :       return object;
  177426             :     }
  177427             : #endif
  177428             : 
  177429        7285 :     if (SgEnumFieldSymbol::next_node == nullptr) {
  177430         183 :         SgEnumFieldSymbol * alloc = (SgEnumFieldSymbol*) ROSE_MALLOC ( SgEnumFieldSymbol::pool_size * sizeof(SgEnumFieldSymbol) );
  177431         183 :         ROSE_ASSERT(alloc != nullptr);
  177432             : 
  177433             : #if ROSE_ALLOC_TRACE == 2
  177434             : //        printf("SgEnumFieldSymbol::alloc\n  block[%zi] = [ %p , %p [\n", SgEnumFieldSymbol::pools.size(), alloc, alloc + SgEnumFieldSymbol::pool_size);
  177435             : #endif
  177436             : 
  177437             : #if ROSE_ALLOC_MEMSET == 1
  177438             : #elif ROSE_ALLOC_MEMSET == 2
  177439             :         memset(alloc, 0x00, SgEnumFieldSymbol::pool_size * sizeof(SgEnumFieldSymbol));
  177440             : #elif ROSE_ALLOC_MEMSET == 3
  177441             :         memset(alloc, 0xAA, SgEnumFieldSymbol::pool_size * sizeof(SgEnumFieldSymbol));
  177442             : #endif
  177443      366000 :         for (unsigned i=0; i < SgEnumFieldSymbol::pool_size-1; i++) {
  177444      365817 :           alloc[i].p_freepointer = &(alloc[i+1]);
  177445             :         }
  177446         183 :         alloc[SgEnumFieldSymbol::pool_size-1].p_freepointer = nullptr;
  177447             : 
  177448         183 :         SgEnumFieldSymbol::pools.push_back ( (unsigned char *) alloc );
  177449         183 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgEnumFieldSymbol::pool_size * sizeof(SgEnumFieldSymbol), V_SgEnumFieldSymbol ) );
  177450         183 :         SgEnumFieldSymbol::next_node = alloc;
  177451             :     }
  177452        7285 :     ROSE_ASSERT(SgEnumFieldSymbol::next_node != nullptr);
  177453             : 
  177454        7285 :     SgEnumFieldSymbol * object = SgEnumFieldSymbol::next_node;
  177455        7285 :     SgEnumFieldSymbol::next_node = (SgEnumFieldSymbol*)(object->p_freepointer);
  177456             : 
  177457             : #if ROSE_ALLOC_TRACE == 2
  177458             :     printf("SgEnumFieldSymbol::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgEnumFieldSymbol::next_node);
  177459             : #endif
  177460             : 
  177461        7285 :     SgNode * fp = object->p_freepointer;
  177462             : #if ROSE_ALLOC_MEMSET == 1
  177463             : #elif ROSE_ALLOC_MEMSET == 2
  177464             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgEnumFieldSymbol) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  177465             : #elif ROSE_ALLOC_MEMSET == 3
  177466             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgEnumFieldSymbol) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  177467             : #endif
  177468        7285 :     object->p_freepointer = fp;
  177469             : 
  177470             : #if ROSE_ALLOC_TRACE == 2
  177471             : //    printf("SgEnumFieldSymbol::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgEnumFieldSymbol::next_node);
  177472             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  177473             :     Rose::MemPool::snapshot(oss.str());
  177474             :     alloc_trace_cnt++;
  177475             : #endif
  177476             : 
  177477        7285 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  177478             : 
  177479        7285 :     ALLOC_MUTEX(SgEnumFieldSymbol, unlock);
  177480             : 
  177481             :     return object;
  177482             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  177483             : }
  177484             : 
  177485             : 
  177486             : 
  177487             : /*! \brief Delete operator for SgEnumFieldSymbol.
  177488             : 
  177489             :    This delete operator implements deallocation using memory pools to 
  177490             :    provide most efficent use of the heap within construction of large ASTs.
  177491             : 
  177492             : \internal The new and delete operators use the lower level C malloc/free
  177493             :    function calls for performance and to make sure that mixing of malloc/free
  177494             :    and new/delete by the used can be caught more readily.  This may change
  177495             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  177496             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  177497             :    deallocate memory allocated using ROSE_MALLOC.
  177498             : */
  177499         558 : void SgEnumFieldSymbol::operator delete(void *Pointer, size_t Size)
  177500             : {
  177501             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  177502             :      * or throwing an exception. */
  177503         558 :     ALLOC_MUTEX(SgEnumFieldSymbol, lock);
  177504             : 
  177505             : #if USE_CPP_NEW_DELETE_OPERATORS
  177506             :     ROSE_FREE(Pointer);
  177507             : #else
  177508             : #if ROSE_PEDANTIC_ALLOC
  177509             :     ROSE_ASSERT(Size == sizeof(SgEnumFieldSymbol));
  177510             : #else
  177511         558 :     if (Size != sizeof(SgEnumFieldSymbol)) {
  177512           0 :       ROSE_FREE(Pointer);
  177513           0 :       ALLOC_MUTEX(SgEnumFieldSymbol, unlock);
  177514             :       return;
  177515             :     }
  177516             : #endif
  177517             : 
  177518         558 :     SgEnumFieldSymbol * object = (SgEnumFieldSymbol*) Pointer;
  177519         558 :     ROSE_ASSERT(object != nullptr);
  177520             : 
  177521             : #if ROSE_ALLOC_TRACE == 2
  177522             : //  printf("SgEnumFieldSymbol::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgEnumFieldSymbol::next_node);
  177523             :     printf("SgEnumFieldSymbol::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgEnumFieldSymbol::next_node);
  177524             : #endif
  177525             : 
  177526             : #if ROSE_PEDANTIC_ALLOC
  177527             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  177528             : #endif
  177529             : 
  177530             : #if ROSE_ALLOC_MEMSET == 1
  177531             : #elif ROSE_ALLOC_MEMSET == 2
  177532             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgEnumFieldSymbol) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  177533             : #elif ROSE_ALLOC_MEMSET == 3
  177534             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgEnumFieldSymbol) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  177535             : #endif
  177536             : 
  177537             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  177538             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  177539             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  177540             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  177541             : #else
  177542         558 :     object->p_freepointer = SgEnumFieldSymbol::next_node;
  177543         558 :     SgEnumFieldSymbol::next_node = object;
  177544             : #endif
  177545             : 
  177546             : #if ROSE_ALLOC_TRACE == 2
  177547             : //  printf("SgEnumFieldSymbol::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgEnumFieldSymbol::next_node);
  177548             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  177549             :     Rose::MemPool::snapshot(oss.str());
  177550             :     alloc_trace_cnt++;
  177551             : #endif
  177552             : 
  177553             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  177554             : 
  177555         558 :     ALLOC_MUTEX(SgEnumFieldSymbol, unlock);
  177556             : }
  177557             : 
  177558             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  177559             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  177560             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  177561             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  177562             : // Also, note comment below from Robb (copied from the Common.code file).
  177563             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  177564             : //
  177565             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  177566             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  177567             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  177568             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  177569             : #if 0
  177570             : void SgEnumFieldSymbol::operator delete(void* pointer) { SgEnumFieldSymbol::operator delete (pointer, sizeof(SgEnumFieldSymbol)); };
  177571             : #endif
  177572             : /* #line 177573 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  177573             : 
  177574             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  177575             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  177576             : // obviously imply C++.
  177577             : 
  177578             : // This implements the support within ROSE for memory pools.  Memory pools
  177579             : // support the most condensed usage of memory within the construction of
  177580             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  177581             : // by a new operator written for each class.
  177582             : 
  177583             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  177584             :     // User wants multi-thread support and POSIX threads are available.
  177585             : #   include <pthread.h>
  177586             :     static pthread_mutex_t SgTypedefSymbol_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  177587             : #else
  177588             :      // Cause synchronization to be skipped.
  177589             : #    ifndef ALLOC_MUTEX
  177590             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  177591             : #    endif
  177592             : #    ifdef _REENTRANT
  177593             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  177594             : #       ifdef _MSC_VER
  177595             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  177596             : #       else
  177597             : #           warning "POSIX threads are not available; synchronization being skipped"
  177598             : #       endif
  177599             : #    endif
  177600             : #endif
  177601             : 
  177602             : #ifndef ROSE_ALLOC_TRACE
  177603             : #  define ROSE_ALLOC_TRACE 0
  177604             : #endif
  177605             : 
  177606             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  177607             : #define ROSE_ALLOC_TRACE_CNT
  177608             : #include "memory-pool-snapshot.h"
  177609             : unsigned long alloc_trace_cnt = 0;
  177610             : #endif
  177611             : 
  177612             : #if ROSE_ALLOC_TRACE
  177613             : const unsigned SgTypedefSymbol::pool_size = 5;
  177614             : #else
  177615             : const unsigned SgTypedefSymbol::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  177616             : #endif
  177617             : 
  177618             : #ifndef ROSE_ALLOC_MEMSET
  177619             : #  define ROSE_ALLOC_MEMSET 0
  177620             : #endif
  177621             : 
  177622             : #ifndef ROSE_PEDANTIC_ALLOC
  177623             : #  define ROSE_PEDANTIC_ALLOC 0
  177624             : #endif
  177625             : 
  177626             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  177627             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  177628             : #endif
  177629             : 
  177630             : #if !defined(SGNODE__ALL_POOLS)
  177631             : #define SGNODE__ALL_POOLS
  177632             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  177633             : #endif
  177634             : 
  177635             : SgTypedefSymbol* SgTypedefSymbol::next_node = nullptr;
  177636             : std::vector<unsigned char*> SgTypedefSymbol::pools;
  177637             : 
  177638             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  177639             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  177640             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  177641             : // around this macro definition rather than each use).
  177642             : #ifndef ALLOC_MUTEX
  177643             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  177644             :         do {                                                                     \
  177645             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  177646             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  177647             :                 abort();                                                         \
  177648             :             }                                                                    \
  177649             :         } while (0);
  177650             : #endif
  177651             : 
  177652             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  177653             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  177654             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  177655             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  177656             : 
  177657             : /*! \brief New operator for SgTypedefSymbol.
  177658             : 
  177659             :    This new operator implements memory pools to provide most efficent 
  177660             :    use of the heap within construction of large ASTs.
  177661             : 
  177662             : \internal The new and delete operators use the lower level C malloc/free
  177663             :    function calls for performance and to make sure that mixing of malloc/free
  177664             :    and new/delete by the used can be caught more readily.  This may change
  177665             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  177666             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  177667             :    deallocate memory allocated using ROSE_MALLOC.
  177668             : */
  177669       56799 : void *SgTypedefSymbol::operator new ( size_t Size )
  177670             : {
  177671             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  177672             :      * returning or throwing an exception. */
  177673       56799 :     ALLOC_MUTEX(SgTypedefSymbol, lock);
  177674             : 
  177675             : #if ROSE_ALLOC_TRACE == 2
  177676             : //    printf("SgTypedefSymbol::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgTypedefSymbol::next_node);
  177677             : #endif
  177678             : 
  177679             : #if USE_CPP_NEW_DELETE_OPERATORS
  177680             :     void *mem = ROSE_MALLOC(Size);
  177681             :     ALLOC_MUTEX(SgTypedefSymbol, unlock);
  177682             :     return mem;
  177683             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  177684             : #if ROSE_PEDANTIC_ALLOC
  177685             :     ROSE_ASSERT(Size == sizeof(SgTypedefSymbol));
  177686             : #else
  177687       56799 :     if (Size != sizeof(SgTypedefSymbol)) {
  177688           0 :       void * object = ROSE_MALLOC(Size);
  177689           0 :       ALLOC_MUTEX(SgTypedefSymbol, unlock);
  177690             :       return object;
  177691             :     }
  177692             : #endif
  177693             : 
  177694       56799 :     if (SgTypedefSymbol::next_node == nullptr) {
  177695         315 :         SgTypedefSymbol * alloc = (SgTypedefSymbol*) ROSE_MALLOC ( SgTypedefSymbol::pool_size * sizeof(SgTypedefSymbol) );
  177696         315 :         ROSE_ASSERT(alloc != nullptr);
  177697             : 
  177698             : #if ROSE_ALLOC_TRACE == 2
  177699             : //        printf("SgTypedefSymbol::alloc\n  block[%zi] = [ %p , %p [\n", SgTypedefSymbol::pools.size(), alloc, alloc + SgTypedefSymbol::pool_size);
  177700             : #endif
  177701             : 
  177702             : #if ROSE_ALLOC_MEMSET == 1
  177703             : #elif ROSE_ALLOC_MEMSET == 2
  177704             :         memset(alloc, 0x00, SgTypedefSymbol::pool_size * sizeof(SgTypedefSymbol));
  177705             : #elif ROSE_ALLOC_MEMSET == 3
  177706             :         memset(alloc, 0xAA, SgTypedefSymbol::pool_size * sizeof(SgTypedefSymbol));
  177707             : #endif
  177708      630000 :         for (unsigned i=0; i < SgTypedefSymbol::pool_size-1; i++) {
  177709      629685 :           alloc[i].p_freepointer = &(alloc[i+1]);
  177710             :         }
  177711         315 :         alloc[SgTypedefSymbol::pool_size-1].p_freepointer = nullptr;
  177712             : 
  177713         315 :         SgTypedefSymbol::pools.push_back ( (unsigned char *) alloc );
  177714         315 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgTypedefSymbol::pool_size * sizeof(SgTypedefSymbol), V_SgTypedefSymbol ) );
  177715         315 :         SgTypedefSymbol::next_node = alloc;
  177716             :     }
  177717       56799 :     ROSE_ASSERT(SgTypedefSymbol::next_node != nullptr);
  177718             : 
  177719       56799 :     SgTypedefSymbol * object = SgTypedefSymbol::next_node;
  177720       56799 :     SgTypedefSymbol::next_node = (SgTypedefSymbol*)(object->p_freepointer);
  177721             : 
  177722             : #if ROSE_ALLOC_TRACE == 2
  177723             :     printf("SgTypedefSymbol::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypedefSymbol::next_node);
  177724             : #endif
  177725             : 
  177726       56799 :     SgNode * fp = object->p_freepointer;
  177727             : #if ROSE_ALLOC_MEMSET == 1
  177728             : #elif ROSE_ALLOC_MEMSET == 2
  177729             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgTypedefSymbol) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  177730             : #elif ROSE_ALLOC_MEMSET == 3
  177731             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgTypedefSymbol) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  177732             : #endif
  177733       56799 :     object->p_freepointer = fp;
  177734             : 
  177735             : #if ROSE_ALLOC_TRACE == 2
  177736             : //    printf("SgTypedefSymbol::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypedefSymbol::next_node);
  177737             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  177738             :     Rose::MemPool::snapshot(oss.str());
  177739             :     alloc_trace_cnt++;
  177740             : #endif
  177741             : 
  177742       56799 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  177743             : 
  177744       56799 :     ALLOC_MUTEX(SgTypedefSymbol, unlock);
  177745             : 
  177746             :     return object;
  177747             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  177748             : }
  177749             : 
  177750             : 
  177751             : 
  177752             : /*! \brief Delete operator for SgTypedefSymbol.
  177753             : 
  177754             :    This delete operator implements deallocation using memory pools to 
  177755             :    provide most efficent use of the heap within construction of large ASTs.
  177756             : 
  177757             : \internal The new and delete operators use the lower level C malloc/free
  177758             :    function calls for performance and to make sure that mixing of malloc/free
  177759             :    and new/delete by the used can be caught more readily.  This may change
  177760             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  177761             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  177762             :    deallocate memory allocated using ROSE_MALLOC.
  177763             : */
  177764        3438 : void SgTypedefSymbol::operator delete(void *Pointer, size_t Size)
  177765             : {
  177766             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  177767             :      * or throwing an exception. */
  177768        3438 :     ALLOC_MUTEX(SgTypedefSymbol, lock);
  177769             : 
  177770             : #if USE_CPP_NEW_DELETE_OPERATORS
  177771             :     ROSE_FREE(Pointer);
  177772             : #else
  177773             : #if ROSE_PEDANTIC_ALLOC
  177774             :     ROSE_ASSERT(Size == sizeof(SgTypedefSymbol));
  177775             : #else
  177776        3438 :     if (Size != sizeof(SgTypedefSymbol)) {
  177777           0 :       ROSE_FREE(Pointer);
  177778           0 :       ALLOC_MUTEX(SgTypedefSymbol, unlock);
  177779             :       return;
  177780             :     }
  177781             : #endif
  177782             : 
  177783        3438 :     SgTypedefSymbol * object = (SgTypedefSymbol*) Pointer;
  177784        3438 :     ROSE_ASSERT(object != nullptr);
  177785             : 
  177786             : #if ROSE_ALLOC_TRACE == 2
  177787             : //  printf("SgTypedefSymbol::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypedefSymbol::next_node);
  177788             :     printf("SgTypedefSymbol::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypedefSymbol::next_node);
  177789             : #endif
  177790             : 
  177791             : #if ROSE_PEDANTIC_ALLOC
  177792             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  177793             : #endif
  177794             : 
  177795             : #if ROSE_ALLOC_MEMSET == 1
  177796             : #elif ROSE_ALLOC_MEMSET == 2
  177797             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgTypedefSymbol) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  177798             : #elif ROSE_ALLOC_MEMSET == 3
  177799             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgTypedefSymbol) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  177800             : #endif
  177801             : 
  177802             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  177803             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  177804             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  177805             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  177806             : #else
  177807        3438 :     object->p_freepointer = SgTypedefSymbol::next_node;
  177808        3438 :     SgTypedefSymbol::next_node = object;
  177809             : #endif
  177810             : 
  177811             : #if ROSE_ALLOC_TRACE == 2
  177812             : //  printf("SgTypedefSymbol::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTypedefSymbol::next_node);
  177813             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  177814             :     Rose::MemPool::snapshot(oss.str());
  177815             :     alloc_trace_cnt++;
  177816             : #endif
  177817             : 
  177818             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  177819             : 
  177820        3438 :     ALLOC_MUTEX(SgTypedefSymbol, unlock);
  177821             : }
  177822             : 
  177823             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  177824             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  177825             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  177826             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  177827             : // Also, note comment below from Robb (copied from the Common.code file).
  177828             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  177829             : //
  177830             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  177831             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  177832             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  177833             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  177834             : #if 0
  177835             : void SgTypedefSymbol::operator delete(void* pointer) { SgTypedefSymbol::operator delete (pointer, sizeof(SgTypedefSymbol)); };
  177836             : #endif
  177837             : /* #line 177838 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  177838             : 
  177839             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  177840             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  177841             : // obviously imply C++.
  177842             : 
  177843             : // This implements the support within ROSE for memory pools.  Memory pools
  177844             : // support the most condensed usage of memory within the construction of
  177845             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  177846             : // by a new operator written for each class.
  177847             : 
  177848             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  177849             :     // User wants multi-thread support and POSIX threads are available.
  177850             : #   include <pthread.h>
  177851             :     static pthread_mutex_t SgTemplateTypedefSymbol_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  177852             : #else
  177853             :      // Cause synchronization to be skipped.
  177854             : #    ifndef ALLOC_MUTEX
  177855             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  177856             : #    endif
  177857             : #    ifdef _REENTRANT
  177858             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  177859             : #       ifdef _MSC_VER
  177860             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  177861             : #       else
  177862             : #           warning "POSIX threads are not available; synchronization being skipped"
  177863             : #       endif
  177864             : #    endif
  177865             : #endif
  177866             : 
  177867             : #ifndef ROSE_ALLOC_TRACE
  177868             : #  define ROSE_ALLOC_TRACE 0
  177869             : #endif
  177870             : 
  177871             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  177872             : #define ROSE_ALLOC_TRACE_CNT
  177873             : #include "memory-pool-snapshot.h"
  177874             : unsigned long alloc_trace_cnt = 0;
  177875             : #endif
  177876             : 
  177877             : #if ROSE_ALLOC_TRACE
  177878             : const unsigned SgTemplateTypedefSymbol::pool_size = 5;
  177879             : #else
  177880             : const unsigned SgTemplateTypedefSymbol::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  177881             : #endif
  177882             : 
  177883             : #ifndef ROSE_ALLOC_MEMSET
  177884             : #  define ROSE_ALLOC_MEMSET 0
  177885             : #endif
  177886             : 
  177887             : #ifndef ROSE_PEDANTIC_ALLOC
  177888             : #  define ROSE_PEDANTIC_ALLOC 0
  177889             : #endif
  177890             : 
  177891             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  177892             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  177893             : #endif
  177894             : 
  177895             : #if !defined(SGNODE__ALL_POOLS)
  177896             : #define SGNODE__ALL_POOLS
  177897             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  177898             : #endif
  177899             : 
  177900             : SgTemplateTypedefSymbol* SgTemplateTypedefSymbol::next_node = nullptr;
  177901             : std::vector<unsigned char*> SgTemplateTypedefSymbol::pools;
  177902             : 
  177903             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  177904             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  177905             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  177906             : // around this macro definition rather than each use).
  177907             : #ifndef ALLOC_MUTEX
  177908             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  177909             :         do {                                                                     \
  177910             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  177911             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  177912             :                 abort();                                                         \
  177913             :             }                                                                    \
  177914             :         } while (0);
  177915             : #endif
  177916             : 
  177917             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  177918             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  177919             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  177920             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  177921             : 
  177922             : /*! \brief New operator for SgTemplateTypedefSymbol.
  177923             : 
  177924             :    This new operator implements memory pools to provide most efficent 
  177925             :    use of the heap within construction of large ASTs.
  177926             : 
  177927             : \internal The new and delete operators use the lower level C malloc/free
  177928             :    function calls for performance and to make sure that mixing of malloc/free
  177929             :    and new/delete by the used can be caught more readily.  This may change
  177930             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  177931             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  177932             :    deallocate memory allocated using ROSE_MALLOC.
  177933             : */
  177934        1654 : void *SgTemplateTypedefSymbol::operator new ( size_t Size )
  177935             : {
  177936             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  177937             :      * returning or throwing an exception. */
  177938        1654 :     ALLOC_MUTEX(SgTemplateTypedefSymbol, lock);
  177939             : 
  177940             : #if ROSE_ALLOC_TRACE == 2
  177941             : //    printf("SgTemplateTypedefSymbol::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgTemplateTypedefSymbol::next_node);
  177942             : #endif
  177943             : 
  177944             : #if USE_CPP_NEW_DELETE_OPERATORS
  177945             :     void *mem = ROSE_MALLOC(Size);
  177946             :     ALLOC_MUTEX(SgTemplateTypedefSymbol, unlock);
  177947             :     return mem;
  177948             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  177949             : #if ROSE_PEDANTIC_ALLOC
  177950             :     ROSE_ASSERT(Size == sizeof(SgTemplateTypedefSymbol));
  177951             : #else
  177952        1654 :     if (Size != sizeof(SgTemplateTypedefSymbol)) {
  177953           0 :       void * object = ROSE_MALLOC(Size);
  177954           0 :       ALLOC_MUTEX(SgTemplateTypedefSymbol, unlock);
  177955             :       return object;
  177956             :     }
  177957             : #endif
  177958             : 
  177959        1654 :     if (SgTemplateTypedefSymbol::next_node == nullptr) {
  177960          10 :         SgTemplateTypedefSymbol * alloc = (SgTemplateTypedefSymbol*) ROSE_MALLOC ( SgTemplateTypedefSymbol::pool_size * sizeof(SgTemplateTypedefSymbol) );
  177961          10 :         ROSE_ASSERT(alloc != nullptr);
  177962             : 
  177963             : #if ROSE_ALLOC_TRACE == 2
  177964             : //        printf("SgTemplateTypedefSymbol::alloc\n  block[%zi] = [ %p , %p [\n", SgTemplateTypedefSymbol::pools.size(), alloc, alloc + SgTemplateTypedefSymbol::pool_size);
  177965             : #endif
  177966             : 
  177967             : #if ROSE_ALLOC_MEMSET == 1
  177968             : #elif ROSE_ALLOC_MEMSET == 2
  177969             :         memset(alloc, 0x00, SgTemplateTypedefSymbol::pool_size * sizeof(SgTemplateTypedefSymbol));
  177970             : #elif ROSE_ALLOC_MEMSET == 3
  177971             :         memset(alloc, 0xAA, SgTemplateTypedefSymbol::pool_size * sizeof(SgTemplateTypedefSymbol));
  177972             : #endif
  177973       20000 :         for (unsigned i=0; i < SgTemplateTypedefSymbol::pool_size-1; i++) {
  177974       19990 :           alloc[i].p_freepointer = &(alloc[i+1]);
  177975             :         }
  177976          10 :         alloc[SgTemplateTypedefSymbol::pool_size-1].p_freepointer = nullptr;
  177977             : 
  177978          10 :         SgTemplateTypedefSymbol::pools.push_back ( (unsigned char *) alloc );
  177979          10 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgTemplateTypedefSymbol::pool_size * sizeof(SgTemplateTypedefSymbol), V_SgTemplateTypedefSymbol ) );
  177980          10 :         SgTemplateTypedefSymbol::next_node = alloc;
  177981             :     }
  177982        1654 :     ROSE_ASSERT(SgTemplateTypedefSymbol::next_node != nullptr);
  177983             : 
  177984        1654 :     SgTemplateTypedefSymbol * object = SgTemplateTypedefSymbol::next_node;
  177985        1654 :     SgTemplateTypedefSymbol::next_node = (SgTemplateTypedefSymbol*)(object->p_freepointer);
  177986             : 
  177987             : #if ROSE_ALLOC_TRACE == 2
  177988             :     printf("SgTemplateTypedefSymbol::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTemplateTypedefSymbol::next_node);
  177989             : #endif
  177990             : 
  177991        1654 :     SgNode * fp = object->p_freepointer;
  177992             : #if ROSE_ALLOC_MEMSET == 1
  177993             : #elif ROSE_ALLOC_MEMSET == 2
  177994             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgTemplateTypedefSymbol) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  177995             : #elif ROSE_ALLOC_MEMSET == 3
  177996             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgTemplateTypedefSymbol) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  177997             : #endif
  177998        1654 :     object->p_freepointer = fp;
  177999             : 
  178000             : #if ROSE_ALLOC_TRACE == 2
  178001             : //    printf("SgTemplateTypedefSymbol::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTemplateTypedefSymbol::next_node);
  178002             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  178003             :     Rose::MemPool::snapshot(oss.str());
  178004             :     alloc_trace_cnt++;
  178005             : #endif
  178006             : 
  178007        1654 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  178008             : 
  178009        1654 :     ALLOC_MUTEX(SgTemplateTypedefSymbol, unlock);
  178010             : 
  178011             :     return object;
  178012             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  178013             : }
  178014             : 
  178015             : 
  178016             : 
  178017             : /*! \brief Delete operator for SgTemplateTypedefSymbol.
  178018             : 
  178019             :    This delete operator implements deallocation using memory pools to 
  178020             :    provide most efficent use of the heap within construction of large ASTs.
  178021             : 
  178022             : \internal The new and delete operators use the lower level C malloc/free
  178023             :    function calls for performance and to make sure that mixing of malloc/free
  178024             :    and new/delete by the used can be caught more readily.  This may change
  178025             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  178026             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  178027             :    deallocate memory allocated using ROSE_MALLOC.
  178028             : */
  178029         320 : void SgTemplateTypedefSymbol::operator delete(void *Pointer, size_t Size)
  178030             : {
  178031             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  178032             :      * or throwing an exception. */
  178033         320 :     ALLOC_MUTEX(SgTemplateTypedefSymbol, lock);
  178034             : 
  178035             : #if USE_CPP_NEW_DELETE_OPERATORS
  178036             :     ROSE_FREE(Pointer);
  178037             : #else
  178038             : #if ROSE_PEDANTIC_ALLOC
  178039             :     ROSE_ASSERT(Size == sizeof(SgTemplateTypedefSymbol));
  178040             : #else
  178041         320 :     if (Size != sizeof(SgTemplateTypedefSymbol)) {
  178042           0 :       ROSE_FREE(Pointer);
  178043           0 :       ALLOC_MUTEX(SgTemplateTypedefSymbol, unlock);
  178044             :       return;
  178045             :     }
  178046             : #endif
  178047             : 
  178048         320 :     SgTemplateTypedefSymbol * object = (SgTemplateTypedefSymbol*) Pointer;
  178049         320 :     ROSE_ASSERT(object != nullptr);
  178050             : 
  178051             : #if ROSE_ALLOC_TRACE == 2
  178052             : //  printf("SgTemplateTypedefSymbol::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTemplateTypedefSymbol::next_node);
  178053             :     printf("SgTemplateTypedefSymbol::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTemplateTypedefSymbol::next_node);
  178054             : #endif
  178055             : 
  178056             : #if ROSE_PEDANTIC_ALLOC
  178057             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  178058             : #endif
  178059             : 
  178060             : #if ROSE_ALLOC_MEMSET == 1
  178061             : #elif ROSE_ALLOC_MEMSET == 2
  178062             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgTemplateTypedefSymbol) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  178063             : #elif ROSE_ALLOC_MEMSET == 3
  178064             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgTemplateTypedefSymbol) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  178065             : #endif
  178066             : 
  178067             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  178068             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  178069             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  178070             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  178071             : #else
  178072         320 :     object->p_freepointer = SgTemplateTypedefSymbol::next_node;
  178073         320 :     SgTemplateTypedefSymbol::next_node = object;
  178074             : #endif
  178075             : 
  178076             : #if ROSE_ALLOC_TRACE == 2
  178077             : //  printf("SgTemplateTypedefSymbol::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgTemplateTypedefSymbol::next_node);
  178078             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  178079             :     Rose::MemPool::snapshot(oss.str());
  178080             :     alloc_trace_cnt++;
  178081             : #endif
  178082             : 
  178083             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  178084             : 
  178085         320 :     ALLOC_MUTEX(SgTemplateTypedefSymbol, unlock);
  178086             : }
  178087             : 
  178088             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  178089             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  178090             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  178091             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  178092             : // Also, note comment below from Robb (copied from the Common.code file).
  178093             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  178094             : //
  178095             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  178096             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  178097             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  178098             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  178099             : #if 0
  178100             : void SgTemplateTypedefSymbol::operator delete(void* pointer) { SgTemplateTypedefSymbol::operator delete (pointer, sizeof(SgTemplateTypedefSymbol)); };
  178101             : #endif
  178102             : /* #line 178103 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  178103             : 
  178104             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  178105             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  178106             : // obviously imply C++.
  178107             : 
  178108             : // This implements the support within ROSE for memory pools.  Memory pools
  178109             : // support the most condensed usage of memory within the construction of
  178110             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  178111             : // by a new operator written for each class.
  178112             : 
  178113             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  178114             :     // User wants multi-thread support and POSIX threads are available.
  178115             : #   include <pthread.h>
  178116             :     static pthread_mutex_t SgLabelSymbol_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  178117             : #else
  178118             :      // Cause synchronization to be skipped.
  178119             : #    ifndef ALLOC_MUTEX
  178120             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  178121             : #    endif
  178122             : #    ifdef _REENTRANT
  178123             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  178124             : #       ifdef _MSC_VER
  178125             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  178126             : #       else
  178127             : #           warning "POSIX threads are not available; synchronization being skipped"
  178128             : #       endif
  178129             : #    endif
  178130             : #endif
  178131             : 
  178132             : #ifndef ROSE_ALLOC_TRACE
  178133             : #  define ROSE_ALLOC_TRACE 0
  178134             : #endif
  178135             : 
  178136             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  178137             : #define ROSE_ALLOC_TRACE_CNT
  178138             : #include "memory-pool-snapshot.h"
  178139             : unsigned long alloc_trace_cnt = 0;
  178140             : #endif
  178141             : 
  178142             : #if ROSE_ALLOC_TRACE
  178143             : const unsigned SgLabelSymbol::pool_size = 5;
  178144             : #else
  178145             : const unsigned SgLabelSymbol::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  178146             : #endif
  178147             : 
  178148             : #ifndef ROSE_ALLOC_MEMSET
  178149             : #  define ROSE_ALLOC_MEMSET 0
  178150             : #endif
  178151             : 
  178152             : #ifndef ROSE_PEDANTIC_ALLOC
  178153             : #  define ROSE_PEDANTIC_ALLOC 0
  178154             : #endif
  178155             : 
  178156             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  178157             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  178158             : #endif
  178159             : 
  178160             : #if !defined(SGNODE__ALL_POOLS)
  178161             : #define SGNODE__ALL_POOLS
  178162             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  178163             : #endif
  178164             : 
  178165             : SgLabelSymbol* SgLabelSymbol::next_node = nullptr;
  178166             : std::vector<unsigned char*> SgLabelSymbol::pools;
  178167             : 
  178168             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  178169             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  178170             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  178171             : // around this macro definition rather than each use).
  178172             : #ifndef ALLOC_MUTEX
  178173             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  178174             :         do {                                                                     \
  178175             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  178176             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  178177             :                 abort();                                                         \
  178178             :             }                                                                    \
  178179             :         } while (0);
  178180             : #endif
  178181             : 
  178182             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  178183             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  178184             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  178185             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  178186             : 
  178187             : /*! \brief New operator for SgLabelSymbol.
  178188             : 
  178189             :    This new operator implements memory pools to provide most efficent 
  178190             :    use of the heap within construction of large ASTs.
  178191             : 
  178192             : \internal The new and delete operators use the lower level C malloc/free
  178193             :    function calls for performance and to make sure that mixing of malloc/free
  178194             :    and new/delete by the used can be caught more readily.  This may change
  178195             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  178196             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  178197             :    deallocate memory allocated using ROSE_MALLOC.
  178198             : */
  178199          11 : void *SgLabelSymbol::operator new ( size_t Size )
  178200             : {
  178201             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  178202             :      * returning or throwing an exception. */
  178203          11 :     ALLOC_MUTEX(SgLabelSymbol, lock);
  178204             : 
  178205             : #if ROSE_ALLOC_TRACE == 2
  178206             : //    printf("SgLabelSymbol::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgLabelSymbol::next_node);
  178207             : #endif
  178208             : 
  178209             : #if USE_CPP_NEW_DELETE_OPERATORS
  178210             :     void *mem = ROSE_MALLOC(Size);
  178211             :     ALLOC_MUTEX(SgLabelSymbol, unlock);
  178212             :     return mem;
  178213             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  178214             : #if ROSE_PEDANTIC_ALLOC
  178215             :     ROSE_ASSERT(Size == sizeof(SgLabelSymbol));
  178216             : #else
  178217          11 :     if (Size != sizeof(SgLabelSymbol)) {
  178218           0 :       void * object = ROSE_MALLOC(Size);
  178219           0 :       ALLOC_MUTEX(SgLabelSymbol, unlock);
  178220             :       return object;
  178221             :     }
  178222             : #endif
  178223             : 
  178224          11 :     if (SgLabelSymbol::next_node == nullptr) {
  178225           5 :         SgLabelSymbol * alloc = (SgLabelSymbol*) ROSE_MALLOC ( SgLabelSymbol::pool_size * sizeof(SgLabelSymbol) );
  178226           5 :         ROSE_ASSERT(alloc != nullptr);
  178227             : 
  178228             : #if ROSE_ALLOC_TRACE == 2
  178229             : //        printf("SgLabelSymbol::alloc\n  block[%zi] = [ %p , %p [\n", SgLabelSymbol::pools.size(), alloc, alloc + SgLabelSymbol::pool_size);
  178230             : #endif
  178231             : 
  178232             : #if ROSE_ALLOC_MEMSET == 1
  178233             : #elif ROSE_ALLOC_MEMSET == 2
  178234             :         memset(alloc, 0x00, SgLabelSymbol::pool_size * sizeof(SgLabelSymbol));
  178235             : #elif ROSE_ALLOC_MEMSET == 3
  178236             :         memset(alloc, 0xAA, SgLabelSymbol::pool_size * sizeof(SgLabelSymbol));
  178237             : #endif
  178238       10000 :         for (unsigned i=0; i < SgLabelSymbol::pool_size-1; i++) {
  178239        9995 :           alloc[i].p_freepointer = &(alloc[i+1]);
  178240             :         }
  178241           5 :         alloc[SgLabelSymbol::pool_size-1].p_freepointer = nullptr;
  178242             : 
  178243           5 :         SgLabelSymbol::pools.push_back ( (unsigned char *) alloc );
  178244           5 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgLabelSymbol::pool_size * sizeof(SgLabelSymbol), V_SgLabelSymbol ) );
  178245           5 :         SgLabelSymbol::next_node = alloc;
  178246             :     }
  178247          11 :     ROSE_ASSERT(SgLabelSymbol::next_node != nullptr);
  178248             : 
  178249          11 :     SgLabelSymbol * object = SgLabelSymbol::next_node;
  178250          11 :     SgLabelSymbol::next_node = (SgLabelSymbol*)(object->p_freepointer);
  178251             : 
  178252             : #if ROSE_ALLOC_TRACE == 2
  178253             :     printf("SgLabelSymbol::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgLabelSymbol::next_node);
  178254             : #endif
  178255             : 
  178256          11 :     SgNode * fp = object->p_freepointer;
  178257             : #if ROSE_ALLOC_MEMSET == 1
  178258             : #elif ROSE_ALLOC_MEMSET == 2
  178259             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgLabelSymbol) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  178260             : #elif ROSE_ALLOC_MEMSET == 3
  178261             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgLabelSymbol) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  178262             : #endif
  178263          11 :     object->p_freepointer = fp;
  178264             : 
  178265             : #if ROSE_ALLOC_TRACE == 2
  178266             : //    printf("SgLabelSymbol::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgLabelSymbol::next_node);
  178267             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  178268             :     Rose::MemPool::snapshot(oss.str());
  178269             :     alloc_trace_cnt++;
  178270             : #endif
  178271             : 
  178272          11 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  178273             : 
  178274          11 :     ALLOC_MUTEX(SgLabelSymbol, unlock);
  178275             : 
  178276             :     return object;
  178277             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  178278             : }
  178279             : 
  178280             : 
  178281             : 
  178282             : /*! \brief Delete operator for SgLabelSymbol.
  178283             : 
  178284             :    This delete operator implements deallocation using memory pools to 
  178285             :    provide most efficent use of the heap within construction of large ASTs.
  178286             : 
  178287             : \internal The new and delete operators use the lower level C malloc/free
  178288             :    function calls for performance and to make sure that mixing of malloc/free
  178289             :    and new/delete by the used can be caught more readily.  This may change
  178290             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  178291             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  178292             :    deallocate memory allocated using ROSE_MALLOC.
  178293             : */
  178294           0 : void SgLabelSymbol::operator delete(void *Pointer, size_t Size)
  178295             : {
  178296             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  178297             :      * or throwing an exception. */
  178298           0 :     ALLOC_MUTEX(SgLabelSymbol, lock);
  178299             : 
  178300             : #if USE_CPP_NEW_DELETE_OPERATORS
  178301             :     ROSE_FREE(Pointer);
  178302             : #else
  178303             : #if ROSE_PEDANTIC_ALLOC
  178304             :     ROSE_ASSERT(Size == sizeof(SgLabelSymbol));
  178305             : #else
  178306           0 :     if (Size != sizeof(SgLabelSymbol)) {
  178307           0 :       ROSE_FREE(Pointer);
  178308           0 :       ALLOC_MUTEX(SgLabelSymbol, unlock);
  178309             :       return;
  178310             :     }
  178311             : #endif
  178312             : 
  178313           0 :     SgLabelSymbol * object = (SgLabelSymbol*) Pointer;
  178314           0 :     ROSE_ASSERT(object != nullptr);
  178315             : 
  178316             : #if ROSE_ALLOC_TRACE == 2
  178317             : //  printf("SgLabelSymbol::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgLabelSymbol::next_node);
  178318             :     printf("SgLabelSymbol::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgLabelSymbol::next_node);
  178319             : #endif
  178320             : 
  178321             : #if ROSE_PEDANTIC_ALLOC
  178322             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  178323             : #endif
  178324             : 
  178325             : #if ROSE_ALLOC_MEMSET == 1
  178326             : #elif ROSE_ALLOC_MEMSET == 2
  178327             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgLabelSymbol) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  178328             : #elif ROSE_ALLOC_MEMSET == 3
  178329             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgLabelSymbol) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  178330             : #endif
  178331             : 
  178332             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  178333             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  178334             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  178335             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  178336             : #else
  178337           0 :     object->p_freepointer = SgLabelSymbol::next_node;
  178338           0 :     SgLabelSymbol::next_node = object;
  178339             : #endif
  178340             : 
  178341             : #if ROSE_ALLOC_TRACE == 2
  178342             : //  printf("SgLabelSymbol::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgLabelSymbol::next_node);
  178343             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  178344             :     Rose::MemPool::snapshot(oss.str());
  178345             :     alloc_trace_cnt++;
  178346             : #endif
  178347             : 
  178348             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  178349             : 
  178350           0 :     ALLOC_MUTEX(SgLabelSymbol, unlock);
  178351             : }
  178352             : 
  178353             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  178354             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  178355             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  178356             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  178357             : // Also, note comment below from Robb (copied from the Common.code file).
  178358             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  178359             : //
  178360             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  178361             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  178362             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  178363             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  178364             : #if 0
  178365             : void SgLabelSymbol::operator delete(void* pointer) { SgLabelSymbol::operator delete (pointer, sizeof(SgLabelSymbol)); };
  178366             : #endif
  178367             : /* #line 178368 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  178368             : 
  178369             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  178370             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  178371             : // obviously imply C++.
  178372             : 
  178373             : // This implements the support within ROSE for memory pools.  Memory pools
  178374             : // support the most condensed usage of memory within the construction of
  178375             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  178376             : // by a new operator written for each class.
  178377             : 
  178378             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  178379             :     // User wants multi-thread support and POSIX threads are available.
  178380             : #   include <pthread.h>
  178381             :     static pthread_mutex_t SgDefaultSymbol_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  178382             : #else
  178383             :      // Cause synchronization to be skipped.
  178384             : #    ifndef ALLOC_MUTEX
  178385             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  178386             : #    endif
  178387             : #    ifdef _REENTRANT
  178388             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  178389             : #       ifdef _MSC_VER
  178390             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  178391             : #       else
  178392             : #           warning "POSIX threads are not available; synchronization being skipped"
  178393             : #       endif
  178394             : #    endif
  178395             : #endif
  178396             : 
  178397             : #ifndef ROSE_ALLOC_TRACE
  178398             : #  define ROSE_ALLOC_TRACE 0
  178399             : #endif
  178400             : 
  178401             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  178402             : #define ROSE_ALLOC_TRACE_CNT
  178403             : #include "memory-pool-snapshot.h"
  178404             : unsigned long alloc_trace_cnt = 0;
  178405             : #endif
  178406             : 
  178407             : #if ROSE_ALLOC_TRACE
  178408             : const unsigned SgDefaultSymbol::pool_size = 5;
  178409             : #else
  178410             : const unsigned SgDefaultSymbol::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  178411             : #endif
  178412             : 
  178413             : #ifndef ROSE_ALLOC_MEMSET
  178414             : #  define ROSE_ALLOC_MEMSET 0
  178415             : #endif
  178416             : 
  178417             : #ifndef ROSE_PEDANTIC_ALLOC
  178418             : #  define ROSE_PEDANTIC_ALLOC 0
  178419             : #endif
  178420             : 
  178421             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  178422             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  178423             : #endif
  178424             : 
  178425             : #if !defined(SGNODE__ALL_POOLS)
  178426             : #define SGNODE__ALL_POOLS
  178427             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  178428             : #endif
  178429             : 
  178430             : SgDefaultSymbol* SgDefaultSymbol::next_node = nullptr;
  178431             : std::vector<unsigned char*> SgDefaultSymbol::pools;
  178432             : 
  178433             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  178434             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  178435             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  178436             : // around this macro definition rather than each use).
  178437             : #ifndef ALLOC_MUTEX
  178438             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  178439             :         do {                                                                     \
  178440             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  178441             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  178442             :                 abort();                                                         \
  178443             :             }                                                                    \
  178444             :         } while (0);
  178445             : #endif
  178446             : 
  178447             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  178448             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  178449             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  178450             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  178451             : 
  178452             : /*! \brief New operator for SgDefaultSymbol.
  178453             : 
  178454             :    This new operator implements memory pools to provide most efficent 
  178455             :    use of the heap within construction of large ASTs.
  178456             : 
  178457             : \internal The new and delete operators use the lower level C malloc/free
  178458             :    function calls for performance and to make sure that mixing of malloc/free
  178459             :    and new/delete by the used can be caught more readily.  This may change
  178460             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  178461             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  178462             :    deallocate memory allocated using ROSE_MALLOC.
  178463             : */
  178464           0 : void *SgDefaultSymbol::operator new ( size_t Size )
  178465             : {
  178466             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  178467             :      * returning or throwing an exception. */
  178468           0 :     ALLOC_MUTEX(SgDefaultSymbol, lock);
  178469             : 
  178470             : #if ROSE_ALLOC_TRACE == 2
  178471             : //    printf("SgDefaultSymbol::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgDefaultSymbol::next_node);
  178472             : #endif
  178473             : 
  178474             : #if USE_CPP_NEW_DELETE_OPERATORS
  178475             :     void *mem = ROSE_MALLOC(Size);
  178476             :     ALLOC_MUTEX(SgDefaultSymbol, unlock);
  178477             :     return mem;
  178478             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  178479             : #if ROSE_PEDANTIC_ALLOC
  178480             :     ROSE_ASSERT(Size == sizeof(SgDefaultSymbol));
  178481             : #else
  178482           0 :     if (Size != sizeof(SgDefaultSymbol)) {
  178483           0 :       void * object = ROSE_MALLOC(Size);
  178484           0 :       ALLOC_MUTEX(SgDefaultSymbol, unlock);
  178485             :       return object;
  178486             :     }
  178487             : #endif
  178488             : 
  178489           0 :     if (SgDefaultSymbol::next_node == nullptr) {
  178490           0 :         SgDefaultSymbol * alloc = (SgDefaultSymbol*) ROSE_MALLOC ( SgDefaultSymbol::pool_size * sizeof(SgDefaultSymbol) );
  178491           0 :         ROSE_ASSERT(alloc != nullptr);
  178492             : 
  178493             : #if ROSE_ALLOC_TRACE == 2
  178494             : //        printf("SgDefaultSymbol::alloc\n  block[%zi] = [ %p , %p [\n", SgDefaultSymbol::pools.size(), alloc, alloc + SgDefaultSymbol::pool_size);
  178495             : #endif
  178496             : 
  178497             : #if ROSE_ALLOC_MEMSET == 1
  178498             : #elif ROSE_ALLOC_MEMSET == 2
  178499             :         memset(alloc, 0x00, SgDefaultSymbol::pool_size * sizeof(SgDefaultSymbol));
  178500             : #elif ROSE_ALLOC_MEMSET == 3
  178501             :         memset(alloc, 0xAA, SgDefaultSymbol::pool_size * sizeof(SgDefaultSymbol));
  178502             : #endif
  178503           0 :         for (unsigned i=0; i < SgDefaultSymbol::pool_size-1; i++) {
  178504           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
  178505             :         }
  178506           0 :         alloc[SgDefaultSymbol::pool_size-1].p_freepointer = nullptr;
  178507             : 
  178508           0 :         SgDefaultSymbol::pools.push_back ( (unsigned char *) alloc );
  178509           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgDefaultSymbol::pool_size * sizeof(SgDefaultSymbol), V_SgDefaultSymbol ) );
  178510           0 :         SgDefaultSymbol::next_node = alloc;
  178511             :     }
  178512           0 :     ROSE_ASSERT(SgDefaultSymbol::next_node != nullptr);
  178513             : 
  178514           0 :     SgDefaultSymbol * object = SgDefaultSymbol::next_node;
  178515           0 :     SgDefaultSymbol::next_node = (SgDefaultSymbol*)(object->p_freepointer);
  178516             : 
  178517             : #if ROSE_ALLOC_TRACE == 2
  178518             :     printf("SgDefaultSymbol::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgDefaultSymbol::next_node);
  178519             : #endif
  178520             : 
  178521           0 :     SgNode * fp = object->p_freepointer;
  178522             : #if ROSE_ALLOC_MEMSET == 1
  178523             : #elif ROSE_ALLOC_MEMSET == 2
  178524             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgDefaultSymbol) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  178525             : #elif ROSE_ALLOC_MEMSET == 3
  178526             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgDefaultSymbol) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  178527             : #endif
  178528           0 :     object->p_freepointer = fp;
  178529             : 
  178530             : #if ROSE_ALLOC_TRACE == 2
  178531             : //    printf("SgDefaultSymbol::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgDefaultSymbol::next_node);
  178532             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  178533             :     Rose::MemPool::snapshot(oss.str());
  178534             :     alloc_trace_cnt++;
  178535             : #endif
  178536             : 
  178537           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  178538             : 
  178539           0 :     ALLOC_MUTEX(SgDefaultSymbol, unlock);
  178540             : 
  178541             :     return object;
  178542             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  178543             : }
  178544             : 
  178545             : 
  178546             : 
  178547             : /*! \brief Delete operator for SgDefaultSymbol.
  178548             : 
  178549             :    This delete operator implements deallocation using memory pools to 
  178550             :    provide most efficent use of the heap within construction of large ASTs.
  178551             : 
  178552             : \internal The new and delete operators use the lower level C malloc/free
  178553             :    function calls for performance and to make sure that mixing of malloc/free
  178554             :    and new/delete by the used can be caught more readily.  This may change
  178555             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  178556             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  178557             :    deallocate memory allocated using ROSE_MALLOC.
  178558             : */
  178559           0 : void SgDefaultSymbol::operator delete(void *Pointer, size_t Size)
  178560             : {
  178561             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  178562             :      * or throwing an exception. */
  178563           0 :     ALLOC_MUTEX(SgDefaultSymbol, lock);
  178564             : 
  178565             : #if USE_CPP_NEW_DELETE_OPERATORS
  178566             :     ROSE_FREE(Pointer);
  178567             : #else
  178568             : #if ROSE_PEDANTIC_ALLOC
  178569             :     ROSE_ASSERT(Size == sizeof(SgDefaultSymbol));
  178570             : #else
  178571           0 :     if (Size != sizeof(SgDefaultSymbol)) {
  178572           0 :       ROSE_FREE(Pointer);
  178573           0 :       ALLOC_MUTEX(SgDefaultSymbol, unlock);
  178574             :       return;
  178575             :     }
  178576             : #endif
  178577             : 
  178578           0 :     SgDefaultSymbol * object = (SgDefaultSymbol*) Pointer;
  178579           0 :     ROSE_ASSERT(object != nullptr);
  178580             : 
  178581             : #if ROSE_ALLOC_TRACE == 2
  178582             : //  printf("SgDefaultSymbol::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgDefaultSymbol::next_node);
  178583             :     printf("SgDefaultSymbol::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgDefaultSymbol::next_node);
  178584             : #endif
  178585             : 
  178586             : #if ROSE_PEDANTIC_ALLOC
  178587             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  178588             : #endif
  178589             : 
  178590             : #if ROSE_ALLOC_MEMSET == 1
  178591             : #elif ROSE_ALLOC_MEMSET == 2
  178592             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgDefaultSymbol) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  178593             : #elif ROSE_ALLOC_MEMSET == 3
  178594             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgDefaultSymbol) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  178595             : #endif
  178596             : 
  178597             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  178598             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  178599             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  178600             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  178601             : #else
  178602           0 :     object->p_freepointer = SgDefaultSymbol::next_node;
  178603           0 :     SgDefaultSymbol::next_node = object;
  178604             : #endif
  178605             : 
  178606             : #if ROSE_ALLOC_TRACE == 2
  178607             : //  printf("SgDefaultSymbol::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgDefaultSymbol::next_node);
  178608             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  178609             :     Rose::MemPool::snapshot(oss.str());
  178610             :     alloc_trace_cnt++;
  178611             : #endif
  178612             : 
  178613             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  178614             : 
  178615           0 :     ALLOC_MUTEX(SgDefaultSymbol, unlock);
  178616             : }
  178617             : 
  178618             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  178619             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  178620             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  178621             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  178622             : // Also, note comment below from Robb (copied from the Common.code file).
  178623             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  178624             : //
  178625             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  178626             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  178627             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  178628             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  178629             : #if 0
  178630             : void SgDefaultSymbol::operator delete(void* pointer) { SgDefaultSymbol::operator delete (pointer, sizeof(SgDefaultSymbol)); };
  178631             : #endif
  178632             : /* #line 178633 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  178633             : 
  178634             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  178635             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  178636             : // obviously imply C++.
  178637             : 
  178638             : // This implements the support within ROSE for memory pools.  Memory pools
  178639             : // support the most condensed usage of memory within the construction of
  178640             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  178641             : // by a new operator written for each class.
  178642             : 
  178643             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  178644             :     // User wants multi-thread support and POSIX threads are available.
  178645             : #   include <pthread.h>
  178646             :     static pthread_mutex_t SgNamespaceSymbol_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  178647             : #else
  178648             :      // Cause synchronization to be skipped.
  178649             : #    ifndef ALLOC_MUTEX
  178650             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  178651             : #    endif
  178652             : #    ifdef _REENTRANT
  178653             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  178654             : #       ifdef _MSC_VER
  178655             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  178656             : #       else
  178657             : #           warning "POSIX threads are not available; synchronization being skipped"
  178658             : #       endif
  178659             : #    endif
  178660             : #endif
  178661             : 
  178662             : #ifndef ROSE_ALLOC_TRACE
  178663             : #  define ROSE_ALLOC_TRACE 0
  178664             : #endif
  178665             : 
  178666             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  178667             : #define ROSE_ALLOC_TRACE_CNT
  178668             : #include "memory-pool-snapshot.h"
  178669             : unsigned long alloc_trace_cnt = 0;
  178670             : #endif
  178671             : 
  178672             : #if ROSE_ALLOC_TRACE
  178673             : const unsigned SgNamespaceSymbol::pool_size = 5;
  178674             : #else
  178675             : const unsigned SgNamespaceSymbol::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  178676             : #endif
  178677             : 
  178678             : #ifndef ROSE_ALLOC_MEMSET
  178679             : #  define ROSE_ALLOC_MEMSET 0
  178680             : #endif
  178681             : 
  178682             : #ifndef ROSE_PEDANTIC_ALLOC
  178683             : #  define ROSE_PEDANTIC_ALLOC 0
  178684             : #endif
  178685             : 
  178686             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  178687             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  178688             : #endif
  178689             : 
  178690             : #if !defined(SGNODE__ALL_POOLS)
  178691             : #define SGNODE__ALL_POOLS
  178692             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  178693             : #endif
  178694             : 
  178695             : SgNamespaceSymbol* SgNamespaceSymbol::next_node = nullptr;
  178696             : std::vector<unsigned char*> SgNamespaceSymbol::pools;
  178697             : 
  178698             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  178699             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  178700             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  178701             : // around this macro definition rather than each use).
  178702             : #ifndef ALLOC_MUTEX
  178703             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  178704             :         do {                                                                     \
  178705             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  178706             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  178707             :                 abort();                                                         \
  178708             :             }                                                                    \
  178709             :         } while (0);
  178710             : #endif
  178711             : 
  178712             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  178713             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  178714             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  178715             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  178716             : 
  178717             : /*! \brief New operator for SgNamespaceSymbol.
  178718             : 
  178719             :    This new operator implements memory pools to provide most efficent 
  178720             :    use of the heap within construction of large ASTs.
  178721             : 
  178722             : \internal The new and delete operators use the lower level C malloc/free
  178723             :    function calls for performance and to make sure that mixing of malloc/free
  178724             :    and new/delete by the used can be caught more readily.  This may change
  178725             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  178726             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  178727             :    deallocate memory allocated using ROSE_MALLOC.
  178728             : */
  178729         163 : void *SgNamespaceSymbol::operator new ( size_t Size )
  178730             : {
  178731             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  178732             :      * returning or throwing an exception. */
  178733         163 :     ALLOC_MUTEX(SgNamespaceSymbol, lock);
  178734             : 
  178735             : #if ROSE_ALLOC_TRACE == 2
  178736             : //    printf("SgNamespaceSymbol::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgNamespaceSymbol::next_node);
  178737             : #endif
  178738             : 
  178739             : #if USE_CPP_NEW_DELETE_OPERATORS
  178740             :     void *mem = ROSE_MALLOC(Size);
  178741             :     ALLOC_MUTEX(SgNamespaceSymbol, unlock);
  178742             :     return mem;
  178743             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  178744             : #if ROSE_PEDANTIC_ALLOC
  178745             :     ROSE_ASSERT(Size == sizeof(SgNamespaceSymbol));
  178746             : #else
  178747         163 :     if (Size != sizeof(SgNamespaceSymbol)) {
  178748           0 :       void * object = ROSE_MALLOC(Size);
  178749           0 :       ALLOC_MUTEX(SgNamespaceSymbol, unlock);
  178750             :       return object;
  178751             :     }
  178752             : #endif
  178753             : 
  178754         163 :     if (SgNamespaceSymbol::next_node == nullptr) {
  178755          16 :         SgNamespaceSymbol * alloc = (SgNamespaceSymbol*) ROSE_MALLOC ( SgNamespaceSymbol::pool_size * sizeof(SgNamespaceSymbol) );
  178756          16 :         ROSE_ASSERT(alloc != nullptr);
  178757             : 
  178758             : #if ROSE_ALLOC_TRACE == 2
  178759             : //        printf("SgNamespaceSymbol::alloc\n  block[%zi] = [ %p , %p [\n", SgNamespaceSymbol::pools.size(), alloc, alloc + SgNamespaceSymbol::pool_size);
  178760             : #endif
  178761             : 
  178762             : #if ROSE_ALLOC_MEMSET == 1
  178763             : #elif ROSE_ALLOC_MEMSET == 2
  178764             :         memset(alloc, 0x00, SgNamespaceSymbol::pool_size * sizeof(SgNamespaceSymbol));
  178765             : #elif ROSE_ALLOC_MEMSET == 3
  178766             :         memset(alloc, 0xAA, SgNamespaceSymbol::pool_size * sizeof(SgNamespaceSymbol));
  178767             : #endif
  178768       32000 :         for (unsigned i=0; i < SgNamespaceSymbol::pool_size-1; i++) {
  178769       31984 :           alloc[i].p_freepointer = &(alloc[i+1]);
  178770             :         }
  178771          16 :         alloc[SgNamespaceSymbol::pool_size-1].p_freepointer = nullptr;
  178772             : 
  178773          16 :         SgNamespaceSymbol::pools.push_back ( (unsigned char *) alloc );
  178774          16 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgNamespaceSymbol::pool_size * sizeof(SgNamespaceSymbol), V_SgNamespaceSymbol ) );
  178775          16 :         SgNamespaceSymbol::next_node = alloc;
  178776             :     }
  178777         163 :     ROSE_ASSERT(SgNamespaceSymbol::next_node != nullptr);
  178778             : 
  178779         163 :     SgNamespaceSymbol * object = SgNamespaceSymbol::next_node;
  178780         163 :     SgNamespaceSymbol::next_node = (SgNamespaceSymbol*)(object->p_freepointer);
  178781             : 
  178782             : #if ROSE_ALLOC_TRACE == 2
  178783             :     printf("SgNamespaceSymbol::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgNamespaceSymbol::next_node);
  178784             : #endif
  178785             : 
  178786         163 :     SgNode * fp = object->p_freepointer;
  178787             : #if ROSE_ALLOC_MEMSET == 1
  178788             : #elif ROSE_ALLOC_MEMSET == 2
  178789             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgNamespaceSymbol) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  178790             : #elif ROSE_ALLOC_MEMSET == 3
  178791             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgNamespaceSymbol) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  178792             : #endif
  178793         163 :     object->p_freepointer = fp;
  178794             : 
  178795             : #if ROSE_ALLOC_TRACE == 2
  178796             : //    printf("SgNamespaceSymbol::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgNamespaceSymbol::next_node);
  178797             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  178798             :     Rose::MemPool::snapshot(oss.str());
  178799             :     alloc_trace_cnt++;
  178800             : #endif
  178801             : 
  178802         163 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  178803             : 
  178804         163 :     ALLOC_MUTEX(SgNamespaceSymbol, unlock);
  178805             : 
  178806             :     return object;
  178807             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  178808             : }
  178809             : 
  178810             : 
  178811             : 
  178812             : /*! \brief Delete operator for SgNamespaceSymbol.
  178813             : 
  178814             :    This delete operator implements deallocation using memory pools to 
  178815             :    provide most efficent use of the heap within construction of large ASTs.
  178816             : 
  178817             : \internal The new and delete operators use the lower level C malloc/free
  178818             :    function calls for performance and to make sure that mixing of malloc/free
  178819             :    and new/delete by the used can be caught more readily.  This may change
  178820             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  178821             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  178822             :    deallocate memory allocated using ROSE_MALLOC.
  178823             : */
  178824          28 : void SgNamespaceSymbol::operator delete(void *Pointer, size_t Size)
  178825             : {
  178826             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  178827             :      * or throwing an exception. */
  178828          28 :     ALLOC_MUTEX(SgNamespaceSymbol, lock);
  178829             : 
  178830             : #if USE_CPP_NEW_DELETE_OPERATORS
  178831             :     ROSE_FREE(Pointer);
  178832             : #else
  178833             : #if ROSE_PEDANTIC_ALLOC
  178834             :     ROSE_ASSERT(Size == sizeof(SgNamespaceSymbol));
  178835             : #else
  178836          28 :     if (Size != sizeof(SgNamespaceSymbol)) {
  178837           0 :       ROSE_FREE(Pointer);
  178838           0 :       ALLOC_MUTEX(SgNamespaceSymbol, unlock);
  178839             :       return;
  178840             :     }
  178841             : #endif
  178842             : 
  178843          28 :     SgNamespaceSymbol * object = (SgNamespaceSymbol*) Pointer;
  178844          28 :     ROSE_ASSERT(object != nullptr);
  178845             : 
  178846             : #if ROSE_ALLOC_TRACE == 2
  178847             : //  printf("SgNamespaceSymbol::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgNamespaceSymbol::next_node);
  178848             :     printf("SgNamespaceSymbol::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgNamespaceSymbol::next_node);
  178849             : #endif
  178850             : 
  178851             : #if ROSE_PEDANTIC_ALLOC
  178852             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  178853             : #endif
  178854             : 
  178855             : #if ROSE_ALLOC_MEMSET == 1
  178856             : #elif ROSE_ALLOC_MEMSET == 2
  178857             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgNamespaceSymbol) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  178858             : #elif ROSE_ALLOC_MEMSET == 3
  178859             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgNamespaceSymbol) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  178860             : #endif
  178861             : 
  178862             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  178863             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  178864             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  178865             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  178866             : #else
  178867          28 :     object->p_freepointer = SgNamespaceSymbol::next_node;
  178868          28 :     SgNamespaceSymbol::next_node = object;
  178869             : #endif
  178870             : 
  178871             : #if ROSE_ALLOC_TRACE == 2
  178872             : //  printf("SgNamespaceSymbol::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgNamespaceSymbol::next_node);
  178873             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  178874             :     Rose::MemPool::snapshot(oss.str());
  178875             :     alloc_trace_cnt++;
  178876             : #endif
  178877             : 
  178878             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  178879             : 
  178880          28 :     ALLOC_MUTEX(SgNamespaceSymbol, unlock);
  178881             : }
  178882             : 
  178883             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  178884             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  178885             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  178886             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  178887             : // Also, note comment below from Robb (copied from the Common.code file).
  178888             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  178889             : //
  178890             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  178891             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  178892             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  178893             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  178894             : #if 0
  178895             : void SgNamespaceSymbol::operator delete(void* pointer) { SgNamespaceSymbol::operator delete (pointer, sizeof(SgNamespaceSymbol)); };
  178896             : #endif
  178897             : /* #line 178898 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  178898             : 
  178899             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  178900             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  178901             : // obviously imply C++.
  178902             : 
  178903             : // This implements the support within ROSE for memory pools.  Memory pools
  178904             : // support the most condensed usage of memory within the construction of
  178905             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  178906             : // by a new operator written for each class.
  178907             : 
  178908             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  178909             :     // User wants multi-thread support and POSIX threads are available.
  178910             : #   include <pthread.h>
  178911             :     static pthread_mutex_t SgIntrinsicSymbol_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  178912             : #else
  178913             :      // Cause synchronization to be skipped.
  178914             : #    ifndef ALLOC_MUTEX
  178915             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  178916             : #    endif
  178917             : #    ifdef _REENTRANT
  178918             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  178919             : #       ifdef _MSC_VER
  178920             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  178921             : #       else
  178922             : #           warning "POSIX threads are not available; synchronization being skipped"
  178923             : #       endif
  178924             : #    endif
  178925             : #endif
  178926             : 
  178927             : #ifndef ROSE_ALLOC_TRACE
  178928             : #  define ROSE_ALLOC_TRACE 0
  178929             : #endif
  178930             : 
  178931             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  178932             : #define ROSE_ALLOC_TRACE_CNT
  178933             : #include "memory-pool-snapshot.h"
  178934             : unsigned long alloc_trace_cnt = 0;
  178935             : #endif
  178936             : 
  178937             : #if ROSE_ALLOC_TRACE
  178938             : const unsigned SgIntrinsicSymbol::pool_size = 5;
  178939             : #else
  178940             : const unsigned SgIntrinsicSymbol::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  178941             : #endif
  178942             : 
  178943             : #ifndef ROSE_ALLOC_MEMSET
  178944             : #  define ROSE_ALLOC_MEMSET 0
  178945             : #endif
  178946             : 
  178947             : #ifndef ROSE_PEDANTIC_ALLOC
  178948             : #  define ROSE_PEDANTIC_ALLOC 0
  178949             : #endif
  178950             : 
  178951             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  178952             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  178953             : #endif
  178954             : 
  178955             : #if !defined(SGNODE__ALL_POOLS)
  178956             : #define SGNODE__ALL_POOLS
  178957             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  178958             : #endif
  178959             : 
  178960             : SgIntrinsicSymbol* SgIntrinsicSymbol::next_node = nullptr;
  178961             : std::vector<unsigned char*> SgIntrinsicSymbol::pools;
  178962             : 
  178963             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  178964             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  178965             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  178966             : // around this macro definition rather than each use).
  178967             : #ifndef ALLOC_MUTEX
  178968             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  178969             :         do {                                                                     \
  178970             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  178971             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  178972             :                 abort();                                                         \
  178973             :             }                                                                    \
  178974             :         } while (0);
  178975             : #endif
  178976             : 
  178977             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  178978             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  178979             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  178980             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  178981             : 
  178982             : /*! \brief New operator for SgIntrinsicSymbol.
  178983             : 
  178984             :    This new operator implements memory pools to provide most efficent 
  178985             :    use of the heap within construction of large ASTs.
  178986             : 
  178987             : \internal The new and delete operators use the lower level C malloc/free
  178988             :    function calls for performance and to make sure that mixing of malloc/free
  178989             :    and new/delete by the used can be caught more readily.  This may change
  178990             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  178991             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  178992             :    deallocate memory allocated using ROSE_MALLOC.
  178993             : */
  178994           0 : void *SgIntrinsicSymbol::operator new ( size_t Size )
  178995             : {
  178996             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  178997             :      * returning or throwing an exception. */
  178998           0 :     ALLOC_MUTEX(SgIntrinsicSymbol, lock);
  178999             : 
  179000             : #if ROSE_ALLOC_TRACE == 2
  179001             : //    printf("SgIntrinsicSymbol::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgIntrinsicSymbol::next_node);
  179002             : #endif
  179003             : 
  179004             : #if USE_CPP_NEW_DELETE_OPERATORS
  179005             :     void *mem = ROSE_MALLOC(Size);
  179006             :     ALLOC_MUTEX(SgIntrinsicSymbol, unlock);
  179007             :     return mem;
  179008             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  179009             : #if ROSE_PEDANTIC_ALLOC
  179010             :     ROSE_ASSERT(Size == sizeof(SgIntrinsicSymbol));
  179011             : #else
  179012           0 :     if (Size != sizeof(SgIntrinsicSymbol)) {
  179013           0 :       void * object = ROSE_MALLOC(Size);
  179014           0 :       ALLOC_MUTEX(SgIntrinsicSymbol, unlock);
  179015             :       return object;
  179016             :     }
  179017             : #endif
  179018             : 
  179019           0 :     if (SgIntrinsicSymbol::next_node == nullptr) {
  179020           0 :         SgIntrinsicSymbol * alloc = (SgIntrinsicSymbol*) ROSE_MALLOC ( SgIntrinsicSymbol::pool_size * sizeof(SgIntrinsicSymbol) );
  179021           0 :         ROSE_ASSERT(alloc != nullptr);
  179022             : 
  179023             : #if ROSE_ALLOC_TRACE == 2
  179024             : //        printf("SgIntrinsicSymbol::alloc\n  block[%zi] = [ %p , %p [\n", SgIntrinsicSymbol::pools.size(), alloc, alloc + SgIntrinsicSymbol::pool_size);
  179025             : #endif
  179026             : 
  179027             : #if ROSE_ALLOC_MEMSET == 1
  179028             : #elif ROSE_ALLOC_MEMSET == 2
  179029             :         memset(alloc, 0x00, SgIntrinsicSymbol::pool_size * sizeof(SgIntrinsicSymbol));
  179030             : #elif ROSE_ALLOC_MEMSET == 3
  179031             :         memset(alloc, 0xAA, SgIntrinsicSymbol::pool_size * sizeof(SgIntrinsicSymbol));
  179032             : #endif
  179033           0 :         for (unsigned i=0; i < SgIntrinsicSymbol::pool_size-1; i++) {
  179034           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
  179035             :         }
  179036           0 :         alloc[SgIntrinsicSymbol::pool_size-1].p_freepointer = nullptr;
  179037             : 
  179038           0 :         SgIntrinsicSymbol::pools.push_back ( (unsigned char *) alloc );
  179039           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgIntrinsicSymbol::pool_size * sizeof(SgIntrinsicSymbol), V_SgIntrinsicSymbol ) );
  179040           0 :         SgIntrinsicSymbol::next_node = alloc;
  179041             :     }
  179042           0 :     ROSE_ASSERT(SgIntrinsicSymbol::next_node != nullptr);
  179043             : 
  179044           0 :     SgIntrinsicSymbol * object = SgIntrinsicSymbol::next_node;
  179045           0 :     SgIntrinsicSymbol::next_node = (SgIntrinsicSymbol*)(object->p_freepointer);
  179046             : 
  179047             : #if ROSE_ALLOC_TRACE == 2
  179048             :     printf("SgIntrinsicSymbol::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgIntrinsicSymbol::next_node);
  179049             : #endif
  179050             : 
  179051           0 :     SgNode * fp = object->p_freepointer;
  179052             : #if ROSE_ALLOC_MEMSET == 1
  179053             : #elif ROSE_ALLOC_MEMSET == 2
  179054             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgIntrinsicSymbol) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  179055             : #elif ROSE_ALLOC_MEMSET == 3
  179056             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgIntrinsicSymbol) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  179057             : #endif
  179058           0 :     object->p_freepointer = fp;
  179059             : 
  179060             : #if ROSE_ALLOC_TRACE == 2
  179061             : //    printf("SgIntrinsicSymbol::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgIntrinsicSymbol::next_node);
  179062             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  179063             :     Rose::MemPool::snapshot(oss.str());
  179064             :     alloc_trace_cnt++;
  179065             : #endif
  179066             : 
  179067           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  179068             : 
  179069           0 :     ALLOC_MUTEX(SgIntrinsicSymbol, unlock);
  179070             : 
  179071             :     return object;
  179072             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  179073             : }
  179074             : 
  179075             : 
  179076             : 
  179077             : /*! \brief Delete operator for SgIntrinsicSymbol.
  179078             : 
  179079             :    This delete operator implements deallocation using memory pools to 
  179080             :    provide most efficent use of the heap within construction of large ASTs.
  179081             : 
  179082             : \internal The new and delete operators use the lower level C malloc/free
  179083             :    function calls for performance and to make sure that mixing of malloc/free
  179084             :    and new/delete by the used can be caught more readily.  This may change
  179085             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  179086             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  179087             :    deallocate memory allocated using ROSE_MALLOC.
  179088             : */
  179089           0 : void SgIntrinsicSymbol::operator delete(void *Pointer, size_t Size)
  179090             : {
  179091             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  179092             :      * or throwing an exception. */
  179093           0 :     ALLOC_MUTEX(SgIntrinsicSymbol, lock);
  179094             : 
  179095             : #if USE_CPP_NEW_DELETE_OPERATORS
  179096             :     ROSE_FREE(Pointer);
  179097             : #else
  179098             : #if ROSE_PEDANTIC_ALLOC
  179099             :     ROSE_ASSERT(Size == sizeof(SgIntrinsicSymbol));
  179100             : #else
  179101           0 :     if (Size != sizeof(SgIntrinsicSymbol)) {
  179102           0 :       ROSE_FREE(Pointer);
  179103           0 :       ALLOC_MUTEX(SgIntrinsicSymbol, unlock);
  179104             :       return;
  179105             :     }
  179106             : #endif
  179107             : 
  179108           0 :     SgIntrinsicSymbol * object = (SgIntrinsicSymbol*) Pointer;
  179109           0 :     ROSE_ASSERT(object != nullptr);
  179110             : 
  179111             : #if ROSE_ALLOC_TRACE == 2
  179112             : //  printf("SgIntrinsicSymbol::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgIntrinsicSymbol::next_node);
  179113             :     printf("SgIntrinsicSymbol::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgIntrinsicSymbol::next_node);
  179114             : #endif
  179115             : 
  179116             : #if ROSE_PEDANTIC_ALLOC
  179117             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  179118             : #endif
  179119             : 
  179120             : #if ROSE_ALLOC_MEMSET == 1
  179121             : #elif ROSE_ALLOC_MEMSET == 2
  179122             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgIntrinsicSymbol) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  179123             : #elif ROSE_ALLOC_MEMSET == 3
  179124             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgIntrinsicSymbol) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  179125             : #endif
  179126             : 
  179127             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  179128             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  179129             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  179130             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  179131             : #else
  179132           0 :     object->p_freepointer = SgIntrinsicSymbol::next_node;
  179133           0 :     SgIntrinsicSymbol::next_node = object;
  179134             : #endif
  179135             : 
  179136             : #if ROSE_ALLOC_TRACE == 2
  179137             : //  printf("SgIntrinsicSymbol::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgIntrinsicSymbol::next_node);
  179138             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  179139             :     Rose::MemPool::snapshot(oss.str());
  179140             :     alloc_trace_cnt++;
  179141             : #endif
  179142             : 
  179143             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  179144             : 
  179145           0 :     ALLOC_MUTEX(SgIntrinsicSymbol, unlock);
  179146             : }
  179147             : 
  179148             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  179149             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  179150             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  179151             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  179152             : // Also, note comment below from Robb (copied from the Common.code file).
  179153             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  179154             : //
  179155             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  179156             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  179157             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  179158             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  179159             : #if 0
  179160             : void SgIntrinsicSymbol::operator delete(void* pointer) { SgIntrinsicSymbol::operator delete (pointer, sizeof(SgIntrinsicSymbol)); };
  179161             : #endif
  179162             : /* #line 179163 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  179163             : 
  179164             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  179165             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  179166             : // obviously imply C++.
  179167             : 
  179168             : // This implements the support within ROSE for memory pools.  Memory pools
  179169             : // support the most condensed usage of memory within the construction of
  179170             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  179171             : // by a new operator written for each class.
  179172             : 
  179173             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  179174             :     // User wants multi-thread support and POSIX threads are available.
  179175             : #   include <pthread.h>
  179176             :     static pthread_mutex_t SgModuleSymbol_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  179177             : #else
  179178             :      // Cause synchronization to be skipped.
  179179             : #    ifndef ALLOC_MUTEX
  179180             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  179181             : #    endif
  179182             : #    ifdef _REENTRANT
  179183             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  179184             : #       ifdef _MSC_VER
  179185             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  179186             : #       else
  179187             : #           warning "POSIX threads are not available; synchronization being skipped"
  179188             : #       endif
  179189             : #    endif
  179190             : #endif
  179191             : 
  179192             : #ifndef ROSE_ALLOC_TRACE
  179193             : #  define ROSE_ALLOC_TRACE 0
  179194             : #endif
  179195             : 
  179196             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  179197             : #define ROSE_ALLOC_TRACE_CNT
  179198             : #include "memory-pool-snapshot.h"
  179199             : unsigned long alloc_trace_cnt = 0;
  179200             : #endif
  179201             : 
  179202             : #if ROSE_ALLOC_TRACE
  179203             : const unsigned SgModuleSymbol::pool_size = 5;
  179204             : #else
  179205             : const unsigned SgModuleSymbol::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  179206             : #endif
  179207             : 
  179208             : #ifndef ROSE_ALLOC_MEMSET
  179209             : #  define ROSE_ALLOC_MEMSET 0
  179210             : #endif
  179211             : 
  179212             : #ifndef ROSE_PEDANTIC_ALLOC
  179213             : #  define ROSE_PEDANTIC_ALLOC 0
  179214             : #endif
  179215             : 
  179216             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  179217             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  179218             : #endif
  179219             : 
  179220             : #if !defined(SGNODE__ALL_POOLS)
  179221             : #define SGNODE__ALL_POOLS
  179222             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  179223             : #endif
  179224             : 
  179225             : SgModuleSymbol* SgModuleSymbol::next_node = nullptr;
  179226             : std::vector<unsigned char*> SgModuleSymbol::pools;
  179227             : 
  179228             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  179229             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  179230             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  179231             : // around this macro definition rather than each use).
  179232             : #ifndef ALLOC_MUTEX
  179233             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  179234             :         do {                                                                     \
  179235             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  179236             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  179237             :                 abort();                                                         \
  179238             :             }                                                                    \
  179239             :         } while (0);
  179240             : #endif
  179241             : 
  179242             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  179243             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  179244             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  179245             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  179246             : 
  179247             : /*! \brief New operator for SgModuleSymbol.
  179248             : 
  179249             :    This new operator implements memory pools to provide most efficent 
  179250             :    use of the heap within construction of large ASTs.
  179251             : 
  179252             : \internal The new and delete operators use the lower level C malloc/free
  179253             :    function calls for performance and to make sure that mixing of malloc/free
  179254             :    and new/delete by the used can be caught more readily.  This may change
  179255             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  179256             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  179257             :    deallocate memory allocated using ROSE_MALLOC.
  179258             : */
  179259           0 : void *SgModuleSymbol::operator new ( size_t Size )
  179260             : {
  179261             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  179262             :      * returning or throwing an exception. */
  179263           0 :     ALLOC_MUTEX(SgModuleSymbol, lock);
  179264             : 
  179265             : #if ROSE_ALLOC_TRACE == 2
  179266             : //    printf("SgModuleSymbol::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgModuleSymbol::next_node);
  179267             : #endif
  179268             : 
  179269             : #if USE_CPP_NEW_DELETE_OPERATORS
  179270             :     void *mem = ROSE_MALLOC(Size);
  179271             :     ALLOC_MUTEX(SgModuleSymbol, unlock);
  179272             :     return mem;
  179273             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  179274             : #if ROSE_PEDANTIC_ALLOC
  179275             :     ROSE_ASSERT(Size == sizeof(SgModuleSymbol));
  179276             : #else
  179277           0 :     if (Size != sizeof(SgModuleSymbol)) {
  179278           0 :       void * object = ROSE_MALLOC(Size);
  179279           0 :       ALLOC_MUTEX(SgModuleSymbol, unlock);
  179280             :       return object;
  179281             :     }
  179282             : #endif
  179283             : 
  179284           0 :     if (SgModuleSymbol::next_node == nullptr) {
  179285           0 :         SgModuleSymbol * alloc = (SgModuleSymbol*) ROSE_MALLOC ( SgModuleSymbol::pool_size * sizeof(SgModuleSymbol) );
  179286           0 :         ROSE_ASSERT(alloc != nullptr);
  179287             : 
  179288             : #if ROSE_ALLOC_TRACE == 2
  179289             : //        printf("SgModuleSymbol::alloc\n  block[%zi] = [ %p , %p [\n", SgModuleSymbol::pools.size(), alloc, alloc + SgModuleSymbol::pool_size);
  179290             : #endif
  179291             : 
  179292             : #if ROSE_ALLOC_MEMSET == 1
  179293             : #elif ROSE_ALLOC_MEMSET == 2
  179294             :         memset(alloc, 0x00, SgModuleSymbol::pool_size * sizeof(SgModuleSymbol));
  179295             : #elif ROSE_ALLOC_MEMSET == 3
  179296             :         memset(alloc, 0xAA, SgModuleSymbol::pool_size * sizeof(SgModuleSymbol));
  179297             : #endif
  179298           0 :         for (unsigned i=0; i < SgModuleSymbol::pool_size-1; i++) {
  179299           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
  179300             :         }
  179301           0 :         alloc[SgModuleSymbol::pool_size-1].p_freepointer = nullptr;
  179302             : 
  179303           0 :         SgModuleSymbol::pools.push_back ( (unsigned char *) alloc );
  179304           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgModuleSymbol::pool_size * sizeof(SgModuleSymbol), V_SgModuleSymbol ) );
  179305           0 :         SgModuleSymbol::next_node = alloc;
  179306             :     }
  179307           0 :     ROSE_ASSERT(SgModuleSymbol::next_node != nullptr);
  179308             : 
  179309           0 :     SgModuleSymbol * object = SgModuleSymbol::next_node;
  179310           0 :     SgModuleSymbol::next_node = (SgModuleSymbol*)(object->p_freepointer);
  179311             : 
  179312             : #if ROSE_ALLOC_TRACE == 2
  179313             :     printf("SgModuleSymbol::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgModuleSymbol::next_node);
  179314             : #endif
  179315             : 
  179316           0 :     SgNode * fp = object->p_freepointer;
  179317             : #if ROSE_ALLOC_MEMSET == 1
  179318             : #elif ROSE_ALLOC_MEMSET == 2
  179319             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgModuleSymbol) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  179320             : #elif ROSE_ALLOC_MEMSET == 3
  179321             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgModuleSymbol) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  179322             : #endif
  179323           0 :     object->p_freepointer = fp;
  179324             : 
  179325             : #if ROSE_ALLOC_TRACE == 2
  179326             : //    printf("SgModuleSymbol::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgModuleSymbol::next_node);
  179327             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  179328             :     Rose::MemPool::snapshot(oss.str());
  179329             :     alloc_trace_cnt++;
  179330             : #endif
  179331             : 
  179332           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  179333             : 
  179334           0 :     ALLOC_MUTEX(SgModuleSymbol, unlock);
  179335             : 
  179336             :     return object;
  179337             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  179338             : }
  179339             : 
  179340             : 
  179341             : 
  179342             : /*! \brief Delete operator for SgModuleSymbol.
  179343             : 
  179344             :    This delete operator implements deallocation using memory pools to 
  179345             :    provide most efficent use of the heap within construction of large ASTs.
  179346             : 
  179347             : \internal The new and delete operators use the lower level C malloc/free
  179348             :    function calls for performance and to make sure that mixing of malloc/free
  179349             :    and new/delete by the used can be caught more readily.  This may change
  179350             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  179351             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  179352             :    deallocate memory allocated using ROSE_MALLOC.
  179353             : */
  179354           0 : void SgModuleSymbol::operator delete(void *Pointer, size_t Size)
  179355             : {
  179356             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  179357             :      * or throwing an exception. */
  179358           0 :     ALLOC_MUTEX(SgModuleSymbol, lock);
  179359             : 
  179360             : #if USE_CPP_NEW_DELETE_OPERATORS
  179361             :     ROSE_FREE(Pointer);
  179362             : #else
  179363             : #if ROSE_PEDANTIC_ALLOC
  179364             :     ROSE_ASSERT(Size == sizeof(SgModuleSymbol));
  179365             : #else
  179366           0 :     if (Size != sizeof(SgModuleSymbol)) {
  179367           0 :       ROSE_FREE(Pointer);
  179368           0 :       ALLOC_MUTEX(SgModuleSymbol, unlock);
  179369             :       return;
  179370             :     }
  179371             : #endif
  179372             : 
  179373           0 :     SgModuleSymbol * object = (SgModuleSymbol*) Pointer;
  179374           0 :     ROSE_ASSERT(object != nullptr);
  179375             : 
  179376             : #if ROSE_ALLOC_TRACE == 2
  179377             : //  printf("SgModuleSymbol::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgModuleSymbol::next_node);
  179378             :     printf("SgModuleSymbol::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgModuleSymbol::next_node);
  179379             : #endif
  179380             : 
  179381             : #if ROSE_PEDANTIC_ALLOC
  179382             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  179383             : #endif
  179384             : 
  179385             : #if ROSE_ALLOC_MEMSET == 1
  179386             : #elif ROSE_ALLOC_MEMSET == 2
  179387             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgModuleSymbol) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  179388             : #elif ROSE_ALLOC_MEMSET == 3
  179389             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgModuleSymbol) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  179390             : #endif
  179391             : 
  179392             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  179393             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  179394             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  179395             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  179396             : #else
  179397           0 :     object->p_freepointer = SgModuleSymbol::next_node;
  179398           0 :     SgModuleSymbol::next_node = object;
  179399             : #endif
  179400             : 
  179401             : #if ROSE_ALLOC_TRACE == 2
  179402             : //  printf("SgModuleSymbol::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgModuleSymbol::next_node);
  179403             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  179404             :     Rose::MemPool::snapshot(oss.str());
  179405             :     alloc_trace_cnt++;
  179406             : #endif
  179407             : 
  179408             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  179409             : 
  179410           0 :     ALLOC_MUTEX(SgModuleSymbol, unlock);
  179411             : }
  179412             : 
  179413             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  179414             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  179415             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  179416             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  179417             : // Also, note comment below from Robb (copied from the Common.code file).
  179418             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  179419             : //
  179420             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  179421             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  179422             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  179423             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  179424             : #if 0
  179425             : void SgModuleSymbol::operator delete(void* pointer) { SgModuleSymbol::operator delete (pointer, sizeof(SgModuleSymbol)); };
  179426             : #endif
  179427             : /* #line 179428 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  179428             : 
  179429             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  179430             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  179431             : // obviously imply C++.
  179432             : 
  179433             : // This implements the support within ROSE for memory pools.  Memory pools
  179434             : // support the most condensed usage of memory within the construction of
  179435             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  179436             : // by a new operator written for each class.
  179437             : 
  179438             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  179439             :     // User wants multi-thread support and POSIX threads are available.
  179440             : #   include <pthread.h>
  179441             :     static pthread_mutex_t SgInterfaceSymbol_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  179442             : #else
  179443             :      // Cause synchronization to be skipped.
  179444             : #    ifndef ALLOC_MUTEX
  179445             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  179446             : #    endif
  179447             : #    ifdef _REENTRANT
  179448             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  179449             : #       ifdef _MSC_VER
  179450             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  179451             : #       else
  179452             : #           warning "POSIX threads are not available; synchronization being skipped"
  179453             : #       endif
  179454             : #    endif
  179455             : #endif
  179456             : 
  179457             : #ifndef ROSE_ALLOC_TRACE
  179458             : #  define ROSE_ALLOC_TRACE 0
  179459             : #endif
  179460             : 
  179461             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  179462             : #define ROSE_ALLOC_TRACE_CNT
  179463             : #include "memory-pool-snapshot.h"
  179464             : unsigned long alloc_trace_cnt = 0;
  179465             : #endif
  179466             : 
  179467             : #if ROSE_ALLOC_TRACE
  179468             : const unsigned SgInterfaceSymbol::pool_size = 5;
  179469             : #else
  179470             : const unsigned SgInterfaceSymbol::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  179471             : #endif
  179472             : 
  179473             : #ifndef ROSE_ALLOC_MEMSET
  179474             : #  define ROSE_ALLOC_MEMSET 0
  179475             : #endif
  179476             : 
  179477             : #ifndef ROSE_PEDANTIC_ALLOC
  179478             : #  define ROSE_PEDANTIC_ALLOC 0
  179479             : #endif
  179480             : 
  179481             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  179482             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  179483             : #endif
  179484             : 
  179485             : #if !defined(SGNODE__ALL_POOLS)
  179486             : #define SGNODE__ALL_POOLS
  179487             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  179488             : #endif
  179489             : 
  179490             : SgInterfaceSymbol* SgInterfaceSymbol::next_node = nullptr;
  179491             : std::vector<unsigned char*> SgInterfaceSymbol::pools;
  179492             : 
  179493             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  179494             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  179495             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  179496             : // around this macro definition rather than each use).
  179497             : #ifndef ALLOC_MUTEX
  179498             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  179499             :         do {                                                                     \
  179500             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  179501             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  179502             :                 abort();                                                         \
  179503             :             }                                                                    \
  179504             :         } while (0);
  179505             : #endif
  179506             : 
  179507             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  179508             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  179509             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  179510             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  179511             : 
  179512             : /*! \brief New operator for SgInterfaceSymbol.
  179513             : 
  179514             :    This new operator implements memory pools to provide most efficent 
  179515             :    use of the heap within construction of large ASTs.
  179516             : 
  179517             : \internal The new and delete operators use the lower level C malloc/free
  179518             :    function calls for performance and to make sure that mixing of malloc/free
  179519             :    and new/delete by the used can be caught more readily.  This may change
  179520             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  179521             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  179522             :    deallocate memory allocated using ROSE_MALLOC.
  179523             : */
  179524           0 : void *SgInterfaceSymbol::operator new ( size_t Size )
  179525             : {
  179526             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  179527             :      * returning or throwing an exception. */
  179528           0 :     ALLOC_MUTEX(SgInterfaceSymbol, lock);
  179529             : 
  179530             : #if ROSE_ALLOC_TRACE == 2
  179531             : //    printf("SgInterfaceSymbol::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgInterfaceSymbol::next_node);
  179532             : #endif
  179533             : 
  179534             : #if USE_CPP_NEW_DELETE_OPERATORS
  179535             :     void *mem = ROSE_MALLOC(Size);
  179536             :     ALLOC_MUTEX(SgInterfaceSymbol, unlock);
  179537             :     return mem;
  179538             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  179539             : #if ROSE_PEDANTIC_ALLOC
  179540             :     ROSE_ASSERT(Size == sizeof(SgInterfaceSymbol));
  179541             : #else
  179542           0 :     if (Size != sizeof(SgInterfaceSymbol)) {
  179543           0 :       void * object = ROSE_MALLOC(Size);
  179544           0 :       ALLOC_MUTEX(SgInterfaceSymbol, unlock);
  179545             :       return object;
  179546             :     }
  179547             : #endif
  179548             : 
  179549           0 :     if (SgInterfaceSymbol::next_node == nullptr) {
  179550           0 :         SgInterfaceSymbol * alloc = (SgInterfaceSymbol*) ROSE_MALLOC ( SgInterfaceSymbol::pool_size * sizeof(SgInterfaceSymbol) );
  179551           0 :         ROSE_ASSERT(alloc != nullptr);
  179552             : 
  179553             : #if ROSE_ALLOC_TRACE == 2
  179554             : //        printf("SgInterfaceSymbol::alloc\n  block[%zi] = [ %p , %p [\n", SgInterfaceSymbol::pools.size(), alloc, alloc + SgInterfaceSymbol::pool_size);
  179555             : #endif
  179556             : 
  179557             : #if ROSE_ALLOC_MEMSET == 1
  179558             : #elif ROSE_ALLOC_MEMSET == 2
  179559             :         memset(alloc, 0x00, SgInterfaceSymbol::pool_size * sizeof(SgInterfaceSymbol));
  179560             : #elif ROSE_ALLOC_MEMSET == 3
  179561             :         memset(alloc, 0xAA, SgInterfaceSymbol::pool_size * sizeof(SgInterfaceSymbol));
  179562             : #endif
  179563           0 :         for (unsigned i=0; i < SgInterfaceSymbol::pool_size-1; i++) {
  179564           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
  179565             :         }
  179566           0 :         alloc[SgInterfaceSymbol::pool_size-1].p_freepointer = nullptr;
  179567             : 
  179568           0 :         SgInterfaceSymbol::pools.push_back ( (unsigned char *) alloc );
  179569           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgInterfaceSymbol::pool_size * sizeof(SgInterfaceSymbol), V_SgInterfaceSymbol ) );
  179570           0 :         SgInterfaceSymbol::next_node = alloc;
  179571             :     }
  179572           0 :     ROSE_ASSERT(SgInterfaceSymbol::next_node != nullptr);
  179573             : 
  179574           0 :     SgInterfaceSymbol * object = SgInterfaceSymbol::next_node;
  179575           0 :     SgInterfaceSymbol::next_node = (SgInterfaceSymbol*)(object->p_freepointer);
  179576             : 
  179577             : #if ROSE_ALLOC_TRACE == 2
  179578             :     printf("SgInterfaceSymbol::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgInterfaceSymbol::next_node);
  179579             : #endif
  179580             : 
  179581           0 :     SgNode * fp = object->p_freepointer;
  179582             : #if ROSE_ALLOC_MEMSET == 1
  179583             : #elif ROSE_ALLOC_MEMSET == 2
  179584             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgInterfaceSymbol) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  179585             : #elif ROSE_ALLOC_MEMSET == 3
  179586             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgInterfaceSymbol) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  179587             : #endif
  179588           0 :     object->p_freepointer = fp;
  179589             : 
  179590             : #if ROSE_ALLOC_TRACE == 2
  179591             : //    printf("SgInterfaceSymbol::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgInterfaceSymbol::next_node);
  179592             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  179593             :     Rose::MemPool::snapshot(oss.str());
  179594             :     alloc_trace_cnt++;
  179595             : #endif
  179596             : 
  179597           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  179598             : 
  179599           0 :     ALLOC_MUTEX(SgInterfaceSymbol, unlock);
  179600             : 
  179601             :     return object;
  179602             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  179603             : }
  179604             : 
  179605             : 
  179606             : 
  179607             : /*! \brief Delete operator for SgInterfaceSymbol.
  179608             : 
  179609             :    This delete operator implements deallocation using memory pools to 
  179610             :    provide most efficent use of the heap within construction of large ASTs.
  179611             : 
  179612             : \internal The new and delete operators use the lower level C malloc/free
  179613             :    function calls for performance and to make sure that mixing of malloc/free
  179614             :    and new/delete by the used can be caught more readily.  This may change
  179615             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  179616             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  179617             :    deallocate memory allocated using ROSE_MALLOC.
  179618             : */
  179619           0 : void SgInterfaceSymbol::operator delete(void *Pointer, size_t Size)
  179620             : {
  179621             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  179622             :      * or throwing an exception. */
  179623           0 :     ALLOC_MUTEX(SgInterfaceSymbol, lock);
  179624             : 
  179625             : #if USE_CPP_NEW_DELETE_OPERATORS
  179626             :     ROSE_FREE(Pointer);
  179627             : #else
  179628             : #if ROSE_PEDANTIC_ALLOC
  179629             :     ROSE_ASSERT(Size == sizeof(SgInterfaceSymbol));
  179630             : #else
  179631           0 :     if (Size != sizeof(SgInterfaceSymbol)) {
  179632           0 :       ROSE_FREE(Pointer);
  179633           0 :       ALLOC_MUTEX(SgInterfaceSymbol, unlock);
  179634             :       return;
  179635             :     }
  179636             : #endif
  179637             : 
  179638           0 :     SgInterfaceSymbol * object = (SgInterfaceSymbol*) Pointer;
  179639           0 :     ROSE_ASSERT(object != nullptr);
  179640             : 
  179641             : #if ROSE_ALLOC_TRACE == 2
  179642             : //  printf("SgInterfaceSymbol::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgInterfaceSymbol::next_node);
  179643             :     printf("SgInterfaceSymbol::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgInterfaceSymbol::next_node);
  179644             : #endif
  179645             : 
  179646             : #if ROSE_PEDANTIC_ALLOC
  179647             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  179648             : #endif
  179649             : 
  179650             : #if ROSE_ALLOC_MEMSET == 1
  179651             : #elif ROSE_ALLOC_MEMSET == 2
  179652             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgInterfaceSymbol) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  179653             : #elif ROSE_ALLOC_MEMSET == 3
  179654             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgInterfaceSymbol) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  179655             : #endif
  179656             : 
  179657             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  179658             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  179659             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  179660             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  179661             : #else
  179662           0 :     object->p_freepointer = SgInterfaceSymbol::next_node;
  179663           0 :     SgInterfaceSymbol::next_node = object;
  179664             : #endif
  179665             : 
  179666             : #if ROSE_ALLOC_TRACE == 2
  179667             : //  printf("SgInterfaceSymbol::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgInterfaceSymbol::next_node);
  179668             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  179669             :     Rose::MemPool::snapshot(oss.str());
  179670             :     alloc_trace_cnt++;
  179671             : #endif
  179672             : 
  179673             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  179674             : 
  179675           0 :     ALLOC_MUTEX(SgInterfaceSymbol, unlock);
  179676             : }
  179677             : 
  179678             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  179679             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  179680             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  179681             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  179682             : // Also, note comment below from Robb (copied from the Common.code file).
  179683             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  179684             : //
  179685             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  179686             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  179687             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  179688             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  179689             : #if 0
  179690             : void SgInterfaceSymbol::operator delete(void* pointer) { SgInterfaceSymbol::operator delete (pointer, sizeof(SgInterfaceSymbol)); };
  179691             : #endif
  179692             : /* #line 179693 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  179693             : 
  179694             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  179695             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  179696             : // obviously imply C++.
  179697             : 
  179698             : // This implements the support within ROSE for memory pools.  Memory pools
  179699             : // support the most condensed usage of memory within the construction of
  179700             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  179701             : // by a new operator written for each class.
  179702             : 
  179703             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  179704             :     // User wants multi-thread support and POSIX threads are available.
  179705             : #   include <pthread.h>
  179706             :     static pthread_mutex_t SgCommonSymbol_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  179707             : #else
  179708             :      // Cause synchronization to be skipped.
  179709             : #    ifndef ALLOC_MUTEX
  179710             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  179711             : #    endif
  179712             : #    ifdef _REENTRANT
  179713             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  179714             : #       ifdef _MSC_VER
  179715             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  179716             : #       else
  179717             : #           warning "POSIX threads are not available; synchronization being skipped"
  179718             : #       endif
  179719             : #    endif
  179720             : #endif
  179721             : 
  179722             : #ifndef ROSE_ALLOC_TRACE
  179723             : #  define ROSE_ALLOC_TRACE 0
  179724             : #endif
  179725             : 
  179726             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  179727             : #define ROSE_ALLOC_TRACE_CNT
  179728             : #include "memory-pool-snapshot.h"
  179729             : unsigned long alloc_trace_cnt = 0;
  179730             : #endif
  179731             : 
  179732             : #if ROSE_ALLOC_TRACE
  179733             : const unsigned SgCommonSymbol::pool_size = 5;
  179734             : #else
  179735             : const unsigned SgCommonSymbol::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  179736             : #endif
  179737             : 
  179738             : #ifndef ROSE_ALLOC_MEMSET
  179739             : #  define ROSE_ALLOC_MEMSET 0
  179740             : #endif
  179741             : 
  179742             : #ifndef ROSE_PEDANTIC_ALLOC
  179743             : #  define ROSE_PEDANTIC_ALLOC 0
  179744             : #endif
  179745             : 
  179746             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  179747             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  179748             : #endif
  179749             : 
  179750             : #if !defined(SGNODE__ALL_POOLS)
  179751             : #define SGNODE__ALL_POOLS
  179752             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  179753             : #endif
  179754             : 
  179755             : SgCommonSymbol* SgCommonSymbol::next_node = nullptr;
  179756             : std::vector<unsigned char*> SgCommonSymbol::pools;
  179757             : 
  179758             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  179759             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  179760             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  179761             : // around this macro definition rather than each use).
  179762             : #ifndef ALLOC_MUTEX
  179763             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  179764             :         do {                                                                     \
  179765             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  179766             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  179767             :                 abort();                                                         \
  179768             :             }                                                                    \
  179769             :         } while (0);
  179770             : #endif
  179771             : 
  179772             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  179773             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  179774             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  179775             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  179776             : 
  179777             : /*! \brief New operator for SgCommonSymbol.
  179778             : 
  179779             :    This new operator implements memory pools to provide most efficent 
  179780             :    use of the heap within construction of large ASTs.
  179781             : 
  179782             : \internal The new and delete operators use the lower level C malloc/free
  179783             :    function calls for performance and to make sure that mixing of malloc/free
  179784             :    and new/delete by the used can be caught more readily.  This may change
  179785             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  179786             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  179787             :    deallocate memory allocated using ROSE_MALLOC.
  179788             : */
  179789           0 : void *SgCommonSymbol::operator new ( size_t Size )
  179790             : {
  179791             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  179792             :      * returning or throwing an exception. */
  179793           0 :     ALLOC_MUTEX(SgCommonSymbol, lock);
  179794             : 
  179795             : #if ROSE_ALLOC_TRACE == 2
  179796             : //    printf("SgCommonSymbol::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgCommonSymbol::next_node);
  179797             : #endif
  179798             : 
  179799             : #if USE_CPP_NEW_DELETE_OPERATORS
  179800             :     void *mem = ROSE_MALLOC(Size);
  179801             :     ALLOC_MUTEX(SgCommonSymbol, unlock);
  179802             :     return mem;
  179803             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  179804             : #if ROSE_PEDANTIC_ALLOC
  179805             :     ROSE_ASSERT(Size == sizeof(SgCommonSymbol));
  179806             : #else
  179807           0 :     if (Size != sizeof(SgCommonSymbol)) {
  179808           0 :       void * object = ROSE_MALLOC(Size);
  179809           0 :       ALLOC_MUTEX(SgCommonSymbol, unlock);
  179810             :       return object;
  179811             :     }
  179812             : #endif
  179813             : 
  179814           0 :     if (SgCommonSymbol::next_node == nullptr) {
  179815           0 :         SgCommonSymbol * alloc = (SgCommonSymbol*) ROSE_MALLOC ( SgCommonSymbol::pool_size * sizeof(SgCommonSymbol) );
  179816           0 :         ROSE_ASSERT(alloc != nullptr);
  179817             : 
  179818             : #if ROSE_ALLOC_TRACE == 2
  179819             : //        printf("SgCommonSymbol::alloc\n  block[%zi] = [ %p , %p [\n", SgCommonSymbol::pools.size(), alloc, alloc + SgCommonSymbol::pool_size);
  179820             : #endif
  179821             : 
  179822             : #if ROSE_ALLOC_MEMSET == 1
  179823             : #elif ROSE_ALLOC_MEMSET == 2
  179824             :         memset(alloc, 0x00, SgCommonSymbol::pool_size * sizeof(SgCommonSymbol));
  179825             : #elif ROSE_ALLOC_MEMSET == 3
  179826             :         memset(alloc, 0xAA, SgCommonSymbol::pool_size * sizeof(SgCommonSymbol));
  179827             : #endif
  179828           0 :         for (unsigned i=0; i < SgCommonSymbol::pool_size-1; i++) {
  179829           0 :           alloc[i].p_freepointer = &(alloc[i+1]);
  179830             :         }
  179831           0 :         alloc[SgCommonSymbol::pool_size-1].p_freepointer = nullptr;
  179832             : 
  179833           0 :         SgCommonSymbol::pools.push_back ( (unsigned char *) alloc );
  179834           0 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgCommonSymbol::pool_size * sizeof(SgCommonSymbol), V_SgCommonSymbol ) );
  179835           0 :         SgCommonSymbol::next_node = alloc;
  179836             :     }
  179837           0 :     ROSE_ASSERT(SgCommonSymbol::next_node != nullptr);
  179838             : 
  179839           0 :     SgCommonSymbol * object = SgCommonSymbol::next_node;
  179840           0 :     SgCommonSymbol::next_node = (SgCommonSymbol*)(object->p_freepointer);
  179841             : 
  179842             : #if ROSE_ALLOC_TRACE == 2
  179843             :     printf("SgCommonSymbol::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgCommonSymbol::next_node);
  179844             : #endif
  179845             : 
  179846           0 :     SgNode * fp = object->p_freepointer;
  179847             : #if ROSE_ALLOC_MEMSET == 1
  179848             : #elif ROSE_ALLOC_MEMSET == 2
  179849             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgCommonSymbol) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  179850             : #elif ROSE_ALLOC_MEMSET == 3
  179851             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgCommonSymbol) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  179852             : #endif
  179853           0 :     object->p_freepointer = fp;
  179854             : 
  179855             : #if ROSE_ALLOC_TRACE == 2
  179856             : //    printf("SgCommonSymbol::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgCommonSymbol::next_node);
  179857             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  179858             :     Rose::MemPool::snapshot(oss.str());
  179859             :     alloc_trace_cnt++;
  179860             : #endif
  179861             : 
  179862           0 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  179863             : 
  179864           0 :     ALLOC_MUTEX(SgCommonSymbol, unlock);
  179865             : 
  179866             :     return object;
  179867             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  179868             : }
  179869             : 
  179870             : 
  179871             : 
  179872             : /*! \brief Delete operator for SgCommonSymbol.
  179873             : 
  179874             :    This delete operator implements deallocation using memory pools to 
  179875             :    provide most efficent use of the heap within construction of large ASTs.
  179876             : 
  179877             : \internal The new and delete operators use the lower level C malloc/free
  179878             :    function calls for performance and to make sure that mixing of malloc/free
  179879             :    and new/delete by the used can be caught more readily.  This may change
  179880             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  179881             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  179882             :    deallocate memory allocated using ROSE_MALLOC.
  179883             : */
  179884           0 : void SgCommonSymbol::operator delete(void *Pointer, size_t Size)
  179885             : {
  179886             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  179887             :      * or throwing an exception. */
  179888           0 :     ALLOC_MUTEX(SgCommonSymbol, lock);
  179889             : 
  179890             : #if USE_CPP_NEW_DELETE_OPERATORS
  179891             :     ROSE_FREE(Pointer);
  179892             : #else
  179893             : #if ROSE_PEDANTIC_ALLOC
  179894             :     ROSE_ASSERT(Size == sizeof(SgCommonSymbol));
  179895             : #else
  179896           0 :     if (Size != sizeof(SgCommonSymbol)) {
  179897           0 :       ROSE_FREE(Pointer);
  179898           0 :       ALLOC_MUTEX(SgCommonSymbol, unlock);
  179899             :       return;
  179900             :     }
  179901             : #endif
  179902             : 
  179903           0 :     SgCommonSymbol * object = (SgCommonSymbol*) Pointer;
  179904           0 :     ROSE_ASSERT(object != nullptr);
  179905             : 
  179906             : #if ROSE_ALLOC_TRACE == 2
  179907             : //  printf("SgCommonSymbol::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgCommonSymbol::next_node);
  179908             :     printf("SgCommonSymbol::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgCommonSymbol::next_node);
  179909             : #endif
  179910             : 
  179911             : #if ROSE_PEDANTIC_ALLOC
  179912             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  179913             : #endif
  179914             : 
  179915             : #if ROSE_ALLOC_MEMSET == 1
  179916             : #elif ROSE_ALLOC_MEMSET == 2
  179917             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgCommonSymbol) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  179918             : #elif ROSE_ALLOC_MEMSET == 3
  179919             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgCommonSymbol) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  179920             : #endif
  179921             : 
  179922             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  179923             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  179924             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  179925             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  179926             : #else
  179927           0 :     object->p_freepointer = SgCommonSymbol::next_node;
  179928           0 :     SgCommonSymbol::next_node = object;
  179929             : #endif
  179930             : 
  179931             : #if ROSE_ALLOC_TRACE == 2
  179932             : //  printf("SgCommonSymbol::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgCommonSymbol::next_node);
  179933             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  179934             :     Rose::MemPool::snapshot(oss.str());
  179935             :     alloc_trace_cnt++;
  179936             : #endif
  179937             : 
  179938             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  179939             : 
  179940           0 :     ALLOC_MUTEX(SgCommonSymbol, unlock);
  179941             : }
  179942             : 
  179943             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  179944             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  179945             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  179946             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  179947             : // Also, note comment below from Robb (copied from the Common.code file).
  179948             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  179949             : //
  179950             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  179951             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  179952             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  179953             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  179954             : #if 0
  179955             : void SgCommonSymbol::operator delete(void* pointer) { SgCommonSymbol::operator delete (pointer, sizeof(SgCommonSymbol)); };
  179956             : #endif
  179957             : /* #line 179958 "../../../src/frontend/SageIII//Cxx_GrammarNewAndDeleteOperators.C" */
  179958             : 
  179959             : /* #line 1 "/home/yyan7/compiler/rexompiler/src/ROSETTA/Grammar/grammarNewDeleteOperatorMacros.macro" */
  179960             : // This string (-*- c++ -*-) is to make XEmacs C-aware tools available automatically since this file's name and contents don't
  179961             : // obviously imply C++.
  179962             : 
  179963             : // This implements the support within ROSE for memory pools.  Memory pools
  179964             : // support the most condensed usage of memory within the construction of
  179965             : // and AST. Large blocks of contiguous storage for each RI node is allocated
  179966             : // by a new operator written for each class.
  179967             : 
  179968             : #if defined(_REENTRANT) && defined(HAVE_PTHREAD_H)
  179969             :     // User wants multi-thread support and POSIX threads are available.
  179970             : #   include <pthread.h>
  179971             :     static pthread_mutex_t SgAliasSymbol_allocation_mutex = PTHREAD_MUTEX_INITIALIZER;
  179972             : #else
  179973             :      // Cause synchronization to be skipped.
  179974             : #    ifndef ALLOC_MUTEX
  179975             : #        define ALLOC_MUTEX(CLASS_NAME, HOW)
  179976             : #    endif
  179977             : #    ifdef _REENTRANT
  179978             :         // User wnats multi-thread support, but POSIX is unavailable. Consider using Boost Threads which are more portable.
  179979             : #       ifdef _MSC_VER
  179980             : #           pragma message("POSIX threads are not available; synchronization being skipped")
  179981             : #       else
  179982             : #           warning "POSIX threads are not available; synchronization being skipped"
  179983             : #       endif
  179984             : #    endif
  179985             : #endif
  179986             : 
  179987             : #ifndef ROSE_ALLOC_TRACE
  179988             : #  define ROSE_ALLOC_TRACE 0
  179989             : #endif
  179990             : 
  179991             : #if ROSE_ALLOC_TRACE && !defined(ROSE_ALLOC_TRACE_CNT)
  179992             : #define ROSE_ALLOC_TRACE_CNT
  179993             : #include "memory-pool-snapshot.h"
  179994             : unsigned long alloc_trace_cnt = 0;
  179995             : #endif
  179996             : 
  179997             : #if ROSE_ALLOC_TRACE
  179998             : const unsigned SgAliasSymbol::pool_size = 5;
  179999             : #else
  180000             : const unsigned SgAliasSymbol::pool_size = DEFAULT_CLASS_ALLOCATION_POOL_SIZE;
  180001             : #endif
  180002             : 
  180003             : #ifndef ROSE_ALLOC_MEMSET
  180004             : #  define ROSE_ALLOC_MEMSET 0
  180005             : #endif
  180006             : 
  180007             : #ifndef ROSE_PEDANTIC_ALLOC
  180008             : #  define ROSE_PEDANTIC_ALLOC 0
  180009             : #endif
  180010             : 
  180011             : #ifndef ROSE_ALLOC_MEMSET_OFFSET
  180012             : #  define ROSE_ALLOC_MEMSET_OFFSET 1 // prevents erasing the vtable pointer when ROSE_ALLOC_MEMSET is set, cause to many issues when investigating bugs
  180013             : #endif
  180014             : 
  180015             : #if !defined(SGNODE__ALL_POOLS)
  180016             : #define SGNODE__ALL_POOLS
  180017             : std::vector<std::tuple<unsigned char*, unsigned, VariantT>> SgNode::all_pools;
  180018             : #endif
  180019             : 
  180020             : SgAliasSymbol* SgAliasSymbol::next_node = nullptr;
  180021             : std::vector<unsigned char*> SgAliasSymbol::pools;
  180022             : 
  180023             : // This macro protects allocation functions by locking/unlocking a mutex. We have one mutex defined for each Sage class. The
  180024             : // HOW argument should be the word "lock" or "unlock".  Using a macro allows us to not have to use conditional compilation
  180025             : // every time we access a mutex (in the case where mutexes aren't defined on one OS, we can place the conditional compilation
  180026             : // around this macro definition rather than each use).
  180027             : #ifndef ALLOC_MUTEX
  180028             : #   define ALLOC_MUTEX(CLASS_NAME, HOW)                                          \
  180029             :         do {                                                                     \
  180030             :             if (pthread_mutex_##HOW(&CLASS_NAME##_allocation_mutex)) {           \
  180031             :                 fprintf(stderr, "%s mutex %s failed\n", #CLASS_NAME, #HOW);      \
  180032             :                 abort();                                                         \
  180033             :             }                                                                    \
  180034             :         } while (0);
  180035             : #endif
  180036             : 
  180037             : // DQ (11/1/2016): This is redundant and repeated hundreds to times which is misleading.
  180038             : // This macro appears to be set within code within ROSETTA, but only for when _MSC_VER is true.
  180039             : #define USE_CPP_NEW_DELETE_OPERATORS FALSE
  180040             : // #define USE_CPP_NEW_DELETE_OPERATORS TRUE
  180041             : 
  180042             : /*! \brief New operator for SgAliasSymbol.
  180043             : 
  180044             :    This new operator implements memory pools to provide most efficent 
  180045             :    use of the heap within construction of large ASTs.
  180046             : 
  180047             : \internal The new and delete operators use the lower level C malloc/free
  180048             :    function calls for performance and to make sure that mixing of malloc/free
  180049             :    and new/delete by the used can be caught more readily.  This may change
  180050             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  180051             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  180052             :    deallocate memory allocated using ROSE_MALLOC.
  180053             : */
  180054      982960 : void *SgAliasSymbol::operator new ( size_t Size )
  180055             : {
  180056             :     /* This entire function is protected by a mutex.  To avoid deadlock, be sure to unlock the mutex before
  180057             :      * returning or throwing an exception. */
  180058      982960 :     ALLOC_MUTEX(SgAliasSymbol, lock);
  180059             : 
  180060             : #if ROSE_ALLOC_TRACE == 2
  180061             : //    printf("SgAliasSymbol::new[%zi] (IN)\n  current_link = %p\n", alloc_trace_cnt, SgAliasSymbol::next_node);
  180062             : #endif
  180063             : 
  180064             : #if USE_CPP_NEW_DELETE_OPERATORS
  180065             :     void *mem = ROSE_MALLOC(Size);
  180066             :     ALLOC_MUTEX(SgAliasSymbol, unlock);
  180067             :     return mem;
  180068             : #else /* !USE_CPP_NEW_DELETE_OPERATORS... */
  180069             : #if ROSE_PEDANTIC_ALLOC
  180070             :     ROSE_ASSERT(Size == sizeof(SgAliasSymbol));
  180071             : #else
  180072      982960 :     if (Size != sizeof(SgAliasSymbol)) {
  180073           0 :       void * object = ROSE_MALLOC(Size);
  180074           0 :       ALLOC_MUTEX(SgAliasSymbol, unlock);
  180075             :       return object;
  180076             :     }
  180077             : #endif
  180078             : 
  180079      982960 :     if (SgAliasSymbol::next_node == nullptr) {
  180080         717 :         SgAliasSymbol * alloc = (SgAliasSymbol*) ROSE_MALLOC ( SgAliasSymbol::pool_size * sizeof(SgAliasSymbol) );
  180081         717 :         ROSE_ASSERT(alloc != nullptr);
  180082             : 
  180083             : #if ROSE_ALLOC_TRACE == 2
  180084             : //        printf("SgAliasSymbol::alloc\n  block[%zi] = [ %p , %p [\n", SgAliasSymbol::pools.size(), alloc, alloc + SgAliasSymbol::pool_size);
  180085             : #endif
  180086             : 
  180087             : #if ROSE_ALLOC_MEMSET == 1
  180088             : #elif ROSE_ALLOC_MEMSET == 2
  180089             :         memset(alloc, 0x00, SgAliasSymbol::pool_size * sizeof(SgAliasSymbol));
  180090             : #elif ROSE_ALLOC_MEMSET == 3
  180091             :         memset(alloc, 0xAA, SgAliasSymbol::pool_size * sizeof(SgAliasSymbol));
  180092             : #endif
  180093     1434000 :         for (unsigned i=0; i < SgAliasSymbol::pool_size-1; i++) {
  180094     1433280 :           alloc[i].p_freepointer = &(alloc[i+1]);
  180095             :         }
  180096         717 :         alloc[SgAliasSymbol::pool_size-1].p_freepointer = nullptr;
  180097             : 
  180098         717 :         SgAliasSymbol::pools.push_back ( (unsigned char *) alloc );
  180099         717 :         SgNode::all_pools.push_back (std::tuple<unsigned char *, unsigned, VariantT>( (unsigned char *) alloc, SgAliasSymbol::pool_size * sizeof(SgAliasSymbol), V_SgAliasSymbol ) );
  180100         717 :         SgAliasSymbol::next_node = alloc;
  180101             :     }
  180102      982960 :     ROSE_ASSERT(SgAliasSymbol::next_node != nullptr);
  180103             : 
  180104      982960 :     SgAliasSymbol * object = SgAliasSymbol::next_node;
  180105      982960 :     SgAliasSymbol::next_node = (SgAliasSymbol*)(object->p_freepointer);
  180106             : 
  180107             : #if ROSE_ALLOC_TRACE == 2
  180108             :     printf("SgAliasSymbol::new[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgAliasSymbol::next_node);
  180109             : #endif
  180110             : 
  180111      982960 :     SgNode * fp = object->p_freepointer;
  180112             : #if ROSE_ALLOC_MEMSET == 1
  180113             : #elif ROSE_ALLOC_MEMSET == 2
  180114             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgAliasSymbol) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  180115             : #elif ROSE_ALLOC_MEMSET == 3
  180116             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xBB, sizeof(SgAliasSymbol) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  180117             : #endif
  180118      982960 :     object->p_freepointer = fp;
  180119             : 
  180120             : #if ROSE_ALLOC_TRACE == 2
  180121             : //    printf("SgAliasSymbol::new[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgAliasSymbol::next_node);
  180122             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  180123             :     Rose::MemPool::snapshot(oss.str());
  180124             :     alloc_trace_cnt++;
  180125             : #endif
  180126             : 
  180127      982960 :     object->p_freepointer = AST_FileIO::IS_VALID_POINTER();
  180128             : 
  180129      982960 :     ALLOC_MUTEX(SgAliasSymbol, unlock);
  180130             : 
  180131             :     return object;
  180132             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  180133             : }
  180134             : 
  180135             : 
  180136             : 
  180137             : /*! \brief Delete operator for SgAliasSymbol.
  180138             : 
  180139             :    This delete operator implements deallocation using memory pools to 
  180140             :    provide most efficent use of the heap within construction of large ASTs.
  180141             : 
  180142             : \internal The new and delete operators use the lower level C malloc/free
  180143             :    function calls for performance and to make sure that mixing of malloc/free
  180144             :    and new/delete by the used can be caught more readily.  This may change
  180145             :    in the future.  ROSE_MALLOC macro is used to permit memory allocation to
  180146             :    be alligned on page boundaries.  ROSE_FREE is whatever it takes to 
  180147             :    deallocate memory allocated using ROSE_MALLOC.
  180148             : */
  180149       34691 : void SgAliasSymbol::operator delete(void *Pointer, size_t Size)
  180150             : {
  180151             :     /* Entire function is protected by a mutex. To prevent deadlock, be sure to unlock this mutex before returning
  180152             :      * or throwing an exception. */
  180153       34691 :     ALLOC_MUTEX(SgAliasSymbol, lock);
  180154             : 
  180155             : #if USE_CPP_NEW_DELETE_OPERATORS
  180156             :     ROSE_FREE(Pointer);
  180157             : #else
  180158             : #if ROSE_PEDANTIC_ALLOC
  180159             :     ROSE_ASSERT(Size == sizeof(SgAliasSymbol));
  180160             : #else
  180161       34691 :     if (Size != sizeof(SgAliasSymbol)) {
  180162           0 :       ROSE_FREE(Pointer);
  180163           0 :       ALLOC_MUTEX(SgAliasSymbol, unlock);
  180164             :       return;
  180165             :     }
  180166             : #endif
  180167             : 
  180168       34691 :     SgAliasSymbol * object = (SgAliasSymbol*) Pointer;
  180169       34691 :     ROSE_ASSERT(object != nullptr);
  180170             : 
  180171             : #if ROSE_ALLOC_TRACE == 2
  180172             : //  printf("SgAliasSymbol::delete[%zi] (IN)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgAliasSymbol::next_node);
  180173             :     printf("SgAliasSymbol::delete[%zi] %p %p %p %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgAliasSymbol::next_node);
  180174             : #endif
  180175             : 
  180176             : #if ROSE_PEDANTIC_ALLOC
  180177             :     ROSE_ASSERT(object->p_freepointer == AST_FileIO::IS_VALID_POINTER());
  180178             : #endif
  180179             : 
  180180             : #if ROSE_ALLOC_MEMSET == 1
  180181             : #elif ROSE_ALLOC_MEMSET == 2
  180182             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0x00, sizeof(SgAliasSymbol) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  180183             : #elif ROSE_ALLOC_MEMSET == 3
  180184             :     memset(((char*)object) + ROSE_ALLOC_MEMSET_OFFSET, 0xDD, sizeof(SgAliasSymbol) - ROSE_ALLOC_MEMSET_OFFSET * sizeof(char*));
  180185             : #endif
  180186             : 
  180187             : // Liao, 8/11/2014, to support IR mapping, we need unique IDs for AST nodes.
  180188             : // We provide a mode in which memory space will not be reused later so we can easily generate unique IDs based on memory addresses.
  180189             : #ifdef ROSE_USE_MEMORY_POOL_NO_REUSE
  180190             :     object->p_freepointer = nullptr;   // clear IS_VALID_POINTER flag, but not putting it back to the memory pool.
  180191             : #else
  180192       34691 :     object->p_freepointer = SgAliasSymbol::next_node;
  180193       34691 :     SgAliasSymbol::next_node = object;
  180194             : #endif
  180195             : 
  180196             : #if ROSE_ALLOC_TRACE == 2
  180197             : //  printf("SgAliasSymbol::delete[%zi] (OUT)\n  object = %p\n    ->freepointer = %p\n    ->parent = %p\n  current_link = %p\n", alloc_trace_cnt, object, object->p_freepointer, object->p_parent, SgAliasSymbol::next_node);
  180198             :     std::ostringstream oss; oss << "mempool-" << alloc_trace_cnt << ".csv";
  180199             :     Rose::MemPool::snapshot(oss.str());
  180200             :     alloc_trace_cnt++;
  180201             : #endif
  180202             : 
  180203             : #endif /* USE_CPP_NEW_DELETE_OPERATORS */
  180204             : 
  180205       34691 :     ALLOC_MUTEX(SgAliasSymbol, unlock);
  180206             : }
  180207             : 
  180208             : // DQ (11/27/2009): I have moved this member function definition to outside of the
  180209             : // class declaration to make Cxx_Grammar.h smaller, easier, and faster to parse.
  180210             : // This is part of work to reduce the size of the Cxx_Grammar.h file for MSVS. 
  180211             : // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
  180212             : // Also, note comment below from Robb (copied from the Common.code file).
  180213             : /* RPM (2009-06-03): Apparently this must all be on one line for configuration "--with-javaport"; reverting r5427 */
  180214             : //
  180215             : // Matzke (2018-02-16): We don't need to provide both operator delete(void*) and operator delete(void*,size_t) because the C++
  180216             : // runtime calls exactly one of them (whichever is defined). Futhermore, the Boost serialization library assumes that classes
  180217             : // don't provide both versions at once (doing so causes compile errors in boost header files that try to invoke the
  180218             : // destructor).  Therefore, I'm commenting out operator delete(void*). See [http://en.cppreference.com/w/cpp/language/delete].
  180219             : #if 0
  180220             : void SgAliasSymbol::operator delete(void* pointer) { SgAliasSymbol::operator delete (pointer, sizeof(SgAliasSymbol)); };
  180221             : #endif
  180222             : 

Generated by: LCOV version 1.14